From 12ec89425280dc65ac4ade1bddc7b13608af3d9c Mon Sep 17 00:00:00 2001 From: Jiewen Yao Date: Fri, 22 Mar 2024 13:25:35 +0800 Subject: [PATCH] Fix error code for unsupported_req error. Signed-off-by: Jiewen Yao --- .../spdm_requester_lib/libspdm_req_encap_certificate.c | 4 ++-- .../spdm_requester_lib/libspdm_req_encap_challenge_auth.c | 2 +- library/spdm_requester_lib/libspdm_req_encap_digests.c | 4 ++-- library/spdm_requester_lib/libspdm_req_encap_key_update.c | 4 ++-- library/spdm_responder_lib/libspdm_rsp_chunk_get.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_chunk_send_ack.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_csr.c | 3 ++- library/spdm_responder_lib/libspdm_rsp_encap_response.c | 8 +++++--- library/spdm_responder_lib/libspdm_rsp_end_session.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_finish.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_heartbeat.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_key_exchange.c | 3 ++- library/spdm_responder_lib/libspdm_rsp_key_update.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_psk_exchange.c | 3 ++- library/spdm_responder_lib/libspdm_rsp_psk_finish.c | 5 +++-- library/spdm_responder_lib/libspdm_rsp_set_certificate.c | 3 ++- 16 files changed, 41 insertions(+), 28 deletions(-) diff --git a/library/spdm_requester_lib/libspdm_req_encap_certificate.c b/library/spdm_requester_lib/libspdm_req_encap_certificate.c index 2eaaf51bfb5..8e1fe31db6b 100644 --- a/library/spdm_requester_lib/libspdm_req_encap_certificate.c +++ b/library/spdm_requester_lib/libspdm_req_encap_certificate.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -31,7 +31,7 @@ libspdm_return_t libspdm_get_encap_response_certificate(void *spdm_context, if (libspdm_get_connection_version(context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_encap_error_response( context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, - 0, response_size, response); + SPDM_GET_CERTIFICATE, response_size, response); } if (spdm_request->header.spdm_version != libspdm_get_connection_version(context)) { diff --git a/library/spdm_requester_lib/libspdm_req_encap_challenge_auth.c b/library/spdm_requester_lib/libspdm_req_encap_challenge_auth.c index 129ca1d6585..996a2947079 100644 --- a/library/spdm_requester_lib/libspdm_req_encap_challenge_auth.c +++ b/library/spdm_requester_lib/libspdm_req_encap_challenge_auth.c @@ -37,7 +37,7 @@ libspdm_return_t libspdm_get_encap_response_challenge_auth( if (libspdm_get_connection_version(context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_encap_error_response( context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, - 0, response_size, response); + SPDM_CHALLENGE, response_size, response); } if (spdm_request->header.spdm_version != libspdm_get_connection_version(context)) { diff --git a/library/spdm_requester_lib/libspdm_req_encap_digests.c b/library/spdm_requester_lib/libspdm_req_encap_digests.c index 19711a07c21..92b7c065361 100644 --- a/library/spdm_requester_lib/libspdm_req_encap_digests.c +++ b/library/spdm_requester_lib/libspdm_req_encap_digests.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -40,7 +40,7 @@ libspdm_return_t libspdm_get_encap_response_digest(void *spdm_context, if (libspdm_get_connection_version(context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_encap_error_response( context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, - 0, response_size, response); + SPDM_GET_DIGESTS, response_size, response); } if (spdm_request->header.spdm_version != libspdm_get_connection_version(context)) { diff --git a/library/spdm_requester_lib/libspdm_req_encap_key_update.c b/library/spdm_requester_lib/libspdm_req_encap_key_update.c index 4d291426cbd..e8eb5d5ef75 100644 --- a/library/spdm_requester_lib/libspdm_req_encap_key_update.c +++ b/library/spdm_requester_lib/libspdm_req_encap_key_update.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -31,7 +31,7 @@ libspdm_return_t libspdm_get_encap_response_key_update(void *spdm_context, if (libspdm_get_connection_version(context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_encap_error_response( context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, - 0, response_size, response); + SPDM_KEY_UPDATE, response_size, response); } if (spdm_request->header.spdm_version != libspdm_get_connection_version(context)) { diff --git a/library/spdm_responder_lib/libspdm_rsp_chunk_get.c b/library/spdm_responder_lib/libspdm_rsp_chunk_get.c index d502f5f3f12..0fb140ee0b6 100644 --- a/library/spdm_responder_lib/libspdm_rsp_chunk_get.c +++ b/library/spdm_responder_lib/libspdm_rsp_chunk_get.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -29,7 +29,8 @@ libspdm_return_t libspdm_get_response_chunk_get( if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_12) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_CHUNK_GET, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_chunk_send_ack.c b/library/spdm_responder_lib/libspdm_rsp_chunk_send_ack.c index 92e4dd09e6f..906dbcbd335 100644 --- a/library/spdm_responder_lib/libspdm_rsp_chunk_send_ack.c +++ b/library/spdm_responder_lib/libspdm_rsp_chunk_send_ack.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -30,7 +30,8 @@ libspdm_return_t libspdm_get_response_chunk_send(libspdm_context_t *spdm_context if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_12) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_CHUNK_SEND, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_csr.c b/library/spdm_responder_lib/libspdm_rsp_csr.c index 388a251cb58..0b4871273f0 100644 --- a/library/spdm_responder_lib/libspdm_rsp_csr.c +++ b/library/spdm_responder_lib/libspdm_rsp_csr.c @@ -41,7 +41,8 @@ libspdm_return_t libspdm_get_response_csr(libspdm_context_t *spdm_context, if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_12) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_GET_CSR, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_encap_response.c b/library/spdm_responder_lib/libspdm_rsp_encap_response.c index 9bfb6bd257a..0fbdea05fff 100644 --- a/library/spdm_responder_lib/libspdm_rsp_encap_response.c +++ b/library/spdm_responder_lib/libspdm_rsp_encap_response.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -225,7 +225,8 @@ libspdm_return_t libspdm_get_response_encapsulated_request( if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_GET_ENCAPSULATED_REQUEST, response_size, response); } @@ -306,7 +307,8 @@ libspdm_return_t libspdm_get_response_encapsulated_response_ack( if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_DELIVER_ENCAPSULATED_RESPONSE, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_end_session.c b/library/spdm_responder_lib/libspdm_rsp_end_session.c index 418e7ee6894..f3a5799b39f 100644 --- a/library/spdm_responder_lib/libspdm_rsp_end_session.c +++ b/library/spdm_responder_lib/libspdm_rsp_end_session.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -21,7 +21,8 @@ libspdm_return_t libspdm_get_response_end_session(libspdm_context_t *spdm_contex if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_END_SESSION, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_finish.c b/library/spdm_responder_lib/libspdm_rsp_finish.c index ff41619cfb1..7d692eebb24 100644 --- a/library/spdm_responder_lib/libspdm_rsp_finish.c +++ b/library/spdm_responder_lib/libspdm_rsp_finish.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -383,7 +383,8 @@ libspdm_return_t libspdm_get_response_finish(libspdm_context_t *spdm_context, si if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_FINISH, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_heartbeat.c b/library/spdm_responder_lib/libspdm_rsp_heartbeat.c index 12ca5e8df2d..8e4de91a761 100644 --- a/library/spdm_responder_lib/libspdm_rsp_heartbeat.c +++ b/library/spdm_responder_lib/libspdm_rsp_heartbeat.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -24,7 +24,8 @@ libspdm_return_t libspdm_get_response_heartbeat(libspdm_context_t *spdm_context, if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_HEARTBEAT, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_key_exchange.c b/library/spdm_responder_lib/libspdm_rsp_key_exchange.c index 1d0e07134c1..dd55a0e1182 100644 --- a/library/spdm_responder_lib/libspdm_rsp_key_exchange.c +++ b/library/spdm_responder_lib/libspdm_rsp_key_exchange.c @@ -208,7 +208,8 @@ libspdm_return_t libspdm_get_response_key_exchange(libspdm_context_t *spdm_conte if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_KEY_EXCHANGE, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_key_update.c b/library/spdm_responder_lib/libspdm_rsp_key_update.c index d4dcda2baf8..2379331dcf1 100644 --- a/library/spdm_responder_lib/libspdm_rsp_key_update.c +++ b/library/spdm_responder_lib/libspdm_rsp_key_update.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -46,7 +46,8 @@ libspdm_return_t libspdm_get_response_key_update(libspdm_context_t *spdm_context if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_KEY_UPDATE, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_psk_exchange.c b/library/spdm_responder_lib/libspdm_rsp_psk_exchange.c index 95cf686f19e..1948635b89c 100644 --- a/library/spdm_responder_lib/libspdm_rsp_psk_exchange.c +++ b/library/spdm_responder_lib/libspdm_rsp_psk_exchange.c @@ -106,7 +106,8 @@ libspdm_return_t libspdm_get_response_psk_exchange(libspdm_context_t *spdm_conte if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_PSK_EXCHANGE, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_psk_finish.c b/library/spdm_responder_lib/libspdm_rsp_psk_finish.c index 261d2aef170..1c02a1f0351 100644 --- a/library/spdm_responder_lib/libspdm_rsp_psk_finish.c +++ b/library/spdm_responder_lib/libspdm_rsp_psk_finish.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -89,7 +89,8 @@ libspdm_return_t libspdm_get_response_psk_finish(libspdm_context_t *spdm_context if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_11) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_PSK_FINISH, response_size, response); } diff --git a/library/spdm_responder_lib/libspdm_rsp_set_certificate.c b/library/spdm_responder_lib/libspdm_rsp_set_certificate.c index bfad0bce8f8..8c2d36fca8e 100644 --- a/library/spdm_responder_lib/libspdm_rsp_set_certificate.c +++ b/library/spdm_responder_lib/libspdm_rsp_set_certificate.c @@ -78,7 +78,8 @@ libspdm_return_t libspdm_get_response_set_certificate(libspdm_context_t *spdm_co if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_12) { return libspdm_generate_error_response(spdm_context, - SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, 0, + SPDM_ERROR_CODE_UNSUPPORTED_REQUEST, + SPDM_SET_CERTIFICATE, response_size, response); }