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

When reading certificate fail, we should stop the communication between the requester and responder #17

Open
Zhiqiang520 opened this issue Oct 13, 2021 · 0 comments · Fixed by #22
Assignees

Comments

@Zhiqiang520
Copy link
Contributor

Test at the commit 2c4ada8

The line 248, 264, and 278 just handle the case when res = TRUE, I think we should also handle the other case when res = FALSE.
When read certificate fail, we should stop the communication between the requester and responder, maybe just like the following three lines sample code(bold text).
free(m_spdm_context);
m_spdm_context = NULL;
return NULL;

res = read_responder_public_certificate_chain(m_use_hash_algo,
m_use_asym_algo,
&data, &data_size,
NULL, NULL);
if (res) {
zero_mem(&parameter, sizeof(parameter));
parameter.location = SPDM_DATA_LOCATION_LOCAL;
spdm_set_data(spdm_context,
SPDM_DATA_PEER_PUBLIC_CERT_CHAIN,
&parameter, data, data_size);
// Do not free it.
}
} else {
res = read_responder_root_public_certificate(m_use_hash_algo,
m_use_asym_algo,
&data, &data_size,
&hash, &hash_size);
x509_get_cert_from_cert_chain((uint8 *)data + sizeof(spdm_cert_chain_t) + hash_size,
data_size - sizeof(spdm_cert_chain_t) - hash_size, 0,
&root_cert, &root_cert_size);
if (res) {
zero_mem(&parameter, sizeof(parameter));
parameter.location = SPDM_DATA_LOCATION_LOCAL;
spdm_set_data(spdm_context,
SPDM_DATA_PEER_PUBLIC_ROOT_CERT,
&parameter, root_cert, root_cert_size);
// Do not free it.
}
}
res = read_requester_public_certificate_chain(m_use_hash_algo,
m_use_req_asym_algo,
&data, &data_size, NULL,
NULL);
if (res) {
zero_mem(&parameter, sizeof(parameter));
parameter.location = SPDM_DATA_LOCATION_LOCAL;
data8 = m_use_slot_count;
spdm_set_data(spdm_context, SPDM_DATA_LOCAL_SLOT_COUNT,
&parameter, &data8, sizeof(data8));
for (index = 0; index < m_use_slot_count; index++) {
parameter.additional_data[0] = index;
spdm_set_data(spdm_context,
SPDM_DATA_LOCAL_PUBLIC_CERT_CHAIN,
&parameter, data, data_size);
}
// do not free it
}

Zhiqiang520 added a commit to Zhiqiang520/spdm-emu that referenced this issue Oct 21, 2021
…en the requester and responder.

FIX:DMTF#17

Signed-off-by: Zhao, Zhiqiang <zhiqiang.zhao@intel.com>
jyao1 pushed a commit that referenced this issue Dec 6, 2021
…en the requester and responder.

FIX:#17

Signed-off-by: Zhao, Zhiqiang <zhiqiang.zhao@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant