AES-NI acceleration with mandatory pure-Pascal fallback (package C) - #7
AES-NI acceleration with mandatory pure-Pascal fallback (package C)#7omonien wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ec6b252 to
156e504
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 62dd0eb. Configure here.
156e504 to
c6fb30c
Compare
Port AES-NI key expand/encode/decode from pr-90 into TCipher_Rijndael, gated by X86ASM/X64ASM at compile time and UseAESAsm + CPUID AES + standard 16/24/32 key sizes at runtime. Instance flag FAESAsmActive keeps encode/decode on the schedule actually built by DoInit. - BuildAsmKey128/192/256 (196 renamed to 192), BuildAsmDecodeKey (AESIMC) - AESEncode/AESDecode; Context buffer +$20 for AlignPtr32 - class var UseAESAsm defaulted from TDEC_CPUSupport.AES when ASM compiled - FIPS-197 ECB KATs in TestDECAESNI (PAS and AES-NI must match) - Docs/plans/2026-07-25-aes-ni.md ARM/FPC/PUREPASCAL: pure Pascal only; correctness never requires AES-NI.
Stop writing a 16th AES-256 encode round key at offset 240; place the AESIMC inverse schedule after (FRounds+1) encode keys so AES-256 no longer overwrites the last encode key; point AESDecode at the same offset.
Addressed 2026-07-27 (fork cleanup pass)Linear stack restored (
Tests (D13 Win32 Console): GCM 21/21, ChaCha20Poly1305 12/12, AESNI 7/7. Pre-existing Keccak reds only. |

Package C — AES-NI (optional, cross-platform safe)
Stacked on package B (
package/chacha-poly1305). No PR against MHumm for now (fork only).Policy
X86ASM/X64ASMUseAESAsm and TDEC_CPUSupport.AESand key size 16/24/32TCipher_Rijndael.UseAESAsm := Falsebefore InitOut of scope
Tests
See
Docs/plans/2026-07-25-aes-ni.md.Note
Medium Risk
Touches core block-cipher encrypt/decrypt and key scheduling in
DECCiphers.pas; dual paths must stay bit-identical, though tests and compile/runtime gates reduce exposure.Overview
Adds optional AES-NI for
TCipher_Rijndaeland AES-128/192/256 on x86/x64 builds whereX86ASM/X64ASMis defined, while keeping the existing pure Pascal path as the correctness baseline everywhere else.Runtime control: new class var
TCipher_Rijndael.UseAESAsmdefaults fromTDEC_CPUSupport.AESat unit init; per-instanceFAESAsmActiveis set inDoInitonly whenUseAESAsm, CPU AES-NI, and key size is 16/24/32 bytes—non-standard Rijndael key lengths and togglingUseAESAsmafter init stay on Pascal until re-init. Implementation: large inline assembler block for key expansion (128/192/256), AESIMC decode schedule, andAESEncode/AESDecode;AdditionalBufferSizeincreases by$20for 32-byte-aligned AES-NI schedules (existing context tests updated 480→512).Tests & docs: new
TestDECAESNI(FIPS-197 ECB KATs, PAS vs AES-NI parity) wired into the DUnit suite; plan docDocs/plans/2026-07-25-aes-ni.mddescribes policy and gates.Reviewed by Cursor Bugbot for commit e1df722. Bugbot is set up for automated code reviews on this repo. Configure here.