Software APIs
tpm.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CERT_TPM_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CERT_TPM_H_
7 
8 #include <stdint.h>
9 
10 #include "sw/device/silicon_creator/lib/cert/cert.h"
11 #include "sw/device/silicon_creator/lib/drivers/keymgr.h"
12 #include "sw/device/silicon_creator/lib/error.h"
13 #include "sw/device/silicon_creator/lib/sigverify/ecdsa_p256_key.h"
14 
15 /**
16  * TPM ECC key descriptors.
17  */
18 extern const sc_keymgr_ecc_key_t kTpmKeyEk;
19 extern const sc_keymgr_ecc_key_t kTpmKeyCek;
20 extern const sc_keymgr_ecc_key_t kTpmKeyCik;
21 
22 /**
23  * Generates an X.509 TBS section of a TPM EK certificate.
24  *
25  * @param key_ids Pointer to the (current and endorsement) public key IDs.
26  * @param tpm_ek_pubkey Pointer to the TPM EK public key in big endian.
27  * @param[out] tbs_cert Buffer to hold the generated TBS section.
28  * @param[in,out] tbs_cert_size Size of the generated TBS section (input value
29  * is the size of the allocated cert_buf, output
30  * value final computed size of the certificate).
31  * @return The result of the operation.
32  */
34 rom_error_t tpm_ek_tbs_cert_build(cert_key_id_pair_t *key_ids,
35  ecdsa_p256_public_key_t *tpm_ek_pubkey,
36  uint8_t *tbs_cert, size_t *tbs_cert_size);
37 
38 /**
39  * Generates an X.509 TBS section of a TPM CEK certificate.
40  *
41  * @param key_ids Pointer to the (current and endorsement) public key IDs.
42  * @param tpm_cek_pubkey Pointer to the TPM CEK public key in big endian.
43  * @param[out] tbs_cert Buffer to hold the generated UDS section.
44  * @param[in,out] tbs_cert_size Size of the generated TBS section (input value
45  * is the size of the allocated cert_buf, output
46  * value final computed size of the certificate).
47  * @return The result of the operation.
48  */
50 rom_error_t tpm_cek_tbs_cert_build(cert_key_id_pair_t *key_ids,
51  ecdsa_p256_public_key_t *tpm_cek_pubkey,
52  uint8_t *tbs_cert, size_t *tbs_cert_size);
53 
54 /**
55  * Generates an X.509 TBS section of a TPM CIK certificate.
56  *
57  * @param key_ids Pointer to the (current and endorsement) public key IDs.
58  * @param tpm_cik_pubkey Pointer to the TPM CIK public key in big endian.
59  * @param[out] tbs_cert Buffer to hold the generated UDS section.
60  * @param[in,out] tbs_cert_size Size of the generated TBS section (input value
61  * is the size of the allocated cert_buf, output
62  * value final computed size of the certificate).
63  * @return The result of the operation.
64  */
66 rom_error_t tpm_cik_tbs_cert_build(cert_key_id_pair_t *key_ids,
67  ecdsa_p256_public_key_t *tpm_cik_pubkey,
68  uint8_t *tbs_cert, size_t *tbs_cert_size);
69 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_CERT_TPM_H_