API参考
载入中...
搜索中...
未找到
Crypt_eal_mac

mac of crypto module 更多...

Crypt_eal_mac 的协作图:

函数

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

函数说明

◆ CRYPT_EAL_GetMacLen()

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
返回值
TheMAC length corresponding to the context.

◆ CRYPT_EAL_MacCopyCtx()

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,parametersare set successfully.
CRYPT_NULL_INPUT,theinput parameter is NULL. Other error codes see crypt_errno.h

◆ CRYPT_EAL_MacCtrl()

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,parametersare set successfully.
CRYPT_EAL_ERR_STATE,statusincorrect.
CRYPT_EAL_MAC_CTRL_TYPE_ERROR,theparameter type is set incorrect.
CRYPT_EAL_ERR_ALGID,algorithmID exclude GMAC. Other error codes see crypt_errno.h

◆ CRYPT_EAL_MacDeinit()

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_MacDupCtx()

CRYPT_EAL_MacCtx * CRYPT_EAL_MacDupCtx ( const CRYPT_EAL_MacCtx * from)

Dup the MAC context.

参数
from[IN] original MAC context.
返回值
CRYPT_EAL_MacCtx,MACcontext pointer. NULL, if the operation fails.

◆ CRYPT_EAL_MacFinal()

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,calculationsucceeded.
CRYPT_NULL_INPUT,theinput parameter is NULL.
CRYPT_EAL_ERR_STATE,statusincorrect.
CRYPT_HMAC_OUT_BUFF_LEN_NOT_ENOUGH,thelength of the output buffer in the HMAC algorithm is insufficient.
CRYPT_CMAC_OUT_BUFF_LEN_NOT_ENOUGH,thelength of the output buffer in the CMAC algorithm is insufficient.
CRYPT_SHA1_INPUT_OVERFLOW,thelength of the HMAC-SHA1 input data exceeds the maximum.
CRYPT_SHA2_INPUT_OVERFLOW,thelength 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

◆ CRYPT_EAL_MacFreeCtx()

void CRYPT_EAL_MacFreeCtx ( CRYPT_EAL_MacCtx * ctx)

Release the MAC context memory.

参数
ctx[IN] MAC context, ctx set NULL by caller.

◆ CRYPT_EAL_MacInit()

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,initializationsucceeded.
CRYPT_NULL_INPUT,pointerctx parameter or key parameter is NULL.
CRYPT_AES_ERR_KEYLEN,thekey length of the AES & CMAC algorithm is incorrect. Other error codes see the crypt_errno.h.

◆ CRYPT_EAL_MacIsValidAlgId()

bool CRYPT_EAL_MacIsValidAlgId ( CRYPT_MAC_AlgId id)

Check whether the id is Valid MAC algorithm ID.

参数
id[IN] MAC algorithm ID
返回值
true,ifvalid. false, if invalid.

◆ CRYPT_EAL_MacNewCtx()

CRYPT_EAL_MacCtx * CRYPT_EAL_MacNewCtx ( CRYPT_MAC_AlgId id)

Apply for a MAC context.

参数
id[IN] MAC algorithm ID
返回值
CRYPT_EAL_MacCtxPointer. NULL, if the operation fails.

◆ CRYPT_EAL_MacReinit()

int32_t CRYPT_EAL_MacReinit ( CRYPT_EAL_MacCtx * ctx)

Re-initialize with the information retained in ctx.

注意
Doesn't need call the init interface again for initialization, it is equivalent to the combination of the deinit and init interfaces.
参数
ctx[IN] MAC context
返回值
CRYPT_SUCCESS,reinitsucceeded.
CRYPT_NULL_INPUT,theinput parameter is NULL.

◆ CRYPT_EAL_MacSetParam()

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,parametersare set successfully.
CRYPT_NULL_INPUT,theinput parameter is NULL. Other error codes see crypt_errno.h

◆ CRYPT_EAL_MacUpdate()

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,succeededin updating the internal status of the digest.
CRYPT_NULL_INPUT,theinput parameter is NULL.
CRYPT_EAL_ERR_STATE,statuserror.
CRYPT_SHA1_INPUT_OVERFLOW,thelength of the HMAC-SHA1 input data exceeds the maximum value.
CRYPT_SHA2_INPUT_OVERFLOW,thelength 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_ProviderMacNewCtx()

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_MacCtxpointer. NULL, if the operation fails.