Map certs with ITUT X509 to our RSA implementation (#1754) #1893
+81
−37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues:
Addresses #P157022381
Description of changes:
This is a cherry pick of 4916fe8 to the fips-2022-11-02 branch. The changes are outside the fipsmodule and were modified from the original commit to match the return values of
parse_key_type()
inevp_asn1.c
without changing the fipsmodule files.There exists a rarer OID of RSA public keys which comes from the ITU-T version of X.509 (links below).
Links:
https://www.itu.int/ITU-T/formal-language/itu-t/x/x509/2008/AlgorithmObjectIdentifiers.html
OpenSSL accepts the
sign_nid
andpkey_nid
for this draft.NID_md5WithRSA
NID_sha1WithRSA
NID_rsa
We can parse both
sign_nid
s correctly. But we lack the logic to interpretNID_rsa
in a certificate or map the parsedsign_nid
s to any RSA implementation.OpenSSL maps the corresponding nids from the same draft, which means
NID_md5WithRSA
andNID_sha1WithRSA
aremapped to
NID_rsa
and an additionalEVP_PKEY_RSA2
is used to representNID_rsa
. The additionalEVP_PKEY
type introduces additional complexities however and the underlying functionality inEVP_PKEY_RSA2
isidentical to it's more common
EVP_PKEY_RSA
counterpart.We've been burned by multiple OpenSSL cert parsing differences in the past, so we should have logic to understand certs that have
NID_rsa
. We don't want to duplicate all the function pointers forEVP_PKEY_RSA2
however. Since the underlying RSA functions pointers are the same, I think it should be OK for us toNID_md5WithRSA
andNID_sha1WithRSA
to our RSA implementation (NID_rsa_encryption
).NID_rsa
toEVP_PKEY_RSA
when parsing certificates.Unfortunately, there's some stricter parsing in
rsa_pub_decode
that I've had to remove since it doesn't apply to both RFCs for RSA public keys. This is aligning with OpenSSL, which happens to ignore both of the early parameters specified in either.Although we have
EVP_PKEY_RSA2
and we could map the logic for that toEVP_PKEY_RSA
inEVP_PKEY_type
, I've intentionally left that out for now. We still want to discourage people from using this form, we just need to understand how to parse certificates that have it.Relevant historic commits:
NID_rsa
: f6094e0(cherry picked from commit 4916fe8)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.