Public-only RSA subset

vendor/bearssl/UPSTREAM.json preserves the original BearSSL file hashes and vendor/bearssl/LOCAL_CHANGES.md preserves the historical import's notes. Those notes mention private/signing routines that are not included or compiled here.

src/adapter.h contains only the inherited public-key validation, public preparation, fixed-exponent transforms, SHA256/MGF1/PSS unpadding and verification function bodies. Export-prefix macros build matched baseline and outer4 controls and the fixed public-profile candidates described below. The selected src/montmul.c changes only its exported symbol from the Showtime outer4 candidate. No private-key parser, CRT arithmetic, signing routine or generic RSA exponentiation file is shipped in this subset. The required shared integer helpers remain their original public-verification dependencies.

PROVENANCE.json records original source identities and local adaptations. Every C input is borrowed, all scratch is fixed-size stack storage, and prepared public contexts are opaque factory-created 824-byte immutable native values.

Fixed public-profile candidates, 25 October 2026

src/public.c and src/compact.c select the new public-only helpers in src/public_montmul.c and src/public_montmul_impl.h. The Montgomery recurrence is adapted from the licensed BearSSL i31_montmul.c already recorded in PROVENANCE.json. Inputs and modulus are reduced, the output is disjoint, and the admitted modulus has exactly 100 radix-2^31 limbs and 3072 bits. Consequently every intermediate output is below 2*m < 2^3073 < R=2^3100; the extra dh carry above the 100 limbs is always zero. The discarded zero low limb is not stored. Operands and carry stay in uint64_t, and the final comparison and any subtraction are variable-time on public inputs. The full and compact controls differ only in loop scheduling.

The public conversion helper adapts BearSSL i31_muladd.c and i31_tmont.c. It retains the quotient estimate and at-most-one correction bound, uses native unsigned 64-bit division on public inputs, combines the radix shift and multiply/subtract pass, and executes only the needed public correction. It allocates no buffers. The generic reference helpers remain unchanged.

Under RSX_RSA_NORMAL_BASE, the fixed exponent schedule saves the ordinary decoded signature instead of its Montgomery image as its final multiplier. After 16 squarings the last multiply returns signature^65537 mod n directly; the separate Montgomery exit is omitted. Prepared verification uses the same schedule with the original signature and the existing immutable R2 context. SHA256, MGF1, salt length, PSS format, modulus and signature checks are unchanged. These routines are unsuitable for secret arithmetic and expose no private-key operation. They remain explicit candidates pending compiled IC qualification.

tests/montgomery.rs differentially checks 8,704 public input pairs per kernel and 544 conversions across 34 moduli, including zero/one, m-1, m-2, and the extreme admitted moduli. The full 174-case independent PSS corpus, strict encoding checks and 500 distinct fixture keys run against all four backends. The new benchmark rows keep all fresh-key admission/conversion inside run; separate repeated-tuple rows rebuild a single prepared key within each call.

Source-level scratch is unchanged: four 102-word arrays (1,632 bytes) for the fresh exponentiation, or three (1,224 bytes) for prepared exponentiation; their callers also hold the 384-byte encoded signature and 32-byte digest. New conversion and multiply helpers use only scalar locals. A within-call reused key adds one transient 824-byte prepared context and a temporary 384-byte public key, with no heap allocation. Compiler stack/spills and installed Wasm memory are separate measurements owned by the canonical artifact qualification.