From 900ea17a9b2abca6f1291e67ef1e24bfea4d7bd6 Mon Sep 17 00:00:00 2001 From: Jiewen Yao Date: Tue, 3 Dec 2024 13:01:11 +0800 Subject: [PATCH] Assign correct key pair number for test. Signed-off-by: Jiewen Yao --- .../set_key_pair_info_ack.c | 3 ++- unit_test/test_spdm_responder/key_pair_info.c | 10 +++++----- unit_test/test_spdm_responder/set_key_pair_info_ack.c | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/unit_test/fuzzing/test_responder/test_spdm_responder_set_key_pair_info_ack/set_key_pair_info_ack.c b/unit_test/fuzzing/test_responder/test_spdm_responder_set_key_pair_info_ack/set_key_pair_info_ack.c index a5478488345..bc10ec2d5f9 100644 --- a/unit_test/fuzzing/test_responder/test_spdm_responder_set_key_pair_info_ack/set_key_pair_info_ack.c +++ b/unit_test/fuzzing/test_responder/test_spdm_responder_set_key_pair_info_ack/set_key_pair_info_ack.c @@ -7,6 +7,7 @@ #include "spdm_unit_fuzzing.h" #include "toolchain_harness.h" #include "internal/libspdm_responder_lib.h" +#include "spdm_device_secret_lib_internal.h" #if LIBSPDM_ENABLE_CAPABILITY_SET_KEY_PAIR_INFO_CAP @@ -33,7 +34,7 @@ void libspdm_test_responder_set_key_pair_info_ack(void **State) m_libspdm_use_asym_algo; spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP; - spdm_context->local_context.total_key_pairs = 16; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); response_size = sizeof(response); libspdm_get_response_set_key_pair_info_ack(spdm_context, diff --git a/unit_test/test_spdm_responder/key_pair_info.c b/unit_test/test_spdm_responder/key_pair_info.c index ddbfdb2a0ef..1e34291495f 100644 --- a/unit_test/test_spdm_responder/key_pair_info.c +++ b/unit_test/test_spdm_responder/key_pair_info.c @@ -45,7 +45,7 @@ void libspdm_test_responder_key_pair_info_case1(void **state) m_libspdm_use_asym_algo; spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_GET_KEY_PAIR_INFO_CAP; - spdm_context->local_context.total_key_pairs = 16; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); key_pair_id = 4; public_key_info_len = sizeof(public_key_info_ecp256); @@ -96,7 +96,7 @@ void libspdm_test_responder_key_pair_info_case2(void **state) key_pair_id = 0; m_libspdm_get_key_pair_info_request1.key_pair_id = key_pair_id; - spdm_context->local_context.total_key_pairs = 1; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); response_size = sizeof(response); @@ -136,9 +136,9 @@ void libspdm_test_responder_key_pair_info_case3(void **state) SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_GET_KEY_PAIR_INFO_CAP; /* key_pair_id > total_key_pairs*/ - key_pair_id = 2; + key_pair_id = libspdm_read_total_key_pairs() + 1; m_libspdm_get_key_pair_info_request1.key_pair_id = key_pair_id; - spdm_context->local_context.total_key_pairs = 1; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); response_size = sizeof(response); @@ -181,7 +181,7 @@ void libspdm_test_responder_key_pair_info_case4(void **state) key_pair_id = 1; m_libspdm_get_key_pair_info_request1.key_pair_id = key_pair_id; - spdm_context->local_context.total_key_pairs = key_pair_id; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); response_size = sizeof(response); diff --git a/unit_test/test_spdm_responder/set_key_pair_info_ack.c b/unit_test/test_spdm_responder/set_key_pair_info_ack.c index ff8d6a49c8d..45f878151fa 100644 --- a/unit_test/test_spdm_responder/set_key_pair_info_ack.c +++ b/unit_test/test_spdm_responder/set_key_pair_info_ack.c @@ -46,7 +46,7 @@ void libspdm_test_responder_set_key_pair_info_ack_case1(void **state) m_libspdm_use_asym_algo; spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP; - spdm_context->local_context.total_key_pairs = 16; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); key_pair_id = 4; response_size = sizeof(response); @@ -161,7 +161,7 @@ void libspdm_test_responder_set_key_pair_info_ack_case2(void **state) m_libspdm_use_asym_algo; spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP; - spdm_context->local_context.total_key_pairs = 16; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); key_pair_id = 4; /*set responder need reset*/ @@ -318,7 +318,7 @@ void libspdm_test_responder_set_key_pair_info_ack_case3(void **state) m_libspdm_use_asym_algo; spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP; - spdm_context->local_context.total_key_pairs = 16; + spdm_context->local_context.total_key_pairs = libspdm_read_total_key_pairs(); key_pair_id = 4; /*set responder need reset*/