[Cryptography-dev] RSA sign() with algorithm=None

M.S. Kandanur mskandanur at fastmail.in
Sun Dec 24 13:01:30 EST 2023


In the latest released version 41.0.7, comments to _rsa_sig_setup() say:

# Hash algorithm can be absent (None) to initialize the context without setting
# any message digest algorithm. This is currently only valid for the PKCS1v15
# padding type, where it means that the signature data is encoded/decoded
# as provided, without being wrapped in a DigestInfo structure.

Which sort of seems to indicate that passing algorithm=None to RSA sign() should work if padding=PKCS1v15, but you can't actually do this because you can't get through _calculate_digest_and_algorithm() which doesn't allow algorithm=None. Unless I'm missing something important here, this seems to be an inconsistency and most likely a bug as well.


More information about the Cryptography-dev mailing list