Skip to content

Commit d4911d6

Browse files
committed
Add 1.3 GET_CERT handling
Signed-off-by: Jiewen Yao <[email protected]>
1 parent 5d5f04a commit d4911d6

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Diff for: library/spdm_requester_lib/libspdm_req_get_certificate.c

+23
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,29 @@ static libspdm_return_t libspdm_try_get_certificate(libspdm_context_t *spdm_cont
229229
status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
230230
goto done;
231231
}
232+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
233+
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "cert_info - 0x%02x\n",
234+
spdm_response->header.param2));
235+
if ((spdm_response->header.param2 &
236+
SPDM_CERTIFICATE_RESPONSE_ATTRIBUTES_CERTIFICATE_INFO_MASK) ==
237+
SPDM_CERTIFICATE_INFO_CERT_MODEL_NONE) {
238+
libspdm_release_receiver_buffer (spdm_context);
239+
status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
240+
goto done;
241+
}
242+
if (spdm_context->connection_info.peer_cert_info[slot_id] ==
243+
SPDM_CERTIFICATE_INFO_CERT_MODEL_NONE) {
244+
spdm_context->connection_info.peer_cert_info[slot_id] =
245+
(spdm_response->header.param2 &
246+
SPDM_CERTIFICATE_RESPONSE_ATTRIBUTES_CERTIFICATE_INFO_MASK);
247+
} else if (spdm_context->connection_info.peer_cert_info[slot_id] !=
248+
(spdm_response->header.param2 &
249+
SPDM_CERTIFICATE_RESPONSE_ATTRIBUTES_CERTIFICATE_INFO_MASK)) {
250+
libspdm_release_receiver_buffer (spdm_context);
251+
status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
252+
goto done;
253+
}
254+
}
232255
if (spdm_response_size < sizeof(spdm_certificate_response_t) +
233256
spdm_response->portion_length) {
234257
libspdm_release_receiver_buffer (spdm_context);

Diff for: library/spdm_responder_lib/libspdm_rsp_certificate.c

+12
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ libspdm_return_t libspdm_get_response_certificate(libspdm_context_t *spdm_contex
9696
offset = spdm_request->offset;
9797
length = spdm_request->length;
9898

99+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
100+
if (spdm_request->header.param2 &
101+
SPDM_GET_CERTIFICATE_REQUEST_ATTRIBUTES_SLOT_SIZE_REQUESTED) {
102+
offset = 0;
103+
length = 0;
104+
}
105+
}
106+
99107
if (offset >= spdm_context->local_context.local_cert_chain_provision_size[slot_id]) {
100108
return libspdm_generate_error_response(spdm_context,
101109
SPDM_ERROR_CODE_INVALID_REQUEST, 0,
@@ -130,6 +138,10 @@ libspdm_return_t libspdm_get_response_certificate(libspdm_context_t *spdm_contex
130138
spdm_response->header.request_response_code = SPDM_CERTIFICATE;
131139
spdm_response->header.param1 = slot_id;
132140
spdm_response->header.param2 = 0;
141+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
142+
spdm_response->header.param2 = spdm_context->local_context.local_cert_info[slot_id];
143+
}
144+
133145
spdm_response->portion_length = length;
134146
spdm_response->remainder_length = (uint16_t)remainder_length;
135147

0 commit comments

Comments
 (0)