blob: c4b02cce13aedff187f95241acf0d8103a3b2715 [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
8#Definitions to compile the "crypto" module.
9#This file assumes it will be included from a project specific cmakefile, and
10#will not create a library or executable.
11#Inputs:
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010012# MBEDTLS_INSTALL_DIR - directory where mbed TLS headers and libraries can be found. Needed only when using CRYPTO_ENGINE_MBEDTLS ON.
Antonio de Angelis8908f472018-08-31 15:44:25 +010013# TFM_ROOT_DIR - root directory of the TF-M repository.
14#Outputs:
15# Will modify include directories to make the source compile.
16# ALL_SRC_C: C source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
17# ALL_SRC_CXX: C++ source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
18# ALL_SRC_ASM: assembly source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
19# Include directories will be modified by using the include_directories() commands as needed.
20
21#Get the current directory where this file is located.
22set(CRYPTO_DIR ${CMAKE_CURRENT_LIST_DIR})
23
24#Check input variables
25if (NOT DEFINED ENABLE_CRYPTO)
26 message(FATAL_ERROR "Incomplete build configuration: ENABLE_CRYPTO is undefined. ")
27endif()
28
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010029if (NOT DEFINED CRYPTO_ENGINE_MBEDTLS)
30 message(FATAL_ERROR "Incomplete build configuration: CRYPTO_ENGINE_MBEDTLS is undefined. ")
31endif()
32
Antonio de Angelis8908f472018-08-31 15:44:25 +010033if (ENABLE_CRYPTO)
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010034 if (CRYPTO_ENGINE_MBEDTLS)
35 if (NOT DEFINED MBEDTLS_INSTALL_DIR)
36 message(FATAL_ERROR "Please set MBEDTLS_INSTALL_DIR before including this file.")
37 endif()
Antonio de Angelis8908f472018-08-31 15:44:25 +010038 endif()
39
40 if (NOT DEFINED TFM_ROOT_DIR)
41 message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
42 endif()
43
44 set (CRYPTO_C_SRC "${CRYPTO_DIR}/crypto_init.c"
45 "${CRYPTO_DIR}/crypto_alloc.c"
46 "${CRYPTO_DIR}/crypto_cipher.c"
Antonio de Angelisa6f72162018-09-05 11:00:37 +010047 "${CRYPTO_DIR}/crypto_hash.c"
Louis Mayencourt7a36f782018-09-24 14:00:57 +010048 "${CRYPTO_DIR}/crypto_mac.c"
Antonio de Angelis8908f472018-08-31 15:44:25 +010049 "${CRYPTO_DIR}/crypto_key.c"
50 "${CRYPTO_DIR}/crypto_wrappers.c"
51 "${CRYPTO_DIR}/crypto_utils.c"
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010052 "${CRYPTO_DIR}/crypto_engine.c"
Antonio de Angelis3a480992018-11-07 11:53:28 +000053 "${CRYPTO_DIR}/crypto_aead.c"
Jamie Fox9da91f32019-02-07 18:11:45 +000054 "${CRYPTO_DIR}/tfm_crypto_secure_api.c"
Antonio de Angelis8908f472018-08-31 15:44:25 +010055 )
56
57 #Append all our source files to global lists.
58 list(APPEND ALL_SRC_C ${CRYPTO_C_SRC})
59 unset(CRYPTO_C_SRC)
60
61 #Setting include directories
62 embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
63 embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010064 if (CRYPTO_ENGINE_MBEDTLS)
65 embedded_include_directories(PATH ${MBEDTLS_INSTALL_DIR}/include ABSOLUTE)
66 endif()
67
68 #Inform the user about Crypto service features selected based on the Crypto service cmake flags
69 message("The Crypto service compile configuration is as follows:")
70 message("- CRYPTO_ENGINE_MBEDTLS: " ${CRYPTO_ENGINE_MBEDTLS})
Jamie Fox82b87ca2018-12-11 16:41:11 +000071 if (NOT DEFINED CRYPTO_KEY_STORAGE_NUM)
72 message("- CRYPTO_KEY_STORAGE_NUM using default value")
73 else()
74 message("- CRYPTO_KEY_STORAGE_NUM: " ${CRYPTO_KEY_STORAGE_NUM})
75 endif()
76 if (NOT DEFINED CRYPTO_KEY_MAX_KEY_LENGTH)
77 message("- CRYPTO_KEY_MAX_KEY_LENGTH using default value")
78 else()
79 message("- CRYPTO_KEY_MAX_KEY_LENGTH: " ${CRYPTO_KEY_MAX_KEY_LENGTH})
80 endif()
81 if (NOT DEFINED CRYPTO_ENGINE_BUF_SIZE)
82 message("- CRYPTO_ENGINE_BUF_SIZE using default value")
83 else()
84 message("- CRYPTO_ENGINE_BUF_SIZE: " ${CRYPTO_ENGINE_BUF_SIZE})
85 endif()
Antonio de Angelis8908f472018-08-31 15:44:25 +010086
87else()
88 message(FATAL_ERROR "Build system currently doesn't support selectively disabling of a service.")
89endif()