RFC5869 HKDF-SHA256, matching ccan's hkdf_sha256 (salt is the HMAC key).
(ikm, salt, info, length)
| 40 | |
| 41 | |
| 42 | def hkdf_sha256(ikm, salt, info, length): |
| 43 | """RFC5869 HKDF-SHA256, matching ccan's hkdf_sha256 (salt is the HMAC key).""" |
| 44 | prk = hmac.new(salt if salt is not None else b'', ikm, hashlib.sha256).digest() |
| 45 | okm, t, i = b'', b'', 1 |
| 46 | while len(okm) < length: |
| 47 | t = hmac.new(prk, t + info + bytes([i]), hashlib.sha256).digest() |
| 48 | okm += t |
| 49 | i += 1 |
| 50 | return okm[:length] |
| 51 | |
| 52 | |
| 53 | def channel_delayed_basepoint_secret(hsm_secret, peer_id, dbid): |
no test coverage detected