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
impl NonceClient
Sourcepub fn new(secret: &[u8]) -> Self
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().
Sourcepub fn builder() -> NonceClientBuilder
pub fn builder() -> NonceClientBuilder
Creates a new NonceClientBuilder for advanced configuration.
Sourcepub fn credential_builder(&self) -> NonceCredentialBuilder<'_>
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§
impl Freeze for NonceClient
impl !RefUnwindSafe for NonceClient
impl Send for NonceClient
impl Sync for NonceClient
impl Unpin for NonceClient
impl !UnwindSafe for NonceClient
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