pub struct Server<R: Read, W: Write, A: Attester> { /* private fields */ }Expand description
Server side of the wire, an encrypted transport for serving protobuf requests from a connected client. It waits for session resets (empty frames), responds to handshake and afterward decrypts inbound and encrypts outbound messages.
Whenever the server drops a session, fails a handshake or receives data while it has no session, it answers with an empty frame of its own. A client still holding a session thus learns it is gone instead of having to time out.
The device attestation is not interpreted by the wire, it is provided by an
Attester and forwarded to the client verbatim.
Implementations§
Source§impl<R: Read, W: Write, A: Attester> Server<R, W, A>
impl<R: Read, W: Write, A: Attester> Server<R, W, A>
Sourcepub fn new(reader: R, writer: W, signer: SecretKey, attester: A) -> Self
pub fn new(reader: R, writer: W, signer: SecretKey, attester: A) -> Self
Creates a new server side around a low level reader and writer. The signer is the server’s identity key, which signs the handshake. The client verifies that signature against the key it extracts from the attestation, so the two must match. Reads block per the transport’s semantics, so any timeout must be configured on the reader passed in.
Sourcepub fn next_message(&mut self) -> Result<HostToArk, Error>
pub fn next_message(&mut self) -> Result<HostToArk, Error>
Serves the next host-to-ark message, decrypting and protobuf decoding it. Empty frames are session resets and run the handshake inline. Junk outside a session, undecryptable packets and failed handshakes are logged, answered with an empty frame and skipped. Only transport failures and malformed messages surface as errors.
Sourcepub fn send_message(&mut self, res: ArkToHost) -> Result<(), Error>
pub fn send_message(&mut self, res: ArkToHost) -> Result<(), Error>
Protobuf encodes an ark-to-host message, seals it with the session and sends it. Fails without an active session. A failure after sealing drops the session and signals the client, as the client’s HPKE sequence can no longer be caught up with.