mutable: wire in RSA for real, using pycryptopp
This commit is contained in:
parent
30e7ca06f5
commit
c783128012
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue