| 68 | } |
| 69 | |
| 70 | static void get_hsm_secret(struct secret *hsm_secret, |
| 71 | const char *hsm_secret_path) |
| 72 | { |
| 73 | int fd; |
| 74 | |
| 75 | fd = open(hsm_secret_path, O_RDONLY); |
| 76 | if (fd < 0) |
| 77 | errx(EXITCODE_ERROR_HSM_FILE, "Could not open hsm_secret"); |
| 78 | if (!read_all(fd, hsm_secret, sizeof(*hsm_secret))) |
| 79 | errx(EXITCODE_ERROR_HSM_FILE, "Could not read hsm_secret"); |
| 80 | close(fd); |
| 81 | } |
| 82 | |
| 83 | /* Derive the encryption key from the password provided, and try to decrypt |
| 84 | * the cipher. */ |
no test coverage detected