2 * This file is part of the coreboot project.
4 * Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
5 * Copyright 2018 Facebook Inc.
6 * Copyright 2018 Siemens AG
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
21 #include <security/tpm/tss.h>
22 #include <commonlib/tcpa_log_serialized.h>
23 #include <commonlib/region.h>
26 #define TPM_PCR_MAX_LEN 64
27 #define HASH_DATA_CHUNK_SIZE 1024
30 * Clears the pre-RAM tcpa log data and initializes
31 * any content with default values
33 void tcpa_preram_log_clear(void);
36 * Add table entry for cbmem TCPA log.
37 * @param name Name of the hashed data
38 * @param pcr PCR used to extend hashed data
39 * @param diget_algo sets the digest algorithm
40 * @param digest sets the hash extended into the tpm
41 * @param digest_len the length of the digest
43 void tcpa_log_add_table_entry(const char *name
, const uint32_t pcr
,
44 enum vb2_hash_algorithm digest_algo
,
45 const uint8_t *digest
,
46 const size_t digest_len
);
49 * Dump TCPA log entries on console
51 void tcpa_log_dump(void *unused
);
54 * Ask vboot for a digest and extend a TPM PCR with it.
55 * @param pcr sets the pcr index
56 * @param diget_algo sets the digest algorithm
57 * @param digest sets the hash to extend into the tpm
58 * @param digest_len the length of the digest
59 * @param name sets additional info where the digest comes from
60 * @return TPM_SUCCESS on success. If not a tpm error is returned
62 uint32_t tpm_extend_pcr(int pcr
, enum vb2_hash_algorithm digest_algo
,
63 uint8_t *digest
, size_t digest_len
,
67 * Issue a TPM_Clear and reenable/reactivate the TPM.
68 * @return TPM_SUCCESS on success. If not a tpm error is returned
70 uint32_t tpm_clear_and_reenable(void);
73 * Start the TPM and establish the root of trust.
74 * @param s3flag tells the tpm setup if we wake up from a s3 state on x86
75 * @return TPM_SUCCESS on success. If not a tpm error is returned
77 uint32_t tpm_setup(int s3flag
);
80 * Measure a given region device and extend given PCR with the result.
81 * @param *rdev Pointer to the region device to measure
82 * @param pcr Index of the PCR which will be extended by this measure
83 * @param *rname Name of the region that is measured
84 * @return TPM error code in case of error otherwise TPM_SUCCESS
86 uint32_t tpm_measure_region(const struct region_device
*rdev
, uint8_t pcr
,