/**
 * 
 * @file sha256.h
 * 
 * @ingroup generic_bootloader_8bit
 * 
 * @brief This file contains API prototypes for SHA256 cryptographic hash calculation.
 *
 * @version BOOTLOADER Driver Version 3.0.0
*/

${disclaimer}

#ifndef _SHA256_H
#define _SHA256_H
 
#include <stdint.h>

/**
 * @ingroup generic_bootloader_8bit
 * @brief Initializes a SHA-256 context to perform a SHA-256 hash.
 * @param none
 * @retval none
 */
void SHA256_Initialize(void);

/**
 * @ingroup generic_bootloader_8bit
 * @brief This routine adds data to a SHA-256 hash being calculated.  When the data 
 *        length reaches a block size (64 bytes), this function will calculate the hash 
 * over that block and store the current hash value in the hash context.
 * @param data - Pointer to the data being added.
 * @retval none
 */
void SHA256_DataAdd (uint8_t * data);

/**
 * @ingroup generic_bootloader_8bit
 * @brief This routine finishes calculating a SHA-256 hash.  It will automatically add 
 *        the padding required by the hashing algorithm and return the hash digest.
 * @param result - A buffer to store the calculated hash digest.
 *                 32 bytes for SHA-256, 28 bytes for SHA-224.
 * @retval none
 */
void SHA256_Calculate(uint8_t *result);

/**
 * @ingroup generic_bootloader_8bit
 * @brief This routine calculates SHA256  over the range of user application memory
 *        startAddress and endAddress are inclusive.
 * @param startAddress - The start address of the memory range for hash calculation
 * @param endAddress - The end address of the memory range for hash calculation
 * @param resultBuffer - A buffer to store the calculated hash digest (32 bytes for SHA-256)
 * @retval none
 */
void SHA256(const uint32_t startAddress, const uint32_t endAddress, uint8_t* resultBuffer);

#endif //_SHA256_H
