danielhavir / xchacha20blake2b

Authenticated encryption scheme with XChaCha20, Blake2b in the synthethic IV construction.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Godoc Reference Build Status Go Report Card

AEAD: XChaCha20-Blake2b SIV

This project implements the XChaCha20-Blake2b in the synthetic IV constructions (MAC-then-encrypt) autheticated encryption construction with extended 192-bit nonce.

Install

  • Run go get -u github.com/danielhavir/xchacha20blake2b

Example

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")
    }
}

References

About

Authenticated encryption scheme with XChaCha20, Blake2b in the synthethic IV construction.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%