From 273c62516d2708e71518cf35b4561737196849df Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Tue, 20 Aug 2019 10:10:49 +0100 Subject: [PATCH] crypto: Remove old compliance tests We'll use the new ARM-software/psa-arch-tests directly instead for PSA Crypto API 1.0b3. This commit removes the crypto compliance tests only for now, leaving attestation and storage tests. --- .../compliance_crypto/psa_crypto_testlist.md | 574 ------------------ .../TESTS/compliance_crypto/test_c001/main.c | 9 - .../compliance_crypto/test_c001/test_c001.c | 73 --- .../compliance_crypto/test_c001/test_c001.h | 34 -- .../compliance_crypto/test_c001/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c002/main.c | 9 - .../compliance_crypto/test_c002/test_c002.c | 217 ------- .../compliance_crypto/test_c002/test_c002.h | 31 - .../compliance_crypto/test_c002/test_data.h | 299 --------- .../compliance_crypto/test_c002/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c003/main.c | 9 - .../compliance_crypto/test_c003/test_c003.c | 220 ------- .../compliance_crypto/test_c003/test_c003.h | 31 - .../compliance_crypto/test_c003/test_data.h | 289 --------- .../compliance_crypto/test_c003/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c004/main.c | 9 - .../compliance_crypto/test_c004/test_c004.c | 258 -------- .../compliance_crypto/test_c004/test_c004.h | 31 - .../compliance_crypto/test_c004/test_data.h | 312 ---------- .../compliance_crypto/test_c004/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c005/main.c | 9 - .../compliance_crypto/test_c005/test_c005.c | 182 ------ .../compliance_crypto/test_c005/test_c005.h | 31 - .../compliance_crypto/test_c005/test_data.h | 274 --------- .../compliance_crypto/test_c005/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c006/main.c | 9 - .../compliance_crypto/test_c006/test_c006.c | 178 ------ .../compliance_crypto/test_c006/test_c006.h | 31 - .../compliance_crypto/test_c006/test_data.h | 273 --------- .../compliance_crypto/test_c006/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c007/main.c | 9 - .../compliance_crypto/test_c007/test_c007.c | 188 ------ .../compliance_crypto/test_c007/test_c007.h | 32 - .../compliance_crypto/test_c007/test_data.h | 285 --------- .../compliance_crypto/test_c007/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c008/main.c | 9 - .../compliance_crypto/test_c008/test_c008.c | 181 ------ .../compliance_crypto/test_c008/test_c008.h | 31 - .../compliance_crypto/test_c008/test_data.h | 272 --------- .../compliance_crypto/test_c008/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c009/main.c | 9 - .../compliance_crypto/test_c009/test_c009.c | 85 --- .../compliance_crypto/test_c009/test_c009.h | 31 - .../compliance_crypto/test_c009/test_data.h | 86 --- .../compliance_crypto/test_c009/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c010/main.c | 9 - .../compliance_crypto/test_c010/test_c010.c | 168 ----- .../compliance_crypto/test_c010/test_c010.h | 31 - .../compliance_crypto/test_c010/test_data.h | 275 --------- .../compliance_crypto/test_c010/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c011/main.c | 9 - .../compliance_crypto/test_c011/test_c011.c | 62 -- .../compliance_crypto/test_c011/test_c011.h | 31 - .../compliance_crypto/test_c011/test_data.h | 120 ---- .../compliance_crypto/test_c011/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c012/main.c | 10 - .../compliance_crypto/test_c012/test_c012.c | 148 ----- .../compliance_crypto/test_c012/test_c012.h | 32 - .../compliance_crypto/test_c012/test_data.h | 82 --- .../compliance_crypto/test_c012/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c013/main.c | 9 - .../compliance_crypto/test_c013/test_c013.c | 135 ---- .../compliance_crypto/test_c013/test_c013.h | 31 - .../compliance_crypto/test_c013/test_data.h | 131 ---- .../compliance_crypto/test_c013/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c014/main.c | 9 - .../compliance_crypto/test_c014/test_c014.c | 186 ------ .../compliance_crypto/test_c014/test_c014.h | 32 - .../compliance_crypto/test_c014/test_data.h | 115 ---- .../compliance_crypto/test_c014/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c015/main.c | 9 - .../compliance_crypto/test_c015/test_c015.c | 110 ---- .../compliance_crypto/test_c015/test_c015.h | 31 - .../compliance_crypto/test_c015/test_data.h | 80 --- .../compliance_crypto/test_c015/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c016/main.c | 9 - .../compliance_crypto/test_c016/test_c016.c | 174 ------ .../compliance_crypto/test_c016/test_c016.h | 31 - .../compliance_crypto/test_c016/test_data.h | 145 ----- .../compliance_crypto/test_c016/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c017/main.c | 9 - .../compliance_crypto/test_c017/test_c017.c | 74 --- .../compliance_crypto/test_c017/test_c017.h | 30 - .../compliance_crypto/test_c017/test_data.h | 56 -- .../compliance_crypto/test_c017/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c018/main.c | 9 - .../compliance_crypto/test_c018/test_c018.c | 146 ----- .../compliance_crypto/test_c018/test_c018.h | 30 - .../compliance_crypto/test_c018/test_data.h | 97 --- .../compliance_crypto/test_c018/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c019/main.c | 9 - .../compliance_crypto/test_c019/test_c019.c | 121 ---- .../compliance_crypto/test_c019/test_c019.h | 30 - .../compliance_crypto/test_c019/test_data.h | 70 --- .../compliance_crypto/test_c019/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c020/main.c | 9 - .../compliance_crypto/test_c020/test_c020.c | 302 --------- .../compliance_crypto/test_c020/test_c020.h | 31 - .../compliance_crypto/test_c020/test_data.h | 122 ---- .../compliance_crypto/test_c020/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c021/main.c | 9 - .../compliance_crypto/test_c021/test_c021.c | 111 ---- .../compliance_crypto/test_c021/test_c021.h | 30 - .../compliance_crypto/test_c021/test_data.h | 51 -- .../compliance_crypto/test_c021/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c022/main.c | 9 - .../compliance_crypto/test_c022/test_c022.c | 188 ------ .../compliance_crypto/test_c022/test_c022.h | 31 - .../compliance_crypto/test_c022/test_data.h | 136 ----- .../compliance_crypto/test_c022/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c023/main.c | 9 - .../compliance_crypto/test_c023/test_c023.c | 68 --- .../compliance_crypto/test_c023/test_c023.h | 30 - .../compliance_crypto/test_c023/test_data.h | 55 -- .../compliance_crypto/test_c023/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c024/main.c | 9 - .../compliance_crypto/test_c024/test_c024.c | 217 ------- .../compliance_crypto/test_c024/test_c024.h | 32 - .../compliance_crypto/test_c024/test_data.h | 180 ------ .../compliance_crypto/test_c024/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c025/main.c | 9 - .../compliance_crypto/test_c025/test_c025.c | 211 ------- .../compliance_crypto/test_c025/test_c025.h | 32 - .../compliance_crypto/test_c025/test_data.h | 209 ------- .../compliance_crypto/test_c025/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c026/main.c | 9 - .../compliance_crypto/test_c026/test_c026.c | 149 ----- .../compliance_crypto/test_c026/test_c026.h | 31 - .../compliance_crypto/test_c026/test_data.h | 155 ----- .../compliance_crypto/test_c026/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c027/main.c | 9 - .../compliance_crypto/test_c027/test_c027.c | 138 ----- .../compliance_crypto/test_c027/test_c027.h | 31 - .../compliance_crypto/test_c027/test_data.h | 70 --- .../compliance_crypto/test_c027/test_entry.c | 52 -- .../TESTS/compliance_crypto/test_c028/main.c | 9 - .../compliance_crypto/test_c028/test_c028.c | 123 ---- .../compliance_crypto/test_c028/test_c028.h | 30 - .../compliance_crypto/test_c028/test_data.h | 114 ---- .../compliance_crypto/test_c028/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c029/main.c | 9 - .../compliance_crypto/test_c029/test_c029.c | 144 ----- .../compliance_crypto/test_c029/test_c029.h | 32 - .../compliance_crypto/test_c029/test_data.h | 158 ----- .../compliance_crypto/test_c029/test_entry.c | 52 -- .../TESTS/compliance_crypto/test_c030/main.c | 9 - .../compliance_crypto/test_c030/test_c030.c | 113 ---- .../compliance_crypto/test_c030/test_c030.h | 30 - .../compliance_crypto/test_c030/test_data.h | 131 ---- .../compliance_crypto/test_c030/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c031/main.c | 9 - .../compliance_crypto/test_c031/test_c031.c | 163 ----- .../compliance_crypto/test_c031/test_c031.h | 31 - .../compliance_crypto/test_c031/test_data.h | 80 --- .../compliance_crypto/test_c031/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c032/main.c | 9 - .../compliance_crypto/test_c032/test_c032.c | 181 ------ .../compliance_crypto/test_c032/test_c032.h | 31 - .../compliance_crypto/test_c032/test_data.h | 315 ---------- .../compliance_crypto/test_c032/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c033/main.c | 9 - .../compliance_crypto/test_c033/test_c033.c | 181 ------ .../compliance_crypto/test_c033/test_c033.h | 31 - .../compliance_crypto/test_c033/test_data.h | 317 ---------- .../compliance_crypto/test_c033/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c034/main.c | 9 - .../compliance_crypto/test_c034/test_c034.c | 123 ---- .../compliance_crypto/test_c034/test_c034.h | 30 - .../compliance_crypto/test_c034/test_data.h | 139 ----- .../compliance_crypto/test_c034/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c035/main.c | 9 - .../compliance_crypto/test_c035/test_c035.c | 100 --- .../compliance_crypto/test_c035/test_c035.h | 30 - .../compliance_crypto/test_c035/test_data.h | 151 ----- .../compliance_crypto/test_c035/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c036/main.c | 10 - .../compliance_crypto/test_c036/test_c036.c | 131 ---- .../compliance_crypto/test_c036/test_c036.h | 30 - .../compliance_crypto/test_c036/test_data.h | 252 -------- .../compliance_crypto/test_c036/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c037/main.c | 10 - .../compliance_crypto/test_c037/test_c037.c | 143 ----- .../compliance_crypto/test_c037/test_c037.h | 30 - .../compliance_crypto/test_c037/test_data.h | 281 --------- .../compliance_crypto/test_c037/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c038/main.c | 9 - .../compliance_crypto/test_c038/test_c038.c | 177 ------ .../compliance_crypto/test_c038/test_c038.h | 31 - .../compliance_crypto/test_c038/test_data.h | 145 ----- .../compliance_crypto/test_c038/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c039/main.c | 9 - .../compliance_crypto/test_c039/test_c039.c | 245 -------- .../compliance_crypto/test_c039/test_c039.h | 31 - .../compliance_crypto/test_c039/test_data.h | 254 -------- .../compliance_crypto/test_c039/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c040/main.c | 9 - .../compliance_crypto/test_c040/test_c040.c | 232 ------- .../compliance_crypto/test_c040/test_c040.h | 31 - .../compliance_crypto/test_c040/test_data.h | 329 ---------- .../compliance_crypto/test_c040/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c041/main.c | 9 - .../compliance_crypto/test_c041/test_c041.c | 199 ------ .../compliance_crypto/test_c041/test_c041.h | 31 - .../compliance_crypto/test_c041/test_data.h | 317 ---------- .../compliance_crypto/test_c041/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c042/main.c | 9 - .../compliance_crypto/test_c042/test_c042.c | 190 ------ .../compliance_crypto/test_c042/test_c042.h | 31 - .../compliance_crypto/test_c042/test_data.h | 373 ------------ .../compliance_crypto/test_c042/test_entry.c | 53 -- .../TESTS/compliance_crypto/test_c043/main.c | 9 - .../compliance_crypto/test_c043/test_c043.c | 186 ------ .../compliance_crypto/test_c043/test_c043.h | 31 - .../compliance_crypto/test_c043/test_data.h | 194 ------ .../compliance_crypto/test_c043/test_entry.c | 53 -- .../frameworks/TARGET_PSA/pal/pal_common.h | 1 - .../TARGET_PSA/pal/pal_crypto_config.h | 407 ------------- .../TARGET_PSA/pal/pal_crypto_config_check.h | 223 ------- .../TARGET_PSA/pal/pal_crypto_intf.c | 339 ----------- .../TARGET_PSA/pal/pal_crypto_intf.h | 84 --- features/frameworks/TARGET_PSA/val_crypto.c | 39 -- features/frameworks/TARGET_PSA/val_crypto.h | 108 ---- .../frameworks/TARGET_PSA/val_interfaces.c | 2 - 223 files changed, 20485 deletions(-) delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/psa_crypto_testlist.md delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c001/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c002/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c003/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c004/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c005/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c006/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c007/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c008/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c009/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c010/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c011/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c012/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c013/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c014/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c015/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c016/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c017/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c018/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c019/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c020/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c021/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c022/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c023/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c024/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c025/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c026/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c027/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c028/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c029/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c030/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c031/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c032/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c033/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c034/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c035/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c036/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c037/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c038/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c039/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c040/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c041/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c042/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_entry.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c043/main.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.c delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_data.h delete mode 100644 components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_entry.c delete mode 100644 features/frameworks/TARGET_PSA/pal/pal_crypto_config.h delete mode 100644 features/frameworks/TARGET_PSA/pal/pal_crypto_config_check.h delete mode 100644 features/frameworks/TARGET_PSA/pal/pal_crypto_intf.c delete mode 100644 features/frameworks/TARGET_PSA/pal/pal_crypto_intf.h delete mode 100644 features/frameworks/TARGET_PSA/val_crypto.c delete mode 100644 features/frameworks/TARGET_PSA/val_crypto.h diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/psa_crypto_testlist.md b/components/TARGET_PSA/TESTS/compliance_crypto/psa_crypto_testlist.md deleted file mode 100644 index 12def99d6c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/psa_crypto_testlist.md +++ /dev/null @@ -1,574 +0,0 @@ -# PSA Crypto Testcase checklist - - - -| Group | Test | Function | Scenario | Return Value | Steps | Test Case | -|------------------------------|-----------|----------------------------|-----------------------------------------------------------------------------------------------------------------------|---------------------------------|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| -| Basic | test_c001 | psa_crypto_init | Library initialization | PSA_SUCCESS | Calling this function should return SUCCESS | | -| | | | Applications must call this function before calling any other function in this module. | PSA_SUCCESS | Try calling crypto operations doing a crypto_init should be successful(can be covered as part of other testcase) | | -| | | | Applications may call this function more than once. Once a call succeeds, subsequent calls are guaranteed to succeed. | PSA_SUCCESS | Try calling multiple crypto init and should return SUCCESS | | -| | | | Applications must call this function before calling any other function in this module. | PSA_ERROR_BAD_STATE | Try calling crypto operations without doing a crypto_init should return FAILURE | | -| | | | | | | | -| Key Management | test_c002 | psa_import_key | Import a key in binary format. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. 2048 RSA public key | -| | | | | | 5. Import the key data into the key slot | 5. 2048 RSA keypair | -| | | | | | 6. Get basic metadata about a key | 6. DES 64 bit key | -| | | | | | 7. Export a key in binary format | 7. Triple DES 2-Key | -| | | | | | 8. Check if original key data matches with the exported data | 8. Triple DES 3-Key | -| | | | | | | 9. EC Public key | -| | | | | | | 10. EC keypair | -| | | | | PSA_ERROR_NOT_SUPPORTED | Calling this function with incorrect key type | Incorrect key type | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function with invalid parameter should return this error | 1. Key data greater than the algorithm size | -| | | | | | | 2. Incorrect key data size | -| | | | | | | | -| | | | | | | | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid key handle should return this error | 1. Invalid key slot
2. Zero key slot | -| | | | | PSA_ERROR_OCCUPIED_SLOT | Pass the key slot to store data which is already occupied | Already occupied key slot | -| | test_c003 | psa_export_key | Export a key in binary format | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | | | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. 2048 RSA public key | -| | | | | | 5. Import the key data into the key slot | 5. 2048 RSA keypair | -| | | | | | 6. Get basic metadata about a key | 6. DES 64 bit key | -| | | | | | 7. Export a key in binary format | 7. Triple DES 2-Key | -| | | | | | 8. Check if original key data matches with the exported data | 8. Triple DES 3-Key | -| | | | | | | 9. EC Public key | -| | | | | | | 10. EC keypair | -| | | | | PSA_ERROR_BUFFER_TOO_SMALL | Calling this function with buffer size less than required | Less buffer size | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid parameter should return this error | 1. Zero key slot | -| | | | | | | 2. Invalid key slot | -| | | | | PSA_ERROR_BAD_STATE | Calling this function with key policy that cannot be exported | Invalid key policy usage | -| | | | | PSA_ERROR_EMPTY_SLOT | Calling this function with empty key slot | Empty key slot | -| | test_c004 | psa_export_public_key | Export a public key or the public part of a key pair in binary format. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 2048 RSA public key | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 2048 RSA keypair | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. EC Public key | -| | | | | | 4. Set the usage policy on a key slot | 4. EC keypair | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Get basic metadata about a key | | -| | | | | | 7. Export a key in binary format | | -| | | | | | 8. Check if original key data matches with the exported data | | -| | | | | PSA_ERROR_INVALID_ARGUMENT | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. DES 64 bit key | -| | | | | | 5. Import the key data into the key slot | 5. Triple DES 2-Key | -| | | | | | 6. Get basic metadata about a key | 6. Triple DES 3-Key | -| | | | | | 7. Export a key in binary format | | -| | | | | | 8. Check if original key data matches with the exported data | | -| | | | | PSA_ERROR_BUFFER_TOO_SMALL | Calling this function with buffer size less than required | Less buffer size | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid parameter should return this error | 1. Zero key slot | -| | | | | | | 2. Invalid key slot | -| | | | | PSA_ERROR_BAD_STATE | Calling this function with key policy that cannot be exported | Invalid key policy usage | -| | test_c005 | psa_destroy_key | Destroy a key and restore the slot to its default state. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. 2048 RSA public key | -| | | | | | 5. Import the key data into the key slot | 5. 2048 RSA keypair | -| | | | | | 6. Get basic metadata about a key | 6. DES 64 bit key | -| | | | | | 7. Destroy a key and restore the slot to its default state | 7. Triple DES 2-Key | -| | | | | | 8. Check that if the key metadata are destroyed | 8. Triple DES 3-Key | -| | | | | | | 9. EC Public key | -| | | | | | | 10. EC keypair | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid parameter should return this error | 1. Invalid key slot | -| | | | | | | 2. Zero key slot | -| | | | | | | 3. Empty key slot | -| | test_c006 | psa_get_key_information | Get basic metadata about a key. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. 2048 RSA public key | -| | | | | | 5. Import the key data into the key slot | 5. 2048 RSA keypair | -| | | | | | 6. Get basic metadata about a key | 6. DES 64 bit key | -| | | | | | | 7. Triple DES 2-Key | -| | | | | | | 8. Triple DES 3-Key | -| | | | | | | 9. EC Public key | -| | | | | | | 10. EC keypair | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid parameter should return this error | 1. Zero key slot | -| | | | | | | 2. Invalid key slot | -| | | | | PSA_ERROR_EMPTY_SLOT | Pass the key slot number which has the key type as none | Empty key slot | -| | NO TEST | psa_key_policy_set_usage | Set the standard fields of a policy structure. | void | Void function. Covered as part of other cases | | -| | | | | | | | -| Key Policies | test_c007 | psa_set_key_policy | Set the usage policy on a key slot. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. 2048 RSA public key | -| | | | | | 5. Import the key data into the key slot | 5. 2048 RSA keypair | -| | | | | | 6. Get the usage policy for a key slot | 6. DES 64 bit key | -| | | | | | 7. Check if the policy matches the original input | 7. Triple DES 2-Key | -| | | | | | | 8. Triple DES 3-Key | -| | | | | | | 9. EC Public key | -| | | | | | | 10. EC keypair | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid parameter should return this error | 1. Invalid key policy | -| | | | | | | 2. Zero key slot | -| | | | | | | 3. Invalid key slot | -| | | | | PSA_ERROR_OCCUPIED_SLOT | Pass the key slot to store data which is already occupied | Already occupied key slot | -| | test_c008 | psa_get_key_policy | Get the usage policy for a key slot | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | 2. 24 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte AES | -| | | | | | 4. Set the usage policy on a key slot | 4. 2048 RSA public key | -| | | | | | 5. Change the lifetime of a key slot | 5. 2048 RSA keypair | -| | | | | | 6. Import the key data into the key slot | 6. DES 64 bit key | -| | | | | | 7. Get the usage policy for a key slot | 7. Triple DES 2-Key | -| | | | | | 8. Retrieve the usage field of a policy structure | 8. Triple DES 3-Key | -| | | | | | 9. Retrieve the algorithm field of a policy structure | 9. EC Public key | -| | | | | | 10. Make sure they match the original value | 10. EC keypair | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid parameter should return this error | 1. Zero key slot | -| | | | | | | 2. Invalid key slot | -| | test_c009 | psa_allocate_key | Allocate a key slot for a transient key | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. Volatile keys | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | | -| | | | | | 3. Allocate a key slot for a transient key | | -| | | | | | | | -| | | | | | | | -| | | | | | | | -| | | | | | | | -| | | | | | | | -| | | | | PSA_ERROR_INSUFFICIENT_MEMORY | Calling this function with multiple time | | -| | | | | | | | -| | | | | | | | -| | test_c010 | psa_get_key_lifetime | Retrieve the lifetime of a key slot. | PSA_SUCCESS | 1. Initialize the PSA crypto library | Testing only volatile keys as other key types are currently not supported | -| | | | | | 2. Initialize a key policy structure to a default that forbids all usage of the key | | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Change the lifetime of a key slot | | -| | | | | | 6. Import the key data into the key slot | | -| | | | | | 7. Get the lifetime of a key slot | | -| | | | | PSA_ERROR_INVALID_HANDLE | | 1. Zero key slot | -| | | | | | | 2. Invalid key slot | -| | | | | | | 3. Empty key slot | -| | | | | PSA_ERROR_INVALID_ARGUMENT | | 1. Invalid key policy | -| Message Authentication Codes | test_c011 | psa_hash_start | Start a multipart hash operation. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. MD2 | -| | | | | | 2. Start a multipart hash operation | 2. MD4 | -| | | | | | | 3. MD5 | -| | | | | | | 4. RIPEMD160 | -| | | | | | | 5. SHA1 | -| | | | | | | 6. SHA224 | -| | | | | | | 7. SHA256 | -| | | | | | | 8. SHA512 | -| | | | | | | 9. SHA512_224 | -| | | | | | | 10. SHA512_256 | -| | | | | | | 11. SHA3_224 1 | -| | | | | | | 2. SHA3_256 1 | -| | | | | | | 3. SHA3_384 1 | -| | | | | | | 4. SHA3_512 | -| | | | | PSA_ERROR_NOT_SUPPORTED | Calling this function with unsupported algorithm should return error | Invalid hash algorithm | -| | test_c012 | psa_hash_update | Add a message fragment to a multipart hash operation. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. MD2 | -| | | | | | 2. Start a multipart hash operation | 2. MD4 | -| | | | | | 3. Add a message fragment to a multipart hash operation | 3. MD5 | -| | | | | | | 4. RIPEMD160 | -| | | | | | | 5. SHA1 | -| | | | | | | 6. SHA224 | -| | | | | | | 7. SHA256 | -| | | | | | | 8. SHA384 | -| | | | | | | 9. SHA512 | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function without calling the psa_hash_start() should return error | Inactive operation handle | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function with completed operation handle should return error | Completed operation handle | -| | test_c013 | psa_hash_verify | Finish the calculation of the hash of a message and compare it with an expected value. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. MD2 | -| | | | | | 2. Start a multipart hash operation | 2. MD4 | -| | | | | | 3. Add a message fragment to a multipart hash operation | 3. MD5 | -| | | | | | 4. Finish the calculation of the hash of a message and compare it with an expected value | 4. RIPEMD160 | -| | | | | | | 5. SHA1 | -| | | | | | | 6. SHA224 | -| | | | | | | 7. SHA256 | -| | | | | | | 8. SHA384 | -| | | | | | | 9. SHA512 | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function with inactive operation handle should return error | Inactive operation handle | -| | | | | PSA_ERROR_INVALID_SIGNATURE | Calling this function with incorrect expected value should return error | 1. Incorrect expected hash value | -| | | | | | | 2. Incorrect expected hash length | -| | test_c014 | psa_hash_finish | Finish the calculation of the hash of a message. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. MD2 | -| | | | | | 2. Start a multipart hash operation | 2. MD4 | -| | | | | | 3. Add a message fragment to a multipart hash operation | 3. MD5 | -| | | | | | 4. Finish the calculation of the hash of a message | 4. RIPEMD160 | -| | | | | | 5. Compare it with the expected value | 5. SHA1 | -| | | | | | | 6. SHA224 | -| | | | | | | 7. SHA256 | -| | | | | | | 8. SHA384 | -| | | | | | | 9. SHA512 | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function with an inactive operation handle should return error | Inactive operation handle | -| | | | | PSA_ERROR_BUFFER_TOO_SMALL | Calling this function with a hash buffer whose size is less than the algorithm output should return error | Buffer size less than required | -| | test_c015 | psa_hash_abort | Abort a hash operation. | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. MD2 | -| | | | | | 2. Start a multipart hash operation | 2. MD4 | -| | | | | | 3. Abort a hash operation | 3. MD5 | -| | | | | | | 4. RIPEMD160 | -| | | | | | | 5. SHA1 | -| | | | | | | 6. SHA224 | -| | | | | | | 7. SHA256 | -| | | | | | | 8. SHA384 | -| | | | | | | 9. SHA512 | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling psa_hash_finish after calling psa_hash_abort should return error | | -| Generator | test_c016 | psa_generate_key | Generate a key or key pair | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. AES | -| | | | | | 2. Initialize a key policy structure | 2. DES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. ECC | -| | | | | | 4. Set the usage policy on a key slot | 4. RSA | -| | | | | | 5. Generate a key or key pair | | -| | | | | | 6. Get basic metadata about a key | | -| | | | | | 7. Check if key type and key length matches | | -| | | | | | 8. Export a key in binary format | | -| | | | | | 9. Check if the metadata matches | | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid key slot should return this error | Invalid key slot | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with zero as key slot should return this error | Zero as key slot | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function with Null extra and Non-Zero extra size should return this error | Null extra and Non-Zero extra size | -| | | | | PSA_ERROR_OCCUPIED_SLOT | Calling this function with pre-occupied key slot should return this error | Pre-occupied key slot | -| | | | | PSA_ERROR_NOT_SUPPORTED | Calling this function to generate only public key should return this error | Key type as public key | -| | test_c017 | psa_generate_random | Generate random bytes | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte data | -| | | | | | 2. Generate random bytes | 2. 24 Byte data | -| | | | | | 3. Check that if generated data are Non-Zero | 3. 32 Byte data | -| | | | | | | 4. 64 Byte data | -| | | | | | | 5. 128 Byte data | -| | | | | | | 6. 256 Byte data | -| | | | | | | 7. 512 Byte data | -| | | | | | | 8. 1000 Byte data | -| | | | | | | 9. 1024 Byte data | -| | test_c018 | psa_generator_read | Read some data from a generator | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte key | -| | | | | | 2. Initialize a key policy structure | 2. 32 Byte key | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 8 Byte Key | -| | | | | | 4. Set the usage policy on a key slot | 4. SHA 256 | -| | | | | | 5. Import the key data into the key slot | 5. SHA 512 | -| | | | | | 6. Set up a key derivation operation | 6. SHA 1 | -| | | | | | 7. Generate random bytes | 7. Output size less than generator capacity | -| | | | | | 8. Check that if generated data are non-zero | 8. Output size equal to generator capacity | -| | | | | | 9. Generate random bytes for remaining capacity | 9. Request maximum capacity | -| | | | | | 10. Check that if generated data are non-zero | | -| | | | | | 11. Generate random bytes and check that it fails | | -| | | | | PSA_ERROR_INSUFFICIENT_CAPACITY | Calling this function with output size greater than the current capacity should return this error | output size greater than the current capacity | -| | | | | PSA_ERROR_INSUFFICIENT_CAPACITY | Calling this function with capacity greater than the allowed capacity should return this error | request maximum capacity +1 | -| | test_c019 | psa_generator_get_capacity | Retrieve the current capacity of a generator | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. Output size less than generator capacity | -| | | | | | 2. Initialize a key policy structure | 2. Output size equal to generator capacity | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Set up a key derivation operation | | -| | | | | | 7. Retrieve the current capacity of a generator | | -| | | | | | 8. Check that it is equal to the input capacity | | -| | | | | | 9. Generate random bytes | | -| | | | | | 10. Retrieve the current capacity of a generator | | -| | | | | | 11. Check that it is equal to the remaining capacity | | -| | test_c020 | psa_generator_import_key | Create a symmetric key from data read from a generator | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte AES | -| | | | | | 2. Initialize a key policy structure | 2. 32 Byte AES | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Set up a key derivation operation | | -| | | | | | 7. Initialize a key policy structure for new slot | | -| | | | | | 8. Set the standard fields of a policy structure | | -| | | | | | 9. Set the usage policy on a new key slot | | -| | | | | | 10. Create a symmetric key from data read from a generator | | -| | | | | | 11. Export a key in binary format | | -| | | | | | 12. Check that length of the key matches | | -| | | | | | 13. Check that the key is non-zero | | -| | | | | | 14. Initialize a key policy structure for new slot | | -| | | | | | 15. Set the standard fields of a policy structure | | -| | | | | | 16. Set the usage policy on a new key slot | | -| | | | | | 17. Create a symmetric key from data read from a generator for the remaining size | | -| | | | | | 18. Export a key in binary format | | -| | | | | | 19. Check that length of the key matches | | -| | | | | | 20. Check that the key is non-zero | | -| | | | | | 21. Initialize a key policy structure for new slot | | -| | | | | | 22. Set the standard fields of a policy structure | | -| | | | | | 23. Set the usage policy on a new key slot | | -| | | | | | 24. Create a symmetric key from data read from a generator for the some size | | -| | | | | | Check that it fails | | -| | | | | PSA_ERROR_INSUFFICIENT_CAPACITY | Calling this function with output greater than capacity should return this error | Output greater than capacity | -| | | | | PSA_ERROR_INVALID_ARGUMENT | Calling this function with public key algorithm should return this error | 1. RSA public key
2.Invalid key size | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this function with invalid arguments should return this error | 1. Invalid key slot | -| | | | | | | 2. Zero as key slot | -| | | | | | | | -| | | | | PSA_ERROR_OCCUPIED_SLOT | Calling this function with already occupied key slot should return this error | Pre-occupied key slot | -| | test_c021 | psa_generator_abort | Abort a generator | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. Abort | -| | | | | | 2. Initialize a key policy structure | 2. Multiple | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. Calling generator functions after abort should fail | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Set the key for a multipart symmetric encryption/decryption operation | | -| | | | | | 7. Abort a cipher operation | | -| | | | | | 8. Multiple abort cipher operation should return success | | -| Key derivation | test_c022 | psa_key_derivation | Set up a key derivation operation | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 16 Byte data with SHA-256 | -| | | | | | 2. Initialize a key policy structure | 2. 32 byte data with SHA-512 | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. 32 Byte data with MD-5 | -| | | | | | 4. Import the key data into the key slot | 4. Salt and label provided as input | -| | | | | | 5. Set up a key derivation operation | | -| | | | | | 6. Retrieve the current capacity of a generator | | -| | | | | | 7. Make sure that the capacity is same as input capacity | | -| | | | | PSA_INVALID_ARGUMENT | Calling this function with invalid argument should return this error | 1. Invalid algorithm 2. Unsupported generator capacity | -| | | | | | | 3. Unsupported key type | -| | | | | PSA_ERROR_INVALID_HANDLE | Calling this functoin wih incorrect key handle | 1. Invalid key handle
2. Zero as key slot | -| | | | | PSA_ERROR_EMPTY_SLOT | Calling this function with empty key slot should return this error | Empty key slot | -| Key policies | test_c023 | psa_key_policy_get_usage | Retrieve the usage field of a policy structure | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. Encrypt | -| | | | | | 2. Initialize a key policy structure | 2. Decrypt | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. Export | -| | | | | | 4. Retrieve the usage field of a policy structure | 4. Sign | -| | | | | | 5. Check that usage is same as input | 5. Verify | -| | | | | | | 6. Derive | -| AEAD | test_c024 | psa_aead_encrypt | Process an authenticated encryption operation | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. CCM - 16B AES - Nounce and additional data | -| | | | | | 2. Initialize a key policy structure | 2. GCM - 16B AES - NULL Nounce & addi data | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. GCM -16B AES - 12B Nounce & 12B addi data | -| | | | | | 4. Set the usage policy on a key slot | 4. CCM - 16B AES - 13B Nounce & 8B addi data | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Call aead encrypt | | -| | | | | | 7. Check if the status is expected | | -| | | | | | 8. Check if the cipher text is expected length | | -| | | | | PSA_ERROR_NOT_SUPPORTED | | 1. DES key | -| | | | | | | 2. Unsupported algorithm | -| | | | | PSA_ERROR_EMPTY_SLOT | | Empty key slot | -| | | | | PSA_ERROR_INVALID_HANDLE | | 1. Zero as key slot | -| | | | | | | 2. Invalid key slot | -| | | | | PSA_ERROR_NOT_PERMITTED | | 1. Small output buffer size | -| | | | | | | 2. Invalid key usage | -| | test_c025 | psa_aead_decrypt | Process an authenticated decryption operation | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. CCM - 16B AES - Nounce and additional data | -| | | | | | 2. Initialize a key policy structure | 2. GCM - 16B AES - NULL Nounce & addi data | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. GCM -16B AES - 12B Nounce & 12B addi data | -| | | | | | 4. Set the usage policy on a key slot | 4. CCM - 16B AES - 13B Nounce & 8B addi data | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Call aead decrypt | | -| | | | | | 7. Check if the status is expected | | -| | | | | | 8. Check if the plain text is expected length | | -| | | | | PSA_ERROR_NOT_SUPPORTED | | 1. DES key | -| | | | | | | 2. Unsupported algorithm | -| | | | | PSA_ERROR_EMPTY_SLOT | | Empty key slot | -| | | | | PSA_ERROR_INVALID_HANDLE | | 1. Zero as key slot | -| | | | | | | 2. Invalid key slot | -| | | | | PSA_ERROR_NOT_PERMITTED | | 1. Small output buffer size | -| | | | | | | 2. Invalid key usage | -| Message Authentication Codes | test_c026 | psa_mac_sign_setup | Start a multipart MAC calculation operation | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. 64 Byte HMAC | -| | | | | | 2. Initialize a key policy structure | 2. 16 Byte AES - CMAC | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Start a multipart MAC calculation operation | | -| | | | | PSA_ERROR_NOT_SUPPORTED | | 1. 16 Byte AES - GMAC | -| | | | | | | 2. Incompatible HMAC for CMAC | -| | | | | | | 3. Bad algorithm (unknown MAC algorithm)
2. Zero key slot | -| | | | | PSA_ERROR_NOT_PERMITTED | | Invalid usage | -| | | | | PSA_ERROR_EMPTY_SLOT | | Empty key slot | -| | test_c040 | psa_asymmetric_decrypt | Decrypt a short message with a private key | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. RSA KEYPAIR PKCS1V15 | -| | | | | | 2. Initialize a key policy structure | 2. RSA KEYPAIR OAEP SHA256 | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. RSA KEYPAIR OAEP SHA256 with label | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Decrypt a short message with a private key | | -| | | | | | 7. Check if the output length matches with the expected length | | -| | | | | | 8. Check if the output matches with the expected data | | -| | | | | PSA_ERROR_INVALID_ARGUMENT | | 1. Invalid key type (RSA public key) | -| | | | | | | 2. Invalid algorithm | -| | | | | | | 3. Invalid key type (AES Key) | -| | | | | PSA_ERROR_EMPTY_SLOT | | Empty key slot | -| | | | | PSA_ERROR_NOT_PERMITTED | | Invalid usage | -| | | | | PSA_ERROR_INVALID_HANDLE | | 1. Invalid key slot
2. Zero key slot | -| | | | | PSA_ERROR_BUFFER_TOO_SMALL | | Small output buffer | -| | test_c041 | psa_asymmetric_sign | Sign a hash or short message with a private key | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. RSA KEYPAIR PKCS1V15 RAW | -| | | | | | 2. Initialize a key policy structure | 2. RSA KEYPAIR PKCS1V15 SHA-256 | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. ECDSA KEYPAIR SECP256R1 SHA-256 | -| | | | | | 4. Set the usage policy on a key slot | | -| | | | | | 5. Import the key data into the key slot | | -| | | | | | 6. Sign a hash or short message with a private key | | -| | | | | | 7. Check if the output length matches with the expected length | | -| | | | | | 8. Check if the output matches with the expected data | | -| | | | | PSA_ERROR_INVALID_ARGUMENT | | 1. Invalid key type (RSA public key) | -| | | | | | | 2. Invalid algorithm | -| | | | | | | 3. Invalid key type (AES Key) | -| | | | | | | 4. Wrong hash size | -| | | | | PSA_ERROR_INVALID_HANDLE | | 1. Invalid key slot
2. Zero key slot | -| | | | | PSA_ERROR_EMPTY_SLOT | | Empty key slot | -| | | | | PSA_ERROR_NOT_PERMITTED | | Invalid usage | -| | | | | PSA_ERROR_BUFFER_TOO_SMALL | | Small output buffer | -| | test_c042 | psa_asymmetric_verify | Verify the signature a hash or short message using a public key | PSA_SUCCESS | 1. Initialize the PSA crypto library | 1. RSA KEYPAIR PKCS1V15 RAW | -| | | | | | 2. Initialize a key policy structure | 2. RSA KEYPAIR PKCS1V15 SHA-256 | -| | | | | | 3. Allocate a key slot for a transient key and set the standard fields of a policy structure | 3. ECDSA KEYPAIR SECP256R1 SHA-256 | -| | | | | | 4. Set the key data based on key type | 4. RSA public key | -| | | | | | 5. Set the usage policy on a key slot | 5. EC public key | -| | | | | | 6. Import the key data into the key slot | | -| | | | | | 7. Verify the signature a hash or short message using a public key | | -| | | | | PSA_ERROR_INVALID_ARGUMENT | | 1. Invalid algorithm | -| | | | | | | 2. Wrong hash size | -| | | | | PSA_ERROR_INVALID_HANDLE | | 1. Invalid key slot
2. Zero key slot | -| | | | | PSA_ERROR_INVALID_SIGNATURE | | Wrong signature size | -| | | | | | | Wrong signature | -| | | | | PSA_ERROR_EMPTY_SLOT | | Empty key slot | -| | | | | PSA_ERROR_NOT_PERMITTED | | Invalid usage | -| | | | | PSA_ERROR_NOT_SUPPORTED | | Invalid key type (AES Key) | -| | | | | PSA_ERROR_BUFFER_TOO_SMALL | | Small output buffer | - -## License -Arm PSA test suite is distributed under Apache v2.0 License. - --------------- - -*Copyright (c) 2018-2019, Arm Limited and Contributors. All rights reserved.* diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/main.c deleted file mode 100644 index d53cc88e8d..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c001(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c001, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.c deleted file mode 100644 index 0b334fcf74..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.c +++ /dev/null @@ -1,73 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c001.h" - -client_test_t test_c001_crypto_list[] = { - NULL, - psa_generate_random_without_init_test, - psa_crypto_init_test, - multiple_psa_crypto_init_test, - NULL, -}; - -int32_t psa_generate_random_without_init_test(security_t caller) -{ - uint8_t output[GENERATE_SIZE]; - int32_t status; - - val->print(PRINT_TEST, "[Check 1] Test calling crypto functions before psa_crypto_init\n", 0); - - /* Generate random bytes */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_RANDOM, output, GENERATE_SIZE); - if (status == PSA_SUCCESS) - return RESULT_SKIP(VAL_STATUS_INIT_ALREADY_DONE); - else - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(1)); - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_crypto_init_test(security_t caller) -{ - int32_t status; - - val->print(PRINT_TEST, "[Check 2] Test psa_crypto_init\n", 0); - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - return VAL_STATUS_SUCCESS; -} - -int32_t multiple_psa_crypto_init_test(security_t caller) -{ - int32_t i, status; - - val->print(PRINT_TEST, "[Check 3] Test multiple psa_crypto_init \n", 0); - for (i = 0; i < 5; i++) - { - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.h deleted file mode 100644 index 02a8c6b90a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_c001.h +++ /dev/null @@ -1,34 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C001_CLIENT_TESTS_H_ -#define _TEST_C001_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c001) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -#define GENERATE_SIZE 32 - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c001_crypto_list[]; - -int32_t psa_crypto_init_test(security_t caller); -int32_t multiple_psa_crypto_init_test(security_t caller); -int32_t psa_generate_random_without_init_test(security_t caller); -#endif /* _TEST_C001_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_entry.c deleted file mode 100644 index e1ba064ca0..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c001/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c001.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 1) -#define TEST_DESC "Testing psa_crypto_init API: Basic\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_LOW_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_client_tests_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c001_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/main.c deleted file mode 100644 index ca02c740fb..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c002(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c002, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.c deleted file mode 100644 index 19e1c44fc1..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.c +++ /dev/null @@ -1,217 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c002.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c002_crypto_list[] = { - NULL, - psa_import_key_test, - psa_import_key_negative_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_import_key_test(security_t caller) -{ - uint32_t length, i; - uint8_t data[BUFFER_SIZE]; - const uint8_t *key_data; - psa_key_policy_t policy; - psa_key_type_t key_type; - size_t bits; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - TEST_ASSERT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(8)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check1[i].key_handle, data, - BUFFER_SIZE, &length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - TEST_ASSERT_EQUAL(length, check1[i].expected_key_length, TEST_CHECKPOINT_NUM(10)); - - if (PSA_KEY_TYPE_IS_UNSTRUCTURED(check1[i].key_type)) - { - TEST_ASSERT_MEMCMP(data, check1[i].key_data, length, TEST_CHECKPOINT_NUM(11)); - } - else if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type) || PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - TEST_ASSERT_MEMCMP(key_data, data, length, TEST_CHECKPOINT_NUM(12)); - } - else - { - return VAL_STATUS_INVALID; - } - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_import_key_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_key_handle_t invalid_key_handle; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_import_key with already occupied key slot\n", - g_test_count++); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&invalid_key_handle, 0xDEADDEAD, sizeof(invalid_key_handle)); - /* Set the usage policy on a key slot */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the occupied key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_OCCUPIED_SLOT, TEST_CHECKPOINT_NUM(5)); - - val->print(PRINT_TEST, "[Check %d] Test psa_import_key with zero as key handle\n", - g_test_count++); - /* Import the key data with zero as key handle */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, 0, check2[i].key_type, - check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(6)); - - val->print(PRINT_TEST, "[Check %d] Test psa_import_key with destroyed handle\n", - g_test_count++); - /* Destroy the handle */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Import the key data with destroyed handle */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(8)); - - val->print(PRINT_TEST, "[Check %d] Test psa_import_key with unallocated key handle\n", - g_test_count++); - /* Import the key data with unallocated key handle */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, invalid_key_handle, check2[i].key_type, - check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(6)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.h deleted file mode 100644 index 4081d294fe..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_c002.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C002_CLIENT_TESTS_H_ -#define _TEST_C002_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c002) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c002_crypto_list[]; - -int32_t psa_import_key_test(security_t caller); -int32_t psa_import_key_negative_test(security_t caller); -#endif /* _TEST_C002_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_data.h deleted file mode 100644 index aaa6840baf..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_data.h +++ /dev/null @@ -1,299 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0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, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_import_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_import_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_import_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_import_key 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_import_key with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 1193, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_import_key with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_import_key with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_import_key with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_import_key with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_import_key with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 224, 28, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES -{"Test psa_import_key with key data greater than the algorithm size\n", 11, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_34B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_34B_KEY_SIZE), AES_34B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_import_key with incorrect key data size\n", 12, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90}, -AES_18B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, -BYTES_TO_BITS(AES_18B_KEY_SIZE), AES_18B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -{"Test psa_import_key with incorrect key type\n", 13, PSA_KEY_TYPE_VENDOR_FLAG, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, -AES_24B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, -BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_ERROR_NOT_SUPPORTED, -}, -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_import_key negative cases\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, -AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, -BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_OCCUPIED_SLOT -}, -#endif -#endif - -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_entry.c deleted file mode 100644 index 6f31df0d33..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c002/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c002.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 2) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c002_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/main.c deleted file mode 100644 index e30c469953..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c003(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c003, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.c deleted file mode 100644 index e25d80dd84..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.c +++ /dev/null @@ -1,220 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c003.h" -#include "test_data.h" - -client_test_t test_c003_crypto_list[] = { - NULL, - psa_export_key_test, - psa_export_key_negative_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_export_key_test(security_t caller) -{ - uint32_t length, i; - const uint8_t *key_data; - psa_key_policy_t policy; - psa_key_type_t key_type; - size_t bits; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - TEST_ASSERT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(8)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check1[i].key_handle, data, - check1[i].buffer_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(9)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - TEST_ASSERT_EQUAL(length, check1[i].expected_key_length, TEST_CHECKPOINT_NUM(10)); - - /* Check if original key data matches with the exported data */ - if (PSA_KEY_TYPE_IS_UNSTRUCTURED(check1[i].key_type)) - { - TEST_ASSERT_MEMCMP(check1[i].key_data, data, length, TEST_CHECKPOINT_NUM(11)); - } - else if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type) || PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - TEST_ASSERT_MEMCMP(key_data, data, length, TEST_CHECKPOINT_NUM(12)); - } - else - { - return VAL_STATUS_INVALID; - } - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_export_key_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - uint32_t i, length; - int32_t status; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with unallocated key handle\n", - g_test_count++); - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check2[i].key_handle, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check2[i].key_handle, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(5)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with zero as key handle\n", - g_test_count++); - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, 0, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(6)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with destroyed key handle\n", - g_test_count++); - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Destroy the key handle */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check2[i].key_handle, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.h deleted file mode 100644 index 4d8a4d6c98..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_c003.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C003_CLIENT_TESTS_H_ -#define _TEST_C003_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c003) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c003_crypto_list[]; - -int32_t psa_export_key_test(security_t caller); -int32_t psa_export_key_negative_test(security_t caller); -#endif /* _TEST_C003_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_data.h deleted file mode 100644 index c5832c7d82..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_data.h +++ /dev/null @@ -1,289 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - size_t buffer_size; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 0xDA, - 0xAC, 0x1B, 0x53, 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f3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_export_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_export_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_export_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_export_key 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, BUFFER_SIZE, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_export_key with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, BUFFER_SIZE, - 2048, 1193, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_export_key with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_export_key with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_export_key with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_export_key with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, BUFFER_SIZE, - 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_export_key with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, BUFFER_SIZE, - 224, 28, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_export_key with key policy verify\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_NOT_PERMITTED -}, - -{"Test psa_export_key with less buffer size\n", 12, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, 14, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_export_key negative case\n", 13, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_entry.c deleted file mode 100644 index 8b501599f2..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c003/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c003.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 3) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c003_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/main.c deleted file mode 100644 index 448b4c1632..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c004(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c004, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.c deleted file mode 100644 index fceade54b4..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.c +++ /dev/null @@ -1,258 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c004.h" -#include "test_data.h" - -client_test_t test_c004_crypto_list[] = { - NULL, - test_psa_export_public_key, - test_psa_export_public_key_handle, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t test_psa_export_public_key(security_t caller) -{ - uint32_t length, i; - const uint8_t *key_data; - psa_key_policy_t policy; - psa_key_type_t key_type; - size_t bits; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - TEST_ASSERT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(8)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_PUBLIC_KEY, check1[i].key_handle, data, - check1[i].buffer_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(9)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - TEST_ASSERT_EQUAL(length, check1[i].expected_key_length, TEST_CHECKPOINT_NUM(10)); - - /* Check if original key data matches with the exported data */ - if (PSA_KEY_TYPE_IS_UNSTRUCTURED(check1[i].key_type)) - { - TEST_ASSERT_MEMCMP(check1[i].key_data, data, length, TEST_CHECKPOINT_NUM(11)); - } - else if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type) || PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - key_data = expected_rsa_256_pubprv; - - else if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = expected_ec_pubprv; - - TEST_ASSERT_MEMCMP(key_data, data, length, TEST_CHECKPOINT_NUM(12)); - } - else - { - return VAL_STATUS_INVALID; - } - } - - return VAL_STATUS_SUCCESS; - -} - -int32_t test_psa_export_public_key_handle(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - uint32_t i, length; - int32_t status; - const uint8_t *key_data; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with unallocated key handle\n", - g_test_count++); - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_PUBLIC_KEY, check2[i].key_handle, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_PUBLIC_KEY, check2[i].key_handle, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(5)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with zero as key handle\n", - g_test_count++); - status = val->crypto_function(VAL_CRYPTO_EXPORT_PUBLIC_KEY, 0, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(6)); - - val->print(PRINT_TEST, "[Check %d] Test psa_export_key with destroyed key handle\n", - g_test_count++); - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - if (PSA_KEY_TYPE_IS_RSA(check2[i].key_type)) - { - if (check2[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check2[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check2[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check2[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check2[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check2[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check2[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check2[i].key_data; - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle, - check2[i].key_type, key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Destroy the key handle */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_PUBLIC_KEY, check2[i].key_handle, data, - check2[i].key_length, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.h deleted file mode 100644 index c24ec82b4f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_c004.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C004_CLIENT_TESTS_H_ -#define _TEST_C004_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c004) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c004_crypto_list[]; - -int32_t test_psa_export_public_key(security_t caller); -int32_t test_psa_export_public_key_handle(security_t caller); -#endif /* _TEST_C004_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_data.h deleted file mode 100644 index 66dae2a2b5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_data.h +++ /dev/null @@ -1,312 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - size_t buffer_size; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t expected_rsa_256_pubprv[] = { -0x30, 0x82, -0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, 0x95, 0x08, 0xE1, 0x57, 0x41, -0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, 0x01, 0x65, 0xC6, 0x45, 0xAE, -0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, 0x4E, 0xD6, 0xF6, 0x1C, 0x88, -0xBC, 0x7C, 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0x25, 0xC9, 0x6A, 0x0D, 0xC3, 0x39, 0x60, 0xA4, 0xB4, 0xB0, 0x69, -0x42, 0x42, 0x09, 0xE9, 0xD8, 0x08, 0xBC, 0x33, 0x20, 0xB3, 0x58, 0x22, 0xA7, -0xAA, 0xEB, 0xC4, 0xE1, 0xE6, 0x61, 0x83, 0xC5, 0xD2, 0x96, 0xDF, 0xD9, 0xD0, -0x4F, 0xAD, 0xD7, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t expected_ec_pubprv[] = { -0x04, 0x16, 0x93, 0xa2, 0x90, 0xf7, 0xf0, 0xb5, 0x71, 0xfe, 0x2b, 0x41, 0xd5, -0xd8, 0x4b, 0x01, 0x32, 0x76, 0x31, 0xf4, 0xa8, 0x60, 0xf9, 0x95, 0xfa, 0x33, -0x2c, 0x09, 0x7f, 0x54, 0x19, 0x2b, 0xb1, 0x0f, 0x00, 0x11, 0x3f, 0x2a, 0xff, -0xb1, 0x3c, 0x1a, 0x24, 0xce, 0x44, 0x91, 0x45, 0x71, 0xa9, 0x54, 0x40, 0xae, -0x01, 0x4a, 0x00, 0xcb, 0xf7}; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17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x01, 0x16, 0x59, 0x7E, 0x1C, 0x17, 0xC3, 0x53, - 0xFD, 0xD1, 0x72, 0xCB, 0x4C, 0x60, 0x15, 0xDA, 0x7D, 0xE2, 0xEA, 0xAD, 0x50, 0xEF, - 0x8E, 0xE2, 0x8B, 0xD4, 0x6A, 0x77, 0x55, 0xD6, 0x70, 0xD9, 0x6B, 0xBB, 0xF1, 0xEE, - 0x39, 0x04, 0x38, 0xA3, 0xBD, 0xE2, 0xD1, 0xE0, 0x66, 0x6B, 0xE2, 0x9C, 0x47, 0x99, - 0xE9, 0x28, 0xE6, 0xB6, 0xFC, 0x2E, 0xCA, 0x67, 0x43, 0x84, 0xE8, 0xD5, 0x83, 0xD6, - 0x9D, 0x98, 0x6B, 0x01, 0x3E, 0x81, 0xDC, 0x3C, 0x7A, 0xCA, 0xF9, 0xF3, 0x9C, 0xF7, - 0xD6, 0x28, 0x1B, 0x27, 0x78, 0x7C, 0xC3, 0xD0, 0xD5, 0x63, 0xA7, 0x81, 0x34, 0x89, - 0xAD, 0x25, 0x6A, 0xBD, 0xF2, 0xEA, 0xED, 0xFA, 0x57, 0xFC, 0xE5, 0x34, 0xC6, 0xC1, - 0x0F, 0x71, 0x2D, 0xD2, 0x08, 0x10, 0x1B, 0xAD, 0x44, 0x41, 0xE0, 0xFE, 0x79, 0xA0, - 0x63, 0x93, 0x8A, 0xB1, 0x5D, 0xE9, 0xB0, 0xEE, 0x6F, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t ec_keydata[] = { - 0x04, 0xde, 0xa5, 0xe4, 0x5d, 0x0e, 0xa3, 0x7f, 0xc5, 0x66, 0x23, 0x2a, 0x50, 0x8f, - 0x4a, 0xd2, 0x0e, 0xa1, 0x3d, 0x47, 0xe4, 0xbf, 0x5f, 0xa4, 0xd5, 0x4a, 0x57, 0xa0, - 0xba, 0x01, 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, - 0x24, 0xa5, 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_export_public_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_export_public_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_export_public_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_export_public_key 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, BUFFER_SIZE, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_export_public_key with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, BUFFER_SIZE, - 2048, 270, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_export_public_key with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_export_public_key with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_export_public_key with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, BUFFER_SIZE, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_export_public_key with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, BUFFER_SIZE, - 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_export_public_key with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, BUFFER_SIZE, - 224, 57, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA -{"Test psa_export_public_key with less buffer size\n", 12, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, -270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, 200, -2048, 270, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA -{"Test psa_export_public_key negative case\n", 13, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, BUFFER_SIZE, - 2048, 270, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_entry.c deleted file mode 100644 index 7b8fdc9277..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c004/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c004.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 4) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c004_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/main.c deleted file mode 100644 index 82aba84607..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c005(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c005, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.c deleted file mode 100644 index f58819291f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.c +++ /dev/null @@ -1,182 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c005.h" -#include "test_data.h" - -client_test_t test_c005_crypto_list[] = { - NULL, - psa_destroy_key_test, - psa_destroy_invalid_key_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_destroy_key_test(security_t caller) -{ - uint32_t i; - const uint8_t *key_data; - psa_key_policy_t policy; - psa_key_type_t key_type; - size_t bits; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - key_type = 0; - bits = 0; - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get basic metadata about a key */ - TEST_ASSERT_EQUAL(val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits), - PSA_SUCCESS, - TEST_CHECKPOINT_NUM(6)); - - TEST_ASSERT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(8)); - - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check1[i].key_handle); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(9)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(10)); - - /* Check that if the key metadata are destroyed */ - TEST_ASSERT_NOT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(11)); - TEST_ASSERT_NOT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(12)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_destroy_invalid_key_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_destroy_key with unallocated key handle\n", - g_test_count++); - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_destroy_key with zero as key handle\n", - g_test_count++); - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, 0); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - val->print(PRINT_TEST, "[Check %d] Test psa_destroy_key with empty key handle\n", - g_test_count++); - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.h deleted file mode 100644 index d191aede39..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_c005.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C005_CLIENT_TESTS_H_ -#define _TEST_C005_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c005) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c005_crypto_list[]; - -int32_t psa_destroy_key_test(security_t caller); -int32_t psa_destroy_invalid_key_test(security_t caller); -#endif /* _TEST_C005_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_data.h deleted file mode 100644 index bab27f248c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_data.h +++ /dev/null @@ -1,274 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 0xDA, - 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 0x19, 0x0D, 0x25, 0x4F, 0xE1, 0x63, - 0x63, 0x51, 0x8B, 0x0B, 0x64, 0x3F, 0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, - 0xB3, 0xAE, 0x00, 0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68, 0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 0x2E, 0xCA, 0x67, 0x43, 0x84, 0xE8, 0xD5, 0x83, 0xD6, - 0x9D, 0x98, 0x6B, 0x01, 0x3E, 0x81, 0xDC, 0x3C, 0x7A, 0xCA, 0xF9, 0xF3, 0x9C, 0xF7, - 0xD6, 0x28, 0x1B, 0x27, 0x78, 0x7C, 0xC3, 0xD0, 0xD5, 0x63, 0xA7, 0x81, 0x34, 0x89, - 0xAD, 0x25, 0x6A, 0xBD, 0xF2, 0xEA, 0xED, 0xFA, 0x57, 0xFC, 0xE5, 0x34, 0xC6, 0xC1, - 0x0F, 0x71, 0x2D, 0xD2, 0x08, 0x10, 0x1B, 0xAD, 0x44, 0x41, 0xE0, 0xFE, 0x79, 0xA0, - 0x63, 0x93, 0x8A, 0xB1, 0x5D, 0xE9, 0xB0, 0xEE, 0x6F, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t ec_keydata[] = { - 0x04, 0xde, 0xa5, 0xe4, 0x5d, 0x0e, 0xa3, 0x7f, 0xc5, 0x66, 0x23, 0x2a, 0x50, 0x8f, - 0x4a, 0xd2, 0x0e, 0xa1, 0x3d, 0x47, 0xe4, 0xbf, 0x5f, 0xa4, 0xd5, 0x4a, 0x57, 0xa0, - 0xba, 0x01, 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, - 0x24, 0xa5, 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_destroy_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_destroy_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_destroy_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_destroy_key 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_destroy_key with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 1193, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_destroy_key with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_destroy_key with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_destroy_key with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_destroy_key with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 256, 65, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_destroy_key with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, - 224, 28, PSA_SUCCESS -}, -#endif -#endif -}; - - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_destroy_key negative case\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_entry.c deleted file mode 100644 index 9559f136c5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c005/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c005.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 5) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c005_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/main.c deleted file mode 100644 index 32d951a318..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c006(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c006, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.c deleted file mode 100644 index ca6d5258be..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.c +++ /dev/null @@ -1,178 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c006.h" -#include "test_data.h" - -client_test_t test_c006_crypto_list[] = { - NULL, - psa_get_key_information_test, - psa_get_key_information_invalid_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_get_key_information_test(security_t caller) -{ - int32_t i, status; - const uint8_t *key_data; - psa_key_policy_t policy; - psa_key_type_t key_type; - size_t bits; - int num_checks = sizeof(check1)/sizeof(check1[0]); - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - TEST_ASSERT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_get_key_information_invalid_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_information with unallocated" - " key handle\n", g_test_count++); - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check2[i].key_handle, - &check2[i].key_type, &check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_information with zero as" - " key handle\n", g_test_count++); - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, 0, - &check2[i].key_type, &check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_information with empty key handle\n", - g_test_count++); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check2[i].key_handle, - &check2[i].key_type, &check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(6)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_information with destroyed" - " key handle\n", g_test_count++); - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check2[i].key_handle, - &check2[i].key_type, &check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(8)); - - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.h deleted file mode 100644 index f8d834bffd..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_c006.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C006_CLIENT_TESTS_H_ -#define _TEST_C006_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c006) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c006_crypto_list[]; - -int32_t psa_get_key_information_test(security_t caller); -int32_t psa_get_key_information_invalid_test(security_t caller); -#endif /* _TEST_C006_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_data.h deleted file mode 100644 index e4ae077430..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_data.h +++ /dev/null @@ -1,273 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA,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 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_get_key_information 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_get_key_information 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_get_key_information 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_get_key_information 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_get_key_information with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_EXPORT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 1193, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_get_key_information with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_get_key_information with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_get_key_information with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_get_key_information with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_get_key_information with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 224, 28, PSA_SUCCESS -}, -#endif -#endif -}; - - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_get_key_information negative cases\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_entry.c deleted file mode 100644 index 983ee819d1..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c006/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c006.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 6) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c006_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/main.c deleted file mode 100644 index ff4047dfea..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c007(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c007, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.c deleted file mode 100644 index 82a77c2778..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.c +++ /dev/null @@ -1,188 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c007.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c007_crypto_list[] = { - NULL, - psa_set_key_policy_test, - psa_set_key_policy_negative_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_set_key_policy_test(security_t caller) -{ - const uint8_t *key_data; - psa_key_policy_t policy, expected_policy; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(4)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get the usage policy for a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_POLICY, check1[i].key_handle, - &expected_policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Check if the usage is same as programmed */ - TEST_ASSERT_EQUAL(expected_policy.usage, check1[i].usage, TEST_CHECKPOINT_NUM(7)); - - /* Check if the algorithm is same as programmed */ - TEST_ASSERT_EQUAL(expected_policy.alg, check1[i].key_alg, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_set_key_policy_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_set_key_policy with unallocated key handle\n", - g_test_count++); - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the usage policy on a key slot */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_set_key_policy with zero as key handle\n", - g_test_count++); - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, 0, &policy); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the usage policy on a key slot */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - val->print(PRINT_TEST, "[Check %d] Test psa_set_key_policy with already occupied handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_ERROR_OCCUPIED_SLOT, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.h deleted file mode 100644 index ee5635f061..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_c007.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C007_CLIENT_TESTS_H_ -#define _TEST_C007_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c007) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c007_crypto_list[]; - -int32_t psa_set_key_policy_test(security_t caller); -int32_t psa_set_key_policy_negative_test(security_t caller); -#endif /* _TEST_C007_CLIENT_TESTS_H_ */ - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_data.h deleted file mode 100644 index 183c3b56f8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_data.h +++ /dev/null @@ -1,285 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 0xDA, - 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 0x19, 0x0D, 0x25, 0x4F, 0xE1, 0x63, - 0x63, 0x51, 0x8B, 0x0B, 0x64, 0x3F, 0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, - 0xB3, 0xAE, 0x00, 0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68, 0x78, 0x73, - 0xA6, 0x8C, 0x18, 0xA9, 0x02, 0x6D, 0xAF, 0xC3, 0x19, 0x01, 0x2E, 0xB8, 0x10, - 0xE3, 0xC6, 0xCC, 0x40, 0xB4, 0x69, 0xA3, 0x46, 0x33, 0x69, 0x87, 0x6E, 0xC4, - 0xBB, 0x17, 0xA6, 0xF3, 0xE8, 0xDD, 0xAD, 0x73, 0xBC, 0x7B, 0x2F, 0x21, 0xB5, - 0xFD, 0x66, 0x51,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xED, 0xFA, 0x57, 0xFC, 0xE5, 0x34, 0xC6, 0xC1, - 0x0F, 0x71, 0x2D, 0xD2, 0x08, 0x10, 0x1B, 0xAD, 0x44, 0x41, 0xE0, 0xFE, 0x79, 0xA0, - 0x63, 0x93, 0x8A, 0xB1, 0x5D, 0xE9, 0xB0, 0xEE, 0x6F, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t ec_keydata[] = { - 0x04, 0xde, 0xa5, 0xe4, 0x5d, 0x0e, 0xa3, 0x7f, 0xc5, 0x66, 0x23, 0x2a, 0x50, 0x8f, - 0x4a, 0xd2, 0x0e, 0xa1, 0x3d, 0x47, 0xe4, 0xbf, 0x5f, 0xa4, 0xd5, 0x4a, 0x57, 0xa0, - 0xba, 0x01, 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, - 0x24, 0xa5, 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_set_key_policy 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_set_key_policy 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_set_key_policy 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_set_key_policy 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_set_key_policy with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 1193, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_set_key_policy with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_set_key_policy with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_set_key_policy with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_set_key_policy with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_set_key_policy with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 224, 28, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_set_key_policy with invalid usage\n", 13, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, -AES_16B_KEY_SIZE, PSA_KEY_USAGE_INVALID, PSA_ALG_CTR, -BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; - - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_set_key_policy negative case\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, -AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, -BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_OCCUPIED_SLOT -}, -#endif -#endif - -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_entry.c deleted file mode 100644 index c1fbe5381e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c007/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c007.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 7) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c007_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/main.c deleted file mode 100644 index 8c0aaf52c7..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c008(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c008, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.c deleted file mode 100644 index 05ce0f8126..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.c +++ /dev/null @@ -1,181 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c008.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c008_crypto_list[] = { - NULL, - psa_get_key_policy_test, - psa_get_key_policy_negative_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_get_key_policy_test(security_t caller) -{ - const uint8_t *key_data; - psa_key_policy_t policy, expected_policy; - psa_key_usage_t expected_usage; - psa_algorithm_t expected_alg; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get the usage policy for a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_POLICY, check1[i].key_handle, - &expected_policy); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - TEST_ASSERT_EQUAL(expected_policy.usage, check1[i].usage, TEST_CHECKPOINT_NUM(7)); - TEST_ASSERT_EQUAL(expected_policy.alg, check1[i].key_alg, TEST_CHECKPOINT_NUM(8)); - - /* Retrieve the usage field of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_GET_USAGE, &policy, &expected_usage); - - /* Retrieve the algorithm field of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_GET_ALGORITHM, &policy, &expected_alg); - - TEST_ASSERT_EQUAL(expected_usage, check1[i].usage, TEST_CHECKPOINT_NUM(9)); - TEST_ASSERT_EQUAL(expected_alg, check1[i].key_alg, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_get_key_policy_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check2[i].test_desc, 0); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_policy with unallocated key handle\n", - g_test_count++); - /* Get the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_policy with zero as key handle\n", - g_test_count++); - /* Get the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_POLICY, 0, &policy); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_policy with empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.h deleted file mode 100644 index a67628dbbe..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_c008.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C008_CLIENT_TESTS_H_ -#define _TEST_C008_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c008) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c008_crypto_list[]; - -int32_t psa_get_key_policy_test(security_t caller); -int32_t psa_get_key_policy_negative_test(security_t caller); -#endif /* _TEST_C008_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_data.h deleted file mode 100644 index 90a9d91bad..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_data.h +++ /dev/null @@ -1,272 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA,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 0xa0, - 0xba, 0x01, 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, - 0x24, 0xa5, 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_get_key_policy 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_get_key_policy 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_get_key_policy 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_get_key_policy 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 270, PSA_SUCCESS -}, - -{"Test psa_get_key_policy with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, 1193, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_get_key_policy with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_get_key_policy with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_get_key_policy with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_get_key_policy with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_get_key_policy with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_ECDSA_ANY, - 224, 28, PSA_SUCCESS -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_get_key_policy negative cases\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_entry.c deleted file mode 100644 index 59f3a24af4..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c008/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c008.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 8) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c008_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/main.c deleted file mode 100644 index 4ad093b4f2..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c009(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c009, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.c deleted file mode 100644 index aa4af1525c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.c +++ /dev/null @@ -1,85 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c009.h" -#include "test_data.h" -#include "val_crypto.h" - -#define MAX_KEYS 100 - -client_test_t test_c009_crypto_list[] = { - NULL, - psa_allocate_key_test, - psa_allocate_key_negative_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_allocate_key_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(3)); - - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_allocate_key_negative_test(security_t caller) -{ - int32_t i, status; - psa_key_handle_t key_handle[MAX_KEYS]; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] Testing the insufficient memory\n", g_test_count++); - - for (i = 0; i < MAX_KEYS; i++) - { - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &key_handle[i]); - if (status != PSA_SUCCESS) - break; - } - - TEST_ASSERT_EQUAL(status, PSA_ERROR_INSUFFICIENT_MEMORY, TEST_CHECKPOINT_NUM(2)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.h deleted file mode 100644 index f5e758ba78..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_c009.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C009_CLIENT_TESTS_H_ -#define _TEST_C009_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c009) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c009_crypto_list[]; - -int32_t psa_allocate_key_test(security_t caller); -int32_t psa_allocate_key_negative_test(security_t caller); -#endif /* _TEST_C009_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_data.h deleted file mode 100644 index 4a85986489..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_data.h +++ /dev/null @@ -1,86 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - size_t key_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_AES_128 -{"Test psa_allocate_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, - AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_allocate_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, - AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_allocate_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, - AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_allocate_key 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - 294, PSA_SUCCESS -}, - -{"Test psa_allocate_key with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - 1193, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_allocate_key with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_allocate_key with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, - DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_allocate_key with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, - DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP192R1 -{"Test psa_allocate_key with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | PSA_ECC_CURVE_SECP192R1, - 75, PSA_SUCCESS -}, - -{"Test psa_allocate_key with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR_BASE | PSA_ECC_CURVE_SECP192R1, - 97, PSA_SUCCESS -}, -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_entry.c deleted file mode 100644 index 93a0abe180..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c009/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c009.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 9) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c009_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/main.c deleted file mode 100644 index 57bdac9050..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c010(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c010, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.c deleted file mode 100644 index 24e335ec39..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.c +++ /dev/null @@ -1,168 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c010.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c010_crypto_list[] = { - NULL, - psa_get_key_lifetime_test, - psa_get_key_lifetime_negative_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_get_key_lifetime_test(security_t caller) -{ - const uint8_t *key_data; - psa_key_policy_t policy; - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_lifetime_t lifetime; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Set the key data buffer to the input base on algorithm */ - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Get the lifetime of a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_LIFETIME, check1[i].key_handle, &lifetime); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - TEST_ASSERT_EQUAL(lifetime, check1[i].lifetime, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_get_key_lifetime_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_lifetime_t lifetime; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_lifetime with invalid key handle\n", - g_test_count++); - /* Get the lifetime of a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_LIFETIME, check2[i].key_handle, &lifetime); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_lifetime with zero as key handle\n", - g_test_count++); - /* Get the lifetime of a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_LIFETIME, 0, &lifetime); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_get_key_lifetime with empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Get the lifetime of a key slot */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_LIFETIME, check2[i].key_handle, &lifetime); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.h deleted file mode 100644 index 03308e8a23..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_c010.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C010_CLIENT_TESTS_H_ -#define _TEST_C010_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c010) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c010_crypto_list[]; - -int32_t psa_get_key_lifetime_test(security_t caller); -int32_t psa_get_key_lifetime_negative_test(security_t caller); -#endif /* _TEST_C010_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_data.h deleted file mode 100644 index e8c7b2da18..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_data.h +++ /dev/null @@ -1,275 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[34]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_key_lifetime_t lifetime; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 0xDA, - 0xAC, 0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54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_get_key_lifetime 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - PSA_KEY_LIFETIME_VOLATILE, BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef NO_SUPPORT -/* PSA crypto doesn't support these test scenarios */ -{"Test psa_get_key_lifetime 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, - AES_24B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, - PSA_KEY_LIFETIME_PERSISTENT, BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, - -{"Test psa_get_key_lifetime 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, - PSA_KEY_LIFETIME_WRITE_ONCE, BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_get_key_lifetime 2048 RSA public key\n", 4, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - {0}, - 270, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - PSA_KEY_LIFETIME_VOLATILE, 2048, 270, PSA_SUCCESS -}, -#endif -#endif - -#ifdef NO_SUPPORT -/* PSA crypto doesn't support these test scenarios */ -{"Test psa_get_key_lifetime with RSA 2048 keypair\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, - {0}, - 1193, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - PSA_KEY_LIFETIME_PERSISTENT, 2048, 1193, PSA_SUCCESS -}, - -{"Test psa_get_key_lifetime with DES 64 bit key\n", 6, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - PSA_KEY_LIFETIME_WRITE_ONCE, BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_get_key_lifetime with Triple DES 2-Key\n", 7, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - PSA_KEY_LIFETIME_VOLATILE, BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef NO_SUPPORT -/* PSA crypto doesn't support these test scenarios */ -{"Test psa_get_key_lifetime with Triple DES 3-Key\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - PSA_KEY_LIFETIME_PERSISTENT, BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_get_key_lifetime with EC Public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), - {0}, - 65, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, - PSA_KEY_LIFETIME_VOLATILE, 256, 65, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_get_key_lifetime with EC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - {0}, - 28, PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, - PSA_KEY_LIFETIME_VOLATILE, 224, 28, PSA_SUCCESS -}, -#endif -#endif - -}; - - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_get_key_lifetime with negative cases\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, PSA_KEY_LIFETIME_VOLATILE, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_entry.c deleted file mode 100644 index 23012e9f73..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c010/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c010.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 10) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c010_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/main.c deleted file mode 100644 index 6f87397f8e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c011(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c011, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.c deleted file mode 100644 index 7e4b4dffa8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.c +++ /dev/null @@ -1,62 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c011.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c011_crypto_list[] = { - NULL, - psa_hash_setup_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_hash_setup_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_hash_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, check1[i].alg); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(3)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.h deleted file mode 100644 index 3b334449a3..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_c011.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C011_CLIENT_TESTS_H_ -#define _TEST_C011_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c011) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c011_crypto_list[]; - -int32_t psa_hash_setup_test(security_t caller); -int32_t psa_get_key_lifetime_negative_test(security_t caller); -#endif /* _TEST_C011_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_data.h deleted file mode 100644 index fab7bd59f2..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_data.h +++ /dev/null @@ -1,120 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[50]; - psa_algorithm_t alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_MD2 -{"Test psa_hash_setup with MD2 algorithm\n", - PSA_ALG_MD2, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD4 -{"Test psa_hash_setup with MD4 algorithm\n", - PSA_ALG_MD4, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD5 -{"Test psa_hash_setup with MD5 algorithm\n", - PSA_ALG_MD5, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_RIPEMD160 -{"Test psa_hash_setup with RIPEMD160 algorithm\n", - PSA_ALG_RIPEMD160, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA1 -{"Test psa_hash_setup with SHA1 algorithm\n", - PSA_ALG_SHA_1, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_hash_setup with SHA224 algorithm\n", - PSA_ALG_SHA_224, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_hash_setup with SHA256 algorithm\n", - PSA_ALG_SHA_256, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA384 -{"Test psa_hash_setup with SHA384 algorithm\n", - PSA_ALG_SHA_384, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_hash_setup with SHA512 algorithm\n", - PSA_ALG_SHA_512, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512_224 -{"Test psa_hash_setup with SHA512_224 algorithm\n", - PSA_ALG_SHA_512_224, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512_256 -{"Test psa_hash_setup with SHA512_256 algorithm\n", - PSA_ALG_SHA_512_256, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA3_224 -{"Test psa_hash_setup with SHA3_224 algorithm\n", - PSA_ALG_SHA3_224, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA3_256 -{"Test psa_hash_setup with SHA3_256 algorithm\n", - PSA_ALG_SHA3_256, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA3_384 -{"Test psa_hash_setup with SHA3_384 algorithm\n", - PSA_ALG_SHA3_384, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA3_512 -{"Test psa_hash_setup with SHA3_512 algorithm\n", - PSA_ALG_SHA3_512, PSA_SUCCESS, -}, -#endif - -{"Test psa_hash_setup with Invalid algorithm\n", - PSA_ALG_INVALID, PSA_ERROR_INVALID_ARGUMENT, -}, -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_entry.c deleted file mode 100644 index 33d5730d37..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c011/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c011.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 11) -#define TEST_DESC "Testing crypto hash functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c011_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/main.c deleted file mode 100644 index 58954b7293..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" -#include "unity/unity.h" - -void test_entry_c012(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c012, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.c deleted file mode 100644 index 5a3181cb99..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.c +++ /dev/null @@ -1,148 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c012.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c012_crypto_list[] = { - NULL, - psa_hash_update_test, - psa_hash_update_invalid_handle, - psa_hash_update_with_completed_handle, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_hash_update_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_hash_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, check1[i].alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, - check1[i].input, check1[i].input_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(4)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_hash_update_invalid_handle(security_t caller) -{ - psa_hash_operation_t operation; - uint8_t input[] = "Hello World"; - size_t input_length = sizeof(input)/sizeof(input[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "Test psa_hash_update without hash setup\n", 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, input, input_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(3)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_hash_update_with_completed_handle(security_t caller) -{ - psa_hash_operation_t operation; - uint8_t input[] = {0xbd}; - size_t input_length = sizeof(input)/sizeof(input[0]); - psa_algorithm_t alg = PSA_ALG_SHA_256; - uint8_t hash[] = {0x68, 0x32, 0x57, 0x20, 0xAA, 0xBD, 0x7C, 0x82, 0xF3, 0x0F, - 0x55, 0x4B, 0x31, 0x3D, 0x05, 0x70, 0xC9, 0x5A, 0xCC, 0xBB, - 0x7D, 0xC4, 0xB5, 0xAA, 0xE1, 0x12, 0x04, 0xC0, 0x8F, 0xFE, - 0x73, 0x2B}; - size_t hash_length = sizeof(hash)/sizeof(hash[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "Test psa_hash_update with completed opertaion handle \n", 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, - input, input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Finish the calculation of the hash of a message and compare it with an expected value*/ - status = val->crypto_function(VAL_CRYPTO_HASH_VERIFY, &operation, hash, hash_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, input, input_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(6)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.h deleted file mode 100644 index ca3622033b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_c012.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C012_CLIENT_TESTS_H_ -#define _TEST_C012_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c012) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c012_crypto_list[]; - -int32_t psa_hash_update_test(security_t caller); -int32_t psa_hash_update_invalid_handle(security_t caller); -int32_t psa_hash_update_with_completed_handle(security_t caller); -#endif /* _TEST_C012_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_data.h deleted file mode 100644 index f5c4f5213c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_data.h +++ /dev/null @@ -1,82 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[50]; - psa_algorithm_t alg; - char input[15]; - size_t input_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_MD2 -{"Test psa_hash_update with MD2 algorithm\n", - PSA_ALG_MD2, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD4 -{"Test psa_hash_update with MD4 algorithm\n", - PSA_ALG_MD4, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD5 -{"Test psa_hash_update with MD5 algorithm\n", - PSA_ALG_MD5, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_RIPEMD160 -{"Test psa_hash_update with RIPEMD160 algorithm\n", - PSA_ALG_RIPEMD160, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA1 -{"Test psa_hash_update with SHA1 algorithm\n", - PSA_ALG_SHA_1, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_hash_update with SHA224 algorithm\n", - PSA_ALG_SHA_224, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_hash_update with SHA256 algorithm\n", - PSA_ALG_SHA_256, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA384 -{"Test psa_hash_update with SHA384 algorithm\n", - PSA_ALG_SHA_384, "Hello World", 11, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_hash_update with SHA512 algorithm\n", - PSA_ALG_SHA_512, "Hello World", 11, PSA_SUCCESS, -}, -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_entry.c deleted file mode 100644 index cae0904117..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c012/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c012.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 12) -#define TEST_DESC "Testing crypto hash functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c012_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/main.c deleted file mode 100644 index 0fe55816af..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c013(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c013, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.c deleted file mode 100644 index ccec9ca22c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.c +++ /dev/null @@ -1,135 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c013.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c013_crypto_list[] = { - NULL, - psa_hash_verify_test, - psa_hash_verify_inactive_operation_handle, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_hash_verify_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_hash_operation_t operation; - const char *hash; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (check1[i].alg == PSA_ALG_SHA_384) - hash = sha384_hash; - else if (check1[i].alg == PSA_ALG_SHA_512) - hash = sha512_hash; - else - hash = check1[i].hash; - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, check1[i].alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, - &check1[i].input, check1[i].input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Finish the calculation of the hash of a message and compare it with an expected value*/ - status = val->crypto_function(VAL_CRYPTO_HASH_VERIFY, &operation, hash, - check1[i].hash_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(5)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_hash_verify_inactive_operation_handle(security_t caller) -{ - psa_hash_operation_t operation, invalid_operation; - char input = 0xbd; - size_t input_length = 1; - psa_algorithm_t alg = PSA_ALG_SHA_256; - size_t hash_length = PSA_HASH_SIZE(alg); - char hash[] = {0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, - 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70, 0xc9, 0x5a, 0xcc, 0xbb, - 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, - 0x73, 0x2b}; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "test psa_hash_verify with inactive & invalid operation handle\n", 0); - memset(&operation, 0, sizeof(operation)); - memset(&invalid_operation, 0, sizeof(invalid_operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, - &input, input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Finish the calculation of the hash of a message and compare it with an expected value*/ - status = val->crypto_function(VAL_CRYPTO_HASH_VERIFY, &operation, hash, hash_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Retry the operation with completed operation handle */ - status = val->crypto_function(VAL_CRYPTO_HASH_VERIFY, &operation, hash, hash_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(6)); - - /* Retry the operation with invalid operation handle */ - status = val->crypto_function(VAL_CRYPTO_HASH_VERIFY, &invalid_operation, hash, hash_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(7)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.h deleted file mode 100644 index 5135dda7d6..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_c013.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C013_CLIENT_TESTS_H_ -#define _TEST_C013_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c013) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c013_crypto_list[]; - -int32_t psa_hash_verify_test(security_t caller); -int32_t psa_hash_verify_inactive_operation_handle(security_t caller); -#endif /* _TEST_C013_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_data.h deleted file mode 100644 index 520309a6aa..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_data.h +++ /dev/null @@ -1,131 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[50]; - psa_algorithm_t alg; - char input; - size_t input_length; - char hash[32]; - size_t hash_length; - psa_status_t expected_status; -} test_data; - -static const char sha384_hash[] = { -0x43, 0x72, 0xe3, 0x8a, 0x92, 0xa2, 0x8b, 0x5d, 0x2c, 0x39, 0x1e, 0x62, -0x45, 0x2a, 0x86, 0xd5, 0x0e, 0x02, 0x67, 0x22, 0x8b, 0xe1, 0x76, 0xc7, 0x7d, 0x24, 0x02, 0xef, -0xfe, 0x9f, 0xa5, 0x0d, 0xe4, 0x07, 0xbb, 0xb8, 0x51, 0xb3, 0x7d, 0x59, 0x04, 0xab, 0xa2, 0xde, -0xde, 0x74, 0xda, 0x2a}; - -static const char sha512_hash[] = { -0x29, 0x6e, 0x22, 0x67, 0xd7, 0x4c, 0x27, 0x8d, 0xaa, 0xaa, 0x94, 0x0d, -0x17, 0xb0, 0xcf, 0xb7, 0x4a, 0x50, 0x83, 0xf8, 0xe0, 0x69, 0x72, 0x6d, 0x8c, 0x84, 0x1c, 0xbe, -0x59, 0x6e, 0x04, 0x31, 0xcb, 0x77, 0x41, 0xa5, 0xb5, 0x0f, 0x71, 0x66, 0x6c, 0xfd, 0x54, 0xba, -0xcb, 0x7b, 0x00, 0xae, 0xa8, 0x91, 0x49, 0x9c, 0xf4, 0xef, 0x6a, 0x03, 0xc8, 0xa8, 0x3f, 0xe3, -0x7c, 0x3f, 0x7b, 0xaf}; - -static test_data check1[] = { -#ifdef ARCH_TEST_MD2 -{"Test psa_hash_verify with MD2 algorithm\n", - PSA_ALG_MD2, 0xbd, 1, - {0x8c, 0x9c, 0x17, 0x66, 0x5d, 0x25, 0xb3, 0x5f, 0xc4, 0x13, 0xc4, 0x18, 0x05, 0xc6, 0x79, 0xcf}, - 16, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD4 -{"Test psa_hash_verify with MD4 algorithm\n", - PSA_ALG_MD4, 0xbd, 1, - {0x18, 0xc3, 0x3f, 0x97, 0x29, 0x7e, 0xfe, 0x5f, 0x8a, 0x73, 0x22, 0x58, 0x28, 0x9f, 0xda, 0x25}, - 16, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD5 -{"Test psa_hash_verify with MD5 algorithm\n", - PSA_ALG_MD5, 0xbd, 1, - {0xab, 0xae, 0x57, 0xcb, 0x56, 0x2e, 0xcf, 0x29, 0x5b, 0x4a, 0x37, 0xa7, 0x6e, 0xfe, 0x61, 0xfb}, - 16, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_RIPEMD160 -{"Test psa_hash_verify with RIPEMD160 algorithm\n", - PSA_ALG_RIPEMD160, 0xbd, 1, - {0x50, 0x89, 0x26, 0x5e, 0xe5, 0xd9, 0xaf, 0x75, 0xd1, 0x2d, 0xbf, 0x7e, 0xa2, 0xf2, 0x7d, 0xbd, - 0xee, 0x43, 0x5b, 0x37}, - 20, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA1 -{"Test psa_hash_verify with SHA1 algorithm\n", - PSA_ALG_SHA_1, 0xbd, 1, - {0x90, 0x34, 0xaa, 0xf4, 0x51, 0x43, 0x99, 0x6a, 0x2b, 0x14, 0x46, 0x5c, 0x35, 0x2a, 0xb0, 0xc6, - 0xfa, 0x26, 0xb2, 0x21}, - 20, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_hash_verify with SHA224 algorithm\n", - PSA_ALG_SHA_224, 0xbd, 1, - {0xb1, 0xe4, 0x6b, 0xb9, 0xef, 0xe4, 0x5a, 0xf5, 0x54, 0x36, 0x34, 0x49, 0xc6, 0x94, 0x5a, 0x0d, - 0x61, 0x69, 0xfc, 0x3a, 0x5a, 0x39, 0x6a, 0x56, 0xcb, 0x97, 0xcb, 0x57}, - 28, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_hash_verify with SHA256 algorithm\n", - PSA_ALG_SHA_256, 0xbd, 1, - {0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70, - 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b}, - 32, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA384 -{"Test psa_hash_verify with SHA384 algorithm\n", - PSA_ALG_SHA_384, 0xbd, 1, {0}, 48, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_hash_verify with SHA512 algorithm\n", - PSA_ALG_SHA_512, 0xbd, 1, {0}, 64, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_hash_verify with incorrect expected hash\n", - PSA_ALG_SHA_256, 0xbd, 1, - {0x68, 0x32, 0x57, 0x20, 0xab, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70, - 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x78}, - 32, PSA_ERROR_INVALID_SIGNATURE, -}, - -{"Test psa_hash_verify with incorrect hash length\n", - PSA_ALG_SHA_256, 0xbd, 1, - {0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70, - 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b}, - 31, PSA_ERROR_INVALID_SIGNATURE, -}, -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_entry.c deleted file mode 100644 index 99ca4d2f8a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c013/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c013.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 13) -#define TEST_DESC "Testing crypto hash functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c013_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/main.c deleted file mode 100644 index c114c363a6..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c014(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c014, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.c deleted file mode 100644 index 48e3c5ab72..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.c +++ /dev/null @@ -1,186 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c014.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c014_crypto_list[] = { - NULL, - psa_hash_finish_test, - psa_hash_finish_inactive_operation_handle, - psa_hash_finish_invalid_hash_buffer_size, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_hash_finish_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_hash_operation_t operation; - const char *expected_hash; - char hash[HASH_64B]; - size_t hash_length, hash_size = sizeof(hash)/sizeof(hash[0]); - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - if (check1[i].alg == PSA_ALG_SHA_384) - expected_hash = sha384_hash; - else if (check1[i].alg == PSA_ALG_SHA_512) - expected_hash = sha512_hash; - else - expected_hash = check1[i].hash; - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, check1[i].alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, - &check1[i].input, check1[i].input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Finish the calculation of the hash of a message */ - status = val->crypto_function(VAL_CRYPTO_HASH_FINISH, &operation, hash, hash_size, - &hash_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - continue; - } - - TEST_ASSERT_EQUAL(hash_length, PSA_HASH_SIZE(check1[i].alg), TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_MEMCMP(hash, expected_hash, hash_length, TEST_CHECKPOINT_NUM(8)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_hash_finish_inactive_operation_handle(security_t caller) -{ - psa_hash_operation_t operation; - char input = 0xbd; - size_t input_length = 1; - psa_algorithm_t alg = PSA_ALG_SHA_256; - char hash[HASH_64B]; - size_t hash_length, hash_size = sizeof(hash)/sizeof(hash[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "test psa_hash_finish with inactive operation handle\n", 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, - &input, input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Finish the calculation of the hash of a message */ - status = val->crypto_function(VAL_CRYPTO_HASH_FINISH, &operation, hash, hash_size, - &hash_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Retry the operation with completed operation handle */ - status = val->crypto_function(VAL_CRYPTO_HASH_FINISH, &operation, hash, hash_size, - &hash_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(6)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_hash_finish_invalid_hash_buffer_size(security_t caller) -{ - psa_hash_operation_t operation; - char input = 0xbd; - size_t input_length = 1; - psa_algorithm_t alg = PSA_ALG_SHA_256; - char hash[HASH_64B]; - size_t hash_length, hash_size = 10; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "test psa_hash_finish with invalid hash buffer size\n", 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, &input, input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Finish the calculation of the hash of a message */ - status = val->crypto_function(VAL_CRYPTO_HASH_FINISH, &operation, hash, hash_size, - &hash_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BUFFER_TOO_SMALL, TEST_CHECKPOINT_NUM(5)); - - /*Abort the hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.h deleted file mode 100644 index 348e07c41f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_c014.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C014_CLIENT_TESTS_H_ -#define _TEST_C014_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c014) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c014_crypto_list[]; - -int32_t psa_hash_finish_test(security_t caller); -int32_t psa_hash_finish_inactive_operation_handle(security_t caller); -int32_t psa_hash_finish_invalid_hash_buffer_size(security_t caller); -#endif /* _TEST_C014_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_data.h deleted file mode 100644 index fb0fdb4045..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_data.h +++ /dev/null @@ -1,115 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[50]; - psa_algorithm_t alg; - char input; - size_t input_length; - char hash[32]; - size_t hash_length; - psa_status_t expected_status; -} test_data; - -static const char sha384_hash[] = { -0x43, 0x72, 0xe3, 0x8a, 0x92, 0xa2, 0x8b, 0x5d, 0x2c, 0x39, 0x1e, 0x62, -0x45, 0x2a, 0x86, 0xd5, 0x0e, 0x02, 0x67, 0x22, 0x8b, 0xe1, 0x76, 0xc7, 0x7d, 0x24, 0x02, 0xef, -0xfe, 0x9f, 0xa5, 0x0d, 0xe4, 0x07, 0xbb, 0xb8, 0x51, 0xb3, 0x7d, 0x59, 0x04, 0xab, 0xa2, 0xde, -0xde, 0x74, 0xda, 0x2a}; - -static const char sha512_hash[] = { -0x29, 0x6e, 0x22, 0x67, 0xd7, 0x4c, 0x27, 0x8d, 0xaa, 0xaa, 0x94, 0x0d, -0x17, 0xb0, 0xcf, 0xb7, 0x4a, 0x50, 0x83, 0xf8, 0xe0, 0x69, 0x72, 0x6d, 0x8c, 0x84, 0x1c, 0xbe, -0x59, 0x6e, 0x04, 0x31, 0xcb, 0x77, 0x41, 0xa5, 0xb5, 0x0f, 0x71, 0x66, 0x6c, 0xfd, 0x54, 0xba, -0xcb, 0x7b, 0x00, 0xae, 0xa8, 0x91, 0x49, 0x9c, 0xf4, 0xef, 0x6a, 0x03, 0xc8, 0xa8, 0x3f, 0xe3, -0x7c, 0x3f, 0x7b, 0xaf}; - -static test_data check1[] = { -#ifdef ARCH_TEST_MD2 -{"Test psa_hash_finish with MD2 algorithm\n", - PSA_ALG_MD2, 0xbd, 1, - {0x8c, 0x9c, 0x17, 0x66, 0x5d, 0x25, 0xb3, 0x5f, 0xc4, 0x13, 0xc4, 0x18, 0x05, 0xc6, 0x79, 0xcf}, - 16, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD4 -{"Test psa_hash_finish with MD4 algorithm\n", - PSA_ALG_MD4, 0xbd, 1, - {0x18, 0xc3, 0x3f, 0x97, 0x29, 0x7e, 0xfe, 0x5f, 0x8a, 0x73, 0x22, 0x58, 0x28, 0x9f, 0xda, 0x25}, - 16, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD5 -{"Test psa_hash_finish with MD5 algorithm\n", - PSA_ALG_MD5, 0xbd, 1, - {0xab, 0xae, 0x57, 0xcb, 0x56, 0x2e, 0xcf, 0x29, 0x5b, 0x4a, 0x37, 0xa7, 0x6e, 0xfe, 0x61, 0xfb}, - 16, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_RIPEMD160 -{"Test psa_hash_finish with RIPEMD160 algorithm\n", - PSA_ALG_RIPEMD160, 0xbd, 1, - {0x50, 0x89, 0x26, 0x5e, 0xe5, 0xd9, 0xaf, 0x75, 0xd1, 0x2d, 0xbf, 0x7e, 0xa2, 0xf2, 0x7d, 0xbd, - 0xee, 0x43, 0x5b, 0x37}, - 20, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA1 -{"Test psa_hash_finish with SHA1 algorithm\n", - PSA_ALG_SHA_1, 0xbd, 1, - {0x90, 0x34, 0xaa, 0xf4, 0x51, 0x43, 0x99, 0x6a, 0x2b, 0x14, 0x46, 0x5c, 0x35, 0x2a, 0xb0, 0xc6, - 0xfa, 0x26, 0xb2, 0x21}, - 20, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_hash_finish with SHA224 algorithm\n", - PSA_ALG_SHA_224, 0xbd, 1, - {0xb1, 0xe4, 0x6b, 0xb9, 0xef, 0xe4, 0x5a, 0xf5, 0x54, 0x36, 0x34, 0x49, 0xc6, 0x94, 0x5a, 0x0d, - 0x61, 0x69, 0xfc, 0x3a, 0x5a, 0x39, 0x6a, 0x56, 0xcb, 0x97, 0xcb, 0x57}, - 28, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_hash_finish with SHA256 algorithm\n", - PSA_ALG_SHA_256, 0xbd, 1, - {0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70, - 0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b}, - 32, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA384 -{"Test psa_hash_finish with SHA384 algorithm\n", - PSA_ALG_SHA_384, 0xbd, 1, {0}, 48, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_hash_finish with SHA512 algorithm\n", - PSA_ALG_SHA_512, 0xbd, 1, {0}, 64, PSA_SUCCESS, -}, -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_entry.c deleted file mode 100644 index 3934edc87d..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c014/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c014.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 14) -#define TEST_DESC "Testing crypto hash functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c014_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/main.c deleted file mode 100644 index 7f722a337d..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c015(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c015, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.c deleted file mode 100644 index 208d7b563f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.c +++ /dev/null @@ -1,110 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c015.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c015_crypto_list[] = { - NULL, - psa_hash_abort_test, - psa_hash_abort_before_operation_finish, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_hash_abort_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_hash_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, check1[i].alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Abort a hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(4)); - - /* Multiple hash abort should succeed */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(5)); - - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_hash_abort_before_operation_finish(security_t caller) -{ - psa_hash_operation_t operation; - char input = 0xbd; - size_t input_length = 1; - psa_algorithm_t alg = PSA_ALG_SHA_256; - char hash[HASH_64B]; - size_t hash_length, hash_size = sizeof(hash)/sizeof(hash[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "Test psa_hash_finish after calling psa_hash_abort\n", 0); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Start a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_SETUP, &operation, alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Add a message fragment to a multipart hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_UPDATE, &operation, &input, input_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Abort a hash operation */ - status = val->crypto_function(VAL_CRYPTO_HASH_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Finish the calculation of the hash of a message */ - status = val->crypto_function(VAL_CRYPTO_HASH_FINISH, &operation, hash, hash_size, - &hash_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(6)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.h deleted file mode 100644 index bf435c2c07..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_c015.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C015_CLIENT_TESTS_H_ -#define _TEST_C015_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c015) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c015_crypto_list[]; - -int32_t psa_hash_abort_test(security_t caller); -int32_t psa_hash_abort_before_operation_finish(security_t caller); -#endif /* _TEST_C015_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_data.h deleted file mode 100644 index 98ec64c7db..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_data.h +++ /dev/null @@ -1,80 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[50]; - psa_algorithm_t alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_MD2 -{"Test psa_hash_abort with MD2 algorithm\n", - PSA_ALG_MD2, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD4 -{"Test psa_hash_abort with MD4 algorithm\n", - PSA_ALG_MD4, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_MD5 -{"Test psa_hash_abort with MD5 algorithm\n", - PSA_ALG_MD5, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_RIPEMD160 -{"Test psa_hash_abort with RIPEMD160 algorithm\n", - PSA_ALG_RIPEMD160, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA1 -{"Test psa_hash_abort with SHA1 algorithm\n", - PSA_ALG_SHA_1, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_hash_abort with SHA224 algorithm\n", - PSA_ALG_SHA_224, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_hash_abort with SHA256 algorithm\n", - PSA_ALG_SHA_256, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA384 -{"Test psa_hash_abort with SHA384 algorithm\n", - PSA_ALG_SHA_384, PSA_SUCCESS, -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_hash_abort with SHA512 algorithm\n", - PSA_ALG_SHA_512, PSA_SUCCESS, -}, -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_entry.c deleted file mode 100644 index b403a9553a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c015/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c015.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 15) -#define TEST_DESC "Testing crypto hash functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c015_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/main.c deleted file mode 100644 index 40711d457c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c016(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c016, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.c deleted file mode 100644 index 5862ba563b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.c +++ /dev/null @@ -1,174 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c016.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c016_crypto_list[] = { - NULL, - psa_generate_key_test, - psa_generate_key_negative_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_generate_key_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint32_t i, length; - psa_key_policy_t policy; - psa_key_type_t key_type; - size_t bits; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Generate a key or key pair */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].bits, check1[i].extra, check1[i].extra_size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Get basic metadata about a key */ - status = val->crypto_function(VAL_CRYPTO_GET_KEY_INFORMATION, check1[i].key_handle, - &key_type, &bits); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - TEST_ASSERT_EQUAL(key_type, check1[i].key_type, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(bits, check1[i].expected_bit_length, TEST_CHECKPOINT_NUM(8)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check1[i].key_handle, data, - BUFFER_SIZE, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(9)); - - TEST_ASSERT_EQUAL(length, check1[i].expected_key_length, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_generate_key_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - uint32_t i; - psa_key_policy_t policy; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generate_key with unallocated key handle\n", - g_test_count++); - /* Generate a key or key pair */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].bits, check2[i].extra, check2[i].extra_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generate_key with zero as key handle\n", - g_test_count++); - /* Generate a key or key pair */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_KEY, 0, check2[i].key_type, - check2[i].bits, check2[i].extra, check2[i].extra_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generate_key with pre-occupied key handle\n", - g_test_count++); - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Generate a key or key pair */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].bits, check2[i].extra, check2[i].extra_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Generate a key or key pair */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].bits, check2[i].extra, check2[i].extra_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_OCCUPIED_SLOT, TEST_CHECKPOINT_NUM(8)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generate_key with destroyed key handle\n", - g_test_count++); - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Generate a key or key pair */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_KEY, check2[i].key_handle, - check2[i].key_type, check2[i].bits, check2[i].extra, check2[i].extra_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.h deleted file mode 100644 index 7697b911ca..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_c016.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C016_CLIENT_TESTS_H_ -#define _TEST_C016_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c016) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c016_crypto_list[]; - -int32_t psa_generate_key_test(security_t caller); -int32_t psa_generate_key_negative_test(security_t caller); -#endif /* _TEST_C016_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_data.h deleted file mode 100644 index 8bcd0877d9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_data.h +++ /dev/null @@ -1,145 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - size_t bits; - void *extra; - size_t extra_size; - uint32_t expected_bit_length; - uint32_t expected_key_length; - psa_status_t expected_status; -} test_data; - -#ifdef FUTURE_SUPPORT -static uint32_t rsa_extra = 3; -#endif - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_generate_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), NULL, 0, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_generate_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_24B_KEY_SIZE), NULL, 0, - BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_generate_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), NULL, 0, - BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_generate_key with DES 64 bit key\n", 4, PSA_KEY_TYPE_DES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES_8B_KEY_SIZE), NULL, 0, - BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_generate_key with Triple DES 2-Key\n", 5, PSA_KEY_TYPE_DES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_2KEY_SIZE), NULL, 0, - BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_generate_key with Triple DES 3-Key\n", 6, PSA_KEY_TYPE_DES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(DES3_3KEY_SIZE), NULL, 0, - BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_generate_key with Null extra and Non-Zero extra size\n", 7, PSA_KEY_TYPE_AES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), NULL, sizeof(uint32_t), - 0, 0, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef FUTURE_SUPPORT -{"Test psa_generate_key with RSA 2048 Keypair\n", 8, PSA_KEY_TYPE_RSA_KEYPAIR, - PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, NULL, 0, - 2048, 1193, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -#ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION -{"Test psa_generate_key with ECC KeyPair\n", 9, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), - PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, - 224, NULL, 0, - 224, 28, PSA_SUCCESS -}, -#endif -#endif - -#ifdef FUTURE_SUPPORT -{"Test psa_generate_key with Non-Null extra for 32 Byte AES key\n", 10, PSA_KEY_TYPE_AES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_32B_KEY_SIZE), &rsa_extra, sizeof(uint32_t), - 0, 0, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_generate_key with RSA 2048 Public key\n", 11, PSA_KEY_TYPE_RSA_PUBLIC_KEY, - PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, - 2048, NULL, 0, - 2048, 1193, PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_generate_key negative cases\n", 12, PSA_KEY_TYPE_AES, - PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR, - BYTES_TO_BITS(AES_16B_KEY_SIZE), NULL, 0, - BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_entry.c deleted file mode 100644 index 3957dd6d6e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c016/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c016.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 16) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c016_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/main.c deleted file mode 100644 index 42b89b3e77..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c017(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c017, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.c deleted file mode 100644 index 10387b8d7c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.c +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c017.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c017_crypto_list[] = { - NULL, - psa_generate_random_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_generate_random_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint32_t i, j, data_sum; - uint8_t data[BUFFER_SIZE] = {0}; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Generate random bytes */ - status = val->crypto_function(VAL_CRYPTO_GENERATE_RANDOM, data, check1[i].size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(3)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - data_sum = 0; - /* Check that if generated data are zero */ - for (j = 0; j < check1[i].size; j++) - { - data_sum += data[j]; - data[j] = 0; - } - - if (check1[i].size != 0) - TEST_ASSERT_NOT_EQUAL(data_sum, 0, TEST_CHECKPOINT_NUM(4)); - else - TEST_ASSERT_EQUAL(data_sum, 0, TEST_CHECKPOINT_NUM(5)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.h deleted file mode 100644 index ee8c4efbf3..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_c017.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C017_CLIENT_TESTS_H_ -#define _TEST_C017_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c017) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c017_crypto_list[]; - -int32_t psa_generate_random_test(security_t caller); -#endif /* _TEST_C017_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_data.h deleted file mode 100644 index 4e0c46cfa0..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_data.h +++ /dev/null @@ -1,56 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - size_t size; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -{"Test psa_generate_random to get 0 Byte data\n", 0, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 16 Byte data\n", 16, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 24 Byte data\n", 24, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 32 Byte data\n", 32, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 64 Byte data\n", 64, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 128 Byte data\n", 128, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 256 Byte data\n", 256, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 512 Byte data\n", 512, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 1000 Byte data\n", 100, PSA_SUCCESS -}, - -{"Test psa_generate_random to get 1024 Byte data\n", 1024, PSA_SUCCESS -}, -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_entry.c deleted file mode 100644 index 500d2ec664..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c017/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c017.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 17) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c017_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/main.c deleted file mode 100644 index b21ffb85df..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c018(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c018, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.c deleted file mode 100644 index 971c6de33f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.c +++ /dev/null @@ -1,146 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c018.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c018_crypto_list[] = { - NULL, - psa_generator_read_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE_HIGH]; - -int32_t psa_generator_read_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint32_t i, j, data_sum, remaining_size; - psa_key_policy_t policy; - psa_crypto_generator_t generator, invalid_generator; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(&invalid_generator, 0xDEADEAD, sizeof(invalid_generator)); - memset(data, 0, sizeof(data)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, check1[i].key_handle, - check1[i].key_alg, &check1[i].salt, check1[i].salt_length, &check1[i].label, - check1[i].label_length, check1[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Read some data from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &generator, data, - check1[i].size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(7)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - continue; - } - - data_sum = 0; - /* Check that if generated data are zero */ - for (j = 0; j < check1[i].size; j++) - { - data_sum += data[j]; - } - - memset(data, 0, sizeof(data)); - TEST_ASSERT_NOT_EQUAL(data_sum, 0, TEST_CHECKPOINT_NUM(9)); - - remaining_size = check1[i].capacity - check1[i].size; - if (remaining_size > 0) - { - /* Read some data from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &generator, - data, remaining_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(10)); - - data_sum = 0; - /* Check that if generated data are zero */ - for (j = 0; j < remaining_size; j++) - { - data_sum += data[j]; - } - - memset(data, 0, sizeof(data)); - TEST_ASSERT_NOT_EQUAL(data_sum, 0, TEST_CHECKPOINT_NUM(11)); - - /* Read some data from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &generator, - data, check1[i].size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INSUFFICIENT_CAPACITY, TEST_CHECKPOINT_NUM(12)); - } - - /* Read data using invalid generator handle */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &invalid_generator, - data, 1); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(13)); - - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(14)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.h deleted file mode 100644 index 34f72c8db5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_c018.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C018_CLIENT_TESTS_H_ -#define _TEST_C018_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c018) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c018_crypto_list[]; - -int32_t psa_generator_read_test(security_t caller); -#endif /* _TEST_C018_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_data.h deleted file mode 100644 index 9506e173ab..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_data.h +++ /dev/null @@ -1,97 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t salt[16]; - size_t salt_length; - uint8_t label[16]; - size_t label_length; - size_t capacity; - size_t size; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -/* Covers the following cases - * - 16 Byte key - * - SHA 256 - * - Output size less than generator capacity - */ -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_SHA256 -{"Test psa_generator_read to get 16 Byte data with SHA-256\n", 1, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), - {0}, 0, {0}, 0, 32, - 16, PSA_SUCCESS -}, -#endif -/* Covers the following cases - * - 32 Byte key - * - SHA 512 - * - Output size equal to generator capacity - */ -#ifdef ARCH_TEST_SHA512 -{"Test psa_generator_read to get 32 Byte data with SHA-512\n", 2, PSA_KEY_TYPE_DERIVE, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_512), - {0}, 0, {0}, 0, 64, - 64, PSA_SUCCESS -}, -#endif - -/* Covers the following cases - * - 8 Byte Key - * - SHA 1 - * - Output size greater than the generator capacity - */ -#ifdef ARCH_TEST_SHA1 -{"Test psa_generator_read to get 8 Byte data with SHA-1\n", 3, PSA_KEY_TYPE_DERIVE, -{0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_1), - {0}, 0, {0}, 0, 64, - 70, PSA_ERROR_INSUFFICIENT_CAPACITY -}, - -{"Test psa_generator_read to request maximum capacity\n", 4, PSA_KEY_TYPE_DERIVE, -{0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_1), - {0}, 0, {0}, 0, (255 * 20), - (255 * 20), PSA_SUCCESS -}, - -{"Test psa_generator_read to request maximum capacity +1\n", 5, PSA_KEY_TYPE_DERIVE, -{0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_1), - {0}, 0, {0}, 0, (255 * 20), - ((255 * 20) + 1), PSA_ERROR_INSUFFICIENT_CAPACITY -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_entry.c deleted file mode 100644 index 4ae7f2d95c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c018/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c018.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 18) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c018_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/main.c deleted file mode 100644 index 2f757a4871..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c019(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c019, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.c deleted file mode 100644 index c110892cc5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.c +++ /dev/null @@ -1,121 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c019.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c019_crypto_list[] = { - NULL, - psa_get_generator_capacity_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_get_generator_capacity_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint32_t i, remaining_size; - size_t capacity; - psa_key_policy_t policy; - psa_crypto_generator_t generator; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(data, 0, sizeof(data)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, check1[i].key_handle, - check1[i].key_alg, check1[i].salt, check1[i].salt_length, check1[i].label, - check1[i].label_length, check1[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Retrieve the current capacity of a generator */ - status = val->crypto_function(VAL_CRYPTO_GET_GENERATOR_CAPACITY, &generator, &capacity); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(7)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - continue; - } - - TEST_ASSERT_EQUAL(capacity, check1[i].capacity, TEST_CHECKPOINT_NUM(9)); - - /* Generate random bytes */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &generator, data, - check1[i].size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(10)); - - remaining_size = check1[i].capacity - check1[i].size; - - /* Retrieve the current capacity of a generator */ - status = val->crypto_function(VAL_CRYPTO_GET_GENERATOR_CAPACITY, &generator, &capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(11)); - - TEST_ASSERT_EQUAL(capacity, remaining_size, TEST_CHECKPOINT_NUM(12)); - - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(13)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.h deleted file mode 100644 index da29369cf9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_c019.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C019_CLIENT_TESTS_H_ -#define _TEST_C019_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c019) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c019_crypto_list[]; - -int32_t psa_get_generator_capacity_test(security_t caller); -#endif /* _TEST_C019_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_data.h deleted file mode 100644 index 592d03e4ca..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_data.h +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t salt[16]; - size_t salt_length; - uint8_t label[16]; - size_t label_length; - size_t capacity; - size_t size; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -/* Covers the following cases - * - 16 Byte key - * - SHA 256 - * - Output size less than generator capacity - */ -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_SHA256 -{"Test psa_generator_get_capacity to get 16 Byte data with SHA-256\n", 1, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), - {0}, 0, {0}, 0, 32, - 16, PSA_SUCCESS -}, -#endif - -/* Covers the following cases - * - 32 Byte key - * - SHA 512 - * - Output size equal to generator capacity - */ -#ifdef ARCH_TEST_SHA512 -{"Test psa_generator_get_capacity to get 32 Byte data with SHA-512\n", 2, PSA_KEY_TYPE_DERIVE, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_512), - {0}, 0, {0}, 0, 64, - 64, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_entry.c deleted file mode 100644 index b1c5b1502e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c019/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c019.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 19) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c019_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/main.c deleted file mode 100644 index 9cd6dddc14..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c020(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c020, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.c deleted file mode 100644 index 700c3de041..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.c +++ /dev/null @@ -1,302 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c020.h" -#include "test_data.h" -#include "val_crypto.h" - -#define SLOT_1 0 -#define SLOT_2 1 -#define SLOT_3 2 -#define SLOT_4 3 - -client_test_t test_c020_crypto_list[] = { - NULL, - psa_generator_import_key_test, - psa_generator_import_key_negative_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; -static psa_crypto_generator_t generator; - -int32_t psa_generator_import_key_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint32_t i, j, data_sum, remaining_size, length = 0; - uint32_t salt = 0, label = 0; - size_t salt_length = 0, label_length = 0; - psa_key_policy_t policy; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(data, 0, sizeof(data)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage[SLOT_1], - check1[i].key_alg[SLOT_1]); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle[SLOT_1]); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle[SLOT_1], - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle[SLOT_1], - check1[i].key_type[SLOT_1], check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, - check1[i].key_handle[SLOT_1], check1[i].key_alg[SLOT_1], &salt, salt_length, - &label, label_length, check1[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage[SLOT_2], - check1[i].key_alg[SLOT_2]); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle[SLOT_2]); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle[SLOT_2], - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Create a symmetric key from data read from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_IMPORT_KEY, check1[i].key_handle[SLOT_2], - check1[i].key_type[SLOT_2], BYTES_TO_BITS(check1[i].size), &generator); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(7)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - continue; - } - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check1[i].key_handle[SLOT_2], data, - BUFFER_SIZE, &length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - TEST_ASSERT_EQUAL(length, check1[i].size, TEST_CHECKPOINT_NUM(10)); - - data_sum = 0; - /* Check that if generated data are zero */ - for (j = 0; j < check1[i].size; j++) - { - data_sum += data[j]; - } - - memset(data, 0, sizeof(data)); - TEST_ASSERT_NOT_EQUAL(data_sum, 0, TEST_CHECKPOINT_NUM(12)); - - remaining_size = check1[i].capacity - check1[i].size; - if (remaining_size > 0) - { - length = 0; - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage[SLOT_2], - check1[i].key_alg[SLOT_2]); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle[SLOT_3]); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle[SLOT_3], - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(12)); - - /* Create a symmetric key from data read from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_IMPORT_KEY, - check1[i].key_handle[SLOT_3], check1[i].key_type[SLOT_2], - BYTES_TO_BITS(check1[i].size), &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(13)); - - /* Export a key in binary format */ - status = val->crypto_function(VAL_CRYPTO_EXPORT_KEY, check1[i].key_handle[SLOT_3], data, - BUFFER_SIZE, &length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(14)); - - TEST_ASSERT_EQUAL(length, remaining_size, TEST_CHECKPOINT_NUM(15)); - - data_sum = 0; - /* Check that if generated data are zero */ - for (j = 0; j < remaining_size; j++) - { - data_sum += data[j]; - } - - memset(data, 0, sizeof(data)); - TEST_ASSERT_NOT_EQUAL(data_sum, 0, TEST_CHECKPOINT_NUM(16)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage[SLOT_2], - check1[i].key_alg[SLOT_2]); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle[SLOT_4]); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle[SLOT_4], - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(17)); - - /* Create a symmetric key from data read from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_IMPORT_KEY, - check1[i].key_handle[SLOT_4], check1[i].key_type[SLOT_2], - BYTES_TO_BITS(check1[i].size), &generator); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INSUFFICIENT_CAPACITY, TEST_CHECKPOINT_NUM(18)); - } - - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(19)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_generator_import_key_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - uint32_t salt = 0, label = 0; - size_t salt_length = 0, label_length = 0; - uint8_t data[BUFFER_SIZE]; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(data, 0, sizeof(data)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage[SLOT_1], - check2[i].key_alg[SLOT_1]); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle[SLOT_1]); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle[SLOT_1], - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check2[i].key_handle[SLOT_1], - check2[i].key_type[SLOT_1], check2[i].key_data, check2[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, - check2[i].key_handle[SLOT_1], check2[i].key_alg[SLOT_1], &salt, salt_length, - &label, label_length, check2[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generator_import_key with invalid handle\n", - g_test_count++); - /* Create a symmetric key from data read from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_IMPORT_KEY, check2[i].key_handle[SLOT_2], - check2[i].key_type[SLOT_2], check2[i].size, &generator); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(7)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generator_import_key with zero handle\n", - g_test_count++); - /* Create a symmetric key from data read from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_IMPORT_KEY, ZERO_KEY_SLOT, - check2[i].key_type[SLOT_2], check2[i].size, &generator); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(7)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generator_import_key with" - " pre-occupied key slot\n", g_test_count++); - /* Create a symmetric key from data read from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_IMPORT_KEY, check2[i].key_handle[SLOT_1], - check2[i].key_type[SLOT_2], check2[i].size, &generator); - TEST_ASSERT_EQUAL(status, PSA_ERROR_OCCUPIED_SLOT, TEST_CHECKPOINT_NUM(9)); - - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.h deleted file mode 100644 index 9584befd42..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_c020.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C020_CLIENT_TESTS_H_ -#define _TEST_C020_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c020) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c020_crypto_list[]; - -int32_t psa_generator_import_key_test(security_t caller); -int32_t psa_generator_import_key_negative_test(security_t caller); -#endif /* _TEST_C020_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_data.h deleted file mode 100644 index 95fe77b771..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_data.h +++ /dev/null @@ -1,122 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle[4]; - psa_key_type_t key_type[2]; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage[2]; - psa_algorithm_t key_alg[2]; - size_t capacity; - size_t size; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_SHA256 -{"Test psa_generator_import_key for 16 Byte AES Key\n", {1, 2, 3, 4}, -{PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES}, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT}, - {PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR}, - 32, 16, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_SHA512 -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_generator_import_key for Triple DES 3-Key\n", {5, 6, 7, 8}, -{PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_DES}, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT}, -{PSA_ALG_HKDF(PSA_ALG_SHA_512), PSA_ALG_CTR}, - DES3_3KEY_SIZE, DES3_3KEY_SIZE, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_SHA1 -#ifdef ARCH_TEST_AES -{"Test psa_generator_import_key output greater than capacity\n", {9, 10, 11, 12}, -{PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES}, -{0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT}, -{PSA_ALG_HKDF(PSA_ALG_SHA_1), PSA_ALG_CTR}, - 64, 80, PSA_ERROR_INSUFFICIENT_CAPACITY -}, -#endif -#endif - -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_RSA -{"Test psa_generator_import_key for RSA Public Key - Invalid type\n", {13, 14, 15, 16}, -{PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_RSA_PUBLIC_KEY}, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT}, -{PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR}, - 32, 16, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_AES_128 -{"Test psa_generator_import_key for invalid byte for generation\n", {20, 21, 22, 23}, -{PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES}, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT}, -{PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR}, - 32, 10, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_SHA256 -{"Test psa_generator_import_key negative cases\n", -{17, 18, 18, 18}, -{PSA_KEY_TYPE_DERIVE, PSA_KEY_TYPE_AES}, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, {PSA_KEY_USAGE_DERIVE, PSA_KEY_USAGE_EXPORT}, -{PSA_ALG_HKDF(PSA_ALG_SHA_256), PSA_ALG_CTR}, - 32, BYTES_TO_BITS(8), PSA_ERROR_INVALID_HANDLE -}, -#endif -#endif -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_entry.c deleted file mode 100644 index c109392ce4..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c020/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c020.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 20) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c020_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/main.c deleted file mode 100644 index bfc314683d..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c021(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c021, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.c deleted file mode 100644 index 64619d1cc5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.c +++ /dev/null @@ -1,111 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c021.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c021_crypto_list[] = { - NULL, - psa_generator_abort_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_generator_abort_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_crypto_generator_t generator; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(data, 0, sizeof(data)); - - val->print(PRINT_TEST, "[Check %d] Test psa_generator_abort on empty generator\n", - g_test_count++); - /* Abort an empty generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, check1[i].key_handle, - check1[i].key_alg, check1[i].salt, check1[i].salt_length, check1[i].label, - check1[i].label_length, check1[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Abort the generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Generate random bytes */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &generator, data, check1[i].size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(8)); - - val->print(PRINT_TEST, "[Check %d] Multiple psa_generator_abort test\n", g_test_count++); - /* Abort the generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Abort the generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.h deleted file mode 100644 index 77b0783d07..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_c021.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C021_CLIENT_TESTS_H_ -#define _TEST_C021_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c021) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c021_crypto_list[]; - -int32_t psa_generator_abort_test(security_t caller); -#endif /* _TEST_C021_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_data.h deleted file mode 100644 index 6f42e9e4cc..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_data.h +++ /dev/null @@ -1,51 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t salt[16]; - size_t salt_length; - uint8_t label[16]; - size_t label_length; - size_t capacity; - size_t size; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_SHA256 -{"Test psa_generator_abort\n", 1, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), - {0}, 0, {0}, 0, 32, - 16, PSA_SUCCESS -}, -#endif -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_entry.c deleted file mode 100644 index 621cd97856..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c021/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c021.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 21) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c021_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/main.c deleted file mode 100644 index 43655771d7..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c022(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c022, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.c deleted file mode 100644 index 8f8ac601f9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.c +++ /dev/null @@ -1,188 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c022.h" -#include "test_data.h" -#include "val_crypto.h" - - -client_test_t test_c022_crypto_list[] = { - NULL, - psa_key_derivation_test, - psa_key_derivation_negative_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_key_derivation_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - size_t capacity; - psa_key_policy_t policy; - psa_crypto_generator_t generator; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(data, 0, sizeof(data)); - capacity = 0; - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, - check1[i].key_handle, check1[i].key_alg, check1[i].salt, - check1[i].salt_length, check1[i].label, check1[i].label_length, - check1[i].capacity); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort the generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - continue; - } - - /* Retrieve the current capacity of a generator */ - status = val->crypto_function(VAL_CRYPTO_GET_GENERATOR_CAPACITY, &generator, &capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - TEST_ASSERT_EQUAL(capacity, check1[i].capacity, TEST_CHECKPOINT_NUM(8)); - - /* Abort the generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_key_derivation_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_key_handle_t empty_key_handle; - psa_crypto_generator_t generator; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - memset(&generator, 0, sizeof(generator)); - memset(data, 0, sizeof(data)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_key_derivation with invalid key handle\n", - g_test_count++); - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, - check2[i].key_handle, check2[i].key_alg, check2[i].salt, - check2[i].salt_length, check2[i].label, check2[i].label_length, - check2[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(6)); - - val->print(PRINT_TEST, "[Check %d] Test psa_key_derivation with zero as key handle\n", - g_test_count++); - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, - 0, check2[i].key_alg, check2[i].salt, - check2[i].salt_length, check2[i].label, check2[i].label_length, - check2[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(7)); - - val->print(PRINT_TEST, "[Check %d] Test psa_key_derivation with empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &empty_key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, empty_key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Set up a key derivation operation. Using this function to initialize the generate as - * XOR or PRNG generator initialization is not implemented. - */ - status = val->crypto_function(VAL_CRYPTO_KEY_DERIVATION, &generator, - empty_key_handle, check2[i].key_alg, check2[i].salt, - check2[i].salt_length, check2[i].label, check2[i].label_length, - check2[i].capacity); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(10)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.h deleted file mode 100644 index 1339ec7965..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_c022.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C022_CLIENT_TESTS_H_ -#define _TEST_C022_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c022) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c022_crypto_list[]; - -int32_t psa_key_derivation_test(security_t caller); -int32_t psa_key_derivation_negative_test(security_t caller); -#endif /* _TEST_C022_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_data.h deleted file mode 100644 index ecd5cded19..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_data.h +++ /dev/null @@ -1,136 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - const uint8_t salt[16]; - size_t salt_length; - const uint8_t label[16]; - size_t label_length; - size_t capacity; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_SHA256 -{"Test psa_key_derivation to get 16 Byte data with SHA-256\n", 1, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), - {0}, 0, {0}, 0, 32, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_key_derivation to get 32 Byte data with SHA-512\n", 2, PSA_KEY_TYPE_DERIVE, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_512), - {0}, 0, {0}, 0, 64, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_MD5 -{"Test psa_key_derivation to get 32 Byte data with MD-5\n", 3, PSA_KEY_TYPE_DERIVE, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_MD5), - {0}, 0, {0}, 0, 64, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_key_derivation to get 16 Byte data with salt and label\n", 4, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), - "abcdefghijklmnop", 16, "This is a label", 15, 32, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA1 -{"Test psa_key_derivation with too large capacity for alg and key\n", 6, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_1), - {0}, 0, {0}, 0, 5200, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_key_derivation with unsupported key type\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), - {0}, 0, {0}, 0, 32, - PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_key_derivation with incorrect usage\n", 12, PSA_KEY_TYPE_DERIVE, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_HKDF(PSA_ALG_SHA_256), - {0}, 0, {0}, 0, 32, - PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -{"Test psa_key_derivation with invalid algorithm\n", 5, PSA_KEY_TYPE_DERIVE, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_RSA_PKCS1V15_CRYPT, - {0}, 0, {0}, 0, 64, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_SHA512 -{"Test psa_key_derivation to get 32 Byte data with SHA-512\n", 13, PSA_KEY_TYPE_DERIVE, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, - AES_32B_KEY_SIZE, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_512), - {0}, 0, {0}, 0, 64, - PSA_SUCCESS -}, -#endif -#endif - -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_entry.c deleted file mode 100644 index 2d7e7981bd..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c022/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c022.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 22) -#define TEST_DESC "Testing crypto generator functions APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c022_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/main.c deleted file mode 100644 index a30a203b47..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c023(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c023, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.c deleted file mode 100644 index 9c786dcf7b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.c +++ /dev/null @@ -1,68 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c023.h" -#include "test_data.h" -#include "val_crypto.h" - -client_test_t test_c023_crypto_list[] = { - NULL, - psa_key_policy_get_usage_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_key_policy_get_usage_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_key_usage_t usage; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Retrieve the usage field of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_GET_USAGE, &policy, &usage); - - TEST_ASSERT_EQUAL(usage, check1[i].usage, TEST_CHECKPOINT_NUM(3)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.h deleted file mode 100644 index 43c40e4de6..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_c023.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C023_CLIENT_TESTS_H_ -#define _TEST_C023_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c023) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c023_crypto_list[]; - -int32_t psa_key_policy_get_usage_test(security_t caller); -#endif /* _TEST_C023_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_data.h deleted file mode 100644 index 2ef937cc94..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_data.h +++ /dev/null @@ -1,55 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_usage_t usage; - psa_algorithm_t key_alg; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HKDF -#ifdef ARCH_TEST_SHA256 -{"Test psa_key_policy_get_usage with usage as encrypt\n", - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_HKDF(PSA_ALG_SHA_256), -}, - -{"Test psa_key_policy_get_usage with usage as decrypt\n", - PSA_KEY_USAGE_DECRYPT, PSA_ALG_HKDF(PSA_ALG_SHA_256), -}, - -{"Test psa_key_policy_get_usage with usage as derive\n", - PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), -}, - -{"Test psa_key_policy_get_usage with usage as export\n", - PSA_KEY_USAGE_EXPORT, PSA_ALG_HKDF(PSA_ALG_SHA_256), -}, - -{"Test psa_key_policy_get_usage with usage as sign\n", - PSA_KEY_USAGE_SIGN, PSA_ALG_HKDF(PSA_ALG_SHA_256), -}, - -{"Test psa_key_policy_get_usage with usage as verify\n", - PSA_KEY_USAGE_VERIFY, PSA_ALG_HKDF(PSA_ALG_SHA_256), -}, -#endif -#endif - -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_entry.c deleted file mode 100644 index d177a9db5b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c023/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c023.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 23) -#define TEST_DESC "Testing crypto key management APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c023_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/main.c deleted file mode 100644 index cbaac02d6d..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c024(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c024, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.c deleted file mode 100644 index 5736b37c1b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.c +++ /dev/null @@ -1,217 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c024.h" -#include "test_data.h" - -client_test_t test_c024_crypto_list[] = { - NULL, - psa_aead_encrypt_test, - psa_aead_encrypt_negative_test, - NULL, -}; - -static int g_test_count = 1; - -static bool_t is_buffer_empty(uint8_t *buffer, size_t size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (buffer[i] != 0) - return FALSE; - } - - return TRUE; -} - -int32_t psa_aead_encrypt_test(security_t caller) -{ - int32_t i, status; - uint8_t ciphertext[BUFFER_SIZE]; - psa_key_policy_t policy; - size_t ciphertext_length; - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint8_t *nonce, *additional_data; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - memset(ciphertext, 0, sizeof(ciphertext)); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (is_buffer_empty(check1[i].nonce, check1[i].nonce_length) == TRUE) - { - nonce = NULL; - check1[i].nonce_length = 0; - } - else - nonce = check1[i].nonce; - - if (is_buffer_empty(check1[i].additional_data, check1[i].additional_data_length) == TRUE) - { - additional_data = NULL; - check1[i].additional_data_length = 0; - } - else - additional_data = check1[i].additional_data; - - /* Process an authenticated encryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_ENCRYPT, check1[i].key_handle, - check1[i].key_alg, nonce, check1[i].nonce_length, additional_data, - check1[i].additional_data_length, check1[i].plaintext, - check1[i].plaintext_length, ciphertext, check1[i].ciphertext_size, - &ciphertext_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Check if the length matches */ - TEST_ASSERT_EQUAL(ciphertext_length, - check1[i].expected_ciphertext_length, - TEST_CHECKPOINT_NUM(7)); - - /* Check if the data matches */ - TEST_ASSERT_MEMCMP(ciphertext, check1[i].expected_ciphertext, ciphertext_length, - TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_aead_encrypt_negative_test(security_t caller) -{ - int32_t i, status; - uint8_t ciphertext[BUFFER_SIZE]; - psa_key_policy_t policy; - size_t ciphertext_length; - int num_checks = sizeof(check2)/sizeof(check2[0]); - uint8_t *nonce, *additional_data; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - if (is_buffer_empty(check2[i].nonce, check2[i].nonce_length) == TRUE) - { - nonce = NULL; - check2[i].nonce_length = 0; - } - else - nonce = check2[i].nonce; - - if (is_buffer_empty(check2[i].additional_data, check2[i].additional_data_length) == TRUE) - { - additional_data = NULL; - check2[i].additional_data_length = 0; - } - else - additional_data = check2[i].additional_data; - - val->print(PRINT_TEST, "[Check %d] Test psa_aead_encrypt - invalid key handle\n", - g_test_count++); - /* Process an authenticated encryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_ENCRYPT, check2[i].key_handle, - check2[i].key_alg, nonce, check2[i].nonce_length, additional_data, - check2[i].additional_data_length, check2[i].plaintext, - check2[i].plaintext_length, ciphertext, check2[i].ciphertext_size, - &ciphertext_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_aead_encrypt - zero as key handle\n", - g_test_count++); - /* Process an authenticated encryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_ENCRYPT, 0, - check2[i].key_alg, nonce, check2[i].nonce_length, additional_data, - check2[i].additional_data_length, check2[i].plaintext, - check2[i].plaintext_length, ciphertext, check2[i].ciphertext_size, - &ciphertext_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_aead_encrypt - empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Process an authenticated encryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_ENCRYPT, check2[i].key_handle, - check2[i].key_alg, nonce, check2[i].nonce_length, additional_data, - check2[i].additional_data_length, check2[i].plaintext, - check2[i].plaintext_length, ciphertext, check2[i].ciphertext_size, - &ciphertext_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.h deleted file mode 100644 index 5060e3e953..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C024_CLIENT_TESTS_H_ -#define _TEST_C024_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c024) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c024_crypto_list[]; - -int32_t psa_aead_encrypt_test(security_t caller); -int32_t psa_aead_encrypt_negative_test(security_t caller); - -#endif /* _TEST_C024_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_data.h deleted file mode 100644 index 9f52ecb8de..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_data.h +++ /dev/null @@ -1,180 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -#define EMPTY_KEY_SLOT 31 - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t nonce[16]; - size_t nonce_length; - uint8_t additional_data[32]; - size_t additional_data_length; - uint8_t plaintext[30]; - size_t plaintext_length; - uint8_t expected_ciphertext[45]; - size_t ciphertext_size; - size_t expected_ciphertext_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_CCM -#ifdef ARCH_TEST_AES_128 -{"Test psa_aead_encrypt - CCM - 16B AES - 13B nounce & 8B addi data\n", 1, PSA_KEY_TYPE_AES, -{0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3, 0x25, 0xA7, 0x62, 0x36, 0xDF, - 0x93, 0xCC, 0x6B}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CCM, -{0x00, 0x41, 0x2B, 0x4E, 0xA9, 0xCD, 0xBE, 0x3C, 0x96, 0x96, 0x76, 0x6C, 0xFA}, - 13, -{0x0B, 0xE1, 0xA8, 0x8B, 0xAC, 0xE0, 0x18, 0xB1}, 8, -{0x08, 0xE8, 0xCF, 0x97, 0xD8, 0x20, 0xEA, 0x25, 0x84, 0x60, 0xE9, 0x6A, 0xD9, - 0xCF, 0x52, 0x89, 0x05, 0x4D, 0x89, 0x5C, 0xEA, 0xC4, 0x7C}, 23, -{0x4C, 0xB9, 0x7F, 0x86, 0xA2, 0xA4, 0x68, 0x9A, 0x87, 0x79, 0x47, 0xAB, 0x80, - 0x91, 0xEF, 0x53, 0x86, 0xA6, 0xFF, 0xBD, 0xD0, 0x80, 0xF8, 0x12, 0x03, 0x33, - 0xD1, 0xFC, 0xB6, 0x91, 0xF3, 0x40, 0x6C, 0xBF, 0x53, 0x1F, 0x83, 0xA4, 0xD8}, - BUFFER_SIZE, 39, PSA_SUCCESS -}, - -{"Test psa_aead_encrypt - AES-CCM\n", 2, PSA_KEY_TYPE_AES, -{0x41, 0x89, 0x35, 0x1B, 0x5C, 0xAE, 0xA3, 0x75, 0xA0, 0x29, 0x9E, 0x81, 0xC6, - 0x21, 0xBF, 0x43}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CCM, -{0x48, 0xc0, 0x90, 0x69, 0x30, 0x56, 0x1e, 0x0a, 0xb0, 0xef, 0x4c, 0xd9, 0x72}, - 13, -{0x40, 0xa2, 0x7c, 0x1d, 0x1e, 0x23, 0xea, 0x3d, 0xbe, 0x80, 0x56, 0xb2, 0x77, - 0x48, 0x61, 0xa4, 0xa2, 0x01, 0xcc, 0xe4, 0x9f, 0x19, 0x99, 0x7d, 0x19, 0x20, - 0x6d, 0x8c, 0x8a, 0x34, 0x39, 0x51}, 32, -{0x45, 0x35, 0xd1, 0x2b, 0x43, 0x77, 0x92, 0x8a, 0x7c, 0x0a, 0x61, 0xc9, 0xf8, - 0x25, 0xa4, 0x86, 0x71, 0xea, 0x05, 0x91, 0x07, 0x48, 0xc8, 0xef}, 24, -{0x26, 0xc5, 0x69, 0x61, 0xc0, 0x35, 0xa7, 0xe4, 0x52, 0xcc, 0xe6, 0x1b, 0xc6, - 0xee, 0x22, 0x0d, 0x77, 0xb3, 0xf9, 0x4d, 0x18, 0xfd, 0x10, 0xb6, 0xd8, 0x0e, - 0x8b, 0xf8, 0x0f, 0x4a, 0x46, 0xca, 0xb0, 0x6d, 0x43, 0x13, 0xf0, 0xdb, 0x9b, - 0xe9}, BUFFER_SIZE, 40, PSA_SUCCESS -}, - -{"Test psa_aead_encrypt - AES-CCM 24 bytes Tag length = 4\n", 3, PSA_KEY_TYPE_AES, -{0x41, 0x89, 0x35, 0x1B, 0x5C, 0xAE, 0xA3, 0x75, 0xA0, 0x29, 0x9E, 0x81, 0xC6, - 0x21, 0xBF, 0x43}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, - PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_CCM, 4), -{0x48, 0xc0, 0x90, 0x69, 0x30, 0x56, 0x1e, 0x0a, 0xb0, 0xef, 0x4c, 0xd9, 0x72}, - 13, -{0x40, 0xa2, 0x7c, 0x1d, 0x1e, 0x23, 0xea, 0x3d, 0xbe, 0x80, 0x56, 0xb2, 0x77, - 0x48, 0x61, 0xa4, 0xa2, 0x01, 0xcc, 0xe4, 0x9f, 0x19, 0x99, 0x7d, 0x19, 0x20, - 0x6d, 0x8c, 0x8a, 0x34, 0x39, 0x51}, 32, -{0x45, 0x35, 0xd1, 0x2b, 0x43, 0x77, 0x92, 0x8a, 0x7c, 0x0a, 0x61, 0xc9, 0xf8, - 0x25, 0xa4, 0x86, 0x71, 0xea, 0x05, 0x91, 0x07, 0x48, 0xc8, 0xef}, 24, -{0x26, 0xc5, 0x69, 0x61, 0xc0, 0x35, 0xa7, 0xe4, 0x52, 0xcc, 0xe6, 0x1b, 0xc6, - 0xee, 0x22, 0x0d, 0x77, 0xb3, 0xf9, 0x4d, 0x18, 0xfd, 0x10, 0xb6, 0x64, 0x3b, - 0x4f, 0x39}, - BUFFER_SIZE, 28, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_GCM -#ifdef ARCH_TEST_AES_128 -{"Test psa_aead_encrypt - GCM - 16B AES - 12B Nounce & 12B addi data\n", -4, PSA_KEY_TYPE_AES, -{0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, 0x19, 0x88, 0xd0, 0xc3, 0x60, - 0x7e, 0xae, 0x1f}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_GCM, -{0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00, 0xa2, 0xfc, 0xa1, 0xa3}, 12, -{0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, 12, -{0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00, 0x80, 0x01, 0x44, 0x1f, 0x40, - 0x67, 0x93, 0xb6, 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff, 0x01, 0x02, - 0x02, 0x01}, 28, -{0xFB, 0xA2, 0xCA, 0x84, 0x5E, 0x5D, 0xF9, 0xF0, 0xF2, 0x2C, 0x3E, 0x6E, 0x86, - 0xDD, 0x83, 0x1E, 0x1F, 0xC6, 0x57, 0x92, 0xCD, 0x1A, 0xF9, 0x13, 0x0E, 0x13, - 0x79, 0xED, 0x36, 0x9F, 0x07, 0x1F, 0x35, 0xE0, 0x34, 0xBE, 0x95, 0xF1, 0x12, - 0xE4, 0xE7, 0xD0, 0x5D, 0x35}, - BUFFER_SIZE, 44, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CCM -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_aead_encrypt - DES Key\n", 5, PSA_KEY_TYPE_DES, -{0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CCM, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B}, 12, -{0xEC, 0x46, 0xBB, 0x63, 0xB0, 0x25, 0x20, 0xC3, 0x3C, 0x49, 0xFD, 0x70}, 12, -{0xB9, 0x6B, 0x49, 0xE2, 0x1D, 0x62, 0x17, 0x41, 0x63, 0x28, 0x75, 0xDB, 0x7F, - 0x6C, 0x92, 0x43, 0xD2, 0xD7, 0xC2}, 19, -{0}, BUFFER_SIZE, 0, PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CIPER_MODE_CFB -{"Test psa_aead_encrypt - Unsupported Algorithm\n", 6, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CFB, -{0}, 13, {0}, 0, "hello world", 11, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - BUFFER_SIZE, 27, PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_GCM -{"Test psa_aead_encrypt - Invalid key usage\n", 7, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_GCM, -{0}, 13, {0}, 0, "hello world", 11, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - BUFFER_SIZE, 27, PSA_ERROR_NOT_PERMITTED -}, - -{"Test psa_aead_encrypt - Small output buffer size\n", 8, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_GCM, -{0}, 13, {0}, 0, "hello world", 11, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - 10, 27, PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_GCM -#ifdef ARCH_TEST_AES_128 -{"Test psa_aead_encrypt - Negative case\n", 9, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_GCM, -{0}, 13, {0}, 0, "hello world", 11, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - BUFFER_SIZE, 27, PSA_ERROR_EMPTY_SLOT -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_entry.c deleted file mode 100644 index caf74156de..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c024.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 24) -#define TEST_DESC "Testing crypto AEAD APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c024_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/main.c deleted file mode 100644 index 3919ac4c94..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c025(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c025, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.c deleted file mode 100644 index d8d15ec701..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.c +++ /dev/null @@ -1,211 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c025.h" -#include "test_data.h" - -client_test_t test_c025_crypto_list[] = { - NULL, - psa_aead_decrypt_test, - psa_aead_decrypt_negative_test, - NULL, -}; - -static int g_test_count = 1; - -static bool_t is_buffer_empty(uint8_t *buffer, size_t size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (buffer[i] != 0) - return FALSE; - } - - return TRUE; -} - -int32_t psa_aead_decrypt_test(security_t caller) -{ - int32_t i, status; - uint8_t plaintext[BUFFER_SIZE]; - psa_key_policy_t policy; - size_t plaintext_length; - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint8_t *nonce, *additional_data; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - memset(plaintext, 0, sizeof(plaintext)); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (is_buffer_empty(check1[i].nonce, check1[i].nonce_length) == TRUE) - { - nonce = NULL; - check1[i].nonce_length = 0; - } - else - nonce = check1[i].nonce; - - if (is_buffer_empty(check1[i].additional_data, check1[i].additional_data_length) == TRUE) - { - additional_data = NULL; - check1[i].additional_data_length = 0; - } - else - additional_data = check1[i].additional_data; - - /* Process an authenticated decryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, check1[i].key_handle, - check1[i].key_alg, nonce, check1[i].nonce_length, additional_data, - check1[i].additional_data_length, check1[i].ciphertext, check1[i].ciphertext_size, - plaintext, check1[i].plaintext_size, &plaintext_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Check if the length matches */ - TEST_ASSERT_EQUAL(plaintext_length, check1[i].expected_plaintext_length, - TEST_CHECKPOINT_NUM(7)); - - /* Check if the data matches */ - TEST_ASSERT_MEMCMP(plaintext, check1[i].expected_plaintext, plaintext_length, - TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_aead_decrypt_negative_test(security_t caller) -{ - int32_t i, status; - uint8_t plaintext[BUFFER_SIZE]; - psa_key_policy_t policy; - size_t plaintext_length; - int num_checks = sizeof(check2)/sizeof(check2[0]); - uint8_t *nonce, *additional_data; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - if (is_buffer_empty(check2[i].nonce, check2[i].nonce_length) == TRUE) - { - nonce = NULL; - check2[i].nonce_length = 0; - } - else - nonce = check2[i].nonce; - - if (is_buffer_empty(check2[i].additional_data, check2[i].additional_data_length) == TRUE) - { - additional_data = NULL; - check2[i].additional_data_length = 0; - } - else - additional_data = check2[i].additional_data; - - val->print(PRINT_TEST, "[Check %d] Test psa_aead_decrypt - invalid key handle\n", - g_test_count++); - /* Process an authenticated decryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, check2[i].key_handle, - check2[i].key_alg, nonce, check2[i].nonce_length, additional_data, - check2[i].additional_data_length, check2[i].ciphertext, check2[i].ciphertext_size, - plaintext, check2[i].plaintext_size, &plaintext_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_aead_decrypt - zero as key handle\n", - g_test_count++); - /* Process an authenticated decryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, 0, - check2[i].key_alg, nonce, check2[i].nonce_length, additional_data, - check2[i].additional_data_length, check2[i].ciphertext, check2[i].ciphertext_size, - plaintext, check2[i].plaintext_size, &plaintext_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_aead_decrypt - empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Process an authenticated decryption operation */ - status = val->crypto_function(VAL_CRYPTO_AEAD_DECRYPT, check2[i].key_handle, - check2[i].key_alg, nonce, check2[i].nonce_length, additional_data, - check2[i].additional_data_length, check2[i].ciphertext, check2[i].ciphertext_size, - plaintext, check2[i].plaintext_size, &plaintext_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.h deleted file mode 100644 index 5b0667b838..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C025_CLIENT_TESTS_H_ -#define _TEST_C025_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c025) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c025_crypto_list[]; - -int32_t psa_aead_decrypt_test(security_t caller); -int32_t psa_aead_decrypt_negative_test(security_t caller); - -#endif /* _TEST_C025_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_data.h deleted file mode 100644 index 4ad0e17d40..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_data.h +++ /dev/null @@ -1,209 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -#define EMPTY_KEY_SLOT 31 - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t nonce[16]; - size_t nonce_length; - uint8_t additional_data[32]; - size_t additional_data_length; - uint8_t expected_plaintext[30]; - size_t plaintext_size; - uint8_t ciphertext[45]; - size_t ciphertext_size; - size_t expected_plaintext_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CCM -{"Test psa_aead_decrypt - CCM - 16B AES - 13B nounce & 8B addi data\n", 1, PSA_KEY_TYPE_AES, -{0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3, 0x25, 0xA7, 0x62, 0x36, 0xDF, - 0x93, 0xCC, 0x6B}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CCM, -{0x00, 0x41, 0x2B, 0x4E, 0xA9, 0xCD, 0xBE, 0x3C, 0x96, 0x96, 0x76, 0x6C, 0xFA}, - 13, -{0x0B, 0xE1, 0xA8, 0x8B, 0xAC, 0xE0, 0x18, 0xB1}, 8, -{0x08, 0xE8, 0xCF, 0x97, 0xD8, 0x20, 0xEA, 0x25, 0x84, 0x60, 0xE9, 0x6A, 0xD9, - 0xCF, 0x52, 0x89, 0x05, 0x4D, 0x89, 0x5C, 0xEA, 0xC4, 0x7C}, BUFFER_SIZE, -{0x4C, 0xB9, 0x7F, 0x86, 0xA2, 0xA4, 0x68, 0x9A, 0x87, 0x79, 0x47, 0xAB, 0x80, - 0x91, 0xEF, 0x53, 0x86, 0xA6, 0xFF, 0xBD, 0xD0, 0x80, 0xF8, 0x12, 0x03, 0x33, - 0xD1, 0xFC, 0xB6, 0x91, 0xF3, 0x40, 0x6C, 0xBF, 0x53, 0x1F, 0x83, 0xA4, 0xD8}, - 39, 23, PSA_SUCCESS -}, - -{"Test psa_aead_encrypt - AES-CCM\n", 2, PSA_KEY_TYPE_AES, -{0x41, 0x89, 0x35, 0x1B, 0x5C, 0xAE, 0xA3, 0x75, 0xA0, 0x29, 0x9E, 0x81, 0xC6, - 0x21, 0xBF, 0x43}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CCM, -{0x48, 0xc0, 0x90, 0x69, 0x30, 0x56, 0x1e, 0x0a, 0xb0, 0xef, 0x4c, 0xd9, 0x72}, - 13, -{0x40, 0xa2, 0x7c, 0x1d, 0x1e, 0x23, 0xea, 0x3d, 0xbe, 0x80, 0x56, 0xb2, 0x77, - 0x48, 0x61, 0xa4, 0xa2, 0x01, 0xcc, 0xe4, 0x9f, 0x19, 0x99, 0x7d, 0x19, 0x20, - 0x6d, 0x8c, 0x8a, 0x34, 0x39, 0x51}, 32, -{0x45, 0x35, 0xd1, 0x2b, 0x43, 0x77, 0x92, 0x8a, 0x7c, 0x0a, 0x61, 0xc9, 0xf8, - 0x25, 0xa4, 0x86, 0x71, 0xea, 0x05, 0x91, 0x07, 0x48, 0xc8, 0xef}, BUFFER_SIZE, -{0x26, 0xc5, 0x69, 0x61, 0xc0, 0x35, 0xa7, 0xe4, 0x52, 0xcc, 0xe6, 0x1b, 0xc6, - 0xee, 0x22, 0x0d, 0x77, 0xb3, 0xf9, 0x4d, 0x18, 0xfd, 0x10, 0xb6, 0xd8, 0x0e, - 0x8b, 0xf8, 0x0f, 0x4a, 0x46, 0xca, 0xb0, 0x6d, 0x43, 0x13, 0xf0, 0xdb, 0x9b, - 0xe9}, 40, 24, PSA_SUCCESS -}, - -{"Test psa_aead_encrypt - AES-CCM 24 bytes Tag length = 4\n", 3, PSA_KEY_TYPE_AES, -{0x41, 0x89, 0x35, 0x1B, 0x5C, 0xAE, 0xA3, 0x75, 0xA0, 0x29, 0x9E, 0x81, 0xC6, - 0x21, 0xBF, 0x43}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, - PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_CCM, 4), -{0x48, 0xc0, 0x90, 0x69, 0x30, 0x56, 0x1e, 0x0a, 0xb0, 0xef, 0x4c, 0xd9, 0x72}, - 13, -{0x40, 0xa2, 0x7c, 0x1d, 0x1e, 0x23, 0xea, 0x3d, 0xbe, 0x80, 0x56, 0xb2, 0x77, - 0x48, 0x61, 0xa4, 0xa2, 0x01, 0xcc, 0xe4, 0x9f, 0x19, 0x99, 0x7d, 0x19, 0x20, - 0x6d, 0x8c, 0x8a, 0x34, 0x39, 0x51}, 32, -{0x45, 0x35, 0xd1, 0x2b, 0x43, 0x77, 0x92, 0x8a, 0x7c, 0x0a, 0x61, 0xc9, 0xf8, - 0x25, 0xa4, 0x86, 0x71, 0xea, 0x05, 0x91, 0x07, 0x48, 0xc8, 0xef}, BUFFER_SIZE, -{0x26, 0xc5, 0x69, 0x61, 0xc0, 0x35, 0xa7, 0xe4, 0x52, 0xcc, 0xe6, 0x1b, 0xc6, - 0xee, 0x22, 0x0d, 0x77, 0xb3, 0xf9, 0x4d, 0x18, 0xfd, 0x10, 0xb6, 0x64, 0x3b, - 0x4f, 0x39}, - 28, 24, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_GCM -{"Test psa_aead_decrypt - GCM - 16B AES - 12B Nounce & 12B addi data\n", 4, PSA_KEY_TYPE_AES, -{0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, 0x19, 0x88, 0xd0, 0xc3, 0x60, - 0x7e, 0xae, 0x1f}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_GCM, -{0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00, 0xa2, 0xfc, 0xa1, 0xa3}, 12, -{0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, 12, -{0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00, 0x80, 0x01, 0x44, 0x1f, 0x40, - 0x67, 0x93, 0xb6, 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff, 0x01, 0x02, - 0x02, 0x01}, BUFFER_SIZE, -{0xFB, 0xA2, 0xCA, 0x84, 0x5E, 0x5D, 0xF9, 0xF0, 0xF2, 0x2C, 0x3E, 0x6E, 0x86, - 0xDD, 0x83, 0x1E, 0x1F, 0xC6, 0x57, 0x92, 0xCD, 0x1A, 0xF9, 0x13, 0x0E, 0x13, - 0x79, 0xED, 0x36, 0x9F, 0x07, 0x1F, 0x35, 0xE0, 0x34, 0xBE, 0x95, 0xF1, 0x12, - 0xE4, 0xE7, 0xD0, 0x5D, 0x35}, - 44, 28, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CCM -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_aead_decrypt - DES Key\n", 5, PSA_KEY_TYPE_DES, -{0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CCM, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B}, 12, -{0xEC, 0x46, 0xBB, 0x63, 0xB0, 0x25, 0x20, 0xC3, 0x3C, 0x49, 0xFD, 0x70}, 12, -{0xB9, 0x6B, 0x49, 0xE2, 0x1D, 0x62, 0x17, 0x41, 0x63, 0x28, 0x75, 0xDB, 0x7F, - 0x6C, 0x92, 0x43, 0xD2, 0xD7, 0xC2}, BUFFER_SIZE, -{0}, 11, 0, PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CIPER_MODE_CFB -{"Test psa_aead_decrypt - Unsupported Algorithm\n", 6, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CFB, -{0}, 13, {0}, 0, "hello world", BUFFER_SIZE, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - 27, 11, PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_GCM -{"Test psa_aead_decrypt - Invalid key usage\n", 7, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_GCM, -{0}, 13, {0}, 0, "hello world", BUFFER_SIZE, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - 27, 11, PSA_ERROR_NOT_PERMITTED -}, - -{"Test psa_aead_decrypt - Small output buffer size\n", 8, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_GCM, -{0}, 13, {0}, 0, "hello world", 10, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - 27, 11, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif - -#ifdef ARCH_TEST_CCM -{"Test psa_aead_decrypt - Invalid cipher text\n", 9, PSA_KEY_TYPE_AES, -{0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3, 0x25, 0xA7, 0x62, 0x36, 0xDF, - 0x93, 0xCC, 0x6B}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CCM, -{0x00, 0x41, 0x2B, 0x4E, 0xA9, 0xCD, 0xBE, 0x3C, 0x96, 0x96, 0x76, 0x6C, 0xFA}, - 13, -{0x0B, 0xE1, 0xA8, 0x8B, 0xAC, 0xE0, 0x18, 0xB1}, 8, -{0x08, 0xE8, 0xCF, 0x97, 0xD8, 0x20, 0xEA, 0x25, 0x84, 0x60, 0xE9, 0x6A, 0xD9, - 0xCF, 0x52, 0x89, 0x05, 0x4D, 0x89, 0x5C, 0xEA, 0xC4, 0x7C}, BUFFER_SIZE, -{0x4C, 0xB8, 0x7F, 0x86, 0xA2, 0xA4, 0x68, 0x9A, 0x87, 0x79, 0x47, 0xAB, 0x80, - 0x91, 0xEF, 0x53, 0x86, 0xA6, 0xFF, 0xBD, 0xD0, 0x80, 0xF8, 0x12, 0x03, 0x33, - 0xD1, 0xFC, 0xB6, 0x91, 0xF3, 0x40, 0x6C, 0xBF, 0x53, 0x1F, 0x83, 0xA4, 0xD8}, - 39, 23, PSA_ERROR_INVALID_SIGNATURE -}, - -{"Test psa_aead_decrypt - Invalid cipher text size\n", 10, PSA_KEY_TYPE_AES, -{0xD7, 0x82, 0x8D, 0x13, 0xB2, 0xB0, 0xBD, 0xC3, 0x25, 0xA7, 0x62, 0x36, 0xDF, - 0x93, 0xCC, 0x6B}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CCM, -{0x00, 0x41, 0x2B, 0x4E, 0xA9, 0xCD, 0xBE, 0x3C, 0x96, 0x96, 0x76, 0x6C, 0xFA}, - 13, -{0x0B, 0xE1, 0xA8, 0x8B, 0xAC, 0xE0, 0x18, 0xB1}, 8, -{0x08, 0xE8, 0xCF, 0x97, 0xD8, 0x20, 0xEA, 0x25, 0x84, 0x60, 0xE9, 0x6A, 0xD9, - 0xCF, 0x52, 0x89, 0x05, 0x4D, 0x89, 0x5C, 0xEA, 0xC4, 0x7C}, BUFFER_SIZE, -{0x4C, 0xB9, 0x7F, 0x86, 0xA2, 0xA4, 0x68, 0x9A, 0x87, 0x79, 0x47, 0xAB, 0x80, - 0x91, 0xEF, 0x53, 0x86, 0xA6, 0xFF, 0xBD, 0xD0, 0x80, 0xF8, 0x12, 0x03, 0x33, - 0xD1, 0xFC, 0xB6, 0x91, 0xF3, 0x40, 0x6C, 0xBF, 0x53, 0x1F, 0x83, 0xA4}, - 38, 23, PSA_ERROR_INVALID_SIGNATURE -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_GCM -#ifdef ARCH_TEST_AES_128 -{"Test psa_aead_decrypt - Negative cases\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_GCM, -{0}, 13, {0}, 0, "hello world", BUFFER_SIZE, -{0x5D, 0xC1, 0x72, 0x23, 0x66, 0x96, 0xFD, 0xFC, 0x93, 0x06, 0x27, 0x52, 0xC7, - 0x0A, 0xCB, 0x36, 0x55, 0x30, 0xC9, 0x48, 0x8F, 0x5E, 0xA5, 0xB9, 0x51, 0xFB, - 0x4E}, - 11, 27, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_entry.c deleted file mode 100644 index f71ac410df..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c025.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 25) -#define TEST_DESC "Testing crypto AEAD APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c025_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/main.c deleted file mode 100644 index ef298086c3..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c026(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c026, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.c deleted file mode 100644 index 9f43a7ab40..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.c +++ /dev/null @@ -1,149 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c026.h" -#include "test_data.h" - -client_test_t test_c026_crypto_list[] = { - NULL, - psa_mac_sign_setup_test, - psa_mac_sign_setup_negative_test, - NULL, -}; - -static int g_test_count = 1; -static psa_mac_operation_t operation; - -int32_t psa_mac_sign_setup_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - psa_key_policy_t policy; - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_mac_sign_setup_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - psa_key_policy_t policy; - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_mac_sign_setup with invalid key handle\n", - g_test_count++); - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_mac_sign_setup with zero key handle\n", - g_test_count++); - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - 0, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_mac_sign_setup with empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.h deleted file mode 100644 index 8d3e052e58..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_c026.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C026_CLIENT_TESTS_H_ -#define _TEST_C026_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c026) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c026_crypto_list[]; - -int32_t psa_mac_sign_setup_test(security_t caller); -int32_t psa_mac_sign_setup_negative_test(security_t caller); -#endif /* _TEST_C026_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_data.h deleted file mode 100644 index df4d3a5144..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_data.h +++ /dev/null @@ -1,155 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -#define EMPTY_KEY_SLOT 31 - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_sign_setup 64 Byte HMAC\n", 1, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_sign_setup 16 Byte AES - CMAC\n", 2, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_GMAC -{"Test psa_mac_sign_setup 16 Byte AES - GMAC\n", 3, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_GMAC, - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_CMAC -#ifdef ARCH_TEST_HMAC -{"Test psa_mac_sign_setup incompactible HMAC for CMAC\n", 4, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -{"Test psa_mac_sign_setup invalid usage\n", 5, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CMAC, - PSA_ERROR_NOT_PERMITTED -}, -#endif - -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_sign_setup invalid key type\n", 7, PSA_KEY_TYPE_RAW_DATA, -{0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_TRUNCATED_MAC -{"Test psa_mac_sign_setup truncated MAC too large\n", 8, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_SIGN, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 33), - PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_mac_sign_setup truncated MAC too small\n", 9, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_SIGN, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 1), - PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -{"Test psa_mac_sign_setup bad algorithm (unknown MAC algorithm)\n", 10, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(0), - PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_mac_sign_setup bad algorithm (not a MAC algorithm)\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CBC_NO_PADDING, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_sign_setup - Negative case\n", 12, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_entry.c deleted file mode 100644 index 89b3126670..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c026/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c026.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 26) -#define TEST_DESC "Testing crypto MAC APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c026_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/main.c deleted file mode 100644 index 3f88f244a4..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c027(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c027, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.c deleted file mode 100644 index e761848f09..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.c +++ /dev/null @@ -1,138 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c027.h" -#include "test_data.h" - -client_test_t test_c027_crypto_list[] = { - NULL, - psa_mac_update_test, - psa_mac_update_invalid_operator_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_mac_update_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - size_t length; - psa_key_policy_t policy; - psa_mac_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - memset(data, 0, sizeof(data)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Add a message fragment to a multipart MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_UPDATE, &operation, check1[i].data, - check1[i].data_size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(7)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - continue; - } - - /* Finish the calculation of the MAC of a message */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_FINISH, &operation, data, - sizeof(data)/sizeof(data[0]), &length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Add a message fragment to the same multipart MAC operation*/ - status = val->crypto_function(VAL_CRYPTO_MAC_UPDATE, &operation, check1[i].data, - check1[i].data_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(10)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(11)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_mac_update_invalid_operator_test(security_t caller) -{ - psa_mac_operation_t operation; - int32_t status; - - memset(data, 0, sizeof(data)); - memset(&operation, 0, sizeof(operation)); - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "Test psa_mac_update without mac setup\n", 0); - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_UPDATE, &operation, data, - sizeof(data)/sizeof(data[0])); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(2)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.h deleted file mode 100644 index ea4c22fc36..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_c027.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C027_CLIENT_TESTS_H_ -#define _TEST_C027_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c027) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c027_crypto_list[]; - -int32_t psa_mac_update_test(security_t caller); -int32_t psa_mac_update_invalid_operator_test(security_t caller); -#endif /* _TEST_C027_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_data.h deleted file mode 100644 index 6537c7eefe..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_data.h +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - uint8_t data[64]; - size_t data_size; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_update 64 Byte HMAC SHA256\n", 1, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, "hello world", 11, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_update 16 Byte AES - CMAC\n", 2, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, "hello world", 11, PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA512 -{"Test psa_mac_update 32 Byte HMAC SHA512\n", 3, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, - 32, "hello world", 11, PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_512), - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_entry.c deleted file mode 100644 index fedebfce98..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c027/test_entry.c +++ /dev/null @@ -1,52 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c027.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 27) -#define TEST_DESC "Testing crypto MAC APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c027_crypto_list, FALSE); - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/main.c deleted file mode 100644 index 7e3d64c05a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c028(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c028, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.c deleted file mode 100644 index 089827860b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.c +++ /dev/null @@ -1,123 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c028.h" -#include "test_data.h" - -client_test_t test_c028_crypto_list[] = { - NULL, - psa_mac_sign_finish_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_mac_sign_finish_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - size_t length; - psa_key_policy_t policy; - psa_mac_operation_t operation; - - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - memset(data, 0, sizeof(data)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Add a message fragment to a multipart MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_UPDATE, &operation, check1[i].data, - check1[i].data_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Finish the calculation of the MAC of a message */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_FINISH, &operation, data, - check1[i].mac_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(8)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - continue; - } - - /* Check if the MAC length matches with the expected length */ - TEST_ASSERT_EQUAL(length, check1[i].expected_length, TEST_CHECKPOINT_NUM(10)); - - /* Check if the MAC data matches with the expected data */ - TEST_ASSERT_MEMCMP(check1[i].expected_data, data, length, TEST_CHECKPOINT_NUM(11)); - - memset(data, 0, sizeof(data)); - - /* Finish the calculation of the MAC of a message using same operation - * should return error - */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_FINISH, &operation, data, - check1[i].mac_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(12)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(13)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.h deleted file mode 100644 index a8b1b0f03e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_c028.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C028_CLIENT_TESTS_H_ -#define _TEST_C028_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c028) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c028_crypto_list[]; - -int32_t psa_mac_sign_finish_test(security_t caller); -#endif /* _TEST_C028_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_data.h deleted file mode 100644 index 215307163d..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_data.h +++ /dev/null @@ -1,114 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - uint8_t data[16]; - size_t data_size; - uint8_t expected_data[64]; - size_t mac_size; - size_t expected_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_sign_finish HMAC SHA 224\n", 1, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, 0x68, 0x32, 0x10, 0x7c, 0xd4, - 0x9d, 0xf3, 0x3f, 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f, 0x53, 0x68, - 0x4b, 0x22}, 64, 28, - PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_224), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_sign_finish HMAC SHA 256\n", 2, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, - 0x0b, 0xf1, 0x2b, 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, - 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7}, 64, 32, - PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_mac_sign_finish HMAC SHA 512\n", 3, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d, 0x4f, 0xf0, 0xb4, 0x24, 0x1a, - 0x1d, 0x6c, 0xb0, 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78, 0x7a, 0xd0, - 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde, 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, - 0x02, 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4, 0xbe, 0x9d, 0x91, 0x4e, - 0xeb, 0x61, 0xf1, 0x70, 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54}, 64, 64, - PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_512), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_sign_finish HMAC SHA 224 (truncated to 8 Byte)\n", 4, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, 0x68}, 64, 8, - PSA_KEY_USAGE_SIGN, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_224), 8), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_sign_finish CMAC AES 128\n", 5, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, 16, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x9A, 0x8F, 0xFF, 0x8D, 0xA3, 0x5B, 0x97, 0xCB, 0x4C, 0x95, 0xF0, 0xFA, 0x6A, - 0xE7, 0xE0, 0x77}, 64, 16, - PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_SUCCESS -}, - -{"Test psa_mac_sign_finish small size buffer\n", 6, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, 16, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x9A, 0x8F, 0xFF, 0x8D, 0xA3, 0x5B, 0x97, 0xCB, 0x4C, 0x95, 0xF0, 0xFA, 0x6A, - 0xE7, 0xE0, 0x77}, 8, 16, - PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_entry.c deleted file mode 100644 index 86dda651fd..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c028/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c028.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 28) -#define TEST_DESC "Testing crypto MAC APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c028_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/main.c deleted file mode 100644 index 372866ab92..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c029(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c029, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.c deleted file mode 100644 index d732d92044..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.c +++ /dev/null @@ -1,144 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c029.h" -#include "test_data.h" - -client_test_t test_c029_crypto_list[] = { - NULL, - psa_mac_verify_setup_test, - psa_mac_verify_setup_negative_test, - NULL, -}; - -static int g_test_count = 1; -static psa_mac_operation_t operation; - -int32_t psa_mac_verify_setup_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - psa_key_policy_t policy; - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC verification operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_mac_verify_setup_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - psa_key_policy_t policy; - int32_t i, status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_mac_verify_setup invalid key handle\n", - g_test_count++); - /* Start a multipart MAC verification operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_mac_verify_setup zero as key handle\n", - g_test_count++); - /* Start a multipart MAC verification operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_SETUP, &operation, - 0, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - val->print(PRINT_TEST, "[Check %d] Test psa_mac_verify_setup empty key handle\n", - g_test_count++); - /* Start a multipart MAC verification operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(6)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.h deleted file mode 100644 index b549fed674..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_c029.h +++ /dev/null @@ -1,32 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C029_CLIENT_TESTS_H_ -#define _TEST_C029_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c029) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c029_crypto_list[]; - -int32_t psa_mac_verify_setup_test(security_t caller); -int32_t psa_mac_verify_setup_negative_test(security_t caller); - -#endif /* _TEST_C029_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_data.h deleted file mode 100644 index 4adad3a3c0..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_data.h +++ /dev/null @@ -1,158 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -#define EMPTY_KEY_SLOT 31 - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_verify_setup 64 Byte HMAC\n", 1, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_verify_setup 16 Byte AES - CMAC\n", 2, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_CMAC, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_GMAC -{"Test psa_mac_verify_setup 16 Byte AES - GMAC\n", 3, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_GMAC, - PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_CMAC -#ifdef ARCH_TEST_HMAC -{"Test psa_mac_verify_setup incompactible HMAC for CMAC\n", 4, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_CMAC, - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_AES_128 -{"Test psa_mac_verify_setup invalid usage\n", 5, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_EXPORT, PSA_ALG_CMAC, - PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif - -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_verify_setup invalid key type\n", 6, PSA_KEY_TYPE_RAW_DATA, -{0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_verify_setup truncated MAC too large\n", 7, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_VERIFY, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 33), - PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_mac_verify_setup truncated MAC too small\n", 8, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_VERIFY, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_256), 1), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_AES_128 -{"Test psa_mac_verify_setup bad algorithm (unknown MAC algorithm)\n", 9, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(0), - PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_mac_verify_setup bad algorithm (not a MAC algorithm)\n", 10, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0x00}, - AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, PSA_ALG_CBC_NO_PADDING, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_verify_setup 64 negative case\n", 11, PSA_KEY_TYPE_HMAC, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}, - 64, PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_entry.c deleted file mode 100644 index 78c323f3c6..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c029/test_entry.c +++ /dev/null @@ -1,52 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c029.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 29) -#define TEST_DESC "Testing crypto MAC APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c029_crypto_list, FALSE); - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/main.c deleted file mode 100644 index ea4889ca33..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c030(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c030, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.c deleted file mode 100644 index ad14048c4a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.c +++ /dev/null @@ -1,113 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c030.h" -#include "test_data.h" - -client_test_t test_c030_crypto_list[] = { - NULL, - psa_mac_verify_finish_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_mac_verify_finish_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_mac_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Add a message fragment to a multipart MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_UPDATE, &operation, check1[i].data, - check1[i].data_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Finish the calculation of the MAC of a message and compare it with - * an expected value - */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_FINISH, &operation, - check1[i].expected_mac, check1[i].mac_size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(8)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - continue; - } - - /* Finish the calculation of the MAC of a message using same operation - * should return error - */ - status = val->crypto_function(VAL_CRYPTO_MAC_VERIFY_FINISH, &operation, - check1[i].expected_mac, check1[i].mac_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(10)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(11)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.h deleted file mode 100644 index 46c27207c1..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_c030.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C030_CLIENT_TESTS_H_ -#define _TEST_C030_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c030) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c030_crypto_list[]; - -int32_t psa_mac_verify_finish_test(security_t caller); -#endif /* _TEST_C030_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_data.h deleted file mode 100644 index eb9f250196..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_data.h +++ /dev/null @@ -1,131 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - uint8_t data[16]; - size_t data_size; - uint8_t expected_mac[64]; - size_t mac_size; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_verify_finish HMAC SHA 224\n", 1, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, 0x68, 0x32, 0x10, 0x7c, 0xd4, - 0x9d, 0xf3, 0x3f, 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f, 0x53, 0x68, - 0x4b, 0x22}, 28, - PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_224), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_verify_finish HMAC SHA 256\n", 2, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, - 0x0b, 0xf1, 0x2b, 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, - 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7}, 32, - PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_mac_verify_finish HMAC SHA 512\n", 3, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d, 0x4f, 0xf0, 0xb4, 0x24, 0x1a, - 0x1d, 0x6c, 0xb0, 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78, 0x7a, 0xd0, - 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde, 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, - 0x02, 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4, 0xbe, 0x9d, 0x91, 0x4e, - 0xeb, 0x61, 0xf1, 0x70, 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54}, 64, - PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_512), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_verify_finish HMAC SHA 224 (truncated to 8 Byte)\n", 4, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, 0x68}, 8, - PSA_KEY_USAGE_VERIFY, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_224), 8), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_verify_finish CMAC AES 128\n", 5, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, 16, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x9A, 0x8F, 0xFF, 0x8D, 0xA3, 0x5B, 0x97, 0xCB, 0x4C, 0x95, 0xF0, 0xFA, 0x6A, - 0xE7, 0xE0, 0x77}, 16, - PSA_KEY_USAGE_VERIFY, PSA_ALG_CMAC, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_verify_finish small size buffer\n", 6, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, - 0x0b, 0xf1, 0x2b, 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, - 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7}, 30, - PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_ERROR_INVALID_SIGNATURE -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_verify_finish incorrect expected MAC\n", 7, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, -{0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, 8, -{0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, 0x68, 0x32, 0x10, 0x7c, 0xd4, - 0x9d, 0xf3, 0x3f, 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f, 0x53, 0x68, - 0x4b, 0x20}, 28, - PSA_KEY_USAGE_VERIFY, PSA_ALG_HMAC(PSA_ALG_SHA_224), - PSA_ERROR_INVALID_SIGNATURE -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_entry.c deleted file mode 100644 index 0188a08265..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c030/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c030.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 30) -#define TEST_DESC "Testing crypto MAC APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c030_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/main.c deleted file mode 100644 index 77a4997f6c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c031(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c031, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.c deleted file mode 100644 index 9988fae8a9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.c +++ /dev/null @@ -1,163 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c031.h" -#include "test_data.h" - -client_test_t test_c031_crypto_list[] = { - NULL, - psa_mac_abort_test, - psa_mac_abort_before_finish_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t data[BUFFER_SIZE]; - -int32_t psa_mac_abort_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_mac_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Multiple Abort a MAC operation should succeed */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_mac_abort_before_finish_test(security_t caller) -{ - size_t length; - psa_key_policy_t policy; - psa_algorithm_t key_alg = PSA_ALG_CMAC; - psa_key_usage_t usage = PSA_KEY_USAGE_SIGN; - psa_key_handle_t key_handle = 10; - psa_key_type_t key_type = PSA_KEY_TYPE_AES; - psa_mac_operation_t operation; - uint8_t key_data[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, - 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; - uint8_t input_data[] = {0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}; - size_t key_length = sizeof(key_data)/sizeof(key_data[0]); - size_t inputdata_size = sizeof(input_data)/sizeof(input_data[0]); - int32_t status; - - memset(data, 0, sizeof(data)); - memset(&operation, 0, sizeof(operation)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "Test psa_mac_sign_finish after calling psa_mac_abort\n", 0); - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, usage, key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, key_handle, key_type, key_data, - key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Start a multipart MAC calculation operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_SETUP, &operation, key_handle, key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Add a message fragment to a multipart MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_UPDATE, &operation, input_data, inputdata_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Abort a MAC operation */ - status = val->crypto_function(VAL_CRYPTO_MAC_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Finish the calculation of the MAC of a message */ - status = val->crypto_function(VAL_CRYPTO_MAC_SIGN_FINISH, &operation, data, - BUFFER_SIZE, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(9)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.h deleted file mode 100644 index 0aee628767..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_c031.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C031_CLIENT_TESTS_H_ -#define _TEST_C031_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c031) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c031_crypto_list[]; - -int32_t psa_mac_abort_test(security_t caller); -int32_t psa_mac_abort_before_finish_test(security_t caller); -#endif /* _TEST_C031_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_data.h deleted file mode 100644 index e816f812ba..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_data.h +++ /dev/null @@ -1,80 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_HMAC -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_abort HMAC SHA 224\n", 1, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, - PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_224), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_mac_abort HMAC SHA 256\n", 2, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, - PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_256), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA512 -{"Test psa_mac_abort HMAC SHA 512\n", 3, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, - PSA_KEY_USAGE_SIGN, PSA_ALG_HMAC(PSA_ALG_SHA_512), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA224 -{"Test psa_mac_abort HMAC SHA 224 (truncated to 8 Byte)\n", 4, PSA_KEY_TYPE_HMAC, -{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 20, - PSA_KEY_USAGE_SIGN, PSA_ALG_TRUNCATED_MAC(PSA_ALG_HMAC(PSA_ALG_SHA_224), 8), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_mac_abort CMAC AES 128\n", 5, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, 16, - PSA_KEY_USAGE_SIGN, PSA_ALG_CMAC, - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_entry.c deleted file mode 100644 index bd97a0d78a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c031/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c031.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 31) -#define TEST_DESC "Testing crypto MAC APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c031_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/main.c deleted file mode 100644 index 790ca052f9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c032(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c032, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.c deleted file mode 100644 index de4dcf78a5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.c +++ /dev/null @@ -1,181 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c032.h" -#include "test_data.h" - -client_test_t test_c032_crypto_list[] = { - NULL, - psa_cipher_encrypt_setup_test, - psa_cipher_encrypt_setup_negative_test, - NULL, -}; - -static int g_test_count = 1; -static psa_cipher_operation_t operation; - -int32_t psa_cipher_encrypt_setup_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - const uint8_t *key_data; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_cipher_encrypt_setup_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_cipher_encrypt_setup - Invalid key handle\n", - g_test_count++); - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_cipher_encrypt_setup - Zero as key handle\n", - g_test_count++); - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - 0, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_cipher_encrypt_setup - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.h deleted file mode 100644 index 02a902c11e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_c032.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C032_CLIENT_TESTS_H_ -#define _TEST_C032_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c032) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c032_crypto_list[]; - -int32_t psa_cipher_encrypt_setup_test(security_t caller); -int32_t psa_cipher_encrypt_setup_negative_test(security_t caller); -#endif /* _TEST_C032_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_data.h deleted file mode 100644 index f7be679545..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_data.h +++ /dev/null @@ -1,315 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - size_t expected_bit_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 0xDA, - 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 0x19, 0x0D, 0x25, 0x4F, 0xE1, 0x63, - 0x63, 0x51, 0x8B, 0x0B, 0x64, 0x3F, 0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, - 0xB3, 0xAE, 0x00, 0xA0, 0x63, 0xC5,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- 0xE9, 0x28, 0xE6, 0xB6, 0xFC, 0x2E, 0xCA, 0x67, 0x43, 0x84, 0xE8, 0xD5, 0x83, 0xD6, - 0x9D, 0x98, 0x6B, 0x01, 0x3E, 0x81, 0xDC, 0x3C, 0x7A, 0xCA, 0xF9, 0xF3, 0x9C, 0xF7, - 0xD6, 0x28, 0x1B, 0x27, 0x78, 0x7C, 0xC3, 0xD0, 0xD5, 0x63, 0xA7, 0x81, 0x34, 0x89, - 0xAD, 0x25, 0x6A, 0xBD, 0xF2, 0xEA, 0xED, 0xFA, 0x57, 0xFC, 0xE5, 0x34, 0xC6, 0xC1, - 0x0F, 0x71, 0x2D, 0xD2, 0x08, 0x10, 0x1B, 0xAD, 0x44, 0x41, 0xE0, 0xFE, 0x79, 0xA0, - 0x63, 0x93, 0x8A, 0xB1, 0x5D, 0xE9, 0xB0, 0xEE, 0x6F, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t ec_keydata[] = { - 0x04, 0xde, 0xa5, 0xe4, 0x5d, 0x0e, 0xa3, 0x7f, 0xc5, 0x66, 0x23, 0x2a, 0x50, 0x8f, - 0x4a, 0xd2, 0x0e, 0xa1, 0x3d, 0x47, 0xe4, 0xbf, 0x5f, 0xa4, 0xd5, 0x4a, 0x57, 0xa0, - 0xba, 0x01, 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, - 0x24, 0xa5, 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_encrypt_setup 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_cipher_encrypt_setup 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, AES_24B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_24B_KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_cipher_encrypt_setup 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, AES_32B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_32B_KEY_SIZE), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_encrypt_setup DES 64 bit key\n", 4, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, BYTES_TO_BITS(DES_8B_KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_encrypt_setup Triple DES 2-Key\n", 5, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, BYTES_TO_BITS(DES3_2KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_encrypt_setup Triple DES 3-Key\n", 6, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, BYTES_TO_BITS(DES3_3KEY_SIZE), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_encrypt_setup 16 Byte raw data\n", 7, PSA_KEY_TYPE_RAW_DATA, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CMAC -{"Test psa_cipher_encrypt_setup - not a cipher algorithm\n", 8, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CMAC, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_CIPER -{"Test psa_cipher_encrypt_setup - unknown cipher algorithm\n", 9, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CATEGORY_CIPHER, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_ARC4 -{"Test psa_cipher_encrypt_setup - incompatible key ARC4\n", 10, PSA_KEY_TYPE_ARC4, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -{"Test psa_cipher_encrypt_setup - incorrect usage\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_cipher_encrypt_setup - RSA public key\n", 12, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 270, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, 2048, - PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_cipher_encrypt_setup - RSA keypair\n", 13, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 1193, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, 2048, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_cipher_encrypt_setup - EC Public key\n", 14, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), {0}, 65, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, 256, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_cipher_encrypt_setup - EC keypair\n", 15, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), {0}, 28, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION, 224, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_encrypt_setup negative cases\n", 16, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_entry.c deleted file mode 100644 index 1ff8b8e486..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c032/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c032.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 32) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c032_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/main.c deleted file mode 100644 index 056b0729dc..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c033(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c033, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.c deleted file mode 100644 index 45d5b15f30..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.c +++ /dev/null @@ -1,181 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c033.h" -#include "test_data.h" - -client_test_t test_c033_crypto_list[] = { - NULL, - psa_cipher_decrypt_setup_test, - psa_cipher_decrypt_setup_negative_test, - NULL, -}; - -static int g_test_count = 1; -static psa_cipher_operation_t operation; - -int32_t psa_cipher_decrypt_setup_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - const uint8_t *key_data; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the key for a multipart symmetric decryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_cipher_decrypt_setup_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&operation, 0, sizeof(operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_cipher_decrypt_setup - Invalid key handle\n", - g_test_count++); - /* Set the key for a multipart symmetric decryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_cipher_decrypt_setup - Zero as key handle\n", - g_test_count++); - /* Set the key for a multipart symmetric decryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - 0, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_cipher_decrypt_setup - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Set the key for a multipart symmetric decryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - check2[i].key_handle, check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.h deleted file mode 100644 index 7a0befb99f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_c033.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C033_CLIENT_TESTS_H_ -#define _TEST_C033_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c033) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c033_crypto_list[]; - -int32_t psa_cipher_decrypt_setup_test(security_t caller); -int32_t psa_cipher_decrypt_setup_negative_test(security_t caller); -#endif /* _TEST_C033_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_data.h deleted file mode 100644 index 82cc109720..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_data.h +++ /dev/null @@ -1,317 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -#define EMPTY_KEY_SLOT 31 - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[64]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - size_t expected_bit_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; - -static const uint8_t rsa_256_keypair[] = { - 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC0, - 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, - 0x01, 0x65, 0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, - 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67, 0x7F, 0xFE, - 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, - 0xBD, 0x7B, 0xC0, 0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, - 0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73, 0xDA, - 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 0x19, 0x0D, 0x25, 0x4F, 0xE1, 0x63, - 0x63, 0x51, 0x8B, 0x0B, 0x64, 0x3F, 0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, - 0xB3, 0xAE, 0x00, 0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68, 0x78, 0x73, - 0xA6, 0x8C, 0x18, 0xA9, 0x02, 0x6D, 0xAF, 0xC3, 0x19, 0x01, 0x2E, 0xB8, 0x10, - 0xE3, 0xC6, 0xCC, 0x40, 0xB4, 0x69, 0xA3, 0x46, 0x33, 0x69, 0x87, 0x6E, 0xC4, - 0xBB, 0x17, 0xA6, 0xF3, 0xE8, 0xDD, 0xAD, 0x73, 0xBC, 0x7B, 0x2F, 0x21, 0xB5, - 0x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0xF2, 0xEA, 0xED, 0xFA, 0x57, 0xFC, 0xE5, 0x34, 0xC6, 0xC1, - 0x0F, 0x71, 0x2D, 0xD2, 0x08, 0x10, 0x1B, 0xAD, 0x44, 0x41, 0xE0, 0xFE, 0x79, 0xA0, - 0x63, 0x93, 0x8A, 0xB1, 0x5D, 0xE9, 0xB0, 0xEE, 0x6F, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t ec_keydata[] = { - 0x04, 0xde, 0xa5, 0xe4, 0x5d, 0x0e, 0xa3, 0x7f, 0xc5, 0x66, 0x23, 0x2a, 0x50, 0x8f, - 0x4a, 0xd2, 0x0e, 0xa1, 0x3d, 0x47, 0xe4, 0xbf, 0x5f, 0xa4, 0xd5, 0x4a, 0x57, 0xa0, - 0xba, 0x01, 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, - 0x24, 0xa5, 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, - 0xa1, 0x6f, 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0x68, 0x49, 0xf9, 0x7d, 0x10, 0x66, 0xf6, 0x99, 0x77, 0x59, 0x63, 0x7c, 0x7e, 0x38, - 0x99, 0x46, 0x4c, 0xee, 0x3e, 0xc7, 0xac, 0x97, 0x06, 0x53, 0xa0, 0xbe, 0x07, 0x42}; - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_decrypt_setup 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_cipher_decrypt_setup 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, AES_24B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_24B_KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_cipher_decrypt_setup 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, AES_32B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_32B_KEY_SIZE), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_decrypt_setup DES 64 bit key\n", 4, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, BYTES_TO_BITS(DES_8B_KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_decrypt_setup Triple DES 2-Key\n", 5, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, BYTES_TO_BITS(DES3_2KEY_SIZE), - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_decrypt_setup Triple DES 3-Key\n", 6, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, BYTES_TO_BITS(DES3_3KEY_SIZE), - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_decrypt_setup 16 Byte raw data\n", 7, PSA_KEY_TYPE_RAW_DATA, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_CMAC -{"Test psa_cipher_decrypt_setup - not a cipher algorithm\n", 8, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CMAC, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_CIPER -{"Test psa_cipher_decrypt_setup - unknown cipher algorithm\n", 9, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CATEGORY_CIPHER, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_ARC4 -{"Test psa_cipher_decrypt_setup - incompatible key ARC4\n", 10, PSA_KEY_TYPE_ARC4, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_SUPPORTED -}, -#endif - -{"Test psa_cipher_decrypt_setup - incorrect usage\n", 11, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#ifdef ARCH_TEST_RSA_2048 -{"Test psa_cipher_decrypt_setup - RSA public key\n", 12, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 270, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, 2048, - PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_cipher_decrypt_setup - RSA keypair\n", 13, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 1193, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, 2048, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_cipher_decrypt_setup - EC Public key\n", 14, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), {0}, 65, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, 192, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP224R1 -{"Test psa_cipher_decrypt_setup - EC keypair\n", 15, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1), {0}, 28, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, 224, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_decrypt_setup - negative test\n", 16, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, BYTES_TO_BITS(AES_16B_KEY_SIZE), - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_entry.c deleted file mode 100644 index a979d304ae..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c033/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c033.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 33) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c033_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/main.c deleted file mode 100644 index 0cd68eebd8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c034(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c034, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.c deleted file mode 100644 index 65b680c3ac..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.c +++ /dev/null @@ -1,123 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c034.h" -#include "test_data.h" - - -client_test_t test_c034_crypto_list[] = { - NULL, - psa_cipher_generate_iv_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_cipher_generate_iv_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - uint32_t i, j, iv_sum; - uint8_t iv[32]; - size_t iv_length; - psa_key_policy_t policy; - psa_cipher_operation_t operation; - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Generate an IV for a symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_GENERATE_IV, &operation, iv, - check1[i].iv_size, &iv_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(7)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - continue; - } - - /* Check that if generated iv length match the expected length */ - TEST_ASSERT_EQUAL(iv_length, check1[i].expected_iv_length, TEST_CHECKPOINT_NUM(9)); - - iv_sum = 0; - for (j = 0; j < iv_length; j++) - { - iv_sum += iv[j]; - } - - /* Check that if generated iv are zero */ - TEST_ASSERT_NOT_EQUAL(iv_sum, 0, TEST_CHECKPOINT_NUM(10)); - - /* Generating an IV for a symmetric encryption operation using the same operator - * should fail - */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_GENERATE_IV, &operation, iv, - check1[i].iv_size, &iv_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(11)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(12)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.h deleted file mode 100644 index 3d1211a6f5..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_c034.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C034_CLIENT_TESTS_H_ -#define _TEST_C034_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c034) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c034_crypto_list[]; - -int32_t psa_cipher_generate_iv_test(security_t caller); -#endif /* _TEST_C034_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_data.h deleted file mode 100644 index 7bc7eab9aa..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_data.h +++ /dev/null @@ -1,139 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - size_t iv_size; - size_t expected_iv_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_generate_iv 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, 16, 16, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_cipher_generate_iv 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, AES_24B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, 16, 16, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_cipher_generate_iv 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, AES_32B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, 16, 16, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_generate_iv DES 64 bit key\n", 4, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - 8, 8, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_generate_iv Triple DES 2-Key\n", 5, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - 8, 8, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_generate_iv Triple DES 3-Key\n", 6, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - 8, 8, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_generate_iv AES - small iv buffer\n", 7, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, 8, 16, - PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_generate_iv DES - small iv buffer\n", 8, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - 4, 8, - PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_generate_iv AES - large iv buffer\n", 9, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, 32, 16, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_generate_iv DES - large iv buffer\n", 10, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - 16, 8, - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_entry.c deleted file mode 100644 index c86a67df47..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c034/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c034.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 34) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c034_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/main.c deleted file mode 100644 index 57e66b9a64..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c035(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c035, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.c deleted file mode 100644 index 368b699c49..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.c +++ /dev/null @@ -1,100 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c035.h" -#include "test_data.h" - - -client_test_t test_c035_crypto_list[] = { - NULL, - psa_cipher_set_iv_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_cipher_set_iv_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_cipher_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Set an IV for a symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_SET_IV, &operation, check1[i].iv, - check1[i].iv_size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(7)); - - /* Setting an IV for a symmetric encryption operation using the same operator - * should fail - */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_SET_IV, &operation, check1[i].iv, - check1[i].iv_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(8)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.h deleted file mode 100644 index d4cf6f8fed..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_c035.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C035_CLIENT_TESTS_H_ -#define _TEST_C035_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c035) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c035_crypto_list[]; - -int32_t psa_cipher_set_iv_test(security_t caller); -#endif /* _TEST_C035_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_data.h deleted file mode 100644 index af43a3b8dc..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_data.h +++ /dev/null @@ -1,151 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t iv[32]; - size_t iv_size; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_set_iv 16 Byte AES\n", 1, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F}, 16, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_192 -{"Test psa_cipher_set_iv 24 Byte AES\n", 2, PSA_KEY_TYPE_AES, -{0x24, 0x13, 0x61, 0x47, 0x61, 0xB8, 0xC8, 0xF0, 0xDF, 0xAB, 0x5A, 0x0E, 0x87, - 0x40, 0xAC, 0xA3, 0x90, 0x77, 0x83, 0x52, 0x31, 0x74, 0xF9}, AES_24B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F}, 16, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_256 -{"Test psa_cipher_set_iv 32 Byte AES\n", 3, PSA_KEY_TYPE_AES, -{0xEA, 0xD5, 0xE6, 0xC8, 0x51, 0xF9, 0xEC, 0xBB, 0x9B, 0x57, 0x7C, 0xED, 0xD2, - 0x4B, 0x82, 0x84, 0x9F, 0x9F, 0xE6, 0x73, 0x21, 0x3D, 0x1A, 0x05, 0xC9, 0xED, - 0xDF, 0x25, 0x17, 0x68, 0x86, 0xAE}, AES_32B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F}, 16, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_AES_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_set_iv DES 64 bit key\n", 4, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, 8, - PSA_SUCCESS -}, - -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_set_iv Triple DES 2-Key\n", 5, PSA_KEY_TYPE_DES, -{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - DES3_2KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, 8, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_set_iv Triple DES 3-Key\n", 6, PSA_KEY_TYPE_DES, -{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0xF1, 0xE0, 0xD3, 0xC2, 0xB5, 0xA4, 0x97, 0x86, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}, - DES3_3KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, 8, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_set_iv AES - small iv buffer\n", 7, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, - {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, 8, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_AES_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_set_iv DES - small iv buffer\n", 8, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x00, 0x01, 0x02, 0x03,}, 4, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_set_iv AES - large iv buffer\n", 9, PSA_KEY_TYPE_AES, -{0x49, 0x8E, 0xC7, 0x7D, 0x01, 0x95, 0x0D, 0x94, 0x2C, 0x16, 0xA5, 0x3E, 0x99, - 0x5F, 0xC9, 0xD0}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}, 32, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_AES_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_set_iv DES - large iv buffer\n", 10, PSA_KEY_TYPE_DES, - {0x70, 0x24, 0x55, 0x0C, 0x14, 0x9D, 0xED, 0x29}, - DES_8B_KEY_SIZE, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F}, 16, - PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_entry.c deleted file mode 100644 index a37200fca3..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c035/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c035.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 35) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c035_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/main.c deleted file mode 100644 index b4361193b8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" -#include "unity/unity.h" - -void test_entry_c036(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c036, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.c deleted file mode 100644 index 4a917c484b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.c +++ /dev/null @@ -1,131 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c036.h" -#include "test_data.h" - - -client_test_t test_c036_crypto_list[] = { - NULL, - psa_cipher_update_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t output[SIZE_32B]; -static psa_cipher_operation_t operation; - -int32_t psa_cipher_update_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - size_t length; - psa_key_policy_t policy; - psa_cipher_operation_t invalid_operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&operation, 0, sizeof(operation)); - memset(&invalid_operation, 0, sizeof(invalid_operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].usage == PSA_KEY_USAGE_ENCRYPT) - { - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - } - else if (check1[i].usage == PSA_KEY_USAGE_DECRYPT) - { - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - /* Set an IV for a symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_SET_IV, &operation, check1[i].iv, - check1[i].iv_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Encrypt or decrypt a message fragment in an active cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_UPDATE, &operation, check1[i].input, - check1[i].input_length, output, check1[i].output_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(9)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(10)); - continue; - } - - /* Check if the output length matches the expected length */ - TEST_ASSERT_EQUAL(length, check1[i].expected_output_length, TEST_CHECKPOINT_NUM(11)); - - /* Check if the output data matches the expected data */ - TEST_ASSERT_MEMCMP(output, check1[i].expected_output, length, TEST_CHECKPOINT_NUM(12)); - - /* Encrypt or decrypt a message fragment in an invalid cipher operation should fail */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_UPDATE, &invalid_operation, - check1[i].input, check1[i].input_length, output, check1[i].output_size, - &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(13)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(14)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.h deleted file mode 100644 index 045271a04b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_c036.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C036_CLIENT_TESTS_H_ -#define _TEST_C036_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c036) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c036_crypto_list[]; - -int32_t psa_cipher_update_test(security_t caller); -#endif /* _TEST_C036_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_data.h deleted file mode 100644 index c5e4fbe8cb..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_data.h +++ /dev/null @@ -1,252 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t iv[16]; - size_t iv_size; - uint8_t input[32]; - size_t input_length; - size_t output_size; - uint8_t expected_output[32]; - size_t expected_output_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_cipher_update - Encrypt - AES CBC_NO_PADDING\n", 1, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, 16, -{0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F, - 0x20, 0x74, 0x3B}, 16, PSA_SUCCESS -}, - -{"Test psa_cipher_update - Encrypt - AES CBC_NO_PADDING (Short input)\n", 2, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_update - Encrypt - AES CBC_PKCS7\n", 3, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, 16, -{0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f, - 0x20, 0x74, 0x3b}, 16, PSA_SUCCESS -}, - -{"Test psa_cipher_update - Encrypt - AES CBC_PKCS7 (Short input)\n", 4, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17}, 15, 16, -{0}, 0, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_update - Encrypt - AES CTR\n", 5, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, 16, -{0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0, - 0xb2, 0xbd, 0x32}, 16, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_update - Encrypt - DES CBC (nopad)\n", 6, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, 8, -{0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 8, PSA_SUCCESS -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_update - Encrypt - 2-key 3DE -CBC (nopad)\n", 7, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, 8, -{0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 8, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_update - Encrypt - 3-key 3DE -CBC (nopad)\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, 8, -{0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 8, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_AES_128 -{"Test psa_cipher_update - small output buffer size\n", 9, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, 15, -{0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F, - 0x20, 0x74, 0x3B}, 16, PSA_ERROR_BUFFER_TOO_SMALL -}, - -{"Test psa_cipher_update - Decrypt - AES CBC_NO_PADDING\n", 10, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F, - 0x20, 0x74, 0x3B}, 16, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, PSA_SUCCESS -}, - -{"Test psa_cipher_update - Decrypt - AES CBC_NO_PADDING (Short input)\n", 11, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_update - Decrypt - AES CBC_PKCS7\n", 12, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f, - 0x20, 0x74, 0x3b}, 16, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 0, PSA_SUCCESS -}, - -{"Test psa_cipher_update - Decrypt - AES CBC_PKCS7 (Short input)\n", 13, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f, - 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31, - 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 32, 32, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_update - Decrypt - AES CTR\n", 14, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0, - 0xb2, 0xbd, 0x32}, 16, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_update - Decrypt - DES CBC (nopad)\n", 15, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 8, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_update - Decrypt - 2-key 3DE -CBC (nopad)\n", 16, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 8, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_update - Decrypt - 3-key 3DE -CBC (nopad)\n", 17, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 8, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_entry.c deleted file mode 100644 index f46a6b3cf0..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c036/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c036.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 36) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c036_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/main.c deleted file mode 100644 index ee6266ecab..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" -#include "unity/unity.h" - -void test_entry_c037(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c037, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.c deleted file mode 100644 index fa2ab6c5b8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.c +++ /dev/null @@ -1,143 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c037.h" -#include "test_data.h" - -#define SLOT_1 0 -#define SLOT_2 1 - -client_test_t test_c037_crypto_list[] = { - NULL, - psa_cipher_finish_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t output[SIZE_32B]; - -int32_t psa_cipher_finish_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - size_t update_length, finish_length; - psa_key_policy_t policy; - psa_cipher_operation_t operation, invalid_operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - memset(&operation, 0, sizeof(operation)); - memset(&invalid_operation, 0, sizeof(invalid_operation)); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].usage == PSA_KEY_USAGE_ENCRYPT) - { - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - } - else if (check1[i].usage == PSA_KEY_USAGE_DECRYPT) - { - /* Set the key for a multipart symmetric decryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - /* Set an IV for a symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_SET_IV, &operation, check1[i].iv, - check1[i].iv_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Encrypt or decrypt a message fragment in an active cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_UPDATE, &operation, check1[i].input, - check1[i].input_length, output, check1[i].output_size[SLOT_1], &update_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Finish encrypting or decrypting a message in a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_FINISH, &operation, - output + update_length, check1[i].output_size[SLOT_2], &finish_length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(10)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(11)); - continue; - } - - /* Check if the output length matches the expected length */ - TEST_ASSERT_EQUAL(finish_length, check1[i].expected_output_length, TEST_CHECKPOINT_NUM(12)); - - /* Check if the output data matches the expected data */ - TEST_ASSERT_MEMCMP(output, check1[i].expected_output, - (update_length + finish_length), - TEST_CHECKPOINT_NUM(13)); - - /* Finish encrypting or decrypting a message using an invalid operation should fail */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_FINISH, &invalid_operation, output, - check1[i].output_size[SLOT_2], &finish_length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(14)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(15)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &invalid_operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(16)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.h deleted file mode 100644 index e7e1bdaa83..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_c037.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C037_CLIENT_TESTS_H_ -#define _TEST_C037_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c037) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c037_crypto_list[]; - -int32_t psa_cipher_finish_test(security_t caller); -#endif /* _TEST_C037_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_data.h deleted file mode 100644 index 013eec189e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_data.h +++ /dev/null @@ -1,281 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t iv[16]; - size_t iv_size; - uint8_t input[32]; - size_t input_length; - size_t output_size[2]; - uint8_t expected_output[32]; - size_t expected_output_length; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_cipher_finish - Encrypt - AES CBC_NO_PADDING\n", 1, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, {SIZE_32B, SIZE_32B}, -{0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F, - 0x20, 0x74, 0x3B}, 0, PSA_SUCCESS -}, - -{"Test psa_cipher_finish - Encrypt - AES CBC_NO_PADDING (Short input)\n", 2, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, {16, 16}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_finish - Encrypt - AES CBC_PKCS7\n", 3, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, {SIZE_32B, SIZE_32B}, -{0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f, - 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31, - 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 16, PSA_SUCCESS -}, - -{"Test psa_cipher_finish - Encrypt - AES CBC_PKCS7 (Short input)\n", 4, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17}, 15, {SIZE_32B, SIZE_32B}, -{0x62, 0x79, 0xb4, 0x9d, 0x7f, 0x7a, 0x8d, 0xd8, 0x7b, 0x68, 0x51, 0x75, 0xd4, - 0x27, 0x6e, 0x24}, 16, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_finish - Encrypt - AES CTR\n", 5, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, {SIZE_32B, SIZE_32B}, -{0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0, - 0xb2, 0xbd, 0x32}, 0, PSA_SUCCESS -}, - -{"Test psa_cipher_finish - Encrypt - AES CTR (short input)\n", 6, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17}, 15, {SIZE_32B, SIZE_32B}, -{0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0, - 0xb2, 0xbd}, 0, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_finish - Encrypt - DES CBC (nopad)\n", 7, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, {SIZE_32B, SIZE_32B}, -{0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 0, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_finish - Encrypt - 2-key 3DE -CBC (nopad)\n", 8, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, {SIZE_32B, SIZE_32B}, -{0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 0, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_finish - Encrypt - 3-key 3DE -CBC (nopad)\n", 9, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 8, {SIZE_32B, SIZE_32B}, -{0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 0, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_finish - small output buffer size\n", 10, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 16, {SIZE_32B, 15}, -{0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f, - 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31, - 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 16, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_cipher_finish - Decrypt - AES CBC_NO_PADDING\n", 11, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0xA0, 0x76, 0xEC, 0x9D, 0xFB, 0xE4, 0x7D, 0x52, 0xAF, 0xC3, 0x57, 0x33, 0x6F, - 0x20, 0x74, 0x3B}, - 16, {SIZE_32B, SIZE_32B}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 0, PSA_SUCCESS -}, - -{"Test psa_cipher_finish - Decrypt - AES CBC_NO_PADDING (Short input)\n", 12, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 5, {16, 16}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x23}, 0, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_finish - Decrypt - AES CBC_PKCS7\n", 13, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0xa0, 0x76, 0xec, 0x9d, 0xfb, 0xe4, 0x7d, 0x52, 0xaf, 0xc3, 0x57, 0x33, 0x6f, - 0x20, 0x74, 0x3b, 0xca, 0x7e, 0x8a, 0x15, 0xdc, 0x3c, 0x77, 0x64, 0x36, 0x31, - 0x42, 0x93, 0x03, 0x1c, 0xd4, 0xf3}, 32, {SIZE_32B, SIZE_32B}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, 0, PSA_SUCCESS -}, - -{"Test psa_cipher_finish - Decrypt - AES CBC_PKCS7 (Short input)\n", 14, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x62, 0x79, 0xb4, 0x9d, 0x7f, 0x7a, 0x8d, 0xd8, 0x7b, 0x68, 0x51, 0x75, 0xd4, - 0x27, 0x6e, 0x24}, 16, {SIZE_32B, SIZE_32B}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17}, 15, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_finish - Decrypt - AES CTR\n", 15, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0, - 0xb2, 0xbd, 0x32}, 16, {SIZE_32B, SIZE_32B}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a}, - 0, PSA_SUCCESS -}, - -{"Test psa_cipher_finish - Decrypt - AES CTR (short input)\n", 16, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a}, 16, -{0x8f, 0x94, 0x08, 0xfe, 0x80, 0xa8, 0x1d, 0x3e, 0x81, 0x3d, 0xa3, 0xc7, 0xb0, - 0xb2, 0xbd}, 15, {SIZE_32B, SIZE_32B}, -{0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17}, 0, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_finish - Decrypt - DES CBC (nopad)\n", 17, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0x64, 0xf9, 0x17, 0xb0, 0x15, 0x2f, 0x8f, 0x05}, 8, {SIZE_32B, SIZE_32B}, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 0, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_finish - Decrypt - 2-key 3DE -CBC (nopad)\n", 18, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0x5d, 0x06, 0x52, 0x42, 0x9c, 0x5b, 0x0a, 0xc7}, 8, {SIZE_32B, SIZE_32B}, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 0, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_finish - 3-key 3DE -CBC (nopad)\n", 19, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, -{0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}, 8, -{0x81, 0x7c, 0xa7, 0xd6, 0x9b, 0x80, 0xd8, 0x6a}, 8, {SIZE_32B, SIZE_32B}, -{0xed, 0xa4, 0x01, 0x12, 0x39, 0xbc, 0x3a, 0xc9}, 0, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_entry.c deleted file mode 100644 index 7732adb47e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c037/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c037.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 37) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c037_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/main.c deleted file mode 100644 index 3d5b9844e8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c038(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c038, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.c deleted file mode 100644 index b8d8840c09..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.c +++ /dev/null @@ -1,177 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c038.h" -#include "test_data.h" - -client_test_t test_c038_crypto_list[] = { - NULL, - psa_cipher_abort_test, - psa_cipher_abort_before_update_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t output[SIZE_32B]; - -int32_t psa_cipher_abort_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_cipher_operation_t operation; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (check1[i].usage == PSA_KEY_USAGE_ENCRYPT) - { - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - } - else if (check1[i].usage == PSA_KEY_USAGE_DECRYPT) - { - /* Set the key for a multipart symmetric decryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_DECRYPT_SETUP, &operation, - check1[i].key_handle, check1[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Multiple abort cipher operation should return success*/ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_cipher_abort_before_update_test(security_t caller) -{ - size_t length; - psa_key_policy_t policy; - psa_algorithm_t key_alg = PSA_ALG_CBC_NO_PADDING; - psa_key_usage_t usage = PSA_KEY_USAGE_ENCRYPT; - psa_key_handle_t key_handle = 13; - psa_key_type_t key_type = PSA_KEY_TYPE_AES; - psa_cipher_operation_t operation; - uint8_t key_data[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, - 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; - uint8_t input[] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, - 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}; - uint8_t iv[] = {0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a}; - size_t key_length = sizeof(key_data)/sizeof(key_data[0]); - size_t input_length = sizeof(input)/sizeof(input[0]); - size_t iv_size = sizeof(iv)/sizeof(iv[0]); - int32_t status; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, "Test psa_cipher_update after psa_cipher_abort should fail\n", 0); - memset(&operation, 0, sizeof(operation)); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, usage, key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, key_handle, &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, key_handle, - key_type, key_data, key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the key for a multipart symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ENCRYPT_SETUP, &operation, - key_handle, key_alg); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Set an IV for a symmetric encryption operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_SET_IV, &operation, iv, iv_size); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - - /* Abort a cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_ABORT, &operation); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Encrypt or decrypt a message fragment in an active cipher operation */ - status = val->crypto_function(VAL_CRYPTO_CIPHER_UPDATE, &operation, input, - input_length, output, SIZE_32B, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_BAD_STATE, TEST_CHECKPOINT_NUM(9)); - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.h deleted file mode 100644 index 6d6e5f019c..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_c038.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C038_CLIENT_TESTS_H_ -#define _TEST_C038_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c038) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c038_crypto_list[]; - -int32_t psa_cipher_abort_test(security_t caller); -int32_t psa_cipher_abort_before_update_test(security_t caller); -#endif /* _TEST_C038_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_data.h deleted file mode 100644 index 1dedbecbc9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_data.h +++ /dev/null @@ -1,145 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[32]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - psa_status_t expected_status; -} test_data; - -static test_data check1[] = { -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_cipher_abort - Encrypt - AES CBC_NO_PADDING\n", 1, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_abort - Encrypt - AES CBC_PKCS7\n", 2, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_PKCS7, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_abort - Encrypt - AES CTR\n", 3, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CTR, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_abort - Encrypt - DES CBC (nopad)\n", 4, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_abort - Encrypt - 2-key 3DE -CBC (nopad)\n", 5, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_abort - Encrypt - 3-key 3DE -CBC (nopad)\n", 6, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_AES_128 -#ifdef ARCH_TEST_CBC_NO_PADDING -{"Test psa_cipher_abort - Decrypt - AES CBC_NO_PADDING\n", 7, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CBC_PKCS7 -{"Test psa_cipher_abort - Decrypt - AES CBC_PKCS7\n", 8, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_PKCS7, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_CIPER_MODE_CTR -{"Test psa_cipher_abort - Decrypt - AES CTR\n", 9, PSA_KEY_TYPE_AES, -{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, - 0xcf, 0x4f, 0x3c}, AES_16B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CTR, - PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_CBC_NO_PADDING -#ifdef ARCH_TEST_DES_1KEY -{"Test psa_cipher_abort - Decrypt - DES CBC (nopad)\n", 10, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e}, DES_8B_KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_2KEY -{"Test psa_cipher_abort - Decrypt - 2-key 3DE -CBC (nopad)\n", 11, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce}, DES3_2KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_DES_3KEY -{"Test psa_cipher_abort - Decrypt - 3-key 3DE -CBC (nopad)\n", 12, PSA_KEY_TYPE_DES, -{0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, - 0xcb, 0xcd, 0xce, 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e}, DES3_3KEY_SIZE, - PSA_KEY_USAGE_DECRYPT, PSA_ALG_CBC_NO_PADDING, - PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_entry.c deleted file mode 100644 index d027adae90..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c038/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c038.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 38) -#define TEST_DESC "Testing crypto symmetric cipher APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c038_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/main.c deleted file mode 100644 index 455badce9f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c039(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c039, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.c deleted file mode 100644 index dfdc09e324..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.c +++ /dev/null @@ -1,245 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c039.h" -#include "test_data.h" - -client_test_t test_c039_crypto_list[] = { - NULL, - psa_asymmetric_encrypt_test, - psa_asymmetric_encrypt_negative_test, - NULL, -}; - -static bool_t is_buffer_empty(uint8_t *buffer, size_t size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (buffer[i] != 0) - return FALSE; - } - - return TRUE; -} - -static int g_test_count = 1; -static uint8_t output[SIZE_128B]; - -int32_t psa_asymmetric_encrypt_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - const uint8_t *key_data; - uint8_t *salt; - size_t length; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - memset(output, 0, sizeof(output)); - - /* Set the key data based on key type */ - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE) - { - salt = NULL; - check1[i].salt_length = 0; - } - else - salt = check1[i].salt; - - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_ENCRYPT, check1[i].key_handle, - check1[i].key_alg, check1[i].input, check1[i].input_length, salt, - check1[i].salt_length, output, check1[i].output_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Check if the output length matches with the expected output length */ - TEST_ASSERT_EQUAL(length, check1[i].expected_output_length, TEST_CHECKPOINT_NUM(7)); - - /* We test encryption by checking that encrypt-then-decrypt gives back - * the original plaintext because of the non-optional random - * part of encryption process which prevents using fixed vectors. */ - if ((check1[i].usage & PSA_KEY_USAGE_DECRYPT) == PSA_KEY_USAGE_DECRYPT) - { - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_DECRYPT, - check1[i].key_handle, check1[i].key_alg, output, length, salt, - check1[i].salt_length, output, check1[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - - /* Check if the output length matches with the input length */ - TEST_ASSERT_EQUAL(length, check1[i].input_length, TEST_CHECKPOINT_NUM(9)); - - /* Check if the output matches with the given input data */ - TEST_ASSERT_MEMCMP(output, check1[i].input, length, TEST_CHECKPOINT_NUM(10)); - } - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_asymmetric_encrypt_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - uint8_t *salt; - size_t length; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_encrypt - Invalid key handle\n", - g_test_count++); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_encrypt - Invalid key handle\n", - g_test_count++); - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_ENCRYPT, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, salt, - check2[i].salt_length, output, check2[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_encrypt - Zero as key handle\n", - g_test_count++); - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_ENCRYPT, 0, - check2[i].key_alg, check2[i].input, check2[i].input_length, salt, - check2[i].salt_length, output, check2[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_encrypt - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE) - { - salt = NULL; - check1[i].salt_length = 0; - } - else - salt = check1[i].salt; - - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_ENCRYPT, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, salt, - check2[i].salt_length, output, check2[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.h deleted file mode 100644 index 27d74972fb..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C039_CLIENT_TESTS_H_ -#define _TEST_C039_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c039) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c039_crypto_list[]; - -int32_t psa_asymmetric_encrypt_test(security_t caller); -int32_t psa_asymmetric_encrypt_negative_test(security_t caller); -#endif /* _TEST_C039_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_data.h deleted file mode 100644 index 4853825308..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_data.h +++ /dev/null @@ -1,254 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[16]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t salt[16]; - size_t salt_length; - uint8_t input[32]; - size_t input_length; - size_t output_size; - size_t expected_output_length; - size_t expected_bit_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t rsa_256_keypair[1]; -static const uint8_t rsa_256_keydata[1]; - -static const uint8_t ec_keydata[] = { - 0x30, 0x49, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, - 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01, 0x03, 0x32, 0x00, 0x04, 0xBC, - 0x79, 0x7D, 0xB3, 0xAE, 0x7F, 0x08, 0xEC, 0x3D, 0x49, 0x6B, 0x4F, 0xB4, 0x11, 0xB3, - 0xF6, 0x20, 0xA5, 0x58, 0xA5, 0x01, 0xE0, 0x22, 0x2D, 0x08, 0xCF, 0xE0, 0xDC, 0x8A, - 0xEC, 0x8B, 0x1A, 0x7B, 0xF2, 0x4B, 0xE9, 0x29, 0x51, 0xCC, 0x5B, 0xA1, 0xBE, 0xBB, - 0x24, 0x74, 0x90, 0x9A, 0xE0}; - -static const uint8_t ec_keypair[] = { - 0x30, 0x5F, 0x02, 0x01, 0x01, 0x04, 0x18, 0x33, 0x8E, 0x86, 0xA8, 0x81, 0xE2, 0x38, - 0xF5, 0x49, 0xBD, 0x6F, 0x05, 0x53, 0x49, 0x4B, 0x73, 0xE3, 0xD6, 0x11, 0x30, 0xFD, - 0xC6, 0xC9, 0x6D, 0xA0, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, - 0x01, 0xA1, 0x34, 0x03, 0x32, 0x00, 0x04, 0x51, 0x75, 0xBC, 0xDF, 0x30, 0xA3, 0x70, - 0xF3, 0x9D, 0x53, 0x93, 0xE6, 0x12, 0x72, 0x88, 0xD8, 0x01, 0x67, 0xB5, 0xF4, 0xB4, - 0xB7, 0x76, 0xC6, 0x74, 0xF7, 0xC6, 0xF3, 0x54, 0xB7, 0xD2, 0x24, 0x06, 0x2C, 0x1F, - 0x68, 0x54, 0xB5, 0xA7, 0xAF, 0x0F, 0xE5, 0x78, 0xEA, 0xF2, 0x58, 0xF0, 0x27}; - -static const uint8_t rsa_128_keydata[] = { - 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, - 0x81, 0x81, 0x00, 0xaf, 0x05, 0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, - 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, 0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, - 0x54, 0x1e, 0xe1, 0xfe, 0xb0, 0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, - 0x49, 0xe1, 0x12, 0x96, 0x28, 0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, - 0x35, 0x24, 0xef, 0x4c, 0x0e, 0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, - 0xf1, 0x23, 0x49, 0xdd, 0xee, 0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, - 0x48, 0xcd, 0x02, 0xb2, 0x02, 0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, - 0xf8, 0x59, 0xc2, 0xc1, 0x81, 0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, - 0xde, 0x26, 0x3a, 0x2a, 0xbf, 0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, - 0x60, 0xf7, 0xd6, 0x83, 0x4d, 0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, - 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t rsa_128_keypair[] = { -0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, -0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, -0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, 0x54, 0x1e, 0xe1, 0xfe, 0xb0, -0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, 0x49, 0xe1, 0x12, 0x96, 0x28, -0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, 0x35, 0x24, 0xef, 0x4c, 0x0e, -0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, 0xf1, 0x23, 0x49, 0xdd, 0xee, -0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, 0x48, 0xcd, 0x02, 0xb2, 0x02, -0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, 0xf8, 0x59, 0xc2, 0xc1, 0x81, -0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, 0xde, 0x26, 0x3a, 0x2a, 0xbf, -0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, 0x60, 0xf7, 0xd6, 0x83, 0x4d, -0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, 0xc3, 0x02, 0x03, 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0x7f, 0xd4, 0x5c, 0x12, 0xd6, 0xb5, 0x2e, 0x2c, 0x98, 0x71, 0xa1, 0x74, -0xc6, 0x6b, 0x48, 0x81, 0x13, 0x02, 0x41, 0x00, 0xc5, 0xab, 0x27, 0x60, 0x21, -0x59, 0xae, 0x7d, 0x6f, 0x20, 0xc3, 0xc2, 0xee, 0x85, 0x1e, 0x46, 0xdc, 0x11, -0x2e, 0x68, 0x9e, 0x28, 0xd5, 0xfc, 0xbb, 0xf9, 0x90, 0xa9, 0x9e, 0xf8, 0xa9, -0x0b, 0x8b, 0xb4, 0x4f, 0xd3, 0x64, 0x67, 0xe7, 0xfc, 0x17, 0x89, 0xce, 0xb6, -0x63, 0xab, 0xda, 0x33, 0x86, 0x52, 0xc3, 0xc7, 0x3f, 0x11, 0x17, 0x74, 0x90, -0x2e, 0x84, 0x05, 0x65, 0x92, 0x70, 0x91, 0x02, 0x41, 0x00, 0xb6, 0xcd, 0xbd, -0x35, 0x4f, 0x7d, 0xf5, 0x79, 0xa6, 0x3b, 0x48, 0xb3, 0x64, 0x3e, 0x35, 0x3b, -0x84, 0x89, 0x87, 0x77, 0xb4, 0x8b, 0x15, 0xf9, 0x4e, 0x0b, 0xfc, 0x05, 0x67, -0xa6, 0xae, 0x59, 0x11, 0xd5, 0x7a, 0xd6, 0x40, 0x9c, 0xf7, 0x64, 0x7b, 0xf9, -0x62, 0x64, 0xe9, 0xbd, 0x87, 0xeb, 0x95, 0xe2, 0x63, 0xb7, 0x11, 0x0b, 0x9a, -0x1f, 0x9f, 0x94, 0xac, 0xce, 0xd0, 0xfa, 0xfa, 0x4d, 0x02, 0x40, 0x71, 0x19, -0x5e, 0xec, 0x37, 0xe8, 0xd2, 0x57, 0xde, 0xcf, 0xc6, 0x72, 0xb0, 0x7a, 0xe6, -0x39, 0xf1, 0x0c, 0xbb, 0x9b, 0x0c, 0x73, 0x9d, 0x0c, 0x80, 0x99, 0x68, 0xd6, -0x44, 0xa9, 0x4e, 0x3f, 0xd6, 0xed, 0x92, 0x87, 0x07, 0x7a, 0x14, 0x58, 0x3f, -0x37, 0x90, 0x58, 0xf7, 0x6a, 0x8a, 0xec, 0xd4, 0x3c, 0x62, 0xdc, 0x8c, 0x0f, -0x41, 0x76, 0x66, 0x50, 0xd7, 0x25, 0x27, 0x5a, 0xc4, 0xa1, 0x02, 0x41, 0x00, -0xbb, 0x32, 0xd1, 0x33, 0xed, 0xc2, 0xe0, 0x48, 0xd4, 0x63, 0x38, 0x8b, 0x7b, -0xe9, 0xcb, 0x4b, 0xe2, 0x9f, 0x4b, 0x62, 0x50, 0xbe, 0x60, 0x3e, 0x70, 0xe3, -0x64, 0x75, 0x01, 0xc9, 0x7d, 0xdd, 0xe2, 0x0a, 0x4e, 0x71, 0xbe, 0x95, 0xfd, -0x5e, 0x71, 0x78, 0x4e, 0x25, 0xac, 0xa4, 0xba, 0xf2, 0x5b, 0xe5, 0x73, 0x8a, -0xae, 0x59, 0xbb, 0xfe, 0x1c, 0x99, 0x77, 0x81, 0x44, 0x7a, 0x2b, 0x24}; - -static test_data check1[] = { -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -{"Test psa_asymmetric_encrypt - RSA PKCS1V15\n", 1, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_RSA_OAEP -{"Test psa_asymmetric_encrypt - RSA OAEP SHA256\n", 2, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_OAEP(PSA_ALG_SHA_256), -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_SUCCESS -}, - -{"Test psa_asymmetric_encrypt - RSA OAEP SHA256 with label\n", 3, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_OAEP(PSA_ALG_SHA_256), -{0x74, 0x68, 0x69, 0x73, 0x00, 0x69, 0x73, 0x00, 0x61, 0x00, 0x6c, 0x61, 0x62, - 0x65, 0x6c, 0x00}, 16, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -{"Test psa_asymmetric_encrypt - RSA KEYPAIR PKCS1V15\n", 4, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_SUCCESS -}, - -{"Test psa_asymmetric_encrypt - Small output buffer\n", 5, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 110, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_asymmetric_encrypt - Invalid algorithm\n", 6, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_SHA_256, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -#ifdef ARCH_TEST_AES_128 -{"Test psa_asymmetric_encrypt - Invalid key type\n", 7, PSA_KEY_TYPE_AES, -{0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, - 0x7d, 0x39, 0x6e}, 16, - PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 0, BYTES_TO_BITS(AES_16B_KEY_SIZE), PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_RSA_1024 -{"Test psa_asymmetric_encrypt - Invalid usage\n", 8, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif - -#ifdef FUTURE_SUPPORT -{"Test psa_asymmetric_encrypt - ECC public key\n", 9, - PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | PSA_ECC_CURVE_SECP192R1, -{0}, 75, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_ECDSA_ANY, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 0, 192, PSA_SUCCESS -} - -{"Test psa_asymmetric_encrypt - ECC keypair\n", 10, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0}, 97, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256), -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 0, 192, PSA_SUCCESS -} -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -#ifdef ARCH_TEST_RSA_1024 -{"Test psa_asymmetric_encrypt - Negative case\n", 11, PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 22, 128, - 128, 1024, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_entry.c deleted file mode 100644 index 323f17382b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c039.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 39) -#define TEST_DESC "Testing crypto asymmetric APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c039_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/main.c deleted file mode 100644 index c885f70149..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c040(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c040, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.c deleted file mode 100644 index 07c8090a08..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.c +++ /dev/null @@ -1,232 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c040.h" -#include "test_data.h" - -client_test_t test_c040_crypto_list[] = { - NULL, - psa_asymmetric_decrypt_test, - psa_asymmetric_decrypt_negative_test, - NULL, -}; - -static bool_t is_buffer_empty(uint8_t *buffer, size_t size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (buffer[i] != 0) - return FALSE; - } - - return TRUE; -} - -static int g_test_count = 1; -static uint8_t output[SIZE_128B]; - -int32_t psa_asymmetric_decrypt_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - const uint8_t *key_data; - uint8_t *salt; - size_t length; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - memset(output, 0, sizeof(output)); - - /* Set the key data based on key type */ - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE) - { - salt = NULL; - check1[i].salt_length = 0; - } - else - salt = check1[i].salt; - - /* Decrypt a short message with a private key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_DECRYPT, check1[i].key_handle, - check1[i].key_alg, check1[i].input, check1[i].input_length, salt, - check1[i].salt_length, output, check1[i].output_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Check if the output length matches with the expected length */ - TEST_ASSERT_EQUAL(length, check1[i].expected_output_length, TEST_CHECKPOINT_NUM(7)); - - /* Check if the output matches with the expected data */ - TEST_ASSERT_MEMCMP(output, check1[i].expected_output, length, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_asymmetric_decrypt_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - uint8_t *salt; - size_t length; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_decrypt - Invalid key handle\n", - g_test_count++); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_decrypt - Invalid key handle\n", - g_test_count++); - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_DECRYPT, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, salt, - check2[i].salt_length, output, check2[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_decrypt - Zero as key handle\n", - g_test_count++); - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_DECRYPT, 0, - check2[i].key_alg, check2[i].input, check2[i].input_length, salt, - check2[i].salt_length, output, check2[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_decrypt - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE) - { - salt = NULL; - check1[i].salt_length = 0; - } - else - salt = check1[i].salt; - - /* Encrypt a short message with a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_DECRYPT, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, salt, - check2[i].salt_length, output, check2[i].output_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.h deleted file mode 100644 index ebb8f5b096..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C040_CLIENT_TESTS_H_ -#define _TEST_C040_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c040) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c040_crypto_list[]; - -int32_t psa_asymmetric_decrypt_test(security_t caller); -int32_t psa_asymmetric_decrypt_negative_test(security_t caller); -#endif /* _TEST_C040_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_data.h deleted file mode 100644 index c6bc2487a6..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_data.h +++ /dev/null @@ -1,329 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[16]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t salt[16]; - size_t salt_length; - uint8_t input[128]; - size_t input_length; - size_t output_size; - uint8_t expected_output[32]; - size_t expected_output_length; - size_t expected_bit_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t rsa_256_keypair[1]; -static const uint8_t rsa_256_keydata[1]; - -static const uint8_t ec_keydata[] = { - 0x30, 0x49, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, - 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01, 0x03, 0x32, 0x00, 0x04, 0xBC, - 0x79, 0x7D, 0xB3, 0xAE, 0x7F, 0x08, 0xEC, 0x3D, 0x49, 0x6B, 0x4F, 0xB4, 0x11, 0xB3, - 0xF6, 0x20, 0xA5, 0x58, 0xA5, 0x01, 0xE0, 0x22, 0x2D, 0x08, 0xCF, 0xE0, 0xDC, 0x8A, - 0xEC, 0x8B, 0x1A, 0x7B, 0xF2, 0x4B, 0xE9, 0x29, 0x51, 0xCC, 0x5B, 0xA1, 0xBE, 0xBB, - 0x24, 0x74, 0x90, 0x9A, 0xE0}; - -static const uint8_t ec_keypair[] = { - 0x30, 0x5F, 0x02, 0x01, 0x01, 0x04, 0x18, 0x33, 0x8E, 0x86, 0xA8, 0x81, 0xE2, 0x38, - 0xF5, 0x49, 0xBD, 0x6F, 0x05, 0x53, 0x49, 0x4B, 0x73, 0xE3, 0xD6, 0x11, 0x30, 0xFD, - 0xC6, 0xC9, 0x6D, 0xA0, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, - 0x01, 0xA1, 0x34, 0x03, 0x32, 0x00, 0x04, 0x51, 0x75, 0xBC, 0xDF, 0x30, 0xA3, 0x70, - 0xF3, 0x9D, 0x53, 0x93, 0xE6, 0x12, 0x72, 0x88, 0xD8, 0x01, 0x67, 0xB5, 0xF4, 0xB4, - 0xB7, 0x76, 0xC6, 0x74, 0xF7, 0xC6, 0xF3, 0x54, 0xB7, 0xD2, 0x24, 0x06, 0x2C, 0x1F, - 0x68, 0x54, 0xB5, 0xA7, 0xAF, 0x0F, 0xE5, 0x78, 0xEA, 0xF2, 0x58, 0xF0, 0x27}; - -static const uint8_t rsa_128_keydata[] = { - 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, - 0x81, 0x81, 0x00, 0xaf, 0x05, 0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, - 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, 0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, - 0x54, 0x1e, 0xe1, 0xfe, 0xb0, 0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, - 0x49, 0xe1, 0x12, 0x96, 0x28, 0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, - 0x35, 0x24, 0xef, 0x4c, 0x0e, 0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, - 0xf1, 0x23, 0x49, 0xdd, 0xee, 0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, - 0x48, 0xcd, 0x02, 0xb2, 0x02, 0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, - 0xf8, 0x59, 0xc2, 0xc1, 0x81, 0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, - 0xde, 0x26, 0x3a, 0x2a, 0xbf, 0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, - 0x60, 0xf7, 0xd6, 0x83, 0x4d, 0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, - 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t rsa_128_keypair[] = { -0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, -0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, -0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, 0x54, 0x1e, 0xe1, 0xfe, 0xb0, -0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, 0x49, 0xe1, 0x12, 0x96, 0x28, -0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, 0x35, 0x24, 0xef, 0x4c, 0x0e, -0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, 0xf1, 0x23, 0x49, 0xdd, 0xee, -0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, 0x48, 0xcd, 0x02, 0xb2, 0x02, -0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, 0xf8, 0x59, 0xc2, 0xc1, 0x81, -0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, 0xde, 0x26, 0x3a, 0x2a, 0xbf, -0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, 0x60, 0xf7, 0xd6, 0x83, 0x4d, -0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, 0xc3, 0x02, 0x03, 0x01, 0x00, -0x01, 0x02, 0x81, 0x81, 0x00, 0x87, 0x4b, 0xf0, 0xff, 0xc2, 0xf2, 0xa7, 0x1d, -0x14, 0x67, 0x1d, 0xdd, 0x01, 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, 0xc5, 0xab, 0x27, 0x60, 0x21, -0x59, 0xae, 0x7d, 0x6f, 0x20, 0xc3, 0xc2, 0xee, 0x85, 0x1e, 0x46, 0xdc, 0x11, -0x2e, 0x68, 0x9e, 0x28, 0xd5, 0xfc, 0xbb, 0xf9, 0x90, 0xa9, 0x9e, 0xf8, 0xa9, -0x0b, 0x8b, 0xb4, 0x4f, 0xd3, 0x64, 0x67, 0xe7, 0xfc, 0x17, 0x89, 0xce, 0xb6, -0x63, 0xab, 0xda, 0x33, 0x86, 0x52, 0xc3, 0xc7, 0x3f, 0x11, 0x17, 0x74, 0x90, -0x2e, 0x84, 0x05, 0x65, 0x92, 0x70, 0x91, 0x02, 0x41, 0x00, 0xb6, 0xcd, 0xbd, -0x35, 0x4f, 0x7d, 0xf5, 0x79, 0xa6, 0x3b, 0x48, 0xb3, 0x64, 0x3e, 0x35, 0x3b, -0x84, 0x89, 0x87, 0x77, 0xb4, 0x8b, 0x15, 0xf9, 0x4e, 0x0b, 0xfc, 0x05, 0x67, -0xa6, 0xae, 0x59, 0x11, 0xd5, 0x7a, 0xd6, 0x40, 0x9c, 0xf7, 0x64, 0x7b, 0xf9, -0x62, 0x64, 0xe9, 0xbd, 0x87, 0xeb, 0x95, 0xe2, 0x63, 0xb7, 0x11, 0x0b, 0x9a, -0x1f, 0x9f, 0x94, 0xac, 0xce, 0xd0, 0xfa, 0xfa, 0x4d, 0x02, 0x40, 0x71, 0x19, -0x5e, 0xec, 0x37, 0xe8, 0xd2, 0x57, 0xde, 0xcf, 0xc6, 0x72, 0xb0, 0x7a, 0xe6, -0x39, 0xf1, 0x0c, 0xbb, 0x9b, 0x0c, 0x73, 0x9d, 0x0c, 0x80, 0x99, 0x68, 0xd6, -0x44, 0xa9, 0x4e, 0x3f, 0xd6, 0xed, 0x92, 0x87, 0x07, 0x7a, 0x14, 0x58, 0x3f, -0x37, 0x90, 0x58, 0xf7, 0x6a, 0x8a, 0xec, 0xd4, 0x3c, 0x62, 0xdc, 0x8c, 0x0f, -0x41, 0x76, 0x66, 0x50, 0xd7, 0x25, 0x27, 0x5a, 0xc4, 0xa1, 0x02, 0x41, 0x00, -0xbb, 0x32, 0xd1, 0x33, 0xed, 0xc2, 0xe0, 0x48, 0xd4, 0x63, 0x38, 0x8b, 0x7b, -0xe9, 0xcb, 0x4b, 0xe2, 0x9f, 0x4b, 0x62, 0x50, 0xbe, 0x60, 0x3e, 0x70, 0xe3, -0x64, 0x75, 0x01, 0xc9, 0x7d, 0xdd, 0xe2, 0x0a, 0x4e, 0x71, 0xbe, 0x95, 0xfd, -0x5e, 0x71, 0x78, 0x4e, 0x25, 0xac, 0xa4, 0xba, 0xf2, 0x5b, 0xe5, 0x73, 0x8a, -0xae, 0x59, 0xbb, 0xfe, 0x1c, 0x99, 0x77, 0x81, 0x44, 0x7a, 0x2b, 0x24}; - -static test_data check1[] = { -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -{"Test psa_asymmetric_decrypt - RSA KEYPAIR PKCS1V15\n", 1, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0x99, 0xff, 0xde, 0x2f, 0xcc, 0x00, 0xc9, 0xcc, 0x01, 0x97, 0x2e, 0xbf, 0xa7, - 0x77, 0x9b, 0x29, 0x8d, 0xbb, 0xaf, 0x7f, 0x50, 0x70, 0x7a, 0x74, 0x05, 0x29, - 0x6d, 0xd2, 0x78, 0x34, 0x56, 0xfc, 0x79, 0x20, 0x02, 0xf4, 0x62, 0xe7, 0x60, - 0x50, 0x0e, 0x02, 0xaf, 0xa2, 0x5a, 0x85, 0x9a, 0xce, 0x87, 0x01, 0xcb, 0x5d, - 0x3b, 0x02, 0x62, 0x11, 0x64, 0x31, 0xc4, 0x3a, 0xf8, 0xeb, 0x08, 0xf5, 0xa8, - 0x83, 0x01, 0x05, 0x7c, 0xf1, 0xc1, 0x56, 0xa2, 0xa5, 0x19, 0x3c, 0x14, 0x3e, - 0x7a, 0x5b, 0x03, 0xfa, 0xc1, 0x32, 0xb7, 0xe8, 0x9e, 0x6d, 0xcd, 0x8f, 0x4c, - 0x82, 0xc9, 0xb2, 0x84, 0x52, 0x32, 0x9c, 0x26, 0x0d, 0x30, 0xbc, 0x39, 0xb3, - 0x81, 0x6b, 0x7c, 0x46, 0xb4, 0x1b, 0x37, 0xb4, 0x85, 0x0d, 0x2a, 0xe7, 0x4e, - 0x72, 0x9f, 0x99, 0xc6, 0x62, 0x1f, 0xbb, 0xe2, 0xe4, 0x68, 0x72}, - 128, 128, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - 32, 1024, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_RSA_OAEP -{"Test psa_asymmetric_decrypt - RSA KEYPAIR OAEP SHA256\n", 2, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_OAEP(PSA_ALG_SHA_256), -{0}, 0, -{0x3d, 0x31, 0x46, 0xb1, 0xc9, 0x82, 0x00, 0x42, 0x73, 0xa9, 0xeb, 0xb9, 0xb0, - 0x63, 0xe6, 0xae, 0x53, 0xb1, 0xa8, 0x5b, 0xfc, 0x80, 0x23, 0x24, 0xbc, 0xdd, - 0x04, 0xfa, 0xa0, 0xf7, 0x21, 0x1f, 0xb2, 0xbd, 0xee, 0xa4, 0x03, 0x58, 0x09, - 0x55, 0x54, 0xdf, 0x9c, 0x25, 0x08, 0x66, 0xc7, 0x36, 0x1e, 0x73, 0x8f, 0x0d, - 0x27, 0x0e, 0xaa, 0x27, 0x73, 0x8e, 0x87, 0x92, 0x8c, 0x5e, 0x31, 0x81, 0x55, - 0x06, 0x34, 0x67, 0x27, 0x90, 0x0f, 0xf0, 0x3c, 0xef, 0x0b, 0xe6, 0xf9, 0xdd, - 0x6b, 0xba, 0x63, 0xce, 0x89, 0x07, 0x4e, 0x81, 0x94, 0xfe, 0x68, 0xb5, 0xa5, - 0x73, 0x94, 0x22, 0xd4, 0xf1, 0x38, 0xbb, 0xbb, 0x61, 0xf4, 0x9b, 0x76, 0xcf, - 0x1f, 0x18, 0xde, 0xf2, 0xc9, 0x93, 0xe3, 0x11, 0x3b, 0x08, 0xc1, 0x91, 0xea, - 0x1d, 0xa0, 0xfe, 0xb9, 0x4f, 0x8f, 0xd9, 0xb3, 0x01, 0x09, 0xa1}, - 128, 128, -{0}, - 0, 1024, PSA_SUCCESS -}, - -{"Test psa_asymmetric_decrypt - RSA KEYPAIR OAEP SHA256 with label\n", 3, - PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_OAEP(PSA_ALG_SHA_256), -{0x74, 0x68, 0x69, 0x73, 0x00, 0x69, 0x73, 0x00, 0x61, 0x00, 0x6c, 0x61, 0x62, - 0x65, 0x6c, 0x00}, 16, -{0x46, 0xed, 0xc9, 0x98, 0x4a, 0x6d, 0x4b, 0x7c, 0x7f, 0xd8, 0x8f, 0xda, 0x9e, - 0xa9, 0x1d, 0xdb, 0xd3, 0x0b, 0x28, 0xa0, 0x79, 0x3c, 0xc7, 0x5a, 0x9f, 0xcd, - 0xd9, 0x4d, 0x86, 0x7c, 0x69, 0x09, 0x0a, 0x69, 0x7d, 0x46, 0xa6, 0xf3, 0x36, - 0xa3, 0xe4, 0x8a, 0x12, 0x2d, 0xd3, 0xee, 0x3b, 0x51, 0x56, 0x6b, 0x44, 0x5f, - 0xf7, 0x8a, 0xdb, 0x61, 0x3d, 0x09, 0xb7, 0xd8, 0xc5, 0x9c, 0x25, 0xa2, 0x7d, - 0x8c, 0xf7, 0xf5, 0xe3, 0x64, 0x55, 0xf2, 0xe7, 0x1f, 0xf6, 0xc6, 0xee, 0x98, - 0xd5, 0x74, 0x0e, 0x66, 0xb2, 0x37, 0x94, 0xac, 0xc7, 0x29, 0x06, 0x56, 0x19, - 0x51, 0xc2, 0xbe, 0x50, 0x64, 0xf6, 0xa2, 0x50, 0x64, 0x6a, 0xb6, 0x27, 0xec, - 0xbf, 0xa4, 0x8c, 0x02, 0xf8, 0x2c, 0x29, 0xfe, 0x9b, 0x8c, 0x8e, 0x6b, 0xe8, - 0xeb, 0x75, 0x24, 0x32, 0x12, 0x49, 0x74, 0x37, 0x3b, 0x54, 0x2c}, - 128, 128, -{0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x6f, 0x20, 0x73, 0x71, - 0x75, 0x65, 0x61, 0x6d, 0x69, 0x73, 0x68, 0x20, 0x6f, 0x73, 0x73, 0x69, 0x66, - 0x72, 0x61, 0x67, 0x65}, - 30, 1024, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -{"Test psa_asymmetric_decrypt - Invalid key type (RSA public key)\n", 4, -PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0x3d, 0x31, 0x46, 0xb1, 0xc9, 0x82, 0x00, 0x42, 0x73, 0xa9, 0xeb, 0xb9, 0xb0, - 0x63, 0xe6, 0xae, 0x53, 0xb1, 0xa8, 0x5b, 0xfc, 0x80, 0x23, 0x24, 0xbc, 0xdd, - 0x04, 0xfa, 0xa0, 0xf7, 0x21, 0x1f, 0xb2, 0xbd, 0xee, 0xa4, 0x03, 0x58, 0x09, - 0x55, 0x54, 0xdf, 0x9c, 0x25, 0x08, 0x66, 0xc7, 0x36, 0x1e, 0x73, 0x8f, 0x0d, - 0x27, 0x0e, 0xaa, 0x27, 0x73, 0x8e, 0x87, 0x92, 0x8c, 0x5e, 0x31, 0x81, 0x55, - 0x06, 0x34, 0x67, 0x27, 0x90, 0x0f, 0xf0, 0x3c, 0xef, 0x0b, 0xe6, 0xf9, 0xdd, - 0x6b, 0xba, 0x63, 0xce, 0x89, 0x07, 0x4e, 0x81, 0x94, 0xfe, 0x68, 0xb5, 0xa5, - 0x73, 0x94, 0x22, 0xd4, 0xf1, 0x38, 0xbb, 0xbb, 0x61, 0xf4, 0x9b, 0x76, 0xcf, - 0x1f, 0x18, 0xde, 0xf2, 0xc9, 0x93, 0xe3, 0x11, 0x3b, 0x08, 0xc1, 0x91, 0xea, - 0x1d, 0xa0, 0xfe, 0xb9, 0x4f, 0x8f, 0xd9, 0xb3, 0x01, 0x09, 0xa1}, - 128, 128, -{0}, - 0, 1024, PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_asymmetric_decrypt - Small output buffer\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0x99, 0xff, 0xde, 0x2f, 0xcc, 0x00, 0xc9, 0xcc, 0x01, 0x97, 0x2e, 0xbf, 0xa7, - 0x77, 0x9b, 0x29, 0x8d, 0xbb, 0xaf, 0x7f, 0x50, 0x70, 0x7a, 0x74, 0x05, 0x29, - 0x6d, 0xd2, 0x78, 0x34, 0x56, 0xfc, 0x79, 0x20, 0x02, 0xf4, 0x62, 0xe7, 0x60, - 0x50, 0x0e, 0x02, 0xaf, 0xa2, 0x5a, 0x85, 0x9a, 0xce, 0x87, 0x01, 0xcb, 0x5d, - 0x3b, 0x02, 0x62, 0x11, 0x64, 0x31, 0xc4, 0x3a, 0xf8, 0xeb, 0x08, 0xf5, 0xa8, - 0x83, 0x01, 0x05, 0x7c, 0xf1, 0xc1, 0x56, 0xa2, 0xa5, 0x19, 0x3c, 0x14, 0x3e, - 0x7a, 0x5b, 0x03, 0xfa, 0xc1, 0x32, 0xb7, 0xe8, 0x9e, 0x6d, 0xcd, 0x8f, 0x4c, - 0x82, 0xc9, 0xb2, 0x84, 0x52, 0x32, 0x9c, 0x26, 0x0d, 0x30, 0xbc, 0x39, 0xb3, - 0x81, 0x6b, 0x7c, 0x46, 0xb4, 0x1b, 0x37, 0xb4, 0x85, 0x0d, 0x2a, 0xe7, 0x4e, - 0x72, 0x9f, 0x99, 0xc6, 0x62, 0x1f, 0xbb, 0xe2, 0xe4, 0x68, 0x72}, - 128, 30, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - 32, 1024, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif - -#ifdef ARCH_TEST_SHA256 -{"Test psa_asymmetric_decrypt - Invalid algorithm\n", 6, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_DECRYPT, PSA_ALG_SHA_256, -{0}, 0, -{0x99, 0xff, 0xde, 0x2f, 0xcc, 0x00, 0xc9, 0xcc, 0x01, 0x97, 0x2e, 0xbf, 0xa7, - 0x77, 0x9b, 0x29, 0x8d, 0xbb, 0xaf, 0x7f, 0x50, 0x70, 0x7a, 0x74, 0x05, 0x29, - 0x6d, 0xd2, 0x78, 0x34, 0x56, 0xfc, 0x79, 0x20, 0x02, 0xf4, 0x62, 0xe7, 0x60, - 0x50, 0x0e, 0x02, 0xaf, 0xa2, 0x5a, 0x85, 0x9a, 0xce, 0x87, 0x01, 0xcb, 0x5d, - 0x3b, 0x02, 0x62, 0x11, 0x64, 0x31, 0xc4, 0x3a, 0xf8, 0xeb, 0x08, 0xf5, 0xa8, - 0x83, 0x01, 0x05, 0x7c, 0xf1, 0xc1, 0x56, 0xa2, 0xa5, 0x19, 0x3c, 0x14, 0x3e, - 0x7a, 0x5b, 0x03, 0xfa, 0xc1, 0x32, 0xb7, 0xe8, 0x9e, 0x6d, 0xcd, 0x8f, 0x4c, - 0x82, 0xc9, 0xb2, 0x84, 0x52, 0x32, 0x9c, 0x26, 0x0d, 0x30, 0xbc, 0x39, 0xb3, - 0x81, 0x6b, 0x7c, 0x46, 0xb4, 0x1b, 0x37, 0xb4, 0x85, 0x0d, 0x2a, 0xe7, 0x4e, - 0x72, 0x9f, 0x99, 0xc6, 0x62, 0x1f, 0xbb, 0xe2, 0xe4, 0x68, 0x72}, - 128, 128, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - 32, 1024, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -#ifdef ARCH_TEST_AES_128 -{"Test psa_asymmetric_decrypt - Invalid key type (AES Key)\n", 7, PSA_KEY_TYPE_AES, -{0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, - 0x7d, 0x39, 0x6e}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0x99, 0xff, 0xde, 0x2f, 0xcc, 0x00, 0xc9, 0xcc, 0x01, 0x97, 0x2e, 0xbf, 0xa7, - 0x77, 0x9b, 0x29, 0x8d, 0xbb, 0xaf, 0x7f, 0x50, 0x70, 0x7a, 0x74, 0x05, 0x29, - 0x6d, 0xd2, 0x78, 0x34, 0x56, 0xfc, 0x79, 0x20, 0x02, 0xf4, 0x62, 0xe7, 0x60, - 0x50, 0x0e, 0x02, 0xaf, 0xa2, 0x5a, 0x85, 0x9a, 0xce, 0x87, 0x01, 0xcb, 0x5d, - 0x3b, 0x02, 0x62, 0x11, 0x64, 0x31, 0xc4, 0x3a, 0xf8, 0xeb, 0x08, 0xf5, 0xa8, - 0x83, 0x01, 0x05, 0x7c, 0xf1, 0xc1, 0x56, 0xa2, 0xa5, 0x19, 0x3c, 0x14, 0x3e, - 0x7a, 0x5b, 0x03, 0xfa, 0xc1, 0x32, 0xb7, 0xe8, 0x9e, 0x6d, 0xcd, 0x8f, 0x4c, - 0x82, 0xc9, 0xb2, 0x84, 0x52, 0x32, 0x9c, 0x26, 0x0d, 0x30, 0xbc, 0x39, 0xb3, - 0x81, 0x6b, 0x7c, 0x46, 0xb4, 0x1b, 0x37, 0xb4, 0x85, 0x0d, 0x2a, 0xe7, 0x4e, - 0x72, 0x9f, 0x99, 0xc6, 0x62, 0x1f, 0xbb, 0xe2, 0xe4, 0x68, 0x72}, - 128, 128, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - 32, BYTES_TO_BITS(AES_16B_KEY_SIZE), PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_RSA_1024 -{"Test psa_asymmetric_decrypt - Invalid usage\n", 8, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0x99, 0xff, 0xde, 0x2f, 0xcc, 0x00, 0xc9, 0xcc, 0x01, 0x97, 0x2e, 0xbf, 0xa7, - 0x77, 0x9b, 0x29, 0x8d, 0xbb, 0xaf, 0x7f, 0x50, 0x70, 0x7a, 0x74, 0x05, 0x29, - 0x6d, 0xd2, 0x78, 0x34, 0x56, 0xfc, 0x79, 0x20, 0x02, 0xf4, 0x62, 0xe7, 0x60, - 0x50, 0x0e, 0x02, 0xaf, 0xa2, 0x5a, 0x85, 0x9a, 0xce, 0x87, 0x01, 0xcb, 0x5d, - 0x3b, 0x02, 0x62, 0x11, 0x64, 0x31, 0xc4, 0x3a, 0xf8, 0xeb, 0x08, 0xf5, 0xa8, - 0x83, 0x01, 0x05, 0x7c, 0xf1, 0xc1, 0x56, 0xa2, 0xa5, 0x19, 0x3c, 0x14, 0x3e, - 0x7a, 0x5b, 0x03, 0xfa, 0xc1, 0x32, 0xb7, 0xe8, 0x9e, 0x6d, 0xcd, 0x8f, 0x4c, - 0x82, 0xc9, 0xb2, 0x84, 0x52, 0x32, 0x9c, 0x26, 0x0d, 0x30, 0xbc, 0x39, 0xb3, - 0x81, 0x6b, 0x7c, 0x46, 0xb4, 0x1b, 0x37, 0xb4, 0x85, 0x0d, 0x2a, 0xe7, 0x4e, - 0x72, 0x9f, 0x99, 0xc6, 0x62, 0x1f, 0xbb, 0xe2, 0xe4, 0x68, 0x72}, - 128, 128, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - 32, 1024, PSA_ERROR_NOT_PERMITTED -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_RSA_PKCS1V15_CRYPT -#ifdef ARCH_TEST_RSA_1024 -{"Test psa_asymmetric_decrypt - Negative case\n", 1, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_DECRYPT, PSA_ALG_RSA_PKCS1V15_CRYPT, -{0}, 0, -{0x99, 0xff, 0xde, 0x2f, 0xcc, 0x00, 0xc9, 0xcc, 0x01, 0x97, 0x2e, 0xbf, 0xa7, - 0x77, 0x9b, 0x29, 0x8d, 0xbb, 0xaf, 0x7f, 0x50, 0x70, 0x7a, 0x74, 0x05, 0x29, - 0x6d, 0xd2, 0x78, 0x34, 0x56, 0xfc, 0x79, 0x20, 0x02, 0xf4, 0x62, 0xe7, 0x60, - 0x50, 0x0e, 0x02, 0xaf, 0xa2, 0x5a, 0x85, 0x9a, 0xce, 0x87, 0x01, 0xcb, 0x5d, - 0x3b, 0x02, 0x62, 0x11, 0x64, 0x31, 0xc4, 0x3a, 0xf8, 0xeb, 0x08, 0xf5, 0xa8, - 0x83, 0x01, 0x05, 0x7c, 0xf1, 0xc1, 0x56, 0xa2, 0xa5, 0x19, 0x3c, 0x14, 0x3e, - 0x7a, 0x5b, 0x03, 0xfa, 0xc1, 0x32, 0xb7, 0xe8, 0x9e, 0x6d, 0xcd, 0x8f, 0x4c, - 0x82, 0xc9, 0xb2, 0x84, 0x52, 0x32, 0x9c, 0x26, 0x0d, 0x30, 0xbc, 0x39, 0xb3, - 0x81, 0x6b, 0x7c, 0x46, 0xb4, 0x1b, 0x37, 0xb4, 0x85, 0x0d, 0x2a, 0xe7, 0x4e, - 0x72, 0x9f, 0x99, 0xc6, 0x62, 0x1f, 0xbb, 0xe2, 0xe4, 0x68, 0x72}, - 128, 128, -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - 32, 1024, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_entry.c deleted file mode 100644 index 7b36aedc40..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c040.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 40) -#define TEST_DESC "Testing crypto asymmetric APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c040_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/main.c deleted file mode 100644 index 2699f556c8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c041(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c041, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.c deleted file mode 100644 index 55106f7288..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.c +++ /dev/null @@ -1,199 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c041.h" -#include "test_data.h" - -client_test_t test_c041_crypto_list[] = { - NULL, - psa_asymmetric_sign_test, - psa_asymmetric_sign_negative_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t signature[SIZE_128B]; - -int32_t psa_asymmetric_sign_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - const uint8_t *key_data; - size_t length; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - memset(signature, 0, sizeof(signature)); - - /* Set the key data based on key type */ - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Sign a hash or short message with a private key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_SIGN, check1[i].key_handle, - check1[i].key_alg, check1[i].input, check1[i].input_length, - signature, check1[i].signature_size, &length); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - continue; - - /* Check if the output length matches with the expected length */ - TEST_ASSERT_EQUAL(length, check1[i].expected_signature_length, TEST_CHECKPOINT_NUM(7)); - - /* Check if the output matches with the expected data */ - TEST_ASSERT_MEMCMP(signature, check1[i].expected_signature, length, TEST_CHECKPOINT_NUM(8)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_asymmetric_sign_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - size_t length; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_sign - Invalid key handle\n", - g_test_count++); - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_sign - Invalid key handle\n", - g_test_count++); - /* Sign a hash or short message with a private key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_SIGN, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, - signature, check2[i].signature_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_sign - zero as key handle\n", - g_test_count++); - /* Sign a hash or short message with a private key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_SIGN, 0, - check2[i].key_alg, check2[i].input, check2[i].input_length, - signature, check2[i].signature_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_sign - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Sign a hash or short message with a private key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_SIGN, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, - signature, check2[i].signature_size, &length); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.h deleted file mode 100644 index 11f8074aa8..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_c041.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C041_CLIENT_TESTS_H_ -#define _TEST_C041_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c041) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c041_crypto_list[]; - -int32_t psa_asymmetric_sign_test(security_t caller); -int32_t psa_asymmetric_sign_negative_test(security_t caller); -#endif /* _TEST_C041_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_data.h deleted file mode 100644 index cecccb6ca9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_data.h +++ /dev/null @@ -1,317 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[16]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t input[32]; - size_t input_length; - size_t signature_size; - uint8_t expected_signature[128]; - size_t expected_signature_length; - size_t expected_bit_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t rsa_256_keypair[1]; -static const uint8_t rsa_256_keydata[1]; -static const uint8_t ec_keydata[1]; - -static const uint8_t ec_keypair[] = { - 0xab, 0x45, 0x43, 0x57, 0x12, 0x64, - 0x9c, 0xb3, 0x0b, 0xbd, 0xda, 0xc4, 0x91, 0x97, 0xee, 0xbf, 0x27, 0x40, 0xff, 0xc7, - 0xf8, 0x74, 0xd9, 0x24, 0x4c, 0x34, 0x60, 0xf5, 0x4f, 0x32, 0x2d, 0x3a}; - -static const uint8_t rsa_128_keydata[] = { - 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, - 0x81, 0x81, 0x00, 0xaf, 0x05, 0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, - 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, 0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, - 0x54, 0x1e, 0xe1, 0xfe, 0xb0, 0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, - 0x49, 0xe1, 0x12, 0x96, 0x28, 0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, - 0x35, 0x24, 0xef, 0x4c, 0x0e, 0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, - 0xf1, 0x23, 0x49, 0xdd, 0xee, 0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, - 0x48, 0xcd, 0x02, 0xb2, 0x02, 0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, - 0xf8, 0x59, 0xc2, 0xc1, 0x81, 0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, - 0xde, 0x26, 0x3a, 0x2a, 0xbf, 0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, - 0x60, 0xf7, 0xd6, 0x83, 0x4d, 0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, - 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t rsa_128_keypair[] = { -0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, -0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, -0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, 0x54, 0x1e, 0xe1, 0xfe, 0xb0, -0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, 0x49, 0xe1, 0x12, 0x96, 0x28, -0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, 0x35, 0x24, 0xef, 0x4c, 0x0e, -0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, 0xf1, 0x23, 0x49, 0xdd, 0xee, -0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, 0x48, 0xcd, 0x02, 0xb2, 0x02, -0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, 0xf8, 0x59, 0xc2, 0xc1, 0x81, -0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, 0xde, 0x26, 0x3a, 0x2a, 0xbf, -0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, 0x60, 0xf7, 0xd6, 0x83, 0x4d, -0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, 0xc3, 0x02, 0x03, 0x01, 0x00, -0x01, 0x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 0x12, 0xd6, 0xb5, 0x2e, 0x2c, 0x98, 0x71, 0xa1, 0x74, -0xc6, 0x6b, 0x48, 0x81, 0x13, 0x02, 0x41, 0x00, 0xc5, 0xab, 0x27, 0x60, 0x21, -0x59, 0xae, 0x7d, 0x6f, 0x20, 0xc3, 0xc2, 0xee, 0x85, 0x1e, 0x46, 0xdc, 0x11, -0x2e, 0x68, 0x9e, 0x28, 0xd5, 0xfc, 0xbb, 0xf9, 0x90, 0xa9, 0x9e, 0xf8, 0xa9, -0x0b, 0x8b, 0xb4, 0x4f, 0xd3, 0x64, 0x67, 0xe7, 0xfc, 0x17, 0x89, 0xce, 0xb6, -0x63, 0xab, 0xda, 0x33, 0x86, 0x52, 0xc3, 0xc7, 0x3f, 0x11, 0x17, 0x74, 0x90, -0x2e, 0x84, 0x05, 0x65, 0x92, 0x70, 0x91, 0x02, 0x41, 0x00, 0xb6, 0xcd, 0xbd, -0x35, 0x4f, 0x7d, 0xf5, 0x79, 0xa6, 0x3b, 0x48, 0xb3, 0x64, 0x3e, 0x35, 0x3b, -0x84, 0x89, 0x87, 0x77, 0xb4, 0x8b, 0x15, 0xf9, 0x4e, 0x0b, 0xfc, 0x05, 0x67, -0xa6, 0xae, 0x59, 0x11, 0xd5, 0x7a, 0xd6, 0x40, 0x9c, 0xf7, 0x64, 0x7b, 0xf9, -0x62, 0x64, 0xe9, 0xbd, 0x87, 0xeb, 0x95, 0xe2, 0x63, 0xb7, 0x11, 0x0b, 0x9a, -0x1f, 0x9f, 0x94, 0xac, 0xce, 0xd0, 0xfa, 0xfa, 0x4d, 0x02, 0x40, 0x71, 0x19, -0x5e, 0xec, 0x37, 0xe8, 0xd2, 0x57, 0xde, 0xcf, 0xc6, 0x72, 0xb0, 0x7a, 0xe6, -0x39, 0xf1, 0x0c, 0xbb, 0x9b, 0x0c, 0x73, 0x9d, 0x0c, 0x80, 0x99, 0x68, 0xd6, -0x44, 0xa9, 0x4e, 0x3f, 0xd6, 0xed, 0x92, 0x87, 0x07, 0x7a, 0x14, 0x58, 0x3f, -0x37, 0x90, 0x58, 0xf7, 0x6a, 0x8a, 0xec, 0xd4, 0x3c, 0x62, 0xdc, 0x8c, 0x0f, -0x41, 0x76, 0x66, 0x50, 0xd7, 0x25, 0x27, 0x5a, 0xc4, 0xa1, 0x02, 0x41, 0x00, -0xbb, 0x32, 0xd1, 0x33, 0xed, 0xc2, 0xe0, 0x48, 0xd4, 0x63, 0x38, 0x8b, 0x7b, -0xe9, 0xcb, 0x4b, 0xe2, 0x9f, 0x4b, 0x62, 0x50, 0xbe, 0x60, 0x3e, 0x70, 0xe3, -0x64, 0x75, 0x01, 0xc9, 0x7d, 0xdd, 0xe2, 0x0a, 0x4e, 0x71, 0xbe, 0x95, 0xfd, -0x5e, 0x71, 0x78, 0x4e, 0x25, 0xac, 0xa4, 0xba, 0xf2, 0x5b, 0xe5, 0x73, 0x8a, -0xae, 0x59, 0xbb, 0xfe, 0x1c, 0x99, 0x77, 0x81, 0x44, 0x7a, 0x2b, 0x24}; - -static test_data check1[] = { -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -{"Test psa_asymmetric_sign - RSA KEYPAIR PKCS1V15 RAW\n", 1, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, -{0x61, 0x62, 0x63}, 3, 128, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -#ifdef ARCH_TEST_SHA256 -{"Test psa_asymmetric_sign - RSA KEYPAIR PKCS1V15 SHA-256\n", 2, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, 128, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_SUCCESS -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_DETERMINISTIC_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_asymmetric_sign - ECDSA SECP256R1 SHA-256\n", 3, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), {0}, 32, - PSA_KEY_USAGE_SIGN, PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256), -{0x9a, 0xc4, 0x33, 0x5b, 0x46, 0x9b, 0xbd, 0x79, 0x14, 0x39, 0x24, 0x85, 0x04, - 0xdd, 0x0d, 0x49, 0xc7, 0x13, 0x49, 0xa2, 0x95, 0xfe, 0xe5, 0xa1, 0xc6, 0x85, - 0x07, 0xf4, 0x5a, 0x9e, 0x1c, 0x7b}, 32, 128, -{0x6a, 0x33, 0x99, 0xf6, 0x94, 0x21, 0xff, 0xe1, 0x49, 0x03, 0x77, 0xad, 0xf2, - 0xea, 0x1f, 0x11, 0x7d, 0x81, 0xa6, 0x3c, 0xf5, 0xbf, 0x22, 0xe9, 0x18, 0xd5, - 0x11, 0x75, 0xeb, 0x25, 0x91, 0x51, 0xce, 0x95, 0xd7, 0xc2, 0x6c, 0xc0, 0x4e, - 0x25, 0x50, 0x3e, 0x2f, 0x7a, 0x1e, 0xc3, 0x57, 0x3e, 0x3c, 0x24, 0x12, 0x53, - 0x4b, 0xb4, 0xa1, 0x9b, 0x3a, 0x78, 0x11, 0x74, 0x2f, 0x49, 0xf5, 0x0f}, - 64, 512, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -{"Test psa_asymmetric_sign - Invalid key type (RSA public key)\n", 4, -PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, 128, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_asymmetric_sign - Small output buffer\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, 120, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif - -{"Test psa_asymmetric_sign - Invalid algorithm\n", 6, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_SIGN, PSA_ALG_SHA_256, -{0x61, 0x62, 0x63}, 3, 128, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -#ifdef ARCH_TEST_AES_128 -{"Test psa_asymmetric_sign - Invalid key type (AES Key)\n", 7, PSA_KEY_TYPE_AES, -{0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, - 0x7d, 0x39, 0x6e}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_SIGN, - PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0x61, 0x62, 0x63}, 3, 128, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, BYTES_TO_BITS(AES_16B_KEY_SIZE), PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -{"Test psa_asymmetric_sign - Invalid usage\n", 8, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, -{0x61, 0x62, 0x63}, 3, 128, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_ERROR_NOT_PERMITTED -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -#ifdef ARCH_TEST_SHA256 -{"Test psa_asymmetric_sign - Wrong hash size\n", 9, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00}, 30, 128, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -{"Test psa_asymmetric_sign - Negative case\n", 10, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_SIGN, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, -{0x61, 0x62, 0x63}, 3, 128, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_entry.c deleted file mode 100644 index dd70f13e0a..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c041/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c041.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 41) -#define TEST_DESC "Testing crypto asymmetric APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c041_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/main.c deleted file mode 100644 index 024d74494e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c042(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c042, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.c deleted file mode 100644 index afa83775c7..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.c +++ /dev/null @@ -1,190 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c042.h" -#include "test_data.h" - -client_test_t test_c042_crypto_list[] = { - NULL, - psa_asymmetric_verify_test, - psa_asymmetric_verify_negative_test, - NULL, -}; - -static int g_test_count = 1; - -int32_t psa_asymmetric_verify_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - const uint8_t *key_data; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Set the key data based on key type */ - if (PSA_KEY_TYPE_IS_RSA(check1[i].key_type)) - { - if (check1[i].key_type == PSA_KEY_TYPE_RSA_KEYPAIR) - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keypair; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keypair; - else - return VAL_STATUS_INVALID; - } - else - { - if (check1[i].expected_bit_length == BYTES_TO_BITS(384)) - key_data = rsa_384_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(256)) - key_data = rsa_256_keydata; - else if (check1[i].expected_bit_length == BYTES_TO_BITS(128)) - key_data = rsa_128_keydata; - else - return VAL_STATUS_INVALID; - } - } - else if (PSA_KEY_TYPE_IS_ECC(check1[i].key_type)) - { - if (PSA_KEY_TYPE_IS_ECC_KEYPAIR(check1[i].key_type)) - key_data = ec_keypair; - else - key_data = ec_keydata; - } - else - key_data = check1[i].key_data; - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Verify the signature a hash or short message using a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_VERIFY, check1[i].key_handle, - check1[i].key_alg, check1[i].input, check1[i].input_length, - check1[i].signature, check1[i].signature_size); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_asymmetric_verify_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_verify - Invalid key handle\n", - g_test_count++); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_verify - Invalid key handle\n", - g_test_count++); - /* Verify the signature a hash or short message using a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_VERIFY, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, - check2[i].signature, check2[i].signature_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_verify - Zero as key handle\n", - g_test_count++); - /* Verify the signature a hash or short message using a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_VERIFY, 0, - check2[i].key_alg, check2[i].input, check2[i].input_length, - check2[i].signature, check2[i].signature_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_asymmetric_verify - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Verify the signature a hash or short message using a public key */ - status = val->crypto_function(VAL_CRYPTO_ASYMMTERIC_VERIFY, check2[i].key_handle, - check2[i].key_alg, check2[i].input, check2[i].input_length, - check2[i].signature, check2[i].signature_size); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} - diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.h deleted file mode 100644 index b6c2f615ce..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_c042.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C042_CLIENT_TESTS_H_ -#define _TEST_C042_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c042) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c042_crypto_list[]; - -int32_t psa_asymmetric_verify_test(security_t caller); -int32_t psa_asymmetric_verify_negative_test(security_t caller); -#endif /* _TEST_C042_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_data.h deleted file mode 100644 index 53a4ea609b..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_data.h +++ /dev/null @@ -1,373 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[16]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t input[32]; - size_t input_length; - uint8_t signature[128]; - size_t signature_size; - size_t expected_bit_length; - psa_status_t expected_status; -} test_data; - -static const uint8_t rsa_384_keypair[1]; -static const uint8_t rsa_384_keydata[1]; -static const uint8_t rsa_256_keypair[1]; -static const uint8_t rsa_256_keydata[1]; -static const uint8_t ec_keydata[] = { - 0x04, 0xde, - 0xa5, 0xe4, 0x5d, 0x0e, 0xa3, 0x7f, 0xc5, 0x66, 0x23, 0x2a, 0x50, 0x8f, 0x4a, 0xd2, - 0x0e, 0xa1, 0x3d, 0x47, 0xe4, 0xbf, 0x5f, 0xa4, 0xd5, 0x4a, 0x57, 0xa0, 0xba, 0x01, - 0x20, 0x42, 0x08, 0x70, 0x97, 0x49, 0x6e, 0xfc, 0x58, 0x3f, 0xed, 0x8b, 0x24, 0xa5, - 0xb9, 0xbe, 0x9a, 0x51, 0xde, 0x06, 0x3f, 0x5a, 0x00, 0xa8, 0xb6, 0x98, 0xa1, 0x6f, - 0xd7, 0xf2, 0x9b, 0x54, 0x85, 0xf3, 0x20}; - -static const uint8_t ec_keypair[] = { - 0xab, 0x45, 0x43, 0x57, 0x12, 0x64, - 0x9c, 0xb3, 0x0b, 0xbd, 0xda, 0xc4, 0x91, 0x97, 0xee, 0xbf, 0x27, 0x40, 0xff, 0xc7, - 0xf8, 0x74, 0xd9, 0x24, 0x4c, 0x34, 0x60, 0xf5, 0x4f, 0x32, 0x2d, 0x3a}; - -static const uint8_t rsa_128_keydata[] = { - 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, - 0x81, 0x81, 0x00, 0xaf, 0x05, 0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f, 0xdb, - 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, 0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, - 0x54, 0x1e, 0xe1, 0xfe, 0xb0, 0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, - 0x49, 0xe1, 0x12, 0x96, 0x28, 0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, - 0x35, 0x24, 0xef, 0x4c, 0x0e, 0x6e, 0x1d, 0x89, 0x56, 0xee, 0xb2, 0x07, 0x7a, - 0xf1, 0x23, 0x49, 0xdd, 0xee, 0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2, 0xc6, 0x19, - 0x48, 0xcd, 0x02, 0xb2, 0x02, 0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, - 0xf8, 0x59, 0xc2, 0xc1, 0x81, 0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, - 0xde, 0x26, 0x3a, 0x2a, 0xbf, 0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, - 0x60, 0xf7, 0xd6, 0x83, 0x4d, 0xa5, 0x3d, 0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, - 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01}; - -static const uint8_t rsa_128_keypair[] = { -0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x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, 0xa9, -0x0b, 0x8b, 0xb4, 0x4f, 0xd3, 0x64, 0x67, 0xe7, 0xfc, 0x17, 0x89, 0xce, 0xb6, -0x63, 0xab, 0xda, 0x33, 0x86, 0x52, 0xc3, 0xc7, 0x3f, 0x11, 0x17, 0x74, 0x90, -0x2e, 0x84, 0x05, 0x65, 0x92, 0x70, 0x91, 0x02, 0x41, 0x00, 0xb6, 0xcd, 0xbd, -0x35, 0x4f, 0x7d, 0xf5, 0x79, 0xa6, 0x3b, 0x48, 0xb3, 0x64, 0x3e, 0x35, 0x3b, -0x84, 0x89, 0x87, 0x77, 0xb4, 0x8b, 0x15, 0xf9, 0x4e, 0x0b, 0xfc, 0x05, 0x67, -0xa6, 0xae, 0x59, 0x11, 0xd5, 0x7a, 0xd6, 0x40, 0x9c, 0xf7, 0x64, 0x7b, 0xf9, -0x62, 0x64, 0xe9, 0xbd, 0x87, 0xeb, 0x95, 0xe2, 0x63, 0xb7, 0x11, 0x0b, 0x9a, -0x1f, 0x9f, 0x94, 0xac, 0xce, 0xd0, 0xfa, 0xfa, 0x4d, 0x02, 0x40, 0x71, 0x19, -0x5e, 0xec, 0x37, 0xe8, 0xd2, 0x57, 0xde, 0xcf, 0xc6, 0x72, 0xb0, 0x7a, 0xe6, -0x39, 0xf1, 0x0c, 0xbb, 0x9b, 0x0c, 0x73, 0x9d, 0x0c, 0x80, 0x99, 0x68, 0xd6, -0x44, 0xa9, 0x4e, 0x3f, 0xd6, 0xed, 0x92, 0x87, 0x07, 0x7a, 0x14, 0x58, 0x3f, -0x37, 0x90, 0x58, 0xf7, 0x6a, 0x8a, 0xec, 0xd4, 0x3c, 0x62, 0xdc, 0x8c, 0x0f, -0x41, 0x76, 0x66, 0x50, 0xd7, 0x25, 0x27, 0x5a, 0xc4, 0xa1, 0x02, 0x41, 0x00, -0xbb, 0x32, 0xd1, 0x33, 0xed, 0xc2, 0xe0, 0x48, 0xd4, 0x63, 0x38, 0x8b, 0x7b, -0xe9, 0xcb, 0x4b, 0xe2, 0x9f, 0x4b, 0x62, 0x50, 0xbe, 0x60, 0x3e, 0x70, 0xe3, -0x64, 0x75, 0x01, 0xc9, 0x7d, 0xdd, 0xe2, 0x0a, 0x4e, 0x71, 0xbe, 0x95, 0xfd, -0x5e, 0x71, 0x78, 0x4e, 0x25, 0xac, 0xa4, 0xba, 0xf2, 0x5b, 0xe5, 0x73, 0x8a, -0xae, 0x59, 0xbb, 0xfe, 0x1c, 0x99, 0x77, 0x81, 0x44, 0x7a, 0x2b, 0x24}; - -static test_data check1[] = { -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -{"Test psa_asymmetric_verify - RSA KEYPAIR PKCS1V15 RAW\n", 1, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, -{0x61, 0x62, 0x63}, 3, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -#ifdef ARCH_TEST_SHA256 -{"Test psa_asymmetric_verify - RSA KEYPAIR PKCS1V15 SHA-256\n", 2, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_SUCCESS -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_DETERMINISTIC_ECDSA -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_asymmetric_verify - ECDSA KEYPAIR SECP256R1 SHA-256\n", 3, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), {0}, 32, - PSA_KEY_USAGE_VERIFY, PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256), -{0x9a, 0xc4, 0x33, 0x5b, 0x46, 0x9b, 0xbd, 0x79, 0x14, 0x39, 0x24, 0x85, 0x04, - 0xdd, 0x0d, 0x49, 0xc7, 0x13, 0x49, 0xa2, 0x95, 0xfe, 0xe5, 0xa1, 0xc6, 0x85, - 0x07, 0xf4, 0x5a, 0x9e, 0x1c, 0x7b}, 32, -{0x6a, 0x33, 0x99, 0xf6, 0x94, 0x21, 0xff, 0xe1, 0x49, 0x03, 0x77, 0xad, 0xf2, - 0xea, 0x1f, 0x11, 0x7d, 0x81, 0xa6, 0x3c, 0xf5, 0xbf, 0x22, 0xe9, 0x18, 0xd5, - 0x11, 0x75, 0xeb, 0x25, 0x91, 0x51, 0xce, 0x95, 0xd7, 0xc2, 0x6c, 0xc0, 0x4e, - 0x25, 0x50, 0x3e, 0x2f, 0x7a, 0x1e, 0xc3, 0x57, 0x3e, 0x3c, 0x24, 0x12, 0x53, - 0x4b, 0xb4, 0xa1, 0x9b, 0x3a, 0x78, 0x11, 0x74, 0x2f, 0x49, 0xf5, 0x0f}, - 64, 512, PSA_SUCCESS -}, -#endif -#endif - -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -{"Test psa_asymmetric_verify - RSA public key\n", 4, -PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_SUCCESS -}, - -{"Test psa_asymmetric_verify - Small output buffer\n", 5, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 120, 1024, PSA_ERROR_BUFFER_TOO_SMALL -}, -#endif - -{"Test psa_asymmetric_verify - Invalid algorithm\n", 6, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_VERIFY, PSA_ALG_SHA_256, -{0x61, 0x62, 0x63}, 3, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -#ifdef ARCH_TEST_AES_128 -{"Test psa_asymmetric_verify - Invalid key type (AES Key)\n", 7, PSA_KEY_TYPE_AES, -{0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, - 0x7d, 0x39, 0x6e}, AES_16B_KEY_SIZE, PSA_KEY_USAGE_VERIFY, - PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0x61, 0x62, 0x63}, 3, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, BYTES_TO_BITS(AES_16B_KEY_SIZE), PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -{"Test psa_asymmetric_verify - Invalid usage\n", 8, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, -{0x61, 0x62, 0x63}, 3, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_ERROR_NOT_PERMITTED -}, -#endif - -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN -#ifdef ARCH_TEST_SHA256 -{"Test psa_asymmetric_verify - Wrong hash size\n", 9, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00}, 30, -{0xa7, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_asymmetric_verify - Wrong signature\n", 10, -PSA_KEY_TYPE_RSA_PUBLIC_KEY, -{0}, 162, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN(PSA_ALG_SHA_256), -{0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, - 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, - 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, 32, -{0xa8, 0x36, 0x64, 0xd5, 0x5b, 0x39, 0xc7, 0xea, 0x6c, 0x1e, 0x5b, 0x50, 0x11, - 0x72, 0x4a, 0x11, 0xe1, 0xd7, 0x07, 0x3d, 0x3a, 0x68, 0xf4, 0x8c, 0x83, 0x6f, - 0xad, 0x15, 0x3a, 0x1d, 0x91, 0xb6, 0xab, 0xdb, 0xc8, 0xf6, 0x9d, 0xa1, 0x3b, - 0x20, 0x6c, 0xc9, 0x6a, 0xf6, 0x36, 0x3b, 0x11, 0x44, 0x58, 0xb0, 0x26, 0xaf, - 0x14, 0xb2, 0x4f, 0xab, 0x89, 0x29, 0xed, 0x63, 0x4c, 0x6a, 0x2a, 0xca, 0xce, - 0x0b, 0xcc, 0x62, 0xd9, 0xbb, 0x6a, 0x98, 0x4a, 0xfb, 0xcb, 0xfc, 0xd3, 0xa0, - 0x60, 0x8d, 0x32, 0xa2, 0xba, 0xe5, 0x35, 0xb9, 0xcd, 0x1e, 0xcd, 0xf9, 0xdd, - 0x28, 0x1d, 0xb1, 0xe0, 0x02, 0x5c, 0x3b, 0xfb, 0x55, 0x12, 0x96, 0x3e, 0xc3, - 0xb9, 0x8d, 0xda, 0xa6, 0x9e, 0x38, 0xbc, 0x3c, 0x84, 0xb1, 0xb6, 0x1a, 0x04, - 0xe5, 0x64, 0x86, 0x40, 0x85, 0x6a, 0xac, 0xc6, 0xfc, 0x73, 0x11}, - 128, 1024, PSA_ERROR_INVALID_SIGNATURE -}, -#endif -#endif -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -#ifdef ARCH_TEST_ECDSA -{"Test psa_asymmetric_verify - EC public key\n", 11, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), -{0}, 65, PSA_KEY_USAGE_VERIFY, PSA_ALG_ECDSA_ANY, -{0x9a, 0xc4, 0x33, 0x5b, 0x46, 0x9b, 0xbd, 0x79, 0x14, 0x39, 0x24, 0x85, 0x04, - 0xdd, 0x0d, 0x49, 0xc7, 0x13, 0x49, 0xa2, 0x95, 0xfe, 0xe5, 0xa1, 0xc6, 0x85, - 0x07, 0xf4, 0x5a, 0x9e, 0x1c, 0x7b}, 32, -{0x6a, 0x33, 0x99, 0xf6, 0x94, 0x21, 0xff, 0xe1, 0x49, 0x03, 0x77, 0xad, 0xf2, - 0xea, 0x1f, 0x11, 0x7d, 0x81, 0xa6, 0x3c, 0xf5, 0xbf, 0x22, 0xe9, 0x18, 0xd5, - 0x11, 0x75, 0xeb, 0x25, 0x91, 0x51, 0xce, 0x95, 0xd7, 0xc2, 0x6c, 0xc0, 0x4e, - 0x25, 0x50, 0x3e, 0x2f, 0x7a, 0x1e, 0xc3, 0x57, 0x3e, 0x3c, 0x24, 0x12, 0x53, - 0x4b, 0xb4, 0xa1, 0x9b, 0x3a, 0x78, 0x11, 0x74, 0x2f, 0x49, 0xf5, 0x0f}, - 64, 512, PSA_SUCCESS -}, - -{"Test psa_asymmetric_verify - Wrong signature size\n", 12, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), -{0}, 65, PSA_KEY_USAGE_VERIFY, PSA_ALG_ECDSA_ANY, -{0x9a, 0xc4, 0x33, 0x5b, 0x46, 0x9b, 0xbd, 0x79, 0x14, 0x39, 0x24, 0x85, 0x04, - 0xdd, 0x0d, 0x49, 0xc7, 0x13, 0x49, 0xa2, 0x95, 0xfe, 0xe5, 0xa1, 0xc6, 0x85, - 0x07, 0xf4, 0x5a, 0x9e, 0x1c, 0x7b}, 32, -{0x6a, 0x33, 0x99, 0xf6, 0x94, 0x21, 0xff, 0xe1, 0x49, 0x03, 0x77, 0xad, 0xf2, - 0xea, 0x1f, 0x11, 0x7d, 0x81, 0xa6, 0x3c, 0xf5, 0xbf, 0x22, 0xe9, 0x18, 0xd5, - 0x11, 0x75, 0xeb, 0x25, 0x91, 0x51, 0xce, 0x95, 0xd7, 0xc2, 0x6c, 0xc0, 0x4e, - 0x25, 0x50, 0x3e, 0x2f, 0x7a, 0x1e, 0xc3, 0x57, 0x3e, 0x3c, 0x24, 0x12, 0x53, - 0x4b, 0xb4, 0xa1, 0x9b, 0x3a, 0x78, 0x11, 0x74, 0x2f, 0x49, 0xf5, 0x0f, 0x00}, - 65, 512, PSA_ERROR_INVALID_SIGNATURE -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_RSA_1024 -#ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -{"Test psa_asymmetric_verify - Negative case\n", 13, PSA_KEY_TYPE_RSA_KEYPAIR, -{0}, 610, PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW, -{0x61, 0x62, 0x63}, 3, -{0x2c, 0x77, 0x44, 0x98, 0x3f, 0x02, 0x3a, 0xc7, 0xbb, 0x1c, 0x55, 0x52, 0x9d, - 0x83, 0xed, 0x11, 0xa7, 0x6a, 0x78, 0x98, 0xa1, 0xbb, 0x5c, 0xe1, 0x91, 0x37, - 0x5a, 0x4a, 0xa7, 0x49, 0x5a, 0x63, 0x3d, 0x27, 0x87, 0x9f, 0xf5, 0x8e, 0xba, - 0x5a, 0x57, 0x37, 0x1c, 0x34, 0xfe, 0xb1, 0x18, 0x0e, 0x8b, 0x85, 0x0d, 0x55, - 0x24, 0x76, 0xeb, 0xb5, 0x63, 0x4d, 0xf6, 0x20, 0x26, 0x19, 0x92, 0xf1, 0x2e, - 0xbe, 0xe9, 0x09, 0x70, 0x41, 0xdb, 0xbe, 0xa8, 0x5a, 0x42, 0xd4, 0x5b, 0x34, - 0x4b, 0xe5, 0x07, 0x3c, 0xeb, 0x77, 0x2f, 0xfc, 0x60, 0x49, 0x54, 0xb9, 0x15, - 0x8b, 0xa8, 0x1e, 0xc3, 0xdc, 0x4d, 0x9d, 0x65, 0xe3, 0xab, 0x7a, 0xa3, 0x18, - 0x16, 0x5f, 0x38, 0xc3, 0x6f, 0x84, 0x1f, 0x1c, 0x69, 0xcb, 0x1c, 0xfa, 0x49, - 0x4a, 0xa5, 0xcb, 0xb4, 0xd6, 0xc0, 0xef, 0xba, 0xfb, 0x04, 0x3a}, - 128, 1024, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_entry.c deleted file mode 100644 index 7687142f21..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c042/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c042.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 42) -#define TEST_DESC "Testing crypto asymmetric APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c042_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/main.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/main.c deleted file mode 100644 index 47e9adca0f..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "val_interfaces.h" -#include "pal_mbed_os_intf.h" - -void test_entry_c043(val_api_t *val_api, psa_api_t *psa_api); - -int main(void) -{ - test_start(test_entry_c043, COMPLIANCE_TEST_CRYPTO); -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.c deleted file mode 100644 index bf4f99eca9..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.c +++ /dev/null @@ -1,186 +0,0 @@ - -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c043.h" -#include "test_data.h" - -client_test_t test_c043_crypto_list[] = { - NULL, - psa_key_agreement_test, - psa_key_agreement_negative_test, - NULL, -}; - -static int g_test_count = 1; -static uint8_t output[SIZE_50B]; - -int32_t psa_key_agreement_test(security_t caller) -{ - int num_checks = sizeof(check1)/sizeof(check1[0]); - int32_t i, status; - size_t capacity; - psa_key_policy_t policy; - psa_crypto_generator_t generator = {0}; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] ", g_test_count++); - val->print(PRINT_TEST, check1[i].test_desc, 0); - - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check1[i].usage, - check1[i].key_alg); - - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(3)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check1[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(4)); - - /* Import the key data into the key slot */ - status = val->crypto_function(VAL_CRYPTO_IMPORT_KEY, check1[i].key_handle, - check1[i].key_type, check1[i].key_data, check1[i].key_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set up a key agreement operation */ - status = val->crypto_function(VAL_CRYPTO_KEY_AGREEMENT, &generator, - check1[i].key_handle, check1[i].peer_key, check1[i].peer_key_length, - check1[i].key_alg); - TEST_ASSERT_EQUAL(status, check1[i].expected_status, TEST_CHECKPOINT_NUM(6)); - - if (check1[i].expected_status != PSA_SUCCESS) - { - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(7)); - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(8)); - continue; - } - - /* Retrieve the current capacity of a generator */ - status = val->crypto_function(VAL_CRYPTO_GET_GENERATOR_CAPACITY, &generator, &capacity); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(9)); - - /* Check if the generator capacity matches with the expected capacity */ - TEST_ASSERT_EQUAL(capacity, check1[i].expected_capacity, TEST_CHECKPOINT_NUM(10)); - - /* Read some data from a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_READ, &generator, output, - check1[i].expected_output_length); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(11)); - - /* Check if the output matches with the expected data */ - TEST_ASSERT_MEMCMP(output, check1[i].expected_output, check1[i].expected_output_length, - TEST_CHECKPOINT_NUM(12)); - - /* Abort a generator */ - status = val->crypto_function(VAL_CRYPTO_GENERATOR_ABORT, &generator); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(13)); - - /* Destroy a key and restore the slot to its default state */ - status = val->crypto_function(VAL_CRYPTO_DESTROY_KEY, check1[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(14)); - } - - return VAL_STATUS_SUCCESS; -} - -int32_t psa_key_agreement_negative_test(security_t caller) -{ - int num_checks = sizeof(check2)/sizeof(check2[0]); - int32_t i, status; - psa_key_policy_t policy; - psa_crypto_generator_t generator = {0}; - - /* Initialize the PSA crypto library*/ - status = val->crypto_function(VAL_CRYPTO_INIT); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(1)); - - for (i = 0; i < num_checks; i++) - { - val->print(PRINT_TEST, "[Check %d] Test psa_key_agreement - Invalid key handle\n", - g_test_count++); - /* Initialize a key policy structure to a default that forbids all - * usage of the key - */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_INIT, &policy); - - /* Setting up the watchdog timer for each check */ - status = val->wd_reprogram_timer(WD_CRYPTO_TIMEOUT); - TEST_ASSERT_EQUAL(status, VAL_STATUS_SUCCESS, TEST_CHECKPOINT_NUM(2)); - - /* Set the standard fields of a policy structure */ - val->crypto_function(VAL_CRYPTO_KEY_POLICY_SET_USAGE, &policy, check2[i].usage, - check2[i].key_alg); - - val->print(PRINT_TEST, "[Check %d] Test psa_key_agreement - Invalid key handle\n", - g_test_count++); - /* Set up a key agreement operation */ - status = val->crypto_function(VAL_CRYPTO_KEY_AGREEMENT, &generator, - check2[i].key_handle, check2[i].peer_key, check2[i].peer_key_length, - check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(3)); - - val->print(PRINT_TEST, "[Check %d] Test psa_key_agreement - Zero as key handle\n", - g_test_count++); - /* Set up a key agreement operation */ - status = val->crypto_function(VAL_CRYPTO_KEY_AGREEMENT, &generator, - 0, check2[i].peer_key, check2[i].peer_key_length, - check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_INVALID_HANDLE, TEST_CHECKPOINT_NUM(4)); - - val->print(PRINT_TEST, "[Check %d] Test psa_key_agreement - Empty key handle\n", - g_test_count++); - /* Allocate a key slot for a transient key */ - status = val->crypto_function(VAL_CRYPTO_ALLOCATE_KEY, &check2[i].key_handle); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5)); - - /* Set the usage policy on a key slot */ - status = val->crypto_function(VAL_CRYPTO_SET_KEY_POLICY, check2[i].key_handle, - &policy); - TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6)); - - /* Set up a key agreement operation */ - status = val->crypto_function(VAL_CRYPTO_KEY_AGREEMENT, &generator, - check2[i].key_handle, check2[i].peer_key, check2[i].peer_key_length, - check2[i].key_alg); - TEST_ASSERT_EQUAL(status, PSA_ERROR_EMPTY_SLOT, TEST_CHECKPOINT_NUM(7)); - } - - return VAL_STATUS_SUCCESS; -} diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.h deleted file mode 100644 index 0192b6e66e..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_c043.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ -#ifndef _TEST_C043_CLIENT_TESTS_H_ -#define _TEST_C043_CLIENT_TESTS_H_ - -#include "val_crypto.h" -#define test_entry CONCAT(test_entry_,c043) -#define val CONCAT(val,test_entry) -#define psa CONCAT(psa,test_entry) - -extern val_api_t *val; -extern psa_api_t *psa; -extern client_test_t test_c043_crypto_list[]; - -int32_t psa_key_agreement_test(security_t caller); -int32_t psa_key_agreement_negative_test(security_t caller); -#endif /* _TEST_C043_CLIENT_TESTS_H_ */ diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_data.h b/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_data.h deleted file mode 100644 index e2d100fccd..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_data.h +++ /dev/null @@ -1,194 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_crypto.h" - -typedef struct { - char test_desc[75]; - psa_key_handle_t key_handle; - psa_key_type_t key_type; - uint8_t key_data[91]; - uint32_t key_length; - psa_key_usage_t usage; - psa_algorithm_t key_alg; - uint8_t peer_key[120]; - size_t peer_key_length; - uint8_t expected_output[48]; - size_t expected_output_length; - size_t expected_capacity; - psa_status_t expected_status; -} test_data; - - -static test_data check1[] = { -#ifdef ARCH_TEST_ECDH -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_key_agreement - ECDH SECP256R1\n", 1, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0xc8, 0x8f, 0x01, 0xf5, 0x10, 0xd9, 0xac, 0x3f, 0x70, 0xa2, 0x92, 0xda, 0xa2, - 0x31, 0x6d, 0xe5, 0x44, 0xe9, 0xaa, 0xb8, 0xaf, 0xe8, 0x40, 0x49, 0xc6, 0x2a, - 0x9c, 0x57, 0x86, 0x2d, 0x14, 0x33}, 32, PSA_KEY_USAGE_DERIVE, PSA_ALG_ECDH(PSA_ALG_SELECT_RAW), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, -{0xd6, 0x84, 0x0f, 0x6b, 0x42, 0xf6, 0xed, 0xaf, 0xd1, 0x31, 0x16, 0xe0, 0xe1, - 0x25, 0x65, 0x20, 0x2f, 0xef, 0x8e, 0x9e, 0xce, 0x7d, 0xce, 0x03, 0x81, 0x24, - 0x64, 0xd0, 0x4b, 0x94, 0x42, 0xde}, 32, 32, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP384R1 -{"Test psa_key_agreement - ECDH SECP384R1\n", 2, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP384R1), -{0x09, 0x9f, 0x3c, 0x70, 0x34, 0xd4, 0xa2, 0xc6, 0x99, 0x88, 0x4d, 0x73, 0xa3, - 0x75, 0xa6, 0x7f, 0x76, 0x24, 0xef, 0x7c, 0x6b, 0x3c, 0x0f, 0x16, 0x06, 0x47, - 0xb6, 0x74, 0x14, 0xdc, 0xe6, 0x55, 0xe3, 0x5b, 0x53, 0x80, 0x41, 0xe6, 0x49, - 0xee, 0x3f, 0xae, 0xf8, 0x96, 0x78, 0x3a, 0xb1, 0x94}, 48, PSA_KEY_USAGE_DERIVE, - PSA_ALG_ECDH(PSA_ALG_SELECT_RAW), -{0x04, 0xe5, 0x58, - 0xdb, 0xef, 0x53, 0xee, 0xcd, 0xe3, 0xd3, 0xfc, 0xcf, 0xc1, 0xae, 0xa0, 0x8a, - 0x89, 0xa9, 0x87, 0x47, 0x5d, 0x12, 0xfd, 0x95, 0x0d, 0x83, 0xcf, 0xa4, 0x17, - 0x32, 0xbc, 0x50, 0x9d, 0x0d, 0x1a, 0xc4, 0x3a, 0x03, 0x36, 0xde, 0xf9, 0x6f, - 0xda, 0x41, 0xd0, 0x77, 0x4a, 0x35, 0x71, 0xdc, 0xfb, 0xec, 0x7a, 0xac, 0xf3, - 0x19, 0x64, 0x72, 0x16, 0x9e, 0x83, 0x84, 0x30, 0x36, 0x7f, 0x66, 0xee, 0xbe, - 0x3c, 0x6e, 0x70, 0xc4, 0x16, 0xdd, 0x5f, 0x0c, 0x68, 0x75, 0x9d, 0xd1, 0xff, - 0xf8, 0x3f, 0xa4, 0x01, 0x42, 0x20, 0x9d, 0xff, 0x5e, 0xaa, 0xd9, 0x6d, 0xb9, - 0xe6, 0x38, 0x6c}, 97, -{0x11, 0x18, 0x73, 0x31, 0xc2, 0x79, 0x96, 0x2d, 0x93, 0xd6, 0x04, 0x24, 0x3f, - 0xd5, 0x92, 0xcb, 0x9d, 0x0a, 0x92, 0x6f, 0x42, 0x2e, 0x47, 0x18, 0x75, 0x21, - 0x28, 0x7e, 0x71, 0x56, 0xc5, 0xc4, 0xd6, 0x03, 0x13, 0x55, 0x69, 0xb9, 0xe9, - 0xd0, 0x9c, 0xf5, 0xd4, 0xa2, 0x70, 0xf5, 0x97, 0x46}, 48, 48, PSA_SUCCESS -}, -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_key_agreement - Invalid usage\n", 3, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0xc8, 0x8f, 0x01, 0xf5, 0x10, 0xd9, 0xac, 0x3f, 0x70, 0xa2, 0x92, 0xda, 0xa2, - 0x31, 0x6d, 0xe5, 0x44, 0xe9, 0xaa, 0xb8, 0xaf, 0xe8, 0x40, 0x49, 0xc6, 0x2a, - 0x9c, 0x57, 0x86, 0x2d, 0x14, 0x33}, 32, PSA_KEY_USAGE_ENCRYPT, PSA_ALG_ECDH(PSA_ALG_SELECT_RAW), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, -{0xd6, 0x84, 0x0f, 0x6b, 0x42, 0xf6, 0xed, 0xaf, 0xd1, 0x31, 0x16, 0xe0, 0xe1, - 0x25, 0x65, 0x20, 0x2f, 0xef, 0x8e, 0x9e, 0xce, 0x7d, 0xce, 0x03, 0x81, 0x24, - 0x64, 0xd0, 0x4b, 0x94, 0x42, 0xde}, 32, 32, PSA_ERROR_NOT_PERMITTED -}, - -{"Test psa_key_agreement - Unknown KDF\n", 4, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0xc8, 0x8f, 0x01, 0xf5, 0x10, 0xd9, 0xac, 0x3f, 0x70, 0xa2, 0x92, 0xda, 0xa2, - 0x31, 0x6d, 0xe5, 0x44, 0xe9, 0xaa, 0xb8, 0xaf, 0xe8, 0x40, 0x49, 0xc6, 0x2a, - 0x9c, 0x57, 0x86, 0x2d, 0x14, 0x33}, 32, PSA_KEY_USAGE_DERIVE, PSA_ALG_ECDH(0), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, -{0xd6, 0x84, 0x0f, 0x6b, 0x42, 0xf6, 0xed, 0xaf, 0xd1, 0x31, 0x16, 0xe0, 0xe1, - 0x25, 0x65, 0x20, 0x2f, 0xef, 0x8e, 0x9e, 0xce, 0x7d, 0xce, 0x03, 0x81, 0x24, - 0x64, 0xd0, 0x4b, 0x94, 0x42, 0xde}, 32, 32, PSA_ERROR_NOT_SUPPORTED -}, -#endif -#endif - -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -#ifdef ARCH_TEST_SHA256 -#ifdef ARCH_TEST_HKDF -{"Test psa_key_agreement - Not a key agreement alg\n", 5, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0xc8, 0x8f, 0x01, 0xf5, 0x10, 0xd9, 0xac, 0x3f, 0x70, 0xa2, 0x92, 0xda, 0xa2, - 0x31, 0x6d, 0xe5, 0x44, 0xe9, 0xaa, 0xb8, 0xaf, 0xe8, 0x40, 0x49, 0xc6, 0x2a, - 0x9c, 0x57, 0x86, 0x2d, 0x14, 0x33}, 32, PSA_KEY_USAGE_DERIVE, PSA_ALG_HKDF(PSA_ALG_SHA_256), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, -{0xd6, 0x84, 0x0f, 0x6b, 0x42, 0xf6, 0xed, 0xaf, 0xd1, 0x31, 0x16, 0xe0, 0xe1, - 0x25, 0x65, 0x20, 0x2f, 0xef, 0x8e, 0x9e, 0xce, 0x7d, 0xce, 0x03, 0x81, 0x24, - 0x64, 0xd0, 0x4b, 0x94, 0x42, 0xde}, 32, 32, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif - -#ifdef ARCH_TEST_ECDH -{"Test psa_key_agreement - Public key on different curve\n", 6, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0xc8, 0x8f, 0x01, 0xf5, 0x10, 0xd9, 0xac, 0x3f, 0x70, 0xa2, 0x92, 0xda, 0xa2, - 0x31, 0x6d, 0xe5, 0x44, 0xe9, 0xaa, 0xb8, 0xaf, 0xe8, 0x40, 0x49, 0xc6, 0x2a, - 0x9c, 0x57, 0x86, 0x2d, 0x14, 0x33}, 32, PSA_KEY_USAGE_DERIVE, PSA_ALG_ECDH(PSA_ALG_SELECT_RAW), -{0x04, 0xe5, 0x58, - 0xdb, 0xef, 0x53, 0xee, 0xcd, 0xe3, 0xd3, 0xfc, 0xcf, 0xc1, 0xae, 0xa0, 0x8a, - 0x89, 0xa9, 0x87, 0x47, 0x5d, 0x12, 0xfd, 0x95, 0x0d, 0x83, 0xcf, 0xa4, 0x17, - 0x32, 0xbc, 0x50, 0x9d, 0x0d, 0x1a, 0xc4, 0x3a, 0x03, 0x36, 0xde, 0xf9, 0x6f, - 0xda, 0x41, 0xd0, 0x77, 0x4a, 0x35, 0x71, 0xdc, 0xfb, 0xec, 0x7a, 0xac, 0xf3, - 0x19, 0x64, 0x72, 0x16, 0x9e, 0x83, 0x84, 0x30, 0x36, 0x7f, 0x66, 0xee, 0xbe, - 0x3c, 0x6e, 0x70, 0xc4, 0x16, 0xdd, 0x5f, 0x0c, 0x68, 0x75, 0x9d, 0xd1, 0xff, - 0xf8, 0x3f, 0xa4, 0x01, 0x42, 0x20, 0x9d, 0xff, 0x5e, 0xaa, 0xd9, 0x6d, 0xb9, - 0xe6, 0x38, 0x6c}, 97, -{0}, 0, 0, PSA_ERROR_INVALID_ARGUMENT -}, - -{"Test psa_key_agreement - Public key instead of private key\n", 7, - PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_CURVE_SECP256R1), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, PSA_KEY_USAGE_DERIVE, PSA_ALG_ECDH(PSA_ALG_SELECT_RAW), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, {0}, 0, 0, PSA_ERROR_INVALID_ARGUMENT -}, -#endif -#endif -}; - -static test_data check2[] = { -#ifdef ARCH_TEST_ECDH -#ifdef ARCH_TEST_ECC_CURVE_SECP256R1 -{"Test psa_key_agreement - Negative case\n", 8, - PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP256R1), -{0xc8, 0x8f, 0x01, 0xf5, 0x10, 0xd9, 0xac, 0x3f, 0x70, 0xa2, 0x92, 0xda, 0xa2, - 0x31, 0x6d, 0xe5, 0x44, 0xe9, 0xaa, 0xb8, 0xaf, 0xe8, 0x40, 0x49, 0xc6, 0x2a, - 0x9c, 0x57, 0x86, 0x2d, 0x14, 0x33}, 32, PSA_KEY_USAGE_DERIVE, PSA_ALG_ECDH(PSA_ALG_SELECT_RAW), -{0x04, 0xd1, 0x2d, 0xfb, 0x52, 0x89, 0xc8, 0xd4, 0xf8, 0x12, 0x08, 0xb7, 0x02, - 0x70, 0x39, 0x8c, 0x34, 0x22, 0x96, 0x97, 0x0a, 0x0b, 0xcc, 0xb7, 0x4c, 0x73, - 0x6f, 0xc7, 0x55, 0x44, 0x94, 0xbf, 0x63, 0x56, 0xfb, 0xf3, 0xca, 0x36, 0x6c, - 0xc2, 0x3e, 0x81, 0x57, 0x85, 0x4c, 0x13, 0xc5, 0x8d, 0x6a, 0xac, 0x23, 0xf0, - 0x46, 0xad, 0xa3, 0x0f, 0x83, 0x53, 0xe7, 0x4f, 0x33, 0x03, 0x98, 0x72, 0xab}, - 65, -{0xd6, 0x84, 0x0f, 0x6b, 0x42, 0xf6, 0xed, 0xaf, 0xd1, 0x31, 0x16, 0xe0, 0xe1, - 0x25, 0x65, 0x20, 0x2f, 0xef, 0x8e, 0x9e, 0xce, 0x7d, 0xce, 0x03, 0x81, 0x24, - 0x64, 0xd0, 0x4b, 0x94, 0x42, 0xde}, 32, 32, PSA_SUCCESS -}, -#endif -#endif -}; diff --git a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_entry.c b/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_entry.c deleted file mode 100644 index b1ba5e3d86..0000000000 --- a/components/TARGET_PSA/TESTS/compliance_crypto/test_c043/test_entry.c +++ /dev/null @@ -1,53 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_interfaces.h" -#include "val_target.h" -#include "test_c043.h" - -#define TEST_NUM VAL_CREATE_TEST_ID(VAL_CRYPTO_BASE, 43) -#define TEST_DESC "Testing crypto generator APIs\n" -TEST_PUBLISH(TEST_NUM, test_entry); -val_api_t *val = NULL; -psa_api_t *psa = NULL; - -void test_entry(val_api_t *val_api, psa_api_t *psa_api) -{ - int32_t status = VAL_STATUS_SUCCESS; - - val = val_api; - psa = psa_api; - - /* test init */ - val->test_init(TEST_NUM, TEST_DESC, TEST_FIELD(TEST_ISOLATION_L1, WD_HIGH_TIMEOUT)); - if (!IS_TEST_START(val->get_status())) - { - goto test_exit; - } - - /* Execute list of tests available in test[num]_crypto_list from Non-secure side*/ - status = val->execute_non_secure_tests(TEST_NUM, test_c043_crypto_list, FALSE); - - if (VAL_ERROR(status)) - { - goto test_exit; - } - -test_exit: - val->crypto_function(VAL_CRYPTO_FREE); - val->test_exit(); -} diff --git a/features/frameworks/TARGET_PSA/pal/pal_common.h b/features/frameworks/TARGET_PSA/pal/pal_common.h index 2e905e47cc..bcf637cc4d 100644 --- a/features/frameworks/TARGET_PSA/pal/pal_common.h +++ b/features/frameworks/TARGET_PSA/pal/pal_common.h @@ -29,7 +29,6 @@ #define ITS_TEST 1 #endif -#include "pal_crypto_config.h" #include "internal_trusted_storage.h" /* typedef's */ diff --git a/features/frameworks/TARGET_PSA/pal/pal_crypto_config.h b/features/frameworks/TARGET_PSA/pal/pal_crypto_config.h deleted file mode 100644 index 388c02fb42..0000000000 --- a/features/frameworks/TARGET_PSA/pal/pal_crypto_config.h +++ /dev/null @@ -1,407 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -/* - * \file pal_crypto_config.h - * - * \brief Configuration options for crypto tests (set of defines) - * - * This set of compile-time options may be used to enable - * or disable features selectively for crypto test suite - */ - -#ifndef _PAL_CRYPTO_CONFIG_H_ -#define _PAL_CRYPTO_CONFIG_H_ - -#include "mbedtls/config.h" - -/** - * \def ARCH_TEST_RSA - * - * Enable the RSA public-key cryptosystem. - * By default all supported keys are enabled. - * - * Comment macros to disable the types - */ -#ifdef MBEDTLS_RSA_C -#define ARCH_TEST_RSA -#define ARCH_TEST_RSA_1024 -#define ARCH_TEST_RSA_2048 -#define ARCH_TEST_RSA_3072 -#endif -/** - * \def ARCH_TEST_ECC - * \def ARCH_TEST_ECC_CURVE_SECPXXXR1 - * - * Enable the elliptic curve - * Enable specific curves within the Elliptic Curve - * module. By default all supported curves are enabled. - * - * Requires: ARCH_TEST_ECC - * Comment macros to disable the curve - */ -#ifdef MBEDTLS_ECP_C -#define ARCH_TEST_ECC -#ifdef MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define ARCH_TEST_ECC_CURVE_SECP192R1 -#endif -#ifdef MBEDTLS_ECP_DP_SECP224R1_ENABLED -#define ARCH_TEST_ECC_CURVE_SECP224R1 -#endif -#ifdef MBEDTLS_ECP_DP_SECP256R1_ENABLED -#define ARCH_TEST_ECC_CURVE_SECP256R1 -#endif -#ifdef MBEDTLS_ECP_DP_SECP384R1_ENABLED -#define ARCH_TEST_ECC_CURVE_SECP384R1 -#endif -#endif -/** - * \def ARCH_TEST_AES - * - * Enable the AES block cipher. - * By default all supported keys are enabled. - * - * Comment macros to disable the types - */ -#ifdef MBEDTLS_AES_C -#define ARCH_TEST_AES -#define ARCH_TEST_AES_128 -#define ARCH_TEST_AES_192 -#define ARCH_TEST_AES_256 -#define ARCH_TEST_AES_512 -#endif - -/** - * \def ARCH_TEST_DES - * - * Enable the DES block cipher. - * By default all supported keys are enabled. - * - * Comment macros to disable the types - */ -#ifdef MBEDTLS_DES_C -#define ARCH_TEST_DES -#define ARCH_TEST_DES_1KEY -#define ARCH_TEST_DES_2KEY -#define ARCH_TEST_DES_3KEY -#endif - -/** - * \def ARCH_TEST_RAW - * - * A "key" of this type cannot be used for any cryptographic operation. - * Applications may use this type to store arbitrary data in the keystore. - */ -#define ARCH_TEST_RAW - -/** - * \def ARCH_TEST_CIPER - * - * Enable the generic cipher layer. - */ -#ifdef MBEDTLS_CIPHER_C -#define ARCH_TEST_CIPER -#endif -/** - * \def ARCH_TEST_ARC4 - * - * Enable the ARC4 key type. - */ -#ifdef MBEDTLS_ARC4_C -#define ARCH_TEST_ARC4 -#endif -/** - * \def ARCH_TEST_CIPER_MODE_CTR - * - * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. - * - * Requires: ARCH_TEST_CIPER - */ -#ifdef MBEDTLS_CIPHER_MODE_CTR -#define ARCH_TEST_CIPER_MODE_CTR -#endif - -/** - * \def ARCH_TEST_CIPER_MODE_CFB - * - * Enable Cipher Feedback mode (CFB) for symmetric ciphers. - * - * Requires: ARCH_TEST_CIPER - */ -#ifdef MBEDTLS_CIPHER_MODE_CFB -#define ARCH_TEST_CIPER_MODE_CFB -#endif - -/** - * \def ARCH_TEST_CIPER_MODE_CBC - * - * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. - * - * Requires: ARCH_TEST_CIPER - */ -#ifdef MBEDTLS_CIPHER_MODE_CBC -#define ARCH_TEST_CIPER_MODE_CBC -#endif - -/** - * \def ARCH_TEST_CTR_AES - * - * Requires: ARCH_TEST_CIPER, ARCH_TEST_AES, ARCH_TEST_CIPER_MODE_CTR - */ -#if defined(MBEDTLS_CIPHER_MODE_CTR) && defined(MBEDTLS_AES_C) -#define ARCH_TEST_CTR_AES -#endif -/** - * \def ARCH_TEST_CBC_AES - * - * Requires: ARCH_TEST_CIPER, ARCH_TEST_AES, ARCH_TEST_CIPER_MODE_CBC - * - * Comment macros to disable the types - */ -#if defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_AES_C) -#define ARCH_TEST_CBC_AES -#define ARCH_TEST_CBC_AES_NO_PADDING -#endif - - -/** - * \def ARCH_TEST_CBC_NO_PADDING - * - * Requires: ARCH_TEST_CIPER, ARCH_TEST_CIPER_MODE_CBC - * - * Comment macros to disable the types - */ -#ifdef MBEDTLS_CIPHER_MODE_CBC -#define ARCH_TEST_CBC_NO_PADDING -#endif - -/** - * \def ARCH_TEST_CFB_AES - * - * Requires: ARCH_TEST_CIPER, ARCH_TEST_AES, ARCH_TEST_CIPER_MODE_CFB - */ -#if defined(MBEDTLS_CIPHER_MODE_CFB) && defined(MBEDTLS_AES_C) -#define ARCH_TEST_CFB_AES -#endif - -/** - * \def ARCH_TEST_PKCS1V15_* - * - * Enable support for PKCS#1 v1.5 encoding. - * Enable support for PKCS#1 v1.5 operations. - * Enable support for RSA-OAEP - * - * Requires: ARCH_TEST_RSA, ARCH_TEST_PKCS1V15 - * - * Comment macros to disable the types - */ -#if defined(MBEDTLS_PKCS1_V15) && defined(MBEDTLS_RSA_C) -#define ARCH_TEST_PKCS1V15 -#define ARCH_TEST_RSA_PKCS1V15_SIGN -#define ARCH_TEST_RSA_PKCS1V15_SIGN_RAW -#define ARCH_TEST_RSA_PKCS1V15_CRYPT -#endif -#if defined(MBEDTLS_PKCS1_V21) && defined(MBEDTLS_RSA_C) -#define ARCH_TEST_RSA_OAEP -#endif - - -/** - * \def ARCH_TEST_CBC_PKCS7 - * - * Requires: ARCH_TEST_CIPER_MODE_CBC - * - * Comment macros to disable the types - */ -#if defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_CIPHER_PADDING_PKCS7) -#define ARCH_TEST_CBC_PKCS7 -#endif - -/** - * \def ARCH_TEST_ASYMMETRIC_ENCRYPTION - * - * Enable support for Asymmetric encryption algorithms - */ -#define ARCH_TEST_ASYMMETRIC_ENCRYPTION - -/** - * \def ARCH_TEST_HASH - * - * Enable the hash algorithm. - */ -#define ARCH_TEST_HASH - -/** - * \def ARCH_TEST_HMAC - * - * The key policy determines which underlying hash algorithm the key can be - * used for. - * - * Requires: ARCH_TEST_HASH - */ -#define ARCH_TEST_HMAC - -/** - * \def ARCH_TEST_MDX - * \def ARCH_TEST_SHAXXX - * - * Enable the MDX algorithm. - * Enable the SHAXXX algorithm. - * - * Requires: ARCH_TEST_HASH - * - * Comment macros to disable the types - */ -#ifdef MBEDTLS_MD_C -#ifdef MBEDTLS_MD2_C -#define ARCH_TEST_MD2 -#endif -#ifdef MBEDTLS_MD4_C -#define ARCH_TEST_MD4 -#endif -#ifdef MBEDTLS_MD5_C -#define ARCH_TEST_MD5 -#endif -#endif -#ifdef MBEDTLS_RIPEMD160_C -#define ARCH_TEST_RIPEMD160 -#endif -#ifdef MBEDTLS_SHA1_C -#define ARCH_TEST_SHA1 -#endif -#ifdef MBEDTLS_SHA224_C -#define ARCH_TEST_SHA224 -#endif -#ifdef MBEDTLS_SHA256_C -#define ARCH_TEST_SHA256 -#endif -#ifdef MBEDTLS_SHA384_C -#define ARCH_TEST_SHA384 -#endif -#ifdef MBEDTLS_SHA512_C -#define ARCH_TEST_SHA512 -#ifdef MBEDTLS_SHA512_224_C -#define ARCH_TEST_SHA512_224 -#endif -#ifdef MBEDTLS_SHA512_256_C -#define ARCH_TEST_SHA512_256 -#endif -#endif -#ifdef MBEDTLS_SHA3_C -#define ARCH_TEST_SHA3_224 -#define ARCH_TEST_SHA3_256 -#define ARCH_TEST_SHA3_384 -#define ARCH_TEST_SHA3_512 -#endif - -/** - * \def ARCH_TEST_HKDF - * - * Enable the HKDF algorithm (RFC 5869). - * - * Requires: ARCH_TEST_HASH -*/ -#ifdef MBEDTLS_HKDF_C -#define ARCH_TEST_HKDF -#endif - -/** - * \def ARCH_TEST_xMAC - * - * Enable the xMAC (Cipher/Hash/G-based Message Authentication Code) mode for block - * ciphers. - * Requires: ARCH_TEST_AES or ARCH_TEST_DES - * - * Comment macros to disable the types - */ -#ifdef MBEDTLS_CMAC_C -#define ARCH_TEST_CMAC -#endif -#ifdef MBEDTLS_GMAC_C -#define ARCH_TEST_GMAC -#endif -#define ARCH_TEST_HMAC - - -/** - * \def ARCH_TEST_CCM - * - * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. - * - * Requires: ARCH_TEST_AES - */ -#ifdef MBEDTLS_CCM_C -#define ARCH_TEST_CCM -#endif - -/** - * \def ARCH_TEST_GCM - * - * Enable the Galois/Counter Mode (GCM) for AES. - * - * Requires: ARCH_TEST_AES - * - */ -#ifdef MBEDTLS_GCM_C -#define ARCH_TEST_GCM -#endif - -/** - * \def ARCH_TEST_TRUNCATED_MAC - * - * Enable support for RFC 6066 truncated HMAC in SSL. - * - * Comment this macro to disable support for truncated HMAC in SSL - */ -#ifdef MBEDTLS_SSL_TRUNCATED_HMAC -#define ARCH_TEST_TRUNCATED_MAC -#endif - - -/** - * \def ARCH_TEST_ECDH - * - * Enable the elliptic curve Diffie-Hellman library. - * - * Requires: ARCH_TEST_ECC - */ -#ifdef MBEDTLS_ECDH_C -#define ARCH_TEST_ECDH -#endif - -/** - * \def ARCH_TEST_ECDSA - * - * Enable the elliptic curve DSA library. - * Requires: ARCH_TEST_ECC - */ -#ifdef MBEDTLS_ECDSA_C -#define ARCH_TEST_ECDSA -#endif - -/** - * \def ARCH_TEST_DETERMINISTIC_ECDSA - * - * Enable deterministic ECDSA (RFC 6979). -*/ -#ifdef MBEDTLS_ECDSA_DETERMINISTIC -#define ARCH_TEST_DETERMINISTIC_ECDSA -#endif - -#include "pal_crypto_config_check.h" - -#endif diff --git a/features/frameworks/TARGET_PSA/pal/pal_crypto_config_check.h b/features/frameworks/TARGET_PSA/pal/pal_crypto_config_check.h deleted file mode 100644 index 85b225e4a3..0000000000 --- a/features/frameworks/TARGET_PSA/pal/pal_crypto_config_check.h +++ /dev/null @@ -1,223 +0,0 @@ -/** @file - * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -/** - * \file pal_crypto_config_check.h - * - * \brief Consistency checks for configuration options - * - */ - -#ifndef _PAL_CRYPTO_CONFIG_CHECK_H_ -#define _PAL_CRYPTO_CONFIG_CHECK_H_ - -#if defined(ARCH_TEST_RSA_1024) && !defined(ARCH_TEST_RSA) -#error "ARCH_TEST_RSA_1024 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_RSA_2048) && !defined(ARCH_TEST_RSA) -#error "ARCH_TEST_RSA_2048 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_RSA_3072) && !defined(ARCH_TEST_RSA) -#error "ARCH_TEST_RSA_3072 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_ECC_CURVE_SECP192R1) && !defined(ARCH_TEST_ECC) -#error "ARCH_TEST_ECC_CURVE_SECP192R1 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_ECC_CURVE_SECP224R1) && !defined(ARCH_TEST_ECC) -#error "ARCH_TEST_ECC_CURVE_SECP224R1 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_ECC_CURVE_SECP256R1) && !defined(ARCH_TEST_ECC) -#error "ARCH_TEST_ECC_CURVE_SECP256R1 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_ECC_CURVE_SECP384R1) && !defined(ARCH_TEST_ECC) -#error "ARCH_TEST_ECC_CURVE_SECP384R1 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_AES_128) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_AES_128 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_AES_256) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_AES_256 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_AES_512) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_AES_512 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_DES_1KEY) && !defined(ARCH_TEST_DES) -#error "ARCH_TEST_DES_1KEY defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_DES_2KEY) && !defined(ARCH_TEST_DES) -#error "ARCH_TEST_DES_2KEY defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_DES_3KEY) && !defined(ARCH_TEST_DES) -#error "ARCH_TEST_DES_3KEY defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CIPER_MODE_CTR) && !defined(ARCH_TEST_CIPER) -#error "ARCH_TEST_CIPER_MODE_CTR defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CIPER_MODE_CFB) && !defined(ARCH_TEST_CIPER) -#error "ARCH_TEST_CIPER_MODE_CFB defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CIPER_MODE_CBC) && !defined(ARCH_TEST_CIPER) -#error "ARCH_TEST_CIPER_MODE_CBC defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CTR_AES) &&\ - (!defined(ARCH_TEST_CIPER) || !defined(ARCH_TEST_AES) || !defined(ARCH_TEST_CIPER_MODE_CTR)) -#error "ARCH_TEST_CTR_AES defined, but not all prerequisites" -#endif - -#if (defined(ARCH_TEST_CBC_AES)|| defined(ARCH_TEST_CBC_AES_NO_PADDING)) &&\ - (!defined(ARCH_TEST_CIPER) || !defined(ARCH_TEST_AES) || !defined(ARCH_TEST_CIPER_MODE_CBC)) -#error "ARCH_TEST_CBC_AES defined, but not all prerequisites" -#endif - -#if (defined(ARCH_TEST_CBC_NO_PADDING)) &&\ - (!defined(ARCH_TEST_CIPER) ||!defined(ARCH_TEST_CIPER_MODE_CBC)) -#error "ARCH_TEST_CBC_NO_PADDING defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CFB_AES) &&\ - (!defined(ARCH_TEST_CIPER) || !defined(ARCH_TEST_AES) || !defined(ARCH_TEST_CIPER_MODE_CFB)) -#error "ARCH_TEST_CFB_AES defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_RSA_PKCS1V15_SIGN) &&\ - (!defined(ARCH_TEST_RSA) || !defined(ARCH_TEST_PKCS1V15)) -#error "ARCH_TEST_RSA_PKCS1V15_SIGN defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_RSA_PKCS1V15_SIGN_RAW) &&\ - (!defined(ARCH_TEST_RSA) || !defined(ARCH_TEST_PKCS1V15)) -#error "ARCH_TEST_RSA_PKCS1V15_SIGN_RAW defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_RSA_PKCS1V15_CRYPT) &&\ - (!defined(ARCH_TEST_RSA) || !defined(ARCH_TEST_PKCS1V15)) -#error "ARCH_TEST_RSA_PKCS1V15_CRYPT defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CBC_PKCS7) && !defined(ARCH_TEST_CIPER_MODE_CBC) -#error "ARCH_TEST_CBC_PKCS7 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_HMAC) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_HMAC defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_MD2) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_MD2 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_MD4) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_MD4 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_MD5) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_MD5 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_RIPEMD160) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_RIPEMD160 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA1) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA1 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA224) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA224 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA256) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA256 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA512) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA512 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA512_224) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA512_224 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA512_256) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA512_256 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA3_224) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA3_224 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA3_256) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA3_256 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA3_384) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA3_256 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_SHA3_512) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_SHA3_256 defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_HKDF) && !defined(ARCH_TEST_HASH) -#error "ARCH_TEST_HKDF defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CMAC) && !defined(ARCH_TEST_AES) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_CMAC defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_GMAC) && !defined(ARCH_TEST_AES) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_GMAC defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_HMAC) && !defined(ARCH_TEST_AES) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_HMAC defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_CCM) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_CCM defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_GCM) && !defined(ARCH_TEST_AES) -#error "ARCH_TEST_GCM defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_ECDH) && !defined(ARCH_TEST_ECC) -#error "ARCH_TEST_ECDH defined, but not all prerequisites" -#endif - -#if defined(ARCH_TEST_ECDSA) && !defined(ARCH_TEST_ECC) -#error "ARCH_TEST_ECDSA defined, but not all prerequisites" -#endif - -#endif /* _PAL_CRYPTO_CONFIG_CHECK_H_ */ diff --git a/features/frameworks/TARGET_PSA/pal/pal_crypto_intf.c b/features/frameworks/TARGET_PSA/pal/pal_crypto_intf.c deleted file mode 100644 index ad97e15ad1..0000000000 --- a/features/frameworks/TARGET_PSA/pal/pal_crypto_intf.c +++ /dev/null @@ -1,339 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#define PSA_CRYPTO_IMPLEMENTED 1 -#include "pal_crypto_intf.h" - -#define PAL_KEY_SLOT_COUNT 32 - -/** - @brief - This API will call the requested crypto function - @param - type : function code - valist : variable argument list - @return - error status -**/ -int32_t pal_crypto_function(int type, va_list valist) -{ -#if PSA_CRYPTO_IMPLEMENTED - int i; - size_t size, *length, salt_length, label_length, ciphertext_size; - uint8_t *buffer, *ciphertext; - const uint8_t *salt, *label, *nonce, *additional_data; - uint8_t *plaintext; - uint32_t status; - const void *extra; - size_t extra_size, capacity, *gen_cap, nonce_length, additional_data_length; - psa_key_handle_t handle, *key_handle; - psa_key_type_t key_type, *key_type_out; - psa_key_policy_t *policy; - psa_key_usage_t usage, *usage_out; - psa_key_lifetime_t *lifetime_out; - psa_algorithm_t alg, *alg_out; - psa_hash_operation_t *hash_operation; - psa_mac_operation_t *mac_operation; - psa_cipher_operation_t *cipher_operation; - psa_crypto_generator_t *generator; - - switch (type) - { - case PAL_CRYPTO_INIT: - return psa_crypto_init(); - case PAL_CRYPTO_GENERATE_RANDOM: - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, int); - return psa_generate_random(buffer, size); - case PAL_CRYPTO_IMPORT_KEY: - handle = (psa_key_handle_t)va_arg(valist, int); - key_type = va_arg(valist, psa_key_type_t); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, int); - status = psa_import_key(handle, key_type, buffer, size); - return status; - case PAL_CRYPTO_EXPORT_KEY: - handle = (psa_key_handle_t)va_arg(valist, int); - buffer = (uint8_t *)(va_arg(valist, uint8_t*)); - size = va_arg(valist, int); - length = (size_t *)va_arg(valist, size_t*); - status = psa_export_key(handle, buffer, size, length); - return status; - case PAL_CRYPTO_EXPORT_PUBLIC_KEY: - handle = (psa_key_handle_t)va_arg(valist, int); - buffer = (uint8_t *)(va_arg(valist, uint8_t*)); - size = va_arg(valist, int); - length = (size_t *)va_arg(valist, size_t*); - status = psa_export_public_key(handle, buffer, size, length); - return status; - case PAL_CRYPTO_KEY_POLICY_INIT: - policy = va_arg(valist, psa_key_policy_t*); - memset(policy, 0, sizeof(psa_key_policy_t)); - return 0; - case PAL_CRYPTO_KEY_POLICY_SET_USAGE: - policy = va_arg(valist, psa_key_policy_t*); - usage = va_arg(valist, psa_key_usage_t); - alg = va_arg(valist, psa_algorithm_t); - psa_key_policy_set_usage(policy, usage, alg); - return 0; - case PAL_CRYPTO_SET_KEY_POLICY: - handle = (psa_key_handle_t)va_arg(valist, int); - policy = va_arg(valist, psa_key_policy_t*); - return psa_set_key_policy(handle, policy); - case PAL_CRYPTO_DESTROY_KEY: - handle = (psa_key_handle_t)va_arg(valist, int); - status = psa_destroy_key(handle); - return status; - case PAL_CRYPTO_GET_KEY_INFORMATION: - handle = (psa_key_handle_t)va_arg(valist, int); - key_type_out = va_arg(valist, psa_key_type_t*); - length = (size_t *)va_arg(valist, size_t*); - status = psa_get_key_information(handle, key_type_out, length); - return status; - case PAL_CRYPTO_GET_KEY_POLICY: - handle = (psa_key_handle_t)va_arg(valist, int); - policy = va_arg(valist, psa_key_policy_t*); - return psa_get_key_policy(handle, policy); - case PAL_CRYPTO_KEY_POLICY_GET_USAGE: - policy = va_arg(valist, psa_key_policy_t*); - usage_out = va_arg(valist, psa_key_usage_t*); - *usage_out = psa_key_policy_get_usage(policy); - return 0; - case PAL_CRYPTO_KEY_POLICY_GET_ALGORITHM: - policy = va_arg(valist, psa_key_policy_t*); - alg_out = va_arg(valist, psa_algorithm_t*); - *alg_out = psa_key_policy_get_algorithm(policy); - return 0; - case PAL_CRYPTO_GET_KEY_LIFETIME: - handle = (psa_key_handle_t)va_arg(valist, int); - lifetime_out = va_arg(valist, psa_key_lifetime_t*); - return psa_get_key_lifetime(handle, lifetime_out); - case PAL_CRYPTO_HASH_SETUP: - hash_operation = va_arg(valist, psa_hash_operation_t*); - alg = va_arg(valist, psa_algorithm_t); - return psa_hash_setup(hash_operation, alg); - case PAL_CRYPTO_HASH_UPDATE: - hash_operation = va_arg(valist, psa_hash_operation_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - return psa_hash_update(hash_operation, buffer, size); - case PAL_CRYPTO_HASH_VERIFY: - hash_operation = va_arg(valist, psa_hash_operation_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - return psa_hash_verify(hash_operation, buffer, size); - case PAL_CRYPTO_HASH_FINISH: - hash_operation = va_arg(valist, psa_hash_operation_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_hash_finish(hash_operation, buffer, size, length); - case PAL_CRYPTO_HASH_ABORT: - hash_operation = va_arg(valist, psa_hash_operation_t*); - return psa_hash_abort(hash_operation); - case PAL_CRYPTO_GENERATE_KEY: - handle = (psa_key_handle_t)va_arg(valist, int); - key_type = va_arg(valist, psa_key_type_t); - size = va_arg(valist, size_t); - extra = va_arg(valist, const void*); - extra_size = va_arg(valist, size_t); - return psa_generate_key(handle, key_type, size, extra, extra_size); - case PAL_CRYPTO_GENERATOR_READ: - generator = va_arg(valist, psa_crypto_generator_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, int); - return psa_generator_read(generator, buffer, size); - case PAL_CRYPTO_KEY_DERIVATION: - generator = va_arg(valist, psa_crypto_generator_t*); - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - salt = va_arg(valist, const uint8_t *); - salt_length = va_arg(valist, size_t); - label = va_arg(valist, const uint8_t *); - label_length = va_arg(valist, size_t); - capacity = va_arg(valist, size_t); - return psa_key_derivation(generator, handle, alg, salt, salt_length, label, - label_length, capacity); - case PAL_CRYPTO_GET_GENERATOR_CAPACITY: - generator = va_arg(valist, psa_crypto_generator_t*); - gen_cap = va_arg(valist, size_t*); - return psa_get_generator_capacity(generator, gen_cap); - case PAL_CRYPTO_GENERATOR_IMPORT_KEY: - handle = (psa_key_handle_t)va_arg(valist, int); - key_type = va_arg(valist, psa_key_type_t); - size = va_arg(valist, size_t); - generator = va_arg(valist, psa_crypto_generator_t*); - return psa_generator_import_key(handle, key_type, size, generator); - case PAL_CRYPTO_GENERATOR_ABORT: - generator = va_arg(valist, psa_crypto_generator_t*); - return psa_generator_abort(generator); - case PAL_CRYPTO_AEAD_ENCRYPT: - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - nonce = va_arg(valist, const uint8_t *); - nonce_length = va_arg(valist, size_t); - additional_data = va_arg(valist, const uint8_t *); - additional_data_length = va_arg(valist, size_t); - plaintext = va_arg(valist, uint8_t *); - size = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_aead_encrypt(handle, alg, nonce, nonce_length, additional_data, - additional_data_length, plaintext, size, ciphertext, ciphertext_size, length); - case PAL_CRYPTO_AEAD_DECRYPT: - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - nonce = va_arg(valist, const uint8_t *); - nonce_length = va_arg(valist, size_t); - additional_data = va_arg(valist, const uint8_t *); - additional_data_length = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - plaintext = va_arg(valist, uint8_t *); - size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_aead_decrypt(handle, alg, nonce, nonce_length, additional_data, - additional_data_length, ciphertext, ciphertext_size, plaintext, size, length); - case PAL_CRYPTO_MAC_SIGN_SETUP: - mac_operation = va_arg(valist, psa_mac_operation_t*); - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - return psa_mac_sign_setup(mac_operation, handle, alg); - case PAL_CRYPTO_MAC_UPDATE: - mac_operation = va_arg(valist, psa_mac_operation_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - return psa_mac_update(mac_operation, buffer, size); - case PAL_CRYPTO_MAC_SIGN_FINISH: - mac_operation = va_arg(valist, psa_mac_operation_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - length = (size_t *)va_arg(valist, size_t*); - return psa_mac_sign_finish(mac_operation, buffer, size, length); - case PAL_CRYPTO_MAC_VERIFY_SETUP: - mac_operation = va_arg(valist, psa_mac_operation_t*); - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - return psa_mac_verify_setup(mac_operation, handle, alg); - case PAL_CRYPTO_MAC_VERIFY_FINISH: - mac_operation = va_arg(valist, psa_mac_operation_t*); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - return psa_mac_verify_finish(mac_operation, buffer, size); - case PAL_CRYPTO_MAC_ABORT: - mac_operation = va_arg(valist, psa_mac_operation_t*); - return psa_mac_abort(mac_operation); - case PAL_CRYPTO_ASYMMTERIC_ENCRYPT: - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - plaintext = va_arg(valist, uint8_t *); - size = va_arg(valist, size_t); - salt = va_arg(valist, const uint8_t *); - salt_length = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_asymmetric_encrypt(handle, alg, plaintext, size, salt, salt_length, - ciphertext, ciphertext_size, length); - case PAL_CRYPTO_ASYMMTERIC_DECRYPT: - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - plaintext = va_arg(valist, uint8_t *); - size = va_arg(valist, size_t); - salt = va_arg(valist, const uint8_t *); - salt_length = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_asymmetric_decrypt(handle, alg, plaintext, size, salt, salt_length, - ciphertext, ciphertext_size, length); - case PAL_CRYPTO_CIPHER_ENCRYPT_SETUP: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - return psa_cipher_encrypt_setup(cipher_operation, handle, alg); - case PAL_CRYPTO_CIPHER_DECRYPT_SETUP: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - return psa_cipher_decrypt_setup(cipher_operation, handle, alg); - case PAL_CRYPTO_CIPHER_GENERATE_IV: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_cipher_generate_iv(cipher_operation, buffer, size, length); - case PAL_CRYPTO_CIPHER_SET_IV: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - return psa_cipher_set_iv(cipher_operation, buffer, size); - case PAL_CRYPTO_CIPHER_UPDATE: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - plaintext = va_arg(valist, uint8_t *); - size = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_cipher_update(cipher_operation, plaintext, size, ciphertext, ciphertext_size, - length); - case PAL_CRYPTO_CIPHER_FINISH: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_cipher_finish(cipher_operation, ciphertext, ciphertext_size, length); - case PAL_CRYPTO_CIPHER_ABORT: - cipher_operation = va_arg(valist, psa_cipher_operation_t *); - return psa_cipher_abort(cipher_operation); - case PAL_CRYPTO_ASYMMTERIC_SIGN: - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - length = va_arg(valist, size_t*); - return psa_asymmetric_sign(handle, alg, buffer, size, ciphertext, ciphertext_size, - length); - case PAL_CRYPTO_ASYMMTERIC_VERIFY: - handle = (psa_key_handle_t)va_arg(valist, int); - alg = va_arg(valist, psa_algorithm_t); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - ciphertext = va_arg(valist, uint8_t *); - ciphertext_size = va_arg(valist, size_t); - return psa_asymmetric_verify(handle, alg, buffer, size, ciphertext, ciphertext_size); - case PAL_CRYPTO_KEY_AGREEMENT: - generator = va_arg(valist, psa_crypto_generator_t*); - handle = (psa_key_handle_t)va_arg(valist, int); - buffer = va_arg(valist, uint8_t*); - size = va_arg(valist, size_t); - alg = va_arg(valist, psa_algorithm_t); - return psa_key_agreement(generator, handle, buffer, size, alg); - case PAL_CRYPTO_ALLOCATE_KEY: - key_handle = (psa_key_handle_t *)va_arg(valist, int*); - return psa_allocate_key(key_handle); - case PAL_CRYPTO_FREE: - for (i = 0; i < PAL_KEY_SLOT_COUNT; i++) - psa_destroy_key(i); - return 0; - default: - return PAL_STATUS_UNSUPPORTED_FUNC; - } -#else - return PAL_STATUS_ERROR; -#endif -} diff --git a/features/frameworks/TARGET_PSA/pal/pal_crypto_intf.h b/features/frameworks/TARGET_PSA/pal/pal_crypto_intf.h deleted file mode 100644 index 90c5d9d349..0000000000 --- a/features/frameworks/TARGET_PSA/pal/pal_crypto_intf.h +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - * Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _PAL_CRYPTO_H_ -#define _PAL_CRYPTO_H_ - -#include -#include "pal_common.h" - -#if PSA_IPC_IMPLEMENTED -#include "psa/client.h" -#endif - -#if PSA_CRYPTO_IMPLEMENTED -#include "psa/crypto.h" -#endif - -enum crypto_function_code { - PAL_CRYPTO_INIT = 0x1, - PAL_CRYPTO_GENERATE_RANDOM = 0x2, - PAL_CRYPTO_IMPORT_KEY = 0x3, - PAL_CRYPTO_EXPORT_KEY = 0x4, - PAL_CRYPTO_EXPORT_PUBLIC_KEY = 0x5, - PAL_CRYPTO_DESTROY_KEY = 0x6, - PAL_CRYPTO_GET_KEY_INFO = 0x7, - PAL_CRYPTO_KEY_POLICY_INIT = 0x8, - PAL_CRYPTO_KEY_POLICY_SET_USAGE = 0x9, - PAL_CRYPTO_KEY_POLICY_GET_USAGE = 0xA, - PAL_CRYPTO_KEY_POLICY_GET_ALGORITHM = 0xB, - PAL_CRYPTO_SET_KEY_POLICY = 0xC, - PAL_CRYPTO_GET_KEY_POLICY = 0xD, - PAL_CRYPTO_GET_KEY_INFORMATION = 0xE, - PAL_CRYPTO_GET_KEY_LIFETIME = 0xF, - PAL_CRYPTO_HASH_SETUP = 0x11, - PAL_CRYPTO_HASH_UPDATE = 0x12, - PAL_CRYPTO_HASH_VERIFY = 0x13, - PAL_CRYPTO_HASH_FINISH = 0x14, - PAL_CRYPTO_HASH_ABORT = 0x15, - PAL_CRYPTO_GENERATE_KEY = 0x16, - PAL_CRYPTO_GENERATOR_READ = 0x17, - PAL_CRYPTO_KEY_DERIVATION = 0x18, - PAL_CRYPTO_GET_GENERATOR_CAPACITY = 0x19, - PAL_CRYPTO_GENERATOR_IMPORT_KEY = 0x1A, - PAL_CRYPTO_GENERATOR_ABORT = 0x1B, - PAL_CRYPTO_AEAD_ENCRYPT = 0x1C, - PAL_CRYPTO_AEAD_DECRYPT = 0x1D, - PAL_CRYPTO_MAC_SIGN_SETUP = 0x1E, - PAL_CRYPTO_MAC_UPDATE = 0x1F, - PAL_CRYPTO_MAC_SIGN_FINISH = 0x20, - PAL_CRYPTO_MAC_VERIFY_SETUP = 0x21, - PAL_CRYPTO_MAC_VERIFY_FINISH = 0x22, - PAL_CRYPTO_MAC_ABORT = 0x23, - PAL_CRYPTO_ASYMMTERIC_ENCRYPT = 0x24, - PAL_CRYPTO_ASYMMTERIC_DECRYPT = 0x25, - PAL_CRYPTO_CIPHER_ENCRYPT_SETUP = 0x26, - PAL_CRYPTO_CIPHER_DECRYPT_SETUP = 0x2A, - PAL_CRYPTO_CIPHER_GENERATE_IV = 0x2B, - PAL_CRYPTO_CIPHER_SET_IV = 0x2C, - PAL_CRYPTO_CIPHER_UPDATE = 0x2D, - PAL_CRYPTO_CIPHER_FINISH = 0x2E, - PAL_CRYPTO_CIPHER_ABORT = 0x2F, - PAL_CRYPTO_ASYMMTERIC_SIGN = 0x30, - PAL_CRYPTO_ASYMMTERIC_VERIFY = 0x31, - PAL_CRYPTO_KEY_AGREEMENT = 0x32, - PAL_CRYPTO_ALLOCATE_KEY = 0x33, - PAL_CRYPTO_FREE = 0xFE, -}; - -int32_t pal_crypto_function(int type, va_list valist); -#endif /* _PAL_CRYPTO_H_ */ diff --git a/features/frameworks/TARGET_PSA/val_crypto.c b/features/frameworks/TARGET_PSA/val_crypto.c deleted file mode 100644 index 764b44a95e..0000000000 --- a/features/frameworks/TARGET_PSA/val_crypto.c +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#include "val_target.h" -#include "pal_interfaces_ns.h" -#include "val_framework.h" -#include "val_client_defs.h" -#include "val_crypto.h" - -/** - @brief - This API will call the requested crypto function - @param - type : function code - ... : variable number of arguments - @return - Error status -**/ -int32_t val_crypto_function(int type, ...) -{ - va_list valist; - val_status_t status; - - va_start(valist, type); - status = pal_crypto_function(type, valist); - va_end(valist); - return status; -} diff --git a/features/frameworks/TARGET_PSA/val_crypto.h b/features/frameworks/TARGET_PSA/val_crypto.h deleted file mode 100644 index 644e59c787..0000000000 --- a/features/frameworks/TARGET_PSA/val_crypto.h +++ /dev/null @@ -1,108 +0,0 @@ -/** @file - * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved. - * SPDX-License-Identifier : Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -**/ - -#ifndef _VAL_CRYPTO_H_ -#define _VAL_CRYPTO_H_ - -#include "val.h" -#include "psa/client.h" -#include "crypto_values.h" -#include "crypto.h" - -#define BYTES_TO_BITS(byte) (byte * 8) - -/* Size */ -#define AES_16B_KEY_SIZE 16 -#define AES_24B_KEY_SIZE 24 -#define AES_32B_KEY_SIZE 32 -#define AES_18B_KEY_SIZE 18 -#define AES_34B_KEY_SIZE 34 -#define DES_8B_KEY_SIZE 8 -#define DES3_2KEY_SIZE 16 -#define DES3_3KEY_SIZE 24 -#define SIZE_32B 32 -#define SIZE_50B 50 -#define SIZE_128B 128 -#define SIZE_256B 256 -#define SIZE_512B 512 -#define BUFFER_SIZE 1200 -#define HASH_64B 64 -#define BUFFER_SIZE_HIGH 5130 - -/* Key Slot */ -#define INVALID_KEY_SLOT 0xDEAD -#define ZERO_KEY_SLOT 0 -#define OCCUPIED_KEY_SLOT 1 -#define MAX_KEY_SLOT 32 - -#define PSA_KEY_LIFETIME_INVALID 0xFFFFFFFF -#define PSA_KEY_USAGE_INVALID 0xFFFFFFFF -#define PSA_ALG_INVALID 0xFFFFFFFF - -enum crypto_function_code { - VAL_CRYPTO_INIT = 0x1, - VAL_CRYPTO_GENERATE_RANDOM = 0x2, - VAL_CRYPTO_IMPORT_KEY = 0x3, - VAL_CRYPTO_EXPORT_KEY = 0x4, - VAL_CRYPTO_EXPORT_PUBLIC_KEY = 0x5, - VAL_CRYPTO_DESTROY_KEY = 0x6, - VAL_CRYPTO_GET_KEY_INFO = 0x7, - VAL_CRYPTO_KEY_POLICY_INIT = 0x8, - VAL_CRYPTO_KEY_POLICY_SET_USAGE = 0x9, - VAL_CRYPTO_KEY_POLICY_GET_USAGE = 0xA, - VAL_CRYPTO_KEY_POLICY_GET_ALGORITHM = 0xB, - VAL_CRYPTO_SET_KEY_POLICY = 0xC, - VAL_CRYPTO_GET_KEY_POLICY = 0xD, - VAL_CRYPTO_GET_KEY_INFORMATION = 0xE, - VAL_CRYPTO_GET_KEY_LIFETIME = 0xF, - VAL_CRYPTO_HASH_SETUP = 0x11, - VAL_CRYPTO_HASH_UPDATE = 0x12, - VAL_CRYPTO_HASH_VERIFY = 0x13, - VAL_CRYPTO_HASH_FINISH = 0x14, - VAL_CRYPTO_HASH_ABORT = 0x15, - VAL_CRYPTO_GENERATE_KEY = 0x16, - VAL_CRYPTO_GENERATOR_READ = 0x17, - VAL_CRYPTO_KEY_DERIVATION = 0x18, - VAL_CRYPTO_GET_GENERATOR_CAPACITY = 0x19, - VAL_CRYPTO_GENERATOR_IMPORT_KEY = 0x1A, - VAL_CRYPTO_GENERATOR_ABORT = 0x1B, - VAL_CRYPTO_AEAD_ENCRYPT = 0x1C, - VAL_CRYPTO_AEAD_DECRYPT = 0x1D, - VAL_CRYPTO_MAC_SIGN_SETUP = 0x1E, - VAL_CRYPTO_MAC_UPDATE = 0x1F, - VAL_CRYPTO_MAC_SIGN_FINISH = 0x20, - VAL_CRYPTO_MAC_VERIFY_SETUP = 0x21, - VAL_CRYPTO_MAC_VERIFY_FINISH = 0x22, - VAL_CRYPTO_MAC_ABORT = 0x23, - VAL_CRYPTO_ASYMMTERIC_ENCRYPT = 0x24, - VAL_CRYPTO_ASYMMTERIC_DECRYPT = 0x25, - VAL_CRYPTO_CIPHER_ENCRYPT_SETUP = 0x26, - VAL_CRYPTO_CIPHER_DECRYPT_SETUP = 0x2A, - VAL_CRYPTO_CIPHER_GENERATE_IV = 0x2B, - VAL_CRYPTO_CIPHER_SET_IV = 0x2C, - VAL_CRYPTO_CIPHER_UPDATE = 0x2D, - VAL_CRYPTO_CIPHER_FINISH = 0x2E, - VAL_CRYPTO_CIPHER_ABORT = 0x2F, - VAL_CRYPTO_ASYMMTERIC_SIGN = 0x30, - VAL_CRYPTO_ASYMMTERIC_VERIFY = 0x31, - VAL_CRYPTO_KEY_AGREEMENT = 0x32, - VAL_CRYPTO_ALLOCATE_KEY = 0x33, - VAL_CRYPTO_FREE = 0xFE, -}; - -int32_t val_crypto_function(int type, ...); -#endif /* _VAL_CRYPTO_H_ */ diff --git a/features/frameworks/TARGET_PSA/val_interfaces.c b/features/frameworks/TARGET_PSA/val_interfaces.c index a3ba81c601..b6bf085462 100644 --- a/features/frameworks/TARGET_PSA/val_interfaces.c +++ b/features/frameworks/TARGET_PSA/val_interfaces.c @@ -18,7 +18,6 @@ #include "val_greentea.h" #include "val_interfaces.h" -#include "val_crypto.h" #include "val_internal_trusted_storage.h" #include "val_protected_storage.h" #include "val_attestation.h" @@ -47,7 +46,6 @@ const val_api_t val_api = { .wd_reprogram_timer = mbed_val_wd_reprogram_timer, .set_boot_flag = NULL, .get_boot_flag = NULL, - .crypto_function = val_crypto_function, .its_function = val_its_function, .ps_function = val_ps_function, .attestation_function = val_attestation_function,