Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Last active December 17, 2024 16:48
Show Gist options
  • Save kwilczynski/eb76ff5ebb811729b286a9261de0577f to your computer and use it in GitHub Desktop.
Save kwilczynski/eb76ff5ebb811729b286a9261de0577f to your computer and use it in GitHub Desktop.
Test for AES NI in the CPU.
#include <stdio.h>
int main (int argc, char **argv)
{
unsigned int eax, ebx, ecx, edx;
asm(
"xchg{l}\t{%%}ebx, %1\n\t" \
"cpuid\n\t" \
"xchg{l}\t{%%}ebx, %1\n\t" \
: "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx) \
: "0" (1)
);
if (ecx & (1 << 25))
printf("AES supported.\n");
else
printf("No AES support.\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment