Skip to content

Commit

Permalink
Get_cert and Set_cert need read alias cert in alias_cert_model
Browse files Browse the repository at this point in the history
Fix the issue: #310

Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
  • Loading branch information
Wenxing-hou committed Dec 12, 2023
1 parent a440016 commit 11adadf
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
29 changes: 24 additions & 5 deletions spdm_emu/spdm_requester_emu/spdm_requester_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ libspdm_return_t do_certificate_provising_via_spdm(uint32_t* session_id)
size_t cert_chain_size_to_set;
uint8_t slot_id;
bool res;
libspdm_data_parameter_t parameter;
uint32_t data32;
size_t data32_size;

cert_chain_to_set = NULL;
cert_chain_size_to_set = 0;
Expand All @@ -245,11 +248,27 @@ libspdm_return_t do_certificate_provising_via_spdm(uint32_t* session_id)
#endif /*LIBSPDM_ENABLE_CAPABILITY_CSR_CAP*/

#if LIBSPDM_ENABLE_CAPABILITY_SET_CERT_CAP
res = libspdm_read_responder_public_certificate_chain(m_use_hash_algo,
m_use_asym_algo,
&cert_chain_to_set,
&cert_chain_size_to_set,
NULL, NULL);
libspdm_zero_mem(&parameter, sizeof(parameter));
parameter.location = LIBSPDM_DATA_LOCATION_CONNECTION;
data32_size = sizeof(data32);
libspdm_get_data(spdm_context, LIBSPDM_DATA_CAPABILITY_FLAGS, &parameter,
&data32, &data32_size);

if ((data32 & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP) == 0) {
res = libspdm_read_responder_public_certificate_chain(m_use_hash_algo,
m_use_asym_algo,
&cert_chain_to_set,
&cert_chain_size_to_set,
NULL, NULL);
} else {
res = libspdm_read_responder_public_certificate_chain_alias_cert_till_dev_cert_ca(
m_use_hash_algo,
m_use_asym_algo,
&cert_chain_to_set,
&cert_chain_size_to_set,
NULL, NULL);
}

if (!res) {
printf("set certificate :read_responder_public_certificate_chain fail!\n");
free(cert_chain_to_set);
Expand Down
23 changes: 19 additions & 4 deletions spdm_emu/spdm_responder_emu/spdm_responder_spdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,25 @@ void spdm_server_connection_state_callback(
&parameter, &data16, &data_size);
m_use_req_asym_algo = data16;

res = libspdm_read_responder_public_certificate_chain(m_use_hash_algo,
m_use_asym_algo,
&data, &data_size,
NULL, NULL);
libspdm_zero_mem(&parameter, sizeof(parameter));
parameter.location = LIBSPDM_DATA_LOCATION_LOCAL;
data_size = sizeof(data32);
libspdm_get_data(spdm_context, LIBSPDM_DATA_CAPABILITY_FLAGS, &parameter,
&data32, &data_size);

if ((data32 & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP) == 0) {
res = libspdm_read_responder_public_certificate_chain(m_use_hash_algo,
m_use_asym_algo,
&data, &data_size,
NULL, NULL);
} else {
res = libspdm_read_responder_public_certificate_chain_alias_cert_entire(
m_use_hash_algo,
m_use_asym_algo,
&data, &data_size,
NULL, NULL);
}

res = libspdm_read_responder_public_certificate_chain_per_slot(1,
m_use_hash_algo,
m_use_asym_algo,
Expand Down

0 comments on commit 11adadf

Please sign in to comment.