Revision 541822e0 lib/serializer.py

b/lib/serializer.py
28 28
import simplejson
29 29
import re
30 30
import hmac
31
import hashlib
32 31

  
33 32
from ganeti import errors
34 33

  
34
try:
35
  from hashlib import sha1
36
except ImportError:
37
  import sha as sha1
35 38

  
36 39
# Check whether the simplejson module supports indentation
37 40
_JSON_INDENT = 2
......
88 91
  signed_dict = {
89 92
    'msg': txt,
90 93
    'salt': salt,
91
    'hmac': hmac.new(key, salt + txt, hashlib.sha256).hexdigest(),
94
    'hmac': hmac.new(key, salt + txt, sha1).hexdigest(),
92 95
  }
93 96
  return DumpJson(signed_dict)
94 97

  
......
120 123
    if not salt_verifier(salt):
121 124
      raise errors.SignatureError('Invalid salt')
122 125

  
123
  if hmac.new(key, salt + msg, hashlib.sha256).hexdigest() != hmac_sign:
126
  if hmac.new(key, salt + msg, sha1).hexdigest() != hmac_sign:
124 127
    raise errors.SignatureError('Invalid Signature')
125 128
  return LoadJson(msg)
126 129

  

Also available in: Unified diff