From 6ead082ae27e029d4a322841b4db388d2c82ba94 Mon Sep 17 00:00:00 2001 From: suwanghw Date: Thu, 18 May 2023 17:32:58 +0800 Subject: [PATCH] Delete some xts test cases Signed-off-by: suwanghw --- test/xts/CMakeLists.txt | 19 - test/xts/ca/BUILD.gn | 325 -- test/xts/ca/CMakeLists.txt | 19 - test/xts/ca/Test.json | 25 - test/xts/ca/arithmetic_api/CMakeLists.txt | 31 - .../ca/arithmetic_api/common/common_test.h | 56 - .../src/tee_test_arithmetic_api.cpp | 489 --- test/xts/ca/crypto_api/CMakeLists.txt | 32 - test/xts/ca/crypto_api/common/common_test.cpp | 48 - test/xts/ca/crypto_api/common/common_test.h | 59 - .../ca/crypto_api/src/tee_test_crypto_api.cpp | 1449 --------- test/xts/ca/libc_api/CMakeLists.txt | 31 - test/xts/ca/libc_api/common/common_test.h | 51 - .../xts/ca/libc_api/src/tee_test_libc_api.cpp | 364 --- test/xts/ca/tcf_api/CMakeLists.txt | 51 - test/xts/ca/tcf_api/common/common_test.h | 299 -- test/xts/ca/tcf_api/src/common_test.cpp | 568 ---- .../src/mem/tee_checkmemaccessrights_test.cpp | 251 -- test/xts/ca/tcf_api/src/mem/tee_free_test.cpp | 53 - .../ca/tcf_api/src/mem/tee_instance_test.cpp | 94 - .../ca/tcf_api/src/mem/tee_malloc_test.cpp | 221 -- .../tcf_api/src/mem/tee_memcompare_test.cpp | 168 -- .../ca/tcf_api/src/mem/tee_memfill_test.cpp | 83 - .../ca/tcf_api/src/mem/tee_memmove_test.cpp | 134 - .../ca/tcf_api/src/mem/tee_realloc_test.cpp | 187 -- .../src/other/internal_client_api_test.cpp | 508 ---- .../ca/tcf_api/src/other/tee_panic_test.cpp | 79 - .../property/get_prop_as_binaryblock_test.cpp | 220 -- .../src/property/get_prop_as_bool_test.cpp | 341 --- .../property/get_prop_as_identity_test.cpp | 168 -- .../src/property/get_prop_as_string_test.cpp | 510 ---- .../src/property/get_prop_as_u32_test.cpp | 394 --- .../src/property/get_prop_as_u64_test.cpp | 148 - .../src/property/get_prop_as_uuid_test.cpp | 168 -- .../get_prop_with_enumerator_test.cpp | 603 ---- test/xts/ca/tee_test_drv/CMakeLists.txt | 30 - .../ca/tee_test_drv/include/tee_test_drv.h | 28 - test/xts/ca/tee_test_drv/src/tee_test_drv.cpp | 80 - test/xts/ca/time_api/CMakeLists.txt | 31 - test/xts/ca/time_api/common/common_test.h | 37 - .../xts/ca/time_api/src/tee_test_time_api.cpp | 170 -- .../xts/ca/trusted_storage_api/CMakeLists.txt | 32 - .../common/common_test.cpp | 46 - .../trusted_storage_api/common/common_test.h | 58 - .../src/tee_test_trusted_storage_api.cpp | 68 - test/xts/cmake/common.cmake | 25 - test/xts/cmake/drv.cmake | 93 - test/xts/cmake/ta.cmake | 77 - test/xts/driver/CMakeLists.txt | 13 - .../xts/driver/drv_test_module/CMakeLists.txt | 35 - .../drv_test_module/drv_test_module.csv | 22 - test/xts/driver/drv_test_module/dyn_perm.xml | 15 - .../drv_test_module/include/drv_test_module.h | 60 - test/xts/driver/drv_test_module/manifest.txt | 6 - .../drv_test_module/src/drv_test_module.c | 262 -- test/xts/ta/CMakeLists.txt | 19 - test/xts/ta/config_ta_public.ini | 19 - .../xts/ta/test_arithmetic_api/CMakeLists.txt | 39 - test/xts/ta/test_arithmetic_api/manifest.txt | 7 - .../src/test_arithmetic_api_base.c | 67 - .../src/test_arithmetic_api_base.h | 60 - .../src/test_arithmetic_api_main.c | 129 - .../src/test_basic_arithmetic_operation.c | 250 -- .../src/test_basic_arithmetic_operation.h | 23 - .../src/test_converter_function.c | 82 - .../src/test_converter_function.h | 21 - ...st_fast_modular_multiplication_operation.c | 209 -- ...st_fast_modular_multiplication_operation.h | 23 - .../src/test_logical_operation.c | 216 -- .../src/test_logical_operation.h | 27 - .../src/test_modular_arithmetic_operation.c | 314 -- .../src/test_modular_arithmetic_operation.h | 23 - .../src/test_other_arithmetic_operation.c | 192 -- .../src/test_other_arithmetic_operation.h | 22 - test/xts/ta/test_crypto_api/CMakeLists.txt | 45 - test/xts/ta/test_crypto_api/manifest.txt | 7 - .../src/cases/cases_ae_crypto_basic_cases.c | 2670 ----------------- .../src/cases/cases_asym_crypto_basic_cases.c | 630 ---- .../src/cases/cases_asym_sign_basic_cases.c | 839 ------ .../src/cases/cases_derive_basic_cases.c | 342 --- .../cases/cases_digest_crypto_basic_cases.c | 491 --- .../test_crypto_api/src/cases/cases_entry.c | 1330 -------- .../test_crypto_api/src/cases/cases_entry.h | 252 -- .../src/cases/cases_mac_crypto_basic_cases.c | 1090 ------- .../src/cases/cases_sym_crypto_basic_cases.c | 1238 -------- .../test_crypto_api/src/data/alg_map_data.c | 1032 ------- .../src/data/key_object_database.c | 586 ---- .../src/data/test_crypto_data.h | 23 - test/xts/ta/test_crypto_api/src/monad/monad.h | 86 - .../test_crypto_api/src/monad/monad_actions.c | 1338 --------- .../src/monad/monad_inverse_map.c | 130 - .../ta/test_crypto_api/src/monad/monad_run.c | 108 - .../ta/test_crypto_api/src/oh_crypto_entry.c | 86 - .../src/test_crypto_api_types.h | 255 -- test/xts/ta/test_driver_ta/CMakeLists.txt | 35 - .../xts/ta/test_driver_ta/drv_test_module.csv | 22 - test/xts/ta/test_driver_ta/dyn_perm.xml | 17 - test/xts/ta/test_driver_ta/manifest.txt | 5 - .../ta/test_driver_ta/src/drvcaller_test.c | 171 -- test/xts/ta/test_libc_api/CMakeLists.txt | 133 - test/xts/ta/test_libc_api/manifest.txt | 7 - .../src/libc_func/pthread_attr_destroy_1_1.c | 64 - .../src/libc_func/pthread_attr_destroy_2_1.c | 47 - .../src/libc_func/pthread_attr_destroy_3_1.c | 40 - .../src/libc_func/pthread_attr_getstack_1_1.c | 87 - .../libc_func/pthread_attr_getstacksize_1_1.c | 86 - .../src/libc_func/pthread_attr_init_1_1.c | 46 - .../src/libc_func/pthread_attr_init_3_1.c | 57 - .../src/libc_func/pthread_attr_init_4_1.c | 44 - .../src/libc_func/pthread_attr_setstack_1_1.c | 108 - .../src/libc_func/pthread_attr_setstack_2_1.c | 129 - .../src/libc_func/pthread_attr_setstack_4_1.c | 121 - .../src/libc_func/pthread_attr_setstack_6_1.c | 86 - .../src/libc_func/pthread_attr_setstack_7_1.c | 80 - .../libc_func/pthread_attr_setstacksize_1_1.c | 95 - .../libc_func/pthread_attr_setstacksize_2_1.c | 95 - .../libc_func/pthread_attr_setstacksize_4_1.c | 59 - .../libc_func/pthread_cond_broadcast_1_1.c | 131 - .../src/libc_func/pthread_cond_init_1_1.c | 39 - .../src/libc_func/pthread_cond_wait_0_1.c | 190 -- .../src/libc_func/pthread_cond_wait_0_2.c | 124 - .../src/libc_func/pthread_cond_wait_0_3.c | 147 - .../src/libc_func/pthread_create_12_1.c | 44 - .../src/libc_func/pthread_create_1_1.c | 47 - .../src/libc_func/pthread_create_2_1.c | 47 - .../src/libc_func/pthread_create_4_1.c | 58 - .../src/libc_func/pthread_create_5_1.c | 50 - .../src/libc_func/pthread_create_5_2.c | 54 - .../src/libc_func/pthread_equal.c | 82 - .../src/libc_func/pthread_exit_2_1.c | 111 - .../src/libc_func/pthread_exit_3_1.c | 82 - .../src/libc_func/pthread_getspecific_1_1.c | 58 - .../src/libc_func/pthread_mutex_destroy_1_1.c | 61 - .../libc_func/pthread_mutex_destroy_1_1_0.c | 72 - .../src/libc_func/pthread_mutex_destroy_2_1.c | 41 - .../src/libc_func/pthread_mutex_destroy_4_2.c | 46 - .../src/libc_func/pthread_mutex_init_0_1.c | 59 - .../src/libc_func/pthread_mutex_init_1_1.c | 45 - .../src/libc_func/pthread_mutex_init_2_1_0.c | 53 - .../src/libc_func/pthread_mutex_lock_0_2.c | 110 - .../src/libc_func/pthread_mutex_lock_0_3.c | 123 - .../src/libc_func/pthread_mutex_lock_1_1_0.c | 98 - .../src/libc_func/pthread_mutex_trylock_0_1.c | 71 - .../src/libc_func/pthread_mutex_trylock_1_1.c | 109 - .../src/libc_func/pthread_mutex_trylock_4_1.c | 42 - .../src/libc_func/pthread_mutex_unlock_1_1.c | 51 - .../pthread_mutexattr_getprotocol_1_1.c | 75 - .../libc_func/pthread_mutexattr_gettype_1_1.c | 87 - .../src/libc_func/pthread_once_1_3.c | 124 - .../src/libc_func/pthread_setspecific_1_2.c | 91 - .../src/libc_func/pthread_spin_destroy_0_1.c | 34 - .../src/libc_func/pthread_spin_destroy_1_1.c | 59 - .../src/libc_func/pthread_spin_destroy_3_1.c | 74 - .../src/libc_func/pthread_spin_init_1_1.c | 65 - .../src/libc_func/pthread_spin_init_4_1.c | 85 - .../src/libc_func/pthread_spin_lock_0_1.c | 99 - .../src/libc_func/pthread_spin_lock_0_3.c | 123 - .../src/libc_func/pthread_spin_lock_3_1.c | 65 - .../src/libc_func/pthread_spin_trylock_0_1.c | 53 - .../src/libc_func/pthread_spin_trylock_1_1.c | 84 - .../src/libc_func/pthread_spin_trylock_4_1.c | 43 - .../libc_func/pthread_spin_trylock_4_1_0.c | 43 - .../src/libc_func/pthread_spin_unlock_1_1.c | 114 - .../test_libc_api/src/libc_func/test-string.c | 373 --- .../test_libc_api/src/libc_func/test_ctype.c | 177 -- .../test_libc_api/src/libc_func/test_error.c | 31 - .../test_libc_api/src/libc_func/test_getpid.c | 61 - .../src/libc_func/test_libc_func.h | 167 -- .../test_libc_api/src/libc_func/test_locale.c | 206 -- .../test_libc_api/src/libc_func/test_math.c | 177 -- .../test_libc_api/src/libc_func/test_mmap.c | 100 - .../src/libc_func/test_multibyte.c | 158 - .../test_libc_api/src/libc_func/test_prng.c | 119 - .../src/libc_func/test_pthread_key_create.c | 58 - .../ta/test_libc_api/src/libc_func/test_sem.c | 77 - .../test_libc_api/src/libc_func/test_stdio.c | 175 -- .../test_libc_api/src/libc_func/test_stdlib.c | 780 ----- .../test_libc_api/src/libc_func/test_time.c | 69 - .../test_libc_api/src/libc_func/tst-calloc.c | 110 - .../test_libc_api/src/libc_func/tst-malloc.c | 86 - .../ta/test_libc_api/src/libc_func/tst_free.c | 43 - test/xts/ta/test_libc_api/src/ta_case_work.c | 50 - test/xts/ta/test_libc_api/src/ta_case_work.h | 34 - .../ta/test_libc_api/src/test_libc_cases.h | 63 - .../test_libc_api/src/test_libc_common_lib.c | 141 - .../xts/ta/test_libc_api/src/test_libc_main.c | 116 - test/xts/ta/test_libc_api/src/test_libc_mem.c | 37 - .../ta/test_libc_api/src/test_libc_pthread.c | 125 - .../ta/test_libc_api/src/test_libc_string.c | 32 - test/xts/ta/test_tcf2_api/CMakeLists.txt | 28 - test/xts/ta/test_tcf2_api/manifest.txt | 8 - test/xts/ta/test_tcf2_api/src/tee_test_tcf.c | 716 ----- test/xts/ta/test_tcf_api/CMakeLists.txt | 28 - test/xts/ta/test_tcf_api/manifest.txt | 11 - test/xts/ta/test_tcf_api/src/tee_test_tcf.c | 755 ----- test/xts/ta/test_time_api/CMakeLists.txt | 33 - test/xts/ta/test_time_api/manifest.txt | 7 - .../ta/test_time_api/src/test_time_api_func.c | 271 -- .../ta/test_time_api/src/test_time_api_func.h | 34 - .../ta/test_time_api/src/test_time_api_main.c | 71 - .../test_trusted_storage_api/CMakeLists.txt | 45 - .../ta/test_trusted_storage_api/manifest.txt | 8 - .../src/cases/cases_entry.c | 129 - .../src/cases/cases_entry.h | 42 - .../src/cases/cases_trusted_storage.c | 214 -- .../src/monad/monad.h | 66 - .../src/monad/monad_actions.c | 462 --- .../src/monad/monad_inverse_map.c | 141 - .../src/monad/monad_run.c | 108 - .../src/oh_trusted_storage_entry.c | 88 - .../src/test_trusted_storage_api_defines.h | 134 - test/xts/utils/cmd_id/test_drv_cmdid.h | 21 - test/xts/utils/cmd_id/test_tcf_cmdid.h | 60 - 213 files changed, 35996 deletions(-) delete mode 100644 test/xts/CMakeLists.txt delete mode 100644 test/xts/ca/BUILD.gn delete mode 100644 test/xts/ca/CMakeLists.txt delete mode 100644 test/xts/ca/Test.json delete mode 100644 test/xts/ca/arithmetic_api/CMakeLists.txt delete mode 100644 test/xts/ca/arithmetic_api/common/common_test.h delete mode 100644 test/xts/ca/arithmetic_api/src/tee_test_arithmetic_api.cpp delete mode 100644 test/xts/ca/crypto_api/CMakeLists.txt delete mode 100644 test/xts/ca/crypto_api/common/common_test.cpp delete mode 100644 test/xts/ca/crypto_api/common/common_test.h delete mode 100644 test/xts/ca/crypto_api/src/tee_test_crypto_api.cpp delete mode 100644 test/xts/ca/libc_api/CMakeLists.txt delete mode 100644 test/xts/ca/libc_api/common/common_test.h delete mode 100644 test/xts/ca/libc_api/src/tee_test_libc_api.cpp delete mode 100644 test/xts/ca/tcf_api/CMakeLists.txt delete mode 100644 test/xts/ca/tcf_api/common/common_test.h delete mode 100644 test/xts/ca/tcf_api/src/common_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_checkmemaccessrights_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_free_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_instance_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_malloc_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_memcompare_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_memfill_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_memmove_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/mem/tee_realloc_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/other/internal_client_api_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/other/tee_panic_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_binaryblock_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_bool_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_identity_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_string_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_u32_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_u64_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_as_uuid_test.cpp delete mode 100644 test/xts/ca/tcf_api/src/property/get_prop_with_enumerator_test.cpp delete mode 100644 test/xts/ca/tee_test_drv/CMakeLists.txt delete mode 100644 test/xts/ca/tee_test_drv/include/tee_test_drv.h delete mode 100644 test/xts/ca/tee_test_drv/src/tee_test_drv.cpp delete mode 100644 test/xts/ca/time_api/CMakeLists.txt delete mode 100644 test/xts/ca/time_api/common/common_test.h delete mode 100644 test/xts/ca/time_api/src/tee_test_time_api.cpp delete mode 100644 test/xts/ca/trusted_storage_api/CMakeLists.txt delete mode 100644 test/xts/ca/trusted_storage_api/common/common_test.cpp delete mode 100644 test/xts/ca/trusted_storage_api/common/common_test.h delete mode 100644 test/xts/ca/trusted_storage_api/src/tee_test_trusted_storage_api.cpp delete mode 100644 test/xts/cmake/common.cmake delete mode 100644 test/xts/cmake/drv.cmake delete mode 100644 test/xts/cmake/ta.cmake delete mode 100644 test/xts/driver/CMakeLists.txt delete mode 100644 test/xts/driver/drv_test_module/CMakeLists.txt delete mode 100644 test/xts/driver/drv_test_module/drv_test_module.csv delete mode 100644 test/xts/driver/drv_test_module/dyn_perm.xml delete mode 100644 test/xts/driver/drv_test_module/include/drv_test_module.h delete mode 100644 test/xts/driver/drv_test_module/manifest.txt delete mode 100644 test/xts/driver/drv_test_module/src/drv_test_module.c delete mode 100644 test/xts/ta/CMakeLists.txt delete mode 100644 test/xts/ta/config_ta_public.ini delete mode 100644 test/xts/ta/test_arithmetic_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_arithmetic_api/manifest.txt delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.h delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_main.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.h delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_converter_function.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_converter_function.h delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.h delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_logical_operation.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_logical_operation.h delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.h delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.c delete mode 100644 test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.h delete mode 100644 test/xts/ta/test_crypto_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_crypto_api/manifest.txt delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_ae_crypto_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_asym_crypto_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_asym_sign_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_derive_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_digest_crypto_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_entry.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_entry.h delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_mac_crypto_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/cases/cases_sym_crypto_basic_cases.c delete mode 100644 test/xts/ta/test_crypto_api/src/data/alg_map_data.c delete mode 100644 test/xts/ta/test_crypto_api/src/data/key_object_database.c delete mode 100644 test/xts/ta/test_crypto_api/src/data/test_crypto_data.h delete mode 100644 test/xts/ta/test_crypto_api/src/monad/monad.h delete mode 100644 test/xts/ta/test_crypto_api/src/monad/monad_actions.c delete mode 100644 test/xts/ta/test_crypto_api/src/monad/monad_inverse_map.c delete mode 100644 test/xts/ta/test_crypto_api/src/monad/monad_run.c delete mode 100644 test/xts/ta/test_crypto_api/src/oh_crypto_entry.c delete mode 100644 test/xts/ta/test_crypto_api/src/test_crypto_api_types.h delete mode 100644 test/xts/ta/test_driver_ta/CMakeLists.txt delete mode 100644 test/xts/ta/test_driver_ta/drv_test_module.csv delete mode 100644 test/xts/ta/test_driver_ta/dyn_perm.xml delete mode 100644 test/xts/ta/test_driver_ta/manifest.txt delete mode 100644 test/xts/ta/test_driver_ta/src/drvcaller_test.c delete mode 100644 test/xts/ta/test_libc_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_libc_api/manifest.txt delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_2_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_3_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstack_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstacksize_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_3_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_4_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_2_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_4_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_6_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_7_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_2_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_4_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_cond_broadcast_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_cond_init_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_2.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_3.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_create_12_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_create_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_create_2_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_create_4_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_2.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_equal.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_exit_2_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_exit_3_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_getspecific_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1_0.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_2_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_4_2.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_0_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_2_1_0.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_2.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_3.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_1_1_0.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_0_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_4_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_unlock_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_getprotocol_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_gettype_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_once_1_3.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_setspecific_1_2.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_0_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_3_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_4_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_3.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_3_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_0_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_1_1.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1_0.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/pthread_spin_unlock_1_1.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test-string.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_ctype.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_error.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_getpid.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_libc_func.h delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_locale.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_math.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_mmap.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_multibyte.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_prng.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_pthread_key_create.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_sem.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_stdio.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_stdlib.c delete mode 100644 test/xts/ta/test_libc_api/src/libc_func/test_time.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/tst-calloc.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/tst-malloc.c delete mode 100755 test/xts/ta/test_libc_api/src/libc_func/tst_free.c delete mode 100644 test/xts/ta/test_libc_api/src/ta_case_work.c delete mode 100644 test/xts/ta/test_libc_api/src/ta_case_work.h delete mode 100644 test/xts/ta/test_libc_api/src/test_libc_cases.h delete mode 100644 test/xts/ta/test_libc_api/src/test_libc_common_lib.c delete mode 100644 test/xts/ta/test_libc_api/src/test_libc_main.c delete mode 100644 test/xts/ta/test_libc_api/src/test_libc_mem.c delete mode 100644 test/xts/ta/test_libc_api/src/test_libc_pthread.c delete mode 100644 test/xts/ta/test_libc_api/src/test_libc_string.c delete mode 100644 test/xts/ta/test_tcf2_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_tcf2_api/manifest.txt delete mode 100644 test/xts/ta/test_tcf2_api/src/tee_test_tcf.c delete mode 100644 test/xts/ta/test_tcf_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_tcf_api/manifest.txt delete mode 100644 test/xts/ta/test_tcf_api/src/tee_test_tcf.c delete mode 100644 test/xts/ta/test_time_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_time_api/manifest.txt delete mode 100644 test/xts/ta/test_time_api/src/test_time_api_func.c delete mode 100644 test/xts/ta/test_time_api/src/test_time_api_func.h delete mode 100644 test/xts/ta/test_time_api/src/test_time_api_main.c delete mode 100644 test/xts/ta/test_trusted_storage_api/CMakeLists.txt delete mode 100644 test/xts/ta/test_trusted_storage_api/manifest.txt delete mode 100644 test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.c delete mode 100644 test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.h delete mode 100644 test/xts/ta/test_trusted_storage_api/src/cases/cases_trusted_storage.c delete mode 100644 test/xts/ta/test_trusted_storage_api/src/monad/monad.h delete mode 100644 test/xts/ta/test_trusted_storage_api/src/monad/monad_actions.c delete mode 100644 test/xts/ta/test_trusted_storage_api/src/monad/monad_inverse_map.c delete mode 100644 test/xts/ta/test_trusted_storage_api/src/monad/monad_run.c delete mode 100644 test/xts/ta/test_trusted_storage_api/src/oh_trusted_storage_entry.c delete mode 100644 test/xts/ta/test_trusted_storage_api/src/test_trusted_storage_api_defines.h delete mode 100644 test/xts/utils/cmd_id/test_drv_cmdid.h delete mode 100644 test/xts/utils/cmd_id/test_tcf_cmdid.h diff --git a/test/xts/CMakeLists.txt b/test/xts/CMakeLists.txt deleted file mode 100644 index b3b3b624..00000000 --- a/test/xts/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -cmake_minimum_required(VERSION 3.14.1) - -project(tee_test) - -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake) - -add_subdirectory(ta) diff --git a/test/xts/ca/BUILD.gn b/test/xts/ca/BUILD.gn deleted file mode 100644 index fd1ff1a2..00000000 --- a/test/xts/ca/BUILD.gn +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import("//test/xts/tools/lite/build/suite_lite.gni") - -hcpptest_suite("tee_test_client_api") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - - tee_test_root_dir + "/ca/client_api/src/initializecontext_test.cpp", - tee_test_root_dir + "/ca/client_api/src/opensession_test.cpp", - tee_test_root_dir + "/ca/client_api/src/invokecommand_test.cpp", - tee_test_root_dir + "/ca/client_api/src/closesession_test.cpp", - tee_test_root_dir + "/ca/client_api/src/finalizecontext_test.cpp", - tee_test_root_dir + "/ca/client_api/src/allocatesharedmemory_test.cpp", - tee_test_root_dir + "/ca/client_api/src/registersharedmemory_test.cpp", - tee_test_root_dir + "/ca/client_api/src/releasesharedmemory_test.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/ca/client_api/common", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} - -hcpptest_suite("tee_test_tcf_api") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_identity_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_string_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_bool_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_u32_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_u64_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_binaryblock_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_as_uuid_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/property/get_prop_with_enumerator_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_malloc_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_realloc_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_memmove_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_memfill_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_free_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_memcompare_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_checkmemaccessrights_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/mem/tee_instance_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/other/internal_client_api_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/other/tee_panic_test.cpp", - tee_test_root_dir + "/ca/tcf_api/src/common_test.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/ca/tcf_api/common", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} - -hcpptest_suite("tee_test_time_api") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - - tee_test_root_dir + "/ca/time_api/src/tee_test_time_api.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/ca/time_api/common", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} - -hcpptest_suite("tee_test_arithmetic_api") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - - tee_test_root_dir + "/ca/arithmetic_api/src/tee_test_arithmetic_api.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/ca/arithmetic_api/common", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} - -hcpptest_suite("tee_test_crypto_api") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - - tee_test_root_dir + "/ca/crypto_api/src/tee_test_crypto_api.cpp", - tee_test_root_dir + "/ca/crypto_api/common/common_test.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/ca/crypto_api/common", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} - -hcpptest_suite("tee_test_drv") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - - tee_test_root_dir + "/ca/tee_test_drv/src/tee_test_drv.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/ca/tee_test_drv/include", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} - -hcpptest_suite("tee_test_libc_api") { - suite_name = "acts" - - tee_dev_kit_dir = "//base/tee/tee_dev_kit" - tee_test_root_dir = "//base/tee/tee_os_framework/test/xts" - sources = [ - tee_test_root_dir + "/utils/public_test/public_test.cpp", - tee_test_root_dir + "/utils/session_mgr/client_session_mgr.cpp", - tee_test_root_dir + "/ca/libc_api/src/tee_test_libc_api.cpp", - ] - - include_dirs = [ - tee_dev_kit_dir + "/sdk/include/TA", - tee_dev_kit_dir + "/sdk/thirdparty/open_source/libboundscheck/include/libhwsecurec", - tee_dev_kit_dir + "/sdk/include/CA", - - tee_test_root_dir + "/utils", - tee_test_root_dir + "/utils/public_test", - tee_test_root_dir + "/utils/cmd_id", - tee_test_root_dir + "/utils/include", - tee_test_root_dir + "/ca/libc_api/common", - - "//test/xts/tools/lite/hctest/include", - "//third_party/googletest/googletest/include", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] - - deps = [ - "//base/tee/tee_client/frameworks/build/lite:libteec_vendor", - "//third_party/bounds_checking_function:libsec_static", - ] - - cflags = [ "-Wno-error" ] - ldflags = [ - "-lstdc++", - "-lm", - "-lpthread", - ] -} diff --git a/test/xts/ca/CMakeLists.txt b/test/xts/ca/CMakeLists.txt deleted file mode 100644 index c83958fd..00000000 --- a/test/xts/ca/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -add_subdirectory(sample) -add_subdirectory(client_api) -add_subdirectory(tcf_api) -add_subdirectory(tee_test_drv) -add_subdirectory(arithmetic_api) -add_subdirectory(time_api) -add_subdirectory(crypto_api) diff --git a/test/xts/ca/Test.json b/test/xts/ca/Test.json deleted file mode 100644 index 6bb78d77..00000000 --- a/test/xts/ca/Test.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "description": "Config for tee test cases", - "environment": [ - { - "type": "device", - "label": "ipcamera" - } - ], - "kits": [ - { - "type": "MountKit", - "server": "NfsServer", - "mount": [ - { - "source": "testcases/tee", - "target": "/test_root/tee" - } - ] - } - ], - "driver": { - "type": "CppTestLite", - "execute": "/test_root/tee/tee_test_client_api.bin" - } -} diff --git a/test/xts/ca/arithmetic_api/CMakeLists.txt b/test/xts/ca/arithmetic_api/CMakeLists.txt deleted file mode 100644 index ae9f9606..00000000 --- a/test/xts/ca/arithmetic_api/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(ca_sources) -list(APPEND ca_sources - src/tee_test_arithmetic_api.cpp -) - -ca_compile_pub( - TEST_NAME - arithmetic_api - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - common - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ca/arithmetic_api/common/common_test.h b/test/xts/ca/arithmetic_api/common/common_test.h deleted file mode 100644 index 2337a7f3..00000000 --- a/test/xts/ca/arithmetic_api/common/common_test.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __COMMON_TEST_H__ -#define __COMMON_TEST_H__ - -#include -#include - -#define ARITHMETIC_API_UUID \ - { \ - 0x9ac09588, 0xfed1, 0x4b1e, \ - { \ - 0xbb, 0x36, 0xd3, 0xe5, 0xa3, 0xf2, 0x6c, 0x39 \ - } \ - } - -enum TEST_ARITHMETIC_API_CMD_ID { - CMD_ID_TEST_BIG_INT_COMPUTE_FMM = 0, - CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT = 1, - CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM = 2, - CMD_ID_TEST_BIG_INT_EXP_MOD = 3, - CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING = 4, - CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32 = 5, - CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD = 6, - CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD = 7, - CMD_ID_TEST_BIG_INT_MOD = 8, - CMD_ID_TEST_BIG_INT_ADD_AND_SUB = 9, - CMD_ID_TEST_BIG_INT_NEG = 10, - CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE = 11, - CMD_ID_TEST_BIG_INT_DIV = 12, - CMD_ID_TEST_BIG_INT_SHIFT_RIGHT = 13, - CMD_ID_TEST_BIG_INT_GET_BIT = 14, - CMD_ID_TEST_BIG_INT_GET_BIT_COUNT = 15, - CMD_ID_TEST_BIG_INT_SET_BIT = 16, - CMD_ID_TEST_BIG_INT_ASSIGN = 17, - CMD_ID_TEST_BIG_INT_ABS = 18, - CMD_ID_TEST_BIG_INT_RELATIVE_PRIME = 19, - CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD = 20, - CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME = 21, - CMD_ID_TEST_BIG_INT_CMP = 22, - CMD_ID_TEST_BIG_INT_CMP_S32 = 23, - CMD_ID_TEST_BIG_INT_INIT_FMM = 24, - CMD_ID_TEST_BIG_INT_INIT = 25, -}; - -#endif diff --git a/test/xts/ca/arithmetic_api/src/tee_test_arithmetic_api.cpp b/test/xts/ca/arithmetic_api/src/tee_test_arithmetic_api.cpp deleted file mode 100644 index 033eea92..00000000 --- a/test/xts/ca/arithmetic_api/src/tee_test_arithmetic_api.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : BigInt_ComputeFMM - * @testcase.desc : test TEE_BigIntComputeFMM api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ComputeFMM, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_COMPUTE_FMM, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_InitFMMContext - * @testcase.desc : test initialize context for FMM - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_InitFMMContext, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ConverterBetweenBigIntAndFMM - * @testcase.desc : test converter between big int and FMM - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ConverterBetweenBigIntAndFMM, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ComputeExpMod - * @testcase.desc : test TEE_BigIntExpMod api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ComputeExpMod, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_EXP_MOD, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ConverterBetweenBigIntAndOctetString - * @testcase.desc : test converter between big int and octet string - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ConverterBetweenBigIntAndOctetString, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ComputeExpMod - * @testcase.desc : test converter between big int and shortVal - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ConverterBetweenBigIntAndShortVal, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_AddAndSubMod - * @testcase.desc : test compute add and sub mod - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_AddAndSubMod, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_MulAndInvMod - * @testcase.desc : test compute mul, square and inv mod - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_MulAndInvMod, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_InitMod - * @testcase.desc : test TEE_BigIntMod api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_InitMod, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_MOD, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_AddAndSub - * @testcase.desc : test add and sub - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_AddAndSub, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ADD_AND_SUB, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_Neg - * @testcase.desc : test negate - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_Neg, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_NEG, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_MulAndSquare - * @testcase.desc : test mul and square - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_MulAndSquare, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_div - * @testcase.desc : test div - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_div, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_DIV, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ShiftRight - * @testcase.desc : test shift right - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ShiftRight, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_SHIFT_RIGHT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_GetBit - * @testcase.desc : test get bit - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_GetBit, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_GET_BIT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_GetBitCount - * @testcase.desc : test get bit counts - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_GetBitCount, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_GET_BIT_COUNT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_SetBit - * @testcase.desc : test set bit - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_SetBit, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_SET_BIT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_AssignSrcToDest - * @testcase.desc : test TEE_BigIntAssign api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_AssignSrcToDest, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ASSIGN, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_Abs - * @testcase.desc : test abs - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_Abs, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_ABS, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_RelativePrime - * @testcase.desc : test Relative Prime - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_RelativePrime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_RELATIVE_PRIME, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ComputeExtendedGcd - * @testcase.desc : test compute extended gcd - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ComputeExtendedGcd, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_ProbabilisticPrimality - * @testcase.desc : test probabilistic primality - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_ProbabilisticPrimality, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_Compare - * @testcase.desc : test comparison - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_Compare, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_CMP, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_CompareWithShortVal - * @testcase.desc : test comparison with shortVal - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_CompareWithShortVal, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_CMP_S32, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_InitializeFMM - * @testcase.desc : test initialize bigIntFMM - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_InitializeFMM, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_INIT_FMM, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : BigInt_InitializeBigInt - * @testcase.desc : test initialize bigInt - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, BigInt_InitializeBigInt, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_BIG_INT_INIT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} \ No newline at end of file diff --git a/test/xts/ca/crypto_api/CMakeLists.txt b/test/xts/ca/crypto_api/CMakeLists.txt deleted file mode 100644 index be90dbdf..00000000 --- a/test/xts/ca/crypto_api/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(ca_sources) -list(APPEND ca_sources - common/common_test.cpp - src/tee_test_crypto_api.cpp -) - -ca_compile_pub( - TEST_NAME - crypto_api - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - common - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ca/crypto_api/common/common_test.cpp b/test/xts/ca/crypto_api/common/common_test.cpp deleted file mode 100644 index 9e333043..00000000 --- a/test/xts/ca/crypto_api/common/common_test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -void CryptoTest::SetUp() -{ - TEEC_Result ret; - TEEC_UUID testId = CRYPTO_API_UUID; - ret = session.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_WHOLE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - (void)memset_s(&testMem.sharedMem, FUN_NAME_LEN, 0, FUN_NAME_LEN); - testMem.sharedMem.size = FUN_NAME_LEN; - testMem.sharedMem.flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT; - ret = TEEC_AllocateSharedMemory(&session.context, &testMem.sharedMem); - ASSERT_EQ(ret, TEEC_SUCCESS); -} - -void CryptoTest::TearDown() -{ - TEEC_ReleaseSharedMemory(&testMem.sharedMem); - session.Destroy(); -} - -TEEC_Result CryptoTest::InvokeTest(const char *casename) -{ - int rc; - rc = strcpy_s(reinterpret_cast(testMem.sharedMem.buffer), FUN_NAME_LEN, casename); - if (rc != 0) { - return TEEC_FAIL; - } - operation.params[0].memref.parent = &testMem.sharedMem; - operation.params[0].memref.offset = 0; - operation.params[0].memref.size = testMem.sharedMem.size; - return TEEC_InvokeCommand(&session.session, CMD_RUN_BY_FUN_SEQ, &operation, &origin); -} diff --git a/test/xts/ca/crypto_api/common/common_test.h b/test/xts/ca/crypto_api/common/common_test.h deleted file mode 100644 index aeb147b7..00000000 --- a/test/xts/ca/crypto_api/common/common_test.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __CRYPTO_COMMON_TEST_H__ -#define __CRYPTO_COMMON_TEST_H__ - -#include -#include - -#define CRYPTO_API_UUID \ - { \ - 0x05050505, 0x0303, 0x0303, \ - { \ - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01 \ - } \ - } - -#define FUN_NAME_LEN 64 -enum TEST_CRYPTO_API_CMD_ID { - CMD_RUN_BY_FUN_SEQ = 0, -}; - -class CryptoTest : public EmptyTest -{ -protected: - ClientSessionMgr session; - TEEC_Operation operation = { 0 }; - uint32_t origin; - ClientShareMemMgr testMem; - -public: - void SetUp(); - void TearDown(); - TEEC_Result InvokeTest(const char *casename); -}; - -#define CRYPTO_TEST_EQ(casename) \ - TEE_TEST(CryptoTest, casename, Function | MediumTest | Level0) \ - { \ - TEEC_Result ret = InvokeTest(#casename); \ - ASSERT_EQ(ret, TEEC_SUCCESS); \ - } - -#define CRYPTO_TEST_NE(casename) \ - TEE_TEST(CryptoTest, casename, Function | MediumTest | Level0) \ - { \ - TEEC_Result ret = InvokeTest(#casename); \ - ASSERT_NE(ret, TEEC_SUCCESS); \ - } -#endif diff --git a/test/xts/ca/crypto_api/src/tee_test_crypto_api.cpp b/test/xts/ca/crypto_api/src/tee_test_crypto_api.cpp deleted file mode 100644 index 94397452..00000000 --- a/test/xts/ca/crypto_api/src/tee_test_crypto_api.cpp +++ /dev/null @@ -1,1449 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -using namespace testing::ext; -/** - * @testcase.name : CaseDigestSha256OnceOnce - * @testcase.desc : run case CaseDigestSha256OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha256OnceOnce); - -/** - * @testcase.name : CaseDigestSha256OnceMulti - * @testcase.desc : run case CaseDigestSha256OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha256OnceMulti); - -/** - * @testcase.name : CaseDigestSha256MultiOnce - * @testcase.desc : run case CaseDigestSha256MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha256MultiOnce); - -/** - * @testcase.name : CaseDigestSha256MultiMulti - * @testcase.desc : run case CaseDigestSha256MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha256MultiMulti); - -/** - * @testcase.name : CaseDigestSha384OnceOnce - * @testcase.desc : run case CaseDigestSha384OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha384OnceOnce); - -/** - * @testcase.name : CaseDigestSha384OnceMulti - * @testcase.desc : run case CaseDigestSha384OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha384OnceMulti); - -/** - * @testcase.name : CaseDigestSha384MultiOnce - * @testcase.desc : run case CaseDigestSha384MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha384MultiOnce); - -/** - * @testcase.name : CaseDigestSha384MultiMulti - * @testcase.desc : run case CaseDigestSha384MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha384MultiMulti); - -/** - * @testcase.name : CaseDigestSha512OnceOnce - * @testcase.desc : run case CaseDigestSha512OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha512OnceOnce); - -/** - * @testcase.name : CaseDigestSha512OnceMulti - * @testcase.desc : run case CaseDigestSha512OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha512OnceMulti); - -/** - * @testcase.name : CaseDigestSha512MultiOnce - * @testcase.desc : run case CaseDigestSha512MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha512MultiOnce); - -/** - * @testcase.name : CaseDigestSha512MultiMulti - * @testcase.desc : run case CaseDigestSha512MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSha512MultiMulti); - -/** - * @testcase.name : CaseDigestSM3OnceOnce - * @testcase.desc : run case CaseDigestSM3OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSM3OnceOnce); - -/** - * @testcase.name : CaseDigestSM3OnceMulti - * @testcase.desc : run case CaseDigestSM3OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSM3OnceMulti); - -/** - * @testcase.name : CaseDigestSM3MultiOnce - * @testcase.desc : run case CaseDigestSM3MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSM3MultiOnce); - -/** - * @testcase.name : CaseDigestSM3MultiMulti - * @testcase.desc : run case CaseDigestSM3MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDigestSM3MultiMulti); - -/** - * @testcase.name : CaseDREcdhNistP224DataSize14 - * @testcase.desc : run case CaseDREcdhNistP224DataSize14 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDREcdhNistP224DataSize14); - -/** - * @testcase.name : CaseDREcdhNistP256DataSize128 - * @testcase.desc : run case CaseDREcdhNistP256DataSize128 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDREcdhNistP256DataSize128); - -/** - * @testcase.name : CaseDREcdhNistP384DataSize512 - * @testcase.desc : run case CaseDREcdhNistP384DataSize512 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDREcdhNistP384DataSize512); - -/** - * @testcase.name : CaseDREcdhNistP521DataSize1024 - * @testcase.desc : run case CaseDREcdhNistP521DataSize1024 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDREcdhNistP521DataSize1024); - -/** - * @testcase.name : CaseDREcdhNistP521DataSize4096 - * @testcase.desc : run case CaseDREcdhNistP521DataSize4096 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDREcdhNistP521DataSize4096); - -/** - * @testcase.name : CaseDREcdhNistP384DataSize10000 - * @testcase.desc : run case CaseDREcdhNistP384DataSize10000 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDREcdhNistP384DataSize10000); - -/** - * @testcase.name : CaseDRDHKeySize512Pram512DataSize1024 - * @testcase.desc : run case CaseDRDHKeySize512Pram512DataSize1024 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDRDHKeySize512Pram512DataSize1024); - -/** - * @testcase.name : CaseDRDHKeySize1024Pram1024DataSize1024 - * @testcase.desc : run case CaseDRDHKeySize1024Pram1024DataSize1024 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDRDHKeySize1024Pram1024DataSize1024); - -/** - * @testcase.name : CaseDRX25519DataSize1024 - * @testcase.desc : run case CaseDRX25519DataSize1024 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDRX25519DataSize1024); - -/** - * @testcase.name : CaseDRX25519DataSize4096 - * @testcase.desc : run case CaseDRX25519DataSize4096 - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseDRX25519DataSize4096); - -/** - * @testcase.name : CaseSymEncryptAesEcbNopadKeySize128OnceOnce - * @testcase.desc : run case CaseSymEncryptAesEcbNopadKeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesEcbNopadKeySize128OnceOnce); - -/** - * @testcase.name : CaseSymEncryptAesEcbNopadKeySize128OnceMulti - * @testcase.desc : run case CaseSymEncryptAesEcbNopadKeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesEcbNopadKeySize128OnceMulti); - -/** - * @testcase.name : CaseSymEncryptAesEcbNopadKeySize128MultiOnce - * @testcase.desc : run case CaseSymEncryptAesEcbNopadKeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesEcbNopadKeySize128MultiOnce); - -/** - * @testcase.name : CaseSymEncryptAesEcbNopadKeySize128MultiMulti - * @testcase.desc : run case CaseSymEncryptAesEcbNopadKeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesEcbNopadKeySize128MultiMulti); - -/** - * @testcase.name : CaseSymEncryptAesCbcNopadKeySize192OnceOnce - * @testcase.desc : run case CaseSymEncryptAesCbcNopadKeySize192OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcNopadKeySize192OnceOnce); - -/** - * @testcase.name : CaseSymEncryptAesCbcNopadKeySize192OnceMulti - * @testcase.desc : run case CaseSymEncryptAesCbcNopadKeySize192OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcNopadKeySize192OnceMulti); - -/** - * @testcase.name : CaseSymEncryptAesCbcNopadKeySize192MultiOnce - * @testcase.desc : run case CaseSymEncryptAesCbcNopadKeySize192MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcNopadKeySize192MultiOnce); - -/** - * @testcase.name : CaseSymEncryptAesCbcNopadKeySize192MultiMulti - * @testcase.desc : run case CaseSymEncryptAesCbcNopadKeySize192MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcNopadKeySize192MultiMulti); - -/** - * @testcase.name : CaseSymEncryptAesCtrKeySize128OnceOnce - * @testcase.desc : run case CaseSymEncryptAesCtrKeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCtrKeySize128OnceOnce); - -/** - * @testcase.name : CaseSymEncryptAesCtrKeySize128OnceMulti - * @testcase.desc : run case CaseSymEncryptAesCtrKeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCtrKeySize128OnceMulti); - -/** - * @testcase.name : CaseSymEncryptAesCtrKeySize128MultiOnce - * @testcase.desc : run case CaseSymEncryptAesCtrKeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCtrKeySize128MultiOnce); - -/** - * @testcase.name : CaseSymEncryptAesCtrKeySize128MultiMulti - * @testcase.desc : run case CaseSymEncryptAesCtrKeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCtrKeySize128MultiMulti); - -/** - * @testcase.name : CaseSymEncryptAesXtsKeySize256OnceOnce - * @testcase.desc : run case CaseSymEncryptAesXtsKeySize256OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesXtsKeySize256OnceOnce); - -/** - * @testcase.name : CaseSymEncryptAesXtsKeySize256OnceMulti - * @testcase.desc : run case CaseSymEncryptAesXtsKeySize256OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesXtsKeySize256OnceMulti); - -/** - * @testcase.name : CaseSymEncryptAesXtsKeySize256MultiOnce - * @testcase.desc : run case CaseSymEncryptAesXtsKeySize256MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesXtsKeySize256MultiOnce); - -/** - * @testcase.name : CaseSymEncryptAesXtsKeySize256MultiMulti - * @testcase.desc : run case CaseSymEncryptAesXtsKeySize256MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesXtsKeySize256MultiMulti); - -/** - * @testcase.name : CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce - * @testcase.desc : run case CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce); - -/** - * @testcase.name : CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti - * @testcase.desc : run case CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti); - -/** - * @testcase.name : CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce - * @testcase.desc : run case CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce); - -/** - * @testcase.name : CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti - * @testcase.desc : run case CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti); - -/** - * @testcase.name : CaseSymEncryptSm4CbcNopadKeySize128OnceOnce - * @testcase.desc : run case CaseSymEncryptSm4CbcNopadKeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcNopadKeySize128OnceOnce); - -/** - * @testcase.name : CaseSymEncryptSm4CbcNopadKeySize128OnceMulti - * @testcase.desc : run case CaseSymEncryptSm4CbcNopadKeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcNopadKeySize128OnceMulti); - -/** - * @testcase.name : CaseSymEncryptSm4CbcNopadKeySize128MultiOnce - * @testcase.desc : run case CaseSymEncryptSm4CbcNopadKeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcNopadKeySize128MultiOnce); - -/** - * @testcase.name : CaseSymEncryptSm4CbcNopadKeySize128MultiMulti - * @testcase.desc : run case CaseSymEncryptSm4CbcNopadKeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcNopadKeySize128MultiMulti); - -/** - * @testcase.name : CaseSymEncryptSm4CtrKeySize128OnceOnce - * @testcase.desc : run case CaseSymEncryptSm4CtrKeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CtrKeySize128OnceOnce); - -/** - * @testcase.name : CaseSymEncryptSm4CtrKeySize128OnceMulti - * @testcase.desc : run case CaseSymEncryptSm4CtrKeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CtrKeySize128OnceMulti); - -/** - * @testcase.name : CaseSymEncryptSm4CtrKeySize128MultiOnce - * @testcase.desc : run case CaseSymEncryptSm4CtrKeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CtrKeySize128MultiOnce); - -/** - * @testcase.name : CaseSymEncryptSm4CtrKeySize128MultiMulti - * @testcase.desc : run case CaseSymEncryptSm4CtrKeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CtrKeySize128MultiMulti); - -/** - * @testcase.name : CaseSymEncryptSm4Cfb128KeySize128OnceOnce - * @testcase.desc : run case CaseSymEncryptSm4Cfb128KeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4Cfb128KeySize128OnceOnce); - -/** - * @testcase.name : CaseSymEncryptSm4Cfb128KeySize128OnceMulti - * @testcase.desc : run case CaseSymEncryptSm4Cfb128KeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4Cfb128KeySize128OnceMulti); - -/** - * @testcase.name : CaseSymEncryptSm4Cfb128KeySize128MultiOnce - * @testcase.desc : run case CaseSymEncryptSm4Cfb128KeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4Cfb128KeySize128MultiOnce); - -/** - * @testcase.name : CaseSymEncryptSm4Cfb128KeySize128MultiMulti - * @testcase.desc : run case CaseSymEncryptSm4Cfb128KeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4Cfb128KeySize128MultiMulti); - -/** - * @testcase.name : CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce - * @testcase.desc : run case CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce); - -/** - * @testcase.name : CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti - * @testcase.desc : run case CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti); - -/** - * @testcase.name : CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce - * @testcase.desc : run case CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce); - -/** - * @testcase.name : CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti - * @testcase.desc : run case CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK128N7T32Aad32MultiOnce - * @testcase.desc : run case CaseAEAesCcmK128N7T32Aad32MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N7T32Aad32MultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK128N7T32Aad32MultiMulti - * @testcase.desc : run case CaseAEAesCcmK128N7T32Aad32MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N7T32Aad32MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK128N7T32Aad32update0Multi - * @testcase.desc : run case CaseAEAesCcmK128N7T32Aad32update0Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N7T32Aad32update0Multi); - -/** - * @testcase.name : CaseAEAesCcmK128N7T32Aad32OnceOnce - * @testcase.desc : run case CaseAEAesCcmK128N7T32Aad32OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N7T32Aad32OnceOnce); - -/** - * @testcase.name : CaseAEAesCcmK128N7T32Aad32OnceMulti - * @testcase.desc : run case CaseAEAesCcmK128N7T32Aad32OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N7T32Aad32OnceMulti); - -/** - * @testcase.name : CaseAEAesCcmK192N8T48Aad288MultiOnce - * @testcase.desc : run case CaseAEAesCcmK192N8T48Aad288MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N8T48Aad288MultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK192N8T48Aad288MultiMulti - * @testcase.desc : run case CaseAEAesCcmK192N8T48Aad288MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N8T48Aad288MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK192N8T48Aad288OnceOnce - * @testcase.desc : run case CaseAEAesCcmK192N8T48Aad288OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N8T48Aad288OnceOnce); - -/** - * @testcase.name : CaseAEAesCcmK192N8T48Aad288OnceMulti - * @testcase.desc : run case CaseAEAesCcmK192N8T48Aad288OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N8T48Aad288OnceMulti); - -/** - * @testcase.name : CaseAEAesCcmK256N9T64Aad512MultiOnce - * @testcase.desc : run case CaseAEAesCcmK256N9T64Aad512MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N9T64Aad512MultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK256N9T64Aad512MultiMulti - * @testcase.desc : run case CaseAEAesCcmK256N9T64Aad512MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N9T64Aad512MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK256N13T128Aad512OnceOnce - * @testcase.desc : run case CaseAEAesCcmK256N13T128Aad512OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N13T128Aad512OnceOnce); - -/** - * @testcase.name : CaseAEAesCcmK256N13T128Aad512OnceMulti - * @testcase.desc : run case CaseAEAesCcmK256N13T128Aad512OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N13T128Aad512OnceMulti); - -/** - * @testcase.name : CaseAEAesCcmK128N10T80Aad4MMultiOnce - * @testcase.desc : run case CaseAEAesCcmK128N10T80Aad4MMultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N10T80Aad4MMultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK128N10T80Aad4MMultiMulti - * @testcase.desc : run case CaseAEAesCcmK128N10T80Aad4MMultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N10T80Aad4MMultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK192N11T96Aad32MultiOnce - * @testcase.desc : run case CaseAEAesCcmK192N11T96Aad32MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N11T96Aad32MultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK192N11T96Aad32MultiMulti - * @testcase.desc : run case CaseAEAesCcmK192N11T96Aad32MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N11T96Aad32MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK256N12T112Aad288MultiOnce - * @testcase.desc : run case CaseAEAesCcmK256N12T112Aad288MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N12T112Aad288MultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK256N12T112Aad288MultiMulti - * @testcase.desc : run case CaseAEAesCcmK256N12T112Aad288MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N12T112Aad288MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK128N13T128Aad512MultiOnce - * @testcase.desc : run case CaseAEAesCcmK128N13T128Aad512MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N13T128Aad512MultiOnce); - -/** - * @testcase.name : CaseAEAesCcmK128N13T128Aad512MultiMulti - * @testcase.desc : run case CaseAEAesCcmK128N13T128Aad512MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N13T128Aad512MultiMulti); - -/** - * @testcase.name : CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG - * @testcase.desc : run case CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG); - -/** - * @testcase.name : CaseAEAesCcmK192N8T64NoAadOnce - * @testcase.desc : run case CaseAEAesCcmK192N8T64NoAadOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N8T64NoAadOnce); - -/** - * @testcase.name : CaseAEAesCcmK192N8T64NoAadMulti - * @testcase.desc : run case CaseAEAesCcmK192N8T64NoAadMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK192N8T64NoAadMulti); - -/** - * @testcase.name : CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG - * @testcase.desc : run case CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG); - -/** - * @testcase.name : CaseAEAesGcmK128N7T96Aad32MultiOnce - * @testcase.desc : run case CaseAEAesGcmK128N7T96Aad32MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N7T96Aad32MultiOnce); - -/** - * @testcase.name : CaseAEAesGcmK128N7T96Aad32MultiMulti - * @testcase.desc : run case CaseAEAesGcmK128N7T96Aad32MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N7T96Aad32MultiMulti); - -/** - * @testcase.name : CaseAEAesGcmK128N7T96Aad32update0Multi - * @testcase.desc : run case CaseAEAesGcmK128N7T96Aad32update0Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N7T96Aad32update0Multi); - -/** - * @testcase.name : CaseAEAesGcmK128N7T96Aad32OnceOnce - * @testcase.desc : run case CaseAEAesGcmK128N7T96Aad32OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N7T96Aad32OnceOnce); - -/** - * @testcase.name : CaseAEAesGcmK128N7T96Aad32OnceMulti - * @testcase.desc : run case CaseAEAesGcmK128N7T96Aad32OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N7T96Aad32OnceMulti); - -/** - * @testcase.name : CaseAEAesGcmK192N12T104Aad288MultiOnce - * @testcase.desc : run case CaseAEAesGcmK192N12T104Aad288MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N12T104Aad288MultiOnce); - -/** - * @testcase.name : CaseAEAesGcmK192N12T104Aad288MultiMulti - * @testcase.desc : run case CaseAEAesGcmK192N12T104Aad288MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N12T104Aad288MultiMulti); - -/** - * @testcase.name : CaseAEAesGcmK192N12T104Aad288OnceOnce - * @testcase.desc : run case CaseAEAesGcmK192N12T104Aad288OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N12T104Aad288OnceOnce); - -/** - * @testcase.name : CaseAEAesGcmK192N12T104Aad288OnceMulti - * @testcase.desc : run case CaseAEAesGcmK192N12T104Aad288OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N12T104Aad288OnceMulti); - -/** - * @testcase.name : CaseAEAesGcmK256N7T112Aad512MultiOnce - * @testcase.desc : run case CaseAEAesGcmK256N7T112Aad512MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK256N7T112Aad512MultiOnce); - -/** - * @testcase.name : CaseAEAesGcmK256N7T112Aad512MultiMulti - * @testcase.desc : run case CaseAEAesGcmK256N7T112Aad512MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK256N7T112Aad512MultiMulti); - -/** - * @testcase.name : CaseAEAesGcmK256N7T128Aad512OnceOnce - * @testcase.desc : run case CaseAEAesGcmK256N7T128Aad512OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK256N7T128Aad512OnceOnce); - -/** - * @testcase.name : CaseAEAesGcmK256N7T128Aad512OnceMulti - * @testcase.desc : run case CaseAEAesGcmK256N7T128Aad512OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK256N7T128Aad512OnceMulti); - -/** - * @testcase.name : CaseAEAesGcmK128N12T120Aad4MMultiOnce - * @testcase.desc : run case CaseAEAesGcmK128N12T120Aad4MMultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N12T120Aad4MMultiOnce); - -/** - * @testcase.name : CaseAEAesGcmK128N12T120Aad4MMultiMulti - * @testcase.desc : run case CaseAEAesGcmK128N12T120Aad4MMultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N12T120Aad4MMultiMulti); - -/** - * @testcase.name : CaseAEAesGcmK192N7T128Aad32MultiOnce - * @testcase.desc : run case CaseAEAesGcmK192N7T128Aad32MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N7T128Aad32MultiOnce); - -/** - * @testcase.name : CaseAEAesGcmK192N7T128Aad32MultiMulti - * @testcase.desc : run case CaseAEAesGcmK192N7T128Aad32MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N7T128Aad32MultiMulti); - -/** - * @testcase.name : CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG - * @testcase.desc : run case CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG); - -/** - * @testcase.name : CaseAEAesGcmK192N12T96NoAadOnce - * @testcase.desc : run case CaseAEAesGcmK192N12T96NoAadOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N12T96NoAadOnce); - -/** - * @testcase.name : CaseAEAesGcmK192N12T96NoAadMulti - * @testcase.desc : run case CaseAEAesGcmK192N12T96NoAadMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK192N12T96NoAadMulti); - -/** - * @testcase.name : CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG - * @testcase.desc : run case CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG); - -/** - * @testcase.name : CaseAESM4GcmK128N7T96Aad32MultiOnce - * @testcase.desc : run case CaseAESM4GcmK128N7T96Aad32MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T96Aad32MultiOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N7T96Aad32MultiMulti - * @testcase.desc : run case CaseAESM4GcmK128N7T96Aad32MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T96Aad32MultiMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T96Aad32OnceOnce - * @testcase.desc : run case CaseAESM4GcmK128N7T96Aad32OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T96Aad32OnceOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N7T96Aad32OnceMulti - * @testcase.desc : run case CaseAESM4GcmK128N7T96Aad32OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T96Aad32OnceMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T96Aad32update0Multi - * @testcase.desc : run case CaseAESM4GcmK128N7T96Aad32update0Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T96Aad32update0Multi); - -/** - * @testcase.name : CaseAESM4GcmK128N12T104Aad288MultiOnce - * @testcase.desc : run case CaseAESM4GcmK128N12T104Aad288MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T104Aad288MultiOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N12T104Aad288MultiMulti - * @testcase.desc : run case CaseAESM4GcmK128N12T104Aad288MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T104Aad288MultiMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N12T104Aad288OnceOnce - * @testcase.desc : run case CaseAESM4GcmK128N12T104Aad288OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T104Aad288OnceOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N12T104Aad288OnceMulti - * @testcase.desc : run case CaseAESM4GcmK128N12T104Aad288OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T104Aad288OnceMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T112Aad512MultiOnce - * @testcase.desc : run case CaseAESM4GcmK128N7T112Aad512MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T112Aad512MultiOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N7T112Aad512MultiMulti - * @testcase.desc : run case CaseAESM4GcmK128N7T112Aad512MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T112Aad512MultiMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T128Aad512OnceOnce - * @testcase.desc : run case CaseAESM4GcmK128N7T128Aad512OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T128Aad512OnceOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N7T128Aad512OnceMulti - * @testcase.desc : run case CaseAESM4GcmK128N7T128Aad512OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T128Aad512OnceMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N12T120Aad4MMultiOnce - * @testcase.desc : run case CaseAESM4GcmK128N12T120Aad4MMultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T120Aad4MMultiOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N12T120Aad4MMultiMulti - * @testcase.desc : run case CaseAESM4GcmK128N12T120Aad4MMultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T120Aad4MMultiMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T128Aad32MultiOnce - * @testcase.desc : run case CaseAESM4GcmK128N7T128Aad32MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T128Aad32MultiOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N7T128Aad32MultiMulti - * @testcase.desc : run case CaseAESM4GcmK128N7T128Aad32MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T128Aad32MultiMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG - * @testcase.desc : run case CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG); - -/** - * @testcase.name : CaseAESM4GcmK128N12T96NoAadOnce - * @testcase.desc : run case CaseAESM4GcmK128N12T96NoAadOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T96NoAadOnce); - -/** - * @testcase.name : CaseAESM4GcmK128N12T96NoAadMulti - * @testcase.desc : run case CaseAESM4GcmK128N12T96NoAadMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N12T96NoAadMulti); - -/** - * @testcase.name : CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG - * @testcase.desc : run case CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG); - -/** - * @testcase.name : CaseHmacSha256KeySize64OnceOnce - * @testcase.desc : run case CaseHmacSha256KeySize64OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize64OnceOnce); - -/** - * @testcase.name : CaseHmacSha256KeySize64OnceMulti - * @testcase.desc : run case CaseHmacSha256KeySize64OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize64OnceMulti); - -/** - * @testcase.name : CaseHmacSha256KeySize64MultiOnce - * @testcase.desc : run case CaseHmacSha256KeySize64MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize64MultiOnce); - -/** - * @testcase.name : CaseHmacSha256KeySize64MultiMulti - * @testcase.desc : run case CaseHmacSha256KeySize64MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize64MultiMulti); - -/** - * @testcase.name : CaseHmacSha384KeySize1024OnceOnce - * @testcase.desc : run case CaseHmacSha384KeySize1024OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha384KeySize1024OnceOnce); - -/** - * @testcase.name : CaseHmacSha384KeySize1024OnceMulti - * @testcase.desc : run case CaseHmacSha384KeySize1024OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha384KeySize1024OnceMulti); - -/** - * @testcase.name : CaseHmacSha384KeySize1024MultiOnce - * @testcase.desc : run case CaseHmacSha384KeySize1024MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha384KeySize1024MultiOnce); - -/** - * @testcase.name : CaseHmacSha384KeySize1024MultiMulti - * @testcase.desc : run case CaseHmacSha384KeySize1024MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha384KeySize1024MultiMulti); - -/** - * @testcase.name : CaseHmacSha512KeySize256OnceOnce - * @testcase.desc : run case CaseHmacSha512KeySize256OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha512KeySize256OnceOnce); - -/** - * @testcase.name : CaseHmacSha512KeySize256OnceMulti - * @testcase.desc : run case CaseHmacSha512KeySize256OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha512KeySize256OnceMulti); - -/** - * @testcase.name : CaseHmacSha512KeySize256MultiOnce - * @testcase.desc : run case CaseHmacSha512KeySize256MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha512KeySize256MultiOnce); - -/** - * @testcase.name : CaseHmacSha512KeySize256MultiMulti - * @testcase.desc : run case CaseHmacSha512KeySize256MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha512KeySize256MultiMulti); - -/** - * @testcase.name : CaseHmacSM3KeySize512OnceOnce - * @testcase.desc : run case CaseHmacSM3KeySize512OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSM3KeySize512OnceOnce); - -/** - * @testcase.name : CaseHmacSM3KeySize512OnceMulti - * @testcase.desc : run case CaseHmacSM3KeySize512OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSM3KeySize512OnceMulti); - -/** - * @testcase.name : CaseHmacSM3KeySize512MultiOnce - * @testcase.desc : run case CaseHmacSM3KeySize512MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSM3KeySize512MultiOnce); - -/** - * @testcase.name : CaseHmacSM3KeySize512MultiMulti - * @testcase.desc : run case CaseHmacSM3KeySize512MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSM3KeySize512MultiMulti); - -/** - * @testcase.name : CaseHmacSha256KeySize8192OnceOnce - * @testcase.desc : run case CaseHmacSha256KeySize8192OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize8192OnceOnce); - -/** - * @testcase.name : CaseHmacSha256KeySize8192OnceMulti - * @testcase.desc : run case CaseHmacSha256KeySize8192OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize8192OnceMulti); - -/** - * @testcase.name : CaseHmacSha256KeySize8192MultiOnce - * @testcase.desc : run case CaseHmacSha256KeySize8192MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize8192MultiOnce); - -/** - * @testcase.name : CaseHmacSha256KeySize8192MultiMulti - * @testcase.desc : run case CaseHmacSha256KeySize8192MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseHmacSha256KeySize8192MultiMulti); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize128OnceOnce - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize128OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize128OnceOnce); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize128OnceMulti - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize128OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize128OnceMulti); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize128MultiOnce - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize128MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize128MultiOnce); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize128MultiMulti - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize128MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize128MultiMulti); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize192OnceOnce - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize192OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize192OnceOnce); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize192OnceMulti - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize192OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize192OnceMulti); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize192MultiOnce - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize192MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize192MultiOnce); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize192MultiMulti - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize192MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize192MultiMulti); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize256OnceOnce - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize256OnceOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize256OnceOnce); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize256OnceMulti - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize256OnceMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize256OnceMulti); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize256MultiOnce - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize256MultiOnce - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize256MultiOnce); - -/** - * @testcase.name : CaseCmacAesCbcNopadKeySize256MultiMulti - * @testcase.desc : run case CaseCmacAesCbcNopadKeySize256MultiMulti - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseCmacAesCbcNopadKeySize256MultiMulti); - -/** - * @testcase.name : CaseAsymEncryptRsaV15KeySize512Once - * @testcase.desc : run case CaseAsymEncryptRsaV15KeySize512Once - * @testcase.expect : return is not TEEC_SUCCESS - */ -CRYPTO_TEST_NE(CaseAsymEncryptRsaV15KeySize512Once); - -/** - * @testcase.name : CaseAsymEncryptRsaV15KeySize2048Once - * @testcase.desc : run case CaseAsymEncryptRsaV15KeySize2048Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaV15KeySize2048Once); - -/** - * @testcase.name : CaseAsymEncryptRsaV15KeySize2048Multi - * @testcase.desc : run case CaseAsymEncryptRsaV15KeySize2048Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaV15KeySize2048Multi); - -/** - * @testcase.name : CaseAsymEncryptRsaV15KeySize4096Once - * @testcase.desc : run case CaseAsymEncryptRsaV15KeySize4096Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaV15KeySize4096Once); - -/** - * @testcase.name : CaseAsymEncryptRsaV15KeySize4096Multi - * @testcase.desc : run case CaseAsymEncryptRsaV15KeySize4096Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaV15KeySize4096Multi); - -/** - * @testcase.name : CaseAsymEncryptRsaOaepSha384KeySize2048Once - * @testcase.desc : run case CaseAsymEncryptRsaOaepSha384KeySize2048Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaOaepSha384KeySize2048Once); - -/** - * @testcase.name : CaseAsymEncryptRsaOaepSha384KeySize2048Multi - * @testcase.desc : run case CaseAsymEncryptRsaOaepSha384KeySize2048Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaOaepSha384KeySize2048Multi); - -/** - * @testcase.name : CaseAsymEncryptRsaOaepSha512KeySize4096Once - * @testcase.desc : run case CaseAsymEncryptRsaOaepSha512KeySize4096Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaOaepSha512KeySize4096Once); - -/** - * @testcase.name : CaseAsymEncryptRsaOaepSha512KeySize4096Multi - * @testcase.desc : run case CaseAsymEncryptRsaOaepSha512KeySize4096Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaOaepSha512KeySize4096Multi); - -/** - * @testcase.name : CaseAsymEncryptRsaNopadKeySize2688Once - * @testcase.desc : run case CaseAsymEncryptRsaNopadKeySize2688Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaNopadKeySize2688Once); - -/** - * @testcase.name : CaseAsymEncryptRsaNopadKeySize2688Multi - * @testcase.desc : run case CaseAsymEncryptRsaNopadKeySize2688Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaNopadKeySize2688Multi); - -/** - * @testcase.name : CaseAsymEncryptRsaNopadKeySize4096Once - * @testcase.desc : run case CaseAsymEncryptRsaNopadKeySize4096Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaNopadKeySize4096Once); - -/** - * @testcase.name : CaseAsymEncryptRsaNopadKeySize4096Multi - * @testcase.desc : run case CaseAsymEncryptRsaNopadKeySize4096Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptRsaNopadKeySize4096Multi); - -/** - * @testcase.name : CaseAsymEncryptSm2PkeDataSize64Once - * @testcase.desc : run case CaseAsymEncryptSm2PkeDataSize64Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptSm2PkeDataSize64Once); - -/** - * @testcase.name : CaseAsymEncryptSm2PkeDataSize64Multi - * @testcase.desc : run case CaseAsymEncryptSm2PkeDataSize64Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptSm2PkeDataSize64Multi); - -/** - * @testcase.name : CaseAsymEncryptSm2PkeDataSize470Once - * @testcase.desc : run case CaseAsymEncryptSm2PkeDataSize470Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptSm2PkeDataSize470Once); - -/** - * @testcase.name : CaseAsymEncryptSm2PkeDataSize470Multi - * @testcase.desc : run case CaseAsymEncryptSm2PkeDataSize470Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptSm2PkeDataSize470Multi); - -/** - * @testcase.name : CaseAsymEncryptSm2PkeDataSize1024Once - * @testcase.desc : run case CaseAsymEncryptSm2PkeDataSize1024Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptSm2PkeDataSize1024Once); - -/** - * @testcase.name : CaseAsymEncryptSm2PkeDataSize1024Multi - * @testcase.desc : run case CaseAsymEncryptSm2PkeDataSize1024Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymEncryptSm2PkeDataSize1024Multi); - -/** - * @testcase.name : CaseAsymSignRsaV15Sha384KeySize2048Once - * @testcase.desc : run case CaseAsymSignRsaV15Sha384KeySize2048Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaV15Sha384KeySize2048Once); - -/** - * @testcase.name : CaseAsymSignRsaV15Sha384KeySize2048Multi - * @testcase.desc : run case CaseAsymSignRsaV15Sha384KeySize2048Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaV15Sha384KeySize2048Multi); - -/** - * @testcase.name : CaseAsymSignRsaV15Sha512KeySize4096Once - * @testcase.desc : run case CaseAsymSignRsaV15Sha512KeySize4096Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaV15Sha512KeySize4096Once); - -/** - * @testcase.name : CaseAsymSignRsaV15Sha512KeySize4096Multi - * @testcase.desc : run case CaseAsymSignRsaV15Sha512KeySize4096Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaV15Sha512KeySize4096Multi); - -/** - * @testcase.name : CaseAsymSignRsaPssSha384KeySize2048Once - * @testcase.desc : run case CaseAsymSignRsaPssSha384KeySize2048Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaPssSha384KeySize2048Once); - -/** - * @testcase.name : CaseAsymSignRsaPssSha384KeySize2048Multi - * @testcase.desc : run case CaseAsymSignRsaPssSha384KeySize2048Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaPssSha384KeySize2048Multi); - -/** - * @testcase.name : CaseAsymSignRsaPssSha512KeySize4096Once - * @testcase.desc : run case CaseAsymSignRsaPssSha512KeySize4096Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaPssSha512KeySize4096Once); - -/** - * @testcase.name : CaseAsymSignRsaPssSha512KeySize4096Multi - * @testcase.desc : run case CaseAsymSignRsaPssSha512KeySize4096Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignRsaPssSha512KeySize4096Multi); - -/** - * @testcase.name : CaseAsymSignEcdsaSha256KeySize256Once - * @testcase.desc : run case CaseAsymSignEcdsaSha256KeySize256Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEcdsaSha256KeySize256Once); - -/** - * @testcase.name : CaseAsymSignEcdsaSha256KeySize256Multi - * @testcase.desc : run case CaseAsymSignEcdsaSha256KeySize256Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEcdsaSha256KeySize256Multi); - -/** - * @testcase.name : CaseAsymSignEcdsaSha384KeySize384Once - * @testcase.desc : run case CaseAsymSignEcdsaSha384KeySize384Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEcdsaSha384KeySize384Once); - -/** - * @testcase.name : CaseAsymSignEcdsaSha384KeySize384Multi - * @testcase.desc : run case CaseAsymSignEcdsaSha384KeySize384Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEcdsaSha384KeySize384Multi); - -/** - * @testcase.name : CaseAsymSignEcdsaSha512KeySize521Once - * @testcase.desc : run case CaseAsymSignEcdsaSha512KeySize521Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEcdsaSha512KeySize521Once); - -/** - * @testcase.name : CaseAsymSignEcdsaSha512KeySize521Multi - * @testcase.desc : run case CaseAsymSignEcdsaSha512KeySize521Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEcdsaSha512KeySize521Multi); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize64Once - * @testcase.desc : run case CaseAsymSignEd25519DataSize64Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize64Once); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize64Multi - * @testcase.desc : run case CaseAsymSignEd25519DataSize64Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize64Multi); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize470Once - * @testcase.desc : run case CaseAsymSignEd25519DataSize470Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize470Once); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize470Multi - * @testcase.desc : run case CaseAsymSignEd25519DataSize470Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize470Multi); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize1270Once - * @testcase.desc : run case CaseAsymSignEd25519DataSize1270Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize1270Once); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize1270Multi - * @testcase.desc : run case CaseAsymSignEd25519DataSize1270Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize1270Multi); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize4096Once - * @testcase.desc : run case CaseAsymSignEd25519DataSize4096Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize4096Once); - -/** - * @testcase.name : CaseAsymSignEd25519DataSize4096Multi - * @testcase.desc : run case CaseAsymSignEd25519DataSize4096Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignEd25519DataSize4096Multi); - -/** - * @testcase.name : CaseAsymSignSm2DsaSm3DataSize32Once - * @testcase.desc : run case CaseAsymSignSm2DsaSm3DataSize32Once - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignSm2DsaSm3DataSize32Once); - -/** - * @testcase.name : CaseAsymSignSm2DsaSm3DataSize32Multi - * @testcase.desc : run case CaseAsymSignSm2DsaSm3DataSize32Multi - * @testcase.expect : return TEEC_SUCCESS - */ -CRYPTO_TEST_EQ(CaseAsymSignSm2DsaSm3DataSize32Multi); - -/** - * @testcase.name : CaseAsymSignSm2DsaSm3DataSize128Once - * @testcase.desc : run case CaseAsymSignSm2DsaSm3DataSize128Once - * @testcase.expect : return is not TEEC_SUCCESS - */ -CRYPTO_TEST_NE(CaseAsymSignSm2DsaSm3DataSize128Once); \ No newline at end of file diff --git a/test/xts/ca/libc_api/CMakeLists.txt b/test/xts/ca/libc_api/CMakeLists.txt deleted file mode 100644 index 148a99b6..00000000 --- a/test/xts/ca/libc_api/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2023 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(ca_sources) -list(APPEND ca_sources - src/tee_test_libc_api.cpp -) - -ca_compile_pub( - TEST_NAME - libc_api - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - common - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ca/libc_api/common/common_test.h b/test/xts/ca/libc_api/common/common_test.h deleted file mode 100644 index c6f6d3b9..00000000 --- a/test/xts/ca/libc_api/common/common_test.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __LIBC_COMMON_TEST_H__ -#define __LIBC_COMMON_TEST_H__ - -#include -#include - -using namespace testing::ext; - -#define LIBC_API_UUID \ - { \ - 0x534d4152, 0x542d, 0x4353, \ - { \ - 0x4c, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x0c \ - } \ - } - -enum LibcCmdId { - CMD_TEST_PTHREAD_ATTR = 0, - CMD_TEST_PTHREAD_BASE_FUNC, - CMD_TEST_PTHREAD_MUTEX_LOCK, - CMD_TEST_PTHREAD_SPIN_LOCK, - CMD_TEST_PTHREAD_COND, - CMD_TEST_SEM, - CMD_TEST_APPLY_AND_FREE_MEM, - CMD_TEST_MMAP_AND_MUNMAP, - CMD_TEST_LIBC_MATH, - CMD_TEST_LIBC_STDLIB, - CMD_TEST_LIBC_CTYPE, - CMD_TEST_LIBC_TIME, - CMD_TEST_LIBC_STDIO, - CMD_TEST_LIBC_ERROR, - CMD_TEST_LIBC_UNISTD, - CMD_TEST_LIBC_LOCALE, - CMD_TEST_LIBC_MULTIBYTE, - CMD_TEST_LIBC_PRNG, - CMD_TEST_LIBC_STRING, -}; - -#endif diff --git a/test/xts/ca/libc_api/src/tee_test_libc_api.cpp b/test/xts/ca/libc_api/src/tee_test_libc_api.cpp deleted file mode 100644 index cb1dbaee..00000000 --- a/test/xts/ca/libc_api/src/tee_test_libc_api.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -/** - * @testcase.name : CasePthreadAttr - * @testcase.desc : run case CasePthreadAttr - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CasePthreadAttr, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_ATTR, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CasePthreadBaseFunc - * @testcase.desc : run case CasePthreadBaseFunc - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CasePthreadBaseFunc, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_BASE_FUNC, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CasePthreadMutexLock - * @testcase.desc : run case CasePthreadMutexLock - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CasePthreadMutexLock, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_MUTEX_LOCK, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CasePthreadSpinLock - * @testcase.desc : run case CasePthreadSpinLock - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CasePthreadSpinLock, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_SPIN_LOCK, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CasePthreadCond - * @testcase.desc : run case CasePthreadCond - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CasePthreadCond, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_PTHREAD_COND, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseSem - * @testcase.desc : run case CaseSem - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseSem, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_SEM, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseApplyAndFreeMem - * @testcase.desc : run case CaseApplyAndFreeMem - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseApplyAndFreeMem, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_APPLY_AND_FREE_MEM, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseMmapAndMunmap - * @testcase.desc : run case CaseMmapAndMunmap - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseMmapAndMunmap, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_MMAP_AND_MUNMAP, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcMath - * @testcase.desc : run case CaseLibcMath - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcMath, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_MATH, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcStdlib - * @testcase.desc : run case CaseLibcStdlib - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcStdlib, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_STDLIB, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcCtype - * @testcase.desc : run case CaseLibcCtype - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcCtype, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_CTYPE, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcTime - * @testcase.desc : run case CaseLibcTime - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcTime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_TIME, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcStdio - * @testcase.desc : run case CaseLibcStdio - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcStdio, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_STDIO, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcError - * @testcase.desc : run case CaseLibcError - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcError, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_ERROR, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcUnistd - * @testcase.desc : run case CaseLibcUnistd - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcUnistd, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_UNISTD, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcLocale - * @testcase.desc : run case CaseLibcLocale - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcLocale, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_LOCALE, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcMultiByte - * @testcase.desc : run case CaseLibcMultiByte - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcMultiByte, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_MULTIBYTE, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcPrng - * @testcase.desc : run case CaseLibcPrng - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcPrng, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_PRNG, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : CaseLibcString - * @testcase.desc : run case CaseLibcString - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, CaseLibcString, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = LIBC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_TEST_LIBC_STRING, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/CMakeLists.txt b/test/xts/ca/tcf_api/CMakeLists.txt deleted file mode 100644 index 03aa5157..00000000 --- a/test/xts/ca/tcf_api/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -MESSAGE( STATUS "__ANDROID_API__ = ${__ANDROID_API__}.") - -set(ca_sources) -list(APPEND ca_sources - src/common_test.cpp - src/property/get_prop_as_string_test.cpp - src/property/get_prop_as_bool_test.cpp - src/property/get_prop_as_u32_test.cpp - src/property/get_prop_as_u64_test.cpp - src/property/get_prop_as_binaryblock_test.cpp - src/property/get_prop_as_uuid_test.cpp - src/property/get_prop_as_identity_test.cpp - src/property/get_prop_with_enumerator_test.cpp - src/mem/tee_malloc_test.cpp - src/mem/tee_realloc_test.cpp - src/mem/tee_memmove_test.cpp - src/mem/tee_memfill_test.cpp - src/mem/tee_free_test.cpp - src/mem/tee_memcompare_test.cpp - src/mem/tee_checkmemaccessrights_test.cpp - src/mem/tee_instance_test.cpp - src/other/internal_client_api_test.cpp - src/other/tee_panic_test.cpp -) - -ca_compile_pub( - TEST_NAME - tcf_api - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - common - - COMPILE_OPTS - COMPILE_DEFS -) - diff --git a/test/xts/ca/tcf_api/common/common_test.h b/test/xts/ca/tcf_api/common/common_test.h deleted file mode 100644 index 278e9156..00000000 --- a/test/xts/ca/tcf_api/common/common_test.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TCF_COMMON_TEST_H__ -#define __TCF_COMMON_TEST_H__ - -#include -#include -#include - -#define TESTSIZE 16 -#define BIG_SIZE 1024 -#define MAX_SHARE_SIZE 0x100000 - -#define ENUMERATOR1 1 -#define MAX_ENUMERATOR 1023 - -#define EXPECTBUFFER_ZERO "" -#define EXPECTBUFFER_A "AAAAAAAAAAAAAAAA" -#define EXPECTBUFFER_A_LESS "AAAAAAAAAAAAAAA" -#define EXPECTBUFFER_B "BBBBBBBBBBBBBBBB" -#define EXPECTBUFFER_OVERLAP "AAAAAAAAABBBBBBB" - -// ALL_PROPERTY_NAMES -#define GPD_CLIENT_IDENTITY "gpd.client.identity" -#define GPD_CLIENT_ENDIAN "gpd.client.endian" -#define GPD_TA_APPID "gpd.ta.appID" -#define GPD_TA_SERVICENAME "gpd.ta.service_name" -#define GPD_TA_DATASIZE "gpd.ta.dataSize" -#define GPD_TA_INSTANCEKEEPALIVE "gpd.ta.instanceKeepAlive" -#define GPD_TA_MULTISESSION "gpd.ta.multiSession" -#define GPD_TA_SINGLEINSTANCE "gpd.ta.singleInstance" -#define GPD_TA_STACKSIZE "gpd.ta.stackSize" -#define GPD_TA_VERSION "gpd.ta.version" -#define GPD_TA_DESCRIPTION "gpd.ta.description" -#define GPD_TA_ENDIAN "gpd.ta.endian" -#define GPD_TEE_ARITH_MAXBIGINTSIZE "gpd.tee.arith.maxBigIntSize" -#define GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL "gpd.tee.systemTime.protectionLevel" -#define GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL "gpd.tee.TAPersistentTime.protectionLevel" -#define GPD_TEE_APIVERSION "gpd.tee.apiversion" -#define GPD_TEE_INTERNALCORE_VERSION "gpd.tee.internalCore.version" -#define GPD_TEE_DESCRIPTION "gpd.tee.description" -#define GPD_TEE_DEVICEID "gpd.tee.deviceID" -#define GPD_TEE_CRYPTOGRAPHY_ECC "gpd.tee.cryptography.ecc" -#define GPD_TEE_CRYPTOGRAPHY_NIST "gpd.tee.cryptography.nist" -#define GPD_TEE_CRYPTOGRAPHY_BSI_R "gpd.tee.cryptography.bsi-r" -#define GPD_TEE_CRYPTOGRAPHY_BSI_T "gpd.tee.cryptography.bsi-t" -#define GPD_TEE_CRYPTOGRAPHY_IETF "gpd.tee.cryptography.ietf" -#define GPD_TEE_CRYPTOGRAPHY_OCTA "gpd.tee.cryptography.octa" -#define GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL "gpd.tee.trustedStorage.antiRollback.protectionLevel" -#define GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL "gpd.tee.trustedStorage.rollbackDetection.protectionLevel" -#define GPD_TEE_TRUSTEDOS_IMP_VERSION "gpd.tee.trustedos.implementation.version" -#define GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION "gpd.tee.trustedos.implementation.binaryversion" -#define GPD_TEE_TRUSTEDOS_MANUFACTURER "gpd.tee.trustedos.manufacturer" -#define GPD_TEE_FIRMWARE_IMP_VERSION "gpd.tee.firmware.implementation.version" -#define GPD_TEE_FIRMWARE_IMP_BINARYVERSION "gpd.tee.firmware.implementation.binaryversion" -#define GPD_TEE_FIRMWARE_MANUFACTURER "gpd.tee.firmware.manufacturer" -#define GPD_TEE_EVENT_MAXSOURCES "gpd.tee.event.maxSources" -#define GPD_TEE_API_LEVEL "gpd.tee.api_level" -#define PROPERTY_NAME_UNKNOWN "unknown" -#define SMC_TA_TESTBINARYBLOCK "smc.ta.testbinaryblock" -#define SMC_TA_TESTIDENTITY "smc.ta.identity" -#define SMC_TA_TESTU64 "smc.ta.testu64" - -// ALL_PROPERTY_VALUES -#define VALUE_PREDEFINED_BINARY_BLOCK "VGhpcy" -#define VALUE_PREDEFINED_SERVICENAME "TCF_test" -#define VALUE_PREDEFINED_BOOLEAN "true" -#define VALUE_PREDEFINED_FALSE "false" -#define VALUE_PREDEFINED_DATASIZE 819200 -#define VALUE_PREDEFINED_STACKSIZE 81920 -#define VALUE_PREDEFINED_TA_VERSION "0" -#define VALUE_PREDEFINED_TA_DESCRIPTION "test ta" -#define VALUE_PREDEFINED_CLIENT_IDENTITY "identity:0:00000000-0000-0000-6100-000000000000" -#define VALUE_PREDEFINED_CLIENT_ENDIAN 0 -#define VALUE_PREDEFINED_STRING "test string" -#define VALUE_PREDEFINED_U64 5147483647 -#define VALUE_PREDEFINED_UUID "534d4152-542d-4353-4c54-d3016a171f01" - -#define TEE_INTERNAL_CORE_MAJOR_VERSION 1 -#define TEE_INTERNAL_CORE_MINOR_VERSION 2 -#define TEE_INTERNAL_CORE_MAINTENANCE_VERSION 0 -#define TEE_INTERNAL_CORE_RESERVED_VERSION 0 -// TEE_API_VERSION should match with TEE_INTERNAL_CORE_VERSION -#define TEE_API_VERSION "v1.2.0" -#define TEE_INTERNAL_CORE_VERSION \ - ((TEE_INTERNAL_CORE_MAJOR_VERSION << 24) | (TEE_INTERNAL_CORE_MINOR_VERSION << 16) | \ - (TEE_INTERNAL_CORE_MAINTENANCE_VERSION << 8) | TEE_INTERNAL_CORE_RESERVED_VERSION) -#define TEE_BUILD_VER "B309" -#define TEE_IMP_VERSION "TEE-1.0.0" -#define TEE_MANUFACTURER "TEE" -#define TEE_FIRMWARE_IMP_VERSION "ATF-1.5" -#define TEE_FIRMWARE_MANUFACTURER "TEE" -#define TEE_TIME_PROTECT_LEVEL 100 -#define TA_TIME_PROTECT_LEVEL 100 -#define MAX_BIG_INT_SIZE 32 -#define API_LEVEL1_2 3 -#define CIPHER_LAYER_VERSION 3 -#define TEE_MAX_API_LEVEL_CONFIG ((CIPHER_LAYER_VERSION << 16) | API_LEVEL1_2) - -typedef enum { - TEE_PROPSET_CURRENT_CLIENT = 0xFFFFFFFE, - TEE_PROPSET_CURRENT_TA = 0xFFFFFFFF, - TEE_PROPSET_IMPLEMENTATION = 0xFFFFFFFD, - TEE_PROPSET_ZERO = 0x0, -} ALL_PROP_SETS; - -typedef struct { - uint32_t login; - TEEC_UUID uuid; -} TEEC_Identity; - -#define TCF_API_UUID_1 \ - { \ - 0x534d4152, 0x542d, 0x4353, \ - { \ - 0x4c, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x01 \ - } \ - } - -#define TCF_API_UUID_2 \ - { \ - 0x534D4152, 0x542D, 0x4353, \ - { \ - 0x4C, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x02 \ - } \ - } - -#define UUID_TA_NOT_EXIST \ - { \ - 0x534D4152, 0x542D, 0x4353, \ - { \ - 0x4C, 0x54, 0x2D, 0x54, 0x41, 0x2D, 0x53, 0x5B \ - } \ - } - -struct TestData { - uint32_t cmd; - uint32_t caseId; - ALL_PROP_SETS propSet; - uint32_t enumerator; - uint32_t origin; - char inBuffer[BIG_SIZE]; - uint32_t inBufferLen; - char outBuffer[BIG_SIZE]; - uint32_t outBufferLen; - TEEC_UUID uuid; -}; -typedef struct TestData TestData; - -struct TestMemData { - size_t oldSize; - size_t newSize; - uint32_t oldAddr; - uint32_t newAddr; - uint32_t caseId; - uint32_t origin; - uint32_t accessFlags; - size_t inMemSize; - uint32_t inHint; - char *testBuffer; -}; -typedef struct TestMemData TestMemData; - -typedef enum { - HINT_RESERVE = 0x80000000, - TEE_MALLOC_FILL_ZERO = 0, - TEE_MALLOC_NO_FILL = 1, - TEE_MALLOC_NO_SHARE = 2, -} ALL_MEMORY_HINTS; - -#define TEE_MEMORY_ACCESS_READ 0x00000001 -#define TEE_MEMORY_ACCESS_WRITE 0x00000002 -#define TEE_MEMORY_ACCESS_ANY_OWNER 0x00000004 - -class TCF1Test : public ::testing::Test { -private: - static TEEC_Context context; - static TEEC_Session session; - -public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} - - TEEC_Context *GetContext() - { - return &TCF1Test::context; - } - TEEC_Session *GetSession() - { - return &TCF1Test::session; - } - void SetUp(); - void TearDown(); -}; - -class TCF2Test : public ::testing::Test { -private: - static TEEC_Context context; - static TEEC_Session session; - -public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} - - TEEC_Context *GetContext() - { - return &TCF2Test::context; - } - TEEC_Session *GetSession() - { - return &TCF2Test::session; - } - void SetUp(); - void TearDown(); -}; - -class TCF2TA2TATest : public ::testing::Test { -private: - static TEEC_Context context; - static TEEC_Session session; - static TEEC_Session session2; - -public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} - - TEEC_Context *GetContext() - { - return &TCF2TA2TATest::context; - } - TEEC_Session *GetSession() - { - return &TCF2TA2TATest::session; - } - TEEC_Session *GetSession2() - { - return &TCF2TA2TATest::session2; - } - void SetUp(); - void TearDown(); -}; - -class TCF1ENUM_Test : public ::testing::Test { -private: - static TEEC_Context context; - static TEEC_Session session; - -public: - TestData value = { 0 }; - static void SetUpTestCase(); - static void TearDownTestCase(); - - TEEC_Context *GetContext() - { - return &TCF1ENUM_Test::context; - } - TEEC_Session *GetSession() - { - return &TCF1ENUM_Test::session; - } - - void SetUp(); - void TearDown(); -}; - -TEEC_Result Invoke_GetPropertyAsX(TEEC_Context *context, TEEC_Session *session, TestData *testData); -TEEC_Result Invoke_AllocatePropertyEnumerator(TEEC_Session *session, TestData *testData); -TEEC_Result Invoke_Operate_PropertyEnumerator(TEEC_Session *session, TestData *testData); -TEEC_Result Invoke_Malloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, uint32_t *origin); -TEEC_Result Invoke_Realloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output); -TEEC_Result Invoke_MemMove_Or_Fill(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output); -TEEC_Result Invoke_Free(TEEC_Session *session, uint32_t commandID, uint32_t caseNum, uint32_t *origin); -TEEC_Result Invoke_MemCompare(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *buffer1, - char *buffer2); -TEEC_Result Invoke_CheckMemoryAccessRights(TEEC_Session *session, uint32_t commandID, TestMemData *testData); -TEEC_Result Invoke_SetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t caseNum, - uint32_t *origin); -TEEC_Result Invoke_GetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t *bufSize, - uint32_t *origin); -TEEC_Result Invoke_OpenTASession(TEEC_Session *session, uint32_t commandID, uint32_t *ta2taSession, - TestData *testData, uint32_t *origin); -TEEC_Result Invoke_CloseTASession(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession, - uint32_t *origin); -TEEC_Result Invoke_InvokeTACommand(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession, - TestData *testData, uint32_t *origin); -TEEC_Result Invoke_Panic(TEEC_Session *session, uint32_t commandID, TEEC_Result panicCode, uint32_t *origin); -uint32_t get_ta_data_size(TEEC_Context *context, TEEC_Session *session); -uint32_t get_ta_stack_size(TEEC_Context *context, TEEC_Session *session); -#endif diff --git a/test/xts/ca/tcf_api/src/common_test.cpp b/test/xts/ca/tcf_api/src/common_test.cpp deleted file mode 100644 index 64a09139..00000000 --- a/test/xts/ca/tcf_api/src/common_test.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -TEEC_Context TCF1Test::context = { 0 }; -TEEC_Session TCF1Test::session = { 0 }; - -void TCF1Test::SetUp() -{ - TEEC_Operation operation = { 0 }; - TEEC_Result ret = TEEC_InitializeContext(NULL, &context); - ABORT_UNLESS(ret != TEEC_SUCCESS); - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - TEEC_UUID uuid = TCF_API_UUID_1; - - ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL); - ABORT_UNLESS(ret != TEEC_SUCCESS); -} - -void TCF1Test::TearDown() -{ - TEEC_CloseSession(&session); - TEEC_FinalizeContext(&context); -} - -TEEC_Context TCF2Test::context = { 0 }; -TEEC_Session TCF2Test::session = { 0 }; - -void TCF2Test::SetUp() -{ - TEEC_Operation operation = { 0 }; - - TEEC_Result ret = TEEC_InitializeContext(NULL, &context); - ABORT_UNLESS(ret != TEEC_SUCCESS); - - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - - TEEC_UUID uuid = TCF_API_UUID_2; - ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL); - ABORT_UNLESS(ret != TEEC_SUCCESS); -} - -void TCF2Test::TearDown() -{ - TEEC_CloseSession(&session); - TEEC_FinalizeContext(&context); -} - -TEEC_Context TCF2TA2TATest::context = { 0 }; -TEEC_Session TCF2TA2TATest::session = { 0 }; -TEEC_Session TCF2TA2TATest::session2 = { 0 }; - -void TCF2TA2TATest::SetUp() -{ - TEEC_Operation operation = { 0 }; - - TEEC_Result ret = TEEC_InitializeContext(NULL, &context); - ABORT_UNLESS(ret != TEEC_SUCCESS); - - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - - TEEC_UUID uuid2 = TCF_API_UUID_1; // this is TA2 UUID - ret = TEEC_OpenSession(&context, &session2, &uuid2, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL); - ABORT_UNLESS(ret != TEEC_SUCCESS); - - TEEC_UUID uuid = TCF_API_UUID_2; // this is TA1 UUID - ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL); - ABORT_UNLESS(ret != TEEC_SUCCESS); -} - -void TCF2TA2TATest::TearDown() -{ - TEEC_CloseSession(&session); - TEEC_CloseSession(&session2); - TEEC_FinalizeContext(&context); -} - -TEEC_Context TCF1ENUM_Test::context = { 0 }; -TEEC_Session TCF1ENUM_Test::session = { 0 }; - -void TCF1ENUM_Test::SetUpTestCase() -{ - TEEC_Operation operation = { 0 }; - - TEEC_Result ret = TEEC_InitializeContext(NULL, &context); - ABORT_UNLESS(ret != TEEC_SUCCESS); - - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - - TEEC_UUID uuid = TCF_API_UUID_1; - ret = TEEC_OpenSession(&context, &session, &uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL); - ABORT_UNLESS(ret != TEEC_SUCCESS); -} - -void TCF1ENUM_Test::TearDownTestCase() -{ - TEEC_CloseSession(&session); - TEEC_FinalizeContext(&context); -} - -void TCF1ENUM_Test::SetUp() -{ - TEEC_Result ret; - - // alloc PropertyEnumerator - value.cmd = CMD_TEE_AllocatePropertyEnumerator; - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ABORT_UNLESS(ret != TEEC_SUCCESS); -} - -void TCF1ENUM_Test::TearDown() -{ - value.cmd = CMD_TEE_FreePropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); -} - -TEEC_Result Invoke_GetPropertyAsX(TEEC_Context *context, TEEC_Session *session, TestData *testData) -{ - TEEC_Result result = TEEC_FAIL; - int rc; - TEEC_Operation operation = { 0 }; - TEEC_SharedMemory shareMemInput, shareMemOutput; - - // allocate the share memorys - shareMemInput.size = BIG_SIZE; - shareMemInput.flags = TEEC_MEM_INOUT; - result = TEEC_AllocateSharedMemory(context, &shareMemInput); - if (result != TEEC_SUCCESS) { - TEST_PRINT_ERROR("alloc shareMemInput fail!\n"); - return TEEC_FAIL; - } - - shareMemOutput.size = BIG_SIZE; - shareMemOutput.flags = TEEC_MEM_INOUT; - result = TEEC_AllocateSharedMemory(context, &shareMemOutput); - if (result != TEEC_SUCCESS) { - TEST_PRINT_ERROR("alloc shareMemOutput fail!\n"); - TEEC_ReleaseSharedMemory(&shareMemInput); - return TEEC_FAIL; - } - - // Invoke command - operation.started = 1; - operation.paramTypes = - TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_PARTIAL_INPUT, TEEC_MEMREF_PARTIAL_OUTPUT, TEEC_NONE); - if (testData->enumerator != 0) - operation.params[0].value.a = testData->enumerator; - else - operation.params[0].value.a = testData->propSet; - - operation.params[0].value.b = testData->caseId; - (void)memset_s(shareMemInput.buffer, BIG_SIZE, 0, BIG_SIZE); - rc = memcpy_s(shareMemInput.buffer, shareMemInput.size, testData->inBuffer, testData->inBufferLen); - if (rc != TEEC_SUCCESS) { - TEST_PRINT_ERROR("memcpy_s inBuffer to shareMemInput fail!\n"); - goto clean; - } - - operation.params[1].memref.parent = &shareMemInput; - operation.params[1].memref.size = shareMemInput.size; - operation.params[1].memref.offset = 0; - operation.params[2].memref.parent = &shareMemOutput; - operation.params[2].memref.size = shareMemOutput.size; - operation.params[2].memref.offset = 0; - - result = TEEC_InvokeCommand(session, testData->cmd, &operation, &testData->origin); - testData->outBufferLen = operation.params[2].memref.size; - rc = memcpy_s(testData->outBuffer, BIG_SIZE, shareMemOutput.buffer, testData->outBufferLen); - if (rc != TEEC_SUCCESS) { - TEST_PRINT_ERROR("memcpy_s shareMemOutput to outBuffer fail! rc = 0x%x\n", rc); - } - -clean: - TEEC_ReleaseSharedMemory(&shareMemInput); - TEEC_ReleaseSharedMemory(&shareMemOutput); - return result; -} - -TEEC_Result Invoke_AllocatePropertyEnumerator(TEEC_Session *session, TestData *testData) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = 0; - operation.params[0].value.b = testData->caseId; - result = TEEC_InvokeCommand(session, testData->cmd, &operation, &testData->origin); - - testData->enumerator = operation.params[0].value.a; - return result; -} - -TEEC_Result Invoke_Operate_PropertyEnumerator(TEEC_Session *session, TestData *testData) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - // Invoke command - operation.started = 1; - switch (testData->cmd) { - case CMD_TEE_FreePropertyEnumerator: - case CMD_TEE_ResetPropertyEnumerator: - case CMD_TEE_GetNextPropertyEnumerator: - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = testData->enumerator; - operation.params[0].value.b = testData->cmd; - break; - case CMD_TEE_StartPropertyEnumerator: - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = testData->enumerator; - operation.params[1].value.a = testData->propSet; - break; - case CMD_TEE_GetPropertyNameEnumerator: - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = testData->enumerator; - operation.params[0].value.b = testData->caseId; - operation.params[1].tmpref.buffer = testData->outBuffer; - operation.params[1].tmpref.size = testData->outBufferLen; - break; - default: - TEST_PRINT_ERROR("not support this test command! cmdId: 0x%x", testData->cmd); - return TEEC_FAIL; - } - - result = TEEC_InvokeCommand(session, testData->cmd, &operation, &testData->origin); - if (testData->cmd == CMD_TEE_GetPropertyNameEnumerator) - testData->outBufferLen = operation.params[1].tmpref.size; - - return result; -} - -TEEC_Result Invoke_Malloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, uint32_t *origin) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = testData->inMemSize; - operation.params[0].value.b = testData->inHint; - operation.params[1].tmpref.buffer = testData->testBuffer; - operation.params[1].tmpref.size = MAX_SHARE_SIZE; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - return result; -} - -TEEC_Result Invoke_Realloc(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - char *buffer = NULL; - uint32_t bufSize = testData->oldSize > testData->newSize ? testData->oldSize : testData->newSize; - - if (bufSize > MAX_SHARE_SIZE) - bufSize = TESTSIZE; - - buffer = reinterpret_cast(malloc(bufSize)); - if (buffer == NULL) { - TEST_PRINT_ERROR("malloc buffer fail!\n"); - return TEEC_FAIL; - } - - // Invoke command - operation.started = 1; - operation.paramTypes = - TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_VALUE_OUTPUT, TEEC_VALUE_INPUT); - operation.params[0].value.a = testData->oldSize; - operation.params[0].value.b = testData->newSize; - operation.params[1].tmpref.buffer = buffer; - operation.params[1].tmpref.size = bufSize; - operation.params[3].value.a = testData->caseId; - - result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin); - testData->oldAddr = operation.params[2].value.a; - testData->newAddr = operation.params[2].value.b; - int rc = memcpy_s(output, bufSize, buffer, operation.params[1].tmpref.size); - if (rc != 0) { - TEST_PRINT_ERROR("memcpy_s output failed, rc=0x%x\n", rc); - return TEEC_FAIL; - } - - free(buffer); - return result; -} - -TEEC_Result Invoke_MemMove_Or_Fill(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *output) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - char *buffer = NULL; - uint32_t bufSize = testData->oldSize; - buffer = reinterpret_cast(malloc(bufSize)); - if (buffer == NULL) { - TEST_PRINT_ERROR("malloc buffer fail!\n"); - return TEEC_FAIL; - } - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = testData->oldSize; - operation.params[0].value.b = testData->caseId; - operation.params[1].tmpref.buffer = buffer; - operation.params[1].tmpref.size = bufSize; - - result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin); - int rc = memcpy_s(output, testData->oldSize, buffer, operation.params[1].tmpref.size); - if (rc != 0) { - TEST_PRINT_ERROR("memcpy_s uuid to tee failed, rc=0x%x\n", rc); - return TEEC_FAIL; - } - free(buffer); - return result; -} - -TEEC_Result Invoke_Free(TEEC_Session *session, uint32_t commandID, uint32_t caseNum, uint32_t *origin) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = caseNum; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - return result; -} - -TEEC_Result Invoke_MemCompare(TEEC_Session *session, uint32_t commandID, TestMemData *testData, char *buffer1, - char *buffer2) -{ - TEEC_Result result = TEEC_SUCCESS; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = - TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE); - operation.params[0].value.a = testData->oldSize; - operation.params[0].value.b = testData->caseId; - operation.params[1].tmpref.buffer = buffer1; - operation.params[1].tmpref.size = testData->oldSize > 0 ? testData->oldSize : TESTSIZE; - operation.params[2].tmpref.buffer = buffer2; - operation.params[2].tmpref.size = testData->oldSize > 0 ? testData->oldSize : TESTSIZE; - - result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin); - return result; -} - -TEEC_Result Invoke_CheckMemoryAccessRights(TEEC_Session *session, uint32_t commandID, TestMemData *testData) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - char *buffer = NULL; - uint32_t bufSize = testData->oldSize; - buffer = reinterpret_cast(malloc(bufSize)); - if (buffer == NULL) { - TEST_PRINT_ERROR("malloc buffer fail!\n"); - return TEEC_FAIL; - } - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_OUTPUT, TEEC_VALUE_INPUT, TEEC_NONE); - operation.params[0].value.a = testData->accessFlags; - operation.params[0].value.b = testData->oldSize; - operation.params[1].tmpref.buffer = buffer; - operation.params[1].tmpref.size = bufSize; - operation.params[2].value.a = testData->caseId; - - result = TEEC_InvokeCommand(session, commandID, &operation, &testData->origin); - free(buffer); - return result; -} - -TEEC_Result Invoke_SetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t caseNum, - uint32_t *origin) -{ - TEEC_Result result = TEEC_SUCCESS; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = caseNum; - operation.params[1].tmpref.buffer = buffer; - operation.params[1].tmpref.size = strlen(buffer) + 1; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - return result; -} - -TEEC_Result Invoke_GetInstanceData(TEEC_Session *session, uint32_t commandID, char *buffer, uint32_t *bufSize, - uint32_t *origin) -{ - TEEC_Result result = TEEC_SUCCESS; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE); - operation.params[0].tmpref.buffer = buffer; - operation.params[0].tmpref.size = *bufSize; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - *bufSize = operation.params[0].tmpref.size; - return result; -} - -static void retrieveUint32toBuffer(uint8_t *buffer, uint32_t i) -{ - buffer[3] = i & 0xff; - buffer[2] = (i >> 8) & 0xff; - buffer[1] = (i >> 16) & 0xff; - buffer[0] = (i >> 24) & 0xff; -} - -static void retrieveUint16toBuffer(uint8_t *buffer, uint16_t i) -{ - buffer[1] = i & 0xff; - buffer[0] = (i >> 8) & 0xff; -} - -TEEC_Result Invoke_OpenTASession(TEEC_Session *session, uint32_t commandID, uint32_t *ta2taSession, TestData *testData, - uint32_t *origin) -{ - TEEC_Result result = TEEC_SUCCESS; - TEEC_Operation operation = { 0 }; - uint8_t tempBuffer[16]; - int rc; - - retrieveUint32toBuffer(tempBuffer, testData->uuid.timeLow); - retrieveUint16toBuffer(tempBuffer + 4, testData->uuid.timeMid); - retrieveUint16toBuffer(tempBuffer + 6, testData->uuid.timeHiAndVersion); - rc = memcpy_s(tempBuffer + 8, 8, &(testData->uuid.clockSeqAndNode), 8); - if (rc != 0) { - TEST_PRINT_ERROR("memcpy_s uuid to tee failed, rc=0x%x\n", rc); - return TEEC_ERROR_GENERIC; - } - - // Invoke command - operation.started = 1; - operation.paramTypes = - TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT, TEEC_VALUE_OUTPUT, TEEC_MEMREF_TEMP_INOUT); - operation.params[0].value.a = testData->caseId; - operation.params[1].tmpref.buffer = tempBuffer; - operation.params[1].tmpref.size = sizeof(tempBuffer); - operation.params[3].tmpref.buffer = testData->inBuffer; - operation.params[3].tmpref.size = testData->inBufferLen; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - *ta2taSession = operation.params[2].value.a; - testData->origin = operation.params[2].value.b; - testData->inBufferLen = operation.params[3].tmpref.size; - - return result; -} - -TEEC_Result Invoke_CloseTASession(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession, uint32_t *origin) -{ - TEEC_Result result = TEEC_SUCCESS; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = ta2taSession; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - return result; -} - -TEEC_Result Invoke_InvokeTACommand(TEEC_Session *session, uint32_t commandID, uint32_t ta2taSession, TestData *testData, - uint32_t *origin) -{ - TEEC_Result result = TEEC_SUCCESS; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = - TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INOUT, TEEC_VALUE_OUTPUT, TEEC_MEMREF_TEMP_OUTPUT); - operation.params[0].value.a = testData->caseId; - operation.params[0].value.b = ta2taSession; - operation.params[1].tmpref.buffer = testData->inBuffer; - operation.params[1].tmpref.size = testData->inBufferLen; - operation.params[3].tmpref.buffer = testData->outBuffer; - operation.params[3].tmpref.size = testData->outBufferLen; - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - testData->origin = operation.params[2].value.a; - testData->inBufferLen = operation.params[1].tmpref.size; - testData->outBufferLen = operation.params[3].tmpref.size; - return result; -} - -uint32_t get_ta_data_size(TEEC_Context *context, TEEC_Session *session) -{ - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE)); - if (rc != 0) { - TEST_PRINT_ERROR("memcpy_s for GPD_TA_DATASIZE fail,rc=0x%x\n", rc); - return -1; - } - value.inBufferLen = sizeof(GPD_TA_DATASIZE); - Invoke_GetPropertyAsX(context, session, &value); - - return atoi(value.outBuffer); -} - -uint32_t get_ta_stack_size(TEEC_Context *context, TEEC_Session *session) -{ - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_STACKSIZE, sizeof(GPD_TA_STACKSIZE)); - if (rc != 0) { - TEST_PRINT_ERROR("memcpy_s for GPD_TA_STACKSIZE fail,rc=0x%x\n", rc); - return -1; - } - value.inBufferLen = sizeof(GPD_TA_STACKSIZE); - - Invoke_GetPropertyAsX(context, session, &value); - return atoi(value.outBuffer); -} - -TEEC_Result Invoke_Panic(TEEC_Session *session, uint32_t commandID, TEEC_Result panicCode, uint32_t *origin) -{ - TEEC_Result result; - TEEC_Operation operation = { 0 }; - - // Invoke command - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE); - operation.params[0].value.a = panicCode; - - result = TEEC_InvokeCommand(session, commandID, &operation, origin); - return result; -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/src/mem/tee_checkmemaccessrights_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_checkmemaccessrights_test.cpp deleted file mode 100644 index 74dae472..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_checkmemaccessrights_test.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_Access_Read_Flag - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer whether has Access_Read right - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_Access_Read_Flag, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_Access_Write_Flag - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer whether has Access_Write right - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_Access_Write_Flag, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_WRITE; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_Access_AnyOwner_Flag - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer whether has Access_AnyOwner right - * @testcase.expect : return TEEC_ERROR_ACCESS_DENIED - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_Access_AnyOwner_Flag, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_ANY_OWNER; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_FlagIsZero - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while flag is zero - * @testcase.expect : return TEEC_ERROR_ACCESS_DENIED - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_FlagIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = 0; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsNull - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while assigned buffer is null - * @testcase.expect : return TEEC_ERROR_ACCESS_DENIED - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ; - value.caseId = INPUT_ISNULL; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsFree - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while assigned buffer is freeed - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsFree, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ; - value.caseId = BUFFER_IS_FREE; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsParam - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while assigned buffer is param type - * @testcase.expect : return TEEC_ERROR_ACCESS_DENIED - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsParam, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ; - value.caseId = BUFFER_IS_PARAM; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_BufferIsNotMalloc - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is not alloced,it is on stack - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_BufferIsNotMalloc, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE; - value.caseId = BUFFER_ISNOT_MALLOC; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_SizeIsZero - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while size is zero - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_SizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE; - value.caseId = OUTPUTBUFFERSIZE_ISZERO; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_SizeIsTooBig - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights to check buffer while size is too big - * @testcase.expect : return TEEC_ERROR_ACCESS_DENIED - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_SizeIsTooBig, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE; - value.caseId = BUFFERSIZE_ISTOOBIG; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_GlobalVar - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is global variable - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_GlobalVar, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_WRITE; - value.caseId = BUFFER_IS_GLOBALVAR; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_ReadRight_GlobalConstVar - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is global variable - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_ReadRight_GlobalConstVar, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_READ; - value.caseId = BUFFER_IS_GLOBALCONSTVAR; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CheckMemoryAccessRights_With_WriteRight_GlobalConstVar - * @testcase.desc : test TA call TEE_CheckMemoryAccessRights while buffer is global variable - * @testcase.expect : return TEEC_ERROR_ACCESS_DENIED - */ -TEE_TEST(TCF2Test, TEE_CheckMemoryAccessRights_With_WriteRight_GlobalConstVar, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - - value.oldSize = TESTSIZE; - value.accessFlags = TEE_MEMORY_ACCESS_WRITE; - value.caseId = BUFFER_IS_GLOBALCONSTVAR; - ret = Invoke_CheckMemoryAccessRights(GetSession(), CMD_TEE_CheckMemoryAccessRights, &value); - ASSERT_EQ(ret, TEEC_ERROR_ACCESS_DENIED); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/mem/tee_free_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_free_test.cpp deleted file mode 100644 index d8120bb9..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_free_test.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_Free_With_BufferIsNull - * @testcase.desc : test TA call TEE_Free to while buff is null - * @testcase.expect : return TEEC_SUCCESS -*/ -TEE_TEST(TCF2Test, TEE_Free_With_BufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - uint32_t caseId = INPUT_ISNULL; - - ret = Invoke_Free(GetSession(), CMD_TEE_Free, caseId, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_Free_With_BufferIsNotMalloc - * @testcase.desc : test TA call TEE_Free to while buff is not alloc, it is on stack - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD, ta will crash -*/ -TEE_TEST(TCF2Test, TEE_Free_With_BufferIsNotMalloc, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - uint32_t caseId = BUFFER_ISNOT_MALLOC; - - ret = Invoke_Free(GetSession(), CMD_TEE_Free, caseId, &origin); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/mem/tee_instance_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_instance_test.cpp deleted file mode 100644 index a9b1511b..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_instance_test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_Set_And_GetInstanceData_With_Success - * @testcase.desc : test TA call TEE_SetInstanceData and TEE_GetInstanceData to use instance data - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Set_And_GetInstanceData_With_Success, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char inBuf[] = { 'T', 'E', 'E', 'A', '\0', }; - char outBuf[BIG_SIZE] = { 0 }; - uint32_t caseId = 0; - uint32_t outLen = sizeof(outBuf); - - ret = Invoke_SetInstanceData(GetSession(), CMD_TEE_SetInstanceData, inBuf, caseId, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ret = Invoke_GetInstanceData(GetSession(), CMD_TEE_GetInstanceData, outBuf, &outLen, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(inBuf, outBuf); - ASSERT_EQ(outLen, strlen(inBuf) + 1); -} - -/** - * @testcase.name : TEE_Set_And_GetInstanceData_With_InstanceDataIsNull - * @testcase.desc : test TA call TEE_SetInstanceData and TEE_GetInstanceData to use instance data is null - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Set_And_GetInstanceData_With_InstanceDataIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char inBuf[] = { 'T', 'E', 'E', 'A', '\0', }; - char outBuf[BIG_SIZE] = { 0 }; - uint32_t caseId = INPUT_ISNULL; - uint32_t outLen = sizeof(outBuf); - - ret = Invoke_SetInstanceData(GetSession(), CMD_TEE_SetInstanceData, inBuf, caseId, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ret = Invoke_GetInstanceData(GetSession(), CMD_TEE_GetInstanceData, outBuf, &outLen, &origin); - ASSERT_EQ(ret, TEEC_ERROR_GENERIC); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_Set_And_GetInstanceData_With_GetSizeTooShort - * @testcase.desc : test TA call TEE_SetInstanceData and TEE_GetInstanceData to use instancedata while get size - * too short - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Set_And_GetInstanceData_With_GetSizeTooShort, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char inBuf[] = { 'T', 'E', 'E', 'A', '\0', }; - char outBuf[BIG_SIZE] = { 0 }; - uint32_t caseId = 0; - uint32_t outLen = strlen(inBuf) - 1; - - ret = Invoke_SetInstanceData(GetSession(), CMD_TEE_SetInstanceData, inBuf, caseId, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ret = Invoke_GetInstanceData(GetSession(), CMD_TEE_GetInstanceData, outBuf, &outLen, &origin); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(outLen, strlen(inBuf) + 1); -} diff --git a/test/xts/ca/tcf_api/src/mem/tee_malloc_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_malloc_test.cpp deleted file mode 100644 index 13442d44..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_malloc_test.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_Malloc_With_TEE_MALLOC_FILL_ZERO - * @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is TEE_MALLOC_FILL_ZERO - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_FILL_ZERO, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A' - - TestMemData value = { 0 }; - value.inMemSize = TESTSIZE; - value.inHint = TEE_MALLOC_FILL_ZERO; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_STREQ(buffer, EXPECTBUFFER_ZERO); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_TEE_MALLOC_NO_FILL - * @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is TEE_MALLOC_NO_FILL - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_NO_FILL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A' - - TestMemData value = { 0 }; - value.inMemSize = TESTSIZE; - value.inHint = TEE_MALLOC_NO_FILL; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_STRNE(buffer, EXPECTBUFFER_A); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_TEE_MALLOC_NO_SHARE - * @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is TEE_MALLOC_NO_SHARE - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_NO_SHARE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A' - - TestMemData value = { 0 }; - value.inMemSize = TESTSIZE; - value.inHint = TEE_MALLOC_NO_SHARE; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_STRNE(buffer, EXPECTBUFFER_A); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_TEE_MALLOC_NO_FILL_And_NO_SHARE - * @testcase.desc : test TA call TEE_Malloc to alloc 10 bytes with hint is TEE_MALLOC_NO_FILL|TEE_MALLOC_NO_SHARE - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_TEE_MALLOC_NO_FILL_And_NO_SHARE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A' - - TestMemData value = { 0 }; - value.inMemSize = TESTSIZE; - value.inHint = TEE_MALLOC_NO_FILL | TEE_MALLOC_NO_SHARE; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_STRNE(buffer, EXPECTBUFFER_A); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_HINT_RESERVE - * @testcase.desc : test TA call TEE_Malloc to alloc buffer 10 bytes with hint is HINT_RESERVE - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_HINT_RESERVE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A' - - TestMemData value = { 0 }; - value.inMemSize = TESTSIZE; - value.inHint = HINT_RESERVE; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_STRNE(buffer, EXPECTBUFFER_A); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_SIZEIsZero - * @testcase.desc : test TA call TEE_Malloc to alloc buffer with size is zero - * @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_SizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x0, TESTSIZE); - - TestMemData value = { 0 }; - value.inMemSize = 0; - value.inHint = TEE_MALLOC_FILL_ZERO; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_SizeExceedHeapLimit - * @testcase.desc : test TA call TEE_Malloc to alloc buffer with size exceed heaplimit - * @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY - */ -TEE_TEST(TCF2Test, TEE_Malloc_With_SizeExceedHeapLimit, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x0, TESTSIZE); - - uint32_t dateSize = get_ta_data_size(GetContext(), GetSession()); - EXPECT_GT(dateSize, 0); - - uint32_t stackSize = get_ta_stack_size(GetContext(), GetSession()); - EXPECT_GT(stackSize, 0); - - TestMemData value = { 0 }; - value.inMemSize = dateSize + stackSize; - value.inHint = TEE_MALLOC_FILL_ZERO; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - free(buffer); -} - -/** - * @testcase.name : TEE_Malloc_With_MAXDataSize - * @testcase.desc : test TA call TEE_Malloc to alloc buffer with size is max data size - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF1Test, TEE_Malloc_With_MAXDataSize, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - char *buffer = reinterpret_cast(malloc(MAX_SHARE_SIZE)); - ASSERT_STRNE(buffer, NULL); - (void)memset_s(buffer, TESTSIZE, 0x41, TESTSIZE); // 0x41 = 'A' - - uint32_t dateSize = get_ta_data_size(GetContext(), GetSession()); - EXPECT_GT(dateSize, 0); - - TestMemData value = { 0 }; - value.inMemSize = dateSize; - value.inHint = TEE_MALLOC_FILL_ZERO; - value.testBuffer = buffer; - ret = Invoke_Malloc(GetSession(), CMD_TEE_Malloc, &value, &origin); - EXPECT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_STREQ(buffer, EXPECTBUFFER_ZERO); - free(buffer); -} diff --git a/test/xts/ca/tcf_api/src/mem/tee_memcompare_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_memcompare_test.cpp deleted file mode 100644 index cd0a8b16..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_memcompare_test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_MemCompare_With_Same - * @testcase.desc : test TA call TEE_MemCompare to compare buffer1 and buffer2 - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_MemCompare_With_Same, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t i; - TestMemData value = { 0 }; - char buf1[TESTSIZE] = { 0 }; - char buf2[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - for (i = 0; i < TESTSIZE; i++) { - buf1[i] = (char)'A'; - buf2[i] = (char)'A'; - } - ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_MemCompare_With_Buffer1LessBuffer2 - * @testcase.desc : test TA call TEE_MemCompare to compare buffer1 and buffer2, buffer1 < buffer2 - * @testcase.expect : return -1 - */ -TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer1LessBuffer2, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t i; - TestMemData value = { 0 }; - char buf1[TESTSIZE] = { 0 }; - char buf2[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - for (i = 0; i < TESTSIZE - 1; i++) { - buf1[i] = (char)'A'; - buf2[i] = (char)'A'; - } - buf1[TESTSIZE - 1] = (char)'A'; - buf2[TESTSIZE - 1] = (char)'B'; - - ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2); - ASSERT_EQ(ret, -1); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_MemCompare_With_Buffer1GreaterBuffer2 - * @testcase.desc : test TA call TEE_MemCompare to compare buffer1 and buffer2, buffer1 > buffer2 - * @testcase.expect : return -1 - */ -TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer1GreaterBuffer2, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t i; - TestMemData value = { 0 }; - char buf1[TESTSIZE] = { 0 }; - char buf2[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - for (i = 0; i < TESTSIZE - 1; i++) { - buf1[i] = (char)'A'; - buf2[i] = (char)'A'; - } - buf1[TESTSIZE - 1] = (char)'B'; - buf2[TESTSIZE - 1] = (char)'A'; - - ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2); - ASSERT_EQ(ret, 1); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_MemCompare_With_Buffer1IsNull - * @testcase.desc : test TA call TEE_MemCompare compare while buffer1 is null - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer1IsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t i; - TestMemData value = { 0 }; - char buf1[TESTSIZE] = { 0 }; - char buf2[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - for (i = 0; i < TESTSIZE; i++) { - buf1[i] = (char)'A'; - buf2[i] = (char)'A'; - } - value.caseId = INPUT_ISNULL; - ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2); - ASSERT_EQ(ret, -1); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_MemCompare_With_Buffer2IsNull - * @testcase.desc : test TA call TEE_MemCompare compare while buffer2 is null - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_MemCompare_With_Buffer2IsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t i; - TestMemData value = { 0 }; - char buf1[TESTSIZE] = { 0 }; - char buf2[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - for (i = 0; i < TESTSIZE; i++) { - buf1[i] = (char)'A'; - buf2[i] = (char)'A'; - } - value.caseId = OUTPUT_ISNULL; - ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2); - ASSERT_EQ(ret, 1); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_MemCompare_With_SizeIsZero - * @testcase.desc : test TA call TEE_MemCompare compare while size is zero - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_MemCompare_With_SizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t i; - TestMemData value = { 0 }; - char buf1[TESTSIZE] = { 0 }; - char buf2[TESTSIZE] = { 0 }; - - value.oldSize = 0; - for (i = 0; i < TESTSIZE; i++) { - buf1[i] = (char)'A'; - buf2[i] = (char)'B'; - } - - ret = Invoke_MemCompare(GetSession(), CMD_TEE_MemCompare, &value, buf1, buf2); - ASSERT_EQ(ret, 0); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/mem/tee_memfill_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_memfill_test.cpp deleted file mode 100644 index e7a7fcfe..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_memfill_test.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_MemFill_With_Success - * @testcase.desc : test TA call TEE_MemFill to fill buffer with char assigned in TA - * @testcase.expect : return TEEC_SUCCESS, buffer is filled match expect - */ -TEE_TEST(TCF2Test, TEE_MemFill_With_Success, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemFill, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_A); -} - -/** - * @testcase.name : TEE_MemFill_With_BufferIsNull - * @testcase.desc : test TA call TEE_MemFill while buffer is null - * @testcase.expect : return TEEC_SUCCESS, buffer is not filled and is 0 - */ -TEE_TEST(TCF2Test, TEE_MemFill_With_BufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - uint32_t i; - - value.oldSize = TESTSIZE; - value.caseId = INPUT_ISNULL; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemFill, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - for (i = 0; i < TESTSIZE; i++) { - ASSERT_EQ(outBuf[i], 0); - } -} - -/** - * @testcase.name : TEE_MemFill_With_SizeIsZero - * @testcase.desc : test TA call TEE_MemFill while size is zero - * @testcase.expect : return TEEC_SUCCESS, buffer is not filled and is 0 - */ -TEE_TEST(TCF2Test, TEE_MemFill_With_SizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - uint32_t i; - - value.oldSize = TESTSIZE; - value.caseId = OUTPUTBUFFERSIZE_ISZERO; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemFill, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - for (i = 0; i < TESTSIZE; i++) { - ASSERT_EQ(outBuf[i], 0); - } -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/src/mem/tee_memmove_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_memmove_test.cpp deleted file mode 100644 index dba566d0..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_memmove_test.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_MemMove_With_Success - * @testcase.desc : test TA call TEE_MemMove to move buffer from src to dest - * @testcase.expect : return TEEC_SUCCESS, dest buffer is same as src buffer - */ -TEE_TEST(TCF2Test, TEE_MemMove_With_Success, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = {0}; - - value.oldSize = TESTSIZE; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_A); -} - -/** - * @testcase.name : TEE_MemMove_With_SrcBufferIsNull - * @testcase.desc : test TA call TEE_MemMove to move buffer while srcbuffer is null - * @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer - */ -TEE_TEST(TCF2Test, TEE_MemMove_With_SrcBufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.caseId = INPUT_ISNULL; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_B); -} - -/** - * @testcase.name : TEE_MemMove_With_DestBufferIsNull - * @testcase.desc : test TA call TEE_MemMove to move buffer while destbuffer is null - * @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer - */ -TEE_TEST(TCF2Test, TEE_MemMove_With_DestBufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.caseId = OUTPUT_ISNULL; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_B); -} - -/** - * @testcase.name : TEE_MemMove_With_SizeIsZero - * @testcase.desc : test TA call TEE_MemMove to move buffer while size is zero - * @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer - */ -TEE_TEST(TCF2Test, TEE_MemMove_With_SizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.caseId = OUTPUTBUFFERSIZE_ISZERO; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_B); -} - -/** - * @testcase.name : TEE_MemMove_With_DestIsSameAsSrc - * @testcase.desc : test TA call TEE_MemMove to move buffer while destbuffer addr is same as srcbuffer addr - * @testcase.expect : return TEEC_SUCCESS, dest buffer is not same as src buffer - */ -TEE_TEST(TCF2Test, TEE_MemMove_With_DestIsSameAsSrc, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.caseId = DESTANDSRC_ISSAME; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_B); -} - -/** - * @testcase.name : TEE_MemMove_With_Overlap - * @testcase.desc : test TA call TEE_MemMove to move buffer while src buffer and dest buffer is overlap - * @testcase.expect : return TEEC_SUCCESS, dest buffer is same as src buffer - */ -TEE_TEST(TCF2Test, TEE_MemMove_With_Overlap, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.caseId = DESTANDSRC_OVERLAP; - ret = Invoke_MemMove_Or_Fill(GetSession(), CMD_TEE_MemMove, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_OVERLAP); -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/src/mem/tee_realloc_test.cpp b/test/xts/ca/tcf_api/src/mem/tee_realloc_test.cpp deleted file mode 100644 index 80f20fca..00000000 --- a/test/xts/ca/tcf_api/src/mem/tee_realloc_test.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -/** - * @testcase.name : TEE_Realloc_With_SameSize - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is same as oldsize - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_SameSize, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.newSize = TESTSIZE; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.oldAddr, value.newAddr); - ASSERT_STREQ(outBuf, EXPECTBUFFER_A); -} - -/** - * @testcase.name : TEE_Realloc_With_LessSize - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is less than oldsize - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_LessSize, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - value.newSize = TESTSIZE - 1; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.oldAddr, value.newAddr); - ASSERT_STREQ(outBuf, EXPECTBUFFER_A_LESS); -} - -/** - * @testcase.name : TEE_Realloc_With_GreaterSize - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is greater than oldsize - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_GreaterSize, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[BIG_SIZE] = { 0 }; - uint32_t i; - - value.oldSize = TESTSIZE; - value.newSize = BIG_SIZE; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(outBuf, EXPECTBUFFER_A); - - for (i = TESTSIZE; i < BIG_SIZE; i++) { - ASSERT_EQ(outBuf[i], 0); - } -} - -/** - * @testcase.name : TEE_Realloc_With_NewSizeIsZero - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize is 0 - * @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_NewSizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - value.newSize = 0; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_Realloc_With_SizeExceedHeapLimit - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with newsize exceed heaplimit - * @testcase.expect : return TEEC_ERROR_OUT_OF_MEMORY - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_SizeExceedHeapLimit, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - - uint32_t dateSize = get_ta_data_size(GetContext(), GetSession()); - ASSERT_GT(dateSize, 0); - - uint32_t stackSize = get_ta_stack_size(GetContext(), GetSession()); - ASSERT_GT(stackSize, 0); - - value.oldSize = TESTSIZE; - value.newSize = dateSize + stackSize; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_Realloc_With_BufferIsNull - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with buffer is null - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_BufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE + 1] = { 0 }; - - value.oldSize = TESTSIZE; - value.newSize = TESTSIZE; - value.caseId = INPUT_ISNULL; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_NE(value.oldAddr, value.newAddr); - ASSERT_STREQ(outBuf, EXPECTBUFFER_A); -} - -/** - * @testcase.name : TEE_Realloc_With_BufferIsNotMalloc - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with buffer is malloc, it is on stack - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_BufferIsNotMalloc, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - value.newSize = TESTSIZE; - value.caseId = BUFFER_ISNOT_MALLOC; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_Realloc_With_BufferIsFree - * @testcase.desc : test TA call TEE_Realloc to alloc buffer with buffer is freeed - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD, ta will crash - */ -TEE_TEST(TCF2Test, TEE_Realloc_With_BufferIsFree, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestMemData value = { 0 }; - char outBuf[TESTSIZE] = { 0 }; - - value.oldSize = TESTSIZE; - value.newSize = TESTSIZE; - value.caseId = BUFFER_IS_FREE; - ret = Invoke_Realloc(GetSession(), CMD_TEE_Realloc, &value, outBuf); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/src/other/internal_client_api_test.cpp b/test/xts/ca/tcf_api/src/other/internal_client_api_test.cpp deleted file mode 100644 index 2a03f566..00000000 --- a/test/xts/ca/tcf_api/src/other/internal_client_api_test.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -static char g_teeOutput[] = "TEEMEM_OUTPUT"; -static char g_teeInout[] = "the param is TEEMEM_INOUT"; -static uint32_t g_teeOutputLen; -static uint32_t g_teeInoutLen; - -/** - * @testcase.name : TEE_OpenTASession_With_Success - * @testcase.desc : test TA call TEE_OpenTASession to call other TA - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_Success, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = 0; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - g_teeInoutLen = strlen(g_teeInout) + 1; - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - ASSERT_STREQ(value.inBuffer, g_teeInout); - ASSERT_EQ(value.inBufferLen, g_teeInoutLen); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_UUIDIsNULL - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while uuid is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_UUIDIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = INPUT_ISNULL; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_OriginIsNULL - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while origin is null - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_OriginIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = RETURNORIGIN_ISNULL; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_NE(ta2taSession, 0); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_SessionIsNULL - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while session is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_SessionIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = OUTPUT_ISNULL; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_NoAvailableSession - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while session is null - * @testcase.expect : return TEEC_ERROR_BUSY - */ -TEE_TEST(TCF1Test, TEE_OpenTASession_With_NoAvailableSession, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = 0; - - value.uuid = TCF_API_UUID_2; // this uuid is for ta2, this is a single session ta - ClientSessionMgr sess; - ret = sess.Start(&value.uuid); - EXPECT_EQ(ret, TEEC_SUCCESS); - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - sess.Destroy(); - ASSERT_EQ(ret, TEEC_ERROR_BUSY); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_MaxSession - * @testcase.desc : test TA call TEE_OpenTASession to call other TA to reach max session - * @testcase.expect : return TEEC_ERROR_SESSION_MAXIMUM - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_MaxSession, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession[8] = { 0 }; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = 0; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - int i; - value.inBufferLen = BIG_SIZE; - - for (i = 0; i <= 6; i++) { - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession[i], 0); - if (i >= 1) - ASSERT_NE(ta2taSession[i], ta2taSession[i - 1]); - } - - // ta2 has reach max session,so this time will open session fail - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_SESSION_MAXIMUM); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(ta2taSession[i], 0); -} - -/** - * @testcase.name : TEE_OpenTASession_With_UUIDIsNotExist - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while uuid is not exist - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_UUIDIsNotExist, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = 0; - value.uuid = UUID_TA_NOT_EXIST; // this uuid is for ta2 - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_TA2Crash - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while ta2 is crashed - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_TA2Crash, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.caseId = TA_CRASH_FLAG; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_OpenTASession_With_BufferNoFillNoShare - * @testcase.desc : test TA call TEE_OpenTASession to call other TA while buffer hint is - * TEE_MALLOC_NO_FILL|TEE_MALLOC_NO_SHARE - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_OpenTASession_With_BufferNoFillNoShare, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - g_teeInoutLen = strlen(g_teeInout) + 1; - - value.caseId = BUFFER_NOFILLNOSHARE; - value.inBufferLen = BIG_SIZE; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - ASSERT_STREQ(value.inBuffer, g_teeInout); - ASSERT_EQ(value.inBufferLen, g_teeInoutLen); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_CloseTASession_With_MaxSession - * @testcase.desc : test TA call TEE_CloseTASession when TA to reach max session, then can open new session to ta2 - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_CloseTASession_With_MaxSession, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession[8] = { 0 }; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - int i; - value.inBufferLen = BIG_SIZE; - - for (i = 0; i <= 6; i++) { - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession[i], 0); - if (i >= 1) - ASSERT_NE(ta2taSession[i], ta2taSession[i - 1]); - } - - // ta2 has reach max session,so this time will open session fail - value.inBufferLen = BIG_SIZE; - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[7], &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_SESSION_MAXIMUM); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(ta2taSession[7], 0); - - // close one session of ta2 - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession[6], &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - // ta2 has close one session, so this time will open session success - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[6], &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession[6], 0); -} - -/** - * @testcase.name : TEE_InvokeTACommand_With_PARAM_TYPE_MEMREF - * @testcase.desc : test TA call TEE_InvokeTACommand to pass memref params to other TA - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_PARAM_TYPE_MEMREF, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - g_teeOutputLen = strlen(g_teeOutput) + 1; - g_teeInoutLen = strlen(g_teeInout) + 1; - value.inBufferLen = BIG_SIZE; - value.outBufferLen = BIG_SIZE; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - (void)memset_s(value.inBuffer, BIG_SIZE, 0x41, BIG_SIZE); - - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - - ASSERT_STREQ(value.inBuffer, g_teeInout); - ASSERT_EQ(value.inBufferLen, g_teeInoutLen); - ASSERT_STREQ(value.outBuffer, g_teeOutput); - ASSERT_EQ(value.outBufferLen, g_teeOutputLen); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_InvokeTACommand_With_SessionIsNull - * @testcase.desc : test TA call TEE_InvokeTACommand to other TA while session is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_SessionIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - value.inBufferLen = BIG_SIZE; - value.outBufferLen = BIG_SIZE; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - value.caseId = INPUT_ISNULL; - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_InvokeTACommand_With_OriginIsNull - * @testcase.desc : test TA call TEE_InvokeTACommand to other TA while origin is null - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_OriginIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - g_teeOutputLen = strlen(g_teeOutput) + 1; - g_teeInoutLen = strlen(g_teeInout) + 1; - value.inBufferLen = BIG_SIZE; - value.outBufferLen = BIG_SIZE; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - value.caseId = OUTPUT_ISNULL; - (void)memset_s(value.inBuffer, BIG_SIZE, 0x41, BIG_SIZE); - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ASSERT_STREQ(value.inBuffer, g_teeInout); - ASSERT_EQ(value.inBufferLen, g_teeInoutLen); - ASSERT_STREQ(value.outBuffer, g_teeOutput); - ASSERT_EQ(value.outBufferLen, g_teeOutputLen); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_InvokeTACommand_With_TA2Crash - * @testcase.desc : test TA call TEE_InvokeTACommand to other TA while ta2 is crash - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD - */ -TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_TA2Crash, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - value.inBufferLen = BIG_SIZE; - value.outBufferLen = BIG_SIZE; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - value.caseId = TA_CRASH_FLAG; - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_InvokeTACommand_With_MaxShareBufferSize - * @testcase.desc : test TA call TEE_InvokeTACommand to pass memref to other TA while buffer size is MAX_SHARE_SIZE - * @testcase.expect : return TEEC_ERROR_GENERIC - */ -TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_MaxShareBufferSize, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - value.inBufferLen = BIG_SIZE; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - value.caseId = BUFFERSIZE_ISTOOBIG; - value.outBufferLen = BIG_SIZE; - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_GENERIC); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_InvokeTACommand_With_BufferNoFillNoShare - * @testcase.desc : test TA call TEE_InvokeTACommand to pass memref to TA2 while buffer hint is - * TEE_MALLOC_NO_FILL|TEE_MALLOC_NO_SHARE - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2TA2TATest, TEE_InvokeTACommand_With_BufferNoFillNoShare, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession; - uint32_t origin = 0; - TestData value = { 0 }; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - value.inBufferLen = BIG_SIZE; - value.outBufferLen = BIG_SIZE; - g_teeInoutLen = strlen(g_teeInout) + 1; - - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession, 0); - - value.caseId = BUFFER_NOFILLNOSHARE; - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession, &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - - ASSERT_STREQ(value.inBuffer, g_teeInout); - ASSERT_EQ(value.inBufferLen, g_teeInoutLen); - - ret = Invoke_CloseTASession(GetSession(), CMD_TEE_CloseTASession, ta2taSession, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/other/tee_panic_test.cpp b/test/xts/ca/tcf_api/src/other/tee_panic_test.cpp deleted file mode 100644 index dcb3a1b1..00000000 --- a/test/xts/ca/tcf_api/src/other/tee_panic_test.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace testing::ext; - -/** - * @testcase.name : TEE_Panic_With_Normal - * @testcase.desc : test TA call TEE_Panic to make ta panic - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD - */ -TEE_TEST(TCF1Test, TEE_Panic_With_Normal, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - TEEC_Result panicCode = TEEC_ERROR_GENERIC; - - ret = Invoke_Panic(GetSession(), CMD_TEE_Panic, panicCode, &origin); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(origin, TEEC_ORIGIN_TEE); -} - -/** - * @testcase.name : TEE_Panic_With_MultiSession - * @testcase.desc : test TA call TEE_Panic to make a multisession ta panic - * @testcase.expect : return TEEC_ERROR_TARGET_DEAD,invoke other tasession will return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF2TA2TATest, TEE_Panic_With_MultiSession, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t ta2taSession[8] = { 0 }; - uint32_t origin = 0; - int i; - TestData value = { 0 }; - value.caseId = 0; - value.uuid = TCF_API_UUID_1; // this uuid is for ta2 - value.inBufferLen = BIG_SIZE; - value.outBufferLen = BIG_SIZE; - - for (i = 0; i <= 6; i++) { - ret = Invoke_OpenTASession(GetSession(), CMD_TEE_OpenTASession, &ta2taSession[i], &value, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TEE); - ASSERT_NE(ta2taSession[i], 0); - if (i >= 1) - ASSERT_NE(ta2taSession[i], ta2taSession[i - 1]); - } - - // make ta2 one session panic - TEEC_Result panicCode = TEEC_ERROR_GENERIC; - ret = Invoke_Panic(GetSession2(), CMD_TEE_Panic, panicCode, &origin); - ASSERT_EQ(ret, TEEC_ERROR_TARGET_DEAD); - ASSERT_EQ(origin, TEEC_ORIGIN_TEE); - - for (i = 0; i <= 6; i++) { - ret = Invoke_InvokeTACommand(GetSession(), CMD_TEE_InvokeTACommand, ta2taSession[i], &value, &origin); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(origin, TEEC_ORIGIN_TEE); - } -} diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_binaryblock_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_binaryblock_test.cpp deleted file mode 100644 index fa3a858b..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_binaryblock_test.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_TestBinaryBlock - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock to get value of SMC_TA_TESTBINARYBLOCK - * @testcase.expect : return TEEC_SUCCESS -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_TestBinaryBlock, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_BINARY_BLOCK); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BINARY_BLOCK)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for value buffer is null - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for value buffer size is null - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.caseId = OUTPUTBUFFERSIZE_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock for value buffer size is zero - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_ValueBufferSizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.caseId = OUTPUTBUFFERSIZE_ISZERO; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_BufferTooShort - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock while out buffer is too short - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_BufferTooShort, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.caseId = OUTPUTBUFFERSIZE_TOOSHORT; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTBINARYBLOCK, sizeof(SMC_TA_TESTBINARYBLOCK)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTBINARYBLOCK); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BINARY_BLOCK)); -} - - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotBinaryBlock - * @testcase.desc : test TA call TEE_GetPropertyAsBinaryBlock while Name type is not BinaryBlock - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBinaryBlock_WithoutEnum_NameNotBinaryBlock, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBinaryBlock; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_bool_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_bool_test.cpp deleted file mode 100644 index b5ce414b..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_bool_test.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_SINGLEINSTANCE - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TA_SINGLEINSTANCE - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_SINGLEINSTANCE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE); - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_BOOLEAN); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BOOLEAN)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_MULTISESSION - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TA_MULTISESSION - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_MULTISESSION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_MULTISESSION, sizeof(GPD_TA_MULTISESSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_MULTISESSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_BOOLEAN); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_BOOLEAN)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_INSTANCEKEEPALIVE - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TA_INSTANCEKEEPALIVE - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TA_INSTANCEKEEPALIVE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_INSTANCEKEEPALIVE, sizeof(GPD_TA_INSTANCEKEEPALIVE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_INSTANCEKEEPALIVE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_ECC - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_ECC - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_ECC, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_ECC, sizeof(GPD_TEE_CRYPTOGRAPHY_ECC)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_ECC); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_NIST - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_NIST - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_NIST, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_NIST, sizeof(GPD_TEE_CRYPTOGRAPHY_NIST)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_NIST); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_R - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_BSI_R - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_R, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_BSI_R, sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_R)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_R); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_T - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_BSI_T - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_BSI_T, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_BSI_T, sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_T)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_BSI_T); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_IETF - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_IETF - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_IETF, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_IETF, sizeof(GPD_TEE_CRYPTOGRAPHY_IETF)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_IETF); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_OCTA - * @testcase.desc : test TA call TEE_GetPropertyAsBool to get value of GPD_TEE_CRYPTOGRAPHY_OCTA - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_GPD_TEE_CRYPTOGRAPHY_OCTA, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_CRYPTOGRAPHY_OCTA, sizeof(GPD_TEE_CRYPTOGRAPHY_OCTA)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_CRYPTOGRAPHY_OCTA); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_FALSE); - ASSERT_EQ(value.outBufferLen, sizeof(VALUE_PREDEFINED_FALSE)); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsBool for name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsBool for name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_ValueIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsBool for value is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_ValueIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_MULTISESSION, sizeof(GPD_TA_MULTISESSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_MULTISESSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsBool while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsBool_WithoutEnum_NameNotBool - * @testcase.desc : test TA call TEE_GetPropertyAsBool while Name type is not bool - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsBool_WithoutEnum_NameNotBool, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsBool; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_STACKSIZE, sizeof(GPD_TA_STACKSIZE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_STACKSIZE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_identity_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_identity_test.cpp deleted file mode 100644 index dfaaddb1..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_identity_test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_SMC_TA_TESTIDENTITY - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity to get value of SMC_TA_TESTIDENTITY - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_SMC_TA_TESTIDENTITY, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTIDENTITY, sizeof(SMC_TA_TESTIDENTITY)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTIDENTITY); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity for name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity for name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_ValueBufferIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity for value buffer is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTIDENTITY, sizeof(SMC_TA_TESTIDENTITY)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTIDENTITY); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameNotIdentity - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity while Name type is not Identity - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameNotIdentity, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsIdentity_WithoutEnum_NameNotUUID2 - * @testcase.desc : test TA call TEE_GetPropertyAsIdentity while Name type is not UUID, is string - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT - */ -TEE_TEST(TCF2Test, TEE_GetPropertyAsIdentity_WithoutEnum_NameNotUUID2, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsIdentity; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_DESCRIPTION, sizeof(GPD_TEE_DESCRIPTION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_DESCRIPTION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_string_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_string_test.cpp deleted file mode 100644 index 7534ce10..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_string_test.cpp +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_APPID - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_APPID - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_APPID, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_UUID); - ASSERT_EQ(value.outBufferLen, BIG_SIZE); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_SERVICENAME - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_SERVICENAME - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND, can not get value - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_SERVICENAME, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SERVICENAME, sizeof(GPD_TA_SERVICENAME)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_SERVICENAME); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_CLIENT_IDENTITY - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_CLIENT; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_CLIENT_IDENTITY, sizeof(GPD_CLIENT_IDENTITY)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_CLIENT_IDENTITY); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_CLIENT_IDENTITY); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY_PropsetIsWrong - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_CLIENT_IDENTITY, Propset is wrong - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND, can not get value - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_CLIENT_IDENTITY_PropsetIsWrong, - Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_CLIENT_IDENTITY, sizeof(GPD_CLIENT_IDENTITY)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_CLIENT_IDENTITY); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_VERSION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_VERSION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_VERSION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_VERSION, sizeof(GPD_TA_VERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_VERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_TA_VERSION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TA_DESCRIPTION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TA_DESCRIPTION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TA_DESCRIPTION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DESCRIPTION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, VALUE_PREDEFINED_TA_DESCRIPTION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_APIVERSION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_APIVERSION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_APIVERSION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_APIVERSION, sizeof(GPD_TEE_APIVERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_APIVERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_API_VERSION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_DESCRIPTION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_DESCRIPTION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_DESCRIPTION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_DESCRIPTION, sizeof(GPD_TEE_DESCRIPTION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_DESCRIPTION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_BUILD_VER); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_VERSION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_TRUSTEDOS_IMP_VERSION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_VERSION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TRUSTEDOS_IMP_VERSION, sizeof(GPD_TEE_TRUSTEDOS_IMP_VERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_TRUSTEDOS_IMP_VERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_IMP_VERSION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION, - Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION, - sizeof(GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_IMP_VERSION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_VERSION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_FIRMWARE_IMP_VERSION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_VERSION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_FIRMWARE_IMP_VERSION, sizeof(GPD_TEE_FIRMWARE_IMP_VERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_FIRMWARE_IMP_VERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_FIRMWARE_IMP_VERSION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_BINARYVERSION - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_FIRMWARE_IMP_BINARYVERSION - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_IMP_BINARYVERSION, - Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_FIRMWARE_IMP_BINARYVERSION, - sizeof(GPD_TEE_FIRMWARE_IMP_BINARYVERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_FIRMWARE_IMP_BINARYVERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_FIRMWARE_IMP_VERSION); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_MANUFACTURER - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_TRUSTEDOS_MANUFACTURER - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_TRUSTEDOS_MANUFACTURER, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TRUSTEDOS_MANUFACTURER, sizeof(GPD_TEE_TRUSTEDOS_MANUFACTURER)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_TRUSTEDOS_MANUFACTURER); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_MANUFACTURER); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_MANUFACTURER - * @testcase.desc : test TA call TEE_GetPropertyAsString to get value of GPD_TEE_FIRMWARE_MANUFACTURER - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_GPD_TEE_FIRMWARE_MANUFACTURER, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_FIRMWARE_MANUFACTURER, sizeof(GPD_TEE_FIRMWARE_MANUFACTURER)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_FIRMWARE_MANUFACTURER); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_STREQ(value.outBuffer, TEE_FIRMWARE_MANUFACTURER); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_PropsetIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsString while Propset Is Zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_PropsetIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_ZERO; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_NameIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsString while name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_NameIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsString while name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_ValueBufferIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsString while value buffer is null - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsString while value buffer size is null - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.caseId = OUTPUTBUFFERSIZE_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsString while value buffer size is zero - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_ValueBufferSizeIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.caseId = OUTPUTBUFFERSIZE_ISZERO; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsString while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsString_WithoutEnum_BufferTooShort - * @testcase.desc : test TA call TEE_GetPropertyAsString while out buffer is too short - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsString_WithoutEnum_BufferTooShort, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsString; - value.caseId = OUTPUTBUFFERSIZE_TOOSHORT; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} \ No newline at end of file diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_u32_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_u32_test.cpp deleted file mode 100644 index f5ab7c25..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_u32_test.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_DATASIZE - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TA_DATASIZE - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_DATASIZE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DATASIZE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), VALUE_PREDEFINED_DATASIZE); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_STACKSIZE - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TA_STACKSIZE - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TA_STACKSIZE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_STACKSIZE, sizeof(GPD_TA_STACKSIZE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_STACKSIZE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), VALUE_PREDEFINED_STACKSIZE); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_CLIENT_ENDIAN - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_CLIENT_ENDIAN - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_CLIENT_ENDIAN, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_CLIENT; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_CLIENT_ENDIAN, sizeof(GPD_CLIENT_ENDIAN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_CLIENT_ENDIAN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), VALUE_PREDEFINED_CLIENT_ENDIAN); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_INTERNALCORE_VERSION - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_INTERNALCORE_VERSION - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_INTERNALCORE_VERSION, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_INTERNALCORE_VERSION, sizeof(GPD_TEE_INTERNALCORE_VERSION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_INTERNALCORE_VERSION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), TEE_INTERNAL_CORE_VERSION); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL, - sizeof(GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), TEE_TIME_PROTECT_LEVEL); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL, - Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL, - sizeof(GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), TA_TIME_PROTECT_LEVEL); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ARITH_MAXBIGINTSIZE - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_ARITH_MAXBIGINTSIZE - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ARITH_MAXBIGINTSIZE, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_ARITH_MAXBIGINTSIZE, sizeof(GPD_TEE_ARITH_MAXBIGINTSIZE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_ARITH_MAXBIGINTSIZE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), MAX_BIG_INT_SIZE); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL, - Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL, - sizeof(GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), 0); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL, - Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL, - sizeof(GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), 0); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_EVENT_MAXSOURCES - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_EVENT_MAXSOURCES - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_EVENT_MAXSOURCES, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_EVENT_MAXSOURCES, sizeof(GPD_TEE_EVENT_MAXSOURCES)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_EVENT_MAXSOURCES); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), 0); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_API_LEVEL - * @testcase.desc : test TA call TEE_GetPropertyAsU32 to get value of GPD_TEE_API_LEVEL - * @testcase.expect : return TEEC_SUCCESS, get value is correct - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_GPD_TEE_API_LEVEL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TEE_API_LEVEL, sizeof(GPD_TEE_API_LEVEL)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TEE_API_LEVEL); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoi(value.outBuffer), TEE_MAX_API_LEVEL_CONFIG); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsU32 for name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsU32 for name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_ValueIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsU32 for value is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_ValueIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DATASIZE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsU32 while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU32_WithoutEnum_NameNotU32 - * @testcase.desc : test TA call TEE_GetPropertyAsU32 while Name type is not U32 - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT - */ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU32_WithoutEnum_NameNotU32, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU32; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DESCRIPTION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_u64_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_u64_test.cpp deleted file mode 100644 index 857dc8a5..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_u64_test.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_TESTU64 - * @testcase.desc : test TA call TEE_GetPropertyAsU64 to get value of SMC_TA_TESTU64 - * @testcase.expect : return TEEC_SUCCESS -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_TESTU64, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU64; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, SMC_TA_TESTU64, sizeof(SMC_TA_TESTU64)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(SMC_TA_TESTU64); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(atoll(value.outBuffer), VALUE_PREDEFINED_U64); - ASSERT_EQ(value.outBufferLen, strlen(value.outBuffer) + 1); -} - -/** - * @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsU64 for name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU64; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsU64 for name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU64; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_ValueIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsU64 for value is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_ValueIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU64; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DATASIZE, sizeof(GPD_TA_DATASIZE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DATASIZE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsU64 while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU64; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsU64_WithoutEnum_NameNotU64 - * @testcase.desc : test TA call TEE_GetPropertyAsU64 while Name type is not U64 - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsU64_WithoutEnum_NameNotU64, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsU64; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DESCRIPTION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/property/get_prop_as_uuid_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_as_uuid_test.cpp deleted file mode 100644 index b9fbed76..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_as_uuid_test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_GPD_TA_APPID - * @testcase.desc : test TA call TEE_GetPropertyAsUUID to get value of GPD_TA_APPID - * @testcase.expect : return TEEC_SUCCESS -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_GPD_TA_APPID, Function | MediumTest | Level0) -{ - TEEC_Result ret; - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameIsNull - * @testcase.desc : test TA call TEE_GetPropertyAsUUID for name is null - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.caseId = INPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameIsZero - * @testcase.desc : test TA call TEE_GetPropertyAsUUID for name value is zero - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameIsZero, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.propSet = TEE_PROPSET_CURRENT_TA; - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_ValueBufferIsNULL - * @testcase.desc : test TA call TEE_GetPropertyAsUUID for value buffer is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_ValueBufferIsNULL, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.caseId = OUTPUT_ISNULL; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_APPID, sizeof(GPD_TA_APPID)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_APPID); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameNotFound - * @testcase.desc : test TA call TEE_GetPropertyAsUUID while Name Not Found - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameNotFound, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, PROPERTY_NAME_UNKNOWN, sizeof(PROPERTY_NAME_UNKNOWN)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(PROPERTY_NAME_UNKNOWN); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID - * @testcase.desc : test TA call TEE_GetPropertyAsUUID while Name type is not UUID - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_SINGLEINSTANCE, sizeof(GPD_TA_SINGLEINSTANCE)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_SINGLEINSTANCE); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID2 - * @testcase.desc : test TA call TEE_GetPropertyAsUUID while Name type is not UUID, is string - * @testcase.expect : return TEEC_ERROR_BAD_FORMAT -*/ -TEE_TEST(TCF1Test, TEE_GetPropertyAsUUID_WithoutEnum_NameNotUUID2, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - int rc; - TestData value = { 0 }; - value.cmd = CMD_TEE_GetPropertyAsUUID; - value.propSet = TEE_PROPSET_CURRENT_TA; - rc = memcpy_s(value.inBuffer, BIG_SIZE, GPD_TA_DESCRIPTION, sizeof(GPD_TA_DESCRIPTION)); - ASSERT_EQ(rc, 0); - value.inBufferLen = sizeof(GPD_TA_DESCRIPTION); - - ret = Invoke_GetPropertyAsX(GetContext(), GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_FORMAT); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} diff --git a/test/xts/ca/tcf_api/src/property/get_prop_with_enumerator_test.cpp b/test/xts/ca/tcf_api/src/property/get_prop_with_enumerator_test.cpp deleted file mode 100644 index 04c89045..00000000 --- a/test/xts/ca/tcf_api/src/property/get_prop_with_enumerator_test.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; - -struct unIntMapping { - char *name; - uint32_t cmd; - ALL_PROP_SETS propSet; - char *expectResult; - uint32_t expectLen; -}; - -struct intMapping { - char *name; - uint32_t cmd; - ALL_PROP_SETS propSet; - uint64_t expectResult; -}; - -struct unIntMapping g_unIntMap[] = { - // bool - { (char*)GPD_TA_INSTANCEKEEPALIVE, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_CURRENT_TA, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - { (char*)GPD_TA_MULTISESSION, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_CURRENT_TA, - (char*)VALUE_PREDEFINED_BOOLEAN, sizeof(VALUE_PREDEFINED_BOOLEAN) }, - { (char*)GPD_TA_SINGLEINSTANCE, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_CURRENT_TA, - (char*)VALUE_PREDEFINED_BOOLEAN, sizeof(VALUE_PREDEFINED_BOOLEAN) }, - { (char*)GPD_TEE_CRYPTOGRAPHY_ECC, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - { (char*)GPD_TEE_CRYPTOGRAPHY_NIST, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - { (char*)GPD_TEE_CRYPTOGRAPHY_BSI_R, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - { (char*)GPD_TEE_CRYPTOGRAPHY_BSI_T, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - { (char*)GPD_TEE_CRYPTOGRAPHY_IETF, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - { (char*)GPD_TEE_CRYPTOGRAPHY_OCTA, CMD_TEE_GetPropertyAsBool, TEE_PROPSET_IMPLEMENTATION, - (char*)VALUE_PREDEFINED_FALSE, sizeof(VALUE_PREDEFINED_FALSE) }, - - // binaryblock - { (char*)SMC_TA_TESTBINARYBLOCK, CMD_TEE_GetPropertyAsBinaryBlock, TEE_PROPSET_CURRENT_TA, - (char*)VALUE_PREDEFINED_BINARY_BLOCK, sizeof(VALUE_PREDEFINED_BINARY_BLOCK) }, - - // uuid - { (char*)GPD_TA_APPID, CMD_TEE_GetPropertyAsUUID, TEE_PROPSET_CURRENT_TA, NULL, 0 }, - // do not test GPD_TEE_DEVICEID - { (char*)GPD_TEE_DEVICEID, CMD_TEE_GetPropertyAsUUID, TEE_PROPSET_IMPLEMENTATION, NULL, 0 }, - - // string - // this only test get uuid as string - { (char*)GPD_TA_APPID, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_CURRENT_TA, (char*)VALUE_PREDEFINED_UUID, BIG_SIZE }, - { (char*)GPD_CLIENT_IDENTITY, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_CURRENT_CLIENT, (char*)VALUE_PREDEFINED_CLIENT_IDENTITY, BIG_SIZE }, - { (char*)GPD_TA_VERSION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_CURRENT_TA, (char*)VALUE_PREDEFINED_TA_VERSION, BIG_SIZE }, - { (char*)GPD_TA_DESCRIPTION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_CURRENT_TA, (char*)VALUE_PREDEFINED_TA_DESCRIPTION, BIG_SIZE }, - { (char*)GPD_TEE_APIVERSION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_API_VERSION, BIG_SIZE }, - { (char*)GPD_TEE_DESCRIPTION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_BUILD_VER, BIG_SIZE }, - { (char*)GPD_TEE_TRUSTEDOS_IMP_VERSION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_IMP_VERSION, BIG_SIZE }, - { (char*)GPD_TEE_TRUSTEDOS_IMP_BINARYVERSION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_IMP_VERSION, BIG_SIZE }, - { (char*)GPD_TEE_FIRMWARE_IMP_VERSION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_IMP_VERSION, BIG_SIZE }, - { (char*)GPD_TEE_FIRMWARE_IMP_BINARYVERSION, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_IMP_VERSION, BIG_SIZE }, - { (char*)GPD_TEE_TRUSTEDOS_MANUFACTURER, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_MANUFACTURER, BIG_SIZE }, - { (char*)GPD_TEE_FIRMWARE_MANUFACTURER, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_MANUFACTURER, BIG_SIZE }, - { (char*)GPD_TEE_DEVICEID, CMD_TEE_GetPropertyAsString, - TEE_PROPSET_IMPLEMENTATION, (char*)TEE_FIRMWARE_MANUFACTURER, BIG_SIZE }, -}; - -struct intMapping g_intMap[] = { - // int32 - { (char*)GPD_TA_DATASIZE, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_CURRENT_TA, VALUE_PREDEFINED_DATASIZE }, - { (char*)GPD_TA_STACKSIZE, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_CURRENT_TA, VALUE_PREDEFINED_STACKSIZE }, - { (char*)GPD_TA_ENDIAN, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_CURRENT_TA, 0 }, - { (char*)GPD_CLIENT_ENDIAN, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_CURRENT_CLIENT, VALUE_PREDEFINED_CLIENT_ENDIAN }, - { (char*)GPD_TEE_INTERNALCORE_VERSION, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, TEE_INTERNAL_CORE_VERSION }, - { (char*)GPD_TEE_SYSTEM_TIME_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, TEE_TIME_PROTECT_LEVEL }, - { (char*)GPD_TEE_TA_PERSISTENT_TIME_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, TA_TIME_PROTECT_LEVEL }, - { (char*)GPD_TEE_ARITH_MAXBIGINTSIZE, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, MAX_BIG_INT_SIZE }, - { (char*)GPD_TEE_ANTIROLLBACK_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, 0 }, - { (char*)GPD_TEE_ROLLBACKDETECT_PROTECTIONLEVEL, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, 0 }, - { (char*)GPD_TEE_EVENT_MAXSOURCES, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, 0 }, - { (char*)GPD_TEE_API_LEVEL, CMD_TEE_GetPropertyAsU32, - TEE_PROPSET_IMPLEMENTATION, TEE_MAX_API_LEVEL_CONFIG }, - // int64 - { (char*)SMC_TA_TESTU64, CMD_TEE_GetPropertyAsU64, - TEE_PROPSET_CURRENT_TA, VALUE_PREDEFINED_U64 }, -}; - -TEEC_Result GetPropertyFromUnIntMap(TEEC_Context *context, TEEC_Session *session, TestData *val, int *flag) -{ - TEEC_Result result; - int i; - - for (i = 0; i < (sizeof(g_unIntMap) / sizeof(g_unIntMap[0])); i++) { - if (strncmp(val->inBuffer, g_unIntMap[i].name, val->inBufferLen) == 0) { - *flag = 1; - val->cmd = g_unIntMap[i].cmd; - result = Invoke_GetPropertyAsX(context, session, val); - if (result != TEEC_SUCCESS || val->origin != TEEC_ORIGIN_TRUSTED_APP) { - TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! result = 0x%x\n", val->inBuffer, result); - return result; - } - if (val->cmd != CMD_TEE_GetPropertyAsUUID) { - if (val->outBufferLen != g_unIntMap[i].expectLen || - (strncmp(val->outBuffer, g_unIntMap[i].expectResult, g_unIntMap[i].expectLen) != 0)) { - TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! outlen=0x%x, expect outlen=0x%x\n", - val->inBuffer, val->outBufferLen, g_unIntMap[i].expectLen); - TEST_PRINT_ERROR("outbuffer=%s, expect outbuffer=%s\n", val->outBuffer, g_unIntMap[i].expectResult); - return TEEC_ERROR_GENERIC; - } - } - return result; - } - } - return TEEC_SUCCESS; -} - -TEEC_Result GetPropertyFromIntMap(TEEC_Context *context, TEEC_Session *session, TestData *val, int *flag) -{ - TEEC_Result result; - int i; - - for (i = 0; i < (sizeof(g_intMap) / sizeof(g_intMap[0])); i++) { - if (strncmp(val->inBuffer, g_intMap[i].name, val->inBufferLen) == 0) { - *flag = 1; - val->cmd = g_intMap[i].cmd; - result = Invoke_GetPropertyAsX(context, session, val); - if (result != TEEC_SUCCESS || val->origin != TEEC_ORIGIN_TRUSTED_APP) { - TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! result = 0x%x\n", val->inBuffer, result); - return result; - } - if (val->cmd == CMD_TEE_GetPropertyAsU32) { - if (atoi(val->outBuffer) != (uint32_t)g_intMap[i].expectResult) { - TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! out=0x%x, expect out=0x%x\n", - val->inBuffer, atoi(val->outBuffer), (uint32_t)g_intMap[i].expectResult); - return TEEC_ERROR_GENERIC; - } - } else { - if (atoll(val->outBuffer) != g_intMap[i].expectResult) { - TEST_PRINT_ERROR("getProperty from Enumerator with %s is fail! out=0x%llx, expect out=0x%lu\n", - val->inBuffer, atoll(val->outBuffer), g_intMap[i].expectResult); - return TEEC_ERROR_GENERIC; - } - } - return result; - } - } - return TEEC_SUCCESS; -} - -/** - * @testcase.name : TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_TA - * @testcase.desc : test TA call TEE_AllocatePropertyEnumerator, TEE_StartPropertyEnumerator, TEE_GetPropertyName, - * TEE_GetNextProperty and TEE_GetPropertyAsX API to get all kinds of property from Enumerator for - * TEE_PROPSET_CURRENT_TA - * @testcase.expect : process success - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_TA, Function | MediumTest | Level0) -{ - TEEC_Result result, ret; - int rc, count = 0, findFlag = 0; - - // start PropertyEnumerator this api has no return value - value.cmd = CMD_TEE_StartPropertyEnumerator; - value.propSet = TEE_PROPSET_CURRENT_TA; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - do { - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.outBufferLen = BIG_SIZE; - result = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND)) - break; - ASSERT_EQ(result, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen); - value.inBufferLen = value.outBufferLen; - ASSERT_EQ(rc, 0); - count++; - - ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - - if (findFlag != 1) { - ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - } - - if (findFlag == 0) { - TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n"); - ASSERT_FALSE(1); - } - - value.cmd = CMD_TEE_GetNextPropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - findFlag = 0; - } while (result != TEEC_ERROR_ITEM_NOT_FOUND); -} - -/** - * @testcase.name : TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_CLIENT - * @testcase.desc : test TA call TEE_AllocatePropertyEnumerator, TEE_StartPropertyEnumerator, TEE_GetPropertyName, - * TEE_GetNextProperty and TEE_GetPropertyAsX API to get all kinds of property from Enumerator for - * TEE_PROPSET_CURRENT_CLIENT - * @testcase.expect : process success - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_TEE_PROPSET_CURRENT_CLIENT, Function | MediumTest | Level0) -{ - TEEC_Result result, ret; - int rc, count = 0, findFlag = 0; - - // start PropertyEnumerator this api has no return value - value.cmd = CMD_TEE_StartPropertyEnumerator; - value.propSet = TEE_PROPSET_CURRENT_CLIENT; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - do { - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.outBufferLen = BIG_SIZE; - result = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND)) - break; - ASSERT_EQ(result, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen); - value.inBufferLen = value.outBufferLen; - ASSERT_EQ(rc, 0); - count++; - - ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - - if (findFlag != 1) { - ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - } - - if (findFlag == 0) { - TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n"); - ASSERT_FALSE(1); - } - - value.cmd = CMD_TEE_GetNextPropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - findFlag = 0; - } while (result != TEEC_ERROR_ITEM_NOT_FOUND); -} - -/** - * @testcase.name : TEE_GetProperty_WithEnum_TEE_PROPSET_IMPLEMENTATION - * @testcase.desc : test TA call TEE_AllocatePropertyEnumerator, TEE_StartPropertyEnumerator, TEE_GetPropertyName, - * TEE_GetNextProperty and TEE_GetPropertyAsX API to get all kinds of property from Enumerator for - * TEE_PROPSET_IMPLEMENTATION - * @testcase.expect : process success - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_TEE_PROPSET_IMPLEMENTATION, Function | MediumTest | Level0) -{ - TEEC_Result result, ret; - int rc, count = 0, findFlag = 0; - - // start PropertyEnumerator this api has no return value - value.cmd = CMD_TEE_StartPropertyEnumerator; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - do { - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.outBufferLen = BIG_SIZE; - result = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND)) - break; - ASSERT_EQ(result, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen); - value.inBufferLen = value.outBufferLen; - ASSERT_EQ(rc, 0); - count++; - - ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - - if (findFlag != 1) { - ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - } - - if (findFlag == 0) { - TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n"); - ASSERT_FALSE(1); - } - - value.cmd = CMD_TEE_GetNextPropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - findFlag = 0; - } while (result != TEEC_ERROR_ITEM_NOT_FOUND); -} - -/** - * @testcase.name : TEE_GetProperty_WithEnum_WithResetEnum - * @testcase.desc : test TA call TEE_AllocatePropertyEnumerator , TEE_StartPropertyEnumerator, - * TEE_ResetPropertyEnumerator, TEE_GetPropertyName, TEE_GetNextProperty and TEE_GetPropertyAsX - * API to get all kinds of property from Enumerator for TEE_PROPSET_CURRENT_CLIENT - * @testcase.expect : process success - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetProperty_WithEnum_WithResetEnum, Function | MediumTest | Level0) -{ - TEEC_Result result, ret; - int rc, count = 0, findFlag = 0; - - // start PropertyEnumerator this api has no return value - value.cmd = CMD_TEE_StartPropertyEnumerator; - value.propSet = TEE_PROPSET_CURRENT_CLIENT; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - do { - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.outBufferLen = BIG_SIZE; - result = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - if ((count != 0) && (result == TEEC_ERROR_ITEM_NOT_FOUND)) - break; - ASSERT_EQ(result, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - rc = memcpy_s(value.inBuffer, BIG_SIZE, value.outBuffer, value.outBufferLen); - value.inBufferLen = value.outBufferLen; - ASSERT_EQ(rc, 0); - count++; - - ret = GetPropertyFromUnIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - - if (findFlag != 1) { - ret = GetPropertyFromIntMap(GetContext(), GetSession(), &value, &findFlag); - ASSERT_EQ(ret, TEEC_SUCCESS); - } - - if (findFlag == 0) { - TEST_PRINT_ERROR("get PropertyName from Enumerator is undefined!\n"); - ASSERT_FALSE(1); - } - - value.cmd = CMD_TEE_GetNextPropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - findFlag = 0; - } while (result != TEEC_ERROR_ITEM_NOT_FOUND); - - // reset PropertyEnumerator this api has no return value - value.cmd = CMD_TEE_ResetPropertyEnumerator; - value.propSet = TEE_PROPSET_IMPLEMENTATION; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - // get PropertyEnumerator after reset - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.outBufferLen = BIG_SIZE; - result = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - ASSERT_EQ(result, TEEC_ERROR_ITEM_NOT_FOUND); -} - -/** - * @testcase.name : TEE_AllocatePropertyEnumerator_EnumIsNull - * @testcase.desc : test TA call TEE_AllocatePropertyEnumerator while Enumerator is NULL - * property from TEE_PROPSET_CURRENT_TA - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF1Test, TEE_AllocatePropertyEnumerator_EnumIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestData value = { 0 }; - value.cmd = CMD_TEE_AllocatePropertyEnumerator; - value.caseId = OUTPUT_ISNULL; - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_AllocatePropertyEnumerator_MaxEnum - * @testcase.desc : test TA call TEE_AllocatePropertyEnumerator alloc PropertyEnumerator reach max numbers limit - * property from TEE_PROPSET_CURRENT_TA - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(TCF1Test, TEE_AllocatePropertyEnumerator_MaxEnum, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestData value = { 0 }; - value.cmd = CMD_TEE_AllocatePropertyEnumerator; - - for (int i = 1; i <= MAX_ENUMERATOR; i++) { - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - } - - // then alloc 1024th Enumerator,should fail - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_OUT_OF_MEMORY); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.enumerator, 0); - - // intend to free enumerator which NO is MAX_ENUMERATOR - value.enumerator = MAX_ENUMERATOR; - value.cmd = CMD_TEE_FreePropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - value.cmd = CMD_TEE_AllocatePropertyEnumerator; - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - ASSERT_EQ(value.enumerator, MAX_ENUMERATOR); -} - -/** - * @testcase.name : TEE_GetPropertyName_BufferIsNull - * @testcase.desc : test TA call TEE_GetPropertyName while output buffer is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetPropertyName_BufferIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - // get Property from Enumerator - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.caseId = OUTPUT_ISNULL; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyName_BufferSizeIsNull - * @testcase.desc : test TA call TEE_GetPropertyName while output buffer size is null - * @testcase.expect : return TEEC_ERROR_BAD_PARAMETERS - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetPropertyName_BufferSizeIsNull, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - // get Property from Enumerator - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.caseId = OUTPUTBUFFERSIZE_ISNULL; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_BAD_PARAMETERS); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyName_BufferSizeTooShort - * @testcase.desc : test TA call TEE_GetPropertyName while output buffer size too short - * @testcase.expect : return TEEC_ERROR_SHORT_BUFFER - */ -TEE_TEST(TCF1ENUM_Test, TEE_GetPropertyName_BufferSizeTooShort, Function | MediumTest | Level0) -{ - TEEC_Result ret; - - // start PropertyEnumerator this api has no return value - value.cmd = CMD_TEE_StartPropertyEnumerator; - value.propSet = TEE_PROPSET_CURRENT_TA; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); - - // get Property from Enumerator - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.caseId = OUTPUTBUFFERSIZE_TOOSHORT; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_ERROR_SHORT_BUFFER); - ASSERT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyName_EnumeratorNotAlloc - * @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not alloc - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyName_EnumeratorNotAlloc, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestData value = { 0 }; - - // get Property from Enumerator - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.enumerator = ENUMERATOR1; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetPropertyName_EnumeratorNotStart - * @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not start - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetPropertyName_EnumeratorNotStart, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestData value = { 0 }; - - // alloc PropertyEnumerator - value.cmd = CMD_TEE_AllocatePropertyEnumerator; - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_EQ(value.enumerator, ENUMERATOR1); - - // get Property from Enumerator - value.cmd = CMD_TEE_GetPropertyNameEnumerator; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - - value.cmd = CMD_TEE_FreePropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); -} - -/** - * @testcase.name : TEE_GetNextProperty_EnumeratorNotAlloc - * @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not alloc - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetNextProperty_EnumeratorNotAlloc, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestData value = { 0 }; - - // get next Property from Enumerator - value.cmd = CMD_TEE_GetNextPropertyEnumerator; - value.enumerator = ENUMERATOR1; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : TEE_GetNextProperty_EnumeratorNotStart - * @testcase.desc : test TA call TEE_GetPropertyName while Enumerator is not start - * @testcase.expect : return TEEC_ERROR_ITEM_NOT_FOUND - */ -TEE_TEST(TCF1Test, TEE_GetNextProperty_EnumeratorNotStart, Function | MediumTest | Level0) -{ - TEEC_Result ret; - TestData value = { 0 }; - - // alloc PropertyEnumerator - value.cmd = CMD_TEE_AllocatePropertyEnumerator; - ret = Invoke_AllocatePropertyEnumerator(GetSession(), &value); - ASSERT_EQ(ret, TEEC_SUCCESS); - EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - EXPECT_EQ(value.enumerator, ENUMERATOR1); - - // get next Property from Enumerator - value.cmd = CMD_TEE_GetNextPropertyEnumerator; - value.outBufferLen = BIG_SIZE; - ret = Invoke_Operate_PropertyEnumerator(GetSession(), &value); - EXPECT_EQ(ret, TEEC_ERROR_ITEM_NOT_FOUND); - EXPECT_EQ(value.origin, TEEC_ORIGIN_TRUSTED_APP); - - value.cmd = CMD_TEE_FreePropertyEnumerator; - Invoke_Operate_PropertyEnumerator(GetSession(), &value); -} diff --git a/test/xts/ca/tee_test_drv/CMakeLists.txt b/test/xts/ca/tee_test_drv/CMakeLists.txt deleted file mode 100644 index dade28d8..00000000 --- a/test/xts/ca/tee_test_drv/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(ca_sources) -list(APPEND ca_sources - src/tee_test_drv.cpp -) - -ca_compile_pub( - TEST_NAME - tee_test_drv - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - include - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ca/tee_test_drv/include/tee_test_drv.h b/test/xts/ca/tee_test_drv/include/tee_test_drv.h deleted file mode 100644 index 798195af..00000000 --- a/test/xts/ca/tee_test_drv/include/tee_test_drv.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEE_TEST_DRV_H__ -#define __TEE_TEST_DRV_H__ - -#ifdef __cplusplus -#include -#endif - -#define DRVCALLER_UUID \ - { \ - 0x534d4152, 0x542d, 0x4353, \ - { \ - 0xb9, 0x19, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0xc9 \ - } \ - } - -#endif \ No newline at end of file diff --git a/test/xts/ca/tee_test_drv/src/tee_test_drv.cpp b/test/xts/ca/tee_test_drv/src/tee_test_drv.cpp deleted file mode 100644 index 465fd985..00000000 --- a/test/xts/ca/tee_test_drv/src/tee_test_drv.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -#include -#include -#include - -#include "tee_test_drv.h" -#include -#include - -using namespace std; -using namespace testing::ext; -/** - * @testcase.name : DrvAPITest_Drv_Virt_To_Phys - * @testcase.desc : test drv call drv_virt_to_phys api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, DrvAPITest_Drv_Virt_To_Phys, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - ClientSessionMgr sess; - TEEC_UUID testId = DRVCALLER_UUID; - ret = sess.Start(&testId); - EXPECT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, DRVTEST_COMMAND_DRVVIRTTOPHYS, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : DrvAPITest_Copy_From_Client - * @testcase.desc : test drv call copy_from_client api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, DrvAPITest_Copy_From_Client, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - ClientSessionMgr sess; - TEEC_UUID testId = DRVCALLER_UUID; - ret = sess.Start(&testId); - EXPECT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, DRVTEST_COMMAND_COPYFROMCLIENT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} - -/** - * @testcase.name : DrvAPITest_Copy_To_Client - * @testcase.desc : test drv call copy_to_client api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, DrvAPITest_Copy_To_Client, Function | MediumTest | Level0) -{ - TEEC_Result ret; - uint32_t origin; - ClientSessionMgr sess; - TEEC_UUID testId = DRVCALLER_UUID; - ret = sess.Start(&testId); - EXPECT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, DRVTEST_COMMAND_COPYTOCLIENT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - ASSERT_EQ(origin, TEEC_ORIGIN_TRUSTED_APP); -} \ No newline at end of file diff --git a/test/xts/ca/time_api/CMakeLists.txt b/test/xts/ca/time_api/CMakeLists.txt deleted file mode 100644 index 64269d52..00000000 --- a/test/xts/ca/time_api/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(ca_sources) -list(APPEND ca_sources - src/tee_test_time_api.cpp -) - -ca_compile_pub( - TEST_NAME - time_api - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - common - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ca/time_api/common/common_test.h b/test/xts/ca/time_api/common/common_test.h deleted file mode 100644 index 723f4267..00000000 --- a/test/xts/ca/time_api/common/common_test.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __COMMON_TEST_H__ -#define __COMMON_TEST_H__ - -#include -#include - -#define ARITHMETIC_API_UUID \ - { \ - 0xe7d4c078, 0xb19f, 0x4f97, \ - { \ - 0xa2, 0x2d, 0xf4, 0xaf, 0xd6, 0xae, 0x7a, 0x0e \ - } \ - } - -enum TEST_TIME_API_CMD_ID { - CMD_ID_TEST_GET_SYSTEM_TIME = 0, - CMD_ID_TEST_GET_REE_TIME, - CMD_ID_TEST_TEE_WAIT, - CMD_ID_ONLY_GET_PERSISTENT_TIME, - CMD_ID_TEST_GET_PERSISTENT_TIME, - CMD_ID_TEST_SET_PERSISTENT_TIME, // 5 - CMD_ID_TEST_PERSISTENT_TIME_WITH_EXCEPTION, -}; - -#endif diff --git a/test/xts/ca/time_api/src/tee_test_time_api.cpp b/test/xts/ca/time_api/src/tee_test_time_api.cpp deleted file mode 100644 index ddb9f1ad..00000000 --- a/test/xts/ca/time_api/src/tee_test_time_api.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace testing::ext; -/** - * @testcase.name : GetSystemTime - * @testcase.desc : test TEE_GetSystemTime api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, TEE_GetSystemTime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - TEEC_Operation operation = {0}; - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE); - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_SYSTEM_TIME, &operation, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - uint32_t time1 = operation.params[1].value.a; - - sleep(3); // wait for 3s - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_SYSTEM_TIME, &operation, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - - uint32_t time2 = operation.params[1].value.a; - ASSERT_LT(time1, time2); - sess.Destroy(); -} -#if 0 -/** - * @testcase.name : TeeWait - * @testcase.desc : test TEE_Wait api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, TeeWait, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_TEE_WAIT, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : GetPersistentTime - * @testcase.desc : test get persistent time - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, GetPersistentTime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_PERSISTENT_TIME, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : SetPersistentTime - * @testcase.desc : test set persistent time - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, SetPersistentTime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_SET_PERSISTENT_TIME, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : TestPersistentTimeWithException - * @testcase.desc : test set and get persistent time with exception - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, TestPersistentTimeWithException, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_PERSISTENT_TIME_WITH_EXCEPTION, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} -#endif -/** - * @testcase.name : OnlyGetPersistentTime - * @testcase.desc : test only get persistent time - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, OnlyGetPersistentTime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_ONLY_GET_PERSISTENT_TIME, NULL, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - sess.Destroy(); -} - -/** - * @testcase.name : GetReeTime - * @testcase.desc : test TEE_GetREETime api - * @testcase.expect : return TEEC_SUCCESS - */ -TEE_TEST(EmptyTest, GetReeTime, Function | MediumTest | Level0) -{ - ClientSessionMgr sess; - uint32_t origin; - TEEC_UUID testId = ARITHMETIC_API_UUID; - TEEC_Result ret = sess.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - - TEEC_Operation operation = {0}; - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE); - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_REE_TIME, &operation, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - uint32_t time1 = operation.params[1].value.a; - - sleep(3); // wait for 3s - ret = TEEC_InvokeCommand(&sess.session, CMD_ID_TEST_GET_REE_TIME, &operation, &origin); - ASSERT_EQ(ret, TEEC_SUCCESS); - - uint32_t time2 = operation.params[1].value.a; - ASSERT_LT(time1, time2); - sess.Destroy(); -} diff --git a/test/xts/ca/trusted_storage_api/CMakeLists.txt b/test/xts/ca/trusted_storage_api/CMakeLists.txt deleted file mode 100644 index 2e29f16c..00000000 --- a/test/xts/ca/trusted_storage_api/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(ca_sources) -list(APPEND ca_sources - common/common_test.cpp - src/tee_test_trusted_storage_api.cpp -) - -ca_compile_pub( - TEST_NAME - trusted_storage_api - - SRC_LIST - ${ca_sources} - - INCLUDE_DIRS - common - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ca/trusted_storage_api/common/common_test.cpp b/test/xts/ca/trusted_storage_api/common/common_test.cpp deleted file mode 100644 index 6a564f1c..00000000 --- a/test/xts/ca/trusted_storage_api/common/common_test.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -void TrustedStorageTest::SetUp() -{ - TEEC_Result ret; - TEEC_UUID testId = TRUSTED_STORAGE_API_UUID; - ret = session.Start(&testId); - ASSERT_EQ(ret, TEEC_SUCCESS); - operation.started = 1; - operation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_WHOLE, TEEC_NONE, TEEC_NONE, TEEC_NONE); - (void)memset_s(&testMem.sharedMem, FUN_NAME_LEN, 0, FUN_NAME_LEN); - testMem.sharedMem.size = FUN_NAME_LEN; - testMem.sharedMem.flags = TEEC_MEM_OUTPUT | TEEC_MEM_INPUT; - ret = TEEC_AllocateSharedMemory(&session.context, &testMem.sharedMem); - ASSERT_EQ(ret, TEEC_SUCCESS); -} - -void TrustedStorageTest::TearDown() -{ - TEEC_ReleaseSharedMemory(&testMem.sharedMem); - session.Destroy(); -} - -TEEC_Result TrustedStorageTest::InvokeTest(const char *casename) -{ - int rc = strcpy_s(reinterpret_cast(testMem.sharedMem.buffer), FUN_NAME_LEN, casename); - if (rc != 0) { - return TEEC_FAIL; - } - operation.params[0].memref.parent = &testMem.sharedMem; - operation.params[0].memref.offset = 0; - operation.params[0].memref.size = testMem.sharedMem.size; - return TEEC_InvokeCommand(&session.session, CMD_RUN_BY_FUN_SEQ, &operation, &origin); -} diff --git a/test/xts/ca/trusted_storage_api/common/common_test.h b/test/xts/ca/trusted_storage_api/common/common_test.h deleted file mode 100644 index 1e20f469..00000000 --- a/test/xts/ca/trusted_storage_api/common/common_test.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TRUSTED_STORAGE_COMMON_TEST_H__ -#define __TRUSTED_STORAGE_COMMON_TEST_H__ - -#include -#include - -#define TRUSTED_STORAGE_API_UUID \ - { \ - 0x09090909, 0x0808, 0x0707, \ - { \ - 0x03, 0x03, 0x03, 0x03, 0x05, 0x07, 0x09, 0x01 \ - } \ - } - -#define FUN_NAME_LEN 64 -enum TEST_TRUSTED_STORAGE_API_CMD_ID { - CMD_RUN_BY_FUN_SEQ = 0, -}; - -class TrustedStorageTest : public EmptyTest { -protected: - ClientSessionMgr session; - TEEC_Operation operation = { 0 }; - uint32_t origin; - ClientShareMemMgr testMem; - -public: - void SetUp(); - void TearDown(); - TEEC_Result InvokeTest(const char *casename); -}; - -#define TRUSTED_STORAGE_TEST_EQ(casename) \ - TEE_TEST(TrustedStorageTest, casename, Function | MediumTest | Level0) \ - { \ - TEEC_Result ret = InvokeTest(#casename); \ - ASSERT_EQ(ret, TEEC_SUCCESS); \ - } - -#define TRUSTED_STORAGE_TEST_NE(casename) \ - TEE_TEST(TrustedStorageTest, casename, Function | MediumTest | Level0) \ - { \ - TEEC_Result ret = InvokeTest(#casename); \ - ASSERT_NE(ret, TEEC_SUCCESS); \ - } -#endif diff --git a/test/xts/ca/trusted_storage_api/src/tee_test_trusted_storage_api.cpp b/test/xts/ca/trusted_storage_api/src/tee_test_trusted_storage_api.cpp deleted file mode 100644 index 67cd7ec7..00000000 --- a/test/xts/ca/trusted_storage_api/src/tee_test_trusted_storage_api.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include - -using namespace testing::ext; -/** - * @testcase.name : CaseCreatePersistentObjectAndDelete - * @testcase.desc : test GP interfaces - * TEE_CreatePersistentObject, TEE_CloseAndDeletePersistentObject1, - * TEE_WriteObjectData, TEE_ReadObjectData, TEE_SeekObjectData, - * TEE_OpenPersistentObject, TEE_CloseObject - * @testcase.expect : return TEEC_SUCCESS - */ -TRUSTED_STORAGE_TEST_EQ(CaseCreatePersistentObjectAndDelete); - -/** - * @testcase.name : CaseRenameObjectAndGetInfo - * @testcase.desc : test GP interfaces - * TEE_TruncateObjectData, TEE_RenamePersistentObject, GetObjectInfo, - * @testcase.expect : return TEEC_SUCCESS - */ -TRUSTED_STORAGE_TEST_EQ(CaseRenameObjectAndGetInfo); - -/** - * @testcase.name : CaseEnumerateDeleteAllObject - * @testcase.desc : test GP interfaces - * TEE_AllocatePersistentObjectEnumerator, TEE_FreePersistentObjectEnumerator, - * TEE_ResetPersistentObjectEnumerator, TEE_StartPersistentObjectEnumerator, - * TEE_GetNextPersistentObject - * @testcase.expect : return TEEC_SUCCESS - */ -TRUSTED_STORAGE_TEST_EQ(CaseEnumerateDeleteAllObject); - -/** - * @testcase.name : CaseRestrictObjectUsage - * @testcase.desc : test GP interfaces - * TEE_AllocateTransientObject, TEE_FreeTransientObject, - * TEE_RestrictObjectUsage1, TEE_ResetTransientObject - * @testcase.expect : return TEEC_SUCCESS - */ -TRUSTED_STORAGE_TEST_EQ(CaseRestrictObjectUsage); - -/** - * @testcase.name : CasePopulateAndCopyObject - * @testcase.desc : test GP interfaces - * TEE_InitRefAttribute, TEE_InitValueAttribute, - * TEE_PopulateTransientObject, TEE_CopyObjectAttributes1, - * TEE_GetObjectBufferAttribute, TEE_GetObjectValueAttribute - * @testcase.expect : return TEEC_SUCCESS - */ -TRUSTED_STORAGE_TEST_EQ(CasePopulateAndCopyObject); - -/** - * @testcase.name : CaseGenerateKey - * @testcase.desc : test GP interfaces TEE_GenerateKey - * @testcase.expect : return TEEC_SUCCESS - */ -TRUSTED_STORAGE_TEST_EQ(CaseGenerateKey); diff --git a/test/xts/cmake/common.cmake b/test/xts/cmake/common.cmake deleted file mode 100644 index 7067392d..00000000 --- a/test/xts/cmake/common.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(TEE_TEST_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(REPO_ROOT_DIR ${TEE_TEST_ROOT_DIR}/../../../..) -set(TEE_DEV_KIT_DIR ${TEE_TEST_ROOT_DIR}/../../tee_dev_kit) - -set(TEE_BUILD_OUT_DIR ${TEE_TEST_ROOT_DIR}/output) -set(LIBRARY_OUTPUT_PATH ${TEE_BUILD_OUT_DIR}) - -if ("${TARGET_IS_ARM64}" STREQUAL "") - set(TARGET_IS_ARM64 n) -endif() - -include(${TEE_TEST_ROOT_DIR}/cmake/ta.cmake) diff --git a/test/xts/cmake/drv.cmake b/test/xts/cmake/drv.cmake deleted file mode 100644 index c6f2ad2b..00000000 --- a/test/xts/cmake/drv.cmake +++ /dev/null @@ -1,93 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -include(${TEE_DEV_KIT_DIR}/ddk/build/cmake/common.cmake) - -set(PUB_DRV_INCLUDE_DIRS) -list(APPEND PUB_DRV_INCLUDE_DIRS - ${TEE_DEV_KIT_DIR}/ddk/include - ${TEE_DEV_KIT_DIR}/sdk/include/TA - ${TEE_DEV_KIT_DIR}/sdk/include/TA/ext - ${TEE_TEST_ROOT_DIR}/utils/include - ${TEE_TEST_ROOT_DIR}/utils/cmd_id - /usr/include/aarch64-linux-android -) - -set(PUB_DRV_COMPILE_OPTS) -list(APPEND PUB_DRV_COMPILE_OPTS - -Wall - -Werror - -fstack-protector-all - --target=aarch64-linux-android21 - -fvisibility=default - -fno-exceptions - -fno-common -) - -set(PUB_DRV_COMPILE_DEFS) -list(APPEND PUB_DRV_COMPILE_DEFS - # Test Macros Here -) - -macro(drv_compile_pub) - cmake_parse_arguments( - DRV - "" - "" - "ELF_NAME;SRC_LIST;INCLUDE_DIRS;COMPILE_OPTS;COMPILE_DEFS" - ${ARGN} - ) - - message("DRV_ELF_NAME = ${DRV_ELF_NAME}") - message("DRV_SRC_LIST = ${DRV_SRC_LIST}") - message("DRV_INCLUDE_DIRS = ${DRV_INCLUDE_DIRS}") - message("DRV_COMPILE_OPTS = ${DRV_COMPILE_OPTS}") - message("DRV_COMPILE_DEFS = ${DRV_COMPILE_DEFS}") - - add_executable(${DRV_ELF_NAME}) - target_sources(${DRV_ELF_NAME} PRIVATE - ${DRV_SRC_LIST} - ) - - target_include_directories(${DRV_ELF_NAME} PRIVATE - ${DRV_INCLUDE_DIRS} - ${PUB_DRV_INCLUDE_DIRS} - ) - - target_compile_options(${DRV_ELF_NAME} PRIVATE - ${DRV_COMPILE_OPTS} - ${PUB_DRV_COMPILE_OPTS} - ) - - target_compile_definitions(${DRV_ELF_NAME} PRIVATE - ${DRV_COMPILE_DEFS} - ${PUB_DRV_COMPILE_DEFS} - ) - - target_link_options(${DRV_ELF_NAME} PRIVATE - -v - -s - -nostdlib - -Wl,--discard-all - -Wl,-z,text - -Wl,-z,now - -Wl,-z,relro - -Wl,-shared - -Wl,-z,noexecstack - ) - target_link_directories(${DRV_ELF_NAME} PRIVATE - ${TEE_TEST_ROOT_DIR}/bin - ) - - target_link_libraries(${DRV_ELF_NAME} PRIVATE - ) -endmacro() diff --git a/test/xts/cmake/ta.cmake b/test/xts/cmake/ta.cmake deleted file mode 100644 index 84c62ec5..00000000 --- a/test/xts/cmake/ta.cmake +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -include(${TEE_DEV_KIT_DIR}/sdk/build/cmake/common.cmake) - -set(PUB_TA_INCLUDE_DIRS) -list(APPEND PUB_TA_INCLUDE_DIRS - ${TEE_TEST_ROOT_DIR}/utils/include - ${TEE_TEST_ROOT_DIR}/utils/cmd_id -) - -macro(ta_compile_pub) - cmake_parse_arguments( - TA - "" - "" - "ELF_NAME;SRC_LIST;INCLUDE_DIRS;COMPILE_OPTS;COMPILE_DEFS" - ${ARGN} - ) - - add_library(${TA_ELF_NAME} SHARED) - target_sources(${TA_ELF_NAME} PRIVATE - ${TA_SRC_LIST} - ${SDK_C_SOURCES} - ) - - target_include_directories(${TA_ELF_NAME} PRIVATE - ${PUB_TA_INCLUDE_DIRS} - ${TA_INCLUDE_DIRS} - ${COMMON_INCLUDES} - ) - - target_compile_options(${TA_ELF_NAME} PRIVATE - ${TA_COMPILE_OPTS} - ${COMMON_CFLAGS} - ) - - target_compile_definitions(${TA_ELF_NAME} PRIVATE - ${TA_COMPILE_DEFS} - ) - - target_link_options(${TA_ELF_NAME} PRIVATE - -v - ${COMMON_LDFLAGS} - ) - - target_link_directories(${TA_ELF_NAME} PRIVATE - ${TEE_TEST_ROOT_DIR}/bin - ) - - target_link_libraries(${TA_ELF_NAME} PRIVATE - ) -endmacro() - -macro(ta_entry_check) - cmake_parse_arguments( - SIGN - "" - "" - "TARGET_NAME" - ${ARGN} - ) - - add_custom_command( - TARGET ${SIGN_TARGET_NAME} POST_BUILD - COMMAND sh $ENV{TEE_BUILD_PATH}/build/tools/ta_entry_check.sh ${CMAKE_READELF} ${TEE_BUILD_OUT_DIR}/lib${SIGN_TARGET_NAME}.so n y ${TARGET_IS_ARM64} - ) -endmacro() diff --git a/test/xts/driver/CMakeLists.txt b/test/xts/driver/CMakeLists.txt deleted file mode 100644 index b6660815..00000000 --- a/test/xts/driver/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -add_subdirectory(drv_test_module) \ No newline at end of file diff --git a/test/xts/driver/drv_test_module/CMakeLists.txt b/test/xts/driver/drv_test_module/CMakeLists.txt deleted file mode 100644 index 3a953130..00000000 --- a/test/xts/driver/drv_test_module/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -set(drv_sources) -list(APPEND drv_sources - src/drv_test_module.c -) - -list(APPEND header_dir - include -) - -drv_compile_pub( - ELF_NAME - drv_test_module.elf - - SRC_LIST - ${drv_sources} - - INCLUDE_DIRS - ${header_dir} - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/driver/drv_test_module/drv_test_module.csv b/test/xts/driver/drv_test_module/drv_test_module.csv deleted file mode 100644 index fb621377..00000000 --- a/test/xts/driver/drv_test_module/drv_test_module.csv +++ /dev/null @@ -1,22 +0,0 @@ -perm1,1 -perm2,2 -perm3,3 -perm4,4 -perm5,5 -perm6,6 -perm7,7 -perm8,8 -perm9,9 -perm10,10 -iomap_perm,11 -SHARE_BUFFER_TEST_ID,0x10 -ARGS_TEST_ID,0x11 -BUFFER_TEST_ID,0x12 -RETURN_EXCEPTION_ID,0x13 -SLEEP_TEST_ID,0x14 -MAX_BUFFER_TEST_ID,0x15 -CRASH_TEST_ID,0x16 -NO_PARAM_TEST_ID,0x17 -CALL_OTHER_DRV_TEST_ID,0x18 -STRING_TEST_ID,0x19 -IOMAP_TEST_ID,0x1a diff --git a/test/xts/driver/drv_test_module/dyn_perm.xml b/test/xts/driver/drv_test_module/dyn_perm.xml deleted file mode 100644 index f9d38d8d..00000000 --- a/test/xts/driver/drv_test_module/dyn_perm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - diff --git a/test/xts/driver/drv_test_module/include/drv_test_module.h b/test/xts/driver/drv_test_module/include/drv_test_module.h deleted file mode 100644 index 118b38c0..00000000 --- a/test/xts/driver/drv_test_module/include/drv_test_module.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __DRV_TEST_MODULE_H__ -#define __DRV_TEST_MODULE_H__ -#include -#include - -#define DRV_NAME_MAX_LEN 32U -#define DRV_RESERVED_NUM 8U -#define driver_log(fmt, args...) tee_print(LOG_LEVEL_ERROR, "%s %d: %s" fmt " ", TAG_ERROR, __LINE__, g_log_tag, ##args) - -struct drv_data { - int32_t fd; /* unique label which alloced by driver framework */ - uint32_t taskid; /* caller taskid */ - void *private_data; /* the private data associated with this fd */ - struct tee_uuid uuid; /* caller uuid */ -}; - -struct share_buffer_arg { - uint64_t addr; - uint32_t len; - uint32_t share_token; -}; - -typedef int32_t (*init_func)(void); - -typedef int32_t (*suspned_func)(void); -typedef int32_t (*resume_func)(void); - -typedef int64_t (*ioctl_func)(struct drv_data *drv, uint32_t cmd, unsigned long args, uint32_t args_len); -typedef int64_t (*open_func)(struct drv_data *drv, unsigned long args, uint32_t args_len); -typedef int64_t (*close_func)(struct drv_data *drv); - -struct tee_driver_module { - init_func init; - ioctl_func ioctl; - open_func open; - close_func close; - suspned_func suspend; - resume_func resume; - suspned_func suspend_s4; - resume_func resume_s4; - uint64_t reserved[DRV_RESERVED_NUM]; /* has not used, just reserved */ -}; - -#define tee_driver_declare(name, init, open, ioctl, close, suspend, resume, suspend_s4, resume_s4) \ -__attribute__((visibility("default"))) const struct tee_driver_module g_driver_##name = { \ - init, ioctl, open, close, suspend, resume, suspend_s4, resume_s4, {0} } - -#endif /* __DRV_TEST_MODULE_H__ */ diff --git a/test/xts/driver/drv_test_module/manifest.txt b/test/xts/driver/drv_test_module/manifest.txt deleted file mode 100644 index 2bd1e027..00000000 --- a/test/xts/driver/drv_test_module/manifest.txt +++ /dev/null @@ -1,6 +0,0 @@ -gpd.ta.appID: 11112222-0000-0000-0000-111111111111 -gpd.ta.service_name: drv_test_module -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 1048576 -gpd.ta.stackSize: 8192 -gpd.ta.target_type: 1 diff --git a/test/xts/driver/drv_test_module/src/drv_test_module.c b/test/xts/driver/drv_test_module/src/drv_test_module.c deleted file mode 100644 index c49312c0..00000000 --- a/test/xts/driver/drv_test_module/src/drv_test_module.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "drv_addr_share.h" -#include "drv_param_ops.h" -#include "drv_test_module.h" -#include "tee_log.h" -#include "test_drv_cmdid.h" - -#define TOKEN_BUF_SIZE 0x1000 -#define BUFFER_SIZE 1024 - -const char *g_log_tag = "[32-1 drv] "; - -static int64_t virt2phys_test() -{ - uint64_t va; - uint64_t pa = drv_virt_to_phys((uintptr_t)&va); - if (pa == 0) { - driver_log("drv virt_to phys failed\n"); - return -1; - } - - driver_log("drv virt_to phys success\n"); - return 0; -} - -static int32_t copy_from_client_exception_test(struct share_buffer_arg *input_arg, char *temp_buffer) -{ - driver_log("copy from client exception test begin\n"); - int32_t ret = copy_from_client(0, input_arg->len, (uintptr_t)temp_buffer, input_arg->len); - ret &= copy_from_client(input_arg->addr, 0, (uintptr_t)temp_buffer, input_arg->len); - ret &= copy_from_client(input_arg->addr, input_arg->len, 0, input_arg->len); - ret &= copy_from_client(input_arg->addr, input_arg->len, (uintptr_t)temp_buffer, 0); - ret &= copy_from_client(input_arg->addr, input_arg->len, (uintptr_t)temp_buffer, input_arg->len - 1); - if (ret == 0) { - driver_log("copy from client exception test FAIL\n"); - return -1; - } - - driver_log("copy from client exception test SUCC\n"); - return 0; -} - -static int32_t copy_from_client_test(struct share_buffer_arg *input_arg, char *temp_buffer, uint32_t size) -{ - driver_log("copy from client test begin\n"); - int32_t ret; - char drvcaller_input[] = "the param is drvcaller_input"; - uint32_t drvcaller_input_len; - drvcaller_input_len = strlen(drvcaller_input) + 1; - - ret = copy_from_client(input_arg->addr, input_arg->len, (uintptr_t)temp_buffer, size); - if (ret != 0 || strncmp(drvcaller_input, (char *)temp_buffer, drvcaller_input_len) != 0 || - input_arg->len != BUFFER_SIZE) { - driver_log("test copy_from_client failed,ret = 0x%x, received buffer is: %s, received lens is: %d\n", ret, - temp_buffer, input_arg->len); - return -1; - } - - if (copy_from_client_exception_test(input_arg, temp_buffer) != 0) { - return -1; - } - return ret; -} - -static int32_t copy_to_client_exception_test(struct share_buffer_arg *input_arg, char *temp_buffer) -{ - driver_log("copy to client exception test begin\n"); - int32_t ret = copy_to_client(0, input_arg->len, input_arg->addr, input_arg->len); - ret &= copy_to_client((uintptr_t)temp_buffer, 0, input_arg->addr, input_arg->len); - ret &= copy_to_client((uintptr_t)temp_buffer, input_arg->len, 0, input_arg->len); - ret &= copy_to_client((uintptr_t)temp_buffer, input_arg->len, input_arg->addr, 0); - ret &= copy_to_client((uintptr_t)temp_buffer, input_arg->len, input_arg->addr, input_arg->len - 1); - if (ret == 0) { - driver_log("copy to client exception test FAIL\n"); - return -1; - } - - driver_log("copy to client exception test SUCC\n"); - return 0; -} - -static int32_t copy_to_client_test(struct share_buffer_arg *input_arg, char *temp_buffer, uint32_t size) -{ - driver_log("copy to client test begin\n"); - int32_t ret; - static char drv_output[] = "DRVMEM_OUTPUT"; - uint32_t drv_output_len; - drv_output_len = strlen(drv_output) + 1; - ret = strcpy_s(temp_buffer, drv_output_len, drv_output); - if (ret != 0) { - driver_log("strcpy_s failed,ret = 0x%x\n", ret); - return -1; - } - - ret = copy_to_client((uintptr_t)temp_buffer, size, input_arg->addr, input_arg->len); - if (ret != 0) { - driver_log("test copy_to_client failed,ret = 0x%x\n", ret); - return -1; - } - - if (copy_to_client_exception_test(input_arg, temp_buffer) != 0) { - return -1; - } - return ret; -} - -int32_t init_test(void) -{ - driver_log("driver init test end\n"); - return 0; -} - -int64_t ioctl_test(struct drv_data *drv, uint32_t cmd, unsigned long args, uint32_t args_len) -{ - (void)args; - (void)args_len; - int64_t ret = 0; - if (drv == NULL) { - driver_log("ioctl invalid drv\n"); - return -1; - } - - struct share_buffer_arg *input_arg = (struct share_buffer_arg *)args; - uint32_t size = input_arg->len; - char *temp_buffer = malloc(size); - if (temp_buffer == NULL) { - driver_log("malloc temp buffer failed\n"); - return -1; - } - (void)memset_s(temp_buffer, size, 0x0, size); - - switch (cmd) { - case DRVTEST_COMMAND_DRVVIRTTOPHYS: - ret = virt2phys_test(); - break; - case DRVTEST_COMMAND_COPYFROMCLIENT: - ret = copy_from_client_test(input_arg, temp_buffer, size); - break; - case DRVTEST_COMMAND_COPYTOCLIENT: - ret = copy_to_client_test(input_arg, temp_buffer, size); - break; - default: - driver_log("cmd:0x%x not support\n", cmd); - free(temp_buffer); - return -1; - } - - free(temp_buffer); - return ret; -} - -static uint32_t *buf_init(uint32_t args) -{ - uint32_t *buf = (uint32_t *)malloc(TOKEN_BUF_SIZE * sizeof(uint32_t)); - if (buf == NULL) { - driver_log("alloc buf failed\n"); - return NULL; - } - (void)memset_s(buf, TOKEN_BUF_SIZE * sizeof(uint32_t), 0x0, TOKEN_BUF_SIZE * sizeof(uint32_t)); - - int32_t i; - for (i = 0; i < TOKEN_BUF_SIZE; i++) - buf[i] = args; - - return buf; -} - -int64_t open_test(struct drv_data *drv, unsigned long args, uint32_t args_len) -{ - if (drv == NULL) { - driver_log("open invalid drv\n"); - return -1; - } - - if (args == 0 && args_len == 0) { - driver_log("input NULL param\n"); - return 0; - } - - if (args_len < sizeof(uint32_t) || args == 0) { - driver_log("open invalid drv\n"); - return -1; - } - - char open_succ[10] = { "hello" }; - driver_log("%s", open_succ); - - uint32_t *input = (uint32_t *)(uintptr_t)args; - if (*input == UINT32_MAX) { - driver_log("open test input args is UINT32_MAX, just retrun -1\n"); - return -1; - } - - uint32_t *buf = buf_init(*input); - if (buf == NULL) { - return -1; - } - drv->private_data = buf; - driver_log("driver open test begin: fd=%d args=0x%x", drv->fd, *input); - - return 0; -} - -int64_t close_test(struct drv_data *drv) -{ - if (drv == NULL) { - driver_log("close invalid drv\n"); - return -1; - } - - driver_log("driver close test begin: fd:%d", drv->fd); - if (drv->private_data != NULL) { - driver_log("free private data in close\n"); - free(drv->private_data); - drv->private_data = NULL; - } - - return 0; -} - -int32_t suspend_test(void) -{ - driver_log("suspend test begin\n"); - return 0; -} - -int32_t resume_test(void) -{ - driver_log("resume test begin\n"); - return 0; -} - -int32_t suspend_s4_test(void) -{ - driver_log("suspend_s4 test begin\n"); - return 0; -} - -int32_t resume_s4_test(void) -{ - driver_log("resume_s4 test begin\n"); - return 0; -} - -tee_driver_declare(drv_test_module, init_test, open_test, ioctl_test, close_test, suspend_test, resume_test, - suspend_s4_test, resume_s4_test); diff --git a/test/xts/ta/CMakeLists.txt b/test/xts/ta/CMakeLists.txt deleted file mode 100644 index 60eca041..00000000 --- a/test/xts/ta/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - - -add_subdirectory(test_client_api) -add_subdirectory(test_tcf2_api) -add_subdirectory(test_tcf_api) -add_subdirectory(test_driver_ta) -add_subdirectory(test_arithmetic_api) -add_subdirectory(test_time_api) diff --git a/test/xts/ta/config_ta_public.ini b/test/xts/ta/config_ta_public.ini deleted file mode 100644 index 5e7700ee..00000000 --- a/test/xts/ta/config_ta_public.ini +++ /dev/null @@ -1,19 +0,0 @@ -; Copyright (C) 2022 Huawei Technologies Co., Ltd. -; Licensed under the Mulan PSL v2. -; You can use this software according to the terms and conditions of the Mulan PSL v2. -; You may obtain a copy of Mulan PSL v2 at: -; http://license.coscl.org.cn/MulanPSL2 -; THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -; IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -; PURPOSE. -; See the Mulan PSL v2 for more details. -; - -[signSecPublicCfg] -secSignType = 1 - -secSignServerIp = - -secSignKey = - -configPath = diff --git a/test/xts/ta/test_arithmetic_api/CMakeLists.txt b/test/xts/ta/test_arithmetic_api/CMakeLists.txt deleted file mode 100644 index f8b76af8..00000000 --- a/test/xts/ta/test_arithmetic_api/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_arithmetic_api.elf) - -list(APPEND ta_src - src/test_arithmetic_api_base.c - src/test_arithmetic_api_main.c - src/test_basic_arithmetic_operation.c - src/test_converter_function.c - src/test_fast_modular_multiplication_operation.c - src/test_logical_operation.c - src/test_modular_arithmetic_operation.c - src/test_other_arithmetic_operation.c -) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - ${ta_src} - - INCLUDE_DIRS - - COMPILE_OPTS - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_arithmetic_api/manifest.txt b/test/xts/ta/test_arithmetic_api/manifest.txt deleted file mode 100644 index d3f781f8..00000000 --- a/test/xts/ta/test_arithmetic_api/manifest.txt +++ /dev/null @@ -1,7 +0,0 @@ -gpd.ta.appID: 9ac09588-fed1-4b1e-bb36-d3e5a3f26c39 -gpd.ta.service_name: test_arithmetic_api -gpd.ta.singleInstance: true -gpd.ta.multiSession: true -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 819200 -gpd.ta.stackSize: 81920 diff --git a/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.c b/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.c deleted file mode 100644 index d8c9d49c..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -TEE_BigInt* AllocateAndInitialize(uint32_t bitSize) -{ - uint32_t length = TEE_BigIntSizeInU32(bitSize); - TEE_BigInt *bigInt = (TEE_BigInt *)TEE_Malloc(length * sizeof(TEE_BigInt), 0); - if (bigInt == NULL) { - tloge("AllocateAndInitialize : TEE_Malloc returned NULL."); - return NULL; - } - - TEE_BigIntInit(bigInt, length); - return bigInt; -} - -TEE_BigInt *CreateBigInt(uint32_t size, uint8_t *buffer) -{ - TEE_BigInt *bigInt = (TEE_BigInt *)TEE_Malloc(TEE_BigIntSizeInU32(size * BIT_OF_CHAR) * sizeof(uint32_t), 0); - if (bigInt == NULL) { - return 0; - } - - TEE_BigIntInit(bigInt, TEE_BigIntSizeInU32(size * BIT_OF_CHAR)); - if (buffer != NULL) { - TEE_BigIntConvertFromOctetString(bigInt, buffer, size, 0); - } - return bigInt; -} - -TEE_Result TestBigIntInit() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - uint32_t length = TEE_BigIntSizeInU32(SIZE_256); - TEE_BigInt *bigInt = (TEE_BigInt *)TEE_Malloc(length * sizeof(TEE_BigInt), 0); - if (bigInt == NULL) { - tloge("AllocateAndInitializeFMM : TEE_Malloc returned NULL."); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntInit(bigInt, length); - if (TEE_BigIntCmpS32(bigInt, 0) != 0) { - tloge("BigIntInit fail."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(bigInt); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.h b/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.h deleted file mode 100644 index 6ff6d7a3..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_base.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_ARITHMETIC_API_BASE_H__ -#define __TEST_ARITHMETIC_API_BASE_H__ - -#include - -#define NUM_TWO 2 -#define NUM_THREE 3 -#define NUM_FIVE 5 -#define BIT_OF_CHAR 8 -#define SIZE_256 256 -#define MAX_BITS_PER_VARIABLE 2048 -#define RESULT_SIZE (MAX_BITS_PER_VARIABLE / 8) - -enum TEST_ARITHMETIC_API_CMD_ID { - CMD_ID_TEST_BIG_INT_COMPUTE_FMM = 0, - CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT = 1, - CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM = 2, - CMD_ID_TEST_BIG_INT_EXP_MOD = 3, - CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING = 4, - CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32 = 5, - CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD = 6, - CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD = 7, - CMD_ID_TEST_BIG_INT_MOD = 8, - CMD_ID_TEST_BIG_INT_ADD_AND_SUB = 9, - CMD_ID_TEST_BIG_INT_NEG = 10, - CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE = 11, - CMD_ID_TEST_BIG_INT_DIV = 12, - CMD_ID_TEST_BIG_INT_SHIFT_RIGHT = 13, - CMD_ID_TEST_BIG_INT_GET_BIT = 14, - CMD_ID_TEST_BIG_INT_GET_BIT_COUNT = 15, - CMD_ID_TEST_BIG_INT_SET_BIT = 16, - CMD_ID_TEST_BIG_INT_ASSIGN = 17, - CMD_ID_TEST_BIG_INT_ABS = 18, - CMD_ID_TEST_BIG_INT_RELATIVE_PRIME = 19, - CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD = 20, - CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME = 21, - CMD_ID_TEST_BIG_INT_CMP = 22, - CMD_ID_TEST_BIG_INT_CMP_S32 = 23, - CMD_ID_TEST_BIG_INT_INIT_FMM = 24, - CMD_ID_TEST_BIG_INT_INIT = 25, -}; - - -TEE_BigInt *AllocateAndInitialize(uint32_t bitSize); -TEE_BigInt *CreateBigInt(uint32_t size, uint8_t *buffer); -TEE_Result TestBigIntInit(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_main.c b/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_main.c deleted file mode 100644 index 5d4befef..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_arithmetic_api_main.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include "test_converter_function.h" -#include "test_arithmetic_api_base.h" -#include "test_basic_arithmetic_operation.h" -#include "test_modular_arithmetic_operation.h" -#include "test_logical_operation.h" -#include "test_other_arithmetic_operation.h" -#include "test_fast_modular_multiplication_operation.h" - -#define CA_VENDOR "/vendor/bin/tee_test_arithmetic_api" -#define CA_SYSTEM "/system/bin/tee_test_arithmetic_api" -#define CA_UID 0 - -typedef TEE_Result (* TestArithmeticApiFunc)(void); - -typedef struct { - uint32_t cmdId; - TestArithmeticApiFunc func; -} TestFunctionWithCmd; - -static TestFunctionWithCmd g_CmdList[] = { - {CMD_ID_TEST_BIG_INT_COMPUTE_FMM, TestBigIntComputeFMM}, // 0 - {CMD_ID_TEST_BIG_INT_INIT_FMM_CONTEXT, TestBigIntInitFMMContext}, - {CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_FMM, TestConverterBigIntAndFMM}, - {CMD_ID_TEST_BIG_INT_EXP_MOD, TestBigIntExpMod}, - {CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_OCTET_STRING, TestConverterBetweenBitInAndOctetString}, - {CMD_ID_TEST_CONVERTER_BETWEEN_BIG_INT_AND_S32, TestConverterBetweenBitInAndS32}, // 5 - {CMD_ID_TEST_BIG_INT_ADD_AND_SUB_MOD, TestBigIntAddAndSubMod}, - {CMD_ID_TEST_BIG_INT_MUL_AND_INV_MOD, TestBigIntMulAndInvMod}, - {CMD_ID_TEST_BIG_INT_MOD, TestBigIntMod}, - {CMD_ID_TEST_BIG_INT_ADD_AND_SUB, TestBigIntAddAndSub}, - {CMD_ID_TEST_BIG_INT_NEG, TestBigIntNeg}, // 10 - {CMD_ID_TEST_BIG_INT_MUL_AND_SQUARE, TestBigIntMulAndSquare}, - {CMD_ID_TEST_BIG_INT_DIV, TestBigIntDiv}, - {CMD_ID_TEST_BIG_INT_SHIFT_RIGHT, TestBigIntShiftRight}, - {CMD_ID_TEST_BIG_INT_GET_BIT, TestBigIntGetBit}, - {CMD_ID_TEST_BIG_INT_GET_BIT_COUNT, TestBigIntGetBitCount}, // 15 - {CMD_ID_TEST_BIG_INT_SET_BIT, TestBigIntSetBit}, - {CMD_ID_TEST_BIG_INT_ASSIGN, TestBigIntAssign}, - {CMD_ID_TEST_BIG_INT_ABS, TestBigIntAbs}, - {CMD_ID_TEST_BIG_INT_RELATIVE_PRIME, TestBigIntRelativePrime}, - {CMD_ID_TEST_BIG_INT_COMPUTE_EXTENTED_GCD, TestBigIntComputeExtentedGcd}, // 20 - {CMD_ID_TEST_BIG_INT_IS_PROBABLE_PRIME, TestBigIntIsProbablePrime}, - {CMD_ID_TEST_BIG_INT_CMP, TestBigIntCmp}, - {CMD_ID_TEST_BIG_INT_CMP_S32, TestBigIntCmpS32}, - {CMD_ID_TEST_BIG_INT_INIT_FMM, TestBigIntInitFMM}, - {CMD_ID_TEST_BIG_INT_INIT, TestBigIntInit}, -}; - -static TEE_Result TestArithmeticApi(uint32_t cmdId) -{ - uint32_t count = sizeof(g_CmdList) / sizeof(g_CmdList[0]); - tlogi("[TestArithmeticApi]: g_CmdList count = %d, cmdId = %d\n", count, cmdId); - for (uint32_t i = 0; i < count; i++) { - if (g_CmdList[i].cmdId == cmdId) { - return g_CmdList[i].func(); - } - } - - tlogi("unknown command id, cmdId: %u\n", cmdId); - return TEE_ERROR_INVALID_CMD; -} - - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("---- TA_CreateEntryPoint ---------"); - TEE_Result ret = AddCaller_CA_exec(CA_VENDOR, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("Arithmetic TA Add caller failed, ret = 0x%x", ret); - return ret; - } - - ret = AddCaller_CA_exec(CA_SYSTEM, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("Arithmetic TA Add caller failed, ret = 0x%x", ret); - return ret; - } - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext) -{ - (void)parmType; - (void)params; - (void)sessionContext; - tlogi("---- TA_OpenSessionEntryPoint --------"); - - return TEE_SUCCESS; -} - -TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmdId, uint32_t parmType, TEE_Param params[4]) -{ - TEE_Result ret = TEE_SUCCESS; - (void)sessionContext; - (void)params; - (void)parmType; - - ret = TestArithmeticApi(cmdId); - if (ret != TEE_SUCCESS) - tloge("Arithmetic TA invoke command for value failed! cmdId: %u, ret: 0x%x", cmdId, ret); - - return ret; -} - -void TA_CloseSessionEntryPoint(void *sessionContext) -{ - (void)sessionContext; - tlogi("------ TA_CloseSessionEntryPoint -----"); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("------ TA_DestroyEntryPoint ----"); -} \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.c b/test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.c deleted file mode 100644 index 95855918..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain g_longVal1 copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -static uint8_t g_longVal1[] = { - 0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C, - 0x9A, 0xA3, 0x71, 0xF0, 0x92, 0xC0, 0xA3, 0xC9, 0x00, 0xC3, 0x51, 0xC8, 0x9D, 0x7B, 0x06, 0x7C, - 0x94, 0x4F, 0x30, 0x49, 0x92, 0x5D, 0xB4, 0x27, 0xBA, 0x58, 0x1D, 0xFC, 0xF5, 0x83, 0xAA, 0xDD, - 0x54, 0x02, 0x64, 0x22, 0x6A, 0x4E, 0xD0, 0x77, 0xA6, 0xE8, 0xEB, 0x39, 0x13, 0xE3, 0x42, 0x6B, - 0xDF, 0x75, 0x08, 0xAC, 0xE9, 0xB0, 0xAE, 0x61, 0x31, 0x90, 0xDD, 0x02, 0x77, 0xF1, 0x88, 0x89, - 0x79, 0x90, 0x6C, 0xD8, 0x5A, 0x8B, 0x1A, 0x5B, 0x13, 0xE9, 0x80, 0xC0, 0x50, 0xDA, 0x8F, 0x71, - 0x8F, 0x64, 0x44, 0xFA, 0xDB, 0xDC, 0x1F, 0x95, 0x2E, 0x88, 0x73, 0x3F, 0x75, 0x8D, 0x71, 0x6B, - 0x8F, 0xF6, 0x7E, 0x57, 0xC3, 0x6B, 0x9B, 0xD3, 0xCA, 0x01, 0x25, 0xFC, 0x0C, 0xD2, 0xFB, 0x4F, - 0x93, 0x05, 0xA0, 0x6B, 0xFA, 0x2F, 0xA2, 0x51, 0x35, 0xEF, 0x13, 0xBD, 0x81, 0x7A, 0x88, 0x07, - 0x7C, 0xA2, 0xB8, 0x0F, 0xD1, 0xC2, 0xF6, 0x9A, 0x66, 0x77, 0xA4, 0x5F, 0xE8, 0x6A, 0x5B, 0x1B, - 0x93, 0x05, 0x7C, 0x4F, 0xD5, 0xDA, 0x66, 0xA8, 0x52, 0x80, 0x5B, 0xB3, 0xB6, 0x27, 0xEC, 0x1B, - 0x35, 0xD2, 0x7C, 0x67, 0x2A, 0x33, 0xD0, 0xDF, 0x83, 0x74, 0x11, 0xF5, 0xFF, 0xE4, 0x21, 0x8E, - 0x3D, 0x6E, 0x4F, 0x43, 0x4F, 0x86, 0x55, 0x32, 0x27, 0x99, 0x94, 0x6E, 0x70, 0xA4, 0x51, 0x5E, - 0xD9, 0x2D, 0x5C, 0x91, 0x0E, 0x2F, 0x5F, 0xF7, 0x16, 0xBA, 0x71, 0xBD, 0x95, 0x5D, 0x89, 0xF5, - 0x01, 0x7F, 0x00, 0xEB, 0x30, 0x81, 0x22, 0x23, 0xCE, 0x21, 0x69, 0xAB, 0x16, 0xBC, 0x25, 0x98, - 0x8E, 0x52, 0x32, 0x06, 0xC0, 0x22, 0xAD, 0xEA, 0x49, 0xF9, 0xCA, 0xE0, 0x73, 0x71, 0x02, 0xA5, -}; - -static uint8_t g_longVal2[] = { - 0x71, 0x1A, 0x84, 0x69, 0x8E, 0x93, 0x53, 0x79, 0x90, 0x63, 0x80, 0x40, 0x05, 0x95, 0xEC, 0x2F, - 0xFC, 0x6E, 0x7D, 0xD4, 0x10, 0xF7, 0x68, 0x1B, 0x1A, 0xB7, 0x3D, 0x83, 0x38, 0x3E, 0x84, 0xB8, - 0x9C, 0x4A, 0x6F, 0x04, 0xB3, 0x4D, 0x3E, 0x9D, 0x57, 0xF5, 0xE6, 0x42, 0x43, 0xEA, 0x9E, 0x5D, - 0x65, 0xAF, 0x59, 0x63, 0xC4, 0xAE, 0xD6, 0xAA, 0x9F, 0x9D, 0x7B, 0x5A, 0x75, 0xB0, 0x21, 0xAE, - 0x99, 0xA6, 0xCE, 0x40, 0x39, 0x14, 0xEA, 0x43, 0x3B, 0x08, 0xB9, 0x7D, 0xCB, 0x95, 0x3C, 0x32, - 0xA4, 0x99, 0xE9, 0x3E, 0xDF, 0xC2, 0x27, 0x9F, 0x53, 0xAA, 0xB5, 0xB7, 0x99, 0xA3, 0xB5, 0xF5, - 0xA7, 0x02, 0x31, 0x20, 0x71, 0x0D, 0x73, 0x4F, 0xA3, 0x5E, 0x44, 0x94, 0x7F, 0x08, 0x4D, 0x13, - 0x58, 0xED, 0x03, 0x69, 0xFB, 0xBE, 0x5D, 0xE5, 0x23, 0xA4, 0x0D, 0xFC, 0x05, 0xB3, 0xA1, 0x23, - 0x18, 0x58, 0x1D, 0x03, 0xE9, 0xDE, 0xEC, 0x13, 0x8C, 0x44, 0x35, 0x50, 0x6F, 0x5D, 0x8E, 0xA5, - 0xF3, 0xB1, 0xF7, 0x76, 0x07, 0x4E, 0xC7, 0x49, 0x85, 0x13, 0xA1, 0xD8, 0x3C, 0xAF, 0x77, 0x2D, - 0xC7, 0x9E, 0x8E, 0x8F, 0x16, 0xA8, 0x9E, 0x72, 0x7A, 0xC8, 0xF3, 0x39, 0x81, 0x66, 0xCC, 0xB4, - 0x07, 0x02, 0xE1, 0x1E, 0x11, 0xA1, 0x37, 0x22, 0x8F, 0xA5, 0xF3, 0x12, 0xBE, 0x79, 0xFC, 0x20, - 0x71, 0x26, 0x3D, 0x6B, 0x87, 0xC1, 0xCF, 0x1D, 0x62, 0xCB, 0xD8, 0x96, 0x0E, 0x11, 0xB5, 0x08, - 0x37, 0x64, 0xBF, 0xB3, 0xF2, 0x62, 0xAC, 0x46, 0xC2, 0x01, 0xE1, 0xE0, 0x7E, 0xFB, 0x6A, 0x8D, - 0x85, 0x26, 0xD0, 0x1C, 0x3D, 0x59, 0x31, 0xF1, 0x3B, 0x91, 0xA8, 0x13, 0xBA, 0x58, 0x04, 0xE6, - 0x20, 0xAA, 0xE9, 0x31, 0x21, 0xFF, 0x16, 0xBC, 0x3C, 0xCD, 0xC4, 0x52, 0x0E, 0x82, 0x1D, 0xB7, -}; - -static uint8_t g_checkAddVal[] = { - 0xDB, 0xBD, 0x48, 0x3E, 0x23, 0x91, 0x0B, 0x5C, 0x81, 0x60, 0x11, 0xB2, 0xC6, 0xE6, 0x16, 0x5C, - 0x97, 0x11, 0xEF, 0xC4, 0xA3, 0xB8, 0x0B, 0xE4, 0x1B, 0x7A, 0x8F, 0x4B, 0xD5, 0xB9, 0x8B, 0x35, - 0x30, 0x99, 0x9F, 0x4E, 0x45, 0xAA, 0xF2, 0xC5, 0x12, 0x4E, 0x04, 0x3F, 0x39, 0x6E, 0x49, 0x3A, - 0xB9, 0xB1, 0xBD, 0x86, 0x2E, 0xFD, 0xA7, 0x22, 0x46, 0x86, 0x66, 0x93, 0x89, 0x93, 0x64, 0x1A, - 0x79, 0x1B, 0xD6, 0xED, 0x22, 0xC5, 0x98, 0xA4, 0x6C, 0x99, 0x96, 0x80, 0x43, 0x86, 0xC4, 0xBC, - 0x1E, 0x2A, 0x56, 0x17, 0x3A, 0x4D, 0x41, 0xFA, 0x67, 0x94, 0x36, 0x77, 0xEA, 0x7E, 0x45, 0x67, - 0x36, 0x66, 0x76, 0x1B, 0x4C, 0xE9, 0x92, 0xE4, 0xD1, 0xE6, 0xB7, 0xD3, 0xF4, 0x95, 0xBE, 0x7E, - 0xE8, 0xE3, 0x81, 0xC1, 0xBF, 0x29, 0xF9, 0xB8, 0xED, 0xA5, 0x33, 0xF8, 0x12, 0x86, 0x9C, 0x72, - 0xAB, 0x5D, 0xBD, 0x6F, 0xE4, 0x0E, 0x8E, 0x64, 0xC2, 0x33, 0x49, 0x0D, 0xF0, 0xD8, 0x16, 0xAD, - 0x70, 0x54, 0xAF, 0x85, 0xD9, 0x11, 0xBD, 0xE3, 0xEB, 0x8B, 0x46, 0x38, 0x25, 0x19, 0xD2, 0x49, - 0x5A, 0xA4, 0x0A, 0xDE, 0xEC, 0x83, 0x05, 0x1A, 0xCD, 0x49, 0x4E, 0xED, 0x37, 0x8E, 0xB8, 0xCF, - 0x3C, 0xD5, 0x5D, 0x85, 0x3B, 0xD5, 0x08, 0x02, 0x13, 0x1A, 0x05, 0x08, 0xBE, 0x5E, 0x1D, 0xAE, - 0xAE, 0x94, 0x8C, 0xAE, 0xD7, 0x48, 0x24, 0x4F, 0x8A, 0x65, 0x6D, 0x04, 0x7E, 0xB6, 0x06, 0x67, - 0x10, 0x92, 0x1C, 0x45, 0x00, 0x92, 0x0C, 0x3D, 0xD8, 0xBC, 0x53, 0x9E, 0x14, 0x58, 0xF4, 0x82, - 0x86, 0xA5, 0xD1, 0x07, 0x6D, 0xDA, 0x54, 0x15, 0x09, 0xB3, 0x11, 0xBE, 0xD1, 0x14, 0x2A, 0x7E, - 0xAE, 0xFD, 0x1B, 0x37, 0xE2, 0x21, 0xC4, 0xA6, 0x86, 0xC7, 0x8F, 0x32, 0x81, 0xF3, 0x20, 0x5C, -}; - -static uint8_t g_shortVal1[] = { - 0x60, 0x13, 0x16, 0xE1, 0xFB, 0xFF, 0x59, 0xF9, 0xC6, 0x15, 0x45, 0xCA, 0x9C, 0xE2, 0x10, 0xA1, - 0xC1, 0xE6, 0xC1, 0xFB, 0x4A, 0xA3, 0x14, 0xCD, 0x76, 0xDE, 0x45, 0xB7, 0x99, 0xB5, 0x56, 0x9B, - 0xCC, 0x39, 0xA4, 0x09, 0x09, 0x16, 0x51, 0xB7, 0x74, 0x9C, 0xCE, 0x11, 0x36, 0xFE, 0x37, 0xAC, - 0xF1, 0x02, 0xC4, 0x5B, 0x8E, 0x7A, 0x81, 0x6E, 0x36, 0x85, 0x9B, 0x68, 0x73, 0x85, 0x96, 0xD8, - 0x74, 0x9C, 0xEA, 0x11, 0x53, 0xDF, 0xB4, 0x59, 0xAF, 0x90, 0x71, 0x32, 0x4A, 0x16, 0xF3, 0x7B, - 0x45, 0x3B, 0xF7, 0x53, 0x3B, 0x72, 0x1D, 0xA5, 0xB9, 0xB9, 0x89, 0x63, 0x7E, 0x44, 0x5A, 0xB1, - 0x1A, 0x42, 0x28, 0x0E, 0x85, 0xB1, 0x44, 0x86, 0xB0, 0x94, 0x0E, 0x4A, 0xCE, 0xF6, 0x5A, 0xB8, - 0x4D, 0xAA, 0x49, 0xE4, 0x92, 0xF4, 0x0C, 0x92, 0xCF, 0x7C, 0x4D, 0xE0, 0xF6, 0xDA, 0x7A, 0xCF -}; - -static uint8_t g_shortVal2[] = { - 0x46, 0x6B, 0xA2, 0xBA, 0xA0, 0xE2, 0x03, 0x91, 0x67, 0xF8, 0x7C, 0x69, 0x04, 0x9B, 0x23, 0xF3, - 0xAE, 0x2A, 0x06, 0x2D, 0x5F, 0x2B, 0x76, 0x19, 0xCC, 0x19, 0xDD, 0xCB, 0x57, 0x63, 0x58, 0x2A, - 0xE7, 0xB9, 0x42, 0xB0, 0x33, 0x33, 0xA6, 0x17, 0x0B, 0xE4, 0x4B, 0xC3, 0x70, 0x7C, 0x74, 0xFF, - 0x11, 0xEA, 0xDE, 0x5A, 0x5B, 0xD1, 0x2C, 0xBD, 0x48, 0x8E, 0x85, 0xBB, 0x54, 0xEC, 0xBC, 0x6E, - 0x73, 0x25, 0xF2, 0x58, 0xE3, 0x05, 0x49, 0x31, 0x3E, 0x95, 0xF4, 0x85, 0xAE, 0xD4, 0xB4, 0x51, - 0xA7, 0xD3, 0xC1, 0x4E, 0x1A, 0xAF, 0x83, 0xEE, 0xC1, 0x35, 0xF8, 0x74, 0xF5, 0x33, 0x0C, 0x2E, - 0x32, 0xD2, 0x5A, 0x8E, 0x4A, 0x78, 0x07, 0xD9, 0x53, 0x65, 0x7D, 0xCA, 0x9A, 0xEB, 0xBB, 0x94, - 0x78, 0xC2, 0x2B, 0x8F, 0xF8, 0x03, 0x37, 0x44, 0x1A, 0x58, 0xE2, 0xE0, 0xA8, 0xD6, 0xEE, 0x8D -}; - -static uint8_t g_shortVal3[] = { - 0x22, 0x4A, 0x5A, 0xD4, 0x82, 0x4E, 0xB4, 0x91, 0xEC, 0xF2, 0xC7, 0xD6, 0x3F, 0xA0, 0x7D, 0x86, - 0x42, 0xFB, 0x22, 0xFD, 0xEE, 0x1F, 0xC8, 0xCC, 0x3F, 0x75, 0x79, 0x3A, 0x96, 0x1D, 0x07, 0x53, - 0xF9, 0xD9, 0x63, 0xEE, 0x4A, 0xD9, 0xEF, 0xF8, 0x5B, 0x58, 0x4B, 0xCE, 0xD9, 0xB6, 0xE3, 0xB6, - 0x31, 0xCD, 0x18, 0x61, 0x3F, 0x48, 0x9A, 0xF2, 0x5D, 0x09, 0x0D, 0x30, 0x3F, 0xDF, 0xAF, 0x51, - 0xAE, 0xE5, 0x13, 0xAC, 0xC6, 0xC5, 0x3D, 0x73, 0xDF, 0xFF, 0x16, 0x4F, 0x2D, 0xF0, 0x98, 0x92, - 0xB0, 0x2B, 0x14, 0x1D, 0x60, 0xB1, 0xF6, 0x60, 0x6B, 0x13, 0x69, 0xE5, 0xD0, 0x01, 0xFA, 0x2D, - 0xA0, 0xC8, 0x0A, 0x21, 0x27, 0xD6, 0x89, 0x31, 0x99, 0x2C, 0x2C, 0x36, 0x6B, 0x17, 0x04, 0xFF, - 0xE8, 0x8A, 0xB8, 0xE0, 0x38, 0x70, 0x85, 0xF9, 0x87, 0xF8, 0x4A, 0xE7, 0x3B, 0xA9, 0x3C, 0x0A -}; - -static uint8_t g_checkMulVal[] = { - 0x1a, 0x6D, 0x9D, 0x4E, 0x7A, 0x16, 0x88, 0x7B, 0xD2, 0x20, 0xA5, 0xCD, 0xF8, 0x26, 0x98, 0x73, - 0x10, 0x8C, 0x8D, 0x58, 0xFC, 0xFD, 0x9B, 0x22, 0x88, 0xF2, 0x96, 0xBB, 0xC8, 0x43, 0x6A, 0x90, - 0xE1, 0x72, 0xAE, 0x99, 0x27, 0xEC, 0x03, 0x2F, 0x99, 0x0D, 0x26, 0xF6, 0x33, 0xD1, 0x62, 0xD6, - 0x27, 0x33, 0x04, 0x61, 0x48, 0xF2, 0x30, 0x18, 0x56, 0x81, 0x5D, 0x35, 0x26, 0x0D, 0x1C, 0x0D, - 0x29, 0xE9, 0x8B, 0xC5, 0x6F, 0x71, 0xF3, 0x35, 0xB9, 0x7E, 0xA0, 0x00, 0xEE, 0x66, 0x16, 0x1C, - 0x41, 0x18, 0x02, 0x29, 0xE8, 0x07, 0x88, 0xBE, 0x5B, 0x06, 0x10, 0xAC, 0x74, 0x30, 0x30, 0xA2, - 0x00, 0xE5, 0x66, 0x90, 0xD7, 0xDB, 0xB3, 0x64, 0xF3, 0x8A, 0x04, 0x14, 0x67, 0x1A, 0x99, 0x1B, - 0x5C, 0x8C, 0x9C, 0x50, 0x18, 0x1E, 0x99, 0x7A, 0x1A, 0xAC, 0x43, 0x6A, 0x77, 0x54, 0x83, 0x88, - 0x0F, 0xDF, 0xC0, 0xE3, 0x53, 0xEB, 0x2F, 0xE5, 0x0D, 0x0D, 0x5C, 0x2E, 0xB9, 0xA6, 0xD0, 0x59, - 0xEC, 0x69, 0xE6, 0x38, 0x42, 0xB3, 0xFD, 0xA7, 0xF0, 0xD0, 0xD6, 0xC3, 0x03, 0xA5, 0x6F, 0x50, - 0x35, 0x5A, 0xAB, 0xAE, 0x01, 0xE8, 0x1D, 0xCF, 0x4B, 0x4B, 0x12, 0x17, 0x11, 0xD7, 0xD8, 0x8A, - 0x99, 0x99, 0xA3, 0x09, 0x47, 0x99, 0x0B, 0x02, 0x47, 0x32, 0xBE, 0xDB, 0x79, 0x7E, 0x40, 0xE9, - 0xE2, 0x26, 0x3D, 0xA7, 0x33, 0xB0, 0x04, 0xD4, 0x28, 0x9A, 0xB6, 0x42, 0x39, 0x21, 0x35, 0xA1, - 0x19, 0x28, 0x76, 0x0C, 0x7E, 0xC8, 0xC5, 0x28, 0x13, 0x01, 0x16, 0x7B, 0xD5, 0x88, 0x37, 0xA2, - 0x31, 0x1B, 0x9B, 0x05, 0x42, 0x05, 0x7A, 0xE4, 0xF5, 0xF6, 0x9A, 0xFE, 0x5C, 0xCA, 0x70, 0xDE, - 0x7B, 0x3E, 0xB0, 0xFF, 0x11, 0xC2, 0x51, 0x1A, 0xB0, 0xA9, 0xF8, 0xC1, 0x95, 0x8C, 0x16, 0x03 -}; - -TEE_Result TestBigIntAddAndSub() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op1 = CreateBigInt(sizeof(g_longVal1), g_longVal1); - TEE_BigInt *op2 = CreateBigInt(sizeof(g_longVal2), g_longVal2); - - TEE_BigInt *addDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *addCheck = CreateBigInt(sizeof(g_checkAddVal), g_checkAddVal); - TEE_BigIntAdd(addDest, op1, op2); - if (TEE_BigIntCmp(addDest, addCheck) != 0) { - tloge("BigIntAdd failed."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - TEE_BigInt *subDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigIntSub(subDest, addDest, op1); - if (TEE_BigIntCmp(subDest, op2) != 0) { - tloge("BigIntSubMod failed."); - ret = TEE_ERROR_GENERIC; - } - TEE_Free(subDest); - -CLEANUP: - TEE_Free(op1); - TEE_Free(op2); - TEE_Free(addCheck); - TEE_Free(addDest); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntNeg() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op1 = CreateBigInt(sizeof(g_longVal1), g_longVal1); - TEE_BigInt *negDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *addForNegCheck = CreateBigInt(RESULT_SIZE, 0); - TEE_BigIntNeg(negDest, op1); - TEE_BigIntAdd(addForNegCheck, negDest, op1); - if (TEE_BigIntCmpS32(addForNegCheck, 0) != 0) { - tloge("BigIntNeg failed."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(op1); - TEE_Free(negDest); - TEE_Free(addForNegCheck); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntMulAndSquare() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op1 = CreateBigInt(sizeof(g_shortVal1), g_shortVal1); - TEE_BigInt *op2 = CreateBigInt(sizeof(g_shortVal2), g_shortVal2); - - TEE_BigInt *mulDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *mulCheck = CreateBigInt(sizeof(g_checkMulVal), g_checkMulVal); - TEE_BigIntMul(mulDest, op1, op2); - if (TEE_BigIntCmp(mulDest, mulCheck) != 0) { - tloge("BigIntMul failed."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - TEE_BigInt *squareDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *mulForsquareCheck = CreateBigInt(RESULT_SIZE, 0); - TEE_BigIntSquare(squareDest, op1); - TEE_BigIntMul(mulForsquareCheck, op1, op1); - if (TEE_BigIntCmp(squareDest, mulForsquareCheck) != 0) { - tloge("BigIntSquare failed."); - ret = TEE_ERROR_GENERIC; - } - TEE_Free(squareDest); - TEE_Free(mulForsquareCheck); - -CLEANUP: - TEE_Free(op1); - TEE_Free(op2); - TEE_Free(mulDest); - TEE_Free(mulCheck); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntDiv() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op1 = CreateBigInt(sizeof(g_shortVal1), g_shortVal1); - TEE_BigInt *op2 = CreateBigInt(sizeof(g_shortVal2), g_shortVal2); - TEE_BigInt *op3 = CreateBigInt(sizeof(g_shortVal3), g_shortVal3); - - TEE_BigInt *mulDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *dividend = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *destR = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *destQ = CreateBigInt(RESULT_SIZE, 0); - - TEE_BigIntMul(mulDest, op1, op2); - TEE_BigIntAdd(dividend, mulDest, op3); // dividend = (op1*op2) + op3 - TEE_BigIntDiv(destQ, destR, dividend, op1); - - if (TEE_BigIntCmp(destQ, op2) != 0 || TEE_BigIntCmp(destR, op3) != 0) { - tloge("TEE_BigIntDiv failed."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(op1); - TEE_Free(op2); - TEE_Free(op3); - TEE_Free(mulDest); - TEE_Free(dividend); - TEE_Free(destR); - TEE_Free(destQ); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} diff --git a/test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.h b/test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.h deleted file mode 100644 index 593c390a..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_basic_arithmetic_operation.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_BASIC_ARITHMETIC_OPERATION_H__ -#define __TEST_BASIC_ARITHMETIC_OPERATION_H__ - -#include - -TEE_Result TestBigIntAddAndSub(); -TEE_Result TestBigIntNeg(); -TEE_Result TestBigIntMulAndSquare(); -TEE_Result TestBigIntDiv(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_converter_function.c b/test/xts/ta/test_arithmetic_api/src/test_converter_function.c deleted file mode 100644 index 873b35d1..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_converter_function.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -TEE_Result TestConverterBetweenBitInAndOctetString() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_BigInt *bigInt = AllocateAndInitialize(SIZE_256); - if (bigInt == NULL) { - return TEE_ERROR_GENERIC; - } - - const uint8_t string[] = "tempString"; - TEE_Result ret = TEE_BigIntConvertFromOctetString((TEE_BigInt *)bigInt, string, sizeof(string), -1); - if (ret != TEE_SUCCESS) { - tloge("BigIntConvertFromOctetString failed, ret = 0x%x", ret); - goto CLEANUP; - } - - uint8_t buffer[SIZE_256] = {0}; - size_t bufferLen = sizeof(buffer); - ret = TEE_BigIntConvertToOctetString(buffer, &bufferLen, bigInt); - if (ret != TEE_SUCCESS) { - tloge("BigIntConvertToOctetString failed, ret = 0x%x", ret); - goto CLEANUP; - } - if (strcmp((const char *)buffer, (const char *)string) != 0) { - tloge("convert failed. string is %s; buffer is %s;", string, buffer); - ret = TEE_ERROR_GENERIC; - } - tlogi("after convert buffer is %s", buffer); - -CLEANUP: - TEE_Free(bigInt); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestConverterBetweenBitInAndS32() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_BigInt *bigInt = AllocateAndInitialize(SIZE_256); - if (bigInt == NULL) { - return TEE_ERROR_GENERIC; - } - - const int32_t shortVal = 1234; - TEE_BigIntConvertFromS32(bigInt, shortVal); - - int32_t value; - TEE_Result ret = TEE_BigIntConvertToS32(&value, bigInt); - if (ret != TEE_SUCCESS) { - tloge("BigIntConvertToS32 failed, ret = 0x%x", ret); - goto CLEANUP; - } - if (value != shortVal) { - tloge("convert failed. value is %d; shortVal is %d", value, shortVal); - ret = TEE_ERROR_GENERIC; - } - tlogi("after convert value is %d", value); - -CLEANUP: - TEE_Free(bigInt); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - diff --git a/test/xts/ta/test_arithmetic_api/src/test_converter_function.h b/test/xts/ta/test_arithmetic_api/src/test_converter_function.h deleted file mode 100644 index fc7e5d85..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_converter_function.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_CONVERTER_FUNCTION_H__ -#define __TEST_CONVERTER_FUNCTION_H__ - -#include - -TEE_Result TestConverterBetweenBitInAndOctetString(); -TEE_Result TestConverterBetweenBitInAndS32(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.c b/test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.c deleted file mode 100644 index 31d3c306..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain longVal1 copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -static uint8_t g_modValue[] = { - 0x40, 0x84, 0xB4, 0xAF, 0xF9, 0x13, 0xE0, 0x2B, 0xFF, 0x2D, 0x30, 0x21, 0x7C, 0x94, 0xD2, 0x8F, - 0x89, 0x47, 0x9F, 0x7E, 0x14, 0xC1, 0xB4, 0xD7, 0x64, 0x97, 0x33, 0x65, 0x26, 0x62, 0x86, 0xED -}; -static uint8_t g_bigIntValue[] = { - 0x1C, 0xE1, 0x0C, 0xAE, 0x61, 0xBE, 0xE9, 0xD5, 0x5D, 0xB0, 0xC0, 0x93, 0x5F, 0x78, 0x8C, 0x3C, - 0xA1, 0x44, 0x3B, 0x6F, 0x08, 0xC6, 0x6A, 0x7E, 0x87, 0x32, 0xE9, 0x37, 0xB5, 0xE6, 0x87, 0x6E, -}; - -static TEE_BigIntFMM* AllocateAndInitializeFMM(uint32_t modulusSizeInBits) -{ - uint32_t length = TEE_BigIntFMMSizeInU32(modulusSizeInBits); - TEE_BigIntFMM *bigIntFMM = (TEE_BigIntFMM *)TEE_Malloc(length * sizeof(TEE_BigIntFMM), 0); - if (bigIntFMM == NULL) { - tloge("AllocateAndInitializeFMM : TEE_Malloc returned NULL."); - return NULL; - } - - TEE_BigIntInitFMM(bigIntFMM, length); - return bigIntFMM; -} - -TEE_Result TestBigIntInitFMM() -{ - tlogi("[%s] begin:", __FUNCTION__); - uint32_t length = TEE_BigIntFMMSizeInU32(SIZE_256); - const uint32_t checkLength = 10; - if (length != checkLength) { - tloge("BigIntFMMSizeInU32 fail. length = %d", length); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntFMM *bigIntFMM = (TEE_BigIntFMM *)TEE_Malloc(length * sizeof(TEE_BigIntFMM), 0); - if (bigIntFMM == NULL) { - tloge("AllocateAndInitializeFMM : TEE_Malloc returned NULL."); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntInitFMM(bigIntFMM, length); - TEE_Free(bigIntFMM); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, TEE_SUCCESS); - return TEE_SUCCESS; -} - -TEE_Result TestBigIntInitFMMContext() -{ - tlogi("[%s] begin:", __FUNCTION__); - uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256); - const uint32_t checkLength = 10; - if (length != checkLength) { - tloge("BigIntFMMContextSizeInU32 fail. length = %d", length); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0); - if (bigIntFMMContext == NULL) { - tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL."); - return TEE_ERROR_GENERIC; - } - TEE_BigIntFMMContext *bigIntFMMContext1 = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0); - if (bigIntFMMContext1 == NULL) { - tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL."); - TEE_Free(bigIntFMMContext); - return TEE_ERROR_GENERIC; - } - - const uint8_t p1Value[] = { - 0x40, 0x84, 0xB4, 0xAF, 0xF9, 0x13, 0xE0, 0x2B, 0xFF, 0x2D, 0x30, 0x21, 0x7C, 0x94, 0xD2, 0x8F, - 0x89, 0x47, 0x9F, 0x7E, 0x14, 0xC1, 0xB4, 0xD7, 0x64, 0x97, 0x33, 0x65, 0x26, 0x62, 0x86, 0xED - }; - TEE_BigInt *bigInt = CreateBigInt(sizeof(p1Value), (uint8_t *)p1Value); - TEE_BigIntInitFMMContext(bigIntFMMContext, length, bigInt); - - TEE_Result ret = TEE_BigIntInitFMMContext1(bigIntFMMContext1, length, bigInt); - if (ret != TEE_SUCCESS) { - tloge("TEE_BigIntInitFMMContext1 test failed. ret = 0x%x", ret); - } - TEE_Free(bigIntFMMContext); - TEE_Free(bigIntFMMContext1); - TEE_Free(bigInt); - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestConverterBigIntAndFMM() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - - TEE_BigInt *bigInt = CreateBigInt(sizeof(g_bigIntValue), g_bigIntValue); - if (bigInt == NULL) { - return TEE_ERROR_GENERIC; - } - TEE_BigInt *modulus = CreateBigInt(sizeof(g_modValue), g_modValue); - if (modulus == NULL) { - TEE_Free(bigInt); - return TEE_ERROR_GENERIC; - } - TEE_BigInt *bigIntFMM = AllocateAndInitializeFMM(SIZE_256); - if (bigIntFMM == NULL) { - TEE_Free(modulus); - TEE_Free(bigInt); - return TEE_ERROR_GENERIC; - } - uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256); - TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0); - if (bigIntFMMContext == NULL) { - tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL."); - TEE_Free(bigInt); - TEE_Free(modulus); - TEE_Free(bigIntFMM); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntInitFMMContext(bigIntFMMContext, length, modulus); - TEE_BigIntConvertToFMM(bigIntFMM, bigInt, modulus, bigIntFMMContext); - - TEE_BigInt *convertedBigInt = CreateBigInt(RESULT_SIZE, 0); - if (convertedBigInt == NULL) { - ret = TEE_ERROR_GENERIC; - goto CLEAN_UP; - } - TEE_BigIntConvertFromFMM(convertedBigInt, bigIntFMM, modulus, bigIntFMMContext); - int32_t isSame = TEE_BigIntCmp(convertedBigInt, bigInt); - if (isSame != 0) { - ret = TEE_ERROR_GENERIC; - } - TEE_Free(convertedBigInt); - -CLEAN_UP: - TEE_Free(bigIntFMMContext); - TEE_Free(bigIntFMM); - TEE_Free(bigInt); - TEE_Free(modulus); - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntComputeFMM() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *bigInt = AllocateAndInitialize(SIZE_256); - if (bigInt == NULL) - return TEE_ERROR_GENERIC; - - TEE_BigIntFMM *destBigIntFMM = AllocateAndInitializeFMM(SIZE_256); - if (destBigIntFMM == NULL) { - TEE_Free(bigInt); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntFMM *op1BigIntFMM = AllocateAndInitializeFMM(SIZE_256); - if (op1BigIntFMM == NULL) { - TEE_Free(bigInt); - TEE_Free(destBigIntFMM); - return TEE_ERROR_GENERIC; - } - - TEE_BigIntFMM *op2BigIntFMM = AllocateAndInitializeFMM(SIZE_256); - if (op2BigIntFMM == NULL) { - TEE_Free(bigInt); - TEE_Free(destBigIntFMM); - TEE_Free(op1BigIntFMM); - return TEE_ERROR_GENERIC; - } - - uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256); - TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0); - if (bigIntFMMContext == NULL) { - tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL."); - ret = TEE_ERROR_GENERIC; - goto CLEAN_UP; - } - - tlogi("after TEE_BigIntFMMContextSizeInU32, length = %u", length); - TEE_BigIntComputeFMM(destBigIntFMM, op1BigIntFMM, op2BigIntFMM, bigInt, bigIntFMMContext); - TEE_Free(bigIntFMMContext); - -CLEAN_UP: - TEE_Free(bigInt); - TEE_Free(destBigIntFMM); - TEE_Free(op1BigIntFMM); - TEE_Free(op2BigIntFMM); - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.h b/test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.h deleted file mode 100644 index f1bfa44e..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_fast_modular_multiplication_operation.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_FAST_MODULAR_MULTIPLICATION_OPERATION_H__ -#define __TEST_FAST_MODULAR_MULTIPLICATION_OPERATION_H__ - -#include - -TEE_Result TestBigIntInitFMM(); -TEE_Result TestBigIntInitFMMContext(); -TEE_Result TestConverterBigIntAndFMM(); -TEE_Result TestBigIntComputeFMM(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_logical_operation.c b/test/xts/ta/test_arithmetic_api/src/test_logical_operation.c deleted file mode 100644 index 0ff3bbcf..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_logical_operation.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain longVal1 copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -TEE_Result TestBigIntCmp() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - const uint8_t op1Value[] = { - 0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C - }; - const uint8_t op2Value[] = { - 0x35, 0x51, 0x61, 0xEA, 0x4A, 0x7E, 0xDB, 0xF1, 0x78, 0x7E, 0x48, 0xB9, 0x60, 0xA8, 0x15, 0x16 - }; - - TEE_BigInt *op1 = CreateBigInt(sizeof(op1Value), (uint8_t *)op1Value); - TEE_BigInt *op2 = CreateBigInt(sizeof(op2Value), (uint8_t *)op2Value); - int32_t result = TEE_BigIntCmp(op1, op2); - if (result < 0) { - tloge("BigIntCmp fail."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(op1); - TEE_Free(op2); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntCmpS32() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - const uint8_t opValue[] = { - 0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C - }; - - TEE_BigInt *op = CreateBigInt(sizeof(opValue), (uint8_t *)opValue); - int32_t result = TEE_BigIntCmpS32(op, 0); - if (result < 0) { - tloge("BigIntCmpS32 fail."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(op); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntShiftRight() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - const uint8_t opValue[] = { - 0x6A, 0xA2, 0xC3, 0xD4, 0x94, 0xFD, 0xB7, 0xE2, 0xF0, 0xFC, 0x91, 0x72, 0xC1, 0x50, 0x2A, 0x2C - }; - const uint8_t checkValue[] = { - 0x35, 0x51, 0x61, 0xEA, 0x4A, 0x7E, 0xDB, 0xF1, 0x78, 0x7E, 0x48, 0xB9, 0x60, 0xA8, 0x15, 0x16 - }; - TEE_BigInt *dest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *op = CreateBigInt(sizeof(opValue), (uint8_t *)opValue); - TEE_BigInt *check = CreateBigInt(sizeof(checkValue), (uint8_t *)checkValue); - TEE_BigIntShiftRight(dest, op, 1); - if (TEE_BigIntCmp(dest, check) != 0) { - tloge("BigIntShiftRight fail."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(dest); - TEE_Free(op); - TEE_Free(check); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntGetBit() -{ - tlogi("[%s] begin:", __FUNCTION__); - const uint8_t opValue[] = {0x01, 0x11, 0x01, 0x11}; - const uint32_t bitIndex = 4; - - TEE_BigInt *src = CreateBigInt(sizeof(opValue), (uint8_t *)opValue); - bool bitValue = TEE_BigIntGetBit(src, bitIndex); - if (bitValue) { // expect bitValue is 0. - tloge("BigIntGetBit failed."); - return TEE_ERROR_GENERIC; - } - TEE_Free(src); - return TEE_SUCCESS; -} - -TEE_Result TestBigIntGetBitCount() -{ - tlogi("[%s] begin:", __FUNCTION__); - const uint8_t opValue[] = {0x01, 0x11, 0x11, 0x10}; - const uint32_t check = 25; - TEE_BigInt *src = CreateBigInt(sizeof(opValue), (uint8_t *)opValue); - uint32_t count = TEE_BigIntGetBitCount(src); - if (count != check) { - tloge("BigIntGetBitCount fail. count = %d.", count); - return TEE_ERROR_GENERIC; - } - TEE_Free(src); - return TEE_SUCCESS; -} - -#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2) -TEE_Result TestBigIntSetBit() -{ - tlogi("[%s] begin:", __FUNCTION__); - const uint8_t opValue[] = {0x01, 0x11, 0x01, 0x11}; - const uint32_t bitIndex = 4; - TEE_BigInt *src = CreateBigInt(sizeof(opValue), (uint8_t *)opValue); - - uint32_t value = TEE_BigIntGetBit(src, bitIndex); - value = (value == 1 ? 0 : 1); - TEE_Result ret = TEE_BigIntSetBit(src, bitIndex, value); // action return overflow - if (ret != TEE_SUCCESS) { - tloge("error occurs in set bit operation. ret = 0x%x", ret); - TEE_Free(src); - return ret; - } - - if (value != TEE_BigIntGetBit(src, bitIndex)) { - tloge("BigIntSetBit test failed."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(src); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntAssign() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - uint8_t srcValue[] = "srcValue"; - uint8_t destValue[] = "destValue"; - TEE_BigInt *src = CreateBigInt(sizeof(srcValue), srcValue); - TEE_BigInt *dest = CreateBigInt(sizeof(destValue), destValue); - if (TEE_BigIntAssign(dest, src) != TEE_SUCCESS) { - tloge("TEE_BigIntAssign test failed.\n"); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - if (TEE_BigIntCmp(dest, src) != 0) { - tloge("TEE_BigIntAssign test failed after cmp...\n"); - ret = TEE_ERROR_GENERIC; - } - -CLEANUP: - TEE_Free(src); - TEE_Free(dest); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntAbs() -{ - tlogi("[%s] begin:", __FUNCTION__); - uint8_t absValue[] = "absValue"; - int32_t value = -99; - int32_t adsValue = 0 - value; - TEE_BigInt *src = CreateBigInt(sizeof(absValue), 0); - TEE_BigIntConvertFromS32(src, value); - - TEE_BigInt *absDest = CreateBigInt(sizeof(absValue), absValue); - TEE_BigIntAbs(absDest, src); - if (TEE_BigIntCmpS32(absDest, adsValue) != 0) { - tloge("BigIntAbs fail."); - TEE_Free(src); - TEE_Free(absDest); - return TEE_ERROR_GENERIC; - } - - TEE_Free(src); - TEE_Free(absDest); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, TEE_SUCCESS); - return TEE_SUCCESS; -} -#else -TEE_Result TestBigIntSetBit() -{ - tlogi("API_LEVEL is %d, [%s] is not supported. Return success.", API_LEVEL, __FUNCTION__); - return TEE_SUCCESS; -} - -TEE_Result TestBigIntAssign() -{ - tlogi("API_LEVEL is %d, [%s] is not supported. Return success.", API_LEVEL, __FUNCTION__); - return TEE_SUCCESS; -} - -TEE_Result TestBigIntAbs() -{ - tlogi("API_LEVEL is %d, [%s] is not supported. Return success.", API_LEVEL, __FUNCTION__); - return TEE_SUCCESS; -} -#endif diff --git a/test/xts/ta/test_arithmetic_api/src/test_logical_operation.h b/test/xts/ta/test_arithmetic_api/src/test_logical_operation.h deleted file mode 100644 index 95136195..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_logical_operation.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_LOGICAL_OPERATION_H__ -#define __TEST_LOGICAL_OPERATION_H__ - -#include - -TEE_Result TestBigIntCmp(); -TEE_Result TestBigIntCmpS32(); -TEE_Result TestBigIntShiftRight(); -TEE_Result TestBigIntGetBit(); -TEE_Result TestBigIntGetBitCount(); -TEE_Result TestBigIntSetBit(); -TEE_Result TestBigIntAssign(); -TEE_Result TestBigIntAbs(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.c b/test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.c deleted file mode 100644 index 44dd4ac8..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain g_value1 copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -static uint8_t g_value1[] = { - 0x94, 0x4E, 0xD0, 0x6B, 0x75, 0x9F, 0xE1, 0x83, 0xB8, 0x40, 0xCB, 0x46, 0x5D, 0x7D, 0xAC, 0x35, - 0x71, 0xF2, 0x0A, 0x49, 0x3E, 0x7F, 0x65, 0x26, 0xB8, 0x6E, 0x5A, 0x59, 0x84, 0x47, 0xC4, 0x2B, - 0x53, 0xB6, 0x1D, 0xA9, 0x21, 0xC2, 0x5F, 0x0E, 0x8B, 0x1F, 0x8F, 0x15, 0xBF, 0x2D, 0x0D, 0x5D, - 0x4E, 0x33, 0xB2, 0x29, 0x9C, 0x4E, 0x01, 0xCC, 0x9F, 0x64, 0xD8, 0x56, 0xFB, 0xFD, 0xE7, 0xDC, - 0x37, 0xB4, 0x3C, 0xD5, 0xA1, 0x35, 0xD0, 0xBC, 0xF7, 0x2F, 0x52, 0x18, 0x5E, 0x11, 0xFD, 0x2B, - 0xAC, 0x89, 0xC4, 0x43, 0xE1, 0x84, 0x6B, 0xE1, 0x86, 0x53, 0xA4, 0x19, 0x90, 0x5B, 0xA3, 0xA6, - 0x2A, 0x51, 0xE2, 0x95, 0xFA, 0xF2, 0x54, 0xDA, 0x9B, 0x18, 0x3A, 0x95, 0x68, 0xFD, 0x20, 0xB0, - 0x6B, 0xEB, 0xD9, 0xD7, 0xD2, 0x76, 0x9E, 0x17, 0xCF, 0xD2, 0x68, 0x83, 0x8C, 0x6F, 0xA1, 0xD1, - 0x24, 0xF1, 0xB4, 0xC9, 0x86, 0x57, 0x0C, 0xAC, 0x68, 0xC1, 0x6B, 0x65, 0xF2, 0x4F, 0xB7, 0xBB, - 0xD7, 0xA6, 0xB8, 0xF9, 0x2A, 0x86, 0x16, 0x13, 0xE3, 0x9D, 0x82, 0x9F, 0x58, 0xCE, 0x60, 0x81, - 0x0C, 0x87, 0x87, 0xAD, 0x6C, 0x9C, 0x92, 0x95, 0x2C, 0x59, 0x87, 0x93, 0xF7, 0xEB, 0xA9, 0x8D, - 0x38, 0xBF, 0x78, 0xD9, 0x03, 0x4A, 0xA6, 0xFF, 0xA6, 0xF7, 0xE1, 0x01, 0x39, 0xB2, 0x1A, 0xC3, - 0xC7, 0xAF, 0x02, 0xFE, 0x2E, 0xBE, 0xC4, 0x40, 0x1E, 0xFC, 0x54, 0xC9, 0x32, 0xB7, 0x6F, 0xE8, - 0x19, 0xA6, 0x5B, 0xC1, 0xE6, 0x95, 0x45, 0xE6, 0x0C, 0x81, 0xA7, 0xC7, 0x76, 0x5F, 0xA9, 0x85, - 0x23, 0x96, 0x06, 0x30, 0xE4, 0x09, 0x31, 0x58, 0x72, 0xAE, 0x72, 0xEB, 0xEC, 0x88, 0xCA, 0x6A, - 0xD9, 0xB6, 0x68, 0xBA, 0x4E, 0x92, 0xD6, 0xE5, 0x77, 0x64, 0x5A, 0xE9, 0x4A, 0x65, 0x37, 0x27 -}; - -static uint8_t g_value2[] = { - 0x52, 0xBD, 0x0E, 0x55, 0xE1, 0xD0, 0x2D, 0xA9, 0x6D, 0x08, 0x1C, 0x74, 0x44, 0x1B, 0x47, 0xEF, - 0x7B, 0x03, 0x45, 0x2F, 0x4C, 0x17, 0x41, 0x5A, 0x6C, 0x11, 0x02, 0x8E, 0x5D, 0x75, 0x64, 0x9E, - 0xAE, 0x2C, 0x19, 0x47, 0xD4, 0x7B, 0x1B, 0x95, 0xFD, 0x12, 0x46, 0xFF, 0x93, 0x3D, 0x3D, 0xDA, - 0xD2, 0xE6, 0xFB, 0x1A, 0x23, 0x72, 0x0B, 0xAD, 0xD1, 0x0A, 0x85, 0xE2, 0xD1, 0x29, 0x57, 0x9F, - 0xB7, 0xA5, 0x0B, 0x9F, 0xF4, 0x41, 0x81, 0xD6, 0xEC, 0xFE, 0xB0, 0xAE, 0x91, 0x22, 0x5D, 0xEB, - 0xF3, 0xAE, 0xC8, 0x4D, 0x71, 0xD4, 0xC9, 0xF5, 0x42, 0x2B, 0x77, 0x5C, 0x86, 0x21, 0x97, 0x72, - 0xF4, 0x18, 0xAA, 0x50, 0xDF, 0x80, 0x63, 0x11, 0x52, 0x51, 0xA3, 0xEC, 0x25, 0xAF, 0xD9, 0xCF, - 0xA7, 0x23, 0x3D, 0x5D, 0xCB, 0x0C, 0x4C, 0xB3, 0x75, 0xF8, 0x25, 0x7C, 0x0C, 0xF7, 0x6C, 0xF2, - 0xE6, 0xC9, 0x9E, 0x83, 0xB0, 0x8C, 0xD4, 0x87, 0xDB, 0x94, 0x9B, 0x6B, 0x7F, 0x59, 0xC2, 0x86, - 0x99, 0xA7, 0x64, 0xA2, 0x0A, 0x5D, 0x69, 0x57, 0x52, 0xD1, 0xF7, 0x74, 0x34, 0xF1, 0x09, 0x87, - 0x55, 0xAA, 0xBC, 0x8B, 0x3A, 0x64, 0xD5, 0xEA, 0xCE, 0x6C, 0x56, 0xA1, 0x51, 0x83, 0x2B, 0xEB, - 0x1A, 0x84, 0x9D, 0xA6, 0xB4, 0x7C, 0xA9, 0x1B, 0x48, 0x46, 0xD5, 0x73, 0x40, 0xEC, 0xDA, 0x2A, - 0xA8, 0x54, 0x23, 0x96, 0x36, 0xBE, 0x63, 0x26, 0xA5, 0xAC, 0xFC, 0xB5, 0x3A, 0xC7, 0xA7, 0x9A, - 0x09, 0x1E, 0xA1, 0xAA, 0x82, 0xCB, 0x00, 0x6D, 0x0F, 0xCE, 0xF9, 0x26, 0xEF, 0x7D, 0x39, 0xD6, - 0x3E, 0x89, 0x91, 0x60, 0x1F, 0xC4, 0x14, 0x6F, 0xD4, 0x88, 0x00, 0x1F, 0x8C, 0x05, 0x81, 0xF3, - 0x0F, 0x41, 0x92, 0xFE, 0x03, 0x01, 0xAD, 0x80, 0xAA, 0xB5, 0x5B, 0x54, 0x32, 0x8B, 0xBB, 0x11 -}; - -static uint8_t g_modulusVal[] = { - 0xAC, 0x09, 0xB8, 0xAC, 0x61, 0x73, 0x53, 0xF1, 0x4C, 0x1F, 0x9A, 0x44, 0x9A, 0xD6, 0x18, 0xF4, - 0x3C, 0x92, 0x45, 0x7A, 0xC1, 0xE4, 0xFD, 0x68, 0xCC, 0xBF, 0x89, 0x2E, 0x5E, 0x09, 0x0B, 0xE3, - 0x17, 0x61, 0x88, 0x20, 0xE3, 0x96, 0xE4, 0xAD, 0xC6, 0xB9, 0xC9, 0x02, 0x72, 0xC6, 0x99, 0x4C, - 0xFB, 0x8F, 0x99, 0xA6, 0x69, 0x9C, 0xBA, 0xD4, 0xF5, 0xDF, 0x4A, 0xBC, 0x0D, 0x9B, 0x9C, 0x05, - 0x7A, 0xC2, 0x93, 0xAB, 0x85, 0xD2, 0x6C, 0x4B, 0x01, 0x76, 0x66, 0x2D, 0xC4, 0x81, 0x64, 0x75, - 0xDA, 0x1E, 0x53, 0xAD, 0x00, 0xD6, 0x48, 0x3D, 0xB3, 0x0D, 0x74, 0x4A, 0xDA, 0x9E, 0xE5, 0x17, - 0xA3, 0xB1, 0xE3, 0x7E, 0xD6, 0x8F, 0x94, 0x67, 0x95, 0xDA, 0x29, 0x44, 0x33, 0xA9, 0x44, 0x96, - 0x9C, 0x2C, 0x89, 0xE3, 0x96, 0xBB, 0xD5, 0xF3, 0x29, 0x62, 0xAA, 0xAA, 0x83, 0xE2, 0xBD, 0x74, - 0xC4, 0x95, 0xA8, 0x2C, 0xB8, 0xD0, 0xF2, 0x8F, 0x9D, 0x33, 0xB4, 0x08, 0x52, 0xC5, 0xDF, 0xE1, - 0x32, 0x1C, 0x74, 0xB4, 0x6A, 0x30, 0xDF, 0xFE, 0x4E, 0x14, 0x86, 0x86, 0x75, 0xF8, 0xE5, 0x67, - 0x9A, 0x2D, 0x8A, 0xC4, 0x54, 0x36, 0xC2, 0xB3, 0xDB, 0xF6, 0x33, 0xF4, 0xD4, 0x8B, 0x9B, 0x4F, - 0x7D, 0xFF, 0x8F, 0x95, 0x39, 0x39, 0x60, 0xB2, 0x38, 0x3B, 0xF8, 0x06, 0xCC, 0xF4, 0x25, 0x00, - 0x6B, 0x11, 0xF2, 0xAA, 0x06, 0xC3, 0xEB, 0x3D, 0xFF, 0xF9, 0x8E, 0x89, 0xE2, 0x7A, 0x53, 0xA4, - 0x94, 0x23, 0x6C, 0x4A, 0xFB, 0xC6, 0x36, 0x51, 0xB0, 0xFD, 0xCC, 0x73, 0x53, 0x8F, 0xD2, 0x00, - 0x52, 0xFA, 0x2F, 0x34, 0xB8, 0x84, 0xAD, 0x32, 0x48, 0xB2, 0x49, 0x5C, 0xE5, 0xE2, 0xE0, 0xA1, - 0x9E, 0x76, 0x0D, 0x55, 0x0B, 0x3F, 0xFB, 0x28, 0x79, 0xCA, 0xE4, 0xF8, 0xCF, 0x8D, 0x52, 0x4D -}; - -static uint8_t g_checkModVal[] = { - 0x94, 0x4E, 0xD0, 0x6B, 0x75, 0x9F, 0xE1, 0x83, 0xB8, 0x40, 0xCB, 0x46, 0x5D, 0x7D, 0xAC, 0x35, - 0x71, 0xF2, 0x0A, 0x49, 0x3E, 0x7F, 0x65, 0x26, 0xB8, 0x6E, 0x5A, 0x59, 0x84, 0x47, 0xC4, 0x2B, - 0x53, 0xB6, 0x1D, 0xA9, 0x21, 0xC2, 0x5F, 0x0E, 0x8B, 0x1F, 0x8F, 0x15, 0xBF, 0x2D, 0x0D, 0x5D, - 0x4E, 0x33, 0xB2, 0x29, 0x9C, 0x4E, 0x01, 0xCC, 0x9F, 0x64, 0xD8, 0x56, 0xFB, 0xFD, 0xE7, 0xDC, - 0x37, 0xB4, 0x3C, 0xD5, 0xA1, 0x35, 0xD0, 0xBC, 0xF7, 0x2F, 0x52, 0x18, 0x5E, 0x11, 0xFD, 0x2B, - 0xAC, 0x89, 0xC4, 0x43, 0xE1, 0x84, 0x6B, 0xE1, 0x86, 0x53, 0xA4, 0x19, 0x90, 0x5B, 0xA3, 0xA6, - 0x2A, 0x51, 0xE2, 0x95, 0xFA, 0xF2, 0x54, 0xDA, 0x9B, 0x18, 0x3A, 0x95, 0x68, 0xFD, 0x20, 0xB0, - 0x6B, 0xEB, 0xD9, 0xD7, 0xD2, 0x76, 0x9E, 0x17, 0xCF, 0xD2, 0x68, 0x83, 0x8C, 0x6F, 0xA1, 0xD1, - 0x24, 0xF1, 0xB4, 0xC9, 0x86, 0x57, 0x0C, 0xAC, 0x68, 0xC1, 0x6B, 0x65, 0xF2, 0x4F, 0xB7, 0xBB, - 0xD7, 0xA6, 0xB8, 0xF9, 0x2A, 0x86, 0x16, 0x13, 0xE3, 0x9D, 0x82, 0x9F, 0x58, 0xCE, 0x60, 0x81, - 0x0C, 0x87, 0x87, 0xAD, 0x6C, 0x9C, 0x92, 0x95, 0x2C, 0x59, 0x87, 0x93, 0xF7, 0xEB, 0xA9, 0x8D, - 0x38, 0xBF, 0x78, 0xD9, 0x03, 0x4A, 0xA6, 0xFF, 0xA6, 0xF7, 0xE1, 0x01, 0x39, 0xB2, 0x1A, 0xC3, - 0xC7, 0xAF, 0x02, 0xFE, 0x2E, 0xBE, 0xC4, 0x40, 0x1E, 0xFC, 0x54, 0xC9, 0x32, 0xB7, 0x6F, 0xE8, - 0x19, 0xA6, 0x5B, 0xC1, 0xE6, 0x95, 0x45, 0xE6, 0x0C, 0x81, 0xA7, 0xC7, 0x76, 0x5F, 0xA9, 0x85, - 0x23, 0x96, 0x06, 0x30, 0xE4, 0x09, 0x31, 0x58, 0x72, 0xAE, 0x72, 0xEB, 0xEC, 0x88, 0xCA, 0x6A, - 0xD9, 0xB6, 0x68, 0xBA, 0x4E, 0x92, 0xD6, 0xE5, 0x77, 0x64, 0x5A, 0xE9, 0x4A, 0x65, 0x37, 0x27, -}; - -static uint8_t g_checkAddVal[] = { - 0x3B, 0x02, 0x26, 0x14, 0xF5, 0xFC, 0xBB, 0x3B, 0xD9, 0x29, 0x4D, 0x76, 0x06, 0xC2, 0xDB, 0x30, - 0xB0, 0x63, 0x09, 0xFD, 0xC8, 0xB1, 0xA9, 0x18, 0x57, 0xBF, 0xD3, 0xB9, 0x83, 0xB4, 0x1C, 0xE6, - 0xEA, 0x80, 0xAE, 0xD0, 0x12, 0xA6, 0x95, 0xF6, 0xC1, 0x78, 0x0D, 0x12, 0xDF, 0xA3, 0xB1, 0xEB, - 0x25, 0x8B, 0x13, 0x9D, 0x56, 0x23, 0x52, 0xA5, 0x7A, 0x90, 0x13, 0x7D, 0xBF, 0x8B, 0xA3, 0x76, - 0x74, 0x96, 0xB4, 0xCA, 0x0F, 0xA4, 0xE6, 0x48, 0xE2, 0xB7, 0x9C, 0x99, 0x2A, 0xB2, 0xF6, 0xA1, - 0xC6, 0x1A, 0x38, 0xE4, 0x52, 0x82, 0xED, 0x99, 0x15, 0x71, 0xA7, 0x2B, 0x3B, 0xDE, 0x56, 0x01, - 0x7A, 0xB8, 0xA9, 0x68, 0x03, 0xE3, 0x23, 0x84, 0x57, 0x8F, 0xB5, 0x3D, 0x5B, 0x03, 0xB5, 0xE9, - 0x76, 0xE2, 0x8D, 0x52, 0x06, 0xC7, 0x14, 0xD8, 0x1C, 0x67, 0xE3, 0x55, 0x15, 0x84, 0x51, 0x4F, - 0x47, 0x25, 0xAB, 0x20, 0x7E, 0x12, 0xEE, 0xA4, 0xA7, 0x22, 0x52, 0xC9, 0x1E, 0xE3, 0x9A, 0x61, - 0x3F, 0x31, 0xA8, 0xE6, 0xCA, 0xB2, 0x9F, 0x6C, 0xE8, 0x5A, 0xF3, 0x8D, 0x17, 0xC6, 0x84, 0xA0, - 0xC8, 0x04, 0xB9, 0x74, 0x52, 0xCA, 0xA5, 0xCC, 0x1E, 0xCF, 0xAA, 0x40, 0x74, 0xE3, 0x3A, 0x28, - 0xD5, 0x44, 0x86, 0xEA, 0x7E, 0x8D, 0xEF, 0x68, 0xB7, 0x02, 0xBE, 0x6D, 0xAD, 0xAA, 0xCF, 0xEE, - 0x04, 0xF1, 0x33, 0xEA, 0x5E, 0xB9, 0x3C, 0x28, 0xC4, 0xAF, 0xC2, 0xF4, 0x8B, 0x04, 0xC3, 0xDD, - 0x8E, 0xA1, 0x91, 0x21, 0x6D, 0x9A, 0x10, 0x01, 0x6B, 0x52, 0xD4, 0x7B, 0x12, 0x4D, 0x11, 0x5B, - 0x0F, 0x25, 0x68, 0x5C, 0x4B, 0x48, 0x98, 0x95, 0xFE, 0x84, 0x29, 0xAE, 0x92, 0xAB, 0x6B, 0xBC, - 0x4A, 0x81, 0xEE, 0x63, 0x46, 0x54, 0x89, 0x3D, 0xA8, 0x4E, 0xD1, 0x44, 0xAD, 0x63, 0x9F, 0xEB -}; - -static uint8_t g_checkSubVal[] = { - 0x41, 0x91, 0xC2, 0x15, 0x93, 0xCF, 0xB3, 0xDA, 0x4B, 0x38, 0xAE, 0xD2, 0x19, 0x62, 0x64, 0x45, - 0xF6, 0xEE, 0xC5, 0x19, 0xF2, 0x68, 0x23, 0xCC, 0x4C, 0x5D, 0x57, 0xCB, 0x26, 0xD2, 0x5F, 0x8C, - 0xA5, 0x8A, 0x04, 0x61, 0x4D, 0x47, 0x43, 0x78, 0x8E, 0x0D, 0x48, 0x16, 0x2B, 0xEF, 0xCF, 0x82, - 0x7B, 0x4C, 0xB7, 0x0F, 0x78, 0xDB, 0xF6, 0x1E, 0xCE, 0x5A, 0x52, 0x74, 0x2A, 0xD4, 0x90, 0x3C, - 0x80, 0x0F, 0x31, 0x35, 0xAC, 0xF4, 0x4E, 0xE6, 0x0A, 0x30, 0xA1, 0x69, 0xCC, 0xEF, 0x9F, 0x3F, - 0xB8, 0xDA, 0xFB, 0xF6, 0x6F, 0xAF, 0xA1, 0xEC, 0x44, 0x28, 0x2C, 0xBD, 0x0A, 0x3A, 0x0C, 0x33, - 0x36, 0x39, 0x38, 0x45, 0x1B, 0x71, 0xF1, 0xC9, 0x48, 0xC6, 0x96, 0xA9, 0x43, 0x4D, 0x46, 0xE0, - 0xC4, 0xC8, 0x9C, 0x7A, 0x07, 0x6A, 0x51, 0x64, 0x59, 0xDA, 0x43, 0x07, 0x7F, 0x78, 0x34, 0xDE, - 0x3E, 0x28, 0x16, 0x45, 0xD5, 0xCA, 0x38, 0x24, 0x8D, 0x2C, 0xCF, 0xFA, 0x72, 0xF5, 0xF5, 0x35, - 0x3D, 0xFF, 0x54, 0x57, 0x20, 0x28, 0xAC, 0xBC, 0x90, 0xCB, 0x8B, 0x2B, 0x23, 0xDD, 0x56, 0xF9, - 0xB6, 0xDC, 0xCB, 0x22, 0x32, 0x37, 0xBC, 0xAA, 0x5D, 0xED, 0x30, 0xF2, 0xA6, 0x68, 0x7D, 0xA2, - 0x1E, 0x3A, 0xDB, 0x32, 0x4E, 0xCD, 0xFD, 0xE4, 0x5E, 0xB1, 0x0B, 0x8D, 0xF8, 0xC5, 0x40, 0x99, - 0x1F, 0x5A, 0xDF, 0x67, 0xF8, 0x00, 0x61, 0x19, 0x79, 0x4F, 0x58, 0x13, 0xF7, 0xEF, 0xC8, 0x4E, - 0x10, 0x87, 0xBA, 0x17, 0x63, 0xCA, 0x45, 0x78, 0xFC, 0xB2, 0xAE, 0xA0, 0x86, 0xE2, 0x6F, 0xAE, - 0xE5, 0x0C, 0x74, 0xD0, 0xC4, 0x45, 0x1C, 0xE8, 0x9E, 0x26, 0x72, 0xCC, 0x60, 0x83, 0x48, 0x77, - 0xCA, 0x74, 0xD5, 0xBC, 0x4B, 0x91, 0x29, 0x64, 0xCC, 0xAE, 0xFF, 0x95, 0x17, 0xD9, 0x7C, 0x16, -}; - -static uint8_t g_checkMulVal[] = { - 0x9B, 0xD1, 0x3A, 0x5B, 0x6E, 0x30, 0xC9, 0x43, 0x94, 0x61, 0xB8, 0xC0, 0x6A, 0xC5, 0xD1, 0x63, - 0x34, 0x3D, 0x0D, 0x10, 0x73, 0x5B, 0xAD, 0xE0, 0xDA, 0x9E, 0x25, 0x47, 0xD7, 0x82, 0xDF, 0xF7, - 0x2B, 0xEC, 0x74, 0x5A, 0xEB, 0xE9, 0x98, 0x43, 0xEA, 0x43, 0xFE, 0xD2, 0x2E, 0x1F, 0x30, 0x15, - 0x0B, 0x86, 0x30, 0x77, 0x16, 0x45, 0x16, 0x64, 0x7B, 0xBD, 0x3F, 0x96, 0x57, 0x24, 0x41, 0x86, - 0x06, 0xEB, 0x52, 0x0C, 0x22, 0xA8, 0xCF, 0x92, 0x20, 0x26, 0xC5, 0x33, 0x77, 0x65, 0xCC, 0x5D, - 0x8F, 0xBE, 0x31, 0xD4, 0x1E, 0x3E, 0x8E, 0x38, 0x81, 0x24, 0xAF, 0x60, 0xB2, 0x86, 0x54, 0x8C, - 0xAE, 0x39, 0x97, 0x35, 0xE6, 0x65, 0x3E, 0x6B, 0xEE, 0xC2, 0xCF, 0x18, 0x0A, 0xBA, 0xA3, 0xA6, - 0x66, 0x8E, 0x64, 0x41, 0x9E, 0x50, 0xD2, 0x3E, 0x73, 0xE5, 0x57, 0x08, 0x6B, 0xFE, 0xD9, 0xBA, - 0x62, 0x3B, 0x70, 0xCC, 0xAF, 0xB3, 0x3F, 0x67, 0x24, 0xBC, 0x32, 0x42, 0x48, 0xE3, 0x74, 0x0A, - 0x63, 0xB1, 0xF1, 0xAB, 0xAD, 0x20, 0xFE, 0xB8, 0x66, 0x22, 0x1B, 0x68, 0x45, 0xAB, 0x6E, 0xC9, - 0x0C, 0x84, 0x93, 0x43, 0xA9, 0x51, 0x7E, 0x2A, 0xDC, 0x8D, 0xF0, 0xF4, 0x41, 0x0C, 0x50, 0x6F, - 0x99, 0x3C, 0xC2, 0x71, 0xE6, 0xD9, 0xF6, 0xC5, 0x75, 0x42, 0xFA, 0x71, 0xF6, 0x3B, 0xA1, 0x67, - 0x04, 0xA3, 0xDA, 0x9D, 0x3F, 0xBD, 0x87, 0x90, 0x37, 0x14, 0xB6, 0x3A, 0x04, 0xA6, 0x0F, 0x8F, - 0xF9, 0xA4, 0xCC, 0xE2, 0x3D, 0x9C, 0x71, 0x6E, 0xFB, 0x26, 0x52, 0xD4, 0x7A, 0x3D, 0xE2, 0xEB, - 0xDD, 0x1C, 0x6E, 0xD5, 0xF4, 0x98, 0x96, 0x75, 0xE0, 0xA8, 0xE0, 0x9E, 0xAB, 0x6D, 0x9F, 0x4C, - 0x1F, 0x05, 0xDA, 0xD9, 0x74, 0x5F, 0x3C, 0x4A, 0x5B, 0x51, 0x89, 0x61, 0x7F, 0x15, 0x3C, 0x2C, -}; - -TEE_Result TestBigIntMod() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op = CreateBigInt(sizeof(g_value1), g_value1); - TEE_BigInt *modulus = CreateBigInt(sizeof(g_modulusVal), g_modulusVal); - TEE_BigInt *modDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *modCheck = CreateBigInt(sizeof(g_checkModVal), g_checkModVal); - - TEE_BigIntMod(modDest, op, modulus); - if (TEE_BigIntCmp(modDest, modCheck) != 0) { - tloge("BigIntMod failed."); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(op); - TEE_Free(modulus); - TEE_Free(modDest); - TEE_Free(modCheck); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntAddAndSubMod() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op1 = CreateBigInt(sizeof(g_value1), g_value1); - TEE_BigInt *op2 = CreateBigInt(sizeof(g_value2), g_value2); - TEE_BigInt *modulus = CreateBigInt(sizeof(g_modulusVal), g_modulusVal); - - TEE_BigInt *addDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *addCheck = CreateBigInt(sizeof(g_checkAddVal), g_checkAddVal); - TEE_BigIntAddMod(addDest, op1, op2, modulus); - if (TEE_BigIntCmp(addDest, addCheck) != 0) { - tloge("BigIntAddMod failed."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - TEE_BigInt *subDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *subCheck = CreateBigInt(sizeof(g_checkSubVal), g_checkSubVal); - TEE_BigIntSubMod(subDest, op1, op2, modulus); - if (TEE_BigIntCmp(subDest, subCheck) != 0) { - tloge("BigIntSubMod failed."); - ret = TEE_ERROR_GENERIC; - } - TEE_Free(subDest); - TEE_Free(subCheck); - -CLEANUP: - TEE_Free(op1); - TEE_Free(op2); - TEE_Free(modulus); - TEE_Free(addDest); - TEE_Free(addCheck); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntMulAndInvMod() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *op1 = CreateBigInt(sizeof(g_value1), g_value1); - TEE_BigInt *op2 = CreateBigInt(sizeof(g_value2), g_value2); - TEE_BigInt *modulus = CreateBigInt(sizeof(g_modulusVal), g_modulusVal); - - TEE_BigInt *mulDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *mulCheck = CreateBigInt(sizeof(g_checkMulVal), g_checkMulVal); - TEE_BigIntMulMod(mulDest, op1, op2, modulus); - if (TEE_BigIntCmp(mulDest, mulCheck) != 0) { - tloge("BigIntMulMod failed."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - TEE_BigInt *squareDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *mulForsquareCheck = CreateBigInt(RESULT_SIZE, 0); - TEE_BigIntSquareMod(squareDest, op1, modulus); - TEE_BigIntMulMod(mulForsquareCheck, op1, op1, modulus); - int32_t isSame = TEE_BigIntCmp(squareDest, mulForsquareCheck); - TEE_Free(squareDest); - TEE_Free(mulForsquareCheck); - if (isSame != 0) { - tloge("BigIntSquareMod failed."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - TEE_BigInt *invDest = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *mulForinvCheck = CreateBigInt(RESULT_SIZE, 0); - TEE_BigIntInvMod(invDest, op1, modulus); - TEE_BigIntMulMod(mulForinvCheck, invDest, op1, modulus); - if (TEE_BigIntCmpS32(mulForinvCheck, 1) != 0) { - tloge("BigIntInvMod failed."); - ret = TEE_ERROR_GENERIC; - } - TEE_Free(invDest); - TEE_Free(mulForinvCheck); - -CLEANUP: - TEE_Free(op1); - TEE_Free(op2); - TEE_Free(modulus); - TEE_Free(mulDest); - TEE_Free(mulCheck); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntExpMod() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - uint32_t length = TEE_BigIntFMMContextSizeInU32(SIZE_256); - TEE_BigIntFMMContext *bigIntFMMContext = TEE_Malloc(length * sizeof(TEE_BigIntFMMContext), 0); - if (bigIntFMMContext == NULL) { - tloge("CmdTEEBigIntInitFMMContext: TEE_Malloc returned NULL."); - return TEE_ERROR_GENERIC; - } - - const uint8_t modValue[] = {0x01, 0x31}; - TEE_BigInt *modulus = CreateBigInt(sizeof(modValue), (uint8_t *)modValue); - TEE_BigIntInitFMMContext(bigIntFMMContext, length, modulus); - - const uint8_t desValue[] = "desValue"; - const uint8_t op1Value[] = {0x01, 0x01}; - const uint8_t op2Value[] = {0x01, 0x11}; - TEE_BigInt *des1 = CreateBigInt(sizeof(desValue), (uint8_t *)desValue); - TEE_BigInt *des2 = CreateBigInt(sizeof(desValue), (uint8_t *)desValue); - TEE_BigInt *op1 = CreateBigInt(sizeof(op1Value), (uint8_t *)op1Value); - TEE_BigInt *op2 = CreateBigInt(sizeof(op2Value), (uint8_t *)op2Value); - - if (TEE_BigIntExpMod(des1, op1, op2, modulus, bigIntFMMContext) != TEE_SUCCESS) { - tloge("TEE_BigIntExpMod failed with fmm context."); - ret = TEE_ERROR_GENERIC; - goto CLEAN_UP; - } - - if (TEE_BigIntExpMod(des2, op1, op2, modulus, NULL) != TEE_SUCCESS) { - tloge("TEE_BigIntExpMod failed with null context."); - ret = TEE_ERROR_GENERIC; - goto CLEAN_UP; - } - - if (TEE_BigIntCmp(des1, des2) != 0) { - tloge("TEE_BigIntExpMod failed for different result."); - ret = TEE_ERROR_GENERIC; - } - -CLEAN_UP: - TEE_Free(bigIntFMMContext); - TEE_Free(modulus); - TEE_Free(des1); - TEE_Free(des2); - TEE_Free(op1); - TEE_Free(op2); - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} diff --git a/test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.h b/test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.h deleted file mode 100644 index 52ef64c6..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_modular_arithmetic_operation.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_MODULAR_ARITHMETIC_OPERATION_H__ -#define __TEST_MODULAR_ARITHMETIC_OPERATION_H__ - -#include - -TEE_Result TestBigIntMod(); -TEE_Result TestBigIntAddAndSubMod(); -TEE_Result TestBigIntMulAndInvMod(); -TEE_Result TestBigIntExpMod(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.c b/test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.c deleted file mode 100644 index dea8bf45..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain longVal1 copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_arithmetic_api_base.h" - -// p1,p2 and p3 are primes -static uint8_t g_p1Value[] = { - 0x55, 0xE6, 0xE0, 0xE3, 0x96, 0x50, 0x92, 0x4F, 0x8A, 0x53, 0x48, 0x83, 0xCA, 0xDD, 0x81, 0x2D, - 0x48, 0xBA, 0x7D, 0x71, 0x25, 0xDD, 0x54, 0xB1, 0x01, 0x71, 0x72, 0xFD, 0xC9, 0x11, 0xB4, 0x00, - 0x4B, 0x7C, 0xF4, 0x32, 0xEB, 0x20, 0x12, 0x8E, 0x8D, 0x9D, 0x02, 0x5A, 0xB9, 0xF9, 0xC2, 0xC2, - 0x1E, 0x41, 0x6A, 0xC3, 0xA9, 0x2B, 0x59, 0x21, 0x80, 0x7B, 0xF8, 0x23, 0x3A, 0x73, 0xBE, 0x87, - 0xF7, 0x91, 0xE6, 0xFC, 0x57, 0x15, 0x04, 0x78, 0xCA, 0xD2, 0x75, 0x6E, 0xD1, 0x4E, 0x83, 0x08, - 0x95, 0x60, 0x49, 0x97, 0xF0, 0x83, 0x74, 0xC8, 0xEF, 0x58, 0xFE, 0x0D, 0xAA, 0x4D, 0x81, 0x40, - 0xE0, 0x67, 0x60, 0x76, 0x71, 0xD7, 0xC2, 0x83, 0x7F, 0xF0, 0xC4, 0x1B, 0x2F, 0xCF, 0x3E, 0x3C, - 0x06, 0x07, 0x64, 0x40, 0xBA, 0x83, 0x3E, 0x80, 0x01, 0x9D, 0x52, 0xF6, 0x5F, 0xC5, 0xCF, 0xCB -}; - -static uint8_t g_p2Value[] = { - 0x54, 0x5D, 0x1C, 0xAA, 0x75, 0xF2, 0xCB, 0x78, 0x97, 0x5A, 0x4D, 0x41, 0xAE, 0x9A, 0xDD, 0xB5, - 0x62, 0x10, 0x1F, 0x86, 0x64, 0x07, 0x98, 0x2D, 0x92, 0x00, 0x62, 0x26, 0x35, 0xE9, 0x63, 0xD4, - 0x96, 0x0B, 0x35, 0x25, 0x93, 0xAD, 0x26, 0x0F, 0xD0, 0xE6, 0x86, 0x9F, 0xD3, 0x7C, 0xEC, 0xD5, - 0x6E, 0x23, 0x44, 0x6B, 0xE6, 0x2E, 0xC8, 0x03, 0x5C, 0xB9, 0x63, 0xDF, 0x40, 0xB3, 0xA0, 0x1C, - 0x32, 0xB8, 0x0D, 0x06, 0x04, 0x51, 0xA5, 0x12, 0x75, 0x46, 0x61, 0x8C, 0x65, 0xC2, 0x39, 0x56, - 0x67, 0x3E, 0x51, 0x49, 0xF5, 0xAB, 0x34, 0xEE, 0xE8, 0x35, 0xDA, 0xB8, 0xDC, 0x2A, 0x96, 0x32, - 0xB6, 0x70, 0xB3, 0x49, 0xC2, 0x67, 0xBB, 0x08, 0x89, 0x18, 0x81, 0xED, 0x0F, 0xBE, 0x8C, 0xC1, - 0x39, 0x70, 0x36, 0x61, 0x3E, 0xF7, 0xF9, 0x6C, 0xF3, 0xE1, 0x74, 0x14, 0xC0, 0x49, 0x05, 0x89 -}; - -static uint8_t g_p3Value[] = { - 0x64, 0xDB, 0x43, 0xB6, 0x9E, 0xD9, 0x3A, 0x84, 0xFD, 0xA5, 0xD2, 0xB4, 0xC3, 0xB9, 0x0B, 0xAD, - 0x84, 0xF9, 0x30, 0x3F, 0xE1, 0xDE, 0x53, 0x3E, 0x20, 0x6E, 0x09, 0xD9, 0x59, 0x77, 0xC0, 0x8E, - 0x5D, 0xE4, 0x27, 0x15, 0xB6, 0x51, 0x98, 0x44, 0x71, 0x7E, 0x2B, 0x4E, 0x79, 0x27, 0x49, 0xAE, - 0x4C, 0xF5, 0xCC, 0x6F, 0xCF, 0xBF, 0x27, 0x7E, 0x07, 0x71, 0x4E, 0x48, 0x94, 0x7F, 0x60, 0xFD, - 0x32, 0x81, 0xFB, 0x44, 0x43, 0x04, 0xB1, 0xE0, 0xA2, 0x49, 0xEF, 0xAA, 0xC7, 0x8E, 0x9B, 0xC3, - 0x0C, 0x34, 0x33, 0xF4, 0x23, 0x84, 0x86, 0xAD, 0x70, 0xD9, 0x0F, 0xBE, 0xBC, 0x5A, 0xE6, 0x9E, - 0xC7, 0xB5, 0x15, 0x82, 0xE6, 0x17, 0x10, 0x06, 0x09, 0xC9, 0x9F, 0x9D, 0x99, 0xBA, 0x10, 0x63, - 0x27, 0x59, 0x46, 0xCF, 0x8B, 0x0C, 0x32, 0x0D, 0x0D, 0x9C, 0x82, 0x5A, 0x82, 0x17, 0x43, 0x03 -}; - -static uint8_t g_vCheckValue[] = { - 0x10, 0x69, 0x66, 0x78, 0x0E, 0xAE, 0xE1, 0x39, 0x02, 0x7C, 0xCE, 0x5B, 0x8F, 0x7C, 0xE5, 0x30, - 0x77, 0xA2, 0xF7, 0xE6, 0x75, 0xE8, 0x26, 0xD8, 0xAA, 0x37, 0xEB, 0x71, 0xF3, 0x0D, 0x94, 0xC5, - 0x11, 0xE1, 0x98, 0xF3, 0x65, 0xAA, 0x28, 0xE2, 0xE7, 0x2B, 0x15, 0x2C, 0x63, 0x77, 0x64, 0x40, - 0x22, 0xA8, 0xE4, 0xA7, 0xF5, 0x4E, 0x84, 0x51, 0xDE, 0x0A, 0x3C, 0x2F, 0x81, 0xD2, 0xDF, 0xE2, - 0x6C, 0x20, 0x23, 0x71, 0xB9, 0xA0, 0x0D, 0x00, 0x2A, 0x17, 0x55, 0x1C, 0xB5, 0xA1, 0x66, 0xBD, - 0xDE, 0xAC, 0x9D, 0x32, 0x30, 0xF9, 0xFF, 0x02, 0x8F, 0xD5, 0xC1, 0x1D, 0x4C, 0x91, 0x40, 0x46, - 0x62, 0xA7, 0x8E, 0xAB, 0x6B, 0x74, 0x4E, 0x44, 0x02, 0x08, 0xA4, 0x3D, 0x8B, 0xAB, 0x61, 0xAE, - 0xEE, 0xDC, 0x23, 0x4C, 0x70, 0x7A, 0x31, 0x2B, 0x5C, 0xDD, 0x31, 0x7C, 0x2B, 0x57, 0x69, 0xA3 -}; - -static uint8_t g_uCheckValue[] = { - 0x20, 0xb3, 0x43, 0x5f, 0x2a, 0x64, 0xb5, 0x6e, 0xd8, 0x63, 0x4e, 0xf3, 0xd4, 0xd3, 0x41, 0x1a, - 0xf1, 0x06, 0xb0, 0x28, 0xab, 0x05, 0x8d, 0x5b, 0xf5, 0xca, 0xa3, 0x1b, 0x90, 0x8d, 0x44, 0xae, - 0xd4, 0x26, 0x08, 0x6b, 0x1e, 0x65, 0xbf, 0xc9, 0x26, 0x46, 0xf2, 0xb6, 0xc4, 0xa7, 0x55, 0xdd, - 0x93, 0x42, 0xc0, 0xd4, 0x0c, 0xc9, 0x61, 0x74, 0xd6, 0x05, 0x45, 0x25, 0x70, 0x69, 0xc8, 0x7a, - 0x7c, 0x05, 0xec, 0xf1, 0xe3, 0x51, 0xf3, 0xb0, 0x8d, 0x6b, 0xbd, 0x8a, 0x57, 0xb0, 0x6c, 0x37, - 0x15, 0x56, 0x93, 0x90, 0x74, 0x6b, 0x88, 0x12, 0x51, 0x6c, 0xde, 0xd7, 0x98, 0x12, 0x6f, 0x02, - 0xca, 0x36, 0x63, 0xf5, 0x90, 0x87, 0x75, 0x95, 0x28, 0x9a, 0x6d, 0x19, 0xa0, 0xed, 0xa1, 0x53, - 0x6c, 0x71, 0xa4, 0x2b, 0x8d, 0xfc, 0x3f, 0xbb, 0xaa, 0xcb, 0x89, 0x24, 0xfd, 0xe8, 0x3e, 0x8a, -}; - -TEE_Result TestBigIntRelativePrime() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - TEE_BigInt *p1 = CreateBigInt(sizeof(g_p1Value), g_p1Value); - TEE_BigInt *p2 = CreateBigInt(sizeof(g_p2Value), g_p2Value); - TEE_BigInt *tmp1 = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *tmp2 = CreateBigInt(RESULT_SIZE, 0); - - TEE_BigIntConvertFromS32(tmp1, NUM_THREE); - TEE_BigIntMul(tmp1, tmp1, p1); // tmp1 = p1 * 3 - TEE_BigIntConvertFromS32(tmp2, NUM_FIVE); - TEE_BigIntMul(tmp2, tmp2, p2); // temp2 = p2 * 5 - if (!TEE_BigIntRelativePrime(tmp1, tmp2)) { - tloge("BigIntRelativePrime fail.\n"); - ret = TEE_ERROR_GENERIC; - } - - TEE_Free(p1); - TEE_Free(p2); - TEE_Free(tmp1); - TEE_Free(tmp2); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntComputeExtentedGcd() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - - TEE_BigInt *p1 = CreateBigInt(sizeof(g_p1Value), g_p1Value); - TEE_BigInt *p2 = CreateBigInt(sizeof(g_p2Value), g_p2Value); - TEE_BigInt *p3 = CreateBigInt(sizeof(g_p3Value), g_p3Value); - TEE_BigInt *a = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *b = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *u = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *v = CreateBigInt(RESULT_SIZE, 0); - TEE_BigInt *tmp1 = CreateBigInt(RESULT_SIZE * NUM_TWO, 0); - TEE_BigInt *tmp2 = CreateBigInt(RESULT_SIZE * NUM_TWO, 0); - TEE_BigInt *gcd = CreateBigInt(RESULT_SIZE, 0); - - // a = p1 * p2 * 3 - TEE_BigIntMul(a, p1, p2); - TEE_BigIntConvertFromS32(tmp1, NUM_THREE); - TEE_BigIntMul(a, a, tmp1); - - // b = p1 * p3 * 5 - TEE_BigIntMul(b, p1, p3); - TEE_BigIntConvertFromS32(tmp2, NUM_FIVE); - TEE_BigIntMul(b, b, tmp2); - - // gdc (a,b) = gdc ((p1*p2*3),(p1*p3*5)) = p1 - TEE_BigIntComputeExtendedGcd(gcd, u, v, a, b); - if (TEE_BigIntCmp(gcd, p1) != 0) { - tloge("BigIntComputeExtendedGcd check gcd fail."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - - TEE_BigInt *uCheck = CreateBigInt(sizeof(g_uCheckValue), g_uCheckValue); - TEE_BigInt *vCheck = CreateBigInt(sizeof(g_vCheckValue), g_vCheckValue); - TEE_BigIntNeg(vCheck, vCheck); // turn v to negative - if (TEE_BigIntCmp(v, vCheck) != 0 || TEE_BigIntCmp(u, uCheck) != 0) { - tloge("BigIntComputeExtendedGcd check v or u fail."); - ret = TEE_ERROR_GENERIC; - } - TEE_Free(uCheck); - TEE_Free(vCheck); - -CLEANUP: - TEE_Free(p1); - TEE_Free(p2); - TEE_Free(p3); - TEE_Free(a); - TEE_Free(b); - TEE_Free(u); - TEE_Free(v); - TEE_Free(tmp1); - TEE_Free(tmp2); - TEE_Free(gcd); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -TEE_Result TestBigIntIsProbablePrime() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Result ret = TEE_SUCCESS; - const uint32_t leastConfidenceLevel = 80; - // p1 is a prime - uint8_t g_p1Value[] = { - 0x40, 0x84, 0xB4, 0xAF, 0xF9, 0x13, 0xE0, 0x2B, 0xFF, 0x2D, 0x30, 0x21, 0x7C, 0x94, 0xD2, 0x8F, - 0x89, 0x47, 0x9F, 0x7E, 0x14, 0xC1, 0xB4, 0xD7, 0x64, 0x97, 0x33, 0x65, 0x26, 0x62, 0x86, 0xED - }; - TEE_BigInt *p1 = CreateBigInt(sizeof(g_p1Value), g_p1Value); - TEE_BigInt *tmp = CreateBigInt(RESULT_SIZE, 0); - - if (!TEE_BigIntIsProbablePrime(p1, leastConfidenceLevel)) { - tloge("check p1 is a prime fail."); - ret = TEE_ERROR_GENERIC; - goto CLEANUP; - } - TEE_BigIntConvertFromS32(tmp, NUM_THREE); - TEE_BigIntMul(p1, p1, tmp); - // check that p1 is not a prime - if (TEE_BigIntIsProbablePrime(p1, leastConfidenceLevel)) { - tloge("check p1 is not a prime fail."); - ret = TEE_ERROR_GENERIC; - } - -CLEANUP: - TEE_Free(p1); - TEE_Free(tmp); - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} \ No newline at end of file diff --git a/test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.h b/test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.h deleted file mode 100644 index be7846b4..00000000 --- a/test/xts/ta/test_arithmetic_api/src/test_other_arithmetic_operation.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_OTHER_ARITHMETIC_OPERATION_H__ -#define __TEST_OTHER_ARITHMETIC_OPERATION_H__ - -#include - -TEE_Result TestBigIntRelativePrime(); -TEE_Result TestBigIntComputeExtentedGcd(); -TEE_Result TestBigIntIsProbablePrime(); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/CMakeLists.txt b/test/xts/ta/test_crypto_api/CMakeLists.txt deleted file mode 100644 index 0b15a6a9..00000000 --- a/test/xts/ta/test_crypto_api/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_crypto_api) - -list(APPEND ta_src - src/oh_crypto_entry.c - src/cases/cases_ae_crypto_basic_cases.c - src/cases/cases_asym_crypto_basic_cases.c - src/cases/cases_asym_sign_basic_cases.c - src/cases/cases_derive_basic_cases.c - src/cases/cases_digest_crypto_basic_cases.c - src/cases/cases_entry.c - src/cases/cases_mac_crypto_basic_cases.c - src/cases/cases_sym_crypto_basic_cases.c - src/data/alg_map_data.c - src/data/key_object_database.c - src/monad/monad_actions.c - src/monad/monad_inverse_map.c - src/monad/monad_run.c -) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - ${ta_src} - - INCLUDE_DIRS - - COMPILE_OPTS - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_crypto_api/manifest.txt b/test/xts/ta/test_crypto_api/manifest.txt deleted file mode 100644 index ad9f2eaf..00000000 --- a/test/xts/ta/test_crypto_api/manifest.txt +++ /dev/null @@ -1,7 +0,0 @@ -gpd.ta.appID: 05050505-0303-0303-0303-030303030301 -gpd.ta.service_name: test_crypto_api -gpd.ta.singleInstance: true -gpd.ta.multiSession: true -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 8192000 -gpd.ta.stackSize: 40960 diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_ae_crypto_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_ae_crypto_basic_cases.c deleted file mode 100644 index 770d27cf..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_ae_crypto_basic_cases.c +++ /dev/null @@ -1,2670 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK128N7T32Aad32MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 32, - .aeTagOSize = 4, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N7T32Aad32MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK128N7T32Aad32MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 32, - .aeTagOSize = 4, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N7T32Aad32MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK128N7T32Aad32update0Multi(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 32, - .aeTagOSize = 4, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdate0Fwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdate0Bck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdate0Fwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdate0Bck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 25, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N7T32Aad32update0Multi success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_003 -int CaseAEAesCcmK128N7T32Aad32OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 32, - .aeTagOSize = 4, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_LE1B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N7T32Aad32OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_004 -int CaseAEAesCcmK128N7T32Aad32OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 32, - .aeTagOSize = 4, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_LE1B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N7T32Aad32OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK192N8T48Aad288MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 8, - .nonceByte = 0x11, - .aeTagLen = 48, - .aeTagOSize = 6, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N8T48Aad288MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK192N8T48Aad288MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 8, - .nonceByte = 0x11, - .aeTagLen = 48, - .aeTagOSize = 6, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N8T48Aad288MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_003 -int CaseAEAesCcmK192N8T48Aad288OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 8, - .nonceByte = 0x11, - .aeTagLen = 48, - .aeTagOSize = 6, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_LE1B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N8T48Aad288OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_004 -int CaseAEAesCcmK192N8T48Aad288OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 8, - .nonceByte = 0x11, - .aeTagLen = 48, - .aeTagOSize = 6, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_LE1B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N8T48Aad288OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK256N9T64Aad512MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 9, - .nonceByte = 0x12, - .aeTagLen = 64, - .aeTagOSize = 8, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N9T64Aad512MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK256N9T64Aad512MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 9, - .nonceByte = 0x12, - .aeTagLen = 64, - .aeTagOSize = 8, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N9T64Aad512MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_003 -int CaseAEAesCcmK256N13T128Aad512OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 13, - .nonceByte = 0x12, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_LE16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N13T128Aad512OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_004 -int CaseAEAesCcmK256N13T128Aad512OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 13, - .nonceByte = 0x12, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_LE16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N13T128Aad512OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK128N10T80Aad4MMultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 10, - .nonceByte = 0x13, - .aeTagLen = 80, - .aeTagOSize = 10, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 4096, - .aeAadLenInit = 4096, - .aadByte = 0x13, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N10T80Aad4MMultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK128N10T80Aad4MMultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 10, - .nonceByte = 0x13, - .aeTagLen = 80, - .aeTagOSize = 10, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 4096, - .aeAadLenInit = 4096, - .aadByte = 0x13, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N10T80Aad4MMultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK192N11T96Aad32MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 11, - .nonceByte = 0x14, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x14, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N11T96AadMAXMultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK192N11T96Aad32MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 11, - .nonceByte = 0x14, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x14, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N11T96AadMAXMultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK256N12T112Aad288MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x15, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x15, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N12T112Aad288MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK256N12T112Aad288MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x15, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x15, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N12T112Aad288MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_001 -int CaseAEAesCcmK128N13T128Aad512MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 13, - .nonceByte = 0x16, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x16, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N12T112Aad288MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_002 -int CaseAEAesCcmK128N13T128Aad512MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 13, - .nonceByte = 0x16, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x16, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N13T128Aad512MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_008 -int CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 9, - .nonceByte = 0x17, - .aeTagLen = 64, - .aeTagOSize = 8, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x17, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalOmtBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_005 -int CaseAEAesCcmK192N8T64NoAadOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 8, - .nonceByte = 0x18, - .aeTagLen = 64, - .aeTagOSize = 8, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N8T64NoAadOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_006 -int CaseAEAesCcmK192N8T64NoAadMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 8, - .nonceByte = 0x19, - .aeTagLen = 64, - .aeTagOSize = 8, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK192N8T64NoAadMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_007 -int CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG(void) -{ - TestVector tv = { - .algName = {"AE_aes_ccm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x20, - .aeTagLen = 32, - .aeTagOSize = 4, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x20, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalOmtFwd, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_009 -int CaseAEAesGcmK128N7T96Aad32MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N7T96Aad32MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_010 -int CaseAEAesGcmK128N7T96Aad32MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N7T96Aad32MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_010 -int CaseAEAesGcmK128N7T96Aad32update0Multi(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdate0Fwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdate0Bck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdate0Fwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdate0Bck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 25, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N7T96Aad32update0Multi success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_011 -int CaseAEAesGcmK128N7T96Aad32OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_LE16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N7T96Aad32OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_012 -int CaseAEAesGcmK128N7T96Aad32OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_LE16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N7T96Aad32OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_009 -int CaseAEAesGcmK192N12T104Aad288MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N12T104Aad288MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_010 -int CaseAEAesGcmK192N12T104Aad288MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N12T104Aad288MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_011 -int CaseAEAesGcmK192N12T104Aad288OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_LE1B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N12T104Aad288OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_012 -int CaseAEAesGcmK192N12T104Aad288OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_LE1B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N12T104Aad288OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_009 -int CaseAEAesGcmK256N7T112Aad512MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK256N7T112Aad512MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_010 -int CaseAEAesGcmK256N7T112Aad512MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK256N7T112Aad512MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_011 -int CaseAEAesGcmK256N7T128Aad512OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_LE1B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK256N7T128Aad512OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_012 -int CaseAEAesGcmK256N7T128Aad512OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_LE1B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK256N7T128Aad512OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_009 -int CaseAEAesGcmK128N12T120Aad4MMultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x13, - .aeTagLen = 120, - .aeTagOSize = 15, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 4096, - .aeAadLenInit = 4096, - .aadByte = 0x13, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N12T120Aad4MMultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_010 -int CaseAEAesGcmK128N12T120Aad4MMultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x13, - .aeTagLen = 120, - .aeTagOSize = 15, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 4096, - .aeAadLenInit = 4096, - .aadByte = 0x13, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N12T120Aad4MMultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_009 -int CaseAEAesGcmK192N7T128Aad32MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x14, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x14, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N7T128Aad32MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_010 -int CaseAEAesGcmK192N7T128Aad32MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x14, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x14, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N7T128Aad32MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_016 -int CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x17, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_GR1B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x17, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalOmtBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_013 -int CaseAEAesGcmK192N12T96NoAadOnce(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x18, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_GR1B, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N12T96NoAadOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_014 -int CaseAEAesGcmK192N12T96NoAadMulti(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x18, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_GR1B, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK192N12T96NoAadMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_015 -int CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG(void) -{ - TestVector tv = { - .algName = {"AE_aes_gcm"}, - .operaMaxKeySize = 256, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x20, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x20, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalOmtFwd, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N7T96Aad32MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T96Aad32MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N7T96Aad32MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T96Aad32MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_019 -int CaseAESM4GcmK128N7T96Aad32OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_LE16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T96Aad32OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_020 -int CaseAESM4GcmK128N7T96Aad32OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_LE16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T96Aad32OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N7T96Aad32update0Multi(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x10, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x10, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdate0Fwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdate0Bck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdate0Fwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdate0Bck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 25, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T96Aad32update0Multi success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N12T104Aad288MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T104Aad288MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N12T104Aad288MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_100K_GR200B, - .dataSize = DATA100K_GR500B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T104Aad288MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_019 -int CaseAESM4GcmK128N12T104Aad288OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_LE1B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T104Aad288OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_020 -int CaseAESM4GcmK128N12T104Aad288OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x11, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_LE1B, - .aeAadLen = 288, - .aeAadLenInit = 288, - .aadByte = 0x11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T104Aad288OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N7T112Aad512MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T112Aad512MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N7T112Aad512MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_250K_GR200B, - .dataSize = DATA250K_GR200B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T112Aad512MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_019 -int CaseAESM4GcmK128N7T128Aad512OnceOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_LE1B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T128Aad512OnceOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_020 -int CaseAESM4GcmK128N7T128Aad512OnceMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x12, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_LE1B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x12, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T128Aad512OnceMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N12T120Aad4MMultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x13, - .aeTagLen = 120, - .aeTagOSize = 15, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 4096, - .aeAadLenInit = 4096, - .aadByte = 0x13, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T120Aad4MMultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N12T120Aad4MMultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x13, - .aeTagLen = 120, - .aeTagOSize = 15, - .sliceSize = SLICELEN_500K, - .dataSize = SLICELEN_500K, - .aeAadLen = 4096, - .aeAadLenInit = 4096, - .aadByte = 0x13, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T120Aad4MMultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N7T128Aad32MultiOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x14, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_GR1B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x14, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T128Aad32MultiOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N7T128Aad32MultiMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x14, - .aeTagLen = 128, - .aeTagOSize = 16, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_GR1B, - .aeAadLen = 32, - .aeAadLenInit = 32, - .aadByte = 0x14, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateAadFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 21, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T128Aad32MultiMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x17, - .aeTagLen = 112, - .aeTagOSize = 14, - .sliceSize = SLICELEN_1M, - .dataSize = DATA1M_GR1B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x17, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateAadMtlBck, AEUpdateBck, AEDoFinalOmtBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N12T96NoAadOnce(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x18, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_GR1B, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T96NoAadOnce success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_017 -int CaseAESM4GcmK128N12T96NoAadMulti(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 12, - .nonceByte = 0x18, - .aeTagLen = 96, - .aeTagOSize = 12, - .sliceSize = SLICELEN_500K, - .dataSize = DATA500K_GR1B, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - AEInitFwd, AEUpdateFwd, AEEncFinalFwd, - AEInitBck, AEUpdateBck, AEDoFinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N12T96NoAadMulti success\n", __func__); - return 0; -} - -// Crypto_AE_Fun_018 -int CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG(void) -{ - TestVector tv = { - .algName = {"AE_sm4_gcm"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .aeNonceLen = 7, - .nonceByte = 0x20, - .aeTagLen = 104, - .aeTagOSize = 13, - .sliceSize = SLICELEN_50K, - .dataSize = DATA50K_GR16B, - .aeAadLen = 512, - .aeAadLenInit = 512, - .aadByte = 0x20, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - AEInitFwd, AEUpdateAadMtlFwd, AEUpdateFwd, AEEncFinalOmtFwd, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG success\n", __func__); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_asym_crypto_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_asym_crypto_basic_cases.c deleted file mode 100644 index b66196d1..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_asym_crypto_basic_cases.c +++ /dev/null @@ -1,630 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -// Crypto_AsymEncrypt_Fun_001 -int CaseAsymEncryptRsaV15KeySize512Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_v15"}, - .operaMaxKeySize = 512, - .keySize = 512, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_0, - .fwdKeyTypeName = "kt_rsa_pub", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64 - 11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, - ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize512Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_001 -int CaseAsymEncryptRsaV15KeySize2048Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_v15"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_2, - .fwdKeyTypeName = "kt_rsa_pub", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 256 - 11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, - ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize2048Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_002 -int CaseAsymEncryptRsaV15KeySize2048Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_v15"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_2, - .fwdKeyTypeName = "kt_rsa_pub", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 256 - 11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize2048Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_001 -int CaseAsymEncryptRsaV15KeySize4096Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_v15"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512 - 11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, - ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize4096Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_002 -int CaseAsymEncryptRsaV15KeySize4096Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_v15"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512 - 11, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaV15KeySize4096Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_003 -int CaseAsymEncryptRsaOaepSha384KeySize2048Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_oaep_sha384"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 256 - 98, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, - ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha384KeySize2048Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_004 -int CaseAsymEncryptRsaOaepSha384KeySize2048Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_oaep_sha384"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 256 - 98, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha384KeySize2048Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_003 -int CaseAsymEncryptRsaOaepSha512KeySize4096Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_oaep_sha512"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pub", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512 - 130, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, - ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha512KeySize4096Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_004 -int CaseAsymEncryptRsaOaepSha512KeySize4096Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_oaep_sha512"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pub", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512 - 130, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaOaepSha512KeySize4096Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_006 -int CaseAsymEncryptRsaNopadKeySize2688Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_nopad"}, - .operaMaxKeySize = 2688, - .keySize = 2688, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 336, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize2688Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_006 -int CaseAsymEncryptRsaNopadKeySize2688Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_nopad"}, - .operaMaxKeySize = 2688, - .keySize = 2688, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 336, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize2688Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_006 -int CaseAsymEncryptRsaNopadKeySize4096Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_nopad"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize4096Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_006 -int CaseAsymEncryptRsaNopadKeySize4096Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_rsa_nopad"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptRsaNopadKeySize4096Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_007 -int CaseAsymEncryptSm2PkeDataSize64Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_sm2_pke"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_sm2_pke_pub", - .bckKeyTypeName = "kt_sm2_pke_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize64Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_008 -int CaseAsymEncryptSm2PkeDataSize64Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_sm2_pke"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_sm2_pke_pub", - .bckKeyTypeName = "kt_sm2_pke_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize64Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_007 -int CaseAsymEncryptSm2PkeDataSize470Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_sm2_pke"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_sm2_pke_pair", - .bckKeyTypeName = "kt_sm2_pke_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 470, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize470Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_008 -int CaseAsymEncryptSm2PkeDataSize470Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_sm2_pke"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_sm2_pke_pair", - .bckKeyTypeName = "kt_sm2_pke_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 470, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize470Multi success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_007 -int CaseAsymEncryptSm2PkeDataSize1024Once(void) -{ - TestVector tv = { - .algName = {"AS_ed_sm2_pke"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_sm2_pke_pub", - .bckKeyTypeName = "kt_sm2_pke_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1024, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize1024Once success\n", __func__); - return 0; -} - -// Crypto_AsymEncrypt_Fun_008 -int CaseAsymEncryptSm2PkeDataSize1024Multi(void) -{ - TestVector tv = { - .algName = {"AS_ed_sm2_pke"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_sm2_pke_pub", - .bckKeyTypeName = "kt_sm2_pke_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1024, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASEncryFwd, ASDecryBck, - ASEncryFwd, ASDecryBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymEncryptSm2PkeDataSize1024Multi success\n", __func__); - return 0; -} diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_asym_sign_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_asym_sign_basic_cases.c deleted file mode 100644 index e201de68..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_asym_sign_basic_cases.c +++ /dev/null @@ -1,839 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -// Crypto_AsymSign_Fun_001 -int CaseAsymSignRsaV15Sha384KeySize2048Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_v15_sha384"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 48, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaV15Sha384KeySize2048Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_002 -int CaseAsymSignRsaV15Sha384KeySize2048Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_v15_sha384"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 48, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaV15Sha384KeySize2048Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_001 -int CaseAsymSignRsaV15Sha512KeySize4096Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_v15_sha512"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaV15Sha512KeySize4096Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_002 -int CaseAsymSignRsaV15Sha512KeySize4096Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_v15_sha512"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaV15Sha512KeySize4096Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_003 -int CaseAsymSignRsaPssSha384KeySize2048Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_pss_SHA384"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 48, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaPssSha384KeySize2048Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_004 -int CaseAsymSignRsaPssSha384KeySize2048Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_pss_SHA384"}, - .operaMaxKeySize = 2048, - .keySize = 2048, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 48, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaPssSha384KeySize2048Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_003 -int CaseAsymSignRsaPssSha512KeySize4096Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_pss_SHA512"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaPssSha512KeySize4096Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_004 -int CaseAsymSignRsaPssSha512KeySize4096Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_rsa_pss_SHA512"}, - .operaMaxKeySize = 4096, - .keySize = 4096, - .rsaGenPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - .fwdKeyTypeName = "kt_rsa_pair", - .bckKeyTypeName = "kt_rsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignRsaPssSha512KeySize4096Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_005 -int CaseAsymSignEcdsaSha256KeySize256Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ecdsa_sha256"}, - .operaMaxKeySize = 521, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_NIST_P256, - .fwdKeyTypeName = "kt_ecdsa_pair", - .bckKeyTypeName = "kt_ecdsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 32, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEcdsaSha256KeySize256Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_006 -int CaseAsymSignEcdsaSha256KeySize256Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ecdsa_sha256"}, - .operaMaxKeySize = 521, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_NIST_P256, - .fwdKeyTypeName = "kt_ecdsa_pair", - .bckKeyTypeName = "kt_ecdsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 32, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEcdsaSha256KeySize256Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_005 -int CaseAsymSignEcdsaSha384KeySize384Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ecdsa_sha384"}, - .operaMaxKeySize = 521, - .keySize = 384, - .ecKeyCurve = TEE_ECC_CURVE_NIST_P384, - .fwdKeyTypeName = "kt_ecdsa_pair", - .bckKeyTypeName = "kt_ecdsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 48, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEcdsaSha384KeySize384Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_006 -int CaseAsymSignEcdsaSha384KeySize384Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ecdsa_sha384"}, - .operaMaxKeySize = 521, - .keySize = 384, - .ecKeyCurve = TEE_ECC_CURVE_NIST_P384, - .fwdKeyTypeName = "kt_ecdsa_pair", - .bckKeyTypeName = "kt_ecdsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 48, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEcdsaSha384KeySize384Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_005 -int CaseAsymSignEcdsaSha512KeySize521Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ecdsa_sha512"}, - .operaMaxKeySize = 521, - .keySize = 521, - .ecKeyCurve = TEE_ECC_CURVE_NIST_P521, - .fwdKeyTypeName = "kt_ecdsa_pair", - .bckKeyTypeName = "kt_ecdsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEcdsaSha512KeySize521Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_006 -int CaseAsymSignEcdsaSha512KeySize521Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ecdsa_sha512"}, - .operaMaxKeySize = 521, - .keySize = 521, - .ecKeyCurve = TEE_ECC_CURVE_NIST_P521, - .fwdKeyTypeName = "kt_ecdsa_pair", - .bckKeyTypeName = "kt_ecdsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEcdsaSha512KeySize521Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_007 -int CaseAsymSignEd25519DataSize64Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize64Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_008 -int CaseAsymSignEd25519DataSize64Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 64, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize64Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_007 -int CaseAsymSignEd25519DataSize470Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 470, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize470Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_008 -int CaseAsymSignEd25519DataSize470Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 470, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize470Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_007 -int CaseAsymSignEd25519DataSize1270Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1270, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize1270Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_008 -int CaseAsymSignEd25519DataSize1270Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1270, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize1270Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_007 -int CaseAsymSignEd25519DataSize4096Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 4096, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize4096Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_008 -int CaseAsymSignEd25519DataSize4096Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_ed25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_25519, - .fwdKeyTypeName = "kt_ed25519_pair", - .bckKeyTypeName = "kt_ed25519_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 4096, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignEd25519DataSize4096Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_009 -int CaseAsymSignSm2DsaSm3DataSize32Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_sm2_dsa_sm3"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_SM2, - .fwdKeyTypeName = "kt_sm2_dsa_pair", - .bckKeyTypeName = "kt_sm2_dsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 32, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize32Once success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_010 -int CaseAsymSignSm2DsaSm3DataSize32Multi(void) -{ - TestVector tv = { - .algName = {"AS_sv_sm2_dsa_sm3"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_SM2, - .fwdKeyTypeName = "kt_sm2_dsa_pair", - .bckKeyTypeName = "kt_sm2_dsa_pub", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 32, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, ASVerifyBck, - ASSignFwd, ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize32Multi success\n", __func__); - return 0; -} - -// Crypto_AsymSign_Fun_009 -int CaseAsymSignSm2DsaSm3DataSize128Once(void) -{ - TestVector tv = { - .algName = {"AS_sv_sm2_dsa_sm3"}, - .operaMaxKeySize = 256, - .keySize = 256, - .ecKeyCurve = TEE_ECC_CURVE_SM2, - .fwdKeyTypeName = "kt_sm2_dsa_pair", - .bckKeyTypeName = "kt_sm2_dsa_pair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 128, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - ASSignFwd, - ASVerifyBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseAsymSignSm2DsaSm3DataSize128Once success\n", __func__); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_derive_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_derive_basic_cases.c deleted file mode 100644 index 9928a7f1..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_derive_basic_cases.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -// Crypto_DR_Fun7.0.0_001 -int CaseDRDHKeySize512Pram512DataSize1024(void) -{ - TestVector tv = { - .algName = {"DR_dh"}, - .operaMaxKeySize = 512, - .keySize = 512, - .fwdKeyTypeName = "kt_dh_pair", - .bckKeyTypeName = "kt_dh_pair", - .dhGenKeySize = 512, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1024, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_JF, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDRDHKeySize512Pram512DataSize1024 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_001 -int CaseDRDHKeySize1024Pram1024DataSize1024(void) -{ - TestVector tv = { - .algName = {"DR_dh"}, - .operaMaxKeySize = 1024, - .keySize = 1024, - .fwdKeyTypeName = "kt_dh_pair", - .bckKeyTypeName = "kt_dh_pair", - .dhGenKeySize = 1024, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1024, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_JF, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDRDHKeySize1024Pram1024DataSize1024 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_002 -int CaseDREcdhNistP224DataSize14(void) -{ - TestVector tv = { - .algName = {"DR_ecdh"}, - .operaMaxKeySize = 224, - .keySize = 224, - .fwdKeyTypeName = "kt_ecdh_pair", - .bckKeyTypeName = "kt_ecdh_pair", - .ecKeyCurve = TEE_ECC_CURVE_NIST_P224, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 10000, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDREcdhNistP224DataSize14 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_002 -int CaseDREcdhNistP256DataSize128(void) -{ - TestVector tv = { - .algName = {"DR_ecdh"}, - .operaMaxKeySize = 521, - .keySize = 256, - .fwdKeyTypeName = "kt_ecdh_pair", - .bckKeyTypeName = "kt_ecdh_pair", - .ecKeyCurve = TEE_ECC_CURVE_NIST_P256, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 128, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDREcdhNistP256DataSize128 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_002 -int CaseDREcdhNistP384DataSize512(void) -{ - TestVector tv = { - .algName = {"DR_ecdh"}, - .operaMaxKeySize = 521, - .keySize = 384, - .fwdKeyTypeName = "kt_ecdh_pair", - .bckKeyTypeName = "kt_ecdh_pair", - .ecKeyCurve = TEE_ECC_CURVE_NIST_P384, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 512, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDREcdhNistP384DataSize512 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_002 -int CaseDREcdhNistP521DataSize1024(void) -{ - TestVector tv = { - .algName = {"DR_ecdh"}, - .operaMaxKeySize = 521, - .keySize = 521, - .fwdKeyTypeName = "kt_ecdh_pair", - .bckKeyTypeName = "kt_ecdh_pair", - .ecKeyCurve = TEE_ECC_CURVE_NIST_P521, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1024, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDREcdhNistP521DataSize1024 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_002 -int CaseDREcdhNistP521DataSize4096(void) -{ - TestVector tv = { - .algName = {"DR_ecdh"}, - .operaMaxKeySize = 521, - .keySize = 521, - .fwdKeyTypeName = "kt_ecdh_pair", - .bckKeyTypeName = "kt_ecdh_pair", - .ecKeyCurve = TEE_ECC_CURVE_NIST_P521, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 4096, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDREcdhNistP521DataSize4096 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_002 -int CaseDREcdhNistP384DataSize10000(void) -{ - TestVector tv = { - .algName = {"DR_ecdh"}, - .operaMaxKeySize = 521, - .keySize = 384, - .fwdKeyTypeName = "kt_ecdh_pair", - .bckKeyTypeName = "kt_ecdh_pair", - .ecKeyCurve = TEE_ECC_CURVE_NIST_P384, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 10000, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDREcdhNistP384DataSize10000 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_003 -int CaseDRX25519DataSize1024(void) -{ - TestVector tv = { - .algName = {"DR_x25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_x25519_keypair", - .bckKeyTypeName = "kt_x25519_keypair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 1024, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDRX25519DataSize1024 success\n", __func__); - return 0; -} - -// Crypto_DR_Fun7.0.0_003 -int CaseDRX25519DataSize4096(void) -{ - TestVector tv = { - .algName = {"DR_x25519"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_x25519_keypair", - .bckKeyTypeName = "kt_x25519_keypair", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = 4096, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - DRDeriveFwd, - DRDeriveBck, - GlbFree, - IRTearDown, }, - .actionsSize = 7, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDRX25519DataSize4096 success\n", __func__); - return 0; -} diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_digest_crypto_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_digest_crypto_basic_cases.c deleted file mode 100644 index 257cc2bc..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_digest_crypto_basic_cases.c +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -/* - * Case name meaning: Case&&algname&&Compute mode&&Compute times - * Compute mode: number of calculateing steps, once means datasize is less than slicesize, - multi means datasize is greater than slicesize - * Compute times: algorithm calculation times, once means algorithm calculation once, - multi means algorithm calculation multi times - */ - -// Crypto_DI_Fun_002 -int CaseDigestSha256OnceOnce(void) -{ - TestVector tv = { - .algName = {"DI_sha256"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_LE64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 6, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha256OnceOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_004 -int CaseDigestSha256OnceMulti(void) -{ - TestVector tv = { - .algName = {"DI_sha256"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_LE64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalFwd, - DIDofinalBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha256OnceMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_001 -int CaseDigestSha256MultiOnce(void) -{ - TestVector tv = { - .algName = {"DI_sha256"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_GR64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha256MultiOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_003 -int CaseDigestSha256MultiMulti(void) -{ - TestVector tv = { - .algName = {"DI_sha256"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_GR64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 12, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha256MultiMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_002 -int CaseDigestSha384OnceOnce(void) -{ - TestVector tv = { - .algName = {"DI_sha384"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA100K_LE1B, - .sliceSize = SLICELEN_100K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 6, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha384OnceOnce success\n", __func__); - return 0; -} -// Crypto_DI_Fun_004 -int CaseDigestSha384OnceMulti(void) -{ - TestVector tv = { - .algName = {"DI_sha384"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA100K_LE1B, - .sliceSize = SLICELEN_100K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalFwd, - DIDofinalBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha384OnceMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_001 -int CaseDigestSha384MultiOnce(void) -{ - TestVector tv = { - .algName = {"DI_sha384"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA100K_GR500B, - .sliceSize = SLICELEN_100K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha384MultiOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_003 -int CaseDigestSha384MultiMulti(void) -{ - TestVector tv = { - .algName = {"DI_sha384"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA100K_GR500B, - .sliceSize = SLICELEN_100K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 12, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha384MultiMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_002 -int CaseDigestSha512OnceOnce(void) -{ - TestVector tv = { - .algName = {"DI_sha512"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA250K_LE128B, - .sliceSize = SLICELEN_250K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 6, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha512OnceOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_004 -int CaseDigestSha512OnceMulti(void) -{ - TestVector tv = { - .algName = {"DI_sha512"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA250K_LE128B, - .sliceSize = SLICELEN_250K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalFwd, - DIDofinalBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha512OnceMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_001 -int CaseDigestSha512MultiOnce(void) -{ - TestVector tv = { - .algName = {"DI_sha512"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA250K_GR200B, - .sliceSize = SLICELEN_250K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha512MultiOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_003 -int CaseDigestSha512MultiMulti(void) -{ - TestVector tv = { - .algName = {"DI_sha512"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA250K_GR200B, - .sliceSize = SLICELEN_250K_GR200B, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 12, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSha512MultiMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_002 -int CaseDigestSM3OnceOnce(void) -{ - TestVector tv = { - .algName = {"DI_sm3"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_LE1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 6, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSM3OnceOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_004 -int CaseDigestSM3OnceMulti(void) -{ - TestVector tv = { - .algName = {"DI_sm3"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_LE1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, - DIDofinalFwd, DIDofinalFwd, - DIDofinalBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSM3OnceMulti success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_001 -int CaseDigestSM3MultiOnce(void) -{ - TestVector tv = { - .algName = {"DI_sm3"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_GR1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 8, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSM3MultiOnce success\n", __func__); - return 0; -} - -// Crypto_DI_Fun_003 -int CaseDigestSM3MultiMulti(void) -{ - TestVector tv = { - .algName = {"DI_sm3"}, - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_GR1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, - DIUpdateFwd, DIDofinalFwd, - DIUpdateFwd, DIDofinalFwd, - DIUpdateBck, DIDofinalBck, - DIUpdateBck, DIDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 12, - .expRet = ER_OK, - }; - tlogi("---------------********:sliceSize:%d, dataSize:%d\n", tv.sliceSize, tv.dataSize); - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseDigestSM3MultiMulti success\n", __func__); - return 0; -} - diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_entry.c b/test/xts/ta/test_crypto_api/src/cases/cases_entry.c deleted file mode 100644 index 15477733..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_entry.c +++ /dev/null @@ -1,1330 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "string.h" -#include "monad.h" -#include "cases_entry.h" - -static CaseEntry g_caseEntryList[] = { - // cases_export_plaintext_key.c - { - .name = "CaseSymEncryptAesEcbNopadKeySize128OnceOnce", - .entry = CaseSymEncryptAesEcbNopadKeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesEcbNopadKeySize128OnceMulti", - .entry = CaseSymEncryptAesEcbNopadKeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesEcbNopadKeySize128MultiOnce", - .entry = CaseSymEncryptAesEcbNopadKeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesEcbNopadKeySize128MultiMulti", - .entry = CaseSymEncryptAesEcbNopadKeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcNopadKeySize192OnceOnce", - .entry = CaseSymEncryptAesCbcNopadKeySize192OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcNopadKeySize192OnceMulti", - .entry = CaseSymEncryptAesCbcNopadKeySize192OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcNopadKeySize192MultiOnce", - .entry = CaseSymEncryptAesCbcNopadKeySize192MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcNopadKeySize192MultiMulti", - .entry = CaseSymEncryptAesCbcNopadKeySize192MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCtrKeySize128OnceOnce", - .entry = CaseSymEncryptAesCtrKeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCtrKeySize128OnceMulti", - .entry = CaseSymEncryptAesCtrKeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCtrKeySize128MultiOnce", - .entry = CaseSymEncryptAesCtrKeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCtrKeySize128MultiMulti", - .entry = CaseSymEncryptAesCtrKeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesXtsKeySize256OnceOnce", - .entry = CaseSymEncryptAesXtsKeySize256OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesXtsKeySize256OnceMulti", - .entry = CaseSymEncryptAesXtsKeySize256OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesXtsKeySize256MultiOnce", - .entry = CaseSymEncryptAesXtsKeySize256MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesXtsKeySize256MultiMulti", - .entry = CaseSymEncryptAesXtsKeySize256MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce", - .entry = CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti", - .entry = CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce", - .entry = CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti", - .entry = CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcNopadKeySize128OnceOnce", - .entry = CaseSymEncryptSm4CbcNopadKeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcNopadKeySize128OnceMulti", - .entry = CaseSymEncryptSm4CbcNopadKeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcNopadKeySize128MultiOnce", - .entry = CaseSymEncryptSm4CbcNopadKeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcNopadKeySize128MultiMulti", - .entry = CaseSymEncryptSm4CbcNopadKeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CtrKeySize128OnceOnce", - .entry = CaseSymEncryptSm4CtrKeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CtrKeySize128OnceMulti", - .entry = CaseSymEncryptSm4CtrKeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CtrKeySize128MultiOnce", - .entry = CaseSymEncryptSm4CtrKeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CtrKeySize128MultiMulti", - .entry = CaseSymEncryptSm4CtrKeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4Cfb128KeySize128OnceOnce", - .entry = CaseSymEncryptSm4Cfb128KeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4Cfb128KeySize128OnceMulti", - .entry = CaseSymEncryptSm4Cfb128KeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4Cfb128KeySize128MultiOnce", - .entry = CaseSymEncryptSm4Cfb128KeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4Cfb128KeySize128MultiMulti", - .entry = CaseSymEncryptSm4Cfb128KeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce", - .entry = CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti", - .entry = CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce", - .entry = CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti", - .entry = CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - // cases_ae_crypto_basic_cases.c - { - .name = "CaseAEAesCcmK128N7T32Aad32MultiOnce", - .entry = CaseAEAesCcmK128N7T32Aad32MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N7T32Aad32MultiMulti", - .entry = CaseAEAesCcmK128N7T32Aad32MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N7T32Aad32update0Multi", - .entry = CaseAEAesCcmK128N7T32Aad32update0Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N7T32Aad32OnceOnce", - .entry = CaseAEAesCcmK128N7T32Aad32OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N7T32Aad32OnceMulti", - .entry = CaseAEAesCcmK128N7T32Aad32OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N8T48Aad288MultiOnce", - .entry = CaseAEAesCcmK192N8T48Aad288MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N8T48Aad288MultiMulti", - .entry = CaseAEAesCcmK192N8T48Aad288MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N8T48Aad288OnceOnce", - .entry = CaseAEAesCcmK192N8T48Aad288OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N8T48Aad288OnceMulti", - .entry = CaseAEAesCcmK192N8T48Aad288OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N9T64Aad512MultiOnce", - .entry = CaseAEAesCcmK256N9T64Aad512MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N9T64Aad512MultiMulti", - .entry = CaseAEAesCcmK256N9T64Aad512MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N13T128Aad512OnceOnce", - .entry = CaseAEAesCcmK256N13T128Aad512OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N13T128Aad512OnceMulti", - .entry = CaseAEAesCcmK256N13T128Aad512OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N10T80Aad4MMultiOnce", - .entry = CaseAEAesCcmK128N10T80Aad4MMultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N10T80Aad4MMultiMulti", - .entry = CaseAEAesCcmK128N10T80Aad4MMultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N11T96Aad32MultiOnce", - .entry = CaseAEAesCcmK192N11T96Aad32MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N11T96Aad32MultiMulti", - .entry = CaseAEAesCcmK192N11T96Aad32MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N12T112Aad288MultiOnce", - .entry = CaseAEAesCcmK256N12T112Aad288MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N12T112Aad288MultiMulti", - .entry = CaseAEAesCcmK256N12T112Aad288MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N13T128Aad512MultiOnce", - .entry = CaseAEAesCcmK128N13T128Aad512MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N13T128Aad512MultiMulti", - .entry = CaseAEAesCcmK128N13T128Aad512MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG", - .entry = CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N8T64NoAadOnce", - .entry = CaseAEAesCcmK192N8T64NoAadOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK192N8T64NoAadMulti", - .entry = CaseAEAesCcmK192N8T64NoAadMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG", - .entry = CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N7T96Aad32MultiOnce", - .entry = CaseAEAesGcmK128N7T96Aad32MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N7T96Aad32MultiMulti", - .entry = CaseAEAesGcmK128N7T96Aad32MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N7T96Aad32update0Multi", - .entry = CaseAEAesGcmK128N7T96Aad32update0Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N7T96Aad32OnceOnce", - .entry = CaseAEAesGcmK128N7T96Aad32OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N7T96Aad32OnceMulti", - .entry = CaseAEAesGcmK128N7T96Aad32OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N12T104Aad288MultiOnce", - .entry = CaseAEAesGcmK192N12T104Aad288MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N12T104Aad288MultiMulti", - .entry = CaseAEAesGcmK192N12T104Aad288MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N12T104Aad288OnceOnce", - .entry = CaseAEAesGcmK192N12T104Aad288OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N12T104Aad288OnceMulti", - .entry = CaseAEAesGcmK192N12T104Aad288OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK256N7T112Aad512MultiOnce", - .entry = CaseAEAesGcmK256N7T112Aad512MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK256N7T112Aad512MultiMulti", - .entry = CaseAEAesGcmK256N7T112Aad512MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK256N7T128Aad512OnceOnce", - .entry = CaseAEAesGcmK256N7T128Aad512OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK256N7T128Aad512OnceMulti", - .entry = CaseAEAesGcmK256N7T128Aad512OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N12T120Aad4MMultiOnce", - .entry = CaseAEAesGcmK128N12T120Aad4MMultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N12T120Aad4MMultiMulti", - .entry = CaseAEAesGcmK128N12T120Aad4MMultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N7T128Aad32MultiOnce", - .entry = CaseAEAesGcmK192N7T128Aad32MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N7T128Aad32MultiMulti", - .entry = CaseAEAesGcmK192N7T128Aad32MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG", - .entry = CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N12T96NoAadOnce", - .entry = CaseAEAesGcmK192N12T96NoAadOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK192N12T96NoAadMulti", - .entry = CaseAEAesGcmK192N12T96NoAadMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG", - .entry = CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T96Aad32MultiOnce", - .entry = CaseAESM4GcmK128N7T96Aad32MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T96Aad32MultiMulti", - .entry = CaseAESM4GcmK128N7T96Aad32MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T96Aad32OnceOnce", - .entry = CaseAESM4GcmK128N7T96Aad32OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T96Aad32OnceMulti", - .entry = CaseAESM4GcmK128N7T96Aad32OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T96Aad32update0Multi", - .entry = CaseAESM4GcmK128N7T96Aad32update0Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T104Aad288MultiOnce", - .entry = CaseAESM4GcmK128N12T104Aad288MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T104Aad288MultiMulti", - .entry = CaseAESM4GcmK128N12T104Aad288MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T104Aad288OnceOnce", - .entry = CaseAESM4GcmK128N12T104Aad288OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T104Aad288OnceMulti", - .entry = CaseAESM4GcmK128N12T104Aad288OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T112Aad512MultiOnce", - .entry = CaseAESM4GcmK128N7T112Aad512MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T112Aad512MultiMulti", - .entry = CaseAESM4GcmK128N7T112Aad512MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T128Aad512OnceOnce", - .entry = CaseAESM4GcmK128N7T128Aad512OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T128Aad512OnceMulti", - .entry = CaseAESM4GcmK128N7T128Aad512OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T120Aad4MMultiOnce", - .entry = CaseAESM4GcmK128N12T120Aad4MMultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T120Aad4MMultiMulti", - .entry = CaseAESM4GcmK128N12T120Aad4MMultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T128Aad32MultiOnce", - .entry = CaseAESM4GcmK128N7T128Aad32MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T128Aad32MultiMulti", - .entry = CaseAESM4GcmK128N7T128Aad32MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG", - .entry = CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T96NoAadOnce", - .entry = CaseAESM4GcmK128N12T96NoAadOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N12T96NoAadMulti", - .entry = CaseAESM4GcmK128N12T96NoAadMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG", - .entry = CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - // cases_mac_crypto_basic_cases.c - { - .name = "CaseHmacSha256KeySize64OnceOnce", - .entry = CaseHmacSha256KeySize64OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize64OnceMulti", - .entry = CaseHmacSha256KeySize64OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize64MultiOnce", - .entry = CaseHmacSha256KeySize64MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize64MultiMulti", - .entry = CaseHmacSha256KeySize64MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha384KeySize1024OnceOnce", - .entry = CaseHmacSha384KeySize1024OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha384KeySize1024OnceMulti", - .entry = CaseHmacSha384KeySize1024OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha384KeySize1024MultiOnce", - .entry = CaseHmacSha384KeySize1024MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha384KeySize1024MultiMulti", - .entry = CaseHmacSha384KeySize1024MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha512KeySize256OnceOnce", - .entry = CaseHmacSha512KeySize256OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha512KeySize256OnceMulti", - .entry = CaseHmacSha512KeySize256OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha512KeySize256MultiOnce", - .entry = CaseHmacSha512KeySize256MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha512KeySize256MultiMulti", - .entry = CaseHmacSha512KeySize256MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSM3KeySize512OnceOnce", - .entry = CaseHmacSM3KeySize512OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSM3KeySize512OnceMulti", - .entry = CaseHmacSM3KeySize512OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSM3KeySize512MultiOnce", - .entry = CaseHmacSM3KeySize512MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSM3KeySize512MultiMulti", - .entry = CaseHmacSM3KeySize512MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize8192OnceOnce", - .entry = CaseHmacSha256KeySize8192OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize8192OnceMulti", - .entry = CaseHmacSha256KeySize8192OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize8192MultiOnce", - .entry = CaseHmacSha256KeySize8192MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseHmacSha256KeySize8192MultiMulti", - .entry = CaseHmacSha256KeySize8192MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize128OnceOnce", - .entry = CaseCmacAesCbcNopadKeySize128OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize128OnceMulti", - .entry = CaseCmacAesCbcNopadKeySize128OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize128MultiOnce", - .entry = CaseCmacAesCbcNopadKeySize128MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize128MultiMulti", - .entry = CaseCmacAesCbcNopadKeySize128MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize192OnceOnce", - .entry = CaseCmacAesCbcNopadKeySize192OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize192OnceMulti", - .entry = CaseCmacAesCbcNopadKeySize192OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize192MultiOnce", - .entry = CaseCmacAesCbcNopadKeySize192MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize192MultiMulti", - .entry = CaseCmacAesCbcNopadKeySize192MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize256OnceOnce", - .entry = CaseCmacAesCbcNopadKeySize256OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize256OnceMulti", - .entry = CaseCmacAesCbcNopadKeySize256OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize256MultiOnce", - .entry = CaseCmacAesCbcNopadKeySize256MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseCmacAesCbcNopadKeySize256MultiMulti", - .entry = CaseCmacAesCbcNopadKeySize256MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - // cases_asym_crypto_basic_cases.c - { - .name = "CaseAsymEncryptRsaV15KeySize512Once", - .entry = CaseAsymEncryptRsaV15KeySize512Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaV15KeySize2048Once", - .entry = CaseAsymEncryptRsaV15KeySize2048Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaV15KeySize2048Multi", - .entry = CaseAsymEncryptRsaV15KeySize2048Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaV15KeySize4096Once", - .entry = CaseAsymEncryptRsaV15KeySize4096Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaV15KeySize4096Multi", - .entry = CaseAsymEncryptRsaV15KeySize4096Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaOaepSha384KeySize2048Once", - .entry = CaseAsymEncryptRsaOaepSha384KeySize2048Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaOaepSha384KeySize2048Multi", - .entry = CaseAsymEncryptRsaOaepSha384KeySize2048Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaOaepSha512KeySize4096Once", - .entry = CaseAsymEncryptRsaOaepSha512KeySize4096Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaOaepSha512KeySize4096Multi", - .entry = CaseAsymEncryptRsaOaepSha512KeySize4096Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaNopadKeySize2688Once", - .entry = CaseAsymEncryptRsaNopadKeySize2688Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaNopadKeySize2688Multi", - .entry = CaseAsymEncryptRsaNopadKeySize2688Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaNopadKeySize4096Once", - .entry = CaseAsymEncryptRsaNopadKeySize4096Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptRsaNopadKeySize4096Multi", - .entry = CaseAsymEncryptRsaNopadKeySize4096Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptSm2PkeDataSize64Once", - .entry = CaseAsymEncryptSm2PkeDataSize64Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptSm2PkeDataSize64Multi", - .entry = CaseAsymEncryptSm2PkeDataSize64Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptSm2PkeDataSize470Once", - .entry = CaseAsymEncryptSm2PkeDataSize470Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptSm2PkeDataSize470Multi", - .entry = CaseAsymEncryptSm2PkeDataSize470Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptSm2PkeDataSize1024Once", - .entry = CaseAsymEncryptSm2PkeDataSize1024Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymEncryptSm2PkeDataSize1024Multi", - .entry = CaseAsymEncryptSm2PkeDataSize1024Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - // cases_asym_sign_basic_cases.c - { - .name = "CaseAsymSignRsaV15Sha384KeySize2048Once", - .entry = CaseAsymSignRsaV15Sha384KeySize2048Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaV15Sha384KeySize2048Multi", - .entry = CaseAsymSignRsaV15Sha384KeySize2048Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaV15Sha512KeySize4096Once", - .entry = CaseAsymSignRsaV15Sha512KeySize4096Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaV15Sha512KeySize4096Multi", - .entry = CaseAsymSignRsaV15Sha512KeySize4096Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaPssSha384KeySize2048Once", - .entry = CaseAsymSignRsaPssSha384KeySize2048Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaPssSha384KeySize2048Multi", - .entry = CaseAsymSignRsaPssSha384KeySize2048Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaPssSha512KeySize4096Once", - .entry = CaseAsymSignRsaPssSha512KeySize4096Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignRsaPssSha512KeySize4096Multi", - .entry = CaseAsymSignRsaPssSha512KeySize4096Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEcdsaSha256KeySize256Once", - .entry = CaseAsymSignEcdsaSha256KeySize256Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEcdsaSha256KeySize256Multi", - .entry = CaseAsymSignEcdsaSha256KeySize256Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEcdsaSha384KeySize384Once", - .entry = CaseAsymSignEcdsaSha384KeySize384Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEcdsaSha384KeySize384Multi", - .entry = CaseAsymSignEcdsaSha384KeySize384Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEcdsaSha512KeySize521Once", - .entry = CaseAsymSignEcdsaSha512KeySize521Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEcdsaSha512KeySize521Multi", - .entry = CaseAsymSignEcdsaSha512KeySize521Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize64Once", - .entry = CaseAsymSignEd25519DataSize64Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize64Multi", - .entry = CaseAsymSignEd25519DataSize64Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize470Once", - .entry = CaseAsymSignEd25519DataSize470Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize470Multi", - .entry = CaseAsymSignEd25519DataSize470Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize1270Once", - .entry = CaseAsymSignEd25519DataSize1270Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize1270Multi", - .entry = CaseAsymSignEd25519DataSize1270Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize4096Once", - .entry = CaseAsymSignEd25519DataSize4096Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignEd25519DataSize4096Multi", - .entry = CaseAsymSignEd25519DataSize4096Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignSm2DsaSm3DataSize32Once", - .entry = CaseAsymSignSm2DsaSm3DataSize32Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignSm2DsaSm3DataSize128Once", - .entry = CaseAsymSignSm2DsaSm3DataSize128Once, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseAsymSignSm2DsaSm3DataSize32Multi", - .entry = CaseAsymSignSm2DsaSm3DataSize32Multi, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - // cases_digest_crypto_basic_cases.c - { - .name = "CaseDigestSha256OnceOnce", - .entry = CaseDigestSha256OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha256OnceMulti", - .entry = CaseDigestSha256OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha256MultiOnce", - .entry = CaseDigestSha256MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha256MultiMulti", - .entry = CaseDigestSha256MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha384OnceOnce", - .entry = CaseDigestSha384OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha384OnceMulti", - .entry = CaseDigestSha384OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha384MultiOnce", - .entry = CaseDigestSha384MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha384MultiMulti", - .entry = CaseDigestSha384MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha512OnceOnce", - .entry = CaseDigestSha512OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha512OnceMulti", - .entry = CaseDigestSha512OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha512MultiOnce", - .entry = CaseDigestSha512MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSha512MultiMulti", - .entry = CaseDigestSha512MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSM3OnceOnce", - .entry = CaseDigestSM3OnceOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSM3OnceMulti", - .entry = CaseDigestSM3OnceMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSM3MultiOnce", - .entry = CaseDigestSM3MultiOnce, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDigestSM3MultiMulti", - .entry = CaseDigestSM3MultiMulti, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - // cases_derive_basic_cases.c - { - .name = "CaseDREcdhNistP224DataSize14", - .entry = CaseDREcdhNistP224DataSize14, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDREcdhNistP256DataSize128", - .entry = CaseDREcdhNistP256DataSize128, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDREcdhNistP384DataSize512", - .entry = CaseDREcdhNistP384DataSize512, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDREcdhNistP521DataSize1024", - .entry = CaseDREcdhNistP521DataSize1024, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDREcdhNistP521DataSize4096", - .entry = CaseDREcdhNistP521DataSize4096, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDREcdhNistP384DataSize10000", - .entry = CaseDREcdhNistP384DataSize10000, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDRDHKeySize512Pram512DataSize1024", - .entry = CaseDRDHKeySize512Pram512DataSize1024, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDRDHKeySize1024Pram1024DataSize1024", - .entry = CaseDRDHKeySize1024Pram1024DataSize1024, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDRX25519DataSize1024", - .entry = CaseDRX25519DataSize1024, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseDRX25519DataSize4096", - .entry = CaseDRX25519DataSize4096, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, -}; - -static uint32_t g_caseEntryListSize = (uint32_t)(sizeof(g_caseEntryList) / sizeof(g_caseEntryList[0])); - -static int FindCaseIdByName(const char *name, uint32_t *caseId) -{ - uint32_t i; - for (i = 0; i < g_caseEntryListSize; i++) { - if (strcmp((const char *)name, (const char *)(g_caseEntryList[i].name)) == 0) { - *caseId = i; - return 0; - } - } - return -1; -} - -int RunCaseEntryById(uint32_t startId, uint32_t runCnt, uint32_t cf) -{ - if (startId >= g_caseEntryListSize) { - tloge("[%s]:invalid startId[%u]\n", __func__, startId); - return -1; - } - uint32_t i; - uint32_t runId; - for (i = 0; i < runCnt && i + startId < g_caseEntryListSize; i++) { - runId = i + startId; - g_caseEntryList[runId].ranFlag = CASE_RAN_FLAG_SET; - g_caseEntryList[runId].ret = g_caseEntryList[runId].entry(); - if (g_caseEntryList[runId].ret != 0) { - tloge("[%s]:run case [%s] failed\n", __func__, g_caseEntryList[runId].name); - if (cf == 0) { - return -1; - } - } else { - tlogi("[%s]:run case [%s] success\n", __func__, g_caseEntryList[runId].name); - } - } - return 0; -} - -int RunCaseEntryByName(const char *name, uint32_t runCnt, uint32_t cf) -{ - uint32_t startId; - int ret = FindCaseIdByName(name, &startId); - if (ret != 0) { - tloge("[%s]:find case id by name [%s] failed\n", __func__, name); - return -1; - } - return RunCaseEntryById(startId, runCnt, cf); -} - -int GetRunCaseResult(uint32_t *runCnt, uint32_t *failCnt, uint32_t *passCnt) -{ - *runCnt = 0; - *failCnt = 0; - *passCnt = 0; - uint32_t i; - tlogi("[%s]:------------------------------------------\n", __func__); - for (i = 0; i < g_caseEntryListSize; i++) { - if (g_caseEntryList[i].ranFlag != CASE_RAN_FLAG_SET) { - continue; - } - (*runCnt)++; - char *rets = NULL; - if (g_caseEntryList[i].ret == 0) { - (*passCnt)++; - rets = "pass"; - } else { - (*failCnt)++; - rets = "fail"; - } - tlogi("[ %6s]:%s %s\n", rets, g_caseEntryList[i].name, rets); - } - tlogi("[ Report ]:run %u cases, pass %u, fail %u\n", *runCnt, *passCnt, *failCnt); - return (*failCnt == 0 && *passCnt != 0) ? 0 : -1; -} \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_entry.h b/test/xts/ta/test_crypto_api/src/cases/cases_entry.h deleted file mode 100644 index 52893407..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_entry.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef CASE_HEADER_H_ -#define CASE_HEADER_H_ -#include "test_crypto_data.h" -#include "monad.h" -enum { - CASE_PRESET_RESULT = -1, - CASE_RAN_FLAG_SET = 1, - CASE_RAN_FLAG_CLEAR = 0, -}; - -typedef struct { - char name[MAX_STRING_NAME_LEN]; - int (*entry)(void); - uint8_t ranFlag; - int ret; -} CaseEntry; -// cases_sym_encrypt_basic_cases.c -int CaseSymEncryptAesEcbNopadKeySize128OnceOnce(void); -int CaseSymEncryptAesEcbNopadKeySize128OnceMulti(void); -int CaseSymEncryptAesEcbNopadKeySize128MultiOnce(void); -int CaseSymEncryptAesEcbNopadKeySize128MultiMulti(void); -int CaseSymEncryptAesCbcNopadKeySize192OnceOnce(void); -int CaseSymEncryptAesCbcNopadKeySize192OnceMulti(void); -int CaseSymEncryptAesCbcNopadKeySize192MultiOnce(void); -int CaseSymEncryptAesCbcNopadKeySize192MultiMulti(void); -int CaseSymEncryptAesCtrKeySize128OnceOnce(void); -int CaseSymEncryptAesCtrKeySize128OnceMulti(void); -int CaseSymEncryptAesCtrKeySize128MultiOnce(void); -int CaseSymEncryptAesCtrKeySize128MultiMulti(void); -int CaseSymEncryptAesXtsKeySize256OnceOnce(void); -int CaseSymEncryptAesXtsKeySize256OnceMulti(void); -int CaseSymEncryptAesXtsKeySize256MultiOnce(void); -int CaseSymEncryptAesXtsKeySize256MultiMulti(void); -int CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce(void); -int CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti(void); -int CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce(void); -int CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti(void); -int CaseSymEncryptSm4CbcNopadKeySize128OnceOnce(void); -int CaseSymEncryptSm4CbcNopadKeySize128OnceMulti(void); -int CaseSymEncryptSm4CbcNopadKeySize128MultiOnce(void); -int CaseSymEncryptSm4CbcNopadKeySize128MultiMulti(void); -int CaseSymEncryptSm4CtrKeySize128OnceOnce(void); -int CaseSymEncryptSm4CtrKeySize128OnceMulti(void); -int CaseSymEncryptSm4CtrKeySize128MultiOnce(void); -int CaseSymEncryptSm4CtrKeySize128MultiMulti(void); -int CaseSymEncryptSm4Cfb128KeySize128OnceOnce(void); -int CaseSymEncryptSm4Cfb128KeySize128OnceMulti(void); -int CaseSymEncryptSm4Cfb128KeySize128MultiOnce(void); -int CaseSymEncryptSm4Cfb128KeySize128MultiMulti(void); -int CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce(void); -int CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti(void); -int CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce(void); -int CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti(void); - -// cases_ae_crypto_basic_cases.c -int CaseAEAesCcmK128N7T32Aad32MultiOnce(void); -int CaseAEAesCcmK128N7T32Aad32MultiMulti(void); -int CaseAEAesCcmK128N7T32Aad32update0Multi(void); -int CaseAEAesCcmK128N7T32Aad32OnceOnce(void); -int CaseAEAesCcmK128N7T32Aad32OnceMulti(void); -int CaseAEAesCcmK192N8T48Aad288MultiOnce(void); -int CaseAEAesCcmK192N8T48Aad288MultiMulti(void); -int CaseAEAesCcmK192N8T48Aad288OnceOnce(void); -int CaseAEAesCcmK192N8T48Aad288OnceMulti(void); -int CaseAEAesCcmK256N9T64Aad512MultiOnce(void); -int CaseAEAesCcmK256N9T64Aad512MultiMulti(void); -int CaseAEAesCcmK256N13T128Aad512OnceOnce(void); -int CaseAEAesCcmK256N13T128Aad512OnceMulti(void); -int CaseAEAesCcmK128N10T80Aad4MMultiOnce(void); -int CaseAEAesCcmK128N10T80Aad4MMultiMulti(void); -int CaseAEAesCcmK192N11T96Aad32MultiOnce(void); -int CaseAEAesCcmK192N11T96Aad32MultiMulti(void); -int CaseAEAesCcmK256N12T112Aad288MultiOnce(void); -int CaseAEAesCcmK256N12T112Aad288MultiMulti(void); -int CaseAEAesCcmK128N13T128Aad512MultiOnce(void); -int CaseAEAesCcmK128N13T128Aad512MultiMulti(void); -int CaseAEAesCcmK128N7T32Aad512EncryptOnlyTAG(void); -int CaseAEAesCcmK192N8T64NoAadOnce(void); -int CaseAEAesCcmK192N8T64NoAadMulti(void); -int CaseAEAesCcmK256N9T64Aad512DecryptOnlyTAG(void); -int CaseAEAesGcmK128N7T96Aad32MultiOnce(void); -int CaseAEAesGcmK128N7T96Aad32MultiMulti(void); -int CaseAEAesGcmK128N7T96Aad32update0Multi(void); -int CaseAEAesGcmK128N7T96Aad32OnceOnce(void); -int CaseAEAesGcmK128N7T96Aad32OnceMulti(void); -int CaseAEAesGcmK192N12T104Aad288MultiOnce(void); -int CaseAEAesGcmK192N12T104Aad288MultiMulti(void); -int CaseAEAesGcmK192N12T104Aad288OnceOnce(void); -int CaseAEAesGcmK192N12T104Aad288OnceMulti(void); -int CaseAEAesGcmK256N7T112Aad512MultiOnce(void); -int CaseAEAesGcmK256N7T112Aad512MultiMulti(void); -int CaseAEAesGcmK256N7T128Aad512OnceOnce(void); -int CaseAEAesGcmK256N7T128Aad512OnceMulti(void); -int CaseAEAesGcmK128N12T120Aad4MMultiOnce(void); -int CaseAEAesGcmK128N12T120Aad4MMultiMulti(void); -int CaseAEAesGcmK192N7T128Aad32MultiOnce(void); -int CaseAEAesGcmK192N7T128Aad32MultiMulti(void); -int CaseAEAesGcmK256N7T112Aad512DecryptOnlyTAG(void); -int CaseAEAesGcmK192N12T96NoAadOnce(void); -int CaseAEAesGcmK192N12T96NoAadMulti(void); -int CaseAEAesGcmK128N7T104Aad512EncryptOnlyTAG(void); -int CaseAESM4GcmK128N7T96Aad32MultiOnce(void); -int CaseAESM4GcmK128N7T96Aad32MultiMulti(void); -int CaseAESM4GcmK128N7T96Aad32OnceOnce(void); -int CaseAESM4GcmK128N7T96Aad32OnceMulti(void); -int CaseAESM4GcmK128N7T96Aad32update0Multi(void); -int CaseAESM4GcmK128N12T104Aad288MultiOnce(void); -int CaseAESM4GcmK128N12T104Aad288MultiMulti(void); -int CaseAESM4GcmK128N12T104Aad288OnceOnce(void); -int CaseAESM4GcmK128N12T104Aad288OnceMulti(void); -int CaseAESM4GcmK128N7T112Aad512MultiOnce(void); -int CaseAESM4GcmK128N7T112Aad512MultiMulti(void); -int CaseAESM4GcmK128N7T128Aad512OnceOnce(void); -int CaseAESM4GcmK128N7T128Aad512OnceMulti(void); -int CaseAESM4GcmK128N12T120Aad4MMultiOnce(void); -int CaseAESM4GcmK128N12T120Aad4MMultiMulti(void); -int CaseAESM4GcmK128N7T128Aad32MultiOnce(void); -int CaseAESM4GcmK128N7T128Aad32MultiMulti(void); -int CaseAESM4GcmK128N7T112Aad512DecryptOnlyTAG(void); -int CaseAESM4GcmK128N12T96NoAadOnce(void); -int CaseAESM4GcmK128N12T96NoAadMulti(void); -int CaseAESM4GcmK128N7T104Aad512EncryptOnlyTAG(void); - -// cases_mac_crypto_basic_cases.c -int CaseHmacSha256KeySize64OnceOnce(void); -int CaseHmacSha256KeySize64OnceMulti(void); -int CaseHmacSha256KeySize64MultiOnce(void); -int CaseHmacSha256KeySize64MultiMulti(void); -int CaseHmacSha384KeySize1024OnceOnce(void); -int CaseHmacSha384KeySize1024OnceMulti(void); -int CaseHmacSha384KeySize1024MultiOnce(void); -int CaseHmacSha384KeySize1024MultiMulti(void); -int CaseHmacSha512KeySize256OnceOnce(void); -int CaseHmacSha512KeySize256OnceMulti(void); -int CaseHmacSha512KeySize256MultiOnce(void); -int CaseHmacSha512KeySize256MultiMulti(void); -int CaseHmacSM3KeySize512OnceOnce(void); -int CaseHmacSM3KeySize512OnceMulti(void); -int CaseHmacSM3KeySize512MultiOnce(void); -int CaseHmacSM3KeySize512MultiMulti(void); -int CaseHmacSha256KeySize8192OnceOnce(void); -int CaseHmacSha256KeySize8192OnceMulti(void); -int CaseHmacSha256KeySize8192MultiOnce(void); -int CaseHmacSha256KeySize8192MultiMulti(void); -int CaseCmacAesCbcNopadKeySize128OnceOnce(void); -int CaseCmacAesCbcNopadKeySize128OnceMulti(void); -int CaseCmacAesCbcNopadKeySize128MultiOnce(void); -int CaseCmacAesCbcNopadKeySize128MultiMulti(void); -int CaseCmacAesCbcNopadKeySize192OnceOnce(void); -int CaseCmacAesCbcNopadKeySize192OnceMulti(void); -int CaseCmacAesCbcNopadKeySize192MultiOnce(void); -int CaseCmacAesCbcNopadKeySize192MultiMulti(void); -int CaseCmacAesCbcNopadKeySize256OnceOnce(void); -int CaseCmacAesCbcNopadKeySize256OnceMulti(void); -int CaseCmacAesCbcNopadKeySize256MultiOnce(void); -int CaseCmacAesCbcNopadKeySize256MultiMulti(void); - -// cases_asym_crypto_basic_cases.c -int CaseAsymEncryptRsaV15KeySize512Once(void); -int CaseAsymEncryptRsaV15KeySize2048Once(void); -int CaseAsymEncryptRsaV15KeySize2048Multi(void); -int CaseAsymEncryptRsaV15KeySize4096Once(void); -int CaseAsymEncryptRsaV15KeySize4096Multi(void); -int CaseAsymEncryptRsaOaepSha384KeySize2048Once(void); -int CaseAsymEncryptRsaOaepSha384KeySize2048Multi(void); -int CaseAsymEncryptRsaOaepSha512KeySize4096Once(void); -int CaseAsymEncryptRsaOaepSha512KeySize4096Multi(void); -int CaseAsymEncryptRsaNopadKeySize2688Once(void); -int CaseAsymEncryptRsaNopadKeySize2688Multi(void); -int CaseAsymEncryptRsaNopadKeySize4096Once(void); -int CaseAsymEncryptRsaNopadKeySize4096Multi(void); -int CaseAsymEncryptSm2PkeDataSize64Once(void); -int CaseAsymEncryptSm2PkeDataSize64Multi(void); -int CaseAsymEncryptSm2PkeDataSize470Once(void); -int CaseAsymEncryptSm2PkeDataSize470Multi(void); -int CaseAsymEncryptSm2PkeDataSize1024Once(void); -int CaseAsymEncryptSm2PkeDataSize1024Multi(void); - -// cases_asym_sign_basic_cases.c -int CaseAsymSignRsaV15Sha384KeySize2048Once(void); -int CaseAsymSignRsaV15Sha384KeySize2048Multi(void); -int CaseAsymSignRsaV15Sha512KeySize4096Once(void); -int CaseAsymSignRsaV15Sha512KeySize4096Multi(void); -int CaseAsymSignRsaPssSha384KeySize2048Once(void); -int CaseAsymSignRsaPssSha384KeySize2048Multi(void); -int CaseAsymSignRsaPssSha512KeySize4096Once(void); -int CaseAsymSignRsaPssSha512KeySize4096Multi(void); -int CaseAsymSignEcdsaSha256KeySize256Once(void); -int CaseAsymSignEcdsaSha256KeySize256Multi(void); -int CaseAsymSignEcdsaSha384KeySize384Once(void); -int CaseAsymSignEcdsaSha384KeySize384Multi(void); -int CaseAsymSignEcdsaSha512KeySize521Once(void); -int CaseAsymSignEcdsaSha512KeySize521Multi(void); -int CaseAsymSignEd25519DataSize64Once(void); -int CaseAsymSignEd25519DataSize64Multi(void); -int CaseAsymSignEd25519DataSize470Once(void); -int CaseAsymSignEd25519DataSize470Multi(void); -int CaseAsymSignEd25519DataSize1270Once(void); -int CaseAsymSignEd25519DataSize1270Multi(void); -int CaseAsymSignEd25519DataSize4096Once(void); -int CaseAsymSignEd25519DataSize4096Multi(void); -int CaseAsymSignSm2DsaSm3DataSize32Once(void); -int CaseAsymSignSm2DsaSm3DataSize32Multi(void); -int CaseAsymSignSm2DsaSm3DataSize128Once(void); - -// cases_digest_crypto_basic_cases.c -int CaseDigestSha256OnceOnce(void); -int CaseDigestSha256OnceMulti(void); -int CaseDigestSha256MultiOnce(void); -int CaseDigestSha256MultiMulti(void); -int CaseDigestSha384OnceOnce(void); -int CaseDigestSha384OnceMulti(void); -int CaseDigestSha384MultiOnce(void); -int CaseDigestSha384MultiMulti(void); -int CaseDigestSha512OnceOnce(void); -int CaseDigestSha512OnceMulti(void); -int CaseDigestSha512MultiOnce(void); -int CaseDigestSha512MultiMulti(void); -int CaseDigestSM3OnceOnce(void); -int CaseDigestSM3OnceMulti(void); -int CaseDigestSM3MultiOnce(void); -int CaseDigestSM3MultiMulti(void); - -// cases_derive_basic_cases.c -int CaseDREcdhNistP224DataSize14(void); -int CaseDREcdhNistP256DataSize128(void); -int CaseDREcdhNistP384DataSize512(void); -int CaseDREcdhNistP521DataSize1024(void); -int CaseDREcdhNistP521DataSize4096(void); -int CaseDREcdhNistP384DataSize10000(void); -int CaseDRDHKeySize512Pram512DataSize1024(void); -int CaseDRDHKeySize1024Pram1024DataSize1024(void); -int CaseDRX25519DataSize1024(void); -int CaseDRX25519DataSize4096(void); - -// cases_entry.c -int RunCaseEntryById(uint32_t startId, uint32_t runCnt, uint32_t cf); -int RunCaseEntryByName(const char *name, uint32_t runCnt, uint32_t cf); -int GetRunCaseResult(uint32_t *runCnt, uint32_t *failCnt, uint32_t *passCnt); -#endif // CASE_HEADER_H_ \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_mac_crypto_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_mac_crypto_basic_cases.c deleted file mode 100644 index ae10c1b6..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_mac_crypto_basic_cases.c +++ /dev/null @@ -1,1090 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -/* - * Case name meaning: Case&&Algname&&Compute mode&&Compute times - * Compute mode: number of calculateing steps, once means datasize is less than slicesize, - multi means datasize is greater than slicesize - * Compute times: algorithm calculation times, once means algorithm calculation once, - multi means algorithm calculation multi times - */ - -// Crypto_MAC_Fun_003 -int CaseHmacSha256KeySize64OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 64, - .keySize = 64, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_LE64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize64OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_004 -int CaseHmacSha256KeySize64OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 64, - .keySize = 64, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_LE64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize64OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_001 -int CaseHmacSha256KeySize64MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 64, - .keySize = 64, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_GR64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize64MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_002 -int CaseHmacSha256KeySize64MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 64, - .keySize = 64, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA50K_GR64B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize64MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_003 -int CaseHmacSha512KeySize256OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha512"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_hmac_sha512", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_LE1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha512KeySize256OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_004 -int CaseHmacSha512KeySize256OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha512"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_hmac_sha512", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_LE1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha512KeySize256OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_001 -int CaseHmacSha512KeySize256MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha512"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_hmac_sha512", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_GR1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha512KeySize256MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_002 -int CaseHmacSha512KeySize256MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha512"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_hmac_sha512", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_GR1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha512KeySize256MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_003 -int CaseHmacSM3KeySize512OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sm3"}, - .operaMaxKeySize = 512, - .keySize = 512, - .fwdKeyTypeName = "kt_hmac_sm3", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSM3KeySize512OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_004 -int CaseHmacSM3KeySize512OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sm3"}, - .operaMaxKeySize = 512, - .keySize = 512, - .fwdKeyTypeName = "kt_hmac_sm3", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSM3KeySize512OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_001 -int CaseHmacSM3KeySize512MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sm3"}, - .operaMaxKeySize = 512, - .keySize = 512, - .fwdKeyTypeName = "kt_hmac_sm3", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA2M, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSM3KeySize512MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_002 -int CaseHmacSM3KeySize512MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sm3"}, - .operaMaxKeySize = 512, - .keySize = 512, - .fwdKeyTypeName = "kt_hmac_sm3", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA2M, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSM3KeySize512MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_003 -int CaseHmacSha384KeySize1024OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha384"}, - .operaMaxKeySize = 1024, - .keySize = 1024, - .fwdKeyTypeName = "kt_hmac_sha384", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_LE128B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha384KeySize1024OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_004 -int CaseHmacSha384KeySize1024OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha384"}, - .operaMaxKeySize = 1024, - .keySize = 1024, - .fwdKeyTypeName = "kt_hmac_sha384", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA500K_LE128B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha384KeySize1024OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_001 -int CaseHmacSha384KeySize1024MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha384"}, - .operaMaxKeySize = 1024, - .keySize = 1024, - .fwdKeyTypeName = "kt_hmac_sha384", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha384KeySize1024MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_002 -int CaseHmacSha384KeySize1024MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha384"}, - .operaMaxKeySize = 1024, - .keySize = 1024, - .fwdKeyTypeName = "kt_hmac_sha384", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha384KeySize1024MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_003 -int CaseHmacSha256KeySize8192OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 8192, - .keySize = 8192, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize8192OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_004 -int CaseHmacSha256KeySize8192OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 8192, - .keySize = 8192, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize8192OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_001 -int CaseHmacSha256KeySize8192MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 8192, - .keySize = 8192, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA1M_GR1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize8192MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_002 -int CaseHmacSha256KeySize8192MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_hmac_sha256"}, - .operaMaxKeySize = 8192, - .keySize = 8192, - .fwdKeyTypeName = "kt_hmac_sha256", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .dataSize = DATA1M_GR1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseHmacSha256KeySize8192MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_007 -int CaseCmacAesCbcNopadKeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_008 -int CaseCmacAesCbcNopadKeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_005 -int CaseCmacAesCbcNopadKeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_006 -int CaseCmacAesCbcNopadKeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize128MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_007 -int CaseCmacAesCbcNopadKeySize192OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize192OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_008 -int CaseCmacAesCbcNopadKeySize192OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize192OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_005 -int CaseCmacAesCbcNopadKeySize192MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA500K_LE16B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize192MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_006 -int CaseCmacAesCbcNopadKeySize192MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA500K_LE16B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize192MultiMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_007 -int CaseCmacAesCbcNopadKeySize256OnceOnce(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize256OnceOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_008 -int CaseCmacAesCbcNopadKeySize256OnceMulti(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MComputeFwd, - MInitFwd, MComputeFwd, - MInitBck, MCapareBck, - MInitBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize256OnceMulti success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_005 -int CaseCmacAesCbcNopadKeySize256MultiOnce(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_GR16B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize256MultiOnce success\n", __func__); - return 0; -} - -// Crypto_MAC_Fun_006 -int CaseCmacAesCbcNopadKeySize256MultiMulti(void) -{ - TestVector tv = { - .algName = {"M_aes_cbc_nopad"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_GR16B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitFwd, MUpdateFwd, MComputeFwd, - MInitBck, MUpdateBck, MCapareBck, - MInitBck, MUpdateBck, MCapareBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCmacAesCbcNopadKeySize256MultiMulti success\n", __func__); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/cases/cases_sym_crypto_basic_cases.c b/test/xts/ta/test_crypto_api/src/cases/cases_sym_crypto_basic_cases.c deleted file mode 100644 index d38fb00f..00000000 --- a/test/xts/ta/test_crypto_api/src/cases/cases_sym_crypto_basic_cases.c +++ /dev/null @@ -1,1238 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "monad.h" -#include "tee_log.h" - -// Crypto_Sym_Fun_003 -int CaseSymEncryptAesEcbNopadKeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_ecb_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesEcbNopadKeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_004 -int CaseSymEncryptAesEcbNopadKeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_ecb_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesEcbNopadKeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesEcbNopadKeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_ecb_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesEcbNopadKeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesEcbNopadKeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_ecb_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesEcbNopadKeySize128MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_003 -int CaseSymEncryptAesCbcNopadKeySize192OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA500K_LE16B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcNopadKeySize192OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_004 -int CaseSymEncryptAesCbcNopadKeySize192OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA500K_LE16B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcNopadKeySize192OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesCbcNopadKeySize192MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcNopadKeySize192MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesCbcNopadKeySize192MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_nopad"}, - .operaMaxKeySize = 192, - .keySize = 192, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcNopadKeySize192MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_003 -int CaseSymEncryptAesCtrKeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCtrKeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_004 -int CaseSymEncryptAesCtrKeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCtrKeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesCtrKeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCtrKeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesCtrKeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCtrKeySize128MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_003 -int CaseSymEncryptAesXtsKeySize256OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_xts"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = 256, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesXtsKeySize256OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_004 -int CaseSymEncryptAesXtsKeySize256OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_xts"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = 256, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesXtsKeySize256OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesXtsKeySize256MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_xts"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesXtsKeySize256MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesXtsKeySize256MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_xts"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesXtsKeySize256MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_003 -int CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_pkcs5"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcPkcs5KeySize256OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_004 -int CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_pkcs5"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcPkcs5KeySize256OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_pkcs5"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_GR1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcPkcs5KeySize256MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_001 -int CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_aes_cbc_pkcs5"}, - .operaMaxKeySize = 256, - .keySize = 256, - .fwdKeyTypeName = "kt_aes", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_GR1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptAesCbcPkcs5KeySize256MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_007 -int CaseSymEncryptSm4CbcNopadKeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcNopadKeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_008 -int CaseSymEncryptSm4CbcNopadKeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcNopadKeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_005 -int CaseSymEncryptSm4CbcNopadKeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcNopadKeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_006 -int CaseSymEncryptSm4CbcNopadKeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_nopad"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcNopadKeySize128MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_007 -int CaseSymEncryptSm4CtrKeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CtrKeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_008 -int CaseSymEncryptSm4CtrKeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_LE1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CtrKeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_005 -int CaseSymEncryptSm4CtrKeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_GR1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CtrKeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_006 -int CaseSymEncryptSm4CtrKeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_ctr"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA1M_GR1B, - .sliceSize = SLICELEN_1M, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CtrKeySize128MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_007 -int CaseSymEncryptSm4Cfb128KeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cfb128"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA500K_LE1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4Cfb128KeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_008 -int CaseSymEncryptSm4Cfb128KeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cfb128"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA500K_LE1B, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4Cfb128KeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_005 -int CaseSymEncryptSm4Cfb128KeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cfb128"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4Cfb128KeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_006 -int CaseSymEncryptSm4Cfb128KeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cfb128"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = SLICELEN_500K, - .sliceSize = SLICELEN_500K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4Cfb128KeySize128MultiMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_007 -int CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_pkcs7"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 9, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcPkcs7KeySize128OnceOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_008 -int CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_pkcs7"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_LE16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCDofinalFwd, - SCInitFwd, SCDofinalFwd, - SCInitBck, SCDofinalBck, - SCInitBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 13, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcPkcs7KeySize128OnceMulti success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_005 -int CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_pkcs7"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 11, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcPkcs7KeySize128MultiOnce success\n", __func__); - return 0; -} - -// Crypto_Sym_Fun_006 -int CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti(void) -{ - TestVector tv = { - .algName = {"SC_sm4_cbc_pkcs7"}, - .operaMaxKeySize = 128, - .keySize = 128, - .fwdKeyTypeName = "kt_sm4", - .fwdEngine = FWDENGINE, - .bckEngine = BCKENGINE, - .ivLen = 16, - .dataSize = DATA50K_GR16B, - .sliceSize = SLICELEN_50K, - .actions = { - IRSetUp, - GlbAlloc, GlbS1S2, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitFwd, SCUpdateFwd, SCDofinalFwd, - SCInitBck, SCUpdateBck, SCDofinalBck, - SCInitBck, SCUpdateBck, SCDofinalBck, - GlbFree, - IRTearDown, }, - .actionsSize = 17, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseSymEncryptSm4CbcPkcs7KeySize128MultiMulti success\n", __func__); - return 0; -} diff --git a/test/xts/ta/test_crypto_api/src/data/alg_map_data.c b/test/xts/ta/test_crypto_api/src/data/alg_map_data.c deleted file mode 100644 index 2e4d9b36..00000000 --- a/test/xts/ta/test_crypto_api/src/data/alg_map_data.c +++ /dev/null @@ -1,1032 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "string.h" -#include "test_crypto_api_types.h" -#include "tee_log.h" - -AlgMapInfo g_algMapList[] = { - // Symmetric Crypto - { - .algName = "SC_aes_ecb_nopad", - .algValue = TEE_ALG_AES_ECB_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_des_ecb_nopad", - .algValue = TEE_ALG_DES_ECB_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_des3_ecb_nopad", - .algValue = TEE_ALG_DES3_ECB_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_aes_ecb_pkcs5", - .algValue = TEE_ALG_AES_ECB_PKCS5, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_sm4_ecb_nopad", - .algValue = TEE_ALG_SM4_ECB_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_aes_cbc_nopad", - .algValue = TEE_ALG_AES_CBC_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_aes_ctr", - .algValue = TEE_ALG_AES_CTR, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_aes_cts", - .algValue = TEE_ALG_AES_CTS, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_aes_xts", - .algValue = TEE_ALG_AES_XTS, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 2, - .needKeyCount = 2, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_des_cbc_nopad", - .algValue = TEE_ALG_DES_CBC_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_des3_cbc_nopad", - .algValue = TEE_ALG_DES3_CBC_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_aes_cbc_pkcs5", - .algValue = TEE_ALG_AES_CBC_PKCS5, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_sm4_cbc_nopad", - .algValue = TEE_ALG_SM4_CBC_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_sm4_ctr", - .algValue = TEE_ALG_SM4_CTR, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_sm4_cbc_pkcs7", - .algValue = TEE_ALG_SM4_CBC_PKCS7, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - { - .algName = "SC_sm4_cfb128", - .algValue = TEE_ALG_SM4_CFB128, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "SC", - .algOperaClassValue = TEE_OPERATION_CIPHER, - }, - // Ae encrypt - { - .algName = "AE_aes_ccm", - .algValue = TEE_ALG_AES_CCM, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "AE", - .algOperaClassValue = TEE_OPERATION_AE, - }, - { - .algName = "AE_aes_gcm", - .algValue = TEE_ALG_AES_GCM, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "AE", - .algOperaClassValue = TEE_OPERATION_AE, - }, - { - .algName = "AE_sm4_gcm", - .algValue = TEE_ALG_SM4_GCM, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "AE", - .algOperaClassValue = TEE_OPERATION_AE, - }, - // Mac - { - .algName = "M_aes_cbc_nopad", - .algValue = TEE_ALG_AES_CBC_MAC_NOPAD, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_aes_cbc_pkcs5", - .algValue = TEE_ALG_AES_CBC_MAC_PKCS5, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_aes_cmac", - .algValue = TEE_ALG_AES_CMAC, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_des_cbc_nopad", - .algValue = TEE_ALG_DES_CBC_MAC_NOPAD, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_des_cbc_pkcs5", - .algValue = TEE_ALG_DES_CBC_MAC_PKCS5, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_des3_cbc_nopad", - .algValue = TEE_ALG_DES3_CBC_MAC_NOPAD, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_des3_cbc_pkcs5", - .algValue = TEE_ALG_DES3_CBC_MAC_PKCS5, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_md5", - .algValue = TEE_ALG_HMAC_MD5, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_sha1", - .algValue = TEE_ALG_HMAC_SHA1, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_sha224", - .algValue = TEE_ALG_HMAC_SHA224, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_sha256", - .algValue = TEE_ALG_HMAC_SHA256, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_sha384", - .algValue = TEE_ALG_HMAC_SHA384, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_sha512", - .algValue = TEE_ALG_HMAC_SHA512, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - { - .algName = "M_hmac_sm3", - .algValue = TEE_ALG_HMAC_SM3, - .fwdMode = TEE_MODE_MAC, - .bckMode = TEE_MODE_MAC, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_MAC, - }, - // Asymmetric-Encrypt - { - .algName = "AS_ed_rsa_v15", - .algValue = TEE_ALG_RSAES_PKCS1_V1_5, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "M", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_oaep_sha1", - .algValue = TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_oaep_sha224", - .algValue = TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_oaep_sha256", - .algValue = TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_oaep_sha256", - .algValue = TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_oaep_sha384", - .algValue = TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_oaep_sha512", - .algValue = TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_rsa_nopad", - .algValue = TEE_ALG_RSA_NOPAD, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - { - .algName = "AS_ed_sm2_pke", - .algValue = TEE_ALG_SM2_PKE, - .fwdMode = TEE_MODE_ENCRYPT, - .bckMode = TEE_MODE_DECRYPT, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASEn", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_CIPHER, - }, - // Asymmetric-Signature - { - .algName = "AS_sv_rsa_v15_md5", - .algValue = TEE_ALG_RSASSA_PKCS1_V1_5_MD5, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_v15_sha1", - .algValue = TEE_ALG_RSASSA_PKCS1_V1_5_SHA1, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_v15_sha224", - .algValue = TEE_ALG_RSASSA_PKCS1_V1_5_SHA224, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_v15_sha256", - .algValue = TEE_ALG_RSASSA_PKCS1_V1_5_SHA256, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_v15_sha384", - .algValue = TEE_ALG_RSASSA_PKCS1_V1_5_SHA384, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_v15_sha512", - .algValue = TEE_ALG_RSASSA_PKCS1_V1_5_SHA512, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_pss_MD5", - .algValue = TEE_ALG_RSASSA_PKCS1_PSS_MGF1_MD5, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_pss_SHA1", - .algValue = TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_pss_SHA224", - .algValue = TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_pss_SHA256", - .algValue = TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_pss_SHA384", - .algValue = TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_rsa_pss_SHA512", - .algValue = TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_ecdsa_sha1", - .algValue = TEE_ALG_ECDSA_SHA1, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_ecdsa_sha224", - .algValue = TEE_ALG_ECDSA_SHA224, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_ecdsa_sha256", - .algValue = TEE_ALG_ECDSA_SHA256, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_ecdsa_sha384", - .algValue = TEE_ALG_ECDSA_SHA384, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_ecdsa_sha512", - .algValue = TEE_ALG_ECDSA_SHA512, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_ed25519", - .algValue = TEE_ALG_ED25519, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - { - .algName = "AS_sv_sm2_dsa_sm3", - .algValue = TEE_ALG_SM2_DSA_SM3, - .fwdMode = TEE_MODE_SIGN, - .bckMode = TEE_MODE_VERIFY, - .operaKeyCount = 1, - .needKeyCount = 1, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "ASSg", - .algOperaClassValue = TEE_OPERATION_ASYMMETRIC_SIGNATURE, - }, - // Derive - { - .algName = "DR_ecdh", - .algValue = TEE_ALG_ECDH_DERIVE_SHARED_SECRET, - .fwdMode = TEE_MODE_DERIVE, - .bckMode = TEE_MODE_DERIVE, - .operaKeyCount = 1, - .needKeyCount = 2, - .isSwitchFwdBckOperaKey = 1, - .algOperaClassName = "DR", - .algOperaClassValue = TEE_OPERATION_KEY_DERIVATION, - }, - { - .algName = "DR_dh", - .algValue = TEE_ALG_DH_DERIVE_SHARED_SECRET, - .fwdMode = TEE_MODE_DERIVE, - .bckMode = TEE_MODE_DERIVE, - .operaKeyCount = 1, - .needKeyCount = 2, - .isSwitchFwdBckOperaKey = 1, - .algOperaClassName = "DR", - .algOperaClassValue = TEE_OPERATION_KEY_DERIVATION, - }, - { - .algName = "DR_x25519", - .algValue = TEE_ALG_X25519, - .fwdMode = TEE_MODE_DERIVE, - .bckMode = TEE_MODE_DERIVE, - .operaKeyCount = 1, - .needKeyCount = 2, - .isSwitchFwdBckOperaKey = 1, - .algOperaClassName = "DR", - .algOperaClassValue = TEE_OPERATION_KEY_DERIVATION, - }, - // Digest - { - .algName = "DI_md5", - .algValue = TEE_ALG_MD5, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, - { - .algName = "DI_sha1", - .algValue = TEE_ALG_SHA1, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, - { - .algName = "DI_sha224", - .algValue = TEE_ALG_SHA224, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, - { - .algName = "DI_sha256", - .algValue = TEE_ALG_SHA256, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, - { - .algName = "DI_sha384", - .algValue = TEE_ALG_SHA384, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, - { - .algName = "DI_sha512", - .algValue = TEE_ALG_SHA512, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, - { - .algName = "DI_sm3", - .algValue = TEE_ALG_SM3, - .fwdMode = TEE_MODE_DIGEST, - .bckMode = TEE_MODE_DIGEST, - .operaKeyCount = 0, - .needKeyCount = 0, - .isSwitchFwdBckOperaKey = 0, - .algOperaClassName = "DI", - .algOperaClassValue = TEE_OPERATION_DIGEST, - }, -}; -size_t g_algMapListSize = sizeof(g_algMapList) / sizeof(g_algMapList[0]); - -AlgMapInfo *FindAlgMapInfo(char *algName) -{ - size_t i; - for (i = 0; i < g_algMapListSize; i++) { - if (strcmp((const char *)algName, (const char *)g_algMapList[i].algName) == 0) { - return &(g_algMapList[i]); - } - } - return NULL; -} - -KeyTypeMapInfo g_keyTypeMap[] = { - /* keyTypeName, keyType */ - { - .keyTypeName = {"kt_aes"}, - .keyType = TEE_TYPE_AES, - .keyGenType = TEE_TYPE_AES, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_des"}, - .keyType = TEE_TYPE_DES, - .keyGenType = TEE_TYPE_DES, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_des3"}, - .keyType = TEE_TYPE_DES3, - .keyGenType = TEE_TYPE_DES3, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_md5"}, - .keyType = TEE_TYPE_HMAC_MD5, - .keyGenType = TEE_TYPE_HMAC_MD5, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_sha1"}, - .keyType = TEE_TYPE_HMAC_SHA1, - .keyGenType = TEE_TYPE_HMAC_SHA1, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_sha224"}, - .keyType = TEE_TYPE_HMAC_SHA224, - .keyGenType = TEE_TYPE_HMAC_SHA224, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_sha256"}, - .keyType = TEE_TYPE_HMAC_SHA256, - .keyGenType = TEE_TYPE_HMAC_SHA256, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_sha384"}, - .keyType = TEE_TYPE_HMAC_SHA384, - .keyGenType = TEE_TYPE_HMAC_SHA384, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_sha512"}, - .keyType = TEE_TYPE_HMAC_SHA512, - .keyGenType = TEE_TYPE_HMAC_SHA512, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_rsa_pub"}, - .keyType = TEE_TYPE_RSA_PUBLIC_KEY, - .keyGenType = TEE_TYPE_RSA_KEYPAIR, - .needGenParams = NEED_RSA_EXP_MAYBE, - }, - { - .keyTypeName = {"kt_rsa_pair"}, - .keyType = TEE_TYPE_RSA_KEYPAIR, - .keyGenType = TEE_TYPE_RSA_KEYPAIR, - .needGenParams = NEED_RSA_EXP_MAYBE, - }, - { - .keyTypeName = {"kt_dsa_pub"}, - .keyType = TEE_TYPE_DSA_PUBLIC_KEY, - .keyGenType = TEE_TYPE_DSA_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_dsa_pair"}, - .keyType = TEE_TYPE_DSA_KEYPAIR, - .keyGenType = TEE_TYPE_DSA_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_dh_pair"}, - .keyType = TEE_TYPE_DH_KEYPAIR, - .keyGenType = TEE_TYPE_DH_KEYPAIR, - .needGenParams = NEED_DH_BASE_PRIME_XBITS, - }, - { - .keyTypeName = {"kt_gn_sec"}, - .keyType = TEE_TYPE_GENERIC_SECRET, - .keyGenType = TEE_TYPE_GENERIC_SECRET, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_data"}, - .keyType = TEE_TYPE_DATA, - .keyGenType = TEE_TYPE_DATA, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_data_1_1"}, - .keyType = TEE_TYPE_DATA_GP1_1, - .keyGenType = TEE_TYPE_DATA_GP1_1, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_ecdsa_pub"}, - .keyType = TEE_TYPE_ECDSA_PUBLIC_KEY, - .keyGenType = TEE_TYPE_ECDSA_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_ecdsa_pair"}, - .keyType = TEE_TYPE_ECDSA_KEYPAIR, - .keyGenType = TEE_TYPE_ECDSA_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_ecdh_pub"}, - .keyType = TEE_TYPE_ECDH_PUBLIC_KEY, - .keyGenType = TEE_TYPE_ECDH_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_ecdh_pair"}, - .keyType = TEE_TYPE_ECDH_KEYPAIR, - .keyGenType = TEE_TYPE_ECDH_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_ed25519_pub"}, - .keyType = TEE_TYPE_ED25519_PUBLIC_KEY, - .keyGenType = TEE_TYPE_ED25519_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_ed25519_pair"}, - .keyType = TEE_TYPE_ED25519_KEYPAIR, - .keyGenType = TEE_TYPE_ED25519_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_x25519_pub"}, - .keyType = TEE_TYPE_X25519_PUBLIC_KEY, - .keyGenType = TEE_TYPE_X25519_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = "kt_x25519_keypair", - .keyType = TEE_TYPE_X25519_KEYPAIR, - .keyGenType = TEE_TYPE_X25519_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = "kt_sm2_dsa_pub", - .keyType = TEE_TYPE_SM2_DSA_PUBLIC_KEY, - .keyGenType = TEE_TYPE_SM2_DSA_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_sm2_dsa_pair"}, - .keyType = TEE_TYPE_SM2_DSA_KEYPAIR, - .keyGenType = TEE_TYPE_SM2_DSA_KEYPAIR, - .needGenParams = NEED_GEN_ECC_CURVE, - }, - { - .keyTypeName = {"kt_sm2_kep_pub"}, - .keyType = TEE_TYPE_SM2_KEP_PUBLIC_KEY, - .keyGenType = TEE_TYPE_SM2_KEP_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_sm2_kep_pair"}, - .keyType = TEE_TYPE_SM2_KEP_KEYPAIR, - .keyGenType = TEE_TYPE_SM2_KEP_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = "kt_sm2_pke_pub", - .keyType = TEE_TYPE_SM2_PKE_PUBLIC_KEY, - .keyGenType = TEE_TYPE_SM2_PKE_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_sm2_pke_pair"}, - .keyType = TEE_TYPE_SM2_PKE_KEYPAIR, - .keyGenType = TEE_TYPE_SM2_PKE_KEYPAIR, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = {"kt_hmac_sm3"}, - .keyType = TEE_TYPE_HMAC_SM3, - .keyGenType = TEE_TYPE_HMAC_SM3, - .needGenParams = NEED_NO_GEN_PARAMS, - }, - { - .keyTypeName = "kt_sm4", - .keyType = TEE_TYPE_SM4, - .keyGenType = TEE_TYPE_SM4, - .needGenParams = NEED_NO_GEN_PARAMS, - }, -}; -uint32_t g_keyTypeMapSize = sizeof(g_keyTypeMap) / sizeof(g_keyTypeMap[0]); - -KeyTypeMapInfo *FindKeyTypeValue(char *keyTypeName) -{ - size_t i; - for (i = 0; i < g_keyTypeMapSize; i++) { - if (strcmp((const char *)keyTypeName, (const char *)g_keyTypeMap[i].keyTypeName) == 0) { - return &(g_keyTypeMap[i]); - } - } - return NULL; -} \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/data/key_object_database.c b/test/xts/ta/test_crypto_api/src/data/key_object_database.c deleted file mode 100644 index 3aa60853..00000000 --- a/test/xts/ta/test_crypto_api/src/data/key_object_database.c +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "test_crypto_api_types.h" -#include "tee_log.h" - -TestKeyItem g_testKeyItemList[MAX_TEST_KEY_ITEM_LIST_SIZE]; -size_t g_testKeyItemListSize = 0; - -static int FindKeyItem(IntermediateReprestation *ir) -{ - uint32_t keyType = ir->fwdKeyType; - uint32_t keySize = ir->keySize; - size_t i; - for (i = 0; i < g_testKeyItemListSize; i++) { - if (g_testKeyItemList[i].keyType == keyType && g_testKeyItemList[i].keySize == keySize) { - tlogi("[%s]:find key item at %u\n", __func__, i); - ir->tki = &(g_testKeyItemList[i]); - return 0; - } - } - tlogi("[%s]:could not find key item, g_testKeyItemListSize = %u\n", __func__, g_testKeyItemListSize); - return -1; -} - -/* - * DH算法Base和Prime参数定义 - */ -static uint8_t g_base512[] = { - 0xd4, 0x07, 0xa9, 0x80, 0xaf, 0xc2, 0x7a, 0x5b, 0x61, 0x22, 0x76, 0x29, 0x1d, 0x65, 0x52, 0x59, - 0x7f, 0x4f, 0x17, 0x7a, 0xa1, 0xea, 0x04, 0x02, 0x8c, 0x8b, 0x01, 0x11, 0x72, 0x2b, 0x4d, 0xc3, - 0x78, 0xc0, 0x08, 0x11, 0x01, 0xcd, 0x45, 0xab, 0xb3, 0x05, 0x56, 0xcd, 0x72, 0x52, 0x16, 0x7c, - 0x74, 0xf1, 0x00, 0x77, 0xa4, 0xf3, 0x31, 0x83, 0x50, 0xc3, 0xed, 0x3b, 0xb5, 0xb5, 0x5d, 0x43 -}; -static uint8_t g_prime512[] = { - 0xfc, 0xf6, 0xd3, 0x9e, 0x31, 0x88, 0x25, 0x66, 0x30, 0x74, 0x1c, 0x03, 0x85, 0x6e, 0xbd, 0xea, - 0x02, 0x01, 0x0b, 0x77, 0x43, 0x35, 0xfe, 0x57, 0x9c, 0x60, 0xd5, 0x24, 0x22, 0xbe, 0x99, 0xeb, - 0x4f, 0x8f, 0x95, 0x77, 0xdc, 0x47, 0x6a, 0x5e, 0x31, 0x21, 0x6e, 0x9c, 0x00, 0x1b, 0x55, 0xa7, - 0xed, 0xc4, 0xcd, 0xf2, 0x31, 0xd2, 0x44, 0x60, 0x10, 0xd4, 0xb2, 0x6c, 0xb6, 0xf4, 0xb3, 0x73 -}; -static uint8_t g_base1024[] = { - 0xc4, 0x3b, 0x36, 0xc8, 0xe7, 0xa9, 0x60, 0xea, 0x35, 0x80, 0x6a, 0x02, 0x6a, 0x02, 0x02, 0xcb, - 0x21, 0x24, 0x3d, 0xb8, 0x3d, 0x01, 0x76, 0x63, 0x8a, 0xee, 0x95, 0x50, 0x94, 0x1d, 0x6f, 0x0c, - 0x6f, 0x84, 0x17, 0x16, 0x24, 0x00, 0x27, 0xe2, 0x01, 0x8a, 0xa8, 0xa4, 0xdf, 0x7e, 0xde, 0xb4, - 0x49, 0x20, 0x2c, 0x8f, 0x34, 0x3b, 0xa1, 0x4e, 0x6b, 0x02, 0x23, 0x11, 0x42, 0x9a, 0x9c, 0xba, - 0x22, 0x15, 0x06, 0x1c, 0x26, 0x39, 0x1c, 0xdb, 0x43, 0xd3, 0x2c, 0x75, 0x96, 0xaf, 0x97, 0xcf, - 0xa9, 0x32, 0xa1, 0xa7, 0x3f, 0x90, 0xa9, 0xa8, 0x1d, 0xb8, 0x48, 0xcc, 0x2e, 0x68, 0xc1, 0xf1, - 0x71, 0xd2, 0xfb, 0x4f, 0xda, 0x9c, 0x89, 0x02, 0xea, 0x89, 0x9b, 0xa2, 0xe9, 0x33, 0xc4, 0xfe, - 0x7a, 0x31, 0x39, 0x71, 0x12, 0x18, 0xb9, 0xbe, 0x33, 0x10, 0xcf, 0x1b, 0x65, 0xcb, 0xc1, 0x73 -}; -static uint8_t g_prime1024[] = { - 0xc4, 0xac, 0x0a, 0xd9, 0x6a, 0xf5, 0xb1, 0x93, 0x46, 0x43, 0xac, 0x5b, 0x2e, 0x45, 0x38, 0x29, - 0x4e, 0x24, 0xde, 0x8f, 0x80, 0x28, 0x6c, 0x4a, 0xef, 0xcb, 0xc2, 0x07, 0xe5, 0xae, 0xec, 0x4f, - 0x9a, 0x1b, 0x1b, 0x61, 0x35, 0xdb, 0xf9, 0x88, 0x83, 0x61, 0x4e, 0xca, 0x8e, 0x82, 0x43, 0xf9, - 0x56, 0x9f, 0x4c, 0xb0, 0x28, 0xbc, 0xa9, 0x9a, 0x23, 0x05, 0xbd, 0x08, 0x7d, 0xc6, 0x3b, 0x62, - 0x8f, 0x2a, 0x96, 0x30, 0xcf, 0x29, 0x6f, 0x1c, 0x18, 0x54, 0x57, 0x9f, 0xcb, 0xf3, 0xb0, 0x85, - 0xb9, 0xce, 0xea, 0xce, 0x71, 0x7a, 0x16, 0x05, 0xb3, 0xeb, 0xf4, 0xf6, 0x99, 0xd2, 0x7c, 0xe8, - 0x0e, 0x36, 0x01, 0x3f, 0x87, 0x6c, 0x4a, 0xfc, 0x45, 0x67, 0x09, 0x5c, 0xcb, 0x09, 0x9a, 0x5b, - 0x96, 0x61, 0xd3, 0x35, 0x1a, 0x04, 0x07, 0xa8, 0x68, 0xe4, 0xc4, 0xb1, 0x3b, 0x11, 0xd7, 0xa3 -}; -static uint8_t g_base2048[] = { - 0xc9, 0x16, 0xa6, 0x54, 0x91, 0xa7, 0x1c, 0xdf, 0x9b, 0xf9, 0x59, 0x07, 0x95, 0x06, 0x4f, 0xfa, - 0x95, 0x79, 0xc5, 0x20, 0x47, 0xa4, 0x75, 0xce, 0x49, 0xb5, 0x3c, 0xfa, 0x91, 0xd4, 0xd2, 0xb5, - 0xe5, 0x6b, 0x36, 0x24, 0x5f, 0x90, 0x8e, 0xfb, 0x7a, 0x1b, 0x41, 0xf7, 0x18, 0x41, 0xfc, 0x7b, - 0xa5, 0xb4, 0xc3, 0xe1, 0x71, 0xb4, 0x66, 0x54, 0x02, 0x0a, 0xd3, 0xd9, 0xd2, 0x9d, 0xe6, 0x18, - 0x6d, 0x2a, 0xb7, 0xdb, 0x45, 0xbe, 0xc1, 0x83, 0x7f, 0x94, 0x5b, 0xd7, 0xd8, 0x98, 0xd2, 0xcf, - 0x54, 0x38, 0x39, 0xda, 0x90, 0x86, 0xcc, 0xab, 0x0f, 0x15, 0xf8, 0xb8, 0xbf, 0xde, 0x50, 0x07, - 0x74, 0x45, 0x84, 0x4c, 0x2f, 0x08, 0xb1, 0x2f, 0x40, 0x49, 0x9c, 0xaf, 0xb6, 0xd1, 0x6c, 0xe3, - 0x45, 0xbf, 0xf1, 0x63, 0xcc, 0x77, 0x66, 0x5d, 0x45, 0x35, 0xb9, 0x0a, 0xac, 0x74, 0x14, 0x91, - 0x64, 0x1b, 0x34, 0x50, 0xb4, 0xa0, 0x1e, 0xd9, 0xa9, 0x62, 0x56, 0x57, 0xcb, 0x73, 0x3c, 0x96, - 0x5f, 0x86, 0x7f, 0xc3, 0x66, 0xbf, 0xac, 0x79, 0x21, 0x51, 0x14, 0x3f, 0x37, 0x29, 0xbe, 0x96, - 0xc8, 0xee, 0xf1, 0xaf, 0x4e, 0xc7, 0x9f, 0x83, 0x20, 0xe7, 0xb5, 0xb2, 0x52, 0x57, 0xcc, 0xa8, - 0xb0, 0xf2, 0x4d, 0x88, 0x3e, 0x71, 0xfb, 0xd7, 0x45, 0x4d, 0x96, 0x0b, 0xcb, 0x24, 0x0a, 0x88, - 0x4f, 0xaf, 0xe8, 0x96, 0x79, 0x87, 0x14, 0xf8, 0x1e, 0x3d, 0xf7, 0x2c, 0x48, 0xf7, 0x0e, 0x52, - 0x4e, 0x3d, 0xcb, 0xeb, 0x57, 0x54, 0xb9, 0x90, 0xe1, 0x14, 0x5c, 0x36, 0x7d, 0xc0, 0xa3, 0x5f, - 0xf4, 0xfd, 0xf6, 0x33, 0x23, 0x7e, 0xf2, 0xd0, 0xff, 0x0d, 0xe0, 0xe2, 0xa3, 0xcc, 0x81, 0x86, - 0xbc, 0xde, 0x67, 0x83, 0x03, 0xd6, 0xfa, 0x5b, 0x42, 0xd3, 0x1f, 0xfe, 0xd2, 0x0f, 0x2b, 0x1b -}; -static uint8_t g_prime2048[] = { - 0xce, 0xd3, 0x02, 0x09, 0x7d, 0xe5, 0x34, 0xf5, 0x3f, 0x14, 0x2e, 0x7b, 0x3e, 0x15, 0x4c, 0x66, - 0x2c, 0xe1, 0xf0, 0xb7, 0x40, 0x72, 0x68, 0xfa, 0xad, 0xa6, 0xd5, 0xd9, 0x55, 0x1e, 0x7e, 0xfd, - 0x06, 0xbc, 0x4f, 0xb8, 0x27, 0xe9, 0x22, 0x3d, 0x17, 0xfa, 0x4d, 0x8c, 0x8b, 0x8e, 0xce, 0xf6, - 0xc9, 0x49, 0x38, 0x74, 0xa2, 0x77, 0x3b, 0x9a, 0xe1, 0xc0, 0xa7, 0xc8, 0x83, 0xf9, 0xdc, 0xa7, - 0x9a, 0x12, 0xc5, 0x19, 0x5c, 0xfb, 0x40, 0x0c, 0x08, 0x57, 0xa1, 0xf7, 0x8d, 0xf2, 0x10, 0x83, - 0xe8, 0xe7, 0x8a, 0xc1, 0x0c, 0x59, 0xa1, 0xa3, 0x77, 0xb1, 0x9f, 0x0d, 0x0f, 0xf8, 0x27, 0xdd, - 0xdc, 0xed, 0xbf, 0x04, 0x91, 0xa3, 0x00, 0x19, 0x08, 0x2d, 0x7c, 0xc9, 0xda, 0xfb, 0x05, 0x31, - 0xf5, 0x34, 0x0d, 0xaa, 0xd3, 0xbb, 0xc0, 0x5b, 0xfb, 0xad, 0x32, 0x6b, 0x98, 0x00, 0x17, 0x01, - 0x39, 0x61, 0x0e, 0x03, 0x2e, 0xf6, 0x60, 0x30, 0x7b, 0xb9, 0xeb, 0x39, 0x60, 0x1b, 0xc4, 0x7f, - 0xe5, 0xcb, 0x5f, 0xc3, 0xb0, 0x79, 0xdb, 0x04, 0xd2, 0x9a, 0x11, 0x95, 0x3e, 0xa4, 0x33, 0x61, - 0x8e, 0x94, 0x22, 0x9b, 0x0a, 0xd0, 0xfb, 0xda, 0x07, 0xc7, 0x34, 0xfb, 0xa9, 0x94, 0xc8, 0x31, - 0x03, 0xe1, 0x92, 0xac, 0x86, 0xfc, 0x45, 0xe3, 0x79, 0x0b, 0x9e, 0x29, 0x63, 0xe8, 0xcf, 0x26, - 0x05, 0xb3, 0x6e, 0xa9, 0xae, 0x9d, 0xe3, 0xdc, 0x03, 0x43, 0x26, 0xdf, 0x7e, 0x8b, 0xae, 0xcb, - 0xe8, 0x09, 0x04, 0x25, 0xdd, 0x42, 0xb8, 0x59, 0x44, 0xec, 0xc1, 0xc7, 0xbf, 0x78, 0x50, 0x31, - 0xec, 0x6e, 0xa5, 0x5f, 0xe4, 0x4f, 0x79, 0x7b, 0xf3, 0xbf, 0x03, 0xd3, 0xa9, 0x7b, 0x7c, 0x70, - 0xa2, 0x5f, 0xdb, 0x86, 0x96, 0xfa, 0xd1, 0x3f, 0x43, 0xc5, 0xd2, 0x2a, 0xf8, 0xf3, 0x3c, 0x7b -}; - -// ecc curve value -static TEE_Attribute g_eccCurveAttrNistP192 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_NIST_P192, - .b = 0, - }, - }, -}; -static TEE_Attribute g_eccCurveAttrNistP224 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_NIST_P224, - .b = 0, - }, - }, -}; -static TEE_Attribute g_eccCurveAttrNistP256 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_NIST_P256, - .b = 0, - }, - }, -}; -static TEE_Attribute g_eccCurveAttrNistP384 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_NIST_P384, - .b = 0, - }, - }, -}; -static TEE_Attribute g_eccCurveAttrNistP521 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_NIST_P521, - .b = 0, - }, - }, -}; -static TEE_Attribute g_eccCurveAttrSM2 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_SM2, - .b = 0, - }, - }, -}; -static TEE_Attribute g_eccCurveAttr25519 = { - .attributeID = TEE_ATTR_ECC_CURVE, - .content = { - .value = { - .a = TEE_ECC_CURVE_25519, - .b = 0, - }, - }, -}; -// dh gen params -#define DH_GEN_PARAMS_CNT 3 -static TEE_Attribute g_dhGenParams512[DH_GEN_PARAMS_CNT] = { - { - .attributeID = TEE_ATTR_DH_BASE, - .content = { - .ref = { - .buffer = g_base512, - .length = sizeof(g_base512) - }, - }, - }, - { - .attributeID = TEE_ATTR_DH_PRIME, - .content = { - .ref = { - .buffer = g_prime512, - .length = sizeof(g_prime512) - }, - }, - }, - { - .attributeID = TEE_ATTR_DH_X_BITS, - .content = { - .value = { - .a = 512, - .b = 0, - }, - }, - }, -}; -static TEE_Attribute g_dhGenParams1024[DH_GEN_PARAMS_CNT] = { - { - .attributeID = TEE_ATTR_DH_BASE, - .content = { - .ref = { - .buffer = g_base1024, - .length = sizeof(g_base1024) - }, - }, - }, - { - .attributeID = TEE_ATTR_DH_PRIME, - .content = { - .ref = { - .buffer = g_prime1024, - .length = sizeof(g_prime1024) - }, - }, - }, - { - .attributeID = TEE_ATTR_DH_X_BITS, - .content = { - .value = { - .a = 1024, - .b = 0, - }, - }, - }, -}; -static TEE_Attribute g_dhGenParams2048[DH_GEN_PARAMS_CNT] = { - { - .attributeID = TEE_ATTR_DH_BASE, - .content = { - .ref = { - .buffer = g_base2048, - .length = sizeof(g_base2048) - }, - }, - }, - { - .attributeID = TEE_ATTR_DH_PRIME, - .content = { - .ref = { - .buffer = g_prime2048, - .length = sizeof(g_prime2048) - }, - }, - }, - { - .attributeID = TEE_ATTR_DH_X_BITS, - .content = { - .value = { - .a = 2048, - .b = 0, - }, - }, - }, -}; -// rsa gen pulibc_exponent params -static uint8_t g_e0[] = {0x01, 0x00, 0x01}; -static uint8_t g_e1[] = {0x0D, 0xBA, 0xA9}; -static uint8_t g_e2[] = {0x01, 0x1A, 0x73}; -static uint8_t g_e3[] = {0x01, 0x25, 0xA1}; -static uint8_t g_e4[] = {0x89, 0x95, 0x19}; -static TEE_Attribute g_rsaPubExpAttr0 = { - .attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT, - .content = { - .ref = { - .buffer = g_e0, - .length = sizeof(g_e0) - }, - }, -}; -static TEE_Attribute g_rsaPubExpAttr1 = { - .attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT, - .content = { - .ref = { - .buffer = g_e1, - .length = sizeof(g_e1) - }, - }, -}; -static TEE_Attribute g_rsaPubExpAttr2 = { - .attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT, - .content = { - .ref = { - .buffer = g_e2, - .length = sizeof(g_e2) - }, - }, -}; -static TEE_Attribute g_rsaPubExpAttr3 = { - .attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT, - .content = { - .ref = { - .buffer = g_e3, - .length = sizeof(g_e3) - }, - }, -}; -static TEE_Attribute g_rsaPubExpAttr4 = { - .attributeID = TEE_ATTR_RSA_PUBLIC_EXPONENT, - .content = { - .ref = { - .buffer = g_e4, - .length = sizeof(g_e4) - }, - }, -}; -typedef struct { - char name[MAX_STRING_NAME_LEN]; - uint32_t needParamsType; - TEE_Attribute *params; - uint32_t paramCount; - uint32_t dhKeySize; - uint32_t ecCurve; - uint32_t rsaPubExpId; -} KeyGenParamsMap; -static KeyGenParamsMap g_keyGenParamsMap[] = { - // NEED_RSA_EXP_MAYBE - { - .name = {"default null params"}, - .needParamsType = NEED_NO_GEN_PARAMS, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = 0, - - .params = NULL, - .paramCount = 0, - }, - // NEED_DH_BASE_PRIME_XBITS - { - .name = {"dh bash prime xbits 512"}, - .needParamsType = NEED_DH_BASE_PRIME_XBITS, - .dhKeySize = 512, - .ecCurve = 0, - .rsaPubExpId = 0, - - .params = &(g_dhGenParams512[0]), - .paramCount = 3, - }, - { - .name = {"dh bash prime xbits 1024"}, - .needParamsType = NEED_DH_BASE_PRIME_XBITS, - .dhKeySize = 1024, - .ecCurve = 0, - .rsaPubExpId = 0, - - .params = &(g_dhGenParams1024[0]), - .paramCount = 3, - }, - { - .name = {"dh bash prime xbits 2048"}, - .needParamsType = NEED_DH_BASE_PRIME_XBITS, - .dhKeySize = 2048, - .ecCurve = 0, - .rsaPubExpId = 0, - - .params = &(g_dhGenParams2048[0]), - .paramCount = 3, - }, - // NEED_GEN_ECC_CURVE - { - .name = {"ecc curve nist p192"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_NIST_P192, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttrNistP192, - .paramCount = 1, - - }, - { - .name = {"ecc curve nist p224"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_NIST_P224, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttrNistP224, - .paramCount = 1, - - }, - { - .name = {"ecc curve nist p256"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_NIST_P256, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttrNistP256, - .paramCount = 1, - }, - { - .name = {"ecc curve nist p384"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_NIST_P384, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttrNistP384, - .paramCount = 1, - }, - { - .name = {"ecc curve nist p521"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_NIST_P521, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttrNistP521, - .paramCount = 1, - - }, - { - .name = {"ecc curve sm2"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_SM2, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttrSM2, - .paramCount = 1, - }, - { - .name = {"ecc curve 25519"}, - .needParamsType = NEED_GEN_ECC_CURVE, - .dhKeySize = 0, - .ecCurve = TEE_ECC_CURVE_25519, - .rsaPubExpId = 0, - - .params = &g_eccCurveAttr25519, - .paramCount = 1, - }, - // NEED_RSA_EXP_MAYBE - { - .name = {"rsa key gen params null"}, - .needParamsType = NEED_RSA_EXP_MAYBE, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = 0, - - .params = NULL, - .paramCount = 0, - }, - { - .name = {"rsa key gen params attr0"}, - .needParamsType = NEED_RSA_EXP_MAYBE, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_0, - - .params = &g_rsaPubExpAttr0, - .paramCount = 1, - }, - { - .name = {"rsa key gen params attr1"}, - .needParamsType = NEED_RSA_EXP_MAYBE, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_1, - - .params = &g_rsaPubExpAttr1, - .paramCount = 1, - }, - { - .name = {"rsa key gen params attr2"}, - .needParamsType = NEED_RSA_EXP_MAYBE, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_2, - - .params = &g_rsaPubExpAttr2, - .paramCount = 1, - }, - { - .name = {"rsa key gen params attr3"}, - .needParamsType = NEED_RSA_EXP_MAYBE, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_3, - - .params = &g_rsaPubExpAttr3, - .paramCount = 1, - }, - { - .name = {"rsa key gen params attr4"}, - .needParamsType = NEED_RSA_EXP_MAYBE, - .dhKeySize = 0, - .ecCurve = 0, - .rsaPubExpId = TST_RSA_KEYGEN_PUB_EXP_ID_4, - - .params = &g_rsaPubExpAttr4, - .paramCount = 1, - }, -}; -size_t g_keyGenParamsMapSize = sizeof(g_keyGenParamsMap) / sizeof(g_keyGenParamsMap[0]); - -static int SetGenKeyParams(IntermediateReprestation *ir, TEE_Attribute **params, uint32_t *paramCount) -{ - uint32_t needParamsType = ir->fwdKeyMap->needGenParams; - uint32_t dhKeySize = ir->dhGenKeySize; - uint32_t ecCurve = ir->ecKeyCurve; - uint32_t rsaPubExpId = ir->rsaGenPubExpId; - - uint32_t i; - for (i = 0; i < g_keyGenParamsMapSize; i++) { - if (g_keyGenParamsMap[i].needParamsType == needParamsType && - g_keyGenParamsMap[i].dhKeySize == dhKeySize && - g_keyGenParamsMap[i].ecCurve == ecCurve && - g_keyGenParamsMap[i].rsaPubExpId == rsaPubExpId) { - tlogi("[%s]:find key gen params map:%s\n", __func__, g_keyGenParamsMap[i].name); - *params = g_keyGenParamsMap[i].params; - *paramCount = g_keyGenParamsMap[i].paramCount; - return 0; - } - } - tloge("[%s]:cound not find key gen params\n", __func__); - return -1; -} -static int GenerateKeyItem(IntermediateReprestation *ir) -{ - uint32_t keyType = ir->genKeyType; - uint32_t keySize = ir->keySize; - tlogi("[%s]:keyType[0x%x].keySize[0x%x]\n", __func__, keyType, keySize); - int ret = TEE_AllocateTransientObject(keyType, keySize, - &(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0])); - if (ret != TEE_SUCCESS) { - tloge("[%s]:allocate key object0 failed\n", __func__); - return -1; - } - ret = TEE_AllocateTransientObject(keyType, keySize, - &(g_testKeyItemList[g_testKeyItemListSize].keyObjList[1])); - if (ret != TEE_SUCCESS) { - tloge("[%s]:allocate key object1 failed\n", __func__); - TEE_FreeTransientObject(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0]); - return -1; - } - TEE_Attribute *params = NULL; - uint32_t paramCount = 0; - int ret0 = SetGenKeyParams(ir, ¶ms, ¶mCount); - int ret1 = TEE_GenerateKey(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0], - keySize, params, paramCount); - int ret2 = TEE_GenerateKey(g_testKeyItemList[g_testKeyItemListSize].keyObjList[1], - keySize, params, paramCount); - if (ret0 != 0 || ret1 != 0 || ret2 != 0) { - tloge("[%s]:generte key failed, ret0 = 0x%x, ret2 = 0x%x, ret3 = 0x%x\n", __func__, - ret0, ret1, ret2); - ret = -1; - goto error1; - } - tlogi("[%s]:generte key success\n", __func__); - - ir->tki = &(g_testKeyItemList[g_testKeyItemListSize]); - - g_testKeyItemListSize++; - tlogi("[%s]:GenerateKeyItem success\n", __func__); - return 0; - -error1: - ir->tki = NULL; - TEE_FreeTransientObject(g_testKeyItemList[g_testKeyItemListSize].keyObjList[0]); - TEE_FreeTransientObject(g_testKeyItemList[g_testKeyItemListSize].keyObjList[1]); - tloge("[%s]:generate test key item failed\n", __func__); - return ret; -} - -int GetOrGenIRTestKeys(IntermediateReprestation *ir) -{ - ir->tki = NULL; - int ret = FindKeyItem(ir); - if (ret == 0) { - tlogi("[%s]:find exist test key item and return\n", __func__); - return 0; - } - tlogi("[%s]:could not find key, need to generate.\n", __func__); - ret = GenerateKeyItem(ir); - if (ret != 0) { - tloge("[%s]:GenerateKeyItem failed\n", __func__); - return -1; - } - return 0; -} - diff --git a/test/xts/ta/test_crypto_api/src/data/test_crypto_data.h b/test/xts/ta/test_crypto_api/src/data/test_crypto_data.h deleted file mode 100644 index 978ac276..00000000 --- a/test/xts/ta/test_crypto_api/src/data/test_crypto_data.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef TEST_CRYPTO_DATA_H -#define TEST_CRYPTO_DATA_H -#include "stddef.h" -#include "test_crypto_api_types.h" -// alg_map_data.c -AlgMapInfo *FindAlgMapInfo(char *algName); -KeyTypeMapInfo *FindKeyTypeValue(char *keyTypeName); - -// key_object_database.c -int GetOrGenIRTestKeys(IntermediateReprestation *ir); -#endif // end TEST_CRYPTO_DATA_H \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/monad/monad.h b/test/xts/ta/test_crypto_api/src/monad/monad.h deleted file mode 100644 index 3d556615..00000000 --- a/test/xts/ta/test_crypto_api/src/monad/monad.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef MONAD_H -#define MONAD_H -#include "test_crypto_api_types.h" -#include "test_crypto_data.h" -#include "tee_crypto_api.h" -// monad_run.c -int MonadRun2(TestVector *tv); - -// monad_actions.c -// ir init -int IRSetUp(IntermediateReprestation *ir); -int IRTearDown(IntermediateReprestation *ir); -// common operations -int GlbFree(IntermediateReprestation *ir); -int GlbAlloc(IntermediateReprestation *ir); -int GlbGetInfo(IntermediateReprestation *ir); -int GlbGetInfoMulti(IntermediateReprestation *ir); -int GlbReset(IntermediateReprestation *ir); -int GlbS1S2(IntermediateReprestation *ir); -int GlbS1S2Null(IntermediateReprestation *ir); -int GlbCopy(IntermediateReprestation *ir); -int GlbCopyRpl(IntermediateReprestation *ir); -int GlbIsAlgSprt(IntermediateReprestation *ir); -// digest operations -int DIUpdateFwd(IntermediateReprestation *ir); -int DIDofinalFwd(IntermediateReprestation *ir); -int DIUpdateBck(IntermediateReprestation *ir); -int DIDofinalBck(IntermediateReprestation *ir); -// symmetric cipher operations -int SCInitFwd(IntermediateReprestation *ir); -int SCUpdateFwd(IntermediateReprestation *ir); -int SCDofinalFwd(IntermediateReprestation *ir); -int SCInitBck(IntermediateReprestation *ir); -int SCUpdateBck(IntermediateReprestation *ir); -int SCDofinalBck(IntermediateReprestation *ir); -// mac operations -int MInitFwd(IntermediateReprestation *ir); -int MUpdateFwd(IntermediateReprestation *ir); -int MComputeFwd(IntermediateReprestation *ir); -int MInitBck(IntermediateReprestation *ir); -int MUpdateBck(IntermediateReprestation *ir); -int MCapareBck(IntermediateReprestation *ir); -// ae opeartions -int AEInitFwd(IntermediateReprestation *ir); -int AEUpdateAadFwd(IntermediateReprestation *ir); -int AEUpdateAadMtlFwd(IntermediateReprestation *ir); -int AEUpdateFwd(IntermediateReprestation *ir); -int AEUpdate0Fwd(IntermediateReprestation *ir); -int AEInitBck(IntermediateReprestation *ir); -int AEUpdateAadBck(IntermediateReprestation *ir); -int AEUpdateAadMtlBck(IntermediateReprestation *ir); -int AEUpdateBck(IntermediateReprestation *ir); -int AEUpdate0Bck(IntermediateReprestation *ir); -int AEEncFinalFwd(IntermediateReprestation *ir); -int AEEncFinalOmtFwd(IntermediateReprestation *ir); -int AEDoFinalBck(IntermediateReprestation *ir); -int AEDoFinalOmtBck(IntermediateReprestation *ir); -// asymmetric crypto operations -int ASEncryFwd(IntermediateReprestation *ir); -int ASDecryBck(IntermediateReprestation *ir); -// asymmetric sign operations -int ASSignFwd(IntermediateReprestation *ir); -int ASVerifyBck(IntermediateReprestation *ir); -// derive operations -int DRDeriveFwd(IntermediateReprestation *ir); -int DRDeriveBck(IntermediateReprestation *ir); - -// monad_inverse_map.c -int CopyReversElementList(MonadReversibilityProperty *dest, uint32_t *destSize); -int DisbalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType element); -int BalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType inverseElement); -int BalanceGroupElementList(IntermediateReprestation *ir); - -#endif // end MONAD_H \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/monad/monad_actions.c b/test/xts/ta/test_crypto_api/src/monad/monad_actions.c deleted file mode 100644 index ed7d412c..00000000 --- a/test/xts/ta/test_crypto_api/src/monad/monad_actions.c +++ /dev/null @@ -1,1338 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "securec.h" -#include "tee_crypto_api.h" -#include "test_crypto_data.h" -#include "string.h" -#include "test_crypto_api_types.h" -#include "tee_log.h" -#include "monad.h" - -static int SetupProcessInOutData(ProcessInOutData *data, size_t dataSize, size_t sliceSize) -{ - data->data = malloc(dataSize + DATA_EXPAND_SIZE); - if (data->data == NULL) { - tloge("[%s]:malloc data failed\n", __func__); - return -1; - } - data->dataMallocSize = dataSize + DATA_EXPAND_SIZE; - data->dataSize = dataSize; - data->dataUsed = 0; - data->sliceSize = sliceSize; - data->dataMode = (sliceSize == 0) ? DATA_MODE_WHOLE : DATA_MODE_SLICE; - data->aeTagSize = 0; - return 0; -} -static void TearDownProcessInOutData(ProcessInOutData *data) -{ - if (data->data == NULL) { - return; - } - free(data->data); - data->data = NULL; - data->dataMallocSize = 0; - data->dataSize = 0; - data->dataUsed = 0; - data->sliceSize = 0; - data->dataMode = 0; - data->aeTagSize = 0; -} -static int SetupPlainCipherDecryptedData( - ProcessInOutData *plain, - ProcessInOutData *cipher, - ProcessInOutData *decrypted, - size_t dataSize, size_t sliceSize) -{ - int ret1 = SetupProcessInOutData(plain, dataSize, sliceSize); - int ret2 = SetupProcessInOutData(cipher, dataSize, sliceSize); - int ret3 = SetupProcessInOutData(decrypted, dataSize, sliceSize); - if (ret1 != 0 || ret2 != 0 || ret3 != 0) { - tloge("[%s]:setup plain, chiper, decrypted failed\n", __func__); - TearDownProcessInOutData(plain); - TearDownProcessInOutData(cipher); - TearDownProcessInOutData(decrypted); - return -1; - } - tlogi("[%s]:setup plain, chiper, decrypted success\n", __func__); - return 0; -} -static int TearDownPlainCipherDecryptedData( - ProcessInOutData *plain, - ProcessInOutData *cipher, - ProcessInOutData *decrypted) -{ - TearDownProcessInOutData(plain); - TearDownProcessInOutData(cipher); - TearDownProcessInOutData(decrypted); - - tlogi("[%s]:teardown plain, chiper, decrypted success\n", __func__); - return 0; -} -static int TestVector2IR(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - - AlgMapInfo *algMap = FindAlgMapInfo(tv->algName); - if (algMap == NULL) { - tloge("[%s]:invalid algName:%s\n", __func__, tv->algName); - return -1; - } - ir->algMap = algMap; - - KeyTypeMapInfo *fwdKeyMap = FindKeyTypeValue(tv->fwdKeyTypeName); - KeyTypeMapInfo *bckKeyMap = FindKeyTypeValue(tv->bckKeyTypeName[0] == '\0' ? - tv->fwdKeyTypeName : tv->bckKeyTypeName); - if (fwdKeyMap == NULL || bckKeyMap == NULL) { - tlogi("[%s]:could not fwdKeyTypeName or bckKeyTypeName, maybe this operation need no key.\n", __func__); - } else { - ir->fwdKeyMap = fwdKeyMap; - ir->bckKeyMap = bckKeyMap; - ir->fwdKeyType = fwdKeyMap->keyType; - ir->bckKeyType = bckKeyMap->keyType; - ir->genKeyType = fwdKeyMap->keyGenType; - } - - ir->algValue = algMap->algValue; - ir->algOperaClassValue = algMap->algOperaClassValue; - ir->fwdMode = algMap->fwdMode; - ir->bckMode = algMap->bckMode; - ir->operaKeyCount = algMap->operaKeyCount; - ir->needKeyCount = algMap->needKeyCount; - ir->isSwitchFwdBckOperaKey = algMap->isSwitchFwdBckOperaKey; - ir->operaMaxKeySize = tv->operaMaxKeySize; - ir->keySize = tv->keySize; - ir->dataSize = tv->dataSize; - ir->sliceSize = tv->sliceSize; - ir->fwdEngine = tv->fwdEngine; - ir->bckEngine = tv->bckEngine; - ir->ivLen = tv->ivLen; - // ae - ir->aeNonceLen = tv->aeNonceLen; - ir->aeAadLenInit = tv->aeAadLenInit; - ir->nonceByte = tv->nonceByte; - ir->aeTagLen = tv->aeTagLen; - ir->aeTagOSize = tv->aeTagOSize; - ir->aeAadLen = tv->aeAadLen; - ir->aadByte = tv->aadByte; - // as encry and sign - ir->rsaEnMgf1Hash = tv->rsaEnMgf1Hash; - ir->rsaSgPssLen = tv->rsaSgPssLen; - // gen params - ir->ecKeyCurve = tv->ecKeyCurve; - ir->rsaGenPubExpId = tv->rsaGenPubExpId; - ir->dhGenKeySize = tv->dhGenKeySize; - return 0; -} - -static void IRAEDataTearDown(IntermediateReprestation *ir) -{ - if (ir->pAad == NULL) { - tlogi("[%s]:pAad is null, just return\n", __func__); - return; - } - TEE_Free(ir->pAad); - ir->pAad = NULL; - - tlogi("[%s]:IRAEDataTearDown down\n", __func__); - return; -} -static int IRAEDataSetUp(IntermediateReprestation *ir) -{ - // aad data setup - if (ir->aeAadLen == 0) { - tlogi("[%s]:ir->aeAadLen is zero, just return\n", __func__); - return 0; - } - ir->pAad = TEE_Malloc(ir->aeAadLen, 0); - if (ir->pAad == NULL) { - tlogi("[%s]:TEE_Malloc ir->aeAadLen %u failed\n", __func__); - return -1; - } - size_t i; - for (i = 0; i < ir->aeAadLen; i++) { - ir->pAad[i] = ir->aadByte; - } - - // nonce data setup - for (i = 0; i < ir->aeNonceLen; i++) { - ir->nonce[i] = ir->nonceByte; - } - - tlogi("[%s]:IRAEDataSetUp success\n", __func__); - return 0; -} - -static int IRDataTearDown(IntermediateReprestation *ir) -{ - // teardown plain cipher decrypted data - int ret = TearDownPlainCipherDecryptedData(&(ir->plainData), - &(ir->cipherData), &(ir->decryptedData)); - if (ret != 0) { - tloge("[%s]:TearDownPlainCipherDecryptedData failed\n", __func__); - return -1; - } - tlogi("[%s]:TearDownPlainCipherDecryptedData success\n", __func__); - - // teardown ae data - IRAEDataTearDown(ir); - tlogi("[%s]:IRAEDataTearDown done\n", __func__); - return 0; -} -static int IRDataSetup(IntermediateReprestation *ir) -{ - // setup plain cipher decrypted data - int ret = SetupPlainCipherDecryptedData(&(ir->plainData), - &(ir->cipherData), &(ir->decryptedData), - ir->dataSize, ir->sliceSize); - if (ret != 0) { - tloge("[%s]:SetupPlainCipherDecryptedData failed\n", __func__); - return -1; - } - tlogi("[%s]:SetupPlainCipherDecryptedData success\n", __func__); - - // setup AE data - ret = IRAEDataSetUp(ir); - if (ret != 0) { - tloge("[%s]:IRAEDataSetUp failed\n", __func__); - IRDataTearDown(ir); - return -1; - } - - tlogi("[%s]:IRDataSetup success\n", __func__); - return 0; -} - -int IRSetUp(IntermediateReprestation *ir) -{ - int ret = TestVector2IR(ir); - if (ret != 0) { - tloge("[%s]:TestVector2IR failed\n", __func__); - return -1; - } - - ret = IRDataSetup(ir); - if (ret != 0) { - tloge("[%s]:IRDataSetup failed\n", __func__); - return -1; - } - - ret = DisbalanceGroupElement(ir->mrpl, ir->mrplSize, IRSetUp); - if (ret != 0) { - tloge("[%s]:DisbalanceGroupElement failed\n", __func__); - return -1; - } - - tlogi("[%s]:IRSetUp success\n", __func__); - return 0; -} -int IRTearDown(IntermediateReprestation *ir) -{ - int ret = IRDataTearDown(ir); - if (ret != 0) { - tloge("[%s]:IRDataTearDown failed\n", __func__); - return -1; - } - tlogi("[%s]:IRDataTearDown success\n", __func__); - ret = BalanceGroupElement(ir->mrpl, ir->mrplSize, IRTearDown); - if (ret != 0) { - tloge("[%s]:BalanceGroupElement failed\n", __func__); - return -1; - } - - tlogi("[%s]:IRTearDown success\n", __func__); - return 0; -} -int GlbFree(IntermediateReprestation *ir) -{ - if (ir->fwdOperaHandle != NULL) { - TEE_FreeOperation(ir->fwdOperaHandle); - } - - if (ir->bckOperaHandle != NULL) { - TEE_FreeOperation(ir->bckOperaHandle); - } - - int ret = BalanceGroupElement(ir->mrpl, ir->mrplSize, GlbFree); - if (ret != 0) { - tloge("[%s]:BalanceGroupElement failed\n", __func__); - return -1; - } - - tlogi("[%s]:GlbFree success\n", __func__); - return 0; -} -int GlbAlloc(IntermediateReprestation *ir) -{ - (void)ir; - ir->fwdOperaHandle = NULL; - ir->bckOperaHandle = NULL; - TEE_Result ret1 = TEE_AllocateOperation(&(ir->fwdOperaHandle), ir->algValue, - ir->fwdMode, ir->operaMaxKeySize); - TEE_Result ret2 = TEE_AllocateOperation(&(ir->bckOperaHandle), ir->algValue, - ir->bckMode, ir->operaMaxKeySize); - if (ret1 != TEE_SUCCESS || ret2 != TEE_SUCCESS) { - tloge("[%s]:allocate fwdOperaHandle or bckOperaHandle\n", __func__); - goto error; - } - tlogi("[%s]:TEE_AllocateOperation fwd and bck operation handle success.\n", __func__); - - int ret = DisbalanceGroupElement(ir->mrpl, ir->mrplSize, GlbAlloc); - if (ret != 0) { - tloge("[%s]:DisbalanceGroupElement failed\n", __func__); - return -1; - } - tlogi("[%s]:GlbAlloc success\n", __func__); - return 0; -error: - GlbFree(ir); - return -1; -} - -int GlbGetInfo(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} - -int GlbGetInfoMulti(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} - -int GlbReset(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} -static void FreeFourKeyObj(TEE_ObjectHandle fwdKey0, TEE_ObjectHandle fwdKey1, - TEE_ObjectHandle bckKey0, TEE_ObjectHandle bckKey1) -{ - if (fwdKey0 != NULL) { - TEE_FreeTransientObject(fwdKey0); - } - if (fwdKey1 != NULL) { - TEE_FreeTransientObject(fwdKey1); - } - if (bckKey0 != NULL) { - TEE_FreeTransientObject(bckKey0); - } - if (bckKey1 != NULL) { - TEE_FreeTransientObject(bckKey1); - } -} -int AllocateFourKeyObj(TEE_ObjectHandle *fwdKey0, TEE_ObjectHandle *fwdKey1, - TEE_ObjectHandle *bckKey0, TEE_ObjectHandle *bckKey1, IntermediateReprestation *ir) -{ - TEE_Result ret1 = TEE_AllocateTransientObject(ir->fwdKeyType, ir->keySize, fwdKey0); - TEE_Result ret2 = TEE_AllocateTransientObject(ir->fwdKeyType, ir->keySize, fwdKey1); - TEE_Result ret3 = TEE_AllocateTransientObject(ir->bckKeyType, ir->keySize, bckKey0); - TEE_Result ret4 = TEE_AllocateTransientObject(ir->bckKeyType, ir->keySize, bckKey1); - if (ret1 != TEE_SUCCESS || ret2 != TEE_SUCCESS || - ret3 != TEE_SUCCESS || ret4 != TEE_SUCCESS) { - tloge("[%s]:TEE_AllocateTransientObject fwdKey0, fwdKey1, bckKey0, bckKey1 failed\n", - __func__); - goto error1; - } - tlogi("[%s]:AllocateFourKeyObj success\n", __func__); - return 0; -error1: - FreeFourKeyObj(*fwdKey0, *fwdKey1, *bckKey0, *bckKey1); - return -1; -} -int CopyKeyAndSetOperationKey(TEE_ObjectHandle *fwdKey0, TEE_ObjectHandle *fwdKey1, - TEE_ObjectHandle *bckKey0, TEE_ObjectHandle *bckKey1, IntermediateReprestation *ir) -{ - int ret = GetOrGenIRTestKeys(ir); - if (ret != 0) { - tloge("[%s]:GetOrGenIRTestKeys failed\n", __func__); - return -1; - } - tlogi("[%s]:GetOrGenIRTestKeys success\n", __func__); - - TestKeyItem *keyItem = ir->tki; - - TEE_CopyObjectAttributes1(*fwdKey0, keyItem->keyObjList[0]); - TEE_CopyObjectAttributes1(*fwdKey1, keyItem->keyObjList[1]); - if (ir->isSwitchFwdBckOperaKey) { - TEE_CopyObjectAttributes1(*bckKey0, keyItem->keyObjList[1]); - TEE_CopyObjectAttributes1(*bckKey1, keyItem->keyObjList[0]); - } else { - TEE_CopyObjectAttributes1(*bckKey0, keyItem->keyObjList[0]); - TEE_CopyObjectAttributes1(*bckKey1, keyItem->keyObjList[1]); - } - int ret1 = 0; - int ret2 = 0; - if (ir->operaKeyCount == XTS_KEY_COUNT_TWO) { - ret1 = TEE_SetOperationKey2(ir->fwdOperaHandle, *fwdKey0, *fwdKey1); - ret2 = TEE_SetOperationKey2(ir->bckOperaHandle, *bckKey0, *bckKey1); - } else { - ret1 = TEE_SetOperationKey(ir->fwdOperaHandle, *fwdKey0); - ret2 = TEE_SetOperationKey(ir->bckOperaHandle, *bckKey0); - } - if (ret1 != TEE_SUCCESS || ret2 != TEE_SUCCESS) { - tloge("[%s]:TEE_CopyObjectAttributes1 fwdKey0, fwdKey1, bckKey0, bckKey1 failed\n", __func__); - return -1; - } - return 0; -} -int GlbS1S2(IntermediateReprestation *ir) -{ - TEE_ObjectHandle fwdKey0 = NULL; - TEE_ObjectHandle fwdKey1 = NULL; - TEE_ObjectHandle bckKey0 = NULL; - TEE_ObjectHandle bckKey1 = NULL; - int ret = AllocateFourKeyObj(&fwdKey0, &fwdKey1, &bckKey0, &bckKey1, ir); - if (ret != 0) { - tloge("[%s]:AllocateFourKeyObj falied\n", __func__); - return -1; - } - ret = CopyKeyAndSetOperationKey(&fwdKey0, &fwdKey1, &bckKey0, &bckKey1, ir); - if (ret != 0) { - tloge("[%s]:CopyKeyAndSetOperationKey falied\n", __func__); - goto error; - } - tlogi("[%s]GlbS1S2 success\n", __func__); -error: - FreeFourKeyObj(fwdKey0, fwdKey1, bckKey0, bckKey1); - return ret; -} - -int GlbS1S2Null(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} - -int GlbCopy(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} - -int GlbCopyRpl(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} - -int GlbIsAlgSprt(IntermediateReprestation *ir) -{ - (void)ir; - tlogi("in function [%s]\n", __func__); - return 0; -} - -int DIUpdateFwd(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *chunk = ir->plainData.data + ir->plainData.dataUsed; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - size_t chunkSize = (dataLeft >= ir->plainData.sliceSize) ? ir->plainData.sliceSize : 0; - TEE_DigestUpdate(ir->fwdOperaHandle, (const void *)chunk, chunkSize); - ir->plainData.dataUsed += chunkSize; - - tlogi("[%s]:DIUpdateFwd success.\n", __func__); - return 0; -} - -typedef struct { - uint32_t alg; - uint32_t len; -} DigestMacLenMap; -enum { - LEN_8 = 8, - LEN_16 = 16, - LEN_20 = 20, - LEN_28 = 28, - LEN_32 = 32, - LEN_48 = 48, - LEN_64 = 64, -}; -static DigestMacLenMap g_digestMacLenMapList[] = { - // digest - { .alg = TEE_ALG_MD5, .len = LEN_16, }, - { .alg = TEE_ALG_SHA1, .len = LEN_20, }, - { .alg = TEE_ALG_SHA224, .len = LEN_28, }, - { .alg = TEE_ALG_SHA256, .len = LEN_32, }, - { .alg = TEE_ALG_SHA384, .len = LEN_48, }, - { .alg = TEE_ALG_SHA512, .len = LEN_64, }, - { .alg = TEE_ALG_SM3, .len = LEN_32, }, - // hmac - { .alg = TEE_ALG_HMAC_MD5, .len = LEN_16, }, - { .alg = TEE_ALG_HMAC_SHA1, .len = LEN_20, }, - { .alg = TEE_ALG_HMAC_SHA224, .len = LEN_28, }, - { .alg = TEE_ALG_HMAC_SHA256, .len = LEN_32, }, - { .alg = TEE_ALG_HMAC_SHA384, .len = LEN_48, }, - { .alg = TEE_ALG_HMAC_SHA512, .len = LEN_64, }, - { .alg = TEE_ALG_HMAC_SM3, .len = LEN_32, }, - { .alg = TEE_ALG_AES_CMAC, .len = LEN_16, }, - { .alg = TEE_ALG_AES_CBC_MAC_NOPAD, .len = LEN_16, }, - { .alg = TEE_ALG_DES3_CBC_MAC_NOPAD, .len = LEN_8, }, - { .alg = TEE_ALG_DES_CBC_MAC_NOPAD, .len = LEN_8, }, -}; -static size_t g_digestMacLenMapListSize = sizeof(g_digestMacLenMapList) / sizeof(g_digestMacLenMapList[0]); -static int CheckDigestMacLen(uint32_t alg, size_t len) -{ - size_t i; - for (i = 0; i < g_digestMacLenMapListSize; i++) { - if (g_digestMacLenMapList[i].alg == alg && g_digestMacLenMapList[i].len == len) { - tlogi("[%s]:find expect alg 0x%x and len %lu\n", __func__, alg, len); - return 0; - } - } - tloge("[%s]:could not find alg 0x%x len map\n", __func__, alg); - return 0; -} - -int DIDofinalFwd(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = DIUpdateFwd(ir); - if (ret != 0) { - tloge("[%s]:DIUpdateFwd failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *chunk = ir->plainData.data + ir->plainData.dataUsed; - size_t chunkLen = dataLeft; - void *hash = ir->cipherData.data; - size_t hashLen = ir->cipherData.dataSize; - ret = TEE_DigestDoFinal(ir->fwdOperaHandle, (const void *)chunk, chunkLen, hash, &(hashLen)); - if (ret != 0) { - tloge("[%s]:TEE_DigestDoFinal failed, ret = 0x%x\n", __func__, ret); - return -1; - } - tlogi("[%s]:TEE_DigestDoFinal success\n", __func__); - - ret = CheckDigestMacLen(ir->algMap->algValue, hashLen); - if (ret != 0) { - tloge("[%s]:CheckDigestMacLen failed\n", __func__); - return -1; - } - ir->cipherData.dataSize = hashLen; - ir->plainData.dataUsed = 0; - tlogi("[%s]:DIDofinalFwd success\n", __func__); - return 0; -} - -int DIUpdateBck(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *chunk = ir->plainData.data + ir->plainData.dataUsed; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - size_t chunkSize = (dataLeft >= ir->plainData.sliceSize) ? ir->plainData.sliceSize : 0; - TEE_DigestUpdate(ir->bckOperaHandle, (const void *)chunk, chunkSize); - ir->plainData.dataUsed += chunkSize; - - tlogi("[%s]:DIUpdateBck success.\n", __func__); - return 0; -} - -int DIDofinalBck(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = DIUpdateBck(ir); - if (ret != 0) { - tloge("[%s]:DIUpdateBck failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *chunk = ir->plainData.data + ir->plainData.dataUsed; - size_t chunkLen = dataLeft; - void *hash = ir->decryptedData.data; - size_t hashLen = ir->decryptedData.dataSize; - ret = TEE_DigestDoFinal(ir->bckOperaHandle, (const void *)chunk, chunkLen, hash, &(hashLen)); - if (ret != 0) { - tloge("[%s]:TEE_DigestDoFinal failed, ret = 0x%x\n", __func__, ret); - return -1; - } - tlogi("[%s]:TEE_DigestDoFinal success\n", __func__); - - ret = CheckDigestMacLen(ir->algMap->algValue, hashLen); - if (ret != 0) { - tloge("[%s]:CheckDigestMacLen failed\n", __func__); - return -1; - } - ir->decryptedData.dataSize = hashLen; - ir->plainData.dataUsed = 0; - - if (TEE_MemCompare((void *)ir->cipherData.data, - (void *)ir->decryptedData.data, - (size_t)ir->cipherData.dataSize)) { - tloge("[%s]:TEE_MemCompare failed\n", __func__); - return -1; - } - - tlogi("[%s]:DIDofinalBck success\n", __func__); - return 0; -} - -#define MAX_IV_BUFFER_SIZE 64 -#define IV_VALUE 0x7F -static void *GetIvAddr(void) -{ - static int initFlag = 0; - static uint8_t iv[MAX_IV_BUFFER_SIZE]; - if (initFlag != 0) { - goto ret; - } - int i; - for (i = 0; i < MAX_IV_BUFFER_SIZE; i++) { - iv[i] = IV_VALUE; - } - initFlag = 1; -ret: - return iv; -} -int SCInitFwd(IntermediateReprestation *ir) -{ - ir->plainData.dataUsed = 0; - ir->cipherData.dataSize = ir->cipherData.dataMallocSize; - ir->cipherData.dataUsed = 0; - TEE_CipherInit(ir->fwdOperaHandle, (void *)GetIvAddr(), ir->ivLen); - tlogi("[%s]SCInitFwd success\n", __func__); - return 0; -} - -int SCUpdateFwd(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *pSrcData = ir->plainData.data + ir->plainData.dataUsed; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - size_t srcLen = (dataLeft >= ir->plainData.sliceSize) ? ir->plainData.sliceSize : 0; - void *pDestData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t destLen = ir->cipherData.dataSize - ir->cipherData.dataUsed; - int ret = TEE_CipherUpdate(ir->fwdOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_CipherUpdate failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->plainData.dataUsed += srcLen; - ir->cipherData.dataUsed += destLen; - tlogi("[%s]:SCUpdateFwd success.\n", __func__); - return 0; -} - -int SCDofinalFwd(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = SCUpdateFwd(ir); - if (ret != 0) { - tloge("[%s]:SCUpdateFwd failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *pSrcData = ir->plainData.data + ir->plainData.dataUsed; - size_t srcLen = dataLeft; - void *pDestData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t destLen = ir->cipherData.dataSize - ir->cipherData.dataUsed; - ret = TEE_CipherDoFinal(ir->fwdOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_CipherDoFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->cipherData.dataSize = ir->cipherData.dataUsed + destLen; - tlogi("[%s]:SCDofinalFwd success\n", __func__); - return 0; -} - -int SCInitBck(IntermediateReprestation *ir) -{ - ir->cipherData.dataUsed = 0; - ir->decryptedData.dataSize = ir->decryptedData.dataMallocSize; - ir->decryptedData.dataUsed = 0; - TEE_CipherInit(ir->bckOperaHandle, (void *)GetIvAddr(), ir->ivLen); - tlogi("[%s]SCInitBck success\n", __func__); - return 0; -} - -int SCUpdateBck(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *pSrcData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - size_t srcLen = (dataLeft >= ir->cipherData.sliceSize) ? ir->cipherData.sliceSize : 0; - void *pDestData = ir->decryptedData.data + ir->decryptedData.dataUsed; - size_t destLen = ir->decryptedData.dataSize - ir->decryptedData.dataUsed; - int ret = TEE_CipherUpdate(ir->bckOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_CipherUpdate failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->cipherData.dataUsed += srcLen; - ir->decryptedData.dataUsed += destLen; - tlogi("[%s]:SCUpdateBck success.\n", __func__); - return 0; -} - -int SCDofinalBck(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - while (ir->cipherData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->cipherData.sliceSize) { - ret = SCUpdateBck(ir); - if (ret != 0) { - tloge("[%s]:SCUpdateBck failed\n", __func__); - return -1; - } - dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - } - void *pSrcData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t srcLen = dataLeft; - void *pDestData = ir->decryptedData.data + ir->decryptedData.dataUsed; - size_t destLen = ir->decryptedData.dataSize - ir->decryptedData.dataUsed; - ret = TEE_CipherDoFinal(ir->bckOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_CipherDoFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->decryptedData.dataSize = ir->decryptedData.dataUsed + destLen; - tlogi("[%s]:TEE_CipherDoFinal success\n", __func__); - - if (TEE_MemCompare((void *)ir->plainData.data, - (void *)ir->decryptedData.data, - (size_t)ir->plainData.dataSize)) { - tloge("[%s]:TEE_MemCompare failed\n", __func__); - return -1; - } - tlogi("[%s]:SCDofinalFwd success\n", __func__); - return 0; -} - -int MInitFwd(IntermediateReprestation *ir) -{ - ir->plainData.dataUsed = 0; - ir->cipherData.dataSize = ir->cipherData.dataMallocSize; - ir->cipherData.dataUsed = 0; - TEE_MACInit(ir->fwdOperaHandle, (void *)GetIvAddr(), ir->ivLen); - tlogi("[%s]:MInitFwd success\n", __func__); - return 0; -} - -int MUpdateFwd(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *chunk = ir->plainData.data + ir->plainData.dataUsed; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - size_t chunkSize = (dataLeft >= ir->plainData.sliceSize) ? ir->plainData.sliceSize : 0; - TEE_MACUpdate(ir->fwdOperaHandle, (const void *)chunk, chunkSize); - ir->plainData.dataUsed += chunkSize; - tlogi("[%s]:MUpdateFwd success.\n", __func__); - return 0; -} - -int MComputeFwd(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = MUpdateFwd(ir); - if (ret != 0) { - tloge("[%s]:MUpdateFwd failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *message = ir->plainData.data + ir->plainData.dataUsed; - size_t messageLen = dataLeft; - void *mac = ir->cipherData.data; - size_t macLen = ir->cipherData.dataSize; - ret = TEE_MACComputeFinal(ir->fwdOperaHandle, (const void *)message, messageLen, - mac, &macLen); - if (ret != 0) { - tloge("[%s]:TEE_MACComputeFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->cipherData.dataSize = macLen; - tlogi("[%s]:TEE_MACComputeFinal success \n", __func__); - - ret = CheckDigestMacLen(ir->algMap->algValue, macLen); - if (ret != 0) { - tloge("[%s]:CheckDigestMacLen failed\n", __func__); - return -1; - } - - tlogi("[%s]:MComputeFwd success\n", __func__); - return 0; -} - -int MInitBck(IntermediateReprestation *ir) -{ - ir->plainData.dataUsed = 0; - TEE_MACInit(ir->bckOperaHandle, (void *)GetIvAddr(), ir->ivLen); - tlogi("[%s]:MInitBck success\n", __func__); - return 0; -} - -int MUpdateBck(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *chunk = ir->plainData.data + ir->plainData.dataUsed; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - size_t chunkSize = (dataLeft >= ir->plainData.sliceSize) ? ir->plainData.sliceSize : 0; - TEE_MACUpdate(ir->bckOperaHandle, (const void *)chunk, chunkSize); - ir->plainData.dataUsed += chunkSize; - tlogi("[%s]:MUpdateBck success.\n", __func__); - return 0; -} - -int MCapareBck(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = MUpdateBck(ir); - if (ret != 0) { - tloge("[%s]:MUpdateBck failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *message = ir->plainData.data + ir->plainData.dataUsed; - size_t messageLen = dataLeft; - void *mac = ir->cipherData.data; - size_t macLen = ir->cipherData.dataSize; - ret = TEE_MACCompareFinal(ir->bckOperaHandle, (const void *)message, messageLen, (const void *)mac, - (const size_t)macLen); - if (ret != 0) { - tloge("[%s]:TEE_MACCompareFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - tlogi("[%s]:MCapareBck success\n", __func__); - return 0; -} - -int AEInitFwd(IntermediateReprestation *ir) -{ - ir->plainData.dataUsed = 0; - ir->cipherData.dataSize = ir->cipherData.dataMallocSize; - ir->cipherData.dataUsed = 0; - int ret = TEE_AEInit(ir->fwdOperaHandle, ir->nonce, ir->aeNonceLen, ir->aeTagLen, ir->aeAadLenInit, ir->dataSize); - if (ret != 0) { - tloge("[%s]:TEE_AEInit failed, ret = 0x%x\n", __func__, ret); - } - tlogi("[%s]:TEE_AEInit success\n", __func__); - return 0; -} - -int AEUpdateAadFwd(IntermediateReprestation *ir) -{ - TEE_AEUpdateAAD(ir->fwdOperaHandle, ir->pAad, ir->aeAadLen); - tlogi("[%s]:AEUpdateAadFwd success\n", __func__); - return 0; -} -enum { - MLT_UPDATE_COUNT = 3, -}; -int AEUpdateAadMtlFwd(IntermediateReprestation *ir) -{ - size_t slice = ir->aeAadLen / MLT_UPDATE_COUNT; - size_t used = 0; - size_t left = ir->aeAadLen; - size_t curAadLen = slice; - size_t i; - for (i = 0; i < MLT_UPDATE_COUNT; i++) { - curAadLen = (i == (MLT_UPDATE_COUNT - 1) ? left : slice); - TEE_AEUpdateAAD(ir->fwdOperaHandle, ir->pAad + used, curAadLen); - used += curAadLen; - left = ir->aeAadLen - used; - } - tlogi("[%s]:AEUpdateAadMtlFwd success\n", __func__); - return 0; -} - -int AEUpdateFwd(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - - void *pSrcData = ir->plainData.data + ir->plainData.dataUsed; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - size_t srcLen = (dataLeft >= ir->plainData.sliceSize) ? ir->plainData.sliceSize : 0; - void *pDestData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t destLen = ir->cipherData.dataSize - ir->cipherData.dataUsed; - int ret = TEE_AEUpdate(ir->fwdOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_AEUpdate failed\n", __func__); - return -1; - } - - ir->plainData.dataUsed += srcLen; - ir->cipherData.dataUsed += destLen; - - tlogi("[%s]:AEUpdateFwd success\n", __func__); - return 0; -} - -int AEUpdate0Fwd(IntermediateReprestation *ir) -{ - void *pSrcData = ir->plainData.data + ir->plainData.dataUsed; - size_t srcLen = 0; - void *pDestData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t destLen = ir->cipherData.dataSize - ir->cipherData.dataUsed; - int ret = TEE_AEUpdate(ir->fwdOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_AEUpdate failed\n", __func__); - return -1; - } - tlogi("[%s]:AEUpdate0Fwd success\n", __func__); - return 0; -} - -int AEEncFinalFwd(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = AEUpdateFwd(ir); - if (ret != 0) { - tloge("[%s]:AEUpdateFwd failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *srcData = ir->plainData.data + ir->plainData.dataUsed; - size_t srcLen = dataLeft; - void *destData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t destLen = ir->cipherData.dataSize - ir->cipherData.dataUsed; - void *tag = ir->aeTag; - size_t tagLen = ir->aeTagOSize; - ret = TEE_AEEncryptFinal(ir->fwdOperaHandle, srcData, srcLen, destData, - &destLen, tag, &tagLen); - if (ret != 0) { - tloge("[%s]:TEE_AEEncryptFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->cipherData.dataSize = ir->cipherData.dataUsed + destLen; - ir->aeTagOSize = tagLen; - tlogi("[%s]:AEEncFinalFwd success\n", __func__); - return 0; -} -int AEEncFinalOmtFwd(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - while (ir->plainData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->plainData.sliceSize) { - ret = AEUpdateFwd(ir); - if (ret != 0) { - tloge("[%s]:AEUpdateFwd failed\n", __func__); - return -1; - } - dataLeft = ir->plainData.dataSize - ir->plainData.dataUsed; - } - void *srcData = ir->plainData.data + ir->plainData.dataUsed; - size_t srcLen = dataLeft; - void *tag = ir->aeTag; - size_t tagLen = ir->aeTagOSize; - ret = TEE_AEEncryptFinal(ir->fwdOperaHandle, srcData, srcLen, NULL, - NULL, tag, &tagLen); - if (ret != 0) { - tloge("[%s]:TEE_AEEncryptFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->aeTagOSize = tagLen; - tlogi("[%s]:AEEncFinalOmtFwd success\n", __func__); - return 0; -} -int AEInitBck(IntermediateReprestation *ir) -{ - ir->cipherData.dataUsed = 0; - ir->decryptedData.dataSize = ir->decryptedData.dataMallocSize; - ir->decryptedData.dataUsed = 0; - int ret = TEE_AEInit(ir->bckOperaHandle, ir->nonce, ir->aeNonceLen, ir->aeTagLen, ir->aeAadLenInit, ir->dataSize); - if (ret != 0) { - tloge("[%s]:TEE_AEInit failed, ret = 0x%x\n", __func__, ret); - } - tlogi("[%s]:TEE_AEInit success\n", __func__); - return 0; -} - -int AEUpdateAadBck(IntermediateReprestation *ir) -{ - TEE_AEUpdateAAD(ir->bckOperaHandle, ir->pAad, ir->aeAadLen); - tlogi("[%s]:AEUpdateAadBck success\n", __func__); - return 0; -} - -int AEUpdateAadMtlBck(IntermediateReprestation *ir) -{ - size_t slice = ir->aeAadLen / MLT_UPDATE_COUNT; - size_t used = 0; - size_t left = ir->aeAadLen; - size_t curAadLen = slice; - size_t i; - for (i = 0; i < MLT_UPDATE_COUNT; i++) { - curAadLen = (i == (MLT_UPDATE_COUNT - 1) ? left : slice); - TEE_AEUpdateAAD(ir->bckOperaHandle, ir->pAad + used, curAadLen); - used += curAadLen; - left = ir->aeAadLen - used; - } - tlogi("[%s]:AEUpdateAadMtlBck success\n", __func__); - return 0; -} - -int AEUpdateBck(IntermediateReprestation *ir) -{ - if (ir->plainData.dataMode == DATA_MODE_WHOLE) { - tlogi("[%s]:dataMode is whole, not slice, just return.\n", __func__); - return 0; - } - void *pSrcData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - size_t srcLen = (dataLeft >= ir->cipherData.sliceSize) ? ir->cipherData.sliceSize : 0; - void *pDestData = ir->decryptedData.data + ir->decryptedData.dataUsed; - size_t destLen = ir->decryptedData.dataSize - ir->decryptedData.dataUsed; - int ret = TEE_AEUpdate(ir->bckOperaHandle, pSrcData, srcLen, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_AEUpdate failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->cipherData.dataUsed += srcLen; - ir->decryptedData.dataUsed += destLen; - tlogi("[%s]:AEUpdateBck success.\n", __func__); - return 0; -} - -int AEUpdate0Bck(IntermediateReprestation *ir) -{ - void *pDestData = ir->decryptedData.data + ir->decryptedData.dataUsed; - size_t destLen = ir->decryptedData.dataSize - ir->decryptedData.dataUsed; - int ret = TEE_AEUpdate(ir->bckOperaHandle, NULL, 0, pDestData, &destLen); - if (ret != 0) { - tloge("[%s]:TEE_AEUpdate failed, ret = 0x%x\n", __func__, ret); - return ret; - } - - tlogi("[%s]:AEUpdate0Bck success.\n", __func__); - return 0; -} - -int AEDoFinalBck(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - while (ir->cipherData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->cipherData.sliceSize) { - ret = AEUpdateBck(ir); - if (ret != 0) { - tloge("[%s]:AEUpdateBck failed\n", __func__); - return -1; - } - dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - } - void *srcData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t srcLen = dataLeft; - void *destData = ir->decryptedData.data + ir->decryptedData.dataUsed; - size_t destLen = ir->decryptedData.dataSize - ir->decryptedData.dataUsed; - void *tag = ir->aeTag; - size_t tagLen = ir->aeTagOSize; - ret = TEE_AEDecryptFinal(ir->bckOperaHandle, srcData, srcLen, destData, &destLen, tag, tagLen); - if (ret != 0) { - tloge("[%s]:TEE_AEDecryptFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - ir->decryptedData.dataSize = ir->decryptedData.dataUsed + destLen; - tlogi("[%s]:TEE_AEDecryptFinal success\n", __func__); - - if (TEE_MemCompare((void *)ir->plainData.data, - (void *)ir->decryptedData.data, - (size_t)ir->plainData.dataSize)) { - tloge("[%s]:TEE_MemCompare failed\n", __func__); - return -1; - } - tlogi("[%s]:AEDoFinalBck success\n", __func__); - return 0; -} - -int AEDoFinalOmtBck(IntermediateReprestation *ir) -{ - int ret; - size_t dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - while (ir->cipherData.dataMode != DATA_MODE_WHOLE && - dataLeft > ir->cipherData.sliceSize) { - ret = AEUpdateBck(ir); - if (ret != 0) { - tloge("[%s]:AEUpdateBck failed\n", __func__); - return -1; - } - dataLeft = ir->cipherData.dataSize - ir->cipherData.dataUsed; - } - void *srcData = ir->cipherData.data + ir->cipherData.dataUsed; - size_t srcLen = dataLeft; - size_t destLen; - destLen = 0; - void *tag = ir->aeTag; - size_t tagLen = ir->aeTagOSize; - ret = TEE_AEDecryptFinal(ir->bckOperaHandle, srcData, srcLen, NULL, &destLen, tag, tagLen); - if (ret != 0) { - tloge("[%s]:TEE_AEDecryptFinal failed, ret = 0x%x\n", __func__, ret); - return ret; - } - - tlogi("[%s]:AEDoFinalOmtBck success\n", __func__); - return 0; -} -static uint32_t g_mgfList[RSA_ENCYPT_MGF_COUNT] = { - TEE_DH_HASH_SHA1_mode, TEE_DH_HASH_SHA1_mode, - TEE_DH_HASH_SHA224_mode, TEE_DH_HASH_SHA256_mode, - TEE_DH_HASH_SHA384_mode, TEE_DH_HASH_SHA512_mode, -}; -int ASEncryFwd(IntermediateReprestation *ir) -{ - ir->plainData.dataUsed = 0; - ir->cipherData.dataSize = ir->cipherData.dataMallocSize; - ir->cipherData.dataUsed = 0; - - TEE_Attribute attr = { - .attributeID = TEE_ATTR_RSA_MGF1_HASH, - .content = { - .value = { - .a = g_mgfList[ir->rsaEnMgf1Hash % RSA_ENCYPT_MGF_COUNT], - .b = 0, - }, - }, - }; - TEE_Attribute *params = (ir->rsaEnMgf1Hash == RSA_ENCRYPT_MGF_DEF) ? NULL : &attr; - uint32_t paramCount = (ir->rsaEnMgf1Hash == RSA_ENCRYPT_MGF_DEF) ? 0 : 1; - - memset_s(ir->plainData.data, ir->plainData.dataSize, 0, 1); - int ret = TEE_AsymmetricEncrypt(ir->fwdOperaHandle, (const TEE_Attribute *)params, paramCount, - ir->plainData.data, ir->plainData.dataSize, ir->cipherData.data, &(ir->cipherData.dataSize)); - if (ret != 0) { - tloge("[%]:TEE_AsymmetricEncrypt failed\n", __func__); - return -1; - } - - tlogi("[%s]:ASEncryFwd success\n", __func__); - return 0; -} - -int ASDecryBck(IntermediateReprestation *ir) -{ - ir->cipherData.dataUsed = 0; - ir->decryptedData.dataSize = ir->decryptedData.dataMallocSize; - ir->decryptedData.dataUsed = 0; - - TEE_Attribute attr = { - .attributeID = TEE_ATTR_RSA_MGF1_HASH, - .content = { - .value = { - .a = g_mgfList[ir->rsaEnMgf1Hash % RSA_ENCYPT_MGF_COUNT], - .b = 0, - }, - }, - }; - TEE_Attribute *params = (ir->rsaEnMgf1Hash == RSA_ENCRYPT_MGF_DEF) ? NULL : &attr; - uint32_t paramCount = (ir->rsaEnMgf1Hash == RSA_ENCRYPT_MGF_DEF) ? 0 : 1; - - int ret = TEE_AsymmetricDecrypt(ir->bckOperaHandle, (const TEE_Attribute *)params, paramCount, - (void *)ir->cipherData.data, ir->cipherData.dataSize, - (void *)ir->decryptedData.data, &(ir->decryptedData.dataSize)); - if (ret != 0) { - tloge("[%s]:TEE_AsymmetricDecrypt failed\n", __func__); - return -1; - } - tlogi("[%s]:TEE_AsymmetricDecrypt success\n", __func__); - - if (ir->plainData.dataSize != ir->decryptedData.dataSize) { - tloge("[%s]:ir->plainData.dataSize %u != ir->decryptedData.dataSize %u\n", - __func__, ir->plainData.dataSize, ir->decryptedData.dataSize); - return -1; - } - tlogi("[%s]:plainSize == decryptSize\n", __func__); - - if (TEE_MemCompare((void *)ir->plainData.data, - (void *)ir->decryptedData.data, - (size_t)ir->plainData.dataSize)) { - tloge("[%s]:TEE_MemCompare failed\n", __func__); - return -1; - } - - tlogi("[%s]:ASDecryBck success\n", __func__); - return 0; -} - -int ASSignFwd(IntermediateReprestation *ir) -{ - ir->plainData.dataUsed = 0; - ir->cipherData.dataSize = ir->cipherData.dataMallocSize; - ir->cipherData.dataUsed = 0; - - TEE_Attribute attr = { - .attributeID = TEE_ATTR_RSA_PSS_SALT_LENGTH, - .content = { - .value = { - .a = ir->rsaSgPssLen, - .b = 0, - }, - }, - }; - TEE_Attribute *params = (ir->rsaSgPssLen == 0) ? NULL : &attr; - uint32_t paramCount = (ir->rsaSgPssLen == 0) ? 0 : 1; - int ret = TEE_AsymmetricSignDigest(ir->fwdOperaHandle, (const TEE_Attribute *)params, paramCount, - (void *)ir->plainData.data, ir->plainData.dataSize, - (void *)ir->cipherData.data, &(ir->cipherData.dataSize)); - if (ret != 0) { - tloge("[%s]:TEE_AsymmetricSignDigest failed\n", __func__); - return -1; - } - - tlogi("[%s]:ASSignFwd success\n", __func__); - return 0; -} - -int ASVerifyBck(IntermediateReprestation *ir) -{ - TEE_Attribute attr = { - .attributeID = TEE_ATTR_RSA_PSS_SALT_LENGTH, - .content = { - .value = { - .a = ir->rsaSgPssLen, - .b = 0, - }, - }, - }; - TEE_Attribute *params = (ir->rsaSgPssLen == 0) ? NULL : &attr; - uint32_t paramCount = (ir->rsaSgPssLen == 0) ? 0 : 1; - int ret = TEE_AsymmetricVerifyDigest(ir->bckOperaHandle, (const TEE_Attribute *)params, paramCount, - (void *)ir->plainData.data, ir->plainData.dataSize, - (void *)ir->cipherData.data, ir->cipherData.dataSize); - if (ret != 0) { - tloge("[%s]:TEE_AsymmetricVerifyDigest failed\n", __func__); - return -1; - } - - tlogi("[%s]:ASVerifyBck success\n", __func__); - return 0; -} - -int DRDeriveFwd(IntermediateReprestation *ir) -{ - ir->cipherData.dataSize = ir->cipherData.dataMallocSize; - - TEE_ObjectHandle derivedKey = NULL; - int ret = TEE_AllocateTransientObject(TEE_TYPE_GENERIC_SECRET, 2048, &derivedKey); - if (ret != 0) { - tloge("[%s]:TEE_AllocateTransientObject TEE_TYPE_GENERIC_SECRET failed\n", __func__); - return -1; - } - tlogi("[%s]:TEE_AllocateTransientObject TEE_TYPE_GENERIC_SECRET success\n", __func__); - - TEE_Attribute *pParams = (ir->tki->keyObjList[1])->Attribute; - uint32_t paramCount = (ir->tki->keyObjList[1])->attributesLen; - TEE_DeriveKey(ir->fwdOperaHandle, pParams, paramCount, derivedKey); - - uint8_t *pTmp = TEE_Malloc(derivedKey->Attribute[0].content.ref.length, 0); - if (pTmp == NULL) { - tloge("[%s]:malloc failed\n", __func__); - TEE_FreeTransientObject(derivedKey); - return -1; - } - if (!TEE_MemCompare(pTmp, derivedKey->Attribute[0].content.ref.buffer, - derivedKey->Attribute[0].content.ref.length)) { - tloge("[%s]:derived key is invalid\n", __func__); - TEE_Free(pTmp); - TEE_FreeTransientObject(derivedKey); - return -1; - } - TEE_Free(pTmp); - - if (ir->cipherData.dataSize < derivedKey->Attribute[0].content.ref.length) { - tloge("[%s]:invalid cipherData size %u\n", __func__, ir->cipherData.dataSize); - TEE_FreeTransientObject(derivedKey); - return -1; - } - - TEE_MemMove(ir->cipherData.data, - derivedKey->Attribute[0].content.ref.buffer, - derivedKey->Attribute[0].content.ref.length); - ir->cipherData.dataSize = derivedKey->Attribute[0].content.ref.length; - TEE_FreeTransientObject(derivedKey); - - tlogi("[%s]:DRDeriveFwd success\n", __func__); - return 0; -} - -int DRDeriveBck(IntermediateReprestation *ir) -{ - TEE_ObjectHandle derivedKey = NULL; - int ret = TEE_AllocateTransientObject(TEE_TYPE_GENERIC_SECRET, 2048, &derivedKey); - if (ret != 0) { - tloge("[%s]:TEE_AllocateTransientObject TEE_TYPE_GENERIC_SECRET failed\n", __func__); - return -1; - } - tlogi("[%s]:TEE_AllocateTransientObject TEE_TYPE_GENERIC_SECRET success\n", __func__); - - TEE_Attribute *pParams = (ir->tki->keyObjList[0])->Attribute; - uint32_t paramCount = (ir->tki->keyObjList[0])->attributesLen; - TEE_DeriveKey(ir->bckOperaHandle, pParams, paramCount, derivedKey); - - if (ir->cipherData.dataSize != derivedKey->Attribute[0].content.ref.length) { - tloge("[%s]:derive key length not same\n", __func__); - return -1; - } - if (TEE_MemCompare(ir->cipherData.data, derivedKey->Attribute[0].content.ref.buffer, - derivedKey->Attribute[0].content.ref.length)) { - tloge("[%s]:fwd and bck derived key is not same\n", __func__); - TEE_FreeTransientObject(derivedKey); - return -1; - } - TEE_FreeTransientObject(derivedKey); - - tlogi("[%s]:DRDeriveBck success\n", __func__); - return 0; -} diff --git a/test/xts/ta/test_crypto_api/src/monad/monad_inverse_map.c b/test/xts/ta/test_crypto_api/src/monad/monad_inverse_map.c deleted file mode 100644 index 8198f89c..00000000 --- a/test/xts/ta/test_crypto_api/src/monad/monad_inverse_map.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "string.h" -#include "tee_crypto_api.h" -#include "test_crypto_data.h" -#include "monad.h" -#include "securec.h" -#include "tee_log.h" - -static MonadReversibilityProperty g_groupReverseList[] = { - { - .elementName = "IRSetUp", - .element = IRSetUp, - .inverseElementName = "IRTearDown", - .inverseElement = IRTearDown, - .isBalanced = 0, - }, - { - .elementName = "GlbAlloc", - .element = GlbAlloc, - .inverseElementName = "GlbFree", - .inverseElement = GlbFree, - .isBalanced = 0, - }, -}; - -static uint32_t g_groupReverseListSize = (uint32_t)(sizeof(g_groupReverseList) / sizeof(g_groupReverseList[0])); - -int CopyReversElementList(MonadReversibilityProperty *dest, uint32_t *destSize) -{ - if (*destSize < g_groupReverseListSize) { - tloge("[%s]:destSize = %u < g_groupReverseListSize = %u\n", __func__, - *destSize, g_groupReverseListSize); - return -1; - } - - uint32_t i; - for (i = 0; i < g_groupReverseListSize; i++) { - dest[i].element = g_groupReverseList[i].element; - dest[i].elementName = g_groupReverseList[i].elementName; - dest[i].inverseElement = g_groupReverseList[i].inverseElement; - dest[i].inverseElementName = g_groupReverseList[i].inverseElementName; - dest[i].isBalanced = g_groupReverseList[i].isBalanced; - } - *destSize = g_groupReverseListSize; - - tlogi("[%s]:CopyReversElementList success\n", __func__); - return 0; -} - -int DisbalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType element) -{ - uint32_t i; - MonadReversibilityProperty *find = NULL; - for (i = 0; i < listSize; i++) { - if (list[i].element == element) { - find = &(list[i]); - break; - } - } - - if (find == NULL) { - tloge("[%s]:could not find inverse elment\n", __func__); - return -1; - } - tlogi("[%s]:find element dual %s -> %s\n", __func__, find->elementName, find->inverseElementName); - - find->isBalanced = GRUPP_NOT_BALANCED; - - tlogi("[%s]:DisbalanceGroupElement success\n", __func__); - return 0; -} - -int BalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType inverseElement) -{ - uint32_t i; - MonadReversibilityProperty *find = NULL; - for (i = 0; i < listSize; i++) { - if (list[i].inverseElement == inverseElement) { - find = &(list[i]); - break; - } - } - if (find == NULL) { - tloge("[%s]:could not find inverse elment\n", __func__); - return -1; - } - tlogi("[%s]:find element dual %s -> %s\n", __func__, find->elementName, find->inverseElementName); - - find->isBalanced = GROUP_BALANCED; - - tlogi("[%s]:BalanceGroupElement success\n", __func__); - return 0; -} - -int BalanceGroupElementList(IntermediateReprestation *ir) -{ - MonadReversibilityProperty *list = ir->mrpl; - uint32_t listSize = ir->mrplSize; - - uint32_t i; - for (i = 0; i < listSize; i++) { - if (list[i].isBalanced == GRUPP_NOT_BALANCED) { - int ret = list[i].inverseElement(ir); - if (ret != 0) { - tloge("[%s]:inverse element %s (<- element %s) excute failed\n", __func__, - list[i].inverseElementName, list[i].elementName); - return -1; - } - tlogi("[%s]:inverse element %s (<- element %s) excute success\n", __func__, - list[i].inverseElementName, list[i].elementName); - } else { - tlogi("[%s]:inverse element %s (<- element %s) is balanced, just return.\n", __func__, - list[i].inverseElementName, list[i].elementName); - } - } - - tlogi("[%s]:BalanceGroupElementList success\n", __func__); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_crypto_api/src/monad/monad_run.c b/test/xts/ta/test_crypto_api/src/monad/monad_run.c deleted file mode 100644 index 626863ec..00000000 --- a/test/xts/ta/test_crypto_api/src/monad/monad_run.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "securec.h" -#include "tee_log.h" -#include "tee_crypto_api.h" -#include "test_crypto_data.h" -#include "test_crypto_api_types.h" -#include "monad.h" - -int MonadSetup2(TestVector *tv, IntermediateReprestation *ir) -{ - (void)ir; - ir->tv = tv; - ir->mrplSize = MONAD_REVERSE_PROP_LIST_SIZE; - int ret = CopyReversElementList(ir->mrpl, &(ir->mrplSize)); - if (ret != 0) { - tloge("[%s]:CopyReversElementList failed\n", __func__); - return -1; - } - - tlogi("[%s]:MonadSetup2 success\n", __func__); - return 0; -} - -static int CheckExpResult2(int realRet, int tvExpRet, const char *info) -{ - if ((tvExpRet != 0) && realRet == 0) { - tloge("[%s]:expect fail, but pass. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return -1; - } else if ((tvExpRet == 0) && realRet != 0) { - tloge("[%s]:expect pass, but fail. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return -1; - } else if ((tvExpRet != 0) && realRet != 0) { - tlogi("[%s]:expect fail, and fail. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return 0; - } else if ((tvExpRet == 0) && realRet == 0) { - tlogi("[%s]:expect pass, and pass. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return 0; - } - return 0; -} - -int MonadTearDown(IntermediateReprestation *ir) -{ - int ret = BalanceGroupElementList(ir); - if (ret != 0) { - tloge("[%s]:BalanceGroupElementList failed\n", __func__); - return -1; - } - - tlogi("[%s]:MonadTearDown success\n", __func__); - return 0; -} - -int MonadRun2(TestVector *tv) -{ - IntermediateReprestation ir; - int ret = memset_s((void *)&ir, sizeof(IntermediateReprestation), 0, sizeof(IntermediateReprestation)); - if (ret != EOK) { - tloge("[%s]:memset_s failed\n", __func__); - return -1; - } - - ret = MonadSetup2(tv, &ir); - if (ret != 0) { - tloge("[%s]:MonadSetup2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadSetup2 success\n", __func__); - - int checkResult; - uint32_t i; - for (i = 0; i < tv->actionsSize; i++) { - ret = tv->actions[i](&ir); - if (ret != 0) { - tloge("[%s]:%uth action excute failed, break pipeline.\n", __func__, i); - break; - } - } - - checkResult = CheckExpResult2(ret, tv->expRet, __func__); - if (checkResult != 0) { - tloge("[%s]:CheckExpResult failed at %dth act in of seq.\n", __func__, i); - } - - ret = MonadTearDown(&ir); - if (ret != 0) { - tloge("[%s]:MonadTearDown sucess\n", __func__); - return -1; - } - tlogi("[%s]:MonadTearDown sucess\n", __func__); - - return checkResult; -} diff --git a/test/xts/ta/test_crypto_api/src/oh_crypto_entry.c b/test/xts/ta/test_crypto_api/src/oh_crypto_entry.c deleted file mode 100644 index 59713fa1..00000000 --- a/test/xts/ta/test_crypto_api/src/oh_crypto_entry.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "tee_ext_api.h" -#include "cases_entry.h" - -#define SYSTEM_OH_CRYPTO "/system/bin/tee_test_crypto_api" -#define VENDOR_OH_CRYPTO "/vendor/bin/tee_test_crypto_api" -#define CRYPTO_UID 0 - -// TA_INVOKE_CMD -enum { - CMD_RUN_BY_FUN_SEQ = 0, -}; - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("%s:start add caller info success\n", __func__); - TEE_Result ret; - ret = AddCaller_CA_exec(VENDOR_OH_CRYPTO, CRYPTO_UID); - if (ret != TEE_SUCCESS) - return ret; - ret = AddCaller_CA_exec(SYSTEM_OH_CRYPTO, CRYPTO_UID); - if (ret != TEE_SUCCESS) - return ret; - tlogi("%s:end add caller info success\n", __func__); - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t paramTypes, TEE_Param params[4], void **sessionContext) -{ - (void)paramTypes; - (void)params; - (void)sessionContext; - tlogi("in %s\n", __func__); - return TEE_SUCCESS; -} - -TEE_Result TA_InvokeCommandEntryPoint(void *session_context, uint32_t cmd_id, uint32_t paramTypes, TEE_Param params[4]) -{ - (void)session_context; - // check params - if (!check_param_type(paramTypes, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - tloge("%s:error, invalid param_types\n", __func__); - return TEE_ERROR_BAD_PARAMETERS; - } - tlogi("%s:cmd_id is %d\n", __func__, cmd_id); - int ret; - switch (cmd_id) { - case CMD_RUN_BY_FUN_SEQ: { - ret = RunCaseEntryByName((const char *)params[0].memref.buffer, 1, 0); - if (ret != 0) { - tloge("[%s]:RunCaseEntryByName fail\n", __func__); - return -1; - } - tlogi("[%s]:RunCaseEntryByName success\n", __func__); - return 0; - } - default: - return 0; - } -} - -void TA_CloseSessionEntryPoint(void *session_context) -{ - (void)session_context; - tlogi("in %s.\n", __func__); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("in %s.\n", __func__); -} diff --git a/test/xts/ta/test_crypto_api/src/test_crypto_api_types.h b/test/xts/ta/test_crypto_api/src/test_crypto_api_types.h deleted file mode 100644 index 443d6be4..00000000 --- a/test/xts/ta/test_crypto_api/src/test_crypto_api_types.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef TEST_CRYPTO_API_TYPES_H -#define TEST_CRYPTO_API_TYPES_H -#include "tee_trusted_storage_api.h" -#include "stddef.h" -#include "tee_crypto_api.h" -#include "tee_log.h" - -enum { - DATA_MODE_WHOLE = 0, - DATA_MODE_SLICE = 1, -}; - -#define DATA_EXPAND_SIZE 1024 -#define AE_TAG_MAX_SIZE 64 -#define MAX_STRING_NAME_LEN 100 - -typedef struct { - uint32_t dataMode; - void *data; - size_t dataMallocSize; - size_t dataSize; - size_t dataUsed; - size_t sliceSize; - uint8_t aeTag[AE_TAG_MAX_SIZE]; - size_t aeTagSize; -} ProcessInOutData; - -struct _IntermediateReprestation; -typedef int (*ActionEntryType)(struct _IntermediateReprestation *ir); -#define MAX_ACTIONS_SIZE 100 -typedef struct { - // common test vector - char algName[MAX_STRING_NAME_LEN]; // ae, asymEn, asymSg, derive, digest, symEn, mac, - size_t operaMaxKeySize; // ae, asymEn, asymSg, derive, symEn, mac, - size_t keySize; // ae, asymEn, asymSg, derive, symEn, mac, - char fwdKeyTypeName[MAX_STRING_NAME_LEN]; // ae, asymEn, asymSg, derive, symEn, mac, - char bckKeyTypeName[MAX_STRING_NAME_LEN]; // asymEn, asymSg, derive, mac, - uint32_t fwdEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac, - uint32_t bckEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac, - size_t dataSize; // ae, asymEn, asymSg, derive, digest, symEn, mac, - size_t sliceSize; // ae, asymEn, asymSg, derive, digest, symEn, mac, - uint32_t expRet; // ae, asymEn, asymSg, derive, digest, symEn, mac, - size_t ivLen; // symEn, mac, - - // ae test vector - size_t aeTagLen; // ae, - size_t aeTagOSize; // ae, - size_t aeNonceLen; // ae, - uint8_t nonceByte; // ae, - size_t aeAadLenInit; // aes-ccm, - size_t aeAadLen; // ae, - uint8_t aadByte; // ae, - - // asym encrypt test vector - uint32_t rsaEnMgf1Hash; // asymEn, - - // asym sign test vector - uint32_t rsaSgPssLen; // asymSg, - - // ecc key gen nist - uint32_t ecKeyCurve; // asymEn, asymSg, derive, - // rsa key gen pub exp id - uint32_t rsaGenPubExpId; // asymEn, asymSg, - // dh key gen base prime xbits - uint32_t dhGenKeySize; // derive, - // common action sequence - ActionEntryType actions[MAX_ACTIONS_SIZE]; // ae, asymEn, asymSg, derive, digest, symEn, mac, - uint32_t actionsSize; // ae, asymEn, asymSg, derive, digest, symEn, mac, -} TestVector; - -enum { - ER_OK = 0, - ER_JF = 1, -}; - -#define MAX_ACT_SEQ_LIST_SIZE 100 - -typedef struct { - char algName[MAX_STRING_NAME_LEN]; - uint32_t algValue; - uint32_t fwdMode; - uint32_t bckMode; - uint32_t operaKeyCount; - uint32_t needKeyCount; - uint32_t isSwitchFwdBckOperaKey; - char algOperaClassName[MAX_STRING_NAME_LEN]; - uint32_t algOperaClassValue; -} AlgMapInfo; -enum { - NEED_NO_GEN_PARAMS = 0, - NEED_GEN_ECC_CURVE = 1, - NEED_DH_BASE_PRIME_XBITS = 2, - NEED_RSA_EXP_MAYBE = 3, -}; -typedef struct { - uint8_t keyTypeName[MAX_STRING_NAME_LEN]; - uint32_t keyType; - uint32_t keyGenType; - uint32_t needGenParams; -} KeyTypeMapInfo; - -enum { - XTS_KEY_COUNT_TWO = 2, -}; - -enum { - GROUP_BALANCED = 0, - GRUPP_NOT_BALANCED = 1, -}; -typedef struct { - char *elementName; - ActionEntryType element; - char *inverseElementName; - ActionEntryType inverseElement; - uint32_t isBalanced; -} MonadReversibilityProperty; -#define MONAD_REVERSE_PROP_LIST_SIZE 100 -#define AE_NONCE_BUFFER_SIZE 32 -#define AE_TAG_BUFFER_SIZE 32 -#define MAX_KEY_OBJECT_HANDLE_LIST_SIZE 2 -#define MAX_TEST_KEY_ITEM_LIST_SIZE 100 -typedef struct { - uint32_t keyType; - uint32_t keySize; - TEE_ObjectHandle keyObjList[MAX_KEY_OBJECT_HANDLE_LIST_SIZE]; - size_t keyObjListSize; -} TestKeyItem; - -typedef struct _IntermediateReprestation { - // input factor space - TestVector *tv; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - // inner state factor space - AlgMapInfo *algMap; // ae, asymEn, asymSg, derive, digest, symEn, mac, - KeyTypeMapInfo *fwdKeyMap; // ae, asymEn, asymSg, derive, symEn, mac, - KeyTypeMapInfo *bckKeyMap; // ae, asymEn, asymSg, derive, symEn, mac, - - // common factor - uint32_t algValue; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - uint32_t algOperaClassValue; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - uint32_t fwdMode; // ae, asymEn, asymSg, derive, digest, symEn, mac, - uint32_t bckMode; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - uint32_t operaKeyCount; // ae, asymEn, asymSg, derive, symEn, mac, - uint32_t needKeyCount; // ae, asymEn, asymSg, derive, symEn, mac, - uint32_t isSwitchFwdBckOperaKey; // ae, asymEn, asymSg, derive, symEn, mac, - - size_t operaMaxKeySize; // ae, asymEn, asymSg, derive, symEn, mac, - size_t keySize; // ae, asymEn, asymSg, derive, symEn, mac, - - uint32_t fwdKeyType; // ae, asymEn, asymSg, derive, symEn, mac, - uint32_t bckKeyType; // ae, asymEn, asymSg, derive, symEn, mac, - uint32_t genKeyType; // ae, asymEn, asymSg, derive, symEn, mac, - - uint32_t dataSize; // ae, asymEn, asymSg, derive, digest, symEn, mac, - uint32_t sliceSize; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - size_t ivLen; // digest, symEn, mac, - - size_t aeNonceLen; // ae, - uint8_t nonceByte; // ae, - uint8_t nonce[AE_NONCE_BUFFER_SIZE]; // ae, - size_t aeTagLen; // ae, - size_t aeTagOSize; // ae, - uint8_t aeTag[AE_TAG_BUFFER_SIZE]; // ae, - size_t aeAadLenInit; // aes-ccm, - size_t aeAadLen; // ae, - uint8_t aadByte; // ae, - uint8_t *pAad; // ae, - - size_t rsaEnMgf1Hash; // asymEn, - size_t rsaSgPssLen; // asymSg, - - uint32_t fwdEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac, - uint32_t bckEngine; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - uint32_t tvExpRet; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - ProcessInOutData plainData; // ae, asymEn, asymSg, derive, digest, symEn, mac, - ProcessInOutData cipherData; // ae, asymEn, asymSg, derive, digest, symEn, mac, - ProcessInOutData decryptedData; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - TEE_OperationHandle fwdOperaHandle; // ae, asymEn, asymSg, derive, digest, symEn, mac, - TEE_OperationHandle bckOperaHandle; // ae, asymEn, asymSg, derive, digest, symEn, mac, - - TestKeyItem *tki; // derive, - // ecc key gen nist - uint32_t ecKeyCurve; // asymEn, asymSg, derive, - // rsa key gen pub exp id - uint32_t rsaGenPubExpId; // asymEn, asymSg, - // dh key gen base prime xbits - uint32_t dhGenKeySize; // derive, - - MonadReversibilityProperty mrpl[MONAD_REVERSE_PROP_LIST_SIZE]; - uint32_t mrplSize; -} IntermediateReprestation; - -enum { - ERROR_OK = 0, -}; - -enum { - USE_DX = 0, // 使用DX引擎 - USE_SW = 1, // 使用SW软引擎 - USE_EP = 2, // 使用EPS引擎 - USE_SE = 3, // 使用SEC引擎 - USE_DF = 4, // 使用默认引擎 -}; - -typedef enum { - RSA_ENCRYPT_MGF_DEF = 0, - RSA_ENCYPT_MGF_SHA1 = 1, // TEE_DH_HASH_SHA1_mode = 0 - RSA_ENCYPT_MGF_SHA224 = 2, // TEE_DH_HASH_SHA224_mode = 1, - RSA_ENCYPT_MGF_SHA256 = 3, // TEE_DH_HASH_SHA256_mode = 2, - RSA_ENCYPT_MGF_SHA384 = 4, // TEE_DH_HASH_SHA384_mode = 3, - RSA_ENCYPT_MGF_SHA512 = 5, // TEE_DH_HASH_SHA512_mode = 4, - RSA_ENCYPT_MGF_COUNT, -} RsaEncryptMgfType; - -typedef enum { - TST_ECC_CURVE_NIST_NONE = 0, - TST_ECC_CURVE_NIST_P192 = 1, - TST_ECC_CURVE_NIST_P224 = 2, - TST_ECC_CURVE_NIST_P256 = 3, - TST_ECC_CURVE_NIST_P384 = 4, - TST_ECC_CURVE_NIST_P521 = 5, - TST_ECC_CURVE_SM2 = 6, - TST_ECC_CURVE_25519 = 7, - TST_ECC_CURVE_COUNT = 8, -} EccKeyGenCurve; - -enum { - TST_RSA_KEYGEN_PUB_EXP_ID_NULL = 0, - TST_RSA_KEYGEN_PUB_EXP_ID_0 = 1, - TST_RSA_KEYGEN_PUB_EXP_ID_1 = 2, - TST_RSA_KEYGEN_PUB_EXP_ID_2 = 3, - TST_RSA_KEYGEN_PUB_EXP_ID_3 = 4, - TST_RSA_KEYGEN_PUB_EXP_ID_4 = 5, -}; - -#endif // end TEST_CRYPTO_API_TYPES_H diff --git a/test/xts/ta/test_driver_ta/CMakeLists.txt b/test/xts/ta/test_driver_ta/CMakeLists.txt deleted file mode 100644 index 05530505..00000000 --- a/test/xts/ta/test_driver_ta/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(ta_sources) - -list(APPEND ta_sources - src/drvcaller_test.c -) - -list(APPEND header_dir - include -) - -ta_compile_pub( - ELF_NAME - drvcaller_test.elf - - SRC_LIST - ${ta_sources} - - INCLUDE_DIRS - ${header_dir} - - COMPILE_OPTS - COMPILE_DEFS -) diff --git a/test/xts/ta/test_driver_ta/drv_test_module.csv b/test/xts/ta/test_driver_ta/drv_test_module.csv deleted file mode 100644 index fb621377..00000000 --- a/test/xts/ta/test_driver_ta/drv_test_module.csv +++ /dev/null @@ -1,22 +0,0 @@ -perm1,1 -perm2,2 -perm3,3 -perm4,4 -perm5,5 -perm6,6 -perm7,7 -perm8,8 -perm9,9 -perm10,10 -iomap_perm,11 -SHARE_BUFFER_TEST_ID,0x10 -ARGS_TEST_ID,0x11 -BUFFER_TEST_ID,0x12 -RETURN_EXCEPTION_ID,0x13 -SLEEP_TEST_ID,0x14 -MAX_BUFFER_TEST_ID,0x15 -CRASH_TEST_ID,0x16 -NO_PARAM_TEST_ID,0x17 -CALL_OTHER_DRV_TEST_ID,0x18 -STRING_TEST_ID,0x19 -IOMAP_TEST_ID,0x1a diff --git a/test/xts/ta/test_driver_ta/dyn_perm.xml b/test/xts/ta/test_driver_ta/dyn_perm.xml deleted file mode 100644 index fdf3c34e..00000000 --- a/test/xts/ta/test_driver_ta/dyn_perm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/test/xts/ta/test_driver_ta/manifest.txt b/test/xts/ta/test_driver_ta/manifest.txt deleted file mode 100644 index 55bd45ca..00000000 --- a/test/xts/ta/test_driver_ta/manifest.txt +++ /dev/null @@ -1,5 +0,0 @@ -gpd.ta.appID: 534D4152-542D-4353-b919-d3016a171fc9 -gpd.ta.service_name: drvcaller_test -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 1048576 -gpd.ta.stackSize: 8192 diff --git a/test/xts/ta/test_driver_ta/src/drvcaller_test.c b/test/xts/ta/test_driver_ta/src/drvcaller_test.c deleted file mode 100644 index 5e0858ab..00000000 --- a/test/xts/ta/test_driver_ta/src/drvcaller_test.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define CA_PKGN_VENDOR "/vendor/bin/tee_test_drv" -#define CA_PKGN_SYSTEM "/system/bin/tee_test_drv" -#define CA_UID 0 - -#define DRV_UUID1 \ - { \ - 0x11112222, 0x0000, 0x0000, \ - { \ - 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 \ - } \ - } - -#define BUFFER_SIZE 1024 -struct share_buffer_arg { - uint64_t addr; - uint32_t len; - uint32_t share_token; -}; - -static TEE_Result TeeTestDrive(uint32_t cmd) -{ - int ret; - const char *drvName = "drv_test_module"; - uint32_t args = (uint32_t)(&drvName); - const char drvcallerInput[] = "the param is drvcaller_input"; - char drvOutput[] = "DRVMEM_OUTPUT"; - - uint32_t drvcallerInputLen = (uint32_t)strlen(drvcallerInput) + 1; - uint32_t drvOutputLen = (uint32_t)strlen(drvOutput) + 1; - TEE_UUID uuid = DRV_UUID1; - - int64_t fd = tee_drv_open(drvName, &args, sizeof(args)); - if (fd <= 0) { - tloge("open %s for get fd failed\n", drvName); - return TEE_ERROR_GENERIC; - } - - char *tempBuffer = alloc_sharemem_aux(&uuid, BUFFER_SIZE); - if (tempBuffer == NULL) { - tloge("alloc share mem failed\n"); - return TEE_ERROR_GENERIC; - } - (void)memset_s(tempBuffer, BUFFER_SIZE, 0x0, BUFFER_SIZE); - ret = strcpy_s(tempBuffer, drvcallerInputLen, drvcallerInput); - if (ret != 0) { - tloge("strcpy_s failed,ret = 0x%x\n", ret); - return TEE_ERROR_GENERIC; - } - - struct share_buffer_arg inputArg = { 0 }; -#ifndef __aarch64__ - inputArg.addr = (uint64_t)(uint32_t)tempBuffer; -#else - inputArg.addr = (uint64_t)tempBuffer; -#endif - - inputArg.len = BUFFER_SIZE; - - tlogi("%s drv test ioctl begin args:0x%x fd:%d\n", drvName, inputArg, (int32_t)fd); - - ret = (int)tee_drv_ioctl(fd, cmd, (const void *)(&inputArg), sizeof(inputArg)); - if (ret != 0) { - tloge("%s drv test ioctl failed, fd:%d \n", drvName, (int32_t)fd); - } - if (cmd == DRVTEST_COMMAND_COPYTOCLIENT) { - if (strncmp(drvOutput, (char *)tempBuffer, drvOutputLen) != 0) { - tloge("%s drv copy_to_client test failed, fd:%d, heap_buffer is:%s \n", drvName, (int32_t)fd, tempBuffer); - free_sharemem(tempBuffer, BUFFER_SIZE); - return TEE_ERROR_GENERIC; - } - } - - ret |= (int)tee_drv_close(fd); - if (ret != 0) { - tloge("drv test fail!\n"); - } - - if (free_sharemem(tempBuffer, BUFFER_SIZE) != 0) { - tloge("free sharemem failed\n"); - ret = -1; - } - return (TEE_Result)ret; -} - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("---- TA_CreateEntryPoint ----------- \n"); - TEE_Result ret; - - ret = AddCaller_CA_exec(CA_PKGN_VENDOR, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("add caller failed, ret: 0x%x", ret); - return ret; - } - - ret = AddCaller_CA_exec(CA_PKGN_SYSTEM, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("add caller failed, ret: 0x%x", ret); - return ret; - } - - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext) -{ - (void)parmType; - (void)sessionContext; - tlogi("---- TA_OpenSessionEntryPoint -------- \n"); - if (params[0].value.b == 0xFFFFFFFE) - return TEE_ERROR_GENERIC; - else - return TEE_SUCCESS; -} - -TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmd, uint32_t parmType, TEE_Param params[4]) -{ - TEE_Result ret = TEE_SUCCESS; - (void)sessionContext; - (void)parmType; - (void)params; - tlogi("---- TA invoke command ----------- command id: %u\n", cmd); - - switch (cmd) { - case DRVTEST_COMMAND_DRVVIRTTOPHYS: - case DRVTEST_COMMAND_COPYFROMCLIENT: - case DRVTEST_COMMAND_COPYTOCLIENT: - ret = TeeTestDrive(cmd); - if (ret != TEE_SUCCESS) - tloge("invoke command for driver test failed! cmdId: %u, ret: 0x%x\n", cmd, ret); - break; - default: - tloge("not support this invoke command! cmdId: %u\n", cmd); - ret = TEE_ERROR_GENERIC; - break; - } - - return ret; -} - -void TA_CloseSessionEntryPoint(void *sessionContext) -{ - (void)sessionContext; - tlogi("---- TA_CloseSessionEntryPoint ----- \n"); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("---- TA_DestroyEntryPoint ---- \n"); -} diff --git a/test/xts/ta/test_libc_api/CMakeLists.txt b/test/xts/ta/test_libc_api/CMakeLists.txt deleted file mode 100644 index 0acda69d..00000000 --- a/test/xts/ta/test_libc_api/CMakeLists.txt +++ /dev/null @@ -1,133 +0,0 @@ -# -# Copyright (C) 2023 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_libc_api.elf) - -list(APPEND ta_src - src/test_time_api_func.c - src/test_time_api_main.c - src/test_libc_string.c - src/test_libc_pthread.c - src/test_libc_mem.c - src/test_libc_main.c - src/test_libc_common_lib.c - src/ta_case_work.c - src/libc_func/pthread_attr_destroy_1_1.c - src/libc_func/pthread_attr_destroy_2_1.c - src/libc_func/pthread_attr_destroy_3_1.c - src/libc_func/pthread_attr_getstack_1_1.c - src/libc_func/pthread_attr_getstacksize_1_1.c - src/libc_func/pthread_attr_init_1_1.c - src/libc_func/pthread_attr_init_3_1.c - src/libc_func/pthread_attr_init_4_1.c - src/libc_func/pthread_attr_setstack_1_1.c - src/libc_func/pthread_attr_setstack_2_1.c - src/libc_func/pthread_attr_setstack_4_1.c - src/libc_func/pthread_attr_setstack_6_1.c - src/libc_func/pthread_attr_setstack_7_1.c - src/libc_func/pthread_attr_setstacksize_1_1.c - src/libc_func/pthread_attr_setstacksize_2_1.c - src/libc_func/pthread_attr_setstacksize_4_1.c - src/libc_func/pthread_cond_broadcast_1_1.c - src/libc_func/pthread_cond_init_1_1.c - src/libc_func/pthread_cond_wait_0_1.c - src/libc_func/pthread_cond_wait_0_2.c - src/libc_func/pthread_cond_wait_0_3.c - src/libc_func/pthread_create_12_1.c - src/libc_func/pthread_create_1_1.c - src/libc_func/pthread_create_2_1.c - src/libc_func/pthread_create_4_1.c - src/libc_func/pthread_create_5_1.c - src/libc_func/pthread_create_5_2.c - src/libc_func/pthread_equal.c - src/libc_func/pthread_exit_2_1.c - src/libc_func/pthread_exit_3_1.c - src/libc_func/pthread_getspecific_1_1.c - src/libc_func/pthread_getspecific_1_1.c - src/libc_func/pthread_getspecific_1_1.c - src/libc_func/pthread_mutex_destroy_1_1.c - src/libc_func/pthread_mutex_destroy_1_1_0.c - src/libc_func/pthread_mutex_destroy_2_1.c - src/libc_func/pthread_mutex_destroy_4_2.c - src/libc_func/pthread_mutex_init_0_1.c - src/libc_func/pthread_mutex_init_1_1.c - src/libc_func/pthread_mutex_init_2_1_0.c - src/libc_func/pthread_mutex_init_3_1.c - src/libc_func/pthread_mutex_lock_0_2.c - src/libc_func/pthread_mutex_lock_0_3.c - src/libc_func/pthread_mutex_lock_1_1_0.c - src/libc_func/pthread_mutex_trylock_0_1.c - src/libc_func/pthread_mutex_trylock_1_1.c - src/libc_func/pthread_mutex_trylock_4_1.c - src/libc_func/pthread_mutex_unlock_1_1.c - src/libc_func/pthread_mutexattr_getprotocol_1_1.c - src/libc_func/pthread_mutexattr_gettype_1_1.c - src/libc_func/pthread_mutexattr_gettype_1_1.c - src/libc_func/pthread_once_1_3.c - src/libc_func/pthread_setspecific_1_2.c - src/libc_func/pthread_spin_destroy_0_1.c - src/libc_func/pthread_spin_destroy_1_1.c - src/libc_func/pthread_spin_destroy_3_1.c - src/libc_func/pthread_spin_init_1_1.c - src/libc_func/pthread_spin_init_4_1.c - src/libc_func/pthread_spin_lock_0_1.c - src/libc_func/pthread_spin_lock_0_2.c - src/libc_func/pthread_spin_lock_0_3.c - src/libc_func/pthread_spin_lock_3_1.c - src/libc_func/pthread_spin_trylock_0_1.c - src/libc_func/pthread_spin_trylock_1_1.c - src/libc_func/pthread_spin_trylock_4_1.c - src/libc_func/pthread_spin_trylock_4_1_0.c - src/libc_func/pthread_spin_unlock_1_1.c - src/libc_func/test-string.c - src/libc_func/test_ctype.c - src/libc_func/test_error.c - src/libc_func/test_getpid.c - src/libc_func/test_locale.c - src/libc_func/test_math.c - src/libc_func/test_mmap.c - src/libc_func/test_multibyte.c - src/libc_func/test_prng.c - src/libc_func/test_pthread_key_create.c - src/libc_func/test_sem.c - src/libc_func/test_stdio.c - src/libc_func/test_stdlib.c - src/libc_func/test_time.c - src/libc_func/tst-calloc.c - src/libc_func/tst-malloc.c - src/libc_func/tst_free.c -) - -list(APPEND cflags - -mfloat-abi=softfp - -Wno-bitwise-op-parentheses - -Wno-shift-op-parentheses - -Wno-implicit-function-declaration - -Wno-int-conversion - -Wno-unused-parameter -) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - ${ta_src} - - INCLUDE_DIRS - - COMPILE_OPTS - ${cflags} - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_libc_api/manifest.txt b/test/xts/ta/test_libc_api/manifest.txt deleted file mode 100644 index a1c0c5ad..00000000 --- a/test/xts/ta/test_libc_api/manifest.txt +++ /dev/null @@ -1,7 +0,0 @@ -gpd.ta.appID: 534d4152-542d-4353-4c54-d3016a171f0c -gpd.ta.service_name: LIBC_test -gpd.ta.singleInstance: true -gpd.ta.multiSession: false -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 4096000 -gpd.ta.stackSize: 81920 \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_1_1.c deleted file mode 100755 index e03c2b99..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_1_1.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - - -static void *a_thread_func(void *args) -{ - - pthread_exit(0); - return NULL; -} - -int pthread_attr_destroy_1_1(void) -{ - pthread_t new_th; - pthread_attr_t new_attr; - int ret; - - /* Initialize attribute */ - if (pthread_attr_init(&new_attr) != 0) { - printf("Cannot initialize attribute object\n"); - return PTS_UNRESOLVED; - } - - /* Destroy attribute */ - if (pthread_attr_destroy(&new_attr) != 0) { - printf("Cannot destroy the attribute object\n"); - return PTS_UNRESOLVED; - } - - /* Creating a thread, passing to it the destroyed attribute, should - * result in an error value of EINVAL (invalid 'attr' value). */ - ret = pthread_create(&new_th, &new_attr, a_thread_func, NULL); - - if (ret == EINVAL) { - printf("Test PASSED\n"); - return PTS_PASS; - } else if ((ret != 0) && ((ret == EPERM) || (ret == EAGAIN))) { - printf("Error created a new thread\n"); - return PTS_UNRESOLVED; - } else if (ret == 0) { - printf("Test PASSED: NOTE*: Though returned 0 when creating a thread with a destroyed attribute, this behavior is compliant with garbage-in-garbage-out. \n"); - return PTS_PASS; - } else { - printf("Test FAILED: (1) Incorrect return code from pthread_create(); %d not EINVAL or (2) Error in pthread_create()'s behavior in returning error codes \n", - ret); - return PTS_FAIL; - } - -} \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_2_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_2_1.c deleted file mode 100755 index 133090d5..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_2_1.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - - -int pthread_attr_destroy_2_1(void) -{ - pthread_attr_t new_attr; - - /* Initialize attribute */ - if (pthread_attr_init(&new_attr) != 0) { - printf("Cannot initialize attribute object\n"); - return PTS_UNRESOLVED; - } - - /* Destroy attribute */ - if (pthread_attr_destroy(&new_attr) != 0) { - printf("Cannot destroy the attribute object\n"); - return PTS_UNRESOLVED; - } - - /* Initialize attribute. This shouldn't result in an error. */ - if (pthread_attr_init(&new_attr) != 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } else { - printf("Test PASSED\n"); - return PTS_PASS; - } - -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_3_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_3_1.c deleted file mode 100755 index 5183f0ec..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_destroy_3_1.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - - -int pthread_attr_destroy_3_1(void) -{ - pthread_attr_t new_attr; - - /* Initialize attribute */ - if (pthread_attr_init(&new_attr) != 0) { - printf("Cannot initialize attribute object\n"); - return PTS_UNRESOLVED; - } - - /* Destroy attribute */ - if (pthread_attr_destroy(&new_attr) != 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } else { - printf("Test PASSED\n"); - return PTS_PASS; - } -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstack_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstack_1_1.c deleted file mode 100755 index 08d8f855..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstack_1_1.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "1-1" -#define FUNCTION "pthread_attr_getstack" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -int pthread_attr_getstack_1_1(void) -{ - pthread_attr_t attr; - void *stack_addr; - size_t stack_size; - size_t ssize; - void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - printf("stack_addr = %p, stack_size = %zu\n", stack_addr, stack_size); - - stack_size = PTHREAD_STACK_MIN; - stack_addr = 0; - - // if (posix_memalign (&stack_addr, sysconf(_SC_PAGE_SIZE), - // stack_size) != 0) - // { - // printf (ERROR_PREFIX "out of memory while " - // "allocating the stack memory"); - // return PTS_UNRESOLVED; - // } - printf("stack_addr = %p, stack_size = %zu\n", stack_addr, stack_size); - - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstack"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstack(&attr, &saddr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - printf("saddr = %p, ssize = %zu\n", saddr, ssize); - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstacksize_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstacksize_1_1.c deleted file mode 100755 index 379385db..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_getstacksize_1_1.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "1-1" -#define FUNCTION "pthread_attr_getstacksize" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -int pthread_attr_getstacksize_1_1(void) -{ - pthread_attr_t attr; - size_t stack_size; - size_t ssize; - // void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstacksize(&attr, &stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstacksize"); - return PTS_UNRESOLVED; - } - /* printf("stack_size = %lu\n", stack_size); */ - - stack_size = PTHREAD_STACK_MIN; - - /* if (posix_memalign (&saddr, sysconf(_SC_PAGE_SIZE), - stack_size) != 0) - { - printf (ERROR_PREFIX "out of memory while " - "allocating the stack memory"); - return PTS_UNRESOLVED; - } - */ - /* printf("stack_size = %lu\n", stack_size); */ - - rc = pthread_attr_setstacksize(&attr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstacksize"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstacksize(&attr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstacksize"); - return PTS_UNRESOLVED; - } - /* printf("ssize = %lu\n", ssize); */ - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_1_1.c deleted file mode 100755 index 9f447d3f..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_1_1.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -#include "test_libc_func.h" - -int pthread_attr_init_1_1(void) -{ - pthread_attr_t new_attr; - int detach_state; - - /* Initialize attribute */ - if (pthread_attr_init(&new_attr) != 0) { - printf("Cannot initialize attribute object\n"); - return PTS_UNRESOLVED; - } - - /* The test passes if the attribute object has a detachstate of - * PTHREAD_CREATE_JOINABLE, which is the default value for this - * attribute. */ - if (pthread_attr_getdetachstate(&new_attr, &detach_state) != 0) { - printf("Error obtaining the detachstate of the attribute\n"); - return PTS_UNRESOLVED; - } - - if (detach_state == PTHREAD_CREATE_JOINABLE) { - printf("Test PASSED\n"); - return PTS_PASS; - } else { - printf("Test FAILED\n"); - return PTS_FAIL; - } -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_3_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_3_1.c deleted file mode 100755 index 10bfcf0c..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_3_1.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -#define NUM_THREADS 5 - -static void *a_thread_func(void *args) -{ - pthread_exit(NULL); - return NULL; -} - -int pthread_attr_init_3_1(void) -{ - pthread_t new_threads[NUM_THREADS]; - pthread_attr_t new_attr; - int i, ret; - - /* Initialize attribute */ - if (pthread_attr_init(&new_attr) != 0) { - printf("Cannot initialize attribute object\n"); - return PTS_UNRESOLVED; - } - - /* Create [NUM_THREADS] number of threads with the same attribute - * object. */ - for (i = 0; i < NUM_THREADS; i++) { - ret = pthread_create(&new_threads[i], &new_attr, a_thread_func, NULL); - if ((ret != 0) && (ret == EINVAL)) { - printf("Test FAILED\n"); - return PTS_FAIL; - } else if (ret != 0) { - printf("Error creating thread\n"); - return PTS_UNRESOLVED; - } - } - - printf("Test PASSED\n"); - return PTS_PASS; - -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_4_1.c deleted file mode 100755 index 0d27b532..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_init_4_1.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -int pthread_attr_init_4_1(void) -{ - pthread_attr_t new_attr; - int ret; - - /* Initialize attribute */ - ret = pthread_attr_init(&new_attr); - if (ret == 0) { - printf("Test PASSED\n"); - return PTS_PASS; - } - /* There's insufficient memory, can't run test */ - else if (ret == ENOMEM) { - printf("Error in pthread_attr_init()\n"); - return PTS_UNRESOLVED; - } - - /* Any other return value other than 0 or ENOMEM, means the test - * failed, because those are the only 2 return values for this - * function. */ - else { - printf("Test FAILED\n"); - return PTS_FAIL; - } - -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_1_1.c deleted file mode 100755 index 4291d9d3..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_1_1.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "1-1" -#define FUNCTION "pthread_attr_setstack" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -#define STACKADDROFFSET 0x8000000 - -static void *stack_addr; -static size_t stack_size; - -static void *thread_func(void *args) -{ - pthread_exit(0); - return NULL; -} -int pthread_attr_setstack_1_1(void) -{ - pthread_t new_th; - pthread_attr_t attr; - size_t ssize; - void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - - stack_size = PTHREAD_STACK_MIN; - - // if (posix_memalign (&stack_addr, sysconf(_SC_PAGE_SIZE), - // stack_size) != 0) - // { - // printf (ERROR_PREFIX "out of memory while " - // "allocating the stack memory"); - // return PTS_UNRESOLVED; - // } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size);*/ - - stack_addr = 0; - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstack"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstack(&attr, &saddr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("saddr = %p, ssize = %u\n", saddr, ssize); */ - - rc = pthread_create(&new_th, &attr, thread_func, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "failed to create a thread"); - return PTS_FAIL; - } - - rc = pthread_join(new_th, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_join"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_2_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_2_1.c deleted file mode 100755 index e7739368..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_2_1.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "2-1" -#define FUNCTION "pthread_attr_setstack" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -static void *stack_addr; -static size_t stack_size; - -static void *thread_func(void *args) -{ - // pthread_attr_t attr; - // void *saddr; - // size_t ssize; - // int rc; - - /* pthread_getattr_np is not POSIX Compliant API*/ - // rc = pthread_getattr_np(pthread_self(), &attr); - // if (rc != 0) - // { - // printf(ERROR_PREFIX "pthread_getattr_np"); - // return PTS_UNRESOLVED; - // } - - // pthread_attr_getstack(&attr, &saddr, &ssize); - // if (ssize != stack_size || saddr != stack_addr) - // { - // printf(ERROR_PREFIX "got the wrong stacksize or stackaddr"); - // return PTS_FAIL; - // } - /* printf("saddr = %p, ssize = %u\n", saddr, ssize); */ - - pthread_exit(0); - return NULL; -} - -int pthread_attr_setstack_2_1() -{ - pthread_t new_th; - pthread_attr_t attr; - size_t ssize; - void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - - stack_size = PTHREAD_STACK_MIN; - stack_addr = 0; - // if (posix_memalign (&stack_addr, sysconf(_SC_PAGE_SIZE), - // stack_size) != 0) - // { - // printf (ERROR_PREFIX "out of memory while " - // "allocating the stack memory"); - // return PTS_UNRESOLVED; - // } - // /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstack"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstack(&attr, &saddr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("saddr = %p, ssize = %u\n", saddr, ssize); */ - - rc = pthread_create(&new_th, &attr, thread_func, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "failed to create a thread"); - return PTS_FAIL; - } - - rc = pthread_join(new_th, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_join"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_4_1.c deleted file mode 100755 index 3a75209f..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_4_1.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "4-1" -#define FUNCTION "pthread_attr_setstack" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -#define STACKADDROFFSET 0x8000000 - -static void *stack_addr; -static size_t stack_size; - -static int teststack(void) -{ - return 0; -} -static void *thread_func(void *args) -{ - /* execute a function to test the read/right of the stack*/ - if (teststack() != 0) { - printf(ERROR_PREFIX "stack wrong"); - return (void *)PTS_FAIL; - } - pthread_exit(0); - return NULL; -} -int pthread_attr_setstack_4_1(void) -{ - pthread_t new_th; - pthread_attr_t attr; - size_t ssize; - void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - - stack_size = PTHREAD_STACK_MIN; - // - // if (posix_memalign (&stack_addr, sysconf(_SC_PAGE_SIZE), - // stack_size) != 0) - // { - // printf (ERROR_PREFIX "out of memory while " - // "allocating the stack memory"); - // return PTS_UNRESOLVED); - // } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - stack_addr = 0; - - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstack"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstack(&attr, &saddr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("saddr = %p, ssize = %u\n", saddr, ssize); */ - - if (ssize != stack_size || saddr != stack_addr) { - printf(ERROR_PREFIX "got the wrong stacksize or stackaddr"); - return PTS_FAIL; - } - - rc = pthread_create(&new_th, &attr, thread_func, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "failed to create a thread"); - return PTS_FAIL; - } - - rc = pthread_join(new_th, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_join"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_6_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_6_1.c deleted file mode 100755 index bc24518d..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_6_1.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "6-1" -#define FUNCTION "pthread_attr_setstack" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -#define STACKSIZE PTHREAD_STACK_MIN - sysconf(_SC_PAGE_SIZE) - -static void *stack_addr; -static size_t stack_size; - -/* -static void *thread_func(void *args) -{ - pthread_exit(0); - return NULL; -} -*/ -int pthread_attr_setstack_6_1(void) -{ - pthread_attr_t attr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - - stack_size = 1024; - stack_addr = 0; - - // if (posix_memalign (&stack_addr, sysconf(_SC_PAGE_SIZE), - // stack_size) != 0) - // { - // printf (ERROR_PREFIX "out of memory while " - // "allocating the stack memory"); - // return PTS_UNRESOLVED; - // } - - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "Got the wrong return value"); - return PTS_FAIL; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_7_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_7_1.c deleted file mode 100755 index 3b1494ee..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstack_7_1.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "7-1" -#define FUNCTION "pthread_attr_setstack" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -#define OFFSET 0x7 - -static void *stack_addr; -static size_t stack_size; - -int pthread_attr_setstack_7_1(void) -{ - pthread_attr_t attr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* Get the default stack_addr and stack_size value */ - rc = pthread_attr_getstack(&attr, &stack_addr, &stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "pthread_attr_getstack"); - return PTS_UNRESOLVED; - } - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - - stack_size = PTHREAD_STACK_MIN; - - stack_addr = stack_addr + OFFSET; - /* printf("stack_addr = %p, stack_size = %u\n", stack_addr, stack_size); */ - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != EINVAL) { - printf("The function didn't fail when stackaddr " - "lacks proper alignment\n"); - } - - stack_addr = stack_addr + OFFSET; - stack_size = PTHREAD_STACK_MIN + OFFSET; - rc = pthread_attr_setstack(&attr, stack_addr, stack_size); - if (rc != EINVAL) { - printf("The function didn't fail when (stackaddr + stacksize) " - "lacks proper alignment\n"); - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_1_1.c deleted file mode 100755 index 27f55b41..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_1_1.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "1-1" -#define FUNCTION "pthread_attr_setstacksize" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -#define STACKADDROFFSET 0x8000000 - -static void *thread_func(void *args) -{ - pthread_exit(0); - return NULL; -} -int pthread_attr_setstacksize_1_1(void) -{ - pthread_t new_th; - pthread_attr_t attr; - size_t stack_size = PTHREAD_STACK_MIN; - size_t ssize; - // void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - /* printf("stack_size = %lu\n", stack_size); */ - - // if (posix_memalign (&saddr, sysconf(_SC_PAGE_SIZE), - // stack_size) != 0) - // { - // printf (ERROR_PREFIX "out of memory while " - // "allocating the stack memory"); - // return PTS_UNRESOLVED); - // } - - rc = pthread_attr_setstacksize(&attr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstacksize"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstacksize(&attr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstacksize"); - return PTS_UNRESOLVED; - } - /* printf("stack_size = %lu\n", ssize); */ - - rc = pthread_create(&new_th, &attr, thread_func, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "failed to create a thread"); - return PTS_FAIL; - } - - rc = pthread_join(new_th, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_join"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_2_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_2_1.c deleted file mode 100755 index 6c5e2bc1..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_2_1.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "2-1" -#define FUNCTION "pthread_attr_setstacksize" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -static size_t stack_size; - -static void *thread_func(void *args) -{ - pthread_attr_t attr; - size_t ssize; - - pthread_attr_getstacksize(&attr, &ssize); - if (ssize != stack_size) { - printf(ERROR_PREFIX "got the wrong stacksize or stackaddr"); - return (void *)PTS_FAIL; - } - - pthread_exit(0); - return NULL; -} - -int pthread_attr_setstacksize_2_1(void) -{ - pthread_t new_th; - pthread_attr_t attr; - size_t ssize; - // void *saddr; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - stack_size = PTHREAD_STACK_MIN; - - rc = pthread_attr_setstacksize(&attr, stack_size); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_setstacksize"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_getstacksize(&attr, &ssize); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_getstacksize"); - return PTS_UNRESOLVED; - } - - rc = pthread_create(&new_th, &attr, thread_func, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "failed to create a thread"); - return PTS_FAIL; - } - - rc = pthread_join(new_th, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_join"); - return PTS_UNRESOLVED; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_4_1.c deleted file mode 100755 index 267537c0..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_attr_setstacksize_4_1.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "4-1" -#define FUNCTION "pthread_attr_setstacksize" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -int pthread_attr_setstacksize_4_1(void) -{ - pthread_attr_t attr; - // void *saddr; - size_t stack_size; - int rc; - - /* Initialize attr */ - rc = pthread_attr_init(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_init"); - return PTS_UNRESOLVED; - } - - stack_size = 1024; - - rc = pthread_attr_setstacksize(&attr, stack_size); - if (rc != EINVAL) { - printf(ERROR_PREFIX "Got the wrong return value"); - return PTS_FAIL; - } - - rc = pthread_attr_destroy(&attr); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_attr_destroy"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_broadcast_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_broadcast_1_1.c deleted file mode 100644 index e5d1d32e..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_broadcast_1_1.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define THREAD_NUM 3 - -struct testdata { - pthread_mutex_t mutex; - pthread_cond_t cond; -}; - -static struct testdata td; -static int start_num = 0; -static int waken_num = 0; - -static void *thr_func(void *arg) -{ - int rc; - pthread_t self = pthread_self(); - - if (pthread_mutex_lock(&td.mutex) != 0) { - fprintf(stderr, "[Thread 0x%p] failed to acquire the mutex\n", (void *)self); - pthread_exit((void *)PTS_UNRESOLVED); - } - start_num ++; - fprintf(stderr, "[Thread 0x%p] started and locked the mutex\n", (void *)self); - - fprintf(stderr, "[Thread 0x%p] is waiting for the cond\n", (void *)self); - rc = pthread_cond_wait(&td.cond, &td.mutex); - if (rc != 0) { - fprintf(stderr, "pthread_cond_wait return %d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - waken_num ++; - fprintf(stderr, "[Thread 0x%p] was wakened and acquired the mutex again\n", - (void *)self); - - if (pthread_mutex_unlock(&td.mutex) != 0) { - fprintf(stderr, "[Thread 0x%p] failed to release the mutex\n", (void *)self); - pthread_exit((void *)PTS_UNRESOLVED); - } - fprintf(stderr, "[Thread 0x%p] released the mutex\n", (void *)self); - return NULL; -} - -int pthread_cond_broadcast_1_1(void) -{ - int i, rc; - pthread_t thread[THREAD_NUM]; - - if (pthread_mutex_init(&td.mutex, NULL) != 0) { - fprintf(stderr, "Fail to initialize mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_cond_init(&td.cond, NULL) != 0) { - fprintf(stderr, "Fail to initialize cond\n"); - return PTS_UNRESOLVED; - } - - for (i = 0; i < THREAD_NUM; i++) { /* create THREAD_NUM threads */ - if (pthread_create(&thread[i], NULL, thr_func, NULL) != 0) { - fprintf(stderr, "Fail to create thread[%d]\n", i); - return PTS_UNRESOLVED; - } - } - while (start_num < THREAD_NUM) {/* waiting for all threads started */ - tee_msleep(1); - (void)sched_yield(); - } - - /* Acquire the mutex to make sure that all waiters are currently - blocked on pthread_cond_wait */ - if (pthread_mutex_lock(&td.mutex) != 0) { - fprintf(stderr, "Main: Fail to acquire mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_unlock(&td.mutex) != 0) { - fprintf(stderr, "Main: Fail to release mutex\n"); - return PTS_UNRESOLVED; - } - - /* broadcast and check if all waiters are wakened */ - fprintf(stderr, "[Main thread] broadcast the condition\n"); - rc = pthread_cond_broadcast(&td.cond); - if (rc != 0) { - fprintf(stderr, "[Main thread] failed to broadcast the condition\n"); - return PTS_UNRESOLVED; - } - (void)sched_yield(); - tee_msleep(1000); - (void)sched_yield(); - if (waken_num < THREAD_NUM) { - fprintf(stderr, "[Main thread] Not all waiters were wakened\n"); - printf("Test FAILED\n"); - return PTS_FAIL; - } - fprintf(stderr, "[Main thread] all waiters were wakened\n"); - - /* join all secondary threads */ - for (i = 0; i < THREAD_NUM; i++) { - if (pthread_join(thread[i], NULL) != 0) { - fprintf(stderr, "Fail to join thread[%d]\n", i); - return PTS_UNRESOLVED; - } - } - if (pthread_mutex_destroy(&td.mutex) != 0) { - fprintf(stderr, "Fail to destroy mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_cond_destroy(&td.cond) != 0) { - fprintf(stderr, "Fail to destroy cond\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_init_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_init_1_1.c deleted file mode 100644 index 2b408bc4..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_init_1_1.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -#include "test_libc_func.h" - -int pthread_cond_init_1_1(void) -{ - /*pthread_condattr_t condattr;*/ - pthread_cond_t cond; - /*pthread_cond_t cond1;*/ - int rc; - - /* Initialize cond with NULL attributes */ - if ((rc = pthread_cond_init(&cond, NULL)) != 0) { - fprintf(stderr, "Fail to initialize cond, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - if ((rc = pthread_cond_destroy(&cond)) != 0) { - fprintf(stderr, "Fail to destroy cond, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_1.c deleted file mode 100644 index b2170ce3..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_1.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -struct testdata { - pthread_mutex_t mutex; - pthread_mutex_t mutex2; - pthread_cond_t cond; - pthread_cond_t cond2; -}; - -static struct testdata td; -static pthread_t thread1; -static pthread_t thread2; - -static int t1_start = 0; -static int signaled = 0; -static int t1_start2 = 0; -static int signaled2 = 0; - - -static void *t1_func(void *arg) -{ - int rc; - - if (pthread_mutex_lock(&td.mutex) != 0) { - fprintf(stderr, "Thread1 failed to acquire mutex\n"); - pthread_exit((void *)PTS_UNRESOLVED); - } - fprintf(stderr, "Thread1 started\n"); - t1_start = 1; /* let main thread continue */ - - fprintf(stderr, "Thread1 is waiting for the cond\n"); - rc = pthread_cond_wait(&td.cond, &td.mutex); - if (rc != 0) { - fprintf(stderr, "pthread_cond_wait return %d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - - fprintf(stderr, "Thread1 wakened\n"); - if (signaled == 0) { - fprintf(stderr, "Thread1 did not block on the cond at all\n"); - printf("Test FAILED\n"); - pthread_exit((void *)PTS_FAIL); - } - pthread_mutex_unlock(&td.mutex); - return NULL; -} - -static void *t2_func(void *arg) -{ - int rc; - - if (pthread_mutex_lock(&td.mutex2) != 0) { - fprintf(stderr, "Thread1 failed to acquire mutex\n"); - pthread_exit((void *)PTS_UNRESOLVED); - } - fprintf(stderr, "Thread1 started\n"); - t1_start2 = 1; /* let main thread continue */ - - fprintf(stderr, "Thread1 is waiting for the cond\n"); - rc = pthread_cond_wait(&td.cond2, &td.mutex2); - if (rc != 0) { - fprintf(stderr, "pthread_cond_wait return %d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - - fprintf(stderr, "Thread1 wakened\n"); - if (signaled2 == 0) { - fprintf(stderr, "Thread1 did not block on the cond at all\n"); - printf("Test FAILED\n"); - pthread_exit((void *)PTS_FAIL); - } - pthread_mutex_unlock(&td.mutex2); - return NULL; -} - -int pthread_cond_wait_0_1(void) -{ - if (pthread_mutex_init(&td.mutex, NULL) != 0) { - fprintf(stderr, "Fail to initialize mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_cond_init(&td.cond, NULL) != 0) { - fprintf(stderr, "Fail to initialize cond\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_init(&td.mutex2, NULL) != 0) { - fprintf(stderr, "Fail to initialize mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_cond_init(&td.cond2, NULL) != 0) { - fprintf(stderr, "Fail to initialize cond\n"); - return PTS_UNRESOLVED; - } - - if (pthread_create(&thread1, NULL, t1_func, NULL) != 0) { - fprintf(stderr, "Fail to create thread 1\n"); - return PTS_UNRESOLVED; - } - if (pthread_create(&thread2, NULL, t2_func, NULL) != 0) { - fprintf(stderr, "Fail to create thread 1\n"); - return PTS_UNRESOLVED; - } - while (!t1_start) { /* wait for thread1 started */ - tee_msleep(1); - (void)sched_yield(); - } - while (!t1_start2) { /* wait for thread1 started */ - tee_msleep(1); - (void)sched_yield(); - } - - /* acquire the mutex released by pthread_cond_wait() within thread 1 */ - if (pthread_mutex_lock(&td.mutex) != 0) { - fprintf(stderr, "Main: Fail to acquire mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_unlock(&td.mutex) != 0) { - fprintf(stderr, "Main: Fail to release mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_lock(&td.mutex2) != 0) { - fprintf(stderr, "Main: Fail to acquire mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_unlock(&td.mutex2) != 0) { - fprintf(stderr, "Main: Fail to release mutex\n"); - return PTS_UNRESOLVED; - } - (void)sched_yield(); - tee_msleep(1000); - (void)sched_yield(); - tee_msleep(1000); - (void)sched_yield(); - - - fprintf(stderr, "Time to wake up thread1 by signaling a condition\n"); - signaled = 1; - signaled2 = 1; - if (pthread_cond_signal(&td.cond) != 0) { - fprintf(stderr, "Main: Fail to signal cond\n"); - return PTS_UNRESOLVED; - } - (void)sched_yield(); - if (pthread_cond_signal(&td.cond2) != 0) { - fprintf(stderr, "Main: Fail to signal cond\n"); - return PTS_UNRESOLVED; - } - (void)sched_yield(); - - pthread_join(thread1, NULL); - pthread_join(thread2, NULL); - if (pthread_mutex_destroy(&td.mutex) != 0) { - fprintf(stderr, "Fail to destroy mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_cond_destroy(&td.cond) != 0) { - fprintf(stderr, "Fail to destroy cond\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_destroy(&td.mutex2) != 0) { - fprintf(stderr, "Fail to destroy mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_cond_destroy(&td.cond2) != 0) { - fprintf(stderr, "Fail to destroy cond\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_2.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_2.c deleted file mode 100644 index 60236f4a..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_2.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_mutex_t mutex; -static pthread_cond_t cond; - -#define THREAD_NUM 8 -#define LOOP 50 - -static pthread_t thread[THREAD_NUM]; - -static int t1_start = 0; -static int cnt[THREAD_NUM]; - -static void *t1_func(void *arg) -{ - int rc; - int i = (int)(intptr_t)arg; - - if (pthread_mutex_lock(&mutex) != 0) { - fprintf(stderr, "Thread1 failed to acquire mutex\n"); - pthread_exit((void *)PTS_UNRESOLVED); - } - //fprintf(stderr,"Thread1 started\n"); - t1_start ++; /* let main thread continue */ - - //fprintf(stderr,"Thread1 is waiting for the cond\n"); - rc = pthread_cond_wait(&cond, &mutex); - if (rc != 0) { - fprintf(stderr, "pthread_cond_wait return %d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - cnt[i] ++; - //fprintf(stderr,"Thread1 wakened\n"); - pthread_mutex_unlock(&mutex); - return NULL; -} - - -int pthread_cond_wait_0_2(void) -{ - int i, j; - - if (pthread_mutex_init(&mutex, NULL) != 0) { - fprintf(stderr, "Fail to initialize mutex\n"); - return PTS_UNRESOLVED; - } - - for (i = 0; i < LOOP; i++) { - printf("loop:%d\n", i); - t1_start = 0; - if (pthread_cond_init(&cond, NULL) != 0) { - fprintf(stderr, "Fail to initialize cond\n"); - return PTS_UNRESOLVED; - } - printf("loop2:%d\n", i); - - for (j = 0; j < THREAD_NUM; j++) { - if (pthread_create(&thread[j], NULL, t1_func, (void *)(intptr_t)j) != 0) { - fprintf(stderr, "Fail to create thread 1\n"); - return PTS_UNRESOLVED; - } - } - printf("loop3:%d\n", i); - while (t1_start < THREAD_NUM) { /* wait for thread1 started */ - tee_msleep(1); - (void)sched_yield(); - } - - /* acquire the mutex released by pthread_cond_wait() within thread 1 */ - if (pthread_mutex_lock(&mutex) != 0) { - fprintf(stderr, "Main: Fail to acquire mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_unlock(&mutex) != 0) { - fprintf(stderr, "Main: Fail to release mutex\n"); - return PTS_UNRESOLVED; - } - - - fprintf(stderr, "Time to wake up thread1 by signaling a condition\n"); - if (pthread_cond_broadcast(&cond) != 0) { - fprintf(stderr, "Main: Fail to signal cond\n"); - return PTS_UNRESOLVED; - } - (void)sched_yield(); - for (j = 0; j < THREAD_NUM; j++) { - pthread_join(thread[j], NULL); - } - for (j = 0; j < THREAD_NUM; j++) { - if (!cnt[j]) - return PTS_FAIL; - } - if (pthread_cond_destroy(&cond) != 0) { - fprintf(stderr, "Fail to destroy cond\n"); - return PTS_UNRESOLVED; - } - } - if (pthread_mutex_destroy(&mutex) != 0) { - fprintf(stderr, "Fail to destroy mutex\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_3.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_3.c deleted file mode 100644 index 0ea74789..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_cond_wait_0_3.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - - -#define THREAD_NUM 8 -#define COND_NUM 2 -#define LOOP 10 - -static pthread_mutex_t mutex[COND_NUM]; -static pthread_cond_t cond[COND_NUM]; -static pthread_t thread[THREAD_NUM][COND_NUM]; - -static int t1_start = 0; -static int cnt[THREAD_NUM]; - -static void *t1_func(void *arg) -{ - int rc; - int i = (int)(intptr_t)arg; - - if (pthread_mutex_lock(&mutex[i]) != 0) { - fprintf(stderr, "Thread1 failed to acquire mutex\n"); - pthread_exit((void *)PTS_UNRESOLVED); - } - //fprintf(stderr,"Thread1 started\n"); - t1_start ++; /* let main thread continue */ - - //fprintf(stderr,"Thread1 is waiting for the cond\n"); - rc = pthread_cond_wait(&cond[i], &mutex[i]); - if (rc != 0) { - fprintf(stderr, "pthread_cond_wait return %d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - cnt[i] ++; - //fprintf(stderr,"Thread1 wakened\n"); - pthread_mutex_unlock(&mutex[i]); - return NULL; -} - - -int pthread_cond_wait_0_3(void) -{ - int i, j, k; - - for (k = 0; k < COND_NUM; k++) { - if (pthread_mutex_init(&mutex[k], NULL) != 0) { - printf("Fail to initialize mutex\n"); - return PTS_UNRESOLVED; - } - } - - for (i = 0; i < LOOP; i++) { - - t1_start = 0; - printf("loop:%d\n", i); - - for (k = 0; k < COND_NUM; k++) { - cnt[k] = 0; - if (pthread_cond_init(&cond[k], NULL) != 0) { - printf("Fail to initialize cond\n"); - return PTS_UNRESOLVED; - } - } - - for (j = 0; j < THREAD_NUM; j++) { - for (k = 0; k < COND_NUM; k++) { - if (pthread_create(&thread[j][k], NULL, t1_func, (void *)(intptr_t)k) != 0) { - printf("Fail to create thread 1\n"); - return PTS_UNRESOLVED; - } - } - } - while (t1_start < THREAD_NUM * COND_NUM) { /* wait for thread1 started */ - tee_msleep(1); - (void)sched_yield(); - } - //printf("start to aquire lock\n"); - - for (k = 0; k < COND_NUM; k++) { - /* acquire the mutex released by pthread_cond_wait() within thread 1 */ - if (pthread_mutex_lock(&mutex[k]) != 0) { - fprintf(stderr, "Main: Fail to acquire mutex\n"); - return PTS_UNRESOLVED; - } - if (pthread_mutex_unlock(&mutex[k]) != 0) { - fprintf(stderr, "Main: Fail to release mutex\n"); - return PTS_UNRESOLVED; - } - } - - //fprintf(stderr,"Time to wake up thread1 by signaling a condition\n"); - for (k = 0; k < COND_NUM; k++) { - if (pthread_cond_broadcast(&cond[k]) != 0) { - fprintf(stderr, "Main: Fail to signal cond\n"); - return PTS_UNRESOLVED; - } - (void)sched_yield(); - } - (void)sched_yield(); - for (j = 0; j < THREAD_NUM; j++) { - for (k = 0; k < COND_NUM; k++) { - pthread_join(thread[j][k], NULL); - } - } - for (j = 0; j < COND_NUM; j++) { - if (cnt[j] != THREAD_NUM) { - printf("result wrong\n"); - return PTS_FAIL; - } - } - for (k = 0; k < COND_NUM; k++) { - if (pthread_cond_destroy(&cond[k]) != 0) { - printf("Fail to destroy cond\n"); - return PTS_UNRESOLVED; - } - } - } - - for (k = 0; k < COND_NUM; k++) { - if (pthread_mutex_destroy(&mutex[k]) != 0) { - printf("Fail to destroy mutex\n"); - return PTS_UNRESOLVED; - } - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_12_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_create_12_1.c deleted file mode 100755 index 07f62f9e..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_12_1.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -/* Thread starting routine that really does nothing. */ -static void *a_thread_func(void *args) -{ - pthread_exit(0); - return NULL; -} - -int pthread_create_12_1(void) -{ - pthread_t new_th; - int ret; - - /* Create new thread and check the return value. */ - ret = pthread_create(&new_th, NULL, a_thread_func, NULL); - if (ret != 0) { - if ((ret != EINVAL) && (ret != EAGAIN) && (ret != EPERM)) - - printf("Test FAILED: Wrong return code: %d\n", ret); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_create_1_1.c deleted file mode 100755 index 1a6d06c2..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_1_1.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -#include "test_libc_func.h" - -static void *a_thread_func(void *args) -{ - pthread_exit(0); - return NULL; -} - -int pthread_create_1_1(void) -{ - pthread_t main_th, new_th; - - if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - printf("Error creating thread\n"); - return PTS_UNRESOLVED; - } - - /* Obtain the thread ID of this main function */ - main_th = pthread_self(); - - /* Compare the thread ID of the new thread to the main thread. - * They should be different. If not, the test fails. */ - if (pthread_equal(new_th, main_th) != 0) { - printf("Test FAILED: A new thread wasn't created\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_2_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_create_2_1.c deleted file mode 100755 index 007099bc..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_2_1.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -static void *a_thread_func(void *args) -{ - - pthread_exit(0); - return NULL; -} - -int pthread_create_2_1(void) -{ - pthread_t new_th; - - /* Create a new thread. The default attribute should be that - * it is joinable. */ - if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - printf("Error creating thread\n"); - return PTS_UNRESOLVED; - } - - /* The new thread should be able to be joined. */ - if (pthread_join(new_th, NULL) == EINVAL) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_create_4_1.c deleted file mode 100755 index c3a9da95..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_4_1.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -#include "test_libc_func.h" - -static void *a_thread_func(void *args); - -pthread_t self_th; /* Save the value of the function call pthread_self() - within the thread. Keeping it global so 'main' can - see it too. */ - -int pthread_create_4_1(void) -{ - pthread_t new_th; - - /* Create a new thread */ - if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - printf("Error creating thread\n"); - return PTS_UNRESOLVED; - } - - /* Wait for the thread function to return to make sure we got - * the thread ID value from pthread_self(). */ - if (pthread_join(new_th, NULL) != 0) { - printf("Error calling pthread_join()\n"); - return PTS_UNRESOLVED; - } - - /* If the value of pthread_self() and the return value from - * pthread_create() is equal, then the test passes. */ - if (pthread_equal(new_th, self_th) == 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - -/* The thread function that calls pthread_self() to obtain its thread ID */ -static void *a_thread_func(void *args) -{ - self_th = pthread_self(); - pthread_exit(0); - return NULL; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_1.c deleted file mode 100755 index 822eab6f..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_1.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -#define NUM_THREADS 5 - -/* The thread start routine. */ -static void *a_thread_func(void *num) -{ - intptr_t i = (intptr_t) num; - printf("Passed argument for thread: %d\n", (int)i); - - pthread_exit(0); - return NULL; -} - -int pthread_create_5_1(void) -{ - pthread_t new_th; - long i; - - for (i = 1; i < NUM_THREADS + 1; i++) { - if (pthread_create(&new_th, NULL, a_thread_func, (void *)i) != 0) { - printf("Error creating thread\n"); - return PTS_FAIL; - } - - /* Wait for thread to end execution */ - pthread_join(new_th, NULL); - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_2.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_2.c deleted file mode 100755 index ef4e8304..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_create_5_2.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -#include "test_libc_func.h" - -#define NUM_THREADS 5 - -/* The thread start routine. */ -static void *a_thread_func(void *num) -{ - int *i, j; - - i = (int *)num; - - for (j = 0; j < NUM_THREADS; j++) - printf("Passed argument %d for thread\n", i[j]); - - pthread_exit(0); - return NULL; -} - -int pthread_create_5_2(void) -{ - pthread_t new_th; - int i[NUM_THREADS], j; - - for (j = 0; j < NUM_THREADS; j++) - i[j] = j + 1; - - if (pthread_create(&new_th, NULL, a_thread_func, (void *)&i) != 0) { - printf("Error creating thread\n"); - return PTS_FAIL; - } - - /* Wait for thread to end execution */ - pthread_join(new_th, NULL); - - printf("Test PASSED\n"); - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_equal.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_equal.c deleted file mode 100644 index 5333a6a5..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_equal.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include - -#define N_THREAD 5 -#define N_MUTEX 5 - -static pthread_spinlock_t sync_spinlock; -static pthread_t tmp_thread; -static char stack_pages[4096 * 4]; - -static void *func_one(void *arg) -{ - tmp_thread = pthread_self(); - // sync_spinlock is locked before creating this thread. so thread will wait here. - // parent will set priority for this thread, (to make sure this thread do not exit). - // then parent will unlock sync_spinlock. - for (;;) { - // try to lock the spin lock, if locked, break. - // else hm_yield(), (here to test pthread_spin_trylock) - if (pthread_spin_trylock(&sync_spinlock) == 0) { - break; - } - (void)sched_yield(); - } - - printf("func_one thread print\n"); - // after we got the lock, just unlock it. - pthread_spin_unlock(&sync_spinlock); - pthread_exit(NULL); -} - -int test_pthread_equal(void) -{ - int ret; - pthread_t thread_one; - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_spin_init(&sync_spinlock, false); - pthread_spin_lock(&sync_spinlock); - // using given thread stack which larger than 3KB(our stack 4KB) - // pthread will use the stack which application provided. - pthread_attr_setstack(&attr, stack_pages, sizeof(stack_pages)); - ret = pthread_create(&thread_one, &attr, func_one, NULL); - if (ret != 0) { - printf("pthread create failed: return %d\n", ret); - return -1; - } - - // let other thread to run. - (void)sched_yield(); - // this print must output before thread print. - printf("main thread print\n"); - pthread_setschedprio(thread_one, 200); - pthread_spin_unlock(&sync_spinlock); - - pthread_join(thread_one, NULL); - pthread_spin_destroy(&sync_spinlock); - - if (!pthread_equal(tmp_thread, thread_one)) { - printf("test pthread_equal fail.\n"); - return -1; - } - return 0; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_exit_2_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_exit_2_1.c deleted file mode 100755 index 75bd8059..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_exit_2_1.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -static int i[3], j; - -/* Cleanup function that the thread executes when it is canceled. So if - * cleanup_flag is 1, it means that the thread was canceled. */ -static void a_cleanup_func1(void *args) -{ - i[j] = 1; - j++; - return; -} - -/* Cleanup function that the thread executes when it is canceled. So if - * cleanup_flag is 1, it means that the thread was canceled. */ -static void a_cleanup_func2(void *args) -{ - i[j] = 2; - j++; - return; -} - -/* Cleanup function that the thread executes when it is canceled. So if - * cleanup_flag is 1, it means that the thread was canceled. */ -static void a_cleanup_func3(void *args) -{ - i[j] = 3; - j++; - return; -} -/* Thread's function. */ -static void *a_thread_func(void *args) -{ - /* Set up 3 cleanup handlers */ - pthread_cleanup_push(a_cleanup_func1, NULL); - pthread_cleanup_push(a_cleanup_func2, NULL); - pthread_cleanup_push(a_cleanup_func3, NULL); - - /* Terminate the thread here. */ - pthread_exit(0); - - /* Need these here for it to compile nicely. We never reach here though. */ - pthread_cleanup_pop(0); - pthread_cleanup_pop(0); - pthread_cleanup_pop(0); - return NULL; -} - -int pthread_exit_2_1(void) -{ - pthread_t new_th; - - /* Initialize integer array. */ - for (j = 0; j < 3; j++) - i[j] = 0; - - /* Initialize counter. */ - j = 0; - - /* Create a new thread. */ - if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - printf("Error creating thread\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to return */ - if (pthread_join(new_th, NULL) != 0) { - printf("Error in pthread_join()\n"); - return PTS_UNRESOLVED; - } - - /* Check to make sure that the cleanup handlers were executed in order. */ - if (i[0] == 3) { - if (i[1] == 2) { - if (i[2] == 1) { - printf("Test PASSED\n"); - return PTS_PASS; - - } - printf("Test FAILED: Did not execute cleanup handlers in order.\n"); - return PTS_FAIL; - } - printf("Test FAILED: Did not execute cleanup handlers in order.\n"); - return PTS_FAIL; - } else if (i[0] == 0) { - printf("Test FAILED: Did not execute cleanup handlers.\n"); - return PTS_FAIL; - } - - printf("Test FAILED: Did not execute cleanup handlers in order.\n"); - return PTS_FAIL; - -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_exit_3_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_exit_3_1.c deleted file mode 100755 index a3fa15e5..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_exit_3_1.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "3-1" -#define FUNCTION "pthread_exit" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -/* Flag to indicate that the destructor was called */ -int cleanup_flag = 0; - -static void destructor(void *tmp) -{ - cleanup_flag = 1; -} - -/* Thread's function. */ -static void *a_thread_func(void *tmp) -{ - pthread_key_t key; - int value = 1; - int rc = 0; - - rc = pthread_key_create(&key, destructor); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_key_create\n"); - return (void *)PTS_UNRESOLVED; - } - - rc = pthread_setspecific(key, &value); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_setspecific\n"); - return (void *)PTS_UNRESOLVED; - } - - pthread_exit(0); - return NULL; -} - -int pthread_exit_3_1(void) -{ - pthread_t new_th; - int rc = 0; - - /* Create a new thread. */ - rc = pthread_create(&new_th, NULL, a_thread_func, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_create\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to return */ - rc = pthread_join(new_th, NULL); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_join\n"); - return PTS_UNRESOLVED; - } - - if (cleanup_flag != 1) { - printf("Test FAIL: Destructor was not called.\n"); - return PTS_FAIL; - } - - printf("Test PASS\n"); - return PTS_PASS; - -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_getspecific_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_getspecific_1_1.c deleted file mode 100755 index 0a0cf7b2..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_getspecific_1_1.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define NUM_OF_KEYS 10 -#define KEY_VALUE 0 - -int pthread_getspecific_1_1(void) -{ - pthread_key_t keys[NUM_OF_KEYS]; - int i; - void *rc; - - for (i = 0; i < NUM_OF_KEYS; i++) { - if (pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); - return PTS_UNRESOLVED; - } else { - if (pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); - return PTS_UNRESOLVED; - } - - } - } - - for (i = 0; i < NUM_OF_KEYS; ++i) { - rc = pthread_getspecific(keys[i]); - if (rc != (void *)(long)(i + KEY_VALUE)) { - printf("Test FAILED: Did not return correct value of thread-specific key, expected %d, but got %ld\n", - (i + KEY_VALUE), (long)rc); - return PTS_FAIL; - } else { - if (pthread_key_delete(keys[i]) != 0) { - printf("Error: pthread_key_delete() failed\n"); - return PTS_UNRESOLVED; - } - } - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1.c deleted file mode 100755 index 484f73b1..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include - -#include "test_libc_func.h" - -pthread_mutex_t mutex1, mutex2; -pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER; - -int pthread_mutex_destroy_1_1(void) -{ - pthread_mutexattr_t mta; - int rc; - - /* Initialize mutex1 with the default mutex attributes */ - if ((rc = pthread_mutex_init(&mutex1, &mta)) != 0) { - fprintf(stderr, "Fail to initialize mutex1, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Initialize mutex2 with NULL attributes */ - if ((rc = pthread_mutex_init(&mutex2, NULL)) != 0) { - fprintf(stderr, "Fail to initialize mutex2, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Destroy mutex1 */ - if ((rc = pthread_mutex_destroy(&mutex1)) != 0) { - fprintf(stderr, "Fail to destroy mutex1, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Destroy mutex2 */ - if ((rc = pthread_mutex_destroy(&mutex2)) != 0) { - fprintf(stderr, "Fail to destroy mutex2, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Destroy mutex3 */ - if ((rc = pthread_mutex_destroy(&mutex3)) != 0) { - fprintf(stderr, "Fail to destroy mutex3, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1_0.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1_0.c deleted file mode 100644 index 623c99a5..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_1_1_0.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include "test_libc_func.h" - -static pthread_mutex_t mutex1, mutex2; -static pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER; - -int pthread_mutex_destroy_1_1_0(void) -{ - pthread_mutexattr_t mta; - int rc; - - /* Initialize a mutex attributes object */ - if ((rc = pthread_mutexattr_init(&mta)) != 0) { - fprintf(stderr, "Error at pthread_mutexattr_init(), rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Initialize mutex1 with the default mutex attributes */ - if ((rc = pthread_mutex_init(&mutex1, &mta)) != 0) { - fprintf(stderr, "Fail to initialize mutex1, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Initialize mutex2 with NULL attributes */ - if ((rc = pthread_mutex_init(&mutex2, NULL)) != 0) { - fprintf(stderr, "Fail to initialize mutex2, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Destroy the mutex attributes object */ - if ((rc = pthread_mutexattr_destroy(&mta)) != 0) { - fprintf(stderr, "Error at pthread_mutexattr_destroy(), rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Destroy mutex1 */ - if ((rc = pthread_mutex_destroy(&mutex1)) != 0) { - fprintf(stderr, "Fail to destroy mutex1, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Destroy mutex2 */ - if ((rc = pthread_mutex_destroy(&mutex2)) != 0) { - fprintf(stderr, "Fail to destroy mutex2, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Destroy mutex3 */ - if ((rc = pthread_mutex_destroy(&mutex3)) != 0) { - fprintf(stderr, "Fail to destroy mutex3, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_2_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_2_1.c deleted file mode 100644 index 9adbdf7a..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_2_1.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include "test_libc_func.h" - -int pthread_mutex_destroy_2_1(void) -{ - pthread_mutex_t mutex; - - /* Initialize a mutex attributes object */ - if (pthread_mutex_init(&mutex, NULL) != 0) { - fprintf(stderr, "Cannot initialize mutex object\n"); - return PTS_UNRESOLVED; - } - - /* Destroy the mutex attributes object */ - if (pthread_mutex_destroy(&mutex) != 0) { - fprintf(stderr, "Cannot destroy the mutex object\n"); - return PTS_UNRESOLVED; - } - - /* Initialize the mutex attributes object again. This shouldn't result in an error. */ - if (pthread_mutex_init(&mutex, NULL) != 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } else { - printf("Test PASSED\n"); - return PTS_PASS; - } -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_4_2.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_4_2.c deleted file mode 100644 index d749a99c..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_destroy_4_2.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -#define TEST "4-2" -#define FUNCTION "pthread_mutex_destroy" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -int pthread_mutex_destroy_4_2(void) -{ - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - int rc = 0; - - /* Lock the mutex */ - rc = pthread_mutex_lock(&mutex); - if (rc != 0) { - printf(ERROR_PREFIX "pthread_mutex_lock\n"); - return PTS_UNRESOLVED; - } - - /* Try to destroy the locked mutex */ - rc = pthread_mutex_destroy(&mutex); - if (rc != EBUSY) { - printf(ERROR_PREFIX "Test PASS: Expected %d(EBUSY) got %d, " - "though the standard states 'may' fail\n", EBUSY, rc); - return PTS_PASS; - } - printf("Test PASS\n"); - - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_0_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_0_1.c deleted file mode 100644 index 6c954d98..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_0_1.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include "test_libc_func.h" - -int pthread_mutex_init_0_1(void) -{ - pthread_mutex_t mutex; - int rc; - - /* Initialize a mutex object */ - if ((rc = pthread_mutex_init(&mutex, NULL)) != 0) { - fprintf(stderr, "Fail to initialize mutex, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Acquire the mutex object using pthread_mutex_lock */ - if ((rc = pthread_mutex_lock(&mutex)) != 0) { - fprintf(stderr, "Fail to lock the mutex, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - fprintf(stderr, "Main: hold the mutex for a while\n"); - tee_msleep(1000); - - if ((rc = pthread_mutex_init(&mutex, NULL)) == 0) { - fprintf(stderr, " initialize locked mutex, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Release the mutex object using pthread_mutex_unlock */ - if ((rc = pthread_mutex_unlock(&mutex)) != 0) { - fprintf(stderr, "Fail to unlock the mutex, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Destory the mutex object */ - if ((rc = pthread_mutex_destroy(&mutex)) != 0) { - fprintf(stderr, "Fail to destory the mutex, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_1_1.c deleted file mode 100644 index 5c7abbea..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_1_1.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include "test_libc_func.h" - -int pthread_mutex_init_1_1(void) -{ - pthread_mutexattr_t mta; - pthread_mutex_t mutex1, mutex2; - int rc; - - /* Initialize a mutex attributes object */ - if ((rc = pthread_mutexattr_init(&mta)) != 0) { - fprintf(stderr, "Error at pthread_mutexattr_init(), rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Initialize mutex1 with the default mutex attributes */ - if ((rc = pthread_mutex_init(&mutex1, &mta)) != 0) { - fprintf(stderr, "Fail to initialize mutex1, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Initialize mutex2 with NULL attributes */ - if ((rc = pthread_mutex_init(&mutex2, NULL)) != 0) { - fprintf(stderr, "Fail to initialize mutex2, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_2_1_0.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_2_1_0.c deleted file mode 100644 index f28a2d85..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_init_2_1_0.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include "test_libc_func.h" - -int pthread_mutex_init_2_1_0(void) -{ - pthread_mutex_t mutex; - int rc; - - /* Initialize a mutex object */ - if ((rc = pthread_mutex_init(&mutex, NULL)) != 0) { - fprintf(stderr, "Fail to initialize mutex, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Acquire the mutex object using pthread_mutex_lock */ - if ((rc = pthread_mutex_lock(&mutex)) != 0) { - fprintf(stderr, "Fail to lock the mutex, rc=%d\n", rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - fprintf(stderr, "Main: hold the mutex for a while\n"); - tee_msleep(1000); - - /* Release the mutex object using pthread_mutex_unlock */ - if ((rc = pthread_mutex_unlock(&mutex)) != 0) { - fprintf(stderr, "Fail to unlock the mutex, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Destory the mutex object */ - if ((rc = pthread_mutex_destroy(&mutex)) != 0) { - fprintf(stderr, "Fail to destory the mutex, rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_2.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_2.c deleted file mode 100644 index 354ec90d..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_2.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -#define THREAD_NUM 16 -#define LOOPS 50 -#define VAR_NUM 10 - -static void *f1(void *parm); - -static pthread_mutex_t mutex[VAR_NUM]; -static int value[VAR_NUM]; /* value protected by mutex */ - -int pthread_mutex_lock_0_2(void) -{ - int i, j, rc; - pthread_attr_t pta; - pthread_t threads[THREAD_NUM]; - //pthread_t self = pthread_self(); - - for (i = 0; i < VAR_NUM; i++) { - pthread_mutex_init(&mutex[i], NULL); - } - pthread_attr_init(&pta); - pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE); - - /* Create threads */ - fprintf(stderr, "Creating %d threads\n", THREAD_NUM); - for (i = 0; i < THREAD_NUM; ++i) { - rc = pthread_create(&threads[i], &pta, f1, (void *)(i + 1)); - if (rc) - return PTS_FAIL; - } - - /* Wait to join all threads */ - for (i = 0; i < THREAD_NUM; ++i) - pthread_join(threads[i], NULL); - pthread_attr_destroy(&pta); - for (i = 0; i < VAR_NUM; i++) { - pthread_mutex_destroy(&mutex[i]); - } - - for (j = 0; j < VAR_NUM; j++) { - /* Check if the final value is as expected */ - if (value[j] != (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS) { - fprintf(stderr, "Using %d threads and each loops %d times\n", THREAD_NUM, - LOOPS); - fprintf(stderr, "Final value must be %d instead of %d\n", - (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS, value[j]); - printf("Test FAILED\n"); - return PTS_FAIL; - } - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - -void *f1(void *parm) -{ - int i, tmp, j; - int rc = 0; - int step = (int)parm; - //pthread_t self = pthread_self(); - - /* Loopd M times to acquire the mutex, increase the value, - and then release the mutex. */ - - for (i = 0; i < LOOPS; ++i) { - for (j = 0; j < VAR_NUM; j++) { - rc = pthread_mutex_lock(&mutex[j]); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - - tmp = value[j]; - tmp = tmp + step; - //fprintf(stderr,"Thread(0x%p) holds the mutex\n",(void*)self); - //msleep(1); /* delay the increasement operation */ - value[j] = tmp; - - rc = pthread_mutex_unlock(&mutex[j]); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - //sleep(1); - } - } - pthread_exit(0); - return (void *)(0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_3.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_3.c deleted file mode 100644 index 2bcc9928..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_0_3.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -#define THREAD_NUM 16 -#define LOOPS 50 - -static void *f1(void *parm); - -static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER; -static int value; /* value protected by mutex */ - -int pthread_mutex_lock_0_3(void) -{ - int i, rc; - pthread_attr_t pta; - pthread_t threads[THREAD_NUM]; - //pthread_t self = pthread_self(); - - pthread_attr_init(&pta); - pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE); - - /* Create threads */ - fprintf(stderr, "Creating %d threads\n", THREAD_NUM); - for (i = 0; i < THREAD_NUM; ++i) { - rc = pthread_create(&threads[i], &pta, f1, (void *)(i + 1)); - if (rc) - return PTS_FAIL; - } - /* Wait to join all threads */ - for (i = 0; i < THREAD_NUM; ++i) - pthread_join(threads[i], NULL); - pthread_attr_destroy(&pta); - pthread_mutex_destroy(&mutex1); - pthread_mutex_destroy(&mutex2); - pthread_mutex_destroy(&mutex3); - - /* Check if the final value is as expected */ - if (value != (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS) { - fprintf(stderr, "Using %d threads and each loops %d times\n", THREAD_NUM, - LOOPS); - fprintf(stderr, "Final value must be %d instead of %d\n", - (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS, value); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - -void *f1(void *parm) -{ - int i, tmp; - int rc = 0; - int step = (int)parm; - //pthread_t self = pthread_self(); - - /* Loopd M times to acquire the mutex, increase the value, - and then release the mutex. */ - - for (i = 0; i < LOOPS; ++i) { - rc = pthread_mutex_lock(&mutex1); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - rc = pthread_mutex_lock(&mutex2); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - rc = pthread_mutex_lock(&mutex3); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - - tmp = value; - tmp = tmp + step; - //fprintf(stderr,"Thread(0x%p) holds the mutex\n",(void*)self); - //msleep(1); /* delay the increasement operation */ - value = tmp; - - rc = pthread_mutex_unlock(&mutex1); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - rc = pthread_mutex_unlock(&mutex2); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - rc = pthread_mutex_unlock(&mutex3); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - //sleep(1); - } - pthread_exit(0); - return (void *)(0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_1_1_0.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_1_1_0.c deleted file mode 100644 index 9e94b783..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_lock_1_1_0.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define THREAD_NUM 16 -#define LOOPS 50 - -static void *f1(void *parm); - -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -static int value; /* value protected by mutex */ - -int pthread_mutex_lock_1_1_0(void) -{ - int i, rc; - //pthread_attr_t pta; - pthread_t threads[THREAD_NUM]; - //pthread_t self = pthread_self(); - - /* Create threads */ - fprintf(stderr, "Creating %d threads\n", THREAD_NUM); - for (i = 0; i < THREAD_NUM; ++i) { - rc = pthread_create(&threads[i], NULL, f1, (void *)(i + 1)); - if (rc) - return PTS_FAIL; - } - //rc = pthread_create(&threads[i], &pta, f1, (void *)(i+1)); - - /* Wait to join all threads */ - for (i = 0; i < THREAD_NUM; ++i) - pthread_join(threads[i], NULL); - //pthread_attr_destroy(&pta); - pthread_mutex_destroy(&mutex); - - /* Check if the final value is as expected */ - if (value != (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS) { - fprintf(stderr, "Using %d threads and each loops %d times\n", THREAD_NUM, - LOOPS); - fprintf(stderr, "Final value must be %d instead of %d\n", - (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS, value); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - -static void *f1(void *parm) -{ - int i, tmp; - int rc = 0; - int step = (int)parm; - - /* Loopd M times to acquire the mutex, increase the value, - and then release the mutex. */ - - for (i = 0; i < LOOPS; ++i) { - rc = pthread_mutex_lock(&mutex); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - - tmp = value; - tmp = tmp + step; - //fprintf(stderr,"Thread(0x%p) holds the mutex\n",(void*)self); - //msleep(1); /* delay the increasement operation */ - value = tmp; - - rc = pthread_mutex_unlock(&mutex); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - //sleep(1); - } - pthread_exit(0); - return (void *)(0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_0_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_0_1.c deleted file mode 100644 index cbe2e854..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_0_1.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -static int flag = 0; -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -static void *func(void *parm) -{ - - if ((pthread_mutex_trylock(&mutex)) != EBUSY) { - - printf("child trylock not ebusy\n"); - pthread_exit((void *)PTS_UNRESOLVED); - } - flag = 1; - - pthread_exit(0); -} - -int pthread_mutex_trylock_0_1(void) -{ - int rc; - pthread_t t1; - - - /* Trylock the mutex and expect it returns EBUSY */ - rc = pthread_mutex_trylock(&mutex); - if (rc != 0) { - printf("Test FAILED trylock failed\n"); - return PTS_FAIL; - } - - rc = pthread_mutex_trylock(&mutex); - if (rc != EBUSY) { - printf("Test FAILED again trylock success\n"); - return PTS_FAIL; - } - - /* Create a secondary thread and wait until it has locked the mutex */ - pthread_create(&t1, NULL, func, NULL); - - /* Clean up */ - pthread_join(t1, NULL); - - pthread_mutex_unlock(&mutex); - - pthread_mutex_destroy(&mutex); - - if (flag == 0) - return PTS_FAIL; - - printf("Test PASSED\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_1_1.c deleted file mode 100755 index a0fb3a9e..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_1_1.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -static void *func(void *parm); - -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -static int t1_start = 0; -static int t1_pause = 1; - -int pthread_mutex_trylock_1_1(void) -{ - int i, rc; - pthread_t t1; - - /* Create a secondary thread and wait until it has locked the mutex */ - pthread_create(&t1, NULL, func, NULL); - while (!t1_start) { - printf("i2222Test PASSED\n"); - (void)sched_yield(); - } - - - printf("333i2222Test PASSED\n"); - /* Trylock the mutex and expect it returns EBUSY */ - rc = pthread_mutex_trylock(&mutex); - if (rc != EBUSY) { - //if(rc!=0) { - fprintf(stderr, "Expected %d(EBUSY), got %d\n", EBUSY, rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Allow the secondary thread to go ahead */ - t1_pause = 0; - - /* Trylock the mutex for N times */ - for (i = 0; i < 5; i++) { - rc = pthread_mutex_trylock(&mutex); - if (rc == 0) { - pthread_mutex_unlock(&mutex); - break; - } else if (rc == EBUSY) { - (void)sched_yield(); - continue; - } else { - fprintf(stderr, "Unexpected error code(%d) for pthread_mutex_lock()\n", rc); - return PTS_UNRESOLVED; - } - } - - /* Clean up */ - pthread_join(t1, NULL); - pthread_mutex_destroy(&mutex); - - if (i >= 5) { - fprintf(stderr, "Have tried %d times but failed to get the mutex\n", i); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} - -static void *func(void *parm) -{ - int rc; - // struct timespec time1; - // time1.tv_sec = 1; - // time1.tv_nsec = 0; - - if ((rc = pthread_mutex_lock(&mutex)) != 0) { - fprintf(stderr, "Error at pthread_mutex_lock(), rc=%d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - t1_start = 1; - - while (t1_pause) { - (void)(void)sched_yield(); -#if 0 - if (nanosleep(&time1, NULL) == -1) { - printf("Failed to nanosleep"); - } -#endif - } - printf("666666Test PASSED\n"); - - if ((rc = pthread_mutex_unlock(&mutex)) != 0) { - fprintf(stderr, "Error at pthread_mutex_unlock(), rc=%d\n", rc); - pthread_exit((void *)PTS_UNRESOLVED); - } - - printf("99666666Test PASSED\n"); - pthread_exit(0); - return (void *)(0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_4_1.c deleted file mode 100644 index bf81ebdd..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_trylock_4_1.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -int pthread_mutex_trylock_4_1(void) -{ - int rc; - - if ((rc = pthread_mutex_lock(&mutex)) != 0) { - fprintf(stderr, "Error at pthread_mutex_lock(), rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - rc = pthread_mutex_trylock(&mutex); - if (rc != EBUSY) { - fprintf(stderr, "Expected %d(EBUSY), got %d\n", EBUSY, rc); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - pthread_mutex_unlock(&mutex); - pthread_mutex_destroy(&mutex); - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_unlock_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_unlock_1_1.c deleted file mode 100644 index 9b2d7919..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutex_unlock_1_1.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -int pthread_mutex_unlock_1_1(void) -{ - int rc; - - /* Get the mutex using pthread_mutex_lock() */ - if ((rc = pthread_mutex_lock(&mutex)) != 0) { - fprintf(stderr, "Error at pthread_mutex_lock(), rc=%d\n", rc); - return PTS_UNRESOLVED; - } - - /* Release the mutex using pthread_mutex_unlock() */ - if ((rc = pthread_mutex_unlock(&mutex)) != 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Get the mutex using pthread_mutex_trylock() */ - if ((rc = pthread_mutex_trylock(&mutex)) != 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - - /* Release the mutex using pthread_mutex_unlock() */ - if ((rc = pthread_mutex_unlock(&mutex)) != 0) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_getprotocol_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_getprotocol_1_1.c deleted file mode 100755 index d6db5a68..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_getprotocol_1_1.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "1-1" -#define FUNCTION "pthread_mutexattr_getprotocol" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -static int verify_protocol(pthread_mutexattr_t *attr, int protocoltype) -{ - int rc; - int protocol; - - rc = pthread_mutexattr_getprotocol(attr, &protocol); - - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_getprotocol"); - return PTS_UNRESOLVED; - } - if (protocol != protocoltype) { - printf(ERROR_PREFIX "got wrong protocol param"); - return PTS_FAIL; - } - return 0; -} - -int pthread_mutexattr_getprotocol_1_1(void) -{ - int rc = 0; - pthread_mutexattr_t attr; - - rc = pthread_mutexattr_init(&attr); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_init"); - return PTS_UNRESOLVED; - } - - verify_protocol(&attr, PTHREAD_PRIO_NONE); - - rc = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_NONE); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_setprotocol"); - return PTS_UNRESOLVED; - } - verify_protocol(&attr, PTHREAD_PRIO_NONE); - - rc = pthread_mutexattr_setprotocol(&attr, !PTHREAD_PRIO_NONE); - if (ENOTSUP != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_setprotocol wrong protocol"); - return PTS_UNRESOLVED; - } - - rc = pthread_mutexattr_destroy(&attr); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_destroy"); - return PTS_UNRESOLVED; - } - printf("Test PASS\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_gettype_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_gettype_1_1.c deleted file mode 100755 index b74df07d..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_mutexattr_gettype_1_1.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define TEST "1-1" -#define FUNCTION "pthread_mutexattr_gettype" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " - -#define CORRECT_NUM (2) -#define WRONG_NUM (3) -#define ZERO_NUM (0) - -static int verify_type(pthread_mutexattr_t *attr, int typetype) -{ - int rc; - int type; - - rc = pthread_mutexattr_gettype(attr, &type); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_gettype"); - return PTS_UNRESOLVED; - } - if (type != typetype) { - printf(ERROR_PREFIX "got wrong type param"); - return PTS_FAIL; - } - return 0; -} - -int pthread_mutexattr_gettype_1_1(void) -{ - int rc = 0; - pthread_mutexattr_t attr; - - rc = pthread_mutexattr_init(&attr); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_init"); - return PTS_UNRESOLVED; - } - - rc = pthread_mutexattr_settype(&attr, WRONG_NUM); - if (EINVAL != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_settype"); - return PTS_UNRESOLVED; - } - - rc = pthread_mutexattr_settype(&attr, CORRECT_NUM); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_settype wrong type"); - return PTS_UNRESOLVED; - } - - verify_type(&attr, CORRECT_NUM); - - - rc = pthread_mutexattr_settype(&attr, ZERO_NUM); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_settype wrong type"); - return PTS_UNRESOLVED; - } - - verify_type(&attr, ZERO_NUM); - - rc = pthread_mutexattr_destroy(&attr); - if (0 != rc) { - printf(ERROR_PREFIX "pthread_mutexattr_destroy"); - return PTS_UNRESOLVED; - } - printf("Test PASS\n"); - return PTS_PASS; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_once_1_3.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_once_1_3.c deleted file mode 100644 index 84a175d2..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_once_1_3.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _POSIX_C_SOURCE 200112L - -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#ifndef VERBOSE -#define VERBOSE 1 -#endif - -#define NTHREADS 3 - -static int control; -static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; - -static void my_init(void) -{ - int ret = 0; - ret = pthread_mutex_lock(&mtx); - - if (ret != 0) { - printf("Failed to lock mutex in initializer\n"); - return; - } - - control++; - - ret = pthread_mutex_unlock(&mtx); - - if (ret != 0) { - printf("Failed to unlock mutex in initializer\n"); - return; - } - - return ; -} - -/* Thread function */ -static void *threaded(void *arg) -{ - int ret; - - ret = pthread_once(arg, my_init); - - if (ret != 0) { - printf("pthread_once failed\n"); - return PTS_FAIL; - } - - return NULL; -} - -/* The main test function. */ -int pthread_once_1_3(void) -{ - int ret, i; - - pthread_once_t myctl = PTHREAD_ONCE_INIT; - - pthread_t th[ NTHREADS ]; - - control = 0; - - /* Create the children */ - - for (i = 0; i < NTHREADS; i++) { - ret = pthread_create(&th[ i ], NULL, threaded, &myctl); - - if (ret != 0) { - printf("Failed to create a thread\n"); - return PTS_FAIL; - } - } - - /* Then join */ - for (i = 0; i < NTHREADS; i++) { - ret = pthread_join(th[ i ], NULL); - - if (ret != 0) { - printf("Failed to join a thread\n"); - return PTS_FAIL; - } - } - - /* Fetch the memory */ - ret = pthread_mutex_lock(&mtx); - - if (ret != 0) { - printf("Failed to lock mutex in initializer\n"); - return PTS_FAIL; - } - - if (control != 1) { - printf("Control: %d\n", control); - printf("The initializer function did not execute once\n"); - return PTS_FAIL; - } - - ret = pthread_mutex_unlock(&mtx); - - if (ret != 0) { - printf("Failed to unlock mutex in initializer\n"); - return PTS_FAIL; - } - - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_setspecific_1_2.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_setspecific_1_2.c deleted file mode 100644 index f9101a11..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_setspecific_1_2.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define KEY_VALUE_1 100 -#define KEY_VALUE_2 200 - -static pthread_key_t key; -void *rc1; -void *rc2; - -static void *a_thread_func(void *args) -{ - /* Bind a value to key for this thread (this will be different from the value - * that we bind for the main thread) */ - if (pthread_setspecific(key, (void *)(KEY_VALUE_2)) != 0) { - printf("Test FAILED: Could not set the value of the key to %d\n", - (KEY_VALUE_2)); - pthread_exit((void *)PTS_FAIL); - return NULL; - } - - /* Get the bound value of the key that we just set. */ - rc2 = pthread_getspecific(key); - - pthread_exit(0); - return NULL; - -} - -int pthread_setspecific_1_2(void) -{ - pthread_t new_th; - - /* Create the key */ - if (pthread_key_create(&key, NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); - return PTS_UNRESOLVED; - } - - /* Bind a value for this main thread */ - if (pthread_setspecific(key, (void *)(KEY_VALUE_1)) != 0) { - printf("Test FAILED: Could not set the value of the key to %d\n", - (KEY_VALUE_1)); - return PTS_FAIL; - } - - /* Create another thread. This thread will also bind a value to the key */ - if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { - printf("Error: in pthread_create()\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to end execution */ - pthread_join(new_th, NULL); - - /* Get the value associated for the key in this main thread */ - rc1 = pthread_getspecific(key); - - /* Compare this value with the value associated for the key in the newly created - * thread, they should be different. */ - if (rc1 != (void *)(KEY_VALUE_1)) { - printf("Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", - KEY_VALUE_1, (long)rc1); - return PTS_FAIL; - } - - if (rc2 != (void *)(KEY_VALUE_2)) { - printf("Test FAILED: Incorrect value bound to key, expected %d, got %ld\n", - KEY_VALUE_2, (long)rc2); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_0_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_0_1.c deleted file mode 100644 index e48485af..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_0_1.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -int pthread_spin_destroy_0_1(void) -{ - static pthread_spinlock_t spinlock; - - if (pthread_spin_destroy(&spinlock) == 0) { - printf("destroy uninitialized spinlock did not return non-zero\n"); - return PTS_FAIL; - } - - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_1_1.c deleted file mode 100755 index 6b0bcd1a..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_1_1.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; - -int pthread_spin_destroy_1_1(void) -{ - int rc = 0; - - printf("main: initialize spin lock\n"); - if (pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE) != 0) { - printf("main: Error at pthread_spin_init()\n"); - return PTS_UNRESOLVED; - } - - printf("main: attempt spin lock\n"); - - /* We should get the lock */ - if (pthread_spin_lock(&spinlock) != 0) { - printf("Unresolved: main cannot get spin lock when no one owns the lock\n"); - return PTS_UNRESOLVED; - } - - printf("main: acquired spin lock\n"); - - printf("main: unlock spin lock\n"); - if (pthread_spin_unlock(&spinlock) != 0) { - printf("main: Error at pthread_spin_unlock()\n"); - return PTS_UNRESOLVED; - } - - printf("main: destroy spin lock\n"); - rc = pthread_spin_destroy(&spinlock); - if (rc != 0) { - printf("Test FAILED: Error at pthread_spin_destroy()" - "Return code : %d\n", rc); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_3_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_3_1.c deleted file mode 100644 index 70272544..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_destroy_3_1.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; -static int ret_value = 0; -static void *fn_chld(void *arg) -{ - int rc = 0; - - printf("child: destroy spin lock\n"); - rc = pthread_spin_destroy(&spinlock); - if (rc == EBUSY) { - printf("child: correctly got EBUSY\n"); - printf("Test PASSED\n"); - } else { - printf("child: got return code %d, %s\n", rc, strerror(rc)); - printf("Test PASSED: *Note: Did not return EBUSY when destroying a spinlock already in use, but standard says 'may' fail\n"); - ret_value = 1; - } - pthread_exit(PTS_PASS); -} - -int pthread_spin_destroy_3_1(void) -{ - pthread_t child_thread; - - if (pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE) != 0) { - printf("main: Error at pthread_spin_init()\n"); - return PTS_UNRESOLVED; - } - - printf("main: attempt spin lock\n"); - - /* We should get the lock */ - if (pthread_spin_lock(&spinlock) != 0) { - printf("main cannot get spin lock when no one owns the lock\n"); - return PTS_UNRESOLVED; - } - printf("main: acquired spin lock\n"); - - printf("main: create thread\n"); - if (pthread_create(&child_thread, NULL, fn_chld, NULL) != 0) { - printf("main: Error creating child thread\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to end execution */ - pthread_join(child_thread, NULL); - - if (ret_value) - return PTS_FAIL; - - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_1_1.c deleted file mode 100644 index 42a4a6f6..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_1_1.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; - -int pthread_spin_init_1_1(void) -{ - int rc = 0; - int pshared; - - // #ifdef PTHREAD_PROCESS_PRIVATE - pshared = PTHREAD_PROCESS_PRIVATE; - // #else - // pshared = -1; - // #endif - - rc = pthread_spin_init(&spinlock, pshared); - if (rc != 0) { - printf("Test FAILED: Error at pthread_spin_init(): %d\n", rc); - return PTS_FAIL; - } - - printf("main: attempt spin lock\n"); - - /* We should get the lock */ - if (pthread_spin_lock(&spinlock) != 0) { - printf("Error: main cannot get spin lock when no one owns the lock\n"); - return PTS_UNRESOLVED; - } - - printf("main: acquired spin lock\n"); - - if (pthread_spin_unlock(&spinlock) != 0) { - printf("main: Error at pthread_spin_unlock()\n"); - return PTS_UNRESOLVED; - } - - rc = pthread_spin_destroy(&spinlock); - if (rc != 0) { - printf("Error at pthread_spin_destroy(): %d\n", rc); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_4_1.c deleted file mode 100644 index 5eee7822..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_init_4_1.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; -static int pshared; -static int ret_value = 0; -static void *fn_chld(void *arg) -{ - int rc; - /* child: initialize a spin lock being locked by main thread */ - printf("child: attempt initialize spin lock\n"); - rc = pthread_spin_init(&spinlock, pshared); - if (rc == EBUSY) - printf("child: correctly got EBUSY\n"); - else { - ret_value = 1; - printf("child: got return code %d, %s\n", rc, strerror(rc)); - printf("Test PASSED: *Note: Did not return EBUSY when initializing a spinlock already in use, but standard says 'may' fail\n"); - } - pthread_exit(PTS_PASS); -} - -int pthread_spin_init_4_1(void) -{ - int rc = 0; - pthread_t child_thread; - -#ifdef PTHREAD_PROCESS_PRIVATE - pshared = PTHREAD_PROCESS_PRIVATE; -#else - pshared = -1; -#endif - - printf("main: initialize spin lock\n"); - - rc = pthread_spin_init(&spinlock, pshared); - if (rc != 0) { - printf("Test FAILED: Error at pthread_spin_init()\n"); - return PTS_FAIL; - } - - printf("main: attempt spin lock\n"); - - /* We should get the lock */ - if (pthread_spin_lock(&spinlock) != 0) { - printf("Error: main cannot get spin lock when no one owns the lock\n"); - return PTS_UNRESOLVED; - } - - printf("main: acquired spin lock\n"); - - printf("main: create thread\n"); - if (pthread_create(&child_thread, NULL, fn_chld, NULL) != 0) { - printf("main: Error creating child thread\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to end execution */ - pthread_join(child_thread, NULL); - - if (ret_value == 1) - return PTS_FAIL; - - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_1.c deleted file mode 100644 index 36938f3f..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_1.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define THREAD_NUM 16 -#define LOOPS 1000 - -static void *f1(void *parm); - -static pthread_spinlock_t spinlock; -static int value; /* value protected by mutex */ - -int pthread_spin_lock_0_1(void) -{ - int i, rc; - pthread_attr_t pta; - pthread_t threads[THREAD_NUM]; - - pthread_attr_init(&pta); - pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE); - pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE); - /* Create threads */ - fprintf(stderr, "Creating %d threads\n", THREAD_NUM); - for (i = 0; i < THREAD_NUM; ++i) { - rc = pthread_create(&threads[i], &pta, f1, (void *)(i + 1)); - if (rc) - return PTS_FAIL; - } - - /* Wait to join all threads */ - for (i = 0; i < THREAD_NUM; ++i) - pthread_join(threads[i], NULL); - pthread_attr_destroy(&pta); - pthread_spin_destroy(&spinlock); - - /* Check if the final value is as expected */ - if (value != (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS) { - fprintf(stderr, "Using %d threads and each loops %d times\n", THREAD_NUM, - LOOPS); - fprintf(stderr, "Final value must be %d instead of %d\n", - (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS, value); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - -void *f1(void *parm) -{ - int i, tmp; - int rc = 0; - int step = (int)parm; - - /* Loopd M times to acquire the mutex, increase the value, - and then release the mutex. */ - - for (i = 0; i < LOOPS; ++i) { - rc = pthread_spin_lock(&spinlock); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - - tmp = value; - tmp = tmp + step; - //fprintf(stderr,"Thread(0x%p) holds the mutex\n",(void*)self); - //msleep(1); /* delay the increasement operation */ - value = tmp; - - rc = pthread_spin_unlock(&spinlock); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - //sleep(1); - } - pthread_exit(0); - return (void *)(0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_3.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_3.c deleted file mode 100644 index e0beca99..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_0_3.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 - -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -#define THREAD_NUM 16 -#define LOOPS 1000 - -static void *f1(void *parm); - -static pthread_spinlock_t spinlock1;//mutex1 = PTHREAD_MUTEX_INITIALIZER; -static pthread_spinlock_t spinlock2;//mutex2 = PTHREAD_MUTEX_INITIALIZER; -static pthread_spinlock_t spinlock3;//mutex3 = PTHREAD_MUTEX_INITIALIZER; -static int value; /* value protected by mutex */ - -int pthread_spin_lock_0_3(void) -{ - int i, rc; - pthread_attr_t pta; - pthread_t threads[THREAD_NUM]; - - pthread_attr_init(&pta); - pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE); - - pthread_spin_init(&spinlock1, PTHREAD_PROCESS_PRIVATE); - pthread_spin_init(&spinlock2, PTHREAD_PROCESS_PRIVATE); - pthread_spin_init(&spinlock3, PTHREAD_PROCESS_PRIVATE); - /* Create threads */ - fprintf(stderr, "Creating %d threads\n", THREAD_NUM); - for (i = 0; i < THREAD_NUM; ++i) - rc = pthread_create(&threads[i], &pta, f1, (void *)(i + 1)); - - /* Wait to join all threads */ - for (i = 0; i < THREAD_NUM; ++i) - pthread_join(threads[i], NULL); - pthread_attr_destroy(&pta); - pthread_spin_destroy(&spinlock1); - pthread_spin_destroy(&spinlock2); - pthread_spin_destroy(&spinlock3); - - /* Check if the final value is as expected */ - if (value != (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS) { - fprintf(stderr, "Using %d threads and each loops %d times\n", THREAD_NUM, - LOOPS); - fprintf(stderr, "Final value must be %d instead of %d\n", - (1 + THREAD_NUM) * THREAD_NUM / 2 * LOOPS, value); - printf("Test FAILED\n"); - return PTS_FAIL; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} - -void *f1(void *parm) -{ - int i, tmp; - int rc = 0; - int step = (int)parm; - - /* Loopd M times to acquire the mutex, increase the value, - and then release the mutex. */ - - for (i = 0; i < LOOPS; ++i) { - rc = pthread_spin_lock(&spinlock1); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - rc = pthread_spin_lock(&spinlock2); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - rc = pthread_spin_lock(&spinlock3); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_lock(), rc=%d\n", rc); - return (void *)(PTS_FAIL); - } - - tmp = value; - tmp = tmp + step; - //fprintf(stderr,"Thread(0x%p) holds the mutex\n",(void*)self); - //msleep(1); /* delay the increasement operation */ - value = tmp; - - rc = pthread_spin_unlock(&spinlock1); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - rc = pthread_spin_unlock(&spinlock2); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - rc = pthread_spin_unlock(&spinlock3); - if (rc != 0) { - fprintf(stderr, "Error on pthread_mutex_unlock(), rc=%d\n", rc); - return (void *)(PTS_UNRESOLVED); - } - //sleep(1); - } - pthread_exit(0); - return (void *)(0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_3_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_3_1.c deleted file mode 100644 index 3a294c67..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_lock_3_1.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -int pthread_spin_lock_3_1(void) -{ - int rc = 0; - pthread_spinlock_t spinlock; - - - if (pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE) != 0) { - printf("main: Error at pthread_spin_init()\n"); - return PTS_UNRESOLVED; - } - - printf("main: attempt spin lock\n"); - - /* We should get the lock */ - if (pthread_spin_lock(&spinlock) != 0) { - printf("Test FAILED: main cannot get spin lock when no one owns the lock\n"); - return PTS_FAIL; - } - printf("main: acquired spin lock\n"); - - - printf("main: re-lock spin lock\n"); - //rc = pthread_spin_lock(&spinlock); - - if (rc == EDEADLK) { - printf("main: correctly got EDEADLK when re-locking the spin lock\n"); - printf("Test PASSED\n"); - } else { - printf("main: get return code: %d , %s\n", rc, strerror(rc)); - printf("Test PASSED: *Note: Did not return EDEADLK when re-locking a spinlock already in use, but standard says 'may' fail\n"); - return PTS_FAIL; - } - /* Unlock spinlock */ - pthread_spin_unlock(&spinlock); - - /* Destroy spinlock */ - pthread_spin_destroy(&spinlock); - - return PTS_PASS; -} - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_0_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_0_1.c deleted file mode 100644 index 8fc03107..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_0_1.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; - -#define NOT_CREATED_THREAD 1 -#define ENTERED_THREAD 2 -#define EXITING_THREAD 3 - -int pthread_spin_trylock_0_1(void) -{ - if (pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE) != 0) { - printf("main: Error at pthread_spin_init()\n"); - return PTS_UNRESOLVED; - } - - printf("main: attempt to trylock\n"); - - /* We should get the lock */ - if (pthread_spin_trylock(&spinlock) != 0) { - printf("Test FAILED: main cannot get spin lock when no one owns the lock\n"); - return PTS_FAIL; - } - printf("main: acquired spin lock\n"); - - - if (pthread_spin_trylock(&spinlock) != EBUSY) { - printf("Test FAILED: main trylock again is not EBUSY\n"); - return PTS_FAIL; - } - - printf("thread: correctly returned EBUSY on trylock\n"); - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_1_1.c deleted file mode 100644 index b034b9cb..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_1_1.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; -volatile static int thread_state; -static int rc; - -#define NOT_CREATED_THREAD 1 -#define ENTERED_THREAD 2 -#define EXITING_THREAD 3 - - -static void *fn_chld(void *arg) -{ - rc = 0; - - thread_state = ENTERED_THREAD; - - printf("thread: attempt trylock\n"); - rc = pthread_spin_trylock(&spinlock); - - pthread_exit(0); - return NULL; -} - -int pthread_spin_trylock_1_1(void) -{ - pthread_t child_thread; - - if (pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE) != 0) { - printf("main: Error at pthread_spin_init()\n"); - return PTS_UNRESOLVED; - } - - printf("main: attempt to trylock\n"); - - /* We should get the lock */ - if (pthread_spin_trylock(&spinlock) != 0) { - printf("Test FAILED: main cannot get spin lock when no one owns the lock\n"); - return PTS_FAIL; - } - printf("main: acquired spin lock\n"); - - thread_state = NOT_CREATED_THREAD; - printf("main: create thread\n"); - if (pthread_create(&child_thread, NULL, fn_chld, NULL) != 0) { - printf("main: Error creating child thread\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to end execution */ - pthread_join(child_thread, NULL); - - /* Check the return code of pthread_spin_trylock */ - if (rc != EBUSY) { - printf("Test FAILED: pthread_spin_trylock should return EBUSY, instead got error code:%d\n" - , rc); - return PTS_FAIL; - } - - printf("thread: correctly returned EBUSY on trylock\n"); - printf("Test PASSED\n"); - return PTS_PASS; - -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1.c deleted file mode 100755 index b4c0bac1..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - - -int pthread_spin_trylock_4_1(void) -{ - - pthread_spinlock_t spinlock; - int rc; - - /* attemp to lock an uninitalized spin lock */ - - rc = pthread_spin_trylock(&spinlock); - if (rc == EINVAL) { - printf("Correctly got EINVAL at pthread_spin_trylock()\n"); - printf("Test PASSED\n"); - } else { - printf("Expected EINVAL, but get return code: %d,%s\n", rc, strerror(rc)); - printf("Test PASSED: *Note: Returned incorrect value, but standard says 'may' fail\n"); - } - - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1_0.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1_0.c deleted file mode 100644 index bc45b33b..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_trylock_4_1_0.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - - -int pthread_spin_trylock_4_1_0(void) -{ - - pthread_spinlock_t spinlock; - int rc; - - /* attemp to lock an uninitalized spin lock */ - - rc = pthread_spin_trylock(&spinlock); - if (rc == EINVAL) { - printf("Correctly got EINVAL at pthread_spin_trylock()\n"); - printf("Test PASSED\n"); - } else { - printf("Expected EINVAL, but get return code: %d,%s\n", rc, strerror(rc)); - printf("Test PASSED: *Note: Returned incorrect value, but standard says 'may' fail\n"); - return PTS_FAIL; - } - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_unlock_1_1.c b/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_unlock_1_1.c deleted file mode 100644 index fc840cad..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/pthread_spin_unlock_1_1.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#define _XOPEN_SOURCE 600 -#include -#include -#include -#include -#include - -#include "test_libc_func.h" - -static pthread_spinlock_t spinlock; -volatile static int thread_state; - -#define NOT_CREATED_THREAD 1 -#define ENTERED_THREAD 2 -#define EXITING_THREAD 3 - -static void *fn_chld(void *arg) -{ - int rc = 0; - thread_state = ENTERED_THREAD; - - printf("thread: attempt trylock\n"); - rc = pthread_spin_trylock(&spinlock); - if (rc != 0) { - printf("Test FAILED: thread failed to get spin lock," - "Error code:%d\n", rc); - return PTS_FAIL; - } - printf("thread: acquired spin lock\n"); - - printf("thread: unlock spin lock\n"); - if (pthread_spin_unlock(&spinlock)) { - printf("thread: Error at pthread_spin_unlock()\n"); - return PTS_FAIL; - } - - thread_state = EXITING_THREAD; - pthread_exit(0); - return NULL; -} - -int pthread_spin_unlock_1_1(void) -{ - int rc; - - pthread_t child_thread; - - if (pthread_spin_init(&spinlock, PTHREAD_PROCESS_PRIVATE) != 0) { - printf("main: Error at pthread_spin_init()\n"); - return PTS_UNRESOLVED; - } - - printf("main: attempt spin lock\n"); - - /* We should get the lock */ - if (pthread_spin_lock(&spinlock) != 0) { - printf("main: cannot get spin lock when no one owns the lock\n"); - return PTS_UNRESOLVED; - } - printf("main: acquired spin lock\n"); - - printf("main: unlock spin lock\n"); - rc = pthread_spin_unlock(&spinlock); - if (rc != 0) { - printf("main: Error at pthread_spin_unlock()\n"); - return PTS_FAIL; - } - - thread_state = NOT_CREATED_THREAD; - printf("main: create thread\n"); - if (pthread_create(&child_thread, NULL, fn_chld, NULL) != 0) { - printf("main: Error creating thread\n"); - return PTS_UNRESOLVED; - } - - /* Wait for thread to end execution */ - if (pthread_join(child_thread, NULL) != 0) { - printf("main: Error at pthread_join()\n"); - return PTS_UNRESOLVED; - } - - printf("main: try to lock again when thread unlocked\n"); - if (pthread_spin_trylock(&spinlock) != 0) { - printf("main: Should get spin lock\n"); - return PTS_FAIL; - } - - printf("main: acquired spin lock\n"); - printf("main: unlock spin lock\n"); - if (pthread_spin_unlock(&spinlock) != 0) { - printf("Test FAILED: main: Error at pthread_spin_unlock()\n"); - return PTS_FAIL; - } - - if (pthread_spin_destroy(&spinlock) != 0) { - printf("Error at pthread_spin_destroy()"); - return PTS_UNRESOLVED; - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test-string.c b/test/xts/ta/test_libc_api/src/libc_func/test-string.c deleted file mode 100644 index 288b036a..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test-string.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include "test_libc_func.h" - -#define STREQ(a, b) (strcmp((a), (b)) == 0) - -int test_rt = 0; -const char *it = ""; - -static void check(int thing, int number) -{ - if (!thing) { - printf("%s %d test failed.\n", it, number); - test_rt++; - } -} - -static void equal(const char *a, const char *b, int number) -{ - check(a != NULL && b != NULL && STREQ(a, b), number); -} - -int do_test_memcmp(void) -{ - printf("start memcmp test printf\n"); - int cnt = 1; - int i; - char one[21]; - char two[21]; - - it = "memcmp"; - test_rt = 0; - - check(memcmp("a", "a", 1) == 0, cnt++); /* Identity. */ - check(memcmp("abc", "abc", 3) == 0, cnt++); /* Multicharacter. */ - check(memcmp("abcd", "abcf", 4) < 0, cnt++); /* Honestly unequal. */ - check(memcmp("abcf", "abcd", 4) > 0, cnt++); - check(memcmp("alph", "cold", 4) < 0, cnt++); - check(memcmp("a\203", "a\003", 2) > 0, cnt++); - check(memcmp("a\003", "a\203", 2) < 0, cnt++); - check(memcmp("a\003bc", "a\203bc", 2) < 0, cnt++); - check(memcmp("abc\203", "abc\003", 4) > 0, cnt++); - check(memcmp("abc\003", "abc\203", 4) < 0, cnt++); - check(memcmp("abcf", "abcd", 3) == 0, cnt++); /* Count limited. */ - check(memcmp("abc", "def", 0) == 0, cnt++); /* Zero count. */ - /* Comparisons with shifting 4-byte boundaries. */ - for (i = 0; i < 4; ++i) { - char *a = one + i; - char *b = two + i; - strncpy(a, "--------11112222", 16); - strncpy(b, "--------33334444", 16); - check(memcmp(b, a, 16) > 0, cnt++); - check(memcmp(a, b, 16) < 0, cnt++); - } - - return test_rt; -} - -int do_test_strcmp(void) -{ - it = "strcmp"; - test_rt = 0; - - check(strcmp("", "") == 0, 1); /* Trivial case. */ - check(strcmp("a", "a") == 0, 2); /* Identity. */ - check(strcmp("abc", "abc") == 0, 3); /* Multicharacter. */ - check(strcmp("abc", "abcd") < 0, 4); /* Length mismatches. */ - check(strcmp("abcd", "abc") > 0, 5); - check(strcmp("abcd", "abce") < 0, 6); /* Honest miscompares. */ - check(strcmp("abce", "abcd") > 0, 7); - check(strcmp("a\203", "a") > 0, 8); /* Tricky if char signed. */ - check(strcmp("a\203", "a\003") > 0, 9); - - char buf1[0x40], buf2[0x40]; - int i, j; - for (i = 0; i < 0x10; i++) { - for (j = 0; j < 0x10; j++) { - int k; - for (k = 0; k < 0x3f; k++) { - buf1[k] = '0' ^ (k & 4); - buf2[k] = '4' ^ (k & 4); - } - buf1[i] = buf1[0x3f] = 0; - buf2[j] = buf2[0x3f] = 0; - for (k = 0; k < 0xf; k++) { - int cnum = 0x10 + 0x10 * k + 0x100 * j + 0x1000 * i; - check(strcmp(buf1 + i, buf2 + j) == 0, cnum); - buf1[i + k] = 'A' + i + k; - buf1[i + k + 1] = 0; - check(strcmp(buf1 + i, buf2 + j) > 0, cnum + 1); - check(strcmp(buf2 + j, buf1 + i) < 0, cnum + 2); - buf2[j + k] = 'B' + i + k; - buf2[j + k + 1] = 0; - check(strcmp(buf1 + i, buf2 + j) < 0, cnum + 3); - check(strcmp(buf2 + j, buf1 + i) > 0, cnum + 4); - buf2[j + k] = 'A' + i + k; - buf1[i] = 'A' + i + 0x80; - check(strcmp(buf2 + j, buf1 + i) < 0, cnum + 6); - buf1[i] = 'A' + i; - } - } - } - return test_rt; -} - -int do_test_strchr(void) -{ - it = "strchr"; - test_rt = 0; - char one[50]; - - check(strchr("abcd", 'z') == NULL, 1); /* Not found. */ - (void) strcpy(one, "abcd"); - check(strchr(one, 'c') == one + 2, 2); /* Basic test. */ - check(strchr(one, 'd') == one + 3, 3); /* End of string. */ - check(strchr(one, 'a') == one, 4); /* Beginning. */ - // check(strchr(one, '\0') == one + 4, 5); /* Finding NUL. */ - (void) strcpy(one, "ababa"); - check(strchr(one, 'b') == one + 1, 6); /* Finding first. */ - (void) strcpy(one, ""); - check(strchr(one, 'b') == NULL, 7); /* Empty string. */ - // check(strchr(one, '\0') == one, 8); /* NUL in empty string. */ - - char buf[4096]; - int i; - char *p; - for (i = 0; i < 0x100; i++) { - p = (char *)((unsigned long int)(buf + 0xff) & ~0xff) + i; - strcpy(p, "OK"); - strcpy(p + 3, "BAD/WRONG"); - check(strchr(p, '/') == NULL, 9 + i); - } - return test_rt; -} - -int do_test_strlen(void) -{ - it = "strlen"; - test_rt = 0; - - check(strlen("") == 0, 1); /* Empty. */ - check(strlen("a") == 1, 2); /* Single char. */ - check(strlen("abcd") == 4, 3); /* Multiple chars. */ - char buf[4096]; - int i; - char *p; - for (i = 0; i < 0x100; i++) { - p = (char *)((unsigned long int)(buf + 0xff) & ~0xff) + i; - strcpy(p, "OK"); - strcpy(p + 3, "BAD/WRONG"); - check(strlen(p) == 2, 4 + i); - } - return test_rt; -} - -int do_test_memset(void) -{ - int i; - - it = "memset"; - test_rt = 0; - char one[50]; - (void) strcpy(one, "abcdefgh"); - check((char *)memset(one + 1, 'x', 3) == one + 1, 1); /* Return value. */ - equal(one, "axxxefgh", 2); /* Basic test. */ - - (void) memset(one + 5, 0, 1); - equal(one, "axxxe", 4); /* Zero fill. */ - equal(one + 6, "gh", 5); /* And the leftover. */ - - (void) memset(one + 2, 010045, 1); - equal(one, "ax\045xe", 6); /* Unsigned char convert. */ - - /* Non-8bit fill character. */ - memset(one, 0x101, sizeof(one)); - for (i = 0; i < (int) sizeof(one); ++i) - check(one[i] == '\01', 7); - - /* Test for more complex versions of memset, for all alignments and - lengths up to 256. This test takes a little while, perhaps it should - be made weaker? */ - char data[512]; - int j; - int k; - int c; - - for (i = 0; i < 512; i++) - data[i] = 'x'; - for (c = 0; c <= 'y'; c += 'y') /* check for memset(,0,) and - memset(,'y',) */ - for (j = 0; j < 256; j++) - for (i = 0; i < 256; i++) { - memset(data + i, c, j); - for (k = 0; k < i; k++) - if (data[k] != 'x') - goto fail; - for (k = i; k < i + j; k++) { - if (data[k] != c) - goto fail; - data[k] = 'x'; - } - for (k = i + j; k < 512; k++) - if (data[k] != 'x') - goto fail; - continue; - -fail: - check(0, 8 + i + j * 256 + (c != 0) * 256 * 256); - } - return test_rt; -} - -int do_test_memmove(void) -{ - it = "memmove"; - test_rt = 0; - char one[50]; - char two[50]; - - check((char *)memmove(one, "abc", 4) == one, 1); /* Returned value. */ - equal(one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one + 1, "xyz", 2); - equal(one, "axydefgh", 3); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) memmove(one, "xyz", 0); - equal(one, "abc", 4); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) memmove(two, one, 9); - equal(two, "hi there", 5); /* Just paranoia. */ - equal(one, "hi there", 6); /* Stomped on source? */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one + 1, one, 9); - equal(one, "aabcdefgh", 7); /* Overlap, right-to-left. */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one + 1, one + 2, 7); - equal(one, "acdefgh", 8); /* Overlap, left-to-right. */ - - (void) strcpy(one, "abcdefgh"); - (void) memmove(one, one, 9); - equal(one, "abcdefgh", 9); /* 100% overlap. */ - - return test_rt; -} - -int do_test_memcpy(void) -{ - int i; - it = "memcpy"; - char one[50]; - char two[50]; - test_rt = 0; - - - check((char *)memcpy(one, "abc", 4) == one, 1); /* Returned value. */ - equal(one, "abc", 2); /* Did the copy go right? */ - - (void) strcpy(one, "abcdefgh"); - (void) memcpy(one + 1, "xyz", 2); - equal(one, "axydefgh", 3); /* Basic test. */ - - (void) strcpy(one, "abc"); - (void) memcpy(one, "xyz", 0); - equal(one, "abc", 4); /* Zero-length copy. */ - - (void) strcpy(one, "hi there"); - (void) strcpy(two, "foo"); - (void) memcpy(two, one, 9); - equal(two, "hi there", 5); /* Just paranoia. */ - equal(one, "hi there", 6); /* Stomped on source? */ - - for (i = 0; i < 16; i++) { - const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; - strcpy(one, x); - check(memcpy(one + i, "hi there", 9) == one + i, - 7 + (i * 6)); /* Unaligned destination. */ - check(memcmp(one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */ - equal(one + i, "hi there", 9 + (i * 6)); - check(one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */ - check(memcpy(two, one + i, 9) == two, - 11 + (i * 6)); /* Unaligned source. */ - equal(two, "hi there", 12 + (i * 6)); - } - - return test_rt; -} - -static int tst_wmemchr4(void) -{ - wchar_t s1[] = L"adbabcd"; - wchar_t s2[] = L"abca"; - wchar_t *sret; - size_t isize = 4; - int ret = -1; - sret = wmemchr(s1, L'a', isize); - ret = memcmp(s2, sret, strlen((char *)s2)); - return ret; -} - -static int tst_wmemchr3(void) -{ - wchar_t s1[] = L"abcdefg"; - wchar_t *sret; - sret = wmemchr(s1, L'h', 1); - if (sret != NULL) return -1; - return 0; -} - -static int tst_wmemchr2(void) -{ - wchar_t s1[] = L"abcdefhhijklmnopqrstuvwxyz"; - wchar_t s2[] = L"abcd"; - wchar_t *sret; - size_t isize = 4; - int ret = -1; - sret = wmemchr(s1, L'a', isize); - ret = memcmp(s2, sret, strlen((char *)s2)); - return ret; -} - -static int tst_wmemchr1(void) -{ - wchar_t s1[] = L"abcdefhhijklmnopqrstuvwxyz"; - wchar_t s2[] = L"abcdefhhijklmnopqrstuvwxyz"; - wchar_t *sret; - size_t isize = 26; - int ret; - sret = wmemchr(s1, L'a', isize); - ret = memcmp(s2, sret, strlen((char *)s2)); - return ret; -} - -int do_test_wmemchr(void) -{ - int ret = 0; - - if ((ret = tst_wmemchr1()) != 0) return ret; - if ((ret = tst_wmemchr2()) != 0) return ret; - if ((ret = tst_wmemchr3()) != 0) return ret; - if ((ret = tst_wmemchr4()) != 0) return ret; - - return ret; -} - -int do_test_wcslen(void) -{ - if (wcslen(L"0123456789\nabcdefghijklmnopqrstuvwxyz") != 37) return -1; - if (wcslen(L"0123测试abc") != 9) return -2; - if (wcslen(L"\n") != 1) return -3; - if (wcslen(L"\r") != 1) return -4; - if (wcslen(L"") != 0) return -5; - if (wcslen(L"测试") != 2) return -6; - - return 0; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_ctype.c b/test/xts/ta/test_libc_api/src/libc_func/test_ctype.c deleted file mode 100644 index 91bf2209..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_ctype.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -int do_test_ctype(void) -{ - printf("=== test ctype begin ===\n"); - if (isdigit('9') == 0) { - printf("Failed: isdigit test failed\n"); - return -1; - } - if (isascii('a') == 0) { - printf("Failed: isascii test failed\n"); - return -1; - } - if (islower('A') != 0) { - printf("ERROR: islower test failed\n"); - return -1; - } - if (isspace(' ') == 0) { - printf("ERROR: isspace test failed\n"); - return -1; - } - wchar_t wc = L'T'; - if (towlower(wc) != L't') { - printf("ERROR: towlower test failed\n"); - return -1; - } - wint_t a = L'1'; - if (iswdigit(a) == 0) { - printf("ERROR: iswdigit test failed\n"); - return -1; - } - // now, locale only support C or UTF-8, __ctype_get_mb_cur_max should be 1 or 4 - unsigned long nbytes = __ctype_get_mb_cur_max(); - if (nbytes != 4 && nbytes != 1) { - printf("Failed: locale only support C or UTF-8, __ctype_get_mb_cur_max should return 1 or 4, but got %lu\n", - nbytes); - return -1; - } - printf("=== test ctype end ===\n\n"); - return 0; -} - - -int do_test_wctype(void) -{ - int result = 0; - wctype_t bit_alnum = wctype("alnum"); - wctype_t bit_alpha = wctype("alpha"); - wctype_t bit_cntrl = wctype("cntrl"); - wctype_t bit_digit = wctype("digit"); - wctype_t bit_graph = wctype("graph"); - wctype_t bit_lower = wctype("lower"); - wctype_t bit_print = wctype("print"); - wctype_t bit_punct = wctype("punct"); - wctype_t bit_space = wctype("space"); - wctype_t bit_upper = wctype("upper"); - wctype_t bit_xdigit = wctype("xdigit"); - int ch; - - if (wctype("does not exist") != 0) { - puts("wctype return value != 0 for non existing property"); - result = 1; - } - - for (ch = 0; ch < 256; ++ch) { -#define TEST(test) \ - do \ - { \ - if ((is##test (ch) == 0) != (iswctype (btowc(ch), bit_##test) == 0)) \ - { \ - printf ("`iswctype' class `%s' test " \ - "for character \\%o failed\n", #test, ch); \ - result = 1; \ - } \ - if ((is##test (ch) == 0) != (isw##test (btowc(ch)) == 0)) \ - { \ - printf ("`isw%s' test for character \\%o failed\n", \ - #test, ch); \ - result = 1; \ - } \ - } \ - while (0) - - TEST(alnum); - TEST(alpha); - TEST(cntrl); - TEST(digit); - TEST(graph); - TEST(lower); - TEST(print); - TEST(punct); - TEST(space); - TEST(upper); - TEST(xdigit); - } - - if (result == 0) - puts("All test successful!"); - return result; -} - -int do_test_towfun(void) -{ - int result = 0; - wint_t ch; - - for (ch = 0; ch < 128; ++ch) { - if (iswlower(ch)) { - /* Get corresponding upper case character. */ - wint_t up = towupper(ch); - /* This should have no effect. */ - wint_t low = towlower(ch); - - if ((ch != low) || (up == ch) || (up == low)) { - printf("iswlower/towupper/towlower for character \\%x failed\n", ch); - result++; - } - } - - if (iswupper(ch)) { - /* Get corresponding lower case character. */ - wint_t low = towlower(ch); - /* This should have no effect. */ - wint_t up = towupper(ch); - - if ((ch != up) || (low == ch) || (up == low)) { - printf("iswupper/towlower/towupper for character \\%x failed\n", ch); - result++; - } - } - } - - /* Finally some specific tests. */ - ch = L'A'; - if (!iswupper(ch) || iswlower(ch)) { - printf("!iswupper/iswlower (L'A') failed\n"); - result++; - } - - ch = L'a'; - if (iswupper(ch) || !iswlower(ch)) { - printf("iswupper/!iswlower (L'a') failed\n"); - result++; - } - - if (towlower(L'A') != L'a') { - printf("towlower(L'A') failed\n"); - result++; - } - - if (towupper(L'a') != L'A') { - printf("towupper(L'a') failed\n"); - result++; - } - - if (result == 0) - puts("All test successful!"); - - return result; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_error.c b/test/xts/ta/test_libc_api/src/libc_func/test_error.c deleted file mode 100644 index 027b1667..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_error.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -int test_error(void) -{ - printf("=== test error begin ===\n"); - const char *str = "File descriptor in bad state"; - errno = EBADFD; - char *msg = strerror(errno); - if (strcmp(str, msg) != 0) { - printf("Failed: errno and strerror failed\n"); - return -1; - } - printf("=== test error end ===\n\n"); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_getpid.c b/test/xts/ta/test_libc_api/src/libc_func/test_getpid.c deleted file mode 100644 index 9e5f6ffb..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_getpid.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -static pid_t pid; -int test_err = 0; - -static void *tf(void *a) -{ - if (getpid() != pid) { - printf("test error:pid mismatch\n"); - test_err++; - } - - return a; -} - -int do_test_getpid(void) -{ - pid = getpid(); - -#define N 2 - pthread_t t[N]; - int i; - - for (i = 0; i < N; ++i) - if (pthread_create(&t[i], NULL, tf, (void *)(long int)(i + 1)) != 0) { - printf("pthread create failed\n"); - test_err++; - } else - printf("created thread %d\n", i); - - for (i = 0; i < N; ++i) { - void *r; - int e; - if ((e = pthread_join(t[i], &r)) != 0) { - printf("join failed: %d\n", e); - test_err++; - } else if (r != (void *)(long int)(i + 1)) { - printf("result wrong\n"); - test_err++; - } else - printf("joined thread %d\n", i); - } - - return test_err; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_libc_func.h b/test/xts/ta/test_libc_api/src/libc_func/test_libc_func.h deleted file mode 100644 index d7aa62b3..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_libc_func.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_LIBC_FUNC_H__ -#define __TEST_LIBC_FUNC_H__ - -#include -#include - -#define PTS_PASS 0 -#define PTS_FAIL 1 -#define PTS_UNRESOLVED 2 -#define PTS_UNSUPPORTED 4 -#define PTS_UNTESTED 5 - -int pthread_create_1_1(void); -int pthread_create_2_1(void); -int pthread_create_4_1(void); -int pthread_create_5_1(void); -int pthread_create_5_2(void); -int pthread_create_12_1(void); -int pthread_attr_destroy_1_1(void); -int pthread_attr_destroy_2_1(void); -int pthread_attr_destroy_3_1(void); -int pthread_attr_getstack_1_1(void); -int pthread_attr_getstacksize_1_1(void); -int pthread_attr_init_1_1(void); -int pthread_attr_init_3_1(void); -int pthread_attr_init_4_1(void); -int pthread_attr_setstack_1_1(void); -int pthread_attr_setstack_2_1(void); -int pthread_attr_setstack_4_1(void); -int pthread_attr_setstack_6_1(void); -int pthread_attr_setstack_7_1(void); -int pthread_attr_setstacksize_1_1(void); -int pthread_attr_setstacksize_2_1(void); -int pthread_attr_setstacksize_4_1(void); -int pthread_exit_2_1(void); -int pthread_exit_3_1(void); -int pthread_mutex_destroy_1_1(void); -int pthread_once_1_1(void); -int pthread_spin_destroy_1_1(void); -int pthread_spin_trylock_4_1(void); -int pthread_mutexattr_getprotocol_1_1(void); -int pthread_mutexattr_gettype_1_1(void); -int test_sem(void); - -//pthread -int pthread_once_1_3(void); -int pthread_exit_0_1(void); -int pthread_exit_0_2(void); -int pthread_exit_1_1_0(void); -int pthread_exit_3_1_0(void); -int pthread_mutex_init_1_1(void); -int pthread_mutex_init_2_1_0(void); -int pthread_mutex_lock_0_2(void); -int pthread_mutex_lock_0_3(void); -int pthread_mutex_lock_1_1_0(void); -int pthread_mutex_trylock_0_1(void); -int pthread_mutex_trylock_1_1(void); -int pthread_mutex_trylock_4_1(void); -int pthread_mutex_unlock_1_1(void); -int pthread_mutex_destroy_1_1_0(void); -int pthread_mutex_destroy_2_1(void); -int pthread_mutex_destroy_4_2(void); -int pthread_spin_init_1_1(void); -int pthread_spin_lock_0_1(void); -int pthread_spin_lock_0_3(void); -int pthread_spin_trylock_0_1(void); -int pthread_spin_trylock_1_1(void); -int pthread_spin_unlock_1_1(void); -int pthread_cond_broadcast_1_1(void); -int pthread_cond_init_1_1(void); -int pthread_cond_wait_0_1(void); -int pthread_cond_wait_0_2(void); -int pthread_cond_wait_0_3(void); -int test_pthread_key_create(void); -int test_pthread_equal(void); -int pthread_getspecific_1_1(void); -int pthread_setspecific_1_2(void); - -//mem -int do_test_calloc(void); -int do_test_malloc(void); -int do_test_free(void); -int do_test_free_1(void); -int test_mmap(void); - -//math -int do_test_atan(void); -int do_test_ceil(void); -int do_test_ceilf(void); -int do_test_exp(void); -int do_test_fabs(void); -int do_test_floor(void); -int do_test_frexpl(void); -int do_test_log(void); -int do_test_log2(void); -int do_test_pow(void); -int do_test_roundf(void); -int do_test_sqrt(void); - -//stdlib -int do_test_stdlib(void); -int do_test_strtol(void); -int do_test_getenv(void); - -//ctype -int do_test_ctype(void); -int do_test_wctype(void); -int do_test_towfun(void); - -//time -int do_test_clock_gettime(void); -int do_test_strftime(void); - -//stdio -int do_test_vsprintf(void); -int do_test_sprintf(void); -int do_test_fflush(void); -int do_test_stdio(void); - -//error -int test_error(void); - -//unistd -int do_test_getpid(void); - -//locale -int do_test_strtod1(void); -int do_test_strtod2(void); -int do_test_strtod3(void); -int do_test_strcoll(void); -int test_strxfrm(void); - -//multibyte -int do_test_mbrtowc(void); -int do_test_wcrtomb(void); -int do_test_wctob(void); - -//prng -int do_test_random(void); -int do_test_srandom(void); - -//string -int do_test_memcmp(void); -int do_test_strcmp(void); -int do_test_strchr(void); -int do_test_strlen(void); -int do_test_memset(void); -int do_test_memmove(void); -int do_test_memcpy(void); -int do_test_wmemchr(void); -int do_test_wcslen(void); - -#endif - - diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_locale.c b/test/xts/ta/test_libc_api/src/libc_func/test_locale.c deleted file mode 100644 index baf05f63..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_locale.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -struct ltest { - const char *str; /* Convert this. */ - double expect; /* To get this. */ - char left; /* With this left over. */ - int err; /* And this in errno. */ -}; -static const struct ltest tests_g1[] = { - { "12.345", 12.345, '\0', 0 }, - { "12.345e19", 12.345e19, '\0', 0 }, - { "-.1e+9", -.1e+9, '\0', 0 }, - { ".125", .125, '\0', 0 }, - { "1e20", 1e20, '\0', 0 }, - { "0e-19", 0, '\0', 0 }, - { "4\00012", 4.0, '\0', 0 }, - { "5.9e-76", 5.9e-76, '\0', 0 }, - { "0x1.4p+3", 10.0, '\0', 0 }, - { "0xAp0", 10.0, '\0', 0 }, - { "0x0Ap0", 10.0, '\0', 0 }, - { "0x0A", 10.0, '\0', 0 }, - { "0xA0", 160.0, '\0', 0 }, - { "0x0.A0p8", 160.0, '\0', 0 }, - { "0x0.50p9", 160.0, '\0', 0 }, - { "0x0.28p10", 160.0, '\0', 0 }, - { "0x0.14p11", 160.0, '\0', 0 }, - { "0x0.0A0p12", 160.0, '\0', 0 }, - { "0x0.050p13", 160.0, '\0', 0 }, - { "0x0.028p14", 160.0, '\0', 0 }, - { "0x0.014p15", 160.0, '\0', 0 }, - { "0x00.00A0p16", 160.0, '\0', 0 }, - { "0x00.0050p17", 160.0, '\0', 0 }, - { "0x00.0028p18", 160.0, '\0', 0 }, - { "0x00.0014p19", 160.0, '\0', 0 }, - { NULL, 0, '\0', 0 } -}; - -struct test { - const char *str; - double result; - size_t offset; -} tests_g2[] = { - { "0xy", 0.0, 1 }, - { "0x.y", 0.0, 1 }, - { "0x0.y", 0.0, 4 }, - { "0x.0y", 0.0, 4 }, - { ".y", 0.0, 0 }, - { "0.y", 0.0, 2 }, - { ".0y", 0.0, 2 } -}; - -static void expand(char *dst, register int c) -{ - if (isprint(c)) { - dst[0] = c; - dst[1] = '\0'; - } else - (void) sprintf(dst, "%#.3o", (unsigned int) c); -} - -int do_test_strtod1(void) -{ - char buf[100]; - register const struct ltest *lt; - char *ep; - int status = 0; - int save_errno; - - for (lt = tests_g1; lt->str != NULL; ++lt) { - double d; - - errno = 0; - d = strtod(lt->str, &ep); - save_errno = errno; - printf("strtod (\"%s\") test %u", - lt->str, (unsigned int)(lt - tests_g1)); - if (d == lt->expect && *ep == lt->left && save_errno == lt->err) - puts("\tOK"); - else { - puts("\tBAD"); - if (d != lt->expect) - printf(" returns %.60g, expected %.60g\n", d, lt->expect); - if (lt->left != *ep) { - char exp1[5], exp2[5]; - expand(exp1, *ep); - expand(exp2, lt->left); - printf(" leaves '%s', expected '%s'\n", exp1, exp2); - } - if (save_errno != lt->err) - printf(" errno %d (%s) instead of %d (%s)\n", - save_errno, strerror(save_errno), - lt->err, strerror(lt->err)); - status = 1; - } - } - - sprintf(buf, "%f", strtod("-0.0", NULL)); - if (strcmp(buf, "-0.000000") != 0) { - printf(" strtod (\"-0.0\", NULL) returns \"%s\"\n", buf); - status = 1; - } - return status; -} - -int do_test_strtod2(void) -{ - /* Regenerate this string using - - echo '(2^53-1)*2^(1024-53)' | bc | sed 's/\([^\]*\)\\*$/ "\1"/' - - */ - static const char longestdbl[] = - "17976931348623157081452742373170435679807056752584499659891747680315" - "72607800285387605895586327668781715404589535143824642343213268894641" - "82768467546703537516986049910576551282076245490090389328944075868508" - "45513394230458323690322294816580855933212334827479782620414472316873" - "8177180919299881250404026184124858368"; - double d = strtod(longestdbl, NULL); - - printf("strtod (\"%s\", NULL) = %g\n", longestdbl, d); - - if (d != 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000) - return 1; - - return 0; -} - -int do_test_strtod3(void) -{ - int status = 0; - size_t i; - for (i = 0; i < sizeof(tests_g2) / sizeof(tests_g2[0]); ++i) { - char *ep; - double r = strtod(tests_g2[i].str, &ep); - if (r != tests_g2[i].result) { - printf("test %zu r = %g, expect %g\n", i, r, tests_g2[i].result); - status = 1; - } - if (ep != tests_g2[i].str + tests_g2[i].offset) { - printf("test %zu strtod parsed %tu characters, expected %zu\n", - i, ep - tests_g2[i].str, tests_g2[i].offset); - status = 1; - } - } - return status; -} - -int do_test_strcoll(void) -{ - const char t1[] = "0-0-0-0-0-0-0-0-0-0.COM"; - const char t2[] = "00000-00000.COM"; - int res1; - int res2; - - res1 = strcoll(t1, t2); - printf("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, res1); - res2 = strcoll(t2, t1); - printf("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, res2); - - return ((res1 == 0 && res2 != 0) - || (res1 != 0 && res2 == 0) - | (res1 < 0 && res2 < 0) - || (res1 > 0 && res2 > 0)); -} - -int test_strxfrm(void) -{ - char dest[10], src[10]; - int len; - if (strcmp("C.UTF-8", setlocale(1, NULL)) != 0) { - printf("Failed: Test setlocale fail\n"); - return -1; - } - if (!(strcoll("ABC", "abc") < 0)) { - printf("Failed: Test strcoll fail\n"); - return -1; - } - strcpy(src, "strxfrm"); - len = strxfrm(dest, src, 10); - if (!(len == 7 && strcmp(dest, src) == 0)) { - printf("Failed: Test strxfm fail, got len %d, str %s\n", len, dest); - return -1; - } - return 0; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_math.c b/test/xts/ta/test_libc_api/src/libc_func/test_math.c deleted file mode 100644 index 7ff8d502..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_math.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include "test_libc_func.h" - -int do_test_atan(void) -{ - double result; - double x = 0.5; - - result = atan(x); - printf("The arctangent of %lf is %lf\n", x, result); - result = tan(x); - printf("The tan of %lf is %lf\n", x, result); - x = 100.98; - result = atan(x); - printf("The arctangent of %lf is %lf\n", x, result); - result = tan(x); - printf("The tan of %lf is %lf\n", x, result); - - return (0); -} - -int do_test_ceil(void) -{ - double number = 123.45; - double down, up; - down = floor(number); - up = ceil(number); - printf("origina lnumber %5.2lf\n", number); - printf("number rounded down%5.2lf\n", down); - printf("number rounded up%5.2lf\n", up); - - return 0; -} - -int do_test_ceilf(void) -{ - float number = 123.45; - float down, up; - down = floor(number); - up = ceilf(number); - printf("original number %5.2lf\n", number); - printf("number rounded down%5.2lf\n", down); - printf("number rounded up%5.2lf\n", up); - - return 0; -} - -int do_test_exp(void) -{ - double result; - double x = 4.0; - result = exp(x); - printf("'e'raised to the power of %lf(e^%lf)=%lf\n", x, x, result); - return 0; -} - -int do_test_fabs(void) -{ -#define Delta 1.0E-6 - if (fabs(atan(1) - 0.785398) > Delta) { - printf("Failed: atan(1) = %f, delta=%f\n", atan(1), fabs(atan(1) - 0.785398)); - return -1; - } - if (fabs(ceil(-1.1) - (-1.000000)) > Delta) { - printf("Failed: ceil(-1.1) = %f, delta=%f\n", ceil(-1.1), - fabs(ceil(-1.1) - (-1.00))); - return -1; - } - if (fabs(floor(3.8) - 3.000000) > Delta) { - printf("Failed: floor(3.8) = %f, delta=%f\n", floor(3.8), - fabs(floor(3.8) - 3.000000)); - return -1; - } -#undef Delta - return 0; -} - -static int float_eq(double a, double b) -{ - if (a > (b + 0.00000001)) { - return 1; - } else if (a < (b - 0.000000001)) { - return -1; - } - return 0; -} - -int do_test_floor(void) -{ - if (float_eq(floor(0.0), 0.0) != 0) return -1; - if (float_eq(floor(1.9), 1.0) != 0) return -2; - if (float_eq(floor(-1.9), -2.0) != 0) return -3; - if (float_eq(floor(0.0f), 0.0) != 0) return -4; - if (float_eq(floor(1.9f), 1.0) != 0) return -5; - if (float_eq(floor(-1.9f), -2.0) != 0) return -6; - if (float_eq(floor(1ll), 1) != 0) return -7; - - return 0; -} - -int do_test_frexpl(void) -{ - float x; - int exp; - long double y; - - y = 130.12; - x = frexpl(64.0, &exp); - printf("LIBC TEST 64=%.2f*2^%d\n", x, exp); - - x = frexpl(y, &exp); - printf("LIBC TEST %Lf=%f*2^%d\n", y, x, exp); - return 0; -} - -int do_test_log(void) -{ - double result; - double x = 800.6872; - double y = 1000.0; - result = log(x); - printf("LIBC TEST - The common log of %lf is %lf\n", x, result); - result = log(y); - printf("LIBC TEST - The common log of %lf is %lf\n", y, result); - return 0; -} - -int do_test_log2(void) -{ - double result; - double x = 800.6872; - result = log2(x); - printf("The common log2 of %lf is %lf\n", x, result); - return 0; -} - -int do_test_pow(void) -{ - long total; - int x = 2, y = 5; - total = pow(x, y); - printf("The pow test %d^%d=%ld", x, y, total); - return 0; -} - -int do_test_roundf(void) -{ - float num = 1.4999; - printf("ceil(%f) is %f\n", num, ceil(num)); - printf("floor(%f) is %f\n", num, floor(num)); - printf("roundf(%f) is %f\n", num, roundf(num)); - return 0; -} - -int do_test_sqrt(void) -{ - - printf("sqrt (%lf) = %lf\n", 4.0, sqrt(4.0)); - printf("sqrt (%lf) = %lf\n", 5.0, sqrt(5.0)); - printf("sqrtf (%lf) = %lf\n", 9.12, sqrtf(9.12)); - printf("sqrtf (%lf) = %lf\n", 36.0, sqrtf(36.0)); - - return (0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_mmap.c b/test/xts/ta/test_libc_api/src/libc_func/test_mmap.c deleted file mode 100644 index 34082366..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_mmap.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include "test_libc_func.h" - -#define TEST_PAGE_SIZE 4096 -#define FD_MMAP_PMEM (-9) - -static int do_zero_test(void *buf, size_t sz) -{ - size_t *p = buf; - for (size_t i = 0; i < sz; i += sizeof(size_t), p++) { - if (*p) - return -1; - } - return 0; -} - -#define TEST_MMAP_ITER 10 -int test_mmap(void) -{ - int ret = 0; - int i; - char *ptr[TEST_MMAP_ITER]; - char *p; - int k = 0; - - for (i = 0; i < TEST_MMAP_ITER; i++) { - ptr[i] = mmap((char *)0, TEST_PAGE_SIZE * (i + 1), - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS, - -1, 0); - if (ptr[i] == MAP_FAILED) { - printf("Failed to mmap at iteration %d.\n", i); - k = i; - goto err_reclaim; - } - - printf("Mmap at iteration %d with %p[%p].\n", - i, ptr[i], ptr[i] + (TEST_PAGE_SIZE * (i + 1))); - - if (do_zero_test(ptr[i], TEST_PAGE_SIZE * (i + 1))) { - printf("Zero test failed at iteration %d\n", i); - k = i + 1; - goto err_reclaim; - } - } - - for (i = 0; i < TEST_MMAP_ITER; i++) { - ret = munmap(ptr[i], TEST_PAGE_SIZE * (i + 1)); - if (ret != 0) { - printf("Munmap failed at ptr[%d] = %p.\n", i, ptr[i]); - return ret; - } - } - - // mmap with invalid prot. - p = mmap((char *)0, TEST_PAGE_SIZE, - PROT_WRITE, - MAP_ANONYMOUS, - -1, 0); - if (p != MAP_FAILED) { - munmap(p, TEST_PAGE_SIZE); - printf("Mmap with PROT_WRITE should failed.\n"); - return -1; - } - - // mmap physical with all PROT flags (incl PROT_CLEAR) and invalid paddr - p = mmap(NULL, TEST_PAGE_SIZE, -1, MAP_FILE, FD_MMAP_PMEM, 0); - if (p != MAP_FAILED) { - printf("mmap physical failed\n"); - return -1; - } - if (munmap(p, TEST_PAGE_SIZE) == 0) { - printf("munmap physical should failed, but success\n"); - return -1; - } - printf("test mmap & munmap success.\n"); - return 0; - -err_reclaim: - for (i = 0; i < k; i++) { - ret = munmap(ptr[i], TEST_PAGE_SIZE * (i + 1)); - if (ret != 0) - printf("Munmap failed at ptr[%d] = %p.\n", i, ptr[i]); - } - return -1; -} \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_multibyte.c b/test/xts/ta/test_libc_api/src/libc_func/test_multibyte.c deleted file mode 100644 index dc204b0b..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_multibyte.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -static int check_ascii_mbrtowc(const char *locname) -{ - int c; - int res = 0; - - printf("Testing locale \"%s\":\n", locname); - - for (c = 0; c <= 127; ++c) { - char buf[MB_CUR_MAX]; - wchar_t wc = 0xffffffff; - mbstate_t s; - size_t n, i; - - for (i = 0; i < MB_CUR_MAX; ++i) - buf[i] = c + i; - - memset(&s, '\0', sizeof(s)); - - n = mbrtowc(&wc, buf, MB_CUR_MAX, &s); - if (n == (size_t) -1) { - printf("%s: '\\x%x': encoding error\n", locname, c); - ++res; - } else if (n == (size_t) -2) { - printf("%s: '\\x%x': incomplete character\n", locname, c); - ++res; - } else if (n == 0 && c != 0) { - printf("%s: '\\x%x': 0 returned\n", locname, c); - ++res; - } else if (n != 0 && c == 0) { - printf("%s: '\\x%x': not 0 returned\n", locname, c); - ++res; - } else if (c != 0 && n != 1) { - printf("%s: '\\x%x': not 1 returned\n", locname, c); - ++res; - } else if (wc != (wchar_t) c) { - printf("%s: '\\x%x': wc != L'\\x%x'\n", locname, c, c); - ++res; - } - } - - printf(res == 1 ? "%d mbrtowc error\n" : "%d errors mbrtowc pass\n", res); - - return res != 0; -} - -int do_test_mbrtowc(void) -{ - int result = 0; - - /* Check mapping of ASCII range for some character sets which have - ASCII as a subset. For those the wide char generated must have - the same value. */ - setlocale(LC_ALL, "C"); - result |= check_ascii_mbrtowc(setlocale(LC_ALL, NULL)); - - result |= check_ascii_mbrtowc(setlocale(LC_ALL, NULL)); - - result |= check_ascii_mbrtowc(setlocale(LC_ALL, NULL)); - - return result; -} - -static int check_ascii_wcrtomb(const char *locname) -{ - wchar_t wc; - int res = 0; - - printf("Testing locale \"%s\":\n", locname); - - for (wc = 0; wc <= 127; ++wc) { - char buf[2 * MB_CUR_MAX]; - mbstate_t s; - size_t n; - - memset(buf, '\xff', sizeof(buf)); - memset(&s, '\0', sizeof(s)); - - n = wcrtomb(buf, wc, &s); - if (n == (size_t) -1) { - printf("%s: '\\x%x': encoding error\n", locname, (int) wc); - ++res; - } else if (n == 0) { - printf("%s: '\\x%x': 0 returned\n", locname, (int) wc); - ++res; - } else if (n != 1) { - printf("%s: '\\x%x': not 1 returned\n", locname, (int) wc); - ++res; - } else if (wc != (wchar_t) buf[0]) { - printf("%s: L'\\x%x': buf[0] != '\\x%x'\n", locname, (int) wc, - (int) wc); - ++res; - } - } - - printf(res == 1 ? "%d error\n" : "%d errors\n", res); - - return res != 0; -} - -int do_test_wcrtomb(void) -{ - int result = 0; - - setlocale(LC_ALL, "C"); - result |= check_ascii_wcrtomb(setlocale(LC_ALL, NULL)); - - setlocale(LC_ALL, "C.UTF-8"); - result |= check_ascii_wcrtomb(setlocale(LC_ALL, NULL)); - - setlocale(LC_ALL, "en_US.UTF-8"); - result |= check_ascii_wcrtomb(setlocale(LC_ALL, NULL)); - - setlocale(LC_ALL, "POSIX"); - result |= check_ascii_wcrtomb(setlocale(LC_ALL, NULL)); - - return result; -} - -int do_test_wctob(void) -{ - int bChar = 0; - wint_t wChar = 0; - int result = 0; - - // Set the corresponding wide character to exactly one byte. - wChar = (wint_t)'A'; - - bChar = wctob(wChar); - if ((unsigned int)bChar == WEOF) { - printf("No corresponding multibyte character was found.\n"); - result = 1; - } else { - printf("wctob pass: Determined the corresponding multibyte character to be \"%c\".\n", - bChar); - result = 0; - - } - return result; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_prng.c b/test/xts/ta/test_libc_api/src/libc_func/test_prng.c deleted file mode 100644 index 11e3db94..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_prng.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include "test_libc_func.h" - -const int degree = 128; /* random number generator degree (should - be one of 8, 16, 32, 64, 128, 256) */ -const int nseq = 3; /* number of test sequences */ -const int nrnd = 50; /* length of each test sequence */ -const unsigned int seed[3] = { 0x12344321U, 0xEE11DD22U, 0xFEDCBA98 }; -static int errors = 0; - -void fail(const char *msg, int s, int i) -{ - printf("\nTest FAILED: "); - printf("%s (seq %d, pos %d).\n", msg, s, i); - errors++; -} - -int do_test_srandom(void) -{ - long int rnd[nseq][nrnd]; /* pseudorandom numbers */ - char *state[nseq]; /* state for PRNG */ - char *oldstate[nseq]; /* old PRNG state */ - int s; /* sequence index */ - int i; /* element index */ - - printf("Begining random package test using %d sequences of length %d.\n", - nseq, nrnd); - - /* 1. Generate and store the sequences. */ - printf("Generating random sequences.\n"); - for (s = 0; s < nseq; ++s) { - srandom(seed[s]); - for (i = 0; i < nrnd; ++i) - rnd[s][i] = random(); - } - - /* 2. Regenerate and check. */ - printf("Regenerating and checking sequences.\n"); - for (s = 0; s < nseq; ++s) { - srandom(seed[s]); - for (i = 0; i < nrnd; ++i) - if (rnd[s][i] != random()) - fail("first regenerate test", s, i); - } - - /* 3. Create state vector, one for each sequence. - First state is random's internal state; others are malloced. */ - printf("Creating and checking state vector for each sequence.\n"); - srandom(seed[0]); /* reseed with first seed */ - for (s = 1; s < nseq; ++s) { - state[s] = (char *) malloc(degree); - oldstate[s] = initstate(seed[s], state[s], degree); - } - state[0] = oldstate[1]; - - /* Check returned values. */ - for (s = 1; s < nseq - 1; ++s) - if (state[s] != oldstate[s + 1]) - fail("bad initstate() return value", s, i); - - /* 4. Regenerate sequences interleaved and check. */ - printf("Regenerating and checking sequences in interleaved order.\n"); - for (i = 0; i < nrnd; ++i) { - for (s = 0; s < nseq; ++s) { - char *oldstate = (char *) setstate(state[s]); - if (oldstate != state[(s + nseq - 1) % nseq]) - fail("bad setstate() return value", s, i); - if (rnd[s][i] != random()) - fail("bad value generated in interleave test", s, i); - } - } - return errors; -} - -int do_test_random(void) -{ - int pass; - int ret = 0; - long int r[2]; - - for (pass = 0; pass < 2; pass++) { - srandom(0x12344321); - - int j; - for (j = 0; j < 3; ++j) - random(); - if (pass == 1) { - char state[128]; - char *ostate = initstate(0x34562101, state, 128); - if (setstate(ostate) != state) { - puts("setstate (ostate) != state"); - ret = 1; - } - } - - random(); - r[pass] = random(); - } - - if (r[0] != r[1]) { - printf("%ld != %ld\n", r[0], r[1]); - ret = 1; - } - return ret; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_pthread_key_create.c b/test/xts/ta/test_libc_api/src/libc_func/test_pthread_key_create.c deleted file mode 100644 index 4c0462f9..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_pthread_key_create.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -#define NUM_OF_KEYS 100 -#define KEY_VALUE 0 - -static pthread_key_t keys[NUM_OF_KEYS]; - -int test_pthread_key_create(void) -{ - int i; - void *rc; - - for (i = 0; i < NUM_OF_KEYS; i++) { - if (pthread_key_create(&keys[i], NULL) != 0) { - printf("Error: pthread_key_create() failed\n"); - return PTS_UNRESOLVED; - } else { - if (pthread_setspecific(keys[i], (void *)(long)(i + KEY_VALUE)) != 0) { - printf("Error: pthread_setspecific() failed\n"); - return PTS_UNRESOLVED; - } - - } - } - - for (i = 0; i < NUM_OF_KEYS; ++i) { - rc = pthread_getspecific(keys[i]); - if (rc != (void *)(long)(i + KEY_VALUE)) { - printf("Test FAILED: Did not return correct value of thread-specific key, expected %ld, but got %ld\n", - (long)(i + KEY_VALUE), (long)rc); - return PTS_FAIL; - } else { - if (pthread_key_delete(keys[i]) != 0) { - printf("Error: pthread_key_delete() failed\n"); - return PTS_UNRESOLVED; - } - } - } - - printf("Test PASSED\n"); - return PTS_PASS; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_sem.c b/test/xts/ta/test_libc_api/src/libc_func/test_sem.c deleted file mode 100644 index 1a76925c..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_sem.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -static sem_t sem; -static volatile int step = 0; - -static void *thread_run(void *arg) -{ - printf("child thread begin run...\n"); - step = 1; - printf("child thread wait on semaphore...\n"); - sem_wait(&sem); - printf("child thread wake from semaphore...\n"); - step = 2; - printf("child thread done.\n"); - return NULL; -} - -int test_sem(void) -{ - int value; - pthread_t thread; - int ret, i; - printf("main thread init unamed sem...\n"); - ret = sem_init(&sem, 0, 1); - if (ret != 0) { - printf("init sem failed.\n"); - return -1; - } - /* test sem_wait and sem_getvalue */ - sem_wait(&sem); - sem_getvalue(&sem, &value); - if (value != 0) { - printf("sem_wait/sem_getvalue failed.\n"); - return -1; - } - /* test sem_wait and sem_post in threads */ - step = 0; - printf("main thread create child thread...\n"); - ret = pthread_create(&thread, NULL, thread_run, NULL); - if (ret != 0) { - printf("create thread failed.\n"); - return -1; - } - printf("main thread yield...\n"); - for (i = 0; i < 100; i++) - (void)sched_yield(); - if (step != 1) { - printf("child thread should wait on sem, but not.\n"); - return -1; - } - printf("main thread post sem...\n"); - ret = sem_post(&sem); - if (ret != 0) { - printf("post sem failed.\n"); - return -1; - } - printf("main thread join child thread...\n"); - pthread_join(thread, NULL); - printf("main thread done.\n"); - return 0; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_stdio.c b/test/xts/ta/test_libc_api/src/libc_func/test_stdio.c deleted file mode 100644 index 2b830d4a..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_stdio.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -#define BUFSIZE 128 - -#define FMT0 "test: %o %u %x %X\n" -#define AP0 99, 99, 99, 99 - -#define FMT1 "test: %d %i\n" -#define AP1 99, 99 - -#define FMT2 "test: %e %E\n" -#define AP2 99.99, 99.99 - -#define FMT3 "test: %f %F\n" -#define AP3 99.99, 99.99 - -#define FMT4 "test: %g %G\n" -#define AP4 99.99, 99.99 - -#define FMT5 "test: %c\n" -#define AP5 '9' - -#define FMT6 "test: %s\n" -#define AP6 "9999" - -#define FMT7 "test: %%\n" -#define AP7 - -#define FMT8 "test: %#x %#X\n" -#define AP8 99, 99 - -static int test(char *fmt, ...) -{ - va_list ap; - int iret; - char pszbuf[BUFSIZE]; - - va_start(ap, fmt); - iret = vsprintf(pszbuf, fmt, ap); - va_end(ap); - - return iret; -} - -int do_test_vsprintf(void) -{ - int iret; - - if ((iret = test(FMT0, AP0)) < 0) goto fail; - if ((iret = test(FMT1, AP1)) < 0) goto fail; - if ((iret = test(FMT2, AP2)) < 0) goto fail; - if ((iret = test(FMT3, AP3)) < 0) goto fail; - if ((iret = test(FMT4, AP4)) < 0) goto fail; - if ((iret = test(FMT5, AP5)) < 0) goto fail; - if ((iret = test(FMT6, AP6)) < 0) goto fail; - if ((iret = test(FMT7)) < 0) goto fail; - if ((iret = test(FMT8, AP8)) < 0) goto fail; - - printf("TEST PASSED\n"); - return 0; -fail: - fprintf(stderr, "TEST FAULT %d\n", iret); - return -1; -} - -#define SIZE (70) -#define STR(x) #x - -int do_test_sprintf(void) -{ - char buf[100]; - int result = 0; - - puts("sprintf test start"); - if (sprintf(buf, "%.0ls", L"foo") != 0 - || strlen(buf) != 0) { - puts("sprintf (buf, \"%.0ls\", L\"foo\") produced some output"); - result = 1; - } - - char *dst = malloc(SIZE + 1); - - if (dst == NULL) { - puts("memory allocation failure"); - result = 1; - } else { - sprintf(dst, "%*s", SIZE, ""); - if (strnlen(dst, SIZE + 1) != SIZE) { - puts("sprintf (dst, \"%*s\", " STR(SIZE) - ", \"\") did not produce enough output"); - result = 1; - } - free(dst); - } - - if (sprintf(buf, "%1$d%3$.*2$s%4$d", 7, 67108863, "x", 8) != 3 - || strcmp(buf, "7x8") != 0) { - printf("sprintf (buf, \"%%1$d%%3$.*2$s%%4$d\", 7, 67108863, \"x\", 8) produced `%s' output", - buf); - result = 1; - } - - - if (sprintf(buf, "%%67108863.16\"%d", 7) != 14 - || strcmp(buf, "%67108863.16\"7") != 0) { - printf("sprintf (buf, \"%%67108863.16\\\"%%d\", 7) produced `%s' output", buf); - result = 1; - } - - if (sprintf(buf, "%%%d\"%d", 0x3ffffff, 7) != 11 - || strcmp(buf, "%67108863\"7") != 0) { - printf("sprintf (buf, \"%%*\\\"%%d\", 0x3ffffff, 7) produced `%s' output", buf); - result = 1; - } - printf("sprintf test result = %d\n", result); - return result; -} - -int do_test_fflush(void) -{ - int i; - for (i = 0; i < 10; i++) { - printf("fflush i=%d\n", i); - fflush(stdout); - } - return 0; - -} - -int do_test_stdio(void) -{ - printf("=== test stdio begin ===\n"); - - char ch1 = 'x', ch2; - ungetc(ch1, stdin); - ch2 = getc(stdin); - if (ch1 != ch2) { - printf("Failed: getc/ungetc failed, unget %c and get %c\n", ch1, ch2); - return -1; - } - printf("Test putc, expect 'ok' ... "); - putc('o', stdout); - putc('k', stdout); - printf("\n"); - wchar_t wc = L'x', wc2; - ungetwc(wc, stdin); - wc2 = getwc(stdin); - if (wc != wc2) { - printf("Failed: test getwc and ungetwc failed\n"); - return -1; - } - printf("Test putwc, expect 'ok' ... "); - putwc(L'o', stdout); - putwc(L'k', stdout); - printf("\n"); - printf("=== test stdio end ===\n\n"); - return 0; -} - diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_stdlib.c b/test/xts/ta/test_libc_api/src/libc_func/test_stdlib.c deleted file mode 100644 index 3aef6d24..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_stdlib.c +++ /dev/null @@ -1,780 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -struct mi { - int nr; - const char *name; -} months[] = { - {1, "jan"}, {2, "feb"}, {3, "mar"}, {4, "apr"}, - {5, "may"}, {6, "jun"}, {7, "jul"}, {8, "aug"}, - {9, "sep"}, {10, "oct"}, {11, "nov"}, {12, "dec"} -}; - -#define nr_of_months (sizeof(months)/sizeof(months[0])) - -static int compmi(const void *m1, const void *m2) -{ - struct mi *mi1 = (struct mi *) m1; - struct mi *mi2 = (struct mi *) m2; - return strcmp(mi1->name, mi2->name); -} - -struct ltest { - const char *str; /* Convert this. */ - unsigned long int expect; /* To get this. */ - int base; /* Use this base. */ - char left; /* With this left over. */ - int err; /* And this in errno. */ -}; - -static const struct ltest tests[] = { - /* First, signed numbers: */ - /* simple... */ - {"123", 123, 0, 0, 0}, - {"+123", 123, 0, 0, 0}, - {" 123", 123, 0, 0, 0}, - {" 123 ", 123, 0, ' ', 0}, - {" -17", -17, 0, 0, 0}, - - /* implicit base... */ - {"0123", 0123, 0, 0, 0}, - {"0123a", 0123, 0, 'a', 0}, - {"01239", 0123, 0, '9', 0}, - {"0x123", 0x123, 0, 0, 0}, - {"-0x123", -0x123, 0, 0, 0}, - {"0x0xc", 0, 0, 'x', 0}, - {" +0x123fg", 0x123f, 0, 'g', 0}, - - /* explicit base... */ - {"123", 0x123, 16, 0, 0}, - {"0x123", 0x123, 16, 0, 0}, - {"123", 0123, 8, 0, 0}, - {"0123", 0123, 8, 0, 0}, - {"0123", 123, 10, 0, 0}, - {"0x123", 0, 10, 'x', 0}, - - /* case insensitivity... */ - {"abcd", 0xabcd, 16, 0, 0}, - {"AbCd", 0xabcd, 16, 0, 0}, - {"0xABCD", 0xabcd, 16, 0, 0}, - {"0Xabcd", 0xabcd, 16, 0, 0}, - - /* odd bases... */ - {"0xyz", 33 * 35 + 34, 35, 'z', 0}, - {"yz!", 34 * 36 + 35, 36, '!', 0}, - {"-yz", -(34 * 36 + 35), 36, 0, 0}, - {"GhI4", ((16 * 20 + 17) * 20 + 18) * 20 + 4, 20, 0, 0}, - - /* extremes... */ -#if LONG_MAX == 0x7fffffff - {"2147483647", 2147483647, 0, 0, 0}, - {"2147483648", 2147483647, 0, 0, ERANGE}, - {"214748364888", 2147483647, 0, 0, ERANGE}, - {"2147483650", 2147483647, 0, 0, ERANGE}, - {"-2147483648", 0x80000000, 0, 0, 0}, - {"-2147483649", 0x80000000, 0, 0, ERANGE}, - {"0x1122334455z", 2147483647, 16, 'z', ERANGE}, - - {"1111111111111111111111111111111", 2147483647, 2, 0, 0}, - {"10000000000000000000000000000000", 2147483647, 2, 0, ERANGE}, - {"12112122212110202101", 2147483647, 3, 0, 0}, - {"12112122212110202102", 2147483647, 3, 0, ERANGE}, - {"1333333333333333", 2147483647, 4, 0, 0}, - {"2000000000000000", 2147483647, 4, 0, ERANGE}, - {"13344223434042", 2147483647, 5, 0, 0}, - {"13344223434043", 2147483647, 5, 0, ERANGE}, - {"553032005531", 2147483647, 6, 0, 0}, - {"553032005532", 2147483647, 6, 0, ERANGE}, - {"104134211161", 2147483647, 7, 0, 0}, - {"104134211162", 2147483647, 7, 0, ERANGE}, - {"17777777777", 2147483647, 8, 0, 0}, - {"20000000000", 2147483647, 8, 0, ERANGE}, - {"5478773671", 2147483647, 9, 0, 0}, - {"5478773672", 2147483647, 9, 0, ERANGE}, - {"2147483647", 2147483647, 10, 0, 0}, - {"2147483648", 2147483647, 10, 0, ERANGE}, - {"a02220281", 2147483647, 11, 0, 0}, - {"a02220282", 2147483647, 11, 0, ERANGE}, - {"4bb2308a7", 2147483647, 12, 0, 0}, - {"4bb2308a8", 2147483647, 12, 0, ERANGE}, - {"282ba4aaa", 2147483647, 13, 0, 0}, - {"282ba4aab", 2147483647, 13, 0, ERANGE}, - {"1652ca931", 2147483647, 14, 0, 0}, - {"1652ca932", 2147483647, 14, 0, ERANGE}, - {"c87e66b7", 2147483647, 15, 0, 0}, - {"c87e66b8", 2147483647, 15, 0, ERANGE}, - {"7fffffff", 2147483647, 16, 0, 0}, - {"80000000", 2147483647, 16, 0, ERANGE}, - {"53g7f548", 2147483647, 17, 0, 0}, - {"53g7f549", 2147483647, 17, 0, ERANGE}, - {"3928g3h1", 2147483647, 18, 0, 0}, - {"3928g3h2", 2147483647, 18, 0, ERANGE}, - {"27c57h32", 2147483647, 19, 0, 0}, - {"27c57h33", 2147483647, 19, 0, ERANGE}, - {"1db1f927", 2147483647, 20, 0, 0}, - {"1db1f928", 2147483647, 20, 0, ERANGE}, - {"140h2d91", 2147483647, 21, 0, 0}, - {"140h2d92", 2147483647, 21, 0, ERANGE}, - {"ikf5bf1", 2147483647, 22, 0, 0}, - {"ikf5bf2", 2147483647, 22, 0, ERANGE}, - {"ebelf95", 2147483647, 23, 0, 0}, - {"ebelf96", 2147483647, 23, 0, ERANGE}, - {"b5gge57", 2147483647, 24, 0, 0}, - {"b5gge58", 2147483647, 24, 0, ERANGE}, - {"8jmdnkm", 2147483647, 25, 0, 0}, - {"8jmdnkn", 2147483647, 25, 0, ERANGE}, - {"6oj8ion", 2147483647, 26, 0, 0}, - {"6oj8ioo", 2147483647, 26, 0, ERANGE}, - {"5ehncka", 2147483647, 27, 0, 0}, - {"5ehnckb", 2147483647, 27, 0, ERANGE}, - {"4clm98f", 2147483647, 28, 0, 0}, - {"4clm98g", 2147483647, 28, 0, ERANGE}, - {"3hk7987", 2147483647, 29, 0, 0}, - {"3hk7988", 2147483647, 29, 0, ERANGE}, - {"2sb6cs7", 2147483647, 30, 0, 0}, - {"2sb6cs8", 2147483647, 30, 0, ERANGE}, - {"2d09uc1", 2147483647, 31, 0, 0}, - {"2d09uc2", 2147483647, 31, 0, ERANGE}, - {"1vvvvvv", 2147483647, 32, 0, 0}, - {"2000000", 2147483647, 32, 0, ERANGE}, - {"1lsqtl1", 2147483647, 33, 0, 0}, - {"1lsqtl2", 2147483647, 33, 0, ERANGE}, - {"1d8xqrp", 2147483647, 34, 0, 0}, - {"1d8xqrq", 2147483647, 34, 0, ERANGE}, - {"15v22um", 2147483647, 35, 0, 0}, - {"15v22un", 2147483647, 35, 0, ERANGE}, - {"zik0zj", 2147483647, 36, 0, 0}, - {"zik0zk", 2147483647, 36, 0, ERANGE}, - - {"-10000000000000000000000000000000", -2147483648, 2, 0, 0}, - {"-10000000000000000000000000000001", -2147483648, 2, 0, ERANGE}, - {"-12112122212110202102", -2147483648, 3, 0, 0}, - {"-12112122212110202110", -2147483648, 3, 0, ERANGE}, - {"-2000000000000000", -2147483648, 4, 0, 0}, - {"-2000000000000001", -2147483648, 4, 0, ERANGE}, - {"-13344223434043", -2147483648, 5, 0, 0}, - {"-13344223434044", -2147483648, 5, 0, ERANGE}, - {"-553032005532", -2147483648, 6, 0, 0}, - {"-553032005533", -2147483648, 6, 0, ERANGE}, - {"-104134211162", -2147483648, 7, 0, 0}, - {"-104134211163", -2147483648, 7, 0, ERANGE}, - {"-20000000000", -2147483648, 8, 0, 0}, - {"-20000000001", -2147483648, 8, 0, ERANGE}, - {"-5478773672", -2147483648, 9, 0, 0}, - {"-5478773673", -2147483648, 9, 0, ERANGE}, - {"-2147483648", -2147483648, 10, 0, 0}, - {"-2147483649", -2147483648, 10, 0, ERANGE}, - {"-a02220282", -2147483648, 11, 0, 0}, - {"-a02220283", -2147483648, 11, 0, ERANGE}, - {"-4bb2308a8", -2147483648, 12, 0, 0}, - {"-4bb2308a9", -2147483648, 12, 0, ERANGE}, - {"-282ba4aab", -2147483648, 13, 0, 0}, - {"-282ba4aac", -2147483648, 13, 0, ERANGE}, - {"-1652ca932", -2147483648, 14, 0, 0}, - {"-1652ca933", -2147483648, 14, 0, ERANGE}, - {"-c87e66b8", -2147483648, 15, 0, 0}, - {"-c87e66b9", -2147483648, 15, 0, ERANGE}, - {"-80000000", -2147483648, 16, 0, 0}, - {"-80000001", -2147483648, 16, 0, ERANGE}, - {"-53g7f549", -2147483648, 17, 0, 0}, - {"-53g7f54a", -2147483648, 17, 0, ERANGE}, - {"-3928g3h2", -2147483648, 18, 0, 0}, - {"-3928g3h3", -2147483648, 18, 0, ERANGE}, - {"-27c57h33", -2147483648, 19, 0, 0}, - {"-27c57h34", -2147483648, 19, 0, ERANGE}, - {"-1db1f928", -2147483648, 20, 0, 0}, - {"-1db1f929", -2147483648, 20, 0, ERANGE}, - {"-140h2d92", -2147483648, 21, 0, 0}, - {"-140h2d93", -2147483648, 21, 0, ERANGE}, - {"-ikf5bf2", -2147483648, 22, 0, 0}, - {"-ikf5bf3", -2147483648, 22, 0, ERANGE}, - {"-ebelf96", -2147483648, 23, 0, 0}, - {"-ebelf97", -2147483648, 23, 0, ERANGE}, - {"-b5gge58", -2147483648, 24, 0, 0}, - {"-b5gge59", -2147483648, 24, 0, ERANGE}, - {"-8jmdnkn", -2147483648, 25, 0, 0}, - {"-8jmdnko", -2147483648, 25, 0, ERANGE}, - {"-6oj8ioo", -2147483648, 26, 0, 0}, - {"-6oj8iop", -2147483648, 26, 0, ERANGE}, - {"-5ehnckb", -2147483648, 27, 0, 0}, - {"-5ehnckc", -2147483648, 27, 0, ERANGE}, - {"-4clm98g", -2147483648, 28, 0, 0}, - {"-4clm98h", -2147483648, 28, 0, ERANGE}, - {"-3hk7988", -2147483648, 29, 0, 0}, - {"-3hk7989", -2147483648, 29, 0, ERANGE}, - {"-2sb6cs8", -2147483648, 30, 0, 0}, - {"-2sb6cs9", -2147483648, 30, 0, ERANGE}, - {"-2d09uc2", -2147483648, 31, 0, 0}, - {"-2d09uc3", -2147483648, 31, 0, ERANGE}, - {"-2000000", -2147483648, 32, 0, 0}, - {"-2000001", -2147483648, 32, 0, ERANGE}, - {"-1lsqtl2", -2147483648, 33, 0, 0}, - {"-1lsqtl3", -2147483648, 33, 0, ERANGE}, - {"-1d8xqrq", -2147483648, 34, 0, 0}, - {"-1d8xqrr", -2147483648, 34, 0, ERANGE}, - {"-15v22un", -2147483648, 35, 0, 0}, - {"-15v22uo", -2147483648, 35, 0, ERANGE}, - {"-zik0zk", -2147483648, 36, 0, 0}, - {"-zik0zl", -2147483648, 36, 0, ERANGE}, -#else - {"9223372036854775807", 9223372036854775807, 0, 0, 0}, - {"9223372036854775808", 9223372036854775807, 0, 0, ERANGE}, - {"922337203685477580777", 9223372036854775807, 0, 0, ERANGE}, - {"9223372036854775810", 9223372036854775807, 0, 0, ERANGE}, - {"-2147483648", -2147483648, 0, 0, 0}, - {"-9223372036854775808", 0x8000000000000000, 0, 0, 0}, - {"-9223372036854775809", 0x8000000000000000, 0, 0, ERANGE}, - {"0x112233445566778899z", 9223372036854775807, 16, 'z', ERANGE}, - {"0xFFFFFFFFFFFF00FF", 9223372036854775807, 0, 0, ERANGE}, - - { - "111111111111111111111111111111111111111111111111111111111111111", - 9223372036854775807, 2, 0, 0 - }, - { - "1000000000000000000000000000000000000000000000000000000000000000", - 9223372036854775807, 2, 0, ERANGE - }, - { - "2021110011022210012102010021220101220221", - 9223372036854775807, 3, 0, 0 - }, - { - "2021110011022210012102010021220101220222", - 9223372036854775807, 3, 0, ERANGE - }, - {"13333333333333333333333333333333", 9223372036854775807, 4, 0, 0}, - {"20000000000000000000000000000000", 9223372036854775807, 4, 0, ERANGE}, - {"1104332401304422434310311212", 9223372036854775807, 5, 0, 0}, - {"1104332401304422434310311213", 9223372036854775807, 5, 0, ERANGE}, - {"1540241003031030222122211", 9223372036854775807, 6, 0, 0}, - {"1540241003031030222122212", 9223372036854775807, 6, 0, ERANGE}, - {"22341010611245052052300", 9223372036854775807, 7, 0, 0}, - {"22341010611245052052301", 9223372036854775807, 7, 0, ERANGE}, - {"777777777777777777777", 9223372036854775807, 8, 0, 0}, - {"1000000000000000000000", 9223372036854775807, 8, 0, ERANGE}, - {"67404283172107811827", 9223372036854775807, 9, 0, 0}, - {"67404283172107811828", 9223372036854775807, 9, 0, ERANGE}, - {"9223372036854775807", 9223372036854775807, 10, 0, 0}, - {"9223372036854775808", 9223372036854775807, 10, 0, ERANGE}, - {"1728002635214590697", 9223372036854775807, 11, 0, 0}, - {"1728002635214590698", 9223372036854775807, 11, 0, ERANGE}, - {"41a792678515120367", 9223372036854775807, 12, 0, 0}, - {"41a792678515120368", 9223372036854775807, 12, 0, ERANGE}, - {"10b269549075433c37", 9223372036854775807, 13, 0, 0}, - {"10b269549075433c38", 9223372036854775807, 13, 0, ERANGE}, - {"4340724c6c71dc7a7", 9223372036854775807, 14, 0, 0}, - {"4340724c6c71dc7a8", 9223372036854775807, 14, 0, ERANGE}, - {"160e2ad3246366807", 9223372036854775807, 15, 0, 0}, - {"160e2ad3246366808", 9223372036854775807, 15, 0, ERANGE}, - {"7fffffffffffffff", 9223372036854775807, 16, 0, 0}, - {"8000000000000000", 9223372036854775807, 16, 0, ERANGE}, - {"33d3d8307b214008", 9223372036854775807, 17, 0, 0}, - {"33d3d8307b214009", 9223372036854775807, 17, 0, ERANGE}, - {"16agh595df825fa7", 9223372036854775807, 18, 0, 0}, - {"16agh595df825fa8", 9223372036854775807, 18, 0, ERANGE}, - {"ba643dci0ffeehh", 9223372036854775807, 19, 0, 0}, - {"ba643dci0ffeehi", 9223372036854775807, 19, 0, ERANGE}, - {"5cbfjia3fh26ja7", 9223372036854775807, 20, 0, 0}, - {"5cbfjia3fh26ja8", 9223372036854775807, 20, 0, ERANGE}, - {"2heiciiie82dh97", 9223372036854775807, 21, 0, 0}, - {"2heiciiie82dh98", 9223372036854775807, 21, 0, ERANGE}, - {"1adaibb21dckfa7", 9223372036854775807, 22, 0, 0}, - {"1adaibb21dckfa8", 9223372036854775807, 22, 0, ERANGE}, - {"i6k448cf4192c2", 9223372036854775807, 23, 0, 0}, - {"i6k448cf4192c3", 9223372036854775807, 23, 0, ERANGE}, - {"acd772jnc9l0l7", 9223372036854775807, 24, 0, 0}, - {"acd772jnc9l0l8", 9223372036854775807, 24, 0, ERANGE}, - {"64ie1focnn5g77", 9223372036854775807, 25, 0, 0}, - {"64ie1focnn5g78", 9223372036854775807, 25, 0, ERANGE}, - {"3igoecjbmca687", 9223372036854775807, 26, 0, 0}, - {"3igoecjbmca688", 9223372036854775807, 26, 0, ERANGE}, - {"27c48l5b37oaop", 9223372036854775807, 27, 0, 0}, - {"27c48l5b37oaoq", 9223372036854775807, 27, 0, ERANGE}, - {"1bk39f3ah3dmq7", 9223372036854775807, 28, 0, 0}, - {"1bk39f3ah3dmq8", 9223372036854775807, 28, 0, ERANGE}, - {"q1se8f0m04isb", 9223372036854775807, 29, 0, 0}, - {"q1se8f0m04isc", 9223372036854775807, 29, 0, ERANGE}, - {"hajppbc1fc207", 9223372036854775807, 30, 0, 0}, - {"hajppbc1fc208", 9223372036854775807, 30, 0, ERANGE}, - {"bm03i95hia437", 9223372036854775807, 31, 0, 0}, - {"bm03i95hia438", 9223372036854775807, 31, 0, ERANGE}, - {"7vvvvvvvvvvvv", 9223372036854775807, 32, 0, 0}, - {"8000000000000", 9223372036854775807, 32, 0, ERANGE}, - {"5hg4ck9jd4u37", 9223372036854775807, 33, 0, 0}, - {"5hg4ck9jd4u38", 9223372036854775807, 33, 0, ERANGE}, - {"3tdtk1v8j6tpp", 9223372036854775807, 34, 0, 0}, - {"3tdtk1v8j6tpq", 9223372036854775807, 34, 0, ERANGE}, - {"2pijmikexrxp7", 9223372036854775807, 35, 0, 0}, - {"2pijmikexrxp8", 9223372036854775807, 35, 0, ERANGE}, - {"1y2p0ij32e8e7", 9223372036854775807, 36, 0, 0}, - {"1y2p0ij32e8e8", 9223372036854775807, 36, 0, ERANGE}, - - { - "-1000000000000000000000000000000000000000000000000000000000000000", - -9223372036854775808ull, 2, 0, 0 - }, - { - "-1000000000000000000000000000000000000000000000000000000000000001", - -9223372036854775808ull, 2, 0, ERANGE - }, - { - "-2021110011022210012102010021220101220222", - -9223372036854775808ull, 3, 0, 0 - }, - { - "-2021110011022210012102010021220101221000", - -9223372036854775808ull, 3, 0, ERANGE - }, - {"-20000000000000000000000000000000", -9223372036854775808ull, 4, 0, 0}, - {"-20000000000000000000000000000001", -9223372036854775808ull, 4, 0, ERANGE}, - {"-1104332401304422434310311213", -9223372036854775808ull, 5, 0, 0}, - {"-1104332401304422434310311214", -9223372036854775808ull, 5, 0, ERANGE}, - {"-1540241003031030222122212", -9223372036854775808ull, 6, 0, 0}, - {"-1540241003031030222122213", -9223372036854775808ull, 6, 0, ERANGE}, - {"-22341010611245052052301", -9223372036854775808ull, 7, 0, 0}, - {"-22341010611245052052302", -9223372036854775808ull, 7, 0, ERANGE}, - {"-1000000000000000000000", -9223372036854775808ull, 8, 0, 0}, - {"-1000000000000000000001", -9223372036854775808ull, 8, 0, ERANGE}, - {"-67404283172107811828", -9223372036854775808ull, 9, 0, 0}, - {"-67404283172107811830", -9223372036854775808ull, 9, 0, ERANGE}, - {"-9223372036854775808", -9223372036854775808ull, 10, 0, 0}, - {"-9223372036854775809", -9223372036854775808ull, 10, 0, ERANGE}, - {"-1728002635214590698", -9223372036854775808ull, 11, 0, 0}, - {"-1728002635214590699", -9223372036854775808ull, 11, 0, ERANGE}, - {"-41a792678515120368", -9223372036854775808ull, 12, 0, 0}, - {"-41a792678515120369", -9223372036854775808ull, 12, 0, ERANGE}, - {"-10b269549075433c38", -9223372036854775808ull, 13, 0, 0}, - {"-10b269549075433c39", -9223372036854775808ull, 13, 0, ERANGE}, - {"-4340724c6c71dc7a8", -9223372036854775808ull, 14, 0, 0}, - {"-4340724c6c71dc7a9", -9223372036854775808ull, 14, 0, ERANGE}, - {"-160e2ad3246366808", -9223372036854775808ull, 15, 0, 0}, - {"-160e2ad3246366809", -9223372036854775808ull, 15, 0, ERANGE}, - {"-8000000000000000", -9223372036854775808ull, 16, 0, 0}, - {"-8000000000000001", -9223372036854775808ull, 16, 0, ERANGE}, - {"-33d3d8307b214009", -9223372036854775808ull, 17, 0, 0}, - {"-33d3d8307b21400a", -9223372036854775808ull, 17, 0, ERANGE}, - {"-16agh595df825fa8", -9223372036854775808ull, 18, 0, 0}, - {"-16agh595df825fa9", -9223372036854775808ull, 18, 0, ERANGE}, - {"-ba643dci0ffeehi", -9223372036854775808ull, 19, 0, 0}, - {"-ba643dci0ffeei0", -9223372036854775808ull, 19, 0, ERANGE}, - {"-5cbfjia3fh26ja8", -9223372036854775808ull, 20, 0, 0}, - {"-5cbfjia3fh26ja9", -9223372036854775808ull, 20, 0, ERANGE}, - {"-2heiciiie82dh98", -9223372036854775808ull, 21, 0, 0}, - {"-2heiciiie82dh99", -9223372036854775808ull, 21, 0, ERANGE}, - {"-1adaibb21dckfa8", -9223372036854775808ull, 22, 0, 0}, - {"-1adaibb21dckfa9", -9223372036854775808ull, 22, 0, ERANGE}, - {"-i6k448cf4192c3", -9223372036854775808ull, 23, 0, 0}, - {"-i6k448cf4192c4", -9223372036854775808ull, 23, 0, ERANGE}, - {"-acd772jnc9l0l8", -9223372036854775808ull, 24, 0, 0}, - {"-acd772jnc9l0l9", -9223372036854775808ull, 24, 0, ERANGE}, - {"-64ie1focnn5g78", -9223372036854775808ull, 25, 0, 0}, - {"-64ie1focnn5g79", -9223372036854775808ull, 25, 0, ERANGE}, - {"-3igoecjbmca688", -9223372036854775808ull, 26, 0, 0}, - {"-3igoecjbmca689", -9223372036854775808ull, 26, 0, ERANGE}, - {"-27c48l5b37oaoq", -9223372036854775808ull, 27, 0, 0}, - {"-27c48l5b37oap0", -9223372036854775808ull, 27, 0, ERANGE}, - {"-1bk39f3ah3dmq8", -9223372036854775808ull, 28, 0, 0}, - {"-1bk39f3ah3dmq9", -9223372036854775808ull, 28, 0, ERANGE}, - {"-q1se8f0m04isc", -9223372036854775808ull, 29, 0, 0}, - {"-q1se8f0m04isd", -9223372036854775808ull, 29, 0, ERANGE}, - {"-hajppbc1fc208", -9223372036854775808ull, 30, 0, 0}, - {"-hajppbc1fc209", -9223372036854775808ull, 30, 0, ERANGE}, - {"-bm03i95hia438", -9223372036854775808ull, 31, 0, 0}, - {"-bm03i95hia439", -9223372036854775808ull, 31, 0, ERANGE}, - {"-8000000000000", -9223372036854775808ull, 32, 0, 0}, - {"-8000000000001", -9223372036854775808ull, 32, 0, ERANGE}, - {"-5hg4ck9jd4u38", -9223372036854775808ull, 33, 0, 0}, - {"-5hg4ck9jd4u39", -9223372036854775808ull, 33, 0, ERANGE}, - {"-3tdtk1v8j6tpq", -9223372036854775808ull, 34, 0, 0}, - {"-3tdtk1v8j6tpr", -9223372036854775808ull, 34, 0, ERANGE}, - {"-2pijmikexrxp8", -9223372036854775808ull, 35, 0, 0}, - {"-2pijmikexrxp9", -9223372036854775808ull, 35, 0, ERANGE}, - {"-1y2p0ij32e8e8", -9223372036854775808ull, 36, 0, 0}, - {"-1y2p0ij32e8e9", -9223372036854775808ull, 36, 0, ERANGE}, -#endif - {NULL, 0, 0, 0, 0}, - - /* Then unsigned. */ - {" 0", 0, 0, 0, 0}, - {"0xffffffffg", 0xffffffff, 0, 'g', 0}, -#if LONG_MAX == 0x7fffffff - {"-0xfedcba98", 0x01234568, 0, 0, 0}, - {"0xf1f2f3f4f5", 0xffffffff, 0, 0, ERANGE}, - {"-0x123456789", 0xffffffff, 0, 0, ERANGE}, - - {"11111111111111111111111111111111", 0xffffffff, 2, 0, 0}, - {"100000000000000000000000000000000", 0xffffffff, 2, 0, ERANGE}, - {"102002022201221111210", 0xffffffff, 3, 0, 0}, - {"102002022201221111211", 0xffffffff, 3, 0, ERANGE}, - {"3333333333333333", 0xffffffff, 4, 0, 0}, - {"10000000000000000", 0xffffffff, 4, 0, ERANGE}, - {"32244002423140", 0xffffffff, 5, 0, 0}, - {"32244002423141", 0xffffffff, 5, 0, ERANGE}, - {"1550104015503", 0xffffffff, 6, 0, 0}, - {"1550104015504", 0xffffffff, 6, 0, ERANGE}, - {"211301422353", 0xffffffff, 7, 0, 0}, - {"211301422354", 0xffffffff, 7, 0, ERANGE}, - {"37777777777", 0xffffffff, 8, 0, 0}, - {"40000000000", 0xffffffff, 8, 0, ERANGE}, - {"12068657453", 0xffffffff, 9, 0, 0}, - {"12068657454", 0xffffffff, 9, 0, ERANGE}, - {"4294967295", 0xffffffff, 10, 0, 0}, - {"4294967296", 0xffffffff, 10, 0, ERANGE}, - {"1904440553", 0xffffffff, 11, 0, 0}, - {"1904440554", 0xffffffff, 11, 0, ERANGE}, - {"9ba461593", 0xffffffff, 12, 0, 0}, - {"9ba461594", 0xffffffff, 12, 0, ERANGE}, - {"535a79888", 0xffffffff, 13, 0, 0}, - {"535a79889", 0xffffffff, 13, 0, ERANGE}, - {"2ca5b7463", 0xffffffff, 14, 0, 0}, - {"2ca5b7464", 0xffffffff, 14, 0, ERANGE}, - {"1a20dcd80", 0xffffffff, 15, 0, 0}, - {"1a20dcd81", 0xffffffff, 15, 0, ERANGE}, - {"ffffffff", 0xffffffff, 16, 0, 0}, - {"100000000", 0xffffffff, 16, 0, ERANGE}, - {"a7ffda90", 0xffffffff, 17, 0, 0}, - {"a7ffda91", 0xffffffff, 17, 0, ERANGE}, - {"704he7g3", 0xffffffff, 18, 0, 0}, - {"704he7g4", 0xffffffff, 18, 0, ERANGE}, - {"4f5aff65", 0xffffffff, 19, 0, 0}, - {"4f5aff66", 0xffffffff, 19, 0, ERANGE}, - {"3723ai4f", 0xffffffff, 20, 0, 0}, - {"3723ai4g", 0xffffffff, 20, 0, ERANGE}, - {"281d55i3", 0xffffffff, 21, 0, 0}, - {"281d55i4", 0xffffffff, 21, 0, ERANGE}, - {"1fj8b183", 0xffffffff, 22, 0, 0}, - {"1fj8b184", 0xffffffff, 22, 0, ERANGE}, - {"1606k7ib", 0xffffffff, 23, 0, 0}, - {"1606k7ic", 0xffffffff, 23, 0, ERANGE}, - {"mb994af", 0xffffffff, 24, 0, 0}, - {"mb994ag", 0xffffffff, 24, 0, ERANGE}, - {"hek2mgk", 0xffffffff, 25, 0, 0}, - {"hek2mgl", 0xffffffff, 25, 0, ERANGE}, - {"dnchbnl", 0xffffffff, 26, 0, 0}, - {"dnchbnm", 0xffffffff, 26, 0, ERANGE}, - {"b28jpdl", 0xffffffff, 27, 0, 0}, - {"b28jpdm", 0xffffffff, 27, 0, ERANGE}, - {"8pfgih3", 0xffffffff, 28, 0, 0}, - {"8pfgih4", 0xffffffff, 28, 0, ERANGE}, - {"76beigf", 0xffffffff, 29, 0, 0}, - {"76beigg", 0xffffffff, 29, 0, ERANGE}, - {"5qmcpqf", 0xffffffff, 30, 0, 0}, - {"5qmcpqg", 0xffffffff, 30, 0, ERANGE}, - {"4q0jto3", 0xffffffff, 31, 0, 0}, - {"4q0jto4", 0xffffffff, 31, 0, ERANGE}, - {"3vvvvvv", 0xffffffff, 32, 0, 0}, - {"4000000", 0xffffffff, 32, 0, ERANGE}, - {"3aokq93", 0xffffffff, 33, 0, 0}, - {"3aokq94", 0xffffffff, 33, 0, ERANGE}, - {"2qhxjlh", 0xffffffff, 34, 0, 0}, - {"2qhxjli", 0xffffffff, 34, 0, ERANGE}, - {"2br45qa", 0xffffffff, 35, 0, 0}, - {"2br45qb", 0xffffffff, 35, 0, ERANGE}, - {"1z141z3", 0xffffffff, 36, 0, 0}, - {"1z141z4", 0xffffffff, 36, 0, ERANGE}, -#else - {"0xffffffffffffffffg", 0xffffffffffffffff, 0, 'g', 0}, - {"-0xfedcba987654321", 0xf0123456789abcdf, 0, 0, 0}, - {"0xf1f2f3f4f5f6f7f8f9", 0xffffffffffffffff, 0, 0, ERANGE}, - {"-0x123456789abcdef01", 0xffffffffffffffff, 0, 0, ERANGE}, - - { - "1111111111111111111111111111111111111111111111111111111111111111", - 0xffffffffffffffff, 2, 0, 0 - }, - { - "10000000000000000000000000000000000000000000000000000000000000000", - 0xffffffffffffffff, 2, 0, ERANGE - }, - { - "11112220022122120101211020120210210211220", - 0xffffffffffffffff, 3, 0, 0 - }, - { - "11112220022122120101211020120210210211221", - 0xffffffffffffffff, 3, 0, ERANGE - }, - {"33333333333333333333333333333333", 0xffffffffffffffff, 4, 0, 0}, - {"100000000000000000000000000000000", 0xffffffffffffffff, 4, 0, ERANGE}, - {"2214220303114400424121122430", 0xffffffffffffffff, 5, 0, 0}, - {"2214220303114400424121122431", 0xffffffffffffffff, 5, 0, ERANGE}, - {"3520522010102100444244423", 0xffffffffffffffff, 6, 0, 0}, - {"3520522010102100444244424", 0xffffffffffffffff, 6, 0, ERANGE}, - {"45012021522523134134601", 0xffffffffffffffff, 7, 0, 0}, - {"45012021522523134134602", 0xffffffffffffffff, 7, 0, ERANGE}, - {"1777777777777777777777", 0xffffffffffffffff, 8, 0, 0}, - {"2000000000000000000000", 0xffffffffffffffff, 8, 0, ERANGE}, - {"145808576354216723756", 0xffffffffffffffff, 9, 0, 0}, - {"145808576354216723757", 0xffffffffffffffff, 9, 0, ERANGE}, - {"18446744073709551615", 0xffffffffffffffff, 10, 0, 0}, - {"18446744073709551616", 0xffffffffffffffff, 10, 0, ERANGE}, - {"335500516a429071284", 0xffffffffffffffff, 11, 0, 0}, - {"335500516a429071285", 0xffffffffffffffff, 11, 0, ERANGE}, - {"839365134a2a240713", 0xffffffffffffffff, 12, 0, 0}, - {"839365134a2a240714", 0xffffffffffffffff, 12, 0, ERANGE}, - {"219505a9511a867b72", 0xffffffffffffffff, 13, 0, 0}, - {"219505a9511a867b73", 0xffffffffffffffff, 13, 0, ERANGE}, - {"8681049adb03db171", 0xffffffffffffffff, 14, 0, 0}, - {"8681049adb03db172", 0xffffffffffffffff, 14, 0, ERANGE}, - {"2c1d56b648c6cd110", 0xffffffffffffffff, 15, 0, 0}, - {"2c1d56b648c6cd111", 0xffffffffffffffff, 15, 0, ERANGE}, - {"ffffffffffffffff", 0xffffffffffffffff, 16, 0, 0}, - {"10000000000000000", 0xffffffffffffffff, 16, 0, ERANGE}, - {"67979g60f5428010", 0xffffffffffffffff, 17, 0, 0}, - {"67979g60f5428011", 0xffffffffffffffff, 17, 0, ERANGE}, - {"2d3fgb0b9cg4bd2f", 0xffffffffffffffff, 18, 0, 0}, - {"2d3fgb0b9cg4bd2g", 0xffffffffffffffff, 18, 0, ERANGE}, - {"141c8786h1ccaagg", 0xffffffffffffffff, 19, 0, 0}, - {"141c8786h1ccaagh", 0xffffffffffffffff, 19, 0, ERANGE}, - {"b53bjh07be4dj0f", 0xffffffffffffffff, 20, 0, 0}, - {"b53bjh07be4dj0g", 0xffffffffffffffff, 20, 0, ERANGE}, - {"5e8g4ggg7g56dif", 0xffffffffffffffff, 21, 0, 0}, - {"5e8g4ggg7g56dig", 0xffffffffffffffff, 21, 0, ERANGE}, - {"2l4lf104353j8kf", 0xffffffffffffffff, 22, 0, 0}, - {"2l4lf104353j8kg", 0xffffffffffffffff, 22, 0, ERANGE}, - {"1ddh88h2782i515", 0xffffffffffffffff, 23, 0, 0}, - {"1ddh88h2782i516", 0xffffffffffffffff, 23, 0, ERANGE}, - {"l12ee5fn0ji1if", 0xffffffffffffffff, 24, 0, 0}, - {"l12ee5fn0ji1ig", 0xffffffffffffffff, 24, 0, ERANGE}, - {"c9c336o0mlb7ef", 0xffffffffffffffff, 25, 0, 0}, - {"c9c336o0mlb7eg", 0xffffffffffffffff, 25, 0, ERANGE}, - {"7b7n2pcniokcgf", 0xffffffffffffffff, 26, 0, 0}, - {"7b7n2pcniokcgg", 0xffffffffffffffff, 26, 0, ERANGE}, - {"4eo8hfam6fllmo", 0xffffffffffffffff, 27, 0, 0}, - {"4eo8hfam6fllmp", 0xffffffffffffffff, 27, 0, ERANGE}, - {"2nc6j26l66rhof", 0xffffffffffffffff, 28, 0, 0}, - {"2nc6j26l66rhog", 0xffffffffffffffff, 28, 0, ERANGE}, - {"1n3rsh11f098rn", 0xffffffffffffffff, 29, 0, 0}, - {"1n3rsh11f098ro", 0xffffffffffffffff, 29, 0, ERANGE}, - {"14l9lkmo30o40f", 0xffffffffffffffff, 30, 0, 0}, - {"14l9lkmo30o40g", 0xffffffffffffffff, 30, 0, ERANGE}, - {"nd075ib45k86f", 0xffffffffffffffff, 31, 0, 0}, - {"nd075ib45k86g", 0xffffffffffffffff, 31, 0, ERANGE}, - {"fvvvvvvvvvvvv", 0xffffffffffffffff, 32, 0, 0}, - {"g000000000000", 0xffffffffffffffff, 32, 0, ERANGE}, - {"b1w8p7j5q9r6f", 0xffffffffffffffff, 33, 0, 0}, - {"b1w8p7j5q9r6g", 0xffffffffffffffff, 33, 0, ERANGE}, - {"7orp63sh4dphh", 0xffffffffffffffff, 34, 0, 0}, - {"7orp63sh4dphi", 0xffffffffffffffff, 34, 0, ERANGE}, - {"5g24a25twkwff", 0xffffffffffffffff, 35, 0, 0}, - {"5g24a25twkwfg", 0xffffffffffffffff, 35, 0, ERANGE}, - {"3w5e11264sgsf", 0xffffffffffffffff, 36, 0, 0}, - {"3w5e11264sgsg", 0xffffffffffffffff, 36, 0, ERANGE}, -#endif - {NULL, 0, 0, 0, 0}, -}; - -/* Prototypes for local functions. */ -static void expand(char *dst, int c) -{ - if (isprint(c)) { - dst[0] = c; - dst[1] = '\0'; - } else - (void) sprintf(dst, "%#.3o", (unsigned int) c); -} - -int do_test_strtol(void) -{ - register const struct ltest *lt; - char *ep; - int status = 0; - int save_errno; - - for (lt = tests; lt->str != NULL; ++lt) { - register long int l; - - errno = 0; - l = strtol(lt->str, &ep, lt->base); - save_errno = errno; - printf("strtol(\"%s\", , %d) test %u", - lt->str, lt->base, (unsigned int)(lt - tests)); - if (l == (long int) lt->expect && *ep == lt->left - && save_errno == lt->err) - puts("\tOK"); - else { - puts("\tBAD"); - if (l != (long int) lt->expect) - printf(" returns %ld, expected %ld\n", - l, (long int) lt->expect); - if (lt->left != *ep) { - char exp1[5], exp2[5]; - expand(exp1, *ep); - expand(exp2, lt->left); - printf(" leaves '%s', expected '%s'\n", exp1, exp2); - } - if (save_errno != lt->err) - printf(" errno %d (%s) instead of %d (%s)\n", - save_errno, strerror(save_errno), - lt->err, strerror(lt->err)); - status = 1; - } - } - - for (++lt; lt->str != NULL; lt++) { - register unsigned long int ul; - - errno = 0; - ul = strtoul(lt->str, &ep, lt->base); - save_errno = errno; - printf("strtoul(\"%s\", , %d) test %u", - lt->str, lt->base, (unsigned int)(lt - tests)); - if (ul == lt->expect && *ep == lt->left && save_errno == lt->err) - puts("\tOK"); - else { - puts("\tBAD"); - if (ul != lt->expect) - printf(" returns %lu, expected %lu\n", - ul, lt->expect); - if (lt->left != *ep) { - char exp1[5], exp2[5]; - expand(exp1, *ep); - expand(exp2, lt->left); - printf(" leaves '%s', expected '%s'\n", exp1, exp2); - } - if (save_errno != lt->err) - printf(" errno %d (%s) instead of %d (%s)\n", - save_errno, strerror(save_errno), - lt->err, strerror(lt->err)); - status = 1; - } - } - - return status; -} - -int do_test_stdlib(void) -{ -#define Delta 1.0E-6 - printf("=== test stdlib begin ===\n"); - - char c[] = "365.24 29.53"; - char *end; - double d1, d2; - d1 = strtod(c, &end); - d2 = strtod(end, NULL); - if (fabs(d1 - 365.24) > Delta || fabs(d2 - 29.53) > Delta) { - printf("Failed: strtod(%s, X) got two double are %f and %f\n", c, d1, d2); - return -1; - } - int i = abs(-10); - if (i != 10) { - printf("Failed: abs(-10) got %d\n", i); - return -1; - } - long l = labs(-12345678); - if (l != 12345678) { - printf("Failed: labs(-12345678) got %ld\n", l); - return -1; - } - long long ll = llabs(-12345678999l); - if (ll != 12345678999l) { - printf("Failed: llabs(-12345678999l) got %lld\n", ll); - return -1; - } - d1 = atof("-10.231"); - if (d1 != -10.231) { - printf("Failed: atof(\"-10.231\") got: %f\n", d1); - return -1; - } - i = atoi("124"); - if (i != 124) { - printf("Failed: atoi(\"124\") got: %d\n", i); - return -1; - } - l = atol("12345678"); - if (l != 12345678) { - printf("Failed: atol(\"12345678\") got: %ld\n", l); - return -1; - } - ll = atoll("12345678999"); - if (ll != 12345678999l) { - printf("Failed: atoll(\"12345678999\") got: %lld\n", ll); - return -1; - } - div_t res = div(5, 3); - if (res.quot != 1 || res.rem != 2) { - printf("Failed: div(5, 3) got: quot=%d, rem=%d\n", res.quot, res.rem); - return -1; - } - int d, n; - char *str; - str = ecvt(12.3, 5, &d, &n); - if (strcmp(str, "12300") != 0 || d != 2 || n != 0) { - printf("Failed: ecvt(12.3, 5, &d, &n) returns: %s, d=%d, n=%d\n", str, d, n); - return -1; - } - double test_a = 23.12000000; - printf("test_a: %lf\n", test_a); - -//todo - // const wchar_t *wstod = L"12.12 23.12"; - // wchar_t *wend; - // double dd1 = wcstod(wstod, &wend); - // printf("dd1 size:%zd\n",sizeof(dd1)); - // printf("double size:%zd\n",sizeof(double)); - // printf("wend: %ls\n", wend); - // double dd2 = wcstod(wend, NULL); - // printf("dd1: %lf\n", dd1); - // printf("dd2: %lf\n", dd2); - // if (fabs(d1 - 12.12) > Delta || fabs(d2 - 23.12) > Delta) { - // printf("Failed: wcstod(L\"12.12 23.12\", X) got two double are %lf and %lf\n", d1, - // d2); - // return -1; - // } - - - - - - // qsort will sort 'months' by name through compmi method - qsort(months, nr_of_months, sizeof(struct mi), compmi); - // after sort "apr" will be the first. - if (months[0].nr != 4) { - printf("Failed: after qsort(months, ...), first month should be 4, but here got %d\n", - months[0].nr); - return -1; - } - struct mi key, *result; - key.name = "aug"; - result = (struct mi *)bsearch(&key, months, nr_of_months, sizeof(struct mi), - compmi); - if (result == NULL || result->nr != 8) { - if (result == NULL) - printf("Failed: after bsearch(&key, months, ...), result should be 8, but got NULL\n"); - else - printf("Failed: after bsearch(&key, months, ...), result should be 8, but got %d\n", - result->nr); - return -1; - } - printf("=== test stdlib end ===\n\n"); -#undef Delta - return 0; -} - -int do_test_getenv(void) -{ - char *tst_getenv; - tst_getenv = getenv("NOT_EXIST"); - if (tst_getenv != NULL) return -2; - - return 0; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/test_time.c b/test/xts/ta/test_libc_api/src/libc_func/test_time.c deleted file mode 100644 index 1b670b8c..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/test_time.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - - -static clockid_t clocks[2] = { CLOCK_REALTIME, CLOCK_MONOTONIC }; -#define TEST_LOOPING (100) -#define MILLISECOND 1000 -#define WAIT5S 5 - -int do_test_clock_gettime(void) -{ - int lc, i; - struct timespec spec; - int ret = 0, test_ret; - - for (lc = 0; lc < TEST_LOOPING; lc++) { - for (i = 0; i < (int)(sizeof(clocks) / sizeof(clockid_t)); i++) { - test_ret = clock_gettime(clocks[i], &spec); - if (test_ret < 0) { - ret = -1; - goto fail; - } - } - } - - // invalid address - test_ret = clock_gettime(clocks[0], NULL); - //test_ret |= clock_gettime(clocks[1], -1); - if (test_ret == 0) ret = -2; - -fail: - return ret; -} - -int do_test_strftime(void) -{ - struct tm newtime; - char buffer[80]; - - newtime.tm_sec = 10; - newtime.tm_min = 20; - newtime.tm_hour = 20; - newtime.tm_mday = 1; - newtime.tm_mon = 3; - newtime.tm_year = 118; - newtime.tm_wday = 2; - newtime.tm_yday = 11; - - strftime(buffer, 80, "%x - %I:%M%p", &newtime); - printf("time is : |%s|\n", buffer); - - return (0); -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/tst-calloc.c b/test/xts/ta/test_libc_api/src/libc_func/tst-calloc.c deleted file mode 100755 index d337d790..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/tst-calloc.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_libc_func.h" - -/* Number of samples per size. */ -#define N 5 - - -static void fixed_test(int size) -{ - char *ptrs[N]; - int i; - - for (i = 0; i < N; ++i) { - int j; - - ptrs[i] = (char *) calloc(1, size); - - if (ptrs[i] == NULL) - break; - - for (j = 0; j < size; ++j) { - if (ptrs[i][j] != '\0') - printf("LIBC TEST Failed. byte not cleared (size %d, element %d, byte %d)", - size, i, j); - ptrs[i][j] = '\xff'; - } - - } - - while (i-- > 0) - free(ptrs[i]); -} - - -static void random_test(void) -{ - char *ptrs[N]; - int i; - - for (i = 0; i < N; ++i) { - int j; - int n = 1 + random() % 10; - int elem = 1 + random() % 100; - int size = n * elem; - - ptrs[i] = (char *) calloc(n, elem); - - if (ptrs[i] == NULL) - break; - - for (j = 0; j < size; ++j) { - if (ptrs[i][j] != '\0') - printf("LIBC TEST Failed. byte not cleared (size %d, element %d, byte %d)", - size, i, j); - ptrs[i][j] = '\xff'; - } - } - - while (i-- > 0) - free(ptrs[i]); -} - - -static void null_test(void) -{ - /* If the size is 0 the result is implementation defined. Just make - sure the program doesn't crash. */ - calloc(0, 0); - calloc(0, UINT_MAX); - calloc(UINT_MAX, 0); - calloc(0, ~((size_t) 0)); - calloc(~((size_t) 0), 0); -} - - -int do_test_calloc(void) -{ - /* We are allocating blocks with `calloc' and check whether every - block is completely cleared. We first try this for some fixed - times and then with random size. */ - fixed_test(15); - fixed_test(5); - fixed_test(17); - fixed_test(6); - fixed_test(31); - fixed_test(96); - - random_test(); - - null_test(); - - printf("test calloc pass\n"); - return 0; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/tst-malloc.c b/test/xts/ta/test_libc_api/src/libc_func/tst-malloc.c deleted file mode 100755 index 7b68baa6..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/tst-malloc.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include "test_libc_func.h" - -static int errors = 0; - -static void merror(const char *msg) -{ - ++errors; - printf("Error: %s\n", msg); -} - -int do_test_malloc(void) -{ - void *p, *q; - - p = malloc(-1); - if (p != NULL) - merror("malloc (-1) succeeded.\n"); - - if (p == NULL && errno != ENOMEM) - merror("errno is not set correctly.\n"); - - p = malloc(10); - if (p == NULL) - merror("malloc (10) failed."); - - /* realloc (p, 0) == free (p). */ - p = realloc(p, 0); - if (p != NULL) - merror("realloc (p, 0) failed."); - - p = malloc(0); - if (p != NULL) - merror("malloc (0) failed."); - - p = realloc(p, 0); - if (p != NULL) - merror("realloc (p, 0) failed."); - - p = malloc(513 * 1024); - if (p == NULL) - merror("malloc (513K) failed."); - - p = realloc(p, 513 * 1024 - 3); - if (p == NULL) - merror("realloc (p, 513 * 1024 - 3) failed."); - - p = realloc(p, 513 * 1024 + 3); - if (p == NULL) - merror("realloc (p, 513 * 1024 + 3) failed."); - free(p); - - p = malloc(16); - if (p == NULL) - merror("malloc (16) failed."); - - p = realloc(p, 16 + 1024); - if (p == NULL) - merror("realloc (p, 16 + 1024) failed."); - - p = realloc(p, 15 + 1024); - if (p == NULL) - merror("realloc (p, 15 + 1024) failed."); - free(p); - - q = malloc(-512 * 1024); - if (q != NULL) - merror("malloc (-512K) succeeded."); - - printf("test malloc pass\n"); - return errors; -} diff --git a/test/xts/ta/test_libc_api/src/libc_func/tst_free.c b/test/xts/ta/test_libc_api/src/libc_func/tst_free.c deleted file mode 100755 index 95def008..00000000 --- a/test/xts/ta/test_libc_api/src/libc_func/tst_free.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include "test_libc_func.h" - -int do_test_free(void) -{ - void *p; - - p = malloc(1); - free(p); - - p = malloc(4); - free(p); - - p = malloc(1024 * 1024); - free(p); - return 0; -} - -int do_test_free_1(void) -{ - char *str; - str = (char *)malloc(10); - strcpy(str, "Hello"); - printf("free test: String is %s\n", str); - free(str); - str = NULL; - return 0; -} diff --git a/test/xts/ta/test_libc_api/src/ta_case_work.c b/test/xts/ta/test_libc_api/src/ta_case_work.c deleted file mode 100644 index d413c140..00000000 --- a/test/xts/ta/test_libc_api/src/ta_case_work.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "ta_case_work.h" -#include - -void CaseRunner(CaseInfo *caseList, const uint32_t caseNum) -{ - for (uint32_t idx = 0; idx < caseNum; idx++) { - CaseInfo *info = caseList + idx; - tlogi("start case: %s ----- [%u/%u]", info->caseDesc, idx + 1, caseNum); - info->ret = info->pfunc(); - if (info->ret != TEE_SUCCESS) { - tloge("run case %s failed, ret: 0x%x", info->caseDesc, info->ret); - } else { - tlogi("run case %s passed !", info->caseDesc); - } - } -} - -uint32_t CaseReporter(CaseInfo *caseList, const uint32_t caseNum) -{ - uint32_t failCount = 0; - - tlogi("Finished to run all %u cases, start to report:", caseNum); - for (uint32_t idx = 0; idx < caseNum; idx++) { - CaseInfo *info = caseList + idx; - if (info->ret != TEE_SUCCESS) { - failCount++; - tloge("CASE %u --> %s [FAILED], ret: 0x%x", idx + 1, info->caseDesc, info->ret); - } - } - - if (failCount == 0) { - tlogi("All %u Cases Passed !!!", caseNum); - } else { - tloge("[Case Failure] Total %u Cases Failed !!!", failCount); - } - - return failCount; -} diff --git a/test/xts/ta/test_libc_api/src/ta_case_work.h b/test/xts/ta/test_libc_api/src/ta_case_work.h deleted file mode 100644 index 62dacd6f..00000000 --- a/test/xts/ta/test_libc_api/src/ta_case_work.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef _TA_CASE_DEFINE_H_ -#define _TA_CASE_DEFINE_H_ - -#include - -#define number_of(x) (sizeof(x) / sizeof(x[0])) - -typedef int (*CaseEntry)(void); - -typedef struct { - CaseEntry pfunc; - char *caseDesc; - TEE_Result ret; -} CaseInfo; - -#define CASE_REGISTOR(func) {func, #func, 0} - -void CaseRunner(CaseInfo *caseList, const uint32_t caseNum); -uint32_t CaseReporter(CaseInfo *caseList, const uint32_t caseNum); - -#endif - diff --git a/test/xts/ta/test_libc_api/src/test_libc_cases.h b/test/xts/ta/test_libc_api/src/test_libc_cases.h deleted file mode 100644 index 6ab60512..00000000 --- a/test/xts/ta/test_libc_api/src/test_libc_cases.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef _TEST_LIBC_CASES_H_ -#define _TEST_LIBC_CASES_H_ - -#include - -enum LibcCmdId { - CMD_TEST_PTHREAD_ATTR = 0, - CMD_TEST_PTHREAD_BASE_FUNC, - CMD_TEST_PTHREAD_MUTEX_LOCK, - CMD_TEST_PTHREAD_SPIN_LOCK, - CMD_TEST_PTHREAD_COND, - CMD_TEST_SEM, - CMD_TEST_APPLY_AND_FREE_MEM, - CMD_TEST_MMAP_AND_MUNMAP, - CMD_TEST_LIBC_MATH, - CMD_TEST_LIBC_STDLIB, - CMD_TEST_LIBC_CTYPE, - CMD_TEST_LIBC_TIME, - CMD_TEST_LIBC_STDIO, - CMD_TEST_LIBC_ERROR, - CMD_TEST_LIBC_UNISTD, - CMD_TEST_LIBC_LOCALE, - CMD_TEST_LIBC_MULTIBYTE, - CMD_TEST_LIBC_PRNG, - CMD_TEST_LIBC_STRING, -}; - -TEE_Result TestPthreadAttr(void); -TEE_Result TestPthreadBaseFunc(void); -TEE_Result TestPthreadMutexLock(void); -TEE_Result TestPthreadSpinLock(void); -TEE_Result TestPthreadCond(void); -TEE_Result TestSem(void); - -TEE_Result TestApplyAndFreeMem(void); -TEE_Result TestMmapAndMunmap(void); - -TEE_Result TestLibcMath(void); -TEE_Result TestLibcStdlib(void); -TEE_Result TestLibcCtype(void); -TEE_Result TestLibcTime(void); -TEE_Result TestLibcStdio(void); -TEE_Result TestLibcError(void); -TEE_Result TestLibcUnistd(void); -TEE_Result TestLibcLocale(void); -TEE_Result TestLibcMultiByte(void); -TEE_Result TestLibcPrng(void); - -TEE_Result TestLibcString(void); - -#endif \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/test_libc_common_lib.c b/test/xts/ta/test_libc_api/src/test_libc_common_lib.c deleted file mode 100644 index c9c6fb23..00000000 --- a/test/xts/ta/test_libc_api/src/test_libc_common_lib.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include "ta_case_work.h" - -TEE_Result TestLibcMath(void) -{ - static CaseInfo libcMathList[] = { - CASE_REGISTOR(do_test_atan), - CASE_REGISTOR(do_test_ceil), - CASE_REGISTOR(do_test_ceilf), - CASE_REGISTOR(do_test_exp), - CASE_REGISTOR(do_test_fabs), - CASE_REGISTOR(do_test_floor), - CASE_REGISTOR(do_test_frexpl), - CASE_REGISTOR(do_test_log), - CASE_REGISTOR(do_test_log2), - CASE_REGISTOR(do_test_pow), - CASE_REGISTOR(do_test_roundf), - CASE_REGISTOR(do_test_sqrt), - }; - - CaseRunner(libcMathList, number_of(libcMathList)); - return CaseReporter(libcMathList, number_of(libcMathList)); -} - -TEE_Result TestLibcStdlib(void) -{ - static CaseInfo libcStdlibList[] = { - CASE_REGISTOR(do_test_stdlib), - CASE_REGISTOR(do_test_strtol), - CASE_REGISTOR(do_test_getenv), - }; - - CaseRunner(libcStdlibList, number_of(libcStdlibList)); - return CaseReporter(libcStdlibList, number_of(libcStdlibList)); -} - -TEE_Result TestLibcCtype(void) -{ - static CaseInfo libcCtypeList[] = { - CASE_REGISTOR(do_test_ctype), - CASE_REGISTOR(do_test_wctype), - CASE_REGISTOR(do_test_towfun), - }; - - CaseRunner(libcCtypeList, number_of(libcCtypeList)); - return CaseReporter(libcCtypeList, number_of(libcCtypeList)); -} - -TEE_Result TestLibcTime(void) -{ - static CaseInfo libcTimeList[] = { - CASE_REGISTOR(do_test_clock_gettime), - CASE_REGISTOR(do_test_strftime), - }; - - CaseRunner(libcTimeList, number_of(libcTimeList)); - return CaseReporter(libcTimeList, number_of(libcTimeList)); -} - -TEE_Result TestLibcStdio(void) -{ - static CaseInfo libcTimeList[] = { - CASE_REGISTOR(do_test_vsprintf), - CASE_REGISTOR(do_test_sprintf), - CASE_REGISTOR(do_test_fflush), - CASE_REGISTOR(do_test_stdio), - }; - - CaseRunner(libcTimeList, number_of(libcTimeList)); - return CaseReporter(libcTimeList, number_of(libcTimeList)); -} - -TEE_Result TestLibcError(void) -{ - static CaseInfo libcErrorList[] = { - CASE_REGISTOR(test_error), - }; - - CaseRunner(libcErrorList, number_of(libcErrorList)); - return CaseReporter(libcErrorList, number_of(libcErrorList)); -} - -TEE_Result TestLibcUnistd(void) -{ - static CaseInfo libcUnistdList[] = { - CASE_REGISTOR(do_test_getpid), - }; - - CaseRunner(libcUnistdList, number_of(libcUnistdList)); - return CaseReporter(libcUnistdList, number_of(libcUnistdList)); -} - -TEE_Result TestLibcLocale(void) -{ - static CaseInfo libcLocaleList[] = { - CASE_REGISTOR(do_test_strtod1), - CASE_REGISTOR(do_test_strtod2), - CASE_REGISTOR(do_test_strtod3), - CASE_REGISTOR(do_test_strcoll), - CASE_REGISTOR(test_strxfrm), - }; - - CaseRunner(libcLocaleList, number_of(libcLocaleList)); - return CaseReporter(libcLocaleList, number_of(libcLocaleList)); -} - -TEE_Result TestLibcMultiByte(void) -{ - static CaseInfo libcMultiByteList[] = { - CASE_REGISTOR(do_test_mbrtowc), - CASE_REGISTOR(do_test_wcrtomb), - CASE_REGISTOR(do_test_wctob), - }; - - CaseRunner(libcMultiByteList, number_of(libcMultiByteList)); - return CaseReporter(libcMultiByteList, number_of(libcMultiByteList)); -} - -TEE_Result TestLibcPrng(void) -{ - static CaseInfo libcPrngList[] = { - CASE_REGISTOR(do_test_random), - CASE_REGISTOR(do_test_srandom), - CASE_REGISTOR(do_test_wctob), - }; - - CaseRunner(libcPrngList, number_of(libcPrngList)); - return CaseReporter(libcPrngList, number_of(libcPrngList)); -} \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/test_libc_main.c b/test/xts/ta/test_libc_api/src/test_libc_main.c deleted file mode 100644 index e0bcf4a5..00000000 --- a/test/xts/ta/test_libc_api/src/test_libc_main.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include - -#define CA_VENDOR "/vendor/bin/tee_test_libc_api" -#define CA_SYSTEM "/system/bin/tee_test_libc_api" -#define CA_UID 0 - -typedef TEE_Result (* TestLibcApiFunc)(void); - -typedef struct { - uint32_t cmdId; - TestLibcApiFunc func; -} TestFunctionWithCmd; - -static TestFunctionWithCmd g_cmdList[] = { - {CMD_TEST_PTHREAD_ATTR, TestPthreadAttr}, // 0 - {CMD_TEST_PTHREAD_BASE_FUNC, TestPthreadBaseFunc}, - {CMD_TEST_PTHREAD_MUTEX_LOCK, TestPthreadMutexLock}, - {CMD_TEST_PTHREAD_SPIN_LOCK, TestPthreadSpinLock}, - {CMD_TEST_PTHREAD_COND, TestPthreadCond}, - {CMD_TEST_SEM, TestSem}, - {CMD_TEST_APPLY_AND_FREE_MEM, TestApplyAndFreeMem}, - {CMD_TEST_MMAP_AND_MUNMAP, TestMmapAndMunmap}, - {CMD_TEST_LIBC_MATH, TestLibcMath}, - {CMD_TEST_LIBC_STDLIB, TestLibcStdlib}, - {CMD_TEST_LIBC_CTYPE, TestLibcCtype}, - {CMD_TEST_LIBC_TIME, TestLibcTime}, - {CMD_TEST_LIBC_STDIO, TestLibcStdio}, - {CMD_TEST_LIBC_ERROR, TestLibcError}, - {CMD_TEST_LIBC_UNISTD, TestLibcUnistd}, - {CMD_TEST_LIBC_LOCALE, TestLibcLocale}, - {CMD_TEST_LIBC_MULTIBYTE, TestLibcMultiByte}, - {CMD_TEST_LIBC_PRNG, TestLibcPrng}, - {CMD_TEST_LIBC_STRING, TestLibcString}, -}; - -static TEE_Result TestLibcApi(uint32_t cmdId) -{ - uint32_t count = sizeof(g_cmdList) / sizeof(g_cmdList[0]); - tlogi("[TestLibcApi]: g_cmdList count = %d, cmdId = %d\n", count, cmdId); - for (uint32_t i = 0; i < count; i++) { - if (g_cmdList[i].cmdId == cmdId) { - return g_cmdList[i].func(); - } - } - - tlogi("unknown command id, cmdId: %u\n", cmdId); - return TEE_ERROR_INVALID_CMD; -} - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("---- TA_CreateEntryPoint ---------"); - TEE_Result ret = AddCaller_CA_exec(CA_VENDOR, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("Add caller failed, ret = 0x%x", ret); - return ret; - } - - ret = AddCaller_CA_exec(CA_SYSTEM, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("Add caller failed, ret = 0x%x", ret); - return ret; - } - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext) -{ - (void)parmType; - (void)params; - (void)sessionContext; - tlogi("---- TA_OpenSessionEntryPoint --------"); - - return TEE_SUCCESS; -} - -TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmdId, uint32_t parmType, TEE_Param params[4]) -{ - TEE_Result ret = TEE_SUCCESS; - (void)sessionContext; - (void)params; - (void)parmType; - - ret = TestLibcApi(cmdId); - if (ret != TEE_SUCCESS) - tloge("invoke command for value failed! cmdId: %u, ret: 0x%x", cmdId, ret); - - return ret; -} - -void TA_CloseSessionEntryPoint(void *sessionContext) -{ - (void)sessionContext; - tlogi("---- TA_CloseSessionEntryPoint -----"); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("---- TA_DestroyEntryPoint ----"); -} - diff --git a/test/xts/ta/test_libc_api/src/test_libc_mem.c b/test/xts/ta/test_libc_api/src/test_libc_mem.c deleted file mode 100644 index 5dee8f16..00000000 --- a/test/xts/ta/test_libc_api/src/test_libc_mem.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include "ta_case_work.h" - -TEE_Result TestApplyAndFreeMem(void) -{ - static CaseInfo applyAndFreeMemList[] = { - CASE_REGISTOR(do_test_calloc), - CASE_REGISTOR(do_test_malloc), - CASE_REGISTOR(do_test_free), - CASE_REGISTOR(do_test_free_1), - }; - - CaseRunner(applyAndFreeMemList, number_of(applyAndFreeMemList)); - return CaseReporter(applyAndFreeMemList, number_of(applyAndFreeMemList)); -} - -TEE_Result TestMmapAndMunmap(void) -{ - static CaseInfo mmapAndMunmapList[] = { - CASE_REGISTOR(test_mmap), - }; - - CaseRunner(mmapAndMunmapList, number_of(mmapAndMunmapList)); - return CaseReporter(mmapAndMunmapList, number_of(mmapAndMunmapList)); -} \ No newline at end of file diff --git a/test/xts/ta/test_libc_api/src/test_libc_pthread.c b/test/xts/ta/test_libc_api/src/test_libc_pthread.c deleted file mode 100644 index 15bbe802..00000000 --- a/test/xts/ta/test_libc_api/src/test_libc_pthread.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include "ta_case_work.h" - -TEE_Result TestPthreadAttr(void) -{ - static CaseInfo pthreadAttrTestList[] = { - CASE_REGISTOR(pthread_attr_destroy_1_1), - CASE_REGISTOR(pthread_attr_destroy_2_1), - CASE_REGISTOR(pthread_attr_destroy_3_1), - CASE_REGISTOR(pthread_attr_getstack_1_1), - CASE_REGISTOR(pthread_attr_getstacksize_1_1), - CASE_REGISTOR(pthread_attr_init_1_1), - CASE_REGISTOR(pthread_attr_init_3_1), - CASE_REGISTOR(pthread_attr_init_4_1), - CASE_REGISTOR(pthread_attr_setstack_1_1), - CASE_REGISTOR(pthread_attr_setstack_2_1), - CASE_REGISTOR(pthread_attr_setstack_4_1), - CASE_REGISTOR(pthread_attr_setstack_6_1), - CASE_REGISTOR(pthread_attr_setstack_7_1), - CASE_REGISTOR(pthread_attr_setstacksize_1_1), - CASE_REGISTOR(pthread_attr_setstacksize_2_1), - CASE_REGISTOR(pthread_attr_setstacksize_4_1), - }; - - CaseRunner(pthreadAttrTestList, number_of(pthreadAttrTestList)); - return CaseReporter(pthreadAttrTestList, number_of(pthreadAttrTestList)); -} - -TEE_Result TestPthreadBaseFunc(void) -{ - static CaseInfo pthreadBaseFuncList[] = { - CASE_REGISTOR(pthread_create_1_1), - CASE_REGISTOR(pthread_create_2_1), - CASE_REGISTOR(pthread_create_4_1), - CASE_REGISTOR(pthread_create_5_1), - CASE_REGISTOR(pthread_create_5_2), - CASE_REGISTOR(pthread_create_12_1), - CASE_REGISTOR(pthread_exit_2_1), - CASE_REGISTOR(pthread_exit_3_1), - CASE_REGISTOR(pthread_once_1_3), - CASE_REGISTOR(test_pthread_equal), - CASE_REGISTOR(pthread_getspecific_1_1), - CASE_REGISTOR(pthread_setspecific_1_2), - CASE_REGISTOR(test_pthread_key_create), - }; - - CaseRunner(pthreadBaseFuncList, number_of(pthreadBaseFuncList)); - return CaseReporter(pthreadBaseFuncList, number_of(pthreadBaseFuncList)); -} - -TEE_Result TestPthreadMutexLock(void) -{ - static CaseInfo pthreadMutexLockList[] = { - CASE_REGISTOR(pthread_mutex_init_1_1), - CASE_REGISTOR(pthread_mutex_init_2_1_0), - CASE_REGISTOR(pthread_mutex_lock_0_2), - CASE_REGISTOR(pthread_mutex_lock_0_3), - CASE_REGISTOR(pthread_mutex_lock_1_1_0), - CASE_REGISTOR(pthread_mutex_trylock_0_1), - CASE_REGISTOR(pthread_mutex_trylock_1_1), - CASE_REGISTOR(pthread_mutex_trylock_4_1), - CASE_REGISTOR(pthread_mutex_unlock_1_1), - CASE_REGISTOR(pthread_mutex_destroy_1_1_0), - CASE_REGISTOR(pthread_mutex_destroy_2_1), - CASE_REGISTOR(pthread_mutex_destroy_4_2), - CASE_REGISTOR(pthread_mutexattr_getprotocol_1_1), - CASE_REGISTOR(pthread_mutexattr_gettype_1_1), - }; - - CaseRunner(pthreadMutexLockList, number_of(pthreadMutexLockList)); - return CaseReporter(pthreadMutexLockList, number_of(pthreadMutexLockList)); -} - -TEE_Result TestPthreadSpinLock(void) -{ - static CaseInfo pthreadSpinLockList[] = { - CASE_REGISTOR(pthread_spin_destroy_1_1), - CASE_REGISTOR(pthread_spin_init_1_1), - CASE_REGISTOR(pthread_spin_lock_0_1), - CASE_REGISTOR(pthread_spin_lock_0_3), - CASE_REGISTOR(pthread_spin_trylock_0_1), - CASE_REGISTOR(pthread_spin_trylock_1_1), - CASE_REGISTOR(pthread_spin_trylock_4_1), - CASE_REGISTOR(pthread_spin_unlock_1_1), - }; - - CaseRunner(pthreadSpinLockList, number_of(pthreadSpinLockList)); - return CaseReporter(pthreadSpinLockList, number_of(pthreadSpinLockList)); -} - -TEE_Result TestPthreadCond(void) -{ - static CaseInfo pthreadCondTestList[] = { - CASE_REGISTOR(pthread_cond_init_1_1), - CASE_REGISTOR(pthread_cond_wait_0_1), - CASE_REGISTOR(pthread_cond_wait_0_2), - CASE_REGISTOR(pthread_cond_wait_0_3), - CASE_REGISTOR(pthread_cond_broadcast_1_1), - }; - - CaseRunner(pthreadCondTestList, number_of(pthreadCondTestList)); - return CaseReporter(pthreadCondTestList, number_of(pthreadCondTestList)); -} - -TEE_Result TestSem(void) -{ - static CaseInfo semTestList[] = { - CASE_REGISTOR(test_sem), - }; - - CaseRunner(semTestList, number_of(semTestList)); - return CaseReporter(semTestList, number_of(semTestList)); -} diff --git a/test/xts/ta/test_libc_api/src/test_libc_string.c b/test/xts/ta/test_libc_api/src/test_libc_string.c deleted file mode 100644 index 354a86a9..00000000 --- a/test/xts/ta/test_libc_api/src/test_libc_string.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2023 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include "ta_case_work.h" - -TEE_Result TestLibcString(void) -{ - static CaseInfo libcStringList[] = { - CASE_REGISTOR(do_test_memcmp), - CASE_REGISTOR(do_test_strcmp), - CASE_REGISTOR(do_test_strchr), - CASE_REGISTOR(do_test_strlen), - CASE_REGISTOR(do_test_memset), - CASE_REGISTOR(do_test_memmove), - CASE_REGISTOR(do_test_memcpy), - CASE_REGISTOR(do_test_wmemchr), - CASE_REGISTOR(do_test_wcslen), - }; - - CaseRunner(libcStringList, number_of(libcStringList)); - return CaseReporter(libcStringList, number_of(libcStringList)); -} \ No newline at end of file diff --git a/test/xts/ta/test_tcf2_api/CMakeLists.txt b/test/xts/ta/test_tcf2_api/CMakeLists.txt deleted file mode 100644 index feb6be39..00000000 --- a/test/xts/ta/test_tcf2_api/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_tcf2_api.elf) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - src/tee_test_tcf.c - - INCLUDE_DIRS - - COMPILE_OPTS - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_tcf2_api/manifest.txt b/test/xts/ta/test_tcf2_api/manifest.txt deleted file mode 100644 index 017aa191..00000000 --- a/test/xts/ta/test_tcf2_api/manifest.txt +++ /dev/null @@ -1,8 +0,0 @@ -gpd.ta.appID: 534d4152-542d-4353-4c54-d3016a171f02 -gpd.ta.service_name: TCF2_test -gpd.ta.singleInstance: true -gpd.ta.multiSession: false -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 18176000 -gpd.ta.stackSize: 81920 -smc.ta.identity: 0xf0000000:01010101-2020-0303-4040-050505050505 \ No newline at end of file diff --git a/test/xts/ta/test_tcf2_api/src/tee_test_tcf.c b/test/xts/ta/test_tcf2_api/src/tee_test_tcf.c deleted file mode 100644 index 2bcae73b..00000000 --- a/test/xts/ta/test_tcf2_api/src/tee_test_tcf.c +++ /dev/null @@ -1,716 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define CA_PKGN_VENDOR "/vendor/bin/tee_test_tcf_api" -#define CA_PKGN_SYSTEM "/system/bin/tee_test_tcf_api" -#define CA_UID 0 - -#define SMC_TA_TESTIDENTITY_LOGIN 0xF0000000 -#define SMC_TA_TESTIDENTITY_TIMELOW 0x01010101 -#define SMC_TA_TESTIDENTITY_TIMEMID 0x2020 -#define SMC_TA_TESTIDENTITY_TIMEHIANDVERSION 0x0303 -#define SMC_TA_TESTIDENTITY_CLOCKSEQANDNODE \ - { \ - 0x40, 0x40, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 \ - } - -#define TESTSIZE 16 -#define DEFAULT_BUFFER_SIZE 1024 -#define MAX_TA2TA_SIZE 0x800000 - -#define MAXLEN_U32 11 -#define ENUMERATOR1 1 -#define MAX_ENUMERATOR 1023 - -static char g_testVar[] = "this is test for non-const variable"; -static const char g_testVar2[] = "this is test for const variable"; - -static TEE_Result CmdTEEGetPropertyAsIdentity_withoutEnum(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - char nClockSeqAndNode[8] = SMC_TA_TESTIDENTITY_CLOCKSEQANDNODE; - TEE_Identity nResultIdentity; - TEE_Result cmdResult; - uint32_t caseId; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types\n", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsIdentity(nPropSet, NULL, &nResultIdentity); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsIdentity(nPropSet, pPropName, NULL); - break; - default: - cmdResult = TEE_GetPropertyAsIdentity(nPropSet, pPropName, &nResultIdentity); - break; - } - - if (cmdResult == TEE_SUCCESS) { - if ((nResultIdentity.login == (uint32_t)SMC_TA_TESTIDENTITY_LOGIN) && - (nResultIdentity.uuid.timeLow == (uint32_t)SMC_TA_TESTIDENTITY_TIMELOW) && - (nResultIdentity.uuid.timeMid == (uint16_t)SMC_TA_TESTIDENTITY_TIMEMID) && - (nResultIdentity.uuid.timeHiAndVersion == (uint16_t)SMC_TA_TESTIDENTITY_TIMEHIANDVERSION) && - (TEE_MemCompare(&nResultIdentity.uuid.clockSeqAndNode, nClockSeqAndNode, 8) == 0)) { - tlogi("TEE_GetPropertyAsIdentity success and get identity is correct!\n"); - } else { - tloge("TEE_GetPropertyAsUUID get identity is wrong!\n"); - cmdResult = TEE_ERROR_GENERIC; - } - } - - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyAsU32(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - char outStr[MAXLEN_U32] = { 0 }; - uint32_t caseId; - TEE_Result cmdResult; - uint32_t nIntResult = 0; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types\n", __func__); - return TEE_ERROR_COMMUNICATION; - } - - caseId = pParams[0].value.b; - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - pPropName = pParams[1].memref.buffer; - - switch (caseId) { - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsU32(nPropSet, pPropName, NULL); - break; - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsU32(nPropSet, NULL, &nIntResult); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsU32(nPropSet, NULL, &nIntResult); - else - cmdResult = TEE_GetPropertyAsU32(nPropSet, pPropName, &nIntResult); - break; - } - - (void)snprintf_s(outStr, MAXLEN_U32, MAXLEN_U32 - 1, "%lu", nIntResult); - TEE_MemMove(pParams[2].memref.buffer, outStr, strlen(outStr) + 1); - pParams[2].memref.size = strlen(outStr) + 1; - - return cmdResult; -} - -static TEE_Result CmdTEEMalloc(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - size_t nSize; - uint32_t nHint; - char *pBuffer = NULL; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { - tloge("%s: Bad expected parameter types\n", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nSize = pParams[0].value.a; - nHint = pParams[0].value.b; - - tlogi("before TEE_Malloc nSize=%d, nHint=%d\n", nSize, nHint); - pBuffer = (char *)TEE_Malloc(nSize, nHint); - if (pBuffer == NULL) { - tloge("TEE_Malloc is failed!\n"); - return TEE_ERROR_OUT_OF_MEMORY; - } else { - TEE_MemMove(pParams[1].memref.buffer, pBuffer, nSize); - TEE_Free((void *)pBuffer); // free the allocated buffer - tlogi("TEE_Free is finish!\n"); - return TEE_SUCCESS; - } -} - -static TEE_Result CmdTEERealloc(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - size_t nOldSize, nNewSize; - char *pBufferMalloc = NULL; - char *pBufferRealloc = NULL; - char buf[DEFAULT_BUFFER_SIZE] = { 0 }; - - uint32_t caseId = pParams[3].value.a; - nOldSize = pParams[0].value.a; - nNewSize = pParams[0].value.b; - - pBufferMalloc = (char *)TEE_Malloc(nOldSize, 0); - if (pBufferMalloc == NULL) - return TEE_ERROR_OUT_OF_MEMORY; - - (void)memset_s(pBufferMalloc, nOldSize, 0x41, nOldSize); // 'A' is 0x41 - - if (caseId == BUFFER_IS_FREE) { - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - } - if (caseId == INPUT_ISNULL) { - pBufferRealloc = (char *)TEE_Realloc(NULL, nNewSize); - } else if (caseId == BUFFER_ISNOT_MALLOC) { - pBufferRealloc = (char *)TEE_Realloc(buf, nNewSize); - } else { - pBufferRealloc = (char *)TEE_Realloc((void *)pBufferMalloc, nNewSize); - } - if ((pBufferRealloc == NULL) && (pBufferMalloc == NULL)) { - return TEE_ERROR_OUT_OF_MEMORY; - } - if ((pBufferRealloc == NULL) && (pBufferMalloc != NULL)) { - for (uint32_t i = 0; i < nOldSize; i++) { - if (pBufferMalloc[i] != (char)'A') { // checks that the data has not been changed after realloc - tloge("%d th bytes of pBufferMalloc is not correct, it is %c \n", i + 1, pBufferMalloc[i]); - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - return TEE_ERROR_GENERIC; - } - } - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - return TEE_ERROR_OUT_OF_MEMORY; - } - if (pBufferRealloc != NULL) { - pParams[2].value.a = (uint32_t)pBufferMalloc; - pParams[2].value.b = (uint32_t)pBufferRealloc; - if (caseId == INPUT_ISNULL) - TEE_MemMove(pParams[1].memref.buffer, pBufferMalloc, nOldSize); - else - TEE_MemMove(pParams[1].memref.buffer, pBufferRealloc, (nOldSize < nNewSize ? nOldSize : nNewSize)); - - TEE_Free((void *)pBufferRealloc); // free the reallocated buffer - if (pBufferMalloc != NULL) { - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - } - } - return TEE_SUCCESS; -} - -static TEE_Result CmdTEEMemMove(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - uint32_t caseId; - char *pBufferSrc = NULL; - char *pBufferDest = NULL; - uint32_t i; - size_t nSize; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nSize = pParams[0].value.a; - caseId = pParams[0].value.b; - - pBufferSrc = (char *)TEE_Malloc(nSize, 0); - if (pBufferSrc == NULL) - return TEE_ERROR_OUT_OF_MEMORY; - - pBufferDest = (char *)TEE_Malloc(nSize, 0); - if (pBufferDest == NULL) { - TEE_Free((void *)pBufferSrc); - return TEE_ERROR_OUT_OF_MEMORY; - } else { - (void)memset_s(pBufferDest, nSize, 0x42, nSize); // 0x42 is 'B' - for (i = 0; i < nSize; i++) - pBufferSrc[i] = (char)'A'; // writes data into the buffer - if (caseId == INPUT_ISNULL) { - TEE_MemMove((void *)pBufferDest, NULL, nSize); - } else if (caseId == OUTPUT_ISNULL) { - TEE_MemMove(NULL, (void *)pBufferSrc, nSize); - } else if (caseId == OUTPUTBUFFERSIZE_ISZERO) { - TEE_MemMove((void *)pBufferDest, (void *)pBufferSrc, 0); - } else if (caseId == DESTANDSRC_ISSAME) { - TEE_MemMove((void *)pBufferSrc, (void *)pBufferSrc, nSize); - } else if (caseId == DESTANDSRC_OVERLAP) { - TEE_MemMove((void *)pBufferDest, (void *)pBufferSrc, nSize >> 1); - TEE_MemMove((void *)(pBufferDest + 1), (void *)pBufferDest, nSize >> 1); // is overlap - } else { - TEE_MemMove((void *)pBufferDest, (void *)pBufferSrc, nSize); - } - TEE_MemMove(pParams[1].memref.buffer, pBufferDest, nSize); - - TEE_Free((void *)pBufferSrc); - TEE_Free((void *)pBufferDest); - return TEE_SUCCESS; - } -} - -static TEE_Result CmdTEEMemCompare(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - uint32_t caseId; - char *pBuffer1 = NULL; - char *pBuffer2 = NULL; - TEE_Result ret; - size_t nSize; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_INPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nSize = pParams[0].value.a; - caseId = pParams[0].value.b; - - pBuffer1 = pParams[1].memref.buffer; - pBuffer2 = pParams[2].memref.buffer; - - if (caseId == INPUT_ISNULL) - ret = (TEE_Result)TEE_MemCompare(NULL, pBuffer2, nSize); - else if (caseId == OUTPUT_ISNULL) - ret = (TEE_Result)TEE_MemCompare(pBuffer1, NULL, nSize); - else - ret = (TEE_Result)TEE_MemCompare(pBuffer1, pBuffer2, nSize); - - return ret; -} - -static TEE_Result CmdTEEMemFill(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - uint32_t caseId; - char *pBuffer = NULL; - char nCharFill = 'A'; - size_t nMemoryFillSize; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nMemoryFillSize = pParams[0].value.a; - caseId = pParams[0].value.b; - - pBuffer = (char *)TEE_Malloc(nMemoryFillSize, 0); // buffer is filled with 0 - if (pBuffer == NULL) { - return TEE_ERROR_OUT_OF_MEMORY; - } - if (caseId == INPUT_ISNULL) { - TEE_MemFill(NULL, nCharFill, nMemoryFillSize); - } else if (caseId == OUTPUTBUFFERSIZE_ISZERO) { - TEE_MemFill(pBuffer, nCharFill, 0); - } else { - TEE_MemFill(pBuffer, nCharFill, nMemoryFillSize); - } - TEE_MemMove(pParams[1].memref.buffer, pBuffer, nMemoryFillSize); - TEE_Free((void *)pBuffer); - return TEE_SUCCESS; -} - -static TEE_Result CmdTEEFree(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - void *pBufferMalloc = NULL; - uint32_t caseId; - char buf[DEFAULT_BUFFER_SIZE] = { 0 }; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - caseId = pParams[0].value.a; - if (caseId == INPUT_ISNULL) { - TEE_Free(NULL); - return TEE_SUCCESS; - } else if (caseId == BUFFER_ISNOT_MALLOC) { - TEE_Free(buf); - return TEE_SUCCESS; - } else { - pBufferMalloc = TEE_Malloc(DEFAULT_BUFFER_SIZE, 0); - if (pBufferMalloc == NULL) - return TEE_ERROR_OUT_OF_MEMORY; - TEE_Free(pBufferMalloc); - return TEE_SUCCESS; - } -} - -static TEE_Result CmdTEECheckMemoryAccessRights(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - uint32_t caseId; - uint32_t accessFlags; - char *pBuffer = NULL; - char buf[DEFAULT_BUFFER_SIZE] = { 0 }; - size_t nSize; - TEE_Result ret; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_OUTPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_VALUE_INPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - accessFlags = pParams[0].value.a; - nSize = pParams[0].value.b; - caseId = pParams[2].value.a; - - pBuffer = (char *)TEE_Malloc(nSize, 0); - if (pBuffer == NULL) { - return TEE_ERROR_OUT_OF_MEMORY; - } - if (caseId == BUFFER_IS_FREE) { - TEE_Free((void *)pBuffer); // free the allocated buffer - } - if (caseId == INPUT_ISNULL) - ret = TEE_CheckMemoryAccessRights(accessFlags, NULL, nSize); - else if (caseId == BUFFER_ISNOT_MALLOC) - ret = TEE_CheckMemoryAccessRights(accessFlags, buf, nSize); - else if (caseId == OUTPUTBUFFERSIZE_ISZERO) - ret = TEE_CheckMemoryAccessRights(accessFlags, pBuffer, 0); - else if (caseId == BUFFERSIZE_ISTOOBIG) - ret = TEE_CheckMemoryAccessRights(accessFlags, pBuffer, nSize << 6); - else if (caseId == BUFFER_IS_PARAM) - ret = TEE_CheckMemoryAccessRights(accessFlags, pParams[1].memref.buffer, pParams[1].memref.size); - else if (caseId == BUFFER_IS_GLOBALVAR) - ret = TEE_CheckMemoryAccessRights(accessFlags, g_testVar, strlen(g_testVar)); - else if (caseId == BUFFER_IS_GLOBALCONSTVAR) - ret = TEE_CheckMemoryAccessRights(accessFlags, g_testVar2, strlen(g_testVar2)); - else - ret = TEE_CheckMemoryAccessRights(accessFlags, pBuffer, nSize); - - if (caseId != BUFFER_IS_FREE) { - TEE_Free((void *)pBuffer); - } - return ret; -} - -static TEE_Result CmdTEESetInstanceData(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - char *pDataBuffer = NULL; - uint32_t nStringSize; - uint32_t caseId; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - // the input string to copy inside the char[] buffer created - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - caseId = pParams[0].value.a; - nStringSize = pParams[1].memref.size; // retrieve the length of the string - pDataBuffer = TEE_Malloc(nStringSize, 0); // allocates the necessary space for the instance data - if (pDataBuffer == NULL) - return TEE_ERROR_OUT_OF_MEMORY; // TA returns if not possible to allocate the instance data size - - // recopies the input string into the instance data - TEE_MemMove((void *)pDataBuffer, (void *)pParams[1].memref.buffer, nStringSize); - - if (caseId == INPUT_ISNULL) { - TEE_SetInstanceData(NULL); - } else { - TEE_SetInstanceData((void *)pDataBuffer); // calls the SetInstanceData function to store the string address - } - return TEE_SUCCESS; -} - -static TEE_Result CmdTEEGetInstanceData(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - char *pDataBuffer = NULL; - uint32_t nStringSize; - TEE_Result ret; - - // the input string to copy inside the char[] buffer created - if (TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_MEMREF_OUTPUT) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - pDataBuffer = (char *)TEE_GetInstanceData(); // retrieve the pointer - if (pDataBuffer == NULL) - return TEE_ERROR_GENERIC; // if pointer is NULL, it is because the function SetInstanceData has not been called - - nStringSize = strlen(pDataBuffer) + 1; // retrieve the length of the string stored - if (pParams[0].memref.size < nStringSize) { - ret = TEE_ERROR_SHORT_BUFFER; - } else { - TEE_MemMove((void *)pParams[0].memref.buffer, (void *)pDataBuffer, nStringSize); - ret = TEE_SUCCESS; - } - - pParams[0].memref.size = nStringSize; - TEE_Free(pDataBuffer); - return ret; -} - -static void getUUIDFromBuffer(TEE_UUID *pTargetUUID, char uuidvalue[16]) -{ - pTargetUUID->timeLow = (uint32_t)(uuidvalue[0] << 24) + (uint32_t)(uuidvalue[1] << 16) + - (uint32_t)(uuidvalue[2] << 8) + (uint32_t)(uuidvalue[3]); - pTargetUUID->timeMid = (uint32_t)(uuidvalue[4] << 8) + (uint32_t)(uuidvalue[5]); - pTargetUUID->timeHiAndVersion = (uint32_t)(uuidvalue[6] << 8) + (uint32_t)(uuidvalue[7]); - pTargetUUID->clockSeqAndNode[0] = (uint8_t)(uuidvalue[8]); - pTargetUUID->clockSeqAndNode[1] = (uint8_t)(uuidvalue[9]); - pTargetUUID->clockSeqAndNode[2] = (uint8_t)(uuidvalue[10]); - pTargetUUID->clockSeqAndNode[3] = (uint8_t)(uuidvalue[11]); - pTargetUUID->clockSeqAndNode[4] = (uint8_t)(uuidvalue[12]); - pTargetUUID->clockSeqAndNode[5] = (uint8_t)(uuidvalue[13]); - pTargetUUID->clockSeqAndNode[6] = (uint8_t)(uuidvalue[14]); - pTargetUUID->clockSeqAndNode[7] = (uint8_t)(uuidvalue[15]); -} - -static TEE_Result CmdTEEOpenTASession(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_UUID pTargetUUID; - TEE_Param pTargetParams[4]; - uint32_t caseId; - uint32_t nLocalParamTypes; - uint32_t nReturnOrigin = 0; - uint32_t hint = TEE_MALLOC_FILL_ZERO; - uint32_t nSize = DEFAULT_BUFFER_SIZE; - TEE_TASessionHandle nsession = 0; - TEE_Result nTmpResult; - char *pBufferIn = NULL; - - if (pParams[1].memref.size != 16) { - tloge("UUID size not correct"); - return TEE_ERROR_BAD_PARAMETERS; - } - - caseId = pParams[0].value.a; - getUUIDFromBuffer(&pTargetUUID, (char *)pParams[1].memref.buffer); - - nLocalParamTypes = TEE_PARAM_TYPES(TEE_PARAM_TYPE_VALUE_INOUT, TEE_PARAM_TYPE_MEMREF_INOUT, TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE); - pTargetParams[0].value.a = caseId; - - if (caseId == BUFFER_NOFILLNOSHARE) - hint = TEE_MALLOC_NO_FILL | TEE_MALLOC_NO_SHARE; - - pBufferIn = (char *)TEE_Malloc(nSize, hint); - if (pBufferIn == NULL) - return TEE_ERROR_OUT_OF_MEMORY; - - TEE_MemMove(pBufferIn, pParams[3].memref.buffer, pParams[3].memref.size); - pTargetParams[1].memref.buffer = pBufferIn; - pTargetParams[1].memref.size = nSize; - - /* Open the session */ - if (caseId == INPUT_ISNULL) - nTmpResult = - TEE_OpenTASession(NULL, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, &nsession, &nReturnOrigin); - else if (caseId == OUTPUT_ISNULL) - nTmpResult = TEE_OpenTASession(&pTargetUUID, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, NULL, - &nReturnOrigin); - else if (caseId == RETURNORIGIN_ISNULL) - nTmpResult = - TEE_OpenTASession(&pTargetUUID, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, &nsession, NULL); - else - nTmpResult = TEE_OpenTASession(&pTargetUUID, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, &nsession, - &nReturnOrigin); - - pParams[2].value.a = nsession; - pParams[2].value.b = nReturnOrigin; - - TEE_MemMove(pParams[3].memref.buffer, pBufferIn, pTargetParams[1].memref.size); - pParams[3].memref.size = pTargetParams[1].memref.size; - tlogi("test TEE_OpenTASession is finish! nsession=%d, nReturnOrigin=%d\n", nsession, nReturnOrigin); - return nTmpResult; -} - -static TEE_Result CmdTEECloseTASession(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_TASessionHandle nsession; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT)) { /* return origin of the OpenTASession */ - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nsession = pParams[0].value.a; - TEE_CloseTASession(nsession); - - return TEE_SUCCESS; -} - -static TEE_Result CmdTEEInvokeTACommand(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_Result nTmpResult; - char *pBufferIn = NULL; - - /* For the final TAInvoke */ - uint32_t nReturnOrigin = 0; - uint32_t hint = TEE_MALLOC_FILL_ZERO; - uint32_t nSize = MAX_TA2TA_SIZE; - uint32_t cmd = TEE_TEST_BUFFER; - TEE_Param pTargetParams[4]; - - uint32_t caseId = pParams[0].value.a; - TEE_TASessionHandle nsession = pParams[0].value.b; - uint32_t npType = TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, TEE_PARAM_TYPE_MEMREF_OUTPUT, TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE); - - if (caseId == TA_CRASH_FLAG) - cmd = CMD_TEE_Panic; - - if ((caseId == BUFFERSIZE_ISTOOBIG) || (caseId == BUFFER_NOFILLNOSHARE)) { - if (caseId == BUFFER_NOFILLNOSHARE) { - nSize = DEFAULT_BUFFER_SIZE; - hint = TEE_MALLOC_NO_FILL | TEE_MALLOC_NO_SHARE; - } - - pBufferIn = (char *)TEE_Malloc(nSize, hint); - if (pBufferIn == NULL) - return TEE_ERROR_OUT_OF_MEMORY; - - (void)memset_s(pBufferIn, nSize, 0x41, nSize); - npType = - TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT, TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE); - pTargetParams[0].memref.buffer = pBufferIn; - pTargetParams[0].memref.size = nSize; - } else { - pTargetParams[0].memref.buffer = pParams[1].memref.buffer; - pTargetParams[0].memref.size = pParams[1].memref.size; - pTargetParams[1].memref.buffer = pParams[3].memref.buffer; - pTargetParams[1].memref.size = pParams[3].memref.size; - } - - if (caseId == INPUT_ISNULL) - nTmpResult = TEE_InvokeTACommand(0, TEE_TIMEOUT_INFINITE, cmd, npType, pTargetParams, &nReturnOrigin); - else if (caseId == OUTPUT_ISNULL) - nTmpResult = TEE_InvokeTACommand(nsession, TEE_TIMEOUT_INFINITE, cmd, npType, pTargetParams, NULL); - else - nTmpResult = TEE_InvokeTACommand(nsession, TEE_TIMEOUT_INFINITE, cmd, npType, pTargetParams, &nReturnOrigin); - - pParams[2].value.a = nReturnOrigin; - - if (nTmpResult == TEE_SUCCESS) { - TEE_MemMove(pParams[1].memref.buffer, pTargetParams[0].memref.buffer, pTargetParams[0].memref.size); - pParams[1].memref.size = pTargetParams[0].memref.size; - if (caseId != BUFFER_NOFILLNOSHARE) { - pParams[3].memref.size = pTargetParams[1].memref.size; - TEE_MemMove(pParams[3].memref.buffer, pTargetParams[1].memref.buffer, pTargetParams[1].memref.size); - } - } - - tloge("test TEE_InvokeTACommand is finish! nTmpResult=0x%x, nReturnOrigin=%d\n", nTmpResult, nReturnOrigin); - - if (!pBufferIn) { - TEE_Free((void *)pBufferIn); - } - return nTmpResult; -} - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("---- TA_CreateEntryPoint ---------"); - TEE_Result ret; - - ret = AddCaller_CA_exec(CA_PKGN_VENDOR, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("tcf2 ta add caller failed, ret: 0x%x", ret); - return ret; - } - - ret = AddCaller_CA_exec(CA_PKGN_SYSTEM, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("tcf2 ta add caller failed, ret: 0x%x", ret); - return ret; - } - - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext) -{ - (void)parmType; - (void)params; - (void)sessionContext; - tlogi("---- TA_OpenSessionEntryPoint --------"); - - return TEE_SUCCESS; -} - -typedef TEE_Result (*func)(uint32_t nParamTypes, TEE_Param pParams[4]); - -struct testFunc { - uint32_t cmdId; - func funcName; -}; - -struct testFunc g_testTable[] = { - { CMD_TEE_GetPropertyAsIdentity, CmdTEEGetPropertyAsIdentity_withoutEnum }, - { CMD_TEE_GetPropertyAsU32, CmdTEEGetPropertyAsU32 }, - { CMD_TEE_Malloc, CmdTEEMalloc }, - { CMD_TEE_Realloc, CmdTEERealloc }, - { CMD_TEE_MemMove, CmdTEEMemMove }, - { CMD_TEE_MemCompare, CmdTEEMemCompare }, - { CMD_TEE_MemFill, CmdTEEMemFill }, - { CMD_TEE_Free, CmdTEEFree }, - { CMD_TEE_CheckMemoryAccessRights, CmdTEECheckMemoryAccessRights }, - { CMD_TEE_GetInstanceData, CmdTEEGetInstanceData }, - { CMD_TEE_SetInstanceData, CmdTEESetInstanceData }, - { CMD_TEE_OpenTASession, CmdTEEOpenTASession }, - { CMD_TEE_InvokeTACommand, CmdTEEInvokeTACommand }, - { CMD_TEE_CloseTASession, CmdTEECloseTASession }, -}; - -uint32_t g_testTableSize = sizeof(g_testTable) / sizeof(g_testTable[0]); - -TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmd, uint32_t parmType, TEE_Param params[4]) -{ - TEE_Result ret = TEE_SUCCESS; - (void)sessionContext; - uint32_t i; - tlogi("---- TA invoke command ----------- command id: 0x%x", cmd); - - for (i = 0; i < g_testTableSize; i++) { - if (cmd == g_testTable[i].cmdId) { - ret = g_testTable[i].funcName(parmType, params); - if (ret != TEE_SUCCESS) { - tloge("invoke command with cmdId: 0x%x failed! ret: 0x%x", cmd, ret); - } else { - tlogi("invoke command with cmdId: 0x%x success! ret: 0x%x", cmd, ret); - } - return ret; - } - } - - tloge("not support this invoke command! cmdId: 0x%x", cmd); - return TEE_ERROR_GENERIC; -} - -void TA_CloseSessionEntryPoint(void *sessionContext) -{ - (void)sessionContext; - tlogi("---- TA_CloseSessionEntryPoint -----"); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("---- TA_DestroyEntryPoint ----"); -} diff --git a/test/xts/ta/test_tcf_api/CMakeLists.txt b/test/xts/ta/test_tcf_api/CMakeLists.txt deleted file mode 100644 index 337bbb83..00000000 --- a/test/xts/ta/test_tcf_api/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_tcf_api.elf) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - src/tee_test_tcf.c - - INCLUDE_DIRS - - COMPILE_OPTS - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_tcf_api/manifest.txt b/test/xts/ta/test_tcf_api/manifest.txt deleted file mode 100644 index b4deaa66..00000000 --- a/test/xts/ta/test_tcf_api/manifest.txt +++ /dev/null @@ -1,11 +0,0 @@ -gpd.ta.appID: 534d4152-542d-4353-4c54-d3016a171f01 -gpd.ta.service_name: TCF_test -gpd.ta.singleInstance: true -gpd.ta.multiSession: true -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 819200 -gpd.ta.stackSize: 81920 -gpd.ta.version: 0 -gpd.ta.description: test ta -smc.ta.testbinaryblock:VGhpcy -smc.ta.testu64: 5147483647 diff --git a/test/xts/ta/test_tcf_api/src/tee_test_tcf.c b/test/xts/ta/test_tcf_api/src/tee_test_tcf.c deleted file mode 100644 index e0807899..00000000 --- a/test/xts/ta/test_tcf_api/src/tee_test_tcf.c +++ /dev/null @@ -1,755 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CA_PKGN_VENDOR "/vendor/bin/tee_test_tcf_api" -#define CA_PKGN_SYSTEM "/system/bin/tee_test_tcf_api" -#define CA_UID 0 - -#define BOOLEAN_TRUE "true" -#define BOOLEAN_FALSE "false" -#define GPD_TA_DATASIZE "gpd.ta.dataSize" -#define GPD_TA_STACKSIZE "gpd.ta.stackSize" -#define VALUE_PREDEFINED_DATASIZE 819200 -#define VALUE_PREDEFINED_STACKSIZE 81920 -#define PROPERTY_NAME_MAX_SIZE 100 -#define PROPERTY_OUTPUT_STRING_MAX_SIZE 200 -#define DEFAULT_BUFFER_SIZE 1024 -#define DEFAULT_REALLOC_SIZE 10000 -#define PROPERTY_OUTPUT_BINARY_BLOCK_MAX_SIZE 200 -#define MAXLEN_U32 11 -#define MAXLEN_U64 21 -#define SMC_TA_TESTUUID_TIMELOW 0x534D4152 -#define SMC_TA_TESTUUID_TIMEMID 0x542D -#define SMC_TA_TESTUUID_TIMEHIANDVERSION 0x4353 -#define SMC_TA_TESTUUID_CLOCKSEQANDNODE \ - { \ - 0x4c, 0x54, 0xd3, 0x01, 0x6a, 0x17, 0x1f, 0x01 \ - } - -#define SMC_TA_TESTIDENTITY_LOGIN 0xF0000000 -#define SMC_TA_TESTIDENTITY_TIMELOW 0x01010101 -#define SMC_TA_TESTIDENTITY_TIMEMID 0x2020 -#define SMC_TA_TESTIDENTITY_TIMEHIANDVERSION 0x0303 -#define SMC_TA_TESTIDENTITY_CLOCKSEQANDNODE \ - { \ - 0x40, 0x40, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05 \ - } - -#define ENUMERATOR1 1 -#define MAX_ENUMERATOR 1023 - -char *g_teeOutput = "TEEMEM_OUTPUT"; -char *g_teeInout = "the param is TEEMEM_INOUT"; -uint32_t g_teeOutputLen; -uint32_t g_teeInoutLen; - -static TEE_Result CmdTEEGetPropertyAsString(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - char *pOutputName = NULL; - uint32_t caseId; - TEE_Result cmdResult; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - pOutputName = pParams[2].memref.buffer; - - if (caseId == OUTPUTBUFFERSIZE_ISZERO) - pParams[2].memref.size = 0; - else if (caseId == OUTPUTBUFFERSIZE_TOOSHORT) - pParams[2].memref.size = 1; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsString(nPropSet, NULL, pOutputName, &pParams[2].memref.size); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsString(nPropSet, pPropName, NULL, &pParams[2].memref.size); - break; - case OUTPUTBUFFERSIZE_ISNULL: - cmdResult = TEE_GetPropertyAsString(nPropSet, pPropName, pOutputName, NULL); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsString(nPropSet, NULL, pOutputName, &pParams[2].memref.size); - else - cmdResult = TEE_GetPropertyAsString(nPropSet, pPropName, pOutputName, &pParams[2].memref.size); - break; - } - - tlogi("after TEE_GetPropertyAsString, pPropName=%s, pParams[1].memref.size=0x%x", pPropName, - pParams[1].memref.size); - tlogi("after TEE_GetPropertyAsString, pOutputName=%s, pParams[2].memref.size=0x%x", pOutputName, - pParams[2].memref.size); - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyAsBool(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - bool nOutputBool = true; - uint32_t caseId; - TEE_Result cmdResult; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsBool(nPropSet, NULL, &nOutputBool); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsBool(nPropSet, pPropName, NULL); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsBool(nPropSet, NULL, &nOutputBool); - else - cmdResult = TEE_GetPropertyAsBool(nPropSet, pPropName, &nOutputBool); - break; - } - - if ((nOutputBool == true) && (cmdResult == TEE_SUCCESS)) { - TEE_MemMove(pParams[2].memref.buffer, BOOLEAN_TRUE, sizeof(BOOLEAN_TRUE)); - pParams[2].memref.size = sizeof(BOOLEAN_TRUE); - } else { - TEE_MemMove(pParams[2].memref.buffer, BOOLEAN_FALSE, sizeof(BOOLEAN_FALSE)); - pParams[2].memref.size = sizeof(BOOLEAN_FALSE); - } - - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyAsU32(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - uint32_t nIntResult = 0; - uint32_t caseId; - char outStr[MAXLEN_U32] = { 0 }; - TEE_Result cmdResult; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsU32(nPropSet, NULL, &nIntResult); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsU32(nPropSet, pPropName, NULL); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsU32(nPropSet, NULL, &nIntResult); - else - cmdResult = TEE_GetPropertyAsU32(nPropSet, pPropName, &nIntResult); - break; - } - - (void)snprintf_s(outStr, MAXLEN_U32, MAXLEN_U32 - 1, "%lu", nIntResult); - TEE_MemMove(pParams[2].memref.buffer, outStr, strlen(outStr) + 1); - pParams[2].memref.size = strlen(outStr) + 1; - - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyAsU64(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - char outStr[MAXLEN_U64] = { 0 }; - uint64_t nIntResult = 0; - uint32_t caseId; - TEE_Result cmdResult; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsU64(nPropSet, NULL, &nIntResult); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsU64(nPropSet, pPropName, NULL); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsU64(nPropSet, NULL, &nIntResult); - else - cmdResult = TEE_GetPropertyAsU64(nPropSet, pPropName, &nIntResult); - break; - } - - (void)snprintf_s(outStr, MAXLEN_U64, MAXLEN_U64 - 1, "%lu", nIntResult); - TEE_MemMove(pParams[2].memref.buffer, outStr, strlen(outStr) + 1); - pParams[2].memref.size = strlen(outStr) + 1; - - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyAsBinaryBlock(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - void *pOutputBinaryBlock = NULL; - uint32_t caseId; - TEE_Result cmdResult; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - pOutputBinaryBlock = pParams[2].memref.buffer; - if (caseId == OUTPUTBUFFERSIZE_ISZERO) - pParams[2].memref.size = 0; - else if (caseId == OUTPUTBUFFERSIZE_TOOSHORT) - pParams[2].memref.size = 1; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsBinaryBlock(nPropSet, NULL, pOutputBinaryBlock, &pParams[2].memref.size); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsBinaryBlock(nPropSet, pPropName, NULL, &pParams[2].memref.size); - break; - case OUTPUTBUFFERSIZE_ISNULL: - cmdResult = TEE_GetPropertyAsBinaryBlock(nPropSet, pPropName, pOutputBinaryBlock, NULL); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsBinaryBlock(nPropSet, NULL, pOutputBinaryBlock, &pParams[2].memref.size); - else - cmdResult = - TEE_GetPropertyAsBinaryBlock(nPropSet, pPropName, pOutputBinaryBlock, &pParams[2].memref.size); - break; - } - - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyAsUUID(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_PropSetHandle nPropSet; - char *pPropName = NULL; - char nClockSeqAndNode[8] = SMC_TA_TESTUUID_CLOCKSEQANDNODE; - TEE_UUID nResultUUID; - uint32_t caseId; - TEE_Result cmdResult; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // the property set - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || // the property name - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // the output value - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - pPropName = pParams[1].memref.buffer; - - switch (caseId) { - case INPUT_ISNULL: - cmdResult = TEE_GetPropertyAsUUID(nPropSet, NULL, &nResultUUID); - break; - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyAsUUID(nPropSet, pPropName, NULL); - break; - default: - if (nPropSet >= ENUMERATOR1 && nPropSet <= MAX_ENUMERATOR) - cmdResult = TEE_GetPropertyAsUUID(nPropSet, NULL, &nResultUUID); - else - cmdResult = TEE_GetPropertyAsUUID(nPropSet, pPropName, &nResultUUID); - break; - } - - // no need to update the buffer length as the result is a UUID. - // it is the responsibility of the Client app to provide an output buffer large enough to handle a UUID - if ((cmdResult == TEE_SUCCESS) && (strncmp(pPropName, "gpd.tee.deviceID", strlen(pPropName)) != 0)) { - if ((nResultUUID.timeLow == (uint32_t)SMC_TA_TESTUUID_TIMELOW) && - (nResultUUID.timeMid == (uint16_t)SMC_TA_TESTUUID_TIMEMID) && - (nResultUUID.timeHiAndVersion == (uint16_t)SMC_TA_TESTUUID_TIMEHIANDVERSION) && - (TEE_MemCompare(&nResultUUID.clockSeqAndNode, nClockSeqAndNode, 8) == 0)) { - tlogi("TEE_GetPropertyAsUUID success and get uuid is correct!"); - } else { - tloge("TEE_GetPropertyAsUUID get uuid is wrong!"); - cmdResult = TEE_ERROR_GENERIC; - } - } - return cmdResult; -} - -static TEE_Result CmdTEEAllocatePropertyEnumerator(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_Result cmdResult; - TEE_PropSetHandle nPropSet; - uint32_t caseId; - - if (TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_OUTPUT) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - - if (caseId != OUTPUT_ISNULL) { - cmdResult = TEE_AllocatePropertyEnumerator(&nPropSet); - } else { - cmdResult = TEE_AllocatePropertyEnumerator(NULL); - } - pParams[0].value.a = nPropSet; - - return cmdResult; -} - -static TEE_Result CmdTEEStartPropertyEnumerator(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_VALUE_INPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - TEE_StartPropertyEnumerator((TEE_PropSetHandle)pParams[0].value.a, (TEE_PropSetHandle)pParams[1].value.a); - tlogi("test TEE_StartPropertyEnumerator is finish!\n"); - return TEE_SUCCESS; -} - -static TEE_Result CmdTEEEnumeratorOperate(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_Result cmdResult; - TEE_PropSetHandle nPropSet; - uint32_t cmd; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - cmd = pParams[0].value.b; - - switch (cmd) { - case CMD_TEE_FreePropertyEnumerator: - TEE_FreePropertyEnumerator(nPropSet); - tlogi("test TEE_FreePropertyEnumerator is finish!\n"); - return TEE_SUCCESS; - case CMD_TEE_ResetPropertyEnumerator: - TEE_ResetPropertyEnumerator(nPropSet); - tlogi("test TEE_ResetPropertyEnumerator is finish!\n"); - return TEE_SUCCESS; - case CMD_TEE_GetNextPropertyEnumerator: - cmdResult = TEE_GetNextProperty(nPropSet); - break; - default: - tloge("invalid test cmd! cmdId: 0x%x", cmd); - cmdResult = TEE_ERROR_GENERIC; - break; - } - - return cmdResult; -} - -static TEE_Result CmdTEEGetPropertyName(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_Result cmdResult; - TEE_PropSetHandle nPropSet; - uint32_t caseId; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || // enumerator - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { // property set - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nPropSet = (TEE_PropSetHandle)pParams[0].value.a; - caseId = pParams[0].value.b; - if (caseId == OUTPUTBUFFERSIZE_TOOSHORT) - pParams[1].memref.size = 1; - - switch (caseId) { - case OUTPUT_ISNULL: - cmdResult = TEE_GetPropertyName(nPropSet, NULL, &pParams[1].memref.size); - break; - case OUTPUTBUFFERSIZE_ISNULL: - cmdResult = TEE_GetPropertyName(nPropSet, pParams[1].memref.buffer, NULL); - break; - default: - cmdResult = TEE_GetPropertyName(nPropSet, pParams[1].memref.buffer, &pParams[1].memref.size); - break; - } - - tlogi("after TEE_GetPropertyName, pParams[0].value.a=0x%x, cmdResult=0x%x", pParams[0].value.a, cmdResult); - tlogi("after TEE_GetPropertyName, pParams[1].memref.buffer=%s, pParams[1].memref.size=0x%x", - pParams[1].memref.buffer, pParams[1].memref.size); - return cmdResult; -} - -static void getUUIDFromBuffer(TEE_UUID *pTargetUUID, char uuidvalue[16]) -{ - pTargetUUID->timeLow = (uint32_t)(uuidvalue[0] << 24) + (uint32_t)(uuidvalue[1] << 16) + - (uint32_t)(uuidvalue[2] << 8) + (uint32_t)(uuidvalue[3]); - pTargetUUID->timeMid = (uint32_t)(uuidvalue[4] << 8) + (uint32_t)(uuidvalue[5]); - pTargetUUID->timeHiAndVersion = (uint32_t)(uuidvalue[6] << 8) + (uint32_t)(uuidvalue[7]); - pTargetUUID->clockSeqAndNode[0] = (uint8_t)(uuidvalue[8]); - pTargetUUID->clockSeqAndNode[1] = (uint8_t)(uuidvalue[9]); - pTargetUUID->clockSeqAndNode[2] = (uint8_t)(uuidvalue[10]); - pTargetUUID->clockSeqAndNode[3] = (uint8_t)(uuidvalue[11]); - pTargetUUID->clockSeqAndNode[4] = (uint8_t)(uuidvalue[12]); - pTargetUUID->clockSeqAndNode[5] = (uint8_t)(uuidvalue[13]); - pTargetUUID->clockSeqAndNode[6] = (uint8_t)(uuidvalue[14]); - pTargetUUID->clockSeqAndNode[7] = (uint8_t)(uuidvalue[15]); -} - -static TEE_Result CmdTEEOpenTASession(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_UUID pTargetUUID; - TEE_Param pTargetParams[4]; - uint32_t nLocalParamTypes = 0; - uint32_t nReturnOrigin = 0; - TEE_TASessionHandle nsession; - TEE_Result nTmpResult; - uint32_t caseId; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || /* Command to pass to the TA */ - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_INPUT) || /* UUID in a buffer */ - (TEE_PARAM_TYPE_GET(nParamTypes, 2) != TEE_PARAM_TYPE_VALUE_OUTPUT)) { /* return origin of the OpenTASession */ - tloge("%s: Bad expected parameter types\n", __func__); - return TEE_ERROR_COMMUNICATION; - } - - if (pParams[1].memref.size != 16) { - tloge("CmdTEEOpenTASession: UUID size not correct\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - caseId = pParams[0].value.a; - getUUIDFromBuffer(&pTargetUUID, (char *)pParams[1].memref.buffer); - - nLocalParamTypes = - TEE_PARAM_TYPES(TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE); - - /* Open the session */ - if (caseId == INPUT_ISNULL) - nTmpResult = - TEE_OpenTASession(NULL, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, &nsession, &nReturnOrigin); - else if (caseId == RETURNORIGIN_ISNULL) - nTmpResult = - TEE_OpenTASession(&pTargetUUID, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, &nsession, NULL); - else if (caseId == OUTPUT_ISNULL) - nTmpResult = TEE_OpenTASession(&pTargetUUID, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, NULL, - &nReturnOrigin); - else - nTmpResult = TEE_OpenTASession(&pTargetUUID, TEE_TIMEOUT_INFINITE, nLocalParamTypes, pTargetParams, &nsession, - &nReturnOrigin); - - tlogi("test TEE_OpenTASession is success!\n"); - - return nTmpResult; -} - -static TEE_Result TestTypeBuffer(uint32_t paramTypes, TEE_Param params[4]) -{ - TEE_Result ret = TEE_SUCCESS; - - if (TEE_PARAM_TYPE_GET(paramTypes, 0) != TEE_PARAM_TYPE_MEMREF_INOUT) { - tloge("%s: Bad expected parameter types\n", __func__); - return TEE_ERROR_COMMUNICATION; - } - - g_teeOutputLen = strlen(g_teeOutput) + 1; - g_teeInoutLen = strlen(g_teeInout) + 1; - - for (uint32_t i = 0; i < 4; i++) { - uint32_t param_type = TEE_PARAM_TYPE_GET(paramTypes, i); - switch (param_type) { - case TEE_PARAM_TYPE_MEMREF_INPUT: - case TEE_PARAM_TYPE_MEMREF_OUTPUT: - tlogi("param %d is TEE_PARAM_TYPE_MEMREF_INPUT or TEE_PARAM_TYPE_MEMREF_OUTPUT\n", i); - tlogi("before modify,param %d size=%d, val=%s\n", i, params[i].memref.size, params[i].memref.buffer); - TEE_MemMove(params[i].memref.buffer, g_teeOutput, g_teeOutputLen); - params[i].memref.size = g_teeOutputLen; - tlogi("after modify,param %d size=%d, val=%s\n", i, params[i].memref.size, params[i].memref.buffer); - break; - case TEE_PARAM_TYPE_MEMREF_INOUT: - tlogi("param %d is TEE_PARAM_TYPE_MEMREF_INOUT\n", i); - tlogi("before modify,param %d size=%d, val=%s\n", i, params[i].memref.size, params[i].memref.buffer); - TEE_MemMove(params[i].memref.buffer, g_teeInout, g_teeInoutLen); - params[i].memref.size = g_teeInoutLen; - tlogi("after modify,param %d size=%d, val=%s\n", i, params[i].memref.size, params[i].memref.buffer); - break; - case TEE_PARAM_TYPE_VALUE_INPUT: - case TEE_PARAM_TYPE_VALUE_INOUT: - case TEE_PARAM_TYPE_VALUE_OUTPUT: - case TEE_PARAM_TYPE_NONE: - break; - default: - break; - } - } - - return ret; -} - -static TEE_Result CmdTEEMalloc(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - size_t nSize; - uint32_t nHint; - char *pBuffer = NULL; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT) || - (TEE_PARAM_TYPE_GET(nParamTypes, 1) != TEE_PARAM_TYPE_MEMREF_OUTPUT)) { - tloge("%s: Bad expected parameter types", __func__); - return TEE_ERROR_COMMUNICATION; - } - - nSize = pParams[0].value.a; - nHint = pParams[0].value.b; - - tlogi("before TEE_Malloc nSize=%d, nHint=%d\n", nSize, nHint); - pBuffer = (char *)TEE_Malloc(nSize, nHint); - if (pBuffer == NULL) { - return TEE_ERROR_OUT_OF_MEMORY; - } else { - tlogi("test TEE_Malloc is success!\n"); - TEE_MemMove(pParams[1].memref.buffer, pBuffer, nSize); - TEE_Free((void *)pBuffer); // free the allocated buffer - tlogi("TEE_Free is finish!\n"); - return TEE_SUCCESS; - } -} - -static TEE_Result CmdTEERealloc(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - char *pBufferMalloc = NULL; - char *pBufferRealloc = NULL; - char buf[DEFAULT_BUFFER_SIZE] = { 0 }; - - size_t nOldSize = pParams[0].value.a; - size_t nNewSize = pParams[0].value.b; - uint32_t caseId = pParams[3].value.a; - - pBufferMalloc = (char *)TEE_Malloc(nOldSize, 0); - if (pBufferMalloc == NULL) { - return TEE_ERROR_OUT_OF_MEMORY; - } - (void)memset_s(pBufferMalloc, nOldSize, 0x41, nOldSize); // 'A' is 0x41 - - pBufferRealloc = (char *)TEE_Realloc(buf, DEFAULT_REALLOC_SIZE); - - if (caseId == BUFFER_IS_FREE) { - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - } - if (caseId == INPUT_ISNULL) { - pBufferRealloc = (char *)TEE_Realloc(NULL, nNewSize); - } else if (caseId == BUFFER_ISNOT_MALLOC) { - pBufferRealloc = (char *)TEE_Realloc(buf, nNewSize); - } else { - pBufferRealloc = (char *)TEE_Realloc((void *)pBufferMalloc, nNewSize); - } - if ((pBufferRealloc == NULL) && (pBufferMalloc == NULL)) { - return TEE_ERROR_OUT_OF_MEMORY; - } - if ((pBufferMalloc != NULL) && (pBufferRealloc == NULL)) { - for (uint32_t i = 0; i < nOldSize; i++) { - if (pBufferMalloc[i] != (char)'A') { // checks that the data has not been changed after realloc - tloge("%d th bytes of pBufferMalloc is not correct, it is %c\n", i + 1, pBufferMalloc[i]); - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - return TEE_ERROR_GENERIC; - } - } - TEE_Free((void *)pBufferMalloc); // free the allocated buffer - return TEE_ERROR_OUT_OF_MEMORY; - } - - if (pBufferRealloc != NULL) { - pParams[2].value.b = (uint32_t)pBufferRealloc; - pParams[2].value.a = (uint32_t)pBufferMalloc; - if (caseId == INPUT_ISNULL) - TEE_MemMove(pParams[1].memref.buffer, pBufferMalloc, nOldSize); - else - TEE_MemMove(pParams[1].memref.buffer, pBufferRealloc, (nOldSize < nNewSize ? nOldSize : nNewSize)); - - TEE_Free((void *)pBufferRealloc); // free the reallocated buffer - if (pBufferMalloc != NULL) { - TEE_Free((void *)pBufferMalloc); - } - } - return TEE_SUCCESS; -} - -static TEE_Result CmdTEEPanic(uint32_t nParamTypes, TEE_Param pParams[4]) -{ - TEE_Result panicCode; - - if ((TEE_PARAM_TYPE_GET(nParamTypes, 0) != TEE_PARAM_TYPE_VALUE_INPUT)) - panicCode = pParams[0].value.a; - else - panicCode = TEE_ERROR_BAD_PARAMETERS; - - TEE_Panic(panicCode); - return TEE_SUCCESS; -} - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("---- TA_CreateEntryPoint ---------"); - TEE_Result ret; - - ret = AddCaller_CA_exec(CA_PKGN_VENDOR, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("add caller failed, ret: 0x%x", ret); - return ret; - } - - ret = AddCaller_CA_exec(CA_PKGN_SYSTEM, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("add caller failed, ret: 0x%x", ret); - return ret; - } - - ret = AddCaller_TA_all(); - if (ret != TEE_SUCCESS) - return ret; - - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext) -{ - (void)parmType; - (void)sessionContext; - tlogi("---- TA_OpenSessionEntryPoint --------"); - g_teeInoutLen = strlen(g_teeInout) + 1; - - TEE_MemMove(params[1].memref.buffer, g_teeInout, g_teeInoutLen); - params[1].memref.size = g_teeInoutLen; - - if (params[0].value.a == TA_CRASH_FLAG) - TEE_Panic(TEE_ERROR_BAD_PARAMETERS); - - return TEE_SUCCESS; -} - -typedef TEE_Result (*func)(uint32_t nParamTypes, TEE_Param pParams[4]); - -struct testFunc { - uint32_t cmdId; - func funcName; -}; - -struct testFunc g_testTable[] = { - { CMD_TEE_GetPropertyAsString, CmdTEEGetPropertyAsString }, - { CMD_TEE_GetPropertyAsBool, CmdTEEGetPropertyAsBool }, - { CMD_TEE_GetPropertyAsU32, CmdTEEGetPropertyAsU32 }, - { CMD_TEE_GetPropertyAsU64, CmdTEEGetPropertyAsU64 }, - { CMD_TEE_GetPropertyAsBinaryBlock, CmdTEEGetPropertyAsBinaryBlock }, - { CMD_TEE_GetPropertyAsUUID, CmdTEEGetPropertyAsUUID }, - { CMD_TEE_AllocatePropertyEnumerator, CmdTEEAllocatePropertyEnumerator }, - { CMD_TEE_StartPropertyEnumerator, CmdTEEStartPropertyEnumerator }, - { CMD_TEE_FreePropertyEnumerator, CmdTEEEnumeratorOperate }, - { CMD_TEE_ResetPropertyEnumerator, CmdTEEEnumeratorOperate }, - { CMD_TEE_GetNextPropertyEnumerator, CmdTEEEnumeratorOperate }, - { CMD_TEE_GetPropertyNameEnumerator, CmdTEEGetPropertyName }, - { CMD_TEE_OpenTASession, CmdTEEOpenTASession }, - { TEE_TEST_BUFFER, TestTypeBuffer }, - { CMD_TEE_Malloc, CmdTEEMalloc }, - { CMD_TEE_Realloc, CmdTEERealloc }, - { CMD_TEE_Panic, CmdTEEPanic }, -}; - -uint32_t g_testTableSize = sizeof(g_testTable) / sizeof(g_testTable[0]); - -TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmd, uint32_t parmType, TEE_Param params[4]) -{ - (void)sessionContext; - TEE_Result ret = TEE_SUCCESS; - uint32_t i; - tlogi("----- TA invoke command ---------- command id: 0x%x", cmd); - - for (i = 0; i < g_testTableSize; i++) { - if (cmd == g_testTable[i].cmdId) { - ret = g_testTable[i].funcName(parmType, params); - if (ret != TEE_SUCCESS) { - tloge("invoke command with cmdId: 0x%x failed! ret: 0x%x\n", cmd, ret); - } else { - tlogi("invoke command with cmdId: 0x%x success! ret: 0x%x\n", cmd, ret); - } - return ret; - } - } - - tloge(" not support this invoke command! cmdId: 0x%x", cmd); - return TEE_ERROR_GENERIC; -} - -void TA_CloseSessionEntryPoint(void *sessionContext) -{ - (void)sessionContext; - tlogi("----- TA_CloseSessionEntryPoint -----"); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("----- TA_DestroyEntryPoint ----"); -} diff --git a/test/xts/ta/test_time_api/CMakeLists.txt b/test/xts/ta/test_time_api/CMakeLists.txt deleted file mode 100644 index 7dd9aa12..00000000 --- a/test/xts/ta/test_time_api/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_time_api.elf) - -list(APPEND ta_src - src/test_time_api_func.c - src/test_time_api_main.c -) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - ${ta_src} - - INCLUDE_DIRS - - COMPILE_OPTS - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_time_api/manifest.txt b/test/xts/ta/test_time_api/manifest.txt deleted file mode 100644 index 5ed629ec..00000000 --- a/test/xts/ta/test_time_api/manifest.txt +++ /dev/null @@ -1,7 +0,0 @@ -gpd.ta.appID: e7d4c078-b19f-4f97-a22d-f4afd6ae7a0e -gpd.ta.service_name: test_time_api -gpd.ta.singleInstance: true -gpd.ta.multiSession: true -gpd.ta.instanceKeepAlive: false -gpd.ta.dataSize: 819200 -gpd.ta.stackSize: 81920 diff --git a/test/xts/ta/test_time_api/src/test_time_api_func.c b/test/xts/ta/test_time_api/src/test_time_api_func.c deleted file mode 100644 index 73145a7a..00000000 --- a/test/xts/ta/test_time_api/src/test_time_api_func.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_time_api_func.h" - -static TEE_Result TestGetSystemTime(TEE_Param params[4]) -{ - tlogi("[%s] begin:", __FUNCTION__); - - TEE_Time time = {0}; - TEE_GetSystemTime(&time); - params[1].value.a = time.seconds; - tlogi("GetSystemTime: %us %ums", time.seconds, time.millis); - return TEE_SUCCESS; -} - -static TEE_Result TestGetREETime(TEE_Param params[4]) -{ - tlogi("[%s] begin:", __FUNCTION__); - - TEE_Time time = {0}; - TEE_GetREETime(&time); - params[1].value.a = time.seconds; - tlogi("GetREETime: %us %ums", time.seconds, time.millis); - return TEE_SUCCESS; -} - -static TEE_Result CheckTimeInterval(uint64_t startTime, uint64_t endTime, uint32_t waitTime) -{ - if (endTime == startTime) { - tloge("endTime (%llu) == startTime (%llu)\n", endTime, startTime); - return TEE_ERROR_GENERIC; - } - - if ((endTime - startTime) < (uint64_t)waitTime) { - uint64_t subTime = endTime - startTime; - tloge("(endTime (%llu) - startTime (%llu) = subTime(%llu)) < waitTime (%u)\n", - endTime, startTime, subTime, waitTime); - return TEE_ERROR_GENERIC; - } - - if ((endTime - startTime - waitTime) > (uint64_t)(waitTime / 10)) { /* 误差10%以内可接受 */ - tloge("(endTime (%llu) - startTime (%llu)) > (waitTime (%u) + TEE_TEST_TIMER_BASE), " - "and over 10\% tolerance\n", endTime, startTime, waitTime); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static TEE_Result TestTEEWait() -{ - tlogi("[%s] begin:", __FUNCTION__); - - TEE_Time startTime, endTime; - const uint32_t waitTime = 5000; - TEE_GetSystemTime(&startTime); - tlogi("begin wait %ums", waitTime); - TEE_Result ret = TEE_Wait(waitTime); - if (ret != TEE_SUCCESS) { - tloge("TEE_Wait fail, ret = 0x%x", ret); - return ret; - } - TEE_GetSystemTime(&endTime); - - uint64_t startTimeWithMs = startTime.seconds * MILLISECOND + startTime.millis; - uint64_t endTimeWithMs = endTime.seconds * MILLISECOND + endTime.millis; - ret = CheckTimeInterval(startTimeWithMs, endTimeWithMs, waitTime); - if (ret != TEE_SUCCESS) { - tloge("TEE_Wait check time interval fail."); - } - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -static void RemovePersistentTimeFile(void) -{ - TEE_ObjectHandle object = NULL; - TEE_Result ret = TEE_OpenPersistentObject(TEE_OBJECT_STORAGE_PRIVATE, PERSISTENT_TIME_BASE_FILE, - strlen(PERSISTENT_TIME_BASE_FILE), TEE_DATA_FLAG_ACCESS_READ | TEE_DATA_FLAG_ACCESS_WRITE_META, &object); - if (ret == TEE_SUCCESS) { - tlogi("persistent time file is exist\n"); - TEE_CloseAndDeletePersistentObject1(object); - tlogi("fremove time file\n"); - } else { - tlogi("persistent time file is not exist!\n"); - } -} - -static TEE_Result TestGetPersistentTime() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Time time; - RemovePersistentTimeFile(); - TEE_Result ret = TEE_GetTAPersistentTime(&time); - if (ret != TEE_ERROR_TIME_NOT_SET) { - tloge("GetTAPersistentTime fail after remove persistent time file; before set time. ret = 0x%x", ret); - return TEE_ERROR_GENERIC; - } - - TEE_Time setTime = { - .seconds = RESERVED10S, - .millis = 0, - }; - ret = TEE_SetTAPersistentTime(&setTime); - if (ret != TEE_SUCCESS) { - tloge("set time fail ret = 0x%x", ret); - return TEE_ERROR_GENERIC; - } - - tlogi("begin wait %us", WAIT5S); - TEE_Wait(MILLISECOND * WAIT5S); - TEE_Time getTime = {0}; - ret = TEE_GetTAPersistentTime(&getTime); - if (ret != TEE_SUCCESS || - (getTime.seconds != RESERVED10S + WAIT5S && getTime.seconds != RESERVED10S + WAIT5S + 1)) { - tloge("get time fail. ret = 0x%x, get time is %us %ums", ret, getTime.seconds, getTime.millis); - return TEE_ERROR_GENERIC; - } - - tlogi("[%s] end.", __FUNCTION__); - return TEE_SUCCESS; -} - -static TEE_Result TestSetPersistentTime() -{ - tlogi("[%s] begin:", __FUNCTION__); - RemovePersistentTimeFile(); - TEE_Time setTime = { - .seconds = RESERVED10S, - .millis = 0, - }; - TEE_Result ret = TEE_SetTAPersistentTime(&setTime); - if (ret != TEE_SUCCESS) { - tloge("set time fail ret = 0x%x", ret); - return TEE_ERROR_GENERIC; - } - - TEE_Time getTime = {0}; - ret = TEE_GetTAPersistentTime(&getTime); - if (ret != TEE_SUCCESS || (getTime.seconds != RESERVED10S && getTime.seconds != RESERVED10S + 1)) { - tloge("get time fail. ret = 0x%x, get time is %us %ums", ret, getTime.seconds, getTime.millis); - return TEE_ERROR_GENERIC; - } - - tlogi("begin wait %us", WAIT5S); - TEE_Wait(MILLISECOND * WAIT5S); - setTime.seconds = RESERVED10S; - ret = TEE_SetTAPersistentTime(&setTime); // Repeated setting, can be overwritten - if (ret != TEE_SUCCESS) { - tloge("set time fail ret = 0x%x", ret); - return TEE_ERROR_GENERIC; - } - - (void)memset_s(&getTime, sizeof(getTime), 0, sizeof(getTime)); - ret = TEE_GetTAPersistentTime(&getTime); - if (ret != TEE_SUCCESS || (getTime.seconds != RESERVED10S && getTime.seconds != RESERVED10S + 1)) { - tloge("get time fail. ret = 0x%x, get time is %us %ums", ret, getTime.seconds, getTime.millis); - return TEE_ERROR_GENERIC; - } - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} - -static TEE_Result TestOnlyGetPersistentTime() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Time time; - TEE_Result ret; - ret = TEE_GetTAPersistentTime(&time); - tlogi("only get persistent time, not check. ret = 0x%x, seconds = %u, millis = %u\n", ret, time.seconds, - time.millis); - - return TEE_SUCCESS; -} - -static TEE_Result TestPersistentTimeWithException() -{ - tlogi("[%s] begin:", __FUNCTION__); - TEE_Time time; - RemovePersistentTimeFile(); - TEE_Time setTime = { - .seconds = UINT32_MAX - RESERVED10S, - .millis = 0, - }; - TEE_Result ret = TEE_SetTAPersistentTime(&setTime); - if (ret != TEE_SUCCESS) { - tloge("set time fail ret = 0x%x", ret); - return TEE_ERROR_GENERIC; - } - - tlogi("before wait for %ds", WAIT5S); - TEE_Wait(MILLISECOND * WAIT5S); - ret = TEE_GetTAPersistentTime(&time); - if (ret != TEE_SUCCESS || time.seconds > UINT32_MAX - RESERVED10S + WAIT5S + 1 || - time.seconds < UINT32_MAX - RESERVED10S + WAIT5S - 1) { - tloge("get time fail. ret = 0x%x, get time is %us %ums", ret, time.seconds, time.millis); - return TEE_ERROR_GENERIC; - } - - TEE_Wait(MILLISECOND * RESERVED10S); // get time is UINT32_MAX - 10s + 5s + 10s > UINT32_MAX; get time is 5s - ret = TEE_GetTAPersistentTime(&time); - if (ret != TEE_ERROR_OVERFLOW || time.seconds > WAIT5S + 1 || time.seconds < WAIT5S - 1) { - tloge("get time for overflow fail, ret = 0x%x, get time is %us, %ums", ret, time.seconds, time.millis); - return TEE_ERROR_GENERIC; - } - - // set time value max - time.seconds = UINT32_MAX; - time.millis = UINT32_MAX; - ret = TEE_SetTAPersistentTime(&time); - if (ret != TEE_SUCCESS) { - tloge("set time with max time value failed ret = 0x%x\n", ret); - return TEE_ERROR_GENERIC; - } - - tlogi("[%s] end.", __FUNCTION__); - return TEE_SUCCESS; -} - -TEE_Result TestTimeApi(uint32_t cmdId, TEE_Param params[4]) -{ - tlogi("%s begin: cmdId is %d.", __FUNCTION__, cmdId); - TEE_Result ret = TEE_SUCCESS; - - switch (cmdId) { - case CMD_ID_TEST_GET_SYSTEM_TIME: - ret = TestGetSystemTime(params); - break; - case CMD_ID_TEST_GET_REE_TIME: - ret = TestGetREETime(params); - break; - case CMD_ID_TEST_TEE_WAIT: - ret = TestTEEWait(); - break; - case CMD_ID_ONLY_GET_PERSISTENT_TIME: - ret = TestOnlyGetPersistentTime(); - break; - case CMD_ID_TEST_GET_PERSISTENT_TIME: - ret = TestGetPersistentTime(); - break; - case CMD_ID_TEST_SET_PERSISTENT_TIME: - ret = TestSetPersistentTime(); - break; - case CMD_ID_TEST_PERSISTENT_TIME_WITH_EXCEPTION: - ret = TestPersistentTimeWithException(); - break; - default: - tlogi("unknown command id, cmdId: %u\n", cmdId); - return TEE_ERROR_INVALID_CMD; - } - - tlogi("[%s] end. ret = 0x%x.", __FUNCTION__, ret); - return ret; -} \ No newline at end of file diff --git a/test/xts/ta/test_time_api/src/test_time_api_func.h b/test/xts/ta/test_time_api/src/test_time_api_func.h deleted file mode 100644 index d80531db..00000000 --- a/test/xts/ta/test_time_api/src/test_time_api_func.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef __TEST_TIME_API_FUNC_H__ -#define __TEST_TIME_API_FUNC_H__ - -#include - -#define MILLISECOND 1000 -#define PERSISTENT_TIME_BASE_FILE "sec_storage/persistent_time" -#define RESERVED10S 10 -#define WAIT5S 5 - -enum TEST_TIME_API_CMD_ID { - CMD_ID_TEST_GET_SYSTEM_TIME = 0, - CMD_ID_TEST_GET_REE_TIME, - CMD_ID_TEST_TEE_WAIT, - CMD_ID_ONLY_GET_PERSISTENT_TIME, - CMD_ID_TEST_GET_PERSISTENT_TIME, - CMD_ID_TEST_SET_PERSISTENT_TIME, // 5 - CMD_ID_TEST_PERSISTENT_TIME_WITH_EXCEPTION, -}; - -TEE_Result TestTimeApi(uint32_t cmdId, TEE_Param params[4]); -#endif \ No newline at end of file diff --git a/test/xts/ta/test_time_api/src/test_time_api_main.c b/test/xts/ta/test_time_api/src/test_time_api_main.c deleted file mode 100644 index 055ba023..00000000 --- a/test/xts/ta/test_time_api/src/test_time_api_main.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include "test_time_api_func.h" - -#define CA_VENDOR "/vendor/bin/tee_test_time_api" -#define CA_SYSTEM "/system/bin/tee_test_time_api" -#define CA_UID 0 - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("---- TA_CreateEntryPoint ---------"); - TEE_Result ret = AddCaller_CA_exec(CA_VENDOR, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("Add caller failed, ret = 0x%x", ret); - return ret; - } - - ret = AddCaller_CA_exec(CA_SYSTEM, CA_UID); - if (ret != TEE_SUCCESS) { - tloge("Add caller failed, ret = 0x%x", ret); - return ret; - } - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t parmType, TEE_Param params[4], void **sessionContext) -{ - (void)parmType; - (void)params; - (void)sessionContext; - tlogi("---- TA_OpenSessionEntryPoint --------"); - - return TEE_SUCCESS; -} - -TEE_Result TA_InvokeCommandEntryPoint(void *sessionContext, uint32_t cmdId, uint32_t parmType, TEE_Param params[4]) -{ - (void)sessionContext; - (void)parmType; - TEE_Result ret = TestTimeApi(cmdId, params); - if (ret != TEE_SUCCESS) - tloge("invoke command for value failed! cmdId: %u, ret: 0x%x", cmdId, ret); - - return ret; -} - -void TA_CloseSessionEntryPoint(void *sessionContext) -{ - (void)sessionContext; - tlogi("---- TA_CloseSessionEntryPoint -----"); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("---- TA_DestroyEntryPoint ----"); -} \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/CMakeLists.txt b/test/xts/ta/test_trusted_storage_api/CMakeLists.txt deleted file mode 100644 index c9d6aa69..00000000 --- a/test/xts/ta/test_trusted_storage_api/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (C) 2022 Huawei Technologies Co., Ltd. -# Licensed under the Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# You may obtain a copy of Mulan PSL v2 at: -# http://license.coscl.org.cn/MulanPSL2 -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR -# PURPOSE. -# See the Mulan PSL v2 for more details. -# - -set(TARGET_NAME test_store_api.elf) - -list(APPEND ta_src - src/oh_trusted_storage_entry.c - src/monad/monad_actions.c - src/monad/monad_run.c - src/monad/monad_inverse_map.c - src/cases/cases_entry.c - src/cases/cases_trusted_storage.c -) - -list(APPEND header_dir - include - src - src/monad - src/cases -) - -ta_compile_pub( - ELF_NAME - ${TARGET_NAME} - - SRC_LIST - ${ta_src} - - INCLUDE_DIRS - ${header_dir} - - COMPILE_OPTS - - COMPILE_DEFS - API_LEVEL=3 -) diff --git a/test/xts/ta/test_trusted_storage_api/manifest.txt b/test/xts/ta/test_trusted_storage_api/manifest.txt deleted file mode 100644 index 6dbcaf73..00000000 --- a/test/xts/ta/test_trusted_storage_api/manifest.txt +++ /dev/null @@ -1,8 +0,0 @@ -gpd.ta.appID: 09090909-0808-0707-0303-030305070901 -gpd.ta.service_name: test_store_api -gpd.ta.singleInstance: true -gpd.ta.multiSession: false -gpd.ta.instanceKeepAlive: false -gpd.ta.objectEnumEnable: true -gpd.ta.dataSize: 8192000 -gpd.ta.stackSize: 8192000 diff --git a/test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.c b/test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.c deleted file mode 100644 index 15192e45..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "string.h" -#include "monad.h" -#include "cases_entry.h" - -static CaseEntry g_caseEntryList[] = { - { - .name = "CaseCreatePersistentObjectAndDelete", - .entry = CaseCreatePersistentObjectAndDelete, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseRenameObjectAndGetInfo", - .entry = CaseRenameObjectAndGetInfo, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseEnumerateDeleteAllObject", - .entry = CaseEnumerateDeleteAllObject, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseRestrictObjectUsage", - .entry = CaseRestrictObjectUsage, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CasePopulateAndCopyObject", - .entry = CasePopulateAndCopyObject, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, - { - .name = "CaseGenerateKey", - .entry = CaseGenerateKey, - .ranFlag = CASE_RAN_FLAG_CLEAR, - .ret = -1, - }, -}; - -static uint32_t g_caseEntryListSize = (uint32_t)(sizeof(g_caseEntryList) / sizeof(g_caseEntryList[0])); - -static int FindCaseIdByName(const char *name, uint32_t *caseId) -{ - uint32_t i; - for (i = 0; i < g_caseEntryListSize; i++) { - if (strcmp((const char *)name, (const char *)(g_caseEntryList[i].name)) == 0) { - *caseId = i; - return 0; - } - } - return -1; -} - -int RunCaseEntryById(uint32_t startId, uint32_t runCnt, uint32_t cf) -{ - if (startId >= g_caseEntryListSize) { - tloge("[%s]:invalid startId[%u]\n", __func__, startId); - return -1; - } - uint32_t i; - uint32_t runId; - for (i = 0; i < runCnt && i + startId < g_caseEntryListSize; i++) { - runId = i + startId; - g_caseEntryList[runId].ranFlag = CASE_RAN_FLAG_SET; - g_caseEntryList[runId].ret = g_caseEntryList[runId].entry(); - if (g_caseEntryList[runId].ret != 0) { - tloge("[%s]:run case [%s] failed\n", __func__, g_caseEntryList[runId].name); - if (cf == 0) { - return -1; - } - } else { - tlogi("[%s]:run case [%s] success\n", __func__, g_caseEntryList[runId].name); - } - } - return 0; -} - -int RunCaseEntryByName(const char *name, uint32_t runCnt, uint32_t cf) -{ - uint32_t startId; - int ret = FindCaseIdByName(name, &startId); - if (ret != 0) { - tloge("[%s]:find case id by name [%s] failed\n", __func__, name); - return -1; - } - return RunCaseEntryById(startId, runCnt, cf); -} - -int GetRunCaseResult(uint32_t *runCnt, uint32_t *failCnt, uint32_t *passCnt) -{ - *runCnt = 0; - *failCnt = 0; - *passCnt = 0; - uint32_t i; - tlogi("[%s]:------------------------------------------\n", __func__); - for (i = 0; i < g_caseEntryListSize; i++) { - if (g_caseEntryList[i].ranFlag != CASE_RAN_FLAG_SET) { - continue; - } - (*runCnt)++; - char *rets = NULL; - if (g_caseEntryList[i].ret == 0) { - (*passCnt)++; - rets = "pass"; - } else { - (*failCnt)++; - rets = "fail"; - } - tlogi("[ %6s]:%s %s\n", rets, g_caseEntryList[i].name, rets); - } - tlogi("[ Report ]:run %u cases, pass %u, fail %u\n", *runCnt, *passCnt, *failCnt); - return (*failCnt == 0 && *passCnt != 0) ? 0 : -1; -} \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.h b/test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.h deleted file mode 100644 index bcabaa8d..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/cases/cases_entry.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef CASE_HEADER_H_ -#define CASE_HEADER_H_ -#include "test_trusted_storage_api_defines.h" -#include "monad.h" - -enum { - CASE_PRESET_RESULT = -1, - CASE_RAN_FLAG_SET = 1, - CASE_RAN_FLAG_CLEAR = 0, -}; - -typedef struct { - char name[MAX_STRING_NAME_LEN]; - int (*entry)(void); - uint8_t ranFlag; - int ret; -} CaseEntry; - -// cases_trusted_storage.c -int CaseCreatePersistentObjectAndDelete(void); -int CaseRenameObjectAndGetInfo(void); -int CaseEnumerateDeleteAllObject(void); -int CaseRestrictObjectUsage(void); -int CasePopulateAndCopyObject(void); -int CaseGenerateKey(void); - -// cases_entry.c -int RunCaseEntryById(uint32_t startId, uint32_t runCnt, uint32_t cf); -int RunCaseEntryByName(const char *name, uint32_t runCnt, uint32_t cf); -int GetRunCaseResult(uint32_t *runCnt, uint32_t *failCnt, uint32_t *passCnt); -#endif // CASE_HEADER_H_ \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/src/cases/cases_trusted_storage.c b/test/xts/ta/test_trusted_storage_api/src/cases/cases_trusted_storage.c deleted file mode 100644 index 833058f2..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/cases/cases_trusted_storage.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include "test_trusted_storage_api_defines.h" -#include "monad.h" -#include "tee_log.h" - -char object_id[] = "FCA6E042AD82303E489B80AEBBEAA7779C1E73E92690EF320A5EDBC44A979BB9"; -char rename_object_id[] = "816C0DD90927C5A2062968420E5B3ADDFBEA1FDDC"; - -char object_init_data[] = "80D35C919E8BFAABE92DA7D8C309FC08623246FBC8DB61B77F58880EA932BD11"; -char object_write_data[] = "FF89C286D5D9AE021FD96F2DECBD1501228B6D10A13FADA485EBD1C8B078564EFF89C286D5D9AE021FD96F2D"; - -char attr_buffer1[] = "FAABE92DA7D8C309FC08623246FB"; -char attr_buffer2[] = "FAABE92DA7D8C309FC08623246FB"; - -int CaseCreatePersistentObjectAndDelete(void) -{ - TestVector tv = { - .storageID = TEE_OBJECT_STORAGE_PRIVATE, - .createObjectID = object_id, - .createFlags = TEE_DATA_FLAG_ACCESS_WRITE | TEE_DATA_FLAG_ACCESS_READ, - .attributes = TEE_HANDLE_NULL, - .initialData = object_init_data, - .openObjectID = object_id, - .openFlags = TEE_DATA_FLAG_ACCESS_WRITE_META | TEE_DATA_FLAG_ACCESS_READ, - .writeBuffer = object_write_data, - .readBufferLen = sizeof(object_write_data), - .seekOffset = 0, - .whence = TEE_DATA_SEEK_SET, - .actions = { - IRSetUp, - CreatePersistentObject, - SeekObject, - WriteObject, - CloseObject, - OpenPersistentObject, - SeekObject, - ReadObject, CheckReadBuffer, - DeletePersistentObject, - IRTearDown, }, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseCreatePersistentObjectAndDelete success\n", __func__); - return 0; -} - -int CaseRenameObjectAndGetInfo(void) -{ - TestVector tv = { - .storageID = TEE_OBJECT_STORAGE_PRIVATE, - .createObjectID = object_id, - .createFlags = TEE_DATA_FLAG_ACCESS_WRITE | TEE_DATA_FLAG_ACCESS_WRITE_META, - .attributes = TEE_HANDLE_NULL, - .initialData = object_init_data, - .resetSize = 0x100, - .newObjectID = rename_object_id, - .openObjectID = rename_object_id, - .openFlags = TEE_DATA_FLAG_ACCESS_WRITE_META | TEE_DATA_FLAG_ACCESS_READ, - .isTransientObject = false, - .actions = { - IRSetUp, - CreatePersistentObject, - TruncateObject, - RenameObject, - CloseObject, - OpenPersistentObject, - GetObjectInfo, CheckObjectSize, - DeletePersistentObject, - IRTearDown, }, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseRenameObjectAndGetInfo success\n", __func__); - return 0; -} - -int CaseEnumerateDeleteAllObject(void) -{ - TestVector tv = { - .storageID = TEE_OBJECT_STORAGE_PRIVATE, - .createObjectID = object_id, - .createFlags = TEE_DATA_FLAG_ACCESS_WRITE | TEE_DATA_FLAG_ACCESS_WRITE_META, - .attributes = TEE_HANDLE_NULL, - .initialData = object_init_data, - .createNum = 5, - .openFlags = TEE_DATA_FLAG_ACCESS_WRITE_META | TEE_DATA_FLAG_ACCESS_READ, - .actions = { - IRSetUp, - CreateMultiObject, - AllocateEnumerator, - ResetEnumerator, - StartEnumerator, - EnumerateAllObject, - FreeEnumerator, - IRTearDown, }, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseEnumerateDeleteAllObject success\n", __func__); - return 0; -} - -int CaseRestrictObjectUsage(void) -{ - TestVector tv = { - .transientObjectNum = 1, - .objectType = {TEE_TYPE_AES}, - .maxObjectSize = {256}, - .objectUsage = {0xFFFF0000, 0x0000FFFF}, - .isTransientObject = true, - .actions = { - IRSetUp, - AllocateTransientObject, - RestrictObjectUsage, GetObjectInfo, CheckObjectUsage, - ResetObject, - RestrictObjectUsage, GetObjectInfo, CheckObjectUsage, - FreeTransientObject, - IRTearDown, }, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseRestrictObjectUsage success\n", __func__); - return 0; -} - -int CasePopulateAndCopyObject(void) -{ - TestVector tv = { - .transientObjectNum = 2, - .objectType = {TEE_TYPE_ECDSA_PUBLIC_KEY, TEE_TYPE_ECDSA_PUBLIC_KEY}, - .maxObjectSize = {256, 256}, - .attrCount = 3, - .attributeID = {TEE_ATTR_ECC_PUBLIC_VALUE_X, TEE_ATTR_ECC_PUBLIC_VALUE_Y, TEE_ATTR_ECC_CURVE}, - .attrInitBuffer = {attr_buffer1, attr_buffer2}, - .attrInitA = {0x1234}, - .attrInitB = {0x5678}, - .getAttributeID = {TEE_ATTR_ECC_PUBLIC_VALUE_X, TEE_ATTR_ECC_PUBLIC_VALUE_Y, TEE_ATTR_ECC_CURVE}, - .actions = { - IRSetUp, - AllocateTransientObject, - InitRefAttr, InitRefAttr, InitValueAttr, - PopulateTransientObject, - CopyObjectAttr, - GetObjectBufferAttr, GetObjectBufferAttr, GetObjectValueAttr, - CheckAttr, - FreeTransientObject, - IRTearDown, }, - .expRet = ER_OK, - }; - - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CasePopulateAndCopyObject success\n", __func__); - return 0; -} - -int CaseGenerateKey(void) -{ - TestVector tv = { - .transientObjectNum = 1, - .objectType = {TEE_TYPE_AES}, - .maxObjectSize = {256}, - .generateKeySize = 256, - .actions = { - IRSetUp, - AllocateTransientObject, - GenerateKey, - FreeTransientObject, - IRTearDown, }, - .expRet = ER_OK, - }; - int ret = MonadRun2(&tv); - if (ret != 0) { - tloge("[%s]:MonadRun2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadRun2 success\n", __func__); - tlogi("[%s]:--------------CaseGenerateKey success\n", __func__); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/src/monad/monad.h b/test/xts/ta/test_trusted_storage_api/src/monad/monad.h deleted file mode 100644 index 424c2e55..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/monad/monad.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef MONAD_H -#define MONAD_H -#include "test_trusted_storage_api_defines.h" -// monad_run.c -int MonadRun2(TestVector *tv); - -// monad_actions.c -// ir init -int IRSetUp(IntermediateReprestation *ir); -int IRTearDown(IntermediateReprestation *ir); -// common operations -int CreatePersistentObject(IntermediateReprestation *ir); -int DeletePersistentObject(IntermediateReprestation *ir); -int OpenPersistentObject(IntermediateReprestation *ir); -int CloseObject(IntermediateReprestation *ir); -int SeekObject(IntermediateReprestation *ir); -int WriteObject(IntermediateReprestation *ir); -int ReadObject(IntermediateReprestation *ir); -int CheckReadBuffer(IntermediateReprestation *ir); - -int TruncateObject(IntermediateReprestation *ir); -int RenameObject(IntermediateReprestation *ir); -int GetObjectInfo(IntermediateReprestation *ir); -int CheckObjectSize(IntermediateReprestation *ir); - -int CreateMultiObject(IntermediateReprestation *ir); -int AllocateEnumerator(IntermediateReprestation *ir); -int FreeEnumerator(IntermediateReprestation *ir); -int ResetEnumerator(IntermediateReprestation *ir); -int StartEnumerator(IntermediateReprestation *ir); -int EnumerateAllObject(IntermediateReprestation *ir); - -int AllocateTransientObject(IntermediateReprestation *ir); -int FreeTransientObject(IntermediateReprestation *ir); -int RestrictObjectUsage(IntermediateReprestation *ir); -int ResetObject(IntermediateReprestation *ir); -int CheckObjectUsage(IntermediateReprestation *ir); - -int InitRefAttr(IntermediateReprestation *ir); -int InitValueAttr(IntermediateReprestation *ir); -int PopulateTransientObject(IntermediateReprestation *ir); -int CopyObjectAttr(IntermediateReprestation *ir); -int GetObjectBufferAttr(IntermediateReprestation *ir); -int GetObjectValueAttr(IntermediateReprestation *ir); -int CheckAttr(IntermediateReprestation *ir); -int GenerateKey(IntermediateReprestation *ir); - -// monad_inverse_map.c -int CopyReversElementList(MonadReversibilityProperty *dest, uint32_t *destSize); -int DisbalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType element); -int BalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType inverseElement); -int BalanceGroupElementList(IntermediateReprestation *ir); - -#endif // end MONAD_H \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/src/monad/monad_actions.c b/test/xts/ta/test_trusted_storage_api/src/monad/monad_actions.c deleted file mode 100644 index cf36f5b5..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/monad/monad_actions.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include "string.h" -#include "securec.h" -#include "tee_log.h" -#include "monad.h" - -int IRSetUp(IntermediateReprestation *ir) -{ - int ret; - - ret = DisbalanceGroupElement(ir->mrpl, ir->mrplSize, IRSetUp); - if (ret != 0) { - tloge("[%s]:DisbalanceGroupElement failed\n", __func__); - return -1; - } - - tlogi("[%s]:IRSetUp success\n", __func__); - return 0; -} - -int IRTearDown(IntermediateReprestation *ir) -{ - int ret; - - ret = BalanceGroupElement(ir->mrpl, ir->mrplSize, IRTearDown); - if (ret != 0) { - tloge("[%s]:BalanceGroupElement failed\n", __func__); - return -1; - } - - tlogi("[%s]:IRTearDown success\n", __func__); - return 0; -} - -/* Persistent Object Functions */ -int CreatePersistentObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - tv->createObjectLen = strnlen(tv->createObjectID, TEE_DATA_MAX_POSITION); - tv->initialDataLen = strnlen(tv->initialData, TEE_DATA_MAX_POSITION); - TEE_Result res = TEE_CreatePersistentObject(tv->storageID, tv->createObjectID, tv->createObjectLen, - tv->createFlags, tv->attributes, tv->initialData, tv->initialDataLen, &(ir->object)); - if (res != TEE_SUCCESS) { - tloge("[%s]:CreatePersistentObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:CreatePersistentObject success\n", __func__); - return 0; -} - -int DeletePersistentObject(IntermediateReprestation *ir) -{ - TEE_Result res = TEE_CloseAndDeletePersistentObject1(ir->object); - if (res != TEE_SUCCESS) { - tloge("[%s]:DeletePersistentObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:DeletePersistentObject success\n", __func__); - return 0; -} - -int OpenPersistentObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - tv->openObjectLen = strnlen(tv->openObjectID, TEE_DATA_MAX_POSITION); - TEE_Result res = TEE_OpenPersistentObject(tv->storageID, tv->openObjectID, tv->openObjectLen, - tv->openFlags, &(ir->object)); - if (res != TEE_SUCCESS) { - tloge("[%s]:OpenPersistentObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:OpenPersistentObject success\n", __func__); - return 0; -} - -int CloseObject(IntermediateReprestation *ir) -{ - TEE_CloseObject(ir->object); - ir->object = TEE_HANDLE_NULL; - tlogi("[%s]:CloseObject success\n", __func__); - return 0; -} - -int SeekObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_SeekObjectData(ir->object, tv->seekOffset, tv->whence); - if (res != TEE_SUCCESS) { - tloge("[%s]:SeekObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:SeekObject success\n", __func__); - return 0; -} - -int WriteObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - tv->writeBufferLen = strnlen(tv->writeBuffer, TEE_DATA_MAX_POSITION); - TEE_Result res = TEE_WriteObjectData(ir->object, tv->writeBuffer, tv->writeBufferLen); - if (res != TEE_SUCCESS) { - tloge("[%s]:WriteObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:WriteObject success\n", __func__); - return 0; -} - -int ReadObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_ReadObjectData(ir->object, (void *)ir->readBuffer, tv->readBufferLen, &(ir->readCount)); - if (res != TEE_SUCCESS) { - tloge("[%s]:WriteObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:ReadObject success\n", __func__); - return 0; -} - -int CheckReadBuffer(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - if (ir->readCount != tv->writeBufferLen) { - tloge("[%s]:CheckReadBuffer compare dataLen fail\n", __func__); - return -1; - } - - int res = strncmp(tv->writeBuffer, ir->readBuffer, ir->readCount); - if (res != 0) { - tloge("[%s]:CheckReadBuffer compare data fail\n", __func__); - return -1; - } - tlogi("[%s]:CheckReadBuffer success\n", __func__); - return 0; -} - -int TruncateObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_TruncateObjectData(ir->object, tv->resetSize); - if (res != TEE_SUCCESS) { - tloge("[%s]:TruncateObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:TruncateObject success\n", __func__); - return 0; -} - -int RenameObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - tv->newObjectLen = strnlen(tv->newObjectID, TEE_DATA_MAX_POSITION); - TEE_Result res = TEE_RenamePersistentObject(ir->object, tv->newObjectID, tv->newObjectLen); - if (res != TEE_SUCCESS) { - tloge("[%s]:RenameObject failed, 0x%x\n", __func__, res); - return res; - } - - tlogi("[%s]:RenameObject success\n", __func__); - return 0; -} - -int GetObjectInfo(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_SUCCESS; - if (tv->isTransientObject) { - res = TEE_GetObjectInfo1(ir->transientObject[0], &(ir->objectInfo)); - } else { - res = TEE_GetObjectInfo1(ir->object, &(ir->objectInfo)); - } - if (res != TEE_SUCCESS) { - tloge("[%s]:GetObjectInfo failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:GetObjectInfo success\n", __func__); - return 0; -} - -int CheckObjectSize(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - if (ir->objectInfo.dataSize != tv->resetSize) { - tloge("[%s]:CheckObjectSize data size error\n", __func__); - return -1; - } - tlogi("[%s]:CheckObjectSize success\n", __func__); - return 0; -} - -/* Persistent Object Enumeration Functions */ -int CreateMultiObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_SUCCESS; - tv->createObjectLen = strnlen(tv->createObjectID, TEE_DATA_MAX_POSITION); - tv->initialDataLen = strnlen(tv->initialData, TEE_DATA_MAX_POSITION); - for (uint32_t i = 0; i < tv->createNum; ++i) { - *((uint8_t *)tv->createObjectID) = '0' + i; - res = TEE_CreatePersistentObject(tv->storageID, tv->createObjectID, tv->createObjectLen, - tv->createFlags, tv->attributes, tv->initialData, tv->initialDataLen, &(ir->object)); - if (res != TEE_SUCCESS) { - tloge("[%s]:CreateMultiObject failed, id %d, res 0x%x\n", __func__, i, res); - return res; - } - TEE_CloseObject(ir->object); - } - tlogi("[%s]:CreateMultiObject success\n", __func__); - return 0; -} - -int AllocateEnumerator(IntermediateReprestation *ir) -{ - TEE_Result res = TEE_AllocatePersistentObjectEnumerator(&(ir->objectEnumerator)); - if (res != TEE_SUCCESS) { - tloge("[%s]:AllocateEnumerator failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:AllocateEnumerator success\n", __func__); - return 0; -} - -int FreeEnumerator(IntermediateReprestation *ir) -{ - TEE_FreePersistentObjectEnumerator(ir->objectEnumerator); - tlogi("[%s]:FreeEnumerator success\n", __func__); - return 0; -} - -int ResetEnumerator(IntermediateReprestation *ir) -{ - TEE_ResetPersistentObjectEnumerator(ir->objectEnumerator); - tlogi("[%s]:ResetEnumerator success\n", __func__); - return 0; -} - -int StartEnumerator(IntermediateReprestation *ir) -{ - TEE_Result res = TEE_StartPersistentObjectEnumerator(ir->objectEnumerator, ir->tv->storageID); - if (res != TEE_SUCCESS) { - tloge("[%s]:StartEnumerator failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:StartEnumerator success\n", __func__); - return 0; -} - -int EnumerateAllObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_SUCCESS; - int object_num = 0; - while (1) { - ir->enumObjectIDLen = MAX_DATA_LEN; - res = TEE_GetNextPersistentObject(ir->objectEnumerator, &(ir->objectInfo), - ir->enumObjectID, &(ir->enumObjectIDLen)); - if (res == TEE_ERROR_ITEM_NOT_FOUND) { - break; - } - if (res != TEE_SUCCESS) { - tloge("[%s]:GetNextObject failed, 0x%x\n", __func__, res); - return res; - } - res = TEE_OpenPersistentObject(tv->storageID, ir->enumObjectID, ir->enumObjectIDLen, - tv->openFlags, &(ir->object)); - if (res != TEE_SUCCESS) { - tloge("[%s]:GetNextObject open object failed, 0x%x\n", __func__, res); - return res; - } - object_num++; - TEE_CloseAndDeletePersistentObject(ir->object); - } - - tlogi("[%s]:EnumerateAllObject success, object num %d\n", __func__, object_num); - return 0; -} - -/* TransientObject Functions */ -int AllocateTransientObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_SUCCESS; - for (uint32_t i = 0; i < tv->transientObjectNum; ++i) { - res = TEE_AllocateTransientObject(tv->objectType[i], tv->maxObjectSize[i], &(ir->transientObject[i])); - if (res != TEE_SUCCESS) { - tloge("[%s]:AllocateTransientObject failed, Object %d, 0x%x\n", __func__, i, res); - return res; - } - } - tlogi("[%s]:AllocateTransientObject success\n", __func__); - return 0; -} - -int FreeTransientObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - for (uint32_t i = 0; i < tv->transientObjectNum; ++i) { - TEE_FreeTransientObject(ir->transientObject[i]); - } - tlogi("[%s]:FreeTransientObject success\n", __func__); - return 0; -} - -int RestrictObjectUsage(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_RestrictObjectUsage1(ir->transientObject[0], tv->objectUsage[ir->restrictUsageCount]); - ir->restrictUsageCount++; - if (res != TEE_SUCCESS) { - tloge("[%s]:RestrictObjectUsage failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:RestrictObjectUsage success\n", __func__); - return 0; -} - -int ResetObject(IntermediateReprestation *ir) -{ - TEE_ResetTransientObject(ir->transientObject[0]); - tlogi("[%s]:RestrictObjectUsage success\n", __func__); - return 0; -} - -int CheckObjectUsage(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - if (ir->objectInfo.objectUsage != tv->objectUsage[ir->checkUsageCount]) { - tloge("[%s]:CheckObjectUsage check failed, objectUsage 0x%x, RestrictUsage 0x%x\n", - __func__, ir->objectInfo.objectUsage, tv->objectUsage[ir->checkUsageCount]); - return -1; - } - tloge("[%s]:CheckObjectUsage check failed, objectUsage 0x%x, RestrictUsage 0x%x\n", - __func__, ir->objectInfo.objectUsage, tv->objectUsage[ir->checkUsageCount]); - ir->checkUsageCount++; - tlogi("[%s]:RestrictObjectUsage success\n", __func__); - return 0; -} - -/* TEE_Attribute Functions */ -int InitRefAttr(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - - tv->attrInitLength[ir->initRefAddrCount] = strnlen(tv->attrInitBuffer[ir->initRefAddrCount], TEE_DATA_MAX_POSITION); - TEE_InitRefAttribute(&(ir->attr[ir->initAttrNum]), tv->attributeID[ir->initAttrNum], - tv->attrInitBuffer[ir->initRefAddrCount], tv->attrInitLength[ir->initRefAddrCount]); - - ir->initRefAddrCount++; - ir->initAttrNum++; - tlogi("[%s]:InitRefAttr success\n", __func__); - return 0; -} - -int InitValueAttr(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_InitValueAttribute(&(ir->attr[ir->initAttrNum]), tv->attributeID[ir->initAttrNum], - tv->attrInitA[ir->initValueAddrCount], tv->attrInitB[ir->initValueAddrCount]); - - ir->initValueAddrCount++; - ir->initAttrNum++; - tlogi("[%s]:InitValueAttr success\n", __func__); - return 0; -} - -int PopulateTransientObject(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_PopulateTransientObject(ir->transientObject[0], &(ir->attr[0]), tv->attrCount); - if (res != TEE_SUCCESS) { - tloge("[%s]:PopulateTransientObject failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:PopulateTransientObject success\n", __func__); - return 0; -} - -int CopyObjectAttr(IntermediateReprestation *ir) -{ - TEE_Result res = TEE_CopyObjectAttributes1(ir->transientObject[1], ir->transientObject[0]); - if (res != TEE_SUCCESS) { - tloge("[%s]:CopyObjectAttr failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:CopyObjectAttr success\n", __func__); - return 0; -} - -int GetObjectBufferAttr(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - ir->attrGetBufferLen[ir->getRefCount] = MAX_DATA_LEN; - TEE_Result res = TEE_GetObjectBufferAttribute(ir->transientObject[1], tv->getAttributeID[ir->getAttrNum], - &(ir->attrGetBuffer[ir->getRefCount]), &(ir->attrGetBufferLen[ir->getRefCount])); - ir->getRefCount++; - ir->getAttrNum++; - if (res != TEE_SUCCESS) { - tloge("[%s]:GetObjectBufferAttr failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:GetObjectBufferAttr success\n", __func__); - return 0; -} - -int GetObjectValueAttr(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_GetObjectValueAttribute(ir->transientObject[1], tv->getAttributeID[ir->getAttrNum], - &(ir->attrGetA[ir->getValueCount]), &(ir->attrGetB[ir->getValueCount])); - ir->getValueCount++; - ir->getAttrNum++; - if (res != TEE_SUCCESS) { - tloge("[%s]:GetObjectValueAttr failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:GetObjectValueAttr success\n", __func__); - return 0; -} - -int CheckAttr(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - if (ir->attrGetBufferLen[0] != tv->attrInitLength[0] || ir->attrGetBufferLen[1] != tv->attrInitLength[1]) { - tlogi("[%s]:CheckAttr attr_length failed\n", __func__); - return -1; - } - if (strncmp(tv->attrInitBuffer[0], (void *)ir->attrGetBuffer[0], ir->attrGetBufferLen[0]) != 0 || - strncmp(tv->attrInitBuffer[1], (void *)ir->attrGetBuffer[1], ir->attrGetBufferLen[1]) != 0) { - tlogi("[%s]:CheckAttr attr_buffer failed\n", __func__); - return -1; - } - if (ir->attrGetBufferLen[0] != tv->attrInitLength[0] || ir->attrGetBufferLen[1] != tv->attrInitLength[1]) { - tlogi("[%s]:CheckAttr attr_length failed\n", __func__); - return -1; - } - - tlogi("[%s]:CheckAttr success\n", __func__); - return 0; -} - -int GenerateKey(IntermediateReprestation *ir) -{ - TestVector *tv = ir->tv; - TEE_Result res = TEE_GenerateKey(ir->transientObject[0], tv->generateKeySize, ir->attr, tv->attrCount); - if (res != TEE_SUCCESS) { - tloge("[%s]:GenerateKey failed, 0x%x\n", __func__, res); - return res; - } - tlogi("[%s]:GenerateKey success\n", __func__); - return 0; -} diff --git a/test/xts/ta/test_trusted_storage_api/src/monad/monad_inverse_map.c b/test/xts/ta/test_trusted_storage_api/src/monad/monad_inverse_map.c deleted file mode 100644 index 834d885d..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/monad/monad_inverse_map.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include "string.h" -#include "monad.h" -#include "securec.h" -#include "tee_log.h" - -static MonadReversibilityProperty g_groupReverseList[] = { - { - .elementName = "IRSetUp", - .element = IRSetUp, - .inverseElementName = "IRTearDown", - .inverseElement = IRTearDown, - .isBalanced = 0, - }, - { - .elementName = "CreatePersistentObject", - .element = CreatePersistentObject, - .inverseElementName = "DeletePersistentObject", - .inverseElement = DeletePersistentObject, - .isBalanced = 0, - }, - { - .elementName = "AllocateEnumerator", - .element = AllocateEnumerator, - .inverseElementName = "FreeEnumerator", - .inverseElement = FreeEnumerator, - .isBalanced = 0, - }, - { - .elementName = "AllocateTransientObject", - .element = AllocateTransientObject, - .inverseElementName = "FreeTransientObject", - .inverseElement = FreeTransientObject, - .isBalanced = 0, - }, -}; - -static uint32_t g_groupReverseListSize = (uint32_t)(sizeof(g_groupReverseList) / sizeof(g_groupReverseList[0])); - -int CopyReversElementList(MonadReversibilityProperty *dest, uint32_t *destSize) -{ - if (*destSize < g_groupReverseListSize) { - tloge("[%s]:destSize = %u < g_groupReverseListSize = %u\n", __func__, - *destSize, g_groupReverseListSize); - return -1; - } - - uint32_t i; - for (i = 0; i < g_groupReverseListSize; i++) { - dest[i].element = g_groupReverseList[i].element; - dest[i].elementName = g_groupReverseList[i].elementName; - dest[i].inverseElement = g_groupReverseList[i].inverseElement; - dest[i].inverseElementName = g_groupReverseList[i].inverseElementName; - dest[i].isBalanced = g_groupReverseList[i].isBalanced; - } - *destSize = g_groupReverseListSize; - - tlogi("[%s]:CopyReversElementList success\n", __func__); - return 0; -} - -int DisbalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType element) -{ - uint32_t i; - MonadReversibilityProperty *find = NULL; - for (i = 0; i < listSize; i++) { - if (list[i].element == element) { - find = &(list[i]); - break; - } - } - - if (find == NULL) { - tloge("[%s]:could not find inverse elment\n", __func__); - return -1; - } - tlogi("[%s]:find element dual %s -> %s\n", __func__, find->elementName, find->inverseElementName); - - find->isBalanced = GRUPP_NOT_BALANCED; - - tlogi("[%s]:DisbalanceGroupElement success\n", __func__); - return 0; -} - -int BalanceGroupElement(MonadReversibilityProperty *list, uint32_t listSize, ActionEntryType inverseElement) -{ - uint32_t i; - MonadReversibilityProperty *find = NULL; - for (i = 0; i < listSize; i++) { - if (list[i].inverseElement == inverseElement) { - find = &(list[i]); - break; - } - } - if (find == NULL) { - tloge("[%s]:could not find inverse elment\n", __func__); - return -1; - } - tlogi("[%s]:find element dual %s -> %s\n", __func__, find->elementName, find->inverseElementName); - - find->isBalanced = GROUP_BALANCED; - - tlogi("[%s]:BalanceGroupElement success\n", __func__); - return 0; -} - -int BalanceGroupElementList(IntermediateReprestation *ir) -{ - MonadReversibilityProperty *list = ir->mrpl; - uint32_t listSize = ir->mrplSize; - - uint32_t i; - for (i = 0; i < listSize; i++) { - if (list[i].isBalanced == GRUPP_NOT_BALANCED) { - int ret = list[i].inverseElement(ir); - if (ret != 0) { - tloge("[%s]:inverse element %s (<- element %s) excute failed\n", __func__, - list[i].inverseElementName, list[i].elementName); - return -1; - } - tlogi("[%s]:inverse element %s (<- element %s) excute success\n", __func__, - list[i].inverseElementName, list[i].elementName); - } else { - tlogi("[%s]:inverse element %s (<- element %s) is balanced, just return.\n", __func__, - list[i].inverseElementName, list[i].elementName); - } - } - - tlogi("[%s]:BalanceGroupElementList success\n", __func__); - return 0; -} \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/src/monad/monad_run.c b/test/xts/ta/test_trusted_storage_api/src/monad/monad_run.c deleted file mode 100644 index 646e184a..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/monad/monad_run.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include "securec.h" -#include "tee_log.h" -#include "test_trusted_storage_api_defines.h" -#include "monad.h" - -int MonadSetup2(TestVector *tv, IntermediateReprestation *ir) -{ - (void)ir; - ir->tv = tv; - ir->mrplSize = MONAD_REVERSE_PROP_LIST_SIZE; - int ret = CopyReversElementList(ir->mrpl, &(ir->mrplSize)); - if (ret != 0) { - tloge("[%s]:CopyReversElementList failed\n", __func__); - return -1; - } - - tlogi("[%s]:MonadSetup2 success\n", __func__); - return 0; -} - -static int CheckExpResult2(int realRet, int tvExpRet, const char *info) -{ - if ((tvExpRet != 0) && realRet == 0) { - tloge("[%s]:expect fail, but pass. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return -1; - } else if ((tvExpRet == 0) && realRet != 0) { - tloge("[%s]:expect pass, but fail. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return -1; - } else if ((tvExpRet != 0) && realRet != 0) { - tlogi("[%s]:expect fail, and fail. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return 0; - } else if ((tvExpRet == 0) && realRet == 0) { - tlogi("[%s]:expect pass, and pass. tvExpRet[0x%x], realRet[0x%x]\n", - info, tvExpRet, realRet); - return 0; - } - return 0; -} - -int MonadTearDown(IntermediateReprestation *ir) -{ - int ret = BalanceGroupElementList(ir); - if (ret != 0) { - tloge("[%s]:BalanceGroupElementList failed\n", __func__); - return -1; - } - - tlogi("[%s]:MonadTearDown success\n", __func__); - return 0; -} - -int MonadRun2(TestVector *tv) -{ - IntermediateReprestation ir; - int ret = memset_s((void *)&ir, sizeof(IntermediateReprestation), 0, sizeof(IntermediateReprestation)); - if (ret != EOK) { - tloge("[%s]:memset_s failed\n", __func__); - return -1; - } - - ret = MonadSetup2(tv, &ir); - if (ret != 0) { - tloge("[%s]:MonadSetup2 failed\n", __func__); - return -1; - } - tlogi("[%s]:MonadSetup2 success\n", __func__); - - int checkResult; - uint32_t i; - for (i = 0; i < MAX_ACTIONS_SIZE; i++) { - if (tv->actions[i] == NULL) { - tlogi("[%s]:actions size is %u\n", __func__, i); - break; - } - ret = tv->actions[i](&ir); - if (ret != 0) { - tloge("[%s]:%uth action excute failed, break pipeline.\n", __func__, i); - break; - } - } - checkResult = CheckExpResult2(ret, tv->expRet, __func__); - if (checkResult != 0) { - tloge("[%s]:CheckExpResult failed at %dth act in of seq.\n", __func__, i); - } - - ret = MonadTearDown(&ir); - if (ret != 0) { - tloge("[%s]:MonadTearDown sucess\n", __func__); - return -1; - } - tlogi("[%s]:MonadTearDown sucess\n", __func__); - - return checkResult; -} diff --git a/test/xts/ta/test_trusted_storage_api/src/oh_trusted_storage_entry.c b/test/xts/ta/test_trusted_storage_api/src/oh_trusted_storage_entry.c deleted file mode 100644 index c9f6e3bb..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/oh_trusted_storage_entry.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include "tee_ext_api.h" -#include "cases_entry.h" - -#define SYSTEM_OH_TRUSTED_STORAGE "/system/bin/tee_test_store_api" -#define VENDOR_OH_TRUSTED_STORAGE "/vendor/bin/tee_test_store_api" -#define TEST_STORAGE_UID 0 - -// TA_INVOKE_CMD -enum { - CMD_RUN_BY_FUN_SEQ = 0, -}; - -TEE_Result TA_CreateEntryPoint(void) -{ - tlogi("%s:start add caller info success\n", __func__); - TEE_Result ret; - - ret = AddCaller_CA_exec(VENDOR_OH_TRUSTED_STORAGE, TEST_STORAGE_UID); - if (ret != TEE_SUCCESS) - return ret; - ret = AddCaller_CA_exec(SYSTEM_OH_TRUSTED_STORAGE, TEST_STORAGE_UID); - if (ret != TEE_SUCCESS) - return ret; - - tlogi("%s:end add caller info success\n", __func__); - return TEE_SUCCESS; -} - -TEE_Result TA_OpenSessionEntryPoint(uint32_t paramTypes, TEE_Param params[4], void **sessionContext) -{ - (void)paramTypes; - (void)params; - (void)sessionContext; - tlogi("in %s\n", __func__); - return TEE_SUCCESS; -} - -TEE_Result TA_InvokeCommandEntryPoint(void *session_context, uint32_t cmd_id, uint32_t paramTypes, TEE_Param params[4]) -{ - (void)session_context; - // check params - if (!check_param_type(paramTypes, - TEE_PARAM_TYPE_MEMREF_INOUT, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE, - TEE_PARAM_TYPE_NONE)) { - tloge("%s:error, invalid param_types\n", __func__); - return TEE_ERROR_BAD_PARAMETERS; - } - tlogi("%s:cmd_id is %d\n", __func__, cmd_id); - int ret; - switch (cmd_id) { - case CMD_RUN_BY_FUN_SEQ: { - ret = RunCaseEntryByName((const char *)params[0].memref.buffer, 1, 0); - if (ret != 0) { - tloge("[%s]:RunCaseEntryByName fail\n", __func__); - return TEE_ERROR_GENERIC; - } - tlogi("[%s]:RunCaseEntryByName success\n", __func__); - return 0; - } - default: - return 0; - } -} - -void TA_CloseSessionEntryPoint(void *session_context) -{ - (void)session_context; - tlogi("in %s.\n", __func__); -} - -void TA_DestroyEntryPoint(void) -{ - tlogi("in %s.\n", __func__); -} \ No newline at end of file diff --git a/test/xts/ta/test_trusted_storage_api/src/test_trusted_storage_api_defines.h b/test/xts/ta/test_trusted_storage_api/src/test_trusted_storage_api_defines.h deleted file mode 100644 index 034a2b18..00000000 --- a/test/xts/ta/test_trusted_storage_api/src/test_trusted_storage_api_defines.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef TEST_TRUSTED_STORAGE_DEFINES_H -#define TEST_TRUSTED_STORAGE_DEFINES_H -#include "stddef.h" -#include "tee_internal_api.h" -#include "tee_trusted_storage_api.h" -#include "tee_object_api.h" - -struct _IntermediateReprestation; -typedef int (*ActionEntryType)(struct _IntermediateReprestation *ir); - -#define MAX_STRING_NAME_LEN 100 -#define MAX_ACTIONS_SIZE 100 - -#define MAX_DATA_LEN 1024 -#define MAX_ACTION_LOOP_SIZE 10 - -// test vector -typedef struct { - // start of declaration of user defined test data factors - uint32_t storageID; - - void *createObjectID; - size_t createObjectLen; - uint32_t createFlags; - uint32_t createNum; - void* initialData; - size_t initialDataLen; - TEE_ObjectHandle attributes; - - void *openObjectID; - size_t openObjectLen; - uint32_t openFlags; - - int32_t seekOffset; - TEE_Whence whence; - void* writeBuffer; - size_t writeBufferLen; - size_t readBufferLen; - - void *newObjectID; - size_t newObjectLen; - size_t resetSize; - - uint32_t objectUsage[MAX_ACTION_LOOP_SIZE]; - uint32_t objectType[MAX_ACTION_LOOP_SIZE]; - uint32_t maxObjectSize[MAX_ACTION_LOOP_SIZE]; - uint32_t transientObjectNum; - bool isTransientObject; - - uint32_t attributeID[MAX_ACTION_LOOP_SIZE]; - void *attrInitBuffer[MAX_ACTION_LOOP_SIZE]; - size_t attrInitLength[MAX_ACTION_LOOP_SIZE]; - uint32_t attrInitA[MAX_ACTION_LOOP_SIZE]; - uint32_t attrInitB[MAX_ACTION_LOOP_SIZE]; - uint32_t getAttributeID[MAX_ACTION_LOOP_SIZE]; - - uint32_t generateKeySize; - uint32_t attrCount; - - // end of declaration of user defined test data factors - // start of declaration of factors of the test framework - ActionEntryType actions[MAX_ACTIONS_SIZE]; - uint32_t expRet; -} TestVector; - -// expect result -enum { - ER_OK = 0, - ER_JF = 1, -}; - -// inverse actions map info manage -enum { - GROUP_BALANCED = 0, - GRUPP_NOT_BALANCED = 1, -}; -typedef struct { - char *elementName; - ActionEntryType element; - char *inverseElementName; - ActionEntryType inverseElement; - uint32_t isBalanced; -} MonadReversibilityProperty; - -// intermediate represtation of test context -#define MONAD_REVERSE_PROP_LIST_SIZE 100 -typedef struct _IntermediateReprestation { - // start of declaration of user defined test data factors - TEE_ObjectHandle object; - TEE_ObjectInfo objectInfo; - - char readBuffer[MAX_DATA_LEN]; - uint32_t readCount; - - TEE_ObjectEnumHandle objectEnumerator; - char enumObjectID[MAX_DATA_LEN]; - size_t enumObjectIDLen; - - TEE_ObjectHandle transientObject[MAX_ACTION_LOOP_SIZE]; - TEE_Attribute attr[MAX_ACTION_LOOP_SIZE]; - uint32_t initAttrNum; - - void *attrGetBuffer[MAX_ACTION_LOOP_SIZE][MAX_DATA_LEN]; - size_t attrGetBufferLen[MAX_ACTION_LOOP_SIZE]; - uint32_t attrGetA[MAX_ACTION_LOOP_SIZE]; - uint32_t attrGetB[MAX_ACTION_LOOP_SIZE]; - - /* function invoke count */ - uint32_t getAttrNum; - uint32_t getRefCount; - uint32_t getValueCount; - uint32_t restrictUsageCount; - uint32_t checkUsageCount; - uint32_t initRefAddrCount; - uint32_t initValueAddrCount; - // end of declaration of user defined test data factors - - // start of declaration factors of the test framework - TestVector *tv; - MonadReversibilityProperty mrpl[MONAD_REVERSE_PROP_LIST_SIZE]; - uint32_t mrplSize; -} IntermediateReprestation; -#endif // end TEST_DEFINES_H \ No newline at end of file diff --git a/test/xts/utils/cmd_id/test_drv_cmdid.h b/test/xts/utils/cmd_id/test_drv_cmdid.h deleted file mode 100644 index 91f29cdf..00000000 --- a/test/xts/utils/cmd_id/test_drv_cmdid.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef __TEST_DRV_CMDID_H__ -#define __TEST_DRV_CMDID_H__ - -typedef enum { - DRVTEST_COMMAND_DRVVIRTTOPHYS = 1, - DRVTEST_COMMAND_COPYFROMCLIENT, - DRVTEST_COMMAND_COPYTOCLIENT, -} DrvCmdId; - -#endif \ No newline at end of file diff --git a/test/xts/utils/cmd_id/test_tcf_cmdid.h b/test/xts/utils/cmd_id/test_tcf_cmdid.h deleted file mode 100644 index f83e3e9e..00000000 --- a/test/xts/utils/cmd_id/test_tcf_cmdid.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2022 Huawei Technologies Co., Ltd. - * Licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR - * PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef __TEST_TCF_CMDID_H__ -#define __TEST_TCF_CMDID_H__ - -typedef enum { - CMD_TEE_GetPropertyAsString = 0, - CMD_TEE_GetPropertyAsBool, - CMD_TEE_GetPropertyAsU32, - CMD_TEE_GetPropertyAsU64, - CMD_TEE_GetPropertyAsBinaryBlock, - CMD_TEE_GetPropertyAsUUID, - CMD_TEE_GetPropertyAsIdentity, - CMD_TEE_AllocatePropertyEnumerator, - CMD_TEE_FreePropertyEnumerator, - CMD_TEE_StartPropertyEnumerator, - CMD_TEE_ResetPropertyEnumerator, - CMD_TEE_GetPropertyNameEnumerator, - CMD_TEE_GetNextPropertyEnumerator, - CMD_TEE_Malloc, - CMD_TEE_Free, - CMD_TEE_Realloc, - CMD_TEE_MemMove, - CMD_TEE_MemCompare, - CMD_TEE_MemFill, - CMD_TEE_CheckMemoryAccessRights, - CMD_TEE_GetInstanceData, - CMD_TEE_SetInstanceData, - CMD_TEE_OpenTASession, - CMD_TEE_InvokeTACommand, - CMD_TEE_CloseTASession, - CMD_TEE_Panic, -} TCFCmdId; - -#define INPUT_ISNULL 1 -#define OUTPUT_ISNULL 2 -#define OUTPUTBUFFERSIZE_ISNULL 3 -#define OUTPUTBUFFERSIZE_ISZERO 4 -#define OUTPUTBUFFERSIZE_TOOSHORT 5 -#define BUFFER_ISNOT_MALLOC 6 -#define BUFFERSIZE_ISTOOBIG 7 -#define BUFFER_IS_FREE 8 -#define BUFFER_IS_PARAM 9 -#define DESTANDSRC_ISSAME 10 -#define DESTANDSRC_OVERLAP 11 -#define BUFFER_IS_GLOBALVAR 12 -#define BUFFER_IS_GLOBALCONSTVAR 13 -#define RETURNORIGIN_ISNULL 14 -#define TA_CRASH_FLAG 15 -#define BUFFER_NOFILLNOSHARE 16 -#endif \ No newline at end of file