ccRTP 2.1.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
gcrypthmac.cpp File Reference
#include <gcrypt.h>
#include <crypto/hmac.h>
#include <stdio.h>
Include dependency graph for gcrypthmac.cpp:

Go to the source code of this file.

Functions

void hmac_sha1 (uint8_t *key, int32_t keyLength, const uint8_t *data, int32_t dataLength, uint8_t *mac, int32_t *macLength)
 
void hmac_sha1 (uint8_t *key, int32_t keyLength, const uint8_t *dataChunks[], uint32_t dataChunkLength[], uint8_t *mac, int32_t *macLength)
 Compute SHA1 HMAC over several data cunks. More...
 
void * createSha1HmacContext (uint8_t *key, int32_t key_length)
 Create and initialize a SHA1 HMAC context. More...
 
void hmacSha1Ctx (void *ctx, const uint8_t *data, uint32_t data_length, uint8_t *mac, int32_t *mac_length)
 Compute SHA1 HMAC. More...
 
void hmacSha1Ctx (void *ctx, const uint8_t *data[], uint32_t data_length[], uint8_t *mac, int32_t *mac_length)
 Compute SHA1 HMAC over several data cunks. More...
 
void freeSha1HmacContext (void *ctx)
 Free SHA1 HMAC context. More...
 

Function Documentation

void* createSha1HmacContext ( uint8_t *  key,
int32_t  key_length 
)

Create and initialize a SHA1 HMAC context.

An application uses this context to create several HMAC with the same key.

Parameters
keyThe MAC key.
key_lengthLenght of the MAC key in bytes
Returns
Returns a pointer to the initialized context

Definition at line 70 of file gcrypthmac.cpp.

void freeSha1HmacContext ( void *  ctx)

Free SHA1 HMAC context.

Parameters
ctxa pointer to SHA1 HMAC context

Definition at line 113 of file gcrypthmac.cpp.

void hmac_sha1 ( uint8_t *  key,
int32_t  keyLength,
const uint8_t *  data,
int32_t  dataLength,
uint8_t *  mac,
int32_t *  macLength 
)

Definition at line 28 of file gcrypthmac.cpp.

void hmac_sha1 ( uint8_t *  key,
int32_t  key_length,
const uint8_t *  data[],
uint32_t  data_length[],
uint8_t *  mac,
int32_t *  mac_length 
)

Compute SHA1 HMAC over several data cunks.

This functions takes several data chunk and computes the SHA1 HAMAC.

Parameters
keyThe MAC key.
key_lengthLneght of the MAC key in bytes
dataPoints to an array of pointers that point to the data chunks. A NULL pointer in an array element terminates the data chunks.
data_lengthPoints to an array of integers that hold the length of each data chunk.
macPoints to a buffer that receives the computed digest. This buffer must have a size of at least 20 bytes (SHA1_DIGEST_LENGTH).
mac_lengthPoint to an integer that receives the length of the computed HMAC.

Definition at line 47 of file gcrypthmac.cpp.

void hmacSha1Ctx ( void *  ctx,
const uint8_t *  data,
uint32_t  data_length,
uint8_t *  mac,
int32_t *  mac_length 
)

Compute SHA1 HMAC.

This functions takes one data chunk and computes its SHA1 HMAC. On return the SHA1 MAC context is ready to compute a HMAC for another data chunk.

Parameters
ctxPointer to initialized SHA1 HMAC context
dataPoints to the data chunk.
data_lengthLength of the data in bytes
macPoints to a buffer that receives the computed digest. This buffer must have a size of at least 20 bytes (SHA1_DIGEST_LENGTH).
mac_lengthPoint to an integer that receives the length of the computed HMAC.

Definition at line 79 of file gcrypthmac.cpp.

void hmacSha1Ctx ( void *  ctx,
const uint8_t *  data[],
uint32_t  data_length[],
uint8_t *  mac,
int32_t *  mac_length 
)

Compute SHA1 HMAC over several data cunks.

This functions takes several data chunks and computes the SHA1 HAMAC. On return the SHA1 MAC context is ready to compute a HMAC for another data chunk.

Parameters
ctxPointer to initialized SHA1 HMAC context
dataPoints to an array of pointers that point to the data chunks. A NULL pointer in an array element terminates the data chunks.
data_lengthPoints to an array of integers that hold the length of each data chunk.
macPoints to a buffer that receives the computed digest. This buffer must have a size of at least 20 bytes (SHA1_DIGEST_LENGTH).
mac_lengthPoint to an integer that receives the length of the computed HMAC.

Definition at line 95 of file gcrypthmac.cpp.