Skip to content

Hash tables: choose with the generated table dispatchers - #4501

Merged
alex merged 2 commits into
mainfrom
claude/hash-tables-dispatch
Nov 7, 2026
Merged

alex merged 2 commits into
mainfrom
claude/hash-tables-dispatch

Conversation

@alex

@alex alex commented Nov 7, 2026

Copy link
Copy Markdown
Member

The hash functions' tables of functions, which RSAES-OAEP, RSASSA-PSS and deterministic ECDSA's signing pass to verified code, are now chosen by the generated table dispatchers (crate::arch::dispatch::fn_tables, #4468), not by each hash's Backend::select in Rust.

Changes

  • TableHash::hash_table, md_hash_table and hmac_table return the tables from vg_hash_<h>_auto(), vg_md_hash_<h>_auto() and vg_hmac_<h>_auto(). They no longer take the CPU's features.
  • RSA: oaep::table::table, pss::table::table and pss::table::md_table drop their Features argument. RSA's own functions(f) choice is unchanged (the coordinator's).
  • ECDSA: HmacHash::hmac_table and ecdsa::table::sign_with drop their Features argument, so the curves' sign only pass the signing function. The curves' choice of multiplication (Mul::select) is unchanged; ECDSA signing's migration builds on this.
  • streaming_hash! loses its tables: section and the compile-time checks of the tables' features. hashes::tables loses Tables. The tables: blocks of MD5, SHA-1 and SHA-2 are gone.
  • hashes::tables::tests::table_words checks the words of the tables this CPU's dispatchers return. It no longer loops over each backend's REQUIRES. Each VG_CPU_FEATURES line of CI that runs the full suite checks its own choice. The data words are the same for every table of an interface (VG.Rust.tableDispatcher).

Behaviour

The choice is the same as before. The dispatchers rank the tables in the order the backends' selects used:

  • x86-64: SHA-NI, then AVX2 (SHA-1: AVX+BMI)
  • AArch64: SHA2 (SHA-512: SHA3)
  • x86: SHA-NI

No TCB, Spec or Lean change; the generated crates are unchanged.

Benchmark

One scoped run (rsa_oaep, rsa_pss, ecdsa_p256 with SHA-256, x86-64, AArch64 and x86, all features and none), against the merge base: https://github.com/pyca/verified-garbage/actions/runs/42397584348

Checks

  • Every Static checks step
  • cargo fmt --check
  • cargo clippy --all-targets -D warnings for x86-64 (with and without alloc), AArch64, i686, ARMv7, RISC-V 64 and PPC64LE
  • The tables' unit tests, rfc6979, rfc7027, Wycheproof ECDSA, RSA-PSS and RSA-OAEP, run with VG_CPU_FEATURES unset and set to none, sha,ssse3 and avx,avx2,bmi1,bmi2

Generated by Claude Code

`TableHash`'s `hash_table`, `md_hash_table` and `hmac_table` return the
tables that `vg_hash_<h>_auto`, `vg_md_hash_<h>_auto` and
`vg_hmac_<h>_auto` (`crate::arch::dispatch::fn_tables`) choose, instead of
those of the implementation each hash's `Backend::select` chose in Rust.
RSAES-OAEP's and RSASSA-PSS's `table::table` and `table::md_table`, the
`HmacHash` trait and `ecdsa::table::sign_with` no longer take the CPU's
features. `streaming_hash!` loses its `tables:` and the checks of their
features, and `hashes::tables` its `Tables`.

The choice is today's: the dispatchers rank the tables as the backends'
`select`s did (SHA-NI, then AVX2 or AVX+BMI on x86-64; SHA2 or SHA3 on
AArch64; SHA-NI on x86).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFuGsz7F32Tm9DLkuP
`hashes::tables::tests::table_words` now reads the tables the dispatchers
choose, so the lines that choose among SHA-512's implementations (SHA512,
and none) run it, to cover the choices of the SHA-512 family's tables of
`Hmac` (SHA-512/224's and SHA-512/256's), which nothing else there reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFuGsz7F32Tm9DLkuP
@alex
alex added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 124fc2e Nov 7, 2026
43 checks passed
@alex
alex deleted the claude/hash-tables-dispatch branch November 7, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants