diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-11 11:43:11 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-11 11:43:11 -0800 |
| commit | 3b1839e979b843ed5c305970d3e5c61816f06a31 (patch) | |
| tree | d1c8fc7aae799e5d2643fd37b2a9be75f5fb7f11 /oae.go | |
| parent | bd8bb1246cdad558fca64fdcf6af343905746e29 (diff) | |
| download | sym-main.tar.zst | |
Diffstat (limited to 'oae.go')
| -rw-r--r-- | oae.go | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,5 +1,16 @@ package main +// This file is based on the influential paper +// [Online Authenticated-Encryption and its Nonce-Reuse Misuse-Resistance]. +// It encrypts a stream of data in 1MiB segments using ChaCha20-Poly1305 +// to encrypt each segment. The nonce is a 12 byte value, the first 11 +// bytes of which are a counter that gets incremented for each segment, +// and the last byte is 0 for every segment except the last segment +// (where it is 1). Before the encrypted segments, it writes a 32 byte +// header containing the salt for the password hash. +// +// [Online Authenticated-Encryption and its Nonce-Reuse Misuse-Resistance]: https://eprint.iacr.org/2015/189.pdf + import ( "bufio" "bytes" @@ -39,7 +50,7 @@ func (se *segmentEncrypter) nextNonce(lastSegment bool) { // Increment counter for i := 0; ; i++ { if i == len(se.nonce)-1 { - panic("counter overflowed") + panic("counter overflowed") // impossible, 11 bytes } se.nonce[i]++ if se.nonce[i] != 0 { |
