| 
									
										
										
										
											2002-04-03 18:45:09 -07:00
										 |  |  | #! /usr/bin/env python | 
					
						
							| 
									
										
										
										
											2009-08-03 15:14:44 -04:00
										 |  |  | # | 
					
						
							|  |  |  | #  setup.py : Distutils setup script | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # =================================================================== | 
					
						
							| 
									
										
										
										
											2014-06-14 22:00:00 +02:00
										 |  |  | # The contents of this file are dedicated to the public domain.  To | 
					
						
							|  |  |  | # the extent that dedication to the public domain is not available, | 
					
						
							| 
									
										
										
										
											2009-08-03 15:14:44 -04:00
										 |  |  | # everyone is granted a worldwide, perpetual, royalty-free, | 
					
						
							|  |  |  | # non-exclusive license to exercise all rights associated with the | 
					
						
							| 
									
										
										
										
											2014-06-14 22:00:00 +02:00
										 |  |  | # contents of this file for any purpose whatsoever. | 
					
						
							|  |  |  | # No rights are reserved. | 
					
						
							| 
									
										
										
										
											2009-08-03 15:14:44 -04:00
										 |  |  | # | 
					
						
							|  |  |  | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 
					
						
							|  |  |  | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 
					
						
							|  |  |  | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 
					
						
							|  |  |  | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | 
					
						
							|  |  |  | # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 
					
						
							|  |  |  | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | 
					
						
							|  |  |  | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 
					
						
							|  |  |  | # SOFTWARE. | 
					
						
							|  |  |  | # =================================================================== | 
					
						
							| 
									
										
										
										
											2002-07-11 14:31:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-25 22:29:47 +02:00
										 |  |  | try: | 
					
						
							|  |  |  |     from setuptools import Extension, Command, setup | 
					
						
							|  |  |  | except ImportError: | 
					
						
							|  |  |  |     from distutils.core import Extension, Command, setup | 
					
						
							| 
									
										
										
										
											2003-02-28 17:38:29 -07:00
										 |  |  | from distutils.command.build_ext import build_ext | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  | from distutils.errors import CCompilerError | 
					
						
							|  |  |  | import distutils | 
					
						
							|  |  |  | import os, sys | 
					
						
							| 
									
										
										
										
											2002-04-03 18:45:09 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-09 20:58:41 +02:00
										 |  |  | longdesc = open("README.rst").read() | 
					
						
							| 
									
										
										
										
											2014-06-08 21:31:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-17 20:44:27 +02:00
										 |  |  | # By doing this we neeed to change version information in a single file | 
					
						
							|  |  |  | for line in open(os.path.join("lib", "Crypto", "__init__.py")): | 
					
						
							|  |  |  |     if line.startswith("version_info"): | 
					
						
							|  |  |  |         version_tuple = eval(line.split("=")[1]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | version_string = "%d.%d" % version_tuple[:-1] | 
					
						
							|  |  |  | if version_tuple[2] is not None: | 
					
						
							| 
									
										
										
										
											2014-06-24 21:41:33 +02:00
										 |  |  |     if str(version_tuple[2]).isdigit(): | 
					
						
							|  |  |  |         version_string += "." | 
					
						
							| 
									
										
										
										
											2014-06-17 20:44:27 +02:00
										 |  |  |     version_string += str(version_tuple[2]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-18 13:05:37 -07:00
										 |  |  | if sys.version[0:1] == '1': | 
					
						
							| 
									
										
										
										
											2010-12-28 16:26:52 -05:00
										 |  |  |     raise RuntimeError ("The Python Cryptography Toolkit requires " | 
					
						
							|  |  |  |                          "Python 2.x or 3.x to build.") | 
					
						
							| 
									
										
										
										
											2002-07-18 13:05:37 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-28 16:26:52 -05:00
										 |  |  | try: | 
					
						
							|  |  |  |     # Python 3 | 
					
						
							|  |  |  |     from distutils.command.build_py import build_py_2to3 as build_py | 
					
						
							|  |  |  | except ImportError: | 
					
						
							|  |  |  |     # Python 2 | 
					
						
							|  |  |  |     from distutils.command.build_py import build_py | 
					
						
							| 
									
										
										
										
											2011-10-18 23:20:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-29 13:21:05 -05:00
										 |  |  | # Work around the print / print() issue with Python 2.x and 3.x. We only need | 
					
						
							|  |  |  | # to print at one point of the code, which makes this easy | 
					
						
							| 
									
										
										
										
											2010-12-28 16:26:52 -05:00
										 |  |  | def PrintErr(*args, **kwd): | 
					
						
							|  |  |  |     fout = kwd.get("file", sys.stderr) | 
					
						
							|  |  |  |     w = fout.write | 
					
						
							|  |  |  |     if args: | 
					
						
							|  |  |  |         w(str(args[0])) | 
					
						
							|  |  |  |         sep = kwd.get("sep", " ") | 
					
						
							|  |  |  |         for a in args[1:]: | 
					
						
							|  |  |  |             w(sep) | 
					
						
							|  |  |  |             w(str(a)) | 
					
						
							|  |  |  |         w(kwd.get("end", "\n")) | 
					
						
							| 
									
										
										
										
											2008-08-13 23:11:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  | def test_compilation(program, extra_cc_options=None, extra_libraries=None): | 
					
						
							|  |  |  |     """Test if a certain C program can be compiled.""" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     import tempfile | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create a temporary file with the C program | 
					
						
							| 
									
										
										
										
											2014-06-29 11:49:39 +02:00
										 |  |  |     fname = tempfile.mkstemp(".c")[1] | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  |     f = open(fname, 'w') | 
					
						
							|  |  |  |     f.write(program) | 
					
						
							|  |  |  |     f.close() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Name for the temporary executable | 
					
						
							| 
									
										
										
										
											2014-06-29 11:49:39 +02:00
										 |  |  |     oname = tempfile.mkstemp(".out")[1] | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |     debug = False | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  |     # Mute the compiler and the linker | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |     if not debug: | 
					
						
							|  |  |  |         old_stdout = os.dup(sys.stdout.fileno()) | 
					
						
							|  |  |  |         old_stderr = os.dup(sys.stderr.fileno()) | 
					
						
							|  |  |  |         dev_null = open(os.devnull, "w") | 
					
						
							|  |  |  |         os.dup2(dev_null.fileno(), sys.stdout.fileno()) | 
					
						
							|  |  |  |         os.dup2(dev_null.fileno(), sys.stderr.fileno()) | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     objects = [] | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         compiler = distutils.ccompiler.new_compiler() | 
					
						
							| 
									
										
										
										
											2014-07-02 15:52:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if compiler.compiler_type in [ 'msvc' ]: | 
					
						
							|  |  |  |             # Force creation of the manifest file (http://bugs.python.org/issue16296) | 
					
						
							|  |  |  |             # as needed by VS2010 | 
					
						
							|  |  |  |             extra_linker_options = [ "/MANIFEST" ] | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             extra_linker_options = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  |         distutils.sysconfig.customize_compiler(compiler) | 
					
						
							|  |  |  |         objects = compiler.compile([fname], extra_postargs=extra_cc_options) | 
					
						
							| 
									
										
										
										
											2014-07-02 15:52:44 +02:00
										 |  |  |         compiler.link_executable(objects, oname, libraries=extra_libraries, extra_preargs=extra_linker_options) | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  |         result = True | 
					
						
							|  |  |  |     except CCompilerError: | 
					
						
							|  |  |  |         result = False | 
					
						
							|  |  |  |     for f in objects + [fname, oname]: | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             os.remove(f) | 
					
						
							|  |  |  |         except OSError: | 
					
						
							|  |  |  |             pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Restore stdout and stderr | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |     if not debug: | 
					
						
							|  |  |  |         if old_stdout is not None: | 
					
						
							|  |  |  |             os.dup2(old_stdout, sys.stdout.fileno()) | 
					
						
							|  |  |  |         if old_stderr is not None: | 
					
						
							|  |  |  |             os.dup2(old_stderr, sys.stderr.fileno()) | 
					
						
							|  |  |  |         if dev_null is not None: | 
					
						
							|  |  |  |             dev_null.close() | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return result | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def libgmp_exists(): | 
					
						
							|  |  |  |     '''Tests if the GMP library is available''' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     source = """
 | 
					
						
							|  |  |  |     #include <gmp.h> | 
					
						
							|  |  |  |     int main(void) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         mpz_init((void*)0); | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return test_compilation(source, extra_libraries=('gmp',)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-28 17:38:29 -07:00
										 |  |  | class PCTBuildExt (build_ext): | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     aesni_mod_names = "Crypto.Cipher._raw_aesni", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-28 17:38:29 -07:00
										 |  |  |     def build_extensions(self): | 
					
						
							|  |  |  |         # Detect which modules should be compiled | 
					
						
							|  |  |  |         self.detect_modules() | 
					
						
							| 
									
										
										
										
											2009-03-10 23:40:47 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-27 07:28:15 +02:00
										 |  |  |         # Call the superclass's build_extensions method | 
					
						
							| 
									
										
										
										
											2003-02-28 17:38:29 -07:00
										 |  |  |         build_ext.build_extensions(self) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |     def check_cpuid_h(self): | 
					
						
							|  |  |  |         # UNIX | 
					
						
							|  |  |  |         source = """
 | 
					
						
							|  |  |  |         #include <cpuid.h> | 
					
						
							|  |  |  |         int main(void) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             unsigned int eax, ebx, ecx, edx; | 
					
						
							|  |  |  |             __get_cpuid(1, &eax, &ebx, &ecx, &edx); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         if test_compilation(source): | 
					
						
							|  |  |  |             self.compiler.define_macro("HAVE_CPUID_H") | 
					
						
							|  |  |  |             return True | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             return False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def check_intrin_h(self): | 
					
						
							|  |  |  |         # Windows | 
					
						
							|  |  |  |         source = """
 | 
					
						
							|  |  |  |         #include <intrin.h> | 
					
						
							|  |  |  |         int main(void) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int a, b[4]; | 
					
						
							|  |  |  |             __cpuid(b, a); | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         if test_compilation(source): | 
					
						
							|  |  |  |             self.compiler.define_macro("HAVE_INTRIN_H") | 
					
						
							|  |  |  |             return True | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             return False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def check_aesni(self): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         source = """
 | 
					
						
							|  |  |  |         #include <wmmintrin.h> | 
					
						
							|  |  |  |         __m128i f(__m128i x, __m128i y) { | 
					
						
							|  |  |  |             return _mm_aesenc_si128(x, y); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         int main(void) { | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         """
 | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         aes_mods = [ x for x in self.extensions if x.name in self.aesni_mod_names ] | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |         result = test_compilation(source) | 
					
						
							|  |  |  |         if not result: | 
					
						
							|  |  |  |             result = test_compilation(source, extra_cc_options=['-maes']) | 
					
						
							|  |  |  |             if result: | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  |                 for x in aes_mods: | 
					
						
							|  |  |  |                     x.extra_compile_args += ['-maes'] | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |         return result | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-02-28 17:38:29 -07:00
										 |  |  |     def detect_modules (self): | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Detect compiler support for CPUID instruction and AESNI | 
					
						
							|  |  |  |         if (self.check_cpuid_h() or self.check_intrin_h()) and self.check_aesni(): | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  |             PrintErr("Compiling support for Intel AES instructions") | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  |             PrintErr ("warning: no support for Intel AESNI instructions") | 
					
						
							|  |  |  |             self.remove_extensions(self.aesni_mod_names) | 
					
						
							| 
									
										
										
										
											2009-08-18 19:57:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-02 08:53:49 +02:00
										 |  |  |     def remove_extensions(self, names): | 
					
						
							| 
									
										
										
										
											2014-05-22 16:29:52 +02:00
										 |  |  |         """Remove the specified extension from the list of extensions
 | 
					
						
							|  |  |  |         to build"""
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.extensions = [ x for x in self.extensions if x.name not in names ] | 
					
						
							| 
									
										
										
										
											2003-02-28 17:38:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-13 23:11:05 -04:00
										 |  |  | class PCTBuildPy(build_py): | 
					
						
							|  |  |  |     def find_package_modules(self, package, package_dir, *args, **kwargs): | 
					
						
							| 
									
										
										
										
											2010-12-29 13:21:05 -05:00
										 |  |  |         modules = build_py.find_package_modules(self, package, package_dir, | 
					
						
							|  |  |  |             *args, **kwargs) | 
					
						
							| 
									
										
										
										
											2008-08-13 23:11:05 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Exclude certain modules | 
					
						
							| 
									
										
										
										
											2008-09-15 18:16:11 -04:00
										 |  |  |         retval = [] | 
					
						
							|  |  |  |         for item in modules: | 
					
						
							|  |  |  |             pkg, module = item[:2] | 
					
						
							|  |  |  |             retval.append(item) | 
					
						
							|  |  |  |         return retval | 
					
						
							| 
									
										
										
										
											2008-08-13 23:11:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-21 13:04:18 -05:00
										 |  |  | class TestCommand(Command): | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     description = "Run self-test" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-10 18:52:40 +01:00
										 |  |  |     # Long option name, short option name, description | 
					
						
							| 
									
										
										
										
											2008-11-21 13:04:18 -05:00
										 |  |  |     user_options = [ | 
					
						
							|  |  |  |         ('skip-slow-tests', None, | 
					
						
							| 
									
										
										
										
											2011-01-10 18:52:40 +01:00
										 |  |  |             'Skip slow tests'), | 
					
						
							|  |  |  |         ('module=', 'm', 'Test a single module (e.g. Cipher, PublicKey)') | 
					
						
							| 
									
										
										
										
											2008-11-21 13:04:18 -05:00
										 |  |  |     ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def initialize_options(self): | 
					
						
							|  |  |  |         self.build_dir = None | 
					
						
							|  |  |  |         self.skip_slow_tests = None | 
					
						
							| 
									
										
										
										
											2011-01-10 18:52:40 +01:00
										 |  |  |         self.module = None | 
					
						
							| 
									
										
										
										
											2008-11-21 13:04:18 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def finalize_options(self): | 
					
						
							|  |  |  |         self.set_undefined_options('install', ('build_lib', 'build_dir')) | 
					
						
							|  |  |  |         self.config = {'slow_tests': not self.skip_slow_tests} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def run(self): | 
					
						
							| 
									
										
										
										
											2012-10-14 12:59:59 +02:00
										 |  |  |         # Run sub commands | 
					
						
							|  |  |  |         for cmd_name in self.get_sub_commands(): | 
					
						
							|  |  |  |             self.run_command(cmd_name) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-21 13:04:18 -05:00
										 |  |  |         # Run SelfTest | 
					
						
							|  |  |  |         self.announce("running self-tests") | 
					
						
							|  |  |  |         old_path = sys.path[:] | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             sys.path.insert(0, self.build_dir) | 
					
						
							|  |  |  |             from Crypto import SelfTest | 
					
						
							| 
									
										
										
										
											2011-01-10 18:52:40 +01:00
										 |  |  |             moduleObj = None | 
					
						
							|  |  |  |             if self.module: | 
					
						
							|  |  |  |                 if self.module.count('.')==0: | 
					
						
							|  |  |  |                     # Test a whole a sub-package | 
					
						
							|  |  |  |                     full_module = "Crypto.SelfTest." + self.module | 
					
						
							|  |  |  |                     module_name = self.module | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     # Test only a module | 
					
						
							|  |  |  |                     # Assume only one dot is present | 
					
						
							|  |  |  |                     comps = self.module.split('.') | 
					
						
							|  |  |  |                     module_name = "test_" + comps[1] | 
					
						
							|  |  |  |                     full_module = "Crypto.SelfTest." + comps[0] + "." + module_name | 
					
						
							|  |  |  |                 # Import sub-package or module | 
					
						
							|  |  |  |                 moduleObj = __import__( full_module, globals(), locals(), module_name ) | 
					
						
							| 
									
										
										
										
											2015-02-12 21:54:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             from Crypto.Math import Numbers | 
					
						
							|  |  |  |             PrintErr("Crypto.Math implementation:", | 
					
						
							|  |  |  |                      str(Numbers._implementation)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-10 18:52:40 +01:00
										 |  |  |             SelfTest.run(module=moduleObj, verbosity=self.verbose, stream=sys.stdout, config=self.config) | 
					
						
							| 
									
										
										
										
											2008-11-21 13:04:18 -05:00
										 |  |  |         finally: | 
					
						
							|  |  |  |             # Restore sys.path | 
					
						
							|  |  |  |             sys.path[:] = old_path | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Run slower self-tests | 
					
						
							|  |  |  |         self.announce("running extended self-tests") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-14 12:59:59 +02:00
										 |  |  |     sub_commands = [ ('build', None) ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-17 21:40:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  | setup( | 
					
						
							|  |  |  |     name = "pycryptodome", | 
					
						
							| 
									
										
										
										
											2014-06-17 20:44:27 +02:00
										 |  |  |     version = version_string, | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |     description = "Cryptographic library for Python", | 
					
						
							|  |  |  |     long_description = longdesc, | 
					
						
							|  |  |  |     author = "Legrandin", | 
					
						
							|  |  |  |     author_email = "helderijs@gmail.com", | 
					
						
							| 
									
										
										
										
											2014-05-27 13:40:37 +02:00
										 |  |  |     url = "http://www.pycryptodome.org", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |     platforms = 'Posix; MacOS X; Windows', | 
					
						
							|  |  |  |     classifiers = [ | 
					
						
							| 
									
										
										
										
											2014-05-25 14:33:34 +02:00
										 |  |  |         'Development Status :: 4 - Beta', | 
					
						
							| 
									
										
										
										
											2014-06-24 07:38:05 +02:00
										 |  |  |         'License :: OSI Approved :: BSD License', | 
					
						
							| 
									
										
										
										
											2015-03-15 21:32:10 +01:00
										 |  |  |         'License :: Public Domain', | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |         'Intended Audience :: Developers', | 
					
						
							|  |  |  |         'Operating System :: Unix', | 
					
						
							|  |  |  |         'Operating System :: Microsoft :: Windows', | 
					
						
							|  |  |  |         'Operating System :: MacOS :: MacOS X', | 
					
						
							|  |  |  |         'Topic :: Security :: Cryptography', | 
					
						
							|  |  |  |         'Programming Language :: Python :: 2', | 
					
						
							|  |  |  |         'Programming Language :: Python :: 2.4', | 
					
						
							|  |  |  |         'Programming Language :: Python :: 3', | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  |     packages =  [ | 
					
						
							|  |  |  |         "Crypto", | 
					
						
							|  |  |  |         "Crypto.Cipher", | 
					
						
							|  |  |  |         "Crypto.Hash", | 
					
						
							|  |  |  |         "Crypto.IO", | 
					
						
							|  |  |  |         "Crypto.PublicKey", | 
					
						
							|  |  |  |         "Crypto.Protocol", | 
					
						
							|  |  |  |         "Crypto.Random", | 
					
						
							|  |  |  |         "Crypto.Signature", | 
					
						
							|  |  |  |         "Crypto.Util", | 
					
						
							| 
									
										
										
										
											2014-07-15 18:32:07 +02:00
										 |  |  |         "Crypto.Math", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |         "Crypto.SelfTest", | 
					
						
							|  |  |  |         "Crypto.SelfTest.Cipher", | 
					
						
							|  |  |  |         "Crypto.SelfTest.Hash", | 
					
						
							|  |  |  |         "Crypto.SelfTest.IO", | 
					
						
							|  |  |  |         "Crypto.SelfTest.Protocol", | 
					
						
							|  |  |  |         "Crypto.SelfTest.PublicKey", | 
					
						
							|  |  |  |         "Crypto.SelfTest.Random", | 
					
						
							|  |  |  |         "Crypto.SelfTest.Signature", | 
					
						
							|  |  |  |         "Crypto.SelfTest.Util", | 
					
						
							| 
									
										
										
										
											2014-07-15 18:32:07 +02:00
										 |  |  |         "Crypto.SelfTest.Math", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |         ], | 
					
						
							|  |  |  |     package_dir = { "Crypto": "lib/Crypto" }, | 
					
						
							|  |  |  |     package_data = { | 
					
						
							|  |  |  |         "Crypto.SelfTest.Hash" : [ | 
					
						
							| 
									
										
										
										
											2015-03-21 22:01:36 +01:00
										 |  |  |             "test_vectors/SHA3/*.txt", | 
					
						
							|  |  |  |             "test_vectors/BLAKE2s/*.txt", | 
					
						
							|  |  |  |             "test_vectors/BLAKE2b/*.txt" ], | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |         "Crypto.SelfTest.Signature" : [ | 
					
						
							|  |  |  |             "test_vectors/DSA/*.*" ], | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     cmdclass = { | 
					
						
							|  |  |  |         'build_ext':PCTBuildExt, | 
					
						
							|  |  |  |         'build_py': PCTBuildPy, | 
					
						
							|  |  |  |         'test': TestCommand | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |     ext_modules = [ | 
					
						
							|  |  |  |         # Hash functions | 
					
						
							| 
									
										
										
										
											2015-01-29 22:20:57 +01:00
										 |  |  |         Extension("Crypto.Hash._MD2", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/MD2.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-29 22:37:28 +01:00
										 |  |  |         Extension("Crypto.Hash._MD4", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/MD4.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-27 21:57:12 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA256", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA256.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-27 21:57:12 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA224", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA224.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-27 21:57:12 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA384", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA384.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-27 21:57:12 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA512", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA512.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-29 22:03:46 +01:00
										 |  |  |         Extension("Crypto.Hash._RIPEMD160", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							| 
									
										
										
										
											2014-06-05 07:36:19 +02:00
										 |  |  |             sources=["src/RIPEMD160.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-30 22:26:34 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA3_224", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA3_224.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-30 22:26:34 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA3_256", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA3_256.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-30 22:26:34 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA3_384", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA3_384.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-30 22:26:34 +01:00
										 |  |  |         Extension("Crypto.Hash._SHA3_512", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/SHA3_512.c"]), | 
					
						
							| 
									
										
										
										
											2015-03-21 22:01:36 +01:00
										 |  |  |         Extension("Crypto.Hash._BLAKE2b", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/blake2b.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Hash._BLAKE2s", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/blake2s.c"]), | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Block encryption algorithms | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  |         Extension("Crypto.Cipher._raw_aes", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/AES.c"]), | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  |         Extension("Crypto.Cipher._raw_aesni", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/AESNI.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-05 11:29:09 -05:00
										 |  |  |         Extension("Crypto.Cipher._raw_arc2", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/ARC2.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-05 08:36:26 -05:00
										 |  |  |         Extension("Crypto.Cipher._raw_blowfish", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/Blowfish.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-05 08:30:25 -05:00
										 |  |  |         Extension("Crypto.Cipher._raw_cast", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/CAST.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-04 22:45:28 +01:00
										 |  |  |         Extension("Crypto.Cipher._raw_des", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/', 'src/libtom/'], | 
					
						
							|  |  |  |             sources=["src/DES.c"]), | 
					
						
							| 
									
										
										
										
											2015-01-04 22:45:28 +01:00
										 |  |  |         Extension("Crypto.Cipher._raw_des3", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/', 'src/libtom/'], | 
					
						
							|  |  |  |             sources=["src/DES3.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Util._galois", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=['src/galois.c']), | 
					
						
							| 
									
										
										
										
											2015-02-02 21:40:34 +01:00
										 |  |  |         Extension("Crypto.Util._cpuid", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=['src/cpuid.c']), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-16 07:50:48 +01:00
										 |  |  |         # Chaining modes | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._raw_ecb", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/raw_ecb.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._raw_cbc", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/raw_cbc.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._raw_cfb", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/raw_cfb.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._raw_ofb", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/raw_ofb.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._raw_ctr", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/raw_ctr.c"]), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |         # Stream ciphers | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._ARC4", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/ARC4.c"]), | 
					
						
							|  |  |  |         Extension("Crypto.Cipher._Salsa20", | 
					
						
							|  |  |  |             include_dirs=['src/', 'src/libtom/'], | 
					
						
							|  |  |  |             sources=["src/Salsa20.c"]), | 
					
						
							| 
									
										
										
										
											2015-04-19 22:25:12 +02:00
										 |  |  |         Extension("Crypto.Cipher._chacha20", | 
					
						
							|  |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=["src/chacha20.c"]), | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Utility modules | 
					
						
							| 
									
										
										
										
											2015-01-22 22:23:02 +01:00
										 |  |  |         Extension("Crypto.Util._strxor", | 
					
						
							| 
									
										
										
										
											2014-05-25 11:03:35 +02:00
										 |  |  |             include_dirs=['src/'], | 
					
						
							|  |  |  |             sources=['src/strxor.c']), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | ) |