1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 #define FIDO2_SALT_SIZE 32U
8 typedef enum Fido2EnrollFlags
{
9 FIDO2ENROLL_PIN
= 1 << 0,
10 FIDO2ENROLL_UP
= 1 << 1, /* User presence (ie: touching token) */
11 FIDO2ENROLL_UV
= 1 << 2, /* User verification (ie: fingerprint) */
12 FIDO2ENROLL_PIN_IF_NEEDED
= 1 << 3, /* If auth doesn't work without PIN ask for one, as in systemd 248 */
13 FIDO2ENROLL_UP_IF_NEEDED
= 1 << 4, /* If auth doesn't work without UP, enable it, as in systemd 248 */
14 FIDO2ENROLL_UV_OMIT
= 1 << 5, /* Leave "uv" untouched, as in systemd 248 */
15 _FIDO2ENROLL_TYPE_MAX
,
16 _FIDO2ENROLL_TYPE_INVALID
= -EINVAL
,
22 #include "dlfcn-util.h"
24 extern DLSYM_PROTOTYPE(fido_assert_allow_cred
);
25 extern DLSYM_PROTOTYPE(fido_assert_free
);
26 extern DLSYM_PROTOTYPE(fido_assert_hmac_secret_len
);
27 extern DLSYM_PROTOTYPE(fido_assert_hmac_secret_ptr
);
28 extern DLSYM_PROTOTYPE(fido_assert_new
);
29 extern DLSYM_PROTOTYPE(fido_assert_set_clientdata_hash
);
30 extern DLSYM_PROTOTYPE(fido_assert_set_extensions
);
31 extern DLSYM_PROTOTYPE(fido_assert_set_hmac_salt
);
32 extern DLSYM_PROTOTYPE(fido_assert_set_rp
);
33 extern DLSYM_PROTOTYPE(fido_assert_set_up
);
34 extern DLSYM_PROTOTYPE(fido_assert_set_uv
);
35 extern DLSYM_PROTOTYPE(fido_cbor_info_extensions_len
);
36 extern DLSYM_PROTOTYPE(fido_cbor_info_extensions_ptr
);
37 extern DLSYM_PROTOTYPE(fido_cbor_info_free
);
38 extern DLSYM_PROTOTYPE(fido_cbor_info_new
);
39 extern DLSYM_PROTOTYPE(fido_cbor_info_options_len
);
40 extern DLSYM_PROTOTYPE(fido_cbor_info_options_name_ptr
);
41 extern DLSYM_PROTOTYPE(fido_cbor_info_options_value_ptr
);
42 extern DLSYM_PROTOTYPE(fido_cred_free
);
43 extern DLSYM_PROTOTYPE(fido_cred_id_len
);
44 extern DLSYM_PROTOTYPE(fido_cred_id_ptr
);
45 extern DLSYM_PROTOTYPE(fido_cred_new
);
46 extern DLSYM_PROTOTYPE(fido_cred_set_clientdata_hash
);
47 extern DLSYM_PROTOTYPE(fido_cred_set_extensions
);
48 extern DLSYM_PROTOTYPE(fido_cred_set_prot
);
49 extern DLSYM_PROTOTYPE(fido_cred_set_rk
);
50 extern DLSYM_PROTOTYPE(fido_cred_set_rp
);
51 extern DLSYM_PROTOTYPE(fido_cred_set_type
);
52 extern DLSYM_PROTOTYPE(fido_cred_set_user
);
53 extern DLSYM_PROTOTYPE(fido_cred_set_uv
);
54 extern DLSYM_PROTOTYPE(fido_dev_close
);
55 extern DLSYM_PROTOTYPE(fido_dev_free
);
56 extern DLSYM_PROTOTYPE(fido_dev_get_assert
);
57 extern DLSYM_PROTOTYPE(fido_dev_get_cbor_info
);
58 extern DLSYM_PROTOTYPE(fido_dev_info_free
);
59 extern DLSYM_PROTOTYPE(fido_dev_info_manifest
);
60 extern DLSYM_PROTOTYPE(fido_dev_info_manufacturer_string
);
61 extern DLSYM_PROTOTYPE(fido_dev_info_new
);
62 extern DLSYM_PROTOTYPE(fido_dev_info_path
);
63 extern DLSYM_PROTOTYPE(fido_dev_info_product_string
);
64 extern DLSYM_PROTOTYPE(fido_dev_info_ptr
);
65 extern DLSYM_PROTOTYPE(fido_dev_is_fido2
);
66 extern DLSYM_PROTOTYPE(fido_dev_make_cred
);
67 extern DLSYM_PROTOTYPE(fido_dev_new
);
68 extern DLSYM_PROTOTYPE(fido_dev_open
);
69 extern DLSYM_PROTOTYPE(fido_init
);
70 extern DLSYM_PROTOTYPE(fido_set_log_handler
);
71 extern DLSYM_PROTOTYPE(fido_strerr
);
73 int dlopen_libfido2(void);
75 static inline void fido_cbor_info_free_wrapper(fido_cbor_info_t
**p
) {
77 sym_fido_cbor_info_free(p
);
80 static inline void fido_assert_free_wrapper(fido_assert_t
**p
) {
82 sym_fido_assert_free(p
);
85 static inline void fido_dev_free_wrapper(fido_dev_t
**p
) {
87 sym_fido_dev_close(*p
);
92 static inline void fido_cred_free_wrapper(fido_cred_t
**p
) {
94 sym_fido_cred_free(p
);
97 int fido2_use_hmac_hash(
105 Fido2EnrollFlags required
,
107 size_t *ret_hmac_size
);
109 int fido2_generate_hmac_hash(
113 const void *user_id
, size_t user_id_len
,
114 const char *user_name
,
115 const char *user_display_name
,
116 const char *user_icon
,
117 const char *askpw_icon
,
118 const char *askpw_credential
,
119 Fido2EnrollFlags lock_with
,
121 const struct iovec
*salt
,
122 void **ret_cid
, size_t *ret_cid_size
,
123 void **ret_secret
, size_t *ret_secret_size
,
125 Fido2EnrollFlags
*ret_locked_with
);
127 int parse_fido2_algorithm(const char *s
, int *ret
);
129 static inline int parse_fido2_algorithm(const char *s
, int *ret
) {
134 int fido2_list_devices(void);
135 int fido2_find_device_auto(char **ret
);
137 int fido2_have_device(const char *device
);