move convergence secret into SecretHolder, next to lease secret

This commit is contained in:
Brian Warner 2009-11-17 17:54:44 -08:00
parent 5fe713fc52
commit d2426ea3bd
6 changed files with 20 additions and 15 deletions

View File

@ -38,8 +38,9 @@ def _make_secret():
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)
@ -47,6 +48,9 @@ class SecretHolder:
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
@ -108,7 +112,7 @@ class Client(node.Node, pollmixin.PollMixin):
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
@ -179,10 +183,13 @@ class Client(node.Node, pollmixin.PollMixin):
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)?
@ -255,8 +262,6 @@ class Client(node.Node, pollmixin.PollMixin):
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)

View File

@ -21,7 +21,7 @@ class FakeClient:
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):

View File

@ -90,7 +90,7 @@ class AssistedUpload(unittest.TestCase):
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()

View File

@ -196,7 +196,7 @@ def make_storagebroker(s=None, num_peers=10):
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,

View File

@ -187,7 +187,7 @@ class FakeClient:
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

View File

@ -25,7 +25,7 @@ import common_util as testutil
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
@ -93,7 +93,7 @@ class FakeClient(Client):
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)
@ -101,7 +101,7 @@ class FakeClient(Client):
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)