1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/types.h>
5
6 #include "cryptsetup-util.h"
7 #include "libfido2-util.h"
8 #include "log.h"
9 #include "time-util.h"
10
11 #if HAVE_LIBFIDO2
12
13 int acquire_fido2_key(
14 const char *volume_name,
15 const char *friendly_name,
16 const char *device,
17 const char *rp_id,
18 const void *cid,
19 size_t cid_size,
20 const char *key_file,
21 size_t key_file_size,
22 uint64_t key_file_offset,
23 const void *key_data,
24 size_t key_data_size,
25 usec_t until,
26 bool headless,
27 Fido2EnrollFlags required,
28 void **ret_decrypted_key,
29 size_t *ret_decrypted_key_size,
30 AskPasswordFlags ask_password_flags);
31
32 int find_fido2_auto_data(
33 struct crypt_device *cd,
34 char **ret_rp_id,
35 void **ret_salt,
36 size_t *ret_salt_size,
37 void **ret_cid,
38 size_t *ret_cid_size,
39 int *ret_keyslot,
40 Fido2EnrollFlags *ret_required);
41
42 #else
43
acquire_fido2_key(const char * volume_name,const char * friendly_name,const char * device,const char * rp_id,const void * cid,size_t cid_size,const char * key_file,size_t key_file_size,uint64_t key_file_offset,const void * key_data,size_t key_data_size,usec_t until,bool headless,Fido2EnrollFlags required,void ** ret_decrypted_key,size_t * ret_decrypted_key_size,AskPasswordFlags ask_password_flags)44 static inline int acquire_fido2_key(
45 const char *volume_name,
46 const char *friendly_name,
47 const char *device,
48 const char *rp_id,
49 const void *cid,
50 size_t cid_size,
51 const char *key_file,
52 size_t key_file_size,
53 uint64_t key_file_offset,
54 const void *key_data,
55 size_t key_data_size,
56 usec_t until,
57 bool headless,
58 Fido2EnrollFlags required,
59 void **ret_decrypted_key,
60 size_t *ret_decrypted_key_size,
61 AskPasswordFlags ask_password_flags) {
62
63 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
64 "FIDO2 token support not available.");
65 }
66
find_fido2_auto_data(struct crypt_device * cd,char ** ret_rp_id,void ** ret_salt,size_t * ret_salt_size,void ** ret_cid,size_t * ret_cid_size,int * ret_keyslot,Fido2EnrollFlags * ret_required)67 static inline int find_fido2_auto_data(
68 struct crypt_device *cd,
69 char **ret_rp_id,
70 void **ret_salt,
71 size_t *ret_salt_size,
72 void **ret_cid,
73 size_t *ret_cid_size,
74 int *ret_keyslot,
75 Fido2EnrollFlags *ret_required) {
76
77 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
78 "FIDO2 token support not available.");
79 }
80 #endif
81