switch ipfs key rotate flags to use the same ones as ipfs key gen
Adin Schmahmann committed
Aug 17, 2020 at 07:14 UTC
eb664613336a8b95462b05770c16a990c4c111dd
2 files changed
+6
-8
core/commands/keystore.go
+4
-6
@@ -69,8 +69,6 @@ type KeyRenameOutput struct {
69
70
const (
71
keyStoreAlgorithmDefault = options.RSAKey
72
- keyStoreAlgorithmOptionName = "algorithm"
73
- keyStoreBitsOptionName = "bits"
72
keyStoreTypeOptionName = "type"
73
keyStoreSizeOptionName = "size"
74
keyFormatOptionName = "format"
@@ -437,8 +435,8 @@ environment variable:
435
Arguments: []cmds.Argument{},
436
Options: []cmds.Option{
437
cmds.StringOption(oldKeyOptionName, "o", "Keystore name for the old/rotated-out key."),
440
- cmds.StringOption(keyStoreAlgorithmOptionName, "a", "Cryptographic algorithm to use for key generation.").WithDefault(keyStoreAlgorithmDefault),
441
- cmds.IntOption(keyStoreBitsOptionName, "b", "Number of bits to use in the generated RSA private key."),
438
+ cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault),
439
+ cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
440
},
441
NoRemote: true,
442
PreRun: func(req *cmds.Request, env cmds.Environment) error {
@@ -459,8 +457,8 @@ environment variable:
457
},
458
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
459
cctx := env.(*oldcmds.Context)
462
- nBitsForKeypair, nBitsGiven := req.Options[keyStoreBitsOptionName].(int)
463
- algorithm, _ := req.Options[keyStoreAlgorithmOptionName].(string)
460
+ nBitsForKeypair, nBitsGiven := req.Options[keyStoreSizeOptionName].(int)
461
+ algorithm, _ := req.Options[keyStoreTypeOptionName].(string)
462
oldKey, ok := req.Options[oldKeyOptionName].(string)
463
if !ok {
464
return fmt.Errorf("keystore name for backing up old key must be provided")
test/sharness/t0027-rotate.sh
+2
-2
@@ -35,10 +35,10 @@ test_rotate() {
35
test_expect_success "rotating keys" '
36
case $TO_ALG in
37
rsa)
38
- ipfs key rotate -a=rsa -b=2048 --oldkey=oldkey
38
+ ipfs key rotate -t=rsa -s=2048 --oldkey=oldkey
39
;;
40
ed25519)
41
- ipfs key rotate -a=ed25519 --oldkey=oldkey
41
+ ipfs key rotate -t=ed25519 --oldkey=oldkey
42
;;
43
*)
44
ipfs key rotate --oldkey=oldkey