diff --git a/x509-ocsp/src/basic.rs b/x509-ocsp/src/basic.rs index c44f5e566..1b51308fe 100644 --- a/x509-ocsp/src/basic.rs +++ b/x509-ocsp/src/basic.rs @@ -24,20 +24,15 @@ use x509_cert::{ /// ``` /// /// [RFC 6960 Section 4.1.1]: https://datatracker.ietf.org/doc/html/rfc6960#section-4.1.1 -#[derive(Clone, Debug, Copy, PartialEq, Eq, Enumerated)] +#[derive(Clone, Debug, Default, Copy, PartialEq, Eq, Enumerated)] #[asn1(type = "INTEGER")] #[repr(u8)] pub enum Version { /// Version 1 (default) + #[default] V1 = 0, } -impl Default for Version { - fn default() -> Self { - Self::V1 - } -} - /// BasicOcspResponse structure as defined in [RFC 6960 Section 4.2.1]. /// /// ```text diff --git a/x509-ocsp/src/ext.rs b/x509-ocsp/src/ext.rs index 3a6fb413e..7ea8265fe 100644 --- a/x509-ocsp/src/ext.rs +++ b/x509-ocsp/src/ext.rs @@ -69,14 +69,9 @@ impl Nonce { /// ``` #[cfg(feature = "rand_core")] pub fn generate(rng: &mut R, length: usize) -> Result { - let mut bytes = Vec::with_capacity(length); - let mut random = [0u8; 32]; - while bytes.len() < length { - rng.fill_bytes(&mut random); - bytes.extend_from_slice(&random); - } - bytes.resize(length, 0); - Ok(Self(OctetString::new(bytes)?)) + let mut bytes = alloc::vec![0; length]; + rng.fill_bytes(&mut bytes); + Self::new(bytes) } }