Repository navigation
Triple DES CBC and CFB64 decryption on AArch64: 128 blocks at a time, bitsliced - #5114
Merged
Merged
Conversation
The batched core (batchCore: the ECB functions' batch on a buffer of 128 blocks) and CBC decryption over it build, with the registration. Not yet done: CFB64 decryption, the regenerated crate, the checks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
The modes' batched CFB decryption takes blocks of one or two words, and Triple DES-CFB64 decryption runs it over the batched core. The Triple DES registrations build. Not yet done: the full build (the other ciphers' users of the modes' CFB decryption), the regenerated crate, the checks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
…tsliced batch Both called the scalar block function once for each block, 3.77 µs a block on a Neoverse N2, though their blocks need no block's result for the next: 83 times as long as ECB, whose bitsliced batch deciphers 128 blocks at once. batchCore (Impl/TripleDes/AArch64/Cbc.lean) is a core for the modes over that batch, BitsliceNeon.batch, on a buffer of 128 blocks, with the schedule read where the caller passed it. vg_triple_des_cbc_decrypt_chained is the modes' CBC decryption over it, and vg_triple_des_cfb64_decrypt their batched CFB decryption, which now takes blocks of one word as well as two (cfbDecGather and the XOR of the group, xorBlocksW, by the block's words; for two-word blocks the code is what it was, so Camellia's, SEED's and SM4's is unchanged). A group costs one batch whatever its number of blocks, so one block alone takes about a batch (5.8 µs) rather than 3.77 µs; two or more are faster than before. The working space, on the stack, is 1120 bytes (140 words: the buffer and the modes' twelve) rather than 1008. The scalar vg_triple_des_decrypt_block has no caller left and is no longer emitted. CBC encryption, CFB64 encryption, OFB, CFB8 and the functions of a message's last piece are unchanged. The long-message tests split at 127, 128 and 129 blocks too, around this group's size. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Triple DES CBC and CFB64 decryption on AArch64 are 81 times as fast at 16 KiB. This is the decryption half of finding 2 of the ARM64 audit (and finding 1 of the Apple M5 audit), which x86-64 fixed in #4416.
Cause
Both called the scalar block function once per block, 3.77 µs each on a Neoverse N2, though they are as parallel as ECB, whose bitsliced code does 128 blocks in about 6 µs.
Change
Impl/TripleDes/AArch64/Cbc.lean:batchCore d, a core for the shared AArch64 modes over the ECB functions'BitsliceNeon.batch don a buffer of 128 blocks, as Blowfish's core is over its batch of sixteen.cbcDecryptChainedis the modes' CBC decryption overbatchCore .decrypt.Impl/TripleDes/AArch64/Fb.lean:cfbDecryptis the modes'cfbDecryptBatchedoverbatchCore .encrypt.cfbDecryptBatched(Impl/Modes/AArch64/CfbDec.lean,Proof/Modes/AArch64/CfbDec/Whole.lean) only took 16-byte blocks; it now takes blocks of one or two words. For two-word blocks the code is the same: the emitter changed no Camellia, SEED or SM4 file. TheirFbVerified.leaneach lose one argument at a call site._finalfunctions are unchanged. CFB64 encryption, OFB and CFB8 follow in a PR stacked on this one.vg_triple_des_decrypt_blockhas no caller left, so the emitter no longer writes it. Its Lean code and proofs are still built; removing them is left for a follow-up.No change to
Spec/orTCB/.What it costs
Measurement
Benchmarks run 43731654884, against 831067d (this branch's base), on the Neoverse N2 runner:
triple-des-cbc-decrypt/64triple-des-cbc-decrypt/1024triple-des-cbc-decrypt/16384triple-des-cfb64-decrypt/64triple-des-cfb64-decrypt/1024triple-des-cfb64-decrypt/16384The encryption rows of the two modules are unchanged (within 0.1%). In the audit OpenSSL took 472 µs and 506 µs for these at 16 KiB, so they go from 16× and 15× of it to 0.2×. The benchmarks have no one-block size, so the cost above is not in this table.
Tests
tests/cavp/triple_des_{cbc,cfb}.rs: thelong_messagestests already decrypted 1,000 blocks whole and in pieces of 255, 256 and 257 blocks; they now also take pieces of 127, 128 and 129, around a group's size. They check decryption against encryption; no vector was typed.aarch64-unknown-linux-gnuunderqemu-user, the MMT vectors among them. That is emulation; CI is the first run on an ARM64 CPU.Generated by Claude Code