mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-28 18:07:34 +08:00
Merge d327b904b3eac4e40db7ef6c0f07ca4c4cbc6f3c into 4fdb917aae2fb5876e04f88621630712a906a067
This commit is contained in:
commit
6258ee1415
@ -127,6 +127,9 @@ static int create_digit_array_with_checksum(const mbedtls_lmots_parameters_t *pa
|
||||
size_t output_hash_len;
|
||||
unsigned short checksum;
|
||||
|
||||
/* Always zeroize the output buffer because it may contain data from the previous invocation */
|
||||
memset(out, 0, MBEDTLS_LMOTS_N_HASH_LEN(params->type) + CHECKSUM_LEN);
|
||||
|
||||
status = psa_hash_setup(&op, PSA_ALG_SHA_256);
|
||||
if (status != PSA_SUCCESS) {
|
||||
goto exit;
|
||||
@ -222,6 +225,11 @@ static int hash_digit_array(const mbedtls_lmots_parameters_t *params,
|
||||
size_t output_hash_len;
|
||||
unsigned char tmp_hash[MBEDTLS_LMOTS_N_HASH_LEN_MAX];
|
||||
|
||||
/* Always zeroize the output buffer because it may contain data from the previous invocation */
|
||||
memset(output, 0,
|
||||
(size_t) MBEDTLS_LMOTS_P_SIG_DIGIT_COUNT(params->type) *
|
||||
MBEDTLS_LMOTS_N_HASH_LEN(params->type));
|
||||
|
||||
for (i_digit_idx = 0;
|
||||
i_digit_idx < MBEDTLS_LMOTS_P_SIG_DIGIT_COUNT(params->type);
|
||||
i_digit_idx++) {
|
||||
@ -318,6 +326,9 @@ static int public_key_from_hashed_digit_array(const mbedtls_lmots_parameters_t *
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
size_t output_hash_len;
|
||||
|
||||
/* Always zeroize the output buffer because it may contain data from the previous invocation */
|
||||
memset(pub_key, 0, MBEDTLS_LMOTS_N_HASH_LEN(params->type));
|
||||
|
||||
status = psa_hash_setup(&op, PSA_ALG_SHA_256);
|
||||
if (status != PSA_SUCCESS) {
|
||||
goto exit;
|
||||
@ -352,10 +363,11 @@ static int public_key_from_hashed_digit_array(const mbedtls_lmots_parameters_t *
|
||||
MBEDTLS_LMOTS_N_HASH_LEN(params->type),
|
||||
&output_hash_len);
|
||||
if (status != PSA_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
psa_hash_abort(&op);
|
||||
}
|
||||
|
||||
return PSA_TO_MBEDTLS_ERR(status);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user