Question

Does anyone know whether the AesManaged Cryptography provider from .NET (>4.0) supports hardware acceleration, if the CPU has AES extensions (Like Haswell based CPU)?

If so, is there a way to confirm with code?

Was it helpful?

Solution

Clearly the .NET AesManaged implementation is not hardware accelerated. Searches of SO and Google indicate that AesCryptoServiceProvider (which is a wrapper over the OS crypto) is generally much slower than the AesManaged implementation.

However, I have found that the AesCryptoServiceProvider was actually faster, way faster, as in order of magnitude difference. I'm suspecting that the OS level implementation is actually handing AES-NI instructions off to the CPU for hardware acceleration.

I cannot locate any documentation on the above observation, but if my suspicions are correct then at least on a Core i7 4770 CPU running 64-Bit Windows 8.1 Update 1, the AesCryptoServiceProvider is hardware accelerated.

Performance observations are that on the above machine, 8 threads of AES CBC decryption using AesManaged will max out the CPU and consume as much memory as needed for the data (i.e. for us 32GB of RAM gets maxed out regularly). The exact same code but using AesCryptoServiceProvider has the CPU cores average around 30-40% and memory (private working bytes) seldom go over 10GB.

To semi-answer my own question, try AesCryptoServiceProvider, especially on 64-bit Windows 8.1 Update 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top