diff --git a/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/driver/CMakeLists.txt b/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/driver/CMakeLists.txt index d74c5a3..ad6e39b 100644 --- a/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/driver/CMakeLists.txt +++ b/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/driver/CMakeLists.txt @@ -11,6 +11,11 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_REQUIRED_LIBS mbed-ble mbed-events + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + mbed-ble + mbed-events ) diff --git a/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/transport/CMakeLists.txt b/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/transport/CMakeLists.txt index 0717753..4c6e87a 100644 --- a/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/transport/CMakeLists.txt +++ b/connectivity/FEATURE_BLE/source/cordio/TESTS/cordio_hci/transport/CMakeLists.txt @@ -11,6 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_REQUIRED_LIBS mbed-ble + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + mbed-ble ) diff --git a/connectivity/lorawan/tests/TESTS/lorawan/loraradio/CMakeLists.txt b/connectivity/lorawan/tests/TESTS/lorawan/loraradio/CMakeLists.txt index 57d9391..c3bd82b 100644 --- a/connectivity/lorawan/tests/TESTS/lorawan/loraradio/CMakeLists.txt +++ b/connectivity/lorawan/tests/TESTS/lorawan/loraradio/CMakeLists.txt @@ -11,6 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_REQUIRED_LIBS mbed-lorawan + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + mbed-lorawan ) diff --git a/connectivity/mbedtls/tests/TESTS/mbedtls/multi/CMakeLists.txt b/connectivity/mbedtls/tests/TESTS/mbedtls/multi/CMakeLists.txt index a4fb12d..5ad05d2 100644 --- a/connectivity/mbedtls/tests/TESTS/mbedtls/multi/CMakeLists.txt +++ b/connectivity/mbedtls/tests/TESTS/mbedtls/multi/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-mbedtls ) diff --git a/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/CMakeLists.txt b/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/CMakeLists.txt index beb06de..eac12c8 100644 --- a/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/CMakeLists.txt +++ b/connectivity/mbedtls/tests/TESTS/mbedtls/sanity/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-mbedtls ) diff --git a/connectivity/mbedtls/tests/TESTS/mbedtls/selftest/CMakeLists.txt b/connectivity/mbedtls/tests/TESTS/mbedtls/selftest/CMakeLists.txt index f119001..7b47926 100644 --- a/connectivity/mbedtls/tests/TESTS/mbedtls/selftest/CMakeLists.txt +++ b/connectivity/mbedtls/tests/TESTS/mbedtls/selftest/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-mbedtls ) diff --git a/connectivity/netsocket/tests/TESTS/netsocket/dns/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/netsocket/dns/CMakeLists.txt index c3b3fd8..3bffd6b 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/dns/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/netsocket/dns/CMakeLists.txt @@ -13,6 +13,7 @@ list( APPEND TEST_SOURCE_LIST + main.cpp synchronous_dns_multiple.cpp synchronous_dns_multi_ip.cpp synchronous_dns_invalid.cpp @@ -32,7 +33,10 @@ ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/netsocket/nidd/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/netsocket/nidd/CMakeLists.txt index 0f0374f..3458978 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/nidd/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/netsocket/nidd/CMakeLists.txt @@ -13,6 +13,7 @@ list( APPEND TEST_SOURCE_LIST + main.cpp niddsocket_send_timeout.cpp niddsocket_send_repeat.cpp niddsocket_send_invalid.cpp @@ -27,7 +28,10 @@ ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/netsocket/tcp/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/netsocket/tcp/CMakeLists.txt index ff8eecd..44e4596 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/tcp/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/netsocket/tcp/CMakeLists.txt @@ -13,6 +13,7 @@ list( APPEND TEST_SOURCE_LIST + main.cpp tcpsocket_thread_per_socket_safety.cpp tcpsocket_setsockopt_keepalive_valid.cpp tcpsocket_send_timeout.cpp @@ -36,7 +37,10 @@ ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/netsocket/tls/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/netsocket/tls/CMakeLists.txt index dfd4c6f..a10cd75 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/tls/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/netsocket/tls/CMakeLists.txt @@ -13,6 +13,7 @@ list( APPEND TEST_SOURCE_LIST + main.cpp tlssocket_simultaneous.cpp tlssocket_send_unconnected.cpp tlssocket_send_timeout.cpp @@ -31,7 +32,10 @@ ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/netsocket/udp/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/netsocket/udp/CMakeLists.txt index 61cb9de..f2a1128 100644 --- a/connectivity/netsocket/tests/TESTS/netsocket/udp/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/netsocket/udp/CMakeLists.txt @@ -13,6 +13,7 @@ list( APPEND TEST_SOURCE_LIST + main.cpp udpsocket_bind_port.cpp udpsocket_bind_address_null.cpp udpsocket_bind_address_invalid.cpp @@ -33,7 +34,10 @@ ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/network/emac/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/network/emac/CMakeLists.txt index b30576b..001c7da 100644 --- a/connectivity/netsocket/tests/TESTS/network/emac/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/network/emac/CMakeLists.txt @@ -10,24 +10,30 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST - emac_TestMemoryManager.cpp - emac_TestNetworkStack.cpp - emac_ctp.cpp - emac_membuf.cpp - emac_test_broadcast.cpp - emac_test_initialize.cpp - emac_test_memory.cpp - emac_test_multicast_filter.cpp - emac_test_unicast.cpp - emac_test_unicast_burst.cpp - emac_test_unicast_frame_len.cpp - emac_test_unicast_long.cpp - emac_util.cpp +list( + APPEND + TEST_SOURCE_LIST + main.cpp + emac_TestMemoryManager.cpp + emac_TestNetworkStack.cpp + emac_ctp.cpp + emac_membuf.cpp + emac_test_broadcast.cpp + emac_test_initialize.cpp + emac_test_memory.cpp + emac_test_multicast_filter.cpp + emac_test_unicast.cpp + emac_test_unicast_burst.cpp + emac_test_unicast_frame_len.cpp + emac_test_unicast_long.cpp + emac_util.cpp ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-emac + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-emac ) diff --git a/connectivity/netsocket/tests/TESTS/network/interface/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/network/interface/CMakeLists.txt index 46795bf..845ac7b 100644 --- a/connectivity/netsocket/tests/TESTS/network/interface/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/network/interface/CMakeLists.txt @@ -10,13 +10,19 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST - networkinterface_conn_disc_repeat.cpp - networkinterface_status.cpp +list( + APPEND + TEST_SOURCE_LIST + main.cpp + networkinterface_conn_disc_repeat.cpp + networkinterface_status.cpp ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/network/l3ip/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/network/l3ip/CMakeLists.txt index 1ff2f27..0474595 100644 --- a/connectivity/netsocket/tests/TESTS/network/l3ip/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/network/l3ip/CMakeLists.txt @@ -10,10 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST cellular_driver_l3ip.cpp) +list( + APPEND + TEST_SOURCE_LIST + main.cpp + cellular_driver_l3ip.cpp +) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/netsocket/tests/TESTS/network/multihoming/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/network/multihoming/CMakeLists.txt index 529f58a..671361c 100644 --- a/connectivity/netsocket/tests/TESTS/network/multihoming/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/network/multihoming/CMakeLists.txt @@ -10,14 +10,21 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST - multihoming_asynchronous_dns.cpp - multihoming_synchronous_dns.cpp - multihoming_udpsocket_echotest.cpp +list( + APPEND + TEST_SOURCE_LIST + main.cpp + multihoming_asynchronous_dns.cpp + multihoming_synchronous_dns.cpp + multihoming_udpsocket_echotest.cpp ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket mbed-nanostack + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket + mbed-nanostack ) diff --git a/connectivity/netsocket/tests/TESTS/network/wifi/CMakeLists.txt b/connectivity/netsocket/tests/TESTS/network/wifi/CMakeLists.txt index a710fb4..e0de666 100644 --- a/connectivity/netsocket/tests/TESTS/network/wifi/CMakeLists.txt +++ b/connectivity/netsocket/tests/TESTS/network/wifi/CMakeLists.txt @@ -10,29 +10,35 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST - get_interface.cpp - get_security.cpp - wifi-constructor.cpp - wifi_connect.cpp - wifi_connect_disconnect_nonblock.cpp - wifi_connect_disconnect_repeat.cpp - wifi_connect_nocredentials.cpp - wifi_connect_params_channel.cpp - wifi_connect_params_channel_fail.cpp - wifi_connect_params_null.cpp - wifi_connect_params_valid_secure.cpp - wifi_connect_secure.cpp - wifi_connect_secure_fail.cpp - wifi_get_rssi.cpp - wifi_scan.cpp - wifi_scan_null.cpp - wifi_set_channel.cpp - wifi_set_credential.cpp +list( + APPEND + TEST_SOURCE_LIST + main.cpp + get_interface.cpp + get_security.cpp + wifi-constructor.cpp + wifi_connect.cpp + wifi_connect_disconnect_nonblock.cpp + wifi_connect_disconnect_repeat.cpp + wifi_connect_nocredentials.cpp + wifi_connect_params_channel.cpp + wifi_connect_params_channel_fail.cpp + wifi_connect_params_null.cpp + wifi_connect_params_valid_secure.cpp + wifi_connect_secure.cpp + wifi_connect_secure_fail.cpp + wifi_get_rssi.cpp + wifi_scan.cpp + wifi_scan_null.cpp + wifi_set_channel.cpp + wifi_set_credential.cpp ) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_REQUIRED_LIBS mbed-netsocket + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_REQUIRED_LIBS + mbed-netsocket ) diff --git a/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt b/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt index 7c2e481..f57d649 100644 --- a/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt +++ b/connectivity/nfc/tests/TESTS/nfc/eeprom/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-nfc ) diff --git a/drivers/tests/TESTS/mbed_drivers/buffered_serial/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/buffered_serial/CMakeLists.txt index e1edef3..cd90ed6 100644 --- a/drivers/tests/TESTS/mbed_drivers/buffered_serial/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/buffered_serial/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/c_strings/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/c_strings/CMakeLists.txt index 010b398..dfce13e 100644 --- a/drivers/tests/TESTS/mbed_drivers/c_strings/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/c_strings/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/crc/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/crc/CMakeLists.txt index 1daa237..62a3d15 100644 --- a/drivers/tests/TESTS/mbed_drivers/crc/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/crc/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/dev_null/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/dev_null/CMakeLists.txt index 7f49269..9f3b10b 100644 --- a/drivers/tests/TESTS/mbed_drivers/dev_null/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/dev_null/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/echo/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/echo/CMakeLists.txt index 5d32243..70e2e72 100644 --- a/drivers/tests/TESTS/mbed_drivers/echo/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/echo/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/flashiap/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/flashiap/CMakeLists.txt index dfdf7f5..5fa36d2 100644 --- a/drivers/tests/TESTS/mbed_drivers/flashiap/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/flashiap/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/generic_tests/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/generic_tests/CMakeLists.txt index a834dc9..786ca1d 100644 --- a/drivers/tests/TESTS/mbed_drivers/generic_tests/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/generic_tests/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/lp_ticker/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/lp_ticker/CMakeLists.txt index 1eea563..11110b2 100644 --- a/drivers/tests/TESTS/mbed_drivers/lp_ticker/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/lp_ticker/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/lp_timeout/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/lp_timeout/CMakeLists.txt index 46cc546..3ee2163 100644 --- a/drivers/tests/TESTS/mbed_drivers/lp_timeout/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/lp_timeout/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/lp_timer/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/lp_timer/CMakeLists.txt index c2f283b..fad8a3a 100644 --- a/drivers/tests/TESTS/mbed_drivers/lp_timer/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/lp_timer/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/mem_trace/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/mem_trace/CMakeLists.txt index e71591d..ec44253 100644 --- a/drivers/tests/TESTS/mbed_drivers/mem_trace/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/mem_trace/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/race_test/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/race_test/CMakeLists.txt index 437827a..4e95b2b 100644 --- a/drivers/tests/TESTS/mbed_drivers/race_test/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/race_test/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/reset_reason/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/reset_reason/CMakeLists.txt index 913e0d3..3a9dea4 100644 --- a/drivers/tests/TESTS/mbed_drivers/reset_reason/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/reset_reason/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/rtc/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/rtc/CMakeLists.txt index 9adb6e3..e9ae3f1 100644 --- a/drivers/tests/TESTS/mbed_drivers/rtc/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/rtc/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/sleep_lock/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/sleep_lock/CMakeLists.txt index 339516b..0ca0099 100644 --- a/drivers/tests/TESTS/mbed_drivers/sleep_lock/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/sleep_lock/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/stl_features/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/stl_features/CMakeLists.txt index f07b6ff..1c0d494 100644 --- a/drivers/tests/TESTS/mbed_drivers/stl_features/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/stl_features/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/ticker/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/ticker/CMakeLists.txt index 93922eb..6aed7b9 100644 --- a/drivers/tests/TESTS/mbed_drivers/ticker/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/ticker/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/timeout/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/timeout/CMakeLists.txt index 00a8284..58e37b1 100644 --- a/drivers/tests/TESTS/mbed_drivers/timeout/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/timeout/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/timer/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/timer/CMakeLists.txt index c7aa2d8..983f213 100644 --- a/drivers/tests/TESTS/mbed_drivers/timer/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/timer/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/timerevent/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/timerevent/CMakeLists.txt index ec30a4a..cb36315 100644 --- a/drivers/tests/TESTS/mbed_drivers/timerevent/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/timerevent/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/unbuffered_serial/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/unbuffered_serial/CMakeLists.txt index c2bf3c3..08b37e0 100644 --- a/drivers/tests/TESTS/mbed_drivers/unbuffered_serial/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/unbuffered_serial/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/watchdog/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/watchdog/CMakeLists.txt index 836d3d1..579c438 100644 --- a/drivers/tests/TESTS/mbed_drivers/watchdog/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/watchdog/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/drivers/tests/TESTS/mbed_drivers/watchdog_reset/CMakeLists.txt b/drivers/tests/TESTS/mbed_drivers/watchdog_reset/CMakeLists.txt index 445e6f8..3313c0d 100644 --- a/drivers/tests/TESTS/mbed_drivers/watchdog_reset/CMakeLists.txt +++ b/drivers/tests/TESTS/mbed_drivers/watchdog_reset/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/events/tests/TESTS/events/equeue/CMakeLists.txt b/events/tests/TESTS/events/equeue/CMakeLists.txt index b5acea9..f49813e 100644 --- a/events/tests/TESTS/events/equeue/CMakeLists.txt +++ b/events/tests/TESTS/events/equeue/CMakeLists.txt @@ -11,6 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_REQUIRED_LIBS mbed-events + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + mbed-events ) diff --git a/events/tests/TESTS/events/queue/CMakeLists.txt b/events/tests/TESTS/events/queue/CMakeLists.txt index 65861b6..06183db 100644 --- a/events/tests/TESTS/events/queue/CMakeLists.txt +++ b/events/tests/TESTS/events/queue/CMakeLists.txt @@ -11,6 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_REQUIRED_LIBS mbed-events + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + mbed-events ) diff --git a/events/tests/TESTS/events/timing/CMakeLists.txt b/events/tests/TESTS/events/timing/CMakeLists.txt index 1acdce7..f979ea3 100644 --- a/events/tests/TESTS/events/timing/CMakeLists.txt +++ b/events/tests/TESTS/events/timing/CMakeLists.txt @@ -11,6 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} - TEST_REQUIRED_LIBS mbed-events + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + mbed-events ) diff --git a/hal/tests/TESTS/mbed_hal/common_tickers/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/common_tickers/CMakeLists.txt index 8f38d36..b2e0db5 100644 --- a/hal/tests/TESTS/mbed_hal/common_tickers/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/common_tickers/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/common_tickers_freq/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/common_tickers_freq/CMakeLists.txt index d23c4ea..8561881 100644 --- a/hal/tests/TESTS/mbed_hal/common_tickers_freq/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/common_tickers_freq/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/crc/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/crc/CMakeLists.txt index a8f95c5..25606ea 100644 --- a/hal/tests/TESTS/mbed_hal/crc/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/crc/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/critical_section/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/critical_section/CMakeLists.txt index 23e98b8..03faeb9 100644 --- a/hal/tests/TESTS/mbed_hal/critical_section/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/critical_section/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/flash/functional_tests/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/flash/functional_tests/CMakeLists.txt index b356590..fb04da3 100644 --- a/hal/tests/TESTS/mbed_hal/flash/functional_tests/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/flash/functional_tests/CMakeLists.txt @@ -3,11 +3,16 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../.. CACHE INTERNAL "") +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.. CACHE INTERNAL "") set(TEST_TARGET mbed-hal-flash-functional-tests) include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/lp_ticker/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/lp_ticker/CMakeLists.txt index 0d901f9..b60c670 100644 --- a/hal/tests/TESTS/mbed_hal/lp_ticker/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/lp_ticker/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/minimum_requirements/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/minimum_requirements/CMakeLists.txt index 9c319ce..70e8700 100644 --- a/hal/tests/TESTS/mbed_hal/minimum_requirements/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/minimum_requirements/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/mpu/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/mpu/CMakeLists.txt index ffd7fe9..13bef3b 100644 --- a/hal/tests/TESTS/mbed_hal/mpu/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/mpu/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/ospi/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/ospi/CMakeLists.txt index 9e65d61..7fae404 100644 --- a/hal/tests/TESTS/mbed_hal/ospi/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/ospi/CMakeLists.txt @@ -10,7 +10,12 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} - TEST_SOURCES ospi_test_utils.cpp - TEST_INCLUDE_DIRS flash_configs +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + ospi_test_utils.cpp + TEST_INCLUDE_DIRS + flash_configs ) diff --git a/hal/tests/TESTS/mbed_hal/pinmap/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/pinmap/CMakeLists.txt index 43d32cc..4b9e217 100644 --- a/hal/tests/TESTS/mbed_hal/pinmap/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/pinmap/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/qspi/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/qspi/CMakeLists.txt index 9ba8a34..b06f73c 100644 --- a/hal/tests/TESTS/mbed_hal/qspi/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/qspi/CMakeLists.txt @@ -22,10 +22,20 @@ set(FLASH_TARGET_CONFIG_HEADER SiliconLabs/EFM32GG11_STK3701) endif() -list(APPEND TEST_HEADER_DIRS flash_configs flash_configs/${FLASH_TARGET_CONFIG_HEADER}) +list( + APPEND + TEST_HEADER_DIRS + flash_configs + flash_configs/${FLASH_TARGET_CONFIG_HEADER} +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} - TEST_SOURCES qspi_test_utils.cpp - TEST_INCLUDE_DIRS ${TEST_HEADER_DIRS} +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + qspi_test_utils.cpp + TEST_INCLUDE_DIRS + ${TEST_HEADER_DIRS} ) diff --git a/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt index bf8118f..e68344d 100644 --- a/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/rtc/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/rtc/CMakeLists.txt index 2f4ca99..290eaef 100644 --- a/hal/tests/TESTS/mbed_hal/rtc/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/rtc/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt index ab6a85f..b71ff00 100644 --- a/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/rtc_time/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/rtc_time/CMakeLists.txt index 4ad84e3..5f7d1f8 100644 --- a/hal/tests/TESTS/mbed_hal/rtc_time/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/rtc_time/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/rtc_time_conv/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/rtc_time_conv/CMakeLists.txt index 5afe6d4..96b56f7 100644 --- a/hal/tests/TESTS/mbed_hal/rtc_time_conv/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/rtc_time_conv/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/sleep/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/sleep/CMakeLists.txt index 671daf0..aed5bab 100644 --- a/hal/tests/TESTS/mbed_hal/sleep/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/sleep/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/sleep_manager/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/sleep_manager/CMakeLists.txt index 5fcd968..3dc375f 100644 --- a/hal/tests/TESTS/mbed_hal/sleep_manager/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/sleep_manager/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/CMakeLists.txt index 6573883..df182d5 100644 --- a/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/sleep_manager_racecondition/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt index e916e6c..9f3d536 100644 --- a/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/stack_size_unification/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/ticker/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/ticker/CMakeLists.txt index 5254b13..4352cba 100644 --- a/hal/tests/TESTS/mbed_hal/ticker/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/ticker/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/trng/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/trng/CMakeLists.txt index 69ad576..344d44a 100644 --- a/hal/tests/TESTS/mbed_hal/trng/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/trng/CMakeLists.txt @@ -10,10 +10,26 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST base64b/base64b.cpp pithy/pithy.c) -list(APPEND TEST_INC_DIRS base64b pithy) +list( + APPEND + TEST_SOURCE_LIST + main.cpp + base64b/base64b.cpp + pithy/pithy.c +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} - TEST_SOURCES ${TEST_SOURCE_LIST} - TEST_INCLUDE_DIRS ${TEST_INC_DIRS} +list( + APPEND + TEST_INC_DIRS + base64b + pithy +) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} + TEST_INCLUDE_DIRS + ${TEST_INC_DIRS} ) diff --git a/hal/tests/TESTS/mbed_hal/us_ticker/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/us_ticker/CMakeLists.txt index 546d7b3..d04c496 100644 --- a/hal/tests/TESTS/mbed_hal/us_ticker/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/us_ticker/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/watchdog/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/watchdog/CMakeLists.txt index ef11ebc..e216dfa 100644 --- a/hal/tests/TESTS/mbed_hal/watchdog/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/watchdog/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/watchdog_reset/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/watchdog_reset/CMakeLists.txt index 3fa9a53..347ba68 100644 --- a/hal/tests/TESTS/mbed_hal/watchdog_reset/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/watchdog_reset/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal/watchdog_timing/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/watchdog_timing/CMakeLists.txt index 3ea401e..6ecc6f9 100644 --- a/hal/tests/TESTS/mbed_hal/watchdog_timing/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/watchdog_timing/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/CMakeLists.txt deleted file mode 100644 index ec4d8d5..0000000 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2020 ARM Limited. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) - -set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../.. CACHE INTERNAL "") -set(TEST_TARGET mbed-hal-fpga-ci-test-shield) - -include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) - -project(${TEST_TARGET}) - -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/analogin/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/analogin/CMakeLists.txt index 054c8dc..b9d707c 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/analogin/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/analogin/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio/CMakeLists.txt index ebc0da5..d20dbd7 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/CMakeLists.txt index 7ff54b2..293857c 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/i2c/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/i2c/CMakeLists.txt index ba2cf9c..d9ec3eb 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/i2c/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/i2c/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/pwm/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/pwm/CMakeLists.txt index a5b10f0..1c68b90 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/pwm/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/pwm/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/spi/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/spi/CMakeLists.txt index fe3fc88..2148fbe 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/spi/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/spi/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/uart/CMakeLists.txt b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/uart/CMakeLists.txt index 7c892b4..362fae1 100644 --- a/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/uart/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal_fpga_ci_test_shield/uart/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/hal/tests/TESTS/mbed_timing_fpga_ci_test_shield/watchdog/CMakeLists.txt b/hal/tests/TESTS/mbed_timing_fpga_ci_test_shield/watchdog/CMakeLists.txt index a65b5ef..e867dae 100644 --- a/hal/tests/TESTS/mbed_timing_fpga_ci_test_shield/watchdog/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_timing_fpga_ci_test_shield/watchdog/CMakeLists.txt @@ -10,6 +10,18 @@ project(${TEST_TARGET}) -list(APPEND TEST_REQ_LIBS_LIST mbed-fpga-ci-test-shield mbed-storage-blockdevice) +list( + APPEND + TEST_REQ_LIBS_LIST + mbed-fpga-ci-test-shield + mbed-storage-blockdevice +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_REQUIRED_LIBS ${TEST_REQ_LIBS_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + TEST_REQUIRED_LIBS + ${TEST_REQ_LIBS_LIST} +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/CMakeLists.txt index 5fc1be9..7ece49f 100644 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/CMakeLists.txt +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/CMakeLists.txt @@ -6,7 +6,6 @@ inc inc/psa mbedtls - pal services/platform services/attestation services/attestation/qcbor @@ -28,13 +27,6 @@ mbedtls/psa_crypto_storage.c mbedtls/psa_its_file.c - pal/pal_attestation_eat.c - pal/pal_attestation_intf.c - pal/pal_client_api_empty_intf.c - pal/pal_client_api_intf.c - pal/pal_internal_trusted_storage_intf.c - pal/pal_protected_storage_intf.c - services/attestation/attest_boot_status_loader.c services/attestation/attest_crypto.c services/attestation/attest_crypto_keys.c @@ -78,3 +70,6 @@ mbed-storage-kv-global-api mbed-device_key ) + +add_subdirectory(test_abstraction_layers) + diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/attestation/test/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/attestation/test/CMakeLists.txt new file mode 100644 index 0000000..5d82e08 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/attestation/test/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-attestation) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_attestation/test_a001/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_attestation/test_a001/CMakeLists.txt new file mode 100644 index 0000000..d120897 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_attestation/test_a001/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-attestation-a001) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_a001.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s001/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s001/CMakeLists.txt new file mode 100644 index 0000000..aff1a90 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s001/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s001) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s001.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s002/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s002/CMakeLists.txt new file mode 100644 index 0000000..0daeb59 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s002/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s002) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s002.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s003/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s003/CMakeLists.txt new file mode 100644 index 0000000..69ed482 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s003/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s003) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s003.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s004/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s004/CMakeLists.txt new file mode 100644 index 0000000..c010cf3 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s004/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s004) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s004.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s005/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s005/CMakeLists.txt new file mode 100644 index 0000000..c1daabf --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s005/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s005) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s005.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s006/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s006/CMakeLists.txt new file mode 100644 index 0000000..91a4e77 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s006/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s006) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s006.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s007/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s007/CMakeLists.txt new file mode 100644 index 0000000..bc96b48 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s007/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s007) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s007.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s008/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s008/CMakeLists.txt new file mode 100644 index 0000000..8a0f8e0 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s008/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s008) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s008.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s009/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s009/CMakeLists.txt new file mode 100644 index 0000000..430e3c2 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s009/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s009) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s009.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s010/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s010/CMakeLists.txt new file mode 100644 index 0000000..af6cd33 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/compliance_its/test_s010/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-compliance-its-s010) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.c + test_entry.c + test_s010.c + TEST_REQUIRED_LIBS + mbed-psa-tal +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/crypto_init/test/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/crypto_init/test/CMakeLists.txt new file mode 100644 index 0000000..d8590a7 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/crypto_init/test/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-crypto-init) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/entropy_inject/test/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/entropy_inject/test/CMakeLists.txt new file mode 100644 index 0000000..7e982b1 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/entropy_inject/test/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-entropy-inject) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/CMakeLists.txt new file mode 100644 index 0000000..d27e3a9 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/TESTS/its_ps/test/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) + +set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../ CACHE INTERNAL "") +set(TEST_TARGET mbed-platform-psa-its-ps) + +include(${MBED_PATH}/tools/cmake/mbed_greentea.cmake) + +project(${TEST_TARGET}) + +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_eat.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_eat.c deleted file mode 100644 index 8683680..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_eat.c +++ /dev/null @@ -1,365 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "pal_attestation_eat.h" - -uint32_t mandatory_claims = 0, mandaroty_sw_components = 0; -bool_t sw_component_present = 0; - -static int get_items_in_map(QCBORDecodeContext *decode_context, - struct items_to_get_t *item_list) -{ - int item_index; - QCBORItem item; - struct items_to_get_t *item_ptr = item_list; - - /* initialize the data type of all items in the list */ - while (item_ptr->label != 0) { - item_ptr->item.uDataType = QCBOR_TYPE_NONE; - item_ptr++; - } - - QCBORDecode_GetNext(decode_context, &item); - if (item.uDataType != QCBOR_TYPE_MAP) { - return PAL_ATTEST_ERROR; - } - - for (item_index = item.val.uCount; item_index != 0; item_index--) { - if (QCBORDecode_GetNext(decode_context, &item) != QCBOR_SUCCESS) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - if (item.uLabelType != QCBOR_TYPE_INT64) { - continue; - } - - item_ptr = item_list; - while (item_ptr->label != 0) { - if (item.label.int64 == item_ptr->label) { - item_ptr->item = item; - } - item_ptr++; - } - } - - return PAL_ATTEST_SUCCESS; -} - -static int get_item_in_map(QCBORDecodeContext *decode_context, - int32_t label, - QCBORItem *item) -{ - struct items_to_get_t item_list[2]; - - item_list[0].label = label; - item_list[1].label = 0; - - if (get_items_in_map(decode_context, item_list)) { - return PAL_ATTEST_ERROR; - } - - if (item_list[0].item.uDataType == QCBOR_TYPE_NONE) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - *item = item_list[0].item; - - return PAL_ATTEST_SUCCESS; -} - -static int parse_unprotected_headers(QCBORDecodeContext *decode_context, - struct useful_buf_c *child, - bool *loop_back) -{ - struct items_to_get_t item_list[3]; - - item_list[0].label = COSE_HEADER_PARAM_KID; - item_list[1].label = T_COSE_SHORT_CIRCUIT_LABEL; - item_list[2].label = 0; - *loop_back = false; - - if (get_items_in_map(decode_context, item_list)) { - return PAL_ATTEST_ERROR; - } - - if (item_list[1].item.uDataType == QCBOR_TYPE_TRUE) { - *loop_back = true; - } - - if (item_list[0].item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - *child = item_list[0].item.val.string; - - return PAL_ATTEST_SUCCESS; -} - -static int parse_protected_headers(struct useful_buf_c protected_headers, - int32_t *alg_id) -{ - QCBORDecodeContext decode_context; - QCBORItem item; - - QCBORDecode_Init(&decode_context, protected_headers, 0); - - if (get_item_in_map(&decode_context, COSE_HEADER_PARAM_ALG, &item)) { - return PAL_ATTEST_ERROR; - } - - if (QCBORDecode_Finish(&decode_context)) { - return PAL_ATTEST_ERROR; - } - - if ((item.uDataType != QCBOR_TYPE_INT64) || (item.val.int64 > INT32_MAX)) { - return PAL_ATTEST_ERROR; - } - - *alg_id = (int32_t)item.val.int64; - - return PAL_ATTEST_SUCCESS; -} - -/** - @brief - This API will verify the claims - @param - decode_context : The buffer containing the challenge - item : context for decoding the data items - completed_challenge : Buffer containing the challenge - @return - error status -**/ -static int parse_claims(QCBORDecodeContext *decode_context, QCBORItem item, - struct useful_buf_c completed_challenge) -{ - int i, count = 0; - int status = PAL_ATTEST_SUCCESS; - - /* Parse each claim and validate their data type */ - while (status == PAL_ATTEST_SUCCESS) { - status = QCBORDecode_GetNext(decode_context, &item); - if (status != PAL_ATTEST_SUCCESS) { - break; - } - - mandatory_claims |= 1 << (EAT_CBOR_ARM_RANGE_BASE - item.label.int64); - if (item.uLabelType == QCBOR_TYPE_INT64) { - if (item.label.int64 == EAT_CBOR_ARM_LABEL_NONCE) { - if (item.uDataType == QCBOR_TYPE_BYTE_STRING) { - /* Given challenge vs challenge in token */ - if (UsefulBuf_Compare(item.val.string, completed_challenge)) { - return PAL_ATTEST_TOKEN_CHALLENGE_MISMATCH; - } - } else { - return PAL_ATTEST_TOKEN_NOT_SUPPORTED; - } - } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_BOOT_SEED || - item.label.int64 == EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID || - item.label.int64 == EAT_CBOR_ARM_LABEL_UEID) { - if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_ORIGINATION || - item.label.int64 == EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION || - item.label.int64 == EAT_CBOR_ARM_LABEL_HW_VERSION) { - if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_CLIENT_ID || - item.label.int64 == EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE) { - if (item.uDataType != QCBOR_TYPE_INT64) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_SW_COMPONENTS) { - if (item.uDataType != QCBOR_TYPE_ARRAY) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - sw_component_present = 1; - status = QCBORDecode_GetNext(decode_context, &item); - if (status != PAL_ATTEST_SUCCESS) { - continue; - } - - count = item.val.uCount; - for (i = 0; i <= count; i++) { - mandaroty_sw_components |= 1 << item.label.int64; - - if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT) { - if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT_DESC) { - if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_VERSION) { - if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_SIGNER_ID) { - if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_EPOCH) { - if (item.uDataType != QCBOR_TYPE_INT64) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_TYPE) { - if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } - - if (i < count) { - status = QCBORDecode_GetNext(decode_context, &item); - if (status != PAL_ATTEST_SUCCESS) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - } - } - - } - } else { - /* ToDo: Add other claim types */ - } - } - - if (status == QCBOR_ERR_HIT_END) { - return PAL_ATTEST_SUCCESS; - } else { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } -} - -/** - @brief - This API will verify the attestation token - @param - challenge : The buffer containing the challenge - challenge_size : Size of the challenge buffer - token : The buffer containing the attestation token - token_size : Size of the token buffer - @return - error status -**/ -int32_t pal_initial_attest_verify_token(uint8_t *challenge, uint32_t challenge_size, - uint8_t *token, uint32_t token_size) -{ - int status = PAL_ATTEST_SUCCESS; - bool short_circuit; - int32_t cose_algorithm_id; - QCBORItem item; - QCBORDecodeContext decode_context; - struct useful_buf_c completed_challenge; - struct useful_buf_c completed_token; - struct useful_buf_c payload; - struct useful_buf_c protected_headers; - struct useful_buf_c kid; - - /* Construct the token buffer for validation */ - completed_token.ptr = token; - completed_token.len = token_size; - - /* Construct the challenge buffer for validation */ - completed_challenge.ptr = challenge; - completed_challenge.len = challenge_size; - - /* - ------------------------- - | CBOR Array Type | - ------------------------- - | Protected Headers | - ------------------------- - | Unprotected Headers | - ------------------------- - | Payload | - ------------------------- - | Signature | - ------------------------- - */ - - /* Initialize the decorder */ - QCBORDecode_Init(&decode_context, completed_token, QCBOR_DECODE_MODE_NORMAL); - - /* Get the Header */ - QCBORDecode_GetNext(&decode_context, &item); - - /* Check the CBOR Array type. Check if the count is 4. - * Only COSE_SIGN1 is supported now. - */ - if (item.uDataType != QCBOR_TYPE_ARRAY || item.val.uCount != 4 || - !QCBORDecode_IsTagged(&decode_context, &item, CBOR_TAG_COSE_SIGN1)) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - /* Get the next headers */ - QCBORDecode_GetNext(&decode_context, &item); - if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - protected_headers = item.val.string; - - /* Parse the protected headers and check the data type and value*/ - status = parse_protected_headers(protected_headers, &cose_algorithm_id); - if (status != PAL_ATTEST_SUCCESS) { - return status; - } - - /* Parse the unprotected headers and check the data type and value */ - short_circuit = false; - status = parse_unprotected_headers(&decode_context, &kid, &short_circuit); - if (status != PAL_ATTEST_SUCCESS) { - return status; - } - - /* Get the payload */ - QCBORDecode_GetNext(&decode_context, &item); - if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - payload = item.val.string; - - /* Get the digital signature */ - QCBORDecode_GetNext(&decode_context, &item); - if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - /* Initialize the Decoder and validate the payload format */ - QCBORDecode_Init(&decode_context, payload, QCBOR_DECODE_MODE_NORMAL); - status = QCBORDecode_GetNext(&decode_context, &item); - if (status != PAL_ATTEST_SUCCESS) { - return status; - } - - if (item.uDataType != QCBOR_TYPE_MAP) { - return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; - } - - /* Parse the payload and check the data type of each claim */ - status = parse_claims(&decode_context, item, completed_challenge); - if (status != PAL_ATTEST_SUCCESS) { - return status; - } - - if ((mandatory_claims & MANDATORY_CLAIM_WITH_SW_COMP) == MANDATORY_CLAIM_WITH_SW_COMP) { - if ((mandaroty_sw_components & MANDATORY_SW_COMP) != MANDATORY_SW_COMP) { - return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS; - } - } else if ((mandatory_claims & MANDATORY_CLAIM_NO_SW_COMP) != MANDATORY_CLAIM_NO_SW_COMP) { - return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS; - } - - return PAL_ATTEST_SUCCESS; -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_eat.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_eat.h deleted file mode 100644 index 9f435fb..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_eat.h +++ /dev/null @@ -1,73 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "qcbor.h" -#include "pal_common.h" - -#define PAL_ATTEST_MIN_ERROR 30 - -#define COSE_HEADER_PARAM_ALG 1 -#define COSE_HEADER_PARAM_KID 4 - -#define MANDATORY_CLAIM_WITH_SW_COMP 862 -#define MANDATORY_CLAIM_NO_SW_COMP 926 -#define MANDATORY_SW_COMP 36 -#define CBOR_ARM_TOTAL_CLAIM_INSTANCE 10 - -/* - CBOR Label for proprietary header indicating short-circuit - signing was used. Just a random number in the proprietary - label space */ -#define T_COSE_SHORT_CIRCUIT_LABEL (-8675309) - -#define EAT_CBOR_ARM_RANGE_BASE (-75000) -#define EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION (EAT_CBOR_ARM_RANGE_BASE - 0) -#define EAT_CBOR_ARM_LABEL_CLIENT_ID (EAT_CBOR_ARM_RANGE_BASE - 1) -#define EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE (EAT_CBOR_ARM_RANGE_BASE - 2) -#define EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID (EAT_CBOR_ARM_RANGE_BASE - 3) -#define EAT_CBOR_ARM_LABEL_BOOT_SEED (EAT_CBOR_ARM_RANGE_BASE - 4) -#define EAT_CBOR_ARM_LABEL_HW_VERSION (EAT_CBOR_ARM_RANGE_BASE - 5) -#define EAT_CBOR_ARM_LABEL_SW_COMPONENTS (EAT_CBOR_ARM_RANGE_BASE - 6) -#define EAT_CBOR_ARM_LABEL_NO_SW_COMPONENTS (EAT_CBOR_ARM_RANGE_BASE - 7) -#define EAT_CBOR_ARM_LABEL_NONCE (EAT_CBOR_ARM_RANGE_BASE - 8) -#define EAT_CBOR_ARM_LABEL_UEID (EAT_CBOR_ARM_RANGE_BASE - 9) -#define EAT_CBOR_ARM_LABEL_ORIGINATION (EAT_CBOR_ARM_RANGE_BASE - 10) - -#define EAT_CBOR_SW_COMPONENT_TYPE (1u) -#define EAT_CBOR_SW_COMPONENT_MEASUREMENT (2u) -#define EAT_CBOR_SW_COMPONENT_EPOCH (3u) -#define EAT_CBOR_SW_COMPONENT_VERSION (4u) -#define EAT_CBOR_SW_COMPONENT_SIGNER_ID (5u) -#define EAT_CBOR_SW_COMPONENT_MEASUREMENT_DESC (6u) - - -enum attestation_error_code { - PAL_ATTEST_SUCCESS = 0, - PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING = PAL_ATTEST_MIN_ERROR, - PAL_ATTEST_TOKEN_CHALLENGE_MISMATCH, - PAL_ATTEST_TOKEN_NOT_SUPPORTED, - PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS, - PAL_ATTEST_ERROR, -}; - -struct items_to_get_t { - int64_t label; - QCBORItem item; -}; - -int32_t pal_initial_attest_verify_token(uint8_t *challenge, uint32_t challenge_size, - uint8_t *token, uint32_t token_size); diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_intf.c deleted file mode 100644 index 66b3ab4..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_intf.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - - -#include "pal_attestation_intf.h" - -/** - @brief - This API will call the requested attestation function - @param - type : function code - valist : variable argument list - @return - error status -**/ -int32_t pal_attestation_function(int type, va_list valist) -{ - uint8_t *challenge, *token; - uint32_t challenge_size, *token_size, verify_token_size; - - switch (type) { - case PAL_INITIAL_ATTEST_GET_TOKEN: - challenge = va_arg(valist, uint8_t *); - challenge_size = va_arg(valist, uint32_t); - token = va_arg(valist, uint8_t *); - token_size = va_arg(valist, uint32_t *); - return psa_initial_attest_get_token(challenge, challenge_size, token, token_size); - case PAL_INITIAL_ATTEST_GET_TOKEN_SIZE: - challenge_size = va_arg(valist, uint32_t); - token_size = va_arg(valist, uint32_t *); - return psa_initial_attest_get_token_size(challenge_size, token_size); - case PAL_INITIAL_ATTEST_VERIFY_TOKEN: - challenge = va_arg(valist, uint8_t *); - challenge_size = va_arg(valist, uint32_t); - token = va_arg(valist, uint8_t *); - verify_token_size = va_arg(valist, uint32_t); - return pal_initial_attest_verify_token(challenge, challenge_size, - token, verify_token_size); - default: - return PAL_STATUS_UNSUPPORTED_FUNC; - } -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_intf.h deleted file mode 100644 index fdefc83..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_attestation_intf.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _PAL_INITIAL_ATTESTATION_H_ -#define _PAL_INITIAL_ATTESTATION_H_ - -#include "psa_initial_attestation_api.h" -#include "pal_attestation_eat.h" - -enum attestation_function_code { - PAL_INITIAL_ATTEST_GET_TOKEN = 0x1, - PAL_INITIAL_ATTEST_GET_TOKEN_SIZE = 0x2, - PAL_INITIAL_ATTEST_VERIFY_TOKEN = 0x3, -}; - -int32_t pal_attestation_function(int type, va_list valist); -#endif /* _PAL_INITIAL_ATTESTATION_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_empty_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_empty_intf.c deleted file mode 100644 index 8e9b90d..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_empty_intf.c +++ /dev/null @@ -1,94 +0,0 @@ -/** @file - * Copyright (c) 2018-2020, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "pal_common.h" -#include "pal_client_api_intf.h" - - -/** - * @brief - Retrieve the version of the PSA Framework API that is implemented. - * This is a wrapper API for psa_framework_version API. - * @param - void - * @return - The PSA Framework API version. - */ - -uint32_t pal_ipc_framework_version(void) -{ - return 0; -} - -/** - * @brief - Retrieve the minor version of a Root of Trust Service by its SID. - * This is a wrapper API for the psa_version API. - * @param - sid The Root of Trust Service ID - * @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust - * Service not present on the system. - */ - -uint32_t pal_ipc_version(uint32_t sid) -{ - return PSA_VERSION_NONE; -} - -/** - * @brief - Connect to given sid. - * This is a wrapper API for the psa_connect API. - * @param - sid : RoT service id - * @param - minor_version : minor_version of RoT service - * @return - psa_handle_t : return connection handle - */ - -psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version) -{ - return PSA_NULL_HANDLE; -} - -/** - * @brief Call a connected Root of Trust Service. - * This is a wrapper API for the psa_call API. - * The caller must provide an array of ::psa_invec_t structures as the input payload. - * - * @param -handle Handle for the connection. - * @param -in_vec Array of psa_invec structures. - * @param -in_len Number of psa_invec structures in in_vec. - * @param -out_vec Array of psa_outvec structures for optional Root of Trust Service response. - * @param -out_len Number of psa_outvec structures in out_vec. - * @return -psa_status_t - */ - -psa_status_t pal_ipc_call(psa_handle_t handle, - const psa_invec *in_vec, - size_t in_len, - psa_outvec *out_vec, - size_t out_len) -{ - return (PSA_SUCCESS - 1); -} - -/** - * @brief Close a connection to a Root of Trust Service. - * This is a wrapper API for the psa_close API. - * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources. - * - * @param handle Handle for the connection. - * @return void - */ - -void pal_ipc_close(psa_handle_t handle) -{ - return; -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_intf.c deleted file mode 100644 index 73ca73c..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_intf.c +++ /dev/null @@ -1,101 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifdef COMPONENT_PSA_SRV_IPC - -#include "pal_common.h" -#include "pal_client_api_intf.h" - -/** - * @brief - Retrieve the version of the PSA Framework API that is implemented. - * This is a wrapper API for psa_framework_version API. - * @param - void - * @return - The PSA Framework API version. - * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. - */ - -uint32_t pal_ipc_framework_version(void) -{ - return (psa_framework_version()); -} - -/** - * @brief - Retrieve the minor version of a Root of Trust Service by its SID. - * This is a wrapper API for the psa_version API. - * @param - sid The Root of Trust Service ID - * @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust - * Service not present on the system. - * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. - */ - -uint32_t pal_ipc_version(uint32_t sid) -{ - return (psa_version(sid)); -} - -/** - * @brief - Connect to given sid. - * This is a wrapper API for the psa_connect API. - * @param - sid : RoT service id - * @param - minor_version : minor_version of RoT service - * @return - psa_handle_t : return connection handle - * Note - Return PSA_NULL_HANDLE if PSA IPC is not implemented. - */ - -psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version) -{ - return (psa_connect(sid, minor_version)); -} - -/** - * @brief Call a connected Root of Trust Service. - * This is a wrapper API for the psa_call API. - * The caller must provide an array of ::psa_invec_t structures as the input payload. - * - * @param -handle Handle for the connection. - * @param -in_vec Array of psa_invec structures. - * @param -in_len Number of psa_invec structures in in_vec. - * @param -out_vec Array of psa_outvec structures for optional Root of Trust Service response. - * @param -out_len Number of psa_outvec structures in out_vec. - * @return -psa_status_t - * Note - Return -1 if PSA IPC is not implemented. - */ - -psa_status_t pal_ipc_call(psa_handle_t handle, - const psa_invec *in_vec, - size_t in_len, - psa_outvec *out_vec, - size_t out_len) -{ - return (psa_call(handle, in_vec, in_len, out_vec, out_len)); -} - -/** - * @brief Close a connection to a Root of Trust Service. - * This is a wrapper API for the psa_close API. - * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources. - * - * @param - handle Handle for the connection. - * @return - void - */ - -void pal_ipc_close(psa_handle_t handle) -{ - psa_close(handle); -} - -#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_intf.h deleted file mode 100644 index 3c53f5e..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_client_api_intf.h +++ /dev/null @@ -1,61 +0,0 @@ -/** @file - * Copyright (c) 2018-2020, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _PAL_CLIENT_API_H_ -#define _PAL_CLIENT_API_H_ - -#include "pal_common.h" - -#define PSA_VERSION_NONE (0) -#define PSA_CONNECTION_REFUSED (INT32_MIN + 1) -#define PSA_CONNECTION_BUSY (INT32_MIN + 2) -#define PSA_DROP_CONNECTION (INT32_MIN) -#define PSA_NULL_HANDLE ((psa_handle_t)0) - -typedef int32_t psa_status_t; -typedef int32_t psa_handle_t; - -typedef struct psa_invec { - const void *base; - size_t len; -} psa_invec; - -typedef struct psa_outvec { - void *base; - size_t len; -} psa_outvec; - -uint32_t psa_framework_version(void); -uint32_t psa_version(uint32_t sid); -psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version); -psa_status_t psa_call(psa_handle_t handle, - const psa_invec *in_vec, - size_t in_len, - psa_outvec *out_vec, - size_t out_len); -void psa_close(psa_handle_t handle); - -uint32_t pal_ipc_framework_version(void); -uint32_t pal_ipc_version(uint32_t sid); -psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version); -psa_status_t pal_ipc_call(psa_handle_t handle, - const psa_invec *in_vec, - size_t in_len, - psa_outvec *out_vec, - size_t out_len); -void pal_ipc_close(psa_handle_t handle); -#endif /* _PAL_CLIENT_API_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_common.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_common.h deleted file mode 100644 index eaa6b4a..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_common.h +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _PAL_COMMON_H_ -#define _PAL_COMMON_H_ - -#include -#include -#include -#include -#include - -#ifndef PSA_PROTECTED_STORAGE_IMPLEMENTED -#define PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED 1 /* Use ITS by default */ -#define ITS_TEST 1 -#endif - -#include "internal_trusted_storage.h" - -/* typedef's */ -typedef uint8_t bool_t; -typedef uint32_t addr_t; -typedef uint32_t test_id_t; -typedef uint32_t block_id_t; -typedef char char8_t; -typedef uint32_t cfg_id_t; - -#define PAL_STATUS_UNSUPPORTED_FUNC 0xFF - -typedef enum { - PAL_STATUS_SUCCESS = 0x0, - PAL_STATUS_ERROR = 0x80 -} pal_status_t; - -typedef enum { - NVMEM_READ = 0x1, - NVMEM_WRITE = 0x2, -} nvmem_fn_type_t; - -typedef struct { - nvmem_fn_type_t nvmem_fn_type; - addr_t base; - uint32_t offset; - int size; -} nvmem_param_t; - -typedef enum { - WD_INIT_SEQ = 0x1, - WD_ENABLE_SEQ = 0x2, - WD_DISABLE_SEQ = 0x3, - WD_STATUS_SEQ = 0x4, -} wd_fn_type_t; - -typedef enum { - WD_LOW_TIMEOUT = 0x1, - WD_MEDIUM_TIMEOUT = 0x2, - WD_HIGH_TIMEOUT = 0x3, - WD_CRYPTO_TIMEOUT = 0x4, -} wd_timeout_type_t; - -typedef struct { - wd_fn_type_t wd_fn_type; - addr_t wd_base_addr; - uint32_t wd_time_us; - uint32_t wd_timer_tick_us; -} wd_param_t; - -typedef enum { - UART_INIT = 0x1, - UART_PRINT = 0x2, -} uart_fn_type_t; - -/* - * Redefining some of the client.h elements for compilation to go through - * when PSA IPC APIs are not implemented. - */ -#if (PSA_IPC_IMPLEMENTED == 0) - -#ifndef PSA_VERSION_NONE -#define PSA_VERSION_NONE (0) -#endif - -typedef int32_t psa_handle_t; - -#ifndef PSA_NULL_HANDLE -#define PSA_NULL_HANDLE ((psa_handle_t)0) -#endif - - -#endif /* PSA_IPC_IMPLEMENTED */ - -#endif /* _PAL_COMMON_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_interfaces_ns.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_interfaces_ns.h deleted file mode 100644 index 6393a47..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_interfaces_ns.h +++ /dev/null @@ -1,187 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _PAL_INTERFACES_NS_H_ -#define _PAL_INTERFACES_NS_H_ - -#include "val.h" -#include "val_client_defs.h" -#include - -/** - @brief - This function will read peripherals using SPI commands - @param - addr : address of the peripheral - - data : read buffer - - len : length of the read buffer in bytes - @return - error status -**/ -int pal_spi_read(addr_t addr, uint8_t *data, uint32_t len); - -/** - * @brief - Retrieve the version of the PSA Framework API that is implemented. - * This is a wrapper API for psa_framework_version API. - * @param - void - * @return - The PSA Framework API version. - * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. - */ -uint32_t pal_ipc_framework_version(void); - -/** - * @brief - Retrieve the minor version of a Root of Trust Service by its SID. - * This is a wrapper API for the psa_version API. - * @param - sid The Root of Trust Service ID - * @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust Service - * not present on the system. - * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. - */ -uint32_t pal_ipc_version(uint32_t sid); - -/** - * @brief - Connect to given sid. - * This is a wrapper API for the psa_connect API. - * @param - sid : RoT service id - * - minor_version : minor_version of RoT service - * @return - psa_handle_t : return connection handle - * Note - Return PSA_NULL_HANDLE if PSA IPC is not implemented. - */ -psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version); - -/** - * @brief - Call a connected Root of Trust Service. - * This is a wrapper API for the psa_call API. The caller must provide an array of - * psa_invec_t structures as the input payload. - * @param - handle: Handle for the connection. - * - in_vec: Array of psa_invec structures. - * - in_len: Number of psa_invec structures in in_vec. - * - out_vec: Array of psa_outvec structures for optional Root of Trust Service response. - * - out_len: Number of psa_outvec structures in out_vec. - * @return - psa_status_t - */ - -psa_status_t pal_ipc_call(psa_handle_t handle, - const psa_invec *in_vec, - size_t in_len, - psa_outvec *out_vec, - size_t out_len); - -/** - * @brief - Close a connection to a Root of Trust Service. - * This is a wrapper API for the psa_close API. - * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service - * so it can clean up resources. - * @param - handle Handle for the connection. - * @return - void - */ -void pal_ipc_close(psa_handle_t handle); -/** - @brief - This function initializes the UART - @param - uart base addr - @return - SUCCESS/FAILURE -**/ -int pal_uart_init_ns(uint32_t uart_base_addr); - -/** - * @brief - This function parses the input string and writes bytes into UART TX FIFO - * @param - str : Input String - * - data : Value for format specifier - * @return - SUCCESS/FAILURE -**/ - -int pal_print_ns(char *str, uint32_t data); - -/** - * @brief - Initializes an hardware watchdog timer - * @param - base_addr : Base address of the watchdog module - * - time_us : Time in micro seconds - * - timer_tick_us : Number of ticks per micro second - * @return - SUCCESS/FAILURE -**/ -int pal_wd_timer_init_ns(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us); - -/** - * @brief - Enables a hardware watchdog timer - * @param - base_addr : Base address of the watchdog module - * @return - SUCCESS/FAILURE -**/ -int pal_wd_timer_enable_ns(addr_t base_addr); - -/** - * @brief - Disables a hardware watchdog timer - * @param - base_addr : Base address of the watchdog module - * @return - SUCCESS/FAILURE -**/ -int pal_wd_timer_disable_ns(addr_t base_addr); - -/** - * @brief - Reads from given non-volatile address. - * @param - base : Base address of nvmem - * offset : Offset - * buffer : Pointer to source address - * size : Number of bytes - * @return - SUCCESS/FAILURE -**/ -int pal_nvmem_read_ns(addr_t base, uint32_t offset, void *buffer, int size); - -/** - * @brief - Writes into given non-volatile address. - * @param - base : Base address of nvmem - * offset : Offset - * buffer : Pointer to source address - * size : Number of bytes - * @return - SUCCESS/FAILURE -**/ -int pal_nvmem_write_ns(addr_t base, uint32_t offset, void *buffer, int size); - -/** - * @brief - This API will call the requested crypto function - * @param - type : function code - * valist : variable argument list - * @return - error status -**/ -int32_t pal_crypto_function(int type, va_list valist); - -/** - * @brief - This API will call the requested internal trusted storage function - * @param - type : function code - * valist : variable argument list - * @return - error status -**/ -uint32_t pal_its_function(int type, va_list valist); - -/** - * @brief - This API will call the requested protected storage function - * @param - type : function code - * valist : variable argument list - * @return - error status -**/ -uint32_t pal_ps_function(int type, va_list valist); - -/** - * @brief - This API will call the requested attestation function - * @param - type : function code - * valist : variable argument list - * @return - error status -**/ -int32_t pal_attestation_function(int type, va_list valist); - -/** - * @brief - Terminates the simulation at the end of all tests completion. - * By default, it put cpus into power down mode. - * @param - void - * @return - void -**/ -void pal_terminate_simulation(void); -#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_internal_trusted_storage_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_internal_trusted_storage_intf.c deleted file mode 100644 index 2e9de8c..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_internal_trusted_storage_intf.c +++ /dev/null @@ -1,92 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - - -#include "pal_internal_trusted_storage_intf.h" - -/** - @brief - This API will call the requested internal trusted storage function - @param - type : function code - valist : variable argument list - @return - error status -**/ -uint32_t pal_its_function(int type, va_list valist) -{ -#if PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED - uint32_t uid, data_length, offset; - const void *p_write_data; - void *p_read_data; - psa_storage_create_flags_t its_create_flags; - //psa_ps_create_flags_t ps_create_flags; - struct psa_its_info_t *its_p_info; - //struct psa_eps_info_t *ps_p_info; - /* TODO: Actual size argument is currently not supported by the testing framework. - * Changes need to be implemented in the actual tests. - * Should be fixed by the next import of the tests. - */ - size_t actual_size; - - switch (type) { - case PAL_ITS_SET: - uid = va_arg(valist, psa_storage_uid_t); - data_length = va_arg(valist, uint32_t); - p_write_data = va_arg(valist, const void *); - its_create_flags = va_arg(valist, psa_storage_create_flags_t); - return psa_its_set(uid, data_length, p_write_data, its_create_flags); - case PAL_ITS_GET: - uid = va_arg(valist, psa_storage_uid_t); - offset = va_arg(valist, uint32_t); - data_length = va_arg(valist, uint32_t); - p_read_data = va_arg(valist, void *); - /* TODO: Actual size argument is currently not supported by the testing framework. - * Changes need to be implemented in the actual tests. - * Should be fixed by the next import of the tests. - */ - return psa_its_get(uid, offset, data_length, p_read_data, &actual_size); - case PAL_ITS_GET_INFO: - uid = va_arg(valist, psa_storage_uid_t); - its_p_info = va_arg(valist, struct psa_its_info_t *); - return psa_its_get_info(uid, (struct psa_storage_info_t *)its_p_info); - case PAL_ITS_REMOVE: - uid = va_arg(valist, psa_storage_uid_t); - return psa_its_remove(uid); - /* case PAL_PS_SET: */ - /* uid = va_arg(valist, uint32_t); */ - /* data_length = va_arg(valist, uint32_t); */ - /* p_write_data = va_arg(valist, const void*); */ - /* ps_create_flags = va_arg(valist, psa_ps_create_flags_t); */ - /* return psa_ps_set(uid, data_length, p_write_data, ps_create_flags); */ - /* case PAL_PS_GET: */ - /* uid = va_arg(valist, uint32_t); */ - /* offset = va_arg(valist, uint32_t); */ - /* data_length = va_arg(valist, uint32_t); */ - /* p_read_data = va_arg(valist, void*); */ - /* return psa_ps_get(uid, offset, data_length, p_read_data); */ - /* case PAL_PS_GET_INFO: */ - /* uid = va_arg(valist, uint32_t); */ - /* ps_p_info = va_arg(valist, struct psa_eps_info_t*); */ - /* return psa_ps_get_info(uid, ps_p_info); */ - /* case PAL_PS_REMOVE: */ - /* uid = va_arg(valist, uint32_t); */ - /* return psa_ps_remove(uid); */ - default: - return PAL_STATUS_UNSUPPORTED_FUNC; - } -#else - return PAL_STATUS_ERROR; -#endif -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_internal_trusted_storage_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_internal_trusted_storage_intf.h deleted file mode 100644 index c40aa43..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_internal_trusted_storage_intf.h +++ /dev/null @@ -1,36 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _PAL_INTERNAL_TRUSTED_STORAGE_INTF_H_ -#define _PAL_INTERNAL_TRUSTED_STORAGE_INTF_H_ - -#include -#include "pal_common.h" - -#if PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED -#include "psa/internal_trusted_storage.h" -#endif - -enum its_function_code { - PAL_ITS_SET = 0x1, - PAL_ITS_GET = 0x2, - PAL_ITS_GET_INFO = 0x3, - PAL_ITS_REMOVE = 0x4, -}; - -uint32_t pal_its_function(int type, va_list valist); -#endif /* _PAL_INTERNAL_TRUSTED_STORAGE_INTF_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_mbed_os_intf.cpp b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_mbed_os_intf.cpp deleted file mode 100644 index be1c70e..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_mbed_os_intf.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2019-2020 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "rtos.h" -#include "mbed_assert.h" -#include "val_interfaces.h" -#include "pal_common.h" - -#include "psa/crypto.h" -#include "entropy_poll.h" - -#include "psa_attest_inject_key.h" -#include "psa_initial_attestation_api.h" - -#include "pal_mbed_os_intf.h" - -#include "lifecycle.h" - -#define TEST_STACK_SIZE 8192 -#define TEST_KEY_ID_VALUE 17 - -extern val_api_t val_api; -extern psa_api_t psa_api; -#ifdef PS_TEST -extern "C" psa_status_t psa_ps_reset(); -#endif - -test_entry_f test_g = NULL; -compliance_test_type type_g = COMPLIANCE_TEST_UNDEFINED; - -// randomly generated attestation key used for testing the attestation feature. -// The specific key chosen shouldn't matter to the attestation test -// the test just needs a key to be injected before it is run. -static const uint8_t private_key_data[] = { - 0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56, - 0x38, 0xc4, 0x31, 0xcf, 0x1d, 0xf1, 0xc9, 0x94, - 0x13, 0x16, 0x09, 0xb5, 0x80, 0xd4, 0xfd, 0x43, - 0xa0, 0xca, 0xb1, 0x7d, 0xb2, 0xf1, 0x3e, 0xee -}; - -static const uint8_t public_key_data[] = { - 0x04, 0x77, 0x72, 0x65, 0x6f, 0x81, 0x4b, 0x39, - 0x92, 0x79, 0xd5, 0xe1, 0xf1, 0x78, 0x1f, 0xac, - 0x6f, 0x09, 0x9a, 0x3c, 0x5c, 0xa1, 0xb0, 0xe3, - 0x53, 0x51, 0x83, 0x4b, 0x08, 0xb6, 0x5e, 0x0b, - 0x57, 0x25, 0x90, 0xcd, 0xaf, 0x8f, 0x76, 0x93, - 0x61, 0xbc, 0xf3, 0x4a, 0xcf, 0xc1, 0x1e, 0x5e, - 0x07, 0x4e, 0x84, 0x26, 0xbd, 0xde, 0x04, 0xbe, - 0x6e, 0x65, 0x39, 0x45, 0x44, 0x96, 0x17, 0xde, - 0x45 -}; - -static void psa_attestation_destroy_key_for_test() -{ - psa_key_handle_t handle = 0; - psa_open_key(TEST_KEY_ID_VALUE, &handle); - psa_destroy_key(handle); -} - -static void psa_attestation_inject_key_for_test(void) -{ - size_t exported_length; - uint8_t exported[sizeof(public_key_data)]; - - psa_attestation_destroy_key_for_test(); - psa_attestation_inject_key(private_key_data, - sizeof(private_key_data), - PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_CURVE_SECP_R1), - exported, - sizeof(exported), - &exported_length); -} - - - -static void reset_storage_for_compliance_test() -{ -#ifdef ITS_TEST - mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST); -#elif PS_TEST - psa_ps_reset(); -#endif -} - -#if !defined(MAX) -#define MAX(a,b) (((a)>(b))?(a):(b)) -#endif - -#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \ - MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE) - -static void inject_entropy() -{ -#if defined(MBEDTLS_ENTROPY_NV_SEED) - uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = { 0 }; - for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) { - seed[i] = i; - } - mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE); -#endif // defined(MBEDTLS_ENTROPY_NV_SEED) -} - - - -void main_wrapper(void) -{ - test_g(&val_api, &psa_api); -} - - -void pal_mbed_os_compliance_test_initialize(void) -{ - if (COMPLIANCE_TEST_CRYPTO == type_g) { - inject_entropy(); - } else if (COMPLIANCE_TEST_STORAGE == type_g) { - reset_storage_for_compliance_test(); - } else if (COMPLIANCE_TEST_ATTESTATION == type_g) { - reset_storage_for_compliance_test(); - inject_entropy(); - psa_crypto_init(); - psa_attestation_inject_key_for_test(); // inject key in case needed - } - -} - -void pal_mbed_os_compliance_test_destroy(void) -{ - reset_storage_for_compliance_test(); -} - -int test_start(test_entry_f test_f, compliance_test_type type) -{ - test_g = test_f; - type_g = type; -#if defined(MBED_CONF_RTOS_PRESENT) - MBED_ASSERT((type > COMPLIANCE_TEST_START) && (type < COMPLIANCE_TEST_END)); - Thread thread(osPriorityNormal, TEST_STACK_SIZE, NULL); - thread.start(main_wrapper); - thread.join(); -#endif - return 0; -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_mbed_os_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_mbed_os_intf.h deleted file mode 100644 index 5308bf9..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_mbed_os_intf.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef PAL_MBED_OS_CRYPTO_H_ -#define PAL_MBED_OS_CRYPTO_H_ - -#include "val_interfaces.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum _compliance_test_type { - COMPLIANCE_TEST_UNDEFINED, - COMPLIANCE_TEST_START = COMPLIANCE_TEST_UNDEFINED, - COMPLIANCE_TEST_CRYPTO, - COMPLIANCE_TEST_ATTESTATION, - COMPLIANCE_TEST_STORAGE, - COMPLIANCE_TEST_END -} compliance_test_type; - -typedef void (*test_entry_f)(val_api_t *val_api, psa_api_t *psa_api); -int test_start(test_entry_f test_f, compliance_test_type type); - -#ifdef __cplusplus -} -#endif - -#endif /* PAL_MBED_OS_CRYPTO_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_protected_storage_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_protected_storage_intf.c deleted file mode 100644 index 893e5f3..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_protected_storage_intf.c +++ /dev/null @@ -1,63 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - - -#include "pal_protected_storage_intf.h" - -/** - @brief - This API will call the requested protected storage function - @param - type : function code - valist : variable argument list - @return - error status -**/ -uint32_t pal_ps_function(int type, va_list valist) -{ -#if PSA_PROTECTED_STORAGE_IMPLEMENTED - uint32_t uid, data_length, offset; - size_t actual_length; - const void *p_write_data; - void *p_read_data; - psa_storage_create_flags_t ps_create_flags; - struct psa_ps_info_t *ps_p_info; - - switch (type) { - case PAL_PS_SET: - uid = va_arg(valist, psa_storage_uid_t); - data_length = va_arg(valist, uint32_t); - p_write_data = va_arg(valist, const void *); - ps_create_flags = va_arg(valist, psa_storage_create_flags_t); - return psa_ps_set(uid, data_length, p_write_data, ps_create_flags); - case PAL_PS_GET: - uid = va_arg(valist, psa_storage_uid_t); - offset = va_arg(valist, uint32_t); - data_length = va_arg(valist, uint32_t); - p_read_data = va_arg(valist, void *); - return psa_ps_get(uid, offset, data_length, p_read_data, &actual_length); - case PAL_PS_GET_INFO: - uid = va_arg(valist, psa_storage_uid_t); - ps_p_info = va_arg(valist, struct psa_ps_info_t *); - return psa_ps_get_info(uid, ps_p_info); - case PAL_PS_REMOVE: - uid = va_arg(valist, psa_storage_uid_t); - return psa_ps_remove(uid); - default: - return PAL_STATUS_UNSUPPORTED_FUNC; - } -#else - return PAL_STATUS_ERROR; -#endif -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_protected_storage_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_protected_storage_intf.h deleted file mode 100644 index 3ebe86a..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/pal/pal_protected_storage_intf.h +++ /dev/null @@ -1,36 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _PAL_PROTECTED_STORAGE_INTF_H_ -#define _PAL_PROTECTED_STORAGE_INTF_H_ - -#include -#include "pal_common.h" - -#if PSA_PROTECTED_STORAGE_IMPLEMENTED -#include "psa/protected_storage.h" -#endif - -enum ps_function_code { - PAL_PS_SET = 0x1, - PAL_PS_GET = 0x2, - PAL_PS_GET_INFO = 0x3, - PAL_PS_REMOVE = 0x4, -}; - -uint32_t pal_ps_function(int type, va_list valist); -#endif /* _PAL_PROTECTED_STORAGE_INTF_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/CMakeLists.txt b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/CMakeLists.txt new file mode 100644 index 0000000..bfbe4db --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_library(mbed-psa-tal INTERFACE) + +target_include_directories(mbed-psa-tal + INTERFACE + pal + val +) + +target_sources(mbed-psa-tal + INTERFACE + pal/pal_attestation_eat.c + pal/pal_attestation_intf.c + pal/pal_client_api_empty_intf.c + pal/pal_client_api_intf.c + pal/pal_internal_trusted_storage_intf.c + pal/pal_protected_storage_intf.c + pal/pal_mbed_os_intf.cpp + + val/val_attestation.c + val/val_interfaces.c + val/val_internal_trusted_storage.c + val/val_protected_storage.c + val/val_greentea.cpp +) + +target_link_libraries(mbed-psa-tal + INTERFACE + mbed-psa +) diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_eat.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_eat.c new file mode 100644 index 0000000..8683680 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_eat.c @@ -0,0 +1,365 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "pal_attestation_eat.h" + +uint32_t mandatory_claims = 0, mandaroty_sw_components = 0; +bool_t sw_component_present = 0; + +static int get_items_in_map(QCBORDecodeContext *decode_context, + struct items_to_get_t *item_list) +{ + int item_index; + QCBORItem item; + struct items_to_get_t *item_ptr = item_list; + + /* initialize the data type of all items in the list */ + while (item_ptr->label != 0) { + item_ptr->item.uDataType = QCBOR_TYPE_NONE; + item_ptr++; + } + + QCBORDecode_GetNext(decode_context, &item); + if (item.uDataType != QCBOR_TYPE_MAP) { + return PAL_ATTEST_ERROR; + } + + for (item_index = item.val.uCount; item_index != 0; item_index--) { + if (QCBORDecode_GetNext(decode_context, &item) != QCBOR_SUCCESS) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + if (item.uLabelType != QCBOR_TYPE_INT64) { + continue; + } + + item_ptr = item_list; + while (item_ptr->label != 0) { + if (item.label.int64 == item_ptr->label) { + item_ptr->item = item; + } + item_ptr++; + } + } + + return PAL_ATTEST_SUCCESS; +} + +static int get_item_in_map(QCBORDecodeContext *decode_context, + int32_t label, + QCBORItem *item) +{ + struct items_to_get_t item_list[2]; + + item_list[0].label = label; + item_list[1].label = 0; + + if (get_items_in_map(decode_context, item_list)) { + return PAL_ATTEST_ERROR; + } + + if (item_list[0].item.uDataType == QCBOR_TYPE_NONE) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + *item = item_list[0].item; + + return PAL_ATTEST_SUCCESS; +} + +static int parse_unprotected_headers(QCBORDecodeContext *decode_context, + struct useful_buf_c *child, + bool *loop_back) +{ + struct items_to_get_t item_list[3]; + + item_list[0].label = COSE_HEADER_PARAM_KID; + item_list[1].label = T_COSE_SHORT_CIRCUIT_LABEL; + item_list[2].label = 0; + *loop_back = false; + + if (get_items_in_map(decode_context, item_list)) { + return PAL_ATTEST_ERROR; + } + + if (item_list[1].item.uDataType == QCBOR_TYPE_TRUE) { + *loop_back = true; + } + + if (item_list[0].item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + *child = item_list[0].item.val.string; + + return PAL_ATTEST_SUCCESS; +} + +static int parse_protected_headers(struct useful_buf_c protected_headers, + int32_t *alg_id) +{ + QCBORDecodeContext decode_context; + QCBORItem item; + + QCBORDecode_Init(&decode_context, protected_headers, 0); + + if (get_item_in_map(&decode_context, COSE_HEADER_PARAM_ALG, &item)) { + return PAL_ATTEST_ERROR; + } + + if (QCBORDecode_Finish(&decode_context)) { + return PAL_ATTEST_ERROR; + } + + if ((item.uDataType != QCBOR_TYPE_INT64) || (item.val.int64 > INT32_MAX)) { + return PAL_ATTEST_ERROR; + } + + *alg_id = (int32_t)item.val.int64; + + return PAL_ATTEST_SUCCESS; +} + +/** + @brief - This API will verify the claims + @param - decode_context : The buffer containing the challenge + item : context for decoding the data items + completed_challenge : Buffer containing the challenge + @return - error status +**/ +static int parse_claims(QCBORDecodeContext *decode_context, QCBORItem item, + struct useful_buf_c completed_challenge) +{ + int i, count = 0; + int status = PAL_ATTEST_SUCCESS; + + /* Parse each claim and validate their data type */ + while (status == PAL_ATTEST_SUCCESS) { + status = QCBORDecode_GetNext(decode_context, &item); + if (status != PAL_ATTEST_SUCCESS) { + break; + } + + mandatory_claims |= 1 << (EAT_CBOR_ARM_RANGE_BASE - item.label.int64); + if (item.uLabelType == QCBOR_TYPE_INT64) { + if (item.label.int64 == EAT_CBOR_ARM_LABEL_NONCE) { + if (item.uDataType == QCBOR_TYPE_BYTE_STRING) { + /* Given challenge vs challenge in token */ + if (UsefulBuf_Compare(item.val.string, completed_challenge)) { + return PAL_ATTEST_TOKEN_CHALLENGE_MISMATCH; + } + } else { + return PAL_ATTEST_TOKEN_NOT_SUPPORTED; + } + } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_BOOT_SEED || + item.label.int64 == EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID || + item.label.int64 == EAT_CBOR_ARM_LABEL_UEID) { + if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_ORIGINATION || + item.label.int64 == EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION || + item.label.int64 == EAT_CBOR_ARM_LABEL_HW_VERSION) { + if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_CLIENT_ID || + item.label.int64 == EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE) { + if (item.uDataType != QCBOR_TYPE_INT64) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_SW_COMPONENTS) { + if (item.uDataType != QCBOR_TYPE_ARRAY) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + sw_component_present = 1; + status = QCBORDecode_GetNext(decode_context, &item); + if (status != PAL_ATTEST_SUCCESS) { + continue; + } + + count = item.val.uCount; + for (i = 0; i <= count; i++) { + mandaroty_sw_components |= 1 << item.label.int64; + + if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT) { + if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT_DESC) { + if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_VERSION) { + if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_SIGNER_ID) { + if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_EPOCH) { + if (item.uDataType != QCBOR_TYPE_INT64) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_TYPE) { + if (item.uDataType != QCBOR_TYPE_TEXT_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } + + if (i < count) { + status = QCBORDecode_GetNext(decode_context, &item); + if (status != PAL_ATTEST_SUCCESS) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + } + } + + } + } else { + /* ToDo: Add other claim types */ + } + } + + if (status == QCBOR_ERR_HIT_END) { + return PAL_ATTEST_SUCCESS; + } else { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } +} + +/** + @brief - This API will verify the attestation token + @param - challenge : The buffer containing the challenge + challenge_size : Size of the challenge buffer + token : The buffer containing the attestation token + token_size : Size of the token buffer + @return - error status +**/ +int32_t pal_initial_attest_verify_token(uint8_t *challenge, uint32_t challenge_size, + uint8_t *token, uint32_t token_size) +{ + int status = PAL_ATTEST_SUCCESS; + bool short_circuit; + int32_t cose_algorithm_id; + QCBORItem item; + QCBORDecodeContext decode_context; + struct useful_buf_c completed_challenge; + struct useful_buf_c completed_token; + struct useful_buf_c payload; + struct useful_buf_c protected_headers; + struct useful_buf_c kid; + + /* Construct the token buffer for validation */ + completed_token.ptr = token; + completed_token.len = token_size; + + /* Construct the challenge buffer for validation */ + completed_challenge.ptr = challenge; + completed_challenge.len = challenge_size; + + /* + ------------------------- + | CBOR Array Type | + ------------------------- + | Protected Headers | + ------------------------- + | Unprotected Headers | + ------------------------- + | Payload | + ------------------------- + | Signature | + ------------------------- + */ + + /* Initialize the decorder */ + QCBORDecode_Init(&decode_context, completed_token, QCBOR_DECODE_MODE_NORMAL); + + /* Get the Header */ + QCBORDecode_GetNext(&decode_context, &item); + + /* Check the CBOR Array type. Check if the count is 4. + * Only COSE_SIGN1 is supported now. + */ + if (item.uDataType != QCBOR_TYPE_ARRAY || item.val.uCount != 4 || + !QCBORDecode_IsTagged(&decode_context, &item, CBOR_TAG_COSE_SIGN1)) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + /* Get the next headers */ + QCBORDecode_GetNext(&decode_context, &item); + if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + protected_headers = item.val.string; + + /* Parse the protected headers and check the data type and value*/ + status = parse_protected_headers(protected_headers, &cose_algorithm_id); + if (status != PAL_ATTEST_SUCCESS) { + return status; + } + + /* Parse the unprotected headers and check the data type and value */ + short_circuit = false; + status = parse_unprotected_headers(&decode_context, &kid, &short_circuit); + if (status != PAL_ATTEST_SUCCESS) { + return status; + } + + /* Get the payload */ + QCBORDecode_GetNext(&decode_context, &item); + if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + payload = item.val.string; + + /* Get the digital signature */ + QCBORDecode_GetNext(&decode_context, &item); + if (item.uDataType != QCBOR_TYPE_BYTE_STRING) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + /* Initialize the Decoder and validate the payload format */ + QCBORDecode_Init(&decode_context, payload, QCBOR_DECODE_MODE_NORMAL); + status = QCBORDecode_GetNext(&decode_context, &item); + if (status != PAL_ATTEST_SUCCESS) { + return status; + } + + if (item.uDataType != QCBOR_TYPE_MAP) { + return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; + } + + /* Parse the payload and check the data type of each claim */ + status = parse_claims(&decode_context, item, completed_challenge); + if (status != PAL_ATTEST_SUCCESS) { + return status; + } + + if ((mandatory_claims & MANDATORY_CLAIM_WITH_SW_COMP) == MANDATORY_CLAIM_WITH_SW_COMP) { + if ((mandaroty_sw_components & MANDATORY_SW_COMP) != MANDATORY_SW_COMP) { + return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS; + } + } else if ((mandatory_claims & MANDATORY_CLAIM_NO_SW_COMP) != MANDATORY_CLAIM_NO_SW_COMP) { + return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS; + } + + return PAL_ATTEST_SUCCESS; +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_eat.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_eat.h new file mode 100644 index 0000000..9f435fb --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_eat.h @@ -0,0 +1,73 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "qcbor.h" +#include "pal_common.h" + +#define PAL_ATTEST_MIN_ERROR 30 + +#define COSE_HEADER_PARAM_ALG 1 +#define COSE_HEADER_PARAM_KID 4 + +#define MANDATORY_CLAIM_WITH_SW_COMP 862 +#define MANDATORY_CLAIM_NO_SW_COMP 926 +#define MANDATORY_SW_COMP 36 +#define CBOR_ARM_TOTAL_CLAIM_INSTANCE 10 + +/* + CBOR Label for proprietary header indicating short-circuit + signing was used. Just a random number in the proprietary + label space */ +#define T_COSE_SHORT_CIRCUIT_LABEL (-8675309) + +#define EAT_CBOR_ARM_RANGE_BASE (-75000) +#define EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION (EAT_CBOR_ARM_RANGE_BASE - 0) +#define EAT_CBOR_ARM_LABEL_CLIENT_ID (EAT_CBOR_ARM_RANGE_BASE - 1) +#define EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE (EAT_CBOR_ARM_RANGE_BASE - 2) +#define EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID (EAT_CBOR_ARM_RANGE_BASE - 3) +#define EAT_CBOR_ARM_LABEL_BOOT_SEED (EAT_CBOR_ARM_RANGE_BASE - 4) +#define EAT_CBOR_ARM_LABEL_HW_VERSION (EAT_CBOR_ARM_RANGE_BASE - 5) +#define EAT_CBOR_ARM_LABEL_SW_COMPONENTS (EAT_CBOR_ARM_RANGE_BASE - 6) +#define EAT_CBOR_ARM_LABEL_NO_SW_COMPONENTS (EAT_CBOR_ARM_RANGE_BASE - 7) +#define EAT_CBOR_ARM_LABEL_NONCE (EAT_CBOR_ARM_RANGE_BASE - 8) +#define EAT_CBOR_ARM_LABEL_UEID (EAT_CBOR_ARM_RANGE_BASE - 9) +#define EAT_CBOR_ARM_LABEL_ORIGINATION (EAT_CBOR_ARM_RANGE_BASE - 10) + +#define EAT_CBOR_SW_COMPONENT_TYPE (1u) +#define EAT_CBOR_SW_COMPONENT_MEASUREMENT (2u) +#define EAT_CBOR_SW_COMPONENT_EPOCH (3u) +#define EAT_CBOR_SW_COMPONENT_VERSION (4u) +#define EAT_CBOR_SW_COMPONENT_SIGNER_ID (5u) +#define EAT_CBOR_SW_COMPONENT_MEASUREMENT_DESC (6u) + + +enum attestation_error_code { + PAL_ATTEST_SUCCESS = 0, + PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING = PAL_ATTEST_MIN_ERROR, + PAL_ATTEST_TOKEN_CHALLENGE_MISMATCH, + PAL_ATTEST_TOKEN_NOT_SUPPORTED, + PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS, + PAL_ATTEST_ERROR, +}; + +struct items_to_get_t { + int64_t label; + QCBORItem item; +}; + +int32_t pal_initial_attest_verify_token(uint8_t *challenge, uint32_t challenge_size, + uint8_t *token, uint32_t token_size); diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_intf.c new file mode 100644 index 0000000..66b3ab4 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_intf.c @@ -0,0 +1,53 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + + +#include "pal_attestation_intf.h" + +/** + @brief - This API will call the requested attestation function + @param - type : function code + valist : variable argument list + @return - error status +**/ +int32_t pal_attestation_function(int type, va_list valist) +{ + uint8_t *challenge, *token; + uint32_t challenge_size, *token_size, verify_token_size; + + switch (type) { + case PAL_INITIAL_ATTEST_GET_TOKEN: + challenge = va_arg(valist, uint8_t *); + challenge_size = va_arg(valist, uint32_t); + token = va_arg(valist, uint8_t *); + token_size = va_arg(valist, uint32_t *); + return psa_initial_attest_get_token(challenge, challenge_size, token, token_size); + case PAL_INITIAL_ATTEST_GET_TOKEN_SIZE: + challenge_size = va_arg(valist, uint32_t); + token_size = va_arg(valist, uint32_t *); + return psa_initial_attest_get_token_size(challenge_size, token_size); + case PAL_INITIAL_ATTEST_VERIFY_TOKEN: + challenge = va_arg(valist, uint8_t *); + challenge_size = va_arg(valist, uint32_t); + token = va_arg(valist, uint8_t *); + verify_token_size = va_arg(valist, uint32_t); + return pal_initial_attest_verify_token(challenge, challenge_size, + token, verify_token_size); + default: + return PAL_STATUS_UNSUPPORTED_FUNC; + } +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_intf.h new file mode 100644 index 0000000..fdefc83 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_attestation_intf.h @@ -0,0 +1,31 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _PAL_INITIAL_ATTESTATION_H_ +#define _PAL_INITIAL_ATTESTATION_H_ + +#include "psa_initial_attestation_api.h" +#include "pal_attestation_eat.h" + +enum attestation_function_code { + PAL_INITIAL_ATTEST_GET_TOKEN = 0x1, + PAL_INITIAL_ATTEST_GET_TOKEN_SIZE = 0x2, + PAL_INITIAL_ATTEST_VERIFY_TOKEN = 0x3, +}; + +int32_t pal_attestation_function(int type, va_list valist); +#endif /* _PAL_INITIAL_ATTESTATION_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_empty_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_empty_intf.c new file mode 100644 index 0000000..8e9b90d --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_empty_intf.c @@ -0,0 +1,94 @@ +/** @file + * Copyright (c) 2018-2020, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "pal_common.h" +#include "pal_client_api_intf.h" + + +/** + * @brief - Retrieve the version of the PSA Framework API that is implemented. + * This is a wrapper API for psa_framework_version API. + * @param - void + * @return - The PSA Framework API version. + */ + +uint32_t pal_ipc_framework_version(void) +{ + return 0; +} + +/** + * @brief - Retrieve the minor version of a Root of Trust Service by its SID. + * This is a wrapper API for the psa_version API. + * @param - sid The Root of Trust Service ID + * @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust + * Service not present on the system. + */ + +uint32_t pal_ipc_version(uint32_t sid) +{ + return PSA_VERSION_NONE; +} + +/** + * @brief - Connect to given sid. + * This is a wrapper API for the psa_connect API. + * @param - sid : RoT service id + * @param - minor_version : minor_version of RoT service + * @return - psa_handle_t : return connection handle + */ + +psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version) +{ + return PSA_NULL_HANDLE; +} + +/** + * @brief Call a connected Root of Trust Service. + * This is a wrapper API for the psa_call API. + * The caller must provide an array of ::psa_invec_t structures as the input payload. + * + * @param -handle Handle for the connection. + * @param -in_vec Array of psa_invec structures. + * @param -in_len Number of psa_invec structures in in_vec. + * @param -out_vec Array of psa_outvec structures for optional Root of Trust Service response. + * @param -out_len Number of psa_outvec structures in out_vec. + * @return -psa_status_t + */ + +psa_status_t pal_ipc_call(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + psa_outvec *out_vec, + size_t out_len) +{ + return (PSA_SUCCESS - 1); +} + +/** + * @brief Close a connection to a Root of Trust Service. + * This is a wrapper API for the psa_close API. + * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources. + * + * @param handle Handle for the connection. + * @return void + */ + +void pal_ipc_close(psa_handle_t handle) +{ + return; +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_intf.c new file mode 100644 index 0000000..73ca73c --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_intf.c @@ -0,0 +1,101 @@ +/** @file + * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifdef COMPONENT_PSA_SRV_IPC + +#include "pal_common.h" +#include "pal_client_api_intf.h" + +/** + * @brief - Retrieve the version of the PSA Framework API that is implemented. + * This is a wrapper API for psa_framework_version API. + * @param - void + * @return - The PSA Framework API version. + * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. + */ + +uint32_t pal_ipc_framework_version(void) +{ + return (psa_framework_version()); +} + +/** + * @brief - Retrieve the minor version of a Root of Trust Service by its SID. + * This is a wrapper API for the psa_version API. + * @param - sid The Root of Trust Service ID + * @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust + * Service not present on the system. + * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. + */ + +uint32_t pal_ipc_version(uint32_t sid) +{ + return (psa_version(sid)); +} + +/** + * @brief - Connect to given sid. + * This is a wrapper API for the psa_connect API. + * @param - sid : RoT service id + * @param - minor_version : minor_version of RoT service + * @return - psa_handle_t : return connection handle + * Note - Return PSA_NULL_HANDLE if PSA IPC is not implemented. + */ + +psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version) +{ + return (psa_connect(sid, minor_version)); +} + +/** + * @brief Call a connected Root of Trust Service. + * This is a wrapper API for the psa_call API. + * The caller must provide an array of ::psa_invec_t structures as the input payload. + * + * @param -handle Handle for the connection. + * @param -in_vec Array of psa_invec structures. + * @param -in_len Number of psa_invec structures in in_vec. + * @param -out_vec Array of psa_outvec structures for optional Root of Trust Service response. + * @param -out_len Number of psa_outvec structures in out_vec. + * @return -psa_status_t + * Note - Return -1 if PSA IPC is not implemented. + */ + +psa_status_t pal_ipc_call(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + psa_outvec *out_vec, + size_t out_len) +{ + return (psa_call(handle, in_vec, in_len, out_vec, out_len)); +} + +/** + * @brief Close a connection to a Root of Trust Service. + * This is a wrapper API for the psa_close API. + * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources. + * + * @param - handle Handle for the connection. + * @return - void + */ + +void pal_ipc_close(psa_handle_t handle) +{ + psa_close(handle); +} + +#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_intf.h new file mode 100644 index 0000000..3c53f5e --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_client_api_intf.h @@ -0,0 +1,61 @@ +/** @file + * Copyright (c) 2018-2020, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _PAL_CLIENT_API_H_ +#define _PAL_CLIENT_API_H_ + +#include "pal_common.h" + +#define PSA_VERSION_NONE (0) +#define PSA_CONNECTION_REFUSED (INT32_MIN + 1) +#define PSA_CONNECTION_BUSY (INT32_MIN + 2) +#define PSA_DROP_CONNECTION (INT32_MIN) +#define PSA_NULL_HANDLE ((psa_handle_t)0) + +typedef int32_t psa_status_t; +typedef int32_t psa_handle_t; + +typedef struct psa_invec { + const void *base; + size_t len; +} psa_invec; + +typedef struct psa_outvec { + void *base; + size_t len; +} psa_outvec; + +uint32_t psa_framework_version(void); +uint32_t psa_version(uint32_t sid); +psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version); +psa_status_t psa_call(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + psa_outvec *out_vec, + size_t out_len); +void psa_close(psa_handle_t handle); + +uint32_t pal_ipc_framework_version(void); +uint32_t pal_ipc_version(uint32_t sid); +psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version); +psa_status_t pal_ipc_call(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + psa_outvec *out_vec, + size_t out_len); +void pal_ipc_close(psa_handle_t handle); +#endif /* _PAL_CLIENT_API_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_common.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_common.h new file mode 100644 index 0000000..eaa6b4a --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_common.h @@ -0,0 +1,106 @@ +/** @file + * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _PAL_COMMON_H_ +#define _PAL_COMMON_H_ + +#include +#include +#include +#include +#include + +#ifndef PSA_PROTECTED_STORAGE_IMPLEMENTED +#define PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED 1 /* Use ITS by default */ +#define ITS_TEST 1 +#endif + +#include "internal_trusted_storage.h" + +/* typedef's */ +typedef uint8_t bool_t; +typedef uint32_t addr_t; +typedef uint32_t test_id_t; +typedef uint32_t block_id_t; +typedef char char8_t; +typedef uint32_t cfg_id_t; + +#define PAL_STATUS_UNSUPPORTED_FUNC 0xFF + +typedef enum { + PAL_STATUS_SUCCESS = 0x0, + PAL_STATUS_ERROR = 0x80 +} pal_status_t; + +typedef enum { + NVMEM_READ = 0x1, + NVMEM_WRITE = 0x2, +} nvmem_fn_type_t; + +typedef struct { + nvmem_fn_type_t nvmem_fn_type; + addr_t base; + uint32_t offset; + int size; +} nvmem_param_t; + +typedef enum { + WD_INIT_SEQ = 0x1, + WD_ENABLE_SEQ = 0x2, + WD_DISABLE_SEQ = 0x3, + WD_STATUS_SEQ = 0x4, +} wd_fn_type_t; + +typedef enum { + WD_LOW_TIMEOUT = 0x1, + WD_MEDIUM_TIMEOUT = 0x2, + WD_HIGH_TIMEOUT = 0x3, + WD_CRYPTO_TIMEOUT = 0x4, +} wd_timeout_type_t; + +typedef struct { + wd_fn_type_t wd_fn_type; + addr_t wd_base_addr; + uint32_t wd_time_us; + uint32_t wd_timer_tick_us; +} wd_param_t; + +typedef enum { + UART_INIT = 0x1, + UART_PRINT = 0x2, +} uart_fn_type_t; + +/* + * Redefining some of the client.h elements for compilation to go through + * when PSA IPC APIs are not implemented. + */ +#if (PSA_IPC_IMPLEMENTED == 0) + +#ifndef PSA_VERSION_NONE +#define PSA_VERSION_NONE (0) +#endif + +typedef int32_t psa_handle_t; + +#ifndef PSA_NULL_HANDLE +#define PSA_NULL_HANDLE ((psa_handle_t)0) +#endif + + +#endif /* PSA_IPC_IMPLEMENTED */ + +#endif /* _PAL_COMMON_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_interfaces_ns.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_interfaces_ns.h new file mode 100644 index 0000000..6393a47 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_interfaces_ns.h @@ -0,0 +1,187 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifndef _PAL_INTERFACES_NS_H_ +#define _PAL_INTERFACES_NS_H_ + +#include "val.h" +#include "val_client_defs.h" +#include + +/** + @brief - This function will read peripherals using SPI commands + @param - addr : address of the peripheral + - data : read buffer + - len : length of the read buffer in bytes + @return - error status +**/ +int pal_spi_read(addr_t addr, uint8_t *data, uint32_t len); + +/** + * @brief - Retrieve the version of the PSA Framework API that is implemented. + * This is a wrapper API for psa_framework_version API. + * @param - void + * @return - The PSA Framework API version. + * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. + */ +uint32_t pal_ipc_framework_version(void); + +/** + * @brief - Retrieve the minor version of a Root of Trust Service by its SID. + * This is a wrapper API for the psa_version API. + * @param - sid The Root of Trust Service ID + * @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust Service + * not present on the system. + * Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented. + */ +uint32_t pal_ipc_version(uint32_t sid); + +/** + * @brief - Connect to given sid. + * This is a wrapper API for the psa_connect API. + * @param - sid : RoT service id + * - minor_version : minor_version of RoT service + * @return - psa_handle_t : return connection handle + * Note - Return PSA_NULL_HANDLE if PSA IPC is not implemented. + */ +psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version); + +/** + * @brief - Call a connected Root of Trust Service. + * This is a wrapper API for the psa_call API. The caller must provide an array of + * psa_invec_t structures as the input payload. + * @param - handle: Handle for the connection. + * - in_vec: Array of psa_invec structures. + * - in_len: Number of psa_invec structures in in_vec. + * - out_vec: Array of psa_outvec structures for optional Root of Trust Service response. + * - out_len: Number of psa_outvec structures in out_vec. + * @return - psa_status_t + */ + +psa_status_t pal_ipc_call(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + psa_outvec *out_vec, + size_t out_len); + +/** + * @brief - Close a connection to a Root of Trust Service. + * This is a wrapper API for the psa_close API. + * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service + * so it can clean up resources. + * @param - handle Handle for the connection. + * @return - void + */ +void pal_ipc_close(psa_handle_t handle); +/** + @brief - This function initializes the UART + @param - uart base addr + @return - SUCCESS/FAILURE +**/ +int pal_uart_init_ns(uint32_t uart_base_addr); + +/** + * @brief - This function parses the input string and writes bytes into UART TX FIFO + * @param - str : Input String + * - data : Value for format specifier + * @return - SUCCESS/FAILURE +**/ + +int pal_print_ns(char *str, uint32_t data); + +/** + * @brief - Initializes an hardware watchdog timer + * @param - base_addr : Base address of the watchdog module + * - time_us : Time in micro seconds + * - timer_tick_us : Number of ticks per micro second + * @return - SUCCESS/FAILURE +**/ +int pal_wd_timer_init_ns(addr_t base_addr, uint32_t time_us, uint32_t timer_tick_us); + +/** + * @brief - Enables a hardware watchdog timer + * @param - base_addr : Base address of the watchdog module + * @return - SUCCESS/FAILURE +**/ +int pal_wd_timer_enable_ns(addr_t base_addr); + +/** + * @brief - Disables a hardware watchdog timer + * @param - base_addr : Base address of the watchdog module + * @return - SUCCESS/FAILURE +**/ +int pal_wd_timer_disable_ns(addr_t base_addr); + +/** + * @brief - Reads from given non-volatile address. + * @param - base : Base address of nvmem + * offset : Offset + * buffer : Pointer to source address + * size : Number of bytes + * @return - SUCCESS/FAILURE +**/ +int pal_nvmem_read_ns(addr_t base, uint32_t offset, void *buffer, int size); + +/** + * @brief - Writes into given non-volatile address. + * @param - base : Base address of nvmem + * offset : Offset + * buffer : Pointer to source address + * size : Number of bytes + * @return - SUCCESS/FAILURE +**/ +int pal_nvmem_write_ns(addr_t base, uint32_t offset, void *buffer, int size); + +/** + * @brief - This API will call the requested crypto function + * @param - type : function code + * valist : variable argument list + * @return - error status +**/ +int32_t pal_crypto_function(int type, va_list valist); + +/** + * @brief - This API will call the requested internal trusted storage function + * @param - type : function code + * valist : variable argument list + * @return - error status +**/ +uint32_t pal_its_function(int type, va_list valist); + +/** + * @brief - This API will call the requested protected storage function + * @param - type : function code + * valist : variable argument list + * @return - error status +**/ +uint32_t pal_ps_function(int type, va_list valist); + +/** + * @brief - This API will call the requested attestation function + * @param - type : function code + * valist : variable argument list + * @return - error status +**/ +int32_t pal_attestation_function(int type, va_list valist); + +/** + * @brief - Terminates the simulation at the end of all tests completion. + * By default, it put cpus into power down mode. + * @param - void + * @return - void +**/ +void pal_terminate_simulation(void); +#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_internal_trusted_storage_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_internal_trusted_storage_intf.c new file mode 100644 index 0000000..2e9de8c --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_internal_trusted_storage_intf.c @@ -0,0 +1,92 @@ +/** @file + * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + + +#include "pal_internal_trusted_storage_intf.h" + +/** + @brief - This API will call the requested internal trusted storage function + @param - type : function code + valist : variable argument list + @return - error status +**/ +uint32_t pal_its_function(int type, va_list valist) +{ +#if PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED + uint32_t uid, data_length, offset; + const void *p_write_data; + void *p_read_data; + psa_storage_create_flags_t its_create_flags; + //psa_ps_create_flags_t ps_create_flags; + struct psa_its_info_t *its_p_info; + //struct psa_eps_info_t *ps_p_info; + /* TODO: Actual size argument is currently not supported by the testing framework. + * Changes need to be implemented in the actual tests. + * Should be fixed by the next import of the tests. + */ + size_t actual_size; + + switch (type) { + case PAL_ITS_SET: + uid = va_arg(valist, psa_storage_uid_t); + data_length = va_arg(valist, uint32_t); + p_write_data = va_arg(valist, const void *); + its_create_flags = va_arg(valist, psa_storage_create_flags_t); + return psa_its_set(uid, data_length, p_write_data, its_create_flags); + case PAL_ITS_GET: + uid = va_arg(valist, psa_storage_uid_t); + offset = va_arg(valist, uint32_t); + data_length = va_arg(valist, uint32_t); + p_read_data = va_arg(valist, void *); + /* TODO: Actual size argument is currently not supported by the testing framework. + * Changes need to be implemented in the actual tests. + * Should be fixed by the next import of the tests. + */ + return psa_its_get(uid, offset, data_length, p_read_data, &actual_size); + case PAL_ITS_GET_INFO: + uid = va_arg(valist, psa_storage_uid_t); + its_p_info = va_arg(valist, struct psa_its_info_t *); + return psa_its_get_info(uid, (struct psa_storage_info_t *)its_p_info); + case PAL_ITS_REMOVE: + uid = va_arg(valist, psa_storage_uid_t); + return psa_its_remove(uid); + /* case PAL_PS_SET: */ + /* uid = va_arg(valist, uint32_t); */ + /* data_length = va_arg(valist, uint32_t); */ + /* p_write_data = va_arg(valist, const void*); */ + /* ps_create_flags = va_arg(valist, psa_ps_create_flags_t); */ + /* return psa_ps_set(uid, data_length, p_write_data, ps_create_flags); */ + /* case PAL_PS_GET: */ + /* uid = va_arg(valist, uint32_t); */ + /* offset = va_arg(valist, uint32_t); */ + /* data_length = va_arg(valist, uint32_t); */ + /* p_read_data = va_arg(valist, void*); */ + /* return psa_ps_get(uid, offset, data_length, p_read_data); */ + /* case PAL_PS_GET_INFO: */ + /* uid = va_arg(valist, uint32_t); */ + /* ps_p_info = va_arg(valist, struct psa_eps_info_t*); */ + /* return psa_ps_get_info(uid, ps_p_info); */ + /* case PAL_PS_REMOVE: */ + /* uid = va_arg(valist, uint32_t); */ + /* return psa_ps_remove(uid); */ + default: + return PAL_STATUS_UNSUPPORTED_FUNC; + } +#else + return PAL_STATUS_ERROR; +#endif +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_internal_trusted_storage_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_internal_trusted_storage_intf.h new file mode 100644 index 0000000..c40aa43 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_internal_trusted_storage_intf.h @@ -0,0 +1,36 @@ +/** @file + * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _PAL_INTERNAL_TRUSTED_STORAGE_INTF_H_ +#define _PAL_INTERNAL_TRUSTED_STORAGE_INTF_H_ + +#include +#include "pal_common.h" + +#if PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED +#include "psa/internal_trusted_storage.h" +#endif + +enum its_function_code { + PAL_ITS_SET = 0x1, + PAL_ITS_GET = 0x2, + PAL_ITS_GET_INFO = 0x3, + PAL_ITS_REMOVE = 0x4, +}; + +uint32_t pal_its_function(int type, va_list valist); +#endif /* _PAL_INTERNAL_TRUSTED_STORAGE_INTF_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_mbed_os_intf.cpp b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_mbed_os_intf.cpp new file mode 100644 index 0000000..be1c70e --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_mbed_os_intf.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2019-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rtos.h" +#include "mbed_assert.h" +#include "val_interfaces.h" +#include "pal_common.h" + +#include "psa/crypto.h" +#include "entropy_poll.h" + +#include "psa_attest_inject_key.h" +#include "psa_initial_attestation_api.h" + +#include "pal_mbed_os_intf.h" + +#include "lifecycle.h" + +#define TEST_STACK_SIZE 8192 +#define TEST_KEY_ID_VALUE 17 + +extern val_api_t val_api; +extern psa_api_t psa_api; +#ifdef PS_TEST +extern "C" psa_status_t psa_ps_reset(); +#endif + +test_entry_f test_g = NULL; +compliance_test_type type_g = COMPLIANCE_TEST_UNDEFINED; + +// randomly generated attestation key used for testing the attestation feature. +// The specific key chosen shouldn't matter to the attestation test +// the test just needs a key to be injected before it is run. +static const uint8_t private_key_data[] = { + 0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56, + 0x38, 0xc4, 0x31, 0xcf, 0x1d, 0xf1, 0xc9, 0x94, + 0x13, 0x16, 0x09, 0xb5, 0x80, 0xd4, 0xfd, 0x43, + 0xa0, 0xca, 0xb1, 0x7d, 0xb2, 0xf1, 0x3e, 0xee +}; + +static const uint8_t public_key_data[] = { + 0x04, 0x77, 0x72, 0x65, 0x6f, 0x81, 0x4b, 0x39, + 0x92, 0x79, 0xd5, 0xe1, 0xf1, 0x78, 0x1f, 0xac, + 0x6f, 0x09, 0x9a, 0x3c, 0x5c, 0xa1, 0xb0, 0xe3, + 0x53, 0x51, 0x83, 0x4b, 0x08, 0xb6, 0x5e, 0x0b, + 0x57, 0x25, 0x90, 0xcd, 0xaf, 0x8f, 0x76, 0x93, + 0x61, 0xbc, 0xf3, 0x4a, 0xcf, 0xc1, 0x1e, 0x5e, + 0x07, 0x4e, 0x84, 0x26, 0xbd, 0xde, 0x04, 0xbe, + 0x6e, 0x65, 0x39, 0x45, 0x44, 0x96, 0x17, 0xde, + 0x45 +}; + +static void psa_attestation_destroy_key_for_test() +{ + psa_key_handle_t handle = 0; + psa_open_key(TEST_KEY_ID_VALUE, &handle); + psa_destroy_key(handle); +} + +static void psa_attestation_inject_key_for_test(void) +{ + size_t exported_length; + uint8_t exported[sizeof(public_key_data)]; + + psa_attestation_destroy_key_for_test(); + psa_attestation_inject_key(private_key_data, + sizeof(private_key_data), + PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_CURVE_SECP_R1), + exported, + sizeof(exported), + &exported_length); +} + + + +static void reset_storage_for_compliance_test() +{ +#ifdef ITS_TEST + mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST); +#elif PS_TEST + psa_ps_reset(); +#endif +} + +#if !defined(MAX) +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE \ + MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE) + +static void inject_entropy() +{ +#if defined(MBEDTLS_ENTROPY_NV_SEED) + uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = { 0 }; + for (int i = 0; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) { + seed[i] = i; + } + mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE); +#endif // defined(MBEDTLS_ENTROPY_NV_SEED) +} + + + +void main_wrapper(void) +{ + test_g(&val_api, &psa_api); +} + + +void pal_mbed_os_compliance_test_initialize(void) +{ + if (COMPLIANCE_TEST_CRYPTO == type_g) { + inject_entropy(); + } else if (COMPLIANCE_TEST_STORAGE == type_g) { + reset_storage_for_compliance_test(); + } else if (COMPLIANCE_TEST_ATTESTATION == type_g) { + reset_storage_for_compliance_test(); + inject_entropy(); + psa_crypto_init(); + psa_attestation_inject_key_for_test(); // inject key in case needed + } + +} + +void pal_mbed_os_compliance_test_destroy(void) +{ + reset_storage_for_compliance_test(); +} + +int test_start(test_entry_f test_f, compliance_test_type type) +{ + test_g = test_f; + type_g = type; +#if defined(MBED_CONF_RTOS_PRESENT) + MBED_ASSERT((type > COMPLIANCE_TEST_START) && (type < COMPLIANCE_TEST_END)); + Thread thread(osPriorityNormal, TEST_STACK_SIZE, NULL); + thread.start(main_wrapper); + thread.join(); +#endif + return 0; +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_mbed_os_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_mbed_os_intf.h new file mode 100644 index 0000000..5308bf9 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_mbed_os_intf.h @@ -0,0 +1,26 @@ +#ifndef PAL_MBED_OS_CRYPTO_H_ +#define PAL_MBED_OS_CRYPTO_H_ + +#include "val_interfaces.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum _compliance_test_type { + COMPLIANCE_TEST_UNDEFINED, + COMPLIANCE_TEST_START = COMPLIANCE_TEST_UNDEFINED, + COMPLIANCE_TEST_CRYPTO, + COMPLIANCE_TEST_ATTESTATION, + COMPLIANCE_TEST_STORAGE, + COMPLIANCE_TEST_END +} compliance_test_type; + +typedef void (*test_entry_f)(val_api_t *val_api, psa_api_t *psa_api); +int test_start(test_entry_f test_f, compliance_test_type type); + +#ifdef __cplusplus +} +#endif + +#endif /* PAL_MBED_OS_CRYPTO_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_protected_storage_intf.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_protected_storage_intf.c new file mode 100644 index 0000000..893e5f3 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_protected_storage_intf.c @@ -0,0 +1,63 @@ +/** @file + * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + + +#include "pal_protected_storage_intf.h" + +/** + @brief - This API will call the requested protected storage function + @param - type : function code + valist : variable argument list + @return - error status +**/ +uint32_t pal_ps_function(int type, va_list valist) +{ +#if PSA_PROTECTED_STORAGE_IMPLEMENTED + uint32_t uid, data_length, offset; + size_t actual_length; + const void *p_write_data; + void *p_read_data; + psa_storage_create_flags_t ps_create_flags; + struct psa_ps_info_t *ps_p_info; + + switch (type) { + case PAL_PS_SET: + uid = va_arg(valist, psa_storage_uid_t); + data_length = va_arg(valist, uint32_t); + p_write_data = va_arg(valist, const void *); + ps_create_flags = va_arg(valist, psa_storage_create_flags_t); + return psa_ps_set(uid, data_length, p_write_data, ps_create_flags); + case PAL_PS_GET: + uid = va_arg(valist, psa_storage_uid_t); + offset = va_arg(valist, uint32_t); + data_length = va_arg(valist, uint32_t); + p_read_data = va_arg(valist, void *); + return psa_ps_get(uid, offset, data_length, p_read_data, &actual_length); + case PAL_PS_GET_INFO: + uid = va_arg(valist, psa_storage_uid_t); + ps_p_info = va_arg(valist, struct psa_ps_info_t *); + return psa_ps_get_info(uid, ps_p_info); + case PAL_PS_REMOVE: + uid = va_arg(valist, psa_storage_uid_t); + return psa_ps_remove(uid); + default: + return PAL_STATUS_UNSUPPORTED_FUNC; + } +#else + return PAL_STATUS_ERROR; +#endif +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_protected_storage_intf.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_protected_storage_intf.h new file mode 100644 index 0000000..3ebe86a --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/pal/pal_protected_storage_intf.h @@ -0,0 +1,36 @@ +/** @file + * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _PAL_PROTECTED_STORAGE_INTF_H_ +#define _PAL_PROTECTED_STORAGE_INTF_H_ + +#include +#include "pal_common.h" + +#if PSA_PROTECTED_STORAGE_IMPLEMENTED +#include "psa/protected_storage.h" +#endif + +enum ps_function_code { + PAL_PS_SET = 0x1, + PAL_PS_GET = 0x2, + PAL_PS_GET_INFO = 0x3, + PAL_PS_REMOVE = 0x4, +}; + +uint32_t pal_ps_function(int type, va_list valist); +#endif /* _PAL_PROTECTED_STORAGE_INTF_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val.h new file mode 100644 index 0000000..e4d1fa4 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val.h @@ -0,0 +1,277 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_COMMON_H_ +#define _VAL_COMMON_H_ + +#include "pal_common.h" + +#ifndef VAL_NSPE_BUILD +#define STATIC_DECLARE static +#else +#define STATIC_DECLARE +#endif + +#ifndef __WEAK +#define __WEAK __attribute__((weak)) +#endif + +#ifndef __UNUSED +#define __UNUSED __attribute__((unused)) +#endif + +#ifndef TRUE +#define TRUE 0 +#endif +#ifndef FALSE +#define FALSE 1 +#endif + +#ifndef INT_MAX +#define INT_MAX 0xFFFFFFFF +#endif + +#define _CONCAT(A,B) A##B +#define CONCAT(A,B) _CONCAT(A,B) + +/* test status defines */ +#define TEST_START 0x01 +#define TEST_END 0x02 +#define TEST_PASS 0x04 +#define TEST_FAIL 0x08 +#define TEST_SKIP 0x10 +#define TEST_PENDING 0x20 + +#define TEST_NUM_BIT 32 +#define TEST_STATE_BIT 8 +#define TEST_STATUS_BIT 0 + +#define TEST_NUM_MASK 0xFFFFFFFF +#define TEST_STATE_MASK 0xFF +#define TEST_STATUS_MASK 0xFF + +#define RESULT_START(status) (((TEST_START) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) +#define RESULT_END(status) (((TEST_END) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) +#define RESULT_PASS(status) (((TEST_PASS) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) +#define RESULT_FAIL(status) (((TEST_FAIL) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) +#define RESULT_SKIP(status) (((TEST_SKIP) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) +#define RESULT_PENDING(status) (((TEST_PENDING) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) + +#define IS_TEST_FAIL(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_FAIL) +#define IS_TEST_PASS(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_PASS) +#define IS_TEST_SKIP(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_SKIP) +#define IS_TEST_PENDING(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_PENDING) +#define IS_TEST_START(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_START) +#define IS_TEST_END(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_END) +#define VAL_ERROR(status) ((status & TEST_STATUS_MASK) ? 1 : 0) + + + +/* Test Defines */ +#define TEST_PUBLISH(test_id, entry) + +#define VAL_MAX_TEST_PER_COMP 200 +#define VAL_FF_BASE 0 +#define VAL_CRYPTO_BASE 1 +#define VAL_PROTECTED_STORAGE_BASE 2 +#define VAL_INTERNAL_TRUSTED_STORAGE_BASE 3 +#define VAL_INITIAL_ATTESTATION_BASE 4 + +#define VAL_GET_COMP_NUM(test_id) \ + ((test_id - (test_id % VAL_MAX_TEST_PER_COMP)) / VAL_MAX_TEST_PER_COMP) +#define VAL_GET_TEST_NUM(test_id) (test_id % VAL_MAX_TEST_PER_COMP) +#define VAL_CREATE_TEST_ID(comp,num) ((comp*VAL_MAX_TEST_PER_COMP) + num) + +#define TEST_FIELD(num1,num2) (num2 << 8 | num1) +#define GET_TEST_ISOLATION_LEVEL(num) (num & 0x3) +#define GET_WD_TIMOUT_TYPE(num) ((num >> 8) & 0x7) + +#define TEST_CHECKPOINT_NUM(n) n +#define TEST(n) n +#define BLOCK(n) n + +#define BLOCK_NUM_POS 8 +#define ACTION_POS 16 +#define GET_TEST_NUM(n) (0xff & n) +#define GET_BLOCK_NUM(n) ((n >> BLOCK_NUM_POS) & 0xff) + +#define GET_ACTION_NUM(n) ((n >> ACTION_POS) & 0xff) +#define TEST_EXECUTE_FUNC 1 +#define TEST_RETURN_RESULT 2 +#define INVALID_HANDLE 0x1234DEAD + +#define VAL_NVMEM_BLOCK_SIZE 4 +#define VAL_NVMEM_OFFSET(nvmem_idx) (nvmem_idx * VAL_NVMEM_BLOCK_SIZE) + +#define UART_INIT_SIGN 0xff +#define UART_PRINT_SIGN 0xfe + +#define TEST_PANIC() \ + do { \ + } while(1) + +#define TEST_ASSERT_EQUAL(arg1, arg2, checkpoint) \ + do { \ + if ((arg1) != arg2) \ + { \ + val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d\n", checkpoint); \ + val->print(PRINT_ERROR, "\tActual: %d\n", arg1); \ + val->print(PRINT_ERROR, "\tExpected: %d\n", arg2); \ + return 1; \ + } \ + } while (0) + +#define TEST_ASSERT_DUAL(arg1, status1, status2, checkpoint) \ + do { \ + if ((arg1) != status1 && (arg1) != status2) \ + { \ + val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d\n", checkpoint); \ + val->print(PRINT_ERROR, "\tActual: %d\n", arg1); \ + val->print(PRINT_ERROR, "\tExpected: %d", status1); \ + val->print(PRINT_ERROR, "or %d\n", status2); \ + return 1; \ + } \ + } while (0) + +#define TEST_ASSERT_NOT_EQUAL(arg1, arg2, checkpoint) \ + do { \ + if ((arg1) == arg2) \ + { \ + val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d\n", checkpoint); \ + val->print(PRINT_ERROR, "\tValue: %d\n", arg1); \ + return 1; \ + } \ + } while (0) + +#define TEST_ASSERT_MEMCMP(buf1, buf2, size, checkpoint) \ + do { \ + if (memcmp(buf1, buf2, size)) \ + { \ + val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d : ", checkpoint); \ + val->print(PRINT_ERROR, "Unequal data in compared buffers\n", 0); \ + return 1; \ + } \ + } while (0) + +/* enums */ +typedef enum { + CALLER_NONSECURE = 0x0, + CALLER_SECURE = 0x1, +} caller_security_t; + +typedef enum { + TEST_ISOLATION_L1 = 0x1, + TEST_ISOLATION_L2 = 0x2, + TEST_ISOLATION_L3 = 0x3, +} test_isolation_level_t; + +typedef enum { + BOOT_UNKNOWN = 0x1, + BOOT_NOT_EXPECTED = 0x2, + BOOT_EXPECTED_NS = 0x3, + BOOT_EXPECTED_S = 0x4, + BOOT_EXPECTED_BUT_FAILED = 0x5, + BOOT_EXPECTED_CRYPTO = 0x6, +} boot_state_t; + +typedef enum { + NV_BOOT = 0x0, + NV_TEST_ID_PREVIOUS = 0x1, + NV_TEST_ID_CURRENT = 0x2, + NV_TEST_CNT = 0x3, +} nvmem_index_t; + +/* enums to report test sub-state */ +typedef enum { + VAL_STATUS_SUCCESS = 0x0, + VAL_STATUS_INVALID = 0x10, + VAL_STATUS_ERROR = 0x11, + VAL_STATUS_NOT_FOUND = 0x12, + VAL_STATUS_LOAD_ERROR = 0x13, + VAL_STATUS_INSUFFICIENT_SIZE = 0x14, + VAL_STATUS_CONNECTION_FAILED = 0x15, + VAL_STATUS_CALL_FAILED = 0x16, + VAL_STATUS_READ_FAILED = 0x17, + VAL_STATUS_WRITE_FAILED = 0x18, + VAL_STATUS_ISOLATION_LEVEL_NOT_SUPP = 0x19, + VAL_STATUS_INIT_FAILED = 0x1A, + VAL_STATUS_SPM_FAILED = 0x1B, + VAL_STATUS_SPM_UNEXPECTED_BEH = 0x1C, + VAL_STATUS_FRAMEWORK_VERSION_FAILED = 0x1D, + VAL_STATUS_VERSION_API_FAILED = 0x1E, + VAL_STATUS_INVALID_HANDLE = 0x1F, + VAL_STATUS_INVALID_MSG_TYPE = 0x20, + VAL_STATUS_WRONG_IDENTITY = 0x21, + VAL_STATUS_MSG_INSIZE_FAILED = 0x22, + VAL_STATUS_MSG_OUTSIZE_FAILED = 0x23, + VAL_STATUS_SKIP_FAILED = 0x24, + VAL_STATUS_CRYPTO_FAILURE = 0x25, + VAL_STATUS_INVALID_SIZE = 0x26, + VAL_STATUS_DATA_MISMATCH = 0x27, + VAL_STATUS_BOOT_EXPECTED_BUT_FAILED = 0x28, + VAL_STATUS_INIT_ALREADY_DONE = 0x29, + VAL_STATUS_HEAP_NOT_AVAILABLE = 0x2A, + VAL_STATUS_UNSUPPORTED = 0x2B, + VAL_STATUS_ERROR_MAX = INT_MAX, +} val_status_t; + +/* verbosity enums */ +typedef enum { + PRINT_INFO = 1, + PRINT_DEBUG = 2, + PRINT_TEST = 3, + PRINT_WARN = 4, + PRINT_ERROR = 5, + PRINT_ALWAYS = 9 +} print_verbosity_t; + +/* Interrupt test function id enums */ +typedef enum { + TEST_PSA_EOI_WITH_NON_INTR_SIGNAL = 1, + TEST_PSA_EOI_WITH_MULTIPLE_SIGNALS = 2, + TEST_PSA_EOI_WITH_UNASSERTED_SIGNAL = 3, + TEST_INTR_SERVICE = 4, +} test_intr_fn_id_t; + +/* typedef's */ +typedef struct { + boot_state_t state; +} boot_t; + +typedef struct { + uint32_t pass_cnt: 8; + uint32_t skip_cnt: 8; + uint32_t fail_cnt: 8; + uint32_t sim_error_cnt: 8; +} test_count_t; + +typedef struct { + uint16_t test_num; + uint8_t block_num; +} test_info_t; + + +/* struture to capture test state */ +typedef struct { + uint16_t reserved; + uint8_t state; + uint8_t status; +} test_status_buffer_t; + +typedef int32_t (*client_test_t)(caller_security_t caller); +typedef int32_t (*server_test_t)(void); +#endif /* VAL_COMMON_H */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_attestation.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_attestation.c new file mode 100644 index 0000000..cd8069a --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_attestation.c @@ -0,0 +1,40 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "val_target.h" +#include "pal_interfaces_ns.h" +#include "val_framework.h" +#include "val_client_defs.h" +#include "val_attestation.h" + +/** + @brief - This API will call the requested attestation function + @param - type : function code + ... : variable number of arguments + @return - Error status +**/ + +int32_t val_attestation_function(int type, ...) +{ + va_list valist; + val_status_t status; + + va_start(valist, type); + status = pal_attestation_function(type, valist); + va_end(valist); + return status; +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_attestation.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_attestation.h new file mode 100644 index 0000000..5322723 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_attestation.h @@ -0,0 +1,33 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_INITIAL_ATTESTATION_H_ +#define _VAL_INITIAL_ATTESTATION_H_ + +#include "val.h" +#include "psa_initial_attestation_api.h" + +#define MAX_CHALLENGE_SIZE PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 + +enum attestation_function_code { + VAL_INITIAL_ATTEST_GET_TOKEN = 0x1, + VAL_INITIAL_ATTEST_GET_TOKEN_SIZE = 0x2, + VAL_INITIAL_ATTEST_VERIFY_TOKEN = 0x3, +}; + +int32_t val_attestation_function(int type, ...); +#endif /* _VAL_INITIAL_ATTESTATION_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_client_defs.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_client_defs.h new file mode 100644 index 0000000..eaef75c --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_client_defs.h @@ -0,0 +1,35 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_CLIENT_H_ +#define _VAL_CLIENT_H_ + +#include "val.h" +#include "psa/client.h" +#include "psa/crypto_types.h" +#include "psa/crypto_values.h" + +#define INVALID_SID 0x0000FA20 + +#ifndef CLIENT_TEST_DISPATCHER_SID +#define CLIENT_TEST_DISPATCHER_SID 0x0 +#endif + +#ifndef SERVER_TEST_DISPATCHER_SID +#define SERVER_TEST_DISPATCHER_SID 0x0 +#endif +#endif /* _VAL_CLIENT_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_entry.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_entry.h new file mode 100644 index 0000000..2b885e0 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_entry.h @@ -0,0 +1,32 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_ENTRY_H_ +#define _VAL_ENTRY_H_ + +#include "val_framework.h" + +#define PSA_ACS_MAJOR_VER 0 +#define PSA_ACS_MINOR_VER 8 + +/** + @brief - PSA Test Suite C main function, does VAL init and calls test dispatcher + @param - None + @return - void +**/ +extern void val_entry(void); +#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_framework.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_framework.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_framework.h diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_greentea.cpp b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_greentea.cpp new file mode 100644 index 0000000..ba57016 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_greentea.cpp @@ -0,0 +1,297 @@ +#include "greentea-client/test_env.h" +#include "inttypes.h" +#include "val_greentea.h" + +void pal_mbed_os_compliance_test_initialize(void); +void pal_mbed_os_compliance_test_destroy(void); + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* globals */ +test_status_buffer_t g_status_buffer; + +void mbed_val_test_init(uint32_t test_num, char8_t *desc, uint32_t test_bitfield) +{ + /*global init*/ + g_status_buffer.state = 0; + g_status_buffer.status = VAL_STATUS_INVALID; + + mbed_val_print(PRINT_ALWAYS, "\nTEST: %d | DESCRIPTION: ", test_num); + mbed_val_print(PRINT_ALWAYS, desc, 0); + GREENTEA_SETUP(100, "default_auto"); + mbed_val_set_status(RESULT_START(VAL_STATUS_SUCCESS)); + pal_mbed_os_compliance_test_initialize(); + return; +} + +void mbed_val_test_exit(void) +{ + uint32_t status = mbed_val_get_status(); + pal_mbed_os_compliance_test_destroy(); + /* return if test skipped or failed */ + if (IS_TEST_FAIL(status) || IS_TEST_SKIP(status)) { + GREENTEA_TESTSUITE_RESULT(false); + } else { + GREENTEA_TESTSUITE_RESULT(true); + mbed_val_set_status(RESULT_END(VAL_STATUS_SUCCESS)); + } +} + +/** +@brief - This function executes given list of tests from non-secure sequentially + This covers non-secure to secure IPC API scenario +@param - test_num : Test_num +@param - tests_list : list of tests to be executed +@param - server_hs : Initiate a server handshake +@return - val_status_t +**/ +val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t *tests_list, + bool_t server_hs) +{ + val_status_t status = VAL_STATUS_SUCCESS; + int32_t test_status = VAL_STATUS_SUCCESS; + psa_handle_t handle; + uint32_t i = 1; + test_info_t test_info; + char testcase_name[100] = ""; + bool continue_test = true; + + test_info.test_num = test_num; + + mbed_val_print(PRINT_TEST, "[Info] Executing tests from non-secure\n", 0); + while (tests_list[i] != NULL) { + memset(testcase_name, 0, 100); + sprintf(testcase_name, "Check%" PRIu32, i); + GREENTEA_TESTCASE_START(testcase_name); + if (server_hs == TRUE) { + /* Handshake with server tests */ + test_info.block_num = i; + status = mbed_val_execute_secure_test_func(&handle, test_info, + SERVER_TEST_DISPATCHER_SID); + if (VAL_ERROR(status)) { + mbed_val_set_status(RESULT_FAIL(status)); + mbed_val_print(PRINT_ERROR, "[Check%d] START\n", i); + return status; + } else { + mbed_val_print(PRINT_DEBUG, "[Check%d] START\n", i); + } + } + + /* Execute client tests */ + test_status = tests_list[i](CALLER_NONSECURE); + + if (server_hs == TRUE) { + /* Retrive Server test status */ + status = mbed_val_get_secure_test_result(&handle); + } + + if (test_status != VAL_STATUS_SUCCESS) { + status = VAL_STATUS_ERROR; + } + + if (IS_TEST_SKIP(status)) { + mbed_val_set_status(status); + mbed_val_print(PRINT_DEBUG, "[Check%d] SKIPPED\n", i); + GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); + continue_test = false; + } else if (VAL_ERROR(status)) { + mbed_val_set_status(RESULT_FAIL(status)); + if (server_hs == TRUE) { + mbed_val_print(PRINT_ERROR, "[Check%d] FAILED\n", i); + } + GREENTEA_TESTCASE_FINISH(testcase_name, 0, 1); + continue_test = false; + } else { + if (server_hs == TRUE) { + mbed_val_print(PRINT_DEBUG, "[Check%d] PASSED\n", i); + } + GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); + continue_test = true; + } + + if (!continue_test) { + return status; + } + + i++; + } + return status; +} + +/** +@brief - Records the state and status of test +@return - val_status_t +**/ +val_status_t mbed_val_set_status(uint32_t status) +{ + g_status_buffer.state = ((status >> TEST_STATE_BIT) & TEST_STATE_MASK); + g_status_buffer.status = (status & TEST_STATUS_MASK); + + return VAL_STATUS_SUCCESS; +} + +/** +@brief - Updates the state and status for a given test +@return - test status +**/ +uint32_t mbed_val_get_status(void) +{ + return ((g_status_buffer.state) << TEST_STATE_BIT) | (g_status_buffer.status); +} + +/** +@brief - This function is used to handshake between: + - nonsecure client fn to server test fn + - secure client fn and server test fn + - nonsecure client fn to secure client test fn +@param - handle : handle returned while connecting given sid +@param - test_info : Test_num and block_num to be executed +@param - sid : RoT service to be connected. Partition dispatcher sid +@return - val_status_t +**/ +val_status_t mbed_val_execute_secure_test_func(psa_handle_t *handle, test_info_t test_info, uint32_t sid) +{ + uint32_t test_data; + val_status_t status = VAL_STATUS_SUCCESS; + psa_status_t status_of_call = PSA_SUCCESS; + + *handle = pal_ipc_connect(sid, 0); + if (*handle < 0) { + mbed_val_print(PRINT_ERROR, "Could not connect SID. Handle=%x\n", *handle); + return VAL_STATUS_CONNECTION_FAILED; + } + + test_data = ((uint32_t)(test_info.test_num) | ((uint32_t)(test_info.block_num) << BLOCK_NUM_POS) | ((uint32_t)(TEST_EXECUTE_FUNC) << ACTION_POS)); + psa_invec data[1] = {{&test_data, sizeof(test_data)}}; + + status_of_call = pal_ipc_call(*handle, data, 1, NULL, 0); + if (status_of_call != PSA_SUCCESS) { + status = VAL_STATUS_CALL_FAILED; + mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call); + pal_ipc_close(*handle); + } + + return status; +} + +/** +@brief - Print module. This is client interface API of secure partition + mbed_val_print_sf API for nspe world +@param - verbosity: Print verbosity level + - string : Input string + - data : Value for format specifier +@return - val_status_t +**/ +val_status_t mbed_val_print(print_verbosity_t verbosity, const char *string, uint32_t data) +{ + if (data != 0) { + printf(string, data); + } else { + printf(string); + } + + return VAL_STATUS_SUCCESS; +} + +/** +@brief - This function is used to retrive the status of previously connected test function + using mbed_val_execute_secure_test_func +@param - handle : handle of server function. Handle of Partition dispatcher sid +@return - The status of test functions +**/ +val_status_t mbed_val_get_secure_test_result(psa_handle_t *handle) +{ + uint32_t test_data; + val_status_t status = VAL_STATUS_SUCCESS; + psa_status_t status_of_call = PSA_SUCCESS; + + test_data = (TEST_RETURN_RESULT << ACTION_POS); + + psa_outvec resp = {&status, sizeof(status)}; + psa_invec data[1] = {{&test_data, sizeof(test_data)}}; + + status_of_call = pal_ipc_call(*handle, data, 1, &resp, 1); + if (status_of_call != PSA_SUCCESS) { + status = VAL_STATUS_CALL_FAILED; + mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call); + } + + pal_ipc_close(*handle); + return status; +} + +/** + * @brief Connect to given sid + @param -sid : RoT service id + @param -minor_version : minor_version of RoT service + @param -handle - return connection handle + * @return val_status_t + */ +val_status_t mbed_val_ipc_connect(uint32_t sid, uint32_t minor_version, psa_handle_t *handle) +{ + *handle = pal_ipc_connect(sid, minor_version); + + if (*handle < 0) { + return VAL_STATUS_CONNECTION_FAILED; + } + + return VAL_STATUS_SUCCESS; +} + +/** + * @brief Call a connected Root of Trust Service.@n + * The caller must provide an array of ::psa_invec_t structures as the input payload. + * + * @param handle Handle for the connection. + * @param in_vec Array of psa_invec structures. + * @param in_len Number of psa_invec structures in in_vec. + * @param out_vec Array of psa_outvec structures for optional Root of Trust Service response. + * @param out_len Number of psa_outvec structures in out_vec. + * @return val_status_t + */ +val_status_t mbed_val_ipc_call(psa_handle_t handle, psa_invec *in_vec, size_t in_len, + psa_outvec *out_vec, size_t out_len) +{ + psa_status_t call_status = PSA_SUCCESS; + + call_status = pal_ipc_call(handle, in_vec, in_len, out_vec, out_len); + + if (call_status != PSA_SUCCESS) { + return VAL_STATUS_CALL_FAILED; + } + + return VAL_STATUS_SUCCESS; +} + +/** + * @brief Close a connection to a Root of Trust Service. + * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources. + * + * @param handle Handle for the connection. + * @return void + */ +void mbed_val_ipc_close(psa_handle_t handle) +{ + pal_ipc_close(handle); +} + + +/** + * @brief reprogram the watchdog timer + * always succeeds on mbed-greentead testing. + * + * @param timeout_type type of timeout. + * @return val_status_t + */ +val_status_t mbed_val_wd_reprogram_timer(wd_timeout_type_t timeout_type) +{ + return VAL_STATUS_SUCCESS; +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_greentea.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_greentea.h new file mode 100644 index 0000000..a8d7da8 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_greentea.h @@ -0,0 +1,30 @@ +#ifndef _VAL_GREENTEA_H_ +#define _VAL_GREENTEA_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "val.h" +#include "val_interfaces.h" + +void mbed_val_test_init(uint32_t test_num, char8_t *desc, uint32_t test_bitfield); +void mbed_val_test_exit(void); +val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t *tests_list, bool_t server_hs); +val_status_t mbed_val_set_status(uint32_t status); +uint32_t mbed_val_get_status(void); +val_status_t mbed_val_execute_secure_test_func(psa_handle_t *handle, test_info_t test_info, uint32_t sid); +val_status_t mbed_val_print(print_verbosity_t verbosity, const char *string, uint32_t data); +val_status_t mbed_val_get_secure_test_result(psa_handle_t *handle); +val_status_t mbed_val_ipc_connect(uint32_t sid, uint32_t minor_version, psa_handle_t *handle); +val_status_t mbed_val_ipc_call(psa_handle_t handle, psa_invec *in_vec, size_t in_len, + psa_outvec *out_vec, size_t out_len); +void mbed_val_ipc_close(psa_handle_t handle); +val_status_t mbed_val_wd_reprogram_timer(wd_timeout_type_t timeout_type); + +#ifdef __cplusplus +} +#endif + +#endif // _VAL_GREENTEA_H_ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_interfaces.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_interfaces.c new file mode 100644 index 0000000..b6bf085 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_interfaces.c @@ -0,0 +1,60 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + + +#include "val_greentea.h" +#include "val_interfaces.h" +#include "val_internal_trusted_storage.h" +#include "val_protected_storage.h" +#include "val_attestation.h" + +/*VAL APIs to be used by test */ +const val_api_t val_api = { + .print = mbed_val_print, + .set_status = mbed_val_set_status, + .get_status = mbed_val_get_status, + .test_init = mbed_val_test_init, + .test_exit = mbed_val_test_exit, + .err_check_set = NULL, + .target_get_config = NULL, + .execute_non_secure_tests = mbed_val_execute_non_secure_tests, + .switch_to_secure_client = NULL, + .execute_secure_test_func = mbed_val_execute_secure_test_func, + .get_secure_test_result = mbed_val_get_secure_test_result, + .ipc_connect = mbed_val_ipc_connect, + .ipc_call = mbed_val_ipc_call, + .ipc_close = mbed_val_ipc_close, + .nvmem_read = NULL, + .nvmem_write = NULL, + .wd_timer_init = NULL, + .wd_timer_enable = NULL, + .wd_timer_disable = NULL, + .wd_reprogram_timer = mbed_val_wd_reprogram_timer, + .set_boot_flag = NULL, + .get_boot_flag = NULL, + .its_function = val_its_function, + .ps_function = val_ps_function, + .attestation_function = val_attestation_function, +}; + +const psa_api_t psa_api = { + .framework_version = pal_ipc_framework_version, + .version = pal_ipc_version, + .connect = pal_ipc_connect, + .call = pal_ipc_call, + .close = pal_ipc_close, +}; diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_interfaces.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_interfaces.h new file mode 100644 index 0000000..40bc673 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_interfaces.h @@ -0,0 +1,83 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_INTERFACES_H_ +#define _VAL_INTERFACES_H_ + +#include "val.h" +#include "val_client_defs.h" +#include "pal_interfaces_ns.h" + +/* typedef's */ +typedef struct { + val_status_t (*print)(print_verbosity_t verbosity, + const char *string, uint32_t data); + val_status_t (*set_status)(uint32_t status); + uint32_t (*get_status)(void); + void (*test_init)(uint32_t test_num, char8_t *desc, + uint32_t test_bitfield); + void (*test_exit)(void); + val_status_t (*err_check_set)(uint32_t checkpoint, val_status_t status); + val_status_t (*target_get_config)(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); + val_status_t (*execute_non_secure_tests)(uint32_t test_num, client_test_t *tests_list, + bool_t server_hs); + val_status_t (*switch_to_secure_client)(uint32_t test_num); + val_status_t (*execute_secure_test_func)(psa_handle_t *handle, test_info_t test_info, + uint32_t sid); + val_status_t (*ipc_connect)(uint32_t sid, uint32_t minor_version, + psa_handle_t *handle); + val_status_t (*ipc_call)(psa_handle_t handle, psa_invec *in_vec, + size_t in_len, psa_outvec *out_vec, + size_t out_len); + void (*ipc_close)(psa_handle_t handle); + val_status_t (*get_secure_test_result)(psa_handle_t *handle); + val_status_t (*nvmem_read)(uint32_t offset, void *buffer, int size); + val_status_t (*nvmem_write)(uint32_t offset, void *buffer, int size); + val_status_t (*wd_timer_init)(wd_timeout_type_t timeout_type); + val_status_t (*wd_timer_enable)(void); + val_status_t (*wd_timer_disable)(void); + val_status_t (*wd_reprogram_timer)(wd_timeout_type_t timeout_type); + val_status_t (*set_boot_flag)(boot_state_t state); + val_status_t (*get_boot_flag)(boot_state_t *state); + int32_t (*crypto_function)(int type, ...); + uint32_t (*its_function)(int type, ...); + uint32_t (*ps_function)(int type, ...); + int32_t (*attestation_function)(int type, ...); +} val_api_t; + +typedef struct { + uint32_t (*framework_version)(void); + uint32_t (*version)(uint32_t sid); + psa_handle_t (*connect)(uint32_t sid, uint32_t minor_version); + psa_status_t (*call)(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + psa_outvec *out_vec, + size_t out_len + ); + void (*close)(psa_handle_t handle); +} psa_api_t; + +typedef void (*test_fptr_t)(val_api_t *val, psa_api_t *psa); + +typedef struct { + test_id_t test_id; + test_fptr_t entry_addr; +} val_test_info_t; + +void test_entry(val_api_t *val, psa_api_t *psa); +#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_internal_trusted_storage.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_internal_trusted_storage.c new file mode 100644 index 0000000..e79e9c0 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_internal_trusted_storage.c @@ -0,0 +1,39 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "val_target.h" +#include "pal_interfaces_ns.h" +#include "val_framework.h" +#include "val_client_defs.h" +#include "val_internal_trusted_storage.h" + +/** + @brief - This API will call the requested internal trusted storage function + @param - type : function code + ... : variable number of arguments + @return - Error status +**/ +uint32_t val_its_function(int type, ...) +{ + va_list valist; + uint32_t status; + + va_start(valist, type); + status = pal_its_function(type, valist); + va_end(valist); + return status; +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_internal_trusted_storage.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_internal_trusted_storage.h new file mode 100644 index 0000000..2f9384d --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_internal_trusted_storage.h @@ -0,0 +1,34 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_INTERNAL_TRUSTED_STORAGE_H_ +#define _VAL_INTERNAL_TRUSTED_STORAGE_H_ + +#include "val.h" + +#define UID_BASE_VALUE 0 +#define BYTES_TO_BITS(byte) (byte * 8) + +enum its_function_code { + VAL_ITS_SET = 0x1, + VAL_ITS_GET = 0x2, + VAL_ITS_GET_INFO = 0x3, + VAL_ITS_REMOVE = 0x4, +}; + +uint32_t val_its_function(int type, ...); +#endif /* _VAL_INTERNAL_TRUSTED_STORAGE_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_protected_storage.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_protected_storage.c new file mode 100644 index 0000000..06c1f50 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_protected_storage.c @@ -0,0 +1,39 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "val_target.h" +#include "pal_interfaces_ns.h" +#include "val_framework.h" +#include "val_client_defs.h" +#include "val_protected_storage.h" + +/** + @brief - This API will call the requested protected storage function + @param - type : function code + ... : variable number of arguments + @return - Error status +**/ +uint32_t val_ps_function(int type, ...) +{ + va_list valist; + uint32_t status; + + va_start(valist, type); + status = pal_ps_function(type, valist); + va_end(valist); + return status; +} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_protected_storage.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_protected_storage.h new file mode 100644 index 0000000..7f05cea --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_protected_storage.h @@ -0,0 +1,37 @@ +/** @file + * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _VAL_PROTECTED_STORAGE_H_ +#define _VAL_PROTECTED_STORAGE_H_ + +#include "val.h" + +#define UID_BASE_VALUE 0 +#define BYTES_TO_BITS(byte) (byte * 8) + +enum ps_function_code { + VAL_PS_SET = 0x1, + VAL_PS_GET = 0x2, + VAL_PS_GET_INFO = 0x3, + VAL_PS_REMOVE = 0x4, + VAL_PS_CREATE = 0x5, + VAL_PS_SET_EXTENDED = 0x6, + VAL_PS_GET_SUPPORT = 0x7, +}; + +uint32_t val_ps_function(int type, ...); +#endif /* _VAL_PROTECTED_STORAGE_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_target.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_target.h new file mode 100644 index 0000000..1eb7a61 --- /dev/null +++ b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/test_abstraction_layers/val/val_target.h @@ -0,0 +1,205 @@ +/** @file + * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef _TARGET_INFO_DATA_H_ +#define _TARGET_INFO_DATA_H_ + +#include "val.h" + +#define TARGET_CONFIG_CREATE_ID(major, minor, index) \ + (((major & 0xFF) << 24) | ((minor & 0xFF) << 16) | (index & 0xFFFF)) +#define TARGET_CONFIG_GET_MAJOR(config_id) ((config_id >> 24) & 0xFF) +#define TARGET_CONFIG_GET_MINOR(config_id) ((config_id >> 16) & 0xFF) +#define TARGET_CONFIG_INCREMENT_INDEX(config_id) \ + ((config_id & 0xFFFF0000) | ((config_id & 0xFFFF) + 1)) +#define GET_NUM_INSTANCE(struct_type) (struct_type->cfg_type.size >> 24) +#define VAL_TEST_MAJOR_GROUP_MASK 0xFF000000UL +#define VAL_TEST_MINOR_GROUP_MASK 0x00FF0000UL +#define VAL_TEST_CFG_INSTANCE_MASK 0x0000FFFFUL +#define VAL_TEST_INVALID_CFG_ID 0xFFFFFFFFUL +#define TARGET_MIN_CFG_ID TARGET_CONFIG_CREATE_ID(GROUP_SOC_PERIPHERAL, 0, 0) +#define TARGET_MAX_CFG_ID TARGET_CONFIG_CREATE_ID(GROUP_MAX, 0, 0) + +/** + Config IDs for each group/component + 31:24 : MAJOR (group) + 23:16 : MINOR (component) + 16:8 : SUB-component + 7:0 : INSTANCE (instance of same component) +**/ + +/* + MAJOR IDs +*/ +typedef enum _GROUP_CONFIG_ID_ { + GROUP_SOC_PERIPHERAL = 0x1, + GROUP_MEMORY = 0x2, + GROUP_MISCELLANEOUS = 0x3, + GROUP_MAX = 0xFF, +} group_cfg_id_t; + +/* + MINOR IDs + */ +typedef enum _SOC_PERIPHERAL_CONFIG_ID_ { + SOC_PERIPHERAL_UART = 0x1, + SOC_PERIPHERAL_TIMER = 0x2, + SOC_PERIPHERAL_WATCHDOG = 0x3, +} soc_peripheral_cfg_id_t; + +typedef enum _MEMORY_CONFIG_ID_ { + MEMORY_NVMEM = 0x2, + MEMORY_NSPE_MMIO = 0x3, + MEMORY_CLIENT_PARTITION_MMIO = 0x4, + MEMORY_DRIVER_PARTITION_MMIO = 0x5, +} memory_cfg_id_t; + +typedef enum _MISCELLANEOUS_CONFIG_ID_ { + MISCELLANEOUS_BOOT = 0x1, + MISCELLANEOUS_DUT = 0x2 +} miscellaneous_cfg_id_t; + +/** + Assign group type to each system component +**/ +typedef enum _COMPONENT_GROUPING_ { + UART = GROUP_SOC_PERIPHERAL, + TIMER = GROUP_SOC_PERIPHERAL, + WATCHDOG = GROUP_SOC_PERIPHERAL, + NVMEM = GROUP_MEMORY, + NSPE_MMIO = GROUP_MEMORY, + CLIENT_PARTITION_MMIO = GROUP_MEMORY, + DRIVER_PARTITION_MMIO = GROUP_MEMORY, + BOOT = GROUP_MISCELLANEOUS, + DUT = GROUP_MISCELLANEOUS, +} comp_group_assign_t; + +/** + Target Configuration Header +**/ +typedef struct _TARGET_CFG_HDR_ { + /* PSA_CFG */ + uint32_t signature[2]; + /* 8 byte String describing the Target platform */ + uint32_t target_string[2]; + /* version = 1 for now */ + uint32_t version; + /* Header Size */ + uint32_t size; +} target_cfg_hdr_t; + +typedef enum { + LEVEL1 = 0x1, + LEVEL2, + LEVEL3, +} firmware_level_t; + +typedef enum { + NOT_AVAILABLE = 0x0, + AVAILABLE = 0x1, +} is_available_t; + +typedef enum { + SECURE_ACCESS = 0x100, + NONSECURE_ACCESS, + SECURE_PROGRAMMABLE, + NONSECURE_PROGRAMMABLE +} dev_attr_t; + +typedef enum { + MEM_SECURE = 0x100, + MEM_NONSECURE, + MEM_NSC, +} mem_tgt_attr_t; + +typedef enum { + TYPE_READ_ONLY = 0x10, + TYPE_WRITE_ONLY, + TYPE_READ_WRITE, + TYPE_EXECUTE, + TYPE_RESERVED, +} perm_type_t; + +typedef struct _CFG_HDR_TYPE_ { + cfg_id_t cfg_id; + /* size inclusive of this header */ + uint32_t size; +} cfg_type_t; + +/** + Memory Information +**/ +typedef struct _MEM_INFO_DESC_ { + cfg_type_t cfg_type; + uint32_t num; +} memory_hdr_t; + +typedef struct _MEM_REGION_ { + cfg_type_t cfg_type; + addr_t start; + addr_t end; + mem_tgt_attr_t attribute; + perm_type_t permission; +} memory_desc_t; + +/* + SOC Peripheral description structures +*/ +typedef struct _SOC_PER_INFO_NUM_ { + cfg_type_t cfg_type; + uint32_t num; +} soc_peripheral_hdr_t; + +typedef struct _SOC_PER_INFO_DESC_ { + cfg_type_t cfg_type; + uint32_t vendor_id; + uint32_t device_id; + addr_t base; + uint32_t size; + uint32_t intr_id; + perm_type_t permission; + uint32_t timeout_in_micro_sec_low; + uint32_t timeout_in_micro_sec_medium; + uint32_t timeout_in_micro_sec_high; + uint32_t timeout_in_micro_sec_crypto; + uint32_t num_of_tick_per_micro_sec; + dev_attr_t attribute; +} soc_peripheral_desc_t; + +/** + System Miscellaneous Information +**/ + +typedef struct _MISCELLANEOUS_INFO_HDR_ { + cfg_type_t cfg_type; + uint32_t num; +} miscellaneous_hdr_t; + +typedef struct _MISCELLANEOUS_INFO_DESC_ { + cfg_type_t cfg_type; + firmware_level_t implemented_psa_firmware_isolation_level; + addr_t ns_start_addr_of_combine_test_binary; + is_available_t combine_test_binary_in_ram; + addr_t ns_test_addr; +} miscellaneous_desc_t; + +/*val target config read apis */ +STATIC_DECLARE val_status_t val_target_get_config(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); +STATIC_DECLARE val_status_t val_target_cfg_get_next(void **blob); +STATIC_DECLARE val_status_t val_target_get_cfg_blob(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); +STATIC_DECLARE val_status_t val_target_get_config(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); +#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val.h deleted file mode 100644 index e4d1fa4..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val.h +++ /dev/null @@ -1,277 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_COMMON_H_ -#define _VAL_COMMON_H_ - -#include "pal_common.h" - -#ifndef VAL_NSPE_BUILD -#define STATIC_DECLARE static -#else -#define STATIC_DECLARE -#endif - -#ifndef __WEAK -#define __WEAK __attribute__((weak)) -#endif - -#ifndef __UNUSED -#define __UNUSED __attribute__((unused)) -#endif - -#ifndef TRUE -#define TRUE 0 -#endif -#ifndef FALSE -#define FALSE 1 -#endif - -#ifndef INT_MAX -#define INT_MAX 0xFFFFFFFF -#endif - -#define _CONCAT(A,B) A##B -#define CONCAT(A,B) _CONCAT(A,B) - -/* test status defines */ -#define TEST_START 0x01 -#define TEST_END 0x02 -#define TEST_PASS 0x04 -#define TEST_FAIL 0x08 -#define TEST_SKIP 0x10 -#define TEST_PENDING 0x20 - -#define TEST_NUM_BIT 32 -#define TEST_STATE_BIT 8 -#define TEST_STATUS_BIT 0 - -#define TEST_NUM_MASK 0xFFFFFFFF -#define TEST_STATE_MASK 0xFF -#define TEST_STATUS_MASK 0xFF - -#define RESULT_START(status) (((TEST_START) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) -#define RESULT_END(status) (((TEST_END) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) -#define RESULT_PASS(status) (((TEST_PASS) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) -#define RESULT_FAIL(status) (((TEST_FAIL) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) -#define RESULT_SKIP(status) (((TEST_SKIP) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) -#define RESULT_PENDING(status) (((TEST_PENDING) << TEST_STATE_BIT) | ((status) << TEST_STATUS_BIT)) - -#define IS_TEST_FAIL(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_FAIL) -#define IS_TEST_PASS(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_PASS) -#define IS_TEST_SKIP(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_SKIP) -#define IS_TEST_PENDING(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_PENDING) -#define IS_TEST_START(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_START) -#define IS_TEST_END(status) (((status >> TEST_STATE_BIT) & TEST_STATE_MASK) == TEST_END) -#define VAL_ERROR(status) ((status & TEST_STATUS_MASK) ? 1 : 0) - - - -/* Test Defines */ -#define TEST_PUBLISH(test_id, entry) - -#define VAL_MAX_TEST_PER_COMP 200 -#define VAL_FF_BASE 0 -#define VAL_CRYPTO_BASE 1 -#define VAL_PROTECTED_STORAGE_BASE 2 -#define VAL_INTERNAL_TRUSTED_STORAGE_BASE 3 -#define VAL_INITIAL_ATTESTATION_BASE 4 - -#define VAL_GET_COMP_NUM(test_id) \ - ((test_id - (test_id % VAL_MAX_TEST_PER_COMP)) / VAL_MAX_TEST_PER_COMP) -#define VAL_GET_TEST_NUM(test_id) (test_id % VAL_MAX_TEST_PER_COMP) -#define VAL_CREATE_TEST_ID(comp,num) ((comp*VAL_MAX_TEST_PER_COMP) + num) - -#define TEST_FIELD(num1,num2) (num2 << 8 | num1) -#define GET_TEST_ISOLATION_LEVEL(num) (num & 0x3) -#define GET_WD_TIMOUT_TYPE(num) ((num >> 8) & 0x7) - -#define TEST_CHECKPOINT_NUM(n) n -#define TEST(n) n -#define BLOCK(n) n - -#define BLOCK_NUM_POS 8 -#define ACTION_POS 16 -#define GET_TEST_NUM(n) (0xff & n) -#define GET_BLOCK_NUM(n) ((n >> BLOCK_NUM_POS) & 0xff) - -#define GET_ACTION_NUM(n) ((n >> ACTION_POS) & 0xff) -#define TEST_EXECUTE_FUNC 1 -#define TEST_RETURN_RESULT 2 -#define INVALID_HANDLE 0x1234DEAD - -#define VAL_NVMEM_BLOCK_SIZE 4 -#define VAL_NVMEM_OFFSET(nvmem_idx) (nvmem_idx * VAL_NVMEM_BLOCK_SIZE) - -#define UART_INIT_SIGN 0xff -#define UART_PRINT_SIGN 0xfe - -#define TEST_PANIC() \ - do { \ - } while(1) - -#define TEST_ASSERT_EQUAL(arg1, arg2, checkpoint) \ - do { \ - if ((arg1) != arg2) \ - { \ - val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d\n", checkpoint); \ - val->print(PRINT_ERROR, "\tActual: %d\n", arg1); \ - val->print(PRINT_ERROR, "\tExpected: %d\n", arg2); \ - return 1; \ - } \ - } while (0) - -#define TEST_ASSERT_DUAL(arg1, status1, status2, checkpoint) \ - do { \ - if ((arg1) != status1 && (arg1) != status2) \ - { \ - val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d\n", checkpoint); \ - val->print(PRINT_ERROR, "\tActual: %d\n", arg1); \ - val->print(PRINT_ERROR, "\tExpected: %d", status1); \ - val->print(PRINT_ERROR, "or %d\n", status2); \ - return 1; \ - } \ - } while (0) - -#define TEST_ASSERT_NOT_EQUAL(arg1, arg2, checkpoint) \ - do { \ - if ((arg1) == arg2) \ - { \ - val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d\n", checkpoint); \ - val->print(PRINT_ERROR, "\tValue: %d\n", arg1); \ - return 1; \ - } \ - } while (0) - -#define TEST_ASSERT_MEMCMP(buf1, buf2, size, checkpoint) \ - do { \ - if (memcmp(buf1, buf2, size)) \ - { \ - val->print(PRINT_ERROR, "\tFailed at Checkpoint: %d : ", checkpoint); \ - val->print(PRINT_ERROR, "Unequal data in compared buffers\n", 0); \ - return 1; \ - } \ - } while (0) - -/* enums */ -typedef enum { - CALLER_NONSECURE = 0x0, - CALLER_SECURE = 0x1, -} caller_security_t; - -typedef enum { - TEST_ISOLATION_L1 = 0x1, - TEST_ISOLATION_L2 = 0x2, - TEST_ISOLATION_L3 = 0x3, -} test_isolation_level_t; - -typedef enum { - BOOT_UNKNOWN = 0x1, - BOOT_NOT_EXPECTED = 0x2, - BOOT_EXPECTED_NS = 0x3, - BOOT_EXPECTED_S = 0x4, - BOOT_EXPECTED_BUT_FAILED = 0x5, - BOOT_EXPECTED_CRYPTO = 0x6, -} boot_state_t; - -typedef enum { - NV_BOOT = 0x0, - NV_TEST_ID_PREVIOUS = 0x1, - NV_TEST_ID_CURRENT = 0x2, - NV_TEST_CNT = 0x3, -} nvmem_index_t; - -/* enums to report test sub-state */ -typedef enum { - VAL_STATUS_SUCCESS = 0x0, - VAL_STATUS_INVALID = 0x10, - VAL_STATUS_ERROR = 0x11, - VAL_STATUS_NOT_FOUND = 0x12, - VAL_STATUS_LOAD_ERROR = 0x13, - VAL_STATUS_INSUFFICIENT_SIZE = 0x14, - VAL_STATUS_CONNECTION_FAILED = 0x15, - VAL_STATUS_CALL_FAILED = 0x16, - VAL_STATUS_READ_FAILED = 0x17, - VAL_STATUS_WRITE_FAILED = 0x18, - VAL_STATUS_ISOLATION_LEVEL_NOT_SUPP = 0x19, - VAL_STATUS_INIT_FAILED = 0x1A, - VAL_STATUS_SPM_FAILED = 0x1B, - VAL_STATUS_SPM_UNEXPECTED_BEH = 0x1C, - VAL_STATUS_FRAMEWORK_VERSION_FAILED = 0x1D, - VAL_STATUS_VERSION_API_FAILED = 0x1E, - VAL_STATUS_INVALID_HANDLE = 0x1F, - VAL_STATUS_INVALID_MSG_TYPE = 0x20, - VAL_STATUS_WRONG_IDENTITY = 0x21, - VAL_STATUS_MSG_INSIZE_FAILED = 0x22, - VAL_STATUS_MSG_OUTSIZE_FAILED = 0x23, - VAL_STATUS_SKIP_FAILED = 0x24, - VAL_STATUS_CRYPTO_FAILURE = 0x25, - VAL_STATUS_INVALID_SIZE = 0x26, - VAL_STATUS_DATA_MISMATCH = 0x27, - VAL_STATUS_BOOT_EXPECTED_BUT_FAILED = 0x28, - VAL_STATUS_INIT_ALREADY_DONE = 0x29, - VAL_STATUS_HEAP_NOT_AVAILABLE = 0x2A, - VAL_STATUS_UNSUPPORTED = 0x2B, - VAL_STATUS_ERROR_MAX = INT_MAX, -} val_status_t; - -/* verbosity enums */ -typedef enum { - PRINT_INFO = 1, - PRINT_DEBUG = 2, - PRINT_TEST = 3, - PRINT_WARN = 4, - PRINT_ERROR = 5, - PRINT_ALWAYS = 9 -} print_verbosity_t; - -/* Interrupt test function id enums */ -typedef enum { - TEST_PSA_EOI_WITH_NON_INTR_SIGNAL = 1, - TEST_PSA_EOI_WITH_MULTIPLE_SIGNALS = 2, - TEST_PSA_EOI_WITH_UNASSERTED_SIGNAL = 3, - TEST_INTR_SERVICE = 4, -} test_intr_fn_id_t; - -/* typedef's */ -typedef struct { - boot_state_t state; -} boot_t; - -typedef struct { - uint32_t pass_cnt: 8; - uint32_t skip_cnt: 8; - uint32_t fail_cnt: 8; - uint32_t sim_error_cnt: 8; -} test_count_t; - -typedef struct { - uint16_t test_num; - uint8_t block_num; -} test_info_t; - - -/* struture to capture test state */ -typedef struct { - uint16_t reserved; - uint8_t state; - uint8_t status; -} test_status_buffer_t; - -typedef int32_t (*client_test_t)(caller_security_t caller); -typedef int32_t (*server_test_t)(void); -#endif /* VAL_COMMON_H */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_attestation.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_attestation.c deleted file mode 100644 index cd8069a..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_attestation.c +++ /dev/null @@ -1,40 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_target.h" -#include "pal_interfaces_ns.h" -#include "val_framework.h" -#include "val_client_defs.h" -#include "val_attestation.h" - -/** - @brief - This API will call the requested attestation function - @param - type : function code - ... : variable number of arguments - @return - Error status -**/ - -int32_t val_attestation_function(int type, ...) -{ - va_list valist; - val_status_t status; - - va_start(valist, type); - status = pal_attestation_function(type, valist); - va_end(valist); - return status; -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_attestation.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_attestation.h deleted file mode 100644 index 5322723..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_attestation.h +++ /dev/null @@ -1,33 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_INITIAL_ATTESTATION_H_ -#define _VAL_INITIAL_ATTESTATION_H_ - -#include "val.h" -#include "psa_initial_attestation_api.h" - -#define MAX_CHALLENGE_SIZE PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 - -enum attestation_function_code { - VAL_INITIAL_ATTEST_GET_TOKEN = 0x1, - VAL_INITIAL_ATTEST_GET_TOKEN_SIZE = 0x2, - VAL_INITIAL_ATTEST_VERIFY_TOKEN = 0x3, -}; - -int32_t val_attestation_function(int type, ...); -#endif /* _VAL_INITIAL_ATTESTATION_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_client_defs.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_client_defs.h deleted file mode 100644 index eaef75c..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_client_defs.h +++ /dev/null @@ -1,35 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_CLIENT_H_ -#define _VAL_CLIENT_H_ - -#include "val.h" -#include "psa/client.h" -#include "psa/crypto_types.h" -#include "psa/crypto_values.h" - -#define INVALID_SID 0x0000FA20 - -#ifndef CLIENT_TEST_DISPATCHER_SID -#define CLIENT_TEST_DISPATCHER_SID 0x0 -#endif - -#ifndef SERVER_TEST_DISPATCHER_SID -#define SERVER_TEST_DISPATCHER_SID 0x0 -#endif -#endif /* _VAL_CLIENT_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_entry.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_entry.h deleted file mode 100644 index 2b885e0..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_entry.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_ENTRY_H_ -#define _VAL_ENTRY_H_ - -#include "val_framework.h" - -#define PSA_ACS_MAJOR_VER 0 -#define PSA_ACS_MINOR_VER 8 - -/** - @brief - PSA Test Suite C main function, does VAL init and calls test dispatcher - @param - None - @return - void -**/ -extern void val_entry(void); -#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_framework.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_framework.h deleted file mode 100644 index e69de29..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_framework.h +++ /dev/null diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_greentea.cpp b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_greentea.cpp deleted file mode 100644 index ba57016..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_greentea.cpp +++ /dev/null @@ -1,297 +0,0 @@ -#include "greentea-client/test_env.h" -#include "inttypes.h" -#include "val_greentea.h" - -void pal_mbed_os_compliance_test_initialize(void); -void pal_mbed_os_compliance_test_destroy(void); - -#ifdef __cplusplus -extern "C" { -#endif - - - -/* globals */ -test_status_buffer_t g_status_buffer; - -void mbed_val_test_init(uint32_t test_num, char8_t *desc, uint32_t test_bitfield) -{ - /*global init*/ - g_status_buffer.state = 0; - g_status_buffer.status = VAL_STATUS_INVALID; - - mbed_val_print(PRINT_ALWAYS, "\nTEST: %d | DESCRIPTION: ", test_num); - mbed_val_print(PRINT_ALWAYS, desc, 0); - GREENTEA_SETUP(100, "default_auto"); - mbed_val_set_status(RESULT_START(VAL_STATUS_SUCCESS)); - pal_mbed_os_compliance_test_initialize(); - return; -} - -void mbed_val_test_exit(void) -{ - uint32_t status = mbed_val_get_status(); - pal_mbed_os_compliance_test_destroy(); - /* return if test skipped or failed */ - if (IS_TEST_FAIL(status) || IS_TEST_SKIP(status)) { - GREENTEA_TESTSUITE_RESULT(false); - } else { - GREENTEA_TESTSUITE_RESULT(true); - mbed_val_set_status(RESULT_END(VAL_STATUS_SUCCESS)); - } -} - -/** -@brief - This function executes given list of tests from non-secure sequentially - This covers non-secure to secure IPC API scenario -@param - test_num : Test_num -@param - tests_list : list of tests to be executed -@param - server_hs : Initiate a server handshake -@return - val_status_t -**/ -val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t *tests_list, - bool_t server_hs) -{ - val_status_t status = VAL_STATUS_SUCCESS; - int32_t test_status = VAL_STATUS_SUCCESS; - psa_handle_t handle; - uint32_t i = 1; - test_info_t test_info; - char testcase_name[100] = ""; - bool continue_test = true; - - test_info.test_num = test_num; - - mbed_val_print(PRINT_TEST, "[Info] Executing tests from non-secure\n", 0); - while (tests_list[i] != NULL) { - memset(testcase_name, 0, 100); - sprintf(testcase_name, "Check%" PRIu32, i); - GREENTEA_TESTCASE_START(testcase_name); - if (server_hs == TRUE) { - /* Handshake with server tests */ - test_info.block_num = i; - status = mbed_val_execute_secure_test_func(&handle, test_info, - SERVER_TEST_DISPATCHER_SID); - if (VAL_ERROR(status)) { - mbed_val_set_status(RESULT_FAIL(status)); - mbed_val_print(PRINT_ERROR, "[Check%d] START\n", i); - return status; - } else { - mbed_val_print(PRINT_DEBUG, "[Check%d] START\n", i); - } - } - - /* Execute client tests */ - test_status = tests_list[i](CALLER_NONSECURE); - - if (server_hs == TRUE) { - /* Retrive Server test status */ - status = mbed_val_get_secure_test_result(&handle); - } - - if (test_status != VAL_STATUS_SUCCESS) { - status = VAL_STATUS_ERROR; - } - - if (IS_TEST_SKIP(status)) { - mbed_val_set_status(status); - mbed_val_print(PRINT_DEBUG, "[Check%d] SKIPPED\n", i); - GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); - continue_test = false; - } else if (VAL_ERROR(status)) { - mbed_val_set_status(RESULT_FAIL(status)); - if (server_hs == TRUE) { - mbed_val_print(PRINT_ERROR, "[Check%d] FAILED\n", i); - } - GREENTEA_TESTCASE_FINISH(testcase_name, 0, 1); - continue_test = false; - } else { - if (server_hs == TRUE) { - mbed_val_print(PRINT_DEBUG, "[Check%d] PASSED\n", i); - } - GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); - continue_test = true; - } - - if (!continue_test) { - return status; - } - - i++; - } - return status; -} - -/** -@brief - Records the state and status of test -@return - val_status_t -**/ -val_status_t mbed_val_set_status(uint32_t status) -{ - g_status_buffer.state = ((status >> TEST_STATE_BIT) & TEST_STATE_MASK); - g_status_buffer.status = (status & TEST_STATUS_MASK); - - return VAL_STATUS_SUCCESS; -} - -/** -@brief - Updates the state and status for a given test -@return - test status -**/ -uint32_t mbed_val_get_status(void) -{ - return ((g_status_buffer.state) << TEST_STATE_BIT) | (g_status_buffer.status); -} - -/** -@brief - This function is used to handshake between: - - nonsecure client fn to server test fn - - secure client fn and server test fn - - nonsecure client fn to secure client test fn -@param - handle : handle returned while connecting given sid -@param - test_info : Test_num and block_num to be executed -@param - sid : RoT service to be connected. Partition dispatcher sid -@return - val_status_t -**/ -val_status_t mbed_val_execute_secure_test_func(psa_handle_t *handle, test_info_t test_info, uint32_t sid) -{ - uint32_t test_data; - val_status_t status = VAL_STATUS_SUCCESS; - psa_status_t status_of_call = PSA_SUCCESS; - - *handle = pal_ipc_connect(sid, 0); - if (*handle < 0) { - mbed_val_print(PRINT_ERROR, "Could not connect SID. Handle=%x\n", *handle); - return VAL_STATUS_CONNECTION_FAILED; - } - - test_data = ((uint32_t)(test_info.test_num) | ((uint32_t)(test_info.block_num) << BLOCK_NUM_POS) | ((uint32_t)(TEST_EXECUTE_FUNC) << ACTION_POS)); - psa_invec data[1] = {{&test_data, sizeof(test_data)}}; - - status_of_call = pal_ipc_call(*handle, data, 1, NULL, 0); - if (status_of_call != PSA_SUCCESS) { - status = VAL_STATUS_CALL_FAILED; - mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call); - pal_ipc_close(*handle); - } - - return status; -} - -/** -@brief - Print module. This is client interface API of secure partition - mbed_val_print_sf API for nspe world -@param - verbosity: Print verbosity level - - string : Input string - - data : Value for format specifier -@return - val_status_t -**/ -val_status_t mbed_val_print(print_verbosity_t verbosity, const char *string, uint32_t data) -{ - if (data != 0) { - printf(string, data); - } else { - printf(string); - } - - return VAL_STATUS_SUCCESS; -} - -/** -@brief - This function is used to retrive the status of previously connected test function - using mbed_val_execute_secure_test_func -@param - handle : handle of server function. Handle of Partition dispatcher sid -@return - The status of test functions -**/ -val_status_t mbed_val_get_secure_test_result(psa_handle_t *handle) -{ - uint32_t test_data; - val_status_t status = VAL_STATUS_SUCCESS; - psa_status_t status_of_call = PSA_SUCCESS; - - test_data = (TEST_RETURN_RESULT << ACTION_POS); - - psa_outvec resp = {&status, sizeof(status)}; - psa_invec data[1] = {{&test_data, sizeof(test_data)}}; - - status_of_call = pal_ipc_call(*handle, data, 1, &resp, 1); - if (status_of_call != PSA_SUCCESS) { - status = VAL_STATUS_CALL_FAILED; - mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call); - } - - pal_ipc_close(*handle); - return status; -} - -/** - * @brief Connect to given sid - @param -sid : RoT service id - @param -minor_version : minor_version of RoT service - @param -handle - return connection handle - * @return val_status_t - */ -val_status_t mbed_val_ipc_connect(uint32_t sid, uint32_t minor_version, psa_handle_t *handle) -{ - *handle = pal_ipc_connect(sid, minor_version); - - if (*handle < 0) { - return VAL_STATUS_CONNECTION_FAILED; - } - - return VAL_STATUS_SUCCESS; -} - -/** - * @brief Call a connected Root of Trust Service.@n - * The caller must provide an array of ::psa_invec_t structures as the input payload. - * - * @param handle Handle for the connection. - * @param in_vec Array of psa_invec structures. - * @param in_len Number of psa_invec structures in in_vec. - * @param out_vec Array of psa_outvec structures for optional Root of Trust Service response. - * @param out_len Number of psa_outvec structures in out_vec. - * @return val_status_t - */ -val_status_t mbed_val_ipc_call(psa_handle_t handle, psa_invec *in_vec, size_t in_len, - psa_outvec *out_vec, size_t out_len) -{ - psa_status_t call_status = PSA_SUCCESS; - - call_status = pal_ipc_call(handle, in_vec, in_len, out_vec, out_len); - - if (call_status != PSA_SUCCESS) { - return VAL_STATUS_CALL_FAILED; - } - - return VAL_STATUS_SUCCESS; -} - -/** - * @brief Close a connection to a Root of Trust Service. - * Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources. - * - * @param handle Handle for the connection. - * @return void - */ -void mbed_val_ipc_close(psa_handle_t handle) -{ - pal_ipc_close(handle); -} - - -/** - * @brief reprogram the watchdog timer - * always succeeds on mbed-greentead testing. - * - * @param timeout_type type of timeout. - * @return val_status_t - */ -val_status_t mbed_val_wd_reprogram_timer(wd_timeout_type_t timeout_type) -{ - return VAL_STATUS_SUCCESS; -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_greentea.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_greentea.h deleted file mode 100644 index a8d7da8..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_greentea.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _VAL_GREENTEA_H_ -#define _VAL_GREENTEA_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "val.h" -#include "val_interfaces.h" - -void mbed_val_test_init(uint32_t test_num, char8_t *desc, uint32_t test_bitfield); -void mbed_val_test_exit(void); -val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t *tests_list, bool_t server_hs); -val_status_t mbed_val_set_status(uint32_t status); -uint32_t mbed_val_get_status(void); -val_status_t mbed_val_execute_secure_test_func(psa_handle_t *handle, test_info_t test_info, uint32_t sid); -val_status_t mbed_val_print(print_verbosity_t verbosity, const char *string, uint32_t data); -val_status_t mbed_val_get_secure_test_result(psa_handle_t *handle); -val_status_t mbed_val_ipc_connect(uint32_t sid, uint32_t minor_version, psa_handle_t *handle); -val_status_t mbed_val_ipc_call(psa_handle_t handle, psa_invec *in_vec, size_t in_len, - psa_outvec *out_vec, size_t out_len); -void mbed_val_ipc_close(psa_handle_t handle); -val_status_t mbed_val_wd_reprogram_timer(wd_timeout_type_t timeout_type); - -#ifdef __cplusplus -} -#endif - -#endif // _VAL_GREENTEA_H_ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_interfaces.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_interfaces.c deleted file mode 100644 index b6bf085..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_interfaces.c +++ /dev/null @@ -1,60 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - - -#include "val_greentea.h" -#include "val_interfaces.h" -#include "val_internal_trusted_storage.h" -#include "val_protected_storage.h" -#include "val_attestation.h" - -/*VAL APIs to be used by test */ -const val_api_t val_api = { - .print = mbed_val_print, - .set_status = mbed_val_set_status, - .get_status = mbed_val_get_status, - .test_init = mbed_val_test_init, - .test_exit = mbed_val_test_exit, - .err_check_set = NULL, - .target_get_config = NULL, - .execute_non_secure_tests = mbed_val_execute_non_secure_tests, - .switch_to_secure_client = NULL, - .execute_secure_test_func = mbed_val_execute_secure_test_func, - .get_secure_test_result = mbed_val_get_secure_test_result, - .ipc_connect = mbed_val_ipc_connect, - .ipc_call = mbed_val_ipc_call, - .ipc_close = mbed_val_ipc_close, - .nvmem_read = NULL, - .nvmem_write = NULL, - .wd_timer_init = NULL, - .wd_timer_enable = NULL, - .wd_timer_disable = NULL, - .wd_reprogram_timer = mbed_val_wd_reprogram_timer, - .set_boot_flag = NULL, - .get_boot_flag = NULL, - .its_function = val_its_function, - .ps_function = val_ps_function, - .attestation_function = val_attestation_function, -}; - -const psa_api_t psa_api = { - .framework_version = pal_ipc_framework_version, - .version = pal_ipc_version, - .connect = pal_ipc_connect, - .call = pal_ipc_call, - .close = pal_ipc_close, -}; diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_interfaces.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_interfaces.h deleted file mode 100644 index 40bc673..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_interfaces.h +++ /dev/null @@ -1,83 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_INTERFACES_H_ -#define _VAL_INTERFACES_H_ - -#include "val.h" -#include "val_client_defs.h" -#include "pal_interfaces_ns.h" - -/* typedef's */ -typedef struct { - val_status_t (*print)(print_verbosity_t verbosity, - const char *string, uint32_t data); - val_status_t (*set_status)(uint32_t status); - uint32_t (*get_status)(void); - void (*test_init)(uint32_t test_num, char8_t *desc, - uint32_t test_bitfield); - void (*test_exit)(void); - val_status_t (*err_check_set)(uint32_t checkpoint, val_status_t status); - val_status_t (*target_get_config)(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); - val_status_t (*execute_non_secure_tests)(uint32_t test_num, client_test_t *tests_list, - bool_t server_hs); - val_status_t (*switch_to_secure_client)(uint32_t test_num); - val_status_t (*execute_secure_test_func)(psa_handle_t *handle, test_info_t test_info, - uint32_t sid); - val_status_t (*ipc_connect)(uint32_t sid, uint32_t minor_version, - psa_handle_t *handle); - val_status_t (*ipc_call)(psa_handle_t handle, psa_invec *in_vec, - size_t in_len, psa_outvec *out_vec, - size_t out_len); - void (*ipc_close)(psa_handle_t handle); - val_status_t (*get_secure_test_result)(psa_handle_t *handle); - val_status_t (*nvmem_read)(uint32_t offset, void *buffer, int size); - val_status_t (*nvmem_write)(uint32_t offset, void *buffer, int size); - val_status_t (*wd_timer_init)(wd_timeout_type_t timeout_type); - val_status_t (*wd_timer_enable)(void); - val_status_t (*wd_timer_disable)(void); - val_status_t (*wd_reprogram_timer)(wd_timeout_type_t timeout_type); - val_status_t (*set_boot_flag)(boot_state_t state); - val_status_t (*get_boot_flag)(boot_state_t *state); - int32_t (*crypto_function)(int type, ...); - uint32_t (*its_function)(int type, ...); - uint32_t (*ps_function)(int type, ...); - int32_t (*attestation_function)(int type, ...); -} val_api_t; - -typedef struct { - uint32_t (*framework_version)(void); - uint32_t (*version)(uint32_t sid); - psa_handle_t (*connect)(uint32_t sid, uint32_t minor_version); - psa_status_t (*call)(psa_handle_t handle, - const psa_invec *in_vec, - size_t in_len, - psa_outvec *out_vec, - size_t out_len - ); - void (*close)(psa_handle_t handle); -} psa_api_t; - -typedef void (*test_fptr_t)(val_api_t *val, psa_api_t *psa); - -typedef struct { - test_id_t test_id; - test_fptr_t entry_addr; -} val_test_info_t; - -void test_entry(val_api_t *val, psa_api_t *psa); -#endif diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_internal_trusted_storage.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_internal_trusted_storage.c deleted file mode 100644 index e79e9c0..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_internal_trusted_storage.c +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_target.h" -#include "pal_interfaces_ns.h" -#include "val_framework.h" -#include "val_client_defs.h" -#include "val_internal_trusted_storage.h" - -/** - @brief - This API will call the requested internal trusted storage function - @param - type : function code - ... : variable number of arguments - @return - Error status -**/ -uint32_t val_its_function(int type, ...) -{ - va_list valist; - uint32_t status; - - va_start(valist, type); - status = pal_its_function(type, valist); - va_end(valist); - return status; -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_internal_trusted_storage.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_internal_trusted_storage.h deleted file mode 100644 index 2f9384d..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_internal_trusted_storage.h +++ /dev/null @@ -1,34 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_INTERNAL_TRUSTED_STORAGE_H_ -#define _VAL_INTERNAL_TRUSTED_STORAGE_H_ - -#include "val.h" - -#define UID_BASE_VALUE 0 -#define BYTES_TO_BITS(byte) (byte * 8) - -enum its_function_code { - VAL_ITS_SET = 0x1, - VAL_ITS_GET = 0x2, - VAL_ITS_GET_INFO = 0x3, - VAL_ITS_REMOVE = 0x4, -}; - -uint32_t val_its_function(int type, ...); -#endif /* _VAL_INTERNAL_TRUSTED_STORAGE_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_protected_storage.c b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_protected_storage.c deleted file mode 100644 index 06c1f50..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_protected_storage.c +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_target.h" -#include "pal_interfaces_ns.h" -#include "val_framework.h" -#include "val_client_defs.h" -#include "val_protected_storage.h" - -/** - @brief - This API will call the requested protected storage function - @param - type : function code - ... : variable number of arguments - @return - Error status -**/ -uint32_t val_ps_function(int type, ...) -{ - va_list valist; - uint32_t status; - - va_start(valist, type); - status = pal_ps_function(type, valist); - va_end(valist); - return status; -} diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_protected_storage.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_protected_storage.h deleted file mode 100644 index 7f05cea..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_protected_storage.h +++ /dev/null @@ -1,37 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_PROTECTED_STORAGE_H_ -#define _VAL_PROTECTED_STORAGE_H_ - -#include "val.h" - -#define UID_BASE_VALUE 0 -#define BYTES_TO_BITS(byte) (byte * 8) - -enum ps_function_code { - VAL_PS_SET = 0x1, - VAL_PS_GET = 0x2, - VAL_PS_GET_INFO = 0x3, - VAL_PS_REMOVE = 0x4, - VAL_PS_CREATE = 0x5, - VAL_PS_SET_EXTENDED = 0x6, - VAL_PS_GET_SUPPORT = 0x7, -}; - -uint32_t val_ps_function(int type, ...); -#endif /* _VAL_PROTECTED_STORAGE_H_ */ diff --git a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_target.h b/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_target.h deleted file mode 100644 index 1eb7a61..0000000 --- a/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_MBED_PSA_SRV/val/val_target.h +++ /dev/null @@ -1,205 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _TARGET_INFO_DATA_H_ -#define _TARGET_INFO_DATA_H_ - -#include "val.h" - -#define TARGET_CONFIG_CREATE_ID(major, minor, index) \ - (((major & 0xFF) << 24) | ((minor & 0xFF) << 16) | (index & 0xFFFF)) -#define TARGET_CONFIG_GET_MAJOR(config_id) ((config_id >> 24) & 0xFF) -#define TARGET_CONFIG_GET_MINOR(config_id) ((config_id >> 16) & 0xFF) -#define TARGET_CONFIG_INCREMENT_INDEX(config_id) \ - ((config_id & 0xFFFF0000) | ((config_id & 0xFFFF) + 1)) -#define GET_NUM_INSTANCE(struct_type) (struct_type->cfg_type.size >> 24) -#define VAL_TEST_MAJOR_GROUP_MASK 0xFF000000UL -#define VAL_TEST_MINOR_GROUP_MASK 0x00FF0000UL -#define VAL_TEST_CFG_INSTANCE_MASK 0x0000FFFFUL -#define VAL_TEST_INVALID_CFG_ID 0xFFFFFFFFUL -#define TARGET_MIN_CFG_ID TARGET_CONFIG_CREATE_ID(GROUP_SOC_PERIPHERAL, 0, 0) -#define TARGET_MAX_CFG_ID TARGET_CONFIG_CREATE_ID(GROUP_MAX, 0, 0) - -/** - Config IDs for each group/component - 31:24 : MAJOR (group) - 23:16 : MINOR (component) - 16:8 : SUB-component - 7:0 : INSTANCE (instance of same component) -**/ - -/* - MAJOR IDs -*/ -typedef enum _GROUP_CONFIG_ID_ { - GROUP_SOC_PERIPHERAL = 0x1, - GROUP_MEMORY = 0x2, - GROUP_MISCELLANEOUS = 0x3, - GROUP_MAX = 0xFF, -} group_cfg_id_t; - -/* - MINOR IDs - */ -typedef enum _SOC_PERIPHERAL_CONFIG_ID_ { - SOC_PERIPHERAL_UART = 0x1, - SOC_PERIPHERAL_TIMER = 0x2, - SOC_PERIPHERAL_WATCHDOG = 0x3, -} soc_peripheral_cfg_id_t; - -typedef enum _MEMORY_CONFIG_ID_ { - MEMORY_NVMEM = 0x2, - MEMORY_NSPE_MMIO = 0x3, - MEMORY_CLIENT_PARTITION_MMIO = 0x4, - MEMORY_DRIVER_PARTITION_MMIO = 0x5, -} memory_cfg_id_t; - -typedef enum _MISCELLANEOUS_CONFIG_ID_ { - MISCELLANEOUS_BOOT = 0x1, - MISCELLANEOUS_DUT = 0x2 -} miscellaneous_cfg_id_t; - -/** - Assign group type to each system component -**/ -typedef enum _COMPONENT_GROUPING_ { - UART = GROUP_SOC_PERIPHERAL, - TIMER = GROUP_SOC_PERIPHERAL, - WATCHDOG = GROUP_SOC_PERIPHERAL, - NVMEM = GROUP_MEMORY, - NSPE_MMIO = GROUP_MEMORY, - CLIENT_PARTITION_MMIO = GROUP_MEMORY, - DRIVER_PARTITION_MMIO = GROUP_MEMORY, - BOOT = GROUP_MISCELLANEOUS, - DUT = GROUP_MISCELLANEOUS, -} comp_group_assign_t; - -/** - Target Configuration Header -**/ -typedef struct _TARGET_CFG_HDR_ { - /* PSA_CFG */ - uint32_t signature[2]; - /* 8 byte String describing the Target platform */ - uint32_t target_string[2]; - /* version = 1 for now */ - uint32_t version; - /* Header Size */ - uint32_t size; -} target_cfg_hdr_t; - -typedef enum { - LEVEL1 = 0x1, - LEVEL2, - LEVEL3, -} firmware_level_t; - -typedef enum { - NOT_AVAILABLE = 0x0, - AVAILABLE = 0x1, -} is_available_t; - -typedef enum { - SECURE_ACCESS = 0x100, - NONSECURE_ACCESS, - SECURE_PROGRAMMABLE, - NONSECURE_PROGRAMMABLE -} dev_attr_t; - -typedef enum { - MEM_SECURE = 0x100, - MEM_NONSECURE, - MEM_NSC, -} mem_tgt_attr_t; - -typedef enum { - TYPE_READ_ONLY = 0x10, - TYPE_WRITE_ONLY, - TYPE_READ_WRITE, - TYPE_EXECUTE, - TYPE_RESERVED, -} perm_type_t; - -typedef struct _CFG_HDR_TYPE_ { - cfg_id_t cfg_id; - /* size inclusive of this header */ - uint32_t size; -} cfg_type_t; - -/** - Memory Information -**/ -typedef struct _MEM_INFO_DESC_ { - cfg_type_t cfg_type; - uint32_t num; -} memory_hdr_t; - -typedef struct _MEM_REGION_ { - cfg_type_t cfg_type; - addr_t start; - addr_t end; - mem_tgt_attr_t attribute; - perm_type_t permission; -} memory_desc_t; - -/* - SOC Peripheral description structures -*/ -typedef struct _SOC_PER_INFO_NUM_ { - cfg_type_t cfg_type; - uint32_t num; -} soc_peripheral_hdr_t; - -typedef struct _SOC_PER_INFO_DESC_ { - cfg_type_t cfg_type; - uint32_t vendor_id; - uint32_t device_id; - addr_t base; - uint32_t size; - uint32_t intr_id; - perm_type_t permission; - uint32_t timeout_in_micro_sec_low; - uint32_t timeout_in_micro_sec_medium; - uint32_t timeout_in_micro_sec_high; - uint32_t timeout_in_micro_sec_crypto; - uint32_t num_of_tick_per_micro_sec; - dev_attr_t attribute; -} soc_peripheral_desc_t; - -/** - System Miscellaneous Information -**/ - -typedef struct _MISCELLANEOUS_INFO_HDR_ { - cfg_type_t cfg_type; - uint32_t num; -} miscellaneous_hdr_t; - -typedef struct _MISCELLANEOUS_INFO_DESC_ { - cfg_type_t cfg_type; - firmware_level_t implemented_psa_firmware_isolation_level; - addr_t ns_start_addr_of_combine_test_binary; - is_available_t combine_test_binary_in_ram; - addr_t ns_test_addr; -} miscellaneous_desc_t; - -/*val target config read apis */ -STATIC_DECLARE val_status_t val_target_get_config(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); -STATIC_DECLARE val_status_t val_target_cfg_get_next(void **blob); -STATIC_DECLARE val_status_t val_target_get_cfg_blob(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); -STATIC_DECLARE val_status_t val_target_get_config(cfg_id_t cfg_id, uint8_t **data, uint32_t *size); -#endif diff --git a/platform/tests/TESTS/mbed_functional/callback/CMakeLists.txt b/platform/tests/TESTS/mbed_functional/callback/CMakeLists.txt index 869002d..86a6c04 100644 --- a/platform/tests/TESTS/mbed_functional/callback/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_functional/callback/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_functional/callback_big/CMakeLists.txt b/platform/tests/TESTS/mbed_functional/callback_big/CMakeLists.txt index 4495e25..ee96c07 100644 --- a/platform/tests/TESTS/mbed_functional/callback_big/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_functional/callback_big/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_functional/callback_small/CMakeLists.txt b/platform/tests/TESTS/mbed_functional/callback_small/CMakeLists.txt index 1e966d9..0a4d808 100644 --- a/platform/tests/TESTS/mbed_functional/callback_small/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_functional/callback_small/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_micro/attributes/CMakeLists.txt b/platform/tests/TESTS/mbed_micro/attributes/CMakeLists.txt index ec3eaa6..1a51301 100644 --- a/platform/tests/TESTS/mbed_micro/attributes/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_micro/attributes/CMakeLists.txt @@ -10,6 +10,17 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST weak.c attributes.c) +list( + APPEND + TEST_SOURCE_LIST + main.cpp + weak.c + attributes.c +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_SOURCES ${TEST_SOURCE_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} +) diff --git a/platform/tests/TESTS/mbed_micro/call_before_main/CMakeLists.txt b/platform/tests/TESTS/mbed_micro/call_before_main/CMakeLists.txt index 60cdaf4..c89d55f 100644 --- a/platform/tests/TESTS/mbed_micro/call_before_main/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_micro/call_before_main/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_micro/cpp/CMakeLists.txt b/platform/tests/TESTS/mbed_micro/cpp/CMakeLists.txt index 437311b..f04955c 100644 --- a/platform/tests/TESTS/mbed_micro/cpp/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_micro/cpp/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_micro/div/CMakeLists.txt b/platform/tests/TESTS/mbed_micro/div/CMakeLists.txt index d7b6ce4..59cab40 100644 --- a/platform/tests/TESTS/mbed_micro/div/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_micro/div/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_micro/static_assert/CMakeLists.txt b/platform/tests/TESTS/mbed_micro/static_assert/CMakeLists.txt index 5b71968..a054170 100644 --- a/platform/tests/TESTS/mbed_micro/static_assert/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_micro/static_assert/CMakeLists.txt @@ -10,6 +10,17 @@ project(${TEST_TARGET}) -list(APPEND TEST_SOURCE_LIST test_c.c test_cpp.cpp) +list( + APPEND + TEST_SOURCE_LIST + main.cpp + test_c.c + test_cpp.cpp +) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_SOURCES ${TEST_SOURCE_LIST}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + ${TEST_SOURCE_LIST} +) diff --git a/platform/tests/TESTS/mbed_platform/CircularBuffer/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/CircularBuffer/CMakeLists.txt index 42fd77f..459bc85 100644 --- a/platform/tests/TESTS/mbed_platform/CircularBuffer/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/CircularBuffer/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/FileHandle/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/FileHandle/CMakeLists.txt index b0940d0..d216734 100644 --- a/platform/tests/TESTS/mbed_platform/FileHandle/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/FileHandle/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/SharedPtr/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/SharedPtr/CMakeLists.txt index a625ca6..6f4a078 100644 --- a/platform/tests/TESTS/mbed_platform/SharedPtr/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/SharedPtr/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/SingletonPtr/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/SingletonPtr/CMakeLists.txt index 09b0ef7..2821ccd 100644 --- a/platform/tests/TESTS/mbed_platform/SingletonPtr/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/SingletonPtr/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/Stream/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/Stream/CMakeLists.txt index 9dea20f..5ba0c6f 100644 --- a/platform/tests/TESTS/mbed_platform/Stream/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/Stream/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/Transaction/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/Transaction/CMakeLists.txt index baba496..5bb1e32 100644 --- a/platform/tests/TESTS/mbed_platform/Transaction/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/Transaction/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/atomic/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/atomic/CMakeLists.txt index fbbbe92..e8fa7a7 100644 --- a/platform/tests/TESTS/mbed_platform/atomic/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/atomic/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt index 64a69ae..11bf796 100644 --- a/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/crash_reporting/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/critical_section/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/critical_section/CMakeLists.txt index b161080..81a0ea4 100644 --- a/platform/tests/TESTS/mbed_platform/critical_section/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/critical_section/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/error_handling/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/error_handling/CMakeLists.txt index 3ce2927..db79836 100644 --- a/platform/tests/TESTS/mbed_platform/error_handling/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/error_handling/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt index 00c20b0..0e440c0 100644 --- a/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/minimal-printf/compliance/CMakeLists.txt @@ -10,4 +10,10 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET} TEST_SOURCES mbed_printf.c) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp + mbed_printf.c +) diff --git a/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt index f8945d0..427c1e4 100644 --- a/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_cpu/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt index 7b183d1..4f818c4 100644 --- a/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_heap/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt index 78971c0..1a60541 100644 --- a/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_sys/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt index 9b96e10..dd633fe 100644 --- a/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/stats_thread/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/system_reset/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/system_reset/CMakeLists.txt index 4bff029..34c8300 100644 --- a/platform/tests/TESTS/mbed_platform/system_reset/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/system_reset/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/platform/tests/TESTS/mbed_platform/wait_ns/CMakeLists.txt b/platform/tests/TESTS/mbed_platform/wait_ns/CMakeLists.txt index b61c27f..6bf4c65 100644 --- a/platform/tests/TESTS/mbed_platform/wait_ns/CMakeLists.txt +++ b/platform/tests/TESTS/mbed_platform/wait_ns/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/MemoryPool/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/MemoryPool/CMakeLists.txt index d7134d2..9794b7c 100644 --- a/rtos/tests/TESTS/mbed_rtos/MemoryPool/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/MemoryPool/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/basic/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/basic/CMakeLists.txt index 7e190b3..3c9b8cb 100644 --- a/rtos/tests/TESTS/mbed_rtos/basic/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/basic/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/condition_variable/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/condition_variable/CMakeLists.txt index 9351dfc..57e3ef1 100644 --- a/rtos/tests/TESTS/mbed_rtos/condition_variable/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/condition_variable/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/event_flags/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/event_flags/CMakeLists.txt index 7fe7a8c..94460f1 100644 --- a/rtos/tests/TESTS/mbed_rtos/event_flags/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/event_flags/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/heap_and_stack/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/heap_and_stack/CMakeLists.txt index c135147..dd93b95 100644 --- a/rtos/tests/TESTS/mbed_rtos/heap_and_stack/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/heap_and_stack/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/kernel_tick_count/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/kernel_tick_count/CMakeLists.txt index 137ac06..c95ca86 100644 --- a/rtos/tests/TESTS/mbed_rtos/kernel_tick_count/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/kernel_tick_count/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/mail/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/mail/CMakeLists.txt index f986877..26feb9f 100644 --- a/rtos/tests/TESTS/mbed_rtos/mail/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/mail/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/malloc/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/malloc/CMakeLists.txt index a11f7ae..78b0310 100644 --- a/rtos/tests/TESTS/mbed_rtos/malloc/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/malloc/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/mutex/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/mutex/CMakeLists.txt index ce2ae59..8734d6c 100644 --- a/rtos/tests/TESTS/mbed_rtos/mutex/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/mutex/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/queue/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/queue/CMakeLists.txt index 8dea021..9c90819 100644 --- a/rtos/tests/TESTS/mbed_rtos/queue/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/queue/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/semaphore/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/semaphore/CMakeLists.txt index 3de7d6d..d718b92 100644 --- a/rtos/tests/TESTS/mbed_rtos/semaphore/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/semaphore/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/signals/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/signals/CMakeLists.txt index 00c65c2..cca7ed5 100644 --- a/rtos/tests/TESTS/mbed_rtos/signals/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/signals/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/systimer/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/systimer/CMakeLists.txt index 3de2c5a..0606dfb 100644 --- a/rtos/tests/TESTS/mbed_rtos/systimer/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/systimer/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/rtos/tests/TESTS/mbed_rtos/threads/CMakeLists.txt b/rtos/tests/TESTS/mbed_rtos/threads/CMakeLists.txt index 87aa4ef..8499ab3 100644 --- a/rtos/tests/TESTS/mbed_rtos/threads/CMakeLists.txt +++ b/rtos/tests/TESTS/mbed_rtos/threads/CMakeLists.txt @@ -10,4 +10,9 @@ project(${TEST_TARGET}) -mbed_greentea_add_test(TEST_NAME ${TEST_TARGET}) +mbed_greentea_add_test( + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp +) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt index e5cbb34..6d14757 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/buffered_block_device/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-blockdevice ) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt index 26857e3..a4399b6 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/flashsim_block_device/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-blockdevice ) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt index 2469a4c..29a242a 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/general_block_device/CMakeLists.txt @@ -39,7 +39,10 @@ endif() mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-blockdevice mbed-storage diff --git a/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt index fc67062..6f23861 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/heap_block_device/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-blockdevice ) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt index e551da0..a5f58d3 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/mbr_block_device/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-blockdevice ) diff --git a/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt b/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt index 1abc122..464dbba 100644 --- a/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt +++ b/storage/blockdevice/tests/TESTS/blockdevice/util_block_device/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-blockdevice ) diff --git a/storage/filesystem/tests/TESTS/filesystem/general_filesystem/CMakeLists.txt b/storage/filesystem/tests/TESTS/filesystem/general_filesystem/CMakeLists.txt index 7af9cb1..be29681 100644 --- a/storage/filesystem/tests/TESTS/filesystem/general_filesystem/CMakeLists.txt +++ b/storage/filesystem/tests/TESTS/filesystem/general_filesystem/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-littlefs mbed-storage diff --git a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/CMakeLists.txt b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/CMakeLists.txt index 0e80105..130b763e 100644 --- a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/CMakeLists.txt +++ b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_1/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage mbed-storage-filesystemstore diff --git a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/CMakeLists.txt b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/CMakeLists.txt index 4664f38..ad79cfe 100644 --- a/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/CMakeLists.txt +++ b/storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage mbed-storage-filesystemstore diff --git a/storage/kvstore/tests/TESTS/kvstore/static_tests/CMakeLists.txt b/storage/kvstore/tests/TESTS/kvstore/static_tests/CMakeLists.txt index ab4ae90..44b4275 100644 --- a/storage/kvstore/tests/TESTS/kvstore/static_tests/CMakeLists.txt +++ b/storage/kvstore/tests/TESTS/kvstore/static_tests/CMakeLists.txt @@ -11,7 +11,10 @@ project(${TEST_TARGET}) mbed_greentea_add_test( - TEST_NAME ${TEST_TARGET} + TEST_NAME + ${TEST_TARGET} + TEST_SOURCES + main.cpp TEST_REQUIRED_LIBS mbed-storage-kv-global-api ) diff --git a/tools/cmake/mbed_greentea.cmake b/tools/cmake/mbed_greentea.cmake index 23fddc6..6ecd852 100644 --- a/tools/cmake/mbed_greentea.cmake +++ b/tools/cmake/mbed_greentea.cmake @@ -35,26 +35,23 @@ ${ARGN} ) - set(TEST_NAME ${MBED_GREENTEA_TEST_NAME}) - add_subdirectory(${MBED_PATH} build) - add_executable(${TEST_NAME}) + add_executable(${MBED_GREENTEA_TEST_NAME}) # Explicitly enable BUILD_TESTING until CTest is added to the Greentea client set(BUILD_TESTING ON) - mbed_configure_app_target(${TEST_NAME}) + mbed_configure_app_target(${MBED_GREENTEA_TEST_NAME}) - target_include_directories(${TEST_NAME} + target_include_directories(${MBED_GREENTEA_TEST_NAME} PRIVATE . ${MBED_GREENTEA_TEST_INCLUDE_DIRS} ) - target_sources(${TEST_NAME} + target_sources(${MBED_GREENTEA_TEST_NAME} PRIVATE - main.cpp ${MBED_GREENTEA_TEST_SOURCES} ) @@ -67,16 +64,16 @@ if (DEFINED MBED_TEST_LINK_LIBRARIES) separate_arguments(MBED_TEST_LINK_LIBRARIES) list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS ${MBED_TEST_LINK_LIBRARIES} mbed-greentea) - else() + else() list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-greentea) endif() - target_link_libraries(${TEST_NAME} + target_link_libraries(${MBED_GREENTEA_TEST_NAME} PRIVATE ${MBED_GREENTEA_TEST_REQUIRED_LIBS} ) - mbed_set_post_build(${TEST_NAME}) + mbed_set_post_build(${MBED_GREENTEA_TEST_NAME}) option(VERBOSE_BUILD "Have a verbose build process") if(VERBOSE_BUILD)