MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / reference_hifi

Function reference_hifi

tests/test_scram.py:38–46  ·  view source on GitHub ↗

The RFC 5802 Hi() loop that the salted password used to implement.

(password, salt, iterations)

Source from the content-addressed store, hash-verified

36
37
38def 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
49class TestSCRAMSaltedPassword(unittest.TestCase):

Callers 1

Calls 1

newMethod · 0.45

Tested by

no test coverage detected