summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch33
-rw-r--r--meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch34
-rw-r--r--meta-networking/recipes-connectivity/mbedtls/mbedtls/run-ptest17
-rw-r--r--meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb83
4 files changed, 167 insertions, 0 deletions
diff --git a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch
new file mode 100644
index 0000000000..d98d8fa575
--- /dev/null
+++ b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch
@@ -0,0 +1,33 @@
1From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001
2From: Beniamin Sandu <beniaminsandu@gmail.com>
3Date: Sun, 25 Jun 2023 19:58:08 +0300
4Subject: [PATCH] aesce: do not specify an arch version when enabling crypto
5 instructions
6
7Building mbedtls with different aarch64 tuning variations revealed
8that we should use the crypto extensions without forcing a particular
9architecture version or core, as that can create issues.
10
11Upstream-Status: Submitted [https://github.com/Mbed-TLS/mbedtls/pull/7834]
12
13Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
14---
15 library/aesce.c | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
17
18diff --git a/library/aesce.c b/library/aesce.c
19index fe056dc4c..843de3973 100644
20--- a/library/aesce.c
21+++ b/library/aesce.c
22@@ -60,7 +60,7 @@
23 # error "A more recent GCC is required for MBEDTLS_AESCE_C"
24 # endif
25 # pragma GCC push_options
26-# pragma GCC target ("arch=armv8-a+crypto")
27+# pragma GCC target ("+crypto")
28 # define MBEDTLS_POP_TARGET_PRAGMA
29 # else
30 # error "Only GCC and Clang supported for MBEDTLS_AESCE_C"
31--
322.25.1
33
diff --git a/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch
new file mode 100644
index 0000000000..4775c8ddb7
--- /dev/null
+++ b/meta-networking/recipes-connectivity/mbedtls/mbedtls/0002-aesce-use-correct-target-attribute-when-building-wit.patch
@@ -0,0 +1,34 @@
1From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001
2From: Beniamin Sandu <beniaminsandu@gmail.com>
3Date: Mon, 26 Jun 2023 12:07:21 +0300
4Subject: [PATCH] aesce: use correct target attribute when building with clang
5
6Seems clang has its own issues when it comes to crypto extensions,
7and right now the best way to avoid them is to accurately enable
8the needed instructions instead of the broad crypto feature.
9
10E.g.: https://github.com/llvm/llvm-project/issues/61645
11
12Upstream-Status: Pending
13
14Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
15---
16 library/aesce.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19diff --git a/library/aesce.c b/library/aesce.c
20index 843de3973..7bea088ba 100644
21--- a/library/aesce.c
22+++ b/library/aesce.c
23@@ -53,7 +53,7 @@
24 # if __clang_major__ < 4
25 # error "A more recent Clang is required for MBEDTLS_AESCE_C"
26 # endif
27-# pragma clang attribute push (__attribute__((target("crypto"))), apply_to=function)
28+# pragma clang attribute push (__attribute__((target("aes"))), apply_to=function)
29 # define MBEDTLS_POP_TARGET_PRAGMA
30 # elif defined(__GNUC__)
31 # if __GNUC__ < 6
32--
332.25.1
34
diff --git a/meta-networking/recipes-connectivity/mbedtls/mbedtls/run-ptest b/meta-networking/recipes-connectivity/mbedtls/mbedtls/run-ptest
new file mode 100644
index 0000000000..059ab4ecbb
--- /dev/null
+++ b/meta-networking/recipes-connectivity/mbedtls/mbedtls/run-ptest
@@ -0,0 +1,17 @@
1#!/bin/sh
2
3ptestdir=$(dirname "$(readlink -f "$0")")
4cd "$ptestdir"/tests || exit
5
6tests=$(find * -type f -name 'test_suite_*')
7
8for f in $tests
9do
10 if test -x ./"$f"; then
11 if ./"$f" > ./"$f".out 2> ./"$f".err; then
12 echo "PASS: $f"
13 else
14 echo "FAIL: $f"
15 fi
16 fi
17done
diff --git a/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb b/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb
new file mode 100644
index 0000000000..b8c9662de7
--- /dev/null
+++ b/meta-networking/recipes-connectivity/mbedtls/mbedtls_3.4.0.bb
@@ -0,0 +1,83 @@
1SUMMARY = "Lightweight crypto and SSL/TLS library"
2DESCRIPTION = "mbedtls is a lean open source crypto library \
3for providing SSL and TLS support in your programs. It offers \
4an intuitive API and documented header files, so you can actually \
5understand what the code does. It features: \
6 \
7 - Symmetric algorithms, like AES, Blowfish, Triple-DES, DES, ARC4, \
8 Camellia and XTEA \
9 - Hash algorithms, like SHA-1, SHA-2, RIPEMD-160 and MD5 \
10 - Entropy pool and random generators, like CTR-DRBG and HMAC-DRBG \
11 - Public key algorithms, like RSA, Elliptic Curves, Diffie-Hellman, \
12 ECDSA and ECDH \
13 - SSL v3 and TLS 1.0, 1.1 and 1.2 \
14 - Abstraction layers for ciphers, hashes, public key operations, \
15 platform abstraction and threading \
16"
17
18HOMEPAGE = "https://tls.mbed.org/"
19
20LICENSE = "Apache-2.0"
21LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
22
23SECTION = "libs"
24
25S = "${WORKDIR}/git"
26SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33"
27SRC_URI = "git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=master \
28 file://0001-aesce-do-not-specify-an-arch-version-when-enabling-c.patch \
29 file://0002-aesce-use-correct-target-attribute-when-building-wit.patch \
30 file://run-ptest"
31
32inherit cmake update-alternatives ptest
33
34PACKAGECONFIG ??= "shared-libs programs ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
35PACKAGECONFIG[shared-libs] = "-DUSE_SHARED_MBEDTLS_LIBRARY=ON,-DUSE_SHARED_MBEDTLS_LIBRARY=OFF"
36PACKAGECONFIG[programs] = "-DENABLE_PROGRAMS=ON,-DENABLE_PROGRAMS=OFF"
37PACKAGECONFIG[werror] = "-DMBEDTLS_FATAL_WARNINGS=ON,-DMBEDTLS_FATAL_WARNINGS=OFF"
38# Make X.509 and TLS calls use PSA
39# https://github.com/Mbed-TLS/mbedtls/blob/development/docs/use-psa-crypto.md
40PACKAGECONFIG[psa] = ""
41PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF"
42
43EXTRA_OECMAKE = "-DLIB_INSTALL_DIR:STRING=${libdir}"
44
45# For now the only way to enable PSA is to explicitly pass a -D via CFLAGS
46CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', ' -DMBEDTLS_USE_PSA_CRYPTO', '', d)}"
47
48PROVIDES += "polarssl"
49RPROVIDES:${PN} = "polarssl"
50
51PACKAGES =+ "${PN}-programs"
52FILES:${PN}-programs = "${bindir}/"
53
54ALTERNATIVE:${PN}-programs = "hello"
55ALTERNATIVE_LINK_NAME[hello] = "${bindir}/hello"
56
57BBCLASSEXTEND = "native nativesdk"
58
59CVE_PRODUCT = "mbed_tls"
60
61# Fix merged upstream https://github.com/Mbed-TLS/mbedtls/pull/5310
62CVE_CHECK_IGNORE += "CVE-2021-43666"
63# Fix merged upstream https://github.com/Mbed-TLS/mbedtls/commit/9a4a9c66a48edfe9ece03c7e4a53310adf73a86c
64CVE_CHECK_IGNORE += "CVE-2021-45451"
65
66# Strip host paths from autogenerated test files
67do_compile:append() {
68 sed -i 's+${S}/++g' ${B}/tests/*.c 2>/dev/null || :
69 sed -i 's+${B}/++g' ${B}/tests/*.c 2>/dev/null || :
70}
71
72# Export source files/headers needed by Arm Trusted Firmware
73sysroot_stage_all:append() {
74 sysroot_stage_dir "${S}/library" "${SYSROOT_DESTDIR}/usr/share/mbedtls-source/library"
75 sysroot_stage_dir "${S}/include" "${SYSROOT_DESTDIR}/usr/share/mbedtls-source/include"
76}
77
78do_install_ptest () {
79 install -d ${D}${PTEST_PATH}/tests
80 cp -f ${B}/tests/test_suite_* ${D}${PTEST_PATH}/tests/
81 find ${D}${PTEST_PATH}/tests/ -type f -name "*.c" -delete
82 cp -fR ${S}/tests/data_files ${D}${PTEST_PATH}/tests/
83}