From 5fd37ab35b3d8e0504812c6bcb36483c10896f4f Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Fri, 10 Jul 2026 05:39:42 +0100 Subject: [PATCH 1/4] Re-architect fused AEAD subsystem into an open accelerated-kernel framework Rename the "fused kernel" framework to "accelerated kernel" so the contract names the capability, not the mechanism (fusion) - a non-fused-but-accelerated kernel can now register without lying. Genuinely-fused impl artifacts keep "Fused" (the SIMD asm, ClpAesFusedAeadSimd, backend). - Relocate Crypto/Modes/Fused -> Crypto/Accelerated (block AEADs aren't "modes"); kernels stay at their original include depth so shared SIMD asm {$I} includes are untouched. - Open registry: one Supports-filtered list + public GetSnapshot; per-mode TryAcquireX wrappers; no enum - external consumers register their own IAcceleratedKernelFactory with zero framework edits. - Contracts IFusedKernel -> IAcceleratedKernel. TAcceleratedKernelFactoryBase.ProviderName is abstract; Priority defaults to Baseline. Priority ladder: Fallback < Baseline < Preferred < UserOverride. - Inert stream seam: IAcceleratedChaCha20Poly1305Kernel + registry hook + resolve-at-Init in ClpChaCha20Poly1305 (nil today -> two-pass, byte-identical). - Tests: RunWithFusedToggle -> RunWithAcceleratedToggle; FusedExternalRegistration Tests -> AcceleratedExternalRegistrationTests. --- .../Delphi/CryptoLib.BenchmarkConsole.dpr | 43 +- .../Delphi.Examples/CryptoLib.Examples.dpr | 43 +- .../Delphi.Tests/CryptoLib.Tests.Mobile.dpr | 45 +- .../Delphi.Tests/CryptoLib.Tests.Mobile.dproj | 45 +- .../Delphi.Tests/CryptoLib.Tests.dpr | 47 +- .../FreePascal.Tests/CryptoLib.Tests.lpi | 4 +- .../FreePascal.Tests/CryptoLib.lpr | 4 +- .../FreePascal.Tests/CryptoLibConsole.lpi | 4 +- .../FreePascal.Tests/CryptoLibConsole.lpr | 4 +- ... AcceleratedExternalRegistrationTests.pas} | 84 +- CryptoLib.Tests/src/Crypto/CcmTests.pas | 18 +- CryptoLib.Tests/src/Crypto/EaxTests.pas | 14 +- CryptoLib.Tests/src/Crypto/GCMTests.pas | 16 +- .../src/Crypto/GcmSivBulkParityTests.pas | 14 +- CryptoLib.Tests/src/Crypto/GcmSivTests.pas | 18 +- CryptoLib.Tests/src/Crypto/OcbTests.pas | 12 +- ...Toggle.pas => AcceleratedKernelToggle.pas} | 20 +- .../Block}/ClpAesNiCbcKernel.pas | 33 +- .../Block}/ClpAesNiCcmKernel.pas | 41 +- .../Block}/ClpAesNiCtrKernel.pas | 31 +- .../Block}/ClpAesNiEaxKernel.pas | 41 +- .../Block}/ClpAesNiGcmKernel.pas | 35 +- .../Block}/ClpAesNiOcbKernel.pas | 43 +- .../Block}/ClpPclmulGcmSivKernel.pas | 35 +- .../Block}/Internal/ClpAesFusedAeadSimd.pas | 0 .../Internal/ClpAesNiFusedX86Backend.pas | 0 .../ClpAcceleratedKernelDefaults.pas} | 6 +- .../ClpAcceleratedKernelFactoryBase.pas | 51 ++ .../ClpAcceleratedKernelRegistry.pas | 657 ++++++++++++++ .../ClpAcceleratedKernelTypes.pas} | 28 +- .../src/Crypto/Modes/ClpCbcBlockCipher.pas | 10 +- .../src/Crypto/Modes/ClpCcmBlockCipher.pas | 18 +- .../src/Crypto/Modes/ClpChaCha20Poly1305.pas | 13 + .../src/Crypto/Modes/ClpEaxBlockCipher.pas | 18 +- .../src/Crypto/Modes/ClpGcmBlockCipher.pas | 28 +- .../src/Crypto/Modes/ClpGcmSivBlockCipher.pas | 16 +- .../src/Crypto/Modes/ClpOcbBlockCipher.pas | 22 +- .../src/Crypto/Modes/ClpSicBlockCipher.pas | 12 +- .../Modes/Fused/ClpFusedKernelRegistry.pas | 850 ------------------ .../Block/ClpIAcceleratedCbcKernel.pas} | 24 +- .../Block/ClpIAcceleratedCcmKernel.pas} | 18 +- .../Block/ClpIAcceleratedCtrKernel.pas} | 26 +- .../Block/ClpIAcceleratedEaxKernel.pas} | 18 +- .../Block/ClpIAcceleratedGcmKernel.pas} | 25 +- .../Block/ClpIAcceleratedGcmSivKernel.pas} | 22 +- .../Block/ClpIAcceleratedOcbKernel.pas} | 20 +- .../ClpIAcceleratedKernelFactory.pas | 51 ++ .../ClpIAcceleratedChaCha20Poly1305Kernel.pas | 83 ++ .../Delphi/CryptoLib4PascalPackage.dpk | 41 +- .../Packages/FPC/CryptoLib4PascalPackage.lpk | 74 +- .../Packages/FPC/CryptoLib4PascalPackage.pas | 14 +- 51 files changed, 1412 insertions(+), 1427 deletions(-) rename CryptoLib.Tests/src/Crypto/{FusedExternalRegistrationTests.pas => AcceleratedExternalRegistrationTests.pas} (71%) rename CryptoLib.Tests/src/Utils/{FusedKernelToggle.pas => AcceleratedKernelToggle.pas} (76%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpAesNiCbcKernel.pas (88%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpAesNiCcmKernel.pas (91%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpAesNiCtrKernel.pas (89%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpAesNiEaxKernel.pas (90%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpAesNiGcmKernel.pas (90%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpAesNiOcbKernel.pas (90%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/ClpPclmulGcmSivKernel.pas (80%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/Internal/ClpAesFusedAeadSimd.pas (100%) rename CryptoLib/src/Crypto/{Modes/Fused => Accelerated/Block}/Internal/ClpAesNiFusedX86Backend.pas (100%) rename CryptoLib/src/Crypto/{Modes/Fused/ClpFusedKernelDefaults.pas => Accelerated/ClpAcceleratedKernelDefaults.pas} (92%) create mode 100644 CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas create mode 100644 CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas rename CryptoLib/src/{Interfaces/Crypto/Modes/Fused/ClpFusedKernelTypes.pas => Crypto/Accelerated/ClpAcceleratedKernelTypes.pas} (60%) delete mode 100644 CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelRegistry.pas rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedCbcKernel.pas => Accelerated/Block/ClpIAcceleratedCbcKernel.pas} (83%) rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedCcmKernel.pas => Accelerated/Block/ClpIAcceleratedCcmKernel.pas} (88%) rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedCtrKernel.pas => Accelerated/Block/ClpIAcceleratedCtrKernel.pas} (82%) rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedEaxKernel.pas => Accelerated/Block/ClpIAcceleratedEaxKernel.pas} (88%) rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedGcmKernel.pas => Accelerated/Block/ClpIAcceleratedGcmKernel.pas} (83%) rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedGcmSivKernel.pas => Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas} (83%) rename CryptoLib/src/Interfaces/Crypto/{Modes/Fused/ClpIFusedOcbKernel.pas => Accelerated/Block/ClpIAcceleratedOcbKernel.pas} (92%) create mode 100644 CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas create mode 100644 CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas diff --git a/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr b/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr index ad1ad510..d2ed6189 100644 --- a/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr +++ b/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr @@ -686,26 +686,31 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpFusedKernelTypes in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpFusedKernelTypes.pas', - ClpIFusedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmKernel.pas', - ClpIFusedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedOcbKernel.pas', - ClpIFusedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCcmKernel.pas', - ClpIFusedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedEaxKernel.pas', - ClpIFusedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmSivKernel.pas', - ClpIFusedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCtrKernel.pas', - ClpIFusedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCbcKernel.pas', - ClpFusedKernelRegistry in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelRegistry.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesNiFusedX86Backend.pas', + ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', + ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + + ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', + ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', + ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', + ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', + ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', + ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', + ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', + ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', + ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + + ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpPclmulGcmSivKernel.pas', - ClpFusedKernelDefaults in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', + ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', diff --git a/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr b/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr index a0be813e..b8fea99b 100644 --- a/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr +++ b/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr @@ -702,26 +702,31 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpFusedKernelTypes in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpFusedKernelTypes.pas', - ClpIFusedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmKernel.pas', - ClpIFusedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedOcbKernel.pas', - ClpIFusedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCcmKernel.pas', - ClpIFusedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedEaxKernel.pas', - ClpIFusedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmSivKernel.pas', - ClpIFusedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCtrKernel.pas', - ClpIFusedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCbcKernel.pas', - ClpFusedKernelRegistry in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelRegistry.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesNiFusedX86Backend.pas', + ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', + ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + + ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', + ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', + ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', + ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', + ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', + ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', + ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', + ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', + ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + + ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpPclmulGcmSivKernel.pas', - ClpFusedKernelDefaults in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', + ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', diff --git a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr index 35178dd1..ab7b4572 100644 --- a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr +++ b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr @@ -683,26 +683,29 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpFusedKernelTypes in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpFusedKernelTypes.pas', - ClpIFusedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmKernel.pas', - ClpIFusedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedOcbKernel.pas', - ClpIFusedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCcmKernel.pas', - ClpIFusedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedEaxKernel.pas', - ClpIFusedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmSivKernel.pas', - ClpIFusedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCtrKernel.pas', - ClpIFusedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCbcKernel.pas', - ClpFusedKernelRegistry in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelRegistry.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesNiFusedX86Backend.pas', + ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', + ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', + ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', + ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', + ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', + ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', + ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', + ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', + ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', + ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpPclmulGcmSivKernel.pas', - ClpFusedKernelDefaults in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', + ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', @@ -814,7 +817,7 @@ uses AeadTestUtilities in '..\src\Crypto\AeadTestUtilities.pas', CertTestUtilities in '..\src\Utils\CertTestUtilities.pas', CryptoTestKeys in '..\src\Utils\CryptoTestKeys.pas', - FusedKernelToggle in '..\src\Utils\FusedKernelToggle.pas', + AcceleratedKernelToggle in '..\src\Utils\AcceleratedKernelToggle.pas', BlowfishTests in '..\src\Crypto\BlowfishTests.pas', RijndaelTests in '..\src\Crypto\RijndaelTests.pas', Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas', @@ -869,7 +872,7 @@ uses BlockCipherTestBase in '..\src\Crypto\BlockCipherTestBase.pas', AesBlockCipherTestBase in '..\src\Crypto\AesBlockCipherTestBase.pas', AesLightTests in '..\src\Crypto\AesLightTests.pas', - FusedExternalRegistrationTests in '..\src\Crypto\FusedExternalRegistrationTests.pas', + AcceleratedExternalRegistrationTests in '..\src\Crypto\AcceleratedExternalRegistrationTests.pas', AesHardwareEngineTests in '..\src\Crypto\AesHardwareEngineTests.pas', IESCipherTests in '..\src\Math\IESCipherTests.pas', AESSICTests in '..\src\Crypto\AESSICTests.pas', diff --git a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj index 9c815f7a..b51bab55 100644 --- a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj +++ b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj @@ -1026,26 +1026,29 @@ - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -1157,7 +1160,7 @@ - + @@ -1208,7 +1211,7 @@ - + diff --git a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr index c7e20866..c0cbe377 100644 --- a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr +++ b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr @@ -702,26 +702,31 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpFusedKernelTypes in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpFusedKernelTypes.pas', - ClpIFusedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmKernel.pas', - ClpIFusedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedOcbKernel.pas', - ClpIFusedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCcmKernel.pas', - ClpIFusedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedEaxKernel.pas', - ClpIFusedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmSivKernel.pas', - ClpIFusedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCtrKernel.pas', - ClpIFusedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Modes\Fused\ClpIFusedCbcKernel.pas', - ClpFusedKernelRegistry in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelRegistry.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Modes\Fused\Internal\ClpAesNiFusedX86Backend.pas', + ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', + ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + + ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', + ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', + ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', + ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', + ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', + ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', + ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', + ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', + ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + + ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpPclmulGcmSivKernel.pas', - ClpFusedKernelDefaults in '..\..\CryptoLib\src\Crypto\Modes\Fused\ClpFusedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', + ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', @@ -833,7 +838,7 @@ uses AeadTestUtilities in '..\src\Crypto\AeadTestUtilities.pas', CertTestUtilities in '..\src\Utils\CertTestUtilities.pas', CryptoTestKeys in '..\src\Utils\CryptoTestKeys.pas', - FusedKernelToggle in '..\src\Utils\FusedKernelToggle.pas', + AcceleratedKernelToggle in '..\src\Utils\AcceleratedKernelToggle.pas', BlowfishTests in '..\src\Crypto\BlowfishTests.pas', RijndaelTests in '..\src\Crypto\RijndaelTests.pas', Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas', @@ -888,7 +893,7 @@ uses BlockCipherTestBase in '..\src\Crypto\BlockCipherTestBase.pas', AesBlockCipherTestBase in '..\src\Crypto\AesBlockCipherTestBase.pas', AesLightTests in '..\src\Crypto\AesLightTests.pas', - FusedExternalRegistrationTests in '..\src\Crypto\FusedExternalRegistrationTests.pas', + AcceleratedExternalRegistrationTests in '..\src\Crypto\AcceleratedExternalRegistrationTests.pas', AesHardwareEngineTests in '..\src\Crypto\AesHardwareEngineTests.pas', IESCipherTests in '..\src\Math\IESCipherTests.pas', AESSICTests in '..\src\Crypto\AESSICTests.pas', diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi index abd65594..6813ab43 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi @@ -610,11 +610,11 @@ - + - + diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr index 16ccb173..7572647e 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr @@ -11,7 +11,7 @@ SecP256R1FieldTests, SecP384R1FieldTests, ECDsa5Tests, ECTests, NamedCurveTests, SignerUtilitiesTests, SecureRandomTests, DigestRandomNumberTests, FixedPointTests, AESTests, AesLightTests, - FusedExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, + AcceleratedExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, SicBulkParityTests, EcbBulkParityTests, CbcBulkParityTests, GcmSivBulkParityTests, BlockCipherTestBase, SpeckBlockCipherTestBase, SpeckLegacyTests, SpeckTests, @@ -47,7 +47,7 @@ BinaryPrimitivesTests, PkcsEncryptedPrivateKeyInfoTests, Pkcs12StoreTests, OpenSslReaderTests, OpenSslWriterTests, X509CertGenTests, X509CertificatePairTests, X509UtilitiesTests, FixedSecureRandom, - ShortenedDigest, CertTestUtilities, FusedKernelToggle, + ShortenedDigest, CertTestUtilities, AcceleratedKernelToggle, CryptoLibTestResourceLoader, CryptoTestKeys, NistSecureRandom, PqcTestSampler, CsvVectorParser, JsonVectorParser, RspTxtVectorParser, RspTxtVectorParserTests, Bip327Vectors, Bip340Vectors, HmacVectors, diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi index a7f291f4..3259ce4e 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi @@ -569,11 +569,11 @@ - + - + diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr index 35b33c6c..483d92a6 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr @@ -12,7 +12,7 @@ SecP256R1FieldTests, SecP384R1FieldTests, ECDsa5Tests, ECTests, NamedCurveTests, SignerUtilitiesTests, SecureRandomTests, DigestRandomNumberTests, FixedPointTests, AESTests, AesLightTests, - FusedExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, + AcceleratedExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, SicBulkParityTests, EcbBulkParityTests, CbcBulkParityTests, GcmSivBulkParityTests, BlockCipherTestBase, SpeckBlockCipherTestBase, SpeckLegacyTests, SpeckTests, @@ -48,7 +48,7 @@ BinaryPrimitivesTests, PkcsEncryptedPrivateKeyInfoTests, Pkcs12StoreTests, OpenSslReaderTests, OpenSslWriterTests, X509CertGenTests, X509CertificatePairTests, X509UtilitiesTests, FixedSecureRandom, - ShortenedDigest, CertTestUtilities, CryptoTestKeys, FusedKernelToggle, + ShortenedDigest, CertTestUtilities, CryptoTestKeys, AcceleratedKernelToggle, CryptoLibTestResourceLoader, NistSecureRandom, CsvVectorParser, JsonVectorParser, RspTxtVectorParser, RspTxtVectorParserTests, Bip327Vectors, Bip340Vectors, HmacVectors, AsymmetricTestVectors, SymmetricBlockVectors, diff --git a/CryptoLib.Tests/src/Crypto/FusedExternalRegistrationTests.pas b/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas similarity index 71% rename from CryptoLib.Tests/src/Crypto/FusedExternalRegistrationTests.pas rename to CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas index 38dad6be..844f318f 100644 --- a/CryptoLib.Tests/src/Crypto/FusedExternalRegistrationTests.pas +++ b/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit FusedExternalRegistrationTests; +unit AcceleratedExternalRegistrationTests; interface @@ -31,9 +31,9 @@ interface TestFramework, {$ENDIF FPC} ClpIBlockCipher, - ClpFusedKernelTypes, - ClpIFusedGcmKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedGcmKernel, + ClpAcceleratedKernelRegistry, ClpCryptoLibTypes; type @@ -41,17 +41,17 @@ interface /// No-op third-party GCM kernel factory used by the external /// registration pin tests. TryCreate always returns False so no /// code path (production or test) actually acquires this factory - /// as a fused kernel; its only observable effect is its presence + /// as an accelerated kernel; its only observable effect is its presence /// in the registry's public diagnostic lists. /// TMockExternalGcmKernelFactory = class sealed(TInterfacedObject, - IFusedGcmKernelFactory) + IAcceleratedGcmKernelFactory) public function ProviderName: String; - function Priority: TFusedKernelPriority; + function Priority: TAcceleratedKernelPriority; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; end; /// @@ -69,7 +69,7 @@ TMockExternalGcmKernelFactory = class sealed(TInterfacedObject, /// Any future change that silently regresses this external /// registration contract will trip a red test here. /// - TTestFusedExternalRegistration = class(TTestCase) + TTestAcceleratedExternalRegistration = class(TTestCase) strict private class function ProvidersContain(const AList: TCryptoLibStringArray; const AName: String): Boolean; static; @@ -112,26 +112,26 @@ function TMockExternalGcmKernelFactory.ProviderName: String; Result := CMockExternalProviderName; end; -function TMockExternalGcmKernelFactory.Priority: TFusedKernelPriority; +function TMockExternalGcmKernelFactory.Priority: TAcceleratedKernelPriority; begin // Fallback is the lowest rank so this mock never intercepts real // GCM acquires on any platform where a genuine in-tree factory is // also registered. The mock's entire purpose is to appear in the // diagnostic list, not to be picked up by TryAcquireGcm. - Result := TFusedKernelPriority.Fallback; + Result := TAcceleratedKernelPriority.Fallback; end; function TMockExternalGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; begin AKernel := nil; Result := False; end; -{ TTestFusedExternalRegistration } +{ TTestAcceleratedExternalRegistration } -class function TTestFusedExternalRegistration.ProvidersContain( +class function TTestAcceleratedExternalRegistration.ProvidersContain( const AList: TCryptoLibStringArray; const AName: String): Boolean; var LIndex: Int32; @@ -145,33 +145,33 @@ class function TTestFusedExternalRegistration.ProvidersContain( end; end; -procedure TTestFusedExternalRegistration.TestExternalRegistrationAddsProvider; +procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationAddsProvider; var - LFactory: IFusedGcmKernelFactory; + LFactory: IAcceleratedGcmKernelFactory; LProviders: TCryptoLibStringArray; begin LFactory := TMockExternalGcmKernelFactory.Create(); - TFusedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); try - LProviders := TFusedKernelRegistry.GetRegisteredGcmProviders; + LProviders := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; CheckTrue(ProvidersContain(LProviders, CMockExternalProviderName), SMockMustBePresent); finally - TFusedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); end; end; -procedure TTestFusedExternalRegistration.TestExternalRegistrationIsStrictlyAdditive; +procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationIsStrictlyAdditive; var - LFactory: IFusedGcmKernelFactory; + LFactory: IAcceleratedGcmKernelFactory; LBaseline, LAfter: TCryptoLibStringArray; LIndex: Int32; begin - LBaseline := TFusedKernelRegistry.GetRegisteredGcmProviders; + LBaseline := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; LFactory := TMockExternalGcmKernelFactory.Create(); - TFusedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); try - LAfter := TFusedKernelRegistry.GetRegisteredGcmProviders; + LAfter := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; CheckEquals(System.Length(LBaseline) + 1, System.Length(LAfter), SCountMustGrowByOne); // Every baseline name must survive the registration. @@ -179,22 +179,22 @@ procedure TTestFusedExternalRegistration.TestExternalRegistrationIsStrictlyAddit CheckTrue(ProvidersContain(LAfter, LBaseline[LIndex]), SDefaultsMustSurvive); finally - TFusedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); end; end; -procedure TTestFusedExternalRegistration.TestExternalUnregistrationRestoresPriorList; +procedure TTestAcceleratedExternalRegistration.TestExternalUnregistrationRestoresPriorList; var - LFactory: IFusedGcmKernelFactory; + LFactory: IAcceleratedGcmKernelFactory; LBaseline, LAfterUnregister: TCryptoLibStringArray; LIndex: Int32; begin - LBaseline := TFusedKernelRegistry.GetRegisteredGcmProviders; + LBaseline := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; LFactory := TMockExternalGcmKernelFactory.Create(); - TFusedKernelRegistry.RegisterGcmFactory(LFactory); - TFusedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); - LAfterUnregister := TFusedKernelRegistry.GetRegisteredGcmProviders; + LAfterUnregister := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; CheckEquals(System.Length(LBaseline), System.Length(LAfterUnregister), SCountMustRestoreBaseline); CheckFalse(ProvidersContain(LAfterUnregister, CMockExternalProviderName), @@ -204,30 +204,30 @@ procedure TTestFusedExternalRegistration.TestExternalUnregistrationRestoresPrior SDefaultsMustSurvive); end; -procedure TTestFusedExternalRegistration.TestDuplicateExternalRegistrationIsIgnored; +procedure TTestAcceleratedExternalRegistration.TestDuplicateExternalRegistrationIsIgnored; var - LFactory: IFusedGcmKernelFactory; + LFactory: IAcceleratedGcmKernelFactory; LBaseline, LAfter: TCryptoLibStringArray; begin - LBaseline := TFusedKernelRegistry.GetRegisteredGcmProviders; + LBaseline := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; LFactory := TMockExternalGcmKernelFactory.Create(); - TFusedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); try - TFusedKernelRegistry.RegisterGcmFactory(LFactory); - LAfter := TFusedKernelRegistry.GetRegisteredGcmProviders; + TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); + LAfter := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; CheckEquals(System.Length(LBaseline) + 1, System.Length(LAfter), SDuplicateMustBeIgnored); finally - TFusedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); end; end; initialization {$IFDEF FPC} - RegisterTest(TTestFusedExternalRegistration); + RegisterTest(TTestAcceleratedExternalRegistration); {$ELSE} - RegisterTest(TTestFusedExternalRegistration.Suite); + RegisterTest(TTestAcceleratedExternalRegistration.Suite); {$ENDIF FPC} end. diff --git a/CryptoLib.Tests/src/Crypto/CcmTests.pas b/CryptoLib.Tests/src/Crypto/CcmTests.pas index 678e2776..a24de76e 100644 --- a/CryptoLib.Tests/src/Crypto/CcmTests.pas +++ b/CryptoLib.Tests/src/Crypto/CcmTests.pas @@ -49,7 +49,7 @@ interface ClpCryptoLibTypes, ClpIAeadCipher, AeadTestUtilities, - FusedKernelToggle, + AcceleratedKernelToggle, CryptoLibTestBase; type @@ -81,7 +81,7 @@ TTestCcm = class(TCryptoLibAlgorithmTestCase) procedure SetUp; override; procedure TearDown; override; - // Workers run twice via RunWithFusedToggle (fused on / off). + // Workers run twice via RunWithAcceleratedToggle (accelerated on / off). procedure DoTestNistVectorsAndLongData; procedure DoTestCcmIvParameters; procedure DoTestOffsets; @@ -505,22 +505,22 @@ procedure TTestCcm.DoTestRandomised; procedure TTestCcm.TestNistVectorsAndLongData; begin - RunWithFusedToggle(DoTestNistVectorsAndLongData); + RunWithAcceleratedToggle(DoTestNistVectorsAndLongData); end; procedure TTestCcm.TestCcmIvParameters; begin - RunWithFusedToggle(DoTestCcmIvParameters); + RunWithAcceleratedToggle(DoTestCcmIvParameters); end; procedure TTestCcm.TestOffsets; begin - RunWithFusedToggle(DoTestOffsets); + RunWithAcceleratedToggle(DoTestOffsets); end; procedure TTestCcm.TestRandomised; begin - RunWithFusedToggle(DoTestRandomised); + RunWithAcceleratedToggle(DoTestRandomised); end; procedure TTestCcm.TestExceptions; @@ -679,7 +679,7 @@ procedure TTestCcm.DoTestNoUnverifiedPlaintextOnFailure; procedure TTestCcm.TestNoUnverifiedPlaintextOnFailure; begin - RunWithFusedToggle(DoTestNoUnverifiedPlaintextOnFailure); + RunWithAcceleratedToggle(DoTestNoUnverifiedPlaintextOnFailure); end; procedure TTestCcm.DoTestInvalidTagLength; @@ -751,12 +751,12 @@ procedure TTestCcm.DoTestValidTagLength; procedure TTestCcm.TestInvalidTagLength; begin - RunWithFusedToggle(DoTestInvalidTagLength); + RunWithAcceleratedToggle(DoTestInvalidTagLength); end; procedure TTestCcm.TestValidTagLength; begin - RunWithFusedToggle(DoTestValidTagLength); + RunWithAcceleratedToggle(DoTestValidTagLength); end; initialization diff --git a/CryptoLib.Tests/src/Crypto/EaxTests.pas b/CryptoLib.Tests/src/Crypto/EaxTests.pas index 7bdcd2b3..84054bce 100644 --- a/CryptoLib.Tests/src/Crypto/EaxTests.pas +++ b/CryptoLib.Tests/src/Crypto/EaxTests.pas @@ -48,7 +48,7 @@ interface ClpConverters, ClpIAeadCipher, AeadTestUtilities, - FusedKernelToggle, + AcceleratedKernelToggle, CryptoLibTestBase; type @@ -91,7 +91,7 @@ TTestEax = class(TCryptoLibAlgorithmTestCase) procedure SetUp; override; procedure TearDown; override; - // Workers run twice via RunWithFusedToggle (fused on / off). + // Workers run twice via RunWithAcceleratedToggle (accelerated on / off). procedure DoTestVectors; procedure DoTestIvParameters; procedure DoTestExceptionsAndRandomised; @@ -566,27 +566,27 @@ procedure TTestEax.DoTestValidTagLength; procedure TTestEax.TestVectors; begin - RunWithFusedToggle(DoTestVectors); + RunWithAcceleratedToggle(DoTestVectors); end; procedure TTestEax.TestIvParameters; begin - RunWithFusedToggle(DoTestIvParameters); + RunWithAcceleratedToggle(DoTestIvParameters); end; procedure TTestEax.TestExceptionsAndRandomised; begin - RunWithFusedToggle(DoTestExceptionsAndRandomised); + RunWithAcceleratedToggle(DoTestExceptionsAndRandomised); end; procedure TTestEax.TestInvalidTagLength; begin - RunWithFusedToggle(DoTestInvalidTagLength); + RunWithAcceleratedToggle(DoTestInvalidTagLength); end; procedure TTestEax.TestValidTagLength; begin - RunWithFusedToggle(DoTestValidTagLength); + RunWithAcceleratedToggle(DoTestValidTagLength); end; initialization diff --git a/CryptoLib.Tests/src/Crypto/GCMTests.pas b/CryptoLib.Tests/src/Crypto/GCMTests.pas index 1c023c6a..c473c132 100644 --- a/CryptoLib.Tests/src/Crypto/GCMTests.pas +++ b/CryptoLib.Tests/src/Crypto/GCMTests.pas @@ -51,7 +51,7 @@ interface ClpDateTimeUtilities, ClpConverters, ClpCryptoLibTypes, - FusedKernelToggle, + AcceleratedKernelToggle, AeadTestUtilities, CryptoLibTestBase, SymmetricBlockVectors; @@ -81,7 +81,7 @@ TTestGcm = class(TCryptoLibAlgorithmTestCase) procedure DoTestExceptions; function NextInt32(const ARandom: ISecureRandom; AN: Int32): Int32; - // Workers run twice via RunWithFusedToggle (fused on / off). + // Workers run twice via RunWithAcceleratedToggle (accelerated on / off). procedure DoTestRfcVectors; procedure DoTestRandomised; procedure DoTestOutputSizes; @@ -577,32 +577,32 @@ procedure TTestGcm.DoTestExceptions; procedure TTestGcm.TestRfcVectors; begin - RunWithFusedToggle(DoTestRfcVectors); + RunWithAcceleratedToggle(DoTestRfcVectors); end; procedure TTestGcm.TestRandomised; begin - RunWithFusedToggle(DoTestRandomised); + RunWithAcceleratedToggle(DoTestRandomised); end; procedure TTestGcm.TestOutputSizes; begin - RunWithFusedToggle(DoTestOutputSizes); + RunWithAcceleratedToggle(DoTestOutputSizes); end; procedure TTestGcm.TestExceptions; begin - RunWithFusedToggle(DoTestExceptionsWrapper); + RunWithAcceleratedToggle(DoTestExceptionsWrapper); end; procedure TTestGcm.TestFourBlockFusedGcmPath; begin - RunWithFusedToggle(DoTestFourBlockFusedGcmPath); + RunWithAcceleratedToggle(DoTestFourBlockFusedGcmPath); end; procedure TTestGcm.TestEightBlockFusedGcmPath; begin - RunWithFusedToggle(DoTestEightBlockFusedGcmPath); + RunWithAcceleratedToggle(DoTestEightBlockFusedGcmPath); end; procedure TTestGcm.DoTestRfcVectors; diff --git a/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas b/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas index 06536473..596dfd3a 100644 --- a/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas +++ b/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas @@ -34,7 +34,7 @@ interface ClpKeyParameter, ClpIKeyParameter, ClpICipherParameters, - ClpFusedKernelRegistry, + ClpAcceleratedKernelRegistry, ClpSecureRandom, ClpISecureRandom, ClpConverters, @@ -72,10 +72,10 @@ function TTestGcmSivBulkParity.GcmSivEncrypt(const AKey, ANonce, AAad, LSaved: Boolean; LLen: Int32; begin - LSaved := TFusedKernelGate.ForceDisabled; + LSaved := TAcceleratedKernelGate.ForceDisabled; // The fused POLYVAL kernel is resolved during Init (DeriveKeys); the gate must // therefore be set BEFORE Init to select the fused or scalar path. - TFusedKernelGate.ForceDisabled := not AUseFused; + TAcceleratedKernelGate.ForceDisabled := not AUseFused; try LCipher := TGcmSivBlockCipher.Create() as IGcmSivBlockCipher; LCipher.Init(True, TAeadParameters.Create(TKeyParameter.Create(AKey) @@ -86,7 +86,7 @@ function TTestGcmSivBulkParity.GcmSivEncrypt(const AKey, ANonce, AAad, if LLen <> System.Length(Result) then System.SetLength(Result, LLen); finally - TFusedKernelGate.ForceDisabled := LSaved; + TAcceleratedKernelGate.ForceDisabled := LSaved; end; end; @@ -97,8 +97,8 @@ function TTestGcmSivBulkParity.GcmSivDecrypt(const AKey, ANonce, AAad, LSaved: Boolean; LLen: Int32; begin - LSaved := TFusedKernelGate.ForceDisabled; - TFusedKernelGate.ForceDisabled := not AUseFused; + LSaved := TAcceleratedKernelGate.ForceDisabled; + TAcceleratedKernelGate.ForceDisabled := not AUseFused; try LCipher := TGcmSivBlockCipher.Create() as IGcmSivBlockCipher; LCipher.Init(False, TAeadParameters.Create(TKeyParameter.Create(AKey) @@ -109,7 +109,7 @@ function TTestGcmSivBulkParity.GcmSivDecrypt(const AKey, ANonce, AAad, if LLen <> System.Length(Result) then System.SetLength(Result, LLen); finally - TFusedKernelGate.ForceDisabled := LSaved; + TAcceleratedKernelGate.ForceDisabled := LSaved; end; end; diff --git a/CryptoLib.Tests/src/Crypto/GcmSivTests.pas b/CryptoLib.Tests/src/Crypto/GcmSivTests.pas index 86253985..9ea6bfb0 100644 --- a/CryptoLib.Tests/src/Crypto/GcmSivTests.pas +++ b/CryptoLib.Tests/src/Crypto/GcmSivTests.pas @@ -41,7 +41,7 @@ interface ClpSecureRandom, ClpISecureRandom, ClpCryptoLibTypes, - FusedKernelToggle, + AcceleratedKernelToggle, CryptoLibTestBase, SymmetricBlockVectors; @@ -295,42 +295,42 @@ procedure TTestGcmSiv.DoTestRandomised; procedure TTestGcmSiv.TestAesGcmSiv128Set1; begin - RunWithFusedToggle(DoTestAesGcmSiv128Set1); + RunWithAcceleratedToggle(DoTestAesGcmSiv128Set1); end; procedure TTestGcmSiv.TestAesGcmSiv128Set2; begin - RunWithFusedToggle(DoTestAesGcmSiv128Set2); + RunWithAcceleratedToggle(DoTestAesGcmSiv128Set2); end; procedure TTestGcmSiv.TestAesGcmSiv128Set3; begin - RunWithFusedToggle(DoTestAesGcmSiv128Set3); + RunWithAcceleratedToggle(DoTestAesGcmSiv128Set3); end; procedure TTestGcmSiv.TestAesGcmSiv256Set1; begin - RunWithFusedToggle(DoTestAesGcmSiv256Set1); + RunWithAcceleratedToggle(DoTestAesGcmSiv256Set1); end; procedure TTestGcmSiv.TestAesGcmSiv256Set2; begin - RunWithFusedToggle(DoTestAesGcmSiv256Set2); + RunWithAcceleratedToggle(DoTestAesGcmSiv256Set2); end; procedure TTestGcmSiv.TestAesGcmSiv256Set3; begin - RunWithFusedToggle(DoTestAesGcmSiv256Set3); + RunWithAcceleratedToggle(DoTestAesGcmSiv256Set3); end; procedure TTestGcmSiv.TestAesGcmSiv256Set4; begin - RunWithFusedToggle(DoTestAesGcmSiv256Set4); + RunWithAcceleratedToggle(DoTestAesGcmSiv256Set4); end; procedure TTestGcmSiv.TestRandomised; begin - RunWithFusedToggle(DoTestRandomised); + RunWithAcceleratedToggle(DoTestRandomised); end; initialization diff --git a/CryptoLib.Tests/src/Crypto/OcbTests.pas b/CryptoLib.Tests/src/Crypto/OcbTests.pas index ea97b285..39f837d8 100644 --- a/CryptoLib.Tests/src/Crypto/OcbTests.pas +++ b/CryptoLib.Tests/src/Crypto/OcbTests.pas @@ -44,7 +44,7 @@ interface ClpCryptoLibTypes, ClpAesUtilities, ClpOcbBlockCipher, - FusedKernelToggle, + AcceleratedKernelToggle, CryptoLibTestBase, AeadTestUtilities; @@ -92,7 +92,7 @@ TTestOcb = class(TCryptoLibAlgorithmTestCase) procedure SetUp; override; procedure TearDown; override; - // Workers run twice via RunWithFusedToggle (fused on / off) so any + // Workers run twice via RunWithAcceleratedToggle (accelerated on / off) so any // drift between the two code paths surfaces as a test failure. procedure DoTestRfcVectors128; procedure DoTestRfcVectors96; @@ -581,22 +581,22 @@ procedure TTestOcb.TearDown; procedure TTestOcb.TestRfcVectors128; begin - RunWithFusedToggle(DoTestRfcVectors128); + RunWithAcceleratedToggle(DoTestRfcVectors128); end; procedure TTestOcb.TestRfcVectors96; begin - RunWithFusedToggle(DoTestRfcVectors96); + RunWithAcceleratedToggle(DoTestRfcVectors96); end; procedure TTestOcb.TestOcbLongForm; begin - RunWithFusedToggle(DoTestOcbLongForm); + RunWithAcceleratedToggle(DoTestOcbLongForm); end; procedure TTestOcb.TestRandomised; begin - RunWithFusedToggle(DoTestRandomised); + RunWithAcceleratedToggle(DoTestRandomised); end; procedure TTestOcb.DoTestRfcVectors128; diff --git a/CryptoLib.Tests/src/Utils/FusedKernelToggle.pas b/CryptoLib.Tests/src/Utils/AcceleratedKernelToggle.pas similarity index 76% rename from CryptoLib.Tests/src/Utils/FusedKernelToggle.pas rename to CryptoLib.Tests/src/Utils/AcceleratedKernelToggle.pas index ce7b5152..7a81de80 100644 --- a/CryptoLib.Tests/src/Utils/FusedKernelToggle.pas +++ b/CryptoLib.Tests/src/Utils/AcceleratedKernelToggle.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit FusedKernelToggle; +unit AcceleratedKernelToggle; interface @@ -24,36 +24,36 @@ interface uses SysUtils, - ClpFusedKernelRegistry; + ClpAcceleratedKernelRegistry; type - TFusedToggleTestProc = procedure of object; + TAcceleratedToggleTestProc = procedure of object; /// -/// Runs AProc twice: once with fused kernels enabled (production +/// Runs AProc twice: once with accelerated kernels enabled (production /// default) and once with them forcibly disabled so the scalar / /// generic-bulk fallbacks are exercised. Both passes must produce /// byte-identical outputs. The previous kill-switch state is saved /// and restored on return (including on exceptions). /// -procedure RunWithFusedToggle(AProc: TFusedToggleTestProc); +procedure RunWithAcceleratedToggle(AProc: TAcceleratedToggleTestProc); implementation -procedure RunWithFusedToggle(AProc: TFusedToggleTestProc); +procedure RunWithAcceleratedToggle(AProc: TAcceleratedToggleTestProc); var LSaved: Boolean; begin if not Assigned(AProc) then Exit; - LSaved := TFusedKernelGate.ForceDisabled; + LSaved := TAcceleratedKernelGate.ForceDisabled; try - TFusedKernelGate.ForceDisabled := False; + TAcceleratedKernelGate.ForceDisabled := False; AProc(); - TFusedKernelGate.ForceDisabled := True; + TAcceleratedKernelGate.ForceDisabled := True; AProc(); finally - TFusedKernelGate.ForceDisabled := LSaved; + TAcceleratedKernelGate.ForceDisabled := LSaved; end; end; diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCbcKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas similarity index 88% rename from CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCbcKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas index fb341932..370fe748 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCbcKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas @@ -24,14 +24,15 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpFusedKernelTypes, - ClpIFusedCbcKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedCbcKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IFusedCbcKernel: the serial CBC-encrypt chain + /// AES-NI implementation of IAcceleratedCbcKernel: the serial CBC-encrypt chain /// C_i = E_K(P_i xor C_{i-1}) applied over a whole run in one call, with the /// chaining value held in a register between blocks (kernel body in /// Include\Simd\Aes\Cbc). Reuses the shared 1-wide AES round chain @@ -40,7 +41,7 @@ interface /// unavailable the factory returns nil and TCbcBlockCipher keeps its existing /// per-block bulk path. /// - TAesNiCbcKernel = class sealed(TInterfacedObject, IFusedCbcKernel) + TAesNiCbcKernel = class sealed(TInterfacedObject, IAcceleratedCbcKernel) strict private // FEngine is retained so the round-key buffer FKeys points into stays alive // for the kernel's lifetime. @@ -54,13 +55,12 @@ TAesNiCbcKernel = class sealed(TInterfacedObject, IFusedCbcKernel) ABlockCount: NativeInt); end; - TAesNiCbcKernelFactory = class sealed(TInterfacedObject, IFusedCbcKernelFactory) + TAesNiCbcKernelFactory = class sealed(TAcceleratedKernelFactoryBase, IAcceleratedCbcKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCbcKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedCbcKernel): Boolean; end; implementation @@ -167,13 +167,8 @@ function TAesNiCbcKernelFactory.ProviderName: String; Result := 'AES-NI'; end; -function TAesNiCbcKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedCbcKernel): Boolean; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCbcKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -181,7 +176,7 @@ function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; begin AKernel := nil; Result := False; - if ADirection <> TFusedModeDirection.Encrypt then + if ADirection <> TAcceleratedKernelDirection.Encrypt then Exit; // only encrypt is implemented; decrypt not yet supported try {$IFDEF CRYPTOLIB_X86_SIMD} @@ -201,7 +196,7 @@ function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterCbcFactory( - TAesNiCbcKernelFactory.Create() as IFusedCbcKernelFactory); + TAcceleratedKernelRegistry.RegisterCbcFactory( + TAesNiCbcKernelFactory.Create() as IAcceleratedCbcKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCcmKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas similarity index 91% rename from CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCcmKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas index 3cff60f4..4c7c6830 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCcmKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas @@ -24,15 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpFusedKernelTypes, - ClpIFusedCcmKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedCcmKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IFusedCcmKernel. + /// AES-NI implementation of IAcceleratedCcmKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -42,7 +43,7 @@ interface /// The kernel loops internally over ABlockCount body blocks; the /// mode invokes ProcessBody once per Init cycle. /// - TAesNiCcmKernel = class sealed(TInterfacedObject, IFusedCcmKernel) + TAesNiCcmKernel = class sealed(TInterfacedObject, IAcceleratedCcmKernel) strict private const FUSED_CCM_MIN_BLOCKS = 1; @@ -57,25 +58,24 @@ TAesNiCcmKernel = class sealed(TInterfacedObject, IFusedCcmKernel) // multi-block SIMD loop. FEngine: IAesEngineX86; FRounds: Int32; - FDirection: TFusedModeDirection; + FDirection: TAcceleratedKernelDirection; FMask: Pointer; FIncrement: Pointer; public constructor Create(const AEngine: IAesEngineX86; ARounds: Int32; - ADirection: TFusedModeDirection; AMask, AIncrement: Pointer); + ADirection: TAcceleratedKernelDirection; AMask, AIncrement: Pointer); function MinimumBlockCount: Int32; procedure ProcessBody(AInPtr, AOutPtr, ACtrState, ACbcMacState: Pointer; ABlockCount: Int32); end; - TAesNiCcmKernelFactory = class sealed(TInterfacedObject, - IFusedCcmKernelFactory) + TAesNiCcmKernelFactory = class sealed(TAcceleratedKernelFactoryBase, + IAcceleratedCcmKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedCcmKernel): Boolean; end; implementation @@ -200,7 +200,7 @@ procedure CcmFusedCtrCbcMacDec256(PCtx: Pointer); { TAesNiCcmKernel } constructor TAesNiCcmKernel.Create(const AEngine: IAesEngineX86; - ARounds: Int32; ADirection: TFusedModeDirection; + ARounds: Int32; ADirection: TAcceleratedKernelDirection; AMask, AIncrement: Pointer); begin inherited Create; @@ -245,7 +245,7 @@ procedure TAesNiCcmKernel.ProcessBody(AInPtr, AOutPtr, ACtrState, LCtx.PMask := FMask; LCtx.PIncrement := FIncrement; LCtx.BlockCount := NativeUInt(ABlockCount); - if FDirection = TFusedModeDirection.Encrypt then + if FDirection = TAcceleratedKernelDirection.Encrypt then begin case FRounds of 10: CcmFusedCtrCbcMacEnc128(@LCtx); @@ -273,13 +273,8 @@ function TAesNiCcmKernelFactory.ProviderName: String; Result := 'AES-NI'; end; -function TAesNiCcmKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TAesNiCcmKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedCcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCcmKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -312,7 +307,7 @@ function TAesNiCcmKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterCcmFactory( - TAesNiCcmKernelFactory.Create() as IFusedCcmKernelFactory); + TAcceleratedKernelRegistry.RegisterCcmFactory( + TAesNiCcmKernelFactory.Create() as IAcceleratedCcmKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCtrKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas similarity index 89% rename from CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCtrKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas index 1321a903..56462b9f 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiCtrKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas @@ -24,14 +24,15 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpFusedKernelTypes, - ClpIFusedCtrKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedCtrKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IFusedCtrKernel: the fused counter-mode + /// AES-NI implementation of IAcceleratedCtrKernel: the fused counter-mode /// keystream + XOR body used by TSicBlockCipher's bulk path. The MAC-free /// base of the fused-kernel family; reuses the plain 8-wide AES round chain /// (AesNiEightRoundsOnly) since CTR has no extra per-block state. @@ -39,7 +40,7 @@ interface /// both arms gated collectively by CRYPTOLIB_X86_SIMD. When unavailable the /// factory returns nil and TSicBlockCipher keeps its existing bulk path. /// - TAesNiCtrKernel = class sealed(TInterfacedObject, IFusedCtrKernel) + TAesNiCtrKernel = class sealed(TInterfacedObject, IAcceleratedCtrKernel) strict private const FUSED_CTR_BATCH_BLOCKS = 8; @@ -57,13 +58,12 @@ TAesNiCtrKernel = class sealed(TInterfacedObject, IFusedCtrKernel) ABlockCount: NativeInt); end; - TAesNiCtrKernelFactory = class sealed(TInterfacedObject, IFusedCtrKernelFactory) + TAesNiCtrKernelFactory = class sealed(TAcceleratedKernelFactoryBase, IAcceleratedCtrKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCtrKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedCtrKernel): Boolean; end; implementation @@ -173,13 +173,8 @@ function TAesNiCtrKernelFactory.ProviderName: String; Result := 'AES-NI'; end; -function TAesNiCtrKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TAesNiCtrKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedCtrKernel): Boolean; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCtrKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -205,7 +200,7 @@ function TAesNiCtrKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterCtrFactory( - TAesNiCtrKernelFactory.Create() as IFusedCtrKernelFactory); + TAcceleratedKernelRegistry.RegisterCtrFactory( + TAesNiCtrKernelFactory.Create() as IAcceleratedCtrKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiEaxKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas similarity index 90% rename from CryptoLib/src/Crypto/Modes/Fused/ClpAesNiEaxKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas index 8b2bed9f..9c207158 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiEaxKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas @@ -24,15 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpFusedKernelTypes, - ClpIFusedEaxKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedEaxKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IFusedEaxKernel. + /// AES-NI implementation of IAcceleratedEaxKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -46,7 +47,7 @@ interface /// ships a fused EAX kernel (OpenSSL, BoringSSL, AWS-LC, Botan all /// scalar). /// - TAesNiEaxKernel = class sealed(TInterfacedObject, IFusedEaxKernel) + TAesNiEaxKernel = class sealed(TInterfacedObject, IAcceleratedEaxKernel) strict private const FUSED_EAX_MIN_BLOCKS = 2; @@ -54,25 +55,24 @@ TAesNiEaxKernel = class sealed(TInterfacedObject, IFusedEaxKernel) FEngine: IAesEngineX86; FKeys: Pointer; FRounds: Int32; - FDirection: TFusedModeDirection; + FDirection: TAcceleratedKernelDirection; FMask: Pointer; FIncrement: Pointer; public constructor Create(const AEngine: IAesEngineX86; AKeys: Pointer; - ARounds: Int32; ADirection: TFusedModeDirection; AMask, AIncrement: Pointer); + ARounds: Int32; ADirection: TAcceleratedKernelDirection; AMask, AIncrement: Pointer); function MinimumBlockCount: Int32; procedure ProcessBody(AInPtr, AOutPtr, ACtrState, AOmacState: Pointer; ABlockCount: Int32); end; - TAesNiEaxKernelFactory = class sealed(TInterfacedObject, - IFusedEaxKernelFactory) + TAesNiEaxKernelFactory = class sealed(TAcceleratedKernelFactoryBase, + IAcceleratedEaxKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedEaxKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedEaxKernel): Boolean; end; implementation @@ -201,7 +201,7 @@ procedure EaxFusedCtrOmacDec256(PCtx: Pointer); { TAesNiEaxKernel } constructor TAesNiEaxKernel.Create(const AEngine: IAesEngineX86; - AKeys: Pointer; ARounds: Int32; ADirection: TFusedModeDirection; + AKeys: Pointer; ARounds: Int32; ADirection: TAcceleratedKernelDirection; AMask, AIncrement: Pointer); begin inherited Create; @@ -236,7 +236,7 @@ procedure TAesNiEaxKernel.ProcessBody(AInPtr, AOutPtr, ACtrState, LCtx.PMask := FMask; LCtx.PIncrement := FIncrement; LCtx.BlockCount := NativeUInt(ABlockCount); - if FDirection = TFusedModeDirection.Encrypt then + if FDirection = TAcceleratedKernelDirection.Encrypt then begin case FRounds of 10: EaxFusedCtrOmacEnc128(@LCtx); @@ -264,13 +264,8 @@ function TAesNiEaxKernelFactory.ProviderName: String; Result := 'AES-NI'; end; -function TAesNiEaxKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TAesNiEaxKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedEaxKernel): Boolean; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedEaxKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -299,7 +294,7 @@ function TAesNiEaxKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterEaxFactory( - TAesNiEaxKernelFactory.Create() as IFusedEaxKernelFactory); + TAcceleratedKernelRegistry.RegisterEaxFactory( + TAesNiEaxKernelFactory.Create() as IAcceleratedEaxKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiGcmKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas similarity index 90% rename from CryptoLib/src/Crypto/Modes/Fused/ClpAesNiGcmKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas index d2124fd1..1c0456b9 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiGcmKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas @@ -24,15 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpFusedKernelTypes, - ClpIFusedGcmKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedGcmKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI + PCLMULQDQ implementation of IFusedGcmKernel. + /// AES-NI + PCLMULQDQ implementation of IAcceleratedGcmKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -44,7 +45,7 @@ interface /// pipeline internally; the mode primes the first batch and drains the /// last. /// - TAesNiGcmKernel = class sealed(TInterfacedObject, IFusedGcmKernel) + TAesNiGcmKernel = class sealed(TInterfacedObject, IAcceleratedGcmKernel) strict private const FUSED_GCM_MIN_BLOCKS = 8; @@ -63,14 +64,13 @@ TAesNiGcmKernel = class sealed(TInterfacedObject, IFusedGcmKernel) AForEncrypt: Boolean): UInt32; end; - TAesNiGcmKernelFactory = class sealed(TInterfacedObject, - IFusedGcmKernelFactory) + TAesNiGcmKernelFactory = class sealed(TAcceleratedKernelFactoryBase, + IAcceleratedGcmKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; end; implementation @@ -204,14 +204,9 @@ function TAesNiGcmKernelFactory.ProviderName: String; Result := 'AES-NI'; end; -function TAesNiGcmKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TAesNiGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -242,7 +237,7 @@ function TAesNiGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterGcmFactory( - TAesNiGcmKernelFactory.Create() as IFusedGcmKernelFactory); + TAcceleratedKernelRegistry.RegisterGcmFactory( + TAesNiGcmKernelFactory.Create() as IAcceleratedGcmKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiOcbKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas similarity index 90% rename from CryptoLib/src/Crypto/Modes/Fused/ClpAesNiOcbKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas index e49d2db8..44afac6e 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpAesNiOcbKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas @@ -24,15 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpFusedKernelTypes, - ClpIFusedOcbKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedOcbKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IFusedOcbKernel. + /// AES-NI implementation of IAcceleratedOcbKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -44,7 +45,7 @@ interface /// 4 blocks on i386) so the mode layer can amortise call-site /// overhead across large batches. /// - TAesNiOcbKernel = class sealed(TInterfacedObject, IFusedOcbKernel) + TAesNiOcbKernel = class sealed(TInterfacedObject, IAcceleratedOcbKernel) strict private const {$IFDEF CRYPTOLIB_X86_64_ASM} @@ -56,24 +57,23 @@ TAesNiOcbKernel = class sealed(TInterfacedObject, IFusedOcbKernel) FEngine: IAesEngineX86; FKeys: Pointer; FRounds: Int32; - FDirection: TFusedModeDirection; + FDirection: TAcceleratedKernelDirection; public constructor Create(const AEngine: IAesEngineX86; AKeys: Pointer; - ARounds: Int32; ADirection: TFusedModeDirection); + ARounds: Int32; ADirection: TAcceleratedKernelDirection); function MinimumBlockCount: Int32; procedure ProcessBlocks(AInPtr, AOutPtr, AOffsetPtr, AChecksumPtr, ALTablePtr, ABlock0Ptr: Pointer; ABlockCount: Int32; AStartBlockCount: UInt64); end; - TAesNiOcbKernelFactory = class sealed(TInterfacedObject, - IFusedOcbKernelFactory) + TAesNiOcbKernelFactory = class sealed(TAcceleratedKernelFactoryBase, + IAcceleratedOcbKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedOcbKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedOcbKernel): Boolean; end; implementation @@ -196,7 +196,7 @@ procedure OcbFusedDecWide256(PCtx: Pointer); { TAesNiOcbKernel } constructor TAesNiOcbKernel.Create(const AEngine: IAesEngineX86; - AKeys: Pointer; ARounds: Int32; ADirection: TFusedModeDirection); + AKeys: Pointer; ARounds: Int32; ADirection: TAcceleratedKernelDirection); begin inherited Create; FEngine := AEngine; @@ -231,7 +231,7 @@ procedure TAesNiOcbKernel.ProcessBlocks(AInPtr, AOutPtr, AOffsetPtr, LCtx.Block0Ptr := ABlock0Ptr; LCtx.BlockCount := NativeUInt(ABlockCount); LCtx.StartBlockCount := AStartBlockCount; - if FDirection = TFusedModeDirection.Encrypt then + if FDirection = TAcceleratedKernelDirection.Encrypt then begin case FRounds of 10: OcbFusedEncWide128(@LCtx); @@ -259,13 +259,8 @@ function TAesNiOcbKernelFactory.ProviderName: String; Result := 'AES-NI'; end; -function TAesNiOcbKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedOcbKernel): Boolean; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedOcbKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -279,7 +274,7 @@ function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; Exit; if not TAesNiFusedX86Backend.TryResolveEngine(ACipher, LEngine) then Exit; - if ADirection = TFusedModeDirection.Encrypt then + if ADirection = TAcceleratedKernelDirection.Encrypt then LHasSchedule := LEngine.TryGetEncKeysPtr(LKeys, LRounds) else LHasSchedule := LEngine.TryGetDecKeysPtr(LKeys, LRounds); @@ -296,7 +291,7 @@ function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterOcbFactory( - TAesNiOcbKernelFactory.Create() as IFusedOcbKernelFactory); + TAcceleratedKernelRegistry.RegisterOcbFactory( + TAesNiOcbKernelFactory.Create() as IAcceleratedOcbKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpPclmulGcmSivKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas similarity index 80% rename from CryptoLib/src/Crypto/Modes/Fused/ClpPclmulGcmSivKernel.pas rename to CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas index 5c65e931..637bfffd 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpPclmulGcmSivKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas @@ -23,20 +23,21 @@ interface uses SysUtils, ClpIBlockCipher, - ClpFusedKernelTypes, - ClpIFusedGcmSivKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedGcmSivKernel, + ClpAcceleratedKernelFactoryBase, + ClpAcceleratedKernelRegistry, ClpGcmSivSimd; type /// - /// PCLMULQDQ implementation of IFusedGcmSivKernel. Pure + /// PCLMULQDQ implementation of IAcceleratedGcmSivKernel. Pure /// POLYVAL: the factory ignores ACipher identity and only requires /// a valid pre-computed H-power table from the caller. Ships on /// both x86_64 and i386. /// TPclmulGcmSivKernel = class sealed(TInterfacedObject, - IFusedGcmSivKernel) + IAcceleratedGcmSivKernel) strict private const FUSED_POLYVAL_MIN_BLOCKS = 8; @@ -50,14 +51,13 @@ TPclmulGcmSivKernel = class sealed(TInterfacedObject, ABlockCount: Int32); end; - TPclmulGcmSivKernelFactory = class sealed(TInterfacedObject, - IFusedGcmSivKernelFactory) + TPclmulGcmSivKernelFactory = class sealed(TAcceleratedKernelFactoryBase, + IAcceleratedGcmSivKernelFactory) public - function ProviderName: String; - function Priority: TFusedKernelPriority; + function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmSivKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmSivKernel): Boolean; end; implementation @@ -97,14 +97,9 @@ function TPclmulGcmSivKernelFactory.ProviderName: String; Result := 'PCLMULQDQ'; end; -function TPclmulGcmSivKernelFactory.Priority: TFusedKernelPriority; -begin - Result := TFusedKernelPriority.Baseline; -end; - function TPclmulGcmSivKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmSivKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmSivKernel): Boolean; begin AKernel := nil; Result := False; @@ -123,7 +118,7 @@ function TPclmulGcmSivKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TFusedKernelRegistry.RegisterGcmSivFactory( - TPclmulGcmSivKernelFactory.Create() as IFusedGcmSivKernelFactory); + TAcceleratedKernelRegistry.RegisterGcmSivFactory( + TPclmulGcmSivKernelFactory.Create() as IAcceleratedGcmSivKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Modes/Fused/Internal/ClpAesFusedAeadSimd.pas b/CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesFusedAeadSimd.pas similarity index 100% rename from CryptoLib/src/Crypto/Modes/Fused/Internal/ClpAesFusedAeadSimd.pas rename to CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesFusedAeadSimd.pas diff --git a/CryptoLib/src/Crypto/Modes/Fused/Internal/ClpAesNiFusedX86Backend.pas b/CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesNiFusedX86Backend.pas similarity index 100% rename from CryptoLib/src/Crypto/Modes/Fused/Internal/ClpAesNiFusedX86Backend.pas rename to CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesNiFusedX86Backend.pas diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelDefaults.pas b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelDefaults.pas similarity index 92% rename from CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelDefaults.pas rename to CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelDefaults.pas index 0f2ef3f6..71220375 100644 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelDefaults.pas +++ b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelDefaults.pas @@ -14,11 +14,11 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpFusedKernelDefaults; +unit ClpAcceleratedKernelDefaults; -{$I ..\..\..\Include\CryptoLib.inc} +{$I ..\..\Include\CryptoLib.inc} -// Aggregator for CryptoLib's in-tree fused AEAD kernel factories. +// Aggregator for CryptoLib's in-tree accelerated kernel factories. // Listed factory units self-gate on their own CPU/arch defines, so // this file is a plain, platform-agnostic list: adding a new in-tree // accelerator is one `uses` line here, mode units are never touched. diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas new file mode 100644 index 00000000..0dbd46bb --- /dev/null +++ b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas @@ -0,0 +1,51 @@ +{ *********************************************************************************** } +{ * CryptoLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license.php. * } +{ * * } +{ * Acknowledgements: * } +{ * * } +{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } +{ * the development of this library * } +{ * ******************************************************************************* * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +unit ClpAcceleratedKernelFactoryBase; + +{$I ..\..\Include\CryptoLib.inc} + +interface + +uses + ClpAcceleratedKernelTypes; + +type + /// + /// Shared base for accelerated-kernel factory classes. ProviderName is + /// abstract - each concrete factory must declare its own provider identity + /// (there is no generic default). Priority defaults to Baseline, a neutral + /// value a factory overrides only when it should out- or under-rank peers. + /// The base intentionally declares no interface - each concrete factory + /// lists its own IAccelerated<Mode>KernelFactory, and these members + /// satisfy the base slice of that contract. + /// + TAcceleratedKernelFactoryBase = class abstract(TInterfacedObject) + public + function ProviderName: String; virtual; abstract; + function Priority: TAcceleratedKernelPriority; virtual; + end; + +implementation + +{ TAcceleratedKernelFactoryBase } + +function TAcceleratedKernelFactoryBase.Priority: TAcceleratedKernelPriority; +begin + Result := TAcceleratedKernelPriority.Baseline; +end; + +end. diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas new file mode 100644 index 00000000..6c8fa280 --- /dev/null +++ b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas @@ -0,0 +1,657 @@ +{ *********************************************************************************** } +{ * CryptoLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license.php. * } +{ * * } +{ * Acknowledgements: * } +{ * * } +{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } +{ * the development of this library * } +{ * ******************************************************************************* * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +unit ClpAcceleratedKernelRegistry; + +{$I ..\..\Include\CryptoLib.inc} + +interface + +uses + SysUtils, + SyncObjs, + Generics.Collections, + ClpIBlockCipher, + ClpCryptoLibTypes, + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory, + ClpIAcceleratedGcmKernel, + ClpIAcceleratedOcbKernel, + ClpIAcceleratedCcmKernel, + ClpIAcceleratedEaxKernel, + ClpIAcceleratedGcmSivKernel, + ClpIAcceleratedCtrKernel, + ClpIAcceleratedCbcKernel, + ClpIStreamCipher, + ClpIAcceleratedChaCha20Poly1305Kernel; + +type + /// + /// Process-wide kill switch for every registered accelerated kernel. When + /// ForceDisabled is True, every TryAcquireX returns False without walking + /// the factory list, so modes route through their scalar fallbacks. Used by + /// the dual-path test harness to prove both paths agree byte-for-byte. + /// + TAcceleratedKernelGate = class sealed(TObject) + strict private + class var FForceDisabled: Boolean; + public + class property ForceDisabled: Boolean read FForceDisabled write FForceDisabled; + end; + + /// + /// Open, priority-ordered resolver for the whole accelerated-kernel family. Every + /// factory - block-cipher AEAD or stream-cipher AEAD alike - is registered + /// through the family-agnostic IAcceleratedKernelFactory into a single + /// priority-sorted list (highest Priority first; equal priorities keep + /// registration order). A per-mode TryAcquireX re-discovers the concrete + /// family with Supports() and calls its typed TryCreate. An external + /// consumer registers its own IAccelerated<X>KernelFactory and resolves it + /// through the public GetSnapshot + a Supports walk - no framework edit and + /// no central enum. Thread-safe: one TCriticalSection guards mutation and + /// snapshotting; TryAcquireX snapshots under the lock then releases it before + /// invoking factory TryCreate, so factory work never serialises other call + /// sites. + /// + TAcceleratedKernelRegistry = class sealed(TObject) + strict private + class var FLock: TCriticalSection; + class var FFactories: TList; + class function Snapshot: TCryptoLibGenericArray; static; + class constructor Create; + class destructor Destroy; + public + /// Register a factory of any family. Insertion keeps the single + /// list sorted by Ord(Priority) descending; equal priorities retain + /// registration order. Duplicate registrations (same interface identity) + /// are silently ignored. + class procedure Register(const AFactory: IAcceleratedKernelFactory); static; + /// Remove AFactory. No-op if not registered. + class procedure Unregister(const AFactory: IAcceleratedKernelFactory); static; + /// Priority-ordered snapshot of every registered factory. External + /// consumers filter it with Supports() to their own factory interface to + /// resolve an accelerated kernel the framework never enumerated. + class function GetSnapshot: TCryptoLibGenericArray; static; + + class procedure RegisterGcmFactory(const AFactory: IAcceleratedGcmKernelFactory); static; + class procedure RegisterOcbFactory(const AFactory: IAcceleratedOcbKernelFactory); static; + class procedure RegisterCcmFactory(const AFactory: IAcceleratedCcmKernelFactory); static; + class procedure RegisterEaxFactory(const AFactory: IAcceleratedEaxKernelFactory); static; + class procedure RegisterGcmSivFactory(const AFactory: IAcceleratedGcmSivKernelFactory); static; + class procedure RegisterCtrFactory(const AFactory: IAcceleratedCtrKernelFactory); static; + class procedure RegisterCbcFactory(const AFactory: IAcceleratedCbcKernelFactory); static; + class procedure RegisterChaCha20Poly1305Factory(const AFactory: IAcceleratedChaCha20Poly1305KernelFactory); static; + + class procedure UnregisterGcmFactory(const AFactory: IAcceleratedGcmKernelFactory); static; + class procedure UnregisterOcbFactory(const AFactory: IAcceleratedOcbKernelFactory); static; + class procedure UnregisterCcmFactory(const AFactory: IAcceleratedCcmKernelFactory); static; + class procedure UnregisterEaxFactory(const AFactory: IAcceleratedEaxKernelFactory); static; + class procedure UnregisterGcmSivFactory(const AFactory: IAcceleratedGcmSivKernelFactory); static; + class procedure UnregisterCtrFactory(const AFactory: IAcceleratedCtrKernelFactory); static; + class procedure UnregisterCbcFactory(const AFactory: IAcceleratedCbcKernelFactory); static; + class procedure UnregisterChaCha20Poly1305Factory(const AFactory: IAcceleratedChaCha20Poly1305KernelFactory); static; + + class function TryAcquireGcm(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; static; + class function TryAcquireOcb(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedOcbKernel): Boolean; static; + class function TryAcquireCcm(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCcmKernel): Boolean; static; + class function TryAcquireEax(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedEaxKernel): Boolean; static; + class function TryAcquireGcmSiv(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmSivKernel): Boolean; static; + class function TryAcquireCtr(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCtrKernel): Boolean; static; + class function TryAcquireCbc(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCbcKernel): Boolean; static; + class function TryAcquireChaCha20Poly1305(const ACipher: IStreamCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; static; + + /// Snapshot of ProviderName strings in current priority order. + /// Used for diagnostics and test assertions. + class function GetRegisteredGcmProviders: TCryptoLibStringArray; static; + class function GetRegisteredOcbProviders: TCryptoLibStringArray; static; + class function GetRegisteredCcmProviders: TCryptoLibStringArray; static; + class function GetRegisteredEaxProviders: TCryptoLibStringArray; static; + class function GetRegisteredGcmSivProviders: TCryptoLibStringArray; static; + class function GetRegisteredCtrProviders: TCryptoLibStringArray; static; + class function GetRegisteredCbcProviders: TCryptoLibStringArray; static; + class function GetRegisteredChaCha20Poly1305Providers: TCryptoLibStringArray; static; + end; + +implementation + +{ TAcceleratedKernelRegistry } + +class constructor TAcceleratedKernelRegistry.Create; +begin + FLock := TCriticalSection.Create; + FFactories := TList.Create; +end; + +class destructor TAcceleratedKernelRegistry.Destroy; +begin + FFactories.Free; + FLock.Free; +end; + +class procedure TAcceleratedKernelRegistry.Register(const AFactory: IAcceleratedKernelFactory); +var + LI, LPriority: Int32; + LInserted: Boolean; +begin + if AFactory = nil then Exit; + FLock.Enter; + try + if FFactories.IndexOf(AFactory) >= 0 then Exit; + LPriority := Ord(AFactory.Priority); + LInserted := False; + for LI := 0 to FFactories.Count - 1 do + begin + if LPriority > Ord(FFactories[LI].Priority) then + begin + FFactories.Insert(LI, AFactory); + LInserted := True; + Break; + end; + end; + if not LInserted then + FFactories.Add(AFactory); + finally + FLock.Leave; + end; +end; + +class procedure TAcceleratedKernelRegistry.Unregister(const AFactory: IAcceleratedKernelFactory); +var + LIdx: Int32; +begin + if AFactory = nil then Exit; + FLock.Enter; + try + LIdx := FFactories.IndexOf(AFactory); + if LIdx >= 0 then + FFactories.Delete(LIdx); + finally + FLock.Leave; + end; +end; + +class function TAcceleratedKernelRegistry.Snapshot: TCryptoLibGenericArray; +var + LI, LCount: Int32; +begin + FLock.Enter; + try + LCount := FFactories.Count; + System.SetLength(Result, LCount); + for LI := 0 to LCount - 1 do + Result[LI] := FFactories[LI]; + finally + FLock.Leave; + end; +end; + +class function TAcceleratedKernelRegistry.GetSnapshot: TCryptoLibGenericArray; +begin + Result := Snapshot; +end; + +{ ---- Register / Unregister wrappers ---------------------------------------- } + +class procedure TAcceleratedKernelRegistry.RegisterGcmFactory( + const AFactory: IAcceleratedGcmKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterOcbFactory( + const AFactory: IAcceleratedOcbKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterCcmFactory( + const AFactory: IAcceleratedCcmKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterEaxFactory( + const AFactory: IAcceleratedEaxKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterGcmSivFactory( + const AFactory: IAcceleratedGcmSivKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterCtrFactory( + const AFactory: IAcceleratedCtrKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterCbcFactory( + const AFactory: IAcceleratedCbcKernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.RegisterChaCha20Poly1305Factory( + const AFactory: IAcceleratedChaCha20Poly1305KernelFactory); +begin + Register(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterGcmFactory( + const AFactory: IAcceleratedGcmKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterOcbFactory( + const AFactory: IAcceleratedOcbKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterCcmFactory( + const AFactory: IAcceleratedCcmKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterEaxFactory( + const AFactory: IAcceleratedEaxKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterGcmSivFactory( + const AFactory: IAcceleratedGcmSivKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterCtrFactory( + const AFactory: IAcceleratedCtrKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterCbcFactory( + const AFactory: IAcceleratedCbcKernelFactory); +begin + Unregister(AFactory); +end; + +class procedure TAcceleratedKernelRegistry.UnregisterChaCha20Poly1305Factory( + const AFactory: IAcceleratedChaCha20Poly1305KernelFactory); +begin + Unregister(AFactory); +end; + +{ ---- TryAcquire ------------------------------------------------------------- } + +class function TAcceleratedKernelRegistry.TryAcquireGcm(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedGcmKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + if AHPowers = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedGcmKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AHPowers, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireOcb(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedOcbKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedOcbKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedOcbKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireCcm(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCcmKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedCcmKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedCcmKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireEax(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedEaxKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedEaxKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedEaxKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireGcmSiv(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmSivKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedGcmSivKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if AHPowers = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedGcmSivKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AHPowers, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireCtr(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCtrKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedCtrKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedCtrKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireCbc(const ACipher: IBlockCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCbcKernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedCbcKernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedCbcKernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +class function TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(const ACipher: IStreamCipher; + ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; +var + LSnap: TCryptoLibGenericArray; + LI: Int32; + LFac: IAcceleratedChaCha20Poly1305KernelFactory; +begin + AKernel := nil; + Result := False; + if TAcceleratedKernelGate.ForceDisabled then Exit; + if ACipher = nil then Exit; + LSnap := Snapshot; + for LI := 0 to System.Length(LSnap) - 1 do + begin + if Supports(LSnap[LI], IAcceleratedChaCha20Poly1305KernelFactory, LFac) and + LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then + begin + Result := True; + Exit; + end; + end; + AKernel := nil; +end; + +{ ---- Provider queries ------------------------------------------------------- } + +class function TAcceleratedKernelRegistry.GetRegisteredGcmProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedGcmKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedGcmKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredOcbProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedOcbKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedOcbKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredCcmProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedCcmKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedCcmKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredEaxProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedEaxKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedEaxKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredGcmSivProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedGcmSivKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedGcmSivKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredCtrProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedCtrKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedCtrKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredCbcProviders: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedCbcKernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedCbcKernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +class function TAcceleratedKernelRegistry.GetRegisteredChaCha20Poly1305Providers: TCryptoLibStringArray; +var + LSnap: TCryptoLibGenericArray; + LI, LN: Int32; + LFac: IAcceleratedChaCha20Poly1305KernelFactory; +begin + LSnap := Snapshot; + System.SetLength(Result, 0); + LN := 0; + for LI := 0 to System.Length(LSnap) - 1 do + if Supports(LSnap[LI], IAcceleratedChaCha20Poly1305KernelFactory, LFac) then + begin + System.SetLength(Result, LN + 1); + Result[LN] := LFac.ProviderName; + Inc(LN); + end; +end; + +end. diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpFusedKernelTypes.pas b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelTypes.pas similarity index 60% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpFusedKernelTypes.pas rename to CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelTypes.pas index 44381b62..23fa686d 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpFusedKernelTypes.pas +++ b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelTypes.pas @@ -14,33 +14,37 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpFusedKernelTypes; +unit ClpAcceleratedKernelTypes; -{$I ..\..\..\..\Include\CryptoLib.inc} +{$I ..\..\Include\CryptoLib.inc} interface type /// - /// Direction a fused AEAD kernel is being constructed for. Modes + /// Direction an accelerated kernel is being constructed for. Modes /// whose hot path is direction-agnostic may pass Encrypt for both /// cases. /// - TFusedModeDirection = (Encrypt, Decrypt); + TAcceleratedKernelDirection = (Encrypt, Decrypt); /// - /// Priority class used to order factories in the fused AEAD kernel - /// registry. Higher ordinal wins; equal priorities retain - /// registration order. + /// Priority class used to order factories in the accelerated kernel + /// registry. Higher ordinal wins; equal priorities retain registration + /// order (first registered wins), which is why UserOverride sits above + /// Preferred - it keeps the consumer's explicit choice the final word + /// regardless of plug-in load order. /// Fallback - opt-in experimental / diagnostic kernel; loses - /// to anything else. + /// to anything else (never wins over a real kernel). /// Baseline - in-tree built-in accelerators. - /// Accelerated - external plug-in targeting a newer ISA - /// extension than the in-tree baseline. + /// Preferred - a self-registering kernel that should outrank the + /// in-tree baseline when present (e.g. an external + /// plug-in for a newer ISA extension), yet still yield + /// to the consumer's explicit override. /// UserOverride - last-resort explicit override wired in by the - /// consumer (application or test harness). + /// consumer (application or test harness); beats all. /// - TFusedKernelPriority = (Fallback, Baseline, Accelerated, UserOverride); + TAcceleratedKernelPriority = (Fallback, Baseline, Preferred, UserOverride); implementation diff --git a/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas index 172a3703..5672b2aa 100644 --- a/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas @@ -30,9 +30,9 @@ interface ClpICipherParameters, ClpIParametersWithIV, ClpBlockCipherBulkUtilities, - ClpFusedKernelTypes, - ClpIFusedCbcKernel, - ClpFusedKernelRegistry, + ClpAcceleratedKernelTypes, + ClpIAcceleratedCbcKernel, + ClpAcceleratedKernelRegistry, ClpArrayUtilities, ClpByteUtilities, ClpCryptoLibTypes; @@ -76,7 +76,7 @@ TCbcBlockCipher = class sealed(TInterfacedObject, ICbcBlockCipher, // C[i] = E(P[i] xor C[i-1]) in one call with the chaining value held in a // register, replacing the per-block dispatch loop. nil otherwise -- // CbcEncryptBulk keeps its per-block path. - FCbcKernel: IFusedCbcKernel; + FCbcKernel: IAcceleratedCbcKernel; function EncryptBlock(const AInput: TCryptoLibByteArray; AInOff: Int32; const AOutBytes: TCryptoLibByteArray; AOutOff: Int32): Int32; @@ -347,7 +347,7 @@ procedure TCbcBlockCipher.Init(AForEncryption: Boolean; // provider claims FCipher. Encrypt-only: CBC decrypt is parallel and already // served by the bulk engine's 8-wide path. if FEncrypting then - TFusedKernelRegistry.TryAcquireCbc(FCipher, TFusedModeDirection.Encrypt, + TAcceleratedKernelRegistry.TryAcquireCbc(FCipher, TAcceleratedKernelDirection.Encrypt, FCbcKernel) else FCbcKernel := nil; diff --git a/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas index 6ee3767f..81db7e72 100644 --- a/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas @@ -33,10 +33,10 @@ interface ClpISicBlockCipher, ClpIBulkBlockCipherMode, ClpBlockCipherBulkUtilities, - ClpFusedKernelTypes, - ClpIFusedCcmKernel, - ClpFusedKernelRegistry, - ClpFusedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpAcceleratedKernelTypes, + ClpIAcceleratedCcmKernel, + ClpAcceleratedKernelRegistry, + ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories ClpCipherModeParameterUtilities, ClpIKeyParameter, ClpCbcBlockCipherMac, @@ -118,7 +118,7 @@ TCcmBlockCipher = class(TInterfacedObject, ICcmBlockCipher, FPlainScratch: TCryptoLibByteArray; // Cached once per Init; non-nil when the registry resolved a fused // CCM kernel for the underlying cipher and current direction. - FCcmKernel: IFusedCcmKernel; + FCcmKernel: IAcceleratedCcmKernel; class function GetMacSize(ARequestedMacBits: Int32): Int32; static; procedure CheckNonceReuse(AForEncryption: Boolean; @@ -232,7 +232,7 @@ procedure TCcmBlockCipher.Init(AForEncryption: Boolean; var LChoice: TCipherAeadChoice; LRequestedMacSizeBits: Int32; - LDirection: TFusedModeDirection; + LDirection: TAcceleratedKernelDirection; begin FForEncryption := AForEncryption; @@ -272,10 +272,10 @@ procedure TCcmBlockCipher.Init(AForEncryption: Boolean; // schedule contents are identical across those re-keys. FCipher.Init(True, FKeyParam); if AForEncryption then - LDirection := TFusedModeDirection.Encrypt + LDirection := TAcceleratedKernelDirection.Encrypt else - LDirection := TFusedModeDirection.Decrypt; - TFusedKernelRegistry.TryAcquireCcm(FCipher, LDirection, FCcmKernel); + LDirection := TAcceleratedKernelDirection.Decrypt; + TAcceleratedKernelRegistry.TryAcquireCcm(FCipher, LDirection, FCcmKernel); end; Reset(); diff --git a/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas b/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas index 7beb4cdf..62e100d3 100644 --- a/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas +++ b/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas @@ -31,6 +31,9 @@ interface ClpIBulkStreamCipher, ClpIChaCha7539Engine, ClpChaCha7539Engine, + ClpAcceleratedKernelTypes, + ClpAcceleratedKernelRegistry, + ClpIAcceleratedChaCha20Poly1305Kernel, ClpPoly1305, ClpIMac, ClpKeyParameter, @@ -111,6 +114,9 @@ TChaCha20Poly1305 = class(TInterfacedObject, IChaCha20Poly1305, IAeadCipher) // The cipher engine's bulk stream interface when it exposes one (resolved once); // enables the 512B/8-way tier. nil => the narrower per-tier path is used. FBulkChaCha: IBulkStreamCipher; + // A registered ChaCha20-Poly1305 kernel, resolved once at Init. + // the two-pass cipher-then-MAC path runs. + FChaChaKernel: IAcceleratedChaCha20Poly1305Kernel; FNonceBytes: Int32; FPoly1305: IMac; @@ -283,6 +289,13 @@ procedure TChaCha20Poly1305.Init(AForEncryption: Boolean; FChaCha20.Init(True, LChaCha20Params); + if AForEncryption then + TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(FChaCha20, + TAcceleratedKernelDirection.Encrypt, FChaChaKernel) + else + TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(FChaCha20, + TAcceleratedKernelDirection.Decrypt, FChaChaKernel); + if AForEncryption then FState := TState.EncInit else diff --git a/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas index fb4971c4..fb9b68f9 100644 --- a/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas @@ -33,10 +33,10 @@ interface ClpISicBlockCipher, ClpIBulkBlockCipherMode, ClpBlockCipherBulkUtilities, - ClpFusedKernelTypes, - ClpIFusedEaxKernel, - ClpFusedKernelRegistry, - ClpFusedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpAcceleratedKernelTypes, + ClpIAcceleratedEaxKernel, + ClpAcceleratedKernelRegistry, + ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories ClpCipherModeParameterUtilities, ClpIKeyParameter, ClpCMac, @@ -96,7 +96,7 @@ TEaxBlockCipher = class(TInterfacedObject, IEaxBlockCipher, // EAX kernel for the underlying cipher and encrypt direction. Decrypt // and non-AES ciphers stay on the TCMac / TSicBlockCipher scalar // path; set via FUseFusedBody below. - FEaxKernel: IFusedEaxKernel; + FEaxKernel: IAcceleratedEaxKernel; // True iff a fused body kernel is live for this Init cycle. Gates // the mode-owned OMAC substrate (FOmac* + FCtrBlock) against the @@ -311,11 +311,11 @@ procedure TEaxBlockCipher.Init(AForEncryption: Boolean; // TCMac / TSicBlockCipher path runs - no compile-time arch gating needed. FEaxKernel := nil; if FForEncryption then - TFusedKernelRegistry.TryAcquireEax(FCipher, - TFusedModeDirection.Encrypt, FEaxKernel) + TAcceleratedKernelRegistry.TryAcquireEax(FCipher, + TAcceleratedKernelDirection.Encrypt, FEaxKernel) else - TFusedKernelRegistry.TryAcquireEax(FCipher, - TFusedModeDirection.Decrypt, FEaxKernel); + TAcceleratedKernelRegistry.TryAcquireEax(FCipher, + TAcceleratedKernelDirection.Decrypt, FEaxKernel); FUseFusedBody := FEaxKernel <> nil; if FUseFusedBody then diff --git a/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas index 0f48f6fa..d4d38b43 100644 --- a/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas @@ -40,10 +40,10 @@ interface ClpIBulkBlockCipher, ClpBlockCipherBulkUtilities, ClpByteUtilities, - ClpFusedKernelTypes, - ClpIFusedGcmKernel, - ClpFusedKernelRegistry, - ClpFusedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpAcceleratedKernelTypes, + ClpIAcceleratedGcmKernel, + ClpAcceleratedKernelRegistry, + ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories ClpPack, ClpCheck, ClpBasicGcmMultiplier, @@ -106,11 +106,11 @@ TGcmBlockCipher = class(TInterfacedObject, IGcmBlockCipher, // exposes the generic IBulkBlockCipher capability. Drives the // non-fused 4/8-block CTR dispatchers (GetNextCtrBlocks4/8). FBulkCipher: IBulkBlockCipher; - // Fused CTR+GHASH kernel resolved via TFusedKernelRegistry at Init + // Fused CTR+GHASH kernel resolved via TAcceleratedKernelRegistry at Init // time. Non-nil only when an accelerator factory accepts the - // underlying cipher + direction and the fused gate is open (always nil - // off-SIMD; IFusedGcmKernel is arch-neutral). - FGcmKernel: IFusedGcmKernel; + // underlying cipher + direction and the accelerated-kernel gate is open (always nil + // off-SIMD; IAcceleratedGcmKernel is arch-neutral). + FGcmKernel: IAcceleratedGcmKernel; FGcmKernelMinBlocks: Int32; FMultiplier: IGcmMultiplier; FExp: IGcmExponentiator; @@ -190,15 +190,15 @@ TGcmBlockCipher = class(TInterfacedObject, IGcmBlockCipher, ALimit: Int32; AForEncrypt: Boolean); // ===================================================================== // Fused block-cipher keystream + 8-way GHASH pipeline (provided by the - // fused kernel registry; nil kernel -> not used, e.g. off-SIMD). + // accelerated-kernel registry; nil kernel -> not used, e.g. off-SIMD). // ===================================================================== // This outer driver is arch-agnostic: pure Pascal batch orchestration - // plus one call into an IFusedGcmKernel per 8-block stride. The kernel + // plus one call into an IAcceleratedGcmKernel per 8-block stride. The kernel // fuses CTR-mode keystream generation with the GHASH multiply-reduce in a // single pass, interleaving the two at the instruction level so their // independent execution units overlap. How wide that interleave runs and // how it is scheduled against the available vector-register budget is a - // backend detail hidden entirely behind the IFusedGcmKernel surface, so + // backend detail hidden entirely behind the IAcceleratedGcmKernel surface, so // this driver only ever sees the kernel interface. /// /// Pipelined GCM path driven by FGcmKernel (when a fused kernel is @@ -467,7 +467,7 @@ procedure TGcmBlockCipher.InitCipherAndHashSubKey(const AKeyParam: IKeyParameter System.SetLength(FWorkCtrAhead, 128); TArrayUtilities.Fill(FWorkCtrAhead, 0, System.Length(FWorkCtrAhead), Byte(0)); - if TFusedKernelRegistry.TryAcquireGcm(FCipher, TFusedModeDirection.Encrypt, + if TAcceleratedKernelRegistry.TryAcquireGcm(FCipher, TAcceleratedKernelDirection.Encrypt, @FHPow[0], FGcmKernel) and (FGcmKernel <> nil) then begin FGcmKernelMinBlocks := FGcmKernel.MinimumBlockCount; @@ -1143,7 +1143,7 @@ procedure TGcmBlockCipher.GhashFourShuffledBlocks(PC0, PC16, PC32, PC48: PByte); // GHASH to reclaim instruction-level parallelism across the two independent // execution units. The FusedILP variant (further below) pushes this further // by interleaving both at the instruction level inside a single kernel -// supplied by the fused-kernel registry (nil off-SIMD, so that path is +// supplied by the accelerated-kernel registry (nil off-SIMD, so that path is // simply skipped there). AForEncrypt selects which buffer feeds GHASH: // output ciphertext on encrypt, input ciphertext on decrypt. // ======================================================================= @@ -1381,7 +1381,7 @@ class procedure TGcmBlockCipher.FillCtr8BlocksRaw( // ======================================================================= // Fused block-cipher keystream + 8-way GHASH pipeline. The driver is // arch-agnostic: it drives the outer 8-block stride loop and delegates the -// fused work to whichever IFusedGcmKernel the registry resolved (nil +// fused work to whichever IAcceleratedGcmKernel the registry resolved (nil // off-SIMD, so the callers never invoke this path there). The kernel's // internal interleave and register budget are backend details behind the // interface, summarised on the matching banner in the class declaration. diff --git a/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas index b9ac8978..5a633b92 100644 --- a/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas @@ -38,10 +38,10 @@ interface ClpGcmUtilities, ClpGcmSivUtilities, ClpGcmSivSimd, - ClpFusedKernelTypes, - ClpIFusedGcmSivKernel, - ClpFusedKernelRegistry, - ClpFusedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpAcceleratedKernelTypes, + ClpIAcceleratedGcmSivKernel, + ClpAcceleratedKernelRegistry, + ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories ClpKeyParameter, ClpAesUtilities, ClpInt64Utilities, @@ -128,10 +128,10 @@ TGcmSivHasher = class(TObject) // when the fused kernel is available; captured by reference by the // kernel and consumed read-only by TGcmSivHasher.UpdateHash. FHPow128: TCryptoLibByteArray; - // Fused POLYVAL kernel resolved via TFusedKernelRegistry. Non-nil + // Fused POLYVAL kernel resolved via TAcceleratedKernelRegistry. Non-nil // only when the registry produced a kernel whose MinimumBlockCount // matches the mode's 8-block batch contract. - FGcmSivKernel: IFusedGcmSivKernel; + FGcmSivKernel: IAcceleratedGcmSivKernel; FGcmSivKernelBatchBytes: Int32; procedure CheckAeadStatus(ALen: Int32); @@ -869,8 +869,8 @@ procedure TGcmSivBlockCipher.DeriveKeys(const AKey: IKeyParameter); if System.Length(FHPow128) < 128 then System.SetLength(FHPow128, 128); TGcmUtilities.InitEightWayHPowFromH(LMyOut, FHPow128); - if TFusedKernelRegistry.TryAcquireGcmSiv(FTheCipher, - TFusedModeDirection.Encrypt, @FHPow128[0], FGcmSivKernel) and + if TAcceleratedKernelRegistry.TryAcquireGcmSiv(FTheCipher, + TAcceleratedKernelDirection.Encrypt, @FHPow128[0], FGcmSivKernel) and (FGcmSivKernel <> nil) then begin if FGcmSivKernel.MinimumBlockCount = 8 then diff --git a/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas index 2b92cf51..ef540ede 100644 --- a/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas @@ -25,10 +25,10 @@ interface Generics.Collections, ClpIBlockCipher, ClpIBulkBlockCipher, - ClpFusedKernelTypes, - ClpIFusedOcbKernel, - ClpFusedKernelRegistry, - ClpFusedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpAcceleratedKernelTypes, + ClpIAcceleratedOcbKernel, + ClpAcceleratedKernelRegistry, + ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories ClpIOcbBlockCipher, ClpIAeadBlockCipher, ClpIAeadCipher, @@ -124,14 +124,14 @@ TOcbBlockCipher = class(TInterfacedObject, IOcbBlockCipher, FMainBulk: IBulkBlockCipher; // Fused-kernel fast path: cipher-agnostic fused OCB kernel - // resolved via TFusedKernelRegistry on every Init. Nil when no + // resolved via TAcceleratedKernelRegistry on every Init. Nil when no // registered factory accepts the cipher / direction pair or the // registry-wide kill switch is on; ProcessBytes then falls through // to the 8-wide bulk / scalar paths unchanged. // FOcbKernelMinBlocks is also the batch alignment: the kernel // loops internally in MinimumBlockCount chunks so the mode stages // up to FUSED_BATCH_BLOCKS worth of offsets per dispatch. - FOcbKernel: IFusedOcbKernel; + FOcbKernel: IAcceleratedOcbKernel; FOcbKernelMinBlocks: Int32; procedure CheckNonceReuse(AForEncryption: Boolean; @@ -267,7 +267,7 @@ procedure TOcbBlockCipher.Init(AForEncryption: Boolean; LN: TCryptoLibByteArray; LMacSizeBits, LBottom, LBits, LBytes, LI: Int32; LB1, LB2: UInt32; - LFusedDirection: TFusedModeDirection; + LFusedDirection: TAcceleratedKernelDirection; begin LOldForEncryption := FForEncryption; FForEncryption := AForEncryption; @@ -340,10 +340,10 @@ procedure TOcbBlockCipher.Init(AForEncryption: Boolean; FOcbKernel := nil; FOcbKernelMinBlocks := 0; if FForEncryption then - LFusedDirection := TFusedModeDirection.Encrypt + LFusedDirection := TAcceleratedKernelDirection.Encrypt else - LFusedDirection := TFusedModeDirection.Decrypt; - if TFusedKernelRegistry.TryAcquireOcb(FMainCipher, LFusedDirection, + LFusedDirection := TAcceleratedKernelDirection.Decrypt; + if TAcceleratedKernelRegistry.TryAcquireOcb(FMainCipher, LFusedDirection, FOcbKernel) and (FOcbKernel <> nil) then begin FOcbKernelMinBlocks := FOcbKernel.MinimumBlockCount; @@ -663,7 +663,7 @@ procedure TOcbBlockCipher.ProcessFusedBulk(const AInput: TCryptoLibByteArray; // LScratch reshape had to do on every fused decrypt batch. // // The `InPtr - BLOCK_SIZE` pointer is never dereferenced at offset 0 by - // the kernel (guaranteed by the IFusedOcbKernel.ProcessBlocks contract for + // the kernel (guaranteed by the IAcceleratedOcbKernel.ProcessBlocks contract for // Block0Ptr); the address itself only feeds register arithmetic and the // `[InPtr + 16..]` loads, all of which resolve inside AInput. LBlock0Ptr := @FMainBlock[0]; diff --git a/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas index 394f3028..41839be8 100644 --- a/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas @@ -26,9 +26,9 @@ interface ClpIBlockCipher, ClpIBlockCipherMode, ClpIBulkBlockCipher, - ClpIFusedCtrKernel, - ClpFusedKernelTypes, - ClpFusedKernelRegistry, + ClpIAcceleratedCtrKernel, + ClpAcceleratedKernelTypes, + ClpAcceleratedKernelRegistry, ClpIBulkBlockCipherMode, ClpBlockCipherBulkUtilities, ClpByteUtilities, @@ -70,11 +70,11 @@ TSicBlockCipher = class(TInterfacedObject, ISicBlockCipher, // bulk-capable engine plugs in unchanged by implementing the // interface -- the mode does not care which cipher is underneath. FBulkCipher: IBulkBlockCipher; - // Acquired on Init from the fused-kernel registry when an accelerated + // Acquired on Init from the accelerated-kernel registry when an accelerated // counter-mode kernel is available for FCipher: a single AES-NI pass that // fuses counter generation, encryption and XOR. Preferred over FBulkCipher // for the batch-aligned bulk; nil (with FBulkCipher fallback) otherwise. - FCtrKernel: IFusedCtrKernel; + FCtrKernel: IAcceleratedCtrKernel; /// /// Snapshot FCounter into APlainCounters and advance FCounter by ABlockCount @@ -217,7 +217,7 @@ procedure TSicBlockCipher.Init(AForEncryption: Boolean; // Acquire the fused counter-mode kernel if an accelerator is registered for // FCipher (sets FCtrKernel nil on miss). Direction is irrelevant for CTR // keystream (always AES-encrypt of the counter), so request Encrypt. - TFusedKernelRegistry.TryAcquireCtr(FCipher, TFusedModeDirection.Encrypt, + TAcceleratedKernelRegistry.TryAcquireCtr(FCipher, TAcceleratedKernelDirection.Encrypt, FCtrKernel); Reset(); diff --git a/CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelRegistry.pas b/CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelRegistry.pas deleted file mode 100644 index 587b95ed..00000000 --- a/CryptoLib/src/Crypto/Modes/Fused/ClpFusedKernelRegistry.pas +++ /dev/null @@ -1,850 +0,0 @@ -{ *********************************************************************************** } -{ * CryptoLib Library * } -{ * Author - Ugochukwu Mmaduekwe * } -{ * Github Repository * } -{ * * } -{ * Distributed under the MIT software license, see the accompanying file LICENSE * } -{ * or visit http://www.opensource.org/licenses/mit-license.php. * } -{ * * } -{ * Acknowledgements: * } -{ * * } -{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } -{ * the development of this library * } -{ * ******************************************************************************* * } - -(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) - -unit ClpFusedKernelRegistry; - -{$I ..\..\..\Include\CryptoLib.inc} - -interface - -uses - SysUtils, - SyncObjs, - Generics.Collections, - ClpIBlockCipher, - ClpCryptoLibTypes, - ClpFusedKernelTypes, - ClpIFusedGcmKernel, - ClpIFusedOcbKernel, - ClpIFusedCcmKernel, - ClpIFusedEaxKernel, - ClpIFusedGcmSivKernel, - ClpIFusedCtrKernel, - ClpIFusedCbcKernel; - -type - /// - /// Process-wide kill switch for every fused AEAD kernel registered - /// with the registry. When ForceDisabled is True, every TryAcquireX - /// returns False without walking the factory list, so modes route - /// through their scalar fallbacks. Used by the dual-mode test - /// harness to prove both paths agree byte-for-byte. - /// - TFusedKernelGate = class sealed(TObject) - strict private - class var FForceDisabled: Boolean; - public - class property ForceDisabled: Boolean read FForceDisabled write FForceDisabled; - end; - - /// - /// Open factory-based resolver for the fused AEAD kernel family - /// (GCM, OCB, CCM, EAX, GCM-SIV). Accelerator units register an - /// IFused<Mode>KernelFactory in their initialization block; - /// modes resolve a kernel via TryAcquire<Mode> at Init time. - /// Factories are kept sorted by TFusedKernelPriority descending so - /// higher-priority accelerators win. TryCreate failures are - /// expected and the registry walks to the next factory. - /// Lookups are thread-safe: a single TCriticalSection guards - /// insertion / removal / snapshot; TryAcquireX takes a snapshot - /// under the lock then releases it before invoking factory - /// TryCreate, so factory work never serialises other call sites. - /// - TFusedKernelRegistry = class sealed(TObject) - strict private - class var FLock: TCriticalSection; - class var FGcmFactories: TList; - class var FOcbFactories: TList; - class var FCcmFactories: TList; - class var FEaxFactories: TList; - class var FGcmSivFactories: TList; - class var FCtrFactories: TList; - class var FCbcFactories: TList; - - class function SnapshotGcmFactories: TCryptoLibGenericArray; static; - class function SnapshotOcbFactories: TCryptoLibGenericArray; static; - class function SnapshotCcmFactories: TCryptoLibGenericArray; static; - class function SnapshotEaxFactories: TCryptoLibGenericArray; static; - class function SnapshotGcmSivFactories: TCryptoLibGenericArray; static; - class function SnapshotCtrFactories: TCryptoLibGenericArray; static; - class function SnapshotCbcFactories: TCryptoLibGenericArray; static; - - class constructor Create; - class destructor Destroy; - public - /// Register a factory. Insertion keeps the list sorted by - /// Ord(Priority) descending; equal priorities retain registration - /// order. Duplicate registrations (same interface identity) are - /// silently ignored. - class procedure RegisterGcmFactory(const AFactory: IFusedGcmKernelFactory); static; - class procedure RegisterOcbFactory(const AFactory: IFusedOcbKernelFactory); static; - class procedure RegisterCcmFactory(const AFactory: IFusedCcmKernelFactory); static; - class procedure RegisterEaxFactory(const AFactory: IFusedEaxKernelFactory); static; - class procedure RegisterGcmSivFactory(const AFactory: IFusedGcmSivKernelFactory); static; - class procedure RegisterCtrFactory(const AFactory: IFusedCtrKernelFactory); static; - class procedure RegisterCbcFactory(const AFactory: IFusedCbcKernelFactory); static; - - /// Remove AFactory. No-op if not registered. - class procedure UnregisterGcmFactory(const AFactory: IFusedGcmKernelFactory); static; - class procedure UnregisterOcbFactory(const AFactory: IFusedOcbKernelFactory); static; - class procedure UnregisterCcmFactory(const AFactory: IFusedCcmKernelFactory); static; - class procedure UnregisterEaxFactory(const AFactory: IFusedEaxKernelFactory); static; - class procedure UnregisterGcmSivFactory(const AFactory: IFusedGcmSivKernelFactory); static; - class procedure UnregisterCtrFactory(const AFactory: IFusedCtrKernelFactory); static; - class procedure UnregisterCbcFactory(const AFactory: IFusedCbcKernelFactory); static; - - /// Walk the factory list (highest priority first) and - /// return the first kernel whose TryCreate succeeds. Returns False - /// with AKernel = nil when the gate is ForceDisabled, when no - /// factory is registered, or when every TryCreate returns False. - /// Never raises. - class function TryAcquireGcm(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; static; - class function TryAcquireOcb(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedOcbKernel): Boolean; static; - class function TryAcquireCcm(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCcmKernel): Boolean; static; - class function TryAcquireEax(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedEaxKernel): Boolean; static; - /// GCM-SIV variant: AHPowers is forwarded to the factory - /// and captured by reference by the returned kernel; it MUST - /// outlive the kernel. - class function TryAcquireGcmSiv(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - AHPowers: Pointer; - out AKernel: IFusedGcmSivKernel): Boolean; static; - /// CTR variant: no auxiliary state (MAC-free). Returns False (and - /// AKernel nil) when the gate is ForceDisabled, no factory is registered, - /// or every TryCreate returns False. - class function TryAcquireCtr(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCtrKernel): Boolean; static; - /// CBC-encrypt variant: no auxiliary state. Returns False (and - /// AKernel nil) when the gate is ForceDisabled, no factory is registered, - /// or every TryCreate returns False. - class function TryAcquireCbc(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCbcKernel): Boolean; static; - - /// Snapshot of ProviderName strings in current priority - /// order. Used for diagnostics and test assertions. - class function GetRegisteredGcmProviders: TCryptoLibStringArray; static; - class function GetRegisteredOcbProviders: TCryptoLibStringArray; static; - class function GetRegisteredCcmProviders: TCryptoLibStringArray; static; - class function GetRegisteredEaxProviders: TCryptoLibStringArray; static; - class function GetRegisteredGcmSivProviders: TCryptoLibStringArray; static; - class function GetRegisteredCtrProviders: TCryptoLibStringArray; static; - class function GetRegisteredCbcProviders: TCryptoLibStringArray; static; - end; - -implementation - -{ TFusedKernelRegistry } - -class constructor TFusedKernelRegistry.Create; -begin - FLock := TCriticalSection.Create; - FGcmFactories := TList.Create; - FOcbFactories := TList.Create; - FCcmFactories := TList.Create; - FEaxFactories := TList.Create; - FGcmSivFactories := TList.Create; - FCtrFactories := TList.Create; - FCbcFactories := TList.Create; -end; - -class destructor TFusedKernelRegistry.Destroy; -begin - FCbcFactories.Free; - FCtrFactories.Free; - FGcmSivFactories.Free; - FEaxFactories.Free; - FCcmFactories.Free; - FOcbFactories.Free; - FGcmFactories.Free; - FLock.Free; -end; - -{ ---- Register --------------------------------------------------------------- } - -class procedure TFusedKernelRegistry.RegisterGcmFactory( - const AFactory: IFusedGcmKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FGcmFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FGcmFactories.Count - 1 do - begin - if LPriority > Ord(FGcmFactories[LI].Priority) then - begin - FGcmFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FGcmFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.RegisterOcbFactory( - const AFactory: IFusedOcbKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FOcbFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FOcbFactories.Count - 1 do - begin - if LPriority > Ord(FOcbFactories[LI].Priority) then - begin - FOcbFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FOcbFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.RegisterCcmFactory( - const AFactory: IFusedCcmKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FCcmFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FCcmFactories.Count - 1 do - begin - if LPriority > Ord(FCcmFactories[LI].Priority) then - begin - FCcmFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FCcmFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.RegisterEaxFactory( - const AFactory: IFusedEaxKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FEaxFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FEaxFactories.Count - 1 do - begin - if LPriority > Ord(FEaxFactories[LI].Priority) then - begin - FEaxFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FEaxFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.RegisterGcmSivFactory( - const AFactory: IFusedGcmSivKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FGcmSivFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FGcmSivFactories.Count - 1 do - begin - if LPriority > Ord(FGcmSivFactories[LI].Priority) then - begin - FGcmSivFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FGcmSivFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.RegisterCtrFactory( - const AFactory: IFusedCtrKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FCtrFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FCtrFactories.Count - 1 do - begin - if LPriority > Ord(FCtrFactories[LI].Priority) then - begin - FCtrFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FCtrFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.RegisterCbcFactory( - const AFactory: IFusedCbcKernelFactory); -var - LI: Int32; - LInserted: Boolean; - LPriority: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - if FCbcFactories.IndexOf(AFactory) >= 0 then Exit; - LPriority := Ord(AFactory.Priority); - LInserted := False; - for LI := 0 to FCbcFactories.Count - 1 do - begin - if LPriority > Ord(FCbcFactories[LI].Priority) then - begin - FCbcFactories.Insert(LI, AFactory); - LInserted := True; - Break; - end; - end; - if not LInserted then - FCbcFactories.Add(AFactory); - finally - FLock.Leave; - end; -end; - -{ ---- Unregister ------------------------------------------------------------- } - -class procedure TFusedKernelRegistry.UnregisterGcmFactory( - const AFactory: IFusedGcmKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FGcmFactories.IndexOf(AFactory); - if LIdx >= 0 then - FGcmFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.UnregisterOcbFactory( - const AFactory: IFusedOcbKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FOcbFactories.IndexOf(AFactory); - if LIdx >= 0 then - FOcbFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.UnregisterCcmFactory( - const AFactory: IFusedCcmKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FCcmFactories.IndexOf(AFactory); - if LIdx >= 0 then - FCcmFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.UnregisterEaxFactory( - const AFactory: IFusedEaxKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FEaxFactories.IndexOf(AFactory); - if LIdx >= 0 then - FEaxFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.UnregisterGcmSivFactory( - const AFactory: IFusedGcmSivKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FGcmSivFactories.IndexOf(AFactory); - if LIdx >= 0 then - FGcmSivFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.UnregisterCtrFactory( - const AFactory: IFusedCtrKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FCtrFactories.IndexOf(AFactory); - if LIdx >= 0 then - FCtrFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -class procedure TFusedKernelRegistry.UnregisterCbcFactory( - const AFactory: IFusedCbcKernelFactory); -var - LIdx: Int32; -begin - if AFactory = nil then Exit; - FLock.Enter; - try - LIdx := FCbcFactories.IndexOf(AFactory); - if LIdx >= 0 then - FCbcFactories.Delete(LIdx); - finally - FLock.Leave; - end; -end; - -{ ---- Snapshots -------------------------------------------------------------- } - -class function TFusedKernelRegistry.SnapshotGcmFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FGcmFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FGcmFactories[LI]; - finally - FLock.Leave; - end; -end; - -class function TFusedKernelRegistry.SnapshotOcbFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FOcbFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FOcbFactories[LI]; - finally - FLock.Leave; - end; -end; - -class function TFusedKernelRegistry.SnapshotCcmFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FCcmFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FCcmFactories[LI]; - finally - FLock.Leave; - end; -end; - -class function TFusedKernelRegistry.SnapshotEaxFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FEaxFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FEaxFactories[LI]; - finally - FLock.Leave; - end; -end; - -class function TFusedKernelRegistry.SnapshotGcmSivFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FGcmSivFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FGcmSivFactories[LI]; - finally - FLock.Leave; - end; -end; - -class function TFusedKernelRegistry.SnapshotCtrFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FCtrFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FCtrFactories[LI]; - finally - FLock.Leave; - end; -end; - -class function TFusedKernelRegistry.SnapshotCbcFactories: TCryptoLibGenericArray; -var - LI, LCount: Int32; -begin - FLock.Enter; - try - LCount := FCbcFactories.Count; - System.SetLength(Result, LCount); - for LI := 0 to LCount - 1 do - Result[LI] := FCbcFactories[LI]; - finally - FLock.Leave; - end; -end; - -{ ---- TryAcquire ------------------------------------------------------------- } - -class function TFusedKernelRegistry.TryAcquireGcm(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if ACipher = nil then Exit; - if AHPowers = nil then Exit; - LSnapshot := SnapshotGcmFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AHPowers, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -class function TFusedKernelRegistry.TryAcquireOcb(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedOcbKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if ACipher = nil then Exit; - LSnapshot := SnapshotOcbFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -class function TFusedKernelRegistry.TryAcquireCcm(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedCcmKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if ACipher = nil then Exit; - LSnapshot := SnapshotCcmFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -class function TFusedKernelRegistry.TryAcquireEax(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedEaxKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if ACipher = nil then Exit; - LSnapshot := SnapshotEaxFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -class function TFusedKernelRegistry.TryAcquireGcmSiv(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmSivKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if AHPowers = nil then Exit; - LSnapshot := SnapshotGcmSivFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AHPowers, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -class function TFusedKernelRegistry.TryAcquireCtr(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedCtrKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if ACipher = nil then Exit; - LSnapshot := SnapshotCtrFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -class function TFusedKernelRegistry.TryAcquireCbc(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; out AKernel: IFusedCbcKernel): Boolean; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - AKernel := nil; - Result := False; - if TFusedKernelGate.ForceDisabled then Exit; - if ACipher = nil then Exit; - LSnapshot := SnapshotCbcFactories; - for LI := 0 to System.Length(LSnapshot) - 1 do - begin - if LSnapshot[LI].TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then - begin - Result := True; - Exit; - end; - end; - AKernel := nil; -end; - -{ ---- Provider queries ------------------------------------------------------- } - -class function TFusedKernelRegistry.GetRegisteredGcmProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotGcmFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -class function TFusedKernelRegistry.GetRegisteredOcbProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotOcbFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -class function TFusedKernelRegistry.GetRegisteredCcmProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotCcmFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -class function TFusedKernelRegistry.GetRegisteredEaxProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotEaxFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -class function TFusedKernelRegistry.GetRegisteredGcmSivProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotGcmSivFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -class function TFusedKernelRegistry.GetRegisteredCtrProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotCtrFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -class function TFusedKernelRegistry.GetRegisteredCbcProviders: TCryptoLibStringArray; -var - LSnapshot: TCryptoLibGenericArray; - LI: Int32; -begin - LSnapshot := SnapshotCbcFactories; - System.SetLength(Result, System.Length(LSnapshot)); - for LI := 0 to System.Length(LSnapshot) - 1 do - Result[LI] := LSnapshot[LI].ProviderName; -end; - -end. diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCbcKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCbcKernel.pas similarity index 83% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCbcKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCbcKernel.pas index ac483a1d..362c03f3 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCbcKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCbcKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedCbcKernel; +unit ClpIAcceleratedCbcKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -23,11 +23,12 @@ interface uses ClpIBlockCipher, ClpCryptoLibTypes, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused CBC body kernel, direction-bound at + /// Mode-specific contract for an accelerated CBC body kernel, direction-bound at /// construction (like the OCB / CCM kernels). Applies the CBC chain over a /// whole run in one call, keeping the chaining value in a register between /// blocks. Encrypt is inherently serial (C_i = E_K(P_i xor C_{i-1})), so its @@ -35,7 +36,7 @@ interface /// C_{i-1}) parallelises and is not yet implemented. Cipher state lives /// inside the implementation; the mode sees only this interface. /// - IFusedCbcKernel = interface + IAcceleratedCbcKernel = interface ['{898E71F2-B3C8-4B44-A3AB-2A493B4AE126}'] /// @@ -52,22 +53,15 @@ interface /// /// Factory contract for CBC-encrypt kernel providers. Registered with - /// TFusedKernelRegistry; the registry walks the factory list (highest + /// TAcceleratedKernelRegistry; the registry walks the factory list (highest /// priority first) and returns the first kernel whose TryCreate succeeds. /// Factories self-probe (CPU features, cipher identity) and wrap construction /// in try/except; TryCreate MUST return False on failure rather than /// propagating. /// - IFusedCbcKernelFactory = interface + IAcceleratedCbcKernelFactory = interface(IAcceleratedKernelFactory) ['{A4FBAB88-8E80-45A0-86E1-B95B6AFBA9A2}'] - /// Stable human-readable provider label (diagnostics / tests). - function ProviderName: String; - - /// Priority class controlling factory order inside the registry; - /// see TFusedKernelPriority. - function Priority: TFusedKernelPriority; - /// /// Attempt to construct a CBC kernel bound to ACipher for ADirection. /// Only Encrypt is implemented today; a Decrypt request returns False @@ -75,8 +69,8 @@ interface /// failure; never raises. /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCbcKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedCbcKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCcmKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCcmKernel.pas similarity index 88% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCcmKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCcmKernel.pas index 4a644fb6..03b912d3 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCcmKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCcmKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedCcmKernel; +unit ClpIAcceleratedCcmKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,11 +22,12 @@ interface uses ClpIBlockCipher, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused CCM body kernel running the + /// Mode-specific contract for an accelerated CCM body kernel running the /// CTR keystream and CBC-MAC lanes together per iteration. /// Direction-bound at construction: encrypt and decrypt take /// different paths through the inner MAC dependency chain. The @@ -34,7 +35,7 @@ interface /// ProcessBody once per Init / Reset cycle covering the full bulk /// body. /// - IFusedCcmKernel = interface + IAcceleratedCcmKernel = interface ['{BEAAEA01-DF32-441F-96AB-77D07C19578D}'] /// Minimum number of 16-byte body blocks the kernel can @@ -58,15 +59,12 @@ interface ACbcMacState: Pointer; ABlockCount: Int32); end; - IFusedCcmKernelFactory = interface + IAcceleratedCcmKernelFactory = interface(IAcceleratedKernelFactory) ['{F30B4F47-0546-4212-A00D-850F2AF4FF5F}'] - function ProviderName: String; - function Priority: TFusedKernelPriority; - function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedCcmKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCtrKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCtrKernel.pas similarity index 82% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCtrKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCtrKernel.pas index c3ddcd59..61905b22 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedCtrKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCtrKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedCtrKernel; +unit ClpIAcceleratedCtrKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -23,19 +23,20 @@ interface uses ClpIBlockCipher, ClpCryptoLibTypes, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused counter (CTR / SIC) body kernel: + /// Mode-specific contract for an accelerated counter (CTR / SIC) body kernel: /// generate AES-CTR keystream and XOR it into the payload in a single pass, /// advancing the counter. It is the non-authenticated, MAC-free member of - /// the fused-kernel family - the shared core the AEAD kernels are built on + /// the accelerated-kernel family - the shared core the AEAD kernels are built on /// (GCM = CTR + GHASH, CCM = CTR + CBC-MAC, EAX = CTR + OMAC). All cipher /// state (the key schedule) lives inside the implementation; the mode sees /// only this interface. /// - IFusedCtrKernel = interface + IAcceleratedCtrKernel = interface ['{2A9F4C71-6E38-4B0D-9C57-1F3B8E26D4A5}'] /// The batch granularity: ProcessCtrBlocks requires ABlockCount to @@ -58,22 +59,15 @@ interface /// /// Factory contract for CTR kernel providers. Registered with - /// TFusedKernelRegistry; the registry walks the per-mode factory list + /// TAcceleratedKernelRegistry; the registry walks the per-mode factory list /// (highest-priority first) and returns the first kernel whose TryCreate /// succeeds. Factories self-probe (CPU features, cipher identity) and wrap /// construction in try/except; TryCreate MUST return False on failure /// rather than propagating. /// - IFusedCtrKernelFactory = interface + IAcceleratedCtrKernelFactory = interface(IAcceleratedKernelFactory) ['{7D1E6B02-4A9C-4F58-8B3D-2C57F1E96A4D}'] - /// Stable human-readable provider label (diagnostics / tests). - function ProviderName: String; - - /// Priority class controlling factory order inside the registry; - /// see TFusedKernelPriority. - function Priority: TFusedKernelPriority; - /// /// Attempt to construct a CTR kernel bound to ACipher. ADirection is /// accepted for signature symmetry with the AEAD factories but ignored: @@ -81,8 +75,8 @@ interface /// the same E_K(counter) stream). /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedCtrKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedCtrKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedEaxKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedEaxKernel.pas similarity index 88% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedEaxKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedEaxKernel.pas index aaa9117f..16d11cb4 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedEaxKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedEaxKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedEaxKernel; +unit ClpIAcceleratedEaxKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,11 +22,12 @@ interface uses ClpIBlockCipher, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused EAX body kernel running the + /// Mode-specific contract for an accelerated EAX body kernel running the /// CTR keystream and OMAC lanes together per iteration. Direction- /// bound at construction: encrypt and decrypt take different paths /// through the inner MAC dependency chain. The kernel owns the @@ -35,7 +36,7 @@ interface /// CBC-MAC running thereafter) and handles nonce-OMAC, header-OMAC, /// and the final-block OMAC subkey XOR. /// - IFusedEaxKernel = interface + IAcceleratedEaxKernel = interface ['{3D87A0D4-7375-453F-BF72-CA3CA191CDCB}'] /// Minimum number of 16-byte body blocks the kernel can @@ -57,15 +58,12 @@ interface AOmacState: Pointer; ABlockCount: Int32); end; - IFusedEaxKernelFactory = interface + IAcceleratedEaxKernelFactory = interface(IAcceleratedKernelFactory) ['{E3DDE544-91EF-4E41-B707-7ACD366FDB0A}'] - function ProviderName: String; - function Priority: TFusedKernelPriority; - function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedEaxKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedEaxKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedGcmKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmKernel.pas similarity index 83% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedGcmKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmKernel.pas index 51c0c6a4..6f87c25b 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedGcmKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedGcmKernel; +unit ClpIAcceleratedGcmKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,18 +22,19 @@ interface uses ClpIBlockCipher, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused GCM body kernel: produce + /// Mode-specific contract for an accelerated GCM body kernel: produce /// keystream for the current batch, XOR it into the payload, and /// fold the previous batch's ciphertext into the running GHASH /// accumulator. All cipher state (key schedule, H-power table, /// static constants) lives inside the implementation; the mode /// sees only this interface. /// - IFusedGcmKernel = interface + IAcceleratedGcmKernel = interface ['{D4D7F5F0-3C56-44E0-8BDD-944AC05E4D2E}'] /// Number of 16-byte blocks per batch consumed by @@ -58,24 +59,16 @@ interface /// /// Factory contract for GCM kernel providers. Registered with - /// TFusedKernelRegistry; the registry walks the per-mode factory + /// TAcceleratedKernelRegistry; the registry walks the per-mode factory /// list (highest-priority first) and returns the first kernel /// whose TryCreate succeeds. Factories self-probe (CPU features, /// cipher identity, direction support) and wrap construction in /// try/except; TryCreate MUST return False on failure rather than /// propagating. /// - IFusedGcmKernelFactory = interface + IAcceleratedGcmKernelFactory = interface(IAcceleratedKernelFactory) ['{6F25C598-3089-40DA-8A81-9C898A5FCBE1}'] - /// Stable human-readable provider label (used for - /// diagnostics, benchmark labelling, and test assertions). - function ProviderName: String; - - /// Priority class controlling factory order inside the - /// registry; see TFusedKernelPriority. - function Priority: TFusedKernelPriority; - /// /// Attempt to construct a kernel bound to ACipher for the /// requested ADirection, capturing AHPowers as its pre-computed @@ -83,8 +76,8 @@ interface /// pointer MUST outlive the returned kernel. /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; AHPowers: Pointer; - out AKernel: IFusedGcmKernel): Boolean; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; + out AKernel: IAcceleratedGcmKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedGcmSivKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas similarity index 83% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedGcmSivKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas index 81fb67e3..5c9bbc30 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedGcmSivKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedGcmSivKernel; +unit ClpIAcceleratedGcmSivKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,18 +22,19 @@ interface uses ClpIBlockCipher, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused GCM-SIV POLYVAL batch kernel. - /// GCM-SIV's fused path is authentication-only and does not touch + /// Mode-specific contract for an accelerated GCM-SIV POLYVAL batch kernel. + /// GCM-SIV's accelerated path is authentication-only and does not touch /// the cipher's key schedule; the kernel is therefore intrinsically /// cipher-agnostic, but is still registered through the shared - /// factory registry for uniformity with the other fused AEAD + /// factory registry for uniformity with the other accelerated AEAD /// kernels. /// - IFusedGcmSivKernel = interface + IAcceleratedGcmSivKernel = interface ['{5FA774F0-42CC-407C-9410-1D5D66421F66}'] /// Number of 16-byte blocks absorbed per @@ -58,16 +59,13 @@ interface /// kernel. ADirection is accepted for registry uniformity but /// POLYVAL is direction-agnostic and it is typically ignored. /// - IFusedGcmSivKernelFactory = interface + IAcceleratedGcmSivKernelFactory = interface(IAcceleratedKernelFactory) ['{5EA5178B-93BD-4E96-B19E-C09B04B32655}'] - function ProviderName: String; - function Priority: TFusedKernelPriority; - function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; + ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IFusedGcmSivKernel): Boolean; + out AKernel: IAcceleratedGcmSivKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedOcbKernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedOcbKernel.pas similarity index 92% rename from CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedOcbKernel.pas rename to CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedOcbKernel.pas index 132129d3..cc9312af 100644 --- a/CryptoLib/src/Interfaces/Crypto/Modes/Fused/ClpIFusedOcbKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedOcbKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIFusedOcbKernel; +unit ClpIAcceleratedOcbKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,15 +22,16 @@ interface uses ClpIBlockCipher, - ClpFusedKernelTypes; + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; type /// - /// Mode-specific contract for a fused OCB body kernel. All cipher + /// Mode-specific contract for an accelerated OCB body kernel. All cipher /// state lives inside the implementation; the mode sees only this /// interface. /// - IFusedOcbKernel = interface + IAcceleratedOcbKernel = interface ['{ADAF5C2A-FD31-42EF-A266-EB4B0F9AC06D}'] /// The minimum (and alignment) batch width the kernel @@ -40,7 +41,7 @@ interface /// /// Process ABlockCount blocks of OCB body in a single call with - /// the offset ladder, L-table lookup and checksum fold all fused + /// the offset ladder, L-table lookup and checksum fold all combined /// inside the kernel. /// ABlockCount MUST be a positive multiple of MinimumBlockCount; /// the kernel iterates internally in MinimumBlockCount-sized @@ -84,12 +85,9 @@ interface AStartBlockCount: UInt64); end; - IFusedOcbKernelFactory = interface + IAcceleratedOcbKernelFactory = interface(IAcceleratedKernelFactory) ['{A430371B-1B11-46C2-AFC8-EF9B07DE4CFA}'] - function ProviderName: String; - function Priority: TFusedKernelPriority; - /// /// Attempt to construct an OCB kernel bound to ACipher for the /// requested ADirection. Returns False with AKernel = nil on any @@ -97,8 +95,8 @@ interface /// construction exception); never raises. /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TFusedModeDirection; - out AKernel: IFusedOcbKernel): Boolean; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedOcbKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas new file mode 100644 index 00000000..5371438d --- /dev/null +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas @@ -0,0 +1,51 @@ +{ *********************************************************************************** } +{ * CryptoLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license.php. * } +{ * * } +{ * Acknowledgements: * } +{ * * } +{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } +{ * the development of this library * } +{ * ******************************************************************************* * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +unit ClpIAcceleratedKernelFactory; + +{$I ..\..\..\Include\CryptoLib.inc} + +interface + +uses + ClpAcceleratedKernelTypes; + +type + /// + /// Family-agnostic base contract shared by every accelerated kernel factory + /// (block-cipher AEAD modes and stream-cipher AEADs alike). It carries only + /// the identity and ordering a factory needs to live in the registry; the + /// actual TryCreate lives on each derived factory interface with its own + /// strongly-typed cipher parameter. The registry stores factories through + /// this base and rediscovers a concrete family with Supports(); an external + /// consumer can therefore register an accelerated kernel for an algorithm the + /// framework never enumerated, with no framework edit. + /// + IAcceleratedKernelFactory = interface + ['{006B1103-17E9-43C6-9A7A-EB515B120325}'] + + /// Stable human-readable provider label (diagnostics / tests). + function ProviderName: String; + + /// Priority class controlling factory order inside the registry; + /// see TAcceleratedKernelPriority. Higher wins; equal priorities keep + /// registration order. + function Priority: TAcceleratedKernelPriority; + end; + +implementation + +end. diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas b/CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas new file mode 100644 index 00000000..a40b2b79 --- /dev/null +++ b/CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas @@ -0,0 +1,83 @@ +{ *********************************************************************************** } +{ * CryptoLib Library * } +{ * Author - Ugochukwu Mmaduekwe * } +{ * Github Repository * } +{ * * } +{ * Distributed under the MIT software license, see the accompanying file LICENSE * } +{ * or visit http://www.opensource.org/licenses/mit-license.php. * } +{ * * } +{ * Acknowledgements: * } +{ * * } +{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * } +{ * the development of this library * } +{ * ******************************************************************************* * } + +(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) + +unit ClpIAcceleratedChaCha20Poly1305Kernel; + +{$I ..\..\..\..\Include\CryptoLib.inc} + +interface + +uses + ClpIStreamCipher, + ClpAcceleratedKernelTypes, + ClpIAcceleratedKernelFactory; + +type + /// + /// Mode-specific contract for an accelerated ChaCha20-Poly1305 body kernel: in a + /// single pass over a run of 512-byte (8 x 64-byte) strides, generate the + /// ChaCha20 keystream, XOR it into the payload, and fold the appropriate + /// bytes into the running Poly1305 accumulator - encrypt folds the produced + /// ciphertext (encrypt-then-MAC per stride), decrypt folds the input + /// ciphertext before the XOR (MAC-then-decrypt). This is the stream-cipher + /// analogue of the block-cipher accelerated kernels (GCM = CTR + GHASH); the + /// engine key schedule and Poly1305 r/s clamp live inside the implementation. + /// + IAcceleratedChaCha20Poly1305Kernel = interface + ['{87051735-EA07-4800-A6D9-A8922BFDF6A2}'] + + /// Stride granularity in bytes (512 = 8 x 64-byte ChaCha blocks). + /// ProcessStrides consumes a positive multiple of this in one call. + function StrideBytes: Int32; + + /// + /// Process AStrideCount consecutive StrideBytes-sized strides in one pass, + /// interleaving ChaCha20 keystream XOR with Poly1305 accumulation. + /// AChaChaState points at the engine block state (counter advanced in + /// place); APoly1305State points at the running Poly1305 accumulator + /// (updated in place). AForEncrypt selects encrypt-then-MAC vs + /// MAC-then-decrypt. AInPtr and AOutPtr are identical (in-place) or fully + /// disjoint. + /// + procedure ProcessStrides(AInPtr, AOutPtr, AChaChaState, APoly1305State: Pointer; + AStrideCount: NativeInt; AForEncrypt: Boolean); + end; + + /// + /// Factory contract for accelerated ChaCha20-Poly1305 kernel providers. Registered + /// with TAcceleratedKernelRegistry through the family-agnostic IAcceleratedKernelFactory + /// base; the registry re-discovers it via Supports(). Factories self-probe + /// (CPU features, Supports(ACipher, IChaCha7539Engine)) and wrap construction + /// in try/except; TryCreate MUST return False on failure rather than + /// propagating. + /// + IAcceleratedChaCha20Poly1305KernelFactory = interface(IAcceleratedKernelFactory) + ['{A633B415-7A54-44D7-B983-18BBECC2B32F}'] + + /// + /// Attempt to construct an accelerated kernel bound to ACipher (a stream cipher; + /// the factory probes Supports(ACipher, IChaCha7539Engine) for the concrete + /// engine). ADirection is accepted for symmetry with the AEAD factories; + /// the kernel handles both directions via ProcessStrides' AForEncrypt. + /// + function TryCreate(const ACipher: IStreamCipher; + ADirection: TAcceleratedKernelDirection; + out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; + end; + +implementation + +end. diff --git a/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk b/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk index ddbdc48c..32cfc246 100644 --- a/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk +++ b/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk @@ -685,26 +685,29 @@ contains ClpEaxBlockCipher in '..\..\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpFusedKernelTypes in '..\..\Interfaces\Crypto\Modes\Fused\ClpFusedKernelTypes.pas', - ClpIFusedGcmKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmKernel.pas', - ClpIFusedOcbKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedOcbKernel.pas', - ClpIFusedCcmKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedCcmKernel.pas', - ClpIFusedEaxKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedEaxKernel.pas', - ClpIFusedGcmSivKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedGcmSivKernel.pas', - ClpIFusedCtrKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedCtrKernel.pas', - ClpIFusedCbcKernel in '..\..\Interfaces\Crypto\Modes\Fused\ClpIFusedCbcKernel.pas', - ClpFusedKernelRegistry in '..\..\Crypto\Modes\Fused\ClpFusedKernelRegistry.pas', - ClpAesFusedAeadSimd in '..\..\Crypto\Modes\Fused\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\Crypto\Modes\Fused\Internal\ClpAesNiFusedX86Backend.pas', + ClpAcceleratedKernelTypes in '..\..\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', + ClpIAcceleratedKernelFactory in '..\..\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', + ClpIAcceleratedGcmKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', + ClpIAcceleratedOcbKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', + ClpIAcceleratedCcmKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', + ClpIAcceleratedEaxKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', + ClpIAcceleratedGcmSivKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', + ClpIAcceleratedCtrKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', + ClpIAcceleratedCbcKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', + ClpAcceleratedKernelFactoryBase in '..\..\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', + ClpAcceleratedKernelRegistry in '..\..\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + ClpAesFusedAeadSimd in '..\..\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\Crypto\Modes\Fused\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\Crypto\Modes\Fused\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\Crypto\Modes\Fused\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\Crypto\Modes\Fused\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\Crypto\Modes\Fused\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\Crypto\Modes\Fused\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\Crypto\Modes\Fused\ClpPclmulGcmSivKernel.pas', - ClpFusedKernelDefaults in '..\..\Crypto\Modes\Fused\ClpFusedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', + ClpAcceleratedKernelDefaults in '..\..\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', ClpAeadParameters in '..\..\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\Crypto\ClpBufferedAeadBlockCipher.pas', diff --git a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk index 37b2c89c..4c50680e 100644 --- a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk +++ b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk @@ -10,7 +10,7 @@ - + @@ -31,7 +31,7 @@ Acknowledgements: Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the development of this library "/> - + @@ -2706,60 +2706,60 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - - + + @@ -3178,7 +3178,7 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - + @@ -3190,11 +3190,11 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - + @@ -3206,17 +3206,29 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - + + + + + + + + + + + + + diff --git a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas index 9ce3f30f..0a492e6f 100644 --- a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas +++ b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas @@ -218,11 +218,11 @@ interface ClpArmSimdFeatures, ClpSimdLevels, ClpX86SimdFeatures, ClpArmHwCapProvider, ClpDarwinSysCtl, ClpIBulkBlockCipherMode, ClpIBulkBlockCipher, ClpBlockCipherBulkUtilities, ClpCipherModeParameterUtilities, - ClpGcmSivUtilities, ClpFusedKernelTypes, ClpIFusedGcmKernel, - ClpIFusedOcbKernel, ClpIFusedCcmKernel, ClpIFusedEaxKernel, - ClpIFusedGcmSivKernel, ClpFusedKernelRegistry, ClpAesFusedAeadSimd, + ClpGcmSivUtilities, ClpAcceleratedKernelTypes, ClpIAcceleratedGcmKernel, + ClpIAcceleratedOcbKernel, ClpIAcceleratedCcmKernel, ClpIAcceleratedEaxKernel, + ClpIAcceleratedGcmSivKernel, ClpAcceleratedKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiOcbKernel, ClpAesNiCcmKernel, ClpAesNiEaxKernel, ClpAesNiGcmKernel, - ClpPclmulGcmSivKernel, ClpFusedKernelDefaults, ClpXChaCha20Engine, + ClpPclmulGcmSivKernel, ClpAcceleratedKernelDefaults, ClpXChaCha20Engine, ClpIXChaCha20Engine, ClpXChaCha20Poly1305, ClpIXChaCha20Poly1305, ClpDigestStream, ClpMacSink, ClpMacStream, ClpSignerStream, ClpDefaultMacCalculator, ClpDefaultMacResult, ClpIMacAlgorithmFinder, @@ -256,8 +256,10 @@ interface ClpSalsaX86Backend, ClpPoly1305State, ClpPoly1305Simd, ClpPoly1305X86Backend, ClpGhashSimd, ClpGhashX86Backend, ClpGcmSivSimd, ClpGcmSivX86Backend, ClpAesNiFusedX86Backend, ClpBinPolySimd, ClpAesSimd, - ClpIFusedCtrKernel, ClpAesNiCtrKernel, ClpByteXorSimd, ClpByteXorX86Backend, - ClpIFusedCbcKernel, ClpAesNiCbcKernel, ClpIBulkStreamCipher; + ClpIAcceleratedCtrKernel, ClpAesNiCtrKernel, ClpByteXorSimd, ClpByteXorX86Backend, + ClpIAcceleratedCbcKernel, ClpAesNiCbcKernel, ClpIBulkStreamCipher, + ClpIAcceleratedKernelFactory, ClpIAcceleratedChaCha20Poly1305Kernel, + ClpAcceleratedKernelFactoryBase; implementation From 04eed786306e205803a1235fd5e3acc0a6edb337 Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Fri, 10 Jul 2026 06:01:57 +0100 Subject: [PATCH 2/4] Compact accelerated-kernel registry: drop redundant per-mode API The 16 Register*/Unregister*Factory wrappers were one-line pass-throughs to the generic Register/Unregister - redundant, since every IAccelerated KernelFactory already descends IAcceleratedKernelFactory and upcasts to the base-typed parameter. 7 of 8 Unregister wrappers and 7 of 8 GetRegistered* Providers had no callers at all. - Delete the 16 Register*/Unregister*Factory wrappers; in-tree initialization blocks and the contract test now call the generic Register/Unregister - the same public API an external plugin uses (dogfoods the extensibility path). - Collapse the 8 GetRegistered*Providers into one GetRegisteredProviders(const AFactoryIID: TGUID); pass a factory interface, e.g. GetRegisteredProviders(IAcceleratedGcmKernelFactory) - the same interface-to-GUID substitution the TryAcquire* Supports() calls already use. - Keep the 8 typed TryAcquire* (their TryCreate signatures genuinely diverge: AHPowers for GCM/GCM-SIV, IStreamCipher for ChaCha20-Poly1305). --- .../AcceleratedExternalRegistrationTests.pas | 46 +-- .../Accelerated/Block/ClpAesNiCbcKernel.pas | 2 +- .../Accelerated/Block/ClpAesNiCcmKernel.pas | 2 +- .../Accelerated/Block/ClpAesNiCtrKernel.pas | 2 +- .../Accelerated/Block/ClpAesNiEaxKernel.pas | 2 +- .../Accelerated/Block/ClpAesNiGcmKernel.pas | 2 +- .../Accelerated/Block/ClpAesNiOcbKernel.pas | 2 +- .../Block/ClpPclmulGcmSivKernel.pas | 2 +- .../ClpAcceleratedKernelRegistry.pas | 266 +----------------- 9 files changed, 39 insertions(+), 287 deletions(-) diff --git a/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas b/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas index 844f318f..51dc25f1 100644 --- a/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas +++ b/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas @@ -59,12 +59,12 @@ TMockExternalGcmKernelFactory = class sealed(TInterfacedObject, /// CryptoLib" contract. A mock third-party factory is registered /// from test code exactly the way a consumer's own unit would /// register from its initialization block. The tests assert that: - /// * after RegisterGcmFactory, GetRegisteredGcmProviders + /// * after Register, GetRegisteredProviders(IAcceleratedGcmKernelFactory) /// reflects the mock; /// * registration is strictly additive -- every provider that /// was already present is still present afterwards (defaults /// coexist); - /// * UnregisterGcmFactory returns the provider list to its + /// * Unregister returns the provider list to its /// prior state. /// Any future change that silently regresses this external /// registration contract will trip a red test here. @@ -88,21 +88,21 @@ implementation resourcestring SMockMustBePresent = 'Mock external GCM factory must appear in ' + - 'GetRegisteredGcmProviders after RegisterGcmFactory.'; + 'GetRegisteredProviders(IAcceleratedGcmKernelFactory) after Register.'; SMockMustBeAbsent = 'Mock external GCM factory must be absent from ' + - 'GetRegisteredGcmProviders after UnregisterGcmFactory.'; + 'GetRegisteredProviders(IAcceleratedGcmKernelFactory) after Unregister.'; SCountMustGrowByOne = - 'External RegisterGcmFactory must grow the provider count by ' + + 'External Register must grow the provider count by ' + 'exactly one (non-duplicate factory).'; SCountMustRestoreBaseline = - 'External UnregisterGcmFactory must restore the provider count ' + + 'External Unregister must restore the provider count ' + 'to its pre-registration baseline.'; SDefaultsMustSurvive = 'Every provider present before external registration must still ' + 'be reported afterwards (registration is strictly additive).'; SDuplicateMustBeIgnored = - 'RegisterGcmFactory MUST silently ignore duplicate registrations ' + + 'Register MUST silently ignore duplicate registrations ' + '(same interface identity).'; { TMockExternalGcmKernelFactory } @@ -151,13 +151,13 @@ procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationAddsProvi LProviders: TCryptoLibStringArray; begin LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Register(LFactory); try - LProviders := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + LProviders := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); CheckTrue(ProvidersContain(LProviders, CMockExternalProviderName), SMockMustBePresent); finally - TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Unregister(LFactory); end; end; @@ -167,11 +167,11 @@ procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationIsStrictl LBaseline, LAfter: TCryptoLibStringArray; LIndex: Int32; begin - LBaseline := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + LBaseline := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Register(LFactory); try - LAfter := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + LAfter := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); CheckEquals(System.Length(LBaseline) + 1, System.Length(LAfter), SCountMustGrowByOne); // Every baseline name must survive the registration. @@ -179,7 +179,7 @@ procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationIsStrictl CheckTrue(ProvidersContain(LAfter, LBaseline[LIndex]), SDefaultsMustSurvive); finally - TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Unregister(LFactory); end; end; @@ -189,12 +189,12 @@ procedure TTestAcceleratedExternalRegistration.TestExternalUnregistrationRestore LBaseline, LAfterUnregister: TCryptoLibStringArray; LIndex: Int32; begin - LBaseline := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + LBaseline := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); - TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Register(LFactory); + TAcceleratedKernelRegistry.Unregister(LFactory); - LAfterUnregister := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + LAfterUnregister := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); CheckEquals(System.Length(LBaseline), System.Length(LAfterUnregister), SCountMustRestoreBaseline); CheckFalse(ProvidersContain(LAfterUnregister, CMockExternalProviderName), @@ -209,16 +209,16 @@ procedure TTestAcceleratedExternalRegistration.TestDuplicateExternalRegistration LFactory: IAcceleratedGcmKernelFactory; LBaseline, LAfter: TCryptoLibStringArray; begin - LBaseline := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + LBaseline := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Register(LFactory); try - TAcceleratedKernelRegistry.RegisterGcmFactory(LFactory); - LAfter := TAcceleratedKernelRegistry.GetRegisteredGcmProviders; + TAcceleratedKernelRegistry.Register(LFactory); + LAfter := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); CheckEquals(System.Length(LBaseline) + 1, System.Length(LAfter), SDuplicateMustBeIgnored); finally - TAcceleratedKernelRegistry.UnregisterGcmFactory(LFactory); + TAcceleratedKernelRegistry.Unregister(LFactory); end; end; diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas index 370fe748..5670f0ec 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas @@ -196,7 +196,7 @@ function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterCbcFactory( + TAcceleratedKernelRegistry.Register( TAesNiCbcKernelFactory.Create() as IAcceleratedCbcKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas index 4c7c6830..68cbb6a9 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas @@ -307,7 +307,7 @@ function TAesNiCcmKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterCcmFactory( + TAcceleratedKernelRegistry.Register( TAesNiCcmKernelFactory.Create() as IAcceleratedCcmKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas index 56462b9f..3ab683db 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas @@ -200,7 +200,7 @@ function TAesNiCtrKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterCtrFactory( + TAcceleratedKernelRegistry.Register( TAesNiCtrKernelFactory.Create() as IAcceleratedCtrKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas index 9c207158..a5892bd3 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas @@ -294,7 +294,7 @@ function TAesNiEaxKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterEaxFactory( + TAcceleratedKernelRegistry.Register( TAesNiEaxKernelFactory.Create() as IAcceleratedEaxKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas index 1c0456b9..7fb13318 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas @@ -237,7 +237,7 @@ function TAesNiGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterGcmFactory( + TAcceleratedKernelRegistry.Register( TAesNiGcmKernelFactory.Create() as IAcceleratedGcmKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas index 44afac6e..41e793d0 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas @@ -291,7 +291,7 @@ function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterOcbFactory( + TAcceleratedKernelRegistry.Register( TAesNiOcbKernelFactory.Create() as IAcceleratedOcbKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas b/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas index 637bfffd..ef8bf998 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas +++ b/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas @@ -118,7 +118,7 @@ function TPclmulGcmSivKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.RegisterGcmSivFactory( + TAcceleratedKernelRegistry.Register( TPclmulGcmSivKernelFactory.Create() as IAcceleratedGcmSivKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas index 6c8fa280..7791b7dd 100644 --- a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas +++ b/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas @@ -86,24 +86,6 @@ TAcceleratedKernelRegistry = class sealed(TObject) /// resolve an accelerated kernel the framework never enumerated. class function GetSnapshot: TCryptoLibGenericArray; static; - class procedure RegisterGcmFactory(const AFactory: IAcceleratedGcmKernelFactory); static; - class procedure RegisterOcbFactory(const AFactory: IAcceleratedOcbKernelFactory); static; - class procedure RegisterCcmFactory(const AFactory: IAcceleratedCcmKernelFactory); static; - class procedure RegisterEaxFactory(const AFactory: IAcceleratedEaxKernelFactory); static; - class procedure RegisterGcmSivFactory(const AFactory: IAcceleratedGcmSivKernelFactory); static; - class procedure RegisterCtrFactory(const AFactory: IAcceleratedCtrKernelFactory); static; - class procedure RegisterCbcFactory(const AFactory: IAcceleratedCbcKernelFactory); static; - class procedure RegisterChaCha20Poly1305Factory(const AFactory: IAcceleratedChaCha20Poly1305KernelFactory); static; - - class procedure UnregisterGcmFactory(const AFactory: IAcceleratedGcmKernelFactory); static; - class procedure UnregisterOcbFactory(const AFactory: IAcceleratedOcbKernelFactory); static; - class procedure UnregisterCcmFactory(const AFactory: IAcceleratedCcmKernelFactory); static; - class procedure UnregisterEaxFactory(const AFactory: IAcceleratedEaxKernelFactory); static; - class procedure UnregisterGcmSivFactory(const AFactory: IAcceleratedGcmSivKernelFactory); static; - class procedure UnregisterCtrFactory(const AFactory: IAcceleratedCtrKernelFactory); static; - class procedure UnregisterCbcFactory(const AFactory: IAcceleratedCbcKernelFactory); static; - class procedure UnregisterChaCha20Poly1305Factory(const AFactory: IAcceleratedChaCha20Poly1305KernelFactory); static; - class function TryAcquireGcm(const ACipher: IBlockCipher; ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; out AKernel: IAcceleratedGcmKernel): Boolean; static; @@ -123,16 +105,10 @@ TAcceleratedKernelRegistry = class sealed(TObject) class function TryAcquireChaCha20Poly1305(const ACipher: IStreamCipher; ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; static; - /// Snapshot of ProviderName strings in current priority order. - /// Used for diagnostics and test assertions. - class function GetRegisteredGcmProviders: TCryptoLibStringArray; static; - class function GetRegisteredOcbProviders: TCryptoLibStringArray; static; - class function GetRegisteredCcmProviders: TCryptoLibStringArray; static; - class function GetRegisteredEaxProviders: TCryptoLibStringArray; static; - class function GetRegisteredGcmSivProviders: TCryptoLibStringArray; static; - class function GetRegisteredCtrProviders: TCryptoLibStringArray; static; - class function GetRegisteredCbcProviders: TCryptoLibStringArray; static; - class function GetRegisteredChaCha20Poly1305Providers: TCryptoLibStringArray; static; + /// Provider-name list (priority order) of every registered factory + /// supporting AFactoryIID. Pass a per-mode factory interface, e.g. + /// GetRegisteredProviders(IAcceleratedGcmKernelFactory). Diagnostics/tests. + class function GetRegisteredProviders(const AFactoryIID: TGUID): TCryptoLibStringArray; static; end; implementation @@ -213,104 +189,6 @@ class function TAcceleratedKernelRegistry.GetSnapshot: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedGcmKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedGcmKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredOcbProviders: TCryptoLibStringArray; -var - LSnap: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedOcbKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedOcbKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredCcmProviders: TCryptoLibStringArray; -var - LSnap: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedCcmKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedCcmKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredEaxProviders: TCryptoLibStringArray; -var - LSnap: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedEaxKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedEaxKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredGcmSivProviders: TCryptoLibStringArray; +class function TAcceleratedKernelRegistry.GetRegisteredProviders( + const AFactoryIID: TGUID): TCryptoLibStringArray; var LSnap: TCryptoLibGenericArray; LI, LN: Int32; - LFac: IAcceleratedGcmSivKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedGcmSivKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredCtrProviders: TCryptoLibStringArray; -var - LSnap: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedCtrKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedCtrKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredCbcProviders: TCryptoLibStringArray; -var - LSnap: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedCbcKernelFactory; -begin - LSnap := Snapshot; - System.SetLength(Result, 0); - LN := 0; - for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedCbcKernelFactory, LFac) then - begin - System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; - Inc(LN); - end; -end; - -class function TAcceleratedKernelRegistry.GetRegisteredChaCha20Poly1305Providers: TCryptoLibStringArray; -var - LSnap: TCryptoLibGenericArray; - LI, LN: Int32; - LFac: IAcceleratedChaCha20Poly1305KernelFactory; begin LSnap := Snapshot; - System.SetLength(Result, 0); + Result := nil; LN := 0; for LI := 0 to System.Length(LSnap) - 1 do - if Supports(LSnap[LI], IAcceleratedChaCha20Poly1305KernelFactory, LFac) then + if Supports(LSnap[LI], AFactoryIID) then begin System.SetLength(Result, LN + 1); - Result[LN] := LFac.ProviderName; + Result[LN] := LSnap[LI].ProviderName; Inc(LN); end; end; From ceb536fdb6a9002030bbe3fde2791e8998adff28 Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Fri, 10 Jul 2026 06:32:00 +0100 Subject: [PATCH 3/4] Rename accelerated-kernel framework to cipher-kernel; scope on the hub The framework hosts only cipher (AEAD + mode) kernels, but "Accelerated" didn't say so and the per-mode names were long. Put the domain word on the shared hub and let the concrete contracts be bare - the cipher scope reads through the inheritance without repeating it. - Hub: TAcceleratedKernel{Registry,Gate,Priority,Direction,FactoryBase} and IAcceleratedKernelFactory -> TCipherKernel* / ICipherKernelFactory. - Per-mode: IAcceleratedKernel(Factory) -> IKernel(Factory), e.g. IGcmKernel, IChaCha20Poly1305Kernel. Each descends ICipherKernelFactory, so "a GCM kernel, which is a cipher-kernel" needs no prefix (and it's shorter: IChaCha20Poly1305Kernel is 23 chars vs 34). - Folder Crypto/Accelerated -> Crypto/CipherKernels (same depth, so the shared SIMD nested-include constraint is untouched). - Tests: RunWithAcceleratedToggle -> RunWithCipherKernelToggle; AcceleratedExternalRegistrationTests -> CipherKernelExternalRegistrationTests. Genuinely-fused impl artifacts keep their names (ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend, the *Fused* asm). Prose "accelerated" was rebranded only where it named the framework; nature descriptions (hardware-accelerated engine, SIMD-accelerated bulk path) stay. --- .../Delphi/CryptoLib.BenchmarkConsole.dpr | 44 ++-- .../Delphi.Examples/CryptoLib.Examples.dpr | 44 ++-- .../Delphi.Tests/CryptoLib.Tests.Mobile.dpr | 48 ++--- .../Delphi.Tests/CryptoLib.Tests.Mobile.dproj | 48 ++--- .../Delphi.Tests/CryptoLib.Tests.dpr | 48 ++--- .../FreePascal.Tests/CryptoLib.Tests.lpi | 4 +- .../FreePascal.Tests/CryptoLib.lpr | 4 +- .../FreePascal.Tests/CryptoLibConsole.lpi | 4 +- .../FreePascal.Tests/CryptoLibConsole.lpr | 4 +- CryptoLib.Tests/src/Crypto/CcmTests.pas | 18 +- ...CipherKernelExternalRegistrationTests.pas} | 90 ++++----- CryptoLib.Tests/src/Crypto/EaxTests.pas | 14 +- CryptoLib.Tests/src/Crypto/GCMTests.pas | 16 +- .../src/Crypto/GcmSivBulkParityTests.pas | 14 +- CryptoLib.Tests/src/Crypto/GcmSivTests.pas | 18 +- CryptoLib.Tests/src/Crypto/OcbTests.pas | 12 +- ...ernelToggle.pas => CipherKernelToggle.pas} | 20 +- .../Block/ClpAesNiCbcKernel.pas | 26 +-- .../Block/ClpAesNiCcmKernel.pas | 34 ++-- .../Block/ClpAesNiCtrKernel.pas | 24 +-- .../Block/ClpAesNiEaxKernel.pas | 34 ++-- .../Block/ClpAesNiGcmKernel.pas | 28 +-- .../Block/ClpAesNiOcbKernel.pas | 36 ++-- .../Block/ClpPclmulGcmSivKernel.pas | 28 +-- .../Block/Internal/ClpAesFusedAeadSimd.pas | 0 .../Internal/ClpAesNiFusedX86Backend.pas | 0 .../ClpCipherKernelDefaults.pas} | 4 +- .../ClpCipherKernelFactoryBase.pas} | 18 +- .../ClpCipherKernelRegistry.pas} | 190 +++++++++--------- .../ClpCipherKernelTypes.pas} | 10 +- .../src/Crypto/Modes/ClpCbcBlockCipher.pas | 10 +- .../src/Crypto/Modes/ClpCcmBlockCipher.pas | 18 +- .../src/Crypto/Modes/ClpChaCha20Poly1305.pas | 16 +- .../src/Crypto/Modes/ClpEaxBlockCipher.pas | 18 +- .../src/Crypto/Modes/ClpGcmBlockCipher.pas | 28 +-- .../src/Crypto/Modes/ClpGcmSivBlockCipher.pas | 16 +- .../src/Crypto/Modes/ClpOcbBlockCipher.pas | 22 +- .../src/Crypto/Modes/ClpSicBlockCipher.pas | 12 +- .../Block/ClpICbcKernel.pas} | 16 +- .../Block/ClpICcmKernel.pas} | 14 +- .../Block/ClpICtrKernel.pas} | 18 +- .../Block/ClpIEaxKernel.pas} | 14 +- .../Block/ClpIGcmKernel.pas} | 16 +- .../Block/ClpIGcmSivKernel.pas} | 14 +- .../Block/ClpIOcbKernel.pas} | 14 +- .../ClpICipherKernelFactory.pas} | 14 +- .../Stream/ClpIChaCha20Poly1305Kernel.pas} | 18 +- .../Delphi/CryptoLib4PascalPackage.dpk | 44 ++-- .../Packages/FPC/CryptoLib4PascalPackage.lpk | 72 +++---- .../Packages/FPC/CryptoLib4PascalPackage.pas | 16 +- 50 files changed, 645 insertions(+), 647 deletions(-) rename CryptoLib.Tests/src/Crypto/{AcceleratedExternalRegistrationTests.pas => CipherKernelExternalRegistrationTests.pas} (68%) rename CryptoLib.Tests/src/Utils/{AcceleratedKernelToggle.pas => CipherKernelToggle.pas} (76%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpAesNiCbcKernel.pas (89%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpAesNiCcmKernel.pas (91%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpAesNiCtrKernel.pas (90%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpAesNiEaxKernel.pas (90%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpAesNiGcmKernel.pas (91%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpAesNiOcbKernel.pas (90%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/ClpPclmulGcmSivKernel.pas (83%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/Internal/ClpAesFusedAeadSimd.pas (100%) rename CryptoLib/src/Crypto/{Accelerated => CipherKernels}/Block/Internal/ClpAesNiFusedX86Backend.pas (100%) rename CryptoLib/src/Crypto/{Accelerated/ClpAcceleratedKernelDefaults.pas => CipherKernels/ClpCipherKernelDefaults.pas} (94%) rename CryptoLib/src/Crypto/{Accelerated/ClpAcceleratedKernelFactoryBase.pas => CipherKernels/ClpCipherKernelFactoryBase.pas} (77%) rename CryptoLib/src/Crypto/{Accelerated/ClpAcceleratedKernelRegistry.pas => CipherKernels/ClpCipherKernelRegistry.pas} (56%) rename CryptoLib/src/Crypto/{Accelerated/ClpAcceleratedKernelTypes.pas => CipherKernels/ClpCipherKernelTypes.pas} (88%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedCbcKernel.pas => CipherKernels/Block/ClpICbcKernel.pas} (89%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedCcmKernel.pas => CipherKernels/Block/ClpICcmKernel.pas} (91%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedCtrKernel.pas => CipherKernels/Block/ClpICtrKernel.pas} (88%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedEaxKernel.pas => CipherKernels/Block/ClpIEaxKernel.pas} (90%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedGcmKernel.pas => CipherKernels/Block/ClpIGcmKernel.pas} (90%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas => CipherKernels/Block/ClpIGcmSivKernel.pas} (90%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Block/ClpIAcceleratedOcbKernel.pas => CipherKernels/Block/ClpIOcbKernel.pas} (93%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/ClpIAcceleratedKernelFactory.pas => CipherKernels/ClpICipherKernelFactory.pas} (84%) rename CryptoLib/src/Interfaces/Crypto/{Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas => CipherKernels/Stream/ClpIChaCha20Poly1305Kernel.pas} (87%) diff --git a/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr b/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr index d2ed6189..e975cc22 100644 --- a/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr +++ b/CryptoLib.Benchmark/Delphi/CryptoLib.BenchmarkConsole.dpr @@ -686,31 +686,31 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', - ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + ClpCipherKernelTypes in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelTypes.pas', + ClpICipherKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\ClpICipherKernelFactory.pas', - ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', - ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', - ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', - ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', - ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', - ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', - ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', - ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', - ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + ClpIChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Stream\ClpIChaCha20Poly1305Kernel.pas', + ClpIGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmKernel.pas', + ClpIOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIOcbKernel.pas', + ClpICcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICcmKernel.pas', + ClpIEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIEaxKernel.pas', + ClpIGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmSivKernel.pas', + ClpICtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICtrKernel.pas', + ClpICbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICbcKernel.pas', + ClpCipherKernelRegistry in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelRegistry.pas', - ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', + ClpCipherKernelFactoryBase in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', - ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpPclmulGcmSivKernel.pas', + ClpCipherKernelDefaults in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', diff --git a/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr b/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr index b8fea99b..cefdab5f 100644 --- a/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr +++ b/CryptoLib.Examples/Delphi.Examples/CryptoLib.Examples.dpr @@ -702,31 +702,31 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', - ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + ClpCipherKernelTypes in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelTypes.pas', + ClpICipherKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\ClpICipherKernelFactory.pas', - ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', - ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', - ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', - ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', - ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', - ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', - ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', - ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', - ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + ClpIChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Stream\ClpIChaCha20Poly1305Kernel.pas', + ClpIGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmKernel.pas', + ClpIOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIOcbKernel.pas', + ClpICcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICcmKernel.pas', + ClpIEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIEaxKernel.pas', + ClpIGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmSivKernel.pas', + ClpICtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICtrKernel.pas', + ClpICbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICbcKernel.pas', + ClpCipherKernelRegistry in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelRegistry.pas', - ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', + ClpCipherKernelFactoryBase in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', - ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpPclmulGcmSivKernel.pas', + ClpCipherKernelDefaults in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', diff --git a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr index ab7b4572..950972fb 100644 --- a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr +++ b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dpr @@ -683,29 +683,29 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', - ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', - ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', - ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', - ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', - ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', - ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', - ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', - ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', - ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', - ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', - ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', + ClpCipherKernelTypes in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelTypes.pas', + ClpICipherKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\ClpICipherKernelFactory.pas', + ClpIChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Stream\ClpIChaCha20Poly1305Kernel.pas', + ClpIGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmKernel.pas', + ClpIOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIOcbKernel.pas', + ClpICcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICcmKernel.pas', + ClpIEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIEaxKernel.pas', + ClpIGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmSivKernel.pas', + ClpICtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICtrKernel.pas', + ClpICbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICbcKernel.pas', + ClpCipherKernelRegistry in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelRegistry.pas', + ClpCipherKernelFactoryBase in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', - ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpPclmulGcmSivKernel.pas', + ClpCipherKernelDefaults in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', @@ -817,7 +817,7 @@ uses AeadTestUtilities in '..\src\Crypto\AeadTestUtilities.pas', CertTestUtilities in '..\src\Utils\CertTestUtilities.pas', CryptoTestKeys in '..\src\Utils\CryptoTestKeys.pas', - AcceleratedKernelToggle in '..\src\Utils\AcceleratedKernelToggle.pas', + CipherKernelToggle in '..\src\Utils\CipherKernelToggle.pas', BlowfishTests in '..\src\Crypto\BlowfishTests.pas', RijndaelTests in '..\src\Crypto\RijndaelTests.pas', Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas', @@ -872,7 +872,7 @@ uses BlockCipherTestBase in '..\src\Crypto\BlockCipherTestBase.pas', AesBlockCipherTestBase in '..\src\Crypto\AesBlockCipherTestBase.pas', AesLightTests in '..\src\Crypto\AesLightTests.pas', - AcceleratedExternalRegistrationTests in '..\src\Crypto\AcceleratedExternalRegistrationTests.pas', + CipherKernelExternalRegistrationTests in '..\src\Crypto\CipherKernelExternalRegistrationTests.pas', AesHardwareEngineTests in '..\src\Crypto\AesHardwareEngineTests.pas', IESCipherTests in '..\src\Math\IESCipherTests.pas', AESSICTests in '..\src\Crypto\AESSICTests.pas', diff --git a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj index b51bab55..e6c8abd1 100644 --- a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj +++ b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.Mobile.dproj @@ -1026,29 +1026,29 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -1160,7 +1160,7 @@ - + @@ -1211,7 +1211,7 @@ - + diff --git a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr index c0cbe377..240ba637 100644 --- a/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr +++ b/CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr @@ -702,31 +702,31 @@ uses ClpEaxBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\CryptoLib\src\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\CryptoLib\src\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpAcceleratedKernelTypes in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', - ClpIAcceleratedKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', + ClpCipherKernelTypes in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelTypes.pas', + ClpICipherKernelFactory in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\ClpICipherKernelFactory.pas', - ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', - ClpIAcceleratedGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', - ClpIAcceleratedOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', - ClpIAcceleratedCcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', - ClpIAcceleratedEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', - ClpIAcceleratedGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', - ClpIAcceleratedCtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', - ClpIAcceleratedCbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', - ClpAcceleratedKernelRegistry in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', + ClpIChaCha20Poly1305Kernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Stream\ClpIChaCha20Poly1305Kernel.pas', + ClpIGcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmKernel.pas', + ClpIOcbKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIOcbKernel.pas', + ClpICcmKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICcmKernel.pas', + ClpIEaxKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIEaxKernel.pas', + ClpIGcmSivKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpIGcmSivKernel.pas', + ClpICtrKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICtrKernel.pas', + ClpICbcKernel in '..\..\CryptoLib\src\Interfaces\Crypto\CipherKernels\Block\ClpICbcKernel.pas', + ClpCipherKernelRegistry in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelRegistry.pas', - ClpAcceleratedKernelFactoryBase in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', - ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', + ClpCipherKernelFactoryBase in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelFactoryBase.pas', + ClpAesFusedAeadSimd in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\CryptoLib\src\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', - ClpAcceleratedKernelDefaults in '..\..\CryptoLib\src\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\CryptoLib\src\Crypto\CipherKernels\Block\ClpPclmulGcmSivKernel.pas', + ClpCipherKernelDefaults in '..\..\CryptoLib\src\Crypto\CipherKernels\ClpCipherKernelDefaults.pas', ClpAeadParameters in '..\..\CryptoLib\src\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\CryptoLib\src\Crypto\ClpBufferedAeadBlockCipher.pas', @@ -838,7 +838,7 @@ uses AeadTestUtilities in '..\src\Crypto\AeadTestUtilities.pas', CertTestUtilities in '..\src\Utils\CertTestUtilities.pas', CryptoTestKeys in '..\src\Utils\CryptoTestKeys.pas', - AcceleratedKernelToggle in '..\src\Utils\AcceleratedKernelToggle.pas', + CipherKernelToggle in '..\src\Utils\CipherKernelToggle.pas', BlowfishTests in '..\src\Crypto\BlowfishTests.pas', RijndaelTests in '..\src\Crypto\RijndaelTests.pas', Asn1IntegerTests in '..\src\Asn1\Asn1IntegerTests.pas', @@ -893,7 +893,7 @@ uses BlockCipherTestBase in '..\src\Crypto\BlockCipherTestBase.pas', AesBlockCipherTestBase in '..\src\Crypto\AesBlockCipherTestBase.pas', AesLightTests in '..\src\Crypto\AesLightTests.pas', - AcceleratedExternalRegistrationTests in '..\src\Crypto\AcceleratedExternalRegistrationTests.pas', + CipherKernelExternalRegistrationTests in '..\src\Crypto\CipherKernelExternalRegistrationTests.pas', AesHardwareEngineTests in '..\src\Crypto\AesHardwareEngineTests.pas', IESCipherTests in '..\src\Math\IESCipherTests.pas', AESSICTests in '..\src\Crypto\AESSICTests.pas', diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi index 6813ab43..2487bfb5 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.Tests.lpi @@ -610,11 +610,11 @@ - + - + diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr index 7572647e..3001f6db 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLib.lpr @@ -11,7 +11,7 @@ SecP256R1FieldTests, SecP384R1FieldTests, ECDsa5Tests, ECTests, NamedCurveTests, SignerUtilitiesTests, SecureRandomTests, DigestRandomNumberTests, FixedPointTests, AESTests, AesLightTests, - AcceleratedExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, + CipherKernelExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, SicBulkParityTests, EcbBulkParityTests, CbcBulkParityTests, GcmSivBulkParityTests, BlockCipherTestBase, SpeckBlockCipherTestBase, SpeckLegacyTests, SpeckTests, @@ -47,7 +47,7 @@ BinaryPrimitivesTests, PkcsEncryptedPrivateKeyInfoTests, Pkcs12StoreTests, OpenSslReaderTests, OpenSslWriterTests, X509CertGenTests, X509CertificatePairTests, X509UtilitiesTests, FixedSecureRandom, - ShortenedDigest, CertTestUtilities, AcceleratedKernelToggle, + ShortenedDigest, CertTestUtilities, CipherKernelToggle, CryptoLibTestResourceLoader, CryptoTestKeys, NistSecureRandom, PqcTestSampler, CsvVectorParser, JsonVectorParser, RspTxtVectorParser, RspTxtVectorParserTests, Bip327Vectors, Bip340Vectors, HmacVectors, diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi index 3259ce4e..e5e43c52 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpi @@ -569,11 +569,11 @@ - + - + diff --git a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr index 483d92a6..0e47d9ba 100644 --- a/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr +++ b/CryptoLib.Tests/FreePascal.Tests/CryptoLibConsole.lpr @@ -12,7 +12,7 @@ SecP256R1FieldTests, SecP384R1FieldTests, ECDsa5Tests, ECTests, NamedCurveTests, SignerUtilitiesTests, SecureRandomTests, DigestRandomNumberTests, FixedPointTests, AESTests, AesLightTests, - AcceleratedExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, + CipherKernelExternalRegistrationTests, AesHardwareEngineTests, AESSICTests, SicBulkParityTests, EcbBulkParityTests, CbcBulkParityTests, GcmSivBulkParityTests, BlockCipherTestBase, SpeckBlockCipherTestBase, SpeckLegacyTests, SpeckTests, @@ -48,7 +48,7 @@ BinaryPrimitivesTests, PkcsEncryptedPrivateKeyInfoTests, Pkcs12StoreTests, OpenSslReaderTests, OpenSslWriterTests, X509CertGenTests, X509CertificatePairTests, X509UtilitiesTests, FixedSecureRandom, - ShortenedDigest, CertTestUtilities, CryptoTestKeys, AcceleratedKernelToggle, + ShortenedDigest, CertTestUtilities, CryptoTestKeys, CipherKernelToggle, CryptoLibTestResourceLoader, NistSecureRandom, CsvVectorParser, JsonVectorParser, RspTxtVectorParser, RspTxtVectorParserTests, Bip327Vectors, Bip340Vectors, HmacVectors, AsymmetricTestVectors, SymmetricBlockVectors, diff --git a/CryptoLib.Tests/src/Crypto/CcmTests.pas b/CryptoLib.Tests/src/Crypto/CcmTests.pas index a24de76e..3bf91d66 100644 --- a/CryptoLib.Tests/src/Crypto/CcmTests.pas +++ b/CryptoLib.Tests/src/Crypto/CcmTests.pas @@ -49,7 +49,7 @@ interface ClpCryptoLibTypes, ClpIAeadCipher, AeadTestUtilities, - AcceleratedKernelToggle, + CipherKernelToggle, CryptoLibTestBase; type @@ -81,7 +81,7 @@ TTestCcm = class(TCryptoLibAlgorithmTestCase) procedure SetUp; override; procedure TearDown; override; - // Workers run twice via RunWithAcceleratedToggle (accelerated on / off). + // Workers run twice via RunWithCipherKernelToggle (cipher kernel on / off). procedure DoTestNistVectorsAndLongData; procedure DoTestCcmIvParameters; procedure DoTestOffsets; @@ -505,22 +505,22 @@ procedure TTestCcm.DoTestRandomised; procedure TTestCcm.TestNistVectorsAndLongData; begin - RunWithAcceleratedToggle(DoTestNistVectorsAndLongData); + RunWithCipherKernelToggle(DoTestNistVectorsAndLongData); end; procedure TTestCcm.TestCcmIvParameters; begin - RunWithAcceleratedToggle(DoTestCcmIvParameters); + RunWithCipherKernelToggle(DoTestCcmIvParameters); end; procedure TTestCcm.TestOffsets; begin - RunWithAcceleratedToggle(DoTestOffsets); + RunWithCipherKernelToggle(DoTestOffsets); end; procedure TTestCcm.TestRandomised; begin - RunWithAcceleratedToggle(DoTestRandomised); + RunWithCipherKernelToggle(DoTestRandomised); end; procedure TTestCcm.TestExceptions; @@ -679,7 +679,7 @@ procedure TTestCcm.DoTestNoUnverifiedPlaintextOnFailure; procedure TTestCcm.TestNoUnverifiedPlaintextOnFailure; begin - RunWithAcceleratedToggle(DoTestNoUnverifiedPlaintextOnFailure); + RunWithCipherKernelToggle(DoTestNoUnverifiedPlaintextOnFailure); end; procedure TTestCcm.DoTestInvalidTagLength; @@ -751,12 +751,12 @@ procedure TTestCcm.DoTestValidTagLength; procedure TTestCcm.TestInvalidTagLength; begin - RunWithAcceleratedToggle(DoTestInvalidTagLength); + RunWithCipherKernelToggle(DoTestInvalidTagLength); end; procedure TTestCcm.TestValidTagLength; begin - RunWithAcceleratedToggle(DoTestValidTagLength); + RunWithCipherKernelToggle(DoTestValidTagLength); end; initialization diff --git a/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas b/CryptoLib.Tests/src/Crypto/CipherKernelExternalRegistrationTests.pas similarity index 68% rename from CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas rename to CryptoLib.Tests/src/Crypto/CipherKernelExternalRegistrationTests.pas index 51dc25f1..e54ce598 100644 --- a/CryptoLib.Tests/src/Crypto/AcceleratedExternalRegistrationTests.pas +++ b/CryptoLib.Tests/src/Crypto/CipherKernelExternalRegistrationTests.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit AcceleratedExternalRegistrationTests; +unit CipherKernelExternalRegistrationTests; interface @@ -31,9 +31,9 @@ interface TestFramework, {$ENDIF FPC} ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedGcmKernel, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpIGcmKernel, + ClpCipherKernelRegistry, ClpCryptoLibTypes; type @@ -41,17 +41,17 @@ interface /// No-op third-party GCM kernel factory used by the external /// registration pin tests. TryCreate always returns False so no /// code path (production or test) actually acquires this factory - /// as an accelerated kernel; its only observable effect is its presence + /// as a cipher kernel; its only observable effect is its presence /// in the registry's public diagnostic lists. /// TMockExternalGcmKernelFactory = class sealed(TInterfacedObject, - IAcceleratedGcmKernelFactory) + IGcmKernelFactory) public function ProviderName: String; - function Priority: TAcceleratedKernelPriority; + function Priority: TCipherKernelPriority; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; end; /// @@ -59,7 +59,7 @@ TMockExternalGcmKernelFactory = class sealed(TInterfacedObject, /// CryptoLib" contract. A mock third-party factory is registered /// from test code exactly the way a consumer's own unit would /// register from its initialization block. The tests assert that: - /// * after Register, GetRegisteredProviders(IAcceleratedGcmKernelFactory) + /// * after Register, GetRegisteredProviders(IGcmKernelFactory) /// reflects the mock; /// * registration is strictly additive -- every provider that /// was already present is still present afterwards (defaults @@ -69,7 +69,7 @@ TMockExternalGcmKernelFactory = class sealed(TInterfacedObject, /// Any future change that silently regresses this external /// registration contract will trip a red test here. /// - TTestAcceleratedExternalRegistration = class(TTestCase) + TTestCipherKernelExternalRegistration = class(TTestCase) strict private class function ProvidersContain(const AList: TCryptoLibStringArray; const AName: String): Boolean; static; @@ -88,10 +88,10 @@ implementation resourcestring SMockMustBePresent = 'Mock external GCM factory must appear in ' + - 'GetRegisteredProviders(IAcceleratedGcmKernelFactory) after Register.'; + 'GetRegisteredProviders(IGcmKernelFactory) after Register.'; SMockMustBeAbsent = 'Mock external GCM factory must be absent from ' + - 'GetRegisteredProviders(IAcceleratedGcmKernelFactory) after Unregister.'; + 'GetRegisteredProviders(IGcmKernelFactory) after Unregister.'; SCountMustGrowByOne = 'External Register must grow the provider count by ' + 'exactly one (non-duplicate factory).'; @@ -112,26 +112,26 @@ function TMockExternalGcmKernelFactory.ProviderName: String; Result := CMockExternalProviderName; end; -function TMockExternalGcmKernelFactory.Priority: TAcceleratedKernelPriority; +function TMockExternalGcmKernelFactory.Priority: TCipherKernelPriority; begin // Fallback is the lowest rank so this mock never intercepts real // GCM acquires on any platform where a genuine in-tree factory is // also registered. The mock's entire purpose is to appear in the // diagnostic list, not to be picked up by TryAcquireGcm. - Result := TAcceleratedKernelPriority.Fallback; + Result := TCipherKernelPriority.Fallback; end; function TMockExternalGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; begin AKernel := nil; Result := False; end; -{ TTestAcceleratedExternalRegistration } +{ TTestCipherKernelExternalRegistration } -class function TTestAcceleratedExternalRegistration.ProvidersContain( +class function TTestCipherKernelExternalRegistration.ProvidersContain( const AList: TCryptoLibStringArray; const AName: String): Boolean; var LIndex: Int32; @@ -145,33 +145,33 @@ class function TTestAcceleratedExternalRegistration.ProvidersContain( end; end; -procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationAddsProvider; +procedure TTestCipherKernelExternalRegistration.TestExternalRegistrationAddsProvider; var - LFactory: IAcceleratedGcmKernelFactory; + LFactory: IGcmKernelFactory; LProviders: TCryptoLibStringArray; begin LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.Register(LFactory); + TCipherKernelRegistry.Register(LFactory); try - LProviders := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + LProviders := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); CheckTrue(ProvidersContain(LProviders, CMockExternalProviderName), SMockMustBePresent); finally - TAcceleratedKernelRegistry.Unregister(LFactory); + TCipherKernelRegistry.Unregister(LFactory); end; end; -procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationIsStrictlyAdditive; +procedure TTestCipherKernelExternalRegistration.TestExternalRegistrationIsStrictlyAdditive; var - LFactory: IAcceleratedGcmKernelFactory; + LFactory: IGcmKernelFactory; LBaseline, LAfter: TCryptoLibStringArray; LIndex: Int32; begin - LBaseline := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + LBaseline := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.Register(LFactory); + TCipherKernelRegistry.Register(LFactory); try - LAfter := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + LAfter := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); CheckEquals(System.Length(LBaseline) + 1, System.Length(LAfter), SCountMustGrowByOne); // Every baseline name must survive the registration. @@ -179,22 +179,22 @@ procedure TTestAcceleratedExternalRegistration.TestExternalRegistrationIsStrictl CheckTrue(ProvidersContain(LAfter, LBaseline[LIndex]), SDefaultsMustSurvive); finally - TAcceleratedKernelRegistry.Unregister(LFactory); + TCipherKernelRegistry.Unregister(LFactory); end; end; -procedure TTestAcceleratedExternalRegistration.TestExternalUnregistrationRestoresPriorList; +procedure TTestCipherKernelExternalRegistration.TestExternalUnregistrationRestoresPriorList; var - LFactory: IAcceleratedGcmKernelFactory; + LFactory: IGcmKernelFactory; LBaseline, LAfterUnregister: TCryptoLibStringArray; LIndex: Int32; begin - LBaseline := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + LBaseline := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.Register(LFactory); - TAcceleratedKernelRegistry.Unregister(LFactory); + TCipherKernelRegistry.Register(LFactory); + TCipherKernelRegistry.Unregister(LFactory); - LAfterUnregister := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + LAfterUnregister := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); CheckEquals(System.Length(LBaseline), System.Length(LAfterUnregister), SCountMustRestoreBaseline); CheckFalse(ProvidersContain(LAfterUnregister, CMockExternalProviderName), @@ -204,30 +204,30 @@ procedure TTestAcceleratedExternalRegistration.TestExternalUnregistrationRestore SDefaultsMustSurvive); end; -procedure TTestAcceleratedExternalRegistration.TestDuplicateExternalRegistrationIsIgnored; +procedure TTestCipherKernelExternalRegistration.TestDuplicateExternalRegistrationIsIgnored; var - LFactory: IAcceleratedGcmKernelFactory; + LFactory: IGcmKernelFactory; LBaseline, LAfter: TCryptoLibStringArray; begin - LBaseline := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + LBaseline := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); LFactory := TMockExternalGcmKernelFactory.Create(); - TAcceleratedKernelRegistry.Register(LFactory); + TCipherKernelRegistry.Register(LFactory); try - TAcceleratedKernelRegistry.Register(LFactory); - LAfter := TAcceleratedKernelRegistry.GetRegisteredProviders(IAcceleratedGcmKernelFactory); + TCipherKernelRegistry.Register(LFactory); + LAfter := TCipherKernelRegistry.GetRegisteredProviders(IGcmKernelFactory); CheckEquals(System.Length(LBaseline) + 1, System.Length(LAfter), SDuplicateMustBeIgnored); finally - TAcceleratedKernelRegistry.Unregister(LFactory); + TCipherKernelRegistry.Unregister(LFactory); end; end; initialization {$IFDEF FPC} - RegisterTest(TTestAcceleratedExternalRegistration); + RegisterTest(TTestCipherKernelExternalRegistration); {$ELSE} - RegisterTest(TTestAcceleratedExternalRegistration.Suite); + RegisterTest(TTestCipherKernelExternalRegistration.Suite); {$ENDIF FPC} end. diff --git a/CryptoLib.Tests/src/Crypto/EaxTests.pas b/CryptoLib.Tests/src/Crypto/EaxTests.pas index 84054bce..3115ad94 100644 --- a/CryptoLib.Tests/src/Crypto/EaxTests.pas +++ b/CryptoLib.Tests/src/Crypto/EaxTests.pas @@ -48,7 +48,7 @@ interface ClpConverters, ClpIAeadCipher, AeadTestUtilities, - AcceleratedKernelToggle, + CipherKernelToggle, CryptoLibTestBase; type @@ -91,7 +91,7 @@ TTestEax = class(TCryptoLibAlgorithmTestCase) procedure SetUp; override; procedure TearDown; override; - // Workers run twice via RunWithAcceleratedToggle (accelerated on / off). + // Workers run twice via RunWithCipherKernelToggle (cipher kernel on / off). procedure DoTestVectors; procedure DoTestIvParameters; procedure DoTestExceptionsAndRandomised; @@ -566,27 +566,27 @@ procedure TTestEax.DoTestValidTagLength; procedure TTestEax.TestVectors; begin - RunWithAcceleratedToggle(DoTestVectors); + RunWithCipherKernelToggle(DoTestVectors); end; procedure TTestEax.TestIvParameters; begin - RunWithAcceleratedToggle(DoTestIvParameters); + RunWithCipherKernelToggle(DoTestIvParameters); end; procedure TTestEax.TestExceptionsAndRandomised; begin - RunWithAcceleratedToggle(DoTestExceptionsAndRandomised); + RunWithCipherKernelToggle(DoTestExceptionsAndRandomised); end; procedure TTestEax.TestInvalidTagLength; begin - RunWithAcceleratedToggle(DoTestInvalidTagLength); + RunWithCipherKernelToggle(DoTestInvalidTagLength); end; procedure TTestEax.TestValidTagLength; begin - RunWithAcceleratedToggle(DoTestValidTagLength); + RunWithCipherKernelToggle(DoTestValidTagLength); end; initialization diff --git a/CryptoLib.Tests/src/Crypto/GCMTests.pas b/CryptoLib.Tests/src/Crypto/GCMTests.pas index c473c132..bdf75b67 100644 --- a/CryptoLib.Tests/src/Crypto/GCMTests.pas +++ b/CryptoLib.Tests/src/Crypto/GCMTests.pas @@ -51,7 +51,7 @@ interface ClpDateTimeUtilities, ClpConverters, ClpCryptoLibTypes, - AcceleratedKernelToggle, + CipherKernelToggle, AeadTestUtilities, CryptoLibTestBase, SymmetricBlockVectors; @@ -81,7 +81,7 @@ TTestGcm = class(TCryptoLibAlgorithmTestCase) procedure DoTestExceptions; function NextInt32(const ARandom: ISecureRandom; AN: Int32): Int32; - // Workers run twice via RunWithAcceleratedToggle (accelerated on / off). + // Workers run twice via RunWithCipherKernelToggle (cipher kernel on / off). procedure DoTestRfcVectors; procedure DoTestRandomised; procedure DoTestOutputSizes; @@ -577,32 +577,32 @@ procedure TTestGcm.DoTestExceptions; procedure TTestGcm.TestRfcVectors; begin - RunWithAcceleratedToggle(DoTestRfcVectors); + RunWithCipherKernelToggle(DoTestRfcVectors); end; procedure TTestGcm.TestRandomised; begin - RunWithAcceleratedToggle(DoTestRandomised); + RunWithCipherKernelToggle(DoTestRandomised); end; procedure TTestGcm.TestOutputSizes; begin - RunWithAcceleratedToggle(DoTestOutputSizes); + RunWithCipherKernelToggle(DoTestOutputSizes); end; procedure TTestGcm.TestExceptions; begin - RunWithAcceleratedToggle(DoTestExceptionsWrapper); + RunWithCipherKernelToggle(DoTestExceptionsWrapper); end; procedure TTestGcm.TestFourBlockFusedGcmPath; begin - RunWithAcceleratedToggle(DoTestFourBlockFusedGcmPath); + RunWithCipherKernelToggle(DoTestFourBlockFusedGcmPath); end; procedure TTestGcm.TestEightBlockFusedGcmPath; begin - RunWithAcceleratedToggle(DoTestEightBlockFusedGcmPath); + RunWithCipherKernelToggle(DoTestEightBlockFusedGcmPath); end; procedure TTestGcm.DoTestRfcVectors; diff --git a/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas b/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas index 596dfd3a..3a57ed0c 100644 --- a/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas +++ b/CryptoLib.Tests/src/Crypto/GcmSivBulkParityTests.pas @@ -34,7 +34,7 @@ interface ClpKeyParameter, ClpIKeyParameter, ClpICipherParameters, - ClpAcceleratedKernelRegistry, + ClpCipherKernelRegistry, ClpSecureRandom, ClpISecureRandom, ClpConverters, @@ -72,10 +72,10 @@ function TTestGcmSivBulkParity.GcmSivEncrypt(const AKey, ANonce, AAad, LSaved: Boolean; LLen: Int32; begin - LSaved := TAcceleratedKernelGate.ForceDisabled; + LSaved := TCipherKernelGate.ForceDisabled; // The fused POLYVAL kernel is resolved during Init (DeriveKeys); the gate must // therefore be set BEFORE Init to select the fused or scalar path. - TAcceleratedKernelGate.ForceDisabled := not AUseFused; + TCipherKernelGate.ForceDisabled := not AUseFused; try LCipher := TGcmSivBlockCipher.Create() as IGcmSivBlockCipher; LCipher.Init(True, TAeadParameters.Create(TKeyParameter.Create(AKey) @@ -86,7 +86,7 @@ function TTestGcmSivBulkParity.GcmSivEncrypt(const AKey, ANonce, AAad, if LLen <> System.Length(Result) then System.SetLength(Result, LLen); finally - TAcceleratedKernelGate.ForceDisabled := LSaved; + TCipherKernelGate.ForceDisabled := LSaved; end; end; @@ -97,8 +97,8 @@ function TTestGcmSivBulkParity.GcmSivDecrypt(const AKey, ANonce, AAad, LSaved: Boolean; LLen: Int32; begin - LSaved := TAcceleratedKernelGate.ForceDisabled; - TAcceleratedKernelGate.ForceDisabled := not AUseFused; + LSaved := TCipherKernelGate.ForceDisabled; + TCipherKernelGate.ForceDisabled := not AUseFused; try LCipher := TGcmSivBlockCipher.Create() as IGcmSivBlockCipher; LCipher.Init(False, TAeadParameters.Create(TKeyParameter.Create(AKey) @@ -109,7 +109,7 @@ function TTestGcmSivBulkParity.GcmSivDecrypt(const AKey, ANonce, AAad, if LLen <> System.Length(Result) then System.SetLength(Result, LLen); finally - TAcceleratedKernelGate.ForceDisabled := LSaved; + TCipherKernelGate.ForceDisabled := LSaved; end; end; diff --git a/CryptoLib.Tests/src/Crypto/GcmSivTests.pas b/CryptoLib.Tests/src/Crypto/GcmSivTests.pas index 9ea6bfb0..60393398 100644 --- a/CryptoLib.Tests/src/Crypto/GcmSivTests.pas +++ b/CryptoLib.Tests/src/Crypto/GcmSivTests.pas @@ -41,7 +41,7 @@ interface ClpSecureRandom, ClpISecureRandom, ClpCryptoLibTypes, - AcceleratedKernelToggle, + CipherKernelToggle, CryptoLibTestBase, SymmetricBlockVectors; @@ -295,42 +295,42 @@ procedure TTestGcmSiv.DoTestRandomised; procedure TTestGcmSiv.TestAesGcmSiv128Set1; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv128Set1); + RunWithCipherKernelToggle(DoTestAesGcmSiv128Set1); end; procedure TTestGcmSiv.TestAesGcmSiv128Set2; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv128Set2); + RunWithCipherKernelToggle(DoTestAesGcmSiv128Set2); end; procedure TTestGcmSiv.TestAesGcmSiv128Set3; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv128Set3); + RunWithCipherKernelToggle(DoTestAesGcmSiv128Set3); end; procedure TTestGcmSiv.TestAesGcmSiv256Set1; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv256Set1); + RunWithCipherKernelToggle(DoTestAesGcmSiv256Set1); end; procedure TTestGcmSiv.TestAesGcmSiv256Set2; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv256Set2); + RunWithCipherKernelToggle(DoTestAesGcmSiv256Set2); end; procedure TTestGcmSiv.TestAesGcmSiv256Set3; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv256Set3); + RunWithCipherKernelToggle(DoTestAesGcmSiv256Set3); end; procedure TTestGcmSiv.TestAesGcmSiv256Set4; begin - RunWithAcceleratedToggle(DoTestAesGcmSiv256Set4); + RunWithCipherKernelToggle(DoTestAesGcmSiv256Set4); end; procedure TTestGcmSiv.TestRandomised; begin - RunWithAcceleratedToggle(DoTestRandomised); + RunWithCipherKernelToggle(DoTestRandomised); end; initialization diff --git a/CryptoLib.Tests/src/Crypto/OcbTests.pas b/CryptoLib.Tests/src/Crypto/OcbTests.pas index 39f837d8..59906e2d 100644 --- a/CryptoLib.Tests/src/Crypto/OcbTests.pas +++ b/CryptoLib.Tests/src/Crypto/OcbTests.pas @@ -44,7 +44,7 @@ interface ClpCryptoLibTypes, ClpAesUtilities, ClpOcbBlockCipher, - AcceleratedKernelToggle, + CipherKernelToggle, CryptoLibTestBase, AeadTestUtilities; @@ -92,7 +92,7 @@ TTestOcb = class(TCryptoLibAlgorithmTestCase) procedure SetUp; override; procedure TearDown; override; - // Workers run twice via RunWithAcceleratedToggle (accelerated on / off) so any + // Workers run twice via RunWithCipherKernelToggle (cipher kernel on / off) so any // drift between the two code paths surfaces as a test failure. procedure DoTestRfcVectors128; procedure DoTestRfcVectors96; @@ -581,22 +581,22 @@ procedure TTestOcb.TearDown; procedure TTestOcb.TestRfcVectors128; begin - RunWithAcceleratedToggle(DoTestRfcVectors128); + RunWithCipherKernelToggle(DoTestRfcVectors128); end; procedure TTestOcb.TestRfcVectors96; begin - RunWithAcceleratedToggle(DoTestRfcVectors96); + RunWithCipherKernelToggle(DoTestRfcVectors96); end; procedure TTestOcb.TestOcbLongForm; begin - RunWithAcceleratedToggle(DoTestOcbLongForm); + RunWithCipherKernelToggle(DoTestOcbLongForm); end; procedure TTestOcb.TestRandomised; begin - RunWithAcceleratedToggle(DoTestRandomised); + RunWithCipherKernelToggle(DoTestRandomised); end; procedure TTestOcb.DoTestRfcVectors128; diff --git a/CryptoLib.Tests/src/Utils/AcceleratedKernelToggle.pas b/CryptoLib.Tests/src/Utils/CipherKernelToggle.pas similarity index 76% rename from CryptoLib.Tests/src/Utils/AcceleratedKernelToggle.pas rename to CryptoLib.Tests/src/Utils/CipherKernelToggle.pas index 7a81de80..37290fb1 100644 --- a/CryptoLib.Tests/src/Utils/AcceleratedKernelToggle.pas +++ b/CryptoLib.Tests/src/Utils/CipherKernelToggle.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit AcceleratedKernelToggle; +unit CipherKernelToggle; interface @@ -24,36 +24,36 @@ interface uses SysUtils, - ClpAcceleratedKernelRegistry; + ClpCipherKernelRegistry; type - TAcceleratedToggleTestProc = procedure of object; + TCipherKernelToggleProc = procedure of object; /// -/// Runs AProc twice: once with accelerated kernels enabled (production +/// Runs AProc twice: once with cipher kernels enabled (production /// default) and once with them forcibly disabled so the scalar / /// generic-bulk fallbacks are exercised. Both passes must produce /// byte-identical outputs. The previous kill-switch state is saved /// and restored on return (including on exceptions). /// -procedure RunWithAcceleratedToggle(AProc: TAcceleratedToggleTestProc); +procedure RunWithCipherKernelToggle(AProc: TCipherKernelToggleProc); implementation -procedure RunWithAcceleratedToggle(AProc: TAcceleratedToggleTestProc); +procedure RunWithCipherKernelToggle(AProc: TCipherKernelToggleProc); var LSaved: Boolean; begin if not Assigned(AProc) then Exit; - LSaved := TAcceleratedKernelGate.ForceDisabled; + LSaved := TCipherKernelGate.ForceDisabled; try - TAcceleratedKernelGate.ForceDisabled := False; + TCipherKernelGate.ForceDisabled := False; AProc(); - TAcceleratedKernelGate.ForceDisabled := True; + TCipherKernelGate.ForceDisabled := True; AProc(); finally - TAcceleratedKernelGate.ForceDisabled := LSaved; + TCipherKernelGate.ForceDisabled := LSaved; end; end; diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCbcKernel.pas similarity index 89% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCbcKernel.pas index 5670f0ec..ada78f49 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCbcKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCbcKernel.pas @@ -24,15 +24,15 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpAcceleratedKernelTypes, - ClpIAcceleratedCbcKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpICbcKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IAcceleratedCbcKernel: the serial CBC-encrypt chain + /// AES-NI implementation of ICbcKernel: the serial CBC-encrypt chain /// C_i = E_K(P_i xor C_{i-1}) applied over a whole run in one call, with the /// chaining value held in a register between blocks (kernel body in /// Include\Simd\Aes\Cbc). Reuses the shared 1-wide AES round chain @@ -41,7 +41,7 @@ interface /// unavailable the factory returns nil and TCbcBlockCipher keeps its existing /// per-block bulk path. /// - TAesNiCbcKernel = class sealed(TInterfacedObject, IAcceleratedCbcKernel) + TAesNiCbcKernel = class sealed(TInterfacedObject, ICbcKernel) strict private // FEngine is retained so the round-key buffer FKeys points into stays alive // for the kernel's lifetime. @@ -55,12 +55,12 @@ TAesNiCbcKernel = class sealed(TInterfacedObject, IAcceleratedCbcKernel) ABlockCount: NativeInt); end; - TAesNiCbcKernelFactory = class sealed(TAcceleratedKernelFactoryBase, IAcceleratedCbcKernelFactory) + TAesNiCbcKernelFactory = class sealed(TCipherKernelFactoryBase, ICbcKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedCbcKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: ICbcKernel): Boolean; end; implementation @@ -168,7 +168,7 @@ function TAesNiCbcKernelFactory.ProviderName: String; end; function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCbcKernel): Boolean; + ADirection: TCipherKernelDirection; out AKernel: ICbcKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -176,7 +176,7 @@ function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; begin AKernel := nil; Result := False; - if ADirection <> TAcceleratedKernelDirection.Encrypt then + if ADirection <> TCipherKernelDirection.Encrypt then Exit; // only encrypt is implemented; decrypt not yet supported try {$IFDEF CRYPTOLIB_X86_SIMD} @@ -196,7 +196,7 @@ function TAesNiCbcKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TAesNiCbcKernelFactory.Create() as IAcceleratedCbcKernelFactory); + TCipherKernelRegistry.Register( + TAesNiCbcKernelFactory.Create() as ICbcKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCcmKernel.pas similarity index 91% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCcmKernel.pas index 68cbb6a9..8c385fd6 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCcmKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCcmKernel.pas @@ -24,16 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpAcceleratedKernelTypes, - ClpIAcceleratedCcmKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpICcmKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IAcceleratedCcmKernel. + /// AES-NI implementation of ICcmKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -43,7 +43,7 @@ interface /// The kernel loops internally over ABlockCount body blocks; the /// mode invokes ProcessBody once per Init cycle. /// - TAesNiCcmKernel = class sealed(TInterfacedObject, IAcceleratedCcmKernel) + TAesNiCcmKernel = class sealed(TInterfacedObject, ICcmKernel) strict private const FUSED_CCM_MIN_BLOCKS = 1; @@ -58,24 +58,24 @@ TAesNiCcmKernel = class sealed(TInterfacedObject, IAcceleratedCcmKernel) // multi-block SIMD loop. FEngine: IAesEngineX86; FRounds: Int32; - FDirection: TAcceleratedKernelDirection; + FDirection: TCipherKernelDirection; FMask: Pointer; FIncrement: Pointer; public constructor Create(const AEngine: IAesEngineX86; ARounds: Int32; - ADirection: TAcceleratedKernelDirection; AMask, AIncrement: Pointer); + ADirection: TCipherKernelDirection; AMask, AIncrement: Pointer); function MinimumBlockCount: Int32; procedure ProcessBody(AInPtr, AOutPtr, ACtrState, ACbcMacState: Pointer; ABlockCount: Int32); end; - TAesNiCcmKernelFactory = class sealed(TAcceleratedKernelFactoryBase, - IAcceleratedCcmKernelFactory) + TAesNiCcmKernelFactory = class sealed(TCipherKernelFactoryBase, + ICcmKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedCcmKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: ICcmKernel): Boolean; end; implementation @@ -200,7 +200,7 @@ procedure CcmFusedCtrCbcMacDec256(PCtx: Pointer); { TAesNiCcmKernel } constructor TAesNiCcmKernel.Create(const AEngine: IAesEngineX86; - ARounds: Int32; ADirection: TAcceleratedKernelDirection; + ARounds: Int32; ADirection: TCipherKernelDirection; AMask, AIncrement: Pointer); begin inherited Create; @@ -245,7 +245,7 @@ procedure TAesNiCcmKernel.ProcessBody(AInPtr, AOutPtr, ACtrState, LCtx.PMask := FMask; LCtx.PIncrement := FIncrement; LCtx.BlockCount := NativeUInt(ABlockCount); - if FDirection = TAcceleratedKernelDirection.Encrypt then + if FDirection = TCipherKernelDirection.Encrypt then begin case FRounds of 10: CcmFusedCtrCbcMacEnc128(@LCtx); @@ -274,7 +274,7 @@ function TAesNiCcmKernelFactory.ProviderName: String; end; function TAesNiCcmKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCcmKernel): Boolean; + ADirection: TCipherKernelDirection; out AKernel: ICcmKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -307,7 +307,7 @@ function TAesNiCcmKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TAesNiCcmKernelFactory.Create() as IAcceleratedCcmKernelFactory); + TCipherKernelRegistry.Register( + TAesNiCcmKernelFactory.Create() as ICcmKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCtrKernel.pas similarity index 90% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCtrKernel.pas index 3ab683db..5cccb0ed 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiCtrKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiCtrKernel.pas @@ -24,15 +24,15 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpAcceleratedKernelTypes, - ClpIAcceleratedCtrKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpICtrKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IAcceleratedCtrKernel: the fused counter-mode + /// AES-NI implementation of ICtrKernel: the fused counter-mode /// keystream + XOR body used by TSicBlockCipher's bulk path. The MAC-free /// base of the fused-kernel family; reuses the plain 8-wide AES round chain /// (AesNiEightRoundsOnly) since CTR has no extra per-block state. @@ -40,7 +40,7 @@ interface /// both arms gated collectively by CRYPTOLIB_X86_SIMD. When unavailable the /// factory returns nil and TSicBlockCipher keeps its existing bulk path. /// - TAesNiCtrKernel = class sealed(TInterfacedObject, IAcceleratedCtrKernel) + TAesNiCtrKernel = class sealed(TInterfacedObject, ICtrKernel) strict private const FUSED_CTR_BATCH_BLOCKS = 8; @@ -58,12 +58,12 @@ TAesNiCtrKernel = class sealed(TInterfacedObject, IAcceleratedCtrKernel) ABlockCount: NativeInt); end; - TAesNiCtrKernelFactory = class sealed(TAcceleratedKernelFactoryBase, IAcceleratedCtrKernelFactory) + TAesNiCtrKernelFactory = class sealed(TCipherKernelFactoryBase, ICtrKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedCtrKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: ICtrKernel): Boolean; end; implementation @@ -174,7 +174,7 @@ function TAesNiCtrKernelFactory.ProviderName: String; end; function TAesNiCtrKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCtrKernel): Boolean; + ADirection: TCipherKernelDirection; out AKernel: ICtrKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -200,7 +200,7 @@ function TAesNiCtrKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TAesNiCtrKernelFactory.Create() as IAcceleratedCtrKernelFactory); + TCipherKernelRegistry.Register( + TAesNiCtrKernelFactory.Create() as ICtrKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiEaxKernel.pas similarity index 90% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiEaxKernel.pas index a5892bd3..de35f412 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiEaxKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiEaxKernel.pas @@ -24,16 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpAcceleratedKernelTypes, - ClpIAcceleratedEaxKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpIEaxKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IAcceleratedEaxKernel. + /// AES-NI implementation of IEaxKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -47,7 +47,7 @@ interface /// ships a fused EAX kernel (OpenSSL, BoringSSL, AWS-LC, Botan all /// scalar). /// - TAesNiEaxKernel = class sealed(TInterfacedObject, IAcceleratedEaxKernel) + TAesNiEaxKernel = class sealed(TInterfacedObject, IEaxKernel) strict private const FUSED_EAX_MIN_BLOCKS = 2; @@ -55,24 +55,24 @@ TAesNiEaxKernel = class sealed(TInterfacedObject, IAcceleratedEaxKernel) FEngine: IAesEngineX86; FKeys: Pointer; FRounds: Int32; - FDirection: TAcceleratedKernelDirection; + FDirection: TCipherKernelDirection; FMask: Pointer; FIncrement: Pointer; public constructor Create(const AEngine: IAesEngineX86; AKeys: Pointer; - ARounds: Int32; ADirection: TAcceleratedKernelDirection; AMask, AIncrement: Pointer); + ARounds: Int32; ADirection: TCipherKernelDirection; AMask, AIncrement: Pointer); function MinimumBlockCount: Int32; procedure ProcessBody(AInPtr, AOutPtr, ACtrState, AOmacState: Pointer; ABlockCount: Int32); end; - TAesNiEaxKernelFactory = class sealed(TAcceleratedKernelFactoryBase, - IAcceleratedEaxKernelFactory) + TAesNiEaxKernelFactory = class sealed(TCipherKernelFactoryBase, + IEaxKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedEaxKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: IEaxKernel): Boolean; end; implementation @@ -201,7 +201,7 @@ procedure EaxFusedCtrOmacDec256(PCtx: Pointer); { TAesNiEaxKernel } constructor TAesNiEaxKernel.Create(const AEngine: IAesEngineX86; - AKeys: Pointer; ARounds: Int32; ADirection: TAcceleratedKernelDirection; + AKeys: Pointer; ARounds: Int32; ADirection: TCipherKernelDirection; AMask, AIncrement: Pointer); begin inherited Create; @@ -236,7 +236,7 @@ procedure TAesNiEaxKernel.ProcessBody(AInPtr, AOutPtr, ACtrState, LCtx.PMask := FMask; LCtx.PIncrement := FIncrement; LCtx.BlockCount := NativeUInt(ABlockCount); - if FDirection = TAcceleratedKernelDirection.Encrypt then + if FDirection = TCipherKernelDirection.Encrypt then begin case FRounds of 10: EaxFusedCtrOmacEnc128(@LCtx); @@ -265,7 +265,7 @@ function TAesNiEaxKernelFactory.ProviderName: String; end; function TAesNiEaxKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedEaxKernel): Boolean; + ADirection: TCipherKernelDirection; out AKernel: IEaxKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -294,7 +294,7 @@ function TAesNiEaxKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TAesNiEaxKernelFactory.Create() as IAcceleratedEaxKernelFactory); + TCipherKernelRegistry.Register( + TAesNiEaxKernelFactory.Create() as IEaxKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiGcmKernel.pas similarity index 91% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiGcmKernel.pas index 7fb13318..56773b1d 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiGcmKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiGcmKernel.pas @@ -24,16 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpAcceleratedKernelTypes, - ClpIAcceleratedGcmKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpIGcmKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI + PCLMULQDQ implementation of IAcceleratedGcmKernel. + /// AES-NI + PCLMULQDQ implementation of IGcmKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -45,7 +45,7 @@ interface /// pipeline internally; the mode primes the first batch and drains the /// last. /// - TAesNiGcmKernel = class sealed(TInterfacedObject, IAcceleratedGcmKernel) + TAesNiGcmKernel = class sealed(TInterfacedObject, IGcmKernel) strict private const FUSED_GCM_MIN_BLOCKS = 8; @@ -64,13 +64,13 @@ TAesNiGcmKernel = class sealed(TInterfacedObject, IAcceleratedGcmKernel) AForEncrypt: Boolean): UInt32; end; - TAesNiGcmKernelFactory = class sealed(TAcceleratedKernelFactoryBase, - IAcceleratedGcmKernelFactory) + TAesNiGcmKernelFactory = class sealed(TCipherKernelFactoryBase, + IGcmKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; end; implementation @@ -205,8 +205,8 @@ function TAesNiGcmKernelFactory.ProviderName: String; end; function TAesNiGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -237,7 +237,7 @@ function TAesNiGcmKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TAesNiGcmKernelFactory.Create() as IAcceleratedGcmKernelFactory); + TCipherKernelRegistry.Register( + TAesNiGcmKernelFactory.Create() as IGcmKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiOcbKernel.pas similarity index 90% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiOcbKernel.pas index 41e793d0..0aa6142f 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpAesNiOcbKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpAesNiOcbKernel.pas @@ -24,16 +24,16 @@ interface SysUtils, ClpIBlockCipher, ClpIAesEngineX86, - ClpAcceleratedKernelTypes, - ClpIAcceleratedOcbKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpIOcbKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiFusedX86Backend; type /// - /// AES-NI implementation of IAcceleratedOcbKernel. + /// AES-NI implementation of IOcbKernel. /// Available on x86_64 (CRYPTOLIB_X86_64_ASM) and i386 /// (CRYPTOLIB_I386_ASM); both arms gated collectively by /// CRYPTOLIB_X86_SIMD. @@ -45,7 +45,7 @@ interface /// 4 blocks on i386) so the mode layer can amortise call-site /// overhead across large batches. /// - TAesNiOcbKernel = class sealed(TInterfacedObject, IAcceleratedOcbKernel) + TAesNiOcbKernel = class sealed(TInterfacedObject, IOcbKernel) strict private const {$IFDEF CRYPTOLIB_X86_64_ASM} @@ -57,23 +57,23 @@ TAesNiOcbKernel = class sealed(TInterfacedObject, IAcceleratedOcbKernel) FEngine: IAesEngineX86; FKeys: Pointer; FRounds: Int32; - FDirection: TAcceleratedKernelDirection; + FDirection: TCipherKernelDirection; public constructor Create(const AEngine: IAesEngineX86; AKeys: Pointer; - ARounds: Int32; ADirection: TAcceleratedKernelDirection); + ARounds: Int32; ADirection: TCipherKernelDirection); function MinimumBlockCount: Int32; procedure ProcessBlocks(AInPtr, AOutPtr, AOffsetPtr, AChecksumPtr, ALTablePtr, ABlock0Ptr: Pointer; ABlockCount: Int32; AStartBlockCount: UInt64); end; - TAesNiOcbKernelFactory = class sealed(TAcceleratedKernelFactoryBase, - IAcceleratedOcbKernelFactory) + TAesNiOcbKernelFactory = class sealed(TCipherKernelFactoryBase, + IOcbKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedOcbKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: IOcbKernel): Boolean; end; implementation @@ -196,7 +196,7 @@ procedure OcbFusedDecWide256(PCtx: Pointer); { TAesNiOcbKernel } constructor TAesNiOcbKernel.Create(const AEngine: IAesEngineX86; - AKeys: Pointer; ARounds: Int32; ADirection: TAcceleratedKernelDirection); + AKeys: Pointer; ARounds: Int32; ADirection: TCipherKernelDirection); begin inherited Create; FEngine := AEngine; @@ -231,7 +231,7 @@ procedure TAesNiOcbKernel.ProcessBlocks(AInPtr, AOutPtr, AOffsetPtr, LCtx.Block0Ptr := ABlock0Ptr; LCtx.BlockCount := NativeUInt(ABlockCount); LCtx.StartBlockCount := AStartBlockCount; - if FDirection = TAcceleratedKernelDirection.Encrypt then + if FDirection = TCipherKernelDirection.Encrypt then begin case FRounds of 10: OcbFusedEncWide128(@LCtx); @@ -260,7 +260,7 @@ function TAesNiOcbKernelFactory.ProviderName: String; end; function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedOcbKernel): Boolean; + ADirection: TCipherKernelDirection; out AKernel: IOcbKernel): Boolean; var LEngine: IAesEngineX86; LKeys: PByte; @@ -274,7 +274,7 @@ function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; Exit; if not TAesNiFusedX86Backend.TryResolveEngine(ACipher, LEngine) then Exit; - if ADirection = TAcceleratedKernelDirection.Encrypt then + if ADirection = TCipherKernelDirection.Encrypt then LHasSchedule := LEngine.TryGetEncKeysPtr(LKeys, LRounds) else LHasSchedule := LEngine.TryGetDecKeysPtr(LKeys, LRounds); @@ -291,7 +291,7 @@ function TAesNiOcbKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TAesNiOcbKernelFactory.Create() as IAcceleratedOcbKernelFactory); + TCipherKernelRegistry.Register( + TAesNiOcbKernelFactory.Create() as IOcbKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas b/CryptoLib/src/Crypto/CipherKernels/Block/ClpPclmulGcmSivKernel.pas similarity index 83% rename from CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/ClpPclmulGcmSivKernel.pas index ef8bf998..c99b1ce1 100644 --- a/CryptoLib/src/Crypto/Accelerated/Block/ClpPclmulGcmSivKernel.pas +++ b/CryptoLib/src/Crypto/CipherKernels/Block/ClpPclmulGcmSivKernel.pas @@ -23,21 +23,21 @@ interface uses SysUtils, ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedGcmSivKernel, - ClpAcceleratedKernelFactoryBase, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpIGcmSivKernel, + ClpCipherKernelFactoryBase, + ClpCipherKernelRegistry, ClpGcmSivSimd; type /// - /// PCLMULQDQ implementation of IAcceleratedGcmSivKernel. Pure + /// PCLMULQDQ implementation of IGcmSivKernel. Pure /// POLYVAL: the factory ignores ACipher identity and only requires /// a valid pre-computed H-power table from the caller. Ships on /// both x86_64 and i386. /// TPclmulGcmSivKernel = class sealed(TInterfacedObject, - IAcceleratedGcmSivKernel) + IGcmSivKernel) strict private const FUSED_POLYVAL_MIN_BLOCKS = 8; @@ -51,13 +51,13 @@ TPclmulGcmSivKernel = class sealed(TInterfacedObject, ABlockCount: Int32); end; - TPclmulGcmSivKernelFactory = class sealed(TAcceleratedKernelFactoryBase, - IAcceleratedGcmSivKernelFactory) + TPclmulGcmSivKernelFactory = class sealed(TCipherKernelFactoryBase, + IGcmSivKernelFactory) public function ProviderName: String; override; function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmSivKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmSivKernel): Boolean; end; implementation @@ -98,8 +98,8 @@ function TPclmulGcmSivKernelFactory.ProviderName: String; end; function TPclmulGcmSivKernelFactory.TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmSivKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmSivKernel): Boolean; begin AKernel := nil; Result := False; @@ -118,7 +118,7 @@ function TPclmulGcmSivKernelFactory.TryCreate(const ACipher: IBlockCipher; end; initialization - TAcceleratedKernelRegistry.Register( - TPclmulGcmSivKernelFactory.Create() as IAcceleratedGcmSivKernelFactory); + TCipherKernelRegistry.Register( + TPclmulGcmSivKernelFactory.Create() as IGcmSivKernelFactory); end. diff --git a/CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesFusedAeadSimd.pas b/CryptoLib/src/Crypto/CipherKernels/Block/Internal/ClpAesFusedAeadSimd.pas similarity index 100% rename from CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesFusedAeadSimd.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/Internal/ClpAesFusedAeadSimd.pas diff --git a/CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesNiFusedX86Backend.pas b/CryptoLib/src/Crypto/CipherKernels/Block/Internal/ClpAesNiFusedX86Backend.pas similarity index 100% rename from CryptoLib/src/Crypto/Accelerated/Block/Internal/ClpAesNiFusedX86Backend.pas rename to CryptoLib/src/Crypto/CipherKernels/Block/Internal/ClpAesNiFusedX86Backend.pas diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelDefaults.pas b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelDefaults.pas similarity index 94% rename from CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelDefaults.pas rename to CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelDefaults.pas index 71220375..55da86f8 100644 --- a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelDefaults.pas +++ b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelDefaults.pas @@ -14,11 +14,11 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpAcceleratedKernelDefaults; +unit ClpCipherKernelDefaults; {$I ..\..\Include\CryptoLib.inc} -// Aggregator for CryptoLib's in-tree accelerated kernel factories. +// Aggregator for CryptoLib's in-tree cipher kernel factories. // Listed factory units self-gate on their own CPU/arch defines, so // this file is a plain, platform-agnostic list: adding a new in-tree // accelerator is one `uses` line here, mode units are never touched. diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelFactoryBase.pas similarity index 77% rename from CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas rename to CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelFactoryBase.pas index 0dbd46bb..2e14bff4 100644 --- a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelFactoryBase.pas +++ b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelFactoryBase.pas @@ -14,38 +14,38 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpAcceleratedKernelFactoryBase; +unit ClpCipherKernelFactoryBase; {$I ..\..\Include\CryptoLib.inc} interface uses - ClpAcceleratedKernelTypes; + ClpCipherKernelTypes; type /// - /// Shared base for accelerated-kernel factory classes. ProviderName is + /// Shared base for cipher-kernel factory classes. ProviderName is /// abstract - each concrete factory must declare its own provider identity /// (there is no generic default). Priority defaults to Baseline, a neutral /// value a factory overrides only when it should out- or under-rank peers. /// The base intentionally declares no interface - each concrete factory - /// lists its own IAccelerated<Mode>KernelFactory, and these members + /// lists its own I<Mode>KernelFactory, and these members /// satisfy the base slice of that contract. /// - TAcceleratedKernelFactoryBase = class abstract(TInterfacedObject) + TCipherKernelFactoryBase = class abstract(TInterfacedObject) public function ProviderName: String; virtual; abstract; - function Priority: TAcceleratedKernelPriority; virtual; + function Priority: TCipherKernelPriority; virtual; end; implementation -{ TAcceleratedKernelFactoryBase } +{ TCipherKernelFactoryBase } -function TAcceleratedKernelFactoryBase.Priority: TAcceleratedKernelPriority; +function TCipherKernelFactoryBase.Priority: TCipherKernelPriority; begin - Result := TAcceleratedKernelPriority.Baseline; + Result := TCipherKernelPriority.Baseline; end; end. diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelRegistry.pas similarity index 56% rename from CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas rename to CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelRegistry.pas index 7791b7dd..d3587e2c 100644 --- a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelRegistry.pas +++ b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelRegistry.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpAcceleratedKernelRegistry; +unit ClpCipherKernelRegistry; {$I ..\..\Include\CryptoLib.inc} @@ -26,26 +26,26 @@ interface Generics.Collections, ClpIBlockCipher, ClpCryptoLibTypes, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory, - ClpIAcceleratedGcmKernel, - ClpIAcceleratedOcbKernel, - ClpIAcceleratedCcmKernel, - ClpIAcceleratedEaxKernel, - ClpIAcceleratedGcmSivKernel, - ClpIAcceleratedCtrKernel, - ClpIAcceleratedCbcKernel, + ClpCipherKernelTypes, + ClpICipherKernelFactory, + ClpIGcmKernel, + ClpIOcbKernel, + ClpICcmKernel, + ClpIEaxKernel, + ClpIGcmSivKernel, + ClpICtrKernel, + ClpICbcKernel, ClpIStreamCipher, - ClpIAcceleratedChaCha20Poly1305Kernel; + ClpIChaCha20Poly1305Kernel; type /// - /// Process-wide kill switch for every registered accelerated kernel. When + /// Process-wide kill switch for every registered cipher kernel. When /// ForceDisabled is True, every TryAcquireX returns False without walking /// the factory list, so modes route through their scalar fallbacks. Used by /// the dual-path test harness to prove both paths agree byte-for-byte. /// - TAcceleratedKernelGate = class sealed(TObject) + TCipherKernelGate = class sealed(TObject) strict private class var FForceDisabled: Boolean; public @@ -53,24 +53,24 @@ TAcceleratedKernelGate = class sealed(TObject) end; /// - /// Open, priority-ordered resolver for the whole accelerated-kernel family. Every + /// Open, priority-ordered resolver for the whole cipher-kernel family. Every /// factory - block-cipher AEAD or stream-cipher AEAD alike - is registered - /// through the family-agnostic IAcceleratedKernelFactory into a single + /// through the family-agnostic ICipherKernelFactory into a single /// priority-sorted list (highest Priority first; equal priorities keep /// registration order). A per-mode TryAcquireX re-discovers the concrete /// family with Supports() and calls its typed TryCreate. An external - /// consumer registers its own IAccelerated<X>KernelFactory and resolves it + /// consumer registers its own I<X>KernelFactory and resolves it /// through the public GetSnapshot + a Supports walk - no framework edit and /// no central enum. Thread-safe: one TCriticalSection guards mutation and /// snapshotting; TryAcquireX snapshots under the lock then releases it before /// invoking factory TryCreate, so factory work never serialises other call /// sites. /// - TAcceleratedKernelRegistry = class sealed(TObject) + TCipherKernelRegistry = class sealed(TObject) strict private class var FLock: TCriticalSection; - class var FFactories: TList; - class function Snapshot: TCryptoLibGenericArray; static; + class var FFactories: TList; + class function Snapshot: TCryptoLibGenericArray; static; class constructor Create; class destructor Destroy; public @@ -78,56 +78,56 @@ TAcceleratedKernelRegistry = class sealed(TObject) /// list sorted by Ord(Priority) descending; equal priorities retain /// registration order. Duplicate registrations (same interface identity) /// are silently ignored. - class procedure Register(const AFactory: IAcceleratedKernelFactory); static; + class procedure Register(const AFactory: ICipherKernelFactory); static; /// Remove AFactory. No-op if not registered. - class procedure Unregister(const AFactory: IAcceleratedKernelFactory); static; + class procedure Unregister(const AFactory: ICipherKernelFactory); static; /// Priority-ordered snapshot of every registered factory. External /// consumers filter it with Supports() to their own factory interface to - /// resolve an accelerated kernel the framework never enumerated. - class function GetSnapshot: TCryptoLibGenericArray; static; + /// resolve a cipher kernel the framework never enumerated. + class function GetSnapshot: TCryptoLibGenericArray; static; class function TryAcquireGcm(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; static; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; static; class function TryAcquireOcb(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedOcbKernel): Boolean; static; + ADirection: TCipherKernelDirection; out AKernel: IOcbKernel): Boolean; static; class function TryAcquireCcm(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCcmKernel): Boolean; static; + ADirection: TCipherKernelDirection; out AKernel: ICcmKernel): Boolean; static; class function TryAcquireEax(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedEaxKernel): Boolean; static; + ADirection: TCipherKernelDirection; out AKernel: IEaxKernel): Boolean; static; class function TryAcquireGcmSiv(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmSivKernel): Boolean; static; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmSivKernel): Boolean; static; class function TryAcquireCtr(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCtrKernel): Boolean; static; + ADirection: TCipherKernelDirection; out AKernel: ICtrKernel): Boolean; static; class function TryAcquireCbc(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCbcKernel): Boolean; static; + ADirection: TCipherKernelDirection; out AKernel: ICbcKernel): Boolean; static; class function TryAcquireChaCha20Poly1305(const ACipher: IStreamCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; static; + ADirection: TCipherKernelDirection; out AKernel: IChaCha20Poly1305Kernel): Boolean; static; /// Provider-name list (priority order) of every registered factory /// supporting AFactoryIID. Pass a per-mode factory interface, e.g. - /// GetRegisteredProviders(IAcceleratedGcmKernelFactory). Diagnostics/tests. + /// GetRegisteredProviders(IGcmKernelFactory). Diagnostics/tests. class function GetRegisteredProviders(const AFactoryIID: TGUID): TCryptoLibStringArray; static; end; implementation -{ TAcceleratedKernelRegistry } +{ TCipherKernelRegistry } -class constructor TAcceleratedKernelRegistry.Create; +class constructor TCipherKernelRegistry.Create; begin FLock := TCriticalSection.Create; - FFactories := TList.Create; + FFactories := TList.Create; end; -class destructor TAcceleratedKernelRegistry.Destroy; +class destructor TCipherKernelRegistry.Destroy; begin FFactories.Free; FLock.Free; end; -class procedure TAcceleratedKernelRegistry.Register(const AFactory: IAcceleratedKernelFactory); +class procedure TCipherKernelRegistry.Register(const AFactory: ICipherKernelFactory); var LI, LPriority: Int32; LInserted: Boolean; @@ -154,7 +154,7 @@ class procedure TAcceleratedKernelRegistry.Register(const AFactory: IAccelerated end; end; -class procedure TAcceleratedKernelRegistry.Unregister(const AFactory: IAcceleratedKernelFactory); +class procedure TCipherKernelRegistry.Unregister(const AFactory: ICipherKernelFactory); var LIdx: Int32; begin @@ -169,7 +169,7 @@ class procedure TAcceleratedKernelRegistry.Unregister(const AFactory: IAccelerat end; end; -class function TAcceleratedKernelRegistry.Snapshot: TCryptoLibGenericArray; +class function TCipherKernelRegistry.Snapshot: TCryptoLibGenericArray; var LI, LCount: Int32; begin @@ -184,30 +184,30 @@ class function TAcceleratedKernelRegistry.Snapshot: TCryptoLibGenericArray; +class function TCipherKernelRegistry.GetSnapshot: TCryptoLibGenericArray; begin Result := Snapshot; end; { ---- TryAcquire ------------------------------------------------------------- } -class function TAcceleratedKernelRegistry.TryAcquireGcm(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireGcm(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedGcmKernelFactory; + LFac: IGcmKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; if AHPowers = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedGcmKernelFactory, LFac) and + if Supports(LSnap[LI], IGcmKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AHPowers, AKernel) and (AKernel <> nil) then begin Result := True; @@ -217,21 +217,21 @@ class function TAcceleratedKernelRegistry.TryAcquireGcm(const ACipher: IBlockCip AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireOcb(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedOcbKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireOcb(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; out AKernel: IOcbKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedOcbKernelFactory; + LFac: IOcbKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedOcbKernelFactory, LFac) and + if Supports(LSnap[LI], IOcbKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then begin Result := True; @@ -241,21 +241,21 @@ class function TAcceleratedKernelRegistry.TryAcquireOcb(const ACipher: IBlockCip AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireCcm(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCcmKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireCcm(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; out AKernel: ICcmKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedCcmKernelFactory; + LFac: ICcmKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedCcmKernelFactory, LFac) and + if Supports(LSnap[LI], ICcmKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then begin Result := True; @@ -265,21 +265,21 @@ class function TAcceleratedKernelRegistry.TryAcquireCcm(const ACipher: IBlockCip AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireEax(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedEaxKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireEax(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; out AKernel: IEaxKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedEaxKernelFactory; + LFac: IEaxKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedEaxKernelFactory, LFac) and + if Supports(LSnap[LI], IEaxKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then begin Result := True; @@ -289,22 +289,22 @@ class function TAcceleratedKernelRegistry.TryAcquireEax(const ACipher: IBlockCip AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireGcmSiv(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmSivKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireGcmSiv(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmSivKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedGcmSivKernelFactory; + LFac: IGcmSivKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if AHPowers = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedGcmSivKernelFactory, LFac) and + if Supports(LSnap[LI], IGcmSivKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AHPowers, AKernel) and (AKernel <> nil) then begin Result := True; @@ -314,21 +314,21 @@ class function TAcceleratedKernelRegistry.TryAcquireGcmSiv(const ACipher: IBlock AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireCtr(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCtrKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireCtr(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; out AKernel: ICtrKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedCtrKernelFactory; + LFac: ICtrKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedCtrKernelFactory, LFac) and + if Supports(LSnap[LI], ICtrKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then begin Result := True; @@ -338,21 +338,21 @@ class function TAcceleratedKernelRegistry.TryAcquireCtr(const ACipher: IBlockCip AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireCbc(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedCbcKernel): Boolean; +class function TCipherKernelRegistry.TryAcquireCbc(const ACipher: IBlockCipher; + ADirection: TCipherKernelDirection; out AKernel: ICbcKernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedCbcKernelFactory; + LFac: ICbcKernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedCbcKernelFactory, LFac) and + if Supports(LSnap[LI], ICbcKernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then begin Result := True; @@ -362,21 +362,21 @@ class function TAcceleratedKernelRegistry.TryAcquireCbc(const ACipher: IBlockCip AKernel := nil; end; -class function TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(const ACipher: IStreamCipher; - ADirection: TAcceleratedKernelDirection; out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; +class function TCipherKernelRegistry.TryAcquireChaCha20Poly1305(const ACipher: IStreamCipher; + ADirection: TCipherKernelDirection; out AKernel: IChaCha20Poly1305Kernel): Boolean; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI: Int32; - LFac: IAcceleratedChaCha20Poly1305KernelFactory; + LFac: IChaCha20Poly1305KernelFactory; begin AKernel := nil; Result := False; - if TAcceleratedKernelGate.ForceDisabled then Exit; + if TCipherKernelGate.ForceDisabled then Exit; if ACipher = nil then Exit; LSnap := Snapshot; for LI := 0 to System.Length(LSnap) - 1 do begin - if Supports(LSnap[LI], IAcceleratedChaCha20Poly1305KernelFactory, LFac) and + if Supports(LSnap[LI], IChaCha20Poly1305KernelFactory, LFac) and LFac.TryCreate(ACipher, ADirection, AKernel) and (AKernel <> nil) then begin Result := True; @@ -386,12 +386,10 @@ class function TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(const ACiph AKernel := nil; end; -{ ---- Provider queries ------------------------------------------------------- } - -class function TAcceleratedKernelRegistry.GetRegisteredProviders( +class function TCipherKernelRegistry.GetRegisteredProviders( const AFactoryIID: TGUID): TCryptoLibStringArray; var - LSnap: TCryptoLibGenericArray; + LSnap: TCryptoLibGenericArray; LI, LN: Int32; begin LSnap := Snapshot; diff --git a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelTypes.pas b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelTypes.pas similarity index 88% rename from CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelTypes.pas rename to CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelTypes.pas index 23fa686d..902922ef 100644 --- a/CryptoLib/src/Crypto/Accelerated/ClpAcceleratedKernelTypes.pas +++ b/CryptoLib/src/Crypto/CipherKernels/ClpCipherKernelTypes.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpAcceleratedKernelTypes; +unit ClpCipherKernelTypes; {$I ..\..\Include\CryptoLib.inc} @@ -22,14 +22,14 @@ interface type /// - /// Direction an accelerated kernel is being constructed for. Modes + /// Direction a cipher kernel is being constructed for. Modes /// whose hot path is direction-agnostic may pass Encrypt for both /// cases. /// - TAcceleratedKernelDirection = (Encrypt, Decrypt); + TCipherKernelDirection = (Encrypt, Decrypt); /// - /// Priority class used to order factories in the accelerated kernel + /// Priority class used to order factories in the cipher kernel /// registry. Higher ordinal wins; equal priorities retain registration /// order (first registered wins), which is why UserOverride sits above /// Preferred - it keeps the consumer's explicit choice the final word @@ -44,7 +44,7 @@ interface /// UserOverride - last-resort explicit override wired in by the /// consumer (application or test harness); beats all. /// - TAcceleratedKernelPriority = (Fallback, Baseline, Preferred, UserOverride); + TCipherKernelPriority = (Fallback, Baseline, Preferred, UserOverride); implementation diff --git a/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas index 5672b2aa..f9f674c9 100644 --- a/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpCbcBlockCipher.pas @@ -30,9 +30,9 @@ interface ClpICipherParameters, ClpIParametersWithIV, ClpBlockCipherBulkUtilities, - ClpAcceleratedKernelTypes, - ClpIAcceleratedCbcKernel, - ClpAcceleratedKernelRegistry, + ClpCipherKernelTypes, + ClpICbcKernel, + ClpCipherKernelRegistry, ClpArrayUtilities, ClpByteUtilities, ClpCryptoLibTypes; @@ -76,7 +76,7 @@ TCbcBlockCipher = class sealed(TInterfacedObject, ICbcBlockCipher, // C[i] = E(P[i] xor C[i-1]) in one call with the chaining value held in a // register, replacing the per-block dispatch loop. nil otherwise -- // CbcEncryptBulk keeps its per-block path. - FCbcKernel: IAcceleratedCbcKernel; + FCbcKernel: ICbcKernel; function EncryptBlock(const AInput: TCryptoLibByteArray; AInOff: Int32; const AOutBytes: TCryptoLibByteArray; AOutOff: Int32): Int32; @@ -347,7 +347,7 @@ procedure TCbcBlockCipher.Init(AForEncryption: Boolean; // provider claims FCipher. Encrypt-only: CBC decrypt is parallel and already // served by the bulk engine's 8-wide path. if FEncrypting then - TAcceleratedKernelRegistry.TryAcquireCbc(FCipher, TAcceleratedKernelDirection.Encrypt, + TCipherKernelRegistry.TryAcquireCbc(FCipher, TCipherKernelDirection.Encrypt, FCbcKernel) else FCbcKernel := nil; diff --git a/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas index 81db7e72..3def6d53 100644 --- a/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpCcmBlockCipher.pas @@ -33,10 +33,10 @@ interface ClpISicBlockCipher, ClpIBulkBlockCipherMode, ClpBlockCipherBulkUtilities, - ClpAcceleratedKernelTypes, - ClpIAcceleratedCcmKernel, - ClpAcceleratedKernelRegistry, - ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpCipherKernelTypes, + ClpICcmKernel, + ClpCipherKernelRegistry, + ClpCipherKernelDefaults, // registers in-tree fused AEAD kernel factories ClpCipherModeParameterUtilities, ClpIKeyParameter, ClpCbcBlockCipherMac, @@ -118,7 +118,7 @@ TCcmBlockCipher = class(TInterfacedObject, ICcmBlockCipher, FPlainScratch: TCryptoLibByteArray; // Cached once per Init; non-nil when the registry resolved a fused // CCM kernel for the underlying cipher and current direction. - FCcmKernel: IAcceleratedCcmKernel; + FCcmKernel: ICcmKernel; class function GetMacSize(ARequestedMacBits: Int32): Int32; static; procedure CheckNonceReuse(AForEncryption: Boolean; @@ -232,7 +232,7 @@ procedure TCcmBlockCipher.Init(AForEncryption: Boolean; var LChoice: TCipherAeadChoice; LRequestedMacSizeBits: Int32; - LDirection: TAcceleratedKernelDirection; + LDirection: TCipherKernelDirection; begin FForEncryption := AForEncryption; @@ -272,10 +272,10 @@ procedure TCcmBlockCipher.Init(AForEncryption: Boolean; // schedule contents are identical across those re-keys. FCipher.Init(True, FKeyParam); if AForEncryption then - LDirection := TAcceleratedKernelDirection.Encrypt + LDirection := TCipherKernelDirection.Encrypt else - LDirection := TAcceleratedKernelDirection.Decrypt; - TAcceleratedKernelRegistry.TryAcquireCcm(FCipher, LDirection, FCcmKernel); + LDirection := TCipherKernelDirection.Decrypt; + TCipherKernelRegistry.TryAcquireCcm(FCipher, LDirection, FCcmKernel); end; Reset(); diff --git a/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas b/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas index 62e100d3..4193c979 100644 --- a/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas +++ b/CryptoLib/src/Crypto/Modes/ClpChaCha20Poly1305.pas @@ -31,9 +31,9 @@ interface ClpIBulkStreamCipher, ClpIChaCha7539Engine, ClpChaCha7539Engine, - ClpAcceleratedKernelTypes, - ClpAcceleratedKernelRegistry, - ClpIAcceleratedChaCha20Poly1305Kernel, + ClpCipherKernelTypes, + ClpCipherKernelRegistry, + ClpIChaCha20Poly1305Kernel, ClpPoly1305, ClpIMac, ClpKeyParameter, @@ -116,7 +116,7 @@ TChaCha20Poly1305 = class(TInterfacedObject, IChaCha20Poly1305, IAeadCipher) FBulkChaCha: IBulkStreamCipher; // A registered ChaCha20-Poly1305 kernel, resolved once at Init. // the two-pass cipher-then-MAC path runs. - FChaChaKernel: IAcceleratedChaCha20Poly1305Kernel; + FChaChaKernel: IChaCha20Poly1305Kernel; FNonceBytes: Int32; FPoly1305: IMac; @@ -290,11 +290,11 @@ procedure TChaCha20Poly1305.Init(AForEncryption: Boolean; FChaCha20.Init(True, LChaCha20Params); if AForEncryption then - TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(FChaCha20, - TAcceleratedKernelDirection.Encrypt, FChaChaKernel) + TCipherKernelRegistry.TryAcquireChaCha20Poly1305(FChaCha20, + TCipherKernelDirection.Encrypt, FChaChaKernel) else - TAcceleratedKernelRegistry.TryAcquireChaCha20Poly1305(FChaCha20, - TAcceleratedKernelDirection.Decrypt, FChaChaKernel); + TCipherKernelRegistry.TryAcquireChaCha20Poly1305(FChaCha20, + TCipherKernelDirection.Decrypt, FChaChaKernel); if AForEncryption then FState := TState.EncInit diff --git a/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas index fb9b68f9..d9f2a0e1 100644 --- a/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpEaxBlockCipher.pas @@ -33,10 +33,10 @@ interface ClpISicBlockCipher, ClpIBulkBlockCipherMode, ClpBlockCipherBulkUtilities, - ClpAcceleratedKernelTypes, - ClpIAcceleratedEaxKernel, - ClpAcceleratedKernelRegistry, - ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpCipherKernelTypes, + ClpIEaxKernel, + ClpCipherKernelRegistry, + ClpCipherKernelDefaults, // registers in-tree fused AEAD kernel factories ClpCipherModeParameterUtilities, ClpIKeyParameter, ClpCMac, @@ -96,7 +96,7 @@ TEaxBlockCipher = class(TInterfacedObject, IEaxBlockCipher, // EAX kernel for the underlying cipher and encrypt direction. Decrypt // and non-AES ciphers stay on the TCMac / TSicBlockCipher scalar // path; set via FUseFusedBody below. - FEaxKernel: IAcceleratedEaxKernel; + FEaxKernel: IEaxKernel; // True iff a fused body kernel is live for this Init cycle. Gates // the mode-owned OMAC substrate (FOmac* + FCtrBlock) against the @@ -311,11 +311,11 @@ procedure TEaxBlockCipher.Init(AForEncryption: Boolean; // TCMac / TSicBlockCipher path runs - no compile-time arch gating needed. FEaxKernel := nil; if FForEncryption then - TAcceleratedKernelRegistry.TryAcquireEax(FCipher, - TAcceleratedKernelDirection.Encrypt, FEaxKernel) + TCipherKernelRegistry.TryAcquireEax(FCipher, + TCipherKernelDirection.Encrypt, FEaxKernel) else - TAcceleratedKernelRegistry.TryAcquireEax(FCipher, - TAcceleratedKernelDirection.Decrypt, FEaxKernel); + TCipherKernelRegistry.TryAcquireEax(FCipher, + TCipherKernelDirection.Decrypt, FEaxKernel); FUseFusedBody := FEaxKernel <> nil; if FUseFusedBody then diff --git a/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas index d4d38b43..bfacaa53 100644 --- a/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpGcmBlockCipher.pas @@ -40,10 +40,10 @@ interface ClpIBulkBlockCipher, ClpBlockCipherBulkUtilities, ClpByteUtilities, - ClpAcceleratedKernelTypes, - ClpIAcceleratedGcmKernel, - ClpAcceleratedKernelRegistry, - ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpCipherKernelTypes, + ClpIGcmKernel, + ClpCipherKernelRegistry, + ClpCipherKernelDefaults, // registers in-tree fused AEAD kernel factories ClpPack, ClpCheck, ClpBasicGcmMultiplier, @@ -106,11 +106,11 @@ TGcmBlockCipher = class(TInterfacedObject, IGcmBlockCipher, // exposes the generic IBulkBlockCipher capability. Drives the // non-fused 4/8-block CTR dispatchers (GetNextCtrBlocks4/8). FBulkCipher: IBulkBlockCipher; - // Fused CTR+GHASH kernel resolved via TAcceleratedKernelRegistry at Init + // Fused CTR+GHASH kernel resolved via TCipherKernelRegistry at Init // time. Non-nil only when an accelerator factory accepts the - // underlying cipher + direction and the accelerated-kernel gate is open (always nil - // off-SIMD; IAcceleratedGcmKernel is arch-neutral). - FGcmKernel: IAcceleratedGcmKernel; + // underlying cipher + direction and the cipher-kernel gate is open (always nil + // off-SIMD; IGcmKernel is arch-neutral). + FGcmKernel: IGcmKernel; FGcmKernelMinBlocks: Int32; FMultiplier: IGcmMultiplier; FExp: IGcmExponentiator; @@ -190,15 +190,15 @@ TGcmBlockCipher = class(TInterfacedObject, IGcmBlockCipher, ALimit: Int32; AForEncrypt: Boolean); // ===================================================================== // Fused block-cipher keystream + 8-way GHASH pipeline (provided by the - // accelerated-kernel registry; nil kernel -> not used, e.g. off-SIMD). + // cipher-kernel registry; nil kernel -> not used, e.g. off-SIMD). // ===================================================================== // This outer driver is arch-agnostic: pure Pascal batch orchestration - // plus one call into an IAcceleratedGcmKernel per 8-block stride. The kernel + // plus one call into an IGcmKernel per 8-block stride. The kernel // fuses CTR-mode keystream generation with the GHASH multiply-reduce in a // single pass, interleaving the two at the instruction level so their // independent execution units overlap. How wide that interleave runs and // how it is scheduled against the available vector-register budget is a - // backend detail hidden entirely behind the IAcceleratedGcmKernel surface, so + // backend detail hidden entirely behind the IGcmKernel surface, so // this driver only ever sees the kernel interface. /// /// Pipelined GCM path driven by FGcmKernel (when a fused kernel is @@ -467,7 +467,7 @@ procedure TGcmBlockCipher.InitCipherAndHashSubKey(const AKeyParam: IKeyParameter System.SetLength(FWorkCtrAhead, 128); TArrayUtilities.Fill(FWorkCtrAhead, 0, System.Length(FWorkCtrAhead), Byte(0)); - if TAcceleratedKernelRegistry.TryAcquireGcm(FCipher, TAcceleratedKernelDirection.Encrypt, + if TCipherKernelRegistry.TryAcquireGcm(FCipher, TCipherKernelDirection.Encrypt, @FHPow[0], FGcmKernel) and (FGcmKernel <> nil) then begin FGcmKernelMinBlocks := FGcmKernel.MinimumBlockCount; @@ -1143,7 +1143,7 @@ procedure TGcmBlockCipher.GhashFourShuffledBlocks(PC0, PC16, PC32, PC48: PByte); // GHASH to reclaim instruction-level parallelism across the two independent // execution units. The FusedILP variant (further below) pushes this further // by interleaving both at the instruction level inside a single kernel -// supplied by the accelerated-kernel registry (nil off-SIMD, so that path is +// supplied by the cipher-kernel registry (nil off-SIMD, so that path is // simply skipped there). AForEncrypt selects which buffer feeds GHASH: // output ciphertext on encrypt, input ciphertext on decrypt. // ======================================================================= @@ -1381,7 +1381,7 @@ class procedure TGcmBlockCipher.FillCtr8BlocksRaw( // ======================================================================= // Fused block-cipher keystream + 8-way GHASH pipeline. The driver is // arch-agnostic: it drives the outer 8-block stride loop and delegates the -// fused work to whichever IAcceleratedGcmKernel the registry resolved (nil +// fused work to whichever IGcmKernel the registry resolved (nil // off-SIMD, so the callers never invoke this path there). The kernel's // internal interleave and register budget are backend details behind the // interface, summarised on the matching banner in the class declaration. diff --git a/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas index 5a633b92..b3d1570c 100644 --- a/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpGcmSivBlockCipher.pas @@ -38,10 +38,10 @@ interface ClpGcmUtilities, ClpGcmSivUtilities, ClpGcmSivSimd, - ClpAcceleratedKernelTypes, - ClpIAcceleratedGcmSivKernel, - ClpAcceleratedKernelRegistry, - ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpCipherKernelTypes, + ClpIGcmSivKernel, + ClpCipherKernelRegistry, + ClpCipherKernelDefaults, // registers in-tree fused AEAD kernel factories ClpKeyParameter, ClpAesUtilities, ClpInt64Utilities, @@ -128,10 +128,10 @@ TGcmSivHasher = class(TObject) // when the fused kernel is available; captured by reference by the // kernel and consumed read-only by TGcmSivHasher.UpdateHash. FHPow128: TCryptoLibByteArray; - // Fused POLYVAL kernel resolved via TAcceleratedKernelRegistry. Non-nil + // Fused POLYVAL kernel resolved via TCipherKernelRegistry. Non-nil // only when the registry produced a kernel whose MinimumBlockCount // matches the mode's 8-block batch contract. - FGcmSivKernel: IAcceleratedGcmSivKernel; + FGcmSivKernel: IGcmSivKernel; FGcmSivKernelBatchBytes: Int32; procedure CheckAeadStatus(ALen: Int32); @@ -869,8 +869,8 @@ procedure TGcmSivBlockCipher.DeriveKeys(const AKey: IKeyParameter); if System.Length(FHPow128) < 128 then System.SetLength(FHPow128, 128); TGcmUtilities.InitEightWayHPowFromH(LMyOut, FHPow128); - if TAcceleratedKernelRegistry.TryAcquireGcmSiv(FTheCipher, - TAcceleratedKernelDirection.Encrypt, @FHPow128[0], FGcmSivKernel) and + if TCipherKernelRegistry.TryAcquireGcmSiv(FTheCipher, + TCipherKernelDirection.Encrypt, @FHPow128[0], FGcmSivKernel) and (FGcmSivKernel <> nil) then begin if FGcmSivKernel.MinimumBlockCount = 8 then diff --git a/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas index ef540ede..04240926 100644 --- a/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpOcbBlockCipher.pas @@ -25,10 +25,10 @@ interface Generics.Collections, ClpIBlockCipher, ClpIBulkBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedOcbKernel, - ClpAcceleratedKernelRegistry, - ClpAcceleratedKernelDefaults, // registers in-tree fused AEAD kernel factories + ClpCipherKernelTypes, + ClpIOcbKernel, + ClpCipherKernelRegistry, + ClpCipherKernelDefaults, // registers in-tree fused AEAD kernel factories ClpIOcbBlockCipher, ClpIAeadBlockCipher, ClpIAeadCipher, @@ -124,14 +124,14 @@ TOcbBlockCipher = class(TInterfacedObject, IOcbBlockCipher, FMainBulk: IBulkBlockCipher; // Fused-kernel fast path: cipher-agnostic fused OCB kernel - // resolved via TAcceleratedKernelRegistry on every Init. Nil when no + // resolved via TCipherKernelRegistry on every Init. Nil when no // registered factory accepts the cipher / direction pair or the // registry-wide kill switch is on; ProcessBytes then falls through // to the 8-wide bulk / scalar paths unchanged. // FOcbKernelMinBlocks is also the batch alignment: the kernel // loops internally in MinimumBlockCount chunks so the mode stages // up to FUSED_BATCH_BLOCKS worth of offsets per dispatch. - FOcbKernel: IAcceleratedOcbKernel; + FOcbKernel: IOcbKernel; FOcbKernelMinBlocks: Int32; procedure CheckNonceReuse(AForEncryption: Boolean; @@ -267,7 +267,7 @@ procedure TOcbBlockCipher.Init(AForEncryption: Boolean; LN: TCryptoLibByteArray; LMacSizeBits, LBottom, LBits, LBytes, LI: Int32; LB1, LB2: UInt32; - LFusedDirection: TAcceleratedKernelDirection; + LFusedDirection: TCipherKernelDirection; begin LOldForEncryption := FForEncryption; FForEncryption := AForEncryption; @@ -340,10 +340,10 @@ procedure TOcbBlockCipher.Init(AForEncryption: Boolean; FOcbKernel := nil; FOcbKernelMinBlocks := 0; if FForEncryption then - LFusedDirection := TAcceleratedKernelDirection.Encrypt + LFusedDirection := TCipherKernelDirection.Encrypt else - LFusedDirection := TAcceleratedKernelDirection.Decrypt; - if TAcceleratedKernelRegistry.TryAcquireOcb(FMainCipher, LFusedDirection, + LFusedDirection := TCipherKernelDirection.Decrypt; + if TCipherKernelRegistry.TryAcquireOcb(FMainCipher, LFusedDirection, FOcbKernel) and (FOcbKernel <> nil) then begin FOcbKernelMinBlocks := FOcbKernel.MinimumBlockCount; @@ -663,7 +663,7 @@ procedure TOcbBlockCipher.ProcessFusedBulk(const AInput: TCryptoLibByteArray; // LScratch reshape had to do on every fused decrypt batch. // // The `InPtr - BLOCK_SIZE` pointer is never dereferenced at offset 0 by - // the kernel (guaranteed by the IAcceleratedOcbKernel.ProcessBlocks contract for + // the kernel (guaranteed by the IOcbKernel.ProcessBlocks contract for // Block0Ptr); the address itself only feeds register arithmetic and the // `[InPtr + 16..]` loads, all of which resolve inside AInput. LBlock0Ptr := @FMainBlock[0]; diff --git a/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas b/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas index 41839be8..f50ad5b4 100644 --- a/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas +++ b/CryptoLib/src/Crypto/Modes/ClpSicBlockCipher.pas @@ -26,9 +26,9 @@ interface ClpIBlockCipher, ClpIBlockCipherMode, ClpIBulkBlockCipher, - ClpIAcceleratedCtrKernel, - ClpAcceleratedKernelTypes, - ClpAcceleratedKernelRegistry, + ClpICtrKernel, + ClpCipherKernelTypes, + ClpCipherKernelRegistry, ClpIBulkBlockCipherMode, ClpBlockCipherBulkUtilities, ClpByteUtilities, @@ -70,11 +70,11 @@ TSicBlockCipher = class(TInterfacedObject, ISicBlockCipher, // bulk-capable engine plugs in unchanged by implementing the // interface -- the mode does not care which cipher is underneath. FBulkCipher: IBulkBlockCipher; - // Acquired on Init from the accelerated-kernel registry when an accelerated + // Acquired on Init from the cipher-kernel registry when an accelerated // counter-mode kernel is available for FCipher: a single AES-NI pass that // fuses counter generation, encryption and XOR. Preferred over FBulkCipher // for the batch-aligned bulk; nil (with FBulkCipher fallback) otherwise. - FCtrKernel: IAcceleratedCtrKernel; + FCtrKernel: ICtrKernel; /// /// Snapshot FCounter into APlainCounters and advance FCounter by ABlockCount @@ -217,7 +217,7 @@ procedure TSicBlockCipher.Init(AForEncryption: Boolean; // Acquire the fused counter-mode kernel if an accelerator is registered for // FCipher (sets FCtrKernel nil on miss). Direction is irrelevant for CTR // keystream (always AES-encrypt of the counter), so request Encrypt. - TAcceleratedKernelRegistry.TryAcquireCtr(FCipher, TAcceleratedKernelDirection.Encrypt, + TCipherKernelRegistry.TryAcquireCtr(FCipher, TCipherKernelDirection.Encrypt, FCtrKernel); Reset(); diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCbcKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICbcKernel.pas similarity index 89% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCbcKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICbcKernel.pas index 362c03f3..381bde23 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCbcKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICbcKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedCbcKernel; +unit ClpICbcKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -23,8 +23,8 @@ interface uses ClpIBlockCipher, ClpCryptoLibTypes, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -36,7 +36,7 @@ interface /// C_{i-1}) parallelises and is not yet implemented. Cipher state lives /// inside the implementation; the mode sees only this interface. /// - IAcceleratedCbcKernel = interface + ICbcKernel = interface ['{898E71F2-B3C8-4B44-A3AB-2A493B4AE126}'] /// @@ -53,13 +53,13 @@ interface /// /// Factory contract for CBC-encrypt kernel providers. Registered with - /// TAcceleratedKernelRegistry; the registry walks the factory list (highest + /// TCipherKernelRegistry; the registry walks the factory list (highest /// priority first) and returns the first kernel whose TryCreate succeeds. /// Factories self-probe (CPU features, cipher identity) and wrap construction /// in try/except; TryCreate MUST return False on failure rather than /// propagating. /// - IAcceleratedCbcKernelFactory = interface(IAcceleratedKernelFactory) + ICbcKernelFactory = interface(ICipherKernelFactory) ['{A4FBAB88-8E80-45A0-86E1-B95B6AFBA9A2}'] /// @@ -69,8 +69,8 @@ interface /// failure; never raises. /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedCbcKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: ICbcKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCcmKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICcmKernel.pas similarity index 91% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCcmKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICcmKernel.pas index 03b912d3..d28b11fa 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCcmKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICcmKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedCcmKernel; +unit ClpICcmKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,8 +22,8 @@ interface uses ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -35,7 +35,7 @@ interface /// ProcessBody once per Init / Reset cycle covering the full bulk /// body. /// - IAcceleratedCcmKernel = interface + ICcmKernel = interface ['{BEAAEA01-DF32-441F-96AB-77D07C19578D}'] /// Minimum number of 16-byte body blocks the kernel can @@ -59,12 +59,12 @@ interface ACbcMacState: Pointer; ABlockCount: Int32); end; - IAcceleratedCcmKernelFactory = interface(IAcceleratedKernelFactory) + ICcmKernelFactory = interface(ICipherKernelFactory) ['{F30B4F47-0546-4212-A00D-850F2AF4FF5F}'] function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedCcmKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: ICcmKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCtrKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICtrKernel.pas similarity index 88% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCtrKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICtrKernel.pas index 61905b22..9671b70d 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedCtrKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpICtrKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedCtrKernel; +unit ClpICtrKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -23,20 +23,20 @@ interface uses ClpIBlockCipher, ClpCryptoLibTypes, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// /// Mode-specific contract for an accelerated counter (CTR / SIC) body kernel: /// generate AES-CTR keystream and XOR it into the payload in a single pass, /// advancing the counter. It is the non-authenticated, MAC-free member of - /// the accelerated-kernel family - the shared core the AEAD kernels are built on + /// the cipher-kernel family - the shared core the AEAD kernels are built on /// (GCM = CTR + GHASH, CCM = CTR + CBC-MAC, EAX = CTR + OMAC). All cipher /// state (the key schedule) lives inside the implementation; the mode sees /// only this interface. /// - IAcceleratedCtrKernel = interface + ICtrKernel = interface ['{2A9F4C71-6E38-4B0D-9C57-1F3B8E26D4A5}'] /// The batch granularity: ProcessCtrBlocks requires ABlockCount to @@ -59,13 +59,13 @@ interface /// /// Factory contract for CTR kernel providers. Registered with - /// TAcceleratedKernelRegistry; the registry walks the per-mode factory list + /// TCipherKernelRegistry; the registry walks the per-mode factory list /// (highest-priority first) and returns the first kernel whose TryCreate /// succeeds. Factories self-probe (CPU features, cipher identity) and wrap /// construction in try/except; TryCreate MUST return False on failure /// rather than propagating. /// - IAcceleratedCtrKernelFactory = interface(IAcceleratedKernelFactory) + ICtrKernelFactory = interface(ICipherKernelFactory) ['{7D1E6B02-4A9C-4F58-8B3D-2C57F1E96A4D}'] /// @@ -75,8 +75,8 @@ interface /// the same E_K(counter) stream). /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedCtrKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: ICtrKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedEaxKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIEaxKernel.pas similarity index 90% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedEaxKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIEaxKernel.pas index 16d11cb4..369a5192 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedEaxKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIEaxKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedEaxKernel; +unit ClpIEaxKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,8 +22,8 @@ interface uses ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -36,7 +36,7 @@ interface /// CBC-MAC running thereafter) and handles nonce-OMAC, header-OMAC, /// and the final-block OMAC subkey XOR. /// - IAcceleratedEaxKernel = interface + IEaxKernel = interface ['{3D87A0D4-7375-453F-BF72-CA3CA191CDCB}'] /// Minimum number of 16-byte body blocks the kernel can @@ -58,12 +58,12 @@ interface AOmacState: Pointer; ABlockCount: Int32); end; - IAcceleratedEaxKernelFactory = interface(IAcceleratedKernelFactory) + IEaxKernelFactory = interface(ICipherKernelFactory) ['{E3DDE544-91EF-4E41-B707-7ACD366FDB0A}'] function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedEaxKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: IEaxKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIGcmKernel.pas similarity index 90% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIGcmKernel.pas index 6f87c25b..e0ed4fcb 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIGcmKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedGcmKernel; +unit ClpIGcmKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,8 +22,8 @@ interface uses ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -34,7 +34,7 @@ interface /// static constants) lives inside the implementation; the mode /// sees only this interface. /// - IAcceleratedGcmKernel = interface + IGcmKernel = interface ['{D4D7F5F0-3C56-44E0-8BDD-944AC05E4D2E}'] /// Number of 16-byte blocks per batch consumed by @@ -59,14 +59,14 @@ interface /// /// Factory contract for GCM kernel providers. Registered with - /// TAcceleratedKernelRegistry; the registry walks the per-mode factory + /// TCipherKernelRegistry; the registry walks the per-mode factory /// list (highest-priority first) and returns the first kernel /// whose TryCreate succeeds. Factories self-probe (CPU features, /// cipher identity, direction support) and wrap construction in /// try/except; TryCreate MUST return False on failure rather than /// propagating. /// - IAcceleratedGcmKernelFactory = interface(IAcceleratedKernelFactory) + IGcmKernelFactory = interface(ICipherKernelFactory) ['{6F25C598-3089-40DA-8A81-9C898A5FCBE1}'] /// @@ -76,8 +76,8 @@ interface /// pointer MUST outlive the returned kernel. /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmKernel): Boolean; + ADirection: TCipherKernelDirection; AHPowers: Pointer; + out AKernel: IGcmKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIGcmSivKernel.pas similarity index 90% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIGcmSivKernel.pas index 5c9bbc30..55fa1d12 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedGcmSivKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIGcmSivKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedGcmSivKernel; +unit ClpIGcmSivKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,8 +22,8 @@ interface uses ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -34,7 +34,7 @@ interface /// factory registry for uniformity with the other accelerated AEAD /// kernels. /// - IAcceleratedGcmSivKernel = interface + IGcmSivKernel = interface ['{5FA774F0-42CC-407C-9410-1D5D66421F66}'] /// Number of 16-byte blocks absorbed per @@ -59,13 +59,13 @@ interface /// kernel. ADirection is accepted for registry uniformity but /// POLYVAL is direction-agnostic and it is typically ignored. /// - IAcceleratedGcmSivKernelFactory = interface(IAcceleratedKernelFactory) + IGcmSivKernelFactory = interface(ICipherKernelFactory) ['{5EA5178B-93BD-4E96-B19E-C09B04B32655}'] function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; + ADirection: TCipherKernelDirection; AHPowers: Pointer; - out AKernel: IAcceleratedGcmSivKernel): Boolean; + out AKernel: IGcmSivKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedOcbKernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIOcbKernel.pas similarity index 93% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedOcbKernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIOcbKernel.pas index cc9312af..6ff2416f 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Block/ClpIAcceleratedOcbKernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Block/ClpIOcbKernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedOcbKernel; +unit ClpIOcbKernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,8 +22,8 @@ interface uses ClpIBlockCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -31,7 +31,7 @@ interface /// state lives inside the implementation; the mode sees only this /// interface. /// - IAcceleratedOcbKernel = interface + IOcbKernel = interface ['{ADAF5C2A-FD31-42EF-A266-EB4B0F9AC06D}'] /// The minimum (and alignment) batch width the kernel @@ -85,7 +85,7 @@ interface AStartBlockCount: UInt64); end; - IAcceleratedOcbKernelFactory = interface(IAcceleratedKernelFactory) + IOcbKernelFactory = interface(ICipherKernelFactory) ['{A430371B-1B11-46C2-AFC8-EF9B07DE4CFA}'] /// @@ -95,8 +95,8 @@ interface /// construction exception); never raises. /// function TryCreate(const ACipher: IBlockCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedOcbKernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: IOcbKernel): Boolean; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/ClpICipherKernelFactory.pas similarity index 84% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/ClpICipherKernelFactory.pas index 5371438d..2ab88419 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/ClpIAcceleratedKernelFactory.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/ClpICipherKernelFactory.pas @@ -14,36 +14,36 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedKernelFactory; +unit ClpICipherKernelFactory; {$I ..\..\..\Include\CryptoLib.inc} interface uses - ClpAcceleratedKernelTypes; + ClpCipherKernelTypes; type /// - /// Family-agnostic base contract shared by every accelerated kernel factory + /// Family-agnostic base contract shared by every cipher kernel factory /// (block-cipher AEAD modes and stream-cipher AEADs alike). It carries only /// the identity and ordering a factory needs to live in the registry; the /// actual TryCreate lives on each derived factory interface with its own /// strongly-typed cipher parameter. The registry stores factories through /// this base and rediscovers a concrete family with Supports(); an external - /// consumer can therefore register an accelerated kernel for an algorithm the + /// consumer can therefore register a cipher kernel for an algorithm the /// framework never enumerated, with no framework edit. /// - IAcceleratedKernelFactory = interface + ICipherKernelFactory = interface ['{006B1103-17E9-43C6-9A7A-EB515B120325}'] /// Stable human-readable provider label (diagnostics / tests). function ProviderName: String; /// Priority class controlling factory order inside the registry; - /// see TAcceleratedKernelPriority. Higher wins; equal priorities keep + /// see TCipherKernelPriority. Higher wins; equal priorities keep /// registration order. - function Priority: TAcceleratedKernelPriority; + function Priority: TCipherKernelPriority; end; implementation diff --git a/CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Stream/ClpIChaCha20Poly1305Kernel.pas similarity index 87% rename from CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas rename to CryptoLib/src/Interfaces/Crypto/CipherKernels/Stream/ClpIChaCha20Poly1305Kernel.pas index a40b2b79..a9a5cdbd 100644 --- a/CryptoLib/src/Interfaces/Crypto/Accelerated/Stream/ClpIAcceleratedChaCha20Poly1305Kernel.pas +++ b/CryptoLib/src/Interfaces/Crypto/CipherKernels/Stream/ClpIChaCha20Poly1305Kernel.pas @@ -14,7 +14,7 @@ (* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *) -unit ClpIAcceleratedChaCha20Poly1305Kernel; +unit ClpIChaCha20Poly1305Kernel; {$I ..\..\..\..\Include\CryptoLib.inc} @@ -22,8 +22,8 @@ interface uses ClpIStreamCipher, - ClpAcceleratedKernelTypes, - ClpIAcceleratedKernelFactory; + ClpCipherKernelTypes, + ClpICipherKernelFactory; type /// @@ -36,7 +36,7 @@ interface /// analogue of the block-cipher accelerated kernels (GCM = CTR + GHASH); the /// engine key schedule and Poly1305 r/s clamp live inside the implementation. /// - IAcceleratedChaCha20Poly1305Kernel = interface + IChaCha20Poly1305Kernel = interface ['{87051735-EA07-4800-A6D9-A8922BFDF6A2}'] /// Stride granularity in bytes (512 = 8 x 64-byte ChaCha blocks). @@ -58,24 +58,24 @@ interface /// /// Factory contract for accelerated ChaCha20-Poly1305 kernel providers. Registered - /// with TAcceleratedKernelRegistry through the family-agnostic IAcceleratedKernelFactory + /// with TCipherKernelRegistry through the family-agnostic ICipherKernelFactory /// base; the registry re-discovers it via Supports(). Factories self-probe /// (CPU features, Supports(ACipher, IChaCha7539Engine)) and wrap construction /// in try/except; TryCreate MUST return False on failure rather than /// propagating. /// - IAcceleratedChaCha20Poly1305KernelFactory = interface(IAcceleratedKernelFactory) + IChaCha20Poly1305KernelFactory = interface(ICipherKernelFactory) ['{A633B415-7A54-44D7-B983-18BBECC2B32F}'] /// - /// Attempt to construct an accelerated kernel bound to ACipher (a stream cipher; + /// Attempt to construct a cipher kernel bound to ACipher (a stream cipher; /// the factory probes Supports(ACipher, IChaCha7539Engine) for the concrete /// engine). ADirection is accepted for symmetry with the AEAD factories; /// the kernel handles both directions via ProcessStrides' AForEncrypt. /// function TryCreate(const ACipher: IStreamCipher; - ADirection: TAcceleratedKernelDirection; - out AKernel: IAcceleratedChaCha20Poly1305Kernel): Boolean; + ADirection: TCipherKernelDirection; + out AKernel: IChaCha20Poly1305Kernel): Boolean; end; implementation diff --git a/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk b/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk index 32cfc246..b90db160 100644 --- a/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk +++ b/CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk @@ -685,29 +685,29 @@ contains ClpEaxBlockCipher in '..\..\Crypto\Modes\ClpEaxBlockCipher.pas', ClpOcbBlockCipher in '..\..\Crypto\Modes\ClpOcbBlockCipher.pas', ClpGcmSivUtilities in '..\..\Crypto\Modes\Gcm\ClpGcmSivUtilities.pas', - ClpAcceleratedKernelTypes in '..\..\Crypto\Accelerated\ClpAcceleratedKernelTypes.pas', - ClpIAcceleratedKernelFactory in '..\..\Interfaces\Crypto\Accelerated\ClpIAcceleratedKernelFactory.pas', - ClpIAcceleratedChaCha20Poly1305Kernel in '..\..\Interfaces\Crypto\Accelerated\Stream\ClpIAcceleratedChaCha20Poly1305Kernel.pas', - ClpIAcceleratedGcmKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmKernel.pas', - ClpIAcceleratedOcbKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedOcbKernel.pas', - ClpIAcceleratedCcmKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCcmKernel.pas', - ClpIAcceleratedEaxKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedEaxKernel.pas', - ClpIAcceleratedGcmSivKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedGcmSivKernel.pas', - ClpIAcceleratedCtrKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCtrKernel.pas', - ClpIAcceleratedCbcKernel in '..\..\Interfaces\Crypto\Accelerated\Block\ClpIAcceleratedCbcKernel.pas', - ClpAcceleratedKernelFactoryBase in '..\..\Crypto\Accelerated\ClpAcceleratedKernelFactoryBase.pas', - ClpAcceleratedKernelRegistry in '..\..\Crypto\Accelerated\ClpAcceleratedKernelRegistry.pas', - ClpAesFusedAeadSimd in '..\..\Crypto\Accelerated\Block\Internal\ClpAesFusedAeadSimd.pas', - ClpAesNiFusedX86Backend in '..\..\Crypto\Accelerated\Block\Internal\ClpAesNiFusedX86Backend.pas', + ClpCipherKernelTypes in '..\..\Crypto\CipherKernels\ClpCipherKernelTypes.pas', + ClpICipherKernelFactory in '..\..\Interfaces\Crypto\CipherKernels\ClpICipherKernelFactory.pas', + ClpIChaCha20Poly1305Kernel in '..\..\Interfaces\Crypto\CipherKernels\Stream\ClpIChaCha20Poly1305Kernel.pas', + ClpIGcmKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpIGcmKernel.pas', + ClpIOcbKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpIOcbKernel.pas', + ClpICcmKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpICcmKernel.pas', + ClpIEaxKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpIEaxKernel.pas', + ClpIGcmSivKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpIGcmSivKernel.pas', + ClpICtrKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpICtrKernel.pas', + ClpICbcKernel in '..\..\Interfaces\Crypto\CipherKernels\Block\ClpICbcKernel.pas', + ClpCipherKernelFactoryBase in '..\..\Crypto\CipherKernels\ClpCipherKernelFactoryBase.pas', + ClpCipherKernelRegistry in '..\..\Crypto\CipherKernels\ClpCipherKernelRegistry.pas', + ClpAesFusedAeadSimd in '..\..\Crypto\CipherKernels\Block\Internal\ClpAesFusedAeadSimd.pas', + ClpAesNiFusedX86Backend in '..\..\Crypto\CipherKernels\Block\Internal\ClpAesNiFusedX86Backend.pas', ClpBinPolySimd in '..\..\Math\BinPoly\ClpBinPolySimd.pas', - ClpAesNiOcbKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiOcbKernel.pas', - ClpAesNiCcmKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiCcmKernel.pas', - ClpAesNiEaxKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiEaxKernel.pas', - ClpAesNiGcmKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiGcmKernel.pas', - ClpAesNiCtrKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiCtrKernel.pas', - ClpAesNiCbcKernel in '..\..\Crypto\Accelerated\Block\ClpAesNiCbcKernel.pas', - ClpPclmulGcmSivKernel in '..\..\Crypto\Accelerated\Block\ClpPclmulGcmSivKernel.pas', - ClpAcceleratedKernelDefaults in '..\..\Crypto\Accelerated\ClpAcceleratedKernelDefaults.pas', + ClpAesNiOcbKernel in '..\..\Crypto\CipherKernels\Block\ClpAesNiOcbKernel.pas', + ClpAesNiCcmKernel in '..\..\Crypto\CipherKernels\Block\ClpAesNiCcmKernel.pas', + ClpAesNiEaxKernel in '..\..\Crypto\CipherKernels\Block\ClpAesNiEaxKernel.pas', + ClpAesNiGcmKernel in '..\..\Crypto\CipherKernels\Block\ClpAesNiGcmKernel.pas', + ClpAesNiCtrKernel in '..\..\Crypto\CipherKernels\Block\ClpAesNiCtrKernel.pas', + ClpAesNiCbcKernel in '..\..\Crypto\CipherKernels\Block\ClpAesNiCbcKernel.pas', + ClpPclmulGcmSivKernel in '..\..\Crypto\CipherKernels\Block\ClpPclmulGcmSivKernel.pas', + ClpCipherKernelDefaults in '..\..\Crypto\CipherKernels\ClpCipherKernelDefaults.pas', ClpAeadParameters in '..\..\Crypto\Parameters\ClpAeadParameters.pas', ClpBufferedAeadCipher in '..\..\Crypto\ClpBufferedAeadCipher.pas', ClpBufferedAeadBlockCipher in '..\..\Crypto\ClpBufferedAeadBlockCipher.pas', diff --git a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk index 4c50680e..b43b8ee6 100644 --- a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk +++ b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk @@ -10,7 +10,7 @@ - + @@ -2706,60 +2706,60 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - - + + @@ -3178,7 +3178,7 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - + @@ -3190,11 +3190,11 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - + @@ -3206,11 +3206,11 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - + @@ -3218,16 +3218,16 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel - - + + - - + + - - + + diff --git a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas index 0a492e6f..1b204020 100644 --- a/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas +++ b/CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas @@ -218,11 +218,11 @@ interface ClpArmSimdFeatures, ClpSimdLevels, ClpX86SimdFeatures, ClpArmHwCapProvider, ClpDarwinSysCtl, ClpIBulkBlockCipherMode, ClpIBulkBlockCipher, ClpBlockCipherBulkUtilities, ClpCipherModeParameterUtilities, - ClpGcmSivUtilities, ClpAcceleratedKernelTypes, ClpIAcceleratedGcmKernel, - ClpIAcceleratedOcbKernel, ClpIAcceleratedCcmKernel, ClpIAcceleratedEaxKernel, - ClpIAcceleratedGcmSivKernel, ClpAcceleratedKernelRegistry, ClpAesFusedAeadSimd, + ClpGcmSivUtilities, ClpCipherKernelTypes, ClpIGcmKernel, + ClpIOcbKernel, ClpICcmKernel, ClpIEaxKernel, + ClpIGcmSivKernel, ClpCipherKernelRegistry, ClpAesFusedAeadSimd, ClpAesNiOcbKernel, ClpAesNiCcmKernel, ClpAesNiEaxKernel, ClpAesNiGcmKernel, - ClpPclmulGcmSivKernel, ClpAcceleratedKernelDefaults, ClpXChaCha20Engine, + ClpPclmulGcmSivKernel, ClpCipherKernelDefaults, ClpXChaCha20Engine, ClpIXChaCha20Engine, ClpXChaCha20Poly1305, ClpIXChaCha20Poly1305, ClpDigestStream, ClpMacSink, ClpMacStream, ClpSignerStream, ClpDefaultMacCalculator, ClpDefaultMacResult, ClpIMacAlgorithmFinder, @@ -256,10 +256,10 @@ interface ClpSalsaX86Backend, ClpPoly1305State, ClpPoly1305Simd, ClpPoly1305X86Backend, ClpGhashSimd, ClpGhashX86Backend, ClpGcmSivSimd, ClpGcmSivX86Backend, ClpAesNiFusedX86Backend, ClpBinPolySimd, ClpAesSimd, - ClpIAcceleratedCtrKernel, ClpAesNiCtrKernel, ClpByteXorSimd, ClpByteXorX86Backend, - ClpIAcceleratedCbcKernel, ClpAesNiCbcKernel, ClpIBulkStreamCipher, - ClpIAcceleratedKernelFactory, ClpIAcceleratedChaCha20Poly1305Kernel, - ClpAcceleratedKernelFactoryBase; + ClpICtrKernel, ClpAesNiCtrKernel, ClpByteXorSimd, ClpByteXorX86Backend, + ClpICbcKernel, ClpAesNiCbcKernel, ClpIBulkStreamCipher, + ClpICipherKernelFactory, ClpIChaCha20Poly1305Kernel, + ClpCipherKernelFactoryBase; implementation From f568d58254293df5724b4f82094f1e5471d9eee1 Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Fri, 10 Jul 2026 07:32:28 +0100 Subject: [PATCH 4/4] fix stale comment --- .../src/Crypto/Engines/ClpAesEngineX86.pas | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CryptoLib/src/Crypto/Engines/ClpAesEngineX86.pas b/CryptoLib/src/Crypto/Engines/ClpAesEngineX86.pas index 8461ee63..2c43d4f3 100644 --- a/CryptoLib/src/Crypto/Engines/ClpAesEngineX86.pas +++ b/CryptoLib/src/Crypto/Engines/ClpAesEngineX86.pas @@ -114,15 +114,15 @@ TAesEngineX86 = class sealed(TInterfacedObject, IAesEngineX86, IAesHardwareEng /// /// Internal fast-path accessor for the AES-NI encrypt round-key schedule - /// used by the fused GCM + AES-NI pipeline kernel. Returns True (and sets - /// AKeysPtr to the aligned key-schedule buffer plus ANumRounds to the AES - /// round count) only when the engine is currently initialized for AES - /// encryption in any supported key size (AForEncryption=True; ANumRounds - /// in {10, 12, 14} for AES-128 / AES-192 / AES-256 respectively). Returns - /// False in every other state (including all decrypt-direction inits). - /// Note: GCM always uses AES in encrypt mode for CTR keystream generation, - /// regardless of whether the GCM caller is encrypting or decrypting; this - /// accessor therefore deliberately rejects only AES-side decrypt inits. + /// used by the AES-NI fused cipher kernels. Returns True (and sets AKeysPtr + /// to the aligned key-schedule buffer plus ANumRounds to the AES round + /// count) only when the engine is currently initialized for AES encryption + /// in any supported key size (AForEncryption=True; ANumRounds in {10, 12, + /// 14} for AES-128 / AES-192 / AES-256 respectively). Returns False in every + /// other state (including all decrypt-direction inits). Note: the fused + /// modes built on this accessor drive AES in encrypt mode for keystream + /// generation regardless of the AEAD direction, so it rejects decrypt inits; + /// kernels needing the decrypt schedule use TryGetDecKeysPtr instead. /// Callers MUST NOT retain the pointer beyond the lifetime of the current /// engine init; reinit / free invalidates it. /// @@ -1143,9 +1143,9 @@ function TAesEngineX86.ProcessBlocks(AInput, AOutput: PByte; end; // ===================================================================== -// Key-schedule accessor used by the fused AES-NI + GHASH pipeline in -// TGcmBlockCipher. Returns a pointer to the round-key schedule only when -// the engine is in an AES-encrypt mode with a matching round count. +// Key-schedule accessors used by the AES-NI fused cipher kernels. Return a +// pointer to the round-key schedule only when the engine is in the requested +// direction with a matching round count. // ===================================================================== function TAesEngineX86.TryGetEncKeysPtr(out AKeysPtr: PByte; out ANumRounds: Int32): Boolean;