Use hardware accelerated Aes on x64#5196
Use hardware accelerated Aes on x64#5196rubo merged 1 commit intoNethermindEth:masterfrom benaadams:Aes
Conversation
|
Contributed the improvement upstream bcgit/bc-csharp#414 |
|
This looks great. On the other hand, I'm considering replacing the BouncyCastle implementation with .NET's own one. |
Aren't necessarily incompatible; as I assume switching implementation will be a longer and more involved process due to different abstractions? So could do this change as quick win; then follow up with implementation change? |
|
I'm surprised that this is way faster than the implementation of |
Glad to here, I did spend quite a while optimizing the inheritance chain and implementation to get it just so 😅 However everything else is just abstraction cruft; so if you can take this implementation (and the sealed implementation inherence; which the Jit can then switch to direct calls as only use one type size of key and either encryption or decryption but not both at each call site) and combine it with platform version (which will be better for Arm and fallback); rather than bouncy castle; should have a very fast implementation. |
|
What is the speedup? |
|
The implementation of Aes in OpenSsl and Windows side is very good; however for small payloads might pay in interop and abstractions to get there? |
Changes
System.Runtime.Intrinsics.X86.Aeswhen supportedTypes of changes
Generates clean hardware accelerated asm for the encypt+decrypt methods compared to the software version. E.g. the encrypt 256 is below
What types of changes does your code introduce?
Testing
Confirmed all the Aes goes through the accelerated
IBlockCipheron supported hardware (everything x64)Requires testing
If yes, did you write tests?