[Python-checkins] python/dist/src setup.py,1.219,1.220

greg@users.sourceforge.net greg at users.sourceforge.net
Sun Aug 21 20:46:39 CEST 2005


Update of /cvsroot/python/python/dist/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32064

Modified Files:
	setup.py 
Log Message:
[ sf.net patch # 1121611 ]

A new hashlib module to replace the md5 and sha modules.  It adds
support for additional secure hashes such as SHA-256 and SHA-512.  The
hashlib module uses OpenSSL for fast platform optimized
implementations of algorithms when available.  The old md5 and sha
modules still exist as wrappers around hashlib to preserve backwards
compatibility.



Index: setup.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/setup.py,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -d -r1.219 -r1.220
--- setup.py	17 Jul 2005 02:37:00 -0000	1.219
+++ setup.py	21 Aug 2005 18:45:58 -0000	1.220
@@ -400,15 +400,6 @@
         # select(2); not on ancient System V
         exts.append( Extension('select', ['selectmodule.c']) )
 
-        # The md5 module implements the RSA Data Security, Inc. MD5
-        # Message-Digest Algorithm, described in RFC 1321.  The
-        # necessary files md5c.c and md5.h are included here.
-        exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
-
-        # The sha module implements the SHA checksum algorithm.
-        # (NIST's Secure Hash Algorithm.)
-        exts.append( Extension('sha', ['shamodule.c']) )
-
         # Helper module for various ascii-encoders
         exts.append( Extension('binascii', ['binascii.c']) )
 
@@ -506,6 +497,32 @@
                                    libraries = ['ssl', 'crypto'],
                                    depends = ['socketmodule.h']), )
 
+        if (ssl_incs is not None and
+            ssl_libs is not None):
+            # The _hashlib module wraps optimized implementations
+            # of hash functions from the OpenSSL library.
+            exts.append( Extension('_hashlib', ['_hashopenssl.c'],
+                                   include_dirs = ssl_incs,
+                                   library_dirs = ssl_libs,
+                                   libraries = ['ssl', 'crypto']) )
+        else:
+            # The _sha module implements the SHA1 hash algorithm.
+            exts.append( Extension('_sha', ['shamodule.c']) )
+            # The _md5 module implements the RSA Data Security, Inc. MD5
+            # Message-Digest Algorithm, described in RFC 1321.  The
+            # necessary files md5c.c and md5.h are included here.
+            exts.append( Extension('_md5', ['md5module.c', 'md5c.c']) )
+
+        # always compile these for now under the assumption that
+        # OpenSSL does not support them (it doesn't in common OpenSSL
+        # 0.9.7e installs at the time of this writing; OpenSSL 0.9.8
+        # does).  In the future we could make this conditional on
+        # OpenSSL version or support.  The hashlib module uses the
+        # better implementation regardless.
+        exts.append( Extension('_sha256', ['sha256module.c']) )
+        exts.append( Extension('_sha512', ['sha512module.c']) )
+
+
         # Modules that provide persistent dictionary-like semantics.  You will
         # probably want to arrange for at least one of them to be available on
         # your machine, though none are defined by default because of library



More information about the Python-checkins mailing list