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

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