From 91af588c9be3bcc230ce308087f2d5a5050d20f5 Mon Sep 17 00:00:00 2001 From: meejah Date: Thu, 7 May 2020 20:08:02 -0600 Subject: [PATCH] post-merge fixups (keyutil, preferred_peers) --- src/allmydata/client.py | 3 +-- src/allmydata/node.py | 2 +- src/allmydata/scripts/tahoe_grid_manager.py | 17 ++++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/allmydata/client.py b/src/allmydata/client.py index ced282900..24f217288 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -580,8 +580,7 @@ def create_storage_farm_broker(config, default_connection_handlers, foolscap_con tub_maker=tub_creator, node_config=config, storage_client_config=storage_client_config, - preferred_peers=preferred_peers, - grid_manager_keys=grid_manager_keys, + grid_manager_keys=grid_manager_keys, # XXX maybe roll into above storage_client_config? ) for ic in introducer_clients: sb.use_introducer(ic) diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 404f8a125..676975728 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -205,7 +205,7 @@ def config_from_string(basedir, portnumfile, config_str, _valid_config=None): # load configuration from in-memory string parser = ConfigParser.SafeConfigParser() parser.readfp(BytesIO(config_str)) - configutil.validate_config(fname, parser, _valid_config) + configutil.validate_config('', parser, _valid_config) def write_new_config(cfg): """ diff --git a/src/allmydata/scripts/tahoe_grid_manager.py b/src/allmydata/scripts/tahoe_grid_manager.py index b33552861..6c40f0814 100644 --- a/src/allmydata/scripts/tahoe_grid_manager.py +++ b/src/allmydata/scripts/tahoe_grid_manager.py @@ -13,7 +13,7 @@ from twisted.python import usage from twisted.python.filepath import FilePath from allmydata.util import fileutil from allmydata.util import base32 -from allmydata.util import keyutil +from allmydata.crypto import ed25519 from twisted.internet.defer import inlineCallbacks, returnValue @@ -50,7 +50,7 @@ class AddOptions(BaseOptions): self['name'] = unicode(args[0]) try: # WTF?! why does it want 'str' and not six.text_type? - self['storage_public_key'] = keyutil.parse_pubkey(args[1]) + self['storage_public_key'] = ed25519.verifying_key_from_string(args[1]) except Exception as e: raise usage.UsageError( "Invalid public_key argument: {}".format(e) @@ -132,8 +132,11 @@ def _create_gridmanager(): :return: an object providing the GridManager interface initialized with a new random keypair """ - private_key_bytes, public_key_bytes = keyutil.make_keypair() - return _GridManager(private_key_bytes, {}) + private_key, public_key = ed25519.create_signing_keypair() + return _GridManager( + ed25519.string_from_signing_key(private_key), + {}, + ) def _create(gridoptions, options): """ @@ -195,7 +198,7 @@ class _GridManager(object): private_key_bytes = config['private_key'].encode('ascii') try: - private_key, public_key_bytes = keyutil.parse_privkey(private_key_bytes) + private_key, public_key = ed25519.signing_keypair_from_string(private_key_bytes) except Exception as e: raise ValueError( "Invalid Grid Manager private_key: {}".format(e) @@ -209,7 +212,7 @@ class _GridManager(object): ) storage_servers[name] = _GridManagerStorageServer( name, - keyutil.parse_pubkey(srv_config['public_key'].encode('ascii')), + ed25519.verifying_key_from_string(srv_config['public_key'].encode('ascii')), None, ) @@ -225,7 +228,7 @@ class _GridManager(object): def __init__(self, private_key_bytes, storage_servers): self._storage_servers = dict() if storage_servers is None else storage_servers self._private_key_bytes = private_key_bytes - self._private_key, _ = keyutil.parse_privkey(self._private_key_bytes) + self._private_key, _ = ed25519.signing_keypair_from_string(self._private_key_bytes) self._version = 0 @property