Browse Source

test(tc): test for AP/RSS interface for ROTPK

Adding new test for AP/RSS interface for reading ROTPK for
each 3 types of ROTPKs for: CCA, secure, and non-secure firmware.

Enabled by PLATFORM_TEST=rss-rotpk.

Update to print output when AP/RSS interface platform tests
pass to be able to reuse expect script functionality in CI.

Change-Id: Icc50b090e18a272378751fda104d209738b5b70c
Signed-off-by: Lauren Wehrmeister <lauren.wehrmeister@arm.com>
pull/2000/head
laurenw-arm 1 year ago
parent
commit
00b7e0bfaf
  1. 15
      plat/arm/board/tc/include/tc_plat.h
  2. 2
      plat/arm/board/tc/nv_counter_test.c
  3. 14
      plat/arm/board/tc/platform.mk
  4. 55
      plat/arm/board/tc/rotpk_test.c
  5. 2
      plat/arm/board/tc/tc_bl31_setup.c

15
plat/arm/board/tc/include/tc_plat.h

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -7,6 +7,10 @@
#ifndef TC_PLAT_H
#define TC_PLAT_H
#ifdef PLATFORM_TEST_ROTPK
#include <rss_crypto_defs.h>
#endif
void tc_bl31_common_platform_setup(void);
#ifdef PLATFORM_TEST_TFM_TESTSUITE
@ -17,4 +21,13 @@ int run_platform_tests(void);
int nv_counter_test(void);
#endif
#ifdef PLATFORM_TEST_ROTPK
struct key_id_info {
enum rss_key_id_builtin_t key_id;
const char *key_id_name;
};
int rotpk_test(void);
#endif
#endif /* TC_PLAT_H */

2
plat/arm/board/tc/nv_counter_test.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, ARM Limited. All rights reserved.
* Copyright (c) 2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

14
plat/arm/board/tc/platform.mk

@ -205,6 +205,20 @@ ifneq (${PLATFORM_TEST},)
PLAT_INCLUDES += -Iinclude/lib/psa
$(eval $(call add_define,PLATFORM_TEST_NV_COUNTERS))
else ifeq (${PLATFORM_TEST},rss-rotpk)
include drivers/arm/rss/rss_comms.mk
# Test code.
BL31_SOURCES += plat/arm/board/tc/rotpk_test.c
# Code under testing.
BL31_SOURCES += lib/psa/rss_platform.c \
drivers/arm/rss/rss_comms.c \
${RSS_COMMS_SOURCES}
PLAT_INCLUDES += -Iinclude/lib/psa
$(eval $(call add_define,PLATFORM_TEST_ROTPK))
else ifeq (${PLATFORM_TEST},tfm-testsuite)
# Add this include as first, before arm_common.mk. This is necessary
# because arm_common.mk builds Mbed TLS, and platform_test.mk can

55
plat/arm/board/tc/rotpk_test.c

@ -0,0 +1,55 @@
/*
* Copyright (c) 2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdint.h>
#include <stdio.h>
#include <drivers/arm/rss_comms.h>
#include <plat/common/platform.h>
#include <rss_platform_api.h>
#include <tc_plat.h>
static void print_hex(const char *key_id_name, size_t key_size, const uint8_t *key_buf)
{
printf("%s = ", key_id_name);
for (int i = 0; i < key_size; i++) {
printf("%02x", key_buf[i]);
}
printf("\n\n");
}
int rotpk_test(void)
{
psa_status_t status;
uint8_t key_buf[128];
size_t key_size;
struct key_id_info key_ids[3] = {
{.key_id = RSS_BUILTIN_KEY_ID_HOST_S_ROTPK, .key_id_name = "Secure-ROTPK"},
{.key_id = RSS_BUILTIN_KEY_ID_HOST_NS_ROTPK, .key_id_name = "NS-ROTPK"},
{.key_id = RSS_BUILTIN_KEY_ID_HOST_CCA_ROTPK, .key_id_name = "CCA-ROTPK"}
};
status = rss_comms_init(PLAT_RSS_AP_SND_MHU_BASE, PLAT_RSS_AP_RCV_MHU_BASE);
if (status != PSA_SUCCESS) {
printf("Failed to initialize RSS communication channel\n");
return -1;
}
for (int i = 0; i < ARRAY_SIZE(key_ids); i++) {
status = rss_platform_key_read(key_ids[i].key_id, key_buf,
sizeof(key_buf), &key_size);
if (status != PSA_SUCCESS) {
printf("Failed to retrieve %s\n", key_ids[i].key_id_name);
return -1;
}
print_hex(key_ids[i].key_id_name, key_size, key_buf);
}
printf("Passed rotpk_test\n");
return 0;
}

2
plat/arm/board/tc/tc_bl31_setup.c

@ -59,6 +59,8 @@ static __dead2 void tc_run_platform_tests(void)
#ifdef PLATFORM_TEST_NV_COUNTERS
tests_failed = nv_counter_test();
#elif PLATFORM_TEST_ROTPK
tests_failed = rotpk_test();
#elif PLATFORM_TEST_TFM_TESTSUITE
tests_failed = run_platform_tests();
#endif

Loading…
Cancel
Save