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

函数 | |
| 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
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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_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,MD | context pointer. NULL, if the operation fails. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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,no | return value. |
| 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 |
| Digest | length, if successful. 0, if failed(in this case, the ID is invalid). |
| int32_t CRYPT_EAL_MdGetId | ( | CRYPT_EAL_MdCtx * | ctx | ) |
Return the MD algorithm ID.
| ctx | [IN] MD context |
| ID,MD | algorithm ID. CRYPT_MD_MAX, which indicates invalid ID or the input parameter is null. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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,If | the value is valid. false, If the value is invalid. |
| 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_SUCCESS | on 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. |
| void CRYPT_EAL_MdMBFreeCtx | ( | CRYPT_EAL_MdCtx * | ctx | ) |
Release MB context created by CRYPT_EAL_MdMBNewCtx.
| ctx | [IN] MB context pointer. |
| 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_SUCCESS | on 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_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:
| 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_MdCtx | pointer on success. NULL if memory allocation fails or input is invalid. |
| 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_SUCCESS | on 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_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,MD | context pointer. NULL, if the operation fails. |
| 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_BUFFER | if output buffer is too small For other error codes, see crypt_errno.h |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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_SUCCESS | For other error codes, see crypt_errno.h. |
| 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_PkeyCtx | pointer. NULL, if the operation fails. |