Sergii Dmytruk | 094a051 | 2022-10-31 18:41:52 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | |
| 3 | #ifndef TSS1_H_ |
| 4 | #define TSS1_H_ |
| 5 | |
| 6 | #include <types.h> |
| 7 | #include <vb2_sha.h> |
| 8 | |
| 9 | #include <security/tpm/tss/tcg-1.2/tss_structures.h> |
| 10 | #include <security/tpm/tss_errors.h> |
| 11 | |
| 12 | /* |
| 13 | * TPM1.2-specific |
| 14 | * |
| 15 | * Some operations don't have counterparts in standard and are directly exposed |
| 16 | * here. |
| 17 | * |
| 18 | * Other operations are applicable to both TPM versions and have wrappers which |
| 19 | * pick the implementation based on version determined during initialization via |
| 20 | * tlcl_lib_init(). |
| 21 | */ |
| 22 | |
| 23 | /** |
| 24 | * Define a space with permission [perm]. [index] is the index for the space, |
| 25 | * [size] the usable data size. The TPM error code is returned. |
| 26 | */ |
| 27 | tpm_result_t tlcl1_define_space(uint32_t index, uint32_t perm, uint32_t size); |
| 28 | |
| 29 | /** |
| 30 | * Issue a PhysicalEnable. The TPM error code is returned. |
| 31 | */ |
| 32 | tpm_result_t tlcl1_set_enable(void); |
| 33 | |
| 34 | /** |
| 35 | * Issue a SetDeactivated. Pass 0 to activate. Returns result code. |
| 36 | */ |
| 37 | tpm_result_t tlcl1_set_deactivated(uint8_t flag); |
| 38 | |
| 39 | /** |
| 40 | * Get flags of interest. Pointers for flags you aren't interested in may |
| 41 | * be NULL. The TPM error code is returned. |
| 42 | */ |
| 43 | tpm_result_t tlcl1_get_flags(uint8_t *disable, uint8_t *deactivated, uint8_t *nvlocked); |
| 44 | |
| 45 | /** |
| 46 | * Perform a raw TPM request/response transaction. |
| 47 | */ |
| 48 | tpm_result_t tlcl1_send_receive(const uint8_t *request, uint8_t *response, int max_length); |
| 49 | |
| 50 | /** |
| 51 | * Run the self test in the background. |
| 52 | */ |
| 53 | tpm_result_t tlcl1_continue_self_test(void); |
| 54 | |
| 55 | /** |
| 56 | * Set the nvLocked bit. The TPM error code is returned. |
| 57 | */ |
| 58 | tpm_result_t tlcl1_set_nv_locked(void); |
| 59 | |
| 60 | /** |
| 61 | * Get the entire set of permanent flags. |
| 62 | */ |
| 63 | tpm_result_t tlcl1_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags); |
| 64 | |
| 65 | /** |
| 66 | * Set the bGlobalLock flag, which only a reboot can clear. The TPM error |
| 67 | * code is returned. |
| 68 | */ |
| 69 | tpm_result_t tlcl1_set_global_lock(void); |
| 70 | |
| 71 | /** |
| 72 | * Get the permission bits for the NVRAM space with |index|. |
| 73 | */ |
| 74 | tpm_result_t tlcl1_get_permissions(uint32_t index, uint32_t *permissions); |
| 75 | |
| 76 | /* |
| 77 | * Declarations for "private" functions which are dispatched to by tss/tss.c |
| 78 | * based on TPM family. |
| 79 | */ |
| 80 | |
| 81 | tpm_result_t tlcl1_save_state(void); |
| 82 | tpm_result_t tlcl1_resume(void); |
| 83 | tpm_result_t tlcl1_startup(void); |
| 84 | tpm_result_t tlcl1_self_test_full(void); |
| 85 | tpm_result_t tlcl1_read(uint32_t index, void *data, uint32_t length); |
| 86 | tpm_result_t tlcl1_write(uint32_t index, const void *data, uint32_t length); |
| 87 | tpm_result_t tlcl1_assert_physical_presence(void); |
| 88 | tpm_result_t tlcl1_physical_presence_cmd_enable(void); |
| 89 | tpm_result_t tlcl1_finalize_physical_presence(void); |
| 90 | tpm_result_t tlcl1_force_clear(void); |
| 91 | tpm_result_t tlcl1_extend(int pcr_num, const uint8_t *digest_data, |
| 92 | enum vb2_hash_algorithm digest_algo); |
| 93 | |
| 94 | #endif /* TSS1_H_ */ |