pub struct HostSide<R: Read, W: Write> { /* private fields */ }Expand description
Host side of the wire, an encrypted transport for issuing protobuf requests to a connected Ark. It initiates sessions by signaling a transport reset and driving the handshake, afterward encrypting outbound and decrypting inbound messages.
The device attestation presented in the handshake is not interpreted by the
wire, it is handed to a Verifier deciding whether to trust the Ark.
Implementations§
Source§impl<R: Read, W: Write> HostSide<R, W>
impl<R: Read, W: Write> HostSide<R, W>
Sourcepub fn new(reader: R, writer: W) -> Self
pub fn new(reader: R, writer: W) -> Self
Creates a new host side around a low level reader and writer. Reads block per the transport’s semantics, so a timeout for an unresponsive Ark 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 Ark:
- Host -> Ark: HostHello { host_signer, host_crypto } (plain CBOR)
- Ark -> Host: ArkHello { ark_attest, ark_crypto, a2h_encap } (cose::seal)
- Host -> Ark: HostAck { h2a_encap } (cose::seal)
The verifier receives the raw device attestation from the Ark’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 Ark’s HPKE sequence can no longer be followed; only a fresh handshake recovers from that.