Skip to content

Commit e3d1e27

Browse files
committed
mbedtls: Source crypto from Mbed Crypto
Use Mbed Crypto implementations of crypto. For example, use aes.c from Mbed Crypto instead of the Mbed TLS copy.
1 parent 1dbb478 commit e3d1e27

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

features/mbedtls/importer/Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,67 @@ MBED_TLS_DIR:=TARGET_IGNORE/mbedtls
4141
MBED_TLS_API:=$(MBED_TLS_DIR)/include/mbedtls
4242
MBED_TLS_GIT_CFG=$(MBED_TLS_DIR)/.git/config
4343

44+
CRYPTO_SRC := \
45+
$(TARGET_SRC)/aes.c \
46+
$(TARGET_SRC)/aesni.c \
47+
$(TARGET_SRC)/arc4.c \
48+
$(TARGET_SRC)/aria.c \
49+
$(TARGET_SRC)/asn1parse.c \
50+
$(TARGET_SRC)/asn1write.c \
51+
$(TARGET_SRC)/base64.c \
52+
$(TARGET_SRC)/bignum.c \
53+
$(TARGET_SRC)/blowfish.c \
54+
$(TARGET_SRC)/camellia.c \
55+
$(TARGET_SRC)/ccm.c \
56+
$(TARGET_SRC)/chacha20.c \
57+
$(TARGET_SRC)/chachapoly.c \
58+
$(TARGET_SRC)/cipher.c \
59+
$(TARGET_SRC)/cipher_wrap.c \
60+
$(TARGET_SRC)/cmac.c \
61+
$(TARGET_SRC)/ctr_drbg.c \
62+
$(TARGET_SRC)/des.c \
63+
$(TARGET_SRC)/dhm.c \
64+
$(TARGET_SRC)/ecdh.c \
65+
$(TARGET_SRC)/ecdsa.c \
66+
$(TARGET_SRC)/ecjpake.c \
67+
$(TARGET_SRC)/ecp.c \
68+
$(TARGET_SRC)/ecp_curves.c \
69+
$(TARGET_SRC)/entropy.c \
70+
$(TARGET_SRC)/entropy_poll.c \
71+
$(TARGET_SRC)/gcm.c \
72+
$(TARGET_SRC)/havege.c \
73+
$(TARGET_SRC)/hkdf.c \
74+
$(TARGET_SRC)/hmac_drbg.c \
75+
$(TARGET_SRC)/md.c \
76+
$(TARGET_SRC)/md2.c \
77+
$(TARGET_SRC)/md4.c \
78+
$(TARGET_SRC)/md5.c \
79+
$(TARGET_SRC)/md_wrap.c \
80+
$(TARGET_SRC)/memory_buffer_alloc.c \
81+
$(TARGET_SRC)/nist_kw.c \
82+
$(TARGET_SRC)/oid.c \
83+
$(TARGET_SRC)/padlock.c \
84+
$(TARGET_SRC)/pem.c \
85+
$(TARGET_SRC)/pk.c \
86+
$(TARGET_SRC)/pk_wrap.c \
87+
$(TARGET_SRC)/pkcs12.c \
88+
$(TARGET_SRC)/pkcs5.c \
89+
$(TARGET_SRC)/pkparse.c \
90+
$(TARGET_SRC)/pkwrite.c \
91+
$(TARGET_SRC)/platform.c \
92+
$(TARGET_SRC)/platform_util.c \
93+
$(TARGET_SRC)/poly1305.c \
94+
$(TARGET_SRC)/ripemd160.c \
95+
$(TARGET_SRC)/rsa_internal.c \
96+
$(TARGET_SRC)/rsa.c \
97+
$(TARGET_SRC)/sha1.c \
98+
$(TARGET_SRC)/sha256.c \
99+
$(TARGET_SRC)/sha512.c \
100+
$(TARGET_SRC)/threading.c \
101+
$(TARGET_SRC)/timing.c \
102+
$(TARGET_SRC)/xtea.c \
103+
# end
104+
44105
.PHONY: all deploy deploy-tests rsync mbedtls clean update
45106

46107
all: mbedtls
@@ -53,6 +114,9 @@ rsync:
53114
rm -rf $(TARGET_SRC)
54115
rsync -a --exclude='*.txt' $(MBED_TLS_DIR)/library/ $(TARGET_SRC)
55116
#
117+
# Remove files that duplicate Mbed Crypto
118+
rm -rf $(CRYPTO_SRC)
119+
#
56120
# Copying mbed TLS headers to mbed includes...
57121
rm -rf $(TARGET_INC)
58122
mkdir -p $(TARGET_INC)

features/mbedtls/mbed-crypto/importer/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ CRYPTO_REPO_URL ?= [email protected]:ARMmbed/mbed-crypto.git
3535
# Translate between Mbed Crypto namespace and Mbed OS namespace
3636
TARGET_PREFIX:=..
3737
TARGET_INC:=$(TARGET_PREFIX)/inc
38+
TARGET_SRC:=$(TARGET_PREFIX)/src
39+
40+
TLS_SRC := \
41+
$(TARGET_SRC)/error.c \
42+
$(TARGET_SRC)/version.c \
43+
$(TARGET_SRC)/version_features.c \
44+
# end
3845

3946
# A folder structure is introduced here for targets that have both a Secure
4047
# Processing Environment (SPE) targets and Non-secure Processing Environment
@@ -82,6 +89,13 @@ rsync:
8289
rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_SPE)/crypto_struct_spe.h
8390
rsync -a --delete $(CRYPTO_DIR)/library/psa_*.c $(TARGET_SRV_IMPL)/
8491
rsync -a --delete $(CRYPTO_DIR)/library/psa_*.h $(TARGET_SRV_IMPL)/
92+
rsync -a --delete $(CRYPTO_DIR)/library/*.c $(TARGET_SRC)/
93+
#
94+
# Remove PSA-specific C files (they go into $(TARGET_SRV_IMPL))
95+
rm -rf $(TARGET_SRC)/psa_*.c
96+
#
97+
# Remove files that duplicate Mbed TLS
98+
rm -rf $(TLS_SRC)
8599

86100
update: $(CRYPTO_GIT_CFG)
87101
#
@@ -109,6 +123,7 @@ clean:
109123
rm -f $(TARGET_PREFIX)/VERSION.txt
110124
rm -f $(TARGET_PREFIX)/AUTHORS.txt
111125
rm -rf $(TARGET_INC)
126+
rm -rf $(TARGET_SRC)
112127
rm -rf $(CRYPTO_DIR)
113128
rm -rf $(TARGET_SRV_IMPL)
114129
rm -rf $(TARGET_SPE)

0 commit comments

Comments
 (0)