-
Notifications
You must be signed in to change notification settings - Fork 3
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
Improve jwk file store to support different #426
Conversation
PR Verification Succeeded: Coverage >= |
hash = hashForEd25519(key.(ed25519.PublicKey)) | ||
case []byte: | ||
hash = hmac.New(sha256.New, key.([]byte)) | ||
hash.Write([]byte(name)) |
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.
Hash the key name using the key to get a unique value.
//best effort to generate a kid that is consistent across restarts | ||
var hash hash.Hash | ||
switch key.(type) { | ||
case *rsa.PrivateKey: |
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.
I ended up not using encryption to generate a unique value because some of the encryption algorithm is not deterministic.
// - CERTIFICATE | ||
// - * PRIVATE KEY | ||
// - PUBLIC KEY | ||
// - CERTIFICATE | ||
func LoadMultiBlockPem(path string, password string) ([]interface{}, error) { |
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.
"returns *pem.Block
as fallback" when non of above matches
@@ -128,7 +128,7 @@ func LoadMultiBlockPem(path string, password string) ([]interface{}, error) { | |||
case block.Type == "CERTIFICATE": | |||
item, e = parseX509Cert(block) | |||
default: | |||
continue | |||
item = block |
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.
I think maybe we need to try to decrypt it before returning
case *rsa.PublicKey: | ||
pubKey = cert.PublicKey.(*rsa.PublicKey) | ||
case *ecdsa.PublicKey: | ||
pubKey = cert.PublicKey.(*ecdsa.PublicKey) | ||
case ed25519.PublicKey: | ||
pubKey = cert.PublicKey.(ed25519.PublicKey) |
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.
Those cases my be unnecessary. crypto.PublicKey
is interface{}. There is a (currently unused) interface publicKey
in jwk.go
. This could be changed to
var ok bool
if pubKey, ok = cert.PublicKey.(publicKey); !ok {
return ...
}
Description
This PR is intended to address #420. The jwk file store implementation is extended to support ECDSA, ED25519 and HMAC
Type of Change
Checklist