Fix PBKDF2 with empty salt on platforms where malloc(0)=NULL
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
3c861642c8
commit
ca57d78a6e
1 changed files with 3 additions and 1 deletions
|
@ -6679,7 +6679,9 @@ static psa_status_t psa_pbkdf2_set_salt(psa_pbkdf2_key_derivation_t *pbkdf2,
|
|||
return PSA_ERROR_BAD_STATE;
|
||||
}
|
||||
|
||||
if (pbkdf2->state == PSA_PBKDF2_STATE_INPUT_COST_SET) {
|
||||
if (data_length == 0) {
|
||||
/* Nothing to do */
|
||||
} else if (pbkdf2->state == PSA_PBKDF2_STATE_INPUT_COST_SET) {
|
||||
pbkdf2->salt = mbedtls_calloc(1, data_length);
|
||||
if (pbkdf2->salt == NULL) {
|
||||
return PSA_ERROR_INSUFFICIENT_MEMORY;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue