channeld: use pointer for shared secret.

It's more natural than using a zero-secret when something goes wrong.

Also note that the HSM will actually kill the connection if the ECDH
fails, which is fortunately statistically unlikely.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-01-08 10:50:50 +10:30
committed by Christian Decker
parent 7e01efbd1f
commit 66de6b84be
8 changed files with 69 additions and 52 deletions

View File

@@ -72,12 +72,13 @@ void peer_failed_connection_lost(void)
exit(0);
}
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point)
struct secret *hsm_do_ecdh(const tal_t *ctx, const struct pubkey *point)
{
struct secret *ss = tal(ctx, struct secret);
if (secp256k1_ecdh(secp256k1_ctx, ss->data, &point->pubkey,
notsosecret.data) != 1)
errx(1, "ECDH failed");
return true;
return tal_free(ss);
return ss;
}
/* We don't want to discard *any* messages. */