Apache2
apr_siphash.h File Reference

APR-UTIL siphash library "SipHash-c-d is a family of pseudorandom functions (a.k.a. keyed hash functions) optimized for speed on short messages", designed by Jean-Philippe Aumasson and Daniel J. Bernstein. It generates a 64bit hash (or MAC) from the message and a 128bit key. See http://cr.yp.to/siphash/siphash-20120620.pdf for the details, c is the number of compression rounds, d the number of finalization rounds; we also define fast implementations for c = 2 with d = 4 (aka siphash-2-4), and c = 4 with d = 8 (aka siphash-4-8), as recommended parameters per the authors. More...

#include "apr.h"
Include dependency graph for apr_siphash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define APR_SIPHASH_DSIZE   8
 
#define APR_SIPHASH_KSIZE   16
 

Functions

apr_uint64_t apr_siphash (const void *src, apr_size_t len, const unsigned char key[APR_SIPHASH_KSIZE], unsigned int c, unsigned int d)
 Computes SipHash-c-d, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key. More...
 
void apr_siphash_auth (unsigned char out[APR_SIPHASH_DSIZE], const void *src, apr_size_t len, const unsigned char key[APR_SIPHASH_KSIZE], unsigned int c, unsigned int d)
 Computes SipHash-c-d, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key, into a possibly unaligned buffer (using the little endian representation as defined by the authors for interoperabilty) usable as a MAC. More...
 
apr_uint64_t apr_siphash24 (const void *src, apr_size_t len, const unsigned char key[APR_SIPHASH_KSIZE])
 Computes SipHash-2-4, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key. More...
 
void apr_siphash24_auth (unsigned char out[APR_SIPHASH_DSIZE], const void *src, apr_size_t len, const unsigned char key[APR_SIPHASH_KSIZE])
 Computes SipHash-2-4, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key, into a possibly unaligned buffer (using the little endian representation as defined by the authors for interoperabilty) usable as a MAC. More...
 
apr_uint64_t apr_siphash48 (const void *src, apr_size_t len, const unsigned char key[APR_SIPHASH_KSIZE])
 Computes SipHash-4-8, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key. More...
 
void apr_siphash48_auth (unsigned char out[APR_SIPHASH_DSIZE], const void *src, apr_size_t len, const unsigned char key[APR_SIPHASH_KSIZE])
 Computes SipHash-4-8, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key, into a possibly unaligned buffer (using the little endian representation as defined by the authors for interoperabilty) usable as a MAC. More...
 

Detailed Description

APR-UTIL siphash library "SipHash-c-d is a family of pseudorandom functions (a.k.a. keyed hash functions) optimized for speed on short messages", designed by Jean-Philippe Aumasson and Daniel J. Bernstein. It generates a 64bit hash (or MAC) from the message and a 128bit key. See http://cr.yp.to/siphash/siphash-20120620.pdf for the details, c is the number of compression rounds, d the number of finalization rounds; we also define fast implementations for c = 2 with d = 4 (aka siphash-2-4), and c = 4 with d = 8 (aka siphash-4-8), as recommended parameters per the authors.

Macro Definition Documentation

◆ APR_SIPHASH_DSIZE

#define APR_SIPHASH_DSIZE   8

size of the siphash digest

◆ APR_SIPHASH_KSIZE

#define APR_SIPHASH_KSIZE   16

size of the siphash key

Function Documentation

◆ apr_siphash()

apr_uint64_t apr_siphash ( const void *  src,
apr_size_t  len,
const unsigned char  key[APR_SIPHASH_KSIZE],
unsigned int  c,
unsigned int  d 
)

Computes SipHash-c-d, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key.

Parameters
srcThe message
lenThe length of the message
keyThe secret key
cThe number of compression rounds
dThe number of finalization rounds
Returns
The hash value as a 64bit unsigned integer

◆ apr_siphash24()

apr_uint64_t apr_siphash24 ( const void *  src,
apr_size_t  len,
const unsigned char  key[APR_SIPHASH_KSIZE] 
)

Computes SipHash-2-4, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key.

Parameters
srcThe message to hash
lenThe length of the message
keyThe secret key
Returns
The hash value as a 64bit unsigned integer

◆ apr_siphash24_auth()

void apr_siphash24_auth ( unsigned char  out[APR_SIPHASH_DSIZE],
const void *  src,
apr_size_t  len,
const unsigned char  key[APR_SIPHASH_KSIZE] 
)

Computes SipHash-2-4, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key, into a possibly unaligned buffer (using the little endian representation as defined by the authors for interoperabilty) usable as a MAC.

Parameters
outThe output buffer (or MAC)
srcThe message
lenThe length of the message
keyThe secret key
Returns
The hash value as a 64bit unsigned integer

◆ apr_siphash48()

apr_uint64_t apr_siphash48 ( const void *  src,
apr_size_t  len,
const unsigned char  key[APR_SIPHASH_KSIZE] 
)

Computes SipHash-4-8, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key.

Parameters
srcThe message
lenThe length of the message
keyThe secret key
Returns
The hash value as a 64bit unsigned integer

◆ apr_siphash48_auth()

void apr_siphash48_auth ( unsigned char  out[APR_SIPHASH_DSIZE],
const void *  src,
apr_size_t  len,
const unsigned char  key[APR_SIPHASH_KSIZE] 
)

Computes SipHash-4-8, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key, into a possibly unaligned buffer (using the little endian representation as defined by the authors for interoperabilty) usable as a MAC.

Parameters
outThe output buffer (or MAC)
srcThe message
lenThe length of the message
keyThe secret key
Returns
The hash value as a 64bit unsigned integer

◆ apr_siphash_auth()

void apr_siphash_auth ( unsigned char  out[APR_SIPHASH_DSIZE],
const void *  src,
apr_size_t  len,
const unsigned char  key[APR_SIPHASH_KSIZE],
unsigned int  c,
unsigned int  d 
)

Computes SipHash-c-d, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIPHASH_KSIZE) secret key, into a possibly unaligned buffer (using the little endian representation as defined by the authors for interoperabilty) usable as a MAC.

Parameters
outThe output buffer (or MAC)
srcThe message
lenThe length of the message
keyThe secret key
cThe number of compression rounds
dThe number of finalization rounds
Returns
The hash value as a 64bit unsigned integer