10afa8e06SEd Maste /*
2*60a517b6SEd Maste * Copyright (c) 2018-2023 Yubico AB. All rights reserved.
30afa8e06SEd Maste * Use of this source code is governed by a BSD-style
40afa8e06SEd Maste * license that can be found in the LICENSE file.
52ccfa855SEd Maste * SPDX-License-Identifier: BSD-2-Clause
60afa8e06SEd Maste */
70afa8e06SEd Maste
82ccfa855SEd Maste #undef NDEBUG
92ccfa855SEd Maste
102ccfa855SEd Maste #include <assert.h>
112ccfa855SEd Maste #include <string.h>
122ccfa855SEd Maste
13f540a430SEd Maste #define _FIDO_INTERNAL
14f540a430SEd Maste
150afa8e06SEd Maste #include <fido.h>
160afa8e06SEd Maste #include <fido/es256.h>
170afa8e06SEd Maste #include <fido/rs256.h>
180afa8e06SEd Maste #include <fido/eddsa.h>
190afa8e06SEd Maste
202ccfa855SEd Maste static int fake_dev_handle;
210afa8e06SEd Maste
220afa8e06SEd Maste static const unsigned char es256_pk[64] = {
230afa8e06SEd Maste 0x34, 0xeb, 0x99, 0x77, 0x02, 0x9c, 0x36, 0x38,
240afa8e06SEd Maste 0xbb, 0xc2, 0xae, 0xa0, 0xa0, 0x18, 0xc6, 0x64,
250afa8e06SEd Maste 0xfc, 0xe8, 0x49, 0x92, 0xd7, 0x74, 0x9e, 0x0c,
260afa8e06SEd Maste 0x46, 0x8c, 0x9d, 0xa6, 0xdf, 0x46, 0xf7, 0x84,
270afa8e06SEd Maste 0x60, 0x1e, 0x0f, 0x8b, 0x23, 0x85, 0x4a, 0x9a,
280afa8e06SEd Maste 0xec, 0xc1, 0x08, 0x9f, 0x30, 0xd0, 0x0d, 0xd7,
290afa8e06SEd Maste 0x76, 0x7b, 0x55, 0x48, 0x91, 0x7c, 0x4f, 0x0f,
300afa8e06SEd Maste 0x64, 0x1a, 0x1d, 0xf8, 0xbe, 0x14, 0x90, 0x8a,
310afa8e06SEd Maste };
320afa8e06SEd Maste
33f540a430SEd Maste static const unsigned char rs256_pk[259] = {
34f540a430SEd Maste 0x9e, 0x54, 0x78, 0xb2, 0x51, 0xbe, 0x19, 0x7c,
35f540a430SEd Maste 0xcb, 0x1a, 0x9a, 0xc3, 0x49, 0x2a, 0x2f, 0xfd,
36f540a430SEd Maste 0x99, 0x64, 0x76, 0xc6, 0xdb, 0xca, 0x38, 0x3f,
37f540a430SEd Maste 0xb0, 0x6a, 0xc9, 0xc0, 0x07, 0x9f, 0x5c, 0x4d,
38f540a430SEd Maste 0xfc, 0xd1, 0x01, 0x7f, 0x69, 0x65, 0xab, 0x9c,
39f540a430SEd Maste 0x2a, 0xc2, 0x95, 0xd9, 0x44, 0xf3, 0xea, 0x94,
40f540a430SEd Maste 0x6b, 0x25, 0x66, 0x54, 0x81, 0xee, 0x24, 0x1d,
41f540a430SEd Maste 0xe1, 0x7d, 0x7f, 0xbe, 0xea, 0x76, 0x90, 0x5c,
42f540a430SEd Maste 0xbf, 0x59, 0x22, 0xd3, 0xa0, 0x68, 0x1a, 0x65,
43f540a430SEd Maste 0x8b, 0x2f, 0xb6, 0xa8, 0x30, 0x2d, 0x26, 0x81,
44f540a430SEd Maste 0xfa, 0x9e, 0x59, 0xec, 0x2f, 0xee, 0x59, 0x39,
45f540a430SEd Maste 0xe2, 0x79, 0x19, 0x54, 0x54, 0xdf, 0x24, 0x83,
46f540a430SEd Maste 0xee, 0x61, 0x5a, 0x66, 0x24, 0x2b, 0x7b, 0xfb,
47f540a430SEd Maste 0x82, 0x66, 0xe4, 0x85, 0x18, 0x20, 0x76, 0xe5,
48f540a430SEd Maste 0x4a, 0xb6, 0xcb, 0xec, 0x43, 0xbe, 0xfd, 0xb0,
49f540a430SEd Maste 0x8f, 0xfd, 0x2f, 0x69, 0xda, 0x06, 0x9c, 0x09,
50f540a430SEd Maste 0x68, 0x7a, 0x94, 0x6c, 0xb7, 0x51, 0x6d, 0x4c,
51f540a430SEd Maste 0xf7, 0x13, 0xe8, 0xd5, 0x22, 0x6b, 0x1e, 0xba,
52f540a430SEd Maste 0xb9, 0x85, 0xe8, 0x5f, 0xa1, 0x66, 0xe3, 0x20,
53f540a430SEd Maste 0x75, 0x30, 0x11, 0xb5, 0xa3, 0xc3, 0xb0, 0x72,
54f540a430SEd Maste 0x08, 0xff, 0xa3, 0xbb, 0xf1, 0x32, 0x0b, 0x06,
55f540a430SEd Maste 0xc4, 0x12, 0xa3, 0x49, 0x30, 0x19, 0xb9, 0xfe,
56f540a430SEd Maste 0x69, 0x0c, 0xd6, 0xe1, 0x58, 0x36, 0xe6, 0x41,
57f540a430SEd Maste 0x22, 0x41, 0xbf, 0x96, 0x50, 0x35, 0x56, 0x0d,
58f540a430SEd Maste 0x92, 0x8c, 0x34, 0xea, 0x28, 0x91, 0x88, 0x9e,
59f540a430SEd Maste 0x8a, 0xaa, 0x36, 0xd0, 0x0f, 0xbe, 0x16, 0xde,
60f540a430SEd Maste 0x9d, 0x5f, 0x7b, 0xda, 0x52, 0xf7, 0xf1, 0xb6,
61f540a430SEd Maste 0x28, 0x10, 0x05, 0x8f, 0xb9, 0x19, 0x7a, 0xcf,
62f540a430SEd Maste 0x18, 0x9b, 0x40, 0xcd, 0xff, 0x78, 0xea, 0x61,
63f540a430SEd Maste 0x24, 0x3b, 0x80, 0x68, 0x04, 0x9b, 0x40, 0x07,
64f540a430SEd Maste 0x98, 0xd4, 0x94, 0xd1, 0x18, 0x44, 0xa5, 0xed,
65f540a430SEd Maste 0xee, 0x18, 0xc2, 0x25, 0x52, 0x66, 0x42, 0xdf,
66f540a430SEd Maste 0x01, 0x00, 0x01,
67f540a430SEd Maste };
68f540a430SEd Maste
690afa8e06SEd Maste static const unsigned char cdh[32] = {
700afa8e06SEd Maste 0xec, 0x8d, 0x8f, 0x78, 0x42, 0x4a, 0x2b, 0xb7,
710afa8e06SEd Maste 0x82, 0x34, 0xaa, 0xca, 0x07, 0xa1, 0xf6, 0x56,
720afa8e06SEd Maste 0x42, 0x1c, 0xb6, 0xf6, 0xb3, 0x00, 0x86, 0x52,
730afa8e06SEd Maste 0x35, 0x2d, 0xa2, 0x62, 0x4a, 0xbe, 0x89, 0x76,
740afa8e06SEd Maste };
750afa8e06SEd Maste
760afa8e06SEd Maste static const unsigned char authdata[39] = {
770afa8e06SEd Maste 0x58, 0x25, 0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e,
780afa8e06SEd Maste 0x8c, 0x68, 0x74, 0x34, 0x17, 0x0f, 0x64, 0x76,
790afa8e06SEd Maste 0x60, 0x5b, 0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86,
800afa8e06SEd Maste 0x32, 0xc7, 0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d,
810afa8e06SEd Maste 0x97, 0x63, 0x00, 0x00, 0x00, 0x00, 0x03,
820afa8e06SEd Maste };
830afa8e06SEd Maste
840afa8e06SEd Maste static const unsigned char sig[72] = {
850afa8e06SEd Maste 0x30, 0x46, 0x02, 0x21, 0x00, 0xf6, 0xd1, 0xa3,
860afa8e06SEd Maste 0xd5, 0x24, 0x2b, 0xde, 0xee, 0xa0, 0x90, 0x89,
870afa8e06SEd Maste 0xcd, 0xf8, 0x9e, 0xbd, 0x6b, 0x4d, 0x55, 0x79,
880afa8e06SEd Maste 0xe4, 0xc1, 0x42, 0x27, 0xb7, 0x9b, 0x9b, 0xa4,
890afa8e06SEd Maste 0x0a, 0xe2, 0x47, 0x64, 0x0e, 0x02, 0x21, 0x00,
900afa8e06SEd Maste 0xe5, 0xc9, 0xc2, 0x83, 0x47, 0x31, 0xc7, 0x26,
910afa8e06SEd Maste 0xe5, 0x25, 0xb2, 0xb4, 0x39, 0xa7, 0xfc, 0x3d,
920afa8e06SEd Maste 0x70, 0xbe, 0xe9, 0x81, 0x0d, 0x4a, 0x62, 0xa9,
930afa8e06SEd Maste 0xab, 0x4a, 0x91, 0xc0, 0x7d, 0x2d, 0x23, 0x1e,
940afa8e06SEd Maste };
950afa8e06SEd Maste
960afa8e06SEd Maste static void *
dummy_open(const char * path)970afa8e06SEd Maste dummy_open(const char *path)
980afa8e06SEd Maste {
990afa8e06SEd Maste (void)path;
1000afa8e06SEd Maste
1012ccfa855SEd Maste return (&fake_dev_handle);
1020afa8e06SEd Maste }
1030afa8e06SEd Maste
1040afa8e06SEd Maste static void
dummy_close(void * handle)1050afa8e06SEd Maste dummy_close(void *handle)
1060afa8e06SEd Maste {
1072ccfa855SEd Maste assert(handle == &fake_dev_handle);
1080afa8e06SEd Maste }
1090afa8e06SEd Maste
1100afa8e06SEd Maste static int
dummy_read(void * handle,unsigned char * buf,size_t len,int ms)1110afa8e06SEd Maste dummy_read(void *handle, unsigned char *buf, size_t len, int ms)
1120afa8e06SEd Maste {
1130afa8e06SEd Maste (void)handle;
1140afa8e06SEd Maste (void)buf;
1150afa8e06SEd Maste (void)len;
1160afa8e06SEd Maste (void)ms;
1170afa8e06SEd Maste
1180afa8e06SEd Maste abort();
1190afa8e06SEd Maste /* NOTREACHED */
1200afa8e06SEd Maste }
1210afa8e06SEd Maste
1220afa8e06SEd Maste static int
dummy_write(void * handle,const unsigned char * buf,size_t len)1230afa8e06SEd Maste dummy_write(void *handle, const unsigned char *buf, size_t len)
1240afa8e06SEd Maste {
1250afa8e06SEd Maste (void)handle;
1260afa8e06SEd Maste (void)buf;
1270afa8e06SEd Maste (void)len;
1280afa8e06SEd Maste
1290afa8e06SEd Maste abort();
1300afa8e06SEd Maste /* NOTREACHED */
1310afa8e06SEd Maste }
1320afa8e06SEd Maste
1330afa8e06SEd Maste static fido_assert_t *
alloc_assert(void)1340afa8e06SEd Maste alloc_assert(void)
1350afa8e06SEd Maste {
1360afa8e06SEd Maste fido_assert_t *a;
1370afa8e06SEd Maste
1380afa8e06SEd Maste a = fido_assert_new();
1390afa8e06SEd Maste assert(a != NULL);
1400afa8e06SEd Maste
1410afa8e06SEd Maste return (a);
1420afa8e06SEd Maste }
1430afa8e06SEd Maste
1440afa8e06SEd Maste static void
free_assert(fido_assert_t * a)1450afa8e06SEd Maste free_assert(fido_assert_t *a)
1460afa8e06SEd Maste {
1470afa8e06SEd Maste fido_assert_free(&a);
1480afa8e06SEd Maste assert(a == NULL);
1490afa8e06SEd Maste }
1500afa8e06SEd Maste
1510afa8e06SEd Maste static fido_dev_t *
alloc_dev(void)1520afa8e06SEd Maste alloc_dev(void)
1530afa8e06SEd Maste {
1540afa8e06SEd Maste fido_dev_t *d;
1550afa8e06SEd Maste
1560afa8e06SEd Maste d = fido_dev_new();
1570afa8e06SEd Maste assert(d != NULL);
1580afa8e06SEd Maste
1590afa8e06SEd Maste return (d);
1600afa8e06SEd Maste }
1610afa8e06SEd Maste
1620afa8e06SEd Maste static void
free_dev(fido_dev_t * d)1630afa8e06SEd Maste free_dev(fido_dev_t *d)
1640afa8e06SEd Maste {
1650afa8e06SEd Maste fido_dev_free(&d);
1660afa8e06SEd Maste assert(d == NULL);
1670afa8e06SEd Maste }
1680afa8e06SEd Maste
1690afa8e06SEd Maste static es256_pk_t *
alloc_es256_pk(void)1700afa8e06SEd Maste alloc_es256_pk(void)
1710afa8e06SEd Maste {
1720afa8e06SEd Maste es256_pk_t *pk;
1730afa8e06SEd Maste
1740afa8e06SEd Maste pk = es256_pk_new();
1750afa8e06SEd Maste assert(pk != NULL);
1760afa8e06SEd Maste
1770afa8e06SEd Maste return (pk);
1780afa8e06SEd Maste }
1790afa8e06SEd Maste
1800afa8e06SEd Maste static void
free_es256_pk(es256_pk_t * pk)1810afa8e06SEd Maste free_es256_pk(es256_pk_t *pk)
1820afa8e06SEd Maste {
1830afa8e06SEd Maste es256_pk_free(&pk);
1840afa8e06SEd Maste assert(pk == NULL);
1850afa8e06SEd Maste }
1860afa8e06SEd Maste
1870afa8e06SEd Maste static rs256_pk_t *
alloc_rs256_pk(void)1880afa8e06SEd Maste alloc_rs256_pk(void)
1890afa8e06SEd Maste {
1900afa8e06SEd Maste rs256_pk_t *pk;
1910afa8e06SEd Maste
1920afa8e06SEd Maste pk = rs256_pk_new();
1930afa8e06SEd Maste assert(pk != NULL);
1940afa8e06SEd Maste
1950afa8e06SEd Maste return (pk);
1960afa8e06SEd Maste }
1970afa8e06SEd Maste
1980afa8e06SEd Maste static void
free_rs256_pk(rs256_pk_t * pk)1990afa8e06SEd Maste free_rs256_pk(rs256_pk_t *pk)
2000afa8e06SEd Maste {
2010afa8e06SEd Maste rs256_pk_free(&pk);
2020afa8e06SEd Maste assert(pk == NULL);
2030afa8e06SEd Maste }
2040afa8e06SEd Maste
2050afa8e06SEd Maste static eddsa_pk_t *
alloc_eddsa_pk(void)2060afa8e06SEd Maste alloc_eddsa_pk(void)
2070afa8e06SEd Maste {
2080afa8e06SEd Maste eddsa_pk_t *pk;
2090afa8e06SEd Maste
2100afa8e06SEd Maste pk = eddsa_pk_new();
2110afa8e06SEd Maste assert(pk != NULL);
2120afa8e06SEd Maste
2130afa8e06SEd Maste return (pk);
2140afa8e06SEd Maste }
2150afa8e06SEd Maste
2160afa8e06SEd Maste static void
free_eddsa_pk(eddsa_pk_t * pk)2170afa8e06SEd Maste free_eddsa_pk(eddsa_pk_t *pk)
2180afa8e06SEd Maste {
2190afa8e06SEd Maste eddsa_pk_free(&pk);
2200afa8e06SEd Maste assert(pk == NULL);
2210afa8e06SEd Maste }
2220afa8e06SEd Maste
2230afa8e06SEd Maste static void
empty_assert(fido_dev_t * d,fido_assert_t * a,size_t idx)2240afa8e06SEd Maste empty_assert(fido_dev_t *d, fido_assert_t *a, size_t idx)
2250afa8e06SEd Maste {
2260afa8e06SEd Maste es256_pk_t *es256;
2270afa8e06SEd Maste rs256_pk_t *rs256;
2280afa8e06SEd Maste eddsa_pk_t *eddsa;
2290afa8e06SEd Maste
2300afa8e06SEd Maste assert(fido_assert_flags(a, idx) == 0);
2310afa8e06SEd Maste assert(fido_assert_authdata_len(a, idx) == 0);
2320afa8e06SEd Maste assert(fido_assert_authdata_ptr(a, idx) == NULL);
233*60a517b6SEd Maste assert(fido_assert_authdata_raw_len(a, idx) == 0);
234*60a517b6SEd Maste assert(fido_assert_authdata_raw_ptr(a, idx) == NULL);
2350afa8e06SEd Maste assert(fido_assert_clientdata_hash_len(a) == 0);
2360afa8e06SEd Maste assert(fido_assert_clientdata_hash_ptr(a) == NULL);
2370afa8e06SEd Maste assert(fido_assert_id_len(a, idx) == 0);
2380afa8e06SEd Maste assert(fido_assert_id_ptr(a, idx) == NULL);
2390afa8e06SEd Maste assert(fido_assert_rp_id(a) == NULL);
2400afa8e06SEd Maste assert(fido_assert_sig_len(a, idx) == 0);
2410afa8e06SEd Maste assert(fido_assert_sig_ptr(a, idx) == NULL);
2420afa8e06SEd Maste assert(fido_assert_user_display_name(a, idx) == NULL);
2430afa8e06SEd Maste assert(fido_assert_user_icon(a, idx) == NULL);
2440afa8e06SEd Maste assert(fido_assert_user_id_len(a, idx) == 0);
2450afa8e06SEd Maste assert(fido_assert_user_id_ptr(a, idx) == NULL);
2460afa8e06SEd Maste assert(fido_assert_user_name(a, idx) == NULL);
2470afa8e06SEd Maste
2480afa8e06SEd Maste es256 = alloc_es256_pk();
2490afa8e06SEd Maste rs256 = alloc_rs256_pk();
2500afa8e06SEd Maste eddsa = alloc_eddsa_pk();
2510afa8e06SEd Maste
2520afa8e06SEd Maste fido_dev_force_u2f(d);
2530afa8e06SEd Maste assert(fido_dev_get_assert(d, a, NULL) == FIDO_ERR_INVALID_ARGUMENT);
2540afa8e06SEd Maste assert(fido_dev_get_assert(d, a, "") == FIDO_ERR_INVALID_ARGUMENT);
2550afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_ES256,
2560afa8e06SEd Maste NULL) == FIDO_ERR_INVALID_ARGUMENT);
2570afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_ES256,
2580afa8e06SEd Maste es256) == FIDO_ERR_INVALID_ARGUMENT);
2590afa8e06SEd Maste assert(fido_assert_verify(a, idx, -1,
2600afa8e06SEd Maste es256) == FIDO_ERR_INVALID_ARGUMENT);
2610afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_RS256,
2620afa8e06SEd Maste rs256) == FIDO_ERR_INVALID_ARGUMENT);
2630afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_EDDSA,
2640afa8e06SEd Maste eddsa) == FIDO_ERR_INVALID_ARGUMENT);
2650afa8e06SEd Maste
2660afa8e06SEd Maste fido_dev_force_fido2(d);
2670afa8e06SEd Maste assert(fido_dev_get_assert(d, a, NULL) == FIDO_ERR_INVALID_ARGUMENT);
2680afa8e06SEd Maste assert(fido_dev_get_assert(d, a, "") == FIDO_ERR_INVALID_ARGUMENT);
2690afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_ES256,
2700afa8e06SEd Maste NULL) == FIDO_ERR_INVALID_ARGUMENT);
2710afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_ES256,
2720afa8e06SEd Maste es256) == FIDO_ERR_INVALID_ARGUMENT);
2730afa8e06SEd Maste assert(fido_assert_verify(a, idx, -1,
2740afa8e06SEd Maste es256) == FIDO_ERR_INVALID_ARGUMENT);
2750afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_RS256,
2760afa8e06SEd Maste rs256) == FIDO_ERR_INVALID_ARGUMENT);
2770afa8e06SEd Maste assert(fido_assert_verify(a, idx, COSE_EDDSA,
2780afa8e06SEd Maste eddsa) == FIDO_ERR_INVALID_ARGUMENT);
2790afa8e06SEd Maste
2800afa8e06SEd Maste free_es256_pk(es256);
2810afa8e06SEd Maste free_rs256_pk(rs256);
2820afa8e06SEd Maste free_eddsa_pk(eddsa);
2830afa8e06SEd Maste }
2840afa8e06SEd Maste
2850afa8e06SEd Maste static void
empty_assert_tests(void)2860afa8e06SEd Maste empty_assert_tests(void)
2870afa8e06SEd Maste {
2880afa8e06SEd Maste fido_assert_t *a;
2890afa8e06SEd Maste fido_dev_t *d;
2900afa8e06SEd Maste fido_dev_io_t io_f;
2910afa8e06SEd Maste size_t i;
2920afa8e06SEd Maste
2930afa8e06SEd Maste memset(&io_f, 0, sizeof(io_f));
2940afa8e06SEd Maste
2950afa8e06SEd Maste a = alloc_assert();
2960afa8e06SEd Maste d = alloc_dev();
2970afa8e06SEd Maste
2980afa8e06SEd Maste io_f.open = dummy_open;
2990afa8e06SEd Maste io_f.close = dummy_close;
3000afa8e06SEd Maste io_f.read = dummy_read;
3010afa8e06SEd Maste io_f.write = dummy_write;
3020afa8e06SEd Maste
3030afa8e06SEd Maste assert(fido_dev_set_io_functions(d, &io_f) == FIDO_OK);
3040afa8e06SEd Maste
3050afa8e06SEd Maste empty_assert(d, a, 0);
3060afa8e06SEd Maste assert(fido_assert_count(a) == 0);
3070afa8e06SEd Maste assert(fido_assert_set_count(a, 4) == FIDO_OK);
3080afa8e06SEd Maste assert(fido_assert_count(a) == 4);
3090afa8e06SEd Maste for (i = 0; i < 4; i++) {
3100afa8e06SEd Maste empty_assert(d, a, i);
3110afa8e06SEd Maste }
3120afa8e06SEd Maste empty_assert(d, a, 10);
3130afa8e06SEd Maste free_assert(a);
3140afa8e06SEd Maste free_dev(d);
3150afa8e06SEd Maste }
3160afa8e06SEd Maste
3170afa8e06SEd Maste static void
valid_assert(void)3180afa8e06SEd Maste valid_assert(void)
3190afa8e06SEd Maste {
3200afa8e06SEd Maste fido_assert_t *a;
3210afa8e06SEd Maste es256_pk_t *es256;
3220afa8e06SEd Maste rs256_pk_t *rs256;
3230afa8e06SEd Maste eddsa_pk_t *eddsa;
3240afa8e06SEd Maste
3250afa8e06SEd Maste a = alloc_assert();
3260afa8e06SEd Maste es256 = alloc_es256_pk();
3270afa8e06SEd Maste rs256 = alloc_rs256_pk();
3280afa8e06SEd Maste eddsa = alloc_eddsa_pk();
3290afa8e06SEd Maste assert(es256_pk_from_ptr(es256, es256_pk, sizeof(es256_pk)) == FIDO_OK);
3300afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
3310afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
3320afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
3330afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
3340afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
3350afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
3360afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
3370afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
3380afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256, es256) == FIDO_OK);
3390afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_RS256, rs256) == FIDO_ERR_INVALID_SIG);
3400afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_EDDSA, eddsa) == FIDO_ERR_INVALID_SIG);
3410afa8e06SEd Maste free_assert(a);
3420afa8e06SEd Maste free_es256_pk(es256);
3430afa8e06SEd Maste free_rs256_pk(rs256);
3440afa8e06SEd Maste free_eddsa_pk(eddsa);
3450afa8e06SEd Maste }
3460afa8e06SEd Maste
3470afa8e06SEd Maste static void
no_cdh(void)3480afa8e06SEd Maste no_cdh(void)
3490afa8e06SEd Maste {
3500afa8e06SEd Maste fido_assert_t *a;
3510afa8e06SEd Maste es256_pk_t *pk;
3520afa8e06SEd Maste
3530afa8e06SEd Maste a = alloc_assert();
3540afa8e06SEd Maste pk = alloc_es256_pk();
3550afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
3560afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
3570afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
3580afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
3590afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
3600afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
3610afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
3620afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
3630afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
3640afa8e06SEd Maste pk) == FIDO_ERR_INVALID_ARGUMENT);
3650afa8e06SEd Maste free_assert(a);
3660afa8e06SEd Maste free_es256_pk(pk);
3670afa8e06SEd Maste }
3680afa8e06SEd Maste
3690afa8e06SEd Maste static void
no_rp(void)3700afa8e06SEd Maste no_rp(void)
3710afa8e06SEd Maste {
3720afa8e06SEd Maste fido_assert_t *a;
3730afa8e06SEd Maste es256_pk_t *pk;
3740afa8e06SEd Maste
3750afa8e06SEd Maste a = alloc_assert();
3760afa8e06SEd Maste pk = alloc_es256_pk();
3770afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
3780afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
3790afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
3800afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
3810afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
3820afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
3830afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
3840afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
3850afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
3860afa8e06SEd Maste pk) == FIDO_ERR_INVALID_ARGUMENT);
3870afa8e06SEd Maste free_assert(a);
3880afa8e06SEd Maste free_es256_pk(pk);
3890afa8e06SEd Maste }
3900afa8e06SEd Maste
3910afa8e06SEd Maste static void
no_authdata(void)3920afa8e06SEd Maste no_authdata(void)
3930afa8e06SEd Maste {
3940afa8e06SEd Maste fido_assert_t *a;
3950afa8e06SEd Maste es256_pk_t *pk;
3960afa8e06SEd Maste
3970afa8e06SEd Maste a = alloc_assert();
3980afa8e06SEd Maste pk = alloc_es256_pk();
3990afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
4000afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
4010afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
4020afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
4030afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
4040afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
4050afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
4060afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
4070afa8e06SEd Maste pk) == FIDO_ERR_INVALID_ARGUMENT);
4080afa8e06SEd Maste free_assert(a);
4090afa8e06SEd Maste free_es256_pk(pk);
4100afa8e06SEd Maste }
4110afa8e06SEd Maste
4120afa8e06SEd Maste static void
no_sig(void)4130afa8e06SEd Maste no_sig(void)
4140afa8e06SEd Maste {
4150afa8e06SEd Maste fido_assert_t *a;
4160afa8e06SEd Maste es256_pk_t *pk;
4170afa8e06SEd Maste
4180afa8e06SEd Maste a = alloc_assert();
4190afa8e06SEd Maste pk = alloc_es256_pk();
4200afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
4210afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
4220afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
4230afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
4240afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
4250afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
4260afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
4270afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
4280afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
4290afa8e06SEd Maste pk) == FIDO_ERR_INVALID_ARGUMENT);
4300afa8e06SEd Maste free_assert(a);
4310afa8e06SEd Maste free_es256_pk(pk);
4320afa8e06SEd Maste }
4330afa8e06SEd Maste
4340afa8e06SEd Maste static void
junk_cdh(void)4350afa8e06SEd Maste junk_cdh(void)
4360afa8e06SEd Maste {
4370afa8e06SEd Maste fido_assert_t *a;
4380afa8e06SEd Maste es256_pk_t *pk;
4390afa8e06SEd Maste unsigned char *junk;
4400afa8e06SEd Maste
4410afa8e06SEd Maste junk = malloc(sizeof(cdh));
4420afa8e06SEd Maste assert(junk != NULL);
4430afa8e06SEd Maste memcpy(junk, cdh, sizeof(cdh));
444f540a430SEd Maste junk[0] = (unsigned char)~junk[0];
4450afa8e06SEd Maste
4460afa8e06SEd Maste a = alloc_assert();
4470afa8e06SEd Maste pk = alloc_es256_pk();
4480afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
4490afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, junk, sizeof(cdh)) == FIDO_OK);
4500afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
4510afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
4520afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
4530afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
4540afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
4550afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
4560afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
4570afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256, pk) == FIDO_ERR_INVALID_SIG);
4580afa8e06SEd Maste free_assert(a);
4590afa8e06SEd Maste free_es256_pk(pk);
4600afa8e06SEd Maste free(junk);
4610afa8e06SEd Maste }
4620afa8e06SEd Maste
4630afa8e06SEd Maste static void
junk_rp(void)4640afa8e06SEd Maste junk_rp(void)
4650afa8e06SEd Maste {
4660afa8e06SEd Maste fido_assert_t *a;
4670afa8e06SEd Maste es256_pk_t *pk;
4680afa8e06SEd Maste
4690afa8e06SEd Maste a = alloc_assert();
4700afa8e06SEd Maste pk = alloc_es256_pk();
4710afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
4720afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
4730afa8e06SEd Maste assert(fido_assert_set_rp(a, "potato") == FIDO_OK);
4740afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
4750afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
4760afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
4770afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
4780afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
4790afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
4800afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
4810afa8e06SEd Maste pk) == FIDO_ERR_INVALID_PARAM);
4820afa8e06SEd Maste free_assert(a);
4830afa8e06SEd Maste free_es256_pk(pk);
4840afa8e06SEd Maste }
4850afa8e06SEd Maste
4860afa8e06SEd Maste static void
junk_authdata(void)4870afa8e06SEd Maste junk_authdata(void)
4880afa8e06SEd Maste {
4890afa8e06SEd Maste fido_assert_t *a;
4900afa8e06SEd Maste unsigned char *junk;
4910afa8e06SEd Maste
4920afa8e06SEd Maste junk = malloc(sizeof(authdata));
4930afa8e06SEd Maste assert(junk != NULL);
4940afa8e06SEd Maste memcpy(junk, authdata, sizeof(authdata));
495f540a430SEd Maste junk[0] = (unsigned char)~junk[0];
4960afa8e06SEd Maste
4970afa8e06SEd Maste a = alloc_assert();
4980afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
4990afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, junk,
5000afa8e06SEd Maste sizeof(authdata)) == FIDO_ERR_INVALID_ARGUMENT);
501*60a517b6SEd Maste assert(fido_assert_authdata_ptr(a, 0) == NULL);
502*60a517b6SEd Maste assert(fido_assert_authdata_len(a, 0) == 0);
503*60a517b6SEd Maste assert(fido_assert_authdata_raw_ptr(a, 0) == NULL);
504*60a517b6SEd Maste assert(fido_assert_authdata_raw_len(a, 0) == 0);
5050afa8e06SEd Maste free_assert(a);
5060afa8e06SEd Maste free(junk);
5070afa8e06SEd Maste }
5080afa8e06SEd Maste
5090afa8e06SEd Maste static void
junk_sig(void)5100afa8e06SEd Maste junk_sig(void)
5110afa8e06SEd Maste {
5120afa8e06SEd Maste fido_assert_t *a;
5130afa8e06SEd Maste es256_pk_t *pk;
5140afa8e06SEd Maste unsigned char *junk;
5150afa8e06SEd Maste
5160afa8e06SEd Maste junk = malloc(sizeof(sig));
5170afa8e06SEd Maste assert(junk != NULL);
5180afa8e06SEd Maste memcpy(junk, sig, sizeof(sig));
519f540a430SEd Maste junk[0] = (unsigned char)~junk[0];
5200afa8e06SEd Maste
5210afa8e06SEd Maste a = alloc_assert();
5220afa8e06SEd Maste pk = alloc_es256_pk();
5230afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
5240afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
5250afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
5260afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
5270afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
5280afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
5290afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
5300afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
5310afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, junk, sizeof(sig)) == FIDO_OK);
5320afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256, pk) == FIDO_ERR_INVALID_SIG);
5330afa8e06SEd Maste free_assert(a);
5340afa8e06SEd Maste free_es256_pk(pk);
5350afa8e06SEd Maste free(junk);
5360afa8e06SEd Maste }
5370afa8e06SEd Maste
5380afa8e06SEd Maste static void
wrong_options(void)5390afa8e06SEd Maste wrong_options(void)
5400afa8e06SEd Maste {
5410afa8e06SEd Maste fido_assert_t *a;
5420afa8e06SEd Maste es256_pk_t *pk;
5430afa8e06SEd Maste
5440afa8e06SEd Maste a = alloc_assert();
5450afa8e06SEd Maste pk = alloc_es256_pk();
5460afa8e06SEd Maste assert(es256_pk_from_ptr(pk, es256_pk, sizeof(es256_pk)) == FIDO_OK);
5470afa8e06SEd Maste assert(fido_assert_set_clientdata_hash(a, cdh, sizeof(cdh)) == FIDO_OK);
5480afa8e06SEd Maste assert(fido_assert_set_rp(a, "localhost") == FIDO_OK);
5490afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
5500afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
5510afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
5520afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_TRUE) == FIDO_OK);
5530afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
5540afa8e06SEd Maste assert(fido_assert_set_sig(a, 0, sig, sizeof(sig)) == FIDO_OK);
5550afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
5560afa8e06SEd Maste pk) == FIDO_ERR_INVALID_PARAM);
5570afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
5580afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_TRUE) == FIDO_OK);
5590afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256,
5600afa8e06SEd Maste pk) == FIDO_ERR_INVALID_PARAM);
5610afa8e06SEd Maste assert(fido_assert_set_up(a, FIDO_OPT_FALSE) == FIDO_OK);
5620afa8e06SEd Maste assert(fido_assert_set_uv(a, FIDO_OPT_FALSE) == FIDO_OK);
5630afa8e06SEd Maste assert(fido_assert_verify(a, 0, COSE_ES256, pk) == FIDO_OK);
5640afa8e06SEd Maste free_assert(a);
5650afa8e06SEd Maste free_es256_pk(pk);
5660afa8e06SEd Maste }
5670afa8e06SEd Maste
5680afa8e06SEd Maste /* cbor_serialize_alloc misuse */
5690afa8e06SEd Maste static void
bad_cbor_serialize(void)5700afa8e06SEd Maste bad_cbor_serialize(void)
5710afa8e06SEd Maste {
5720afa8e06SEd Maste fido_assert_t *a;
5730afa8e06SEd Maste
5740afa8e06SEd Maste a = alloc_assert();
5750afa8e06SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
5760afa8e06SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
5770afa8e06SEd Maste sizeof(authdata)) == FIDO_OK);
5780afa8e06SEd Maste assert(fido_assert_authdata_len(a, 0) == sizeof(authdata));
5790afa8e06SEd Maste free_assert(a);
5800afa8e06SEd Maste }
5810afa8e06SEd Maste
582f540a430SEd Maste /* rs256 <-> EVP_PKEY transformations */
583f540a430SEd Maste static void
rs256_PKEY(void)584f540a430SEd Maste rs256_PKEY(void)
585f540a430SEd Maste {
586f540a430SEd Maste rs256_pk_t *pk1, *pk2;
587f540a430SEd Maste EVP_PKEY *pkey;
588f540a430SEd Maste
589f540a430SEd Maste pk1 = alloc_rs256_pk();
590f540a430SEd Maste pk2 = alloc_rs256_pk();
591f540a430SEd Maste
592f540a430SEd Maste assert(rs256_pk_from_ptr(pk1, rs256_pk, sizeof(rs256_pk)) == FIDO_OK);
593f540a430SEd Maste assert((pkey = rs256_pk_to_EVP_PKEY(pk1)) != NULL);
594f540a430SEd Maste assert(rs256_pk_from_EVP_PKEY(pk2, pkey) == FIDO_OK);
595f540a430SEd Maste assert(memcmp(pk1, pk2, sizeof(*pk1)) == 0);
596f540a430SEd Maste
597f540a430SEd Maste free_rs256_pk(pk1);
598f540a430SEd Maste free_rs256_pk(pk2);
599f540a430SEd Maste EVP_PKEY_free(pkey);
600f540a430SEd Maste }
601f540a430SEd Maste
602f540a430SEd Maste /* es256 <-> EVP_PKEY transformations */
603f540a430SEd Maste static void
es256_PKEY(void)604f540a430SEd Maste es256_PKEY(void)
605f540a430SEd Maste {
606f540a430SEd Maste es256_pk_t *pk1, *pk2;
607f540a430SEd Maste EVP_PKEY *pkey;
608f540a430SEd Maste
609f540a430SEd Maste pk1 = alloc_es256_pk();
610f540a430SEd Maste pk2 = alloc_es256_pk();
611f540a430SEd Maste
612f540a430SEd Maste assert(es256_pk_from_ptr(pk1, es256_pk, sizeof(es256_pk)) == FIDO_OK);
613f540a430SEd Maste assert((pkey = es256_pk_to_EVP_PKEY(pk1)) != NULL);
614f540a430SEd Maste assert(es256_pk_from_EVP_PKEY(pk2, pkey) == FIDO_OK);
615f540a430SEd Maste assert(memcmp(pk1, pk2, sizeof(*pk1)) == 0);
616f540a430SEd Maste
617f540a430SEd Maste free_es256_pk(pk1);
618f540a430SEd Maste free_es256_pk(pk2);
619f540a430SEd Maste EVP_PKEY_free(pkey);
620f540a430SEd Maste }
621f540a430SEd Maste
622*60a517b6SEd Maste static void
raw_authdata(void)623*60a517b6SEd Maste raw_authdata(void)
624*60a517b6SEd Maste {
625*60a517b6SEd Maste fido_assert_t *a;
626*60a517b6SEd Maste cbor_item_t *item;
627*60a517b6SEd Maste struct cbor_load_result cbor_result;
628*60a517b6SEd Maste const unsigned char *ptr;
629*60a517b6SEd Maste unsigned char *cbor;
630*60a517b6SEd Maste size_t len;
631*60a517b6SEd Maste size_t cbor_len;
632*60a517b6SEd Maste size_t alloclen;
633*60a517b6SEd Maste
634*60a517b6SEd Maste a = alloc_assert();
635*60a517b6SEd Maste assert(fido_assert_set_count(a, 1) == FIDO_OK);
636*60a517b6SEd Maste assert(fido_assert_set_authdata(a, 0, authdata,
637*60a517b6SEd Maste sizeof(authdata)) == FIDO_OK);
638*60a517b6SEd Maste assert((ptr = fido_assert_authdata_ptr(a, 0)) != NULL);
639*60a517b6SEd Maste assert((len = fido_assert_authdata_len(a, 0)) != 0);
640*60a517b6SEd Maste assert((item = cbor_load(ptr, len, &cbor_result)) != NULL);
641*60a517b6SEd Maste assert(cbor_result.read == len);
642*60a517b6SEd Maste assert(cbor_isa_bytestring(item));
643*60a517b6SEd Maste assert((ptr = fido_assert_authdata_raw_ptr(a, 0)) != NULL);
644*60a517b6SEd Maste assert((len = fido_assert_authdata_raw_len(a, 0)) != 0);
645*60a517b6SEd Maste assert(cbor_bytestring_length(item) == len);
646*60a517b6SEd Maste assert(memcmp(ptr, cbor_bytestring_handle(item), len) == 0);
647*60a517b6SEd Maste assert((len = fido_assert_authdata_len(a, 0)) != 0);
648*60a517b6SEd Maste assert((cbor_len = cbor_serialize_alloc(item, &cbor, &alloclen)) == len);
649*60a517b6SEd Maste assert((ptr = cbor_bytestring_handle(item)) != NULL);
650*60a517b6SEd Maste assert((len = cbor_bytestring_length(item)) != 0);
651*60a517b6SEd Maste assert(fido_assert_set_authdata_raw(a, 0, ptr, len) == FIDO_OK);
652*60a517b6SEd Maste assert((ptr = fido_assert_authdata_ptr(a, 0)) != NULL);
653*60a517b6SEd Maste assert((len = fido_assert_authdata_len(a, 0)) != 0);
654*60a517b6SEd Maste assert(len == cbor_len);
655*60a517b6SEd Maste assert(memcmp(cbor, ptr, len) == 0);
656*60a517b6SEd Maste assert(cbor_len == sizeof(authdata));
657*60a517b6SEd Maste assert(memcmp(cbor, authdata, cbor_len) == 0);
658*60a517b6SEd Maste cbor_decref(&item);
659*60a517b6SEd Maste free(cbor);
660*60a517b6SEd Maste free_assert(a);
661*60a517b6SEd Maste }
662*60a517b6SEd Maste
6630afa8e06SEd Maste int
main(void)6640afa8e06SEd Maste main(void)
6650afa8e06SEd Maste {
6660afa8e06SEd Maste fido_init(0);
6670afa8e06SEd Maste
6680afa8e06SEd Maste empty_assert_tests();
6690afa8e06SEd Maste valid_assert();
6700afa8e06SEd Maste no_cdh();
6710afa8e06SEd Maste no_rp();
6720afa8e06SEd Maste no_authdata();
6730afa8e06SEd Maste no_sig();
6740afa8e06SEd Maste junk_cdh();
6750afa8e06SEd Maste junk_rp();
6760afa8e06SEd Maste junk_authdata();
6770afa8e06SEd Maste junk_sig();
6780afa8e06SEd Maste wrong_options();
6790afa8e06SEd Maste bad_cbor_serialize();
680f540a430SEd Maste rs256_PKEY();
681f540a430SEd Maste es256_PKEY();
682*60a517b6SEd Maste raw_authdata();
6830afa8e06SEd Maste
6840afa8e06SEd Maste exit(0);
6850afa8e06SEd Maste }
686