Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 1 | /** |
| 2 | * This is the base AUT that exectues all other AUTs meant to test PSA APIs |
| 3 | * through PSASIM. |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright The Mbed TLS Contributors |
| 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | /* First include Mbed TLS headers to get the Mbed TLS configuration and |
| 12 | * platform definitions that we'll use in this program. Also include |
| 13 | * standard C headers for functions we'll use here. */ |
| 14 | #include "mbedtls/build_info.h" |
| 15 | |
| 16 | #include "psa/crypto.h" |
| 17 | |
| 18 | #include <stdlib.h> |
| 19 | #include <stdio.h> |
| 20 | #include <string.h> |
| 21 | |
| 22 | int psa_hash_compute_main(void); |
| 23 | int psa_hash_main(void); |
Valerio Setti | a06b22d | 2024-06-24 14:59:34 +0200 | [diff] [blame] | 24 | int psa_aead_encrypt_main(char *cipher_name); |
| 25 | int psa_aead_encrypt_decrypt_main(void); |
Valerio Setti | e9829e5 | 2024-06-24 16:37:27 +0200 | [diff] [blame] | 26 | int psa_cipher_encrypt_decrypt_main(void); |
Valerio Setti | 9dc9289 | 2024-06-24 17:38:10 +0200 | [diff] [blame] | 27 | int psa_asymmetric_encrypt_decrypt_main(void); |
Valerio Setti | 25afdc1 | 2024-06-24 13:44:12 +0200 | [diff] [blame] | 28 | int psa_random_main(void); |
Valerio Setti | f79e17a | 2024-06-24 13:57:49 +0200 | [diff] [blame] | 29 | int psa_mac_main(void); |
Valerio Setti | 6d6fe8b | 2024-06-24 14:46:08 +0200 | [diff] [blame] | 30 | int psa_key_agreement_main(void); |
Valerio Setti | bb1502b | 2024-06-24 14:50:54 +0200 | [diff] [blame] | 31 | int psa_sign_verify_main(void); |
Valerio Setti | 87be9db | 2024-06-24 15:09:33 +0200 | [diff] [blame] | 32 | int psa_hkdf_main(void); |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 33 | |
| 34 | #define TEST_MODULE(main_func) \ |
| 35 | do { \ |
| 36 | char title[128] = { 0 }; \ |
| 37 | char separator[128] = { 0 }; \ |
| 38 | int title_len = snprintf(title, sizeof(title), "=== Test: %s ===", #main_func); \ |
| 39 | memset(separator, '=', title_len); \ |
| 40 | printf("%s\n%s\n%s\n", separator, title, separator); \ |
| 41 | ret = main_func; \ |
| 42 | if (ret != 0) { \ |
| 43 | goto exit; \ |
| 44 | } \ |
| 45 | } while (0) |
| 46 | |
| 47 | int main() |
| 48 | { |
| 49 | int ret; |
| 50 | |
| 51 | TEST_MODULE(psa_hash_compute_main()); |
| 52 | TEST_MODULE(psa_hash_main()); |
| 53 | |
Valerio Setti | a06b22d | 2024-06-24 14:59:34 +0200 | [diff] [blame] | 54 | TEST_MODULE(psa_aead_encrypt_main("aes128-gcm")); |
| 55 | TEST_MODULE(psa_aead_encrypt_main("aes256-gcm")); |
| 56 | TEST_MODULE(psa_aead_encrypt_main("aes128-gcm_8")); |
| 57 | TEST_MODULE(psa_aead_encrypt_main("chachapoly")); |
Valerio Setti | e9829e5 | 2024-06-24 16:37:27 +0200 | [diff] [blame] | 58 | TEST_MODULE(psa_aead_encrypt_decrypt_main()); |
| 59 | TEST_MODULE(psa_cipher_encrypt_decrypt_main()); |
Valerio Setti | 9dc9289 | 2024-06-24 17:38:10 +0200 | [diff] [blame] | 60 | TEST_MODULE(psa_asymmetric_encrypt_decrypt_main()); |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 61 | |
Valerio Setti | 25afdc1 | 2024-06-24 13:44:12 +0200 | [diff] [blame] | 62 | TEST_MODULE(psa_random_main()); |
| 63 | |
Valerio Setti | f79e17a | 2024-06-24 13:57:49 +0200 | [diff] [blame] | 64 | TEST_MODULE(psa_mac_main()); |
Valerio Setti | 6d6fe8b | 2024-06-24 14:46:08 +0200 | [diff] [blame] | 65 | TEST_MODULE(psa_key_agreement_main()); |
Valerio Setti | bb1502b | 2024-06-24 14:50:54 +0200 | [diff] [blame] | 66 | TEST_MODULE(psa_sign_verify_main()); |
Valerio Setti | 87be9db | 2024-06-24 15:09:33 +0200 | [diff] [blame] | 67 | TEST_MODULE(psa_hkdf_main()); |
Valerio Setti | f79e17a | 2024-06-24 13:57:49 +0200 | [diff] [blame] | 68 | |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 69 | exit: |
| 70 | return (ret != 0) ? 1 : 0; |
| 71 | } |