1 /*
2  * Copyright (c) 2019,2020 Linaro Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/logging/log_ctrl.h>
9 #include <zephyr/logging/log.h>
10 
11 #include "tfm_ns_interface.h"
12 #include "psa_attestation.h"
13 #include "psa_crypto.h"
14 #include "util_app_cfg.h"
15 #include "util_app_log.h"
16 #include "util_sformat.h"
17 
18 /** Declare a reference to the application logging interface. */
19 LOG_MODULE_DECLARE(app, CONFIG_LOG_DEFAULT_LEVEL);
20 
21 /* Create an instance of the system config struct for the application. */
22 static struct cfg_data cfg;
23 
main(void)24 int main(void)
25 {
26 	/* Initialise the logger subsys and dump the current buffer. */
27 	log_init();
28 
29 	/* Load app config struct from secure storage (create if missing). */
30 	if (cfg_load_data(&cfg)) {
31 		LOG_ERR("Error loading/generating app config data in SS.");
32 	}
33 
34 	/* Get the entity attestation token (requires ~1kB stack memory!). */
35 	att_test();
36 
37 	/* Crypto tests */
38 	crp_test();
39 	crp_test_rng();
40 
41 	/* Generate Certificate Signing Request using Mbed TLS */
42 	crp_generate_csr();
43 
44 	/* Dump any queued log messages, and wait for system events. */
45 	al_dump_log();
46 
47 	LOG_INF("Done.");
48 
49 	return 0;
50 }
51