Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Functions
polyval.h File Reference

Implementation for polyval universal hash function. More...

#include "orconfig.h"
#include "lib/cc/torint.h"

Go to the source code of this file.

Data Structures

struct  polyval_key_t
 
struct  polyval_t
 

Macros

#define POLYVAL_KEY_LEN   16
 
#define POLYVAL_BLOCK_LEN   16
 
#define POLYVAL_TAG_LEN   16
 
#define polyvalx_t   polyval_t
 
#define polyvalx_key_init   polyval_key_init
 
#define polyvalx_init   polyval_init
 
#define polyvalx_init_from_key   polyval_init_from_key
 
#define polyvalx_add_block   polyval_add_block
 
#define polyvalx_add_zpad   polyval_add_zpad
 
#define polyvalx_get_tag   polyval_get_tag
 
#define polyvalx_reset   polyval_reset
 

Functions

void polyval_key_init (polyval_key_t *, const uint8_t *key)
 
void polyval_init (polyval_t *, const uint8_t *key)
 
void polyval_init_from_key (polyval_t *, const polyval_key_t *key)
 
void polyval_add_block (polyval_t *, const uint8_t *block)
 
void polyval_add_zpad (polyval_t *, const uint8_t *data, size_t n)
 
void polyval_get_tag (const polyval_t *, uint8_t *tag_out)
 
void polyval_reset (polyval_t *)
 
void polyval_detect_implementation (void)
 

Detailed Description

Implementation for polyval universal hash function.

APIs for polyval universal hash function.

Polyval, which was first defined for AES-GCM-SIV, is a universal hash based on multiplication in GF(2^128). Unlike the more familiar GHASH, it is defined to work on little-endian inputs, and so is more straightforward and efficient on little-endian architectures.

In Tor we use it as part of the Counter Galois Onion relay encryption format.

Definition in file polyval.h.

Macro Definition Documentation

◆ POLYVAL_BLOCK_LEN

#define POLYVAL_BLOCK_LEN   16

Length of a polyval block, in bytes.

Definition at line 104 of file polyval.h.

◆ POLYVAL_KEY_LEN

#define POLYVAL_KEY_LEN   16

Length of a polyval key, in bytes.

Definition at line 100 of file polyval.h.

◆ POLYVAL_TAG_LEN

#define POLYVAL_TAG_LEN   16

Length of a polyval tag (output), in bytes.

Definition at line 108 of file polyval.h.

◆ polyvalx_add_block

#define polyvalx_add_block   polyval_add_block

Definition at line 179 of file polyval.h.

◆ polyvalx_add_zpad

#define polyvalx_add_zpad   polyval_add_zpad

Definition at line 180 of file polyval.h.

◆ polyvalx_get_tag

#define polyvalx_get_tag   polyval_get_tag

Definition at line 181 of file polyval.h.

◆ polyvalx_init

#define polyvalx_init   polyval_init

Definition at line 177 of file polyval.h.

◆ polyvalx_init_from_key

#define polyvalx_init_from_key   polyval_init_from_key

Definition at line 178 of file polyval.h.

◆ polyvalx_key_init

#define polyvalx_key_init   polyval_key_init

Definition at line 176 of file polyval.h.

◆ polyvalx_reset

#define polyvalx_reset   polyval_reset

Definition at line 182 of file polyval.h.

◆ polyvalx_t

#define polyvalx_t   polyval_t

Definition at line 175 of file polyval.h.

Function Documentation

◆ polyval_add_block()

void polyval_add_block ( polyval_t ,
const uint8_t *  block 
)

Update a polyval instance with a new 16-byte block.

Referenced by cgo_prf_gen_t1(), and cgo_prf_xor_t0().

◆ polyval_add_zpad()

void polyval_add_zpad ( polyval_t ,
const uint8_t *  data,
size_t  n 
)

Update a polyval instance with 'n' bytes from 'data'. If 'n' is not evenly divisible by 16, pad it at the end with zeros.

NOTE: This is not a general-purpose padding construction; it can be insecure if your are using it in context where the input length is variable.

◆ polyval_detect_implementation()

void polyval_detect_implementation ( void  )

If a faster-than-default polyval implementation is available, use it.

Definition at line 444 of file polyval.c.

◆ polyval_get_tag()

void polyval_get_tag ( const polyval_t ,
uint8_t *  tag_out 
)

Copy the 16-byte tag from a polyval instance into 'tag_out'

Referenced by cgo_prf_gen_t1(), and cgo_prf_xor_t0().

◆ polyval_init()

void polyval_init ( polyval_t ,
const uint8_t *  key 
)

Initialize a polyval instance with a given key.

◆ polyval_init_from_key()

void polyval_init_from_key ( polyval_t ,
const polyval_key_t key 
)

Initialize a polyval instance with a preconstructed key.

Referenced by cgo_prf_gen_t1(), and cgo_prf_xor_t0().

◆ polyval_key_init()

void polyval_key_init ( polyval_key_t ,
const uint8_t *  key 
)

Do any necessary precomputation from a polyval key, and store it.

Referenced by cgo_prf_set_key().

◆ polyval_reset()

void polyval_reset ( polyval_t )

Reset a polyval instance to its original state, retaining its key.