Revision 3718bf6d lib/serializer.py
b/lib/serializer.py | ||
---|---|---|
112 | 112 |
signed_dict = { |
113 | 113 |
'msg': txt, |
114 | 114 |
'salt': salt, |
115 |
} |
|
115 |
} |
|
116 |
|
|
116 | 117 |
if key_selector: |
117 | 118 |
signed_dict["key_selector"] = key_selector |
118 |
message = salt + key_selector + txt |
|
119 | 119 |
else: |
120 |
message = salt + txt |
|
121 |
signed_dict["hmac"] = utils.Sha1Hmac(key, message) |
|
120 |
key_selector = "" |
|
121 |
|
|
122 |
signed_dict["hmac"] = utils.Sha1Hmac(key, txt, salt=salt + key_selector) |
|
122 | 123 |
|
123 | 124 |
return DumpJson(signed_dict, indent=False) |
124 | 125 |
|
... | ... | |
156 | 157 |
key_selector = "" |
157 | 158 |
hmac_key = key |
158 | 159 |
|
159 |
if not utils.VerifySha1Hmac(hmac_key, salt + key_selector + msg, hmac_sign): |
|
160 |
if not utils.VerifySha1Hmac(hmac_key, msg, hmac_sign, |
|
161 |
salt=salt + key_selector): |
|
160 | 162 |
raise errors.SignatureError('Invalid Signature') |
161 | 163 |
|
162 | 164 |
return LoadJson(msg), salt |
Also available in: Unified diff