1 Output format is very simple:
3 * "GOHPENC\n" magic string
4 * 32-bit big-endian block length
7 /-------BLOCK---------\ /-------BLOCK---------\
8 +-------+----------+------+------------+----------+------------+----------+----
9 | MAGIC | BLOCKLEN | SALT | CIPHERTEXT | AUTH TAG | CIPHERTEXT | AUTH TAG | ...
10 +-------+----------+------+------------+----------+------------+----------+----
12 There is trivial key generation:
13 keyOrdinary, keyLast = HKDF(SHA512, keySpecified, SALT, AD=MAGIC)
15 Each block is encrypted with ChaCha20-Poly1305, using keyOrdinary and
16 nonce containing 64-bit big-endian counter, starting at zero. Very last
17 block is encrypted with keyLast and it may have zero length plaintext.