forked from wolfSSL/wolfssl
Fixed alignment/padding for hash. ECC tests passing on target.
This commit is contained in:
@@ -740,6 +740,7 @@ int stm32_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
uint8_t Sbin[STM32_MAX_ECC_SIZE];
|
uint8_t Sbin[STM32_MAX_ECC_SIZE];
|
||||||
uint8_t Qxbin[STM32_MAX_ECC_SIZE];
|
uint8_t Qxbin[STM32_MAX_ECC_SIZE];
|
||||||
uint8_t Qybin[STM32_MAX_ECC_SIZE];
|
uint8_t Qybin[STM32_MAX_ECC_SIZE];
|
||||||
|
uint8_t Hashbin[STM32_MAX_ECC_SIZE];
|
||||||
uint8_t privKeybin[STM32_MAX_ECC_SIZE];
|
uint8_t privKeybin[STM32_MAX_ECC_SIZE];
|
||||||
const uint8_t *prime, *coef, *gen_x, *gen_y, *order;
|
const uint8_t *prime, *coef, *gen_x, *gen_y, *order;
|
||||||
const uint32_t *coef_sign;
|
const uint32_t *coef_sign;
|
||||||
@@ -785,7 +786,9 @@ int stm32_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
pka_ecc.pPubKeyCurvePtY = Qybin;
|
pka_ecc.pPubKeyCurvePtY = Qybin;
|
||||||
pka_ecc.RSign = Rbin;
|
pka_ecc.RSign = Rbin;
|
||||||
pka_ecc.SSign = Sbin;
|
pka_ecc.SSign = Sbin;
|
||||||
pka_ecc.hash = hash;
|
memset(Hashbin, 0, STM32_MAX_ECC_SIZE);
|
||||||
|
memcpy(Hashbin + (size - hashlen), hash, hashlen);
|
||||||
|
pka_ecc.hash = Hashbin;
|
||||||
|
|
||||||
status = HAL_PKA_ECDSAVerif(&hpka, &pka_ecc, 0xFFFFFFFF);
|
status = HAL_PKA_ECDSAVerif(&hpka, &pka_ecc, 0xFFFFFFFF);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
@@ -811,6 +814,7 @@ int stm32_ecc_sign_hash_ex(const byte* hash, word32 hashlen, WC_RNG* rng,
|
|||||||
uint8_t Intbin[STM32_MAX_ECC_SIZE];
|
uint8_t Intbin[STM32_MAX_ECC_SIZE];
|
||||||
uint8_t Rbin[STM32_MAX_ECC_SIZE];
|
uint8_t Rbin[STM32_MAX_ECC_SIZE];
|
||||||
uint8_t Sbin[STM32_MAX_ECC_SIZE];
|
uint8_t Sbin[STM32_MAX_ECC_SIZE];
|
||||||
|
uint8_t Hashbin[STM32_MAX_ECC_SIZE];
|
||||||
const uint8_t *prime, *coef, *gen_x, *gen_y, *order;
|
const uint8_t *prime, *coef, *gen_x, *gen_y, *order;
|
||||||
const uint32_t *coef_sign;
|
const uint32_t *coef_sign;
|
||||||
memset(&pka_ecc, 0x00, sizeof(PKA_ECDSASignInTypeDef));
|
memset(&pka_ecc, 0x00, sizeof(PKA_ECDSASignInTypeDef));
|
||||||
@@ -851,7 +855,9 @@ int stm32_ecc_sign_hash_ex(const byte* hash, word32 hashlen, WC_RNG* rng,
|
|||||||
pka_ecc.basePointY = gen_y;
|
pka_ecc.basePointY = gen_y;
|
||||||
pka_ecc.primeOrder = order;
|
pka_ecc.primeOrder = order;
|
||||||
|
|
||||||
pka_ecc.hash = hash;
|
memset(Hashbin, 0, STM32_MAX_ECC_SIZE);
|
||||||
|
memcpy(Hashbin + (size - hashlen), hash, hashlen);
|
||||||
|
pka_ecc.hash = Hashbin;
|
||||||
pka_ecc.integer = Intbin;
|
pka_ecc.integer = Intbin;
|
||||||
pka_ecc.privateKey = Keybin;
|
pka_ecc.privateKey = Keybin;
|
||||||
|
|
||||||
|
@@ -18436,7 +18436,7 @@ int ecc_test(void)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(WOLFSSL_ATECC508A)
|
#if !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_STM32_PKA)
|
||||||
ret = ecc_test_make_pub(&rng);
|
ret = ecc_test_make_pub(&rng);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("ecc_test_make_pub failed!: %d\n", ret);
|
printf("ecc_test_make_pub failed!: %d\n", ret);
|
||||||
|
Reference in New Issue
Block a user