Skip to main content

Module crypt

Module crypt 

Source
Expand description

The core of this program. Encrypt/decrypt, compress/decompress files.

GITSE Binary Header Layout (64 Bytes) 00 04 05 06 07 17 2F 3F +———–+—+—+—+———–+—————––+—————+ | MAGIC | V | F | A | SALT | NONCE | RESERVED | | “GITSE” | | | | (16 bytes)| (24 bytes) | (16 bytes) | +———–+—+—+—+———–+—————––+—————+ 5 bytes 1 1 1 16 bytes 24 bytes 16 bytes | | | Version —+ | +— Encryption Algo (1 = XChaCha20-Poly1305 Stream) | Flags ––––+ (Bit 0: Compression)

Streaming Format: Files are processed in 64KB chunks to prevent OOM on large files. Each chunk is individually encrypted using XChaCha20-Poly1305. The nonce for chunk i is derived by XORing the last 8 bytes of the base nonce with i.

Structs§

FileHeader

Functions§

decrypt_file
Decrypt a single file using streaming chunked decryption.
decrypt_file_with_cache
Decrypt a single file using streaming chunked decryption, with a thread-safe cache for derived keys.
decrypt_repo
Decrypt given files in the repo. If no paths are given, decrypt all files in the repo’s crypt list.
encrypt_file
Encrypt a single file using streaming chunked encryption.
encrypt_repo
Encrypt given files in the repo. If no paths are given, encrypt all files in the repo’s crypt list.