mirror of
https://github.com/HACKERALERT/Picocrypt.git
synced 2024-12-29 19:02:43 +00:00
Update Internals.md
This commit is contained in:
parent
2ab69c07c0
commit
6dfa1276d8
1 changed files with 7 additions and 15 deletions
22
Internals.md
22
Internals.md
|
@ -1,19 +1,11 @@
|
|||
# Internals
|
||||
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 file format.
|
||||
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.
|
||||
|
||||
# Core Cryptography
|
||||
## Encryption
|
||||
Picocrypt uses the following algorithms for encryption:
|
||||
- XChaCha20-Poly1305 (IETF variant)
|
||||
- SHA3
|
||||
- Argon2id
|
||||
Picocrypt uses the following cryptographic primitives:
|
||||
- XChaCha20 (cascaded with Serpent for paranoid mode)
|
||||
- HMAC-SHA3 for normal mode, keyed-BLAKE2b for fast mode (512 bits)
|
||||
- HKDF-SHA3 for deriving a subkey used with the MAC above
|
||||
- Argon2id (8 passes, 1 GiB memory, 8 threads) for normal mode, (4 passes, 128 MiB memory, 4 threads) for fast mode
|
||||
|
||||
The first is provided by <a href="https://monocypher.org">Monocypher</a>, a library that has been <a href="https://monocypher.org/quality-assurance/audit">audited</a> by Cure53. To bind Picocrypt (written in Go) to Monocypher (written in C), I created a binding called <a href="https://github.com/HACKERALERT/Monocypher-GO">Monocypher-Go</a>. For SHA3, Picocrypt uses Go's built-in `golang.org/x/crypto/sha3`. For Argon2id, Picocrypt also uses Go's built-in `golang.org/x/crypto/argon2`.
|
||||
|
||||
### Here's how encryption works:
|
||||
- A master key is generated by hashing the user's password using Argon2id. If fast mode is enabled, Picocrypt uses Argon2id with 4 passes, 128 MiB of memory, and 4 threads. If fast mode is not enabled, Picocrypt uses 8 passes, 1 GiB of memory, and 8 threads.
|
||||
- A SHA3-512 hash of the master key is generated and stored. This is used to let the user know if their password is correct. Note that this is a hash of the <i>derived</i> key, so it cannot be bruteforced.
|
||||
- Encryption occurs in 1 MiB chunks (1048576 bytes). For each chunk, a 24-byte nonce is generated using Go's `crypto/rand`. The nonce is then appended to a list. The chunk is encrypted with the master key and the unique nonce. The Poly1305 tag is obtained after encryption and is appended to the chunk before the chunk is written to file.
|
||||
- When all the chunks have been encrypted, the list of nonces is encrypted using the master key and written to the file. This is done to prevent the nonces from being reordered.
|
||||
|
||||
# This is a work in progress...
|
||||
All algorithms used are from the well-known golang.org/x/crypto module.
|
||||
|
|
Loading…
Reference in a new issue