From ea22e3df3eb017840d90d4150a149400b1965724 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 21 May 2018 13:58:52 +0200 Subject: [PATCH] mbedtls: Update to 2.12.0 Multiple security fixes * CVE-2018-0497 Remote plaintext recovery on use of CBC based ciphersuites through a timing side-channel * CVE-2018-0498 Plaintext recovery on use of CBC based ciphersuites through a cache based side-channel Disable OFB block mode and XTS block cipher mode, added in 2.11.0. Disable Chacha20 and Poly1305 cryptographic primitives, added in 2.12.0 Patch the so version back to the original one, the API changes are looking no so invasive. The size of mbedtls increased a little bit: ipkg for mips_24kc before: 163.967 Bytes ipkg for mips_24kc after: 164.753 Bytes Signed-off-by: Hauke Mehrtens --- package/libs/mbedtls/Makefile | 4 +- package/libs/mbedtls/patches/200-config.patch | 110 +++++++++++++----- .../patches/300-soversion-compatibility.patch | 34 ++++++ package/libs/ustream-ssl/Makefile | 2 +- package/network/services/openvpn/Makefile | 2 +- package/network/utils/curl/Makefile | 2 +- package/utils/px5g/Makefile | 2 +- 7 files changed, 123 insertions(+), 33 deletions(-) create mode 100644 package/libs/mbedtls/patches/300-soversion-compatibility.patch diff --git a/package/libs/mbedtls/Makefile b/package/libs/mbedtls/Makefile index 8ac4e3b13e..4556ad80b4 100644 --- a/package/libs/mbedtls/Makefile +++ b/package/libs/mbedtls/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mbedtls -PKG_VERSION:=2.8.0 +PKG_VERSION:=2.12.0 PKG_RELEASE:=1 PKG_USE_MIPS16:=0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-gpl.tgz PKG_SOURCE_URL:=https://tls.mbed.org/download/ -PKG_HASH:=649eb27187154590edda52943a7f468e740ec08807e5bf68ff45f4e8ffd68923 +PKG_HASH:=8661d19a896a5a7a232ed01ac7f05cf0ec3514798f18076c2c9ef965fbeb5a28 PKG_BUILD_PARALLEL:=1 PKG_LICENSE:=GPL-2.0+ diff --git a/package/libs/mbedtls/patches/200-config.patch b/package/libs/mbedtls/patches/200-config.patch index 0efeb219a0..ab16d4726c 100644 --- a/package/libs/mbedtls/patches/200-config.patch +++ b/package/libs/mbedtls/patches/200-config.patch @@ -1,6 +1,23 @@ --- a/include/mbedtls/config.h +++ b/include/mbedtls/config.h -@@ -566,17 +566,17 @@ +@@ -548,14 +548,14 @@ + * + * Enable Output Feedback mode (OFB) for symmetric ciphers. + */ +-#define MBEDTLS_CIPHER_MODE_OFB ++//#define MBEDTLS_CIPHER_MODE_OFB + + /** + * \def MBEDTLS_CIPHER_MODE_XTS + * + * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. + */ +-#define MBEDTLS_CIPHER_MODE_XTS ++//#define MBEDTLS_CIPHER_MODE_XTS + + /** + * \def MBEDTLS_CIPHER_NULL_CIPHER +@@ -645,19 +645,19 @@ * * Comment macros to disable the curve and functions for it */ @@ -24,9 +41,12 @@ +//#define MBEDTLS_ECP_DP_BP384R1_ENABLED +//#define MBEDTLS_ECP_DP_BP512R1_ENABLED #define MBEDTLS_ECP_DP_CURVE25519_ENABLED +-#define MBEDTLS_ECP_DP_CURVE448_ENABLED ++//#define MBEDTLS_ECP_DP_CURVE448_ENABLED /** -@@ -602,7 +602,7 @@ + * \def MBEDTLS_ECP_NIST_OPTIM +@@ -682,7 +682,7 @@ * * Comment this macro to disable deterministic ECDSA. */ @@ -35,7 +55,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -@@ -655,7 +655,7 @@ +@@ -735,7 +735,7 @@ * See dhm.h for more details. * */ @@ -44,7 +64,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED -@@ -675,7 +675,7 @@ +@@ -755,7 +755,7 @@ * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA */ @@ -53,7 +73,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -@@ -700,7 +700,7 @@ +@@ -780,7 +780,7 @@ * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA */ @@ -62,7 +82,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -@@ -834,7 +834,7 @@ +@@ -914,7 +914,7 @@ * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 */ @@ -71,7 +91,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -@@ -858,7 +858,7 @@ +@@ -938,7 +938,7 @@ * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 */ @@ -80,7 +100,7 @@ /** * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED -@@ -962,7 +962,7 @@ +@@ -1042,7 +1042,7 @@ * This option is only useful if both MBEDTLS_SHA256_C and * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. */ @@ -89,7 +109,7 @@ /** * \def MBEDTLS_ENTROPY_NV_SEED -@@ -1057,14 +1057,14 @@ +@@ -1137,14 +1137,14 @@ * Uncomment this macro to disable the use of CRT in RSA. * */ @@ -106,7 +126,7 @@ /** * \def MBEDTLS_SHA256_SMALLER -@@ -1080,7 +1080,7 @@ +@@ -1160,7 +1160,7 @@ * * Uncomment to enable the smaller implementation of SHA256. */ @@ -115,7 +135,7 @@ /** * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES -@@ -1207,7 +1207,7 @@ +@@ -1298,7 +1298,7 @@ * configuration of this extension). * */ @@ -124,7 +144,7 @@ /** * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO -@@ -1382,7 +1382,7 @@ +@@ -1473,7 +1473,7 @@ * * Comment this macro to disable support for SSL session tickets */ @@ -133,7 +153,7 @@ /** * \def MBEDTLS_SSL_EXPORT_KEYS -@@ -1412,7 +1412,7 @@ +@@ -1503,7 +1503,7 @@ * * Comment this macro to disable support for truncated HMAC in SSL */ @@ -142,7 +162,7 @@ /** * \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT -@@ -1471,7 +1471,7 @@ +@@ -1562,7 +1562,7 @@ * * Comment this to disable run-time checking and save ROM space */ @@ -151,7 +171,7 @@ /** * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 -@@ -1801,7 +1801,7 @@ +@@ -1892,7 +1892,7 @@ * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 */ @@ -159,8 +179,8 @@ +//#define MBEDTLS_CAMELLIA_C /** - * \def MBEDTLS_CCM_C -@@ -1815,7 +1815,7 @@ + * \def MBEDTLS_ARIA_C +@@ -1958,7 +1958,7 @@ * This module enables the AES-CCM ciphersuites, if other requisites are * enabled as well. */ @@ -169,16 +189,34 @@ /** * \def MBEDTLS_CERTS_C -@@ -1827,7 +1827,7 @@ +@@ -1970,7 +1970,7 @@ * * This module is used for testing (ssl_client/server). */ -#define MBEDTLS_CERTS_C +//#define MBEDTLS_CERTS_C + /** + * \def MBEDTLS_CHACHA20_C +@@ -1979,7 +1979,7 @@ + * + * Module: library/chacha20.c + */ +-#define MBEDTLS_CHACHA20_C ++//#define MBEDTLS_CHACHA20_C + + /** + * \def MBEDTLS_CHACHAPOLY_C +@@ -1990,7 +1990,7 @@ + * + * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C + */ +-#define MBEDTLS_CHACHAPOLY_C ++//#define MBEDTLS_CHACHAPOLY_C + /** * \def MBEDTLS_CIPHER_C -@@ -1880,7 +1880,7 @@ +@@ -2043,7 +2043,7 @@ * * This module provides debugging functions. */ @@ -187,7 +225,7 @@ /** * \def MBEDTLS_DES_C -@@ -1909,7 +1909,7 @@ +@@ -2072,7 +2072,7 @@ * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. */ @@ -196,7 +234,16 @@ /** * \def MBEDTLS_DHM_C -@@ -2071,7 +2071,7 @@ +@@ -2235,7 +2235,7 @@ + * This module adds support for the Hashed Message Authentication Code + * (HMAC)-based key derivation function (HKDF). + */ +-#define MBEDTLS_HKDF_C ++//#define MBEDTLS_HKDF_C + + /** + * \def MBEDTLS_HMAC_DRBG_C +@@ -2249,7 +2249,7 @@ * * Uncomment to enable the HMAC_DRBG random number geerator. */ @@ -204,17 +251,26 @@ +//#define MBEDTLS_HMAC_DRBG_C /** - * \def MBEDTLS_MD_C -@@ -2354,7 +2354,7 @@ + * \def MBEDTLS_NIST_KW_C +@@ -2545,7 +2545,7 @@ * * This module enables abstraction of common (libc) functions. */ -#define MBEDTLS_PLATFORM_C +//#define MBEDTLS_PLATFORM_C + /** + * \def MBEDTLS_POLY1305_C +@@ -2555,7 +2555,7 @@ + * Module: library/poly1305.c + * Caller: library/chachapoly.c + */ +-#define MBEDTLS_POLY1305_C ++//#define MBEDTLS_POLY1305_C + /** * \def MBEDTLS_RIPEMD160_C -@@ -2365,7 +2365,7 @@ +@@ -2566,7 +2566,7 @@ * Caller: library/md.c * */ @@ -223,7 +279,7 @@ /** * \def MBEDTLS_RSA_C -@@ -2472,7 +2472,7 @@ +@@ -2673,7 +2673,7 @@ * * Requires: MBEDTLS_CIPHER_C */ @@ -232,7 +288,7 @@ /** * \def MBEDTLS_SSL_CLI_C -@@ -2572,7 +2572,7 @@ +@@ -2773,7 +2773,7 @@ * * This module provides run-time version information. */ @@ -241,7 +297,7 @@ /** * \def MBEDTLS_X509_USE_C -@@ -2682,7 +2682,7 @@ +@@ -2883,7 +2883,7 @@ * Module: library/xtea.c * Caller: */ diff --git a/package/libs/mbedtls/patches/300-soversion-compatibility.patch b/package/libs/mbedtls/patches/300-soversion-compatibility.patch new file mode 100644 index 0000000000..a352b449f1 --- /dev/null +++ b/package/libs/mbedtls/patches/300-soversion-compatibility.patch @@ -0,0 +1,34 @@ +--- a/library/CMakeLists.txt ++++ b/library/CMakeLists.txt +@@ -159,7 +159,7 @@ endif(USE_STATIC_MBEDTLS_LIBRARY) + + if(USE_SHARED_MBEDTLS_LIBRARY) + add_library(mbedcrypto SHARED ${src_crypto}) +- set_target_properties(mbedcrypto PROPERTIES VERSION 2.12.0 SOVERSION 3) ++ set_target_properties(mbedcrypto PROPERTIES VERSION 2.12.0 SOVERSION 1) + target_link_libraries(mbedcrypto ${libs}) + + add_library(mbedx509 SHARED ${src_x509}) +@@ -167,7 +167,7 @@ if(USE_SHARED_MBEDTLS_LIBRARY) + target_link_libraries(mbedx509 ${libs} mbedcrypto) + + add_library(mbedtls SHARED ${src_tls}) +- set_target_properties(mbedtls PROPERTIES VERSION 2.12.0 SOVERSION 11) ++ set_target_properties(mbedtls PROPERTIES VERSION 2.12.0 SOVERSION 10) + target_link_libraries(mbedtls ${libs} mbedx509) + + install(TARGETS mbedtls mbedx509 mbedcrypto +--- a/library/Makefile ++++ b/library/Makefile +@@ -35,9 +35,9 @@ LOCAL_CFLAGS += -fPIC -fpic + endif + endif + +-SOEXT_TLS=so.11 ++SOEXT_TLS=so.10 + SOEXT_X509=so.0 +-SOEXT_CRYPTO=so.3 ++SOEXT_CRYPTO=so.1 + + # Set AR_DASH= (empty string) to use an ar implentation that does not accept + # the - prefix for command line options (e.g. llvm-ar) diff --git a/package/libs/ustream-ssl/Makefile b/package/libs/ustream-ssl/Makefile index e1520f9369..1a79b02551 100644 --- a/package/libs/ustream-ssl/Makefile +++ b/package/libs/ustream-ssl/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ustream-ssl -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/ustream-ssl.git diff --git a/package/network/services/openvpn/Makefile b/package/network/services/openvpn/Makefile index 552ed158b3..374e14f7bd 100644 --- a/package/network/services/openvpn/Makefile +++ b/package/network/services/openvpn/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openvpn PKG_VERSION:=2.4.5 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_URL:=\ https://build.openvpn.net/downloads/releases/ \ diff --git a/package/network/utils/curl/Makefile b/package/network/utils/curl/Makefile index d40b19803a..92b3cab7dd 100644 --- a/package/network/utils/curl/Makefile +++ b/package/network/utils/curl/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=curl PKG_VERSION:=7.60.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://dl.uxnr.de/mirror/curl/ \ diff --git a/package/utils/px5g/Makefile b/package/utils/px5g/Makefile index 4ea495867c..da8d56dcc0 100644 --- a/package/utils/px5g/Makefile +++ b/package/utils/px5g/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=px5g -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_LICENSE:=LGPL-2.1 PKG_BUILD_DIR:=$(BUILD_DIR)/px5g-$(BUILD_VARIANT) -- 2.30.2