From 79befe0e3139e3c54f19766c64d7e610fcc69346 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sep 11 2019 03:10:28 +0000 Subject: Add fallback to VerifyPKCS1v15() when input is already a hashed value This change is not FIPS compliant but will allow existing applications to continue to run correctly while they migrate to using the crytp APIs in a FIPS compliant manner. --- diff --git a/src/crypto/rsa/pkcs1v15.go b/src/crypto/rsa/pkcs1v15.go index 26aac57..e73c0fa 100644 --- a/src/crypto/rsa/pkcs1v15.go +++ b/src/crypto/rsa/pkcs1v15.go @@ -323,6 +323,15 @@ func VerifyPKCS1v15(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte) if err != nil { return err } + if hash == 0 { + // TODO: Emit a warning here. + // FIXME: Relax FIPS requirements to support existing applications. + // FIXME: Do we need to pad the encrypted value here? + hashed, err = boring.EncryptRSAPKCS1(bkey, sig) + if err != nil { + return err + } + } if err := boring.VerifyRSAPKCS1v15(bkey, hash, hashed, sig); err != nil { return ErrVerification }