@@ -54028,6 +54028,16 @@ static wc_test_ret_t ecc_test_sign_vectors(WC_RNG* rng)
5402854028#endif
5402954029
5403054030 ret = wc_ecc_sign_set_k(k, sizeof(k), key);
54031+ #if FIPS_VERSION3_GE(7,0,0) && defined(WC_HAVE_FIPS_INDICATOR) && \
54032+ !defined(FIPS_NO_WRAPPERS)
54033+ /* FIPS 186-5 Section 6.3: a caller-supplied per-message secret is a
54034+ * non-approved use, so the module must deliver the WC_FIPS_NOT_APPROVED
54035+ * indicator to the caller (FIPS 140-3 IG 2.4.C); the test fails if the
54036+ * indicator is missing. */
54037+ if (ret != WC_FIPS_NOT_APPROVED)
54038+ ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
54039+ ret = 0;
54040+ #endif
5403154041 if (ret != 0)
5403254042 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
5403354043
@@ -54039,6 +54049,17 @@ static wc_test_ret_t ecc_test_sign_vectors(WC_RNG* rng)
5403954049 if (ret == 0)
5404054050 ret = wc_ecc_sign_hash(hash, sizeof(hash), sig, &sigSz, rng, key);
5404154051 } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
54052+ #if FIPS_VERSION3_GE(7,0,0) && defined(WC_HAVE_FIPS_INDICATOR) && \
54053+ !defined(FIPS_NO_WRAPPERS)
54054+ /* The signature consuming the staged k must deliver the
54055+ * WC_FIPS_NOT_APPROVED indicator to the caller (FIPS 186-5
54056+ * Section 6.3, FIPS 140-3 IG 2.4.C); the test fails if the indicator
54057+ * is missing, and the signature bytes are still verified against the
54058+ * expected vector below. */
54059+ if (ret != WC_FIPS_NOT_APPROVED)
54060+ ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
54061+ ret = 0;
54062+ #endif
5404254063 if (ret != 0)
5404354064 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
5404454065 TEST_SLEEP();
@@ -54060,6 +54081,9 @@ static wc_test_ret_t ecc_test_sign_vectors(WC_RNG* rng)
5406054081 if (ret == 0)
5406154082 ret = wc_ecc_sign_hash(hash, sizeof(hash), sig, &sigSz, rng, key);
5406254083 } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
54084+ /* The staged k was consumed by the first signature, so this second
54085+ * signature uses a fresh random k and must succeed without the
54086+ * WC_FIPS_NOT_APPROVED indicator. */
5406354087 if (ret != 0)
5406454088 ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
5406554089 TEST_SLEEP();
0 commit comments