Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for P-384, also known as secp384r1 #35

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Supported password/key types:
* `seed` - generates a seed file, which can be used with `-s` option later
* `raw` - generates 32 random bytes (can be used as a symmetric key)
* `ec256` - generates ECC P-256 private key
* `ec384` - generates ECC P-384 private key
* `ec521` - generates ECC P-521 private key
* `rsa2048` - generates 2048-bit RSA private key
* `rsa4096` - generates 4096-bit RSA private key
Expand Down
3 changes: 2 additions & 1 deletion cmd/gokey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
func init() {
flag.StringVar(&pass, "p", "", "master password (if not specified, will be asked interactively)")
flag.StringVar(&passFile, "P", "", "master password file (if not specified, will be asked interactively)")
flag.StringVar(&keyType, "t", "pass", "output type (can be pass, seed, raw, ec256, ec521, rsa2048, rsa4096, x25519, ed25519)")
flag.StringVar(&keyType, "t", "pass", "output type (can be pass, seed, raw, ec256, ec384, ec521, rsa2048, rsa4096, x25519, ed25519)")
flag.StringVar(&seedPath, "s", "", "path to master seed file (optional)")
flag.IntVar(&seedSkipCount, "skip", 0, "number of bytes to skip from master seed file (default 0)")
flag.StringVar(&realm, "r", "", "password/key realm (most probably purpose of the password/key)")
Expand All @@ -35,6 +35,7 @@ func init() {

var keyTypes = map[string]gokey.KeyType{
"ec256": gokey.EC256,
"ec384": gokey.EC384,
"ec521": gokey.EC521,
"rsa2048": gokey.RSA2048,
"rsa4096": gokey.RSA4096,
Expand Down
1 change: 1 addition & 0 deletions gokey.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ operation* below)
* *seed* - generates a seed file, which can be used with **-s** option later
* *raw* - generates 32 random bytes (can be used as a symmetric key)
* *ec256* - generates ECC P-256 private key
* *ec384* - generates ECC P-384 private key
* *ec521* - generates ECC P-521 private key
* *rsa2048* - generates 2048-bit RSA private key
* *rsa4096* - generates 4096-bit RSA private key
Expand Down
1 change: 1 addition & 0 deletions gokey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func testGetKeyType(kt KeyType, t *testing.T) {

func TestGetKey(t *testing.T) {
testGetKeyType(EC256, t)
testGetKeyType(EC384, t)
testGetKeyType(EC521, t)
testGetKeyType(RSA2048, t)
testGetKeyType(RSA4096, t)
Expand Down
5 changes: 4 additions & 1 deletion keygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type KeyType int

const (
EC256 KeyType = iota
EC384
EC521
RSA2048
RSA4096
Expand Down Expand Up @@ -175,6 +176,8 @@ func (keygen *KeyGen) generateEc(kt KeyType) (crypto.PrivateKey, error) {
switch kt {
case EC256:
curve = elliptic.P256()
case EC384:
curve = elliptic.P384()
case EC521:
curve = elliptic.P521()
default:
Expand Down Expand Up @@ -206,7 +209,7 @@ func (keygen *KeyGen) generate25519(kt KeyType) (crypto.PrivateKey, error) {

func (keygen *KeyGen) GenerateKey(kt KeyType) (crypto.PrivateKey, error) {
switch kt {
case EC256, EC521:
case EC256, EC384, EC521:
return keygen.generateEc(kt)
case RSA2048, RSA4096:
return keygen.generateRsa(kt)
Expand Down
17 changes: 15 additions & 2 deletions keytype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.