The RFC 5802 Hi() loop that the salted password used to implement.
(password, salt, iterations)
| 36 | |
| 37 | |
| 38 | def reference_hifi(password, salt, iterations): |
| 39 | """The RFC 5802 Hi() loop that the salted password used to implement.""" |
| 40 | p = password.encode("utf8") |
| 41 | u = hmac.new(p, salt + b"\x00\x00\x00\x01", hashlib.sha256).digest() |
| 42 | result = u |
| 43 | for _ in range(iterations - 1): |
| 44 | u = hmac.new(p, u, hashlib.sha256).digest() |
| 45 | result = bytes(a ^ b for a, b in zip(result, u)) |
| 46 | return result |
| 47 | |
| 48 | |
| 49 | class TestSCRAMSaltedPassword(unittest.TestCase): |
no test coverage detected