Skip to content

Fix STM32 bare-metal V2 PKA ECC scalar multiply and cold init - #11909

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:stm32_bare_pka
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:stm32_bare_pka

Conversation

@dgarske

@dgarske dgarske commented Oct 28, 2026

Copy link
Copy Markdown
Member

Description

The V2 PKA clobbers RAM[PKA_ECC_SCALAR_MUL_IN_OP_NB_BITS] during the operation, so HAL_PKA_ECCMul_GetResult() recomputing the result length from that slot read zero, copied nothing out, and left wc_ecc_mulmod_ex2() handing back the caller's own input point - public keys derived from a private key were wrong, so signatures did not verify against them and ECDH mismatched, surfacing as ECIES and PKCS7 KARI failures rather than as an ECC fault; HAL_PKA_ECCMul() now saves the modulus size on the handle as the V2 HAL does, and V1 still reads it from RAM. Separately the V2 PKA draws on the RNG during its init self-check, so SR.INITOK never asserted from cold and every operation failed with WC_HW_E, which HAL_PKA_Init() now avoids by bringing the RNG up first. Also fixed: INT_MAX undeclared on an STM32 USE_FAST_MATH build, and wolfcrypt_test failing to compile with NO_PKCS7_ENCRYPTED_DATA.

Only reachable without WOLFSSL_HAVE_SP_ECC, since with SP math key generation and ECDH stay in software and never reach the PKA.

ZD 22578

Testing

Validated on NUCLEO-U545RE-Q and B-U585I-IOT02A against the NIST P-256 CAVP d -> Q vector and the full wolfcrypt_test, and regressed on NUCLEO-U385RG-Q (V2 PKA) and STM32L562E-DK (V1 PKA).

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@dgarske dgarske self-assigned this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant