pub struct SerialNumber<P = Rfc5280>where
P: Profile,{ /* private fields */ }Expand description
[RFC 5280 Section 4.1.2.2.] Serial Number
The serial number MUST be a positive integer assigned by the CA to each certificate. It MUST be unique for each certificate issued by a given CA (i.e., the issuer name and serial number identify a unique certificate). CAs MUST force the serialNumber to be a non-negative integer.
Given the uniqueness requirements above, serial numbers can be expected to contain long integers. Certificate users MUST be able to handle serialNumber values up to 20 octets. Conforming CAs MUST NOT use serialNumber values longer than 20 octets.
Note: Non-conforming CAs may issue certificates with serial numbers that are negative or zero. Certificate users SHOULD be prepared to gracefully handle such certificates.
Implementations§
Source§impl<P> SerialNumber<P>where
P: Profile,
impl<P> SerialNumber<P>where
P: Profile,
Sourcepub const MAX_LEN: Length
pub const MAX_LEN: Length
Maximum length in bytes for a SerialNumber
Sourcepub fn new(bytes: &[u8]) -> Result<SerialNumber<P>, Error>
pub fn new(bytes: &[u8]) -> Result<SerialNumber<P>, Error>
Create a new SerialNumber from a byte slice.
The byte slice must represent a positive integer.
Source§impl<P> SerialNumber<P>where
P: Profile,
impl<P> SerialNumber<P>where
P: Profile,
Sourcepub fn generate<R>(rng: &mut R) -> SerialNumber<P>
pub fn generate<R>(rng: &mut R) -> SerialNumber<P>
Generates a random serial number from RNG.
This follows the recommendation the CAB forum ballot 164 and uses a minimum of 64 bits of output from the CSPRNG. This currently defaults to a 17-bytes long serial number.
Sourcepub fn generate_with_prefix<R>(
prefix: &[u8],
rand_len: usize,
rng: &mut R,
) -> Result<SerialNumber<P>, Error>
pub fn generate_with_prefix<R>( prefix: &[u8], rand_len: usize, rng: &mut R, ) -> Result<SerialNumber<P>, Error>
Generates a random serial number from RNG. Include a prefix value.
This follows the recommendation the CAB forum ballot 164 and uses a minimum of 64 bits of output from the CSPRNG.
The specified length does not include the length of the prefix, the maximum length must be equal or below 19 (to account for leading sign disambiguation, and the maximum length of 20).
Trait Implementations§
Source§impl<P> Clone for SerialNumber<P>
impl<P> Clone for SerialNumber<P>
Source§fn clone(&self) -> SerialNumber<P>
fn clone(&self) -> SerialNumber<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more