mldsa: remove tautological ret operand in wc_MlDsaKey_CheckKey

Premise:  wc_mldsa.c:11544 `if (ret == 0) {` opens the block containing the
          claimed condition.
Claim:    wc_mldsa.c:11589 `if ((ret == 0) && (x != 0))` -- the `ret == 0`
          operand.
Proof:    :11544 dominates :11589 and nothing in between assigns ret: the block
          decodes, NTTs, matrix-multiplies and XOR-accumulates into x through
          mldsa_vec_decode_*, mldsa_vec_ntt_small_full, mldsa_matrix_mul,
          mldsa_vec_red, mldsa_vec_invntt_full, mldsa_vec_add/sub/make_pos --
          all void-returning. A grep of the span for `ret` finds only the two
          conditions themselves. The operand is invariantly true and its
          independence pair is unreachable.
Scope:    the only preprocessor construct in the span is WOLFSSL_MLDSA_SMALL at
          :11566, which adds another void call.
Evidence: llvm-cov MC/DC records this condition as never false
          (reports/mldsa/GAPS.md row 11479:13:11479:35:0, pre-drift numbering).

The nearby `ret == 0` guards at :11485 and :11488 stay: prvKeySet / pubKeySet
are user-controlled and those decisions are live.

Compiler cross-check: gcc -O2 emits byte-identical code for this file before
and after this commit -- the optimiser had already folded the removed
condition, independently confirming it was dead.
This commit is contained in:
Daniele Lacamera
2026-07-31 15:26:24 +02:00
parent d1ced3d134
commit 964cc72c38
+1 -1
View File
@@ -11586,7 +11586,7 @@ int wc_MlDsaKey_CheckKey(wc_MlDsaKey* key)
x |= key->p[i] ^ key->k[i];
}
if ((ret == 0) && (x != 0)) {
if (x != 0) {
ret = PUBLIC_KEY_E;
}
}