Re-architect fused AEAD subsystem into an open cipher-kernel framework#142
Merged
Conversation
…mework
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
IAccelerated<X>KernelFactory with zero framework edits.
- Contracts IFused<Mode>Kernel -> IAccelerated<Mode>Kernel.
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.
The 16 Register*/Unregister*Factory wrappers were one-line pass-throughs to the generic Register/Unregister - redundant, since every IAccelerated<Mode> 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).
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: IAccelerated<Mode>Kernel(Factory) -> I<Mode>Kernel(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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the closed fused-kernel registry with an extensible cipher-kernel framework: a single priority-ordered registry where in-tree SIMD kernels and external plug-ins register through the same API.
Framework re-architecture
Crypto/Modes/Fused→Crypto/CipherKernels(block AEADs are not "modes"); shared SIMD asm include depth is unchangedClpFusedKernelRegistrywithTCipherKernelRegistry,TCipherKernelGate, andTCipherKernelFactoryBaseSupports-filtered, priority-sorted factory list; external consumers registerICipherKernelFactoryimplementations with zero framework editsFallback<Baseline<Preferred<UserOverride(equal priorities keep registration order)TCipherKernelGate.ForceDisabledkill-switch routes all modes through scalar fallbacks for dual-path parity testingContracts and naming
IGcmKernel,IOcbKernel,ICcmKernel,IEaxKernel,IGcmSivKernel,ICtrKernel,ICbcKernelICipherKernelFactory(shared registration/discovery surface)ClpAesFusedAeadSimd,ClpAesNiFusedX86Backend, fused asm includes)Compact public API
Register*/Unregister*wrappers; in-tree init and tests call genericRegister/Unregister(same API external plug-ins use)GetRegistered*Providersinto oneGetRegisteredProviders(const AFactoryIID: TGUID)TryAcquire*methods (signatures genuinely diverge:AHPowersfor GCM/GCM-SIV,IStreamCipherfor ChaCha20-Poly1305)Mode integration
IChaCha20Poly1305Kernel+TryAcquireChaCha20Poly1305;TChaCha20Poly1305resolves at init (nil today → two-pass, byte-identical)Tests
FusedKernelToggle→CipherKernelToggle;RunWithFusedToggle→RunWithCipherKernelToggleFusedExternalRegistrationTests→CipherKernelExternalRegistrationTests(4 registration contract tests)