pub trait Session: 'static + Send {
    fn initial_keys(&self, dst_cid: &ConnectionId, side: Side) -> Keys;
    fn handshake_data(&self) -> Option<Box<dyn Any + 'static, Global>>;
    fn peer_identity(&self) -> Option<Box<dyn Any + 'static, Global>>;
    fn early_crypto(
        &self
    ) -> Option<(Box<dyn HeaderKey + 'static, Global>, Box<dyn PacketKey + 'static, Global>)>; fn early_data_accepted(&self) -> Option<bool>; fn is_handshaking(&self) -> bool; fn read_handshake(&mut self, buf: &[u8]) -> Result<bool, Error>; fn transport_parameters(&self) -> Result<Option<TransportParameters>, Error>; fn write_handshake(&mut self, buf: &mut Vec<u8, Global>) -> Option<Keys>; fn next_1rtt_keys(
        &mut self
    ) -> Option<KeyPair<Box<dyn PacketKey + 'static, Global>>>; fn is_valid_retry(
        &self,
        orig_dst_cid: &ConnectionId,
        header: &[u8],
        payload: &[u8]
    ) -> bool; fn export_keying_material(
        &self,
        output: &mut [u8],
        label: &[u8],
        context: &[u8]
    ) -> Result<(), ExportKeyingMaterialError>; }
Expand description

A cryptographic session (commonly TLS)

Required Methods

Create the initial set of keys given the client’s initial destination ConnectionId

Get data negotiated during the handshake, if available

Returns None until the connection emits HandshakeDataReady.

Get the peer’s identity, if available

Get the 0-RTT keys if available (clients only)

On the client side, this method can be used to see if 0-RTT key material is available to start sending data before the protocol handshake has completed.

Returns None if the key material is not available. This might happen if you have not connected to this server before.

If the 0-RTT-encrypted data has been accepted by the peer

Returns true until the connection is fully established.

Read bytes of handshake data

This should be called with the contents of CRYPTO frames. If it returns Ok, the caller should call write_handshake() to check if the crypto protocol has anything to send to the peer.

On success, returns true iff self.handshake_data() has been populated.

The peer’s QUIC transport parameters

These are only available after the first flight from the peer has been received.

Writes handshake bytes into the given buffer and optionally returns the negotiated keys

When the handshake proceeds to the next phase, this method will return a new set of keys to encrypt data with.

Compute keys for the next key update

Verify the integrity of a retry packet

Fill output with output.len() bytes of keying material derived from the Session’s secrets, using label and context for domain separation.

This function will fail, returning ExportKeyingMaterialError, if the requested output length is too large.

Implementors