Path: blob/main/contrib/libfido2/tools/fido2-cred.c
39507 views
/*1* Copyright (c) 2018-2023 Yubico AB. All rights reserved.2* Use of this source code is governed by a BSD-style3* license that can be found in the LICENSE file.4* SPDX-License-Identifier: BSD-2-Clause5*/67/*8* Example usage:9*10* $ echo credential challenge | openssl sha256 -binary | base64 > cred_param11* $ echo relying party >> cred_param12* $ echo user name >> cred_param13* $ dd if=/dev/urandom bs=1 count=32 | base64 >> cred_param14* $ fido2-cred -M -i cred_param /dev/hidraw5 | fido2-cred -V -o cred15*/1617#include <fido.h>18#include <stdio.h>19#include <stdlib.h>20#include <string.h>2122#include "../openbsd-compat/openbsd-compat.h"23#include "extern.h"2425void26usage(void)27{28fprintf(stderr,29"usage: fido2-cred -M [-bdhqruvw] [-c cred_protect] [-i input_file] [-o output_file] device [type]\n"30" fido2-cred -V [-dhv] [-c cred_protect] [-i input_file] [-o output_file] [type]\n"31);3233exit(1);34}3536int37main(int argc, char **argv)38{39if (argc < 2 || strlen(argv[1]) != 2 || argv[1][0] != '-')40usage();4142switch (argv[1][1]) {43case 'M':44return (cred_make(--argc, ++argv));45case 'V':46return (cred_verify(--argc, ++argv));47}4849usage();5051/* NOTREACHED */52}535455