pub struct CompressedDate(/* private fields */);Expand description
3-byte date encoding per Microchip format
Layout (24 bits total, little-endian):
- Bits 0-4: Year (years since
BASE_YEAR, valid 0-31 = 2025-2056) - Bits 5-8: Month (1-12)
- Bits 9-13: Day (1-31)
- Bits 14-18: Hour (0-23)
- Bits 19-23: Expire years (0-31 years validity)
Implementations§
Source§impl CompressedDate
impl CompressedDate
Sourcepub const fn year(&self) -> u8
pub const fn year(&self) -> u8
Get the year offset from Self::BASE_YEAR (0-31)
Sourcepub const fn with_year(self, year: u8) -> Self
pub const fn with_year(self, year: u8) -> Self
Set the year offset and return self (builder pattern)
Sourcepub const fn with_month(self, month: u8) -> Self
pub const fn with_month(self, month: u8) -> Self
Set the month and return self (builder pattern)
Sourcepub const fn expire_years(&self) -> u8
pub const fn expire_years(&self) -> u8
Get the certificate validity in years (0-31)
Sourcepub const fn with_expire_years(self, years: u8) -> Self
pub const fn with_expire_years(self, years: u8) -> Self
Set the expire years and return self (builder pattern)
Sourcepub fn with_month_checked(self, month: u8) -> Result<Self, Error>
pub fn with_month_checked(self, month: u8) -> Result<Self, Error>
Set month with validation (1-12)
Sourcepub fn with_day_checked(self, day: u8) -> Result<Self, Error>
pub fn with_day_checked(self, day: u8) -> Result<Self, Error>
Set day with validation (1-31)
Sourcepub fn with_hour_checked(self, hour: u8) -> Result<Self, Error>
pub fn with_hour_checked(self, hour: u8) -> Result<Self, Error>
Set hour with validation (0-23)
Source§impl CompressedDate
impl CompressedDate
Sourcepub const BASE_YEAR: u16 = 2025
pub const BASE_YEAR: u16 = 2025
Base year for compressed date encoding.
The 5-bit year field encodes an offset 0-31, giving issue years
BASE_YEAR..=BASE_YEAR + 31. The base is not stored in the 72-byte
compressed cert — it is implicit in this constant on both the issuer and
the device, so a cert compressed under one base would reconstruct to a
different date (and thus a different, unverifiable TBS) under another.
It can only be changed before any device holds a compressed cert.
Sourcepub const MAX_YEAR_OFFSET: u8 = 31
pub const MAX_YEAR_OFFSET: u8 = 31
Maximum year offset (5 bits)
Sourcepub const MAX_EXPIRE_YEARS: u8 = 31
pub const MAX_EXPIRE_YEARS: u8 = 31
Maximum expire years (5 bits)
Sourcepub fn from_validity(validity: &Validity) -> Result<Self, Error>
pub fn from_validity(validity: &Validity) -> Result<Self, Error>
Convert from X.509 Validity to compressed date format
Sourcepub fn to_validity(&self) -> Result<Validity, Error>
pub fn to_validity(&self) -> Result<Validity, Error>
Convert compressed date to X.509 Validity
Sourcepub fn from_bytes(bytes: [u8; 3]) -> Self
pub fn from_bytes(bytes: [u8; 3]) -> Self
Create from 3-byte array