aboutsummaryrefslogtreecommitdiff
path: root/src/security/tpm/tss2.h
blob: 16ccf5db6fbff80ea15687e56238643603180c1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* SPDX-License-Identifier: BSD-3-Clause */

#ifndef TSS2_H_
#define TSS2_H_

#include <types.h>
#include <vb2_sha.h>

#include <security/tpm/tss/tcg-2.0/tss_structures.h>
#include <security/tpm/tss_errors.h>

/*
 * TPM2-specific
 *
 * Some operations don't have counterparts in standard and are directly exposed
 * here.
 *
 * Other operations are applicable to both TPM versions and have wrappers which
 * pick the implementation based on version determined during initialization via
 * tlcl_lib_init().
 */

/*
 * Define a TPM2 space. The define space command TPM command used by the tlcl
 * layer offers the ability to use custom nv attributes and policies.
 */
tpm_result_t tlcl2_define_space(uint32_t space_index, size_t space_size,
				const TPMA_NV nv_attributes,
				const uint8_t *nv_policy, size_t nv_policy_size);

/*
 * Issue TPM2_GetCapability command
 */
tpm_result_t tlcl2_get_capability(TPM_CAP capability, uint32_t property,
				  uint32_t property_count,
				  TPMS_CAPABILITY_DATA *capability_data);

/* Issue TPM2_NV_SetBits command */
tpm_result_t tlcl2_set_bits(uint32_t index, uint64_t bits);

/*
 * Makes tlcl2_process_command available for on top implementations of
 * custom tpm standards like cr50
 */
void *tlcl2_process_command(TPM_CC command, void *command_body);

/* Return digest size of hash algorithm */
uint16_t tlcl2_get_hash_size_from_algo(TPMI_ALG_HASH hash_algo);

/**
 * Set Clear Control. The TPM error code is returned.
 */
tpm_result_t tlcl2_clear_control(bool disable);

/**
 * Make an NV Ram location read_only.  The TPM error code is returned.
 */
tpm_result_t tlcl2_lock_nv_write(uint32_t index);

/**
 * Disable platform hierarchy. Specific to TPM2. The TPM error code is returned.
 */
tpm_result_t tlcl2_disable_platform_hierarchy(void);

/*
 * Declarations for "private" functions which are dispatched to by tss/tss.c
 * based on TPM family.
 */

tpm_result_t tlcl2_save_state(void);
tpm_result_t tlcl2_resume(void);
tpm_result_t tlcl2_startup(void);
tpm_result_t tlcl2_self_test_full(void);
tpm_result_t tlcl2_read(uint32_t index, void *data, uint32_t length);
tpm_result_t tlcl2_write(uint32_t index, const void *data, uint32_t length);
tpm_result_t tlcl2_assert_physical_presence(void);
tpm_result_t tlcl2_physical_presence_cmd_enable(void);
tpm_result_t tlcl2_finalize_physical_presence(void);
tpm_result_t tlcl2_force_clear(void);
tpm_result_t tlcl2_extend(int pcr_num, const uint8_t *digest_data,
			  enum vb2_hash_algorithm digest_algo);

#endif /* TSS2_H_ */