From: Brian Warner Date: Tue, 7 Oct 2008 00:23:20 +0000 (-0700) Subject: CLI: remove 'tahoe admin generate-keypair', since the pycryptopp ecdsa API is about... X-Git-Url: https://git.rkrishnan.org/pf/content/simplejson/provisioning?a=commitdiff_plain;h=dbc2337639949062f89df4503c30e4f5826336e2;p=tahoe-lafs%2Ftahoe-lafs.git CLI: remove 'tahoe admin generate-keypair', since the pycryptopp ecdsa API is about to change incompatibly. We'll undo this once pycryptopp is updated --- diff --git a/src/allmydata/scripts/admin.py b/src/allmydata/scripts/admin.py deleted file mode 100644 index b05d6a43..00000000 --- a/src/allmydata/scripts/admin.py +++ /dev/null @@ -1,72 +0,0 @@ - -from twisted.python import usage - -class GenerateKeypairOptions(usage.Options): - def getSynopsis(self): - return "Usage: tahoe admin generate-keypair" - - def getUsage(self, width=None): - t = usage.Options.getUsage(self, width) - t += """ -Generate an ECDSA192 public/private keypair, dumped to stdout as two lines of -base32-encoded text. - -""" - return t - -def make_keypair(): - from pycryptopp.publickey import ecdsa - from allmydata.util import base32 - privkey = ecdsa.generate(192) - privkey_vs = "priv-v0-%s" % base32.b2a(privkey.serialize()) - pubkey = privkey.get_verifying_key() - pubkey_vs = "pub-v0-%s" % base32.b2a(pubkey.serialize()) - return privkey_vs, pubkey_vs - -def print_keypair(options): - out = options.stdout - privkey_vs, pubkey_vs = make_keypair() - print >>out, "private:", privkey_vs - print >>out, "public:", pubkey_vs - -class AdminCommand(usage.Options): - subCommands = [ - ["generate-keypair", None, GenerateKeypairOptions, - "Generate a public/private keypair, write to stdout."], - ] - def postOptions(self): - if not hasattr(self, 'subOptions'): - raise usage.UsageError("must specify a subcommand") - def getSynopsis(self): - return "Usage: tahoe admin SUBCOMMAND" - def getUsage(self, width=None): - #t = usage.Options.getUsage(self, width) - t = """ -Subcommands: - tahoe admin generate-keypair Generate a public/private keypair, - write to stdout. - -Please run e.g. 'tahoe admin generate-keypair --help' for more details on -each subcommand. -""" - return t - -subDispatch = { - "generate-keypair": print_keypair, - } - -def do_admin(options): - so = options.subOptions - so.stdout = options.stdout - so.stderr = options.stderr - f = subDispatch[options.subCommand] - return f(so) - - -subCommands = [ - ["admin", None, AdminCommand, "admin subcommands: use 'tahoe admin' for a list"], - ] - -dispatch = { - "admin": do_admin, - } diff --git a/src/allmydata/scripts/runner.py b/src/allmydata/scripts/runner.py index 39a849e6..01aed0eb 100644 --- a/src/allmydata/scripts/runner.py +++ b/src/allmydata/scripts/runner.py @@ -4,13 +4,12 @@ from cStringIO import StringIO from twisted.python import usage from allmydata.scripts.common import BaseOptions -import debug, create_node, startstop_node, cli, keygen, admin +import debug, create_node, startstop_node, cli, keygen _general_commands = ( create_node.subCommands + keygen.subCommands + debug.subCommands + cli.subCommands - + admin.subCommands ) class Options(BaseOptions, usage.Options): @@ -70,8 +69,6 @@ def runner(argv, rc = startstop_node.dispatch[command](so, stdout, stderr) elif command in debug.dispatch: rc = debug.dispatch[command](so) - elif command in admin.dispatch: - rc = admin.dispatch[command](so) elif command in cli.dispatch: rc = cli.dispatch[command](so) elif command in keygen.dispatch: diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 9333a985..ae77544e 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -505,41 +505,3 @@ class Put(SystemTestMixin, CLITestMixin, unittest.TestCase): self.do_cli("get", "tahoe:uploaded.txt")) d.addCallback(lambda (out,err): self.failUnlessEqual(out, DATA2)) return d - -class Admin(unittest.TestCase): - def do_cli(self, *args, **kwargs): - argv = list(args) - stdin = kwargs.get("stdin", "") - stdout, stderr = StringIO(), StringIO() - d = threads.deferToThread(runner.runner, argv, run_by_human=False, - stdin=StringIO(stdin), - stdout=stdout, stderr=stderr) - def _done(res): - return stdout.getvalue(), stderr.getvalue() - d.addCallback(_done) - return d - - def test_generate_keypair(self): - import sys - if sys.platform == "darwin": - # pycryptopp-0.5.7's ECDSA is broken on OS-X, it raises a C++ - # exception, which halts the whole process. So skip this test. - raise unittest.SkipTest("pycryptopp-0.5.7's ECDSA raises a C++ exception on OS-X") - d = self.do_cli("admin", "generate-keypair") - def _done( (stdout, stderr) ): - lines = stdout.split("\n") - privkey_line = lines[0].strip() - pubkey_line = lines[1].strip() - sk_header = "private: priv-v0-" - vk_header = "public: pub-v0-" - self.failUnless(privkey_line.startswith(sk_header), privkey_line) - self.failUnless(pubkey_line.startswith(vk_header), pubkey_line) - privkey_b = base32.a2b(privkey_line[len(sk_header):]) - pubkey_b = base32.a2b(pubkey_line[len(vk_header):]) - sk = ecdsa.create_signing_key_from_string(privkey_b) - vk = ecdsa.create_verifying_key_from_string(pubkey_b) - self.failUnlessEqual(sk.get_verifying_key().serialize(), - vk.serialize()) - d.addCallback(_done) - return d -