MCPcopy Create free account
hub / github.com/ElementsProject/lightning / hkdf_two_keys

Function hkdf_two_keys

common/cryptomsg.c:9–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

maybe_rotate_keyFunction · 0.70

Calls 1

hkdf_sha256Function · 0.85

Tested by

no test coverage detected