fix array out-of-bounds issues in EAL_FindParam.

Cherry-picked from: https://gitcode.com/openHiTLS/openhitls/merge_requests/1487

Signed-off-by: Dongjianwei001 <dongjianwei1@huawei.com>
This commit is contained in:
Dongjianwei001
2026-05-20 15:15:15 +08:00
parent ad5911f70c
commit aa4c1785bc
2 changed files with 6 additions and 5 deletions
+4 -3
View File
@@ -387,7 +387,10 @@ void CRYPT_SHA256x2_Compress(uint32_t state1[CRYPT_SHA256_STATE_SIZE], uint32_t
* @brief SHA256 multi-buffer one-shot hashing.
*
* Notes:
* - Currently only supports num == 2.
* - This API is intended for internal acceleration paths.
* - Callers must ensure all parameters are valid (data, digest arrays and their elements
* must not be NULL; outlen must point to a valid uint32_t; *outlen >= 32 bytes).
* - Currently only supports num == 2 on AArch64 with SHA2-ASM.
* - nbytes is the same length for all lanes in this one-shot API.
*
* @param data [IN] Input pointer array. data[i] is message pointer for lane i.
@@ -397,9 +400,7 @@ void CRYPT_SHA256x2_Compress(uint32_t state1[CRYPT_SHA256_STATE_SIZE], uint32_t
* @param num [IN] Number of lanes/messages.
*
* @retval #CRYPT_SUCCESS Success.
* @retval #CRYPT_NULL_INPUT Invalid input pointer.
* @retval #CRYPT_NOT_SUPPORT Not supported (e.g. num != 2 or platform capability missing).
* @retval Other error codes, see crypt_errno.h.
*/
int32_t CRYPT_SHA256_MB(const uint8_t *data[], uint32_t nbytes, uint8_t *digest[], uint32_t *outlen, uint32_t num);
+2 -2
View File
@@ -92,7 +92,7 @@ const BSL_Param *EAL_FindConstParam(const BSL_Param *param, int32_t key)
return NULL;
}
int32_t index = 0;
while (param[index].key != 0 && index < PARAM_MAX_NUMBER) {
while (index < PARAM_MAX_NUMBER && param[index].key != 0) {
if (param[index].key == key) {
return &param[index];
}
@@ -112,7 +112,7 @@ BSL_Param *EAL_FindParam(BSL_Param *param, int32_t key)
return NULL;
}
int32_t index = 0;
while (param[index].key != 0 && index < PARAM_MAX_NUMBER) {
while (index < PARAM_MAX_NUMBER && param[index].key != 0) {
if (param[index].key == key) {
return &param[index];
}