Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 2 | # Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 3 | # |
| 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: |
Jamie Fox | 0e54ebc | 2019-04-09 14:21:04 +0100 | [diff] [blame] | 12 | # MBEDTLS_INSTALL_DIR - directory where Mbed Crypto headers and libraries can be found. Needed only when using CRYPTO_ENGINE_MBEDTLS ON. |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 13 | # 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. |
| 22 | set(CRYPTO_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 23 | |
| 24 | #Check input variables |
| 25 | if (NOT DEFINED ENABLE_CRYPTO) |
| 26 | message(FATAL_ERROR "Incomplete build configuration: ENABLE_CRYPTO is undefined. ") |
| 27 | endif() |
| 28 | |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 29 | if (NOT DEFINED CRYPTO_ENGINE_MBEDTLS) |
| 30 | message(FATAL_ERROR "Incomplete build configuration: CRYPTO_ENGINE_MBEDTLS is undefined. ") |
| 31 | endif() |
| 32 | |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 33 | if (ENABLE_CRYPTO) |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 34 | 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 Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 38 | 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 Angelis | a6f7216 | 2018-09-05 11:00:37 +0100 | [diff] [blame] | 47 | "${CRYPTO_DIR}/crypto_hash.c" |
Louis Mayencourt | 7a36f78 | 2018-09-24 14:00:57 +0100 | [diff] [blame] | 48 | "${CRYPTO_DIR}/crypto_mac.c" |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 49 | "${CRYPTO_DIR}/crypto_key.c" |
Antonio de Angelis | 3a48099 | 2018-11-07 11:53:28 +0000 | [diff] [blame] | 50 | "${CRYPTO_DIR}/crypto_aead.c" |
Antonio de Angelis | 25e2b2d | 2019-04-25 14:49:50 +0100 | [diff] [blame^] | 51 | "${CRYPTO_DIR}/crypto_asymmetric.c" |
| 52 | "${CRYPTO_DIR}/crypto_generator.c" |
Jamie Fox | 9da91f3 | 2019-02-07 18:11:45 +0000 | [diff] [blame] | 53 | "${CRYPTO_DIR}/tfm_crypto_secure_api.c" |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 54 | ) |
| 55 | |
| 56 | #Append all our source files to global lists. |
| 57 | list(APPEND ALL_SRC_C ${CRYPTO_C_SRC}) |
| 58 | unset(CRYPTO_C_SRC) |
| 59 | |
| 60 | #Setting include directories |
| 61 | embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE) |
| 62 | embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE) |
Antonio de Angelis | cf85ba2 | 2018-10-09 13:29:40 +0100 | [diff] [blame] | 63 | if (CRYPTO_ENGINE_MBEDTLS) |
| 64 | embedded_include_directories(PATH ${MBEDTLS_INSTALL_DIR}/include ABSOLUTE) |
| 65 | endif() |
| 66 | |
| 67 | #Inform the user about Crypto service features selected based on the Crypto service cmake flags |
| 68 | message("The Crypto service compile configuration is as follows:") |
Jamie Fox | 82b87ca | 2018-12-11 16:41:11 +0000 | [diff] [blame] | 69 | if (NOT DEFINED CRYPTO_ENGINE_BUF_SIZE) |
| 70 | message("- CRYPTO_ENGINE_BUF_SIZE using default value") |
| 71 | else() |
| 72 | message("- CRYPTO_ENGINE_BUF_SIZE: " ${CRYPTO_ENGINE_BUF_SIZE}) |
| 73 | endif() |
Jamie Fox | 0e54ebc | 2019-04-09 14:21:04 +0100 | [diff] [blame] | 74 | if (NOT DEFINED CRYPTO_CONC_OPER_NUM) |
| 75 | message("- CRYPTO_CONC_OPER_NUM using default value") |
| 76 | else() |
| 77 | message("- CRYPTO_CONC_OPER_NUM: " ${CRYPTO_CONC_OPER_NUM}) |
| 78 | endif() |
Antonio de Angelis | 4743e67 | 2019-04-11 11:38:48 +0100 | [diff] [blame] | 79 | if (TFM_PSA_API) |
| 80 | if (NOT DEFINED CRYPTO_IOVEC_BUFFER_SIZE) |
| 81 | message("- CRYPTO_IOVEC_BUFFER_SIZE using default value") |
| 82 | else() |
| 83 | message("- CRYPTO_IOVEC_BUFFER_SIZE: " ${CRYPTO_IOVEC_BUFFER_SIZE}) |
| 84 | endif() |
| 85 | endif() |
Antonio de Angelis | 8908f47 | 2018-08-31 15:44:25 +0100 | [diff] [blame] | 86 | |
| 87 | else() |
| 88 | message(FATAL_ERROR "Build system currently doesn't support selectively disabling of a service.") |
| 89 | endif() |