Picocrypt/Internals.md

22 lines
1.9 KiB
Markdown
Raw Normal View History

2021-05-30 20:50:03 +02:00
# Internals
2021-08-08 00:05:38 +02:00
If you're wondering about how Picocrypt handles cryptography, you've come to the right place! This page contains the technical details about the cryptographic algorithms and parameters used. This page does not go in-depth, as you can just review the source (there's only one file) to understand the nitty-gritty details.
2021-05-30 20:50:03 +02:00
# Core Cryptography
2021-08-08 00:05:38 +02:00
Picocrypt uses the following cryptographic primitives:
2021-09-05 01:05:17 +02:00
- XChaCha20 (cascaded with Serpent-CTR for paranoid mode)
- HMAC-SHA3 for normal annd paranoid mode, keyed-BLAKE2b for fast mode (256-bit key, 512-bit digest)
- HKDF-SHA3-256 for deriving a subkey used with the MAC above, as well as a key for Serpent
- Argon2id:
- Fast mode: 4 passes, 128 MiB memory, 4 threads
- Normal mode: 4 passes, 1 GiB memory, 4 threads
- Paranoid mode: 8 passes, 1 GiB memory, 8 threads
2021-05-30 20:50:03 +02:00
2021-08-13 17:59:04 +02:00
All primitives used are from the well-known golang.org/x/crypto module.
2021-09-05 01:05:17 +02:00
# Keyfile Design
Picocrypt allows the use of keyfiles as an additional (or only) form of authentication. Picocrypt's unique "Require correct order" feature enforces the user to drop keyfiles into the window in the exact same order as he/she did when encrypting, in order to decrypt the volume successfully. Here's how it works:
If "Require correct order" is not checked, Picocrypt will take the SHA3 hash of each file individually, and XORs the hashes together. Finally, the result is XORed to the master key. Because the XOR operation is both commutative and associative, the order in which the keyfiles hashes are XORed to each other doesn't matter -- the end result is the same.
If "Require correct order" is checked, Picocrypt will combine (concatenate) the files together in the order they were dropped into the window, and take the SHA3 hash of combined keyfiles. If the order is not correct, the keyfiles, when appended to each other, will result in a different file, and therefore a different hash. Thus, the correct order of keyfiles has been enforced.