cassemblyaesaes-ni

How to check aes-ni are supported by CPU?


I searching for solution, how to check aes-ni are available on CPU. I need to put this information in my application, so i'm not looking for any CPU-Z, bash commands or something. I know that it is seen as aes flag. I have no idea how to check it in assembly or c. Main application is written in C#, but it doesn't matter.


Solution

  • This information is returned by the cpuid instruction. Pass in eax=1 and bit #25 in ecx will show support. See the intel instruction set reference for more details. Sample code:

    mov eax, 1
    cpuid
    test ecx, 1<<25
    jz no_aesni
    

    Also, you might just try executing it and catch the exception.