From d235013fe9faece4b70a403348ccb8da140e40e2 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 27 Mar 2025 15:30:37 -0700 Subject: [PATCH] Fix for STM32 PKA with P521 and shared secret. ZD 19422 --- wolfcrypt/src/port/st/stm32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/port/st/stm32.c b/wolfcrypt/src/port/st/stm32.c index d998b91ac..80f441232 100644 --- a/wolfcrypt/src/port/st/stm32.c +++ b/wolfcrypt/src/port/st/stm32.c @@ -702,7 +702,6 @@ int wc_ecc_mulmod_ex2(const mp_int* k, ecc_point *G, ecc_point *R, mp_int* a, PKA_ECCMulInTypeDef pka_mul; PKA_ECCMulOutTypeDef pka_mul_res; int szModulus; - int szkbin; int status; int res; uint8_t Gxbin[STM32_MAX_ECC_SIZE]; @@ -730,9 +729,8 @@ int wc_ecc_mulmod_ex2(const mp_int* k, ecc_point *G, ecc_point *R, mp_int* a, } szModulus = mp_unsigned_bin_size(modulus); - szkbin = mp_unsigned_bin_size(k); - res = stm32_get_from_mp_int(kbin, k, szkbin); + res = stm32_get_from_mp_int(kbin, k, szModulus); if (res == MP_OKAY) res = stm32_get_from_mp_int(Gxbin, G->x, szModulus); if (res == MP_OKAY) @@ -767,7 +765,7 @@ int wc_ecc_mulmod_ex2(const mp_int* k, ecc_point *G, ecc_point *R, mp_int* a, pka_mul.modulus = prime; pka_mul.pointX = Gxbin; pka_mul.pointY = Gybin; - pka_mul.scalarMulSize = szkbin; + pka_mul.scalarMulSize = szModulus; pka_mul.scalarMul = kbin; #ifdef WOLFSSL_STM32_PKA_V2 pka_mul.coefB = coefB;