blob: 38197164c93e980b4f9b61e10f584fa05cbcff28 [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
Soby Mathew13b16052017-08-31 11:49:32 +010010# algorithm to use. If the variable is not defined, select it based on algorithm
11# used for key generation `KEY_ALG`. If `KEY_ALG` is not defined or is
12# defined to `rsa`, then set the variable to `rsa`.
David Cunadob1010182017-05-08 09:48:34 +010013ifeq (${TF_MBEDTLS_KEY_ALG},)
Soby Mathew13b16052017-08-31 11:49:32 +010014 ifeq (${KEY_ALG}, ecdsa)
15 TF_MBEDTLS_KEY_ALG := ecdsa
16 else
17 TF_MBEDTLS_KEY_ALG := rsa
18 endif
Juan Castilloa57a4d52015-04-02 15:44:20 +010019endif
20
David Cunadob1010182017-05-08 09:48:34 +010021# If MBEDTLS_KEY_ALG build flag is defined use it to set TF_MBEDTLS_KEY_ALG for
22# backward compatibility
23ifdef MBEDTLS_KEY_ALG
24 ifeq (${ERROR_DEPRECATED},1)
25 $(error "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
26 endif
27 $(warning "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
28 TF_MBEDTLS_KEY_ALG := ${MBEDTLS_KEY_ALG}
29endif
30
Juan Castilloa57a4d52015-04-02 15:44:20 +010031MBEDTLS_CRYPTO_SOURCES := drivers/auth/mbedtls/mbedtls_crypto.c \
32 $(addprefix ${MBEDTLS_DIR}/library/, \
33 bignum.c \
34 md.c \
35 md_wrap.c \
36 pk.c \
37 pk_wrap.c \
38 pkparse.c \
39 pkwrite.c \
40 sha256.c \
41 )
42
43# Key algorithm specific files
David Cunadob1010182017-05-08 09:48:34 +010044ifeq (${TF_MBEDTLS_KEY_ALG},ecdsa)
Juan Castilloa57a4d52015-04-02 15:44:20 +010045 MBEDTLS_CRYPTO_SOURCES += $(addprefix ${MBEDTLS_DIR}/library/, \
46 ecdsa.c \
47 ecp_curves.c \
48 ecp.c \
49 )
David Cunadoc7a1b192017-05-10 16:38:44 +010050 TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_ECDSA
David Cunadob1010182017-05-08 09:48:34 +010051else ifeq (${TF_MBEDTLS_KEY_ALG},rsa)
Juan Castilloa57a4d52015-04-02 15:44:20 +010052 MBEDTLS_CRYPTO_SOURCES += $(addprefix ${MBEDTLS_DIR}/library/, \
53 rsa.c \
54 )
David Cunadoc7a1b192017-05-10 16:38:44 +010055 TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA
Juan Castilloa57a4d52015-04-02 15:44:20 +010056else
David Cunadob1010182017-05-08 09:48:34 +010057 $(error "TF_MBEDTLS_KEY_ALG=${TF_MBEDTLS_KEY_ALG} not supported on mbed TLS")
Juan Castilloa57a4d52015-04-02 15:44:20 +010058endif
59
dp-arm52b1fe52017-03-07 10:08:42 +000060# Needs to be set to drive mbed TLS configuration correctly
David Cunadoc7a1b192017-05-10 16:38:44 +010061$(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID))
Juan Castilloa57a4d52015-04-02 15:44:20 +010062
63BL1_SOURCES += ${MBEDTLS_CRYPTO_SOURCES}
64BL2_SOURCES += ${MBEDTLS_CRYPTO_SOURCES}