-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for non-standard RSA signature encodings #5495
Comments
We've discussed allowing
|
A minor clarification since you talk about padding: we are really discussing two different aspects here:
The change proposed here only deals with case 1. Case 2 is only needed for the rare cases where a custom padding is used. I therefore proposed to keep padding as This is consistent with Windows CryptoAPI CNG, where In OpenSSL (and BoringSSL), the same thing is accomplished by leaving the signature alg as Allowing raw signature data, while using the PKCS #1 padding layer, is not inherently much less secure, especially if the digest alg is present but maybe with a non-standard deviation from DigestInfo. The latest PKCS #1 specification, in RFC 8017, mentions some cases where there is ambiguity in the DigestInfo encoding (in note 2 of of section 9.2). Regarding |
Regarding use cases, in addition to the old Verisign timestamp certificate already mentioned, we also have the same issue with Thawte timestamp certificates: see the function We also have the signed MD5/SHA1 hashes in TLS 1.1 or earlier (RFC 4346, section 4.7). IKE version 1 also requires signatures without DigestInfo (RFC 2409, section 5.1). In addition to the well-known cases above, the world is full of custom crypto implementations. For example, the German Signature Alliance (called TeleTrust), uses this format, as described in https://www.teletrust.de/fileadmin/files/oid/oid_DescriptionRsaSignatureWithoutHash.pdf. But any third-party application can use this functionality, since it is easily available in common crypto APIs:
|
To summarize the proposal:
I am ready to move forward and propose the implementation changes, when (if?) we have agreed on what to do. |
Ping: any news or comments on this proposal? Should I prepare a pull request for both the proposed changes, |
Let's do |
(Given our recent security issue around RSA GHSA-hggm-jpg3-v476 we're also should be very careful about this) |
(regarding GHSA-hggm-jpg3-v476) The RSA signatures are much less of a foot-gun than RSA encryption/decryption, both from handling-of-errors case and from side-channel resistance case. And signing with PKCS#1 v1.5 padding, but without DigestInfo is just as safe as signing in DSA or ECDSA: they don't encode the DigestInfo structure either. |
@tomato42: Good points. The original purpose of DigestInfo was to include the hash algorithm to avoid algorithm ambiguity. There would be no way to know the algorithm used to create a signature, when the signature format supports multiple algorithms with the same digest size. That would open up to signature forgery attacks when one of the algorithms was broken. This attack is mitigated if the digest size uniquely identifies the algorithm used. |
@reaperhulk: Now that the recovery part is done (in #5573), have you thought any more about extending RSA sign and verify with PKCS #1-padded signatures without DigestInfo? (suggested as using None as hash algorithm). |
hmm, I'd say that the #5573 is missing a test case with a static test vector, like a TLS 1.1 signature that encodes the concatenated MD5 and SHA-1 hash... |
@misterzed88 Where did we leave off here? I'm happy to review more proposals 😄 |
Great that you are open for further proposals! The two things which might be of interest are (as proposed above):
|
Someone working on 1. ? |
There are no updates on this effort that are not represented on this issue. |
We've added several features here but reading through the issue now it's difficult to understand what features are still under discussion. If there are additional use cases we should consider please open a new issue and we can discuss. |
There are use cases when there is a need to encode and decode RSA signature data using odd formats inside the PKCS #1-padding, such as:
One example is described in https://vcsjones.dev/2019/07/18/sometimes-valid-rsa-dotnet/
In order to support these cases, a proposal for API extension is described below.
Extension in the RSAPrivateKey.sign function:
Extension in the RSAPublicKey.verify function:
Add a new function RSAPublicKey.verify_recover:
From an API user point of view, I think the proposed changes will be simple to understand and to use, without breaking compatibility and introducing too much complexity. This is the best I could come up with for now. It is not straightforward to find a solution which keeps the current nice, simple API while adding the functionality needed. But please feel free to comment or improve the proposal. (For example, should we replace the None algorithm value with a more specific value similar to Prehashed, such as RawData?)
Note that this proposal only goes so far: it does not help if an application uses a a non-standard RSA padding, for example.
Implementation notes:
The text was updated successfully, but these errors were encountered: