mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
hsmtool: move sodium_init() to top level.
This way we always call it (we weren't for some paths!). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e5c76f829e
commit
441b38c9ea
1 changed files with 4 additions and 8 deletions
|
@ -206,10 +206,6 @@ static int decrypt_hsm(const char *hsm_secret_path)
|
|||
if (!passwd)
|
||||
errx(exit_code, "%s", err);
|
||||
|
||||
if (sodium_init() == -1)
|
||||
errx(ERROR_LIBSODIUM,
|
||||
"Could not initialize libsodium. Not enough entropy ?");
|
||||
|
||||
dir = path_dirname(NULL, hsm_secret_path);
|
||||
backup = path_join(dir, dir, "hsm_secret.backup");
|
||||
|
||||
|
@ -276,10 +272,6 @@ static int encrypt_hsm(const char *hsm_secret_path)
|
|||
dir = path_dirname(NULL, hsm_secret_path);
|
||||
backup = path_join(dir, dir, "hsm_secret.backup");
|
||||
|
||||
if (sodium_init() == -1)
|
||||
errx(ERROR_LIBSODIUM,
|
||||
"Could not initialize libsodium. Not enough entropy ?");
|
||||
|
||||
/* Derive the encryption key from the password provided, and try to encrypt
|
||||
* the seed. */
|
||||
exit_code = hsm_secret_encryption_key_with_exitcode(passwd, &key, &err);
|
||||
|
@ -630,6 +622,10 @@ int main(int argc, char *argv[])
|
|||
if (!method)
|
||||
show_usage(argv[0]);
|
||||
|
||||
if (sodium_init() == -1)
|
||||
errx(ERROR_LIBSODIUM,
|
||||
"Could not initialize libsodium. Not enough entropy ?");
|
||||
|
||||
if (streq(method, "decrypt")) {
|
||||
if (argc < 3)
|
||||
show_usage(argv[0]);
|
||||
|
|
Loading…
Add table
Reference in a new issue