summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorSebastian Ramacher <sebastian@ramacher.at>2013-02-04 14:44:29 +0100
committerDwayne Litzenberger <dlitz@dlitz.net>2013-04-21 20:41:18 -0700
commite1ce77b1673db76fb46d87effa7b1a1dc083d9b7 (patch)
tree3c999461384918aa9b1c2f10813db7211e2534b1 /setup.py
parent1dd8353cc490f954677285415ec01e253f84b93d (diff)
downloadpycrypto-e1ce77b1673db76fb46d87effa7b1a1dc083d9b7.tar.gz
Initial AES-NI support
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 85bd65a..5af83ac 100644
--- a/setup.py
+++ b/setup.py
@@ -162,6 +162,21 @@ class PCTBuildExt (build_ext):
"Crypto.PublicKey._fastmath.")
self.__remove_extensions(["Crypto.PublicKey._fastmath"])
+ # Detect if we have AES-NI instrincs available
+ if not ac.get("HAVE_WMMINTRIN_H"):
+ # AES-NI instrincs not available
+ self.__remove_extensions(["Crypto.Cipher._AESNI"])
+ elif ac.get("HAVE_MAES"):
+ # -maes has to be passed to the compiler to use the AES-NI instrincs
+ self.__add_extension_compile_option(["Crypto.Cipher._AESNI"],
+ ["-maes"])
+
+ def __add_extension_compile_option(self, names, options):
+ """Add compiler options for the specified extension(s)"""
+ for extension in self.extensions:
+ if extension.name in names:
+ extension.extra_compile_args = options
+
def __add_extension_link_option(self, names, options):
"""Add linker options for the specified extension(s)"""
i = 0
@@ -426,6 +441,9 @@ kw = {'name':"pycrypto",
Extension("Crypto.Cipher._AES",
include_dirs=['src/'],
sources=["src/AES.c"]),
+ Extension("Crypto.Cipher._AESNI",
+ include_dirs=['src/'],
+ sources=["src/AESNI.c"]),
Extension("Crypto.Cipher._ARC2",
include_dirs=['src/'],
sources=["src/ARC2.c"]),
@@ -454,6 +472,9 @@ kw = {'name':"pycrypto",
Extension("Crypto.Util.strxor",
include_dirs=['src/'],
sources=['src/strxor.c']),
+ Extension("Crypto.Util.cpuid",
+ include_dirs=['src/'],
+ sources=['src/cpuid.c']),
# Counter modules
Extension("Crypto.Util._counter",