ASCON Suite
|
The asconcrypt
program in the apps
directory demonstrates how to use ASCON-80pq, ASCON-80pq-SIV, and ASCON-PBKDF2 to create a password-based file encryption and decryption utility. The incremental version of ASCON-80pq is used, which permits large files up to 1 terabyte in size to be encrypted.
ASCONcrypt is inspired AES Crypt which provides a simple password-based file encryption method using AES-256 in CBC mode. The file format for ASCONcrypt and the differences with AES Crypt are described below.
The program is installed by "make install" as part of the library build.
Files are encrypted by passing them directly to the asconcrypt
program. If the system supports it, the user will be prompted for a password and the file is then encrypted into a file with the ".ascon" file extension:
$ ls MySecretDocument.txt $ asconcrypt MySecretDocument.txt Password: Confirm Password: $ ls MySecretDocument.txt.ascon MySecretDocument.txt
The password can also be supplied on the command-line or in a "key file":
$ asconcrypt -p Hello MySecretDocument.txt $ asconcrypt -k key MySecretDocument.txt
Decrypting a file whose name ends in ".ascon" is similar:
$ ls MySecretDocument.txt.ascon $ asconcrypt MySecretDocument.txt.ascon Password: $ ls MySecretDocument.txt.ascon MySecretDocument.txt
In the examples above, the asconcrypt
command is able to detect whether to encrypt or decrypt based on the file extension. If the file extension is not clear, then use the "-e" or "-d" options to clarify whether encryption or decryption is required. The "-o" option can also be used to specify an explicit output file:
$ asconcrypt -d -o MySecretDocument.txt -p Hello MySecretDocument.bin
Key files consist of a single line of text with the password, so they are easy to create:
$ echo "This is a long password!" >key $ asconcrypt -k key MySecretDocument.txt
The asconcrypt
program can also generate a random 40 character password for you using the "-g" (generate) option:
$ asconcrypt -g key $ asconcrypt -k key MySecretDocument.txt $ cat key JqEm5mqJUt9mA0wvT3yaoR00knLNVXGD8cwEEpyk
Source code for the asconcrypt program
The ASCONcrypt file format was inspired in part by AES Crypt. That format has several sections of interest:
ASCONcrypt files contain the following sections:
The size of the input file will increase by 96 bytes when it is encrypted.
We don't support plaintext metadata in this format. It makes the decryption process complicated to skip arbitrary-sized metadata blocks. The only metadata item that "AES Crypt" seemed to support was a "CREATED_BY" tag for the name and version of the encryption software.
If metadata is important, then it should be placed into the encrypted payload or distributed separately.
The "SIV block" contains the key and nonce, encrypted with the password and salt. The block is formed as follows:
ASCON-PBKDF2(password, salt, 8192)
where k1 is 20 bytes in length and n1 is 16 bytes in length. The file's contents are encrypted with ASCON-80pq using the key k2 and the nonce n2. The associated data is the 52 bytes of the SIV block.
The SIV block "wraps" the actual encryption key and nonce. When the file is decrypted, the 16 byte authentication tag on the SIV block can be used to verify that the password is correct before attempting to decrypt the rest of the file.
The ASCON specification indicates that no more than 267 bytes of data should be encrypted under the same key with ASCON-80pq. For safety, the encryption process is aborted if more than 240 bytes or 1 terabyte are encountered. Larger files will need to be split into smaller sections.