Repository navigation
Conversation
RFC 5280 Section 5.1 defines TBSCertList.version as optional: `version Version OPTIONAL, -- if present, MUST be v2`. When absent, a v1 CRL omits the version field, but TbsCertList previously required the field to be present during DER decoding. Adding `#[asn1(default = "Default::default")]` allows decoding absent versions as Version::V1 and omits Version::V1 during DER encoding. Closes RustCrypto#2544
This branch has not been deployed
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
Per RFC 5280 Section 5.1,
TBSCertList.versionis defined asVersion OPTIONAL, where absence indicates a v1 CRL. Previously,TbsCertList.versionwas declared as a mandatoryVersion, causing decoding of v1 CRLs (which omit the version field) to fail with a DER tag error. This change marksTbsCertList.versionwith#[asn1(default = "Default::default")]so that absent versions decode asVersion::V1andVersion::V1is omitted during DER encoding.Fixes #2544
Changes
x509-cert/src/crl.rs, markedTbsCertList.versionwith#[asn1(default = "Default::default")].x509-cert/tests/crl.rs, added regression tests covering decoding and DER roundtripping of both v1 CRLs (with omitted version) and v2 CRLs (with explicit versionINTEGER 1), including the test vector from x509-cert: v1 CRLs fail to decode (TBSCertList.versionis OPTIONAL) #2544.Verification
cargo test -p x509-cert --test crlagainst master without the fix reproduces the failure:cargo test -p x509-cert --test crlwith the fix applied passes:cargo fmt --check -p x509-certcargo clippy -p x509-cert --all-targetsAI was used to write this code.