blob: b0f96bee8b14ccc2903ad00ffbe44776c3b5a3fa [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 Setti25afdc12024-06-24 13:44:12 +020026int psa_random_main(void);
Valerio Settif79e17a2024-06-24 13:57:49 +020027int psa_mac_main(void);
Valerio Setti6d6fe8b2024-06-24 14:46:08 +020028int psa_key_agreement_main(void);
Valerio Settibb1502b2024-06-24 14:50:54 +020029int psa_sign_verify_main(void);
Valerio Setti5beb2362024-06-24 13:13:17 +020030
31#define TEST_MODULE(main_func) \
32 do { \
33 char title[128] = { 0 }; \
34 char separator[128] = { 0 }; \
35 int title_len = snprintf(title, sizeof(title), "=== Test: %s ===", #main_func); \
36 memset(separator, '=', title_len); \
37 printf("%s\n%s\n%s\n", separator, title, separator); \
38 ret = main_func; \
39 if (ret != 0) { \
40 goto exit; \
41 } \
42 } while (0)
43
44int main()
45{
46 int ret;
47
48 TEST_MODULE(psa_hash_compute_main());
49 TEST_MODULE(psa_hash_main());
50
Valerio Settia06b22d2024-06-24 14:59:34 +020051 TEST_MODULE(psa_aead_encrypt_main("aes128-gcm"));
52 TEST_MODULE(psa_aead_encrypt_main("aes256-gcm"));
53 TEST_MODULE(psa_aead_encrypt_main("aes128-gcm_8"));
54 TEST_MODULE(psa_aead_encrypt_main("chachapoly"));
Valerio Setti5beb2362024-06-24 13:13:17 +020055
Valerio Setti25afdc12024-06-24 13:44:12 +020056 TEST_MODULE(psa_random_main());
57
Valerio Settif79e17a2024-06-24 13:57:49 +020058 TEST_MODULE(psa_mac_main());
Valerio Setti6d6fe8b2024-06-24 14:46:08 +020059 TEST_MODULE(psa_key_agreement_main());
Valerio Settibb1502b2024-06-24 14:50:54 +020060 TEST_MODULE(psa_sign_verify_main());
Valerio Settia06b22d2024-06-24 14:59:34 +020061 TEST_MODULE(psa_aead_encrypt_decrypt_main());
Valerio Settif79e17a2024-06-24 13:57:49 +020062
Valerio Setti5beb2362024-06-24 13:13:17 +020063exit:
64 return (ret != 0) ? 1 : 0;
65}