Conversation
jgreeer
force-pushed
the
add-public-key-algorithm
branch
from
September 24, 2026 17:45
dc2ce63 to
957b1be
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR splits the SPKI public key identification of
SignatureAlgorithminto its own separate type,PublicKeyAlgorithm. Bundling them together is fine for key generation, but it leads to us making incorrect assumptions when parsing. We also move closer to removingKeyPairfor #450, since we move the signing algorithm fromKeyPairto theSigningKeytrait. This change is inspired by the crypto/x509 package in go.No DER output changes for anything that worked before.
write_alg_idis byte-identical to the oldwrite_oids_sign_algfor every algorithm, which the unchanged openssl/webpki/botan verify-tests cover.Changes
sign_algo.rsPublicKeyAlgorithmstruct with three methods:from_alg_id(),write_alg_id(), anditer()SignatureAlgorithmchangesoids_sign_algand replaced withkey_alg, which holds aPublicKeyAlgorithmfrom_oid(), we've replaced the only usage incsr.rs. For ECDSA, some of the values have the same OIDs, so they were being shadowed.from_oid(ecdsa-with-SHA256)always returnedECDSA_P256_SHA256, soECDSA_P521_SHA256could never be returned at all.key_algmodule, which stores the static public key typeswrite_oids_sign_alg(), this is now done inwrite_alg_id()key_pair.rsalgorithm()fromKeyPair. It lives in theSigningKeytrait assignature_algorithm()PublicKeyData::algorithm()now returns aPublicKeyAlgorithminstead of aSignatureAlgorithmSubjectPublicKeyInfostruct now stores aPublicKeyAlgorithm, since it implementsPublicKeyDatafrom_der()in the SPKI struct now uses thefrom_alg_idmethod ofPublicKeyAlgorithmserialize_public_key_der()now uses thewrite_alg_idmethod ofPublicKeyAlgorithmcsr.rsPublicKeystructsalgfield is now aPublicKeyAlgorithminstead of aSignatureAlgorithmfrom_der(), we read the public key algorithm from the SPKI's AlgorithmIdentifier using thefrom_alg_id()method instead of using the csr's signature algorithm.sha1WithRSAEncryptionor RSASSA-PSS now parse instead of erroring, sincefrom_oidwas acting as a second gate and x509-parser accepts both.NULLis now rejected.certificate.rsandcrl.rsalgorithm()call tosignature_algorithm()crl.rs- changed the doc example for the new trait shapeerror.rsError::UnsupportedPublicKeyAlgorithmvariantrustls-cert-gen/src/cert.rslib.rsverify-testsopenssl.rs- Added a test for the issue CertificateSigningRequestParams::from_der can parse the wrong key type #448webpki.rs- Fixed its PublicKeyData implementation to return aPublicKeyAlgorithmFixes #448