Skip to content

Commit bd37ac8

Browse files
committed
Add 1.3 Encap CERT
Signed-off-by: Jiewen Yao <[email protected]>
1 parent d4911d6 commit bd37ac8

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

library/spdm_requester_lib/libspdm_req_encap_certificate.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ libspdm_return_t libspdm_get_encap_response_certificate(void *spdm_context,
7171

7272
offset = spdm_request->offset;
7373
length = spdm_request->length;
74+
75+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
76+
if (spdm_request->header.param2 &
77+
SPDM_GET_CERTIFICATE_REQUEST_ATTRIBUTES_SLOT_SIZE_REQUESTED) {
78+
offset = 0;
79+
length = 0;
80+
}
81+
}
82+
7483
if (length > LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN) {
7584
length = LIBSPDM_MAX_CERT_CHAIN_BLOCK_LEN;
7685
}
@@ -107,6 +116,10 @@ libspdm_return_t libspdm_get_encap_response_certificate(void *spdm_context,
107116
spdm_response->header.request_response_code = SPDM_CERTIFICATE;
108117
spdm_response->header.param1 = slot_id;
109118
spdm_response->header.param2 = 0;
119+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
120+
spdm_response->header.param2 = context->local_context.local_cert_info[slot_id];
121+
}
122+
110123
spdm_response->portion_length = length;
111124
spdm_response->remainder_length = (uint16_t)remainder_length;
112125
libspdm_copy_mem(spdm_response + 1,

library/spdm_responder_lib/libspdm_rsp_encap_get_certificate.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,30 @@ libspdm_return_t libspdm_process_encap_response_certificate(
118118
request_offset + spdm_response->portion_length + spdm_response->remainder_length) {
119119
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
120120
}
121-
if (spdm_response->header.param1 != spdm_context->encap_context.req_slot_id) {
121+
slot_id = spdm_context->encap_context.req_slot_id;
122+
if ((spdm_response->header.param1 & SPDM_CERTIFICATE_RESPONSE_SLOT_ID_MASK) != slot_id) {
122123
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
123124
}
125+
if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
126+
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "cert_info - 0x%02x\n",
127+
spdm_response->header.param2));
128+
if ((spdm_response->header.param2 &
129+
SPDM_CERTIFICATE_RESPONSE_ATTRIBUTES_CERTIFICATE_INFO_MASK) ==
130+
SPDM_CERTIFICATE_INFO_CERT_MODEL_NONE) {
131+
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
132+
}
133+
if (spdm_context->connection_info.peer_cert_info[slot_id] ==
134+
SPDM_CERTIFICATE_INFO_CERT_MODEL_NONE) {
135+
spdm_context->connection_info.peer_cert_info[slot_id] =
136+
(spdm_response->header.param2 &
137+
SPDM_CERTIFICATE_RESPONSE_ATTRIBUTES_CERTIFICATE_INFO_MASK);
138+
} else if (spdm_context->connection_info.peer_cert_info[slot_id] !=
139+
(spdm_response->header.param2 &
140+
SPDM_CERTIFICATE_RESPONSE_ATTRIBUTES_CERTIFICATE_INFO_MASK)) {
141+
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
142+
}
143+
}
144+
124145
if (spdm_response_size < sizeof(spdm_certificate_response_t) + spdm_response->portion_length) {
125146
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
126147
}

0 commit comments

Comments
 (0)