Fixed-profile RSA-PSS public verification
This allocation-free no_std crate supports exactly RSA-3072, exponent 65537,
SHA256, MGF1-SHA256, and 32-byte salt. It exposes public verification only.
All backends implement identical acceptance policy; select one explicitly.
The preferred paths and
dated best-pick report record measured artifacts
and their fresh-key/prepared-key boundaries.
Baseline and Outer4 preserve the reference controls. Public31 specializes
the public 3072-bit profile with full inner-loop unrolling and four outer
iterations; Public31Compact uses four-limb inner unrolling. The public
candidates use variable-time quotient estimation and final comparison, and
finish the exponentiation in ordinary form without a separate Montgomery exit.
They have no secret-key API and must not be reused for private arithmetic.
use cdk_rsx_crypto_rsa::{Backend, PreparedPublicKey, PublicKey};
let key = PublicKey::from_modulus(modulus_bytes)?;
let valid = key.verify(message, signature_bytes, Backend::Baseline);
let prepared = PreparedPublicKey::new(&key)?;
let same = prepared.verify(message, signature_bytes, Backend::Outer4);
The modulus is exactly 384 unsigned big-endian bytes, with its high bit set and
an odd low bit. These checks do not establish primality or key strength. The
signature is exactly 384 bytes, represents an integer below the modulus, and
must satisfy the fixed PSS encoding. Verification returns false on rejection.
verify_digest requires a 32-byte SHA256 array; callers must compute it over the
actual authorized message. There is no ASN.1/PEM policy parser or signing API.
PreparedPublicKey::new uses the existing public31 preparation routine to
construct the shared decoded-modulus/Montgomery context. This changes neither
its opaque format nor any verification backend's acceptance policy.
Prepared keys are immutable 824-byte factory-created native values containing no
pointers. They have no serialization interface. Rebuild them from the modulus
after restore unless an owner explicitly pins this implementation ABI. C uses
bounded stack scratch; exact compiled stack peaks require artifact qualification.
The crate installs no allocator or mutable cache and supports native tools and
IC Wasm64. Every fresh verification validates/decodes its modulus and performs
its conversion within that call. Separately named within-call-key benchmark
rows validate and prepare a repeated key once inside each call; the context is
discarded after every run. Their current repeated fixtures repeat the exact
message/signature tuple. prepared rows use preparation from the earlier setup
call and are a separate diagnostic, not a fresh-key performance claim.
Provenance, the preserved BearSSL license and local changes identify the public-only source subset. Tests retain the full 174-case independent PSS corpus, including 108 Wycheproof cases; malformed digest lengths reject at the typed array boundary. Public fixtures include 500 distinct keys plus independently signed repeated-key message lengths. Arithmetic tests compare both public kernels and fresh conversion with the reference over edge values, deterministic random pairs, 32 distinct fixture moduli, and the smallest and largest admitted odd moduli. The research note describes benchmark limits and security scope. Historical results do not qualify new source or compiled artifacts.