We detect an encrypted hsm_secret as a hsm_secret which is 73-bytes long. */
| 146 | |
| 147 | /* We detect an encrypted hsm_secret as a hsm_secret which is 73-bytes long. */ |
| 148 | static 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 | |
| 170 | static int decrypt_hsm(const char *hsm_secret_path) |
| 171 | { |
no test coverage detected