diff --git a/crypto.py b/crypto.py index 5cd2e70f..747174c2 100644 --- a/crypto.py +++ b/crypto.py @@ -104,29 +104,17 @@ def security_levels(self): return _CURVES.keys() @attach_runtime_statistics(u"{0.__class__.__name__}.{function_name}") - def generate_key(self, security_level): + def generate_key(self, security_level=u"curve25519"): """ Generate a new Elliptic Curve object with a new public / private key pair. - Security can be u'low', u'medium', or u'high' depending on how secure you need your Elliptic - Curve to be. Currently these values translate into: - - very-low: NID_sect163k1 ~42 byte signatures - - low: NID_sect233k1 ~60 byte signatures - - medium: NID_sect409k1 ~104 byte signatures - - high: NID_sect571r1 ~144 byte signatures - - Besides these predefined curves, all other curves provided by M2Crypto are also available. For - a full list of available curves, see ec_get_curves(). - - @param security_level: Level of security {u'very-low', u'low', u'medium', or u'high'}. + @param security_level: Level of security, currently only u"curve25519". @type security_level: unicode """ assert isinstance(security_level, unicode) assert security_level in _CURVES curve = _CURVES[security_level] - if curve[1] == "M2Crypto": - return M2CryptoSK(curve[0]) if curve[1] == "libnacl": return LibNaCLSK() diff --git a/tests/debugcommunity/node.py b/tests/debugcommunity/node.py index 03702af2..d949a45c 100644 --- a/tests/debugcommunity/node.py +++ b/tests/debugcommunity/node.py @@ -30,7 +30,7 @@ class DebugNode(object): node.init_my_member() """ - def __init__(self, testclass, dispersy, communityclass=DebugCommunity, c_master_member=None, curve=u"low"): + def __init__(self, testclass, dispersy, communityclass=DebugCommunity, c_master_member=None, curve=u"curve25519"): super(DebugNode, self).__init__() self._logger = logging.getLogger(self.__class__.__name__) diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index 99fbc5ae..10ff9d3e 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -363,7 +363,7 @@ def summary(self): candidates = [Candidate(("130.161.211.245", 6429), False)] communities = [PingCommunity.create_community(self._dispersy, self._my_member, candidates) for _ in xrange(COMMUNITIES)] - members = [self._dispersy.get_new_member(u"low") for _ in xrange(MEMBERS)] + members = [self._dispersy.get_new_member(u"curve25519") for _ in xrange(MEMBERS)] for community in communities: for member in members: diff --git a/tests/test_candidates.py b/tests/test_candidates.py index ce179b2c..0da8ab13 100644 --- a/tests/test_candidates.py +++ b/tests/test_candidates.py @@ -363,7 +363,7 @@ def set_timestamps(self, candidates, all_flags): def get_member(): if not member[0]: - member[0] = self._dispersy.get_new_member(u"very-low") + member[0] = self._dispersy.get_new_member(u"curve25519") return member[0] if "w" in flags: @@ -557,7 +557,7 @@ def test_get_introduce_candidate(self, community_create_method=DebugCommunity.cr now = time() got = [] for candidate in candidates: - candidate.associate(self._dispersy.get_new_member(u"very-low")) + candidate.associate(self._dispersy.get_new_member(u"curve25519")) candidate.stumble(now) introduce = community.dispersy_get_introduce_candidate(candidate) got.append(introduce.sock_addr if introduce else None) diff --git a/tests/test_member.py b/tests/test_member.py index 37681198..b4f3f41f 100644 --- a/tests/test_member.py +++ b/tests/test_member.py @@ -5,7 +5,6 @@ class TestMember(DispersyTestFunc): def test_verify(self): - self._test_verify(u"medium") self._test_verify(u"curve25519") @call_on_reactor_thread @@ -70,7 +69,6 @@ def _test_verify(self, curve): def test_sign(self): - self._test_sign(u"medium") self._test_sign(u"curve25519") @call_on_reactor_thread diff --git a/tool/createkey.py b/tool/createkey.py index 3fbea814..651bfda1 100755 --- a/tool/createkey.py +++ b/tool/createkey.py @@ -3,32 +3,24 @@ """ Create one or more Elliptic Curves. -Typically the following curves are used: -- very-low: NID_sect163k1 ~42 byte signatures -- low: NID_sect233k1 ~60 byte signatures -- medium: NID_sect409k1 ~104 byte signatures -- high: NID_sect571r1 ~144 byte signatures +Typically the Curve25519 is used. """ import argparse import time from hashlib import sha1 -from M2Crypto import EC # From: http://docs.python.org/2/tutorial/modules.html#intra-package-references # Note that both explicit and implicit relative imports are based on the name of the current # module. Since the name of the main module is always "__main__", modules intended for use as the # main module of a Python application should always use absolute imports. from dispersy.crypto import ECCrypto, _CURVES + def ec_name(eccrypto, curve): assert isinstance(curve, unicode) curve_id = _CURVES[curve] - for name in dir(EC): - value = getattr(EC, name) - if isinstance(value, int) and value == curve_id: - return name def create_key(eccrypto, curves): for index, curve in enumerate(curves): diff --git a/twisted/plugins/tracker_plugin.py b/twisted/plugins/tracker_plugin.py index 3488e54a..e4b436c6 100644 --- a/twisted/plugins/tracker_plugin.py +++ b/twisted/plugins/tracker_plugin.py @@ -93,7 +93,7 @@ def start(self): def _create_my_member(self): # generate a new my-member - ec = self.crypto.generate_key(u"very-low") + ec = self.crypto.generate_key() self._my_member = self.get_member(private_key=self.crypto.key_to_bin(ec)) @property