Symmetric file encryption tool, targeting 512 bits of security with memory-hard password hashing.
This software aims to provide strong symmetric cryptographic security for protecting important data. Both CLI and GUI interfaces are provided.
Version 0.2.0 of 4crypt is synchronized with version 0.2.0 of tsc, whose multi-block Skein512 output generation has changed. As a result, the on-disk file format has changed: the magic bytes leading every 4crypt-encrypted file are now [0x2F, 0x25, 0xC9, 0x4A] (previously [0xE2, 0x2A, 0x1E, 0x9B]), and the key derivation and pseudorandom byte streams differ from all earlier releases.
Files encrypted with any earlier version of 4crypt cannot be decrypted with version 0.2.0 or later, and will be rejected. If you have important data encrypted with an earlier version, decrypt it with the old version and re-encrypt it with version 0.2.0 before upgrading.
In addition to password-based encryption, 4crypt can now encrypt and decrypt files with raw
64-byte symmetric keys. Supply a key interactively with -K/--use-key (entered as 128
hexadecimal characters), or read one from a file with --key-file=<filepath>. Key files may hold
the key as 128 hexadecimal characters (with an optional "0x" prefix and surrounding whitespace),
or as the 64 raw bytes of the key itself. Key files should be stored with restrictive permissions
(e.g. chmod 600), since any reader of the key file can decrypt the data.
Mirroring the password pathway, the 64-byte key is hashed into 1024 bits with Skein512; the first 512 bits are used as the secret key for Threefish512 in Counter Mode for confidentiality, and the latter 512 bits are used as the secret key for Skein512's native Message Authentication Code.
Files encrypted with a raw symmetric key set bit 1 of the header's flags byte (offset 7), with all Key Derivation Function parameter fields set to zero. Password-encrypted files remain fully compatible with 4crypt 0.3.0 in both directions; raw-key files do not, because 0.3.0 stored the key mode in its own header field, which is reserved (all zero) in the current format.
- SSC header and library files.
- tsc_c header and library files. The file
encryption format itself is implemented inside libTSC's
filecryptmodule, so tsc_c must be a recent version that providesTSC/Filecrypt.hand theTSC_Filecrypt_*procedures.
- ncurses header and library files.
- Windows Vista/Server 2008 or later.
- Visual Studio 2019 development suite or later.
- Build and install SSC.
- Build and install tsc_c.
- cmake -S . -B ${BUILD_DIR}
- cd ${BUILD_DIR}
- make -j${NPROC}
The three most significant algorithms utilized in this project include:
- The Threefish512 block cipher.
- The Skein512 cryptographic hash function.
- A customized implementation of the CATENA password scrambling framework.
All three, along with the entire on-disk file format (header layout, Counter Mode
encipherment, padding, and Message Authentication Code), are implemented inside 4crypt's
dependency tsc and exposed to this program through
libTSC's TSC_Filecrypt_* C API. 4crypt gathers the user's credentials and parameters,
and delegates the file operations themselves to libTSC.
User supplied passwords are scrambled using CATENA and then hashed into two 512 bit keys; the first is used as the secret key for Threefish512 in Counter Mode for confidentiality; the second is used as the secret key for Skein512's native Message Authentication Code, which is appended to the end of encrypted files for authentication and integrity verification.
The beginning of every 4crypt-encrypted file is a header, consisting of:
- The magic bytes [0x2F, 0x25, 0xC9, 0x4A] to uniquely identify 4crypt-encrypted files.
- 4 bytes encoding:
- The Lower Memory Bound of the Key Derivation Function, CATENA.
- The Upper Memory Bound of the Key Derivation Function, CATENA.
- The Iteration Count of the Key Derivation Function, CATENA.
- A flags byte: bit 0 selects "Phi" and Sequential Memory Hardness (discussed later), bit 1 selects raw-key mode, and the remaining bits are reserved (currently always zero).
- 64 bit, little endian encoded unsigned integer describing the total size of the file.
- 128 pseudorandom bits utilized as a Threefish512 tweak for Threefish in Counter Mode.
- 256 pseudorandom bits utilized as a cryptographic salt for CATENA (all zeros for raw-key files, which do not use it).
- 256 pseudorandom bits utilized as an initialization vector for Threefish in Counter Mode.
- 64 bit, little endian encoded unsigned integer describing the thread count for CATENA.
- 64 reserved bits (formerly the key-mode field), currently always all zero.
- 64 bit, Threefish512-CTR enciphered, little endian encoded unsigned integer describing the total number of padding bytes.
- 64 Threefish512-CTR enciphered reserved bits. Currently the plaintext is always all zero.
All 4crypt-encrypted files are evenly divisible into 64 byte blocks; i.e. the payload of the file plus the metadata of the file header, the MAC appenended to the end, and the padding bytes always evenly divides by 64 bytes.



