Skip to content

Commit

Permalink
regress: add basic test for fido_cred_append_type()
Browse files Browse the repository at this point in the history
  • Loading branch information
LDVG committed Nov 15, 2024
1 parent ff717dd commit 511f4c0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions regress/cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -3021,6 +3021,36 @@ entattest(void)
assert(fido_dev_close(dev) == FIDO_OK);
fido_dev_free(&dev);
}
static void
multiple_cose(void)
{
fido_cred_t *c;

c = alloc_cred();
assert(fido_cred_type(c) == COSE_UNSPEC);
assert(fido_cred_append_type(c, COSE_EDDSA) == FIDO_OK);
assert(fido_cred_type(c) == COSE_EDDSA); // compat: only algorithm req.
assert(fido_cred_append_type(c, COSE_ES256) == FIDO_OK);
assert(fido_cred_type(c) == COSE_EDDSA); // compat: first algorithm req.
assert(fido_cred_set_clientdata_hash(c, cdh, sizeof(cdh)) == FIDO_OK);
assert(fido_cred_set_rp(c, rp_id, rp_name) == FIDO_OK);
assert(fido_cred_set_authdata(c, authdata, sizeof(authdata)) == FIDO_OK);
assert(fido_cred_set_rk(c, FIDO_OPT_FALSE) == FIDO_OK);
assert(fido_cred_set_uv(c, FIDO_OPT_FALSE) == FIDO_OK);
assert(fido_cred_set_x509(c, x509, sizeof(x509)) == FIDO_OK);
assert(fido_cred_set_sig(c, sig, sizeof(sig)) == FIDO_OK);
assert(fido_cred_set_fmt(c, "packed") == FIDO_OK);
assert(fido_cred_type(c) == COSE_ES256); // actual algorithm used
assert(fido_cred_verify(c) == FIDO_OK);
assert(fido_cred_prot(c) == 0);
assert(fido_cred_pubkey_len(c) == sizeof(pubkey));
assert(memcmp(fido_cred_pubkey_ptr(c), pubkey, sizeof(pubkey)) == 0);
assert(fido_cred_id_len(c) == sizeof(id));
assert(memcmp(fido_cred_id_ptr(c), id, sizeof(id)) == 0);
assert(fido_cred_aaguid_len(c) == sizeof(aaguid));
assert(memcmp(fido_cred_aaguid_ptr(c), aaguid, sizeof(aaguid)) == 0);
free_cred(c);
}

int
main(void)
Expand Down Expand Up @@ -3058,6 +3088,7 @@ main(void)
attestation_object();
makecred();
entattest();
multiple_cose();

exit(0);
}

0 comments on commit 511f4c0

Please sign in to comment.