Don't let compiler do clever things, which would allow the caller * to measure time, and figure out how much of the passphrase matched! */
| 28 | /* Don't let compiler do clever things, which would allow the caller |
| 29 | * to measure time, and figure out how much of the passphrase matched! */ |
| 30 | static bool compare_passphrases(const char *a, const char *b) |
| 31 | { |
| 32 | struct sha256 a_sha, b_sha; |
| 33 | |
| 34 | /* Technically, this gives information about passphrase length, but |
| 35 | * they can also just brute force it if it is small, so this doesn't |
| 36 | * add much! Also, hashing messes with timing quite a bit. */ |
| 37 | sha256(&a_sha, a, strlen(a)); |
| 38 | sha256(&b_sha, b, strlen(b)); |
| 39 | |
| 40 | return sha256_eq(&a_sha, &b_sha); |
| 41 | } |
| 42 | |
| 43 | static struct command_result *json_exposesecret(struct command *cmd, |
| 44 | const char *buffer, |
no test coverage detected