Conversation
|
This PR still uses the old layout that the conflict restructure (#144, #147, #148, #150) replaced on What to move:
This PR is stacked on another branch, so apply the same moves on that base first. See the "Keeping parallel PRs from conflicting" section of Generated by Claude Code |
0d29621 to
2ed5ea3
Compare
0272e1e to
8ea0ee5
Compare
|
Done, on current Generated by Claude Code |
8ea0ee5 to
2b795d9
Compare
2ed5ea3 to
685b086
Compare
2b795d9 to
49dc845
Compare
0640461 to
dc7bf04
Compare
49dc845 to
e55a1eb
Compare
|
The ppc64le The armv7l job on Generated by Claude Code |
The same algorithm as on AArch64. vg_hmac_sha256_init stores H0 in both states, XORs the key into the ipad and opad blocks, and calls vg_sha256_compress on each; vg_hmac_sha256_finalize calls vg_sha256_finalize on the inner state, rebuilds it as (K0 ^ opad) || digest from the outer hash value, and finalizes it again, leaving the MAC in scratch[176..208). Both move the link register to r0 and save it in an ELFv2 frame; init keeps its variables in r26-r31 (saved in scratch) and finalize in r24-r25, which the callees preserve. As on AArch64, the proofs use 160 and 240 bytes of scratch, and Shared.lean widens them to the shared contracts' 608 and 688. The target-independent lemmas come from Proof/Hmac/Common.lean. HMAC-SHA-256 and its Wycheproof tests now build on little-endian powerpc64 (with the MAC left in scratch, as on the other 64-bit targets); they pass under qemu-ppc64le. The other HMACs, and PBKDF2 (the only user of sha256_key_states), stay on the other architectures. Refs #55 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fw6RULWHCeVgMDGc3wRrwE
HMAC's verify compares MACs with vg_ct_eq (crate::ct), which needs an implementation on every architecture that uses it: a verified PPC64LE one, the same algorithm as AArch64's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fw6RULWHCeVgMDGc3wRrwE
e55a1eb to
e9146d5
Compare
dc7bf04 to
5fe4cf4
Compare
Part of #55. Stacked on #110 (SHA-256), #109 (ChaCha20), #108 (TCB) and #97 (CI). There are no TCB or spec changes. This PR adds implementations proven against the existing
Spec.Hmac.initSha256Contract,finalizeSha256ContractandSpec.Ct.eqContract.HMAC-SHA-256 on PPC64LE
The algorithm is the same as on ARMv7:
vg_hmac_sha256_initstoresH⁽⁰⁾in both states, XORs the key into the ipad and opad blocks, and callsvg_sha256_compresson each.vg_hmac_sha256_finalizecallsvg_sha256_finalizeon the inner state and rebuilds it as(K₀ ⊕ opad) ‖ digestfrom the outer hash value. It then finalizes it again, leaving the MAC inscratch[176..208)(finalizeSha256Contract).r0and save it in an ELFv2 frame (48 and 96 bytes of stack, sincefinalize's callee pushes its own frame).initkeeps its variables inr26–r31(saved in scratch), andfinalizekeeps them inr24–r25, which the callees preserve.On
main, x86-64 and AArch64 now get HMAC from the one generic implementation over every Merkle–Damgård hash, and ARMv7 and x86 keep their owninit/finalizeagainst the per-hash contracts. PPC64LE follows ARMv7 and x86, since it has a single SHA-256 implementation:Artifacts/HmacSha256/PPC64LE.lean(Apiform), modulehmac_sha256.Shared.leanwidens them (Verified.widen).Proof/Hmac/Common.lean, so no PPC64LE module imports another target's.Constant-time comparison on PPC64LE
Hmac::verifycompares MACs withvg_ct_eq(crate::ct), whichmainadded since this PR was opened, so HMAC on PPC64LE needs it as well. The second commit adds it with the AArch64 algorithm, inImpl/Ct/PPC64LE.lean:r7and return(r7 - 1) >> 63.The branches are on the lengths only. The proof in
Proof/Ct/PPC64LE.leanfollowsProof/Ct/AArch64.leanand its sharedProof/Ct/Common.lean. The artifact is registered inArtifacts/Ct/PPC64LE.lean.Rust
src/hmac/mod.rs's module gate,src/hmac/sha256.rsandsrc/ct.rsname PPC64LE.HmacHashimplementation for SHA-256 (Sha256HmacState), with its ownhmac_finalize, which reads the MAC fromscratch(as the 64-bit targets did before they moved to the generic HMAC).sha256_key_states, which only PBKDF2 uses, stays on ARMv7 and x86. Thestreaming_hmac!machinery and the other hashes' HMACs stay off PPC64LE.tests/wycheproof/hmac.rsandhmac_sha256.rsname PPC64LE, and the HMAC-SHA-256 benchmark loses CI: test on ppc64le, on a ppc64le runner as pyca/cryptography does #97's gate.README
Regenerated by
ci/algorithms_table.py: HMAC-SHA-256 is ✅ on PPC64LE.Testing
On #97's head (
mainat 48dfb92), these all pass:lake buildandEmit.lean --checkci/check_lean_imports.py,check_lean_speed.py,check_vectors.py,check_arch_gates.py,check_variants.py,algorithms_table.py --checkcargo fmt, andcargo clippy -D warningson the host and for ppc64lecargo testcross-built forpowerpc64le-unknown-linux-gnuunderqemu-ppc64le(the unit tests, includingct's; Wycheproof HMAC-SHA-256 and ChaCha20; CAVP SHA-256)🤖 Generated with Claude Code
https://claude.ai/code/session_01Fw6RULWHCeVgMDGc3wRrwE