pub struct PendingCiphertexts { /* private fields */ }Expand description
Ciphertexts that failed with Error::UnknownKeyId, kept to
be decrypted once the key is there.
A client MAY do this (RFC 9605 section 4.4.4): a new key can reach a receiver after the
first frames encrypted with it. The store is bounded in frames and in bytes and drops the
oldest entry to make room, so a peer naming keys that never come cannot grow it. Nothing
held here is authenticated: it is only ever handed back for decryption. It has no clock;
an application that wants entries to expire calls discard_oldest
or clear on its own timer.
Implementations§
Source§impl PendingCiphertexts
impl PendingCiphertexts
Sourcepub fn new(max_frames: usize, max_bytes: usize) -> Self
pub fn new(max_frames: usize, max_bytes: usize) -> Self
A store of at most max_frames ciphertexts and max_bytes bytes (ciphertext plus
metadata).
Sourcepub fn push(
&mut self,
metadata: &[u8],
ciphertext: &[u8],
) -> Result<Option<u64>>
pub fn push( &mut self, metadata: &[u8], ciphertext: &[u8], ) -> Result<Option<u64>>
Keeps ciphertext and its metadata under the KID of its header, dropping the oldest
entries if the bounds require it. Returns the KID, or None when the ciphertext alone
exceeds the bounds and was not kept.
Fails when the header does not parse: such a ciphertext can never be decrypted.
Sourcepub fn take(&mut self, kid: u64) -> Vec<PendingCiphertext>
pub fn take(&mut self, kid: u64) -> Vec<PendingCiphertext>
Removes and returns the ciphertexts waiting for kid, oldest first: call it when the
key for kid has been added, and decrypt each.
Sourcepub fn discard_oldest(&mut self, count: usize)
pub fn discard_oldest(&mut self, count: usize)
Drops the count oldest ciphertexts.