Expand description
Attachment AES-256-GCM over a file, a chunk at a time: the cipher of
super::decrypt_data (16-byte nonce, 16-byte tag appended) without the file
ever sitting whole in memory.
GCM is CTR encryption plus a GHASH over the ciphertext, and both run incrementally. The catch is that the tag only speaks at the end, so plaintext is written to a file the caller keeps out of sight until this returns Ok.
Structs§
- Streamed
File - What one pass over a downloaded file learned.
Constants§
- CANCELLED
- What a pass stopped by its caller returns.
- CHANGED
- What a send says when its file changed between being hashed and being sealed.
- TAG_
MISMATCH - What opening says when the bytes aren’t the ones sealed under that key.
Functions§
- decrypt_
file - Decrypt
src(ciphertext || tag) intodst, hashing both sides on the way.dstholds unauthenticated plaintext until this returns: on any error it is removed, and a tag mismatch is reported as a decryption failure. - decrypt_
file_ with_ progress decrypt_file, tellingprogresseach new whole percentage of the file opened.progressanswering false stops the pass, as forencrypt_file_with_progress.- encrypt_
file - Encrypt
srcintodst(ciphertext || tag), the counterpart ofdecrypt_file. Returns the SHA-256 and length of what was written: the blob a server will hold. - encrypt_
file_ matching encrypt_file_with_progressfor a file the sender may still change: the bytes sealed must be the ones hashed asplain_sha256, or nothing is written and the send says so.- encrypt_
file_ with_ progress encrypt_file, tellingprogresseach new whole percentage of the file sealed.progressanswering false stops the pass: nothing is written and the error says it was cancelled.- hash_
file - SHA-256 of a file, read a chunk at a time.
- place_
download - Put a verified download into the download directory under
name: an identical file already there (same name, size and hash) is reused andsrcdropped; otherwisesrcmoves to a free spelling of the name. Returns where it landed. - verify_
file - What
decrypt_filelearns aboutsrc, with no plaintext written anywhere: the tag verdict, both hashes and the length. For ciphertext that stays ciphertext on disk. - verify_
file_ with_ progress verify_file, reporting progress asdecrypt_file_with_progressdoes.