1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/types.h>
5
6 #include "ask-password-api.h"
7 #include "cryptsetup-util.h"
8 #include "log.h"
9 #include "time-util.h"
10 #include "tpm2-util.h"
11
12 #if HAVE_TPM2
13
14 int acquire_tpm2_key(
15 const char *volume_name,
16 const char *device,
17 uint32_t pcr_mask,
18 uint16_t pcr_bank,
19 uint16_t primary_alg,
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 const void *policy_hash,
26 size_t policy_hash_size,
27 TPM2Flags flags,
28 usec_t until,
29 bool headless,
30 AskPasswordFlags ask_password_flags,
31 void **ret_decrypted_key,
32 size_t *ret_decrypted_key_size);
33
34 int find_tpm2_auto_data(
35 struct crypt_device *cd,
36 uint32_t search_pcr_mask,
37 int start_token,
38 uint32_t *ret_pcr_mask,
39 uint16_t *ret_pcr_bank,
40 uint16_t *ret_primary_alg,
41 void **ret_blob,
42 size_t *ret_blob_size,
43 void **ret_policy_hash,
44 size_t *ret_policy_hash_size,
45 int *ret_keyslot,
46 int *ret_token,
47 TPM2Flags *ret_flags);
48
49 #else
50
acquire_tpm2_key(const char * volume_name,const char * device,uint32_t pcr_mask,uint16_t pcr_bank,uint16_t primary_alg,const char * key_file,size_t key_file_size,uint64_t key_file_offset,const void * key_data,size_t key_data_size,const void * policy_hash,size_t policy_hash_size,TPM2Flags flags,usec_t until,bool headless,AskPasswordFlags ask_password_flags,void ** ret_decrypted_key,size_t * ret_decrypted_key_size)51 static inline int acquire_tpm2_key(
52 const char *volume_name,
53 const char *device,
54 uint32_t pcr_mask,
55 uint16_t pcr_bank,
56 uint16_t primary_alg,
57 const char *key_file,
58 size_t key_file_size,
59 uint64_t key_file_offset,
60 const void *key_data,
61 size_t key_data_size,
62 const void *policy_hash,
63 size_t policy_hash_size,
64 TPM2Flags flags,
65 usec_t until,
66 bool headless,
67 AskPasswordFlags ask_password_flags,
68 void **ret_decrypted_key,
69 size_t *ret_decrypted_key_size) {
70
71 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
72 "TPM2 support not available.");
73 }
74
find_tpm2_auto_data(struct crypt_device * cd,uint32_t search_pcr_mask,int start_token,uint32_t * ret_pcr_mask,uint16_t * ret_pcr_bank,uint16_t * ret_primary_alg,void ** ret_blob,size_t * ret_blob_size,void ** ret_policy_hash,size_t * ret_policy_hash_size,int * ret_keyslot,int * ret_token,TPM2Flags * ret_flags)75 static inline int find_tpm2_auto_data(
76 struct crypt_device *cd,
77 uint32_t search_pcr_mask,
78 int start_token,
79 uint32_t *ret_pcr_mask,
80 uint16_t *ret_pcr_bank,
81 uint16_t *ret_primary_alg,
82 void **ret_blob,
83 size_t *ret_blob_size,
84 void **ret_policy_hash,
85 size_t *ret_policy_hash_size,
86 int *ret_keyslot,
87 int *ret_token,
88 TPM2Flags *ret_flags) {
89
90 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
91 "TPM2 support not available.");
92 }
93
94 #endif
95