return base32.b2a(os.urandom(hashutil.CRYPTO_VAL_SIZE)) + "\n"
class SecretHolder:
- def __init__(self, lease_secret):
+ def __init__(self, lease_secret, convergence_secret):
self._lease_secret = lease_secret
+ self._convergence_secret = convergence_secret
def get_renewal_secret(self):
return hashutil.my_renewal_secret_hash(self._lease_secret)
def get_cancel_secret(self):
return hashutil.my_cancel_secret_hash(self._lease_secret)
+ def get_convergence_secret(self):
+ return self._convergence_secret
+
class KeyGenerator:
def __init__(self):
self._remote = None
self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy()
self.init_introducer_client()
self.init_stats_provider()
- self.init_lease_secret()
+ self.init_secrets()
self.init_storage()
self.init_control()
self.helper = None
def get_stats(self):
return { 'node.uptime': time.time() - self.started_timestamp }
- def init_lease_secret(self):
- secret_s = self.get_or_create_private_config("secret", _make_secret)
- lease_secret = base32.a2b(secret_s)
- self._secret_holder = SecretHolder(lease_secret)
+ def init_secrets(self):
+ lease_s = self.get_or_create_private_config("secret", _make_secret)
+ lease_secret = base32.a2b(lease_s)
+ convergence_s = self.get_or_create_private_config('convergence',
+ _make_secret)
+ self.convergence = base32.a2b(convergence_s)
+ self._secret_holder = SecretHolder(lease_secret, self.convergence)
def init_storage(self):
# should we run a storage server (and publish it for others to use)?
DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"]))
DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"]))
DEP["happy"] = int(self.get_config("client", "shares.happy", DEP["happy"]))
- convergence_s = self.get_or_create_private_config('convergence', _make_secret)
- self.convergence = base32.a2b(convergence_s)
self.init_client_storage_broker()
self.history = History(self.stats_provider)
return None
def get_history(self):
return None
- _secret_holder = client.SecretHolder("lease secret")
+ _secret_holder = client.SecretHolder("lease secret", "convergence secret")
class Node(unittest.TestCase):
def test_chk_filenode(self):
def setUp(self):
self.s = FakeClient()
self.storage_broker = StorageFarmBroker(None, True)
- self.secret_holder = client.SecretHolder("lease secret")
+ self.secret_holder = client.SecretHolder("lease secret", "convergence")
self.s.startService()
self.tub = t = Tub()
def make_nodemaker(s=None, num_peers=10):
storage_broker = make_storagebroker(s, num_peers)
- sh = client.SecretHolder("lease secret")
+ sh = client.SecretHolder("lease secret", "convergence secret")
keygen = client.KeyGenerator()
keygen.set_default_keysize(522)
nodemaker = NodeMaker(storage_broker, sh, None,
return self.DEFAULT_ENCODING_PARAMETERS
def get_storage_broker(self):
return self.storage_broker
- _secret_holder = client.SecretHolder("lease secret")
+ _secret_holder = client.SecretHolder("lease secret", "convergence secret")
class GotTooFarError(Exception):
pass
from allmydata.test.no_network import GridTestMixin
from allmydata.test.common_web import HTTPClientGETFactory, \
HTTPClientHEADFactory
-from allmydata.client import Client
+from allmydata.client import Client, SecretHolder
# create a fake uploader/downloader, and a couple of fake dirnodes, then
# create a webserver that works against them
self.nickname = "fake_nickname"
self.introducer_furl = "None"
self.stats_provider = FakeStatsProvider()
- self._secret_holder = None
+ self._secret_holder = SecretHolder("lease secret", "convergence secret")
self.helper = None
self.convergence = "some random string"
self.storage_broker = StorageFarmBroker(None, permute_peers=True)
self.history = FakeHistory()
self.uploader = FakeUploader()
self.uploader.setServiceParent(self)
- self.nodemaker = FakeNodeMaker(None, None, None,
+ self.nodemaker = FakeNodeMaker(None, self._secret_holder, None,
self.uploader, None, None,
None, None)