Go to file
Christopher Wellons ab4206a02f Make it more configurable at compile time. 2017-03-05 13:31:20 -05:00
.gitignore Add amalgamation build. 2017-03-05 12:54:57 -05:00
Makefile Improved amalgamation. 2017-03-05 13:03:20 -05:00
README.md Update README. 2017-03-04 12:02:41 -05:00
UNLICENSE Fix some modes. 2017-03-03 20:54:54 -05:00
chacha.c Tidy up. 2017-03-03 10:42:55 -05:00
chacha.h Add amalgamation build. 2017-03-05 12:54:57 -05:00
config.h Make it more configurable at compile time. 2017-03-05 13:31:20 -05:00
curve25519-donna.c Add amalgamation build. 2017-03-05 12:54:57 -05:00
docs.h Make it more configurable at compile time. 2017-03-05 13:31:20 -05:00
enchive.c Make it more configurable at compile time. 2017-03-05 13:31:20 -05:00
optparse.h Working stuff. 2017-03-03 10:28:45 -05:00
sha256.c Fix incorrect include in sha256.c. 2017-03-04 11:59:13 -05:00
sha256.h Add amalgamation build. 2017-03-05 12:54:57 -05:00

README.md

Enchive : encrypted personal archives

Enchive is a tool encrypts files to yourself for long-term archival. It's intended as a focused, simple alternative to more complex solutions such as GnuPG. This program has no external dependencies and is very easy to build for local use. Portability is emphasized over performance.

Supported platforms: Linux, BSD, macOS, Windows

Files are secured with uses ChaCha20, Curve25519, and SHA-256.

Usage

There are only three commands to worry about: keygen, archive, and extract. The very first thing to do is generate a master keypair using keygen. You will be prompted for the passphrase to protect the secret key, just like ssh-keygen.

$ enchive keygen

By default, this will create two files in your home directory: .enchive.pub (public key) and .enchive.sec (secret key). Distribute .enchive.pub to any machines where you plan to archive files. It's sufficient to encrypt files, but not to decrypt them.

To archive a file for storage:

$ enchive archive sensitive.zip

This will encrypt sensitive.zip as sensitive.zip.enchive (leaving the original in place). You can safely archive this wherever.

To extract the file on a machine with .encrypt.sec, use extract. It will prompt for the passphrase you entered during key generation.

$ enchive extract sensitive.zip.enchive

The original sensitive.zip will be reproduced.

With no filenames, archive and extract operate on standard input and output.

Key management

One of the core features of Enchive is the ability to derive an asymmetric key pair from a passphrase. This means you can store your archive key in your brain! To access this feature, use the --derive (-d) option with the keygen command.

$ enchive keygen --derive

There's an optional argument to --derive that controls the number of key derivation iterations (e.g. --derive=26). The default is 24. This is a power two exponent, so every increment doubles the cost.

If you want to change your protection passphrase, use the --edit option with keygen. It will load the secret key as if it were going to "extract" an archive, then write it back out with the new options. This mode will also regenerate the public key file.

Notes

There's no effort at error recovery. It bails out on early on the first error. It should clean up any incomplete files when it does so.

Format

The process for encrypting a file:

  1. Generate an ephemeral 256-bit Curve25519 key pair.
  2. Perform a Curve25519 Diffie-Hellman key exchange with the master key to produce a shared secret.
  3. Generate a 64-bit IV for ChaCha20.
  4. Initialize ChaCha20 with the shared secret as the key.
  5. Write the 8-byte IV.
  6. Write the 32-byte ephemeral public key.
  7. Encrypt the file with ChaCha20 and write the ciphertext.
  8. Write sha256(key + sha256(plaintext)).

The process for decrypting a file:

  1. Read the 8-byte ChaCha20 IV.
  2. Read the 32-byte ephemeral public key
  3. Perform a Curve25519 Diffie-Hellman key exchange with the ephemeral public key.
  4. Initialize ChaCha20 with the shared secret as the key.
  5. Decrypt the ciphertext using ChaCha20.
  6. Verify sha256(key + sha256(plaintext)).

Roadmap

  • Decrypt multiple files in a short period: some kind of key agent?
  • Improve key generation.