Repository navigation
Description
Summary
CA65FLAGS += -D ENABLE_P384_VERIFY=1 sat inside ifeq ($(USE_NISTCURVES_ONCHIP),1),
so the two REU-profile builds — plain make and make BACKEND=uci — dropped the -D
silently. The flag did nothing at all on those two configurations.
Proof that the -D never reached ca65 (PRG sha256; the PRG is the check, per CLAUDE.md):
make BACKEND=ip65 d780f719fac82e07bba9d30db804e853…
make BACKEND=ip65 ENABLE_P384_VERIFY=1 d780f719fac82e07bba9d30db804e853… identical
make BACKEND=uci 7c79a4e00a19685de7540970247c759a…
make BACKEND=uci ENABLE_P384_VERIFY=1 7c79a4e00a19685de7540970247c759a… identical
Why it matters
ENABLE_P384_VERIFY exists for exactly one reason: so the P-384 safety gate can be
mutation-tested. CLAUDE.md's "Smoke tests" section documents
tools/test_p384_overlay_hazard.py as failing under ENABLE_P384_VERIFY=1 by design —
"a safety gate nobody can switch off is a gate nobody can prove is load-bearing."
On the REU profiles that control passed. Measured, master, BACKEND=uci ENABLE_P384_VERIFY=1, PRG 7c79a4e00a19685d…, VICE, C64_SKIP_BUILD=1:
returned : C=1
bytes changed in the live overlay slot: 0 / 7680
[PASS] resident code left intact
[PASS] clean reject (C=1) on an unsupported curve
PASS: a P-384 certificate is handled safely exit 0
It reported green while exercising the unmutated build. Anyone who ran the control on
BACKEND=uci and saw green concluded the gate was proven, having proven nothing.
After hoisting the block to top level, the same command on the same profile
(PRG 8b67ee949f8507b8…):
returned : DID NOT RETURN (hung)
bytes changed in the live overlay slot: 5548 / 7680
[FAIL] resident code left intact
[FAIL] clean reject (C=1) on an unsupported curve exit 1
Scope
- The gate itself was never weakened.
ecdsa_verify's P-384 arm was asecreject in
every shipped image throughout, and remains one. - No shipped image was affected. All three products set
USE_NISTCURVES_ONCHIP, where
the nesting happened to be harmless; the three onchip profiles' armed PRGs are unchanged
by the fix (b9f03169…,3c271262…,cc555c19…). - What was broken was the control, on two of five configurations.
The class of defect — this is the part worth keeping
This was a flag that silently did nothing, and build/flags.stamp structurally cannot
catch that. The stamp faithfully records the flags that were computed; the computed set
was the wrong one. It guards against stale objects surviving a flag change — not against a
knob that never reaches the compiler. Every existing guard in
tools/test_build_flags_stamp.py was green throughout.
Suggested guard (not built, maintainer's call): assert that every documented knob
changes either the PRG sha256 or build/flags.stamp on each profile it claims to support.
That is a natural companion to test_build_flags_stamp.py, needs no VICE, and would have
caught this the day the nesting was introduced. It would also cover the next knob that
grows a conditional around it.
Fix
Two commits, cherry-picked with -x onto chore/crypto-lib-bump. The first hoists the
block to top level; all five unarmed PRGs are unchanged by it (verified by comparing
fully-expanded CA65FLAGS / LD65FLAGS / ALL_OBJS / archive sets across all five
variants).
Two notes for whoever triages
-
Evidence strength. The finding rests on the two REU rows above (
7c79a4e0…0/7680
exit 0, and8b67ee94…5548/7680 exit 1), both measured here. A supporting row on
USE_NISTCURVES_ONCHIP=1 ENABLE_P384_VERIFY=1was measured once here at PRG
3c2712629063de69…→ 5575/7680; a second lane reports 5653/7680 at PRGc16423ba…,
reportedly on the integrated branch rather thanchore/gate-p384-objectspre-cherry-pick.
Those are different artifact hashes, therefore different builds — so this is not a
discrepancy at all, and neither figure reproduces or contradicts the other. (Two figures
differing on the same PRG hash would be a discrepancy and would need chasing; two
figures on different PRG hashes are simply two different measurements.) Both are single
measurements. The finding does not depend on that row. -
Adjacent, not part of this issue. The two profiles this bug silently disarmed are the
same two thelibs/nistcurvesv0.14.0 exposure analysis concerns: another lane reports
they readLIB_NISTCURVES_REU_BANKS_USED = $0003, i.e. they do library REU DMA and are
exposed to the SPEC §8.2 settle fix. They ship in nothing today, but CLAUDE.md records
restoring them as "one line inPACKAGE_VARIANTS". I have not verified that figure —
it belongs in the bump PR, and is recorded here only because the profile overlap makes it
easy to lose.
Activity
docs(readme): v0.14.0 pin, the P-384 link gate, and the unverified body
JC-000 commentedon Sep 8, 2026
Fixed by
4265ae1(#216) — the Makefile block is now at top level, outside anyUSE_NISTCURVES_ONCHIPconditional.This issue's own discriminator inverts on the REU profile, which is the proof:
make BACKEND=uci→ PRG sha2569eaee61d…,make BACKEND=uci ENABLE_P384_VERIFY=1→7e55fbc7…. Previously identical, which is what made the mutation control pass vacuously. OnBACKEND=ip65the flag now reaches ca65 hard enough to change the link outcome outright (HTTP_AUX_CODE2overflowsCRYPTO_OVERLAYby 174 B) — the strongest available evidence it is no longer being dropped.Not built: the knob-effectiveness guard suggested here.
tools/test_build_flags_stamp.pyhas nine tests and none of them asserts that a flag reaches the compiler. Filing that separately if it is still wanted — the defect is fixed, but nothing stops it recurring.