xref: /freebsd/contrib/libfido2/src/fido/bio.h (revision 1323ec57)
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 __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
28 #ifdef _FIDO_INTERNAL
29 struct fido_bio_template {
30 	fido_blob_t id;
31 	char *name;
32 };
33 
34 struct fido_bio_template_array {
35 	struct fido_bio_template *ptr;
36 	size_t n_alloc; /* number of allocated entries */
37 	size_t n_rx;    /* number of populated entries */
38 };
39 
40 struct fido_bio_enroll {
41 	uint8_t remaining_samples;
42 	uint8_t last_status;
43 	fido_blob_t *token;
44 };
45 
46 struct fido_bio_info {
47 	uint8_t type;
48 	uint8_t max_samples;
49 };
50 #endif
51 
52 typedef struct fido_bio_template fido_bio_template_t;
53 typedef struct fido_bio_template_array fido_bio_template_array_t;
54 typedef struct fido_bio_enroll fido_bio_enroll_t;
55 typedef struct fido_bio_info fido_bio_info_t;
56 
57 #define FIDO_BIO_ENROLL_FP_GOOD				0x00
58 #define FIDO_BIO_ENROLL_FP_TOO_HIGH			0x01
59 #define FIDO_BIO_ENROLL_FP_TOO_LOW			0x02
60 #define FIDO_BIO_ENROLL_FP_TOO_LEFT			0x03
61 #define FIDO_BIO_ENROLL_FP_TOO_RIGHT			0x04
62 #define FIDO_BIO_ENROLL_FP_TOO_FAST			0x05
63 #define FIDO_BIO_ENROLL_FP_TOO_SLOW			0x06
64 #define FIDO_BIO_ENROLL_FP_POOR_QUALITY			0x07
65 #define FIDO_BIO_ENROLL_FP_TOO_SKEWED			0x08
66 #define FIDO_BIO_ENROLL_FP_TOO_SHORT			0x09
67 #define FIDO_BIO_ENROLL_FP_MERGE_FAILURE		0x0a
68 #define FIDO_BIO_ENROLL_FP_EXISTS			0x0b
69 #define FIDO_BIO_ENROLL_FP_DATABASE_FULL		0x0c
70 #define FIDO_BIO_ENROLL_NO_USER_ACTIVITY		0x0d
71 #define FIDO_BIO_ENROLL_NO_USER_PRESENCE_TRANSITION	0x0e
72 
73 const char *fido_bio_template_name(const fido_bio_template_t *);
74 const fido_bio_template_t *fido_bio_template(const fido_bio_template_array_t *,
75     size_t);
76 const unsigned char *fido_bio_template_id_ptr(const fido_bio_template_t *);
77 fido_bio_enroll_t *fido_bio_enroll_new(void);
78 fido_bio_info_t *fido_bio_info_new(void);
79 fido_bio_template_array_t *fido_bio_template_array_new(void);
80 fido_bio_template_t *fido_bio_template_new(void);
81 int fido_bio_dev_enroll_begin(fido_dev_t *, fido_bio_template_t *,
82     fido_bio_enroll_t *, uint32_t, const char *);
83 int fido_bio_dev_enroll_cancel(fido_dev_t *);
84 int fido_bio_dev_enroll_continue(fido_dev_t *, const fido_bio_template_t *,
85     fido_bio_enroll_t *, uint32_t);
86 int fido_bio_dev_enroll_remove(fido_dev_t *, const fido_bio_template_t *,
87     const char *);
88 int fido_bio_dev_get_info(fido_dev_t *, fido_bio_info_t *);
89 int fido_bio_dev_get_template_array(fido_dev_t *, fido_bio_template_array_t *,
90     const char *);
91 int fido_bio_dev_set_template_name(fido_dev_t *, const fido_bio_template_t *,
92     const char *);
93 int fido_bio_template_set_id(fido_bio_template_t *, const unsigned char *,
94     size_t);
95 int fido_bio_template_set_name(fido_bio_template_t *, const char *);
96 size_t fido_bio_template_array_count(const fido_bio_template_array_t *);
97 size_t fido_bio_template_id_len(const fido_bio_template_t *);
98 uint8_t fido_bio_enroll_last_status(const fido_bio_enroll_t *);
99 uint8_t fido_bio_enroll_remaining_samples(const fido_bio_enroll_t *);
100 uint8_t fido_bio_info_max_samples(const fido_bio_info_t *);
101 uint8_t fido_bio_info_type(const fido_bio_info_t *);
102 void fido_bio_enroll_free(fido_bio_enroll_t **);
103 void fido_bio_info_free(fido_bio_info_t **);
104 void fido_bio_template_array_free(fido_bio_template_array_t **);
105 void fido_bio_template_free(fido_bio_template_t **);
106 
107 #ifdef __cplusplus
108 } /* extern "C" */
109 #endif /* __cplusplus */
110 
111 #endif /* !_FIDO_BIO_H */
112