MCPcopy Create free account
hub / github.com/ElementsProject/lightning / hsm_secret_is_encrypted

Function hsm_secret_is_encrypted

tools/hsmtool.c:148–168  ·  view source on GitHub ↗

We detect an encrypted hsm_secret as a hsm_secret which is 73-bytes long. */

Source from the content-addressed store, hash-verified

146
147/* We detect an encrypted hsm_secret as a hsm_secret which is 73-bytes long. */
148static bool hsm_secret_is_encrypted(const char *hsm_secret_path)
149{
150 switch (is_hsm_secret_encrypted(hsm_secret_path)) {
151 case -1:
152 err(EXITCODE_ERROR_HSM_FILE, "Cannot open '%s'", hsm_secret_path);
153 case 1:
154 return true;
155 case 0: {
156 /* Extra sanity check on HSM file! */
157 struct stat st;
158 stat(hsm_secret_path, &st);
159 if (st.st_size != 32)
160 errx(EXITCODE_ERROR_HSM_FILE,
161 "Invalid hsm_secret '%s' (neither plaintext "
162 "nor encrypted).", hsm_secret_path);
163 return false;
164 }
165 }
166
167 abort();
168}
169
170static int decrypt_hsm(const char *hsm_secret_path)
171{

Callers 6

decrypt_hsmFunction · 0.85
encrypt_hsmFunction · 0.85
dump_commitments_infosFunction · 0.85
guess_to_remoteFunction · 0.85
dumponchaindescriptorsFunction · 0.85
check_hsmFunction · 0.85

Calls 5

is_hsm_secret_encryptedFunction · 0.85
errFunction · 0.85
errxFunction · 0.85
abortFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected