Skip to content

Commit b9265cc

Browse files
committed
add 1.3 multi-key connection process in algorithm.
Signed-off-by: Jiewen Yao <[email protected]>
1 parent 7f55437 commit b9265cc

File tree

4 files changed

+109
-4
lines changed

4 files changed

+109
-4
lines changed

include/internal/libspdm_common_lib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ typedef struct {
128128
/* Specifies whether the cached negotiated state should be invalidated. (responder only)
129129
* This is a "sticky" bit wherein if it is set to 1 then it cannot be set to 0. */
130130
uint8_t end_session_attributes;
131+
132+
/* multi-key negotiated result */
133+
bool multi_key_conn_req;
134+
bool multi_key_conn_rsp;
131135
} libspdm_connection_info_t;
132136

133137
typedef struct {

library/spdm_common_lib/libspdm_com_opaque_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ bool libspdm_process_general_opaque_data_check(libspdm_context_t *spdm_context,
261261
LIBSPDM_ASSERT(data_in_size <= SPDM_MAX_OPAQUE_DATA_SIZE);
262262

263263
if (libspdm_get_connection_version(spdm_context) >= SPDM_MESSAGE_VERSION_12) {
264-
if (spdm_context->connection_info.algorithm.other_params_support ==
265-
SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1) {
264+
if ((spdm_context->connection_info.algorithm.other_params_support &
265+
SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK) == SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_1) {
266266
/* Check byte alignment */
267267
if ((data_in_size & 3) != 0) {
268268
return false;

library/spdm_requester_lib/libspdm_req_negotiate_algorithms.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,32 @@ static libspdm_return_t libspdm_try_negotiate_algorithms(libspdm_context_t *spdm
140140
spdm_request->other_params_support =
141141
spdm_context->local_context.algorithm.other_params_support;
142142
}
143+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
144+
switch (spdm_context->connection_info.capability.flags &
145+
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP) {
146+
case 0:
147+
spdm_context->connection_info.multi_key_conn_rsp = false;
148+
break;
149+
case SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY:
150+
spdm_context->connection_info.multi_key_conn_rsp = true;
151+
break;
152+
case SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG:
153+
if ((spdm_context->local_context.algorithm.other_params_support &
154+
SPDM_ALGORITHMS_MULTI_KEY_CONN) == 0) {
155+
spdm_context->connection_info.multi_key_conn_rsp = false;
156+
} else {
157+
spdm_context->connection_info.multi_key_conn_rsp = true;
158+
}
159+
break;
160+
default:
161+
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
162+
}
163+
if (spdm_context->connection_info.multi_key_conn_rsp) {
164+
spdm_request->other_params_support |= SPDM_ALGORITHMS_MULTI_KEY_CONN;
165+
} else {
166+
spdm_request->other_params_support &= ~SPDM_ALGORITHMS_MULTI_KEY_CONN;
167+
}
168+
}
143169
spdm_request->base_asym_algo = spdm_context->local_context.algorithm.base_asym_algo;
144170
spdm_request->base_hash_algo = spdm_context->local_context.algorithm.base_hash_algo;
145171
spdm_request->ext_asym_count = 0;
@@ -536,6 +562,26 @@ static libspdm_return_t libspdm_try_negotiate_algorithms(libspdm_context_t *spdm
536562
}
537563
}
538564
}
565+
566+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
567+
if ((spdm_context->connection_info.algorithm.other_params_support &
568+
SPDM_ALGORITHMS_MULTI_KEY_CONN) == 0) {
569+
if ((spdm_context->local_context.capability.flags &
570+
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP) ==
571+
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY) {
572+
status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
573+
goto receive_done;
574+
}
575+
spdm_context->connection_info.multi_key_conn_req = false;
576+
} else {
577+
if ((spdm_context->local_context.capability.flags &
578+
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP) == 0) {
579+
status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
580+
goto receive_done;
581+
}
582+
spdm_context->connection_info.multi_key_conn_req = true;
583+
}
584+
}
539585
} else {
540586
spdm_context->connection_info.algorithm.dhe_named_group = 0;
541587
spdm_context->connection_info.algorithm.aead_cipher_suite = 0;

library/spdm_responder_lib/libspdm_rsp_algorithms.c

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,39 @@ libspdm_return_t libspdm_get_response_algorithms(libspdm_context_t *spdm_context
579579
spdm_response->other_params_selection = (uint8_t)libspdm_prioritize_algorithm(
580580
other_params_support_priority_table,
581581
LIBSPDM_ARRAY_SIZE(other_params_support_priority_table),
582-
spdm_context->local_context.algorithm.other_params_support,
583-
spdm_context->connection_info.algorithm.other_params_support);
582+
spdm_context->local_context.algorithm.other_params_support &
583+
SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK,
584+
spdm_context->connection_info.algorithm.other_params_support &
585+
SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK);
586+
}
587+
588+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
589+
switch (spdm_context->connection_info.capability.flags &
590+
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP) {
591+
case 0:
592+
spdm_context->connection_info.multi_key_conn_req = false;
593+
break;
594+
case SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY:
595+
spdm_context->connection_info.multi_key_conn_req = true;
596+
break;
597+
case SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_NEG:
598+
if ((spdm_context->local_context.algorithm.other_params_support &
599+
SPDM_ALGORITHMS_MULTI_KEY_CONN) == 0) {
600+
spdm_context->connection_info.multi_key_conn_req = false;
601+
} else {
602+
spdm_context->connection_info.multi_key_conn_req = true;
603+
}
604+
break;
605+
default:
606+
return libspdm_generate_error_response(
607+
spdm_context, SPDM_ERROR_CODE_INVALID_REQUEST,
608+
0, response_size, response);
609+
}
610+
if (spdm_context->connection_info.multi_key_conn_req) {
611+
spdm_response->other_params_selection |= SPDM_ALGORITHMS_MULTI_KEY_CONN;
612+
} else {
613+
spdm_response->other_params_selection &= ~SPDM_ALGORITHMS_MULTI_KEY_CONN;
614+
}
584615
}
585616

586617
spdm_context->connection_info.algorithm.measurement_spec =
@@ -760,6 +791,30 @@ libspdm_return_t libspdm_get_response_algorithms(libspdm_context_t *spdm_context
760791
}
761792
}
762793
}
794+
795+
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
796+
if ((spdm_context->connection_info.algorithm.other_params_support &
797+
SPDM_ALGORITHMS_MULTI_KEY_CONN) == 0) {
798+
if ((spdm_context->local_context.capability.flags &
799+
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP) ==
800+
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY) {
801+
return libspdm_generate_error_response(
802+
spdm_context,
803+
SPDM_ERROR_CODE_INVALID_REQUEST, 0,
804+
response_size, response);
805+
}
806+
spdm_context->connection_info.multi_key_conn_rsp = false;
807+
} else {
808+
if ((spdm_context->local_context.capability.flags &
809+
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP) == 0) {
810+
return libspdm_generate_error_response(
811+
spdm_context,
812+
SPDM_ERROR_CODE_INVALID_REQUEST, 0,
813+
response_size, response);
814+
}
815+
spdm_context->connection_info.multi_key_conn_rsp = true;
816+
}
817+
}
763818
} else {
764819
spdm_context->connection_info.algorithm.dhe_named_group = 0;
765820
spdm_context->connection_info.algorithm.aead_cipher_suite = 0;

0 commit comments

Comments
 (0)