crypto: golang.org/x/crypto/internal/chacha20 Index | Files

package chacha20

import "golang.org/x/crypto/internal/chacha20"

Package ChaCha20 implements the core ChaCha20 function as specified in https://tools.ietf.org/html/rfc7539#section-2.3.

Index

Package Files

chacha_generic.go chacha_noasm.go xor.go

func HChaCha20 Uses

func HChaCha20(key *[8]uint32, nonce *[4]uint32) [8]uint32

HChaCha20 uses the ChaCha20 core to generate a derived key from a key and a nonce. It should only be used as part of the XChaCha20 construction.

func XORKeyStream Uses

func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte)

XORKeyStream crypts bytes from in to out using the given key and counters. In and out must overlap entirely or not at all. Counter contains the raw ChaCha20 counter bytes (i.e. block counter followed by nonce).

type Cipher Uses

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

Cipher is a stateful instance of ChaCha20 using a particular key and nonce. A *Cipher implements the cipher.Stream interface.

func New Uses

func New(key [8]uint32, nonce [3]uint32) *Cipher

New creates a new ChaCha20 stream cipher with the given key and nonce. The initial counter value is set to 0.

func (*Cipher) Advance Uses

func (s *Cipher) Advance()

Advance discards bytes in the key stream until the next 64 byte block boundary is reached and updates the counter accordingly. If the key stream is already at a block boundary no bytes will be discarded and the counter will be unchanged.

func (*Cipher) XORKeyStream Uses

func (s *Cipher) XORKeyStream(dst, src []byte)

XORKeyStream XORs each byte in the given slice with a byte from the cipher's key stream. Dst and src must overlap entirely or not at all.

If len(dst) < len(src), XORKeyStream will panic. It is acceptable to pass a dst bigger than src, and in that case, XORKeyStream will only update dst[:len(src)] and will not touch the rest of dst.

Multiple calls to XORKeyStream behave as if the concatenation of the src buffers was passed in a single run. That is, Cipher maintains state and does not reset at each XORKeyStream call.

Package chacha20 imports 4 packages (graph) and is imported by 2 packages. Updated 2018-12-04. Refresh now. Tools for package owners.