Documentation ¶
Index ¶
- Constants
- Variables
- func New(key *memguard.LockedBuffer, nonce []byte) (cipher.Stream, error)
- func NewWithRounds(key *memguard.LockedBuffer, nonce []byte, rounds uint8) (cipher.Stream, error)
- func NewX(key *memguard.LockedBuffer, nonce []byte) (cipher.Stream, error)
- func NewXWithRounds(key *memguard.LockedBuffer, nonce []byte, rounds uint8) (cipher.Stream, error)
Constants ¶
View Source
const ( // KeySize is the length of ChaCha20 keys, in bytes. KeySize = 32 // NonceSize is the length of ChaCha20 nonces, in bytes. NonceSize = 8 // XNonceSize is the length of XChaCha20 nonces, in bytes. XNonceSize = 24 )
Variables ¶
View Source
var ( // ErrInvalidKey is returned when the provided key is not 256 bits long. ErrInvalidKey = errors.New("invalid key length (must be 256 bits)") // ErrInvalidNonce is returned when the provided nonce is not 64 bits long. ErrInvalidNonce = errors.New("invalid nonce length (must be 64 bits)") // ErrInvalidXNonce is returned when the provided nonce is not 192 bits // long. ErrInvalidXNonce = errors.New("invalid nonce length (must be 192 bits)") // ErrInvalidRounds is returned when the provided rounds is not // 8, 12, or 20. ErrInvalidRounds = errors.New("invalid rounds number (must be 8, 12, or 20)") )
Functions ¶
func New ¶
New creates and returns a new cipher.Stream. The key must be 256 bits long, and the nonce argument must be 64 bits long. The nonce must be randomly generated or used only once.
func NewWithRounds ¶
NewWithRounds creates and returns a new cipher.Stream just like New but the rounds number of 8, 12, or 20 can be specified.
func NewX ¶
NewX creates and returns a new cipher.Stream. The key must be 256 bits long, and the nonce argument must be 192 bits long.
func NewXWithRounds ¶
NewXWithRounds creates and returns a new cipher.Stream just like NewX but the rounds number of 8, 12, or 20 can be specified.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.