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 "log.h"
8 #include "time-util.h"
9 
10 #if HAVE_P11KIT
11 
12 int decrypt_pkcs11_key(
13                 const char *volume_name,
14                 const char *friendly_name,
15                 const char *pkcs11_uri,
16                 const char *key_file,
17                 size_t key_file_size,
18                 uint64_t key_file_offset,
19                 const void *key_data,
20                 size_t key_data_size,
21                 usec_t until,
22                 bool headless,
23                 void **ret_decrypted_key,
24                 size_t *ret_decrypted_key_size);
25 
26 int find_pkcs11_auto_data(
27                 struct crypt_device *cd,
28                 char **ret_uri,
29                 void **ret_encrypted_key,
30                 size_t *ret_encrypted_key_size,
31                 int *ret_keyslot);
32 
33 #else
34 
decrypt_pkcs11_key(const char * volume_name,const char * friendly_name,const char * pkcs11_uri,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,void ** ret_decrypted_key,size_t * ret_decrypted_key_size)35 static inline int decrypt_pkcs11_key(
36                 const char *volume_name,
37                 const char *friendly_name,
38                 const char *pkcs11_uri,
39                 const char *key_file,
40                 size_t key_file_size,
41                 uint64_t key_file_offset,
42                 const void *key_data,
43                 size_t key_data_size,
44                 usec_t until,
45                 bool headless,
46                 void **ret_decrypted_key,
47                 size_t *ret_decrypted_key_size) {
48 
49         return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
50                                "PKCS#11 Token support not available.");
51 }
52 
find_pkcs11_auto_data(struct crypt_device * cd,char ** ret_uri,void ** ret_encrypted_key,size_t * ret_encrypted_key_size,int * ret_keyslot)53 static inline int find_pkcs11_auto_data(
54                 struct crypt_device *cd,
55                 char **ret_uri,
56                 void **ret_encrypted_key,
57                 size_t *ret_encrypted_key_size,
58                 int *ret_keyslot) {
59 
60         return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
61                                "PKCS#11 Token support not available.");
62 }
63 
64 #endif
65