coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
secdata_mock.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 /*
4  * Functions for querying, manipulating and locking rollback indices
5  * stored in the TPM NVRAM.
6  */
7 
8 #include <security/tpm/tspi.h>
9 #include <vb2_api.h>
10 
11 #include "antirollback.h"
12 
13 vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx)
14 {
15  return VB2_SUCCESS;
16 }
17 
18 vb2_error_t antirollback_read_space_firmware(struct vb2_context *ctx)
19 {
20  vb2api_secdata_firmware_create(ctx);
21  return VB2_SUCCESS;
22 }
23 
24 vb2_error_t antirollback_write_space_firmware(struct vb2_context *ctx)
25 {
26  return VB2_SUCCESS;
27 }
28 
29 vb2_error_t antirollback_read_space_kernel(struct vb2_context *ctx)
30 {
31  /*
32  * The new kernel secdata v1 stores the last read EC hash, and reboots the
33  * device during EC software sync when that hash didn't match the currently
34  * active hash on the EC (this is used with TPM_GOOGLE to support EC-EFS2 and
35  * pretty much a no-op for other devices). Generally, of course the whole
36  * point of secdata is always that it persists across reboots, but with
37  * MOCK_SECDATA we can't do that. Previously we always happened to somewhat
38  * get away with presenting freshly-reinitialized data for MOCK_SECDATA on
39  * every boot, but with the EC hash feature in secdata v1, that would cause
40  * a reboot loop. The simplest solution is to just pretend we're a secdata
41  * v0 device when using MOCK_SECDATA.
42  */
43  vb2api_secdata_kernel_create_v0(ctx);
44  return VB2_SUCCESS;
45 }
46 
47 vb2_error_t antirollback_write_space_kernel(struct vb2_context *ctx)
48 {
49  return VB2_SUCCESS;
50 }
51 
53 {
54  return VB2_SUCCESS;
55 }
56 
58 {
59  return VB2_SUCCESS;
60 }
61 
63 {
64  return VB2_SUCCESS;
65 }
66 
67 vb2_error_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data,
68  uint32_t size)
69 {
70  return VB2_SUCCESS;
71 }
vb2_error_t antirollback_lock_space_firmware(void)
Lock must be called.
Definition: secdata_mock.c:52
vb2_error_t antirollback_read_space_mrc_hash(uint32_t index, uint8_t *data, uint32_t size)
Definition: secdata_mock.c:62
vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx)
Definition: secdata_mock.c:13
vb2_error_t antirollback_write_space_firmware(struct vb2_context *ctx)
Write may be called if the versions change.
Definition: secdata_mock.c:24
vb2_error_t antirollback_read_space_firmware(struct vb2_context *ctx)
Definition: secdata_mock.c:18
vb2_error_t antirollback_write_space_kernel(struct vb2_context *ctx)
Definition: secdata_mock.c:47
vb2_error_t antirollback_lock_space_mrc_hash(uint32_t index)
Definition: secdata_mock.c:57
vb2_error_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data, uint32_t size)
Definition: secdata_mock.c:67
vb2_error_t antirollback_read_space_kernel(struct vb2_context *ctx)
Read and write kernel space in TPM.
Definition: secdata_mock.c:29
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8