Skip to content

PBKDF2-HMAC: choose with its generated dispatchers - #4503

Merged
alex merged 1 commit into
mainfrom
claude/pbkdf2-dispatch
Nov 7, 2026
Merged

alex merged 1 commit into
mainfrom
claude/pbkdf2-dispatch

Conversation

@alex

@alex alex commented Nov 7, 2026

Copy link
Copy Markdown
Member

Each hash's Pbkdf2Hash::pbkdf2_derive now calls vg_pbkdf2_hmac_<hash>_auto (crate::arch::dispatch::pbkdf2_<hash>). Before, it matched on the hash's backend enum, which the hash's select chose in Rust.

Changes

  • whole_pbkdf2! takes only the dispatcher and the digest size: whole_pbkdf2!(Sha256, pbkdf2: vg_pbkdf2_hmac_sha256_auto, output: 32).
  • The macro loses its per-implementation lists and the compile-time checks of their features against Backend::REQUIRES.
  • The eight src/kdf/pbkdf2_hmac/<hash>.rs files shrink to that one line plus imports.

Choice

The dispatchers choose the same implementations as before:

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

Each derivation now checks its own function's features rather than those of the hash's update and finalize. The two sets differ only on feature sets no CPU has.

The unit tests (prefix_and_verify) test the API, not a choice, so they stay. ci/cpu_tests.py is unchanged.

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

Benchmark

One scoped run, against the merge base: pbkdf2_sha1, pbkdf2_sha256 and pbkdf2_sha512 on x86-64, AArch64 and x86, each in its own configurations. https://github.com/pyca/verified-garbage/actions/runs/42397773080

Checks

  • cargo fmt --check
  • cargo clippy --all-targets -D warnings for x86-64, AArch64, i686, ARMv7, RISC-V 64 and PPC64LE
  • The Static checks steps that read Rust: check_arch_gates.py, check_variants.py, cpu_tests.py lint, run_unit_tests.py and algorithms_table.py --check
  • The PBKDF2 unit tests and the Wycheproof PBKDF2 tests, with VG_CPU_FEATURES unset and set to none, sha,ssse3 and avx,avx2,bmi1,bmi2

Generated by Claude Code

Each hash's `pbkdf2_derive` calls `vg_pbkdf2_hmac_<hash>_auto`
(`crate::arch::dispatch::pbkdf2_<hash>`) instead of matching on the hash's
backend enum, chosen by its `select` in Rust. `whole_pbkdf2!` takes the
dispatcher alone and loses the per-implementation lists and the checks of
their features.

The choice is today's: SHA-NI, then AVX2 (SHA-1: AVX+BMI) on x86-64; SHA2
(SHA-512's family: SHA3) on AArch64; SHA-NI on x86. Each derivation now
checks its own function's features, not those of the hash's update and
finalize, so they differ only on feature sets no CPU has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFuGsz7F32Tm9DLkuP
@alex
alex enabled auto-merge November 7, 2026 17:55
@alex
alex added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit ba54d82 Nov 7, 2026
62 checks passed
@alex
alex deleted the claude/pbkdf2-dispatch branch November 7, 2026 18:52
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