Skip to content

Commit 36ea2bd

Browse files
committed
preTBS: revert Ed25519/Ed448 alt-sig support to keep PR scope tight
wolfSSL's dual-alg-cert support does not currently exercise Ed25519 or Ed448 alt keys, so the additional plumbing in this PR is out of scope and only adds review surface. Revert the four Ed-specific changes: asn.c - wc_Ed25519PublicKeyDecode and wc_Ed448PublicKeyDecode go back to SPKI-only input (dropping the raw-or-SPKI dual-input pattern that mirrored Falcon/Dilithium). - ConfirmSignature ED25519k / ED448k cases go back to direct wc_ed25519_import_public / wc_ed448_import_public on the supplied raw key (the historical primary-signature behaviour). tests/api.c - Remove test_dual_alg_unsupported_alt_native (depended on Ed25519 alt keys reaching DecodePeerAltPubKey, which is unreachable now). - Remove test_dual_alg_eddsa_pubkey_decode_dual_input (covered the reverted decoder behaviour). - Remove the ED25519_TYPE case from do_build_dual_alg_self_signed's alt-key SPKI export switch and update the helper's pairings comment. - Update the registration list and the negative-tests comment block. Other dual-alg-cert work in this PR is unaffected. After the revert: - 9 dual-alg tests still pass under the full config (--enable-dual-alg-certs --enable-experimental --enable-dilithium --enable-mldsa --enable-certreq --enable-certgen --enable-keygen + -DWOLFSSL_CUSTOM_OID -DHAVE_OID_ENCODING -DHAVE_OID_DECODING): test_dual_alg_support test_dual_alg_crit_ext_support test_dual_alg_ecdsa_mldsa test_dual_alg_pretbs_cert test_dual_alg_pretbs_altsigval_not_last test_dual_alg_csr_roundtrip test_dual_alg_pretbs_csr_altsigval_not_last test_dual_alg_collision_handshake test_dual_alg_minkeysize_handshake - Base config (--enable-dual-alg-certs --enable-experimental): clean -Werror, 0 failures. Ed25519/Ed448 alt-sig support can be added in a follow-up PR alongside DecodePeerAltPubKey cases for those algorithms.
1 parent de21606 commit 36ea2bd

2 files changed

Lines changed: 5 additions & 223 deletions

File tree

tests/api.c

Lines changed: 1 addition & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,9 +2210,6 @@ static int test_dual_alg_pretbs_csr_altsigval_not_last(void)
22102210
* fail (collision detection)
22112211
* - test_dual_alg_minkeysize_handshake alt key smaller than client's
22122212
* minimum, must fail
2213-
* - test_dual_alg_unsupported_alt_native unrecognised alt-key OID with
2214-
* sigSpec=NATIVE, must succeed
2215-
* (graceful skip)
22162213
* ---------------------------------------------------------------------------- */
22172214
#if defined(WOLFSSL_DUAL_ALG_CERTS) && defined(HAVE_ECC) && \
22182215
!defined(WC_NO_RNG) && !defined(WOLFSSL_SMALL_STACK) && \
@@ -2232,7 +2229,7 @@ static int test_dual_alg_pretbs_csr_altsigval_not_last(void)
22322229
* and the final signed cert.
22332230
*
22342231
* Supported pairings (by algorithm, not enforced statically):
2235-
* primary {ECC, RSA} ALG; alt {ECC, Ed25519} ALG.
2232+
* primary {ECC, RSA} ALG; alt ECC ALG.
22362233
* The matrix is open - anything wc_MakeCert_ex / wc_MakeSigWithBitStr
22372234
* accept will work; just gate the call site on the relevant HAVE_*
22382235
* flags.
@@ -2264,12 +2261,6 @@ static int do_build_dual_alg_self_signed(byte* out, word32 outSz,
22642261
altPubSz = wc_EccPublicKeyToDer((ecc_key*)altKey, altPubDer,
22652262
(word32)sizeof(altPubDer), 1);
22662263
break;
2267-
#endif
2268-
#if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT)
2269-
case ED25519_TYPE:
2270-
altPubSz = wc_Ed25519PublicKeyToDer((ed25519_key*)altKey, altPubDer,
2271-
(word32)sizeof(altPubDer), 1);
2272-
break;
22732264
#endif
22742265
default:
22752266
return -1;
@@ -2494,183 +2485,6 @@ static int test_dual_alg_minkeysize_handshake(void)
24942485
}
24952486

24962487

2497-
/* Unsupported alt-key OID + NATIVE handshake: build a self-signed cert
2498-
* with primary ECDSA + alt Ed25519 (real key, real Ed25519 alt
2499-
* signature). The cert validates cleanly during ParseCertRelative -
2500-
* ConfirmSignature now parses SPKI DER for Ed25519/Ed448 sapki, the
2501-
* companion fix in this PR - but DecodePeerAltPubKey has no case for
2502-
* Ed25519. Per the soft-skip behaviour the handshake must still succeed
2503-
* when sigSpec is NATIVE (the alt key just isn't decoded into any
2504-
* peer*Key slot, since NATIVE never consumes it). */
2505-
static int test_dual_alg_unsupported_alt_native(void)
2506-
{
2507-
EXPECT_DECLS;
2508-
#if defined(WOLFSSL_DUAL_ALG_CERTS) && defined(HAVE_ECC) && \
2509-
defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) && \
2510-
defined(HAVE_ED25519_KEY_IMPORT) && \
2511-
defined(HAVE_ED25519_SIGN) && defined(HAVE_ED25519_VERIFY) && \
2512-
!defined(WC_NO_RNG) && !defined(WOLFSSL_SMALL_STACK) && \
2513-
defined(WOLFSSL_CUSTOM_OID) && defined(HAVE_OID_ENCODING) && \
2514-
!defined(NO_TLS) && defined(WOLFSSL_TLS13)
2515-
WC_RNG rng;
2516-
ecc_key primaryKey;
2517-
ed25519_key altKey;
2518-
byte primaryKeyDer[256];
2519-
int primaryKeyDerSz;
2520-
byte certDer[2 * LARGE_TEMP_SZ];
2521-
int certDerSz;
2522-
WOLFSSL_CTX *ctx_c = NULL;
2523-
WOLFSSL_CTX *ctx_s = NULL;
2524-
WOLFSSL *ssl_c = NULL;
2525-
WOLFSSL *ssl_s = NULL;
2526-
struct test_memio_ctx test_ctx;
2527-
2528-
XMEMSET(&rng, 0, sizeof(rng));
2529-
XMEMSET(&primaryKey, 0, sizeof(primaryKey));
2530-
XMEMSET(&altKey, 0, sizeof(altKey));
2531-
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
2532-
2533-
ExpectIntEQ(wc_InitRng(&rng), 0);
2534-
ExpectIntEQ(wc_ecc_init(&primaryKey), 0);
2535-
ExpectIntEQ(wc_ecc_make_key(&rng, KEY32, &primaryKey), 0);
2536-
ExpectIntEQ(wc_ed25519_init(&altKey), 0);
2537-
ExpectIntEQ(wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &altKey), 0);
2538-
2539-
primaryKeyDerSz = wc_EccKeyToDer(&primaryKey, primaryKeyDer,
2540-
sizeof(primaryKeyDer));
2541-
ExpectIntGT(primaryKeyDerSz, 0);
2542-
2543-
if (EXPECT_SUCCESS()) {
2544-
certDerSz = do_build_dual_alg_self_signed(certDer, sizeof(certDer),
2545-
ECC_TYPE, &primaryKey, CTC_SHA256wECDSA,
2546-
ED25519_TYPE, &altKey, CTC_ED25519,
2547-
&rng);
2548-
ExpectIntGT(certDerSz, 0);
2549-
2550-
ExpectIntEQ(test_memio_setup_ex(&test_ctx, &ctx_c, &ctx_s, &ssl_c,
2551-
&ssl_s, wolfTLSv1_3_client_method,
2552-
wolfTLSv1_3_server_method,
2553-
certDer, certDerSz,
2554-
certDer, certDerSz,
2555-
primaryKeyDer, primaryKeyDerSz), 0);
2556-
2557-
/* Default sigSpec is NATIVE; handshake must succeed. The Ed25519
2558-
* alt sig is verified at parse time (ConfirmSignature now handles
2559-
* SPKI DER for Ed25519), and DecodePeerAltPubKey hits its default
2560-
* "log + skip" branch for the unrecognised OID. */
2561-
ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), 0);
2562-
}
2563-
2564-
wolfSSL_free(ssl_c);
2565-
wolfSSL_free(ssl_s);
2566-
wolfSSL_CTX_free(ctx_c);
2567-
wolfSSL_CTX_free(ctx_s);
2568-
wc_ecc_free(&primaryKey);
2569-
wc_ed25519_free(&altKey);
2570-
wc_FreeRng(&rng);
2571-
#endif
2572-
return EXPECT_RESULT();
2573-
}
2574-
2575-
/* Focused regression test for the dual-input handling added to
2576-
* wc_Ed25519PublicKeyDecode / wc_Ed448PublicKeyDecode. The decoders must
2577-
* accept both a raw public key (matches the historical primary-signature
2578-
* verify path) and a full SubjectPublicKeyInfo DER (the X9.146
2579-
* alt-signature verify path's input format). Mirrors the dual-input
2580-
* pattern of wc_Falcon_PublicKeyDecode / wc_Dilithium_PublicKeyDecode. */
2581-
static int test_dual_alg_eddsa_pubkey_decode_dual_input(void)
2582-
{
2583-
EXPECT_DECLS;
2584-
#if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) && \
2585-
defined(HAVE_ED25519_KEY_IMPORT) && !defined(WC_NO_RNG)
2586-
{
2587-
WC_RNG rng;
2588-
ed25519_key src;
2589-
ed25519_key decoded;
2590-
byte spki[128];
2591-
int spkiSz;
2592-
byte raw[ED25519_PUB_KEY_SIZE];
2593-
word32 rawSz = (word32)sizeof(raw);
2594-
word32 idx;
2595-
2596-
XMEMSET(&rng, 0, sizeof(rng));
2597-
XMEMSET(&src, 0, sizeof(src));
2598-
XMEMSET(&decoded, 0, sizeof(decoded));
2599-
2600-
ExpectIntEQ(wc_InitRng(&rng), 0);
2601-
ExpectIntEQ(wc_ed25519_init(&src), 0);
2602-
ExpectIntEQ(wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &src), 0);
2603-
2604-
spkiSz = wc_Ed25519PublicKeyToDer(&src, spki, (word32)sizeof(spki),
2605-
1);
2606-
ExpectIntGT(spkiSz, 0);
2607-
ExpectIntEQ(wc_ed25519_export_public(&src, raw, &rawSz), 0);
2608-
ExpectIntEQ((int)rawSz, ED25519_PUB_KEY_SIZE);
2609-
2610-
/* SPKI form. */
2611-
ExpectIntEQ(wc_ed25519_init(&decoded), 0);
2612-
idx = 0;
2613-
ExpectIntEQ(wc_Ed25519PublicKeyDecode(spki, &idx, &decoded,
2614-
(word32)spkiSz), 0);
2615-
wc_ed25519_free(&decoded);
2616-
2617-
/* Raw form. */
2618-
ExpectIntEQ(wc_ed25519_init(&decoded), 0);
2619-
idx = 0;
2620-
ExpectIntEQ(wc_Ed25519PublicKeyDecode(raw, &idx, &decoded, rawSz),
2621-
0);
2622-
wc_ed25519_free(&decoded);
2623-
2624-
wc_ed25519_free(&src);
2625-
wc_FreeRng(&rng);
2626-
}
2627-
#endif
2628-
2629-
#if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) && \
2630-
defined(HAVE_ED448_KEY_IMPORT) && !defined(WC_NO_RNG)
2631-
{
2632-
WC_RNG rng;
2633-
ed448_key src;
2634-
ed448_key decoded;
2635-
byte spki[128];
2636-
int spkiSz;
2637-
byte raw[ED448_PUB_KEY_SIZE];
2638-
word32 rawSz = (word32)sizeof(raw);
2639-
word32 idx;
2640-
2641-
XMEMSET(&rng, 0, sizeof(rng));
2642-
XMEMSET(&src, 0, sizeof(src));
2643-
XMEMSET(&decoded, 0, sizeof(decoded));
2644-
2645-
ExpectIntEQ(wc_InitRng(&rng), 0);
2646-
ExpectIntEQ(wc_ed448_init(&src), 0);
2647-
ExpectIntEQ(wc_ed448_make_key(&rng, ED448_KEY_SIZE, &src), 0);
2648-
2649-
spkiSz = wc_Ed448PublicKeyToDer(&src, spki, (word32)sizeof(spki), 1);
2650-
ExpectIntGT(spkiSz, 0);
2651-
ExpectIntEQ(wc_ed448_export_public(&src, raw, &rawSz), 0);
2652-
ExpectIntEQ((int)rawSz, ED448_PUB_KEY_SIZE);
2653-
2654-
/* SPKI form. */
2655-
ExpectIntEQ(wc_ed448_init(&decoded), 0);
2656-
idx = 0;
2657-
ExpectIntEQ(wc_Ed448PublicKeyDecode(spki, &idx, &decoded,
2658-
(word32)spkiSz), 0);
2659-
wc_ed448_free(&decoded);
2660-
2661-
/* Raw form. */
2662-
ExpectIntEQ(wc_ed448_init(&decoded), 0);
2663-
idx = 0;
2664-
ExpectIntEQ(wc_Ed448PublicKeyDecode(raw, &idx, &decoded, rawSz), 0);
2665-
wc_ed448_free(&decoded);
2666-
2667-
wc_ed448_free(&src);
2668-
wc_FreeRng(&rng);
2669-
}
2670-
#endif
2671-
return EXPECT_RESULT();
2672-
}
2673-
26742488
/* Test wolfSSL_use_AltPrivateKey_Id.
26752489
* Verify that a valid key ID can be set successfully. Guards against an
26762490
* inverted AllocDer return check (== 0 vs != 0) that would treat successful
@@ -38108,8 +37922,6 @@ TEST_CASE testCases[] = {
3810837922
TEST_DECL(test_dual_alg_pretbs_csr_altsigval_not_last),
3810937923
TEST_DECL(test_dual_alg_collision_handshake),
3811037924
TEST_DECL(test_dual_alg_minkeysize_handshake),
38111-
TEST_DECL(test_dual_alg_unsupported_alt_native),
38112-
TEST_DECL(test_dual_alg_eddsa_pubkey_decode_dual_input),
3811337925

3811437926
TEST_DECL(test_wolfSSL_use_AltPrivateKey_Id),
3811537927
TEST_DECL(test_wolfSSL_use_AltPrivateKey_Label),

wolfcrypt/src/asn.c

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16571,7 +16571,6 @@ int ConfirmSignature(SignatureCtx* sigCtx,
1657116571
#if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_IMPORT)
1657216572
case ED25519k:
1657316573
{
16574-
word32 idx = 0;
1657516574
sigCtx->verify = 0;
1657616575
#ifndef WOLFSSL_NO_MALLOC
1657716576
sigCtx->key.ed25519 = (ed25519_key*)XMALLOC(
@@ -16585,14 +16584,8 @@ int ConfirmSignature(SignatureCtx* sigCtx,
1658516584
sigCtx->heap, sigCtx->devId)) < 0) {
1658616585
goto exit_cs;
1658716586
}
16588-
/* wc_Ed25519PublicKeyDecode accepts both raw and SPKI
16589-
* input (same dual-input pattern as the Falcon and
16590-
* Dilithium decoders), so this branch handles both the
16591-
* primary-signature path (cert->publicKey, raw) and the
16592-
* X9.146 alt-signature path (cert->ca->sapkiDer, SPKI). */
16593-
ret = wc_Ed25519PublicKeyDecode(key, &idx,
16594-
sigCtx->key.ed25519, keySz);
16595-
if (ret < 0) {
16587+
if ((ret = wc_ed25519_import_public(key, keySz,
16588+
sigCtx->key.ed25519)) < 0) {
1659616589
WOLFSSL_MSG("ASN Key import error ED25519");
1659716590
WOLFSSL_ERROR_VERBOSE(ret);
1659816591
goto exit_cs;
@@ -16606,7 +16599,6 @@ int ConfirmSignature(SignatureCtx* sigCtx,
1660616599
#if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_IMPORT)
1660716600
case ED448k:
1660816601
{
16609-
word32 idx = 0;
1661016602
sigCtx->verify = 0;
1661116603
#ifndef WOLFSSL_NO_MALLOC
1661216604
sigCtx->key.ed448 = (ed448_key*)XMALLOC(
@@ -16619,10 +16611,8 @@ int ConfirmSignature(SignatureCtx* sigCtx,
1661916611
if ((ret = wc_ed448_init(sigCtx->key.ed448)) < 0) {
1662016612
goto exit_cs;
1662116613
}
16622-
/* See ED25519k above for the dual-input rationale. */
16623-
ret = wc_Ed448PublicKeyDecode(key, &idx,
16624-
sigCtx->key.ed448, keySz);
16625-
if (ret < 0) {
16614+
if ((ret = wc_ed448_import_public(key, keySz,
16615+
sigCtx->key.ed448)) < 0) {
1662616616
WOLFSSL_MSG("ASN Key import error ED448");
1662716617
WOLFSSL_ERROR_VERBOSE(ret);
1662816618
goto exit_cs;
@@ -32124,19 +32114,6 @@ int wc_Ed25519PublicKeyDecode(const byte* input, word32* inOutIdx,
3212432114
return BAD_FUNC_ARG;
3212532115
}
3212632116

32127-
/* Accept either a raw public key (32 bytes, or 33 bytes with the 0x40
32128-
* compressed-form prefix) or a full SubjectPublicKeyInfo DER. The raw
32129-
* import handles the first two; if the input is neither, fall back to
32130-
* stripping the SPKI wrapper. Mirrors the dual-input pattern of
32131-
* wc_Falcon_PublicKeyDecode / wc_Dilithium_PublicKeyDecode so that
32132-
* the X9.146 alt-signature verify path (which feeds full SPKI from
32133-
* cert->ca->sapkiDer) works alongside the primary-signature path
32134-
* (which feeds raw key bytes from cert->publicKey). */
32135-
ret = wc_ed25519_import_public(input, inSz, key);
32136-
if (ret == 0) {
32137-
return 0;
32138-
}
32139-
3214032117
/* init pubKey */
3214132118
XMEMSET(pubKey, 0, sizeof(pubKey));
3214232119

@@ -32559,13 +32536,6 @@ int wc_Ed448PublicKeyDecode(const byte* input, word32* inOutIdx,
3255932536
return BAD_FUNC_ARG;
3256032537
}
3256132538

32562-
/* See wc_Ed25519PublicKeyDecode for the rationale on accepting either
32563-
* a raw public key or a full SubjectPublicKeyInfo DER. */
32564-
ret = wc_ed448_import_public(input, inSz, key);
32565-
if (ret == 0) {
32566-
return 0;
32567-
}
32568-
3256932539
ret = DecodeAsymKeyPublic(input, inOutIdx, inSz,
3257032540
pubKey, &pubKeyLen, ED448k);
3257132541
if (ret == 0) {

0 commit comments

Comments
 (0)