-
Notifications
You must be signed in to change notification settings - Fork 3k
public_key: Handle key params only present in SignatureAlgorithm of a cert #10023
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
public_key: Handle key params only present in SignatureAlgorithm of a cert #10023
Conversation
CT Test Results 2 files 17 suites 4m 38s ⏱️ Results for commit 3c1957e. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
4534fd1
to
23493b2
Compare
23493b2
to
3cea4cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds handling for RSA-PSS key parameters when they are only present in the certificate’s signature algorithm (not in the SubjectPublicKeyInfo), and adds corresponding tests.
- Introduces a new
key_params/2
helper to extract PSS parameters from the signature algorithm if missing from the key info. - Updates
validate_signature/6
to usekey_params/2
before verifying. - Adds
pkix_pss_params_in_signalg
tests inpublic_key_SUITE.erl
and cleans up an EDDSA test case.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
lib/public_key/src/pubkey_cert.erl | Added key_params/2 , updated validate_signature/6 callsite. |
lib/public_key/test/public_key_SUITE.erl | Added PSS‐params tests and minor EDDSA test cleanup. |
Comments suppressed due to low confidence (3)
lib/public_key/src/pubkey_cert.erl:2200
- [nitpick] Consider adding a docstring above
key_params/2
to explain when and why it extracts parameters from the certificate's signature algorithm, improving maintainability and clarity.
key_params(#'OTPCertificate'{tbsCertificate = TBSCert}, Params) when Params == asn1_NOVALUE;
lib/public_key/test/public_key_SUITE.erl:1466
- Add a test case covering the scenario where key parameters are explicitly
'NULL'
in theSubjectPublicKeyInfo
to ensurekey_params/2
correctly handles bothasn1_NOVALUE
and'NULL'
inputs.
pkix_pss_params_in_signalg() ->
lib/public_key/src/pubkey_cert.erl:261
- [nitpick] The parameter name
KeyParams0
is not descriptive; consider renaming it to something likeRawKeyParams
orInitialParams
to clarify its purpose before transformation.
validate_signature(Cert, DerCert, Key, KeyParams0,
3cea4cd
to
3071429
Compare
3ff492d
to
c894e8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this anyhow covered in RFCs?
lib/public_key/src/pubkey_cert.erl
Outdated
} = TBSCert, | ||
%% Sometimes parameters may be missing in issuer's "SubjectPublicKeyInfo" but included in | ||
%% the certs "SignatureAlgorithm" for RSA PSS signatures. | ||
case Algo of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this case is not needed?
- if you match on
?'id-RSASSA-PSS'
in function head - 2nd case clause would be handled by existing 2nd function clause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not due avoiding long lines, but I split it differently so as to be able to match in function head which I normally prefer.
c894e8e
to
986d49e
Compare
Not explicitly. I think the ASN.1 specs makes it quite possible and it makes sense for RSA keys as you can then upgrade an existing intermediat RSA cert to an RSA-PSS-PSS cert without changing the intermediate cert. And OpenSSL will verify this chain. |
986d49e
to
972991c
Compare
… certificate closes erlang#9632
972991c
to
3c1957e
Compare
closes #9632