Main Page Modules Data Structures File List Data Fields Globals Related Pages

# Keyed Hash Functions, a.k.a. Message Authentication Codes

## Files

file | hmac.c
| HMAC message authentication code, code.

file | hmac.h
| HMAC message authentication code, header.

file | hmacmd5.c
| HMAC-MD5 message authentication code, code.

file | hmacmd5.h
| HMAC-MD5 message authentication code, header.

file | hmacsha1.c
| HMAC-SHA-1 message authentication code, code.

file | hmacsha1.h
| HMAC-SHA-1 message authentication code, header.

file | hmacsha256.c
| HMAC-SHA-256 message authentication code, code.

file | hmacsha256.h
| HMAC-SHA-256 message authentication code, header.

## Data Structures

struct | keyedHashFunction
struct | keyedHashFunctionContext

## Keyed Hash Functions, a.k.a. Message Authentication Codes

typedef void | keyedHashFunctionParam
typedef int(* | keyedHashFunctionSetup )(keyedHashFunctionParam *param, const uint32 *key, int keybits)
typedef int(* | keyedHashFunctionReset )(keyedHashFunctionParam *param)
typedef int(* | keyedHashFunctionUpdate )(keyedHashFunctionParam *param, const byte *data, int size)
typedef int(* | keyedHashFunctionDigest )(keyedHashFunctionParam *param, uint32 *data)
int | keyedHashFunctionCount (void)
const keyedHashFunction * | keyedHashFunctionGet (int index)
const keyedHashFunction * | keyedHashFunctionFind (const char *name)
const keyedHashFunction * | keyedHashFunctionDefault (void)
int | keyedHashFunctionContextInit (keyedHashFunctionContext *ctxt, const keyedHashFunction *mac)
int | keyedHashFunctionContextFree (keyedHashFunctionContext *ctxt)
int | keyedHashFunctionContextSetup (keyedHashFunctionContext *ctxt, const uint32 *key, int keybits)
int | keyedHashFunctionContextReset (keyedHashFunctionContext *ctxt)
int | keyedHashFunctionContextUpdate (keyedHashFunctionContext *ctxt, const byte *data, int size)
int | keyedHashFunctionContextUpdateMC (keyedHashFunctionContext *ctxt, const memchunk *m)
int | keyedHashFunctionContextUpdateMP32 (keyedHashFunctionContext *ctxt, const mp32number *n)
int | keyedHashFunctionContextDigest (keyedHashFunctionContext *ctxt, mp32number *dig)
int | keyedHashFunctionContextDigestMatch (keyedHashFunctionContext *ctxt, const mp32number *match)

## Typedef Documentation

typedef int(* keyedHashFunctionDigest)(keyedHashFunctionParam* param, uint32* data)

Compute the digest (or authentication code) of all the data passed to the keyed hash function, and return the result in data.

Note:
  data must be at least have a bytesize of 'digestsize' as described in the keyedHashFunction struct.

Note:
  For safety reasons, after calling digest, each specific implementation MUST reset itself so that previous values in the parameters are erased.

Parameters:

  param | keyed hash parameters

Return values:

  data | digest (or authentication code)

Returns:
  0 on success, -1 on failure

Definition at line 512 of file beecrypt.h.

typedef void keyedHashFunctionParam

| Definition at line 461 of file beecrypt.h. Referenced by keyedHashFunctionContextDigest, keyedHashFunctionContextFree, keyedHashFunctionContextInit, keyedHashFunctionContextReset, keyedHashFunctionContextSetup, keyedHashFunctionContextUpdate, keyedHashFunctionContextUpdateMC, and keyedHashFunctionContextUpdateMP32.

typedef int(* keyedHashFunctionReset)(keyedHashFunctionParam* param)

Re-initialize the parameters of a keyed hash function.

Parameters:

  param | keyed hash parameters

Returns:
  0 on success, -1 on failure

Definition at line 484 of file beecrypt.h.

typedef int(* keyedHashFunctionSetup)(keyedHashFunctionParam* param, const uint32* key, int keybits)

Setup the keyed hash function parameters with the given secret key. This can also be used to reset the parameters.

Note:
  After use, it is recommended to wipe the parameters by calling setup again with another (dummy) key.

Parameters:

  param | keyed hash parameters
  key | secret key
  keybits | no. bits in secret key

Returns:
  0 on success, -1 on failure

Definition at line 475 of file beecrypt.h.

typedef int(* keyedHashFunctionUpdate)(keyedHashFunctionParam* param, const byte* data, int size)

Update the keyed hash function with an array of bytes.

Parameters:

  param | keyed hash parameters
  data | array of bytes
  size | no. of bytes

Returns:
  0 on success, -1 on failure

Definition at line 495 of file beecrypt.h.

## Function Documentation

int keyedHashFunctionContextDigest | ( | keyedHashFunctionContext * | ctxt,
|  | mp32number * | dig
| ) |

| Definition at line 687 of file beecrypt.c. Referenced by dhaes_pContextEncrypt, and keyedHashFunctionContextDigestMatch.

int keyedHashFunctionContextDigestMatch | ( | keyedHashFunctionContext * | ctxt,
|  | const mp32number * | match
| ) |

| Definition at line 707 of file beecrypt.c. Referenced by dhaes_pContextDecrypt.

int keyedHashFunctionContextFree | ( | keyedHashFunctionContext * | ctxt | ) |

| Destroy a keyedHashFunction instance. Definition at line 562 of file beecrypt.c. References BEECRYPTAPI. Referenced by dhaes_pContextFree.

int keyedHashFunctionContextInit | ( | keyedHashFunctionContext * | ctxt,
|  | const keyedHashFunction * | mac
| ) |

| Initialize a keyedHashFunction instance. Definition at line 541 of file beecrypt.c. Referenced by dhaes_pContextInit.

int keyedHashFunctionContextReset | ( | keyedHashFunctionContext * | ctxt | ) |

| Definition at line 601 of file beecrypt.c. References BEECRYPTAPI.

int keyedHashFunctionContextSetup | ( | keyedHashFunctionContext * | ctxt,
|  | const uint32 * | key,
|  | int | keybits
| ) |

| Definition at line 584 of file beecrypt.c. Referenced by dhaes_pContextSetup.

int keyedHashFunctionContextUpdate | ( | keyedHashFunctionContext * | ctxt,
|  | const byte * | data,
|  | int | size
| ) |

| Definition at line 615 of file beecrypt.c. References BEECRYPTAPI, and uint32.

int keyedHashFunctionContextUpdateMC | ( | keyedHashFunctionContext * | ctxt,
|  | const memchunk * | m
| ) |

| Definition at line 632 of file beecrypt.c. References BEECRYPTAPI. Referenced by dhaes_pContextDecrypt, and dhaes_pContextEncrypt.

int keyedHashFunctionContextUpdateMP32 | ( | keyedHashFunctionContext * | ctxt,
|  | const mp32number * | n
| ) |

| Definition at line 650 of file beecrypt.c. References BEECRYPTAPI.

int keyedHashFunctionCount | ( | void |  | ) |

Return the number of keyed hash functions available.

Returns:
  number of keyed hash functions available

Definition at line 496 of file beecrypt.c.

const keyedHashFunction* keyedHashFunctionDefault | ( | void |  | ) |

Retrieve the default keyed hash function. If the BEECRYPT_KEYEDHASH environment variable is set, use that keyed hash function. Otherwise, use "hmacsha1".

Returns:
  keyed hash function pointer

Definition at line 501 of file beecrypt.c.

const keyedHashFunction* keyedHashFunctionFind | ( | const char * | name | ) |

Retrieve a keyed hash function by name.

Parameters:

  name | keyed hash function name

Returns:
  keyed hash function pointer (or NULL)

Definition at line 526 of file beecrypt.c.

Referenced by keyedHashFunctionDefault.

const keyedHashFunction* keyedHashFunctionGet | ( | int | index | ) |

Retrieve a keyed hash function by index.

Parameters:

  index | keyed hash function index

Returns:
  keyed hash function pointer (or NULL)

Definition at line 513 of file beecrypt.c.