|
| 1 | +## ChaChaCrypt |
| 2 | + |
| 3 | +A small command line utility to encrypt and decrypt files with XChaCha20-Poly1305 written in Go. |
| 4 | + |
| 5 | +### Usage |
| 6 | +```text |
| 7 | +ccc_encrypt.exe "file.txt" |
| 8 | +ccc_decrypt.exe "file.txt.ccc" |
| 9 | +
|
| 10 | +ccc_encrypt.exe -m 1024 "file.txt" "file2.txt" <...> |
| 11 | +ccc_encrypt.exe -m 128 -t 8 -i 1 "file.txt" |
| 12 | +``` |
| 13 | + |
| 14 | +### Command Line Arguments |
| 15 | +```text |
| 16 | +-m <1-65535> | Argon2id Memory Usage in MiB | Default: 64MiB |
| 17 | +-t <1-255> | Argon2id Thread Count | Default: 4 |
| 18 | +-i <1-255> | Argon2id Iteration Count | Default: 4 |
| 19 | +``` |
| 20 | + |
| 21 | +### Information |
| 22 | +Files are encrypted in chunks, using the memory size specified for Argon2id to define the chunk size. |
| 23 | + |
| 24 | +For example, if using the default Argon2id memory of 64MiB, each 64 MiB chunk of the file is encrypted with its own |
| 25 | +nonce. |
| 26 | + |
| 27 | +This is done to keep memory usage of the program down, as for AEAD all bytes being encrypted need to be in memory. It's |
| 28 | +a safe assumption then that if the user uses 4GiB for key derivation, they have the RAM required to read and encrypt |
| 29 | +4GiB chunks of data at a time. |
| 30 | + |
| 31 | +### CCC File Format |
| 32 | +Each CCC file contains a 24 byte header. |
| 33 | + |
| 34 | +| Magic Number | Argon2id Memory Usage (in MiB) | Argon2id Thread Count | Argon2id Iteration Count | Argon2id Salt | |
| 35 | +|--------------|--------------------------------|-----------------------|--------------------------|---------------| |
| 36 | +| 4 Bytes | 2 Bytes | 1 Byte | 1 Byte | 16 Bytes | |
| 37 | + |
| 38 | +Each chunk has a 1 byte status flag, to indicate if it is the last chunk of the file. |
| 39 | + |
| 40 | +As the chunk size is derived from |
| 41 | +Argon2id memory usage, the chunk's size isn't stored. If the chunk is the last chunk, the rest of the file is read. |
| 42 | + |
| 43 | +|Status Byte|File Data| |
| 44 | +|---|---| |
| 45 | +|1 Byte|Variable Bytes| |
0 commit comments