diff options
-rw-r--r-- | plat/st/common/stm32mp_crypto_lib.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/plat/st/common/stm32mp_crypto_lib.c b/plat/st/common/stm32mp_crypto_lib.c index ea2b8dbf8..b3b1d3dae 100644 --- a/plat/st/common/stm32mp_crypto_lib.c +++ b/plat/st/common/stm32mp_crypto_lib.c @@ -80,7 +80,7 @@ static void crypto_lib_init(void) } static int get_plain_pk_from_asn1(void *pk_ptr, unsigned int pk_len, void **plain_pk, - unsigned int *len, int *pk_alg) + size_t *len, int *pk_alg) { int ret; mbedtls_pk_context mbedtls_pk = {0}; @@ -170,7 +170,15 @@ uint32_t verify_signature(uint8_t *hash_in, uint8_t *pubkey_in, static int crypto_convert_pk(void *full_pk_ptr, unsigned int full_pk_len, void **hashed_pk_ptr, unsigned int *hashed_pk_len) { - return get_plain_pk_from_asn1(full_pk_ptr, full_pk_len, hashed_pk_ptr, hashed_pk_len, NULL); + size_t len; + int ret; + + ret = get_plain_pk_from_asn1(full_pk_ptr, full_pk_len, hashed_pk_ptr, &len, NULL); + if (ret == 0) { + *hashed_pk_len = (unsigned int)len; + } + + return ret; } #else /* STM32MP_CRYPTO_ROM_LIB*/ static uint32_t verify_signature(uint8_t *hash_in, uint8_t *pubkey_in, @@ -226,7 +234,7 @@ static int crypto_convert_pk(void *full_pk_ptr, unsigned int full_pk_len, static uint8_t st_pk[CRYPTO_PUBKEY_MAX_SIZE + sizeof(uint32_t)]; int ret; void *plain_pk; - unsigned int len; + size_t len; int curve_id; uint32_t cid; @@ -241,7 +249,7 @@ static int crypto_convert_pk(void *full_pk_ptr, unsigned int full_pk_len, memcpy(st_pk + sizeof(cid), plain_pk, len); *hashed_pk_ptr = st_pk; - *hashed_pk_len = len + sizeof(cid); + *hashed_pk_len = (unsigned int)(len + sizeof(cid)); return 0; } @@ -339,15 +347,15 @@ static int crypto_verify_signature(void *data_ptr, unsigned int data_len, return CRYPTO_ERR_SIGNATURE; } - ret = get_plain_pk_from_asn1(pk_ptr, pk_len, &pk_ptr, &pk_len, &curve_id); + ret = get_plain_pk_from_asn1(pk_ptr, pk_len, &pk_ptr, &len, &curve_id); if (ret != 0) { VERBOSE("%s: get_plain_pk_from_asn1 (%d)\n", __func__, ret); return CRYPTO_ERR_SIGNATURE; } /* We expect a known pk_len */ - if (pk_len != sizeof(my_pk)) { - VERBOSE("%s: pk_len=%u sizeof(my_pk)=%zu)\n", __func__, pk_len, sizeof(my_pk)); + if (len != sizeof(my_pk)) { + VERBOSE("%s: pk_len=%zu sizeof(my_pk)=%zu)\n", __func__, len, sizeof(my_pk)); return CRYPTO_ERR_SIGNATURE; } @@ -517,7 +525,7 @@ int plat_get_enc_key_info(enum fw_enc_status_t fw_enc_status, uint8_t *key, } if (otp_len > (*key_len * CHAR_BIT)) { - VERBOSE("%s: length Error otp_len=%u key_len=%u\n", __func__, + VERBOSE("%s: length Error otp_len=%u key_len=%zu\n", __func__, otp_len, *key_len * CHAR_BIT); return -EINVAL; } |