siv

package
v1.0.4001 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxAssociatedDataItems = 126

MaxAssociatedDataItems is the maximum number of associated data items

Variables

View Source
var (
	// ErrNotAuthentic indicates a ciphertext is malformed or corrupt
	ErrNotAuthentic = errors.New("siv: authentication failed")

	// ErrTooManyAssociatedDataItems indicates more than MaxAssociatedDataItems were given
	ErrTooManyAssociatedDataItems = errors.New("siv: too many associated data items")
)

Functions

func NewCMAC

func NewCMAC(macBlock, ctrBlock cipher.Block, nonceSize int) (cipher.AEAD, error)

NewCMAC returns an SIV instance implementing cipher.AEAD interface

Unless the given nonce size is less than zero, Seal and Open will panic when passed nonce of a different size.

func NewPMAC

func NewPMAC(macBlock, ctrBlock cipher.Block, nonceSize int) (cipher.AEAD, error)

NewPMAC returns an SIV instance implementing cipher.AEAD interface

Unless the given nonce size is less than zero, Seal and Open will panic when passed nonce of a different size.

func NewSiv

func NewSiv(macBlock, ctrBlock cipher.Block, nonceSize int) (cipher.AEAD, error)

NewSiv returns an SIV instance implementing cipher.AEAD interface

Types

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

Cipher is an instance of AES-SIV, configured with either AES-CMAC or AES-PMAC as a message authentication code.

func NewCMACCipher

func NewCMACCipher(macBlock, ctrBlock cipher.Block) (c *Cipher, err error)

NewCMACCipher returns a new SIV cipher.

func NewPMACCipher

func NewPMACCipher(macBlock, ctrBlock cipher.Block) (c *Cipher, err error)

NewPMACCipher returns a new SIV cipher.

func (*Cipher) Open

func (c *Cipher) Open(dst []byte, ciphertext []byte, data ...[]byte) ([]byte, error)

Open decrypts ciphertext, authenticates the decrypted plaintext and the given associated data items and, if successful, appends the resulting plaintext to dst, returning the updated slice. The additional data items must match the items passed to Seal.

The ciphertext and dst may alias exactly or not at all.

For nonce-based encryption, the nonce should be the last associated data item.

func (*Cipher) Overhead

func (c *Cipher) Overhead() int

Overhead returns the difference between plaintext and ciphertext lengths.

func (*Cipher) Seal

func (c *Cipher) Seal(dst []byte, plaintext []byte, data ...[]byte) ([]byte, error)

Seal encrypts and authenticates plaintext, authenticates the given associated data items, and appends the result to dst, returning the updated slice.

The plaintext and dst may alias exactly or not at all.

For nonce-based encryption, the nonce should be the last associated data item.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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