Commit a04efb96 authored by Fábio Silva's avatar Fábio Silva
Browse files

Add capabilities binary

parent 6b6fa0b5
File added
File added
#include <stdio.h>
#include <string.h>
#include <cpuid.h>
#define bit_RDRND (1 << 30)
void rdrand()
{
unsigned int eax;
unsigned int ebx;
unsigned int ecx;
unsigned int edx;
eax = 0x01;
__asm__ __volatile__(
"cpuid;"
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
: "a"(eax)
);
if(ecx & bit_RDRND){
//use rdrand
printf("Has RDRND: %d\n", 1);
}
else
{
printf("Has RDRND: %d\n", 0);
}
}
void aesni()
{
unsigned int eax, ebx, ecx, edx;
eax = ebx = ecx = edx = 0;
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
printf("Has AES-NI: %d\n", (ecx & bit_AES) > 0);
}
int main(int argc, char **argv)
{
rdrand();
aesni();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment