| OLD | NEW |
| 1 # | |
| 2 # Copyright 2014 the Melange authors. | 1 # Copyright 2014 the Melange authors. |
| 3 # | 2 # |
| 4 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 6 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 7 # | 6 # |
| 8 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 # | 8 # |
| 10 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 11 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 expected_token = generate_token(key, user_id, action_id=action_id, | 97 expected_token = generate_token(key, user_id, action_id=action_id, |
| 99 when=token_time) | 98 when=token_time) |
| 100 if len(token) != len(expected_token): | 99 if len(token) != len(expected_token): |
| 101 return False | 100 return False |
| 102 | 101 |
| 103 # Perform constant time comparison to avoid timing attacks | 102 # Perform constant time comparison to avoid timing attacks |
| 104 different = 0 | 103 different = 0 |
| 105 for x, y in zip(bytearray(token), bytearray(expected_token)): | 104 for x, y in zip(bytearray(token), bytearray(expected_token)): |
| 106 different |= x ^ y | 105 different |= x ^ y |
| 107 return not different | 106 return not different |
| OLD | NEW |