Skip to content

Commit

Permalink
hsmtool: only write 32 bytes to hsm_secret on generatehsm
Browse files Browse the repository at this point in the history
Fixes ElementsProject#4302
Changelog-fixed: hsmtool: the `generatehsm` command now generates an appropriately-sized hsm_secret
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
  • Loading branch information
darosior committed Jan 4, 2021
1 parent a1b1dd3 commit 6455c90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion tests/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,6 @@ def test_hsmtool_dump_descriptors(node_factory, bitcoind):
assert len(bitcoind.rpc.listunspent(1, 1, [addr])) == 1


@pytest.mark.xfail(strict=True)
@unittest.skipIf(VALGRIND, "It does not play well with prompt and key derivation.")
def test_hsmtool_generatehsm(node_factory):
l1 = node_factory.get_node()
Expand Down
4 changes: 3 additions & 1 deletion tools/hsmtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ static int generate_hsm(const char *hsm_secret_path)
if (fd < 0) {
errx(ERROR_USAGE, "Unable to create hsm_secret file");
}
if (!write_all(fd, bip32_seed, bip32_seed_len))
/* Write only the first 32 bytes, length of the (plaintext) seed in the
* hsm_secret. */
if (!write_all(fd, bip32_seed, 32))
errx(ERROR_USAGE, "Error writing secret to hsm_secret file");

if (fsync(fd) != 0)
Expand Down

0 comments on commit 6455c90

Please sign in to comment.