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)