Skip to content

Commit

Permalink
[review] ta: pkcs11: update to mbedTLS 3.4.0 API
Browse files Browse the repository at this point in the history
Supply the mandatory f_rng() parmeter to mbedtls_ecp_mul() and
mbedtls_pk_parse_key().

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jenswi-linaro committed Oct 2, 2023
1 parent 9f1e2d2 commit 3619de8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ta/pkcs11/src/pkcs11_attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,12 @@ static enum pkcs11_rc create_priv_key_attributes(struct obj_attrs **out,
return set_attributes_opt_or_null(out, temp, oon, oon_count);
}

static int mbd_rand(void *rng_state __unused, unsigned char *output, size_t len)
{
if (crypto_rng_read(output, len))
return MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED;
return 0;
}
static enum pkcs11_rc
create_ec_priv_key_hidden_attributes(struct obj_attrs **out,
struct obj_attrs *temp,
Expand Down Expand Up @@ -1000,7 +1006,7 @@ create_ec_priv_key_hidden_attributes(struct obj_attrs **out,
}

ret = mbedtls_ecp_mul(&key_pair_grp, &key_pair_Q, &key_pair_d,
&key_pair_grp.G, NULL, NULL);
&key_pair_grp.G, mbd_rand, NULL);
if (ret) {
EMSG("Failed to create public key");
goto out;
Expand Down Expand Up @@ -2512,7 +2518,7 @@ static enum pkcs11_rc set_private_key_data_rsa(struct obj_attrs **head,
mbedtls_mpi_init(&q);

mbedtls_rc = mbedtls_pk_parse_key(&pk, data, key_size,
NULL, 0, NULL, 0);
NULL, 0, mbd_rand, NULL);
if (mbedtls_rc) {
rc = PKCS11_CKR_ARGUMENTS_BAD;
goto out;
Expand Down

0 comments on commit 3619de8

Please sign in to comment.