[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/ reverted changes causing test failures

Andreas Jung andreas at andreas-jung.com
Mon Mar 30 19:46:51 EDT 2009


Log message for revision 98659:
  reverted changes causing test failures
  

Changed:
  U   ZODB/trunk/src/ZEO/auth/auth_digest.py
  U   ZODB/trunk/src/ZEO/auth/base.py
  U   ZODB/trunk/src/ZEO/tests/auth_plaintext.py
  U   ZODB/trunk/src/ZEO/zrpc/smac.py

-=-
Modified: ZODB/trunk/src/ZEO/auth/auth_digest.py
===================================================================
--- ZODB/trunk/src/ZEO/auth/auth_digest.py	2009-03-30 23:42:18 UTC (rev 98658)
+++ ZODB/trunk/src/ZEO/auth/auth_digest.py	2009-03-30 23:46:50 UTC (rev 98659)
@@ -37,14 +37,13 @@
 
 import os
 import random
-
+import sha
 import struct
 import time
 
 from ZEO.auth.base import Database, Client
 from ZEO.StorageServer import ZEOStorage
 from ZEO.Exceptions import AuthError
-from ZEO.hash import sha1
 
 def get_random_bytes(n=8):
     if os.path.exists("/dev/urandom"):
@@ -57,7 +56,7 @@
     return s
 
 def hexdigest(s):
-    return sha1(s).hexdigest()
+    return sha.new(s).hexdigest()
 
 class DigestDatabase(Database):
     def __init__(self, filename, realm=None):
@@ -77,7 +76,7 @@
     # HMAC wants a 64-byte key.  We don't want to use h_up
     # directly because it would never change over time.  Instead
     # use the hash plus part of h_up.
-    return sha1("%s:%s" % (h_up, nonce)).digest() + h_up[:44]
+    return sha.new("%s:%s" % (h_up, nonce)).digest() + h_up[:44]
 
 class StorageClass(ZEOStorage):
     def set_database(self, database):
@@ -93,7 +92,7 @@
     def _get_nonce(self):
         # RFC 2069 recommends a nonce of the form
         # H(client-IP ":" time-stamp ":" private-key)
-        dig = sha1()
+        dig = sha.sha()
         dig.update(str(self.connection.addr))
         dig.update(self._get_time())
         dig.update(self.noncekey)

Modified: ZODB/trunk/src/ZEO/auth/base.py
===================================================================
--- ZODB/trunk/src/ZEO/auth/base.py	2009-03-30 23:42:18 UTC (rev 98658)
+++ ZODB/trunk/src/ZEO/auth/base.py	2009-03-30 23:46:50 UTC (rev 98659)
@@ -18,7 +18,7 @@
 """
 
 import os
-from ZEO.hash import sha1
+import sha
 
 class Client:
     # Subclass should override to list the names of methods that
@@ -113,7 +113,7 @@
         return self._users[username]
 
     def hash(self, s):
-        return sha1(s).hexdigest()
+        return sha.new(s).hexdigest()
 
     def add_user(self, username, password):
         if self._users.has_key(username):

Modified: ZODB/trunk/src/ZEO/tests/auth_plaintext.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/auth_plaintext.py	2009-03-30 23:42:18 UTC (rev 98658)
+++ ZODB/trunk/src/ZEO/tests/auth_plaintext.py	2009-03-30 23:46:50 UTC (rev 98659)
@@ -19,15 +19,14 @@
 is provided by not storing plaintext passwords on disk.
 """
 
+import sha
 
 from ZEO.StorageServer import ZEOStorage
 from ZEO.auth import register_module
 from ZEO.auth.base import Client, Database
 
-from ZEO.hash import sha1
-
 def session_key(username, realm, password):
-    return sha1.new("%s:%s:%s" % (username, realm, password)).hexdigest()
+    return sha.new("%s:%s:%s" % (username, realm, password)).hexdigest()
 
 class StorageClass(ZEOStorage):
 
@@ -37,7 +36,7 @@
         except LookupError:
             return 0
 
-        password_dig = sha1.new(password).hexdigest()
+        password_dig = sha.new(password).hexdigest()
         if dbpw == password_dig:
             self.connection.setSessionKey(session_key(username,
                                                       self.database.realm,

Modified: ZODB/trunk/src/ZEO/zrpc/smac.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/smac.py	2009-03-30 23:42:18 UTC (rev 98658)
+++ ZODB/trunk/src/ZEO/zrpc/smac.py	2009-03-30 23:46:50 UTC (rev 98659)
@@ -27,7 +27,11 @@
 
 import asyncore
 import errno
-import ZEO.hash
+try:
+    import hmac
+except ImportError:
+    import _hmac as hmac
+import sha
 import socket
 import struct
 import threading
@@ -38,8 +42,8 @@
 
 from ZEO.zrpc.log import log, short_repr
 from ZEO.zrpc.error import DisconnectedError
-import ZEO.hash
 
+
 # Use the dictionary to make sure we get the minimum number of errno
 # entries.   We expect that EWOULDBLOCK == EAGAIN on most systems --
 # or that only one is actually used.
@@ -143,8 +147,8 @@
         # and thus iterator, because it contains a yield statement.
 
         def hack():
-            self.__hmac_send = hmac.HMAC(sesskey, digestmod=ZEO.hash)
-            self.__hmac_recv = hmac.HMAC(sesskey, digestmod=ZEO.hash)
+            self.__hmac_send = hmac.HMAC(sesskey, digestmod=sha)
+            self.__hmac_recv = hmac.HMAC(sesskey, digestmod=sha)
             if False:
                 yield ''
 



More information about the Zodb-checkins mailing list