Gabor Toth | 6df91b5 | 2023-05-15 14:17:16 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include "../psa_api_test_common.h" |
| 8 | #include "libpsa.h" |
| 9 | #include "trace.h" |
| 10 | |
| 11 | psa_status_t test_setup(const char *service_name_crypto, const char *service_name_iat, |
| 12 | const char *service_name_ps, const char *service_name_its) |
| 13 | { |
| 14 | psa_status_t psa_status = PSA_ERROR_GENERIC_ERROR; |
| 15 | |
| 16 | if (!service_name_crypto) |
| 17 | service_name_crypto = "sn:trustedfirmware.org:crypto:0"; |
| 18 | |
| 19 | if (!service_name_iat) |
| 20 | service_name_iat = "sn:trustedfirmware.org:attestation:0"; |
| 21 | |
| 22 | psa_status = libpsa_init_crypto_context(service_name_crypto); |
| 23 | if (psa_status) { |
| 24 | EMSG("libpsa_init_crypto_context failed: %d\n", psa_status); |
| 25 | return psa_status; |
| 26 | } |
| 27 | |
| 28 | psa_status = libpsa_init_attestation_context(service_name_iat); |
| 29 | if (psa_status) { |
| 30 | EMSG("libpsa_init_attestation_context failed: %d\n", psa_status); |
| 31 | return psa_status; |
| 32 | } |
| 33 | |
| 34 | psa_status = psa_crypto_init(); |
| 35 | if (psa_status) { |
| 36 | EMSG("psa_crypto_init failed: %d\n", psa_status); |
| 37 | return psa_status; |
| 38 | } |
| 39 | |
| 40 | return PSA_SUCCESS; |
| 41 | } |
| 42 | |
| 43 | void test_teardown(void) |
| 44 | { |
| 45 | libpsa_deinit_crypto_context(); |
| 46 | libpsa_deinit_attestation_context(); |
| 47 | } |