This project implements the XChaCha20-Blake2b in the synthetic IV constructions (MAC-then-encrypt) autheticated encryption construction with extended 192-bit nonce.
- Run
go get -u github.com/danielhavir/xchacha20blake2b
package main
import (
"fmt"
"crypto/rand"
xchacha20blake2b "github.com/danielhavir/xchacha20blake2b"
)
func main() {
// message
msg := ...
// additional data
aad := ...
// key must be 64 bytes long
key := ...
// create the AEAD
cphr, err := xchacha20blake2b.New(key)
if err != nil {
panic(err)
}
// Encrypt
ct := cphr.Seal(nil, nil, msg, aad)
// Decrypt
pt, err := cphr.Open(nil, nil, ct, aad)
if err != nil {
panic(err)
}
if !bytes.Equal(msg, pt) {
panic("plaintexts do not match")
}
}
- Go crypto blake2b package
- Andreas Auernhammer, Go chacha20 package