KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
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_t
 MD5 context. More...
 

Functions

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

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

Function Documentation

◆ kos_md5()

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.

◆ kos_md5_finish()

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.

◆ kos_md5_hash_block()

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.

◆ kos_md5_start()

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.