| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifndef TSS_H_ |
| 10 |
#define TSS_H_ |
| 11 |
|
| 12 |
#include <types.h> |
| 13 |
#include <vb2_sha.h> |
| 14 |
|
| 15 |
#include <security/tpm/tis.h> |
| 16 |
#include <security/tpm/tss_errors.h> |
| 17 |
#include <security/tpm/tss/vendor/cr50/cr50.h> |
| 18 |
#include <security/tpm/tss/tcg-1.2/tss_structures.h> |
| 19 |
#include <security/tpm/tss/tcg-2.0/tss_structures.h> |
| 20 |
#include <security/tpm/tss1.h> |
| 21 |
#include <security/tpm/tss2.h> |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
tpm_result_t tlcl_lib_init(void); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
static inline enum tpm_family tlcl_get_family(void) |
| 40 |
{ |
| 41 |
|
| 42 |
extern enum tpm_family tlcl_tpm_family; |
| 43 |
|
| 44 |
if (CONFIG(TPM1) && CONFIG(TPM2)) |
| 45 |
return tlcl_tpm_family; |
| 46 |
if (CONFIG(TPM1)) |
| 47 |
return TPM_1; |
| 48 |
if (CONFIG(TPM2)) |
| 49 |
return TPM_2; |
| 50 |
return TPM_UNKNOWN; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
#define TLCL_CALL(name, ...) do { \ |
| 56 |
if (tlcl_get_family() == TPM_1) \ |
| 57 |
return tlcl1_##name(__VA_ARGS__); \ |
| 58 |
if (tlcl_get_family() == TPM_2) \ |
| 59 |
return tlcl2_##name(__VA_ARGS__); \ |
| 60 |
return TPM_CB_INTERNAL_INCONSISTENCY; \ |
| 61 |
} while (0) |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
static inline tpm_result_t tlcl_startup(void) |
| 68 |
{ |
| 69 |
TLCL_CALL(startup); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
static inline tpm_result_t tlcl_resume(void) |
| 77 |
{ |
| 78 |
TLCL_CALL(resume); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
static inline tpm_result_t tlcl_save_state(void) |
| 87 |
{ |
| 88 |
TLCL_CALL(save_state); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
static inline tpm_result_t tlcl_self_test_full(void) |
| 98 |
{ |
| 99 |
TLCL_CALL(self_test_full); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
static inline tpm_result_t tlcl_write(uint32_t index, const void *data, uint32_t length) |
| 107 |
{ |
| 108 |
TLCL_CALL(write, index, data, length); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
static inline tpm_result_t tlcl_read(uint32_t index, void *data, uint32_t length) |
| 116 |
{ |
| 117 |
TLCL_CALL(read, index, data, length); |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
static inline tpm_result_t tlcl_assert_physical_presence(void) |
| 124 |
{ |
| 125 |
TLCL_CALL(assert_physical_presence); |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
static inline tpm_result_t tlcl_physical_presence_cmd_enable(void) |
| 132 |
{ |
| 133 |
TLCL_CALL(physical_presence_cmd_enable); |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
static inline tpm_result_t tlcl_finalize_physical_presence(void) |
| 141 |
{ |
| 142 |
TLCL_CALL(finalize_physical_presence); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
static inline tpm_result_t tlcl_force_clear(void) |
| 149 |
{ |
| 150 |
TLCL_CALL(force_clear); |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
static inline tpm_result_t tlcl_extend(int pcr_num, const uint8_t *digest_data, |
| 157 |
enum vb2_hash_algorithm digest_algo) |
| 158 |
{ |
| 159 |
TLCL_CALL(extend, pcr_num, digest_data, digest_algo); |
| 160 |
} |
| 161 |
|
| 162 |
extern tis_sendrecv_fn tlcl_tis_sendrecv; |
| 163 |
|
| 164 |
#endif |