diff options
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 @@ | |||
| 1 | From 2246925e3cb16183e25d4e2cfd13fb800df86270 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 3 | Date: Sun, 25 Jun 2023 19:58:08 +0300 | ||
| 4 | Subject: [PATCH] aesce: do not specify an arch version when enabling crypto | ||
| 5 | instructions | ||
| 6 | |||
| 7 | Building mbedtls with different aarch64 tuning variations revealed | ||
| 8 | that we should use the crypto extensions without forcing a particular | ||
| 9 | architecture version or core, as that can create issues. | ||
| 10 | |||
| 11 | Upstream-Status: Submitted [https://github.com/Mbed-TLS/mbedtls/pull/7834] | ||
| 12 | |||
| 13 | Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 14 | --- | ||
| 15 | library/aesce.c | 2 +- | ||
| 16 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 17 | |||
| 18 | diff --git a/library/aesce.c b/library/aesce.c | ||
| 19 | index 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 | -- | ||
| 32 | 2.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 @@ | |||
| 1 | From 03d3523f974536f2358047382aadb0d4cc762f8a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 3 | Date: Mon, 26 Jun 2023 12:07:21 +0300 | ||
| 4 | Subject: [PATCH] aesce: use correct target attribute when building with clang | ||
| 5 | |||
| 6 | Seems clang has its own issues when it comes to crypto extensions, | ||
| 7 | and right now the best way to avoid them is to accurately enable | ||
| 8 | the needed instructions instead of the broad crypto feature. | ||
| 9 | |||
| 10 | E.g.: https://github.com/llvm/llvm-project/issues/61645 | ||
| 11 | |||
| 12 | Upstream-Status: Pending | ||
| 13 | |||
| 14 | Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 15 | --- | ||
| 16 | library/aesce.c | 2 +- | ||
| 17 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 18 | |||
| 19 | diff --git a/library/aesce.c b/library/aesce.c | ||
| 20 | index 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 | -- | ||
| 33 | 2.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 | |||
| 3 | ptestdir=$(dirname "$(readlink -f "$0")") | ||
| 4 | cd "$ptestdir"/tests || exit | ||
| 5 | |||
| 6 | tests=$(find * -type f -name 'test_suite_*') | ||
| 7 | |||
| 8 | for f in $tests | ||
| 9 | do | ||
| 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 | ||
| 17 | done | ||
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 @@ | |||
| 1 | SUMMARY = "Lightweight crypto and SSL/TLS library" | ||
| 2 | DESCRIPTION = "mbedtls is a lean open source crypto library \ | ||
| 3 | for providing SSL and TLS support in your programs. It offers \ | ||
| 4 | an intuitive API and documented header files, so you can actually \ | ||
| 5 | understand 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 | |||
| 18 | HOMEPAGE = "https://tls.mbed.org/" | ||
| 19 | |||
| 20 | LICENSE = "Apache-2.0" | ||
| 21 | LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" | ||
| 22 | |||
| 23 | SECTION = "libs" | ||
| 24 | |||
| 25 | S = "${WORKDIR}/git" | ||
| 26 | SRCREV = "1873d3bfc2da771672bd8e7e8f41f57e0af77f33" | ||
| 27 | SRC_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 | |||
| 32 | inherit cmake update-alternatives ptest | ||
| 33 | |||
| 34 | PACKAGECONFIG ??= "shared-libs programs ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}" | ||
| 35 | PACKAGECONFIG[shared-libs] = "-DUSE_SHARED_MBEDTLS_LIBRARY=ON,-DUSE_SHARED_MBEDTLS_LIBRARY=OFF" | ||
| 36 | PACKAGECONFIG[programs] = "-DENABLE_PROGRAMS=ON,-DENABLE_PROGRAMS=OFF" | ||
| 37 | PACKAGECONFIG[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 | ||
| 40 | PACKAGECONFIG[psa] = "" | ||
| 41 | PACKAGECONFIG[tests] = "-DENABLE_TESTING=ON,-DENABLE_TESTING=OFF" | ||
| 42 | |||
| 43 | EXTRA_OECMAKE = "-DLIB_INSTALL_DIR:STRING=${libdir}" | ||
| 44 | |||
| 45 | # For now the only way to enable PSA is to explicitly pass a -D via CFLAGS | ||
| 46 | CFLAGS:append = "${@bb.utils.contains('PACKAGECONFIG', 'psa', ' -DMBEDTLS_USE_PSA_CRYPTO', '', d)}" | ||
| 47 | |||
| 48 | PROVIDES += "polarssl" | ||
| 49 | RPROVIDES:${PN} = "polarssl" | ||
| 50 | |||
| 51 | PACKAGES =+ "${PN}-programs" | ||
| 52 | FILES:${PN}-programs = "${bindir}/" | ||
| 53 | |||
| 54 | ALTERNATIVE:${PN}-programs = "hello" | ||
| 55 | ALTERNATIVE_LINK_NAME[hello] = "${bindir}/hello" | ||
| 56 | |||
| 57 | BBCLASSEXTEND = "native nativesdk" | ||
| 58 | |||
| 59 | CVE_PRODUCT = "mbed_tls" | ||
| 60 | |||
| 61 | # Fix merged upstream https://github.com/Mbed-TLS/mbedtls/pull/5310 | ||
| 62 | CVE_CHECK_IGNORE += "CVE-2021-43666" | ||
| 63 | # Fix merged upstream https://github.com/Mbed-TLS/mbedtls/commit/9a4a9c66a48edfe9ece03c7e4a53310adf73a86c | ||
| 64 | CVE_CHECK_IGNORE += "CVE-2021-45451" | ||
| 65 | |||
| 66 | # Strip host paths from autogenerated test files | ||
| 67 | do_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 | ||
| 73 | sysroot_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 | |||
| 78 | do_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 | } | ||
