rustls::quic

Trait PacketKey

source
pub trait PacketKey: Send + Sync {
    // Required methods
    fn encrypt_in_place(
        &self,
        packet_number: u64,
        header: &[u8],
        payload: &mut [u8],
    ) -> Result<Tag, Error>;
    fn decrypt_in_place<'a>(
        &self,
        packet_number: u64,
        header: &[u8],
        payload: &'a mut [u8],
    ) -> Result<&'a [u8], Error>;
    fn tag_len(&self) -> usize;
}
Expand description

Keys to encrypt or decrypt the payload of a packet

Required Methods§

source

fn encrypt_in_place( &self, packet_number: u64, header: &[u8], payload: &mut [u8], ) -> Result<Tag, Error>

Encrypt a QUIC packet

Takes a packet_number, used to derive the nonce; the packet header, which is used as the additional authenticated data; and the payload. The authentication tag is returned if encryption succeeds.

Fails iff the payload is longer than allowed by the cipher suite’s AEAD algorithm.

source

fn decrypt_in_place<'a>( &self, packet_number: u64, header: &[u8], payload: &'a mut [u8], ) -> Result<&'a [u8], Error>

Decrypt a QUIC packet

Takes the packet header, which is used as the additional authenticated data, and the payload, which includes the authentication tag.

If the return value is Ok, the decrypted payload can be found in payload, up to the length found in the return value.

source

fn tag_len(&self) -> usize

Tag length for the underlying AEAD algorithm

Implementors§