descriptionA simple file encryption tool
ownerm@bitsnbites.eu
last changeSat, 4 May 2024 18:43:34 +0000 (4 20:43 +0200)
content tags
add:
README.md

ezcrypt

A tool for strong encryption of arbitrary files.

Features

Easy to use

Resistant against cryptanalytic attacks

Portable

Free, open source and public domain

All code is free and unencumbered software released into the public domain, including the cryptographic algorithms.

For more information, see unlicense.org.

Principles

ezcrypt file format

Encryption is done in four layers. At each level a different cipher is used, and each level has its own encyrption key and its own initialization vector (IV). The different ciphers are:

  1. AES, CBC, 256-bit key (outermost level)
  2. ChaCha, 20 rounds, 256-bit key
  3. Twofish, CBC, 256-bit key
  4. Serpent, CBC, 256-bit key (innermost level)

The key at each level is generated from a combination of the user supplied passphrase, an optional user supplied 256-bit pepper and a per-level 256-bit salt. This is done using a custom compute intensive key derivation function called ZKDF.

The salt and the IV for each encryption level is generated from system level entropy (i.e. highly random data), and is different for each run of ezcrypt. Thus encrypting the same file twice will result in two different ciphertexts (even if the same passphrase is used).

The pepper is the SHA2-256 hash of the contents of a user supplied pepper file (thus the pepper file can be any kind of file, even a binary file).

Note that the encrypted file does not contain any header or other identification metadata. This is by design.

Installation

Prerequisites: A C compiler and CMake.

To build:

mkdir out && cd out
cmake -DCMAKE_BUILD_TYPE=Release ../src
cmake --build .

The resulting executable file is out/ezcrypt.

To install:

sudo cmake --install .

To run the unit tests:

CTEST_OUTPUT_ON_FAILURE=ON cmake --build . -t test

Example usage

Encrypt a file

Encrypt the file myfile, with the passphrase provided via a terminal prompt. The output file is called myfile.z (the original file is kept):

$ ezcrypt myfile
Enter passphrase:
Again:

Decrypt a file

Decrypt the file myfile.z, with the passphrase provided via a terminal prompt. The output file is called myfile (the original file is kept):

$ ezcrypt -d myfile.z
Enter passphrase:

Decrypt and print a file

Decrypt the file myfile.z to stdout, with the passphrase provided via the environment variable $SECRET:

$ ezcrypt --show -E SECRET myfile.z

Encrypt & decrypt via pipes

$ echo "Hello world!" | ezcrypt -E SECRET | ezcrypt -d -E SECRET
Hello world!

Edit an encrypted text file

Edit the plaintext contents of the encrypted file myfile.z, using the default text editor (e.g. $EDITOR or notepad.exe):

$ ezcrypt --edit myfile.z

Note: If the plaintext is not modified by the editor, myfile.z remains unmodified. This is useful if you accidentally use the wrong passphrase (you will notice right away since the plaintext will appear as garbage), in which case you can just exit the editor.

shortlog
8 hours ago mBump version to 1.1.1masterv1.1.1
8 hours ago marguments.c: Better explain pepper files
8 hours ago mharden: Disable core dumps
17 hours ago mCMake: Simplify build requirements
17 hours ago mBump version to 1.1.0v1.1.0
17 hours ago mREADME: Mention pepper files
17 hours ago mezcrypt: Implement pepper file support
17 hours ago marguments: Add a --pepper-file (-P) option
37 hours ago mREADME: Add section about portability
38 hours ago mREADME: Clarify expression about keys vs passphrase...
39 hours ago mREADME: Fix a typo
40 hours ago mBump version to 1.0.0v1.0.0
40 hours ago mREADME: Some re-formatting
43 hours ago mbitsnbitesMerge pull request 'Various usability improvements...
43 hours ago mDisallow empty passphrase unless --allow-empty is given
43 hours ago mezcrypt.c: Improve message when no edits were made
...
tags
8 hours ago v1.1.1
17 hours ago v1.1.0
40 hours ago v1.0.0
3 weeks ago v0.18.6
14 months ago v0.18.5
14 months ago v0.18.4
14 months ago v0.18.3
14 months ago v0.18.2
14 months ago v0.17.0
14 months ago v0.18.1
14 months ago candidate-1
14 months ago v0.18.0
14 months ago v0.16.1
14 months ago v0.16.0
14 months ago v0.15.1
14 months ago v0.15.0
...
heads
8 hours ago master