blob: 1ec7dee11f32978fb5143c5981d55e79c9e50eb7 [file] [log] [blame]
Antonio de Angelis8908f472018-08-31 15:44:25 +01001/*
Antonio de Angeliscf85ba22018-10-09 13:29:40 +01002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Antonio de Angelis8908f472018-08-31 15:44:25 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Antonio de Angelis8908f472018-08-31 15:44:25 +01008#include "tfm_crypto_api.h"
Antonio de Angelisab85ccd2019-03-25 15:14:29 +00009#include "crypto_engine.h"
Antonio de Angelis8908f472018-08-31 15:44:25 +010010
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000011static psa_status_t tfm_crypto_module_init(void)
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010012{
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000013 psa_status_t status = PSA_SUCCESS;
Antonio de Angelis8908f472018-08-31 15:44:25 +010014
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010015 /* Init the Key module */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000016 status = tfm_crypto_init_key();
17 if (status != PSA_SUCCESS) {
18 return status;
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010019 }
Antonio de Angelis8908f472018-08-31 15:44:25 +010020
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010021 /* Init the Alloc module */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000022 return tfm_crypto_init_alloc();
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010023}
Antonio de Angelis8908f472018-08-31 15:44:25 +010024
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000025psa_status_t tfm_crypto_init(void)
Antonio de Angelis8908f472018-08-31 15:44:25 +010026{
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010027 psa_status_t status;
Antonio de Angelis8908f472018-08-31 15:44:25 +010028
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010029 /* Initialise other modules of the service */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000030 status = tfm_crypto_module_init();
31 if (status != PSA_SUCCESS) {
32 return status;
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010033 }
34
35 /* Initialise the engine interface module */
36 status = tfm_crypto_engine_init();
37 if (status != PSA_SUCCESS) {
38 /* FIXME: For the time being, keep returning success even if the engine
39 * is not initialised correctly. This can be used to test corner cases
40 * without triggering any TF-M recovery mechanism during boot-up if it
41 * recognises that a service has not completed booting correctly.
42 */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000043 return PSA_SUCCESS;
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010044 }
Antonio de Angelis8908f472018-08-31 15:44:25 +010045
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000046 return PSA_SUCCESS;
Antonio de Angelis8908f472018-08-31 15:44:25 +010047}