Intel AES New Instructions (AESNI) libraries for C on Ubuntu

First, you need to check if your CPU is compatible with hardware accelerated Intel technology for cipher/decrypt with AES.





Next, we need to download the Intel AESNI library and compile it:

wget https://software.intel.com/sites/default/files/article/181731/intel-aesni-sample-library-v1.2.zip
unzip intel-aesni-sample-library-v1.2.zip
cd Intel_AESNI_Sample_Library_v1.2
./mk_lnx64_all.sh

Maybe, you will get the following errror:

collect2: error: ld returned 1 exit status
Got error on link

If you get it, please install yasm
sudo apt-get install yasm

Now, compile it again:
./mk_lnx64.sh     
~/Downloads/Intel_AESNI_Sample_Library_v1.2/aes_example ~/Downloads/Intel_AESNI_Sample_Library_v1.2/aes_example
~/Downloads/Intel_AESNI_Sample_Library_v1.2/intel_aes_lib ~/Downloads/Intel_AESNI_Sample_Library_v1.2/intel_aes_lib
do iaesx64.s
do do_rdtsc.s
~/Downloads/Intel_AESNI_Sample_Library_v1.2/intel_aes_lib
~/Downloads/Intel_AESNI_Sample_Library_v1.2/aes_example
mkdir: cannot create directory ‘bin’: File exists
src/aes_example.c: In function ‘main’:
src/aes_example.c:2327:10: warning: too many arguments for format [-Wformat-extra-args]
   printf("input_file (will be overwritten)= %s encoded_file= %s, decoded_file= %s\n",
          ^
created bin/aes_example64

Now, you can run bin/aes_example64 
Enjoy it!

If you want more examples remember that AESNI use the following libraries:
#include "iaesni.h"
#include "iaes_asm_interface.h"

Comments

Popular posts from this blog

How to fix Android when developer options are not available for this user

Contiki 3.0 on XM1000

How to fix VirtualBox error when you try to import an ova file