Main Page   Compound List   File List   Compound Members   File Members  

hasher.h File Reference

#include <string.h>
#include <stdlib.h>
#include "sha2.h"
#include "sha1.h"
#include "md5.h"
#include "ripemd160.h"

Include dependency graph for hasher.h:

Include dependency graph

Go to the source code of this file.

Compounds

struct  hasher_t

Defines

#define HASHER_MAX_DIGEST_SIZE
#define HASHER_MAX_CTX_SIZE
#define hasher_t   void

Enumerations

enum  hasher_retcode {
  HASHER_OK,
  HASHER_BAD_HASH_ALGO,
  HASHER_NULL_POINTER
}

Functions

void hasher_init (hasher_t *H)
void hasher_update (hasher_t *H, const uns8 *data, uns32 len)
void hasher_final (hasher_t *H, uns8 *result)
hasher_retcode hasher_setup (hasher_t *H, const char *algo)
hasher_retcode hasher_teardown (hasher_t *H)
const char* hasher_ret_msg (hasher_retcode c)

Variables

const int hasher_lengths [CRYPTO_HASH_COUNT][2]


Define Documentation

#define HASHER_MAX_CTX_SIZE
 

Value:

  ( max(\
     max(\
      sizeof(ripemd160_context),\
      sizeof(md5_context)\
     ),\
     max(\
      sizeof(sha2_context),\
      sizeof(sha1_context)\
     )\
    )\
  )

#define HASHER_MAX_DIGEST_SIZE
 

Value:

  ( max(\
     max(\
      RIPEMD160_DIGEST_SIZE,\
      MD5_DIGEST_SIZE\
     ),\
     max(\
      SHA1_DIGEST_SIZE,\
      SHA2_DIGEST_SIZE\
     )\
    )\
  )

#define hasher_t   void
 


Enumeration Type Documentation

enum hasher_retcode
 

Enumeration values:
HASHER_OK  
HASHER_BAD_HASH_ALGO  
HASHER_NULL_POINTER  


Function Documentation

void hasher_final ( hasher_t * H,
uns8 * result )
 

Finalize the structure and produce a digest

Parameters:
H   the hasher pseudo-object requiring the H->final(H,result)
result   byte array of AT LEAST H->len bytes in size

void hasher_init ( hasher_t * H )
 

Initalize the hasher pseudo-object Resets the digest internal state to unity

const char * hasher_ret_msg ( hasher_retcode c )
 

Provide a human readable representation of an hasher_retcode error code

Parameters:
c   the hasher_ret_msg returned by a hasher static or pseudo-object member function

hasher_retcode hasher_setup ( hasher_t * H,
const char * algo )
 

Setup the hasher object for use

Parameters:
H   the hasher pseudo-object to be setup
algo   string representation of the algorithm to be used for the lifetime of this structure (eg. "md5", "sha-1", "sha-2", "ripemd-160")
See also:
hasher_ret_msg

hasher_retcode hasher_teardown ( hasher_t * H )
 

De-allocate and erase the components of the hasher

Parameters:
H   the hasher pseudo-object to be releasd
See also:
hasher_ret_msg

void hasher_update ( hasher_t * H,
const uns8 * data,
uns32 len )
 

Update the current state of hasher Operations are buffered, thus alignment issues are abstracted from lucky programm who uses this!

Parameters:
H   the hasher pseudo-object requiring the H->update(H,data,len)
data   pointer to array of bytes to process
len   length in bytes of the input


Variable Documentation

const int hasher_lengths
 

Array of digest lengths

See also:
hash_t


Confidential