HMAC API Overview
HMAC API assists you in generating Keyed-Hash Message Authentication Codes (HMACs).
HMACs can be generated in two modes: accumulative and non-accumulative.
The accumulative mode is applied when the data for which the HMAC is calculated (data) represents one or more continuous memory block(s) or when the data is created at runtime in many steps (for instance, when reading a file).
Non-accumulative mode can be applied when the data represents only one continuous memory block.
Note. When the data represents just one continuous memory block, both methods can be applied.
To generate the HMAC in the accumulative mode, perform the following:
Allocate at least SLC_HMAC_CONTEXTSIZE( CONTEXTSIZE, BLOCKSIZE ) bytes for the context. CONTEXTSIZE and BLOCKSIZE from the previous notation are predefined constants for the context size and the block size for a specific hash algorithm. For example, you have to allocate at least SLC_HMAC_CONTEXTSIZE( SLC_MD5_CONTEXTSIZE, SLC_MD5_BLOCKSIZE ) bytes for the context if you need to calculate the HMAC using MD5 hash algorithm.
All supported hash algorithms with their corresponding CONTEXTSIZEs and BLOCKSIZEs are listed in the table below.
|Algorithm Name||Algorithm CONTEXTSIZE||Algorithm BLOCKSIZE|
Call the SL_HMAC_Init function to initialize the context with a key.
Call the SL_HMAC_Update function for each continuous memory block of data to perform the calculations.
Note. Call the SL_HMAC_FinalHex function when you need to retrieve the hexadecimal string representation of the HMAC.
To generate the HMAC in the non-accumulative mode, perform the following:
Note 1. Call the SL_HMAC_CalculateHex function when you need to retrieve the hexadecimal string representation of the HMAC.
HMAC API Functions | Useful Links | HashCalc
|Send Feedback to SlavaSoft Inc.||Tell a friend about QuickHash Library|