pub struct Challenge {
pub nonce: [u8; 32],
pub issued_at: DateTime<Utc>,
pub window: Duration,
}Expand description
A challenge issued to a device signer: a fresh 256-bit nonce and a validity window. Authenticity is established by the ability to produce a timely, nonce-bound response — a static copy of a prior artifact cannot satisfy the challenge.
Fields§
§nonce: [u8; 32]The nonce (>= 128 bits of entropy; we use 256).
issued_at: DateTime<Utc>When the challenge was issued.
window: DurationFreshness window.
Implementations§
Source§impl Challenge
impl Challenge
Sourcepub fn generate(window: Duration) -> SignatifResult<Self>
pub fn generate(window: Duration) -> SignatifResult<Self>
Generate a challenge with an OS-random nonce.
§Errors
Returns a revocation-category error if the OS RNG fails.
Sourcepub fn expected_payload(&self) -> Value
pub fn expected_payload(&self) -> Value
The canonical payload the response artifact must carry: the nonce bound into a deterministic JSON object.
Sourcepub fn verify_response(
&self,
response_payload: &Value,
now: DateTime<Utc>,
) -> SignatifResult<()>
pub fn verify_response( &self, response_payload: &Value, now: DateTime<Utc>, ) -> SignatifResult<()>
Verify a response artifact’s payload: the nonce must match and the response must be inside the freshness window.
§Errors
Returns an artifact-format error on nonce mismatch or expiry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Challenge
impl RefUnwindSafe for Challenge
impl Send for Challenge
impl Sync for Challenge
impl Unpin for Challenge
impl UnsafeUnpin for Challenge
impl UnwindSafe for Challenge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more