Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ-
Binary file not shown.
12 changes: 6 additions & 6 deletions tests/fuzz/fuzz-hsm_encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ void init(int *argc, char ***argv)

void run(const uint8_t *data, size_t size)
{
/* 4294967295 is crypto_pwhash_argon2id_PASSWD_MAX. libfuzzer won't
* generate inputs that large in practice, but hey. */
if (size > 32 && size < 4294967295) {
/* LibFuzzer won't generate inputs larger than
* crypto_pwhash_argon2id_PASSWD_MAX in practice, but hey. */
if (size > sizeof(struct secret) && size < crypto_pwhash_argon2id_PASSWD_MAX) {
struct secret *hsm_secret, decrypted_hsm_secret, encryption_key;
char *passphrase;
struct encrypted_hsm_secret encrypted_secret;
const char *emsg;

/* Take the first 32 bytes as the plaintext hsm_secret seed,
* and the remaining ones as the passphrase. */
hsm_secret = (struct secret *)tal_dup_arr(NULL, u8, data, 32, 0);
passphrase = to_string(NULL, data + 32, size - 32);
hsm_secret = (struct secret *)tal_dup_arr(NULL, u8, data, sizeof(struct secret), 0);
passphrase = to_string(NULL, data + sizeof(struct secret), size - sizeof(struct secret));

/* A valid seed, a valid passphrase. This should not fail. */
assert(!hsm_secret_encryption_key_with_exitcode(passphrase, &encryption_key, &emsg));
Expand All @@ -35,7 +35,7 @@ void run(const uint8_t *data, size_t size)
decrypted_hsm_secret.data,
sizeof(decrypted_hsm_secret.data)));

tal_free(hsm_secret);
discard_key(hsm_secret);
tal_free(passphrase);
}
}
Loading