Blame SOURCES/00169-avoid-implicit-usage-of-md5-in-multiprocessing.patch

c8ca20
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
c8ca20
--- a/Lib/multiprocessing/connection.py
c8ca20
+++ b/Lib/multiprocessing/connection.py
c8ca20
@@ -41,6 +41,10 @@
c8ca20
 # A very generous timeout when it comes to local connections...
c8ca20
 CONNECTION_TIMEOUT = 20.
c8ca20
 
c8ca20
+# The hmac module implicitly defaults to using MD5.
c8ca20
+# Support using a stronger algorithm for the challenge/response code:
c8ca20
+HMAC_DIGEST_NAME='sha256'
c8ca20
+
c8ca20
 _mmap_counter = itertools.count()
c8ca20
 
c8ca20
 default_family = 'AF_INET'
c8ca20
@@ -700,12 +704,16 @@
c8ca20
 WELCOME = b'#WELCOME#'
c8ca20
 FAILURE = b'#FAILURE#'
c8ca20
 
c8ca20
+def get_digestmod_for_hmac():
c8ca20
+    import hashlib
c8ca20
+    return getattr(hashlib, HMAC_DIGEST_NAME)
c8ca20
+
c8ca20
 def deliver_challenge(connection, authkey):
c8ca20
     import hmac
c8ca20
     assert isinstance(authkey, bytes)
c8ca20
     message = os.urandom(MESSAGE_LENGTH)
c8ca20
     connection.send_bytes(CHALLENGE + message)
c8ca20
-    digest = hmac.new(authkey, message).digest()
c8ca20
+    digest = hmac.new(authkey, message, get_digestmod_for_hmac()).digest()
c8ca20
     response = connection.recv_bytes(256)        # reject large message
c8ca20
     if response == digest:
c8ca20
         connection.send_bytes(WELCOME)
c8ca20
@@ -719,7 +727,7 @@
c8ca20
     message = connection.recv_bytes(256)         # reject large message
c8ca20
     assert message[:len(CHALLENGE)] == CHALLENGE, 'message = %r' % message
c8ca20
     message = message[len(CHALLENGE):]
c8ca20
-    digest = hmac.new(authkey, message).digest()
c8ca20
+    digest = hmac.new(authkey, message, get_digestmod_for_hmac()).digest()
c8ca20
     connection.send_bytes(digest)
c8ca20
     response = connection.recv_bytes(256)        # reject large message
c8ca20
     if response != WELCOME: