1#-------------------------------------------------------------------------------
2# Copyright (c) 2021-2024, The TrustedFirmware-M Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8set(CC3XX_TARGET_NAME ${CC3XX_TARGET_PREFIX}cc312_rom)
9
10add_library(${CC3XX_TARGET_NAME} STATIC)
11
12if (NOT DEFINED CC3XX_PLATFORM_INTERFACE)
13    message(FATAL "When building cc312-rom, the platform dependency must be specified")
14endif()
15
16target_sources(${CC3XX_TARGET_NAME}
17    PRIVATE
18        ./cc3xx_lcs.c
19        ./cc3xx_otp.c
20        ./cc3xx_rng.c
21        ./cc3xx_hash.c
22        ./cc3xx_aes.c
23        ./cc3xx_dma.c
24        ./cc3xx_init.c
25        ./cc3xx_engine_state.c
26        ./cc3xx_stdlib.c
27        ./cc3xx_chacha.c
28        ./cc3xx_kdf.c
29        ./cc3xx_pka.c
30        ./cc3xx_poly1305.c
31        ./cc3xx_hmac.c
32        ./cc3xx_drbg_ctr.c
33        ./cc3xx_drbg_hash.c
34        ./cc3xx_drbg_hmac.c
35        ./cc3xx_drbg.c
36        ./cc3xx_ecdsa.c
37        ./cc3xx_ec.c
38        ./cc3xx_ec_curve_data.c
39        ./cc3xx_ec_weierstrass.c
40        ./cc3xx_ec_projective_point.c
41        ./cc3xx_ecdh.c
42)
43
44# This file is the performance-limit for ECDSA, so should be compiled with the
45# highest possible optimizations for speed, even when we are optimizing for
46# code size.
47string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
48if (${BUILD_TYPE_LOWER} STREQUAL "release" OR ${BUILD_TYPE_LOWER} STREQUAL "minsizerel")
49    set_source_files_properties(./cc3xx_pka.c
50        PROPERTIES COMPILE_FLAGS -Ofast
51    )
52endif()
53
54target_include_directories(${CC3XX_TARGET_NAME}
55    PUBLIC
56        .
57)
58
59target_link_libraries(${CC3XX_TARGET_NAME}
60    PRIVATE
61        ${CC3XX_PLATFORM_INTERFACE}
62)
63
64add_subdirectory(psa_driver_api)
65