Skip to content

Commit

Permalink
fix: Remove assertion for private key decryption support during pkcs1…
Browse files Browse the repository at this point in the history
…1 init (#109)
  • Loading branch information
andyrzhao authored Oct 23, 2023
1 parent 5192b8e commit d928958
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/signer/linux/pkcs11/pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ func Cred(pkcs11Module string, slotUint32Str string, label string, userPin strin
if !ok {
return nil, errors.New("PrivateKey does not implement crypto.Signer")
}
kdecrypter, ok := privKey.(crypto.Decrypter)
if !ok {
return nil, errors.New("PrivateKey does not implement crypto.Decrypter")
}
kdecrypter, _ := privKey.(crypto.Decrypter)
defaultHash := crypto.SHA256
return &Key{
slot: kslot,
Expand Down Expand Up @@ -188,6 +185,9 @@ func (k *Key) Decrypt(msg []byte, opts crypto.DecrypterOpts) ([]byte, error) {
} else {
return nil, fmt.Errorf("Unsupported DecrypterOpts: %v", opts)
}
if k.decrypter == nil {
return nil, fmt.Errorf("decrypt error: Decrypter is nil")
}
publicKey := k.Public()
_, ok := publicKey.(*rsa.PublicKey)
if ok {
Expand Down

0 comments on commit d928958

Please sign in to comment.