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

Function create_encrypted_hsm

hsmd/hsmd.c:283–296  ·  view source on GitHub ↗

~ This encrypts the content of the `struct secret hsm_secret` and * stores it in hsm_secret, this is called instead of create_hsm() if * `lightningd` is started with --encrypted-hsm. */

Source from the content-addressed store, hash-verified

281 * `lightningd` is started with --encrypted-hsm.
282 */
283static void create_encrypted_hsm(int fd, const struct secret *encryption_key)
284{
285 struct encrypted_hsm_secret cipher;
286
287 if (!encrypt_hsm_secret(encryption_key, &hsm_secret,
288 &cipher))
289 status_failed(STATUS_FAIL_INTERNAL_ERROR,
290 "Encrypting hsm_secret");
291 if (!write_all(fd, cipher.data, ENCRYPTED_HSM_SECRET_LEN)) {
292 unlink_noerr("hsm_secret");
293 status_failed(STATUS_FAIL_INTERNAL_ERROR,
294 "Writing encrypted hsm_secret: %s", strerror(errno));
295 }
296}
297
298static void create_hsm(int fd)
299{

Callers 1

maybe_create_new_hsmFunction · 0.85

Calls 4

encrypt_hsm_secretFunction · 0.85
unlink_noerrFunction · 0.85
status_failedFunction · 0.50
write_allFunction · 0.50

Tested by

no test coverage detected