pub struct Client<R: Read, W: Write> { /* private fields */ }Expand description
Client side of the wire, an encrypted transport for issuing protobuf requests to a connected server. It initiates sessions by signaling a transport reset and driving the handshake, afterward encrypting outbound and decrypting inbound messages.
An empty frame from the server means it has no session with the client anymore.
It surfaces as Error::SessionReset with the client’s session dropped too,
so the caller can handshake again instead of waiting on a dead session.
The device attestation presented in the handshake is not interpreted by the
wire, it is handed to a Verifier deciding whether to trust the server.
Implementations§
Source§impl<R: Read, W: Write> Client<R, W>
impl<R: Read, W: Write> Client<R, W>
Sourcepub fn new(reader: R, writer: W) -> Self
pub fn new(reader: R, writer: W) -> Self
Creates a new client side around a low level reader and writer. Reads block per the transport’s semantics, so a timeout for an unresponsive server must be configured on the reader passed in.
Sourcepub fn handshake<V: Verifier>(&mut self, verifier: &V) -> Result<V::Info, Error>
pub fn handshake<V: Verifier>(&mut self, verifier: &V) -> Result<V::Info, Error>
Sends a session reset and drives the encrypted handshake with the server:
- Client -> Server: HostHello { host_signer, host_crypto } (plain CBOR)
- Server -> Client: ArkHello { ark_attest, ark_crypto, a2h_encap } (cose::seal)
- Client -> Server: HostAck { h2a_encap } (cose::seal)
The verifier receives the raw device attestation from the server’s hello and its accepted info is returned once the session is established.
Sourcepub fn next_message(&mut self) -> Result<ArkToHost, Error>
pub fn next_message(&mut self) -> Result<ArkToHost, Error>
Reads the next ark-to-host message, decrypting and protobuf decoding it. A frame that cannot be decoded or a packet that cannot be decrypted drops the session, as the server’s HPKE sequence can no longer be followed. So does an empty frame, the server signaling it dropped the session on its end. Only a fresh handshake recovers from either.