From 0be7fe4b9fd762bfc95c11470131ce4ac0c88ebb Mon Sep 17 00:00:00 2001 From: Colton Willey Date: Wed, 24 Jun 2026 11:01:54 -0700 Subject: [PATCH] decoder: skip foreign-OID keys before FIPS CAST A decoder probed with a non-owned key instantiated a wolfCrypt key and fired that algorithm's lazy primitive-Z CAST before any OID check. Check the AlgorithmIdentifier OID and skip instantiation while the CAST is cold. Fixes the ~8s FIPS CMS/RSA-sign regression. --- include/wolfprovider/internal.h | 20 + src/wp_dh_kmgmt.c | 24 +- src/wp_ecc_kmgmt.c | 25 +- src/wp_internal.c | 124 +++ src/wp_rsa_kmgmt.c | 27 +- test/standalone/include.am | 15 + .../test_decode_oid_precheck.c | 816 ++++++++++++++++++ 7 files changed, 1042 insertions(+), 9 deletions(-) create mode 100644 test/standalone/tests/decode_oid_precheck/test_decode_oid_precheck.c diff --git a/include/wolfprovider/internal.h b/include/wolfprovider/internal.h index 1dbd7d01..64bad7c0 100644 --- a/include/wolfprovider/internal.h +++ b/include/wolfprovider/internal.h @@ -242,6 +242,26 @@ int wp_read_pem_bio(WOLFPROV_CTX *provctx, OSSL_CORE_BIO *coreBio, unsigned char** data, word32* len); BIO* wp_corebio_get_bio(WOLFPROV_CTX* provCtx, OSSL_CORE_BIO *coreBio); +#ifdef HAVE_FIPS +/** + * Decide whether a decoder should skip key-object instantiation (FIPS only). + * + * Cold-CAST optimization: if the wrapped key's (SPKI/PKCS#8) AlgorithmIdentifier + * OID is recognized but not in allowedNids, return 1 so the caller bails before + * instantiating a key (which would fire the lazy CAST). + * + * @param [in] castType FIPS CAST id for this decoder's algorithm. + * @param [in] der DER-encoded key bytes. + * @param [in] len Length of der in bytes. + * @param [in] format Encoding format (WP_ENC_FORMAT_*). + * @param [in] allowedNids NIDs owned by this decoder. + * @param [in] nAllowed Number of entries in allowedNids. + * @return 1 to skip instantiation, 0 to proceed. + */ +int wp_decode_should_skip(int castType, const unsigned char* der, word32 len, + int format, const int* allowedNids, size_t nAllowed); +#endif /* HAVE_FIPS */ + byte wp_ct_byte_mask_eq(byte a, byte b); byte wp_ct_byte_mask_ne(byte a, byte b); byte wp_ct_int_mask_gte(int a, int b); diff --git a/src/wp_dh_kmgmt.c b/src/wp_dh_kmgmt.c index b25e27e6..5b47cc25 100644 --- a/src/wp_dh_kmgmt.c +++ b/src/wp_dh_kmgmt.c @@ -33,6 +33,17 @@ #ifdef WP_HAVE_DH +#ifdef HAVE_FIPS +#include + +static const int wp_dh_decode_nids[] = { + NID_dhKeyAgreement, + NID_dhpublicnumber +}; +#define WP_DH_DECODE_NIDS_CNT \ + (sizeof(wp_dh_decode_nids) / sizeof(*wp_dh_decode_nids)) +#endif /* HAVE_FIPS */ + /** Supported selections (key parts) in this key manager for DH. */ #define WP_DH_POSSIBLE_SELECTIONS \ (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) @@ -2307,15 +2318,22 @@ static int wp_dh_decode(wp_DhEncDecCtx* ctx, OSSL_CORE_BIO *cBio, ctx->selection = selection; + if (ok && (!wp_read_der_bio(ctx->provCtx, cBio, &data, &len))) { + ok = 0; + } +#ifdef HAVE_FIPS + if (ok && wp_decode_should_skip(FIPS_CAST_DH_PRIMITIVE_Z, data, len, + ctx->format, wp_dh_decode_nids, WP_DH_DECODE_NIDS_CNT)) { + decoded = 0; + ok = 0; + } +#endif if (ok) { dh = wp_dh_new(ctx->provCtx); if (dh == NULL) { ok = 0; } } - if (ok && (!wp_read_der_bio(ctx->provCtx, cBio, &data, &len))) { - ok = 0; - } if (ok && (ctx->format == WP_ENC_FORMAT_TYPE_SPECIFIC)) { if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0){ if (!wp_dh_decode_pki(dh, data, len)) { diff --git a/src/wp_ecc_kmgmt.c b/src/wp_ecc_kmgmt.c index cd8fe9c4..4e60d086 100644 --- a/src/wp_ecc_kmgmt.c +++ b/src/wp_ecc_kmgmt.c @@ -34,6 +34,16 @@ #ifdef WP_HAVE_ECC +#ifdef HAVE_FIPS +#include + +static const int wp_ecc_decode_nids[] = { + NID_X9_62_id_ecPublicKey +}; +#define WP_ECC_DECODE_NIDS_CNT \ + (sizeof(wp_ecc_decode_nids) / sizeof(*wp_ecc_decode_nids)) +#endif /* HAVE_FIPS */ + /* Note: Explicit parameters are not supported. A predefined curve MUST be used. */ @@ -2307,13 +2317,22 @@ static int wp_ecc_decode(wp_EccEncDecCtx* ctx, OSSL_CORE_BIO *cBio, ctx->selection = selection; - ecc = wp_ecc_new(ctx->provCtx); - if (ecc == NULL) { + if (ok && (!wp_read_der_bio(ctx->provCtx, cBio, &data, &len))) { ok = 0; } - if (ok && (!wp_read_der_bio(ctx->provCtx, cBio, &data, &len))) { +#ifdef HAVE_FIPS + if (ok && wp_decode_should_skip(FIPS_CAST_ECC_PRIMITIVE_Z, data, len, + ctx->format, wp_ecc_decode_nids, WP_ECC_DECODE_NIDS_CNT)) { + decoded = 0; ok = 0; } +#endif + if (ok) { + ecc = wp_ecc_new(ctx->provCtx); + if (ecc == NULL) { + ok = 0; + } + } if (ok && ((ctx->format == WP_ENC_FORMAT_TYPE_SPECIFIC) || (ctx->format == WP_ENC_FORMAT_X9_62))) { if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) { diff --git a/src/wp_internal.c b/src/wp_internal.c index 03d15439..238d86f4 100644 --- a/src/wp_internal.c +++ b/src/wp_internal.c @@ -20,6 +20,9 @@ #include +#include +#include +#include #include #include @@ -29,6 +32,9 @@ #include #include +#ifdef HAVE_FIPS +#include +#endif #ifndef WP_SINGLE_THREADED @@ -197,6 +203,124 @@ int wp_init_cast(int algo) #endif /* HAVE_FIPS */ #endif /* !WP_SINGLE_THREADED */ +#ifdef HAVE_FIPS +/** + * Extract the AlgorithmIdentifier OID NID from a SubjectPublicKeyInfo DER. + * + * Not d2i_X509_PUBKEY: its custom d2i hook drives OSSL_DECODER, which re-enters + * this provider's decoders and recurses. ASN1_get_object + d2i_X509_ALGOR are + * plain templates and re-entry-safe. + * + * @param [in] der DER bytes. + * @param [in] len Length of der. + * @return Algorithm NID, or NID_undef if not a fully-consumed SPKI. + */ +static int wp_spki_alg_nid(const unsigned char* der, word32 len) +{ + int nid = NID_undef; + const unsigned char* p = der; + long plen; + int tag, xclass, hdr; + + ERR_set_mark(); + hdr = ASN1_get_object(&p, &plen, &tag, &xclass, (long)len); + if (!(hdr & 0x80) && (tag == V_ASN1_SEQUENCE) && + (xclass == V_ASN1_UNIVERSAL) && + ((word32)(p - der) + (word32)plen == len)) { + const unsigned char* seqEnd = p + plen; + X509_ALGOR* alg = d2i_X509_ALGOR(NULL, &p, plen); + if (alg != NULL) { + const unsigned char* bsp = p; + long bslen; + int bstag, bsclass, bshdr; + + /* Require the trailing BIT STRING so a foreign SEQUENCE is not + * mistaken for an SPKI. */ + bshdr = ASN1_get_object(&bsp, &bslen, &bstag, &bsclass, + (long)(seqEnd - p)); + if ((alg->algorithm != NULL) && !(bshdr & 0x80) && + (bstag == V_ASN1_BIT_STRING) && + (bsclass == V_ASN1_UNIVERSAL) && + (bsp + bslen == seqEnd)) { + nid = OBJ_obj2nid(alg->algorithm); + } + X509_ALGOR_free(alg); + } + } + ERR_pop_to_mark(); + + return nid; +} + +/** + * Extract the AlgorithmIdentifier OID NID from a PKCS#8 PrivateKeyInfo DER. + * + * @param [in] der DER bytes. + * @param [in] len Length of der. + * @return Algorithm NID, or NID_undef if not a fully-consumed PKCS#8. + */ +static int wp_pki_alg_nid(const unsigned char* der, word32 len) +{ + int nid = NID_undef; + const unsigned char* p = der; + PKCS8_PRIV_KEY_INFO* p8; + + ERR_set_mark(); + p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, (long)len); + if (p8 != NULL) { + if (p == der + len) { + const ASN1_OBJECT* alg = NULL; + if ((PKCS8_pkey_get0(&alg, NULL, NULL, NULL, p8) == 1) && + (alg != NULL)) { + nid = OBJ_obj2nid(alg); + } + } + PKCS8_PRIV_KEY_INFO_free(p8); + } + ERR_pop_to_mark(); + + return nid; +} + +/** + * Decide whether a decoder should skip key-object instantiation. + * + * See declaration in internal.h for the full contract. + */ +int wp_decode_should_skip(int castType, const unsigned char* der, word32 len, + int format, const int* allowedNids, size_t nAllowed) +{ + int nid; + size_t i; + + if (wc_GetCastStatus_fips(castType) == FIPS_CAST_STATE_SUCCESS) { + return 0; + } + if ((format != WP_ENC_FORMAT_SPKI) && (format != WP_ENC_FORMAT_PKI)) { + return 0; + } + + if (format == WP_ENC_FORMAT_SPKI) { + nid = wp_spki_alg_nid(der, len); + } + else { + nid = wp_pki_alg_nid(der, len); + } + + /* Can't prove it foreign -> proceed; protects raw/unwrapped key material. */ + if (nid == NID_undef) { + return 0; + } + for (i = 0; i < nAllowed; i++) { + if (nid == allowedNids[i]) { + return 0; + } + } + + return 1; +} +#endif /* HAVE_FIPS */ + /** * Get the wolfSSL random number generator from the provider context. * diff --git a/src/wp_rsa_kmgmt.c b/src/wp_rsa_kmgmt.c index ee8403a6..009967b8 100644 --- a/src/wp_rsa_kmgmt.c +++ b/src/wp_rsa_kmgmt.c @@ -36,6 +36,18 @@ #ifdef WP_HAVE_RSA +#ifdef HAVE_FIPS +#include +#include + +static const int wp_rsa_decode_nids[] = { + NID_rsaEncryption, + NID_rsassaPss +}; +#define WP_RSA_DECODE_NIDS_CNT \ + (sizeof(wp_rsa_decode_nids) / sizeof(*wp_rsa_decode_nids)) +#endif /* HAVE_FIPS */ + /* In 5.8.2 RSA_MIN_SIZE was changed from 1024 to 2048. We still need to * allow 1024 in some cases, and have extended logic in place for it already. * For FIPS 1024 bit keys, use existing checks and let wolfssl throw us back */ @@ -2577,12 +2589,21 @@ static int wp_rsa_decode(wp_RsaEncDecCtx* ctx, OSSL_CORE_BIO* cBio, ctx->selection = selection; - rsa = wp_rsa_base_new(ctx->provCtx, ctx->type); - if (rsa == NULL) { + if (ok) { + ok = wp_read_der_bio(ctx->provCtx, cBio, &data, &len); + } +#ifdef HAVE_FIPS + if (ok && wp_decode_should_skip(FIPS_CAST_RSA_SIGN_PKCS1v15, data, len, + ctx->format, wp_rsa_decode_nids, WP_RSA_DECODE_NIDS_CNT)) { + decoded = 0; ok = 0; } +#endif if (ok) { - ok = wp_read_der_bio(ctx->provCtx, cBio, &data, &len); + rsa = wp_rsa_base_new(ctx->provCtx, ctx->type); + if (rsa == NULL) { + ok = 0; + } } if (ok && (ctx->format == WP_ENC_FORMAT_SPKI)) { if (!wp_rsa_decode_spki(rsa, data, len)) { diff --git a/test/standalone/include.am b/test/standalone/include.am index da1a7564..84e27dfd 100644 --- a/test/standalone/include.am +++ b/test/standalone/include.am @@ -8,6 +8,12 @@ noinst_HEADERS += test/standalone/test_common.h \ test/standalone/tests/fips_baseline/test_fips_baseline.h +# Process-isolated decoder OID-precheck regression test. Unlike the other +# standalone tests, this one IS part of 'make check' (added to check_PROGRAMS +# below) because its safety invariant must be guarded automatically. It runs in +# its own fresh process so the DH/ECC primitive-Z FIPS CASTs are cold (the +# shared unit.test warms them); see the file header for details. + # Standalone test programs # Each test compiles to its own binary for isolated execution # Note: These are NOT in check_PROGRAMS because they must be run through scripts, not directly @@ -41,6 +47,15 @@ test_fips_baseline_test_SOURCES = test/standalone/tests/fips_baseline/test_fips_ test/standalone/tests/fips_baseline/test_fips_baseline_pbkdf2.c test_fips_baseline_test_LDADD = $(STANDALONE_COMMON_LDADD) +# Decoder OID-precheck regression test - part of 'make check' +check_PROGRAMS += test/decode_oid_precheck.test +noinst_PROGRAMS += test/decode_oid_precheck.test +DISTCLEANFILES += test/.libs/decode_oid_precheck.test +test_decode_oid_precheck_test_CPPFLAGS = $(STANDALONE_COMMON_CPPFLAGS) +test_decode_oid_precheck_test_SOURCES = \ + test/standalone/tests/decode_oid_precheck/test_decode_oid_precheck.c +test_decode_oid_precheck_test_LDADD = $(STANDALONE_COMMON_LDADD) + # Common test utilities are built automatically by automake # Standalone tests are available for manual execution but not part of make check diff --git a/test/standalone/tests/decode_oid_precheck/test_decode_oid_precheck.c b/test/standalone/tests/decode_oid_precheck/test_decode_oid_precheck.c new file mode 100644 index 00000000..3829f9ef --- /dev/null +++ b/test/standalone/tests/decode_oid_precheck/test_decode_oid_precheck.c @@ -0,0 +1,816 @@ +/* test_decode_oid_precheck.c + * + * Copyright (C) 2006-2025 wolfSSL Inc. + * + * This file is part of wolfProvider. + * + * wolfProvider is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * wolfProvider is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wolfProvider. If not, see . + */ + +/* + * Regression test for the FIPS decoder OID-precheck (wp_decode_should_skip). + * + * Standalone process because the precheck only acts while the DH/ECC + * primitive-Z CASTs are cold, and the shared unit.test process warms them. + * Non-FIPS: the precheck is compiled out, so this skips. + */ + +#include +#include +#include + +#ifdef WOLFPROV_USER_SETTINGS +#include +#endif +#include +#include + +#include +#include +#include +#include +#include + +#include "test_common.h" + +#ifdef HAVE_FIPS +#include +#include +#endif + +/* + * Self-contained DER fixtures, HAVE_FIPS-gated so a non-FIPS build (precheck + * compiled out) does not trip -Wunused-const-variable. + */ +#ifdef HAVE_FIPS +static const unsigned char rsa_pkcs8_der[] = { + 0x30, 0x82, 0x04, 0xbd, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, + 0x04, 0xa7, 0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, + 0x01, 0x00, 0xb6, 0xdb, 0x1b, 0xeb, 0x69, 0xcd, 0x5b, 0x80, 0xd5, 0xbc, + 0x1a, 0xfd, 0xa7, 0xf4, 0xb5, 0xc2, 0x89, 0xc9, 0x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ce, 0x6e, 0x4a, 0x03, 0x05, 0xe2, 0x48, 0x37, 0x39, 0x2d, 0x0d, 0x90, + 0xe1, 0xb8, 0xfe, 0xb4, 0xa2, 0x35, 0xff, 0x35, 0xec, 0x6c, 0xc5, 0x44, + 0xce, 0x71, 0x86, 0x12, 0x3a, 0xee, 0x8c, 0x89, 0xab, 0x7e, 0xe3, 0x37, + 0xda, 0x4f, 0xa5, 0xa0, 0x5f, 0x35, 0xcf, 0xfc, 0xb4, 0x5b, 0x83, 0x62, + 0x68, 0x4a, 0xe2, 0x8f, 0x0b, 0x04, 0x15, 0xe2, 0x76, 0xaa, 0x5b, 0xb8, + 0x86, 0x1b, 0x61, 0x2f, 0x9c, 0x57, 0xb8, 0xa2, 0xbc, 0x74, 0xce, 0x95, + 0x52, 0xbc, 0x17, 0xef, 0x47, 0xc4, 0xff, 0x48, 0xc3, 0x64, 0xee, 0xc1, + 0x62, 0x31, 0x87, 0xa5, 0x08, 0x5e, 0x44, 0xda, 0xd9, 0xb1, 0x8a, 0xd6, + 0x16, 0x32, 0xd0, 0x95, 0xa0, 0xec, 0x77, 0xdc, 0xf1, 0x0f, 0x3d, 0x33, + 0xd6, 0x54, 0xad, 0x40, 0xf7, 0x9c, 0xad, 0xda, 0x0a, 0x20, 0x3a, 0x17, + 0x16, 0x11, 0x80, 0xbd, 0x41, 0x0a, 0xce, 0xa2, 0x14, 0x4f, 0x90, 0x82, + 0xd5, 0x06, 0xe5, 0xca, 0x89, 0x67, 0x1b, 0x02, 0x81, 0x81, 0x00, 0xef, + 0x6b, 0x4e, 0x3b, 0x8a, 0x46, 0x54, 0xb6, 0xb2, 0x4f, 0x2d, 0x38, 0xa2, + 0x77, 0x95, 0x23, 0xbe, 0xe1, 0x6a, 0xc6, 0x88, 0x7f, 0x73, 0xc6, 0x9f, + 0x5c, 0xa9, 0x22, 0x9c, 0x24, 0x6e, 0x23, 0x63, 0xd9, 0xa5, 0x75, 0xc3, + 0xc1, 0x7d, 0x8e, 0x94,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b8, 0xc3, 0xc4, 0x00, 0xe2, 0x67, + 0x20, 0x19, 0x30, 0x11, 0x94, 0x62, 0x6c, 0xb9, 0x31, 0xde, 0x74, 0x9a, + 0x43, 0xe6, 0xa3, 0xba, 0x78, 0xd0, 0x4a, 0x58, 0x71, 0xbe, 0x06, 0x55, + 0x79, 0xb4, 0x36, 0x0f, 0xbe, 0x80, 0x2a, 0xac, 0x9f, 0x55, 0xdd, 0x55, + 0x98, 0x38, 0xe2, 0x74, 0x04, 0x7d, 0x37, 0x52, 0xd9, 0x40, 0xc1, 0xc1, + 0xcb, 0x3e, 0x84, 0xb6, 0x1e, 0xaa, 0xb5, 0x0f, 0x25, 0x8a, 0x15, 0x63, + 0xa6, 0xf3, 0x6a, 0x83, 0xe7, 0x9b, 0x0e, 0x68, 0xb4, 0x7d, 0x90, 0x6c, + 0x71, 0x57, 0x69, 0x80, 0x0d, 0x8c, 0xe8, 0x45, 0xd8, 0x97, 0xa0, 0x86, + 0xba, 0x8a, 0x09, 0x05, 0xa8, 0x43, 0xd3, 0xee, 0xa2, 0x7c, 0x83, 0x66, + 0xe6, 0x00, 0xc9, 0x62, 0xff, 0x74, 0x4d, 0x22, 0x03, 0x32, 0xc7, 0x46, + 0xdc, 0xe5, 0xcc, 0xb0, 0x66, 0x81, 0x02, 0x81, 0x80, 0x69, 0xf1, 0xc1, + 0xfa, 0x90, 0x85, 0xc4, 0xbc, 0xa3, 0x51, 0x80, 0x5f, 0x59, 0x15, 0xd0, + 0xca, 0x51, 0x11, 0x4a, 0x84, 0xba, 0xc1, 0x63, 0xa7, 0xa1, 0xad, 0xd2, + 0x84, 0xa1, 0xfd, 0xbd, 0x5a, 0xac, 0x1d, 0xbd, 0x31, 0xb1, 0x0e, 0x6d, + 0xec, 0xc7, 0xfb, 0x3e, 0xe5, 0x55, 0x93, 0x3e, 0xcc, 0x0c, 0xe2, 0xfb, + 0x86, 0x3a, 0xfb, 0xc7, 0x25, 0x26, 0x84, 0xb5, 0x19, 0xf7, 0xc2, 0xb5, + 0xf5, 0xa1, 0x5c, 0xed, 0xb4, 0x63, 0x95, 0xa7, 0x2a, 0x3c, 0x51, 0xf5, + 0xb2, 0xb9, 0x6d, 0x53, 0x44, 0x13, 0xb9, 0x27, 0x8b, 0xeb, 0xbf, 0x69, + 0x1e, 0xed, 0x4a, 0x8d, 0x53, 0x52, 0x77, 0xe1, 0x45, 0x22, 0x02, 0x62, + 0x2d, 0x03, 0x35, 0x43, 0xcb, 0x23, 0x79, 0x12, 0x43, 0xa3, 0x6a, 0xf6, + 0x82, 0xd7, 0x69, 0x24, 0x42, 0xa3, 0xd6, 0x22, 0xfc, 0x18, 0xdb, 0x05, + 0x5e, 0xcb, 0xce, 0xb7, 0xa5, +}; +/* len = 1217 */ + +static const unsigned char rsa_spki_der[] = { + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, + 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0xdb, 0x1b, + 0xeb, 0x69, 0xcd, 0x5b, 0x80, 0xd5, 0xbc, 0x1a, 0xfd, 0xa7, 0xf4, 0xb5, + 0xc2, 0x89, 0xc9, 0x22, 0x26, 0xeb, 0x9a, 0x8b, 0x58, 0x90, 0xbf, 0x79, + 0xef, 0xd6, 0xf7, 0x2b, 0xc6, 0x1e, 0xec, 0x78, 0x64, 0x5f, 0xf7, 0x6f, + 0x36, 0x70, 0xb0, 0x74, 0xe7, 0x7b, 0x09, 0x5a, 0x0e, 0x66, 0x01, 0x12, + 0x4b, 0x73, 0xa2, 0xe0, 0x86, 0x2b, 0x34, 0x49, 0xea, 0xd5, 0x1e, 0x23, + 0x60, 0x7d, 0x9f, 0x2f, 0x6d, 0x67, 0xd8, 0x33, 0xc7, 0xb5, 0x68, 0x68, + 0xc4, 0xa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x01, 0x00, 0x01, +}; +/* len = 294 */ + +static const unsigned char rsapss_spki_der[] = { + 0x30, 0x82, 0x01, 0x20, 0x30, 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, + 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xba, 0xcd, 0x28, 0x35, 0xeb, + 0x50, 0xc6, 0x6c, 0xaf, 0xa0, 0x32, 0xab, 0x87, 0x0d, 0x37, 0xb5, 0x20, + 0xcf, 0x1d, 0x77, 0x28, 0xae, 0xc6, 0x53, 0xc6, 0xb8, 0xf5, 0x36, 0x35, + 0xa3, 0x20, 0xe1, 0x4c, 0x18, 0x40, 0x56, 0x35, 0x03, 0xdd, 0x70, 0x6d, + 0x38, 0x9b, 0xd6, 0x55, 0x97, 0xaf, 0xa0, 0xc6, 0xc9, 0x11, 0x0b, 0x85, + 0x95, 0x22, 0xc5, 0x64, 0xa3, 0x96, 0xce, 0xff, 0xd1, 0x82, 0xa3, 0x0c, + 0x4d, 0xd2, 0xa9, 0x6c, 0xb6, 0xef, 0x80, 0xbf, 0x48, 0x01, 0x59, 0x9b, + 0xe0, 0x07, 0x07, 0x07, 0xe4, 0xaa, 0xd9, 0x54, 0x02, 0xe0, 0xf1, 0xef, + 0x20, 0x6d, 0xb4, 0xd7, 0x60, 0x3b, 0xea, 0x9d, 0x5c, 0x81, 0xc6, 0x3f, + 0xce, 0x10, 0xb8, 0xbb, 0x63, 0x39, 0xf9, 0xb5, 0x80, 0x41, 0x4a, 0x8c, + 0x77, 0xdd, 0x68, 0x58, 0x41, 0x7c, 0xcc, 0xbe, 0xa8, 0xfd, 0xd4, 0x08, + 0xb9, 0x1d, 0x14, 0x6e, 0x68, 0x72, 0xc8, 0x9d, 0xa2, 0x98, 0x47, 0x49, + 0x63, 0x92, 0x07, 0x09, 0x8a, 0x5f, 0x71, 0xab, 0x98, 0x97, 0x82, 0xa4, + 0x4e, 0xf8, 0x64, 0x4b, 0x36, 0x2c, 0x0b, 0x59, 0x5a, 0x80, 0x60, 0x7c, + 0xa7, 0xd2, 0xfa, 0x1a, 0x71, 0x7d, 0xa9, 0xf1, 0xd9, 0x19, 0x74, 0xfa, + 0xa7, 0xf3, 0x28, 0x6b, 0xb7, 0x5a, 0xef, 0x51, 0x70, 0x2d, 0x65, 0xf2, + 0xef, 0x5c, 0x6b, 0xb9, 0xa9, 0x14, 0x83, 0x59, 0xc7, 0x04, 0x34, 0x03, + 0xaf, 0x39, 0x58, 0x7b, 0x0c, 0x81, 0x91, 0x51, 0x5c, 0xc7, 0x10, 0xd5, + 0xf3, 0x8f, 0x6c, 0xe6, 0xaa, 0x09, 0x03, 0xa3, 0x57, 0x66, 0x41, 0xdb, + 0xe9, 0x5b, 0x2e, 0x5f, 0xa8, 0xfe, 0x2c, 0x83, 0x40, 0xbd, 0x77, 0xb6, + 0x88, 0xda, 0xd5, 0x24, 0xcb, 0xbb, 0x9e, 0x58, 0xfc, 0x8e, 0x6f, 0xe7, + 0xb1, 0x85, 0x17, 0x20, 0x62, 0x99, 0xe5, 0x1e, 0x77, 0x89, 0xcf, 0x02, + 0x03, 0x01, 0x00, 0x01, +}; +/* len = 292 */ + +static const unsigned char dhx_pkcs8_der[] = { + 0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x30, 0x82, 0x02, 0x35, 0x06, + 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3e, 0x02, 0x01, 0x30, 0x82, 0x02, 0x28, + 0x02, 0x82, 0x01, 0x01, 0x00, 0xdf, 0x4e, 0x29, 0x86, 0xc7, 0x0a, 0x0f, + 0x4a, 0x3d, 0x41, 0x88, 0x08, 0xf4, 0x07, 0xf5, 0x01, 0xe8, 0xdf, 0xc8, + 0x4c, 0xf0, 0xff, 0x8a, 0x8e, 0x9e, 0x56, 0x86, 0x3f, 0x07, 0xed, 0x76, + 0xbd, 0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, 0x70, 0x3a, 0xfe, 0x57, 0x26, +}; +/* len = 608 */ + +static const unsigned char ec_spki_der[] = { + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, + 0x42, 0x00, 0x04, 0x82, 0x9d, 0xbd, 0x0c, 0x5f, 0x9e, 0xc0, 0xb2, 0x5e, + 0xdb, 0x09, 0x62, 0x14, 0xa1, 0xd6, 0x4e, 0xff, 0x5c, 0x1c, 0xd4, 0xa7, + 0x1d, 0xe3, 0x1d, 0xea, 0x75, 0x76, 0x65, 0x4f, 0xf6, 0x05, 0x49, 0x84, + 0x19, 0xe2, 0xc6, 0xbd, 0x90, 0xc4, 0x14, 0xab, 0xfd, 0xd1, 0xa0, 0xd3, + 0x79, 0x0b, 0x63, 0x85, 0x06, 0x7e, 0x82, 0xb0, 0xc4, 0xa5, 0xdd, 0x08, + 0xaf, 0x59, 0xdd, 0x44, 0x03, 0x6c, 0xac, +}; +/* len = 91 */ + +static const unsigned char dh_pkcs8_der[] = { + 0x30, 0x82, 0x02, 0x26, 0x02, 0x01, 0x00, 0x30, 0x82, 0x01, 0x17, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x03, 0x01, 0x30, 0x82, + 0x01, 0x08, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8f, 0x39, 0x3d, 0x03, 0xd6, + 0x40, 0xb1, 0x31, 0x37, 0xa5, 0x8e, 0x85, 0x5f, 0x1c, 0xe9, 0x22, 0x4b, + 0x0c, 0x28, 0xaa, 0x84, 0x84, 0xdf, 0x46, 0xd3, 0x03, 0x62, 0x8a, 0x65, + 0x53, 0xd1, 0xeb, 0x76, 0x39, 0xb0, 0x09, 0x92, 0x5a, 0x7a, 0x34, 0xa8, + 0xc2, 0x73, 0xf9, 0x7d, 0xa4, 0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, 0x1f, 0x6b, 0xc2, 0xbb, 0xa1, + 0x85, 0x2e, 0x42, 0x6f, 0xf6, 0x35, 0x0a, 0x6c, 0x6c, 0x81, 0x80, 0xb8, + 0xfe, 0x7f, 0xf7, 0xcd, 0x93, 0xce, 0xc5, 0x88, 0x00, 0x19, 0x69, 0xf6, + 0xc9, 0x56, 0x91, 0x12, 0xe4, 0x47, 0x3e, 0x9d, 0x7c, 0x20, 0x62, 0xba, + 0xf0, 0x49, 0xa6, 0x0f, 0x37, 0x8a, 0x77, 0xe0, 0x73, 0x4c, 0xbd, 0x4e, + 0x26, 0xc5, 0x48, 0x02, 0x73, 0x88, 0x6e, 0x94, 0xa6, 0xd2, 0x6b, 0x20, + 0x61, 0x21, 0x6b, 0x34, 0x3d, 0x10, 0xa2, 0xb0, 0x5a, 0x43, 0xb6, 0x12, + 0xda, 0x8d, 0x2b, 0xd8, 0xd6, 0xff, 0xbd, 0x85, 0xff, 0x0d, 0xf7, 0xc5, + 0xe7, 0xdb, 0x7b, 0x41, 0xa3, 0xd3, 0x98, 0x52, 0xb4, 0x53, 0x98, 0xc0, + 0x4b, 0xd0, 0x32, 0x90, 0xe6, 0x8c, 0x6e, 0xf4, 0x48, 0xcf, 0x2d, 0xf6, + 0x9e, 0x0b, +}; +/* len = 554 */ + +static const unsigned char rsa_pkcs1_priv_der[] = { + 0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, + 0xb6, 0xdb, 0x1b, 0xeb, 0x69, 0xcd, 0x5b, 0x80, 0xd5, 0xbc, 0x1a, 0xfd, + 0xa7, 0xf4, 0xb5, 0xc2, 0x89, 0xc9, 0x22, 0x26, 0xeb, 0x9a, 0x8b, 0x58, + 0x90, 0xbf, 0x79, 0xef, 0xd6, 0xf7, 0x2b, 0xc6, 0x1e, 0xec, 0x78, 0x64, + 0x5f, 0xf7, 0x6f, 0x36, 0x70, 0xb0, 0x74, 0xe7, 0x7b, 0x09, 0x5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0xee, 0x8c, 0x89, 0xab, 0x7e, 0xe3, 0x37, 0xda, 0x4f, + 0xa5, 0xa0, 0x5f, 0x35, 0xcf, 0xfc, 0xb4, 0x5b, 0x83, 0x62, 0x68, 0x4a, + 0xe2, 0x8f, 0x0b, 0x04, 0x15, 0xe2, 0x76, 0xaa, 0x5b, 0xb8, 0x86, 0x1b, + 0x61, 0x2f, 0x9c, 0x57, 0xb8, 0xa2, 0xbc, 0x74, 0xce, 0x95, 0x52, 0xbc, + 0x17, 0xef, 0x47, 0xc4, 0xff, 0x48, 0xc3, 0x64, 0xee, 0xc1, 0x62, 0x31, + 0x87, 0xa5, 0x08, 0x5e, 0x44, 0xda, 0xd9, 0xb1, 0x8a, 0xd6, 0x16, 0x32, + 0xd0, 0x95, 0xa0, 0xec, 0x77, 0xdc, 0xf1, 0x0f, 0x3d, 0x33, 0xd6, 0x54, + 0xad, 0x40, 0xf7, 0x9c, 0xad, 0xda, 0x0a, 0x20, 0x3a, 0x17, 0x16, 0x11, + 0x80, 0xbd, 0x41, 0x0a, 0xce, 0xa2, 0x14, 0x4f, 0x90, 0x82, 0xd5, 0x06, + 0xe5, 0xca, 0x89, 0x67, 0x1b, 0x02, 0x81, 0x81, 0x00, 0xef, 0x6b, 0x4e, + 0x3b, 0x8a, 0x46, 0x54, 0xb6, 0xb2, 0x4f, 0x2d, 0x38, 0xa2, 0x77, 0x95, + 0x23, 0xbe, 0xe1, 0x6a, 0xc6, 0x88, 0x7f, 0x73, 0xc6, 0x9f, 0x5c, 0xa9, + 0x22, 0x9c, 0x24, 0x6e, 0x23, 0x63, 0xd9, 0xa5, 0x75, 0xc3, 0xc1, 0x7d, + 0x8e, 0x94, 0x69, 0x53, 0x9c, 0xda, 0x1c, 0x1e, 0x23, 0x58, 0x0e, 0x66, + 0x8a, 0x05, 0x7c, 0xa1, 0x65, 0x09, 0x9f, 0x84, 0xd9, 0x41, 0xc7, 0x5d, + 0x68, 0xe3, 0xc1, 0xca, 0xb1, 0x49, 0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0xed, + 0x4a, 0x8d, 0x53, 0x52, 0x77, 0xe1, 0x45, 0x22, 0x02, 0x62, 0x2d, 0x03, + 0x35, 0x43, 0xcb, 0x23, 0x79, 0x12, 0x43, 0xa3, 0x6a, 0xf6, 0x82, 0xd7, + 0x69, 0x24, 0x42, 0xa3, 0xd6, 0x22, 0xfc, 0x18, 0xdb, 0x05, 0x5e, 0xcb, + 0xce, 0xb7, 0xa5, +}; +/* len = 1191 */ + +static const unsigned char ec_sec1_priv_der[] = { + 0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0xe4, 0x0b, 0x46, 0x3e, 0x87, + 0x92, 0x8b, 0x24, 0xa7, 0x53, 0xb9, 0xdf, 0x4a, 0x12, 0x26, 0x5b, 0x45, + 0xa1, 0xdf, 0x90, 0xe4, 0xc5, 0x80, 0x36, 0xa5, 0x3e, 0x20, 0x48, 0x43, + 0xf6, 0xd2, 0x0e, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x82, 0x9d, 0xbd, + 0x0c, 0x5f, 0x9e, 0xc0, 0xb2, 0x5e, 0xdb, 0x09, 0x62, 0x14, 0xa1, 0xd6, + 0x4e, 0xff, 0x5c, 0x1c, 0xd4, 0xa7, 0x1d, 0xe3, 0x1d, 0xea, 0x75, 0x76, + 0x65, 0x4f, 0xf6, 0x05, 0x49, 0x84, 0x19, 0xe2, 0xc6, 0xbd, 0x90, 0xc4, + 0x14, 0xab, 0xfd, 0xd1, 0xa0, 0xd3, 0x79, 0x0b, 0x63, 0x85, 0x06, 0x7e, + 0x82, 0xb0, 0xc4, 0xa5, 0xdd, 0x08, 0xaf, 0x59, 0xdd, 0x44, 0x03, 0x6c, + 0xac, +}; +/* len = 121 */ + +static const unsigned char dhparams_der[] = { + 0x30, 0x82, 0x01, 0x0c, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8f, 0x39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x50, + 0xca, 0xc8, 0x16, 0xcd, 0xdf, 0x39, 0x61, 0xc4, 0x74, 0x2f, 0xc3, 0xf6, + 0x3e, 0xa6, 0xa3, 0x0c, 0x90, 0x41, 0x7d, 0xad, 0xfd, 0x38, 0xba, 0x8a, + 0xfe, 0x86, 0x4a, 0x93, 0xb0, 0xe6, 0x8f, 0xb0, 0xc0, 0x68, 0x78, 0xa4, + 0x16, 0x08, 0x90, 0x24, 0x20, 0x9b, 0x3b, 0xf9, 0xc0, 0xdb, 0x45, 0xe8, + 0x18, 0x93, 0x3e, 0x96, 0x8a, 0xc3, 0x71, 0x51, 0xf6, 0xa3, 0x31, 0x4f, + 0x4f, 0xe5, 0x3c, 0x83, 0xdd, 0x74, 0x7b, 0xf8, 0x3a, 0x1c, 0x0d, 0x8f, + 0xbf, 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0xe1, +}; +/* len = 272 */ +#endif /* HAVE_FIPS */ + + +/* ----------------------------------------------------------------------- */ + +static OSSL_LIB_CTX* wpLibCtx = NULL; +static OSSL_PROVIDER* wpProv = NULL; + +#ifdef HAVE_FIPS + +static const char* cast_state_str(int s) +{ + switch (s) { + case FIPS_CAST_STATE_INIT: return "INIT"; + case FIPS_CAST_STATE_PROCESSING: return "PROCESSING"; + case FIPS_CAST_STATE_SUCCESS: return "SUCCESS"; + case FIPS_CAST_STATE_FAILURE: return "FAILURE"; + default: return "?"; + } +} + +static int dh_z_cold(void) +{ + return wc_GetCastStatus_fips(FIPS_CAST_DH_PRIMITIVE_Z) + != FIPS_CAST_STATE_SUCCESS; +} +static int ecc_z_cold(void) +{ + return wc_GetCastStatus_fips(FIPS_CAST_ECC_PRIMITIVE_Z) + != FIPS_CAST_STATE_SUCCESS; +} + +/* Load a PKCS#8 key via wolfProvider (routes through wp_*_decode). Caller frees. */ +static EVP_PKEY* load_priv_pkcs8(const unsigned char* der, size_t len) +{ + EVP_PKEY* pkey = NULL; + PKCS8_PRIV_KEY_INFO* p8; + const unsigned char* p = der; + + p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, (long)len); + if (p8 == NULL) { + return NULL; + } + pkey = EVP_PKCS82PKEY_ex(p8, wpLibCtx, NULL); + PKCS8_PRIV_KEY_INFO_free(p8); + return pkey; +} + +/* Load an SPKI public key via wolfProvider. Caller frees. */ +static EVP_PKEY* load_pub_spki(const unsigned char* der, size_t len) +{ + const unsigned char* p = der; + + return d2i_PUBKEY_ex(NULL, &p, (long)len, wpLibCtx, NULL); +} + +/* + * TEST 1 + 2 (cold CASTs): an RSA load must fire only the RSA CAST, never the + * DH/ECC primitive-Z CASTs; the SubjectPublicKeyInfo load also guards the + * d2i_X509_PUBKEY recursion that used to SIGSEGV. + */ +static int test_rsa_load_no_foreign_cast(void) +{ + int err = 0; + EVP_PKEY* priv = NULL; + EVP_PKEY* pub = NULL; + + TEST_INFO("Test 1/2: RSA load must not fire DH/ECC primitive-Z CAST"); + + if (!dh_z_cold() || !ecc_z_cold()) { + TEST_ERROR(" Precondition failed: DH/ECC primitive-Z CAST not cold " + "(DH=%s ECC=%s) - process isolation broken", + cast_state_str(wc_GetCastStatus_fips(FIPS_CAST_DH_PRIMITIVE_Z)), + cast_state_str(wc_GetCastStatus_fips(FIPS_CAST_ECC_PRIMITIVE_Z))); + return TEST_FAILURE; + } + TEST_INFO(" Start: DH primitive-Z=%s, ECC primitive-Z=%s (cold)", + cast_state_str(wc_GetCastStatus_fips(FIPS_CAST_DH_PRIMITIVE_Z)), + cast_state_str(wc_GetCastStatus_fips(FIPS_CAST_ECC_PRIMITIVE_Z))); + + priv = load_priv_pkcs8(rsa_pkcs8_der, sizeof(rsa_pkcs8_der)); + if (priv == NULL) { + TEST_ERROR(" Failed to load RSA PKCS#8 private key"); + err = TEST_FAILURE; + } + + if (err == 0) { + pub = load_pub_spki(rsa_spki_der, sizeof(rsa_spki_der)); + if (pub == NULL) { + TEST_ERROR(" Failed to load RSA SubjectPublicKeyInfo public key"); + err = TEST_FAILURE; + } + } + + if (err == 0) { + TEST_INFO(" After RSA loads: RSA-sign CAST=%s, DH primitive-Z=%s, " + "ECC primitive-Z=%s", + cast_state_str( + wc_GetCastStatus_fips(FIPS_CAST_RSA_SIGN_PKCS1v15)), + cast_state_str(wc_GetCastStatus_fips(FIPS_CAST_DH_PRIMITIVE_Z)), + cast_state_str(wc_GetCastStatus_fips(FIPS_CAST_ECC_PRIMITIVE_Z))); + + if (wc_GetCastStatus_fips(FIPS_CAST_RSA_SIGN_PKCS1v15) + != FIPS_CAST_STATE_SUCCESS) { + TEST_ERROR(" RSA-sign CAST did not fire on RSA load (sanity)"); + err = TEST_FAILURE; + } + } + + if (err == 0 && !dh_z_cold()) { + TEST_ERROR(" REGRESSION: DH primitive-Z CAST fired while loading an " + "RSA key"); + err = TEST_FAILURE; + } + if (err == 0 && !ecc_z_cold()) { + TEST_ERROR(" REGRESSION: ECC primitive-Z CAST fired while loading an " + "RSA key"); + err = TEST_FAILURE; + } + + EVP_PKEY_free(priv); + EVP_PKEY_free(pub); + + if (err == 0) { + TEST_INFO(" PASSED"); + } + return err; +} + +/* + * TEST 3: owned keys in the formats the shared unit tests miss (X9.42 DHX + * PKCS#8, RSA-PSS SPKI) must still decode -- the precheck must not reject them. + */ +static int test_owned_keys_load(void) +{ + int err = 0; + EVP_PKEY* dhx = NULL; + EVP_PKEY* pss = NULL; + + TEST_INFO("Test 3: owned keys in gap formats still load (DHX, RSA-PSS SPKI)"); + + dhx = load_priv_pkcs8(dhx_pkcs8_der, sizeof(dhx_pkcs8_der)); + if (dhx == NULL) { + TEST_ERROR(" Failed to load X9.42 DHX PKCS#8 private key"); + err = TEST_FAILURE; + } + + if (err == 0) { + pss = load_pub_spki(rsapss_spki_der, sizeof(rsapss_spki_der)); + if (pss == NULL) { + TEST_ERROR(" Failed to load RSA-PSS SubjectPublicKeyInfo key"); + err = TEST_FAILURE; + } + } + + EVP_PKEY_free(dhx); + EVP_PKEY_free(pss); + + if (err == 0) { + TEST_INFO(" PASSED"); + } + return err; +} + +/* + * TEST 4: white-box wp_decode_should_skip. Skip (1) only for a fully well-formed + * wrapper with a recognized foreign OID; everything else proceeds (0). + */ +static int test_should_skip_logic(void) +{ + int err = 0; + static const int dhNids[] = { NID_dhKeyAgreement, NID_dhpublicnumber }; + static const int rsaNids[] = { NID_rsaEncryption, NID_rsassaPss }; + const size_t nDh = sizeof(dhNids) / sizeof(dhNids[0]); + const size_t nRsa = sizeof(rsaNids) / sizeof(rsaNids[0]); + + struct { + const char* desc; + int cast; + const unsigned char* der; + size_t len; + int format; + const int* nids; + size_t nNids; + int expect; /* 1 = skip, 0 = proceed */ + } cases[] = { + /* Cases gate on a still-cold CAST (DH/ECC primitive-Z); the RSA-sign + * CAST is warm after Test 1/2 and would short-circuit the gate. */ + { "owned RSA SPKI vs RSA-set", FIPS_CAST_ECC_PRIMITIVE_Z, + rsa_spki_der, sizeof(rsa_spki_der), WP_ENC_FORMAT_SPKI, + rsaNids, nRsa, 0 }, + { "foreign RSA SPKI vs DH-set", FIPS_CAST_DH_PRIMITIVE_Z, + rsa_spki_der, sizeof(rsa_spki_der), WP_ENC_FORMAT_SPKI, + dhNids, nDh, 1 }, + { "foreign EC SPKI vs DH-set", FIPS_CAST_DH_PRIMITIVE_Z, + ec_spki_der, sizeof(ec_spki_der), WP_ENC_FORMAT_SPKI, + dhNids, nDh, 1 }, + { "foreign DH PKCS#8 vs RSA-set", FIPS_CAST_ECC_PRIMITIVE_Z, + dh_pkcs8_der, sizeof(dh_pkcs8_der), WP_ENC_FORMAT_PKI, + rsaNids, nRsa, 1 }, + { "raw PKCS#1 as PKI", FIPS_CAST_ECC_PRIMITIVE_Z, + rsa_pkcs1_priv_der, sizeof(rsa_pkcs1_priv_der), WP_ENC_FORMAT_PKI, + dhNids, nDh, 0 }, + { "raw SEC1 as SPKI", FIPS_CAST_DH_PRIMITIVE_Z, + ec_sec1_priv_der, sizeof(ec_sec1_priv_der), WP_ENC_FORMAT_SPKI, + dhNids, nDh, 0 }, + { "bare DHParameter as SPKI", FIPS_CAST_ECC_PRIMITIVE_Z, + dhparams_der, sizeof(dhparams_der), WP_ENC_FORMAT_SPKI, + rsaNids, nRsa, 0 }, + { "truncated RSA SPKI", FIPS_CAST_DH_PRIMITIVE_Z, + rsa_spki_der, sizeof(rsa_spki_der) - 1, WP_ENC_FORMAT_SPKI, + dhNids, nDh, 0 }, + { "foreign RSA SPKI as TYPE_SPECIFIC", FIPS_CAST_DH_PRIMITIVE_Z, + rsa_spki_der, sizeof(rsa_spki_der), WP_ENC_FORMAT_TYPE_SPECIFIC, + dhNids, nDh, 0 }, + }; + size_t i; + size_t n = sizeof(cases) / sizeof(cases[0]); + + TEST_INFO("Test 4: wp_decode_should_skip decision logic (white-box)"); + + if (!dh_z_cold() || !ecc_z_cold()) { + TEST_ERROR(" Precondition failed: DH/ECC primitive-Z CAST not cold; " + "gate inactive, white-box skip cases invalid"); + return TEST_FAILURE; + } + + /* Clear residual errors (provider load / earlier tests) so the post-loop + * ERR_peek_error() reflects only the probes. */ + ERR_clear_error(); + + for (i = 0; i < n; i++) { + int got = wp_decode_should_skip(cases[i].cast, cases[i].der, + (word32)cases[i].len, cases[i].format, cases[i].nids, + cases[i].nNids); + if (got != cases[i].expect) { + TEST_ERROR(" [%s] expected %d, got %d", cases[i].desc, + cases[i].expect, got); + err = TEST_FAILURE; + } + else { + TEST_DEBUG(" [%s] -> %d OK", cases[i].desc, got); + } + } + + /* The probes must not have leaked errors onto the thread queue. */ + if (err == 0 && ERR_peek_error() != 0) { + TEST_ERROR(" Speculative probes leaked errors onto the error queue"); + err = TEST_FAILURE; + } + + if (err == 0) { + TEST_INFO(" PASSED (%zu cases)", n); + } + return err; +} + +#endif /* HAVE_FIPS */ + +static int load_provider(void) +{ + wpLibCtx = OSSL_LIB_CTX_new(); + if (wpLibCtx == NULL) { + TEST_ERROR("Failed to create library context"); + return TEST_FAILURE; + } + /* Match unit.test: find libwolfprov in .libs. */ + OSSL_PROVIDER_set_default_search_path(wpLibCtx, ".libs"); + wpProv = OSSL_PROVIDER_load(wpLibCtx, "libwolfprov"); + if (wpProv == NULL) { + TEST_ERROR("Failed to load wolfProvider"); + OSSL_LIB_CTX_free(wpLibCtx); + wpLibCtx = NULL; + return TEST_FAILURE; + } + return TEST_SUCCESS; +} + +static void unload_provider(void) +{ + if (wpProv != NULL) { + OSSL_PROVIDER_unload(wpProv); + wpProv = NULL; + } + if (wpLibCtx != NULL) { + OSSL_LIB_CTX_free(wpLibCtx); + wpLibCtx = NULL; + } +} + +int main(void) +{ + TEST_INFO("========================================"); + TEST_INFO("Decoder OID-precheck regression test"); + TEST_INFO("========================================"); + + if (load_provider() != TEST_SUCCESS) { + return TEST_FAILURE; + } + +#ifndef HAVE_FIPS + TEST_INFO("SKIPPED - not a FIPS build (precheck compiled out)"); + unload_provider(); + return TEST_SUCCESS; +#else + { + int rc = TEST_SUCCESS; + /* Order matters: Test 3 warms the DH CAST (owned DHX load), so it must run + * after Tests 1/2 and 4, which need the DH/ECC primitive-Z CASTs cold. */ + if (test_rsa_load_no_foreign_cast() != TEST_SUCCESS) { + rc = TEST_FAILURE; + } + if (rc == TEST_SUCCESS && test_should_skip_logic() != TEST_SUCCESS) { + rc = TEST_FAILURE; + } + if (rc == TEST_SUCCESS && test_owned_keys_load() != TEST_SUCCESS) { + rc = TEST_FAILURE; + } + + TEST_INFO("========================================"); + if (rc == TEST_SUCCESS) { + TEST_INFO("All decoder OID-precheck tests PASSED"); + } + else { + TEST_ERROR("Decoder OID-precheck tests FAILED"); + } + TEST_INFO("========================================"); + + unload_provider(); + return rc; + } +#endif /* HAVE_FIPS */ +}