1 /*
2  * Copyright (c) 2018 Yubico AB. All rights reserved.
3  * Use of this source code is governed by a BSD-style
4  * license that can be found in the LICENSE file.
5  * SPDX-License-Identifier: BSD-2-Clause
6  */
7 
8 /*
9  * Example usage:
10  *
11  * $ echo assertion challenge | openssl sha256 -binary | base64 > assert_param
12  * $ echo relying party >> assert_param
13  * $ head -1 cred >> assert_param # credential id
14  * $ tail -n +2 cred > pubkey # credential pubkey
15  * $ fido2-assert -G -i assert_param /dev/hidraw5 | fido2-assert -V pubkey rs256
16  *
17  * See blurb in fido2-cred.c on how to obtain cred.
18  */
19 
20 #include <fido.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "../openbsd-compat/openbsd-compat.h"
26 #include "extern.h"
27 
28 void
29 usage(void)
30 {
31 	fprintf(stderr,
32 "usage: fido2-assert -G [-bdhpruv] [-t option] [-i input_file] [-o output_file] device\n"
33 "       fido2-assert -V [-dhpv] [-i input_file] key_file [type]\n"
34 	);
35 
36 	exit(1);
37 }
38 
39 int
40 main(int argc, char **argv)
41 {
42 	if (argc < 2 || strlen(argv[1]) != 2 || argv[1][0] != '-')
43 		usage();
44 
45 	switch (argv[1][1]) {
46 	case 'G':
47 		return (assert_get(--argc, ++argv));
48 	case 'V':
49 		return (assert_verify(--argc, ++argv));
50 	}
51 
52 	usage();
53 
54 	/* NOTREACHED */
55 }
56