diff --git a/daemon/secrets.c b/daemon/secrets.c index 7e0e23537..d36f84024 100644 --- a/daemon/secrets.c +++ b/daemon/secrets.c @@ -13,11 +13,11 @@ #include #include #include -#include #include #include #include #include +#include struct secret { /* Secret ID of our node; public is dstate->id. */ @@ -147,8 +147,7 @@ static void new_keypair(struct lightningd_state *dstate, struct privkey *privkey, struct pubkey *pubkey) { do { - if (RAND_bytes(privkey->secret, sizeof(privkey->secret)) != 1) - fatal("Could not get random bytes for privkey"); + randombytes_buf(privkey->secret, sizeof(privkey->secret)); } while (!pubkey_from_privkey(dstate->secpctx, privkey, pubkey)); } @@ -158,10 +157,7 @@ void peer_secrets_init(struct peer *peer) new_keypair(peer->dstate, &peer->secrets->commit, &peer->local.commitkey); new_keypair(peer->dstate, &peer->secrets->final, &peer->local.finalkey); - if (RAND_bytes(peer->secrets->revocation_seed.u.u8, - sizeof(peer->secrets->revocation_seed.u.u8)) != 1) - fatal("Could not get random bytes for revocation seed"); - + randombytes_buf(peer->secrets->revocation_seed.u.u8, sizeof(peer->secrets->revocation_seed.u.u8)); shachain_init(&peer->their_preimages); } diff --git a/daemon/wallet.c b/daemon/wallet.c index 795e5011a..f56584f20 100644 --- a/daemon/wallet.c +++ b/daemon/wallet.c @@ -12,7 +12,7 @@ #include "log.h" #include "wallet.h" #include -#include +#include struct wallet { struct list_node list; @@ -25,8 +25,7 @@ static void new_keypair(struct lightningd_state *dstate, struct privkey *privkey, struct pubkey *pubkey) { do { - if (RAND_bytes(privkey->secret, sizeof(privkey->secret)) != 1) - fatal("Could not get random bytes for privkey"); + randombytes_buf(privkey->secret, sizeof(privkey->secret)); } while (!pubkey_from_privkey(dstate->secpctx, privkey, pubkey)); }