| 9 | #include <wire/wire_io.h> |
| 10 | |
| 11 | static void hkdf_two_keys(struct secret *out1, struct secret *out2, |
| 12 | const struct secret *in1, |
| 13 | const struct secret *in2) |
| 14 | { |
| 15 | /* BOLT #8: |
| 16 | * |
| 17 | * * `HKDF(salt,ikm)`: a function defined in |
| 18 | * `RFC 5869`<sup>[3](#reference-3)</sup>, evaluated with a |
| 19 | * zero-length `info` field |
| 20 | * * All invocations of `HKDF` implicitly return 64 bytes of |
| 21 | * cryptographic randomness using the extract-and-expand component |
| 22 | * of the `HKDF`. |
| 23 | */ |
| 24 | struct secret okm[2]; |
| 25 | |
| 26 | BUILD_ASSERT(sizeof(okm) == 64); |
| 27 | hkdf_sha256(okm, sizeof(okm), in1, sizeof(*in1), in2, sizeof(*in2), |
| 28 | NULL, 0); |
| 29 | *out1 = okm[0]; |
| 30 | *out2 = okm[1]; |
| 31 | } |
| 32 | |
| 33 | static void maybe_rotate_key(u64 *n, struct secret *k, struct secret *ck) |
| 34 | { |
no test coverage detected