blob: cb81d4d6741cf1be452b303ae30fdb4a6fbf7afe [file] [log] [blame]
Juan Castilloa57a4d52015-04-02 15:44:20 +01001#
dp-arm52b1fe52017-03-07 10:08:42 +00002# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Juan Castilloa57a4d52015-04-02 15:44:20 +01003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Juan Castilloa57a4d52015-04-02 15:44:20 +01005#
6
7include drivers/auth/mbedtls/mbedtls_common.mk
8
David Cunadob1010182017-05-08 09:48:34 +01009# The platform may define the variable 'TF_MBEDTLS_KEY_ALG' to select the key
Masahiro Yamada393c48f2017-01-06 16:51:34 +090010# algorithm to use. Default algorithm is RSA.
David Cunadob1010182017-05-08 09:48:34 +010011ifeq (${TF_MBEDTLS_KEY_ALG},)
12 TF_MBEDTLS_KEY_ALG := rsa
Juan Castilloa57a4d52015-04-02 15:44:20 +010013endif
14
David Cunadob1010182017-05-08 09:48:34 +010015# If MBEDTLS_KEY_ALG build flag is defined use it to set TF_MBEDTLS_KEY_ALG for
16# backward compatibility
17ifdef MBEDTLS_KEY_ALG
18 ifeq (${ERROR_DEPRECATED},1)
19 $(error "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
20 endif
21 $(warning "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
22 TF_MBEDTLS_KEY_ALG := ${MBEDTLS_KEY_ALG}
23endif
24
Juan Castilloa57a4d52015-04-02 15:44:20 +010025MBEDTLS_CRYPTO_SOURCES := drivers/auth/mbedtls/mbedtls_crypto.c \
26 $(addprefix ${MBEDTLS_DIR}/library/, \
27 bignum.c \
28 md.c \
29 md_wrap.c \
30 pk.c \
31 pk_wrap.c \
32 pkparse.c \
33 pkwrite.c \
34 sha256.c \
35 )
36
37# Key algorithm specific files
David Cunadob1010182017-05-08 09:48:34 +010038ifeq (${TF_MBEDTLS_KEY_ALG},ecdsa)
Juan Castilloa57a4d52015-04-02 15:44:20 +010039 MBEDTLS_CRYPTO_SOURCES += $(addprefix ${MBEDTLS_DIR}/library/, \
40 ecdsa.c \
41 ecp_curves.c \
42 ecp.c \
43 )
David Cunadoc7a1b192017-05-10 16:38:44 +010044 TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_ECDSA
David Cunadob1010182017-05-08 09:48:34 +010045else ifeq (${TF_MBEDTLS_KEY_ALG},rsa)
Juan Castilloa57a4d52015-04-02 15:44:20 +010046 MBEDTLS_CRYPTO_SOURCES += $(addprefix ${MBEDTLS_DIR}/library/, \
47 rsa.c \
48 )
David Cunadoc7a1b192017-05-10 16:38:44 +010049 TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA
Juan Castilloa57a4d52015-04-02 15:44:20 +010050else
David Cunadob1010182017-05-08 09:48:34 +010051 $(error "TF_MBEDTLS_KEY_ALG=${TF_MBEDTLS_KEY_ALG} not supported on mbed TLS")
Juan Castilloa57a4d52015-04-02 15:44:20 +010052endif
53
dp-arm52b1fe52017-03-07 10:08:42 +000054# Needs to be set to drive mbed TLS configuration correctly
David Cunadoc7a1b192017-05-10 16:38:44 +010055$(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID))
Juan Castilloa57a4d52015-04-02 15:44:20 +010056
57BL1_SOURCES += ${MBEDTLS_CRYPTO_SOURCES}
58BL2_SOURCES += ${MBEDTLS_CRYPTO_SOURCES}