pub struct Challenge {
pub bytes: Vec<u8>,
pub created_at: SystemTime,
}Expand description
A single-use challenge issued by the relying party before a ceremony.
Security contract: each Challenge must be used at most once and must
expire after a short window (typically 60–300 seconds). The caller is
responsible for enforcing both properties.
Fields§
§bytes: Vec<u8>32 cryptographically random bytes.
created_at: SystemTimeWhen this challenge was generated — used for expiry checks.
Implementations§
Source§impl Challenge
impl Challenge
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Generate a fresh 32-byte challenge using the OS cryptographic RNG.
32 bytes provides 256 bits of entropy — far beyond any brute-force threat.
§Errors
Returns WebAuthnError::InvalidClientData if the system RNG fails
(extremely unlikely; would indicate a kernel-level failure).
Sourcepub fn is_expired(&self, ttl_secs: u64) -> bool
pub fn is_expired(&self, ttl_secs: u64) -> bool
Returns true if this challenge is older than ttl_secs seconds.
Returns true if the system clock has gone backwards since the challenge
was created — treating an unverifiable age as expired is the safe default.