Skip to content

Commit

Permalink
Tweaked check_for_aes_instructions to look for AMD as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrnewton committed Feb 8, 2011
1 parent a46e0d7 commit 34318c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
5 changes: 4 additions & 1 deletion cbits/Intel_AESNI_Sample_Library_v1.0/intel_aes_lib/Makefile
Expand Up @@ -3,8 +3,10 @@ UNAME=$(shell uname -m)

# Must be 86 (for 32bit compiler) or 64 (for 64bit compiler)
ARCH=64
#ARCH=86
# Must be 32 or 64:
SZ=64
#SZ=32

STATIC=lib/x$(ARCH)/libintel_aes.a
DYNAMIC=lib/x$(ARCH)/libintel_aes.so
Expand All @@ -17,7 +19,8 @@ OBJ= obj/x$(ARCH)/intel_aes.o \
obj/x$(ARCH)/iaesx$(ARCH).o \
obj/x$(ARCH)/do_rdtsc.o

GCC=gcc
# GCC=gcc -m32
GCC=gcc
YASM=yasm
YASMFLAGS= -D__linux__ -g dwarf2 -f elf$(SZ)

Expand Down
Empty file.
Expand Up @@ -291,17 +291,29 @@ int check_for_aes_instructions()
* ECX = 'l' 'e' 't' 'n'
*/

// AuthenticAMD

int intel = 1;
int amd = 1;
if (memcmp((unsigned char *)&cpuid_results[1], "Genu", 4) != 0 ||
memcmp((unsigned char *)&cpuid_results[3], "ineI", 4) != 0 ||
memcmp((unsigned char *)&cpuid_results[2], "ntel", 4) != 0)
return no;

__cpuid(cpuid_results,1);

if (cpuid_results[2] & AES_INSTRCTIONS_CPUID_BIT)
return yes;

return no;
intel = 0;

if (memcmp((unsigned char *)&cpuid_results[1], "Auth", 4) != 0 ||
memcmp((unsigned char *)&cpuid_results[3], "enti", 4) != 0 ||
memcmp((unsigned char *)&cpuid_results[2], "cAMD", 4) != 0)
amd = 0;

if (intel || amd)
{
__cpuid(cpuid_results,1);

if (cpuid_results[2] & AES_INSTRCTIONS_CPUID_BIT)
return yes;
}
else
return no;
}


Expand Down
3 changes: 2 additions & 1 deletion intel-aes.cabal
Expand Up @@ -5,7 +5,8 @@ License: BSD3
License-file: LICENSE
Stability: Beta
Maintainer: Ryan Newton <rrnewton@gmail.com>
Author: Ryan Newton <rrnewton@gmail.com>, Svein Ove Aas <svein.ove@aas.no>, Thomas M. DuBuisson
Author: Ryan Newton <rrnewton@gmail.com>,
Svein Ove Aas <svein.ove@aas.no>, Thomas M. DuBuisson <thomas.dubuisson@gmail.com>
Copyright: Copyright (c) 2011 Intel Corporation
Synopsis: Hardware accelerated AES encryption and RNG.
HomePage: https://github.com/rrnewton/intel-aes/wiki
Expand Down

0 comments on commit 34318c5

Please sign in to comment.