Help us shape the future of Go! Take the 2026 Go Developer Survey

chacha20

package module
v0.0.0-...-3d46990 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2016 License: BSD-3-Clause Imports: 1 Imported by: 0

README

ChaCha20

Build Status

This is a go implementation of the chacha20 cipher by djb. It uses the C implementation of the chacha20 cipher by Ted Krovetz. If cgo cannot be used it falls back to a go implementation of chacha20.

Speed

Ted Krovetz's version of chacha20 appears to be far faster than AES on my PC (encrypting 1Kb of data).

BenchmarkChaCha2020_1K   1000000              2438 ns/op         419.86 MB/s
BenchmarkChaCha2012_1K   1000000              1898 ns/op         539.48 MB/s
BenchmarkAES256CTR_1K     500000              6564 ns/op         155.99 MB/s
BenchmarkAES192CTR_1K     500000              6226 ns/op         164.46 MB/s
BenchmarkAES128CTR_1K     500000              5938 ns/op         172.44 MB/s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func XORKeyStream

func XORKeyStream(out, in []byte, nonce []byte, key []byte)

XORKeyStream crypts bytes from in to out using the given key and nonce. It performs the 20 round chacha cipher operation. In and out may be the same slice but otherwise should not overlap. Nonce must be 8 bytes long. Key must be either 10, 16 or 32 byte long (32 bytes is recommended for security purposes).

func XORKeyStream8

func XORKeyStream8(out, in []byte, nonce []byte, key []byte)

XORKeyStream8 crypts bytes from in to out using the given key and nonce. It performs the 8 round chacha cipher operation. In and out may be the same slice but otherwise should not overlap. Nonce must be 8 bytes long. Key must be either 10, 16 or 32 byte long (32 bytes is recommended for security purposes).

func XORKeyStream12

func XORKeyStream12(out, in []byte, nonce []byte, key []byte)

XORKeyStream12 crypts bytes from in to out using the given key and nonce. It performs the 12 round chacha cipher operation. In and out may be the same slice but otherwise should not overlap. Nonce must be 8 bytes long. Key must be either 10, 16 or 32 byte long (32 bytes is recommended for security purposes).

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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