Support for retrieving hash algorithm from RSA signature before/during verification

Atul Singh singh.atulks at
Mon Apr 24 07:46:20 UTC 2023

RSASSA-PKCS1-v1_5 signature scheme encodes the AlgorithmIdentifier of
Hash Function in the message data before passing it through the
encryption[1]. So, technically one doesn't need to know the Hash
Function beforehand for verification purposes -- it can be decoded
right out of the decrypted octets.

Does openssl provide a way to perform verification without the
application supplying the Hash Function for RSASSA-PKCS1-v1_5
signatures? I have played around with EVP_DigestVerifyInit and
friends, but it doesn't seem to be possible -- The Hash Function is
required at the init context stage itself and there doesn't seem to be
any way around it[2].

I also did not see anything obvious in rsa.h that could just return
the AlgorithmIdentifier that can be used for EVP_DigestVerifyInit

The reason I am asking this question is that IKEv2 leaves it to the
implementation to choose their Authentication method unannounced[3].
If an IKE peer chooses RSA Signature as their authentication method,
it can then go on to use any of the Hash Functions supported by RSA
(RFC5996 only recommends making SHA1 default). This is causing a lot
of incompatibility issues between vendors. Technically, one could try
all possible algorithms one by one but that means doing 4 passes for
SHA1, SHA256, SHA384 and SHA512 (assuming MD2 and MD5 are not in use



More information about the openssl-users mailing list