diff --git a/spdm_emu/spdm_requester_emu/spdm_requester_session.c b/spdm_emu/spdm_requester_emu/spdm_requester_session.c index 4009747..9566f19 100644 --- a/spdm_emu/spdm_requester_emu/spdm_requester_session.c +++ b/spdm_emu/spdm_requester_emu/spdm_requester_session.c @@ -209,11 +209,6 @@ libspdm_return_t do_certificate_provising_via_spdm(uint32_t* session_id) { void *spdm_context; -#if LIBSPDM_ENABLE_CAPABILITY_CSR_CAP - uint8_t csr_form_get[LIBSPDM_MAX_CSR_SIZE]; - size_t csr_len; -#endif /*LIBSPDM_ENABLE_CAPABILITY_CSR_CAP*/ - #if LIBSPDM_ENABLE_CAPABILITY_SET_CERT_CAP void *cert_chain_to_set; size_t cert_chain_size_to_set; @@ -224,6 +219,19 @@ libspdm_return_t do_certificate_provising_via_spdm(uint32_t* session_id) cert_chain_size_to_set = 0; #endif /*LIBSPDM_ENABLE_CAPABILITY_SET_CERT_CAP*/ +#if LIBSPDM_ENABLE_CAPABILITY_CSR_CAP + uint8_t csr_form_get[LIBSPDM_MAX_CSR_SIZE]; + size_t csr_len; + libspdm_data_parameter_t parameter; + bool multi_key_conn_rsp; + size_t data_size; +#if LIBSPDM_ENABLE_CAPABILITY_CSR_CAP_EX + uint8_t key_pair_id; + uint8_t request_attribute; +#endif /*LIBSPDM_ENABLE_CAPABILITY_CSR_CAP_EX*/ +#endif /*LIBSPDM_ENABLE_CAPABILITY_CSR_CAP*/ + + libspdm_return_t status; spdm_context = m_spdm_context; @@ -233,12 +241,24 @@ libspdm_return_t do_certificate_provising_via_spdm(uint32_t* session_id) csr_len = LIBSPDM_MAX_CSR_SIZE; libspdm_zero_mem(csr_form_get, sizeof(csr_form_get)); if ((m_exe_connection & EXE_CONNECTION_GET_CSR) != 0) { - status = libspdm_get_csr(spdm_context, NULL, NULL, 0, NULL, 0, csr_form_get, - &csr_len); - if (LIBSPDM_STATUS_IS_ERROR(status)) { - printf("libspdm_get_csr - %x\n", - (uint32_t)status); - return status; + libspdm_zero_mem(¶meter, sizeof(parameter)); + parameter.location = LIBSPDM_DATA_LOCATION_CONNECTION; + data_size = sizeof(multi_key_conn_rsp); + libspdm_get_data(spdm_context, LIBSPDM_DATA_MULTI_KEY_CONN_RSP, ¶meter, + &multi_key_conn_rsp, &data_size); + + if (!multi_key_conn_rsp) { + status = libspdm_get_csr(spdm_context, NULL, NULL, 0, NULL, 0, csr_form_get, + &csr_len); + } else { +#if LIBSPDM_ENABLE_CAPABILITY_CSR_CAP_EX + request_attribute = 0; + key_pair_id = 1; + status = libspdm_get_csr_ex(spdm_context, NULL, NULL, 0, NULL, 0, csr_form_get, + &csr_len, request_attribute, key_pair_id, NULL); +#else + return LIBSPDM_STATUS_UNSUPPORTED_CAP; +#endif /*LIBSPDM_ENABLE_CAPABILITY_CSR_CAP_EX*/ } }