chacha20

package module
v0.0.0-...-98c7cb8 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2016 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Godoc Reference

The ChaCha20 stream cipher

ChaCha is a stream cipher family created by Daniel J. Bernstein. The most common ChaCha cipher is ChaCha20 (20 rounds). ChaCha20 is standardized in RFC 7539.

The ChaCha20Poly1305 AEAD construction

RFC 7539 describes the combination of the ChaCha20 stream cipher and the poly1305 MAC to an AEAD cipher.

Installation

Install in your GOPATH: go get -u github.com/aead/chacha20

Performance

Benchmarks are run on a Intel i7-6500U (Sky Lake) on linux/amd64 with Go 1.6.3

Using SSSE3:
BenchmarkSeal64B-4        	  160.13 MB/s
BenchmarkSeal1K-4         	  637.11 MB/s
BenchmarkOpen64B-4        	  152.56 MB/s
BenchmarkOpen1K-4         	  624.52 MB/s
BenchmarkCipher64-4       	  592.42 MB/s
BenchmarkCipher16K-4      	 1130.34 MB/s
BenchmarkXORKeyStream64-4 	  409.88 MB/s
BenchmarkXORKeyStream16K-4	 1125.41 MB/s

Using only SSE2:
BenchmarkSeal64B-4        	  147.87 MB/s
BenchmarkSeal1K-4         	  556.16 MB/s
BenchmarkOpen64B-4        	  142.78 MB/s
BenchmarkOpen1K-4         	  549.39 MB/s
BenchmarkCipher64-4       	  519.70 MB/s
BenchmarkCipher16K-4      	  912.12 MB/s
BenchmarkXORKeyStream64-4 	  369.23 MB/s
BenchmarkXORKeyStream16K-4	  909.42 MB/s

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

View Source
const NonceSize = 12

NonceSize is the size of the ChaCha20 nonce in bytes.

View Source
const TagSize = poly1305.TagSize

TagSize is the max. size of the auth. tag for the ChaCha20Poly1305 AEAD in bytes.

Variables

This section is empty.

Functions

func NewChaCha20Poly1305

func NewChaCha20Poly1305(key *[32]byte) cipher.AEAD

NewChaCha20Poly1305 returns a cipher.AEAD implementing the ChaCha20Poly1305 construction specified in RFC 7539 with a 128 bit auth. tag.

func NewChaCha20Poly1305WithTagSize

func NewChaCha20Poly1305WithTagSize(key *[32]byte, tagsize int) (cipher.AEAD, error)

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

func NewCipher(nonce *[NonceSize]byte, key *[32]byte) cipher.Stream

NewCipher returns a new cipher.Stream implementing the ChaCha20 stream cipher. The nonce must be unique for one key for all time.

func XORKeyStream

func XORKeyStream(dst, src []byte, nonce *[NonceSize]byte, key *[32]byte, counter uint32)

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.

Directories

Path Synopsis
Package chacha implements some low level functions of the ChaCha cipher family.
Package chacha implements some low level functions of the ChaCha cipher family.

Jump to

Keyboard shortcuts

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