Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 committed Feb 15, 2024
1 parent c951136 commit 19ff5e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/jose/jwk/jwksupport/jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func JWKFromKey(opaqueKey interface{}) (*jwk.JWK, error) {
// PubKeyBytesToKey creates an opaque key struct from the given public key bytes.
// It's e.g. *ecdsa.PublicKey, *ecdsa.PrivateKey, ed25519.VerificationMethod, *bbs12381g2pub.PrivateKey or
// *bbs12381g2pub.PublicKey.
func PubKeyBytesToKey(bytes []byte, keyType kms.KeyType) (interface{}, error) { // nolint:gocyclo
func PubKeyBytesToKey(bytes []byte, keyType kms.KeyType) (interface{}, error) { // nolint:gocyclo,funlen
switch keyType {
case kms.ED25519Type:
return ed25519.PublicKey(bytes), nil
Expand Down Expand Up @@ -105,6 +105,7 @@ func PubKeyBytesToKey(bytes []byte, keyType kms.KeyType) (interface{}, error) {
if err != nil {
return nil, errors.New("rsa: invalid public key")
}

return pubKeyRsa, nil
case kms.ECDSASecp256k1TypeDER:
return parseSecp256k1DER(bytes)
Expand Down
6 changes: 6 additions & 0 deletions doc/jose/jwk/jwksupport/jwk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,12 @@ func TestPublicKeyFromJWK(t *testing.T) {
})
}

func TestRSAKeyFailParse(t *testing.T) {
resultJWK, err := PubKeyBytesToJWK([]byte{0x1}, kms.RSARS256)
require.ErrorContains(t, err, "rsa: invalid public key")
require.Nil(t, resultJWK)
}

func TestRSAKey(t *testing.T) {
key, err := rsa.GenerateKey(rand.Reader, 2048)
require.NoError(t, err)
Expand Down

0 comments on commit 19ff5e2

Please sign in to comment.