MD5 and HMAC-MD5 class
Spaniakos - MD5 and HMAC-MD5 class for arduino and Raspberry Pi
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
MD5 Class Reference

#include <MD5.h>

Public Member Functions

 MD5 ()
 
unsigned char * make_hash (const void *arg)
 
char * make_digest (const unsigned char *digest, int len)
 
char * md5 (const void *arg)
 
void hmac_md5 (const void *text, int text_len, void *key, int key_len, unsigned char *digest)
 
char * hmac_md5 (const void *text, int text_len, void *key, int key_len)
 
double millis ()
 

Static Public Member Functions

static const void * body (void *ctxBuf, const void *data, size_t size)
 
static void MD5Init (void *ctxBuf)
 
static void MD5Final (unsigned char *result, void *ctxBuf)
 
static void MD5Update (void *ctxBuf, const void *data, size_t size)
 

Private Attributes

timeval tv
 

Detailed Description

Examples:
HMAC_MD5.cpp, HMAC_MD5.ino, MD5_Hash.cpp, and MD5_Hash.ino.

Constructor & Destructor Documentation

MD5::MD5 ( )

class constructor. Does nothing.

Member Function Documentation

unsigned char * MD5::make_hash ( const void *  arg)

Created the MD5 hash from a string of characters on hex encoding.

It is one of the main function of this class. Gets an pointer to a string, and hash it to MD5.

Parameters
*argpointer to the string or array of characters.
Returns
a pointer containing the MD5digest
char * MD5::make_digest ( const unsigned char *  digest,
int  len 
)

Converts a digest to a string.

In order for tedigest to be readable and printed easyly, we need to conver it.

Parameters
*digestpointer to the array that holds the digest
leninteger defining the lengs of the output, usually 16 for MD5
Returns
poiner to the string that holds the String of the converted digest
char * MD5::md5 ( const void *  arg)

Automation function. Gets a pointer to sequence of chars, Then Hashes it, and converts it to a readable form,

Parameters
*argpointer to the string that will be hashed.
Returns
pointer to the string that holds the string of the converted digest.
Examples:
MD5_Hash.cpp, and MD5_Hash.ino.
void MD5::hmac_md5 ( const void *  text,
int  text_len,
void *  key,
int  key_len,
unsigned char *  digest 
)

Main function of the HMAC-MD5. gets the key and the text, and creates the HMAC-MD5 digest function. in order to be pronted, it is required for the make_digest function to be called.

make_digest(digest,BLOCK_SIZE);
Parameters
*textpointer to the text that will be hashed.
text_leninteget value of the length of the text.
*keypointer to the key that will be used in the HMAC process.
key_leninteger value of the key length.
*digestpointer to the array that will hold the digest of this process
Returns
the digest in the memory block that the *digest is pointing.
Examples:
HMAC_MD5.cpp, and HMAC_MD5.ino.
char * MD5::hmac_md5 ( const void *  text,
int  text_len,
void *  key,
int  key_len 
)

Main function of the HMAC-MD5. gets the key and the text, and creates the HMAC-MD5 digest function in a readable format.

Parameters
*textpointer to the text that will be hashed.
text_leninteget value of the length of the text.
*keypointer to the key that will be used in the HMAC process.
key_leninteger value of the key length.
Returns
pointer that points to the digest in a readable format.
const void * MD5::body ( void *  ctxBuf,
const void *  data,
size_t  size 
)
static

This processes one or more 64-byte data blocks, but does NOT update the bit counters. There are no alignment requirements.

Parameters
*ctxBufthe ctx buffer that will be used
*datapointer to the data that will be processed
sizesize_t type, that hold the size
void MD5::MD5Init ( void *  ctxBuf)
static

Initialized the MD5 hashing process. this function must be called before MD5Update or MD5Final

Parameters
*ctxBufthe ctx buffer that will be used
void MD5::MD5Final ( unsigned char *  result,
void *  ctxBuf 
)
static

MD5Final finilized the Hashing process and creates the diggest. This function must be called after MD5Init and MD5Update

Parameters
*resultpointer that will hold the digest.
*ctxBufthe ctx buffer that will be used
Returns
no return, the result is storesin the *result pointer
void MD5::MD5Update ( void *  ctxBuf,
const void *  data,
size_t  size 
)
static

MD5Update adds data in the buffers. This function can be used as many times as we want in the hashing process. Examples on hmac_md5 functions.

Parameters
*ctxBufthe ctx buffer that will be used
*datathe actual data that will be used in the hashing process.
sizesize_t type, indicated the side of the data pointer.
double MD5::millis ( )

used in linux in order to retrieve the time in milliseconds.

Returns
returns the milliseconds in a double format.
Examples:
HMAC_MD5.cpp, and MD5_Hash.cpp.

Member Data Documentation

timeval MD5::tv
private

holds the time value on linux