pub struct Client { /* private fields */ }Expand description
A client configured for one recipient key and one explicit PSK identity.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
recipient_public_key: &[u8],
recipient_key_id: Vec<u8>,
psk: Vec<u8>,
psk_id: Vec<u8>,
limits: Limits,
) -> Result<Self, Error>
pub fn new( recipient_public_key: &[u8], recipient_key_id: Vec<u8>, psk: Vec<u8>, psk_id: Vec<u8>, limits: Limits, ) -> Result<Self, Error>
Validate and create a client. The public PSK ID cannot equal the PSK.
§Errors
Returns Error::InvalidConfiguration for invalid keys, identifiers,
credentials, or limits.
Sourcepub fn protect(&self, request: &Request) -> Result<ProtectedRequest, Error>
pub fn protect(&self, request: &Request) -> Result<ProtectedRequest, Error>
Protect one complete request with the platform entropy source.
§Errors
Returns a validation, clock, entropy, or cryptographic error before exposing a partially protected envelope.
Sourcepub fn protect_at(
&self,
request: &Request,
now_unix_s: u64,
) -> Result<ProtectedRequest, Error>
pub fn protect_at( &self, request: &Request, now_unix_s: u64, ) -> Result<ProtectedRequest, Error>
Protect one complete request at an injected Unix time.
This entry point exists for hosts with their own trusted clock and for
deterministic conformance tests. Normal native callers use Self::protect.
§Errors
Returns a validation, entropy, or cryptographic error.
Sourcepub fn protect_with_entropy(
&self,
request: &Request,
entropy: &mut impl EntropySource,
) -> Result<ProtectedRequest, Error>
pub fn protect_with_entropy( &self, request: &Request, entropy: &mut impl EntropySource, ) -> Result<ProtectedRequest, Error>
Protect one complete request with an injected fallible entropy source.
§Errors
Returns a validation, clock, entropy, or cryptographic error before exposing a partially protected envelope.
Sourcepub fn protect_at_with_entropy(
&self,
request: &Request,
now_unix_s: u64,
entropy: &mut impl EntropySource,
) -> Result<ProtectedRequest, Error>
pub fn protect_at_with_entropy( &self, request: &Request, now_unix_s: u64, entropy: &mut impl EntropySource, ) -> Result<ProtectedRequest, Error>
Protect a request with injected time and entropy.
§Errors
Returns a validation, entropy, or cryptographic error before exposing a partial envelope.
Source§impl Client
impl Client
Sourcepub fn begin_stream(
&self,
head: &RequestHead,
) -> Result<(StreamRequestSealer, Vec<u8>), Error>
pub fn begin_stream( &self, head: &RequestHead, ) -> Result<(StreamRequestSealer, Vec<u8>), Error>
Start a protected request and return its bounded prefix and checked START.
§Errors
Returns a validation, entropy, or cryptographic error before source bytes are read.
Sourcepub fn begin_stream_at_with_entropy(
&self,
head: &RequestHead,
now_unix_s: u64,
entropy: &mut impl EntropySource,
) -> Result<(StreamRequestSealer, Vec<u8>), Error>
pub fn begin_stream_at_with_entropy( &self, head: &RequestHead, now_unix_s: u64, entropy: &mut impl EntropySource, ) -> Result<(StreamRequestSealer, Vec<u8>), Error>
Start a stream with caller-supplied time and entropy for wire tests.
§Errors
Returns a validation, entropy, or cryptographic error.