blob: 9894e80b200f66dfefba5261ba8ac35060ebc4c5 [file] [log] [blame]
Sergii Dmytruk094a0512022-10-31 18:41:52 +02001/* 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 */
27tpm_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 */
32tpm_result_t tlcl1_set_enable(void);
33
34/**
35 * Issue a SetDeactivated. Pass 0 to activate. Returns result code.
36 */
37tpm_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 */
43tpm_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 */
48tpm_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 */
53tpm_result_t tlcl1_continue_self_test(void);
54
55/**
56 * Set the nvLocked bit. The TPM error code is returned.
57 */
58tpm_result_t tlcl1_set_nv_locked(void);
59
60/**
61 * Get the entire set of permanent flags.
62 */
63tpm_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 */
69tpm_result_t tlcl1_set_global_lock(void);
70
71/**
72 * Get the permission bits for the NVRAM space with |index|.
73 */
74tpm_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
81tpm_result_t tlcl1_save_state(void);
82tpm_result_t tlcl1_resume(void);
83tpm_result_t tlcl1_startup(void);
84tpm_result_t tlcl1_self_test_full(void);
85tpm_result_t tlcl1_read(uint32_t index, void *data, uint32_t length);
86tpm_result_t tlcl1_write(uint32_t index, const void *data, uint32_t length);
87tpm_result_t tlcl1_assert_physical_presence(void);
88tpm_result_t tlcl1_physical_presence_cmd_enable(void);
89tpm_result_t tlcl1_finalize_physical_presence(void);
90tpm_result_t tlcl1_force_clear(void);
91tpm_result_t tlcl1_extend(int pcr_num, const uint8_t *digest_data,
92 enum vb2_hash_algorithm digest_algo);
93
94#endif /* TSS1_H_ */