summaryrefslogtreecommitdiff
path: root/tools/fido2-cred.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/fido2-cred.c')
-rw-r--r--tools/fido2-cred.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/fido2-cred.c b/tools/fido2-cred.c
new file mode 100644
index 0000000..45efca0
--- /dev/null
+++ b/tools/fido2-cred.c
@@ -0,0 +1,52 @@
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 */
6
7/*
8 * Example usage:
9 *
10 * $ echo credential challenge | openssl sha256 -binary | base64 > cred_param
11 * $ echo relying party >> cred_param
12 * $ echo user name >> cred_param
13 * $ dd if=/dev/urandom bs=1 count=32 | base64 >> cred_param
14 * $ fido2-cred -M -i cred_param /dev/hidraw5 | fido2-cred -V -o cred
15 */
16
17#include <fido.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include "../openbsd-compat/openbsd-compat.h"
23#include "extern.h"
24
25void
26usage(void)
27{
28 fprintf(stderr,
29"usage: fido2-cred -M [-dhqruv] [-i input_file] [-o output_file] device [type]\n"
30" fido2-cred -V [-dhv] [-i input_file] [-o output_file] [type]\n"
31 );
32
33 exit(1);
34}
35
36int
37main(int argc, char **argv)
38{
39 if (argc < 2 || strlen(argv[1]) != 2 || argv[1][0] != '-')
40 usage();
41
42 switch (argv[1][1]) {
43 case 'M':
44 return (cred_make(--argc, ++argv));
45 case 'V':
46 return (cred_verify(--argc, ++argv));
47 }
48
49 usage();
50
51 /* NOTREACHED */
52}