From: Brian Warner Date: Thu, 8 Nov 2007 00:51:35 +0000 (-0700) Subject: mutable: wire in RSA for real, using pycryptopp X-Git-Tag: allmydata-tahoe-0.7.0~250 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/%22doc.html?a=commitdiff_plain;h=c78312801284b9867cdecb5774394de1deb5c7ed;p=tahoe-lafs%2Ftahoe-lafs.git mutable: wire in RSA for real, using pycryptopp --- diff --git a/src/allmydata/mutable.py b/src/allmydata/mutable.py index 909049bb..aa44dcc6 100644 --- a/src/allmydata/mutable.py +++ b/src/allmydata/mutable.py @@ -11,6 +11,7 @@ from allmydata.uri import WriteableSSKFileURI from allmydata.Crypto.Cipher import AES from allmydata import hashtree, codec from allmydata.encode import NotEnoughPeersError +from pycryptopp.publickey import rsa class NeedMoreDataError(Exception): @@ -313,10 +314,8 @@ class Retrieve: return d def _deserialize_pubkey(self, pubkey_s): - # TODO - from allmydata.test.test_mutable import FakePubKey - return FakePubKey(0) - return None + verifier = rsa.create_verifying_key_from_string(pubkey_s) + return verifier def _got_results(self, datavs, peerid, readsize): self._queries_outstanding.discard(peerid) @@ -957,6 +956,7 @@ class MutableFileNode: implements(IMutableFileNode) publish_class = Publish retrieve_class = Retrieve + SIGNATURE_KEY_SIZE = 2048 def __init__(self, client): self._client = client @@ -1010,13 +1010,10 @@ class MutableFileNode: return d def _generate_pubprivkeys(self): - # TODO: wire these up to pycryptopp - privkey = "very private" - pubkey = "public" - from allmydata.test.test_mutable import FakePrivKey, FakePubKey - pubkey = FakePubKey(0) - privkey = FakePrivKey(0) - return pubkey, privkey + # RSA key generation for a 2048 bit key takes between 0.8 and 3.2 secs + signer = rsa.generate(self.SIGNATURE_KEY_SIZE) + verifier = signer.get_verifying_key() + return verifier, signer def _publish(self, initial_contents): p = self.publish_class(self) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 6cf99eaf..07ac4ee2 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1,6 +1,6 @@ from base64 import b32encode -import os, sys, time +import os, sys, time, re from cStringIO import StringIO from twisted.trial import unittest from twisted.internet import defer, reactor @@ -294,8 +294,16 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase): peerid = idlib.nodeid_b2a(self.clients[client_num].nodeid) self.failUnless(" WE for nodeid: %s\n" % peerid in output) self.failUnless(" num_extra_leases: 0\n" in output) - self.failUnless(" container_size: 382\n" in output) - self.failUnless(" data_length: 382\n" in output) + # the pubkey size can vary by a byte, so the container might + # be a bit larger on some runs. + m = re.search(r'^ container_size: (\d+)$', output, re.M) + self.failUnless(m) + container_size = int(m.group(1)) + self.failUnless(2046 <= container_size <= 2049) + m = re.search(r'^ data_length: (\d+)$', output, re.M) + self.failUnless(m) + data_length = int(m.group(1)) + self.failUnless(2046 <= data_length <= 2049) self.failUnless(" secrets are for nodeid: %s\n" % peerid in output) self.failUnless(" SDMF contents:\n" in output)