##// END OF EJS Templates
support Python older than 2.7.7
Paul Ivanov -
Show More
@@ -27,6 +27,13 b' except:'
27 cPickle = None
27 cPickle = None
28 import pickle
28 import pickle
29
29
30 try:
31 from hmac import compare_digest
32 except ImportError:
33 # Python < 2.7.7
34 def compare_digest(a,b):
35 return a == b
36
30 import zmq
37 import zmq
31 from zmq.utils import jsonapi
38 from zmq.utils import jsonapi
32 from zmq.eventloop.ioloop import IOLoop
39 from zmq.eventloop.ioloop import IOLoop
@@ -818,7 +825,7 b' class Session(Configurable):'
818 raise ValueError("Duplicate Signature: %r" % signature)
825 raise ValueError("Duplicate Signature: %r" % signature)
819 self._add_digest(signature)
826 self._add_digest(signature)
820 check = self.sign(msg_list[1:5])
827 check = self.sign(msg_list[1:5])
821 if not hmac.compare_digest(signature, check):
828 if not compare_digest(signature, check):
822 raise ValueError("Invalid Signature: %r" % signature)
829 raise ValueError("Invalid Signature: %r" % signature)
823 if not len(msg_list) >= minlen:
830 if not len(msg_list) >= minlen:
824 raise TypeError("malformed message, must have at least %i elements"%minlen)
831 raise TypeError("malformed message, must have at least %i elements"%minlen)
General Comments 0
You need to be logged in to leave comments. Login now