5 #include "sw/device/silicon_creator/lib/cert/tpm.h"
9 #include "sw/device/lib/testing/test_framework/check.h"
10 #include "sw/device/silicon_creator/lib/cert/cert.h"
11 #include "sw/device/silicon_creator/lib/cert/template.h"
12 #include "sw/device/silicon_creator/lib/cert/tpm_ek.h"
13 #include "sw/device/silicon_creator/lib/drivers/keymgr.h"
14 #include "sw/device/silicon_creator/lib/error.h"
15 #include "sw/device/silicon_creator/manuf/lib/flash_info_fields.h"
32 .
type = kScKeymgrKeyTypeSealing,
33 .keygen_seed_idx = kFlashInfoFieldTpmEkKeySeedIdx,
34 .keymgr_diversifier = &kTpmEkKeymgrDiversifier,
35 .required_keymgr_state = kScKeymgrStateOwnerKey,
41 size_t *tpm_ek_tbs_size) {
46 static char tpm_version[] = {
'0',
'.',
'0',
'.',
'1'};
47 static char tpm_vendor[] = {
'N',
'u',
'v',
'o',
't',
'o',
'n'};
48 static char tpm_model[] = {
'T',
'i',
'5',
'0'};
50 tpm_ek_tbs_values_t tpm_ek_tbs_params = {0};
52 TEMPLATE_SET(tpm_ek_tbs_params, TpmEk, TpmEkPubKeyEcX, tpm_ek_pubkey->
x);
53 TEMPLATE_SET(tpm_ek_tbs_params, TpmEk, TpmEkPubKeyEcY, tpm_ek_pubkey->
y);
54 TEMPLATE_SET(tpm_ek_tbs_params, TpmEk, TpmVersion, tpm_version);
55 TEMPLATE_SET(tpm_ek_tbs_params, TpmEk, TpmVendor, tpm_vendor);
56 TEMPLATE_SET(tpm_ek_tbs_params, TpmEk, TpmModel, tpm_model);
58 TEMPLATE_SET_TRUNCATED(tpm_ek_tbs_params, TpmEk, AuthKeyKeyId,
59 key_ids->
endorsement->digest, kCertKeyIdSizeInBytes);
60 TEMPLATE_SET_TRUNCATED(tpm_ek_tbs_params, TpmEk, TpmEkPubKeyId,
61 key_ids->
cert->digest, kCertKeyIdSizeInBytes);
63 HARDENED_RETURN_IF_ERROR(
64 tpm_ek_build_tbs(&tpm_ek_tbs_params, tpm_ek_tbs, tpm_ek_tbs_size));