pub struct Server { /* private fields */ }Expand description
A server with one advertised recipient key and other accepted keys.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(
recipient_private_key: &[u8],
recipient_key_id: Vec<u8>,
limits: Limits,
) -> Result<Self, Error>
pub fn new( recipient_private_key: &[u8], recipient_key_id: Vec<u8>, limits: Limits, ) -> Result<Self, Error>
Validate and create a server for one static recipient key.
§Errors
Returns Error::InvalidConfiguration for invalid key material,
identifiers, or limits.
Sourcepub fn with_accepted_keys(
recipient_private_key: &[u8],
recipient_key_id: Vec<u8>,
accepted: Vec<(Vec<u8>, Vec<u8>)>,
limits: Limits,
) -> Result<Self, Error>
pub fn with_accepted_keys( recipient_private_key: &[u8], recipient_key_id: Vec<u8>, accepted: Vec<(Vec<u8>, Vec<u8>)>, limits: Limits, ) -> Result<Self, Error>
Create a server that advertises one key and also accepts other keys.
Each accepted pair holds a private key followed by its public key ID.
§Errors
Returns Error::InvalidConfiguration for invalid or duplicate IDs,
invalid private keys, or invalid limits.
Sourcepub fn public_key(&self) -> Vec<u8> ⓘ
pub fn public_key(&self) -> Vec<u8> ⓘ
Return the encoded public key for this server’s private key.
Sourcepub fn max_complete_envelope_len(&self) -> Result<usize, Error>
pub fn max_complete_envelope_len(&self) -> Result<usize, Error>
Return the largest complete request envelope accepted by preparse.
Bindings use this limit before they copy a complete envelope.
§Errors
Returns Error::LimitExceeded if the size cannot fit in usize.
Sourcepub fn preparse(&self, envelope: &[u8]) -> Result<PreparsedRequest, Error>
pub fn preparse(&self, envelope: &[u8]) -> Result<PreparsedRequest, Error>
Parse bounded public fields without accepting credentials or plaintext.
§Errors
Returns a stable parse, limit, version, suite, or recipient-key error.
Sourcepub fn preparse_owned(
&self,
envelope: Vec<u8>,
) -> Result<PreparsedRequest, Error>
pub fn preparse_owned( &self, envelope: Vec<u8>, ) -> Result<PreparsedRequest, Error>
Parse an owned envelope without cloning its complete ciphertext.
Bindings which already own their input can move it into the one-shot credential-resolution token. The same bounded public checks run before the token is created.
§Errors
Returns a stable parse, limit, version, suite, or recipient-key error.
Sourcepub fn authenticate(
&self,
token: StartToken,
psk: &[u8],
) -> Result<AuthenticatedRequest, Error>
pub fn authenticate( &self, token: StartToken, psk: &[u8], ) -> Result<AuthenticatedRequest, Error>
Authenticate and parse the full request, then pause before replay admission.
Plaintext stays inside the returned opaque token until admission.
§Errors
Returns a credential, recipient-key, parse, authentication, request-time, or clock error.
Sourcepub fn authenticate_at(
&self,
token: StartToken,
psk: &[u8],
now_unix_s: u64,
) -> Result<AuthenticatedRequest, Error>
pub fn authenticate_at( &self, token: StartToken, psk: &[u8], now_unix_s: u64, ) -> Result<AuthenticatedRequest, Error>
Authenticate at an injected Unix time, then pause before replay admission.
§Errors
Returns a credential, recipient-key, parse, authentication, or request-time error.
Source§impl Server
impl Server
Sourcepub fn stream_start_length(&self, input: &[u8]) -> Result<Option<usize>, Error>
pub fn stream_start_length(&self, input: &[u8]) -> Result<Option<usize>, Error>
Return the START boundary once its bounded frame length is known.
§Errors
Returns a parse, version, suite, or size error.
Sourcepub fn preparse_stream(
&self,
first: &[u8],
) -> Result<PreparsedStreamRequest, Error>
pub fn preparse_stream( &self, first: &[u8], ) -> Result<PreparsedStreamRequest, Error>
Read the exact public prefix and START frame before credential lookup.
§Errors
Returns a parse, limit, or recipient-key error.
Sourcepub fn authenticate_stream(
&self,
token: StreamStartToken,
psk: &[u8],
) -> Result<AuthenticatedStreamRequest, Error>
pub fn authenticate_stream( &self, token: StreamStartToken, psk: &[u8], ) -> Result<AuthenticatedStreamRequest, Error>
Authenticate START, then pause before replay admission.
§Errors
Returns a credential, time, authentication, or parse error.
Sourcepub fn authenticate_stream_at(
&self,
token: StreamStartToken,
psk: &[u8],
now_unix_s: u64,
) -> Result<AuthenticatedStreamRequest, Error>
pub fn authenticate_stream_at( &self, token: StreamStartToken, psk: &[u8], now_unix_s: u64, ) -> Result<AuthenticatedStreamRequest, Error>
Authenticate START at a caller-supplied trusted Unix time.
§Errors
Returns a credential, time, authentication, or parse error.