Skip to content

tests: derive the expected ECC rejection in the priv-only key test - #1187

Open
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:ecc-scalar-test
Open

tests: derive the expected ECC rejection in the priv-only key test#1187
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:ecc-scalar-test

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

tests/unit.test fails against any wolfSSL built from master:

IdentifyAsn1Key: private-only ECC P-256 DER fallback derivation expected WS_CRYPTO_FAILED, got -1017
IdentifyAsn1Key: FAILED

wolfSSL master commit 8bffaff ("Check ECC private key scalar range on import
(F-1930, F-1931)", 2026-08-12) rejects a private scalar outside [1, n-1] at
import. The zeroed scalar that test_IdentifyAsn1Key_EccPrivOnlyDerFailure
builds now fails in wc_EccPrivateKeyDecode with ECC_PRIV_KEY_E instead of
decoding and failing later in the wc_ecc_make_pub fallback, so
IdentifyAsn1Key never sets noPubKeyRet and returns WS_UNIMPLEMENTED_E
rather than the hard-coded WS_CRYPTO_FAILED the test expected. The library is
right either way -- the key is rejected -- only the stage differs.

The test now decodes the corrupted DER itself and expects whichever rejection
the linked wolfSSL performs, so the assertion stays strict on both released and
master wolfSSL and does not simply accept any error.

That commit is in no wolfSSL release, so this only shows up where wolfSSL comes
from master. Verified on x86_64 Linux against wolfSSL master 9ab8a4b
--enable-all: the unpatched test reproduces the failure above, the patched
test passes, and make check is 6 PASS / 2 SKIP / 0 FAIL. Also passes against
wolfSSL 5.9.2 --enable-all on macOS/arm64, Linux/arm64 and Linux/x86_64.

wolfSSL master now rejects a private scalar outside [1, n-1] when importing
one, so the zeroed key that test_IdentifyAsn1Key_EccPrivOnlyDerFailure builds
fails in wc_EccPrivateKeyDecode instead of reaching the wc_ecc_make_pub
fallback in IdentifyAsn1Key. The identify call then reports the key as
unidentified, WS_UNIMPLEMENTED_E, rather than WS_CRYPTO_FAILED, and the test
failed against any wolfSSL built from master.

- decode the corrupted DER first and expect the rejection the linked wolfSSL
  performs, so the assertion stays strict on either library
@ejohnstown
ejohnstown requested review from wolfSSL-Fenrir-bot and a lite review from Copilot August 20, 2026 22:50

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1187

Scan targets checked: wolfssh-bugs, wolfssh-src

No new issues found in the changed files. ✅

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.

2 participants