1 /* 2 * Copyright (c) 2019 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 #ifndef _FIDO_BIO_H 8 #define _FIDO_BIO_H 9 10 #include <stdint.h> 11 #include <stdlib.h> 12 13 #ifdef _FIDO_INTERNAL 14 #include "blob.h" 15 #include "fido/err.h" 16 #include "fido/param.h" 17 #include "fido/types.h" 18 #else 19 #include <fido.h> 20 #include <fido/err.h> 21 #include <fido/param.h> 22 #endif 23 24 #ifdef _FIDO_INTERNAL 25 struct fido_bio_template { 26 fido_blob_t id; 27 char *name; 28 }; 29 30 struct fido_bio_template_array { 31 struct fido_bio_template *ptr; 32 size_t n_alloc; /* number of allocated entries */ 33 size_t n_rx; /* number of populated entries */ 34 }; 35 36 struct fido_bio_enroll { 37 uint8_t remaining_samples; 38 uint8_t last_status; 39 fido_blob_t *token; 40 }; 41 42 struct fido_bio_info { 43 uint8_t type; 44 uint8_t max_samples; 45 }; 46 #endif 47 48 typedef struct fido_bio_template fido_bio_template_t; 49 typedef struct fido_bio_template_array fido_bio_template_array_t; 50 typedef struct fido_bio_enroll fido_bio_enroll_t; 51 typedef struct fido_bio_info fido_bio_info_t; 52 53 #define FIDO_BIO_ENROLL_FP_GOOD 0x00 54 #define FIDO_BIO_ENROLL_FP_TOO_HIGH 0x01 55 #define FIDO_BIO_ENROLL_FP_TOO_LOW 0x02 56 #define FIDO_BIO_ENROLL_FP_TOO_LEFT 0x03 57 #define FIDO_BIO_ENROLL_FP_TOO_RIGHT 0x04 58 #define FIDO_BIO_ENROLL_FP_TOO_FAST 0x05 59 #define FIDO_BIO_ENROLL_FP_TOO_SLOW 0x06 60 #define FIDO_BIO_ENROLL_FP_POOR_QUALITY 0x07 61 #define FIDO_BIO_ENROLL_FP_TOO_SKEWED 0x08 62 #define FIDO_BIO_ENROLL_FP_TOO_SHORT 0x09 63 #define FIDO_BIO_ENROLL_FP_MERGE_FAILURE 0x0a 64 #define FIDO_BIO_ENROLL_FP_EXISTS 0x0b 65 #define FIDO_BIO_ENROLL_FP_DATABASE_FULL 0x0c 66 #define FIDO_BIO_ENROLL_NO_USER_ACTIVITY 0x0d 67 #define FIDO_BIO_ENROLL_NO_USER_PRESENCE_TRANSITION 0x0e 68 69 const char *fido_bio_template_name(const fido_bio_template_t *); 70 const fido_bio_template_t *fido_bio_template(const fido_bio_template_array_t *, 71 size_t); 72 const unsigned char *fido_bio_template_id_ptr(const fido_bio_template_t *); 73 fido_bio_enroll_t *fido_bio_enroll_new(void); 74 fido_bio_info_t *fido_bio_info_new(void); 75 fido_bio_template_array_t *fido_bio_template_array_new(void); 76 fido_bio_template_t *fido_bio_template_new(void); 77 int fido_bio_dev_enroll_begin(fido_dev_t *, fido_bio_template_t *, 78 fido_bio_enroll_t *, uint32_t, const char *); 79 int fido_bio_dev_enroll_cancel(fido_dev_t *); 80 int fido_bio_dev_enroll_continue(fido_dev_t *, const fido_bio_template_t *, 81 fido_bio_enroll_t *, uint32_t); 82 int fido_bio_dev_enroll_remove(fido_dev_t *, const fido_bio_template_t *, 83 const char *); 84 int fido_bio_dev_get_info(fido_dev_t *, fido_bio_info_t *); 85 int fido_bio_dev_get_template_array(fido_dev_t *, fido_bio_template_array_t *, 86 const char *); 87 int fido_bio_dev_set_template_name(fido_dev_t *, const fido_bio_template_t *, 88 const char *); 89 int fido_bio_template_set_id(fido_bio_template_t *, const unsigned char *, 90 size_t); 91 int fido_bio_template_set_name(fido_bio_template_t *, const char *); 92 size_t fido_bio_template_array_count(const fido_bio_template_array_t *); 93 size_t fido_bio_template_id_len(const fido_bio_template_t *); 94 uint8_t fido_bio_enroll_last_status(const fido_bio_enroll_t *); 95 uint8_t fido_bio_enroll_remaining_samples(const fido_bio_enroll_t *); 96 uint8_t fido_bio_info_max_samples(const fido_bio_info_t *); 97 uint8_t fido_bio_info_type(const fido_bio_info_t *); 98 void fido_bio_enroll_free(fido_bio_enroll_t **); 99 void fido_bio_info_free(fido_bio_info_t **); 100 void fido_bio_template_array_free(fido_bio_template_array_t **); 101 void fido_bio_template_free(fido_bio_template_t **); 102 103 #endif /* !_FIDO_BIO_H */ 104