Skip to main content

encrypt_asset_rekey_stream

Function encrypt_asset_rekey_stream 

Source
pub fn encrypt_asset_rekey_stream<R: Read, W: Write>(
    amk: &Amk,
    file_id: &Uuid,
    reader: R,
    writer: W,
    replaces: Option<[u8; 7]>,
) -> Result<(AssetEncryption, [u8; 32]), RekeyStreamError>
Expand description

encrypt_asset_rekey from a reader to a writer, one STREAM chunk at a time: the same prefix draw, key fold and reuse refusal, without the plaintext or the ciphertext ever being whole in memory. Returns the AssetEncryption metadata (whose ciphertext_hash is computed as the chunks pass) and the derived file key.

This is how an original of any size is imported: the writer may be std::io::sink, since the ciphertext is re-derivable from the plaintext and the recorded prefix.