out1, out2 = HKDF(in1, in2)` */
| 222 | |
| 223 | /* out1, out2 = HKDF(in1, in2)` */ |
| 224 | static void hkdf_two_keys(struct secret *out1, struct secret *out2, |
| 225 | const struct secret *in1, |
| 226 | const void *in2, size_t in2_size) |
| 227 | { |
| 228 | /* BOLT #8: |
| 229 | * |
| 230 | * * `HKDF(salt,ikm)`: a function defined in `RFC 5869`<sup>[3](#reference-3)</sup>, |
| 231 | * evaluated with a zero-length `info` field |
| 232 | * * All invocations of `HKDF` implicitly return 64 bytes |
| 233 | * of cryptographic randomness using the extract-and-expand |
| 234 | * component of the `HKDF`. |
| 235 | */ |
| 236 | struct secret okm[2]; |
| 237 | |
| 238 | SUPERVERBOSE("# HKDF(0x%s,%s%s)", |
| 239 | tal_hexstr(tmpctx, in1, sizeof(*in1)), |
| 240 | in2_size ? "0x" : "zero", |
| 241 | tal_hexstr(tmpctx, in2, in2_size)); |
| 242 | BUILD_ASSERT(sizeof(okm) == 64); |
| 243 | hkdf_sha256(okm, sizeof(okm), in1, sizeof(*in1), in2, in2_size, |
| 244 | NULL, 0); |
| 245 | *out1 = okm[0]; |
| 246 | *out2 = okm[1]; |
| 247 | } |
| 248 | |
| 249 | static void le64_nonce(unsigned char *npub, u64 nonce) |
| 250 | { |
no test coverage detected