| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Functions to generate and validate tokens signed with MAC tags.""" | 5 """Functions to generate and validate tokens signed with MAC tags.""" |
| 6 | 6 |
| 7 import base64 | 7 import base64 |
| 8 import hashlib | 8 import hashlib |
| 9 import hmac | 9 import hmac |
| 10 import json | 10 import json |
| 11 import time | 11 import time |
| 12 | 12 |
| 13 from components import utils | 13 from components import utils |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 try: | 364 try: |
| 365 public = { | 365 public = { |
| 366 k.encode('ascii', 'replace'): v.encode('ascii', 'replace') | 366 k.encode('ascii', 'replace'): v.encode('ascii', 'replace') |
| 367 for k, v in json.loads(public).iteritems() | 367 for k, v in json.loads(public).iteritems() |
| 368 } | 368 } |
| 369 except (AttributeError, ValueError): | 369 except (AttributeError, ValueError): |
| 370 pass | 370 pass |
| 371 # At least one secret key should match. | 371 # At least one secret key should match. |
| 372 raise InvalidTokenError( | 372 raise InvalidTokenError( |
| 373 'Bad token MAC; now=%d; data=%s' % (time.time(), public)) | 373 'Bad token MAC; now=%d; data=%s' % (time.time(), public)) |
| OLD | NEW |