1/* 2 * Copyright (c) 2019 Yubico AB. All rights reserved. 3 * SPDX-License-Identifier: BSD-2-Clause 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#ifndef _FIDO_BIO_H 30#define _FIDO_BIO_H 31 32#include <stdint.h> 33#include <stdlib.h> 34 35#ifdef _FIDO_INTERNAL 36#include "blob.h" 37#include "fido/err.h" 38#include "fido/param.h" 39#include "fido/types.h" 40#else 41#include <fido.h> 42#include <fido/err.h> 43#include <fido/param.h> 44#endif 45 46#ifdef __cplusplus 47extern "C" { 48#endif /* __cplusplus */ 49 50#ifdef _FIDO_INTERNAL 51struct fido_bio_template { 52 fido_blob_t id; 53 char *name; 54}; 55 56struct fido_bio_template_array { 57 struct fido_bio_template *ptr; 58 size_t n_alloc; /* number of allocated entries */ 59 size_t n_rx; /* number of populated entries */ 60}; 61 62struct fido_bio_enroll { 63 uint8_t remaining_samples; 64 uint8_t last_status; 65 fido_blob_t *token; 66}; 67 68struct fido_bio_info { 69 uint8_t type; 70 uint8_t max_samples; 71}; 72#endif 73 74typedef struct fido_bio_template fido_bio_template_t; 75typedef struct fido_bio_template_array fido_bio_template_array_t; 76typedef struct fido_bio_enroll fido_bio_enroll_t; 77typedef struct fido_bio_info fido_bio_info_t; 78 79#define FIDO_BIO_ENROLL_FP_GOOD 0x00 80#define FIDO_BIO_ENROLL_FP_TOO_HIGH 0x01 81#define FIDO_BIO_ENROLL_FP_TOO_LOW 0x02 82#define FIDO_BIO_ENROLL_FP_TOO_LEFT 0x03 83#define FIDO_BIO_ENROLL_FP_TOO_RIGHT 0x04 84#define FIDO_BIO_ENROLL_FP_TOO_FAST 0x05 85#define FIDO_BIO_ENROLL_FP_TOO_SLOW 0x06 86#define FIDO_BIO_ENROLL_FP_POOR_QUALITY 0x07 87#define FIDO_BIO_ENROLL_FP_TOO_SKEWED 0x08 88#define FIDO_BIO_ENROLL_FP_TOO_SHORT 0x09 89#define FIDO_BIO_ENROLL_FP_MERGE_FAILURE 0x0a 90#define FIDO_BIO_ENROLL_FP_EXISTS 0x0b 91#define FIDO_BIO_ENROLL_FP_DATABASE_FULL 0x0c 92#define FIDO_BIO_ENROLL_NO_USER_ACTIVITY 0x0d 93#define FIDO_BIO_ENROLL_NO_USER_PRESENCE_TRANSITION 0x0e 94 95const char *fido_bio_template_name(const fido_bio_template_t *); 96const fido_bio_template_t *fido_bio_template(const fido_bio_template_array_t *, 97 size_t); 98const unsigned char *fido_bio_template_id_ptr(const fido_bio_template_t *); 99fido_bio_enroll_t *fido_bio_enroll_new(void); 100fido_bio_info_t *fido_bio_info_new(void); 101fido_bio_template_array_t *fido_bio_template_array_new(void); 102fido_bio_template_t *fido_bio_template_new(void); 103int fido_bio_dev_enroll_begin(fido_dev_t *, fido_bio_template_t *, 104 fido_bio_enroll_t *, uint32_t, const char *); 105int fido_bio_dev_enroll_cancel(fido_dev_t *); 106int fido_bio_dev_enroll_continue(fido_dev_t *, const fido_bio_template_t *, 107 fido_bio_enroll_t *, uint32_t); 108int fido_bio_dev_enroll_remove(fido_dev_t *, const fido_bio_template_t *, 109 const char *); 110int fido_bio_dev_get_info(fido_dev_t *, fido_bio_info_t *); 111int fido_bio_dev_get_template_array(fido_dev_t *, fido_bio_template_array_t *, 112 const char *); 113int fido_bio_dev_set_template_name(fido_dev_t *, const fido_bio_template_t *, 114 const char *); 115int fido_bio_template_set_id(fido_bio_template_t *, const unsigned char *, 116 size_t); 117int fido_bio_template_set_name(fido_bio_template_t *, const char *); 118size_t fido_bio_template_array_count(const fido_bio_template_array_t *); 119size_t fido_bio_template_id_len(const fido_bio_template_t *); 120uint8_t fido_bio_enroll_last_status(const fido_bio_enroll_t *); 121uint8_t fido_bio_enroll_remaining_samples(const fido_bio_enroll_t *); 122uint8_t fido_bio_info_max_samples(const fido_bio_info_t *); 123uint8_t fido_bio_info_type(const fido_bio_info_t *); 124void fido_bio_enroll_free(fido_bio_enroll_t **); 125void fido_bio_info_free(fido_bio_info_t **); 126void fido_bio_template_array_free(fido_bio_template_array_t **); 127void fido_bio_template_free(fido_bio_template_t **); 128 129#ifdef __cplusplus 130} /* extern "C" */ 131#endif /* __cplusplus */ 132 133#endif /* !_FIDO_BIO_H */ 134