|
QuickHash Library |
API |
|
SL_HMAC_Init
int SL_HASHCALL SL_HMAC_Init( void* pContext,
unsigned int nAlgID, const void* pKey, unsigned int
nKeyLength );
Return value
Nonzero if initialization is successful, otherwise 0. In particular, this
function returns 0 when nAlgID is invalid.
Parameters
pContext
[out] Pointer to the memory buffer that
will be used as a context.
nAlgID
[in] The ID of the hash
algorithm selected for calculations. For example, nAlgID has to be set
to SLC_SHA1_ALGID when you need to calculate the HMAC using SHA-1
hash algorithm.
All supported hash algorithms with
their corresponding IDs are listed in
Table1.
pKey
[in] Pointer to the key
which represents a continuous memory block.
nKeyLength
[in] Length in bytes of the key.
Remarks
Initializes the context pointed by pContext
with the key pointed by pKey. Before calling SL_HMAC_Init 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_SHA1_CONTEXTSIZE, SLC_SHA1_BLOCKSIZE
)
bytes for the context if you need to calculate the HMAC using SHA-1 hash
algorithm.
All supported hash algorithms with
their corresponding
CONTEXTSIZEs and BLOCKSIZEs are listed in Table1.
Table1. Supported
hash algorithms, their IDs, CONTEXTSIZEs and BLOCKSIZEs.
|
Algorithm Name |
Algorithm ID |
Algorithm CONTEXTSIZE |
Algorithm BLOCKSIZE |
|
MD4 |
SLC_MD4_ALGID |
SLC_MD4_CONTEXTSIZE |
SLC_MD4_BLOCKSIZE |
|
MD5 |
SLC_MD5_ALGID |
SLC_MD5_CONTEXTSIZE |
SLC_MD5_BLOCKSIZE |
|
SHA-1 |
SLC_SHA1_ALGID |
SLC_SHA1_CONTEXTSIZE |
SLC_SHA1_BLOCKSIZE |
|
SHA-256 |
SLC_SHA256_ALGID |
SLC_SHA256_CONTEXTSIZE |
SLC_SHA256_BLOCKSIZE |
|
SHA-512 |
SLC_SHA512_ALGID |
SLC_SHA512_CONTEXTSIZE |
SLC_SHA512_BLOCKSIZE |
|
SHA-384 |
SLC_SHA384_ALGID |
SLC_SHA384_CONTEXTSIZE |
SLC_SHA384_BLOCKSIZE |
|
RIPEMD128 |
SLC_RIPEMD128_ALGID |
SLC_RIPEMD128_CONTEXTSIZE |
SLC_RIPEMD128_BLOCKSIZE |
|
RIPEMD160 |
SLC_RIPEMD160_ALGID |
SLC_RIPEMD160_CONTEXTSIZE |
SLC_RIPEMD160_BLOCKSIZE |
|
RIPEMD256 |
SLC_RIPEMD256_ALGID |
SLC_RIPEMD256_CONTEXTSIZE |
SLC_RIPEMD256_BLOCKSIZE |
|
RIPEMD320 |
SLC_RIPEMD320_ALGID |
SLC_RIPEMD320_CONTEXTSIZE |
SLC_RIPEMD320_BLOCKSIZE |
|
PANAMA |
SLC_PANAMA_ALGID |
SLC_PANAMA_CONTEXTSIZE |
SLC_PANAMA_BLOCKSIZE |
|
TIGER |
SLC_TIGER_ALGID |
SLC_TIGER_CONTEXTSIZE |
SLC_TIGER_BLOCKSIZE |
Example
See the example for
SL_HMAC_Final.
HMAC API Overview
| HMAC API Functions
|
Useful Links | HashCalc
See Also
SL_HMAC_InitKeyStr,
SL_HMAC_Final,
SL_HMAC_FinalHex,
SL_HMAC_Update,
SL_HMAC_UpdateStr
|