|
QuickHash Library |
API |
|
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 |
|
MD4 |
SLC_MD4_CONTEXTSIZE |
SLC_MD4_BLOCKSIZE |
|
MD5 |
SLC_MD5_CONTEXTSIZE |
SLC_MD5_BLOCKSIZE |
|
SHA-1 |
SLC_SHA1_CONTEXTSIZE |
SLC_SHA1_BLOCKSIZE |
|
SHA-256 |
SLC_SHA256_CONTEXTSIZE |
SLC_SHA256_BLOCKSIZE |
|
SHA-512 |
SLC_SHA512_CONTEXTSIZE |
SLC_SHA512_BLOCKSIZE |
|
SHA-384 |
SLC_SHA384_CONTEXTSIZE |
SLC_SHA384_BLOCKSIZE |
|
RIPEMD128 |
SLC_RIPEMD128_CONTEXTSIZE |
SLC_RIPEMD128_BLOCKSIZE |
|
RIPEMD160 |
SLC_RIPEMD160_CONTEXTSIZE |
SLC_RIPEMD160_BLOCKSIZE |
|
RIPEMD256 |
SLC_RIPEMD256_CONTEXTSIZE |
SLC_RIPEMD256_BLOCKSIZE |
|
RIPEMD320 |
SLC_RIPEMD320_CONTEXTSIZE |
SLC_RIPEMD320_BLOCKSIZE |
|
PANAMA |
SLC_PANAMA_CONTEXTSIZE |
SLC_PANAMA_BLOCKSIZE |
|
TIGER |
SLC_TIGER_CONTEXTSIZE |
SLC_TIGER_BLOCKSIZE |
-
Call the
SL_HMAC_Update function for each continuous memory block of data
to perform the calculations.
Note. You can use
SL_HMAC_UpdateStr function
(instead of
SL_HMAC_Update function)
if the data represents a null-terminated string.
To generate the HMAC in the non-accumulative mode,
perform the following:
HMAC API Functions
|
Useful Links | HashCalc
|