mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-19 02:54:24 +00:00
fix(st): allow crypto lib compilation in aarch64
Cast len with size_t, as it is unsigned long on Aarch64, and no more unsigned int. Changing functions prototypes will not help as .verify_signature awaits an unsigned int for its last parameter. Signed-off-by: Yann Gautier <yann.gautier@foss.st.com> Change-Id: I9332fd46301a9653af917802788fd97fe7c8a162
This commit is contained in:
parent
6fef0f67e4
commit
76e4fab000
1 changed files with 16 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue