from allmydata.Crypto.Cipher import AES
from allmydata import hashtree, codec
from allmydata.encode import NotEnoughPeersError
+from pycryptopp.publickey import rsa
class NeedMoreDataError(Exception):
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)
implements(IMutableFileNode)
publish_class = Publish
retrieve_class = Retrieve
+ SIGNATURE_KEY_SIZE = 2048
def __init__(self, client):
self._client = client
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)
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
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)