Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 1 | # |
Jeenu Viswambharan | ec06c3b | 2018-06-07 15:14:42 +0100 | [diff] [blame] | 2 | # Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 5 | # |
| 6 | |
| 7 | ifneq (${MBEDTLS_COMMON_MK},1) |
| 8 | MBEDTLS_COMMON_MK := 1 |
| 9 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 10 | # MBEDTLS_DIR must be set to the mbed TLS main directory (it must contain |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 11 | # the 'include' and 'library' subdirectories). |
| 12 | ifeq (${MBEDTLS_DIR},) |
| 13 | $(error Error: MBEDTLS_DIR not set) |
| 14 | endif |
| 15 | |
Roberto Vargas | d51207e | 2018-06-04 15:15:04 +0100 | [diff] [blame] | 16 | MBEDTLS_INC = -I${MBEDTLS_DIR}/include |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 17 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 18 | # Specify mbed TLS configuration file |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 19 | MBEDTLS_CONFIG_FILE := "<drivers/auth/mbedtls/mbedtls_config.h>" |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 20 | $(eval $(call add_define,MBEDTLS_CONFIG_FILE)) |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 21 | |
Roberto Vargas | 502290b | 2018-05-08 10:27:10 +0100 | [diff] [blame] | 22 | MBEDTLS_SOURCES += drivers/auth/mbedtls/mbedtls_common.c |
| 23 | |
| 24 | |
| 25 | LIBMBEDTLS_SRCS := $(addprefix ${MBEDTLS_DIR}/library/, \ |
| 26 | asn1parse.c \ |
| 27 | asn1write.c \ |
| 28 | memory_buffer_alloc.c \ |
| 29 | oid.c \ |
| 30 | platform.c \ |
| 31 | platform_util.c \ |
| 32 | bignum.c \ |
| 33 | md.c \ |
| 34 | md_wrap.c \ |
| 35 | pk.c \ |
| 36 | pk_wrap.c \ |
| 37 | pkparse.c \ |
| 38 | pkwrite.c \ |
| 39 | sha256.c \ |
| 40 | sha512.c \ |
| 41 | ecdsa.c \ |
| 42 | ecp_curves.c \ |
| 43 | ecp.c \ |
| 44 | rsa.c \ |
| 45 | rsa_internal.c \ |
| 46 | x509.c \ |
| 47 | x509_crt.c \ |
| 48 | ) |
| 49 | |
| 50 | # The platform may define the variable 'TF_MBEDTLS_KEY_ALG' to select the key |
| 51 | # algorithm to use. If the variable is not defined, select it based on algorithm |
| 52 | # used for key generation `KEY_ALG`. If `KEY_ALG` is not defined or is |
| 53 | # defined to `rsa`/`rsa_1_5`, then set the variable to `rsa`. |
| 54 | ifeq (${TF_MBEDTLS_KEY_ALG},) |
| 55 | ifeq (${KEY_ALG}, ecdsa) |
| 56 | TF_MBEDTLS_KEY_ALG := ecdsa |
| 57 | else |
| 58 | TF_MBEDTLS_KEY_ALG := rsa |
| 59 | endif |
| 60 | endif |
| 61 | |
Roberto Vargas | 502290b | 2018-05-08 10:27:10 +0100 | [diff] [blame] | 62 | ifeq (${HASH_ALG}, sha384) |
| 63 | TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA384 |
| 64 | else ifeq (${HASH_ALG}, sha512) |
| 65 | TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA512 |
| 66 | else |
| 67 | TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA256 |
| 68 | endif |
| 69 | |
| 70 | ifeq (${TF_MBEDTLS_KEY_ALG},ecdsa) |
| 71 | TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_ECDSA |
| 72 | else ifeq (${TF_MBEDTLS_KEY_ALG},rsa) |
| 73 | TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA |
| 74 | else ifeq (${TF_MBEDTLS_KEY_ALG},rsa+ecdsa) |
| 75 | TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA_AND_ECDSA |
| 76 | else |
| 77 | $(error "TF_MBEDTLS_KEY_ALG=${TF_MBEDTLS_KEY_ALG} not supported on mbed TLS") |
| 78 | endif |
| 79 | |
| 80 | # Needs to be set to drive mbed TLS configuration correctly |
| 81 | $(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID)) |
| 82 | $(eval $(call add_define,TF_MBEDTLS_HASH_ALG_ID)) |
| 83 | |
| 84 | |
| 85 | $(eval $(call MAKE_LIB,mbedtls)) |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 86 | |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 87 | endif |