Documentation ¶
Overview ¶
Package chacha20 implements the ChaCha stream cipher and the ChaCha20Poly1305 AEAD construction described in RFC 7539.
ChaCha20 uses a 32 bit counter and produces 64 byte keystream per iteration. Following ChaCha20 can en/decrypt up to 2^32 * 64 byte for one key-nonce combination. Notice that one specific key-nonce combination must be unique for all time.
Index ¶
- Constants
- func NewChaCha20Poly1305(key *[32]byte) cipher.AEAD
- func NewChaCha20Poly1305WithTagSize(key *[32]byte, tagsize int) (cipher.AEAD, error)
- func NewCipher(nonce *[NonceSize]byte, key *[32]byte) cipher.Stream
- func XORKeyStream(dst, src []byte, nonce *[NonceSize]byte, key *[32]byte, counter uint32)
Constants ¶
const NonceSize = 12
The size of the ChaCha20 nonce in bytes.
const TagSize = poly1305.TagSize
The max. size of the auth. tag for the ChaCha20Poly1305 AEAD cipher in bytes.
Variables ¶
This section is empty.
Functions ¶
func NewChaCha20Poly1305 ¶
NewChaCha20Poly1305 returns a cipher.AEAD implementing the ChaCha20Poly1305 construction specified in RFC 7539 with a 128 bit auth. tag.
func NewChaCha20Poly1305WithTagSize ¶
NewChaCha20Poly1305WithTagSize returns a cipher.AEAD implementing the ChaCha20Poly1305 construction specified in RFC 7539 with arbitrary tag size. The tagsize must be between 1 and the TagSize constant.
func NewCipher ¶
NewCipher returns a new cipher.Stream implementing the ChaCha20 stream cipher. The nonce must be unique for one key for all time.
func XORKeyStream ¶
XORKeyStream crypts bytes from src to dst using the given key, nonce and counter. Src and dst may be the same slice but otherwise should not overlap. If len(dst) < len(src) this function panics.
Types ¶
This section is empty.