Skip to main content

PacketKey

Trait PacketKey 

pub trait PacketKey: Send + Sync {
    // Required methods
    fn encrypt(
        &self,
        packet: u64,
        buf: &mut [u8],
        header_len: usize,
    ) -> Result<(), CryptoError>;
    fn decrypt(
        &self,
        packet: u64,
        header: &[u8],
        payload: &mut BytesMut,
    ) -> Result<(), CryptoError>;
    fn tag_len(&self) -> usize;
    fn confidentiality_limit(&self) -> u64;
    fn integrity_limit(&self) -> u64;
}
Available on crate features quic and std only.
Expand description

Keys used to protect packet payloads

Required Methods§

fn encrypt( &self, packet: u64, buf: &mut [u8], header_len: usize, ) -> Result<(), CryptoError>

Encrypt the packet payload with the given packet number

fn decrypt( &self, packet: u64, header: &[u8], payload: &mut BytesMut, ) -> Result<(), CryptoError>

Decrypt the packet payload with the given packet number

fn tag_len(&self) -> usize

The length of the AEAD tag appended to packets on encryption

fn confidentiality_limit(&self) -> u64

Maximum number of packets that may be sent using a single key (RFC 9001 §6.6)

Counted per key: a key update starts the new phase at zero. The last packet of the budget carries the close, and nothing is protected past it. Routine updates begin 10,000 packets short of this value.

fn integrity_limit(&self) -> u64

Maximum number of incoming packets that may fail decryption before the connection must be abandoned (RFC 9001 §6.6)

Counted for the whole connection, across every key it has used. Once exceeded, the connection ends and processes no further packets.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl PacketKey for Box<dyn PacketKey>

§

impl<T> PacketKey for Arc<T>
where T: PacketKey + ?Sized,