TrustCore SDK Crypto Interface API reference  version 2.0
crypto_interface_hmac.h File Reference

Cryptographic Interface header file for declaring HMAC functions. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_MD5 (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pTextOpt, sbyte4 textOptLen, ubyte pResult[MD5_DIGESTSIZE])
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_MD5_quick (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, ubyte *pResult)
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA1 (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pTextOpt, sbyte4 textOptLen, ubyte pResult[SHA_HASH_RESULT_SIZE])
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA1_96 (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pTextOpt, sbyte4 textOptLen, ubyte *pResult)
 Computes a hmac-sha1 truncated to 96 bits. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA1_quick (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, ubyte *pResult)
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA1Ex (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *ppTexts[], sbyte4 pTextLens[], sbyte4 numTexts, ubyte pResult[SHA_HASH_RESULT_SIZE])
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA256 (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pTextOpt, sbyte4 textOptLen, ubyte pResult[SHA256_RESULT_SIZE])
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA512 (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pTextOpt, sbyte4 textOptLen, ubyte pResult[SHA512_RESULT_SIZE])
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacCloneCtx (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX **ppDest, HMAC_CTX *pSrc)
 Allocates and makes a clone of a HMAC_CTX. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacCreate (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX **ppCtx, const BulkHashAlgo *pBHAlgo)
 Create HMAC context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacDelete (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX **ppCtx)
 Delete (free) HMAC context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacFinal (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *pCtx, ubyte *pResult)
 Get final HMAC value. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacKey (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *pCtx, const ubyte *pKey, ubyte4 keyLen)
 Insert and process HMAC context's key. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuick (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, ubyte *pResult, const BulkHashAlgo *pBHAlgo)
 Calculate HMAC (with a single function call). More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuicker (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, ubyte *pResult, const BulkHashAlgo *pBHAlgo, HMAC_CTX *pCtx)
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuickerEx (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pOptText, ubyte4 optTextLen, ubyte *pResult, const BulkHashAlgo *pBHAlgo, HMAC_CTX *pCtx)
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuickerInline (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, ubyte *pResult, const BulkHashAlgo *pBHAlgo, BulkCtx pContext)
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuickerInlineEx (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pOptText, sbyte4 optTextLen, ubyte *pResult, const BulkHashAlgo *pBHAlgo, BulkCtx pContext)
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuickEx (MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *pKey, sbyte4 keyLen, const ubyte *pText, sbyte4 textLen, const ubyte *pOptText, ubyte4 optTextLen, ubyte *pResult, const BulkHashAlgo *pBHAlgo)
 Calculate HMAC (with a single function call) for a message with extended data. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacReset (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *pCtx)
 Reset HMAC context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacSingle (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *pCtx, const ubyte *pText, sbyte4 textLen, ubyte *pResult)
 Calculate HMAC with a single function call, using a prekeyed HMAC ctx. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacUpdate (MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *pCtx, const ubyte *pData, ubyte4 dataLen)
 Update intermediate HMAC value. More...
 

Detailed Description

Add details here.

crypto_interface_hmac.h

Function Documentation

◆ CRYPTO_INTERFACE_HMAC_SHA1_96()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HMAC_SHA1_96 ( MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *  pKey,
sbyte4  keyLen,
const ubyte *  pText,
sbyte4  textLen,
const ubyte *  pTextOpt,
sbyte4  textOptLen,
ubyte *  pResult 
)

Computes a hmac-sha1 truncated to 96 bits.

Parameters
pKeyBufere holding the hmac key.
keyLenThe length of the key in bytes.
pTextThe input data.
textLenThe length of the input data in bytes.
pTextOptOptional additional input data.
textOptLenThe length of the optional input data in bytes.
pResultBuffer that will be filled with the resulting mac. This must be at least 12 bytes in length.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_HmacCloneCtx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacCloneCtx ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX **  ppDest,
HMAC_CTX *  pSrc 
)

Allocates and makes a clone of a HMAC_CTX. Make sure to call CRYPTO_INTERFACE_HmacDelete when finished with the new context.

Parameters
ppDestLocation that will recieve a pointer to a newly allocated context.
pSrcPointer to the context to be copied.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_HmacCreate()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacCreate ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX **  ppCtx,
const BulkHashAlgo *  pBHAlgo 
)

This function creates an HMAC context and initializes data structure fields (function pointers) related to the hash function to be used within HMAC operations.

To avoid memory leaks, your application code must call the HmacDelete() function after HMAC-related operations (because the HMAC context is dynamically allocated by this function during context creation).

Note
If you need an HMAC value for only a single message, it is more efficient to call the HmacQuick() function.
Warning
Be sure to check this function's return status. An unsuccessful return causes subsequent HMAC single-step operations to fail.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
ppCtxOn return, pointer to resultant HMAC context.
pBHAlgoOn return, pointer to collection of hash routines to be used within HMAC.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacDelete()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacDelete ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX **  ppCtx)

This function deletes (frees) an HMAC context. Your application should call this function as soon as it is done using an HMAC context created by HmacCreate().

Note
If you need an HMAC value for only a single message, it is more efficient to call the HmacQuick() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
ppCtxPointer to HMAC context to delete.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacFinal()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacFinal ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *  pCtx,
ubyte *  pResult 
)

This function calculates a final HMAC value, and returns it through the result parameter.

Warning
Before calling this function, be sure that the buffer pointed to by the result parameter is large enough: at least equal to the output size of the underlying hash function (for example, 20 bytes for SHA1). Otherwise, buffer overflow will occur.
Note
If you need an HMAC value for only a single message, it is more efficient to call the HmacQuick() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pCtxPointer to HMAC context.
pResultOn return, pointer to resultant HMAC value. (The calling function must allocate sufficient memory for the result: at least equal to the output size of the underlying hash function — for example, 20 bytes for SHA1. Otherwise buffer overflow will occur.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacKey()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacKey ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *  pCtx,
const ubyte *  pKey,
ubyte4  keyLen 
)

This function inserts and processes an HMAC context's key. After calling this function, your application should call HmacUpdate().

Note
If you need an HMAC value for only a single message, it is more efficient to call the HmacQuick() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pCtxPointer to HMAC context.
pKeyPointer to HMAC key to insert.
keyLenNumber of bytes in HMAC key (key).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacQuick()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuick ( MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *  pKey,
sbyte4  keyLen,
const ubyte *  pText,
sbyte4  textLen,
ubyte *  pResult,
const BulkHashAlgo *  pBHAlgo 
)

This function completely calculates an HMAC, with no need to call multiple, "separate steps" methods. Before calling this function, allocate and assign the desired algorithm values to the pBHAlgo parameter. (Using values for SHA1 is the equivalent to calling the HMAC_SHA1() function.) The resultant HMAC value is returned through the pResult parameter.

Warning
Before calling this function, be sure that the buffer pointed to by the result parameter is large enough: at least equal to the output size of the underlying hash function (for example, 20 bytes for SHA1). Otherwise, buffer overflow will occur.
Note
This function is the most efficient method to calculate the HMAC for a single message, saving both memory and time. However, if you need to calculate the HMAC-MD5 for two or more messages, you must use the "separate steps" methods, HmacCreate(), HmacKey(), HmacReset(), HmacUpdate(), HmacFinal(), and HmacDelete().
To append optional (extended) input data, use the HmacQuickEx() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-MD5, HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pKeyPointer to HMAC key to insert.
keyLenNumber of bytes in HMAC key (pKey).
pTextPointer to input data.
textLenNumber of bytes of input data (pText).
pResultOn return, pointer to resultant HMAC value. (The calling function must allocate sufficient memory for the result: at least equal to the output size of the underlying hash function — for example, 20 bytes for SHA1. Otherwise buffer overflow will occur.)
pBHAlgoPointer to collection of hash routines used within HMAC. (Refer to crypto.h for the structure definition.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacQuickEx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacQuickEx ( MOC_HASH(hwAccelDescr hwAccelCtx) const ubyte *  pKey,
sbyte4  keyLen,
const ubyte *  pText,
sbyte4  textLen,
const ubyte *  pOptText,
ubyte4  optTextLen,
ubyte *  pResult,
const BulkHashAlgo *  pBHAlgo 
)

This function completely calculates an HMAC for a message with extended data, with no need to call multiple, "separate steps" methods. Before calling this function, allocate and assign the desired algorithm values to the pBHAlgo parameter. (Using values for SHA1 is the equivalent to calling the HMAC_SHA1() function.) The resultant HMAC value is returned through the pResult parameter.

Warning
Before calling this function, be sure that the buffer pointed to by the result parameter is large enough: at least equal to the output size of the underlying hash function (for example, 20 bytes for SHA1). Otherwise, buffer overflow will occur.
Note
This function is the most efficient method to calculate the HMAC for a single message, saving both memory and time. However, if you need to calculate the HMAC-MD5 for two or more messages, you must use the "separate steps" methods, HmacCreate(), HmacKey(), HmacReset(), HmacUpdate(), HmacFinal(), and HmacDelete().
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-MD5, HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pKeyPointer to HMAC key to insert.
keyLenNumber of bytes in HMAC key (pKey).
pTextPointer to input data.
textLenNumber of bytes of input data (pText).
pOptTextPointer to optional (extended) input data to append after (pText); may be NULL to indicate none (which makes this function equivalent to the HmacQuick() function).
optTextLenNumber of bytes of optional input data (pOptText); may be zero to indicate none.
pResultOn return, pointer to resultant HMAC value. (The calling function must allocate sufficient memory for the result: at least equal to the output size of the underlying hash function — for example, 20 bytes for SHA1. Otherwise buffer overflow will occur.)
pBHAlgoPointer to collection of hash routines used within HMAC. (Refer to crypto.h for the structure definition.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacReset()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacReset ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *  pCtx)

This function resets an HMAC context.

Note
If you need an HMAC value for only a single message, it is more efficient to call the HmacQuick() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pCtxPointer to HMAC context.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacSingle()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacSingle ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *  pCtx,
const ubyte *  pText,
sbyte4  textLen,
ubyte *  pResult 
)

This function completely calculates an HMAC, with no need to call multiple, "separate steps" methods. Before calling this function, allocate and assign the desired algorithm values to the pBHAlgo parameter. (Using values for SHA1 is the equivalent to calling the HMAC_SHA1() function.) The resultant HMAC value is returned through the pResult parameter.

Warning
Before calling this function, be sure that the buffer pointed to by the result parameter is large enough: at least equal to the output size of the underlying hash function (for example, 20 bytes for SHA1). Otherwise, buffer overflow will occur.
Note
This function is the most efficient method to calculate the HMAC for a single message, saving both memory and time. However, if you need to calculate the HMAC-MD5 for two or more messages, you must use the "separate steps" methods, HmacCreate(), HmacKey(), HmacReset(), HmacUpdate(), HmacFinal(), and HmacDelete().
To append optional (extended) input data, use the HmacQuickEx() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-MD5, HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pCtxPointer to previously created and keyed HMAC ctx.
pTextPointer to input data.
textLenNumber of bytes of input data (pText).
pResultOn return, pointer to resultant HMAC value. (The calling function must allocate sufficient memory for the result: at least equal to the output size of the underlying hash function — for example, 20 bytes for SHA1. Otherwise buffer overflow will occur.)
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c

◆ CRYPTO_INTERFACE_HmacUpdate()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_HmacUpdate ( MOC_HASH(hwAccelDescr hwAccelCtx) HMAC_CTX *  pCtx,
const ubyte *  pData,
ubyte4  dataLen 
)

This function updates the intermediate HMAC value in an HMAC context. Applications can repeatedly call this function to calculate an HMAC for different data items.

Note
If you need an HMAC value for only a single message, it is more efficient to call the HmacQuick() function.
FIPS Approved
check-green.gif
Suite B Algorithm
x-red.gif
Flowchart HMAC-SHA*

There are no flag dependencies to enable this function.

hmac.h

Parameters
hwAccelCtxIf a hardware acceleration flag is defined, this macro expands to an additional parameter, "hwAccelDescr hwAccelCtx". Otherwise, this macro resolves to nothing.
pCtxPointer to HMAC context.
pDataPointer to input data.
dataLenNumber of bytes of input data (text).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

hmac.c