Struct NonceClient

Source
pub struct NonceClient { /* private fields */ }
Expand description

A client for generating cryptographically signed NonceCredentials.

This client is stateless and responsible for creating credentials that can be verified by a NonceServer.

§Example

use nonce_auth::NonceClient;
use hmac::Mac; // Trait for `mac.update()`

let client = NonceClient::new(b"my_secret");
let payload = b"some_data_to_protect";

// Standard usage:
let credential = client.credential_builder().sign(payload).unwrap();

// Advanced usage:
let custom_credential = client.credential_builder().sign_with(|mac, ts, nonce| {
    mac.update(ts.as_bytes());
    mac.update(nonce.as_bytes());
    mac.update(payload);
}).unwrap();

Implementations§

Source§

impl NonceClient

Source

pub fn new(secret: &[u8]) -> Self

Creates a new NonceClient with the specified shared secret and default generators.

Uses UUID v4 for nonce generation and system time for timestamps. For more customization options, use NonceClient::builder().

Source

pub fn builder() -> NonceClientBuilder

Creates a new NonceClientBuilder for advanced configuration.

Source

pub fn credential_builder(&self) -> NonceCredentialBuilder<'_>

Returns a builder to construct and sign a NonceCredential.

This is the recommended entry point for creating credentials.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.