enchive/README.md

104 lines
3.8 KiB
Markdown
Raw Normal View History

2017-03-03 20:06:43 +01:00
# Enchive : encrypted personal archives
2017-03-03 20:04:41 +01:00
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
2017-03-04 01:36:32 +01:00
is very easy to build for local use. Portability is emphasized over
performance.
2017-03-03 20:04:41 +01:00
2017-03-04 18:02:13 +01:00
Supported platforms: Linux, BSD, macOS, Windows
2017-03-04 01:36:32 +01:00
Files are secured with uses ChaCha20, Curve25519, and SHA-256.
2017-03-03 20:04:41 +01:00
## Usage
There are only three commands to worry about: `keygen`, `archive`, and
`extract`. The very first thing to do is generate a master keypair
2017-03-04 17:44:31 +01:00
using `keygen`. You will be prompted for the passphrase to protect the
secret key, just like `ssh-keygen`.
2017-03-03 20:04:41 +01:00
$ 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:
2017-03-04 17:44:31 +01:00
$ enchive archive sensitive.zip
2017-03-03 20:04:41 +01:00
2017-03-04 17:44:31 +01:00
This will encrypt `sensitive.zip` as `sensitive.zip.enchive` (leaving
the original in place). You can safely archive this wherever.
2017-03-03 20:04:41 +01:00
2017-03-04 17:44:31 +01:00
To extract the file on a machine with `.encrypt.sec`, use `extract`.
It will prompt for the passphrase you entered during key generation.
2017-03-03 20:04:41 +01:00
2017-03-04 17:44:31 +01:00
$ enchive extract sensitive.zip.enchive
2017-03-03 20:04:41 +01:00
2017-03-04 17:44:31 +01:00
The original `sensitive.zip` will be reproduced.
2017-03-03 20:07:47 +01:00
2017-03-04 01:36:32 +01:00
With no filenames, `archive` and `extract` operate on standard input
and output.
2017-03-04 17:44:31 +01:00
### 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.
2017-03-05 21:51:38 +01:00
Enchive has a built-in protection key agent that keeps the protection
key in memory for a configurable period of time (default: 15 minutes)
after a protection passphrase has been read. This allows any files to
be decrypted inside this window with only a single passphrase prompt.
Use the `--agent` (`-a`) global option to enable it. If it's enabled
by default, use `--no-agent` to turn it off.
$ enchive --agent extract file.enchive
Unlike gpg-agent and ssh-agent, this agent need not be started ahead
of time. It is started on demand, shuts down on timeout, and does not
coordinate with environment variables. One agent is created per unique
secret key file. This feature requires a unix-like system.
2017-03-03 20:07:47 +01:00
## Notes
2017-03-04 01:36:32 +01:00
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.
2017-03-03 20:48:59 +01:00
## 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.
5. Initialize ChaCha20 with the shared secret as the key.
4. Write the 8-byte IV.
5. Write the 32-byte ephemeral public key.
6. Encrypt the file with ChaCha20 and write the ciphertext.
2017-03-03 22:15:09 +01:00
7. Write `sha256(key + sha256(plaintext))`.
2017-03-03 20:48:59 +01:00
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.
2017-03-03 22:15:09 +01:00
6. Verify `sha256(key + sha256(plaintext))`.