pub trait Schedule<T>: Send + Sync {
// Required methods
fn chunk(
&self,
index: u64,
fun: &mut dyn FnMut(&SessionKey, &[u8], &[u8]) -> Result<T>,
) -> Result<T>;
fn finalizer(
&self,
index: u64,
length: u64,
fun: &mut dyn FnMut(&SessionKey, &[u8], &[u8]) -> Result<T>,
) -> Result<T>;
}Expand description
Schedules key, nonce, and additional authenticated data (AAD) for use with chunked AEAD encryption.
Required Methods§
Sourcefn chunk(
&self,
index: u64,
fun: &mut dyn FnMut(&SessionKey, &[u8], &[u8]) -> Result<T>,
) -> Result<T>
fn chunk( &self, index: u64, fun: &mut dyn FnMut(&SessionKey, &[u8], &[u8]) -> Result<T>, ) -> Result<T>
Computes key, nonce, and AAD for a chunk.
For every chunk, implementations must produce a key, a nonce,
and the additional authenticated data (AAD), then invoke fun
with key, nonce, and AAD.
index is the current chunk index.
Sourcefn finalizer(
&self,
index: u64,
length: u64,
fun: &mut dyn FnMut(&SessionKey, &[u8], &[u8]) -> Result<T>,
) -> Result<T>
fn finalizer( &self, index: u64, length: u64, fun: &mut dyn FnMut(&SessionKey, &[u8], &[u8]) -> Result<T>, ) -> Result<T>
Computes key, nonce, and AAD for the final authentication tag.
When doing chunked AEAD, we need to protect against truncation of the chunked stream. In OpenPGP this is done by adding a final empty chunk that includes the length of the stream in the additional authenticated data (AAD).
Implementations must produce a key, a nonce, and the AAD
(which SHOULD include the length of the stream), then invoke
fun with key, nonce, and AAD.
index is the current chunk index. length is the total
length of the stream.