Created
August 21, 2017 08:43
-
-
Save MostParsingVex/e825ad434fd5fda187463d8144b96769 to your computer and use it in GitHub Desktop.
XMM register preserving SIGILL probe for AES-NI instructions on x86 and AMD64. Should work on Linux, BSD, OSX, Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<setjmp.h> | |
#include<signal.h> | |
jmp_buf state; | |
void sigill_handler( int i ) { | |
signal( SIGILL, SIG_DFL ); | |
longjmp( state, 1 ); | |
} | |
//register preserving aesenc/aesdec sequence | |
#if(unix) | |
const | |
#else //windows | |
#pragma section("foo", execute) | |
__declspec(allocate("foo")) | |
#endif | |
char aesni[]="\x66\x0F\x38\xDD\xC1\x66\x0F\x38\xDF\xC1\xc3"; | |
int aesnidetect( ) { | |
signal( SIGILL, sigill_handler ); | |
int r = setjmp( state ); | |
if( !r ) ((void(*)())(char*)aesni)(); | |
return !r; | |
} | |
int main(){ | |
puts( aesnidetect()?"YES":"NO" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment