From cb4cd741d744d9898cfa8ab82e9da97b4d6fd135 Mon Sep 17 00:00:00 2001 From: TaaviE Date: Mon, 23 Mar 2026 14:14:10 +0000 Subject: [PATCH] Add type aliases for OCSP and PKCS7 types --- src/rust/cryptography-x509/src/ocsp_resp.rs | 4 +- src/rust/cryptography-x509/src/pkcs7.rs | 43 +++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/rust/cryptography-x509/src/ocsp_resp.rs b/src/rust/cryptography-x509/src/ocsp_resp.rs index 495dee5fe845..a83bb501587b 100644 --- a/src/rust/cryptography-x509/src/ocsp_resp.rs +++ b/src/rust/cryptography-x509/src/ocsp_resp.rs @@ -7,11 +7,13 @@ use crate::{certificate, common, crl, extensions, name, ocsp_req}; #[derive(asn1::Asn1Read, asn1::Asn1Write)] pub struct OCSPResponse<'a> { - pub response_status: asn1::Enumerated, + pub response_status: OCSPResponseStatus, #[explicit(0)] pub response_bytes: Option>, } +pub type OCSPResponseStatus = asn1::Enumerated; + #[derive(asn1::Asn1Read, asn1::Asn1Write)] pub struct ResponseBytes<'a> { pub response_type: asn1::DefinedByMarker, diff --git a/src/rust/cryptography-x509/src/pkcs7.rs b/src/rust/cryptography-x509/src/pkcs7.rs index c1f2626f2f5c..5283c534ab43 100644 --- a/src/rust/cryptography-x509/src/pkcs7.rs +++ b/src/rust/cryptography-x509/src/pkcs7.rs @@ -61,6 +61,49 @@ pub struct SignedData<'a> { >, } +pub type CertificateSet<'a> = common::Asn1ReadableOrWritable< + asn1::SetOf<'a, CertificateChoices<'a>>, + asn1::SetOfWriter<'a, CertificateChoices<'a>, Vec>>, +>; + +pub type RevocationInfoChoices<'a> = common::Asn1ReadableOrWritable< + asn1::SetOf<'a, RevocationInfoChoice<'a>>, + asn1::SetOfWriter<'a, RevocationInfoChoice<'a>, Vec>>, +>; + +#[allow(clippy::large_enum_variant)] +#[derive(asn1::Asn1Write, asn1::Asn1Read)] +pub enum CertificateChoices<'a> { + Certificate(certificate::Certificate<'a>), + #[implicit(0)] + ExtendedCertificate(asn1::Sequence<'a>), + #[implicit(1)] + V1AttrCert(asn1::Sequence<'a>), + #[implicit(2)] + V2AttrCert(asn1::Sequence<'a>), + #[implicit(3)] + OtherCertificate(OtherCertificateFormat<'a>), +} + +#[derive(asn1::Asn1Write, asn1::Asn1Read)] +pub struct OtherCertificateFormat<'a> { + pub other_cert_format: asn1::ObjectIdentifier, + pub other_cert: asn1::Tlv<'a>, +} + +#[derive(asn1::Asn1Write, asn1::Asn1Read)] +pub enum RevocationInfoChoice<'a> { + Crl(asn1::Sequence<'a>), + #[implicit(1)] + Other(OtherRevocationInfoFormat<'a>), +} + +#[derive(asn1::Asn1Write, asn1::Asn1Read)] +pub struct OtherRevocationInfoFormat<'a> { + pub other_rev_info_format: asn1::ObjectIdentifier, + pub other_rev_info: asn1::Tlv<'a>, +} + #[derive(asn1::Asn1Write, asn1::Asn1Read)] pub struct SignerInfo<'a> { pub version: u8,