Skip to content

chore(deps): bump libs/nistcurves v0.11.2 → v0.14.0, gate the P-384 objects, and place the growth - #216

Merged
JC-000 merged 14 commits into
masterfrom
chore/crypto-lib-bump
Sep 7, 2026
Merged

JC-000 merged 14 commits into
masterfrom
chore/crypto-lib-bump

Conversation

@JC-000

@JC-000 JC-000 commented Sep 7, 2026

Copy link
Copy Markdown
Owner

What this is

The libs/nistcurves v0.11.2 -> v0.14.0 bump, plus the two changes that let
ip65 link at that pin: gating the unreachable P-384 objects out of the link,
and converging HTTP_AUX_CODE2 onto CRYPTO_OVERLAY on ip65 so all three
cfgs agree.

The commits:

commit what
ec4e478 bump v0.11.2 -> v0.14.0, route LIB_NISTCURVES_P256_RODATA to CRYPTO_OVERLAY under UCI
91242d7 rescope the bare-export guard, which went vacuous at v0.14.0
b313b5f re-anchor CLAUDE.md at the v0.14.0 pin
76826a1 let the KAT oracle be pointed at a shipped profile
377d969 hoist ENABLE_P384_VERIFY out of the USE_NISTCURVES_ONCHIP block (cherry-picked, -x)
f9ad178 link the P-384 objects only under ENABLE_P384_VERIFY (cherry-picked, -x)
d7e8592 move HTTP_AUX_CODE2 to CRYPTO_OVERLAY on ip65 — required for ip65 to link, and convergent with both uci cfgs
e4fda6d CLAUDE.md: record the link gate and the new margins
807d5a6 CLAUDE.md: three UCI margins were stale by exactly 33 B
948542b CLAUDE.md: four more margin figures, two self-contradictory
6ef5e7d CLAUDE.md: the REU-restore line is a security decision; per-profile hazard

Why ip65 could not be made to link by moving segments — the conservation proof

CRYPTO_OVERLAY ($4F8C-$5FFF, 4,212 B) and CRYPTO_RESIDENT ($6000-$9FFF,
16,384 B) are adjacent. They are therefore one pool of 20,596 B, and
nothing that only moves segments between them creates space.

At the v0.14.0 pin, before gating, that pool had to hold 20,631 B of
content. It is 35 B short, however the segments are arranged. The 57-byte
LIB_NISTCURVES_MUL_CODE overflow ld65 reported is one arrangement's symptom,
not the size of the problem, and chasing it by shuffling segments could only
ever relocate the overflow.

The cross-check that proves it. Pre-gating, CRYPTO_OVERLAY had 22 B
free
while CRYPTO_RESIDENT overflowed by 57 B. 57 - 22 = 35 — the pool
deficit, exactly. That single subtraction is why the 57 B ld65 reports is a
symptom rather than the problem, and why no cfg-only fix could exist: the 22 B
on the near side of the boundary was the most any reshuffle could ever donate,
and it was 35 B short.

(The 22 B is pin-invariant, which is worth knowing when reading it: ip65's
CRYPTO_OVERLAY holds only our own code — TLS_CODE 1,852 + CRYPTO_AUX_CODE
1,571 + HTTP_AUX_CODE 468 + HTTP_AUX_CODE2 169 = 4,060 of 4,212 post-gating.
Every library segment routed there is 0 B in the shipped map. The two segments
v0.14.0 actually grew, LIB_NISTCURVES_P256_CODE and LIB_NISTCURVES_MUL_CODE,
both land in CRYPTO_RESIDENT.)

So the fix had to remove content. ecdsa_verify_384.o — in every shipped
image, reachable from none of them — was 332 B of it. Removing it leaves
20,299 B in a 20,596 B pool.

The HTTP_AUX_CODE2 move is load-bearing, not tidying. Gating alone does
not make ip65 link: with the P-384 objects gone and the segment still in
CRYPTO_RESIDENT, LIB_NISTCURVES_MUL_CODE still overflows that region — by
24 B, measured, not 57. The move is what closes the last 24 B, by putting
169 B on the side of the boundary that has room. Two separate claims, and only
the first is optional-sounding:

  • It is required. Without it, BACKEND=ip65 USE_NISTCURVES_ONCHIP=1 does
    not link at the v0.14.0 pin.
  • It is safe, and that is why it takes this form. cfg/c64-https-uci.cfg:252
    and cfg/c64-https-uci-onchip.cfg:297 have always routed the segment to
    CRYPTO_OVERLAY; ip65 was the odd one out, and its own comment said the split
    existed because "CRYPTO_OVERLAY cannot hold the whole W4 machinery on ip65" —
    which gating made untrue. So it retires a workaround whose precondition is
    gone rather than introducing a new trade-off.

The convergence is the reason the move is safe. It is not the reason it is
there.

The 332 B, measured on this tree

pre-gating (this branch, ec4e478) post-gating delta
NET_CODE free, all three UCI builds 67 B 366 B +299 B (CRYPTO_AUX_CODE)
CRYPTO_HOT free, uci-onchip 170 B 203 B +33 B (CRYPTO_RODATA)
CRYPTO_HOT free, plain uci 133 B 166 B +33 B

299 + 33 = 332. The pre-gating column is ec4e478's own measurements on this
branch, so the delta is ours end to end, not inherited.

What gating costs, exactly

Two symbols lose their only link-time consumer. Measured from the Imports list of build/c64-https.map, armed (make BACKEND=uci ENABLE_P384_VERIFY=1,
PRG a4974836…):

crypto_swap_to_p384_curve (crypto_swap.o):
    ecdsa_verify_384.o        src/crypto/ecdsa_verify_384.s(92)
crypto_swap_to_p384_sha384 (crypto_swap.o):
    ecdsa_verify_384.o        src/crypto/ecdsa_verify_384.s(91)

One importer each, the same object, and in all five unarmed builds neither
symbol appears in any Imports-list entry. Both remain exported unconditionally
by crypto_swap.s and still occupy bytes; nothing else changes.

Attribution: synthesising #206

#206 is right about the number and wrong about where it comes from.

  • Their 57 B ip65-onchip CRYPTO_RESIDENT overflow reproduces exactly on
    this tree. Confirmed.
  • Their attribution of it to NET_CODE 366 -> 408 does not. On our tree
    NET_CODE is an ip65 region with a different tenancy, and 366 B is the
    post-gating UCI figure, not an ip65 one.
  • Ours is LIB_NISTCURVES_MUL_CODE 123 -> 162 (+39, the nistcurves_reu_dma_wait
    from SPEC 8.2) plus LIB_NISTCURVES_P256_CODE 8304 -> 8362 (+58 onchip).
    Both read off build/c64-https.map at the v0.14.0 pin: MUL_CODE is
    $00A2 = 162 B and P256_CODE is $20AA = 8,362 B in the ip65-onchip map.

Same 57 B, different derivation. Cite ours.

Exposure — which shipped product is actually at risk

v0.14.0 carries two upstream fixes. Only one product is exposed to either.

product REU comb anchor-table collapse (v0.13.0, c64-nist-curves#148) SPEC 8.2 REU DMA settle (v0.12.0)
c64-https-ip65-onchip.prg no no not exposed not exposed
c64-https-uci-onchip.prg no no not exposed not exposed
c64-https-uci-comb.prg yes (bank 2) yes exposed exposed

The table's underpinning, measured rather than asserted.
LIB_NISTCURVES_REU_BANKS_USED across all five builds:

build banks shipped?
ip65-onchip $0000 yes
uci-onchip $0000 yes
uci-comb $0004 yes
plain-ip65 (REU) $0003 no
plain-uci (REU) $0003 no

This adds a consequence the exposure table did not previously carry: the two
REU profiles read $0003 — they do library REU DMA and are exposed to the
v0.12.0 settle fix.
They ship in nothing today, but CLAUDE.md records that
restoring them is "one line in PACKAGE_VARIANTS". That line is therefore a
security-relevant decision, not merely a curation one, and nothing said so.
6ef5e7d writes it into CLAUDE.md at the PACKAGE_VARIANTS note.

uci-comb is the only image on the Lim-Lee comb path
(LIB_NISTCURVES_REU_BANKS_USED = $0004, measured) and the only one doing
library REU DMA. Keep the scope exact: the v0.13.0 guard catches a collapsed
anchor table, not a corrupt one. An attacker who can write REU bank 2 plants
a valid point instead and no post-condition on the result would see it. This is
not a defence against that attacker.

Builds — all five link

profile PRG sha256 size
ip65-onchip 7905d63c8141816d1e5258c9d40850769667f7eb8753c503a2665ca941b8345c 47,105
uci-onchip 30dd30a5fde7df1b1e00738c1b441cdfbdb75016a17e1bf331b93ae68ef9960d 62,977
uci-comb f85e37123166188c7f4364b531ee1661aa9a22da6639025c360e896f47260993 62,977
plain-ip65 (REU) ca74bffb4e8a700d3322c8d566ba8b401794f5cf77094ba651750fb96fb5382f 47,105
plain-uci (REU) c2d74d70d376d65e97a9e3b9c23c243324b8d9e4ec244f969621321d8d7e1329 62,977

Trap for anyone re-deriving these tables: uci-onchip links against
cfg/c64-https-uci.cfg, NOT cfg/c64-https-uci-onchip.cfg.
Only
USE_NISTCURVES_ONCHIP_COMB retargets $(CFG); plain USE_NISTCURVES_ONCHIP
keeps the base cfg. Reading the region table against the wrong cfg attributes
RODATA and CRYPTO_RODATA to CRYPTO_OVERLAY when they are actually in
CRYPTO_HOT, and yields a negative free count — which is how it was caught
here. Confirm the cfg from the ld65 -C line in the build log, never from the
profile name. That is exactly what the CLAUDE.md rule exists for.

Per-region free bytes (tail free = region end minus the top of the last segment
ld65 placed there; CRYPTO_COLD_SHADOW is reported as its internal hole below
the $BA00-pinned TABLES_BSS, since its tail is always 0 by construction):

ip65-onchip (cfg/c64-https-ip65.cfg) — the build this PR unblocks

LOADER              $0801-$1FFF   6,143 B    21 free
NET_CODE            $2000-$3FFF   8,192 B    56 free
NET_BSS             $4000-$4F8B   3,980 B     — (blob BSS, EMPTY to ld65)
CRYPTO_OVERLAY      $4F8C-$5FFF   4,212 B   152 free
CRYPTO_RESIDENT     $6000-$9FFF  16,384 B   145 free
CRYPTO_COLD_SHADOW  $A000-$BFFF   8,192 B    43 hole below TABLES_BSS
SCRATCH_UNION       $A000-$A5FF   1,536 B   224 free
TCP_BUF             $C000-$CFFF   4,096 B     — (runtime ring)

Both predicted margins confirmed exactly: 152 B CRYPTO_OVERLAY, 145 B
CRYPTO_RESIDENT.

plain-ip65 (REU profile, same cfg)

LOADER                21 free      NET_CODE            56 free
CRYPTO_OVERLAY       152 free      CRYPTO_RESIDENT    231 free
CRYPTO_COLD_SHADOW    43 hole      SCRATCH_UNION      224 free

uci-onchip (cfg/c64-https-uci.cfg — note the base cfg, not -onchip)

LOADER              $0801-$1FFF   6,143 B   148 free
NET_CODE            $2000-$3B65   7,014 B   366 free
NET_BSS_TAIL        $3B66-$41FF   1,690 B    43 free
CRYPTO_OVERLAY      $4200-$5FFF   7,680 B 1,804 free
CRYPTO_HOT          $6000-$9FFF  16,384 B   203 free
CRYPTO_COLD_SHADOW  $A000-$BFFF   8,192 B 1,577 hole below TABLES_BSS
OVERLAY_FILE_PAD / OVERLAY_BLOB_CURVE_RAM   unused

plain-uci (REU profile, same cfg)

LOADER   148 free   NET_CODE   366 free   NET_BSS_TAIL  43 free
CRYPTO_OVERLAY 1,901 free      CRYPTO_HOT 166 free      cold-shadow hole 1,577

uci-comb (cfg/c64-https-uci-onchip.cfg)

LOADER              $0801-$1FFF   6,143 B   122 free
NET_CODE            $2000-$3B65   7,014 B   366 free
NET_BSS_TAIL        $3B66-$41FF   1,690 B    43 free
CRYPTO_OVERLAY      $4200-$5FFF   7,680 B   153 free
CRYPTO_HOT          $6000-$9FFF  16,384 B    93 free
CRYPTO_COLD_SHADOW  $A000-$BFFF   8,192 B 1,577 hole below TABLES_BSS

Tests — re-run on the integrated branch, every hash moved

Each result names the artifact it ran against.

suite invocation artifact result
test_ecdsa_kat_oracle.py C64_MAKE_ARGS="BACKEND=uci USE_NISTCURVES_ONCHIP_COMB=1" C64_INIT_TIMEOUT=900 f85e3712… 6/6 (3 valid accepted, 3 invalid rejected)
test_ecdsa_kat_oracle.py default (ip65 REU profile) ca74bffb… 6/6
test_x25519.py default ca74bffb… 73/73
test_p384_overlay_hazard.py BACKEND=uci USE_NISTCURVES_ONCHIP=1 ENABLE_P384_VERIFY=1 c16423ba… exit 1, by design — hung, 5653/7680 overlay bytes changed †
test_p384_overlay_hazard.py BACKEND=uci ENABLE_P384_VERIFY=1 a4974836… exit 1, by design — hung, 5625/7680 changed
test_p384_overlay_hazard.py BACKEND=uci (control) c2d74d70… exit 0 — C=1, 0/7680 changed
test_tls_p384_negotiation.py bare make (default ip65 REU) ca74bffb… 2/2
pytest -q after make BACKEND=uci c2d74d70… 131 passed (this branch's total — see "A note on test totals")
check_upstream_pins.py --worktree — — all three in sync

† This row was not independently reproduced. The adversarial review re-ran
the other two hazard rows (a4974836… and the c2d74d70… control) and confirmed
them exactly; it did not run this one. It rests on this lane's measurement alone
and should not be read as double-checked.

The comb PRG the KAT ran against, f85e3712…, is byte-identical to the
packaged c64-https-uci-comb.prg
: tools/package/_common.sh:27 builds that
product from exactly BACKEND=uci USE_NISTCURVES_ONCHIP_COMB=1. Coverage names
its artifact, and this is the artifact.

Red/green on 377d969

make BACKEND=uci ENABLE_P384_VERIFY=1 now produces a4974836… while
make BACKEND=uci produces c2d74d70…. Different bytes. Before the hoist
those two builds were byte-identical, which is how test_p384_overlay_hazard.py
passed on the two REU profiles while exercising an unflagged image — a mutation
control that was a no-op on 2 of 5 configurations. It is now red on all of them,
and green with the flag off. Arguably the more valuable result in this PR than
the 57 bytes it was opened for.

Pin state

ip65             25a9c5aa9480  2025-01-19-2-g25a9c5a  (in sync)
libs/nistcurves  c05ead664e46  v0.14.0                (in sync)
libs/x25519      3ea64210ce4c  v0.13.0                (in sync)

One figure that came out different from prediction

Reported as measured rather than adjusted to match.

Cold-shadow hole is 43 B on ip65, not 46 B. d640677's commit message
records the gap below TABLES_BSS going 44 -> 46 B. At the v0.14.0 pin on
this tree it is 43 B on both ip65 builds — measured on ip65-onchip and
plain-ip65 alike. The pin moved under that figure.

The wrong number is left standing in the commit message on purpose, and it
is not the only stale figure in there. Both cherry-picked commits
(377d969, f9ad178) retain their original pre-bump measurements verbatim —
f9ad178's message alone carries five PRG hashes and ten free-byte figures
taken on a v0.11.2 tree, none of which reproduces here; ip65-onchip at that
commit does not even link. Cherry-pick policy is to preserve a message as
written, and correcting any of it would rewrite the commits and move the branch
tip past e4fda6d…, which two hardware/e2e lanes are already pointed at. The
tables in this PR supersede every measurement in both cherry-picked messages.

Cite them, not the commit bodies.

Two disclosures about the commits themselves

d7e8592's commit message says the ip65 overflow is 57 B. It is 24 B at that
point, and the message is wrong.
57 B is the overflow before the P-384
gating; by the time d7e8592 applies, gating has already returned 33 B to
CRYPTO_RESIDENT and the remaining deficit is 24. Measured directly — reverting
just the cfg line on the current tree and linking gives:

ld65: Warning: Segment 'LIB_NISTCURVES_MUL_CODE' overflows memory area
      'CRYPTO_RESIDENT' by 24 bytes

Not corrected in place, for the same reason as d640677's 46 B: d7e8592 is
the last artifact-touching commit, and rewriting it would change the SHA two
in-flight e2e runs were dispatched against. Cite 24 B, from here.

The branch is not bisectable for ip65: BACKEND=ip65 USE_NISTCURVES_ONCHIP=1
does not link at any commit before d7e8592.
The bump lands first (57 B
overflow), gating narrows it (24 B), and only the cfg move closes it. That
ordering is deliberate — each commit is one reviewable idea — but it means
anyone bisecting an ip65 problem across this range will hit a run of
non-building commits and reasonably conclude they broke something. They did
not. The two UCI profiles link at every commit; only ip65 has the gap.

A note on test totals

pytest collects 131 on this branch and 133 on chore/x25519-v0.16.0,
which adds a two-test module (tools/test_x25519_pin.py, registered in
pytest.ini). Both are correct. A pytest total is a property of the tree,
not of the suite, and quoting one without naming the tree invites a phantom
regression — which is what nearly happened here.

This is not a figure that failed. It is a correct number that belongs to a
different configuration, which is a different thing entirely and worth keeping
distinct in a PR whose subject is not mis-attributing causes.

CLAUDE.md already records the same trap one layer down, for test_x509_name.py:
"its vector count is conditional — never quote one without the condition." The
pytest total has it too. Name the tree, or do not quote the number.

Rejected alternatives

  • Shuffle segments between CRYPTO_OVERLAY and CRYPTO_RESIDENT on ip65.
    Cannot work: the regions are adjacent, so they are one pool, and the pool was
    35 B short however arranged. This is the whole point of the conservation proof.
  • Enlarge CRYPTO_RESIDENT. It cannot grow past $A000 without landing
    under boot.s's zbss zero-fill.
  • Move LIB_NISTCURVES_MUL_CODE instead. It is not the segment that
    overflows under UCI, and it already lives in CRYPTO_OVERLAY there.
  • Hold ip65 at v0.11.2 and bump only UCI. Two pins in one tree, for a
    correctness fix, to avoid removing 332 B of code no image can reach.
  • Delete the P-384 lane outright. Both files stay in tree on the same policy
    the retired EMBED_P256_OVERLAY follows. Gating is reversible in one flag and
    keeps the mutation control alive; deletion would remove the only build that
    can still catch a P-384 symbol going away.
  • Take HTTP_AUX_CODE2's move as a new trade-off. It is not one.
    cfg/c64-https-uci.cfg:252 and cfg/c64-https-uci-onchip.cfg:297 have always
    routed that segment to CRYPTO_OVERLAY. ip65's own comment said it lived
    elsewhere because "CRYPTO_OVERLAY cannot hold the whole W4 machinery on ip65"
    — gating made that untrue, so the workaround retires and the stale comment
    goes with it.

NO HARDWARE OR E2E RUN HAS COVERED THESE IMAGES

Every PRG hash in this PR is new. Nothing that ran before this branch covers
anything it produces:

  • The 2026-09-05 RR-Net real-silicon run (ip65-onchip, stock 1 MHz, HTTP 200)
    covered a different ip65-onchip binary. It does not cover 7905d63c….
  • Every prior U64E / C64U hardware pass — github, wikipedia, lwn, browserleaks,
    the banner rig, the bad-Finished rig — covered different uci-onchip and
    uci-comb binaries. They do not cover 30dd30a5… or f85e3712….
  • Everything reported above is VICE and host-side only. No Ultimate 64 device
    was touched by this lane.

The last commit that can change a built artifact is d7e8592. Everything after
it — e4fda6d, 807d5a6, 948542b — is CLAUDE.md-only
(git diff --name-only d7e8592..HEAD returns CLAUDE.md and nothing else), and
all five profiles were rebuilt at the tip and came back bit-identical to the
hashes tabulated above. An e2e run pointed at any commit from d7e8592 forward
is measuring the same bytes.

Provenance note for the hardware write-ups. The two e2e lanes were dispatched
against e4fda6d, which is no longer the tip. Their results still stand — the
artifacts are identical — but this project's standing rule is that a hardware
claim names its artifact, so those write-ups must cite the PRG sha256
alongside the commit, not the commit alone. A commit SHA stops identifying an
image the moment a docs commit lands on top of it; the hash does not.

That is this PR's recurring defect one level up: an identifier that was
accurate when it was recorded and silently stopped being.
d640677's 46 B,
f9ad178's five hashes and ten margins, d7e8592's 57 B, and the six stale
figures in CLAUDE.md are all the same shape — every one of them was true when
written. Nothing here was ever a careless measurement; they went stale because
the tree moved underneath them and nothing tied them to the tree they described.
Hence the rule this PR applies throughout, and asks the hardware lanes to apply
too: name the artifact, not the commit.

uci-comb is the one product exposed to either defect and the one whose crypto
path changed most; it has had no hardware run at these bytes. Treat hardware
and e2e coverage as owed, not carried over.

🤖 Generated with Claude Code

JC-000 and others added 13 commits September 7, 2026 15:37
…rowth

v0.13.0 carries the fail-closed fix for the defect we reported upstream
(c64-nist-curves#148): the Lim-Lee comb accepted an unusable anchor-table
slot and ecdsa_verify returned VALID on the collapsed u1*G = O case.
c64-https-uci-comb.prg is a shipped product on that path
(LIB_NISTCURVES_REU_BANKS_USED = $0004, measured).

Keep the scope exact. The guard catches a COLLAPSED anchor table, not a
CORRUPT one. An attacker who can write REU bank 2 plants a valid point
instead, reaches a forged R with Z != 0 throughout, and no post-condition
on the result would see it. This is not a defence against that attacker.

v0.12.0 adds the SPEC 8.2 REU DMA settle across thirteen sites, and that
is where the bytes went:

  LIB_NISTCURVES_MUL_CODE   123 -> 162  (+39, nistcurves_reu_dma_wait)
  LIB_NISTCURVES_P256_CODE  8304 -> 8362 (+58 onchip; +82 REU; +100 comb)

ABI 2 -> 4 (v0.13.0 gave ec_scalar_mul a carry return; v0.14.0 fixed
reu_fetch_mul_row to take the row index in A per 8.2). Neither hop
reaches our call surface: we never jsr ec_scalar_mul into the library
(src/crypto/ecdsa_verify.s defines its own shim) and we never call the
fetch. src/crypto/ecdsa_verify.s needs no change -- it asserts MAJOR = 0
and MINOR >= 9, both still true.

PLACEMENT. Measured, literal ld65, against the five configurations:

  uci-onchip        'LIB_NISTCURVES_P256_RODATA' overflows 'CRYPTO_HOT' by 22 bytes
  uci REU default   same segment, same region, by 59 bytes
  uci-comb          links (CRYPTO_HOT 93 free)
  ip65 REU default  links (CRYPTO_RESIDENT 29 free)

The fix routes LIB_NISTCURVES_P256_RODATA -- 192 B of curve/mod constants
-- from CRYPTO_HOT to CRYPTO_OVERLAY in cfg/c64-https-uci.cfg. One line,
one cfg, no source change, and cfg/c64-https-uci-onchip.cfg has routed
the same segment the same way since the comb profile existed, so the
shipped comb image is untouched. CRYPTO_OVERLAY is plain resident RAM at
$4200-$5FFF under UCI with ~2 KB free in both affected profiles, it is
where LIB_NISTCURVES_MUL_CODE already lives, and rodata there is subject
to nothing the cold-shadow zero-fill does. Post-fix CRYPTO_HOT margins:
170 B uci-onchip, 133 B uci REU default.

Rejected: moving LIB_NISTCURVES_MUL_CODE instead (it is not the segment
that overflows under UCI, and it already lives in CRYPTO_OVERLAY there);
and enlarging CRYPTO_HOT, which cannot grow past $A000 without landing
under boot's zbss zero-fill.

ip65-onchip is NOT fixed by this commit and still fails to link
('LIB_NISTCURVES_MUL_CODE' overflows 'CRYPTO_RESIDENT' by 57 bytes). It
needs a decision outside a pin bump -- see the PR body.

Suites, both matching their pre-bump baseline:
  tools/test_ecdsa_kat_oracle.py  6/6 (3 valid accepted, 3 invalid rejected)
  tools/test_x25519.py            73/73

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…scope it

tools/integration/build_nistcurves_p256.sh proves LIB_NO_BARE_EXPORTS=1
reached the archive by od65-ing the discovered zp_config*.o member for an
export of the bare `zp_ptr2`. libs/nistcurves v0.14.0 (upstream #154, SPEC
6.1 member isolation) moved the deprecated bare aliases out of
zp_config.s into src/zp_aliases.s -> member zp_aliases_p256verify.o /
_p256comb.o. From that pin, zp_config*.o exports no bare alias WHETHER OR
NOT the flag took effect: the guard passed by reading an object that could
no longer fail.

That matters because this failure has NO link error. CLAUDE.md records the
mechanism: a member built with a different knob string re-exports names the
rest of the archive suppressed, one artifact carrying two configurations,
dormant until a second contract library enters the link.

Retargeted at every member of the archive rather than at the new member
name, so the next re-homing cannot repeat this. Members are read from
upstream's build directory exactly as the ZP slot checks already do --
listing an archive and reading the objects it names is not extraction, so
6.1 stays clean. A member the archive names but that is absent is a hard
error, and a zero-member scan is a hard error, because a guard that
silently scans nothing is the very shape being fixed.

RED-GREEN, measured in this worktree at the v0.14.0 pin:

  GREEN, as shipped:
    $ bash tools/integration/build_nistcurves_p256.sh onchip
    [p256/onchip] ZP overrides verified in zp_config_p256verify.o;
                  bare zp_* suppressed across 18 members
    rc=0

  RED, same script with ` -D LIB_NO_BARE_EXPORTS=1` stripped from
  CONTRACT_DEFINES:
    ERROR: these archive members re-export the bare 'zp_ptr2' —
           LIB_NO_BARE_EXPORTS did not reach them: zp_aliases_p256verify.o
           One archive must carry one configuration (SPEC 6.2).
    rc=1

  VACUITY of the old guard, on that same un-suppressed archive:
    $ od65 --dump-exports libs/nistcurves/build/zp_config_p256verify.o \
        | grep -c '"zp_ptr2"'
    0                     <- old guard passes
    $ od65 --dump-exports libs/nistcurves/build/zp_aliases_p256verify.o \
        | grep '"zp_ptr2"'
          Name:                 "zp_ptr2"

The ZP_MEMBER discovery itself survives the pin unchanged: `ar65 t | grep
'^zp_config'` still matches exactly one member, since zp_aliases_*.o does
not share the prefix.

Also in this file, since both are the same staleness: the pinned-version
string in the c64-https#124 preflight diagnostic is now RESOLVED from the
gitlink with `git describe --tags --exact-match` instead of carrying a
hand-edited literal (it still said v0.11.2 -- a wrong version inside a
message aimed at version staleness), and the ">= v0.11.2" floor block now
lists the v0.12.0/v0.13.0/v0.14.0 reasons, including the #148 scope
caveat.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ured margins

Pin prose: the >= v0.11.2 build rule and the `libs/nistcurves@v0.11.2`
line in Crypto ABI move to v0.14.0, with the new floor reasons pointed at
the CONTRACT_DEFINES block that actually lists them. Adds the ABI = 4
fact and the #148 comb fail-closed fix, the latter with its scope stated
exactly: it catches a COLLAPSED anchor table, not a CORRUPT one, and is
no defence against an attacker who can write REU bank 2.

Three margins this file carried were wrong, all measured here:

  CRYPTO_HOT under UCI          claimed 81 B, is per-profile: 170 / 93 /
                                133 at v0.14.0 (36 / 193 / 23 at v0.11.2,
                                so the 81 was already stale -- issue #193)
  comb CRYPTO_OVERLAY tail      claimed ~223 B, is 120 B (159 at v0.11.2)
  ip65 free blocks              claimed ~170-186 B NET_CODE and 16 B
                                LOADER, are 56 B (beyond the 20 B the
                                default target strings use) and 21 B

The ip65 paragraph also gains the fact that makes its headroom
arithmetic decidable: CRYPTO_OVERLAY ($4F8C-$5FFF) and CRYPTO_RESIDENT
($6000-$9FFF) are ADJACENT, so they are one 20,596 B pool and shuffling
segments between them creates nothing. That is why the contiguous-region
restructure is worth only the 22 B of boundary fragmentation, and why
"route the library segment elsewhere" is not a general answer on ip65:
the other free blocks are NET_CODE's tail, which is the
HTTPS_HOST/HTTPS_PATH budget, and the smallest segment in the pool is
169 B.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The flag's `CA65FLAGS += -D ENABLE_P384_VERIFY=1` was nested inside
`ifeq ($(USE_NISTCURVES_ONCHIP),1)`, so the two REU-profile builds — plain
`make` and `make BACKEND=uci` — dropped it silently. Setting the flag on
those two configurations produced a PRG byte-identical to the unflagged one.

Red/green, PRG sha256, at the parent commit:

  make BACKEND=ip65                       d780f719fac82e07bba9d30db804e853
  make BACKEND=ip65 ENABLE_P384_VERIFY=1  d780f719fac82e07bba9d30db804e853
  make BACKEND=uci                        7c79a4e00a19685de7540970247c759a
  make BACKEND=uci  ENABLE_P384_VERIFY=1  7c79a4e00a19685de7540970247c759a

After this commit those two armed builds move to cbfd9d9b1155447f and
8b67ee949f8507b8 — the flag now does what it says on every profile.

This matters because ENABLE_P384_VERIFY exists solely so the P-384 safety
gate can be mutation-tested (CLAUDE.md, "Crypto ABI"). A mutation control
that is a no-op on 2 of 5 configurations proves nothing about those two.

The three onchip profiles were never affected by the nesting, and their
armed PRGs are byte-identical across this move:

  BACKEND=ip65 USE_NISTCURVES_ONCHIP=1        b9f03169ababe20b (both)
  BACKEND=uci  USE_NISTCURVES_ONCHIP=1        3c2712629063de69 (both)
  BACKEND=uci  USE_NISTCURVES_ONCHIP_COMB=1   cc555c196a8b1673 (both)

All five UNARMED PRGs are unchanged by this commit; no shipped image moves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit f73bbc04d3b746de189caae74f3688a681044498)
ecdsa_verify_384.o was in every shipped image and reachable from none of
them. Its sole export, ecdsa_verify_384_tls, is imported only from inside
ecdsa_verify.s's `.ifdef ENABLE_P384_VERIFY`; ca65 emits no import record
for an unreferenced .import, so the object was pulled in purely because
the wildcard named it on the ld65 command line.

Deadness evidence (not read off the source gate):
  - od65 --dump-imports build/crypto/ecdsa_verify.o does not list
    ecdsa_verify_384_tls.
  - The string ecdsa_verify_384_tls appears in ZERO Imports-list entries
    across all five build/c64-https.map files (ip65-onchip, uci-onchip,
    uci-comb, plain ip65, plain uci).
  - Its own imports (crypto_swap_to_p384_{sha384,curve},
    ecdsa_pubkey_{x,y}_384, tls_rec_buf, tls_transcript) all come from
    objects linked for other reasons, so dropping it resolves nothing away.
  - ec_scalar_mul_384_shim lives in the P-384 CURVE ARCHIVE, which the main
    link never names; it is unaffected.
  - p384_force_link.s was already inert (`.ifdef USE_NISTCURVES_P384`,
    undefined today) and contributes 0 B either way.

Recovered, per build (PRG sha256 before -> after):

  ip65-onchip  ba2be108 -> 7b953a8e   CRYPTO_OVERLAY  22 ->  321 B free
                                      CRYPTO_RESIDENT 40 ->   73 B free
  uci-onchip   5f9e9fb9 -> f0a85c18   NET_CODE        67 ->  366 B free
                                      CRYPTO_HOT      36 ->   69 B free
  uci-comb     c4234760 -> 4a184fdb   NET_CODE        67 ->  366 B free
                                      CRYPTO_OVERLAY 159 ->  192 B free
  plain-ip65   d780f719 -> 0a85a1ff   CRYPTO_OVERLAY  22 ->  321 B free
                                      CRYPTO_RESIDENT 150 -> 183 B free
  plain-uci    7c79a4e0 -> 18c26f5b   NET_CODE        67 ->  366 B free
                                      CRYPTO_HOT      23 ->   56 B free

plus 2 B of BSS in each (the cold-shadow gap below TABLES_BSS goes 44 -> 46 B).

Behaviour is unchanged: the P-384 arm was already a `sec` reject, and it
still is. Red/green on the mutation control, uci-onchip, after this commit:

  ENABLE_P384_VERIFY unset  tools/test_p384_overlay_hazard.py exit 0
                            "0 / 7680 bytes changed, C=1, PASS"
  ENABLE_P384_VERIFY=1      tools/test_p384_overlay_hazard.py exit 1
                            "5575 / 7680 changed, DID NOT RETURN (hung)"

so the gate is still provably load-bearing. tools/test_tls_p384_negotiation.py
is 2/2 before and after; tools/test_ecdsa_p384_kat.py exits 1 with
"required artifact missing: build/labels-p384-sha384.txt" before and after
(the P-384 overlay build has never completed - see "Known issues").

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit d64067754c96ace0d7367521ef5ab972e2729aad)
ip65 was the odd one out. cfg/c64-https-uci.cfg:252 and
cfg/c64-https-uci-onchip.cfg:297 have always routed HTTP_AUX_CODE2 to
CRYPTO_OVERLAY, next to the HTTP_AUX_CODE slice it was split off from;
only cfg/c64-https-ip65.cfg sent it to the CRYPTO_RESIDENT tail. Its own
comment gave the reason: "CRYPTO_OVERLAY cannot hold the whole W4
machinery on ip65".

That precondition is gone. Gating the unreachable P-384 objects out of the
link (previous commit) returned 299 B of CRYPTO_AUX_CODE + 33 B of
CRYPTO_RODATA to every image, and CRYPTO_OVERLAY on ip65 now has room for
the 169 B slice. So this is not a new trade-off being taken; it retires a
workaround whose cause has been removed, and leaves all three cfgs
agreeing on where the W4 helper slice lives.

Measured on the integrated branch (ip65-onchip,
BACKEND=ip65 USE_NISTCURVES_ONCHIP=1):

  CRYPTO_OVERLAY   $4F8C-$5FFF   top $5F67   152 B free
  CRYPTO_RESIDENT  $6000-$9FFF   top $9F6E   145 B free

Without this move the same build overflows CRYPTO_RESIDENT by 57 B at the
libs/nistcurves v0.14.0 pin; with it, both regions link with margin. The
stale comment is replaced with what is now true.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three things changed under this file's feet:

  - ENABLE_P384_VERIFY now applies on all five profiles (it was nested
    inside the USE_NISTCURVES_ONCHIP block and silently dropped by the two
    REU builds), and it is now the ONLY thing that links
    src/crypto/ecdsa_verify_384.s and src/crypto/p384_force_link.s. The
    entry gains that command, because it is the one build that can still
    catch a P-384 symbol going away — and a warning that assembling the
    file proves nothing: `.import` of an undefined symbol is a LINK-time
    error in ca65, so `ca65 src/crypto/ecdsa_verify_384.s` succeeds with
    every import unresolved.
  - The Crypto ABI section records what gating costs: exactly two symbols,
    crypto_swap_to_p384_sha384 and crypto_swap_to_p384_curve, lose their
    only link-time consumer. Read off the Imports list of all five
    build/c64-https.map files, not estimated. Both are still exported
    unconditionally by crypto_swap.s and still occupy bytes.
  - The ip65 headroom paragraph is re-measured at the v0.14.0 pin with the
    gate and the HTTP_AUX_CODE2 move in place: 152 B CRYPTO_OVERLAY,
    145 B CRYPTO_RESIDENT, 56 B NET_CODE tail, 21 B LOADER, 43 B below
    TABLES_BSS. The adjacency argument it already carried is what settled
    the bump, so it now says so: 20,631 B of content against 20,596 B of
    pool, 35 B short however the segments are arranged.

The ip65 memory map also gains HTTP_AUX_CODE + HTTP_AUX_CODE2 in
CRYPTO_OVERLAY's tenant list.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
b313b5f measured these at the v0.14.0 pin, before the P-384 objects were
gated out of the link, and e4fda6d refreshed only the ip65 numbers. The
33 B of CRYPTO_RODATA that gating returned lands in a different region per
profile, so the correction is asymmetric:

  CRYPTO_HOT     uci-onchip        170 -> 203
  CRYPTO_HOT     uci REU default   133 -> 166
  CRYPTO_OVERLAY uci-comb          120 -> 153

Comb's CRYPTO_HOT is the one that does NOT move: it stays 93 B, because
cfg/c64-https-uci-onchip.cfg already routes CRYPTO_RODATA to
CRYPTO_OVERLAY, so comb's 33 B came back there instead. That asymmetry is
now stated at both sites rather than left for the next reader to
rediscover -- it is the third time in this branch that a per-profile
figure has been corrected in one profile and left stale in the others.

All three replacements are measured from build/c64-https.map on this
branch, not derived from the 33 B.

Docs only. No PRG changes; all five profile hashes are unchanged from
d7e8592, re-verified after this commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
An adversarial sweep of EVERY free/margin/hole figure in this file against
five measured maps -- rather than only the hunks this branch touched --
found six wrong. 807d5a6 fixed three; these are the other four, two of
which made the file contradict itself.

Self-contradictions, both now resolved to the measured value:

  LOADER free on ip65    :307 said 58 B, :683 said 21 B    -> 21 B
  comb CRYPTO_OVERLAY    :511 said 223 B, :650 said 120 B  -> 153 B

Six hundred lines apart in a file every session reads start to finish, and
a file that contradicts itself is worse than one uniformly stale: it makes
whichever number you happened to read feel confirmed. Both sites now say
which is current and point at the Memory layout section, and the 58 B and
223 B are kept as dated history rather than deleted, since both were true
when written (#142 and the server-name-validation episode respectively).

Plain staleness:

  smallest segment in the ip65 pool  169 B -> 162 B

169 B is HTTP_AUX_CODE2. The smallest is LIB_NISTCURVES_MUL_CODE at 162 B,
read off build/c64-https.map. The conservation conclusion is unaffected --
162 > 56, so the NET_CODE tail still cannot absorb the smallest pool
segment -- but the number naming it was wrong, and this is the sentence a
future restructure would lean on.

Also: :517's "at v0.11.2 it was 36 / 193 / 23" is CORRECT and stays. It was
flagged as unverifiable because the v0.11.2 pin is no longer reachable from
this branch (it fails the branch's own ABI assert). It is measurable on
master at 48657f5, where the baseline lane measured exactly those three
values before this work began, so the line now says where to check it. A
figure that cannot be re-derived from the tree that carries it needs its
provenance written down, not removing.

Docs only. `git diff --name-only` is CLAUDE.md alone; no PRG changes, and
all five profile hashes are re-verified unchanged from d7e8592 after this
commit. Not squashed into d7e8592 or earlier, so the two in-flight e2e runs
remain valid.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…file hazard

Two additions, both from an adversarial review of this branch.

1. PACKAGE_VARIANTS. The file said restoring a REU-profile image is "one
line in PACKAGE_VARIANTS", framed purely as curation. Measured
LIB_NISTCURVES_REU_BANKS_USED across all five builds:

  ip65-onchip  $0000     uci-onchip  $0000     uci-comb  $0004
  plain-ip65   $0003     plain-uci   $0003

The shipped onchip products touch no REU bank and uci-comb claims bank 2,
which is what the exposure argument for this bump rests on. But the two REU
profiles read $0003 -- they DO library REU DMA, so they are exposed to the
SPEC 8.2 REU DMA settle fix that libs/nistcurves v0.12.0 added. Restoring
that one line therefore restores an image with a security-relevant
dependency on the pin, and nothing said so. Now it does.

2. A maintenance hazard on the margin figures themselves. The recurring
defect in this file is not that a number goes stale; it is that a number
gets corrected in the ONE profile someone was looking at and left stale in
the other four. Three instances in this bump alone, two of which left the
file contradicting itself hundreds of lines apart -- which is worse than
uniform staleness, because the reader who lands on either site sees a file
that agrees with itself.

The note says to re-measure all five off build/c64-https.map rather than
deriving the rest by arithmetic, and gives the worked reason: the deltas are
NOT uniform. Gating returned 33 B of CRYPTO_RODATA to CRYPTO_HOT in three
profiles but to CRYPTO_OVERLAY in comb, because comb's cfg routes that
segment differently -- so an "add 33 everywhere" pass would have been wrong
in exactly one place, and that place is the shipped product.

Docs only. `git diff --name-only` is CLAUDE.md alone; five hashes
re-verified unchanged after this commit. Not squashed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
README was untouched by this branch and carried figures and claims the
bump falsifies. All numbers below are measured on this branch's tip with
`make clean` between products, read off `build/c64-https.map`.

- The nistcurves pin is v0.14.0, not v0.11.2. The comb verify sweep is
  re-attributed to the v0.11.2 pin, where it was taken.
- Free-space table re-measured for all three products. Every cell moved,
  and not uniformly, so the paragraph under it now says to read them per
  profile: ip65 CRYPTO_OVERLAY 22 -> 152 B and CRYPTO_RESIDENT 40 ->
  145 B, UCI NET_CODE 67 -> 366 B (the 299 B of CRYPTO_AUX_CODE the
  unreachable P-384 object held), uci-onchip CRYPTO_OVERLAY 2,035 ->
  1,804 B (LIB_NISTCURVES_P256_RODATA moved there), uci-comb CRYPTO_HOT
  193 -> 93 B. The two CRYPTO_COLD_SHADOW cells also lose a byte: 44 /
  1,578 were measured from the last used address, not the first free one,
  while every other cell in the same table was not.
- Label counts: 2,398/2,729/2,864 -> 2,395/2,726/2,859. PRG sizes are
  unchanged at 47,105 / 62,977 / 62,977, which is the point that section
  already makes about size not being a measurement.
- P-384 is now gated at the link line too (332 B recovered), and
  ENABLE_P384_VERIFY applies on all five profiles rather than being
  silently dropped by the REU ones — issue #207.
- Restoring a REU-profile image in PACKAGE_VARIANTS is flagged as a
  security-relevant decision, with the measured
  LIB_NISTCURVES_REU_BANKS_USED per product ($0000 onchip, $0004 comb,
  $0003 for the two unshipped REU profiles).

The wikipedia claims are corrected rather than softened. The release
blurb and the Project Status entry both presented a 125,235 B
byte-checked fetch; that does not reproduce on either tree. http_get
returns carry=0 / HTTP 200 on bodies tens of kilobytes short of their
Content-Length, intermittently — issue #211, which the README now cites
in three places, along with #210 for why the rig on that path could not
go red on it. The entry also states what has NOT been tested: ip65
against a large body, at any size. The handshake conclusions are left
standing; only the body path is in question.

Two facts in that block are owned by more than one branch, so they land
here as the later branch in the merge order.

Documentation only; no source, cfg or Makefile change on top of this
branch, so no PRG hash moves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ount

Two corrections to the free-space paragraph, both from adversarial
review. Every value in the table above it survived; this is prose.

1. The claimed off-by-one never happened. This commit's parent said the
   old 44 / 1,578 CRYPTO_COLD_SHADOW cells had been measured from the
   last used address while the rest of the table was not. They were not:
   master measured under the same convention as the rest of the table
   yields 44 / 1,578, so the old cells were right. The byte is real
   segment growth at the v0.14.0 pin — a 3 B LIB_NISTCURVES_BSS appears
   and BSS shrinks by 2, walking CRYPTO_BSS's last address $B9D3 ->
   $B9D4 on ip65 and $B3D5 -> $B3D6 under UCI — which is a fact about
   the bump and worth stating in its own right.

   Worth naming what happened here: a correct measurement with a wrong
   story attached to it, written into the very paragraph that corrects
   other people's figures. It is the defect this branch documents,
   committed while documenting it.

2. "Every cell moved, and not by a common factor" was contradicted by
   the table printed directly above: ip65 LOADER and NET_CODE, uci-onchip
   LOADER, and both NET_BSS_TAIL cells are unchanged. Replaced with the
   claim that actually holds (the reasons do not generalise across
   profiles), and the four static cells are now named — an unchanged
   number is not evidence that a region was left alone.

Documentation only; no PRG hash moves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two review findings, both about claims that are true only in a context
the README did not state.

- The wikipedia entry cited three live body counts and an offline
  reproduction, all device runs, without naming an image. It now says
  #211 carries the PRG sha256 of each, and why a commit does not
  substitute for one. Three products ship from this tree; the three
  live counts are three different PRGs.

- The ip65 memory map's `+ HTTP_AUX_CODE2` is true because this branch's
  parent moved that segment in cfg/c64-https-ip65.cfg. On the other
  three branch trees it still rides the CRYPTO_RESIDENT tail, so the
  line is order-dependent and now says so, and says to read the cfg.

Documentation only; no PRG hash moves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@JC-000
JC-000 force-pushed the chore/crypto-lib-bump branch from 22904d6 to f982504 Compare September 7, 2026 20:38
The End-to-end HTTPS status section claimed the 125,235 B article was
byte-verified. It does not reproduce on either tree: `http_get` returns
carry=0 / http_status=200 on bodies tens of kilobytes short of their
Content-Length, intermittently and not as a function of size. Measured
offline against a local listener with Content-Length and no chunking
(25,557 / 78,293 / 160,000 B at a constant 160,000 B request, plus one
run that hung), and live at 117,192 / 89,526 / 73,720 B against a
same-day 125,703 B curl anchor.

README already carried this correction; CLAUDE.md did not. That
asymmetry — a figure fixed where someone was looking and left stale in
the canonical file — is the same shape as the six margin figures this
branch corrects, and CLAUDE.md is the file read first each session.

The handshake and GET results in that paragraph are unaffected; only the
body-completeness claim is withdrawn.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant