2017-08-29 13:42:04 +09:30
|
|
|
#include <hsmd/client.h>
|
|
|
|
#include <hsmd/gen_hsm_client_wire.h>
|
2017-01-10 15:38:33 +10:30
|
|
|
#include <wire/wire_sync.h>
|
|
|
|
|
|
|
|
static int hsm_fd = -1;
|
|
|
|
|
|
|
|
void hsm_setup(int fd)
|
|
|
|
{
|
|
|
|
hsm_fd = fd;
|
|
|
|
}
|
|
|
|
|
2017-05-06 11:49:44 +09:30
|
|
|
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point)
|
2017-01-10 15:38:33 +10:30
|
|
|
{
|
|
|
|
u8 *req = towire_hsm_ecdh_req(NULL, point), *resp;
|
|
|
|
|
|
|
|
if (!wire_sync_write(hsm_fd, req))
|
|
|
|
goto fail;
|
|
|
|
resp = wire_sync_read(req, hsm_fd);
|
|
|
|
if (!resp)
|
|
|
|
goto fail;
|
2018-02-21 07:29:09 +10:30
|
|
|
if (!fromwire_hsm_ecdh_resp(resp, ss))
|
2017-01-10 15:38:33 +10:30
|
|
|
goto fail;
|
|
|
|
tal_free(req);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
tal_free(req);
|
|
|
|
return false;
|
|
|
|
}
|