chacha20poly1305: Index | Files

package chacha20poly1305

import ""

Package chacha20poly1305 implemnets the RFC 7539 AEAD_CHACHA20_POLY1305 construct. It depends on my ChaCha20 and Poly1305 libraries (and not for the latter), and attempts to be correct and easy to read over fast.

When the maintainers feel like providing a sane interface to the Poly1305 code, this will switch to using that, but not before then.


Package Files



const (
    // KeySize is the key length in bytes (32 bytes, 256 bits).
    KeySize = chacha20.KeySize

    // NonceSize is the nonce (IV) length in bytes (12 bytes, 96 bits).
    NonceSize = chacha20.INonceSize

    // Overhead is the tag length in bytes (16 bytes, 128 bits).
    Overhead = poly1305.Size


var (
    // ErrOpen is the error returned when an Open fails.
    ErrOpen = errors.New("chacha20poly1305: message authentication failed")

type ChaCha20Poly1305 Uses

type ChaCha20Poly1305 struct {
    // contains filtered or unexported fields

ChaCha20Poly1305 is an AEAD_CHACHA20_POLY1305 instance.

func New Uses

func New(key []byte) (*ChaCha20Poly1305, error)

New returns a new ChaCha20Poly1305 instance, keyed with a given key.

func (*ChaCha20Poly1305) NonceSize Uses

func (a *ChaCha20Poly1305) NonceSize() int

NonceSize returns the size of the nonce that must be passed to Seal and Open.

func (*ChaCha20Poly1305) Open Uses

func (a *ChaCha20Poly1305) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error)

Open decrypts and authenticates ciphertext, authenticates the additional data and, if successful, appends the resulting plaintext to dst, returning the updated slice. The nonce must be NonceSize() bytes long and both it and the additional data must match the value passed to Seal.

Even if the function fails, the contents of dst, up to its capacity, may be overwritten.

func (*ChaCha20Poly1305) Overhead Uses

func (a *ChaCha20Poly1305) Overhead() int

Overhead returns the maximum difference between the lengths of a plaintext and its ciphertext.

func (*ChaCha20Poly1305) Reset Uses

func (a *ChaCha20Poly1305) Reset()

Reset clears all sensitive cryptographic material from a given instance so that it is no longer resident in memory.

func (*ChaCha20Poly1305) Seal Uses

func (a *ChaCha20Poly1305) Seal(dst, nonce, plaintext, additionalData []byte) []byte

Seal encrypts and authenticates plaintext, authenticates the additional data and appends the result to dst, returning the updated slice. The nonce must be NonceSize() bytes long and unique for all time, for a given key.

Package chacha20poly1305 imports 6 packages (graph) and is imported by 1 packages. Updated 2020-10-25. Refresh now. Tools for package owners.