auth

package
v0.0.0-...-99239cc Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package auth provides functions to quickly compute and verify 128 bit authentication tags for arbitrary long messages.

Therefore this package uses SipHash-128 with c=2 and d=4.

Index

Constants

View Source
const (
	// TagSize is the size of a SipHash-128 authentication tag in bytes.
	TagSize = 16
	// KeySize is the size of a SipHash-128 key in bytes.
	KeySize = 16
	// BlockSize is the blocksize of SipHash-128 in bytes.
	BlockSize = 8
)

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(rand io.Reader) (key []byte, err error)

GenerateKey returns a random SipHash-128 key. Therefore the given reader must return random data. This function returns a non-nil error if the given reader fails to provide enough data. In this case the returned key is nil must not used.

func New

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

New returns a new hash.Hash computing the SipHash-128 authentication tag with the given context and key. The context must be 8 and the key must be 16 bytes long. Otherwise this function panics.

func Sum

func Sum(msg, context, key []byte) [TagSize]byte

Sum returns an authentication tag of the given msg using the provided context and key. The context must be 8 and the key must be 16 bytes long. Otherwise this function panics.

func Verify

func Verify(tag [TagSize]byte, msg, context, key []byte) bool

Verify returns true if and only if tag is a valid authenticator for msg with the given context and key. The context must be 8 and the key must be 16 bytes long. Otherwise this function panics.

Types

This section is empty.

Jump to

Keyboard shortcuts

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