mbedtls_crypto.mk 2.85 KB
Newer Older
1
#
dp-arm's avatar
dp-arm committed
2
# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3
#
dp-arm's avatar
dp-arm committed
4
# SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
#

include drivers/auth/mbedtls/mbedtls_common.mk

9
# The platform may define the variable 'TF_MBEDTLS_KEY_ALG' to select the key
10
11
# algorithm to use. If the variable is not defined, select it based on algorithm
# used for key generation `KEY_ALG`. If `KEY_ALG` is not defined or is
12
# defined to `rsa`/`rsa_1_5`, then set the variable to `rsa`.
13
ifeq (${TF_MBEDTLS_KEY_ALG},)
14
15
16
17
18
    ifeq (${KEY_ALG}, ecdsa)
        TF_MBEDTLS_KEY_ALG		:=	ecdsa
    else
        TF_MBEDTLS_KEY_ALG		:=	rsa
    endif
19
20
21
22
23
24
25
26
27
28
endif

# If MBEDTLS_KEY_ALG build flag is defined use it to set TF_MBEDTLS_KEY_ALG for
# backward compatibility
ifdef MBEDTLS_KEY_ALG
    ifeq (${ERROR_DEPRECATED},1)
        $(error "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
    endif
    $(warning "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
    TF_MBEDTLS_KEY_ALG	:= ${MBEDTLS_KEY_ALG}
29
30
31
32
33
34
35
36
37
38
39
40
41
endif

MBEDTLS_CRYPTO_SOURCES		:=	drivers/auth/mbedtls/mbedtls_crypto.c	\
					$(addprefix ${MBEDTLS_DIR}/library/,	\
					bignum.c				\
					md.c					\
					md_wrap.c				\
					pk.c 					\
					pk_wrap.c 				\
					pkparse.c 				\
					pkwrite.c 				\
					)

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
ifeq (${HASH_ALG}, sha384)
    MBEDTLS_CRYPTO_SOURCES  += \
					$(addprefix ${MBEDTLS_DIR}/library/,	\
						sha256.c            \
						sha512.c            \
					)
    TF_MBEDTLS_HASH_ALG_ID	:=	TF_MBEDTLS_SHA384
else ifeq (${HASH_ALG}, sha512)
    MBEDTLS_CRYPTO_SOURCES  += \
					$(addprefix ${MBEDTLS_DIR}/library/,	\
						sha256.c            \
						sha512.c            \
					)
    TF_MBEDTLS_HASH_ALG_ID	:=	TF_MBEDTLS_SHA512
else
    MBEDTLS_CRYPTO_SOURCES  += \
					$(addprefix ${MBEDTLS_DIR}/library/,	\
						sha256.c            \
					)
    TF_MBEDTLS_HASH_ALG_ID	:=	TF_MBEDTLS_SHA256
endif

64
# Key algorithm specific files
Qixiang Xu's avatar
Qixiang Xu committed
65
66
67
68
69
70
71
72
73
74
MBEDTLS_ECDSA_CRYPTO_SOURCES	+=	$(addprefix ${MBEDTLS_DIR}/library/,	\
					ecdsa.c					\
					ecp_curves.c				\
					ecp.c					\
					)

MBEDTLS_RSA_CRYPTO_SOURCES	+=	$(addprefix ${MBEDTLS_DIR}/library/,	\
					rsa.c					\
					)

75
ifeq (${TF_MBEDTLS_KEY_ALG},ecdsa)
Qixiang Xu's avatar
Qixiang Xu committed
76
    MBEDTLS_CRYPTO_SOURCES	+=	$(MBEDTLS_ECDSA_CRYPTO_SOURCES)
77
    TF_MBEDTLS_KEY_ALG_ID	:=	TF_MBEDTLS_ECDSA
78
else ifeq (${TF_MBEDTLS_KEY_ALG},rsa)
Qixiang Xu's avatar
Qixiang Xu committed
79
    MBEDTLS_CRYPTO_SOURCES	+=	$(MBEDTLS_RSA_CRYPTO_SOURCES)
80
    TF_MBEDTLS_KEY_ALG_ID	:=	TF_MBEDTLS_RSA
Qixiang Xu's avatar
Qixiang Xu committed
81
82
83
84
else ifeq (${TF_MBEDTLS_KEY_ALG},rsa+ecdsa)
    MBEDTLS_CRYPTO_SOURCES	+=	$(MBEDTLS_ECDSA_CRYPTO_SOURCES)
    MBEDTLS_CRYPTO_SOURCES	+=	$(MBEDTLS_RSA_CRYPTO_SOURCES)
    TF_MBEDTLS_KEY_ALG_ID	:=	TF_MBEDTLS_RSA_AND_ECDSA
85
else
86
    $(error "TF_MBEDTLS_KEY_ALG=${TF_MBEDTLS_KEY_ALG} not supported on mbed TLS")
87
88
endif

dp-arm's avatar
dp-arm committed
89
# Needs to be set to drive mbed TLS configuration correctly
90
$(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID))
91
$(eval $(call add_define,TF_MBEDTLS_HASH_ALG_ID))