![]() |
API参考
|
cipher suites 更多...

函数 | |
| bool | CRYPT_EAL_CipherIsValidAlgId (CRYPT_CIPHER_AlgId id) |
| Check whether the given symmetric algorithm ID is valid. | |
| CRYPT_EAL_CipherCtx * | CRYPT_EAL_CipherNewCtx (CRYPT_CIPHER_AlgId id) |
| Generate symmetric encryption and decryption handles. | |
| CRYPT_EAL_CipherCtx * | CRYPT_EAL_ProviderCipherNewCtx (CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName) |
| Generate symmetric encryption and decryption handles in the providers | |
| void | CRYPT_EAL_CipherFreeCtx (CRYPT_EAL_CipherCtx *ctx) |
| Release the symmetric encryption/decryption handle. Clear sensitive information before releasing the handle. | |
| int32_t | CRYPT_EAL_CipherInit (CRYPT_EAL_CipherCtx *ctx, const uint8_t *key, uint32_t keyLen, const uint8_t *iv, uint32_t ivLen, bool enc) |
| Initialize the symmetric encryption/decryption handle. The key cannot be null. Except the ECB mode, other modes iv cannot be null. | |
| void | CRYPT_EAL_CipherDeinit (CRYPT_EAL_CipherCtx *ctx) |
| Deinitialize the handle and restore the handle to the state, when the CRYPT_EAL_CipherNewCtx function is called. | |
| int32_t | CRYPT_EAL_CipherReinit (CRYPT_EAL_CipherCtx *ctx, uint8_t *iv, uint32_t ivLen) |
| int32_t | CRYPT_EAL_CipherUpdate (CRYPT_EAL_CipherCtx *ctx, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| int32_t | CRYPT_EAL_CipherFinal (CRYPT_EAL_CipherCtx *ctx, uint8_t *out, uint32_t *outLen) |
| Fill the data with the size of the block and output the encrypted data; the AEAD tag is obtained through CRYPT_EAL_CipherCtrl. For block encryption algorithms such as CBC and ECB, padding must be set, In XTS mode, final needs to be called to obtain the last two blocks. | |
| int32_t | CRYPT_EAL_CipherCtrl (CRYPT_EAL_CipherCtx *ctx, int32_t type, void *data, uint32_t len) |
| int32_t | CRYPT_EAL_CipherSetPadding (CRYPT_EAL_CipherCtx *ctx, CRYPT_PaddingType type) |
| Set the padding mode. | |
| int32_t | CRYPT_EAL_CipherGetPadding (CRYPT_EAL_CipherCtx *ctx) |
| Obtain the padding type. | |
| int32_t | CRYPT_EAL_CipherGetInfo (CRYPT_CIPHER_AlgId id, int32_t type, uint32_t *infoValue) |
| Obtain the type of an algorithm based on the algorithm ID. | |
| int32_t | CRYPT_EAL_CipherCopyCtx (CRYPT_EAL_CipherCtx *to, const CRYPT_EAL_CipherCtx *from) |
| Copy the cipher context. | |
| CRYPT_EAL_CipherCtx * | CRYPT_EAL_CipherDupCtx (const CRYPT_EAL_CipherCtx *from) |
| Dup the cipher context. | |
cipher suites
| int32_t CRYPT_EAL_CipherCopyCtx | ( | CRYPT_EAL_CipherCtx * | to, |
| const CRYPT_EAL_CipherCtx * | from ) |
Copy the cipher context.
| to | [IN] target cipher context. |
| from | [IN] original cipher 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_CipherCtrl | ( | CRYPT_EAL_CipherCtx * | ctx, |
| int32_t | type, | ||
| void * | data, | ||
| uint32_t | len ) |
Set the mode ctx parameters in the CTX. parameter data type Length(len):number of data bytes CRYPT_CTRL_GET_IV uint8_t array The length of the IV depends on the corresponding algorithm, see the mapping in CRYPT_EAL_CipherInit CRYPT_CTRL_SET_AAD uint8_t array It is used only for AEAD calculation. The length is related to the corresponding AEAD algorithm. CRYPT_CTRL_GET_TAG uint8_t array It is used only for AEAD calculation. The length is the tagLen value set by the user. CRYPT_CTRL_SET_TAGLEN uint32_t length(len) 4 CRYPT_CTRL_SET_MSGLEN uint64_t length(len) 8 CRYPT_CTRL_SET_FEEDBACKSIZE uint32_t length(len) 4 CRYPT_CTRL_GET_FEEDBACKSIZE uint32_t pointer sizeof(*uint32_t) CRYPT_CTRL_GET_BLOCKSIZE uint32_t length(len) 4
| ctx | [IN] Symmetric encryption/decryption handle |
| type | [IN] Parameter type |
| data | [IN/OUT] Input and output data |
| len | [OUT] Data length |
| CRYPT_SUCCESS,success. | error codes see the crypt_errno.h |
| void CRYPT_EAL_CipherDeinit | ( | CRYPT_EAL_CipherCtx * | ctx | ) |
Deinitialize the handle and restore the handle to the state, when the CRYPT_EAL_CipherNewCtx function is called.
| ctx | [IN] Symmetric encryption/decryption handle |
| CRYPT_EAL_CipherCtx * CRYPT_EAL_CipherDupCtx | ( | const CRYPT_EAL_CipherCtx * | from | ) |
Dup the cipher context.
| from | [IN] original cipher context. |
| CRYPT_EAL_CipherCtx,cipher | context pointer. NULL, if the operation fails. |
| int32_t CRYPT_EAL_CipherFinal | ( | CRYPT_EAL_CipherCtx * | ctx, |
| uint8_t * | out, | ||
| uint32_t * | outLen ) |
Fill the data with the size of the block and output the encrypted data; the AEAD tag is obtained through CRYPT_EAL_CipherCtrl. For block encryption algorithms such as CBC and ECB, padding must be set, In XTS mode, final needs to be called to obtain the last two blocks.
| ctx | [IN] Symmetric encryption/decryption handle |
| out | [OUT] Output the encrypted data |
| outLen | [IN/OUT] Input: outLen >= blockSize Output: The output value for stream encryption is 0. If padding is set for CBC and ECB block encryption, the output value of outLen is blockSize. If the padding is not set for CBC and ECB block encryption and CTX contains cached data, an error is reported. If padding is not set for CBC and ECB block encryption, and no data is cached in the CTX, the output value of outLen is 0. |
| CRYPT_SUCCESS,success. | Other error codes see the crypt_errno.h. |
| void CRYPT_EAL_CipherFreeCtx | ( | CRYPT_EAL_CipherCtx * | ctx | ) |
Release the symmetric encryption/decryption handle. Clear sensitive information before releasing the handle.
| ctx | [IN] Symmetric encryption/decryption handle. The CTX is set null by the caller. |
| int32_t CRYPT_EAL_CipherGetInfo | ( | CRYPT_CIPHER_AlgId | id, |
| int32_t | type, | ||
| uint32_t * | infoValue ) |
Obtain the type of an algorithm based on the algorithm ID.
| id | [IN] Symmetric algorithm ID. |
| type | [IN] Attribute type to be obtained. |
| infoValue | [OUT] Obtained attribute data. |
| CRYPT_SUCCESS,success | Other error codes see crypt_errno.h |
| int32_t CRYPT_EAL_CipherGetPadding | ( | CRYPT_EAL_CipherCtx * | ctx | ) |
Obtain the padding type.
| ctx | Symmetric encryption/decryption handle |
| Return | mode |
| int32_t CRYPT_EAL_CipherInit | ( | CRYPT_EAL_CipherCtx * | ctx, |
| const uint8_t * | key, | ||
| uint32_t | keyLen, | ||
| const uint8_t * | iv, | ||
| uint32_t | ivLen, | ||
| bool | enc ) |
Initialize the symmetric encryption/decryption handle. The key cannot be null. Except the ECB mode, other modes iv cannot be null.
The length of iv must be the same as the block length (this requirement is not required in ECB mode). The block length can be obtained through CRYPT_CTRL_GET_BLOCKSIZE of CRYPT_EAL_CipherCtrl. CRYPT_EAL_CipherInit can be called repeatedly at any stage, resets the key and iv, and clears the cached data.
| ctx | [IN] Symmetric encryption/decryption handle |
| key | [IN] Key |
| keyLen | [IN] Key length |
| iv | [IN] Initialization vector |
| ivLen | [IN] Initialize the vector length. |
| enc | [IN] True: encryption; False: decryption |
| CRYPT_SUCCESS,success. | For other error codes, see crypt_errno.h. |
| bool CRYPT_EAL_CipherIsValidAlgId | ( | CRYPT_CIPHER_AlgId | id | ) |
Check whether the given symmetric algorithm ID is valid.
| id | [IN] Symmetric algorithm ID. |
| Valid,true | is returned. Invalid, false is returned. |
| CRYPT_EAL_CipherCtx * CRYPT_EAL_CipherNewCtx | ( | CRYPT_CIPHER_AlgId | id | ) |
Generate symmetric encryption and decryption handles.
| id | [IN] Symmetric encryption/decryption algorithm ID. |
| Success | cipher ctx. Fails: NULL. |
| int32_t CRYPT_EAL_CipherReinit | ( | CRYPT_EAL_CipherCtx * | ctx, |
| uint8_t * | iv, | ||
| uint32_t | ivLen ) |
Re-initialize the handle, retain the key, reset the IV, and clear the cache and sensitive data. Except the ECB mode, other modes iv cannot be null. The setting of iv must be based on the corresponding algorithm ID. For details, see the mapping in CRYPT_EAL_CipherInit.
| ctx | [IN] Symmetric encryption/decryption handle |
| iv | [IN] Vector |
| ivLen | [IN] Vector length |
| int32_t CRYPT_EAL_CipherSetPadding | ( | CRYPT_EAL_CipherCtx * | ctx, |
| CRYPT_PaddingType | type ) |
Set the padding mode.
| ctx | Symmetric encryption/decryption handle |
| type | Padding type |
| CRYPT_SUCCESS,success. | Error codes see crypt_errno.h |
| int32_t CRYPT_EAL_CipherUpdate | ( | CRYPT_EAL_CipherCtx * | ctx, |
| const uint8_t * | in, | ||
| uint32_t | inLen, | ||
| uint8_t * | out, | ||
| uint32_t * | outLen ) |
Continuously enter encrypted and decrypted data. CRYPT_EAL_CipherUpdate should be used in conjunction with CRYPT_EAL_CipherFinal, after one or more calls to CRYPT_EAL_CipherUpdate, Call CRYPT_EAL_CipherFinal. With the exception of SM4_XTS mode, multiple calls to CRYPT_EAL_CipherUpdate and CRYPT_EAL_CipherFinal are not supported.
| ctx | [IN] Symmetric encryption and decryption handle |
| in | [IN] Continuously input data |
| inLen | [IN] Length of continuously input data |
| out | [OUT] Output data |
| outLen | [IN/OUT] Input: For CBC and ECB block encryption, you are advised to set outLen > inLen + blockSize. For CTR and XTS stream encryption, you are advised to set outLen >= inLen. blockSize can be obtained by using CRYPT_CTRL_GET_BLOCKSIZE of CRYPT_EAL_CipherCtrl. Output: Length of the encrypted data. If the block encryption algorithm is used and the length of the last data to be processed is insufficient, the output value of outLen is 0. eg: CBC and ECB block encryption
|
| CRYPT_SUCCESS,success. | Other error codes see the crypt_errno.h. |
| CRYPT_EAL_CipherCtx * CRYPT_EAL_ProviderCipherNewCtx | ( | CRYPT_EAL_LibCtx * | libCtx, |
| int32_t | algId, | ||
| const char * | attrName ) |
Generate symmetric encryption and decryption handles in the providers
| libCtx | [IN] Library context |
| algId | [IN] Symmetric encryption/decryption algorithm ID. |
| attrName | [IN] Specify expected attribute values |
| Success | cipher ctx. Fails: NULL. |