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

# Hash Functions

## Files

file | md5.c
| MD5 hash function, code.

file | md5.h
| MD5 hash function, header.

file | sha1.c
| SHA-1 hash function, code.

file | sha1.h
| SHA-1 hash function, header.

file | sha1opt.h
| SHA-1 assembler-optimized routines, header.

file | sha256.c
| SHA-256 hash function, code.

file | sha256.h
| SHA-256 hash function, header.

## Data Structures

struct | hashFunction
struct | hashFunctionContext

## Hash Functions

typedef void | hashFunctionParam
typedef int(* | hashFunctionReset )(hashFunctionParam *param)
typedef int(* | hashFunctionUpdate )(hashFunctionParam *param, const byte *data, int size)
typedef int(* | hashFunctionDigest )(hashFunctionParam *param, uint32 *data)
int | hashFunctionCount (void)
const hashFunction * | hashFunctionGet (int index)
const hashFunction * | hashFunctionFind (const char *name)
const hashFunction * | hashFunctionDefault (void)
int | hashFunctionContextInit (hashFunctionContext *ctxt, const hashFunction *hash)
int | hashFunctionContextFree (hashFunctionContext *ctxt)
int | hashFunctionContextReset (hashFunctionContext *ctxt)
int | hashFunctionContextUpdate (hashFunctionContext *ctxt, const byte *data, int size)
int | hashFunctionContextUpdateMC (hashFunctionContext *ctxt, const memchunk *m)
int | hashFunctionContextUpdateMP32 (hashFunctionContext *ctxt, const mp32number *n)
int | hashFunctionContextDigest (hashFunctionContext *ctxt, mp32number *dig)
int | hashFunctionContextDigestMatch (hashFunctionContext *ctxt, const mp32number *match)

## Typedef Documentation

typedef int(* hashFunctionDigest)(hashFunctionParam* param, uint32* data)

Compute the digest of all the data passed to the hash function, and return the result in data.

Note:
  data must be at least have a bytesize of 'digestsize' as described in the hashFunction 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 | hash parameters

Return values:

  data | digest

Returns:
  0 on success, -1 on failure

Definition at line 320 of file beecrypt.h.

typedef void hashFunctionParam

| Definition at line 284 of file beecrypt.h. Referenced by hashFunctionContextDigest, hashFunctionContextFree, hashFunctionContextInit, hashFunctionContextReset, hashFunctionContextUpdate, hashFunctionContextUpdateMC, hashFunctionContextUpdateMP32, hmacDigest, hmacReset, hmacSetup, and hmacUpdate.

typedef int(* hashFunctionReset)(hashFunctionParam* param)

Re-initialize the parameters of the hash function.

Parameters:

  param | hash parameters

Returns:
  0 on success, -1 on failure

Definition at line 292 of file beecrypt.h.

typedef int(* hashFunctionUpdate)(hashFunctionParam* param, const byte* data, int size)

Update the hash function with an array of bytes.

Parameters:

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

Returns:
  0 on success, -1 on failure

Definition at line 303 of file beecrypt.h.

## Function Documentation

int hashFunctionContextDigest | ( | hashFunctionContext * | ctxt,
|  | mp32number * | dig
| ) |

| Definition at line 445 of file beecrypt.c. Referenced by dhaes_pContextSetup, and hashFunctionContextDigestMatch.

int hashFunctionContextDigestMatch | ( | hashFunctionContext * | ctxt,
|  | const mp32number * | match
| ) |

| Definition at line 465 of file beecrypt.c.

int hashFunctionContextFree | ( | hashFunctionContext * | ctxt | ) |

| Destroy a hashFunction instance. Definition at line 340 of file beecrypt.c. References BEECRYPTAPI, hashFunctionCount, and hashFunctionGet. Referenced by dhaes_pContextFree.

int hashFunctionContextInit | ( | hashFunctionContext * | ctxt,
|  | const hashFunction * | hash
| ) |

| Initialize a hashFunction instance. Definition at line 319 of file beecrypt.c. Referenced by dhaes_pContextInit.

int hashFunctionContextReset | ( | hashFunctionContext * | ctxt | ) |

| Definition at line 359 of file beecrypt.c. References BEECRYPTAPI. Referenced by dhaes_pContextSetup.

int hashFunctionContextUpdate | ( | hashFunctionContext * | ctxt,
|  | const byte * | data,
|  | int | size
| ) |

| Definition at line 373 of file beecrypt.c.

int hashFunctionContextUpdateMC | ( | hashFunctionContext * | ctxt,
|  | const memchunk * | m
| ) |

| Definition at line 390 of file beecrypt.c.

int hashFunctionContextUpdateMP32 | ( | hashFunctionContext * | ctxt,
|  | const mp32number * | n
| ) |

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

int hashFunctionCount | ( | void |  | ) |

Return the number of hash functions available.

Returns:
  number of hash functions available

Definition at line 274 of file beecrypt.c.

const hashFunction* hashFunctionDefault | ( | void |  | ) |

Retrieve the default hash function. If the BEECRYPT_HASH environment variable is set, use that hash function. Otherwise, use "sha1".

Returns:
  hash function pointer (or NULL)

Definition at line 279 of file beecrypt.c.

const hashFunction* hashFunctionFind | ( | const char * | name | ) |

Retrieve a hash function by name.

Parameters:

  name | hash function name

Returns:
  hash function pointer (or NULL)

Definition at line 304 of file beecrypt.c.

Referenced by hashFunctionDefault.

const hashFunction* hashFunctionGet | ( | int | index | ) |

Retrieve a hash function by index.

Parameters:

  index | hash function index

Returns:
  hash function pointer (or NULL)

Definition at line 291 of file beecrypt.c.

Referenced by hashFunctionContextFree.