cctools
Functions
hmac.h File Reference

Routines for computing Hash-based Message Authentication Codes. More...

#include <stdlib.h>
#include "sha1.h"
#include "md5.h"

Go to the source code of this file.

Functions

int hmac (const void *buffer, size_t buffer_length, const void *key, size_t key_length, unsigned char *digest, size_t digest_len, size_t block_size, void(*hash_func)(const void *, size_t, unsigned char *))
 Generate HMAC. More...
 
int hmac_md5 (const void *buffer, size_t buffer_length, const void *key, size_t key_length, unsigned char digest[MD5_DIGEST_LENGTH])
 
Generate HMAC using md5 hash function

Note that this function produces a digest in binary form which must be converted to a human readable form with md5_string. More...

 
int hmac_sha1 (const void *buffer, size_t buffer_length, const void *key, size_t key_length, unsigned char digest[SHA1_DIGEST_LENGTH])
 
Generate HMAC using sha1 hash function

Note that this function produces a digest in binary form which must be converted to a human readable form with sha1_string. More...

 

Detailed Description

Routines for computing Hash-based Message Authentication Codes.

Function Documentation

int hmac ( const void *  buffer,
size_t  buffer_length,
const void *  key,
size_t  key_length,
unsigned char *  digest,
size_t  digest_len,
size_t  block_size,
void(*)(const void *, size_t, unsigned char *)  hash_func 
)

Generate HMAC.

Parameters
bufferPointer to a memory buffer.
buffer_lengthLength of the buffer in bytes.
keyPointer to a buffer containing the key for hashing.
key_lengthThe length of the key in bytes.
digestPointer to a buffer to store the digest.
digest_lenThe length of the digest buffer.
block_sizeThe size of the block used by the hash function in bytes.
hash_funcA function pointer to the hash function to be used.
int hmac_md5 ( const void *  buffer,
size_t  buffer_length,
const void *  key,
size_t  key_length,
unsigned char  digest[MD5_DIGEST_LENGTH] 
)

Generate HMAC using md5 hash function

Note that this function produces a digest in binary form which must be converted to a human readable form with md5_string.

Parameters
bufferPointer to a memory buffer.
buffer_lengthLength of the buffer in bytes.
keyPointer to a buffer containing the key for hashing.
key_lengthThe length of the key in bytes.
digestPointer to a buffer of size MD5_DIGEST_LENGTH to store the digest.
int hmac_sha1 ( const void *  buffer,
size_t  buffer_length,
const void *  key,
size_t  key_length,
unsigned char  digest[SHA1_DIGEST_LENGTH] 
)

Generate HMAC using sha1 hash function

Note that this function produces a digest in binary form which must be converted to a human readable form with sha1_string.

Parameters
bufferPointer to a memory buffer.
buffer_lengthLength of the buffer in bytes.
keyPointer to a buffer containing the key for hashing.
key_lengthThe length of the key in bytes.
digestPointer to a buffer of size SHA1_DIGEST_LENGTH to store the digest.