Revision 716a32cb lib/utils.py
b/lib/utils.py | ||
---|---|---|
55 | 55 |
from cStringIO import StringIO |
56 | 56 |
|
57 | 57 |
try: |
58 |
from hashlib import sha1 |
|
59 |
except ImportError: |
|
60 |
import sha as sha1 |
|
61 |
|
|
62 |
try: |
|
63 | 58 |
import ctypes |
64 | 59 |
except ImportError: |
65 | 60 |
ctypes = None |
66 | 61 |
|
67 | 62 |
from ganeti import errors |
68 | 63 |
from ganeti import constants |
64 |
from ganeti import compat |
|
69 | 65 |
|
70 | 66 |
|
71 | 67 |
_locksheld = [] |
... | ... | |
748 | 744 |
|
749 | 745 |
f = open(filename) |
750 | 746 |
|
751 |
if callable(sha1): |
|
752 |
fp = sha1() |
|
753 |
else: |
|
754 |
fp = sha1.new() |
|
747 |
fp = compat.sha1_hash() |
|
755 | 748 |
while True: |
756 | 749 |
data = f.read(4096) |
757 | 750 |
if not data: |
... | ... | |
2799 | 2792 |
else: |
2800 | 2793 |
salted_text = text |
2801 | 2794 |
|
2802 |
return hmac.new(key, salted_text, sha1).hexdigest() |
|
2795 |
return hmac.new(key, salted_text, compat.sha1).hexdigest()
|
|
2803 | 2796 |
|
2804 | 2797 |
|
2805 | 2798 |
def VerifySha1Hmac(key, text, digest, salt=None): |
Also available in: Unified diff