Skip to content

Commit

Permalink
fuzz: exercise fido_cred_{,set_}entattest()
Browse files Browse the repository at this point in the history
Use excl_cred's first byte as an input to fido_cred_set_entattest();
like what fido_cred_set_prot() is doing with user_id. This saves adding
additional members to the parameter struct.
  • Loading branch information
LDVG committed Aug 21, 2024
1 parent f803c50 commit a8e9dda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fuzz/export.gnu
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
fido_cred_clientdata_hash_len;
fido_cred_clientdata_hash_ptr;
fido_cred_display_name;
fido_cred_entattset;
fido_cred_exclude;
fido_cred_flags;
fido_cred_largeblob_key_len;
Expand Down Expand Up @@ -172,6 +173,7 @@
fido_cred_set_blob;
fido_cred_set_clientdata;
fido_cred_set_clientdata_hash;
fido_cred_set_entattest;
fido_cred_set_extensions;
fido_cred_set_fmt;
fido_cred_set_id;
Expand Down
6 changes: 6 additions & 0 deletions fuzz/fuzz_cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ make_cred(fido_cred_t *cred, uint8_t opt, int type, const struct blob *cdh,
fido_cred_set_uv(cred, FIDO_OPT_TRUE);
if (user_id->len)
fido_cred_set_prot(cred, user_id->body[0] & 0x03);
if (excl_cred->len)
fido_cred_set_entattest(cred, excl_cred->body[0] & 0x03);

/* repeat memory operations to trigger reallocation paths */
fido_cred_set_type(cred, type);
Expand Down Expand Up @@ -279,6 +281,7 @@ verify_cred(int type, const unsigned char *cdh_ptr, size_t cdh_len,
uint8_t flags;
uint32_t sigcount;
int r;
bool ea;

if ((cred = fido_cred_new()) == NULL)
return;
Expand Down Expand Up @@ -348,6 +351,9 @@ verify_cred(int type, const unsigned char *cdh_ptr, size_t cdh_len,
minpinlen = fido_cred_pin_minlen(cred);
consume(&minpinlen, sizeof(minpinlen));

ea = fido_cred_entattest(cred);
consume(&ea, sizeof(ea));

fido_cred_free(&cred);
}

Expand Down

0 comments on commit a8e9dda

Please sign in to comment.