KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Typedefs | Functions
md5.h File Reference

Message Digest 5 (MD5) hashing support. More...

#include <sys/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Data Structures

struct  kos_md5_cxt
 MD5 context. More...
 

Typedefs

typedef struct kos_md5_cxt kos_md5_cxt_t
 MD5 context. More...
 

Functions

void kos_md5_start (kos_md5_cxt_t *cxt)
 Initialize a MD5 context. More...
 
void kos_md5_hash_block (kos_md5_cxt_t *cxt, const uint8 *input, uint32 size)
 Hash a block of data with MD5. More...
 
void kos_md5_finish (kos_md5_cxt_t *cxt, uint8 output[16])
 Complete a MD5 hash. More...
 
void kos_md5 (const uint8 *input, uint32 size, uint8 output[16])
 Compute the hash of a block of data with MD5. More...
 

Detailed Description

Message Digest 5 (MD5) hashing support.

This file provides the functionality to compute MD5 hashes over any data buffer. While MD5 isn't considered a safe cryptographic hash any more, it still has its uses.

Author
Lawrence Sebald

Typedef Documentation

typedef struct kos_md5_cxt kos_md5_cxt_t

MD5 context.

This structure contains the variables needed to maintain the internal state of the MD5 code. You should not manipulate these variables manually, but rather use the kos_md5_* functions to do everything you need.

Function Documentation

void kos_md5 ( const uint8 input,
uint32  size,
uint8  output[16] 
)

Compute the hash of a block of data with MD5.

This function is used to hash a full block of data without messing around with any contexts or anything else of the sort. This is appropriate if you have all the data you want to hash readily available. It takes care of all of the context setup and teardown for you.

Parameters
inputThe data to hash.
sizeThe number of bytes of input data passed in.
outputWhere to store the final message digest.
void kos_md5_finish ( kos_md5_cxt_t cxt,
uint8  output[16] 
)

Complete a MD5 hash.

This function computes the final MD5 hash of the context passed in, returning the completed digest in the output parameter.

Parameters
cxtThe MD5 context to finalize.
outputWhere to store the final digest.
void kos_md5_hash_block ( kos_md5_cxt_t cxt,
const uint8 input,
uint32  size 
)

Hash a block of data with MD5.

This function is used to hash the block of data input into the function with MD5, updating the state context as appropriate. If the data does not fill an entire block of 64-bytes (or there is left-over data), it will be stored in the context for hashing with a future block. Thus, do not attempt to read the intermediate hash value, as it will not be complete.

Parameters
cxtThe MD5 context to use.
inputThe block of data to hash.
sizeThe number of bytes of input data passed in.
void kos_md5_start ( kos_md5_cxt_t cxt)

Initialize a MD5 context.

This function initializes the context passed in to the initial state needed for computing a MD5 hash. You must call this function to initialize the state variables before attempting to hash any blocks of data.

Parameters
cxtThe MD5 context to initialize.