Skip to main content

Crate enchantress

Crate enchantress 

Source

Constants§

MAGIC
There are two arbitrary consants of sufficient length (46 bytes) used as fixed salts. One of them is a “public const” named “MAGIC”, while the other is a private constant used within this module named “ENCHA”.

Functions§

a2
Generate key material with two rounds of Argon2id. The first round is based on the password and supplied salt. The second round is the output of the first round and the “ENCHA” salt.
aead_decrypt_file
Decrypt a file with AES-256 in GCM mode.
aead_decrypt_stdout
Decrypt a file to STDOUT with AES-256 in GCM mode. The output is any UTF-8 data. If the data is non-UTF-8, decrypt to a file instead with the aead_decrypt_file function.
aead_encrypt_file
Encrypt a file with AES-256 in GCM mode.
checks
This “checks” function is a string comparison function to ensure that the ciphertext hasn’t been tampered with and that the key material is correct. Supply the function with two hashes generated from the ciphertext_hash function.
ciphertext_hash
This function generates a SHA3 XOF with SHAKE 256. The XOF (hash) has input of the password and the ciphertext so that if either the password is incorrect or the ciphertext has been modified, the value will change.
decrypt_file
Decrypt a file with AES-256 in CTR mode. The nonce is read from the first 16 bytes of the file.
decrypt_stdout
Decrypt a file to STDOUT in AES-256 in CTR mode. The output is any UTF-8 data. If the data is non-UTF-8, decrypt to a file instead with the decrypt_file function.
encrypt_file
Encrypt a file with AES-256 in CTR mode. The function takes an input file, and output, and key to use for the encryption. A nonce is generated using the generate_nonce function. With the nonce generation built in, this function ensures that a nonce is not used twice.
generate_nonce
Generate a 16 byte nonces for AES-256 with eight bytes of a nanosecond timestamp and 8 bytes of appended random bytes.