Skip to content

Commit ffcfcf9

Browse files
committed
mtc_api: Properly encode TBSCertificateLogEntry
We were missing a few ASN.1 bits that control encoding of the tags.
1 parent eaf7afe commit ffcfcf9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

crates/mtc_api/src/lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ use x509_cert::{
3232
certificate::Version,
3333
ext::{
3434
pkix::{ExtendedKeyUsage, KeyUsage, KeyUsages},
35-
Extension,
35+
Extension, Extensions,
3636
},
37-
name::RdnSequence,
37+
name::{Name, RdnSequence},
3838
serial_number::SerialNumber,
3939
spki::{AlgorithmIdentifier, SubjectPublicKeyInfo},
4040
time::Validity,
@@ -355,14 +355,24 @@ impl MerkleTreeCertEntry {
355355

356356
#[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)]
357357
pub struct TbsCertificateLogEntry {
358+
/// The certificate version
359+
///
360+
/// Note that this value defaults to Version 1 per the RFC. However,
361+
/// fields such as `issuer_unique_id`, `subject_unique_id` and `extensions`
362+
/// require later versions. Care should be taken in order to ensure
363+
/// standards compliance.
364+
#[asn1(context_specific = "0", default = "Default::default")]
358365
pub version: Version,
359-
pub issuer: RdnSequence,
366+
pub issuer: Name,
360367
pub validity: Validity,
361-
pub subject: RdnSequence,
368+
pub subject: Name,
362369
pub subject_public_key_info_hash: OctetString,
370+
#[asn1(context_specific = "1", tag_mode = "IMPLICIT", optional = "true")]
363371
pub issuer_unique_id: Option<BitString>,
372+
#[asn1(context_specific = "2", tag_mode = "IMPLICIT", optional = "true")]
364373
pub subject_unique_id: Option<BitString>,
365-
pub extensions: Option<Vec<Extension>>,
374+
#[asn1(context_specific = "3", tag_mode = "EXPLICIT", optional = "true")]
375+
pub extensions: Option<Extensions>,
366376
}
367377

368378
// Validate and filter extended key usage extension.

0 commit comments

Comments
 (0)