From e1ce77b1673db76fb46d87effa7b1a1dc083d9b7 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 4 Feb 2013 14:44:29 +0100 Subject: Initial AES-NI support --- setup.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'setup.py') 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", -- cgit v1.2.1