![]() |
API参考
|
mac of crypto module 更多...

函数 | |
| bool | CRYPT_EAL_MacIsValidAlgId (CRYPT_MAC_AlgId id) |
| Check whether the id is Valid MAC algorithm ID. | |
| CRYPT_EAL_MacCtx * | CRYPT_EAL_MacNewCtx (CRYPT_MAC_AlgId id) |
| Apply for a MAC context. | |
| CRYPT_EAL_MacCtx * | CRYPT_EAL_ProviderMacNewCtx (CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName) |
| Create an MAC context in the providers. | |
| void | CRYPT_EAL_MacFreeCtx (CRYPT_EAL_MacCtx *ctx) |
| Release the MAC context memory. | |
| int32_t | CRYPT_EAL_MacInit (CRYPT_EAL_MacCtx *ctx, const uint8_t *key, uint32_t len) |
| int32_t | CRYPT_EAL_MacUpdate (CRYPT_EAL_MacCtx *ctx, const uint8_t *in, uint32_t len) |
| Continuously input the MAC data. | |
| int32_t | CRYPT_EAL_MacFinal (CRYPT_EAL_MacCtx *ctx, uint8_t *out, uint32_t *len) |
| Output the MAC result. | |
| void | CRYPT_EAL_MacDeinit (CRYPT_EAL_MacCtx *ctx) |
| Deinitialization function. | |
| int32_t | CRYPT_EAL_MacReinit (CRYPT_EAL_MacCtx *ctx) |
| Re-initialize with the information retained in ctx. | |
| uint32_t | CRYPT_EAL_GetMacLen (const CRYPT_EAL_MacCtx *ctx) |
| Through the context, obtain the output MAC length of the corresponding algorithm. | |
| int32_t | CRYPT_EAL_MacCtrl (CRYPT_EAL_MacCtx *ctx, int32_t type, void *in, uint32_t len) |
| Set algorithm parameters. This API must be called after the CRYPT_EAL_MacInit API is called. This API supports only the GMAC algorithm. | |
| int32_t | CRYPT_EAL_MacSetParam (CRYPT_EAL_MacCtx *ctx, const BSL_Param *param) |
| Set algorithm parameters. | |
| int32_t | CRYPT_EAL_MacCopyCtx (CRYPT_EAL_MacCtx *to, const CRYPT_EAL_MacCtx *from) |
| Copy the MAC context. | |
| CRYPT_EAL_MacCtx * | CRYPT_EAL_MacDupCtx (const CRYPT_EAL_MacCtx *from) |
| Dup the MAC context. | |
mac of crypto module
| uint32_t CRYPT_EAL_GetMacLen | ( | const CRYPT_EAL_MacCtx * | ctx | ) |
Through the context, obtain the output MAC length of the corresponding algorithm.
| ctx | [IN] MAC context |
| The | MAC length corresponding to the context. |
| int32_t CRYPT_EAL_MacCopyCtx | ( | CRYPT_EAL_MacCtx * | to, |
| const CRYPT_EAL_MacCtx * | from ) |
Copy the MAC context.
| to | [IN] target MAC context. |
| from | [IN] original MAC context. |
| CRYPT_SUCCESS,parameters | are set successfully. |
| CRYPT_NULL_INPUT,the | input parameter is NULL. Other error codes see crypt_errno.h |
| int32_t CRYPT_EAL_MacCtrl | ( | CRYPT_EAL_MacCtx * | ctx, |
| int32_t | type, | ||
| void * | in, | ||
| uint32_t | len ) |
Set algorithm parameters. This API must be called after the CRYPT_EAL_MacInit API is called. This API supports only the GMAC algorithm.
Parameter Data Type len stands for length, and in represents the number of bytes CRYPT_CTRL_SET_IV uint8_t array Length of IV CRYPT_CTRL_SET_TAGLEN uint32_t 4 bytes, sizeof(uint32_t) CRYPT_CTRL_GET_MACLEN
| ctx | [IN] MAC context |
| type | [IN] Set parameter type. |
| in | [IN] Input data |
| len | [IN] Input data length |
| CRYPT_SUCCESS,parameters | are set successfully. |
| CRYPT_EAL_ERR_STATE,status | incorrect. |
| CRYPT_EAL_MAC_CTRL_TYPE_ERROR,the | parameter type is set incorrect. |
| CRYPT_EAL_ERR_ALGID,algorithm | ID exclude GMAC. Other error codes see crypt_errno.h |
| void CRYPT_EAL_MacDeinit | ( | CRYPT_EAL_MacCtx * | ctx | ) |
Deinitialization function.
If calculation is required after this function is called, it needs to be initialized again.
| ctx | [IN] MAC context |
| CRYPT_EAL_MacCtx * CRYPT_EAL_MacDupCtx | ( | const CRYPT_EAL_MacCtx * | from | ) |
Dup the MAC context.
| from | [IN] original MAC context. |
| CRYPT_EAL_MacCtx,MAC | context pointer. NULL, if the operation fails. |
| int32_t CRYPT_EAL_MacFinal | ( | CRYPT_EAL_MacCtx * | ctx, |
| uint8_t * | out, | ||
| uint32_t * | len ) |
Output the MAC result.
This API must be used after the CRYPT_EAL_MacInit API is successfully executed, during the process, you
do not need to call the CRYPT_EAL_MacUpdate API. MAC output length. HMAC-SHA1 corresponds to 20 bytes, HMAC-SHA224 corresponds to 28 bytes, and HMAC-SHA256 corresponds to 32 bytes. HMAC-SHA384 corresponds to 48 bytes, HMAC-SHA512 corresponds to 64 bytes, and CMAC-AES corresponds to 16 bytes. HMAC-SHA3-224 corresponds to 28 bytes, HMAC-SHA3-256 corresponds to 32 bytes, HMAC-SHA3-384 corresponds to 48 bytes, and HMAC-SHA3-512 corresponds to 64 bytes.
| ctx | [IN] MAC context |
| out | [OUT] Output data. Sufficient memory must be allocated to store MAC results and cannot be null. |
| len | [IN/OUT] Output data length. The input parameter must specify the out length, which must be greater than or equal to the length generated by the MAC. The output parameter is the output length of the MAC. |
| CRYPT_SUCCESS,calculation | succeeded. |
| CRYPT_NULL_INPUT,the | input parameter is NULL. |
| CRYPT_EAL_ERR_STATE,status | incorrect. |
| CRYPT_HMAC_OUT_BUFF_LEN_NOT_ENOUGH,the | length of the output buffer in the HMAC algorithm is insufficient. |
| CRYPT_CMAC_OUT_BUFF_LEN_NOT_ENOUGH,the | length of the output buffer in the CMAC algorithm is insufficient. |
| CRYPT_SHA1_INPUT_OVERFLOW,the | length of the HMAC-SHA1 input data exceeds the maximum. |
| CRYPT_SHA2_INPUT_OVERFLOW,the | length of the input data in HMAC-SHA224, HMAC-SHA256, HMAC-SHA384, or HMAC-SHA512 exceeds the maximum value. Other error codes see the crypt_errno.h |
| void CRYPT_EAL_MacFreeCtx | ( | CRYPT_EAL_MacCtx * | ctx | ) |
Release the MAC context memory.
| ctx | [IN] MAC context, ctx set NULL by caller. |
| int32_t CRYPT_EAL_MacInit | ( | CRYPT_EAL_MacCtx * | ctx, |
| const uint8_t * | key, | ||
| uint32_t | len ) |
MAC algorithm initialize the context, which is used after the CRYPT_EAL_MacNewCtx interface is called. The initialization interface can be used at any time during the calculation, note that the last calculation data is cleared after the initialization interface is called.
| ctx | [IN] MAC context |
| key | [IN] Key, The length specifications are as follows: HMAC:Any integer greater than or equal to 0 The length of HMAC-SHA1, HMAC-SHA224, and HMAC-SHA256 must be less than 2^64 bits, the length of HMAC-SHA384 and HMAC-SHA512 must be less than 2^128 bits. HMAC-SHA3 series has no limit on length CMAC: The length of CMAC-AES128 must be 128 bits, and the length of CMAC-AES192 must be 192 bits. The length of CMAC-AES256 must be 256 bits. |
| len | [IN] Key length |
| CRYPT_SUCCESS,initialization | succeeded. |
| CRYPT_NULL_INPUT,pointer | ctx parameter or key parameter is NULL. |
| CRYPT_AES_ERR_KEYLEN,the | key length of the AES & CMAC algorithm is incorrect. Other error codes see the crypt_errno.h. |
| bool CRYPT_EAL_MacIsValidAlgId | ( | CRYPT_MAC_AlgId | id | ) |
Check whether the id is Valid MAC algorithm ID.
| id | [IN] MAC algorithm ID |
| true,if | valid. false, if invalid. |
| CRYPT_EAL_MacCtx * CRYPT_EAL_MacNewCtx | ( | CRYPT_MAC_AlgId | id | ) |
Apply for a MAC context.
| id | [IN] MAC algorithm ID |
| CRYPT_EAL_MacCtx | Pointer. NULL, if the operation fails. |
| int32_t CRYPT_EAL_MacReinit | ( | CRYPT_EAL_MacCtx * | ctx | ) |
Re-initialize with the information retained in ctx.
| ctx | [IN] MAC context |
| CRYPT_SUCCESS,reinit | succeeded. |
| CRYPT_NULL_INPUT,the | input parameter is NULL. |
| int32_t CRYPT_EAL_MacSetParam | ( | CRYPT_EAL_MacCtx * | ctx, |
| const BSL_Param * | param ) |
Set algorithm parameters.
| ctx | [IN] MAC context |
| param | [IN] Parameter |
| CRYPT_SUCCESS,parameters | are set successfully. |
| CRYPT_NULL_INPUT,the | input parameter is NULL. Other error codes see crypt_errno.h |
| int32_t CRYPT_EAL_MacUpdate | ( | CRYPT_EAL_MacCtx * | ctx, |
| const uint8_t * | in, | ||
| uint32_t | len ) |
Continuously input the MAC data.
This command is used only after the CRYPT_EAL_MacInit interface is successfully called.
| ctx | [IN] MAC context |
| in | [IN] Input data, when the variable is null, the len parameter must be 0. Otherwise, an error is reported. |
| len | [IN] Input data length, the value can be 0. |
| CRYPT_SUCCESS,succeeded | in updating the internal status of the digest. |
| CRYPT_NULL_INPUT,the | input parameter is NULL. |
| CRYPT_EAL_ERR_STATE,status | error. |
| CRYPT_SHA1_INPUT_OVERFLOW,the | length of the HMAC-SHA1 input data exceeds the maximum value. |
| CRYPT_SHA2_INPUT_OVERFLOW,the | length of the HMAC-SHA224, HMAC-SHA256, HMAC-SHA384, or HMAC-SHA512 input data exceeds the maximum value, Other error codes see the crypt_errno.h. |
| CRYPT_EAL_MacCtx * CRYPT_EAL_ProviderMacNewCtx | ( | CRYPT_EAL_LibCtx * | libCtx, |
| int32_t | algId, | ||
| const char * | attrName ) |
Create an MAC context in the providers.
| libCtx | [IN] Library context |
| algId | [IN] mac algorithm ID. |
| attrName | [IN] Specify expected attribute values |
| CRYPT_EAL_MacCtx | pointer. NULL, if the operation fails. |