Search code examples
pythonpython-3.xcryptographypycryptopycryptodome

What is the difference between Crypto.Signature.PKCS1_v1_5 and Crypto.Signature.pkcs1_15?


I was wondering which is the difference between Crypto.Signature.PKCS1_v1_5 and Crypto.Signature.pkcs1_15?

In the documentation they use this function Crypto.Signature.pkcs1_15 but sometimes I've seen that Crypto.Signature.PKCS1_v1_5 was used.

What is the difference and which is better to use?


Solution

  • Crypto.Signature.pkcs1_15 is PyCryptodome's implementation of the RSASSA-PKCS1-v1_5 signature scheme. Crypto.Signature.PKCS1_v1_5 is the corresponding implementation of the legacy PyCrypto, the PyCryptodome predecessor. PyCryptodome also supports Crypto.Signature.PKCS1_v1_5, but solely for backwards compatibility, i.e. new implementations should use Crypto.Signature.pkcs1_15.

    Note that both libraries differ in processing, e.g. Crypto.Signature.pkcs1_15.PKCS115_SigScheme#verify() raises a ValueError exception in case of a failed verification, while Crypto.Signature.PKCS1_v1_5.PKCS115_SigScheme#verify() returns the result of a verification as True/False.