pkcs1 verificiation too strict on algid encoding
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python-Crypto |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
I recently ran into an issue with the PKCS#1 v1.5 verification routines in pycrypto. The EMSA_PKCS1_
https:/
Some crypto implementations generate signatures that omit the AlgId parameters field instead of including a Null object. Therefore, those signatures will fail when verified with pycrypto.
Other implementations (Bouncy Castle, OpenSSL) relax their verification routines to accept the signature whether or not the Null is present.
From http://
"""
There are two possible encodings for the AlgorithmIdentifier
parameters field associated with these object identifiers. The two
alternatives arise from the loss of the OPTIONAL associated with the
algorithm identifier parameters when the 1988 syntax for
AlgorithmIde
OPTIONAL was recovered via a defect report, but by then many people
thought that algorithm parameters were mandatory. Because of this
history some implementations encode parameters as a NULL element
while others omit them entirely. The correct encoding is to omit the
parameters field; however, when RSASSA-PSS and RSAES-OAEP were
defined, it was done using the NULL parameters rather than absent
parameters.
All implementations MUST accept both NULL and absent parameters as
legal and equivalent encodings.
"""
I created a fix and opened a pull request for this:
https:/ /github. com/dlitz/ pycrypto/ pull/36
As I say in the comment, I branched it off from my pkcs8 branch mainly for cosmetic reason.
By changing one line it could be applied directly to main.
One last one. RFC 4055 only talks about SHA1/2 algorithms. RFC 3447 (PKCS#1 v2.1) says the same thing,
but it also says that any MD2/5-based signature must have the parameters (field with value NULL).
It is still mandatory in that case.