chacha20poly1305

Imports

Imports #

"encoding/binary"
"golang.org/x/crypto/chacha20"
"golang.org/x/crypto/internal/alias"
"golang.org/x/crypto/internal/poly1305"
"crypto/cipher"
"errors"
"golang.org/x/crypto/chacha20"
"crypto/cipher"
"errors"
"encoding/binary"
"golang.org/x/crypto/internal/alias"
"golang.org/x/sys/cpu"

Constants & Variables

KeySize const #

KeySize is the size of the key used by this AEAD, in bytes.

const KeySize = 32

NonceSize const #

NonceSize is the size of the nonce used with the standard variant of this AEAD, in bytes. Note that this is too short to be safely generated at random if the same key is reused more than 2³² times.

const NonceSize = 12

NonceSizeX const #

NonceSizeX is the size of the nonce used with the XChaCha20-Poly1305 variant of this AEAD, in bytes.

const NonceSizeX = 24

Overhead const #

Overhead is the size of the Poly1305 authentication tag, and the difference between a ciphertext length and its plaintext.

const Overhead = 16

errOpen var #

var errOpen = *ast.CallExpr

useAVX2 var #

var useAVX2 = *ast.BinaryExpr

Structs

chacha20poly1305 struct #

type chacha20poly1305 struct {
key [KeySize]byte
}

xchacha20poly1305 struct #

type xchacha20poly1305 struct {
key [KeySize]byte
}

Functions

New function #

New returns a ChaCha20-Poly1305 AEAD that uses the given 256-bit key.

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

NewX function #

NewX returns a XChaCha20-Poly1305 AEAD that uses the given 256-bit key. XChaCha20-Poly1305 is a ChaCha20-Poly1305 variant that takes a longer nonce, suitable to be generated randomly without risk of collisions. It should be preferred when nonce uniqueness cannot be trivially ensured, or whenever nonces are randomly generated.

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

NonceSize method #

func (c *chacha20poly1305) NonceSize() int

NonceSize method #

func (*xchacha20poly1305) NonceSize() int

Open method #

func (c *chacha20poly1305) Open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)

Open method #

func (x *xchacha20poly1305) Open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)

Overhead method #

func (*xchacha20poly1305) Overhead() int

Overhead method #

func (c *chacha20poly1305) Overhead() int

Seal method #

func (x *xchacha20poly1305) Seal(dst []byte, nonce []byte, plaintext []byte, additionalData []byte) []byte

Seal method #

func (c *chacha20poly1305) Seal(dst []byte, nonce []byte, plaintext []byte, additionalData []byte) []byte

chacha20Poly1305Open function #

go:noescape

func chacha20Poly1305Open(dst []byte, key []uint32, src []byte, ad []byte) bool

chacha20Poly1305Seal function #

go:noescape

func chacha20Poly1305Seal(dst []byte, key []uint32, src []byte, ad []byte)

open method #

func (c *chacha20poly1305) open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)

open method #

func (c *chacha20poly1305) open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)

openGeneric method #

func (c *chacha20poly1305) openGeneric(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)

seal method #

func (c *chacha20poly1305) seal(dst []byte, nonce []byte, plaintext []byte, additionalData []byte) []byte

seal method #

func (c *chacha20poly1305) seal(dst []byte, nonce []byte, plaintext []byte, additionalData []byte) []byte

sealGeneric method #

func (c *chacha20poly1305) sealGeneric(dst []byte, nonce []byte, plaintext []byte, additionalData []byte) []byte

setupState function #

setupState writes a ChaCha20 input matrix to state. See https://tools.ietf.org/html/rfc7539#section-2.3.

func setupState(state *[16]uint32, key *[32]byte, nonce []byte)

sliceForAppend function #

sliceForAppend takes a slice and a requested number of bytes. It returns a slice with the contents of the given slice followed by that many bytes and a second slice that aliases into it and contains only the extra bytes. If the original slice has sufficient capacity then no allocation is performed.

func sliceForAppend(in []byte, n int) (head []byte, tail []byte)

writeUint64 function #

func writeUint64(p *poly1305.MAC, n int)

writeWithPadding function #

func writeWithPadding(p *poly1305.MAC, b []byte)

Generated with Arrow