Skip to content

Commit

Permalink
Add check for builds
Browse files Browse the repository at this point in the history
Signed-off-by: Shrikant Temburwar <[email protected]>
  • Loading branch information
shrikant1407 committed Sep 10, 2024
1 parent d814746 commit 0b52d66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/m-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@
*/

/* All below sizes are excluding NULL termination */
#if defined(BUILD_MFG_TOOLKIT) || defined(DEVICE_CSE_ENABLED)
#define MAC_ARRAY_SZ 1
#else
#define MAC_ARRAY_SZ 0
#endif

#if defined(DEVICE_CSE_ENABLED)
#define DEVICE_MFG_STRING_ARRAY_SZ 9
#define DEVICE_MFG_STRING_ARRAY_SZ (8 + MAC_ARRAY_SZ)
#else
#define DEVICE_MFG_STRING_ARRAY_SZ 6
#define DEVICE_MFG_STRING_ARRAY_SZ (5 + MAC_ARRAY_SZ)
#endif

#define MAX_DEV_SERIAL_SZ 255
Expand Down Expand Up @@ -232,9 +238,11 @@ int ps_get_m_string(fdo_prot_t *ps)
fdo_byte_array_t *csr = NULL;
fdow_t temp_fdow = {0};
size_t enc_device_mfginfo = 0;

#if defined(BUILD_MFG_TOOLKIT) || defined(DEVICE_CSE_ENABLED)
fdo_byte_array_t *mac_addresses = NULL;
size_t mac_addresses_sz = 0;

#endif
#if defined(DEVICE_CSE_ENABLED)
fdo_byte_array_t *cse_cert = NULL;
fdo_byte_array_t *cse_maroeprefix = NULL;
Expand Down Expand Up @@ -368,7 +376,7 @@ int ps_get_m_string(fdo_prot_t *ps)
LOG(LOG_ERROR, "Failed to read %s file!\n", MAC_ADDRESSES);
goto err;
}
#else
#elif !defined(BUILD_MFG_TOOLKIT) && defined(DEVICE_CSE_ENABLED)
mac_addresses = fdo_byte_array_alloc(mac_addresses_sz);
if (!mac_addresses) {
LOG(LOG_ERROR,
Expand Down Expand Up @@ -412,13 +420,14 @@ int ps_get_m_string(fdo_prot_t *ps)
LOG(LOG_ERROR, "DeviceMfgInfo: Failed to write CSR\n");
goto err;
}

#if defined(BUILD_MFG_TOOLKIT) || defined(DEVICE_CSE_ENABLED)
if (!fdow_byte_string(&temp_fdow, mac_addresses->bytes,
mac_addresses->byte_sz)) {
LOG(LOG_ERROR,
"DeviceMfgInfo: Failed to write mac_addresses\n");
goto err;
}
#endif
#if defined(DEVICE_CSE_ENABLED)
if (!fdow_byte_string(&temp_fdow, cse_cert->bytes, cse_cert->byte_sz)) {
LOG(LOG_ERROR,
Expand Down Expand Up @@ -464,12 +473,12 @@ int ps_get_m_string(fdo_prot_t *ps)
if (csr) {
fdo_byte_array_free(csr);
}

#if defined(BUILD_MFG_TOOLKIT) || defined(DEVICE_CSE_ENABLED)
if (mac_addresses) {
fdo_byte_array_free(mac_addresses);
mac_addresses_sz = 0;
}

#endif
#if defined(DEVICE_CSE_ENABLED)
if (cose_sig_structure) {
fdo_byte_array_free(cose_sig_structure);
Expand Down
2 changes: 2 additions & 0 deletions lib/prot/to2/msg70.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ int32_t msg70(fdo_prot_t *ps)
fdo_guid_to_string(ps->dev_cred->owner_blk->guid, guid_buf,
sizeof(guid_buf)));

#if !defined(DEVICE_TPM20_ENABLED) && !defined(DEVICE_CSE_ENABLED)
/* Rotate Data Protection Key */
if (0 != fdo_generate_storage_hmac_key()) {
LOG(LOG_ERROR,
"TO2.Done: Failed to rotate data protection key.\n");
}
LOG(LOG_DEBUG,
"TO2.Done: Data protection key rotated successfully!!\n");
#endif

if (!ps->reuse_enabled) {
/* Commit the replacement hmac key only if reuse was not
Expand Down

0 comments on commit 0b52d66

Please sign in to comment.