diff --git a/x509-ocsp/src/basic.rs b/x509-ocsp/src/basic.rs index 33dffd9fd..c44f5e566 100644 --- a/x509-ocsp/src/basic.rs +++ b/x509-ocsp/src/basic.rs @@ -208,8 +208,8 @@ pub struct RevokedInfo { pub revocation_reason: Option, } -impl From for RevokedInfo { - fn from(rc: RevokedCert) -> Self { +impl From<&RevokedCert> for RevokedInfo { + fn from(rc: &RevokedCert) -> Self { Self { revocation_time: match rc.revocation_date { Time::UtcTime(t) => GeneralizedTime::from_date_time(t.to_date_time()), @@ -233,28 +233,9 @@ impl From for RevokedInfo { } } -impl From<&RevokedCert> for RevokedInfo { - fn from(rc: &RevokedCert) -> Self { - Self { - revocation_time: match rc.revocation_date { - Time::UtcTime(t) => GeneralizedTime::from_date_time(t.to_date_time()), - Time::GeneralTime(t) => t, - }, - revocation_reason: if let Some(extensions) = &rc.crl_entry_extensions { - let mut filter = extensions - .iter() - .filter(|ext| ext.extn_id == CrlReason::OID); - match filter.next() { - None => None, - Some(ext) => match CrlReason::from_der(ext.extn_value.as_bytes()) { - Ok(reason) => Some(reason), - Err(_) => None, - }, - } - } else { - None - }, - } +impl From for RevokedInfo { + fn from(rc: RevokedCert) -> Self { + Self::from(&rc) } } diff --git a/x509-ocsp/src/ext.rs b/x509-ocsp/src/ext.rs index 6572dc220..63eeeb63a 100644 --- a/x509-ocsp/src/ext.rs +++ b/x509-ocsp/src/ext.rs @@ -59,7 +59,14 @@ impl Nonce { Ok(Self(OctetString::new(bytes)?)) } - /// Creates a Nonce object given a random generator and a length + /// Creates a Nonce object given a random generator and a length. + /// + /// A proposed but not (yet) accepted RFC [RFC 8954] wants to limit nonces. RFC 6960 has no + /// mention of a minimum or maximum length. + /// + /// ```text + /// Nonce ::= OCTET STRING(SIZE(1..32)) + /// ``` #[cfg(feature = "rand_core")] pub fn generate(rng: &mut R, length: usize) -> Result { let mut bytes = Vec::with_capacity(length);