Skip to content

Commit

Permalink
go-ipfs-config: Merge pull request ipfs#95 from ipfs/fix/key-init-mes…
Browse files Browse the repository at this point in the history
…sage

fix: include key size in key init method
  • Loading branch information
Stebalien committed May 22, 2020
2 parents 45f2784 + ba2e10a commit 435b942
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
var sk ci.PrivKey
var pk ci.PubKey

fmt.Fprintf(out, "generating %s keypair...", settings.Algorithm)
switch settings.Algorithm {
case "rsa":
if settings.Size == -1 {
settings.Size = options.DefaultRSALen
}

fmt.Fprintf(out, "generating %d-bit RSA keypair...", settings.Size)

priv, pub, err := ci.GenerateKeyPair(ci.RSA, settings.Size)
if err != nil {
return ident, err
Expand All @@ -199,6 +200,7 @@ func CreateIdentity(out io.Writer, opts []options.KeyGenerateOption) (Identity,
sk = priv
pk = pub
case "ed25519":
fmt.Fprintf(out, "generating ED25519 keypair...")
priv, pub, err := ci.GenerateEd25519Key(rand.Reader)
if err != nil {
return ident, err
Expand Down

0 comments on commit 435b942

Please sign in to comment.