mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-12-27 09:04:40 +01:00
4ffda340d3
And turn "" includes into full-path (which makes it easier to put config.h first, and finds some cases check-includes.sh missed previously). config.h sets _GNU_SOURCE which really needs to be done before any '#includes': we mainly got away with it with glibc, but other platforms like Alpine may have stricter requirements. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
31 lines
849 B
C
31 lines
849 B
C
#include "config.h"
|
|
#include <common/ecdh_hsmd.h>
|
|
#include <hsmd/hsmd_wiregen.h>
|
|
#include <wire/wire_sync.h>
|
|
|
|
static int stashed_hsm_fd = -1;
|
|
static void (*stashed_failed)(enum status_failreason, const char *fmt, ...);
|
|
|
|
void ecdh(const struct pubkey *point, struct secret *ss)
|
|
{
|
|
const u8 *msg = towire_hsmd_ecdh_req(NULL, point);
|
|
|
|
if (!wire_sync_write(stashed_hsm_fd, take(msg)))
|
|
stashed_failed(STATUS_FAIL_HSM_IO, "Write ECDH to hsmd failed");
|
|
|
|
msg = wire_sync_read(tmpctx, stashed_hsm_fd);
|
|
if (!msg)
|
|
stashed_failed(STATUS_FAIL_HSM_IO, "No hsmd ECDH response");
|
|
|
|
if (!fromwire_hsmd_ecdh_resp(msg, ss))
|
|
stashed_failed(STATUS_FAIL_HSM_IO, "Invalid hsmd ECDH response");
|
|
}
|
|
|
|
void ecdh_hsmd_setup(int hsm_fd,
|
|
void (*failed)(enum status_failreason,
|
|
const char *fmt, ...))
|
|
{
|
|
stashed_hsm_fd = hsm_fd;
|
|
stashed_failed = failed;
|
|
}
|