SIV-AES (rfc5297) implementation for Golang.
SIV was proposed by Phil Rogaway and Thomas Shrimpton. Synthetic Initialization Vector (SIV) Authenticated Encryption Using the Advanced Encryption Standard (AES) was proposed as a nonce-reuse misuse resistant Deterministic Authenticated Encryption mechanism in rfc5297.
- Import siv into your source
go get github.com/ChandraNarreddy/siv
import "github.com/ChandraNarreddy/siv"
- Create a Blockpair as -
pair, _ := siv.NewAesSIVBlockPair(key)
where key can be 256, 384 or 512 bit sized []byte array
- Initialize SIV as -
siv, _ := siv.NewSIV(pair)
- Wrap plaintext and additionalData using -
plainBytes := []byte(plainText)
additionalDataBytes := [][]byte{[]byte("first additional data"), []byte("second additional data")}
cipherBytes, _ := siv.Wrap(plainBytes, additionalDataBytes...)
- Unwrap encrypted bytes -
plainBytes, failure := siv.Unwrap(cipherBytes, additionalDataBytes...)
if failure != nil {
//Unwrap failed because of wrong {cipherBytes, additionalDataBytes... and key) combination
} else {
//do what you want to do with plainBytes here
}
Chandrakanth Narreddy
Please submit issues for suggestions. Pull requests are welcome too.
MIT License
- Andreas Auernhammer for CMAC