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); |
| 24 | int psa_aead_main(char *cipher_name); |
Valerio Setti | 25afdc1 | 2024-06-24 13:44:12 +0200 | [diff] [blame] | 25 | int psa_random_main(void); |
Valerio Setti | f79e17a | 2024-06-24 13:57:49 +0200 | [diff] [blame^] | 26 | int psa_mac_main(void); |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 27 | |
| 28 | #define TEST_MODULE(main_func) \ |
| 29 | do { \ |
| 30 | char title[128] = { 0 }; \ |
| 31 | char separator[128] = { 0 }; \ |
| 32 | int title_len = snprintf(title, sizeof(title), "=== Test: %s ===", #main_func); \ |
| 33 | memset(separator, '=', title_len); \ |
| 34 | printf("%s\n%s\n%s\n", separator, title, separator); \ |
| 35 | ret = main_func; \ |
| 36 | if (ret != 0) { \ |
| 37 | goto exit; \ |
| 38 | } \ |
| 39 | } while (0) |
| 40 | |
| 41 | int main() |
| 42 | { |
| 43 | int ret; |
| 44 | |
| 45 | TEST_MODULE(psa_hash_compute_main()); |
| 46 | TEST_MODULE(psa_hash_main()); |
| 47 | |
| 48 | TEST_MODULE(psa_aead_main("aes128-gcm")); |
| 49 | TEST_MODULE(psa_aead_main("aes256-gcm")); |
| 50 | TEST_MODULE(psa_aead_main("aes128-gcm_8")); |
| 51 | TEST_MODULE(psa_aead_main("chachapoly")); |
| 52 | |
Valerio Setti | 25afdc1 | 2024-06-24 13:44:12 +0200 | [diff] [blame] | 53 | TEST_MODULE(psa_random_main()); |
| 54 | |
Valerio Setti | f79e17a | 2024-06-24 13:57:49 +0200 | [diff] [blame^] | 55 | TEST_MODULE(psa_mac_main()); |
| 56 | |
Valerio Setti | 5beb236 | 2024-06-24 13:13:17 +0200 | [diff] [blame] | 57 | exit: |
| 58 | return (ret != 0) ? 1 : 0; |
| 59 | } |