grain

package
v1.0.2065 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package grain implements the Grain128-AEAD cipher.

Performance

For 1 KiB plaintext, this implementation runs at about 40-50 cycles per byte (tested on a 2020 MacBook Air M1 @ 3.2Ghz and a 2019 Macbook Pro i7 @ 2.6Ghz). This is roughly equivalent to the optimized C implementation [m1,x86].

This implementation runs at about

References:

[grain]: https://grain-128aead.github.io/
[m1]: https://gist.github.com/ericlagergren/645eb97a05efd37152d6f1cfa9cf9d4a
[x86]: https://gist.github.com/elagergren-spideroak/4bd31a59925de3b19227d4ae80b55cf0

Index

Constants

View Source
const (
	// BlockSize is the size in bytes of an Grain128-AEAD block.
	BlockSize = 16
	// KeySize is the size in bytes of an Grain128-AEAD key.
	KeySize = 16
	// NonceSize is the size in bytes of an Grain128-AEAD nonce.
	NonceSize = 12
	// TagSize is the size in bytes of an Grain128-AEAD
	// authenticator.
	TagSize = 8
)

Variables

This section is empty.

Functions

func New

func New(key []byte) (cipher.AEAD, error)

New creates a 128-bit Grain128-AEAD AEAD.

Grain128-AEAD must not be used to encrypt more than 2^80 bits per key, nonce pair, including additional authenticated data.

func NewUnauthenticated

func NewUnauthenticated(key, nonce []byte) (cipher.Stream, error)

NewUnauthenticated creates a Grain128a stream cipher.

Grain128a must not be used to encrypt more than 2^80 bits per key, nonce pair.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL