poly1305

package module
v0.0.0-...-9cde67c Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: Apache-2.0, BSD-3-Clause, OpenSSL Imports: 3 Imported by: 0

README

poly1305

GoDoc Build Status

Deprecated: This is a legacy implementation. New users should use x/crypto/poly1305 instead.

An AVX/AVX2/x64 implementation of the Poly1305 MAC for Golang.

The AVX and AVX2 Poly1305 implementations were taken from cloudflare/sslconfig.

The x64 Poly1305 implementation was taken from cloudflare/sslconfig.

For non-x64 systems, it falls back to x/crypto/poly1305.

Benchmark

BenchmarkXCryptoSum/1M-8   	    3000	    404575 ns/op	2591.79 MB/s	[golang.org/x/crypto/poly1305]
BenchmarkSumx64/1M-8       	    3000	    419194 ns/op	2501.41 MB/s	[tmthrgd/poly1305]
BenchmarkSumAVX/1M-8       	    5000	    364872 ns/op	2873.82 MB/s	[tmthrgd/poly1305]
BenchmarkNewx64/1M-8       	    3000	    424440 ns/op	2470.49 MB/s	[tmthrgd/poly1305]
BenchmarkNewAVX/1M-8       	    5000	    364626 ns/op	2875.76 MB/s	[tmthrgd/poly1305]
BenchmarkHMAC_MD5/1M-8     	    1000	   1481835 ns/op	 707.62 MB/s	[crypto/hmac crypto/md5]
BenchmarkHMAC_SHA1/1M-8    	    1000	   2253576 ns/op	 465.29 MB/s	[crypto/hmac crypto/sha1]
BenchmarkHMAC_SHA256/1M-8  	     300	   5617349 ns/op	 186.67 MB/s	[crypto/hmac crypto/sha256]

License

Unless otherwise noted, the poly1305 source files are distributed under the Modified BSD License found in the LICENSE file.

This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)

Documentation

Overview

Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf.

Poly1305 is a fast, one-time authentication function. It is infeasible for an attacker to generate an authenticator for a message without the key. However, a key must only be used for a single message. Authenticating two different messages with the same key allows an attacker to forge authenticators for other messages with the same key.

Poly1305 was originally coupled with AES in order to make Poly1305-AES. AES was used with a fixed key in order to generate one-time keys from an nonce. However, in this package AES isn't used and the one-time key is specified directly.

Index

Constants

View Source
const (
	// KeySize is the length of Poly1305 keys, in bytes.
	KeySize = 32

	// TagSize is the length of Poly1305 tags, in bytes.
	TagSize = 16
)

Variables

View Source
var (
	// ErrInvalidKey is returned when the provided key is not KeySize bytes long.
	ErrInvalidKey = errors.New("invalid key length")
)

Functions

func New

func New(key []byte) (hash.Hash, error)

New returns a new Poly1305 hash using the given key. Authenticating two different messages with the same key allows an attacker to forge messages at will.

func Sum

func Sum(out *[TagSize]byte, m []byte, key *[KeySize]byte)

Sum generates an authenticator for m using a one-time key and puts the 16-byte result into out. Authenticating two different messages with the same key allows an attacker to forge messages at will.

func Verify

func Verify(mac *[TagSize]byte, m []byte, key *[KeySize]byte) bool

Verify returns true if mac is a valid authenticator for m with the given key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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