|
◆ CRYPT_EAL_CipherUpdate()
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.
- Attention
- If the function is called by an external user and the error stack is concerned, it is recommended that BSL_ERR_ClearError() be called before this function is called.
- Parameters
-
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
- Encrypted data is input for the first time, and inLen is less than blockSize. In this case, the output value of outLen is 0.
- In the first input encrypted data length, inLen is an integer multiple of blockSize. In this case, outLen is equal to inLen.
- In the first input encrypted data length, inLen > blockSize and not an integer multiple of blockSize. In this case, outLen < inLen.
- Enter the encrypted data for multiple times. (inLen% blockSize) + cache (CTX cache data) >= blockSize. At this point outLen = (inlen / blockSize) * blockSize + blockSize CTR outLen equals inLen. In XTS mode, update reserves the last two blocks for final processing, If the total length of the input data plus the buffer is less than 32 blocks, the output is 0.
- When data is input for the first time, outLen = (inLen / 16 - 2) * 16.
- Enter the encrypted data for multiple times. At this time, outLen = ((inLen + cache) / 16 - 2) * 16. In SM4_XTS mode, after calling CRYPT_EAL_CipherUpdate, you need to use CRYPT_EAL_CipherInit or CRYPT_EAL_CipherReinit to reset the key or iv.
|
- Return values
-
|