4

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?

Emanuele
  • 174
  • 13
  • 3
    _PyCryptodome_ supports [`Crypto.Signature.pkcs1_15`](https://pycryptodome.readthedocs.io/en/latest/src/signature/pkcs1_v1_5.html#pkcs-1-v1-5-rsa) and [`Crypto.Signature.PKCS1_v1_5`](https://www.dlitz.net/software/pycrypto/api/current/Crypto.Signature.PKCS1_v1_5.PKCS115_SigScheme-class.html). However, `pkcs1_15` should be used. `PKCS1_v1_5` is only available for backwards compatibility with the **legacy** _PyCrypto_. `pkcs1_15` generates a `ValueError` in case of a failed verification. `PKCS1_v1_5` returns the result of the verification as `True`/`False`. – Topaco Jan 29 '21 at 17:32
  • Thank you for the explanation! – Emanuele Jan 29 '21 at 18:19

1 Answers1

4

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.

Community
  • 1
  • 1
Topaco
  • 40,594
  • 4
  • 35
  • 62