Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CSDK build to work with FDO GO server #292

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions device_modules/fdo_sim/fdo_sim_download.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,12 @@ int fdo_sim_set_osi_write(size_t bin_len, uint8_t *bin_data)
goto end;
}

if (bytes_received == expected_len || !bin_len) {
// Entire file has been sent
bytes_received = 0;
if (!bin_len) {
if (!fdor_next(fdor)) {
LOG(LOG_ERROR, "Module fdo.download - Failed to read "
"fdo.download\n");
goto end;
}
result = FDO_SI_SUCCESS;
goto end;
}
Expand Down Expand Up @@ -406,6 +409,7 @@ int fdo_sim_set_osi_write(size_t bin_len, uint8_t *bin_data)
if (file_data) {
FSIMModuleFree(file_data);
}
bytes_received = 0;
}

result = fdo_sim_end(&fdor, &fdow, result, bin_data, NULL, 0, &hasmore,
Expand Down
2 changes: 1 addition & 1 deletion lib/fdotypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6194,7 +6194,7 @@ bool fdo_serviceinfo_modules_list_write(fdow_t *fdow)
"ServiceInfoVal (modules) array\n");
goto end;
}
if (!fdow_signed_int(fdow, 3)) {
if (!fdow_signed_int(fdow, 0)) {
LOG(LOG_ERROR, "Platform Device ServiceInfoKV: Failed to write "
"ServiceInfoVal (modules) nummodules\n");
goto end;
Expand Down
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
Loading