blob: ed198790c67e9a736ad358ae445fdc45d3ec77eb [file] [log] [blame]
Valerio Setti5beb2362024-06-24 13:13:17 +02001/**
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
22int psa_hash_compute_main(void);
23int psa_hash_main(void);
Valerio Settia06b22d2024-06-24 14:59:34 +020024int psa_aead_encrypt_main(char *cipher_name);
25int psa_aead_encrypt_decrypt_main(void);
Valerio Settie9829e52024-06-24 16:37:27 +020026int psa_cipher_encrypt_decrypt_main(void);
Valerio Setti9dc92892024-06-24 17:38:10 +020027int psa_asymmetric_encrypt_decrypt_main(void);
Valerio Setti25afdc12024-06-24 13:44:12 +020028int psa_random_main(void);
Valerio Settif79e17a2024-06-24 13:57:49 +020029int psa_mac_main(void);
Valerio Setti6d6fe8b2024-06-24 14:46:08 +020030int psa_key_agreement_main(void);
Valerio Settibb1502b2024-06-24 14:50:54 +020031int psa_sign_verify_main(void);
Valerio Setti87be9db2024-06-24 15:09:33 +020032int psa_hkdf_main(void);
Valerio Setti5beb2362024-06-24 13:13:17 +020033
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
47int main()
48{
49 int ret;
50
51 TEST_MODULE(psa_hash_compute_main());
52 TEST_MODULE(psa_hash_main());
53
Valerio Settia06b22d2024-06-24 14:59:34 +020054 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 Settie9829e52024-06-24 16:37:27 +020058 TEST_MODULE(psa_aead_encrypt_decrypt_main());
59 TEST_MODULE(psa_cipher_encrypt_decrypt_main());
Valerio Setti9dc92892024-06-24 17:38:10 +020060 TEST_MODULE(psa_asymmetric_encrypt_decrypt_main());
Valerio Setti5beb2362024-06-24 13:13:17 +020061
Valerio Setti25afdc12024-06-24 13:44:12 +020062 TEST_MODULE(psa_random_main());
63
Valerio Settif79e17a2024-06-24 13:57:49 +020064 TEST_MODULE(psa_mac_main());
Valerio Setti6d6fe8b2024-06-24 14:46:08 +020065 TEST_MODULE(psa_key_agreement_main());
Valerio Settibb1502b2024-06-24 14:50:54 +020066 TEST_MODULE(psa_sign_verify_main());
Valerio Setti87be9db2024-06-24 15:09:33 +020067 TEST_MODULE(psa_hkdf_main());
Valerio Settif79e17a2024-06-24 13:57:49 +020068
Valerio Setti5beb2362024-06-24 13:13:17 +020069exit:
70 return (ret != 0) ? 1 : 0;
71}