SHA is Secure Hash Algorithm, It is used as a unique value of fixed size representing a large amount of data. Hashes of two sets of data should match if and only if the corresponding data also matches. Small changes to the data result in large unpredictable changes in the hash.The hash size for the SHA512 algorithm is 512 bits and hash size for the SHA256 algorithm is 256 bits.
Features Supported
- Latest versions of Secure Hash Algorithm SHA-512 and SHA-256
- Handles different input buffer lengths.
- It used upto 1024 bits blocks.
- Accepts 2^128 bits maximum length string.
- The initial hash values and round constants are 64 bits in SHA-512 and 32 bits in SHA-256.
- No of rounds 80 for SHA-512 and 64 rounds for SHA 256.
- Word size 64 bits for SHA-512 and 32 bits for SHA-256.
- Supports Hmac Sha-512 and Sha-256.
SysConfig Features
Features NOT Supported
Usage Overview
API Sequence
To use the SHA driver to generate hash for differnt data. Use the following APIs:
HMAC API Sequence
To use the HMAC SHA driver to generate hash for differnt data. Use the following APIs:
Initializing the SHA Driver context buffer
- Crypto_shaOpen() must be called before any other SHA APIs. This function Initializes a SHA context and iterates through the elements of the gCryptoShaConfig[] array. Please note that initializing SHA driver is taken care by the SysConfig generated code.
Generating Hash with SHA Driver
Generating HMAC SHA
- Set the input parameters using Crypto_ShaParams structure, all necessary parametets set to Crypto_ShaParams variables and call Crypto_shaOpen() for Initialize the Sha ctx. To compute fixed block Hmac hash i.e call Crypto_hmacSha() by updating references to input buffer, length and Output buffer. Hash will be available at output buffer on successful computation. Once SHA computation is done for the required data length, reset the SHA ctx buffer using Crypto_shaClose().
Clearing the SHA Driver context buffer
Important Usage Guidelines
Example Usage
Include the below file to access the APIs
Hash Example
static Crypto_ShaContext gCryptoSha512Context;
uint8_t buf[10]={"abcedfghij"};
int32_t buf_len=10;
uint8_t sha512sum[64];
API
APIs for CRYPTO SHA