/**
  * \file		hmac_sha256.h
  *
  * \brief		HMAC-SHA256 algorithm (Hash-based message authentication code)
  *
  * \author		Dmitriy Dorogovtsev (d.dorogovtse@samsung.com)
  *
  * \version	1.0
  *
  * \date		Created May 17, 2012
  *
  * \par		In Samsung Ukraine R&D Center (SURC) under a contract between
  * \par		LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine) and
  * \par		"Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
  * \par		Copyright: (c) Samsung Electronics Co, Ltd 2012. All rights reserved.
  */

#ifndef HMAC_SHA256_H
#define HMAC_SHA256_H

#include "sha_256_hash.h"

/**
  * HMAC SHA-1 algorithm structure
  */
typedef struct
{
	uint32_t keyLength; /**< Length of input key in bytes */
	uint8_t key [ SHA256_MESSAGE_BLOCK_LENGTH ]; /**< Stored key */
	SHA_256_Hash hashCtx; /**< SHA-256 context for hash calculation */
} HMAC_SHA256;

/**
  * \brief				Initialization of HMAC SHA-256 context
  *
  * \param hmac			Pointer to HMAC_SHA256 object
  * \param key			Private key for HMAC function
  * \param keylength	Length of key in bytes
  * \return				void
  */
void init_HMAC_SHA256( HMAC_SHA256 * hmac, const uint8_t* key, unsigned int keylength );

/**
  * \brief				Process part of data via HMAC function. Should be called after
						intialization as many times as needed for the whole data buffer.
  *
  * \param hmac			Pointer to HMAC_SHA256 object
  * \param data			Pointer to data chunk to process
  * \param datalength	Length of data chunk in bytes
  * \return				void
  */
void update_HMAC_SHA256( HMAC_SHA256 * hmac, const uint8_t* data, unsigned int datalength );

/**
  * \brief		Obtain result and reset HMAC context
  *
  * \param hmac	Pointer to HMAC_SHA256 object
  * \param mac	Resulting message authentication code. Should point to 20 bytes (length of
				SHA-256 message digest) of memory.
  * \return		void
  */
void final_HMAC_SHA256( HMAC_SHA256 * hmac, uint8_t* mac );

#endif




