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

md algorithms of crypto module 更多...

Crypt_eal_md 的协作图:

函数

CRYPT_EAL_MdCtx * CRYPT_EAL_MdNewCtx (CRYPT_MD_AlgId id)
 Create the MD context.
CRYPT_EAL_MdCtx * CRYPT_EAL_ProviderMdNewCtx (CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName)
 Create a md context in the providers.
bool CRYPT_EAL_MdIsValidAlgId (CRYPT_MD_AlgId id)
 Check whether the id is valid MD algorithm ID. Not supported in provider
int32_t CRYPT_EAL_MdGetId (CRYPT_EAL_MdCtx *ctx)
 Return the MD algorithm ID.
int32_t CRYPT_EAL_MdCopyCtx (CRYPT_EAL_MdCtx *to, const CRYPT_EAL_MdCtx *from)
 Copy the MD context.
CRYPT_EAL_MdCtx * CRYPT_EAL_MdDupCtx (const CRYPT_EAL_MdCtx *ctx)
 Dup the MD context.
void CRYPT_EAL_MdFreeCtx (CRYPT_EAL_MdCtx *ctx)
 Release the MD context.
int32_t CRYPT_EAL_MdInit (CRYPT_EAL_MdCtx *ctx)
 Initialize the MD context.
int32_t CRYPT_EAL_MdUpdate (CRYPT_EAL_MdCtx *ctx, const uint8_t *data, uint32_t len)
 Continuously input the data to be digested.
int32_t CRYPT_EAL_MdSqueeze (CRYPT_EAL_MdCtx *ctx, uint8_t *out, uint32_t len)
 Generate output from the sponge construction's squeezing phase.
int32_t CRYPT_EAL_MdFinal (CRYPT_EAL_MdCtx *ctx, uint8_t *out, uint32_t *len)
 Complete the digest and output the final digest result.
uint32_t CRYPT_EAL_MdGetDigestSize (CRYPT_MD_AlgId id)
 Obtain the digest length of the algorithm output. Not supported in provider
int32_t CRYPT_EAL_Md (CRYPT_MD_AlgId id, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
 Calculate the data digest. Not supported in provider
int32_t CRYPT_EAL_ProviderMd (CRYPT_EAL_LibCtx *libCtx, CRYPT_MD_AlgId id, const char *attrName, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
 Calculate the data digest. Supported in provider
int32_t CRYPT_EAL_MdDeinit (CRYPT_EAL_MdCtx *ctx)
 Deinitialize the function.
CRYPT_EAL_MdCtx * CRYPT_EAL_MdMBNewCtx (CRYPT_EAL_LibCtx *libCtx, int32_t id, uint32_t num)
 Create a MD context for multi-buffer hash computation.
void CRYPT_EAL_MdMBFreeCtx (CRYPT_EAL_MdCtx *ctx)
 Release MB context created by CRYPT_EAL_MdMBNewCtx.
int32_t CRYPT_EAL_MdMBInit (CRYPT_EAL_MdCtx *ctx)
 Initialize multi-buffer MD context.
int32_t CRYPT_EAL_MdMBUpdate (CRYPT_EAL_MdCtx *ctx, const uint8_t *data[], uint32_t nbytes[], uint32_t num)
 Update multi-buffer MD context with message fragments.
int32_t CRYPT_EAL_MdMBFinal (CRYPT_EAL_MdCtx *ctx, uint8_t *digest[], uint32_t *outlen, uint32_t num)
 Finalize multi-buffer MD context and output digests.

详细描述

md algorithms of crypto module

函数说明

◆ CRYPT_EAL_Md()

int32_t CRYPT_EAL_Md ( CRYPT_MD_AlgId id,
const uint8_t * in,
uint32_t inLen,
uint8_t * out,
uint32_t * outLen )

Calculate the data digest. Not supported in provider

参数
id[IN] Algorithm ID
in[IN] Data to be digested
inLen[IN] Data length
out[OUT] Digest result
outLen[IN/OUT] The input parameter indicates the length of the buffer marked as "out", and the output parameter indicates the valid length of the obtained "out".
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdCopyCtx()

int32_t CRYPT_EAL_MdCopyCtx ( CRYPT_EAL_MdCtx * to,
const CRYPT_EAL_MdCtx * from )

Copy the MD context.

参数
to[IN/OUT] Target MD context
from[IN] Source MD context
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdDeinit()

int32_t CRYPT_EAL_MdDeinit ( CRYPT_EAL_MdCtx * ctx)

Deinitialize the function.

If need to be calculated after the CRYPT_EAL_MdDeinit is called, it needs to be initialized again.

参数
ctx[IN] Md Context

◆ CRYPT_EAL_MdDupCtx()

CRYPT_EAL_MdCtx * CRYPT_EAL_MdDupCtx ( const CRYPT_EAL_MdCtx * ctx)

Dup the MD context.

Note that need to call the CRYPT_EAL_MdFreeCtx interface to release the memory after the duplication is complete.

参数
ctx[IN] Source MD context
返回值
CRYPT_EAL_MdCtx,MDcontext pointer. NULL, if the operation fails.

◆ CRYPT_EAL_MdFinal()

int32_t CRYPT_EAL_MdFinal ( CRYPT_EAL_MdCtx * ctx,
uint8_t * out,
uint32_t * len )

Complete the digest and output the final digest result.

参数
ctx[IN/OUT] MD context, which is created by using the CRYPT_EAL_MdNewCtx interface.
out[OUT] Digest result cache, which needs to be created and managed by users.
len[IN/OUT] The input parameter indicates the length of the buffer marked as "out", and the output parameter indicates the valid length of the obtained "out". The length must be greater than or equal to the hash length of the corresponding algorithm, the hash length can be obtained through the CRYPT_EAL_MdGetDigestSize interface. Requires user creation management.
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdFreeCtx()

void CRYPT_EAL_MdFreeCtx ( CRYPT_EAL_MdCtx * ctx)

Release the MD context.

参数
ctx[IN] MD context. which is created by using the CRYPT_EAL_MdNewCtx interface and need to be set NULL by caller.
返回值
Void,noreturn value.

◆ CRYPT_EAL_MdGetDigestSize()

uint32_t CRYPT_EAL_MdGetDigestSize ( CRYPT_MD_AlgId id)

Obtain the digest length of the algorithm output. Not supported in provider

参数
id[IN] Algorithm ID
返回值
Digestlength, if successful. 0, if failed(in this case, the ID is invalid).

◆ CRYPT_EAL_MdGetId()

int32_t CRYPT_EAL_MdGetId ( CRYPT_EAL_MdCtx * ctx)

Return the MD algorithm ID.

参数
ctx[IN] MD context
返回值
ID,MDalgorithm ID. CRYPT_MD_MAX, which indicates invalid ID or the input parameter is null.

◆ CRYPT_EAL_MdInit()

int32_t CRYPT_EAL_MdInit ( CRYPT_EAL_MdCtx * ctx)

Initialize the MD context.

参数
ctx[IN/OUT] MD context, which is created by using the CRYPT_EAL_MdNewCtx interface.
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdIsValidAlgId()

bool CRYPT_EAL_MdIsValidAlgId ( CRYPT_MD_AlgId id)

Check whether the id is valid MD algorithm ID. Not supported in provider

参数
id[IN] MD algorithm ID.
返回值
true,Ifthe value is valid. false, If the value is invalid.

◆ CRYPT_EAL_MdMBFinal()

int32_t CRYPT_EAL_MdMBFinal ( CRYPT_EAL_MdCtx * ctx,
uint8_t * digest[],
uint32_t * outlen,
uint32_t num )

Finalize multi-buffer MD context and output digests.

digest[i] is the output buffer for message i. The outlen parameter indicates the buffer size on input and returns the actual digest length on output.

参数
ctx[IN/OUT] MB context.
digest[OUT] Digest buffer pointer array.
outlen[IN/OUT] Digest buffer length / output digest length.
num[IN] Number of contexts/messages.
返回值
CRYPT_SUCCESSon success. CRYPT_NULL_INPUT if input is invalid. CRYPT_NOT_SUPPORT if the algorithm does not support multi-buffer mode. For other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdMBFreeCtx()

void CRYPT_EAL_MdMBFreeCtx ( CRYPT_EAL_MdCtx * ctx)

Release MB context created by CRYPT_EAL_MdMBNewCtx.

参数
ctx[IN] MB context pointer.

◆ CRYPT_EAL_MdMBInit()

int32_t CRYPT_EAL_MdMBInit ( CRYPT_EAL_MdCtx * ctx)

Initialize multi-buffer MD context.

参数
ctx[IN/OUT] MB context created by CRYPT_EAL_MdMBNewCtx.
返回值
CRYPT_SUCCESSon success. CRYPT_NULL_INPUT if input is invalid. CRYPT_NOT_SUPPORT if the algorithm does not support multi-buffer mode. For other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdMBNewCtx()

CRYPT_EAL_MdCtx * CRYPT_EAL_MdMBNewCtx ( CRYPT_EAL_LibCtx * libCtx,
int32_t id,
uint32_t num )

Create a MD context for multi-buffer hash computation.

This interface creates a MB context used by the multi-buffer workflow (Init/Update/Final) to hash multiple messages in parallel.

Notes:

  • The returned ctx must be released by calling CRYPT_EAL_MdMBFreeCtx.
  • The multi-buffer capability is algorithm/feature dependent; unsupported cases will return CRYPT_NOT_SUPPORT in subsequent MB operations.
参数
libCtx[IN] Library context (reserved, currently unused).
id[IN] MD algorithm ID (e.g. #CRYPT_MD_SHA256).
num[IN] Number of contexts/messages.
返回值
CRYPT_EAL_MdCtxpointer on success. NULL if memory allocation fails or input is invalid.

◆ CRYPT_EAL_MdMBUpdate()

int32_t CRYPT_EAL_MdMBUpdate ( CRYPT_EAL_MdCtx * ctx,
const uint8_t * data[],
uint32_t nbytes[],
uint32_t num )

Update multi-buffer MD context with message fragments.

Each update processes one fragment per message. The fragment length is specified by nbytes[i] for message i. All nbytes[i] must be equal, otherwise this interface returns CRYPT_NOT_SUPPORT.

参数
ctx[IN/OUT] MB context.
data[IN] Data pointer array. data[i] is the fragment for message i.
nbytes[IN] Fragment length array in bytes. nbytes[i] is the fragment length for message i.
num[IN] Number of contexts/messages.
返回值
CRYPT_SUCCESSon success. CRYPT_NULL_INPUT if input is invalid. CRYPT_NOT_SUPPORT if the algorithm does not support multi-buffer mode or the nbytes are not equal. For other error codes, see crypt_errno.h.

◆ CRYPT_EAL_MdNewCtx()

CRYPT_EAL_MdCtx * CRYPT_EAL_MdNewCtx ( CRYPT_MD_AlgId id)

Create the MD context.

After the calculation is complete, call the CRYPT_EAL_MdFreeCtx interface to release the memory.

参数
id[IN] Algorithm ID
返回值
CRYPT_EAL_MdCtx,MDcontext pointer. NULL, if the operation fails.

◆ CRYPT_EAL_MdSqueeze()

int32_t CRYPT_EAL_MdSqueeze ( CRYPT_EAL_MdCtx * ctx,
uint8_t * out,
uint32_t len )

Generate output from the sponge construction's squeezing phase.

This interface implements the squeeze capability of sponge-based hash functions (e.g. SHAKE). Can be called multiple times to generate additional output. Must be called after finalization.

参数
ctx[IN/OUT] MD context (must be in squeezed state)
out[OUT] Buffer to store squeezed output
len[IN] Input: requested output length (must be <= buffer size)
返回值
CRYPT_SUCCESS
CRYPT_E_SHORT_BUFFERif output buffer is too small For other error codes, see crypt_errno.h

◆ CRYPT_EAL_MdUpdate()

int32_t CRYPT_EAL_MdUpdate ( CRYPT_EAL_MdCtx * ctx,
const uint8_t * data,
uint32_t len )

Continuously input the data to be digested.

参数
ctx[IN/OUT] MD context, which is created by using the CRYPT_EAL_MdNewCtx interface.
data[IN] Data to be digested.
len[IN] Data length. The maximum length of sha384 and sha512 is [0, 2^128 bits). The maximum total length of sha1, sha224, sha256, sm3, and md5 is [0, 2^64 bits). The maximum length at a time is [0, 0xffffffff].
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_ProviderMd()

int32_t CRYPT_EAL_ProviderMd ( CRYPT_EAL_LibCtx * libCtx,
CRYPT_MD_AlgId id,
const char * attrName,
const uint8_t * in,
uint32_t inLen,
uint8_t * out,
uint32_t * outLen )

Calculate the data digest. Supported in provider

参数
libCtx[IN] Library context
id[IN] Algorithm ID
attrName[IN] Attribute name
in[IN] Data to be digested
inLen[IN] Data length
out[OUT] Digest result
outLen[IN/OUT] The input parameter indicates the length of the buffer marked as "out", and the output parameter indicates the valid length of the obtained "out".
返回值
CRYPT_SUCCESSFor other error codes, see crypt_errno.h.

◆ CRYPT_EAL_ProviderMdNewCtx()

CRYPT_EAL_MdCtx * CRYPT_EAL_ProviderMdNewCtx ( CRYPT_EAL_LibCtx * libCtx,
int32_t algId,
const char * attrName )

Create a md context in the providers.

参数
libCtx[IN] Library context, if NULL, use the default provider
algId[IN] md algorithm ID.
attrName[IN] Specify expected attribute values
返回值
CRYPT_EAL_PkeyCtxpointer. NULL, if the operation fails.