Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Macros | Functions
internal-ghash.h File Reference

GHASH algorithm for supporting GCM mode. More...

#include "internal-util.h"
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  gf128_value_t
 Representation of a value in the GF(2^128) field. More...
 
struct  ghash_state_t
 State information for GHASH. More...
 

Macros

#define GHASH_SHOUP_4BIT   1
 Define to 1 to use Shoup's 4-bit method for GF(2^128) multiplications, or define to 0 to use a simpler but slower bit-by-bit method.
 

Functions

void ghash_init (ghash_state_t *state, const unsigned char *key)
 Initializes the GHASH state. More...
 
void ghash_update (ghash_state_t *state, const unsigned char *data, size_t size)
 Updates a GHASH state with more data. More...
 
void ghash_pad (ghash_state_t *state)
 Pads a GHASH state with zeroes to the next block boundary. More...
 
void ghash_finalize (ghash_state_t *state, unsigned char *hash)
 Finalizes a GHASH state. More...
 

Detailed Description

GHASH algorithm for supporting GCM mode.

Note: This implementation is not constant cache. Internally it uses lookup tables for multiplication in the GF(2^128) field. This means that it has similar behaviour to other fast but memory-efficient software implementations of GHASH but is not suitable for use where memory cache attacks are a concern.

Function Documentation

void ghash_finalize ( ghash_state_t state,
unsigned char *  hash 
)

Finalizes a GHASH state.

Parameters
stateGHASH state to be finalized.
hashPoints to the output hash value, which is 16 bytes in length.
void ghash_init ( ghash_state_t state,
const unsigned char *  key 
)

Initializes the GHASH state.

Parameters
stateGHASH state to be initialized.
key128-bit key.
void ghash_pad ( ghash_state_t state)

Pads a GHASH state with zeroes to the next block boundary.

Parameters
stateGHASH state to be padded.
void ghash_update ( ghash_state_t state,
const unsigned char *  data,
size_t  size 
)

Updates a GHASH state with more data.

Parameters
stateGHASH state to be updated.
dataPoints to the input data.
sizeNumber of bytes of input data.