Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Dec 17, 2024
1 parent 6af264f commit 007e0cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ func TestRSASignVerifyPKCS1v15(t *testing.T) {
hashed[0] = 0x30
signed, err := openssl.SignRSAPKCS1v15(priv, hash, hashed)
if err != nil {
if strings.Contains(err.Error(), "check_padding_md:invalid digest") {
t.Skip("skipping test because hash is not supported by PKCS1v15")
if strings.Contains(err.Error(), "invalid digest") || strings.Contains(err.Error(), "digest not allowed") {
// Can happen if the hash is supported by EVP_MD_CTX but not by EVP_PKEY_CTX.
// There is nothing we can do about it.
t.Skip("skipping test because hash is not supported")
}
t.Fatal(err)
}
Expand Down Expand Up @@ -305,8 +307,10 @@ func TestRSASignVerifyRSAPSS(t *testing.T) {
hashed[0] = 0x30
signed, err := openssl.SignRSAPSS(priv, hash, hashed, rsa.PSSSaltLengthEqualsHash)
if err != nil {
if strings.Contains(err.Error(), "check_padding_md:invalid digest") {
t.Skip("skipping test because hash is not supported by PKCS1v15")
if strings.Contains(err.Error(), "invalid digest") || strings.Contains(err.Error(), "digest not allowed") {
// Can happen if the hash is supported by EVP_MD_CTX but not by EVP_PKEY_CTX.
// There is nothing we can do about it.
t.Skip("skipping test because hash is not supported")
}
t.Fatal(err)
}
Expand Down

0 comments on commit 007e0cc

Please sign in to comment.