-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 parsing for NSS-wrapped Ed25519 keys #15742
Conversation
NSS wraps Ed25519 using the PKCS#8 standard structure. The Go standard library as of Go 1.18.x doesn't support parsing this key type with the OID used by NSS; it requires the 1.3.101.112/RFC 8410 format, rather than the RFC 5915-esque structure supported here. Co-authored-by: Rachel Culpepper <[email protected]> Signed-off-by: Alexander Scheel <[email protected]>
Co-authored-by: Rachel Culpepper <[email protected]> Signed-off-by: Alexander Scheel <[email protected]>
Co-authored-by: Rachel Culpepper <[email protected]> Signed-off-by: Alexander Scheel <[email protected]>
@@ -1385,7 +1385,17 @@ func (p *Policy) Import(ctx context.Context, storage logical.Storage, key []byte | |||
} else { | |||
parsedPrivateKey, err := x509.ParsePKCS8PrivateKey(key) | |||
if err != nil { | |||
return fmt.Errorf("error parsing asymmetric key: %s", err) | |||
if strings.Contains(err.Error(), "unknown elliptic curve") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little brittle against possible future changes from an error message?
Are there any reasons we don't just try to call ParsePKCS8Ed25519PrivateKey
on any err?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have a bad ASN.1 blob or something else, that'd trigger a non-unknown curve error. If that's the case, the Ed25519 parsing won't do anything, but give a weird, unrelated error message (if you say, had a corrupted RSA key, the Ed25519 would be weird).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I suppose the unit test will catch the change if they ever do update the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this seems good to me, but another pair of eyes is highly recommended before merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Thanks all! Merging... |
NSS wraps Ed25519 using the PKCS#8 standard structure. The Go standard
library as of Go 1.18.x doesn't support parsing this key type with the
OID used by NSS; it requires the 1.3.101.112/RFC 8410 format, rather
than the RFC 5915-esque structure supported here.