]> Cypherpunks.ru repositories - gohpenc.git/blob - README
/dev/zero encryption is not an option
[gohpenc.git] / README
1 Go high-performance encryption utility.
2
3 gohpenc highly resembles hpenc tool (https://github.com/vstakhov/hpenc).
4
5 Why it was written? hpenc has some problems: it does not work on aarch64
6 and sparc64 architectures under FreeBSD (as seen in the port's Makefile)
7 and produces incompatible output (unauthenticated after 8192 blocks)
8 between FreeBSD and HardenedBSD systems somehow. Instead of painful
9 debugging I decided to write something similar on the Go language,
10 widening supported platforms.
11
12 gohpenc is incompatible with hpenc and much simpler:
13
14 * it uses only ChaCha20-Poly1305 algorithm
15 * no random data generation mode
16 * no metadata in output stream and no structure validation. Only blocks
17   authentication
18 * simpler key derivation -- new key for each block
19
20 But it still satisfies most of hpenc aims:
21
22 * Very simple key management -- single pre-shared key
23 * Parallelizeable -- each block is encrypted in different thread, so all
24   your CPUs could be utilized
25 * Very fast -- ChaCha20-Poly1305 is fast even on relatively low-end
26   devices like mobile devices. Despite gohpenc is written on Go, its
27   dependent libraries contain assembly-optimized code
28 * Built-in authentication and integrity check with small data overhead
29
30 How encryption/authentication is performed:
31
32 * First 32 bytes of the stream contains random data, called salt
33 * BLAKE2X is initialized: unknown length, PSK key as a MAC key. It
34   creates XOF that will be used as a KDF
35 * Salt is fed into that XOF
36 * All data is processed block by block
37 * New key is derived for each block by reading it from the XOF
38 * ChaCha20-Poly1305 algorithm is initialized with that key
39 * 32-bit big-endian value with the length of the block is outputted,
40   then an encrypted and authenticated block goes further, with
41   authenticated data containing that 32-bit length value
42
43        /----------BLOCK-------------\ /----------BLOCK------------\
44 +------+-----+------------+----------+-----+------------+----------+----
45 | SALT | LEN | CIPHERTEXT | AUTH TAG | LEN | CIPHERTEXT | AUTH TAG | ...
46 +------+-----+------------+----------+-----+------------+----------+----
47
48 gohpenc preallocates memory for one block for each thread. If you want
49 to process data with 1 MiB blocks in 4 threads, then you have to have at
50 least 4 MiBs of free memory. Moreover you have at least 1 MiB of free
51 memory on the decrypting side.
52
53 gohpenc is free software: see the file COPYING for copying conditions.