chacha20

package
v0.0.0-...-0941746 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package chacha20 implements the ChaCha20 / XChaCha20 stream chipher. Notice that one specific key-nonce combination must be unique for all time.

There are three versions of ChaCha20: - ChaCha20 with a 64 bit nonce (en/decrypt up to 2^64 * 64 bytes for one key-nonce combination) - ChaCha20 with a 96 bit nonce (en/decrypt up to 2^32 * 64 bytes (~256 GB) for one key-nonce combination) - XChaCha20 with a 192 bit nonce (en/decrypt up to 2^64 * 64 bytes for one key-nonce combination)

Index

Constants

View Source
const (
	KeySize   = 32
	NonceSize = 8
)
View Source
const (
	NonceSizeX = 24
)

Variables

View Source
var (
	ErrBadKeyLength   = errors.New("chacha20: bad key length. 32 bytes required")
	ErrBadNonceLength = errors.New("chacha20: bad nonce length for ChaCha20. 8 bytes required")
)
View Source
var (
	ErrBadNonceXLength = errors.New("chacha20: bad nonce length for XChaCha20. 24 bytes required")
)

Functions

This section is empty.

Types

type StreamCipher

type StreamCipher interface {
	cipher.Stream
	SetCounter(n uint32)
}

func New

func New(key, nonce []byte) (StreamCipher, error)

func NewX

func NewX(key, nonce []byte) (StreamCipher, error)

NewX returns a new instance of the XChaCha20 stream cipher. as of now we use the IETF chacha20 variant with 96-bit nonces

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL