From patchwork Fri Oct 18 14:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 836716 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp848007wrt; Fri, 18 Oct 2024 07:23:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzLjRY8KeijdDcPYNNaxUkuEpOlOGhcrTgkh6e949waky65tM7HGPzsDQLvJhfaLCZd1NNnw==@linaro.org X-Google-Smtp-Source: AGHT+IGKYlFbi6ChH9ZRc4RT6V2Hh9Q77GBx5yYqG361FWSCjKaG3VbtfOowo42ToB98kXsF3uUI X-Received: by 2002:a92:c54a:0:b0:3a3:a5c5:38d8 with SMTP id e9e14a558f8ab-3a3f4178d43mr16641965ab.3.1729261386730; Fri, 18 Oct 2024 07:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729261386; cv=none; d=google.com; s=arc-20240605; b=YPc2pbNlokRA1POd3MvyJ7fR02BYCnzLcM/LvaOxDLB5JP2liJw17oBS0uQwavf93z p9hRugcilTZlweum8bLkgOIiiTko6MuVhK7LDdEl2bRPDg0GGb3/vvGLyifySUDFmynH CTgSJSmm92CHSscNBd1hg2lCOUUvc6UaLKK7obk77N9K4APrUmbI5mYPYpGmUx6pspF8 rRxqdZZKgoEVCC8YqATD/W/WMLSG/JCwSrRVqarZ9725S+cz+Mudax4F29MiXtoHWUlo TnLdxQ1hoGCp+hdWltEYPrPQLqQ5/bPqP4/fS0M5WGBnRuwjEcv5y0b9RhbEOP8Wg+KR 1fZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/nVaCe/5c3Pgv6MVW0O0cTyZuIeAelWqXzVeLvHfcko=; fh=R1Q1kkk+N/VYWIkAAOZqwkaTQCSPDHxHkEBCuwwxkIQ=; b=SkUD14C8tLQejjkoxw+OYeQHiaL6R9nTUZkGwiGDXIfePUthgBboDV+O7aBaRi3AJh Mj8ch2j0oOlv/U9HYW3u9IBg3MzI78FJ7k0eZfl2kr5BXfx189KP9ebXPt0HBP2bfe/K vRM50SordIPon9uewwHOPc62XKjkzY4+BcXj5kosoCd5nscVjuZUBLcEfR20vrDK55vM rSXW7WSbZFiiTI1SB8Rl9j+tsDZrpl5XLf/vz9Hh1Law28emU17eHlcBi9Angi0I0spe CiRVFoF34mLGDhaZWBladmx8RuQMApC2DidNTA8RVGm6O3kbnwe2pbeLHEH1HT2DZRgM qq4A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlY1Nu+d; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a3f4037548si7346775ab.108.2024.10.18.07.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlY1Nu+d; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 22F6A891E1; Fri, 18 Oct 2024 16:23:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="KlY1Nu+d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1D1A891E9; Fri, 18 Oct 2024 16:23:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0C36489130 for ; Fri, 18 Oct 2024 16:22:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4305413aec9so22891885e9.2 for ; Fri, 18 Oct 2024 07:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729261368; x=1729866168; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/nVaCe/5c3Pgv6MVW0O0cTyZuIeAelWqXzVeLvHfcko=; b=KlY1Nu+d0z+p04HEqG/Z5LQTHOnRrumrkod/pb0TwvNGAMYgDryYSDb8+OZNGYRUn3 LFoT6ZIRQPTdG0ggN1aF8+oFV4dWnveZo92bmjlws34wm667guGBAhFHn3/xh5hdjwkc JgC7i4hvQ+cHRmx0HmXxeHUeZDHhwTKsAK8I0TKA4oRVbn/G3IKPANamd6DIu1ptQ7Hh XlW7QciEmQO6twvQVValxTPBG/T8FOAWzPtjB9aA4Uv0TCltVZr9NwWPQC6v8YwSu82f waEvgPAltGyhbf9J+B5LtTZhlQn/VLYU7eoQPryozv+hWotrjuur/TJkkxmSviY2wfLv 8F4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729261368; x=1729866168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/nVaCe/5c3Pgv6MVW0O0cTyZuIeAelWqXzVeLvHfcko=; b=Bqw/QkBuqitoFP1RgP5GSTRkg+v1haAiabZgdmpgcef/nw8GgerLKjfZOL88LFhbev l/DyFkJL38QYqgJmSdKNr81fuqNXI0DDAo0djSENvW8rem6SJWzUT4yzON9UrmwH7Ny8 ol1Cuf6LNEnT+TO+nYZCxaDnGqalD2YNUTGTBLbf4970Nk+41lvg8HhCc7HOzVwBde4e vzCL9PaR0n+utRA9vANL09G3dMSQTyWJUJxV5wdO2u2k9iSM087bR2aS8PLL74TSuSrK jbXjVeP0REKUxWZxwTlBbzHGKs9/L3cqqkJfJTQjIJo+wASENomcpAdHZV7JOYLAYLlY ZhHQ== X-Forwarded-Encrypted: i=1; AJvYcCV9Tp7lqKllKlO7j60InNp5wzFoUgRP6m0kFGzOvydzdPyopUDdpLf5sGYVRW7GCz/6A0wiGjk=@lists.denx.de X-Gm-Message-State: AOJu0YyI27Cz5NZX1OYD7EbtmZ33+MH4bcb26NeroZKmKYF3QZKx+sMR 9RRcuQZkNgvEgT4Dx3XnMJWoO/Vc45K2TNYgEErlOfZ8SUIv74yYxf2ZO5KJoyg= X-Received: by 2002:a05:600c:4e12:b0:431:1d97:2b0a with SMTP id 5b1f17b1804b1-43161641793mr22843545e9.15.1729261368454; Fri, 18 Oct 2024 07:22:48 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316067dc70sm28781665e9.10.2024.10.18.07.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:22:47 -0700 (PDT) From: Ilias Apalodimas To: jerome.forissier@linaro.org, raymond.mao@linaro.org Cc: xypron.glpk@gmx.de, Ilias Apalodimas , Tom Rini , Joe Hershberger , Ramon Fried , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Wei Ming Chen , Jonathan Humphreys , Caleb Connolly , Masahisa Kojima , Javier Tia , u-boot@lists.denx.de Subject: [PATCH 1/6] mbedtls: Enable TLS 1.2 support Date: Fri, 18 Oct 2024 17:21:55 +0300 Message-ID: <20241018142235.715571-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018142235.715571-1-ilias.apalodimas@linaro.org> References: <20241018142235.715571-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Since lwIP and mbedTLS have been merged we can tweak the config options and enable TLS1.2 support. Add RSA and ECDSA by default and enable enough block cipher modes of operation to be comatible with modern TLS requirements and webservers Signed-off-by: Ilias Apalodimas --- lib/mbedtls/Kconfig | 12 ++++++++ lib/mbedtls/Makefile | 33 +++++++++++++++++++- lib/mbedtls/mbedtls_def_config.h | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/lib/mbedtls/Kconfig b/lib/mbedtls/Kconfig index d71adc3648ad..f3e172633999 100644 --- a/lib/mbedtls/Kconfig +++ b/lib/mbedtls/Kconfig @@ -430,4 +430,16 @@ endif # SPL endif # MBEDTLS_LIB_X509 +config MBEDTLS_LIB_TLS + bool "MbedTLS TLS library" + depends on RSA_PUBLIC_KEY_PARSER_MBEDTLS + depends on X509_CERTIFICATE_PARSER_MBEDTLS + depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS + depends on ASN1_DECODER_MBEDTLS + depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS + depends on MBEDTLS_LIB_CRYPTO + help + Enable MbedTLS TLS library. If enabled HTTPs support will be enabled + in wget + endif # MBEDTLS_LIB diff --git a/lib/mbedtls/Makefile b/lib/mbedtls/Makefile index 83cb3c2fa705..845284799a11 100644 --- a/lib/mbedtls/Makefile +++ b/lib/mbedtls/Makefile @@ -25,7 +25,19 @@ obj-$(CONFIG_MBEDTLS_LIB) += mbedtls_lib_crypto.o mbedtls_lib_crypto-y := \ $(MBEDTLS_LIB_DIR)/platform_util.o \ $(MBEDTLS_LIB_DIR)/constant_time.o \ - $(MBEDTLS_LIB_DIR)/md.o + $(MBEDTLS_LIB_DIR)/md.o \ + $(MBEDTLS_LIB_DIR)/entropy.o \ + $(MBEDTLS_LIB_DIR)/entropy_poll.o \ + $(MBEDTLS_LIB_DIR)/aes.o \ + $(MBEDTLS_LIB_DIR)/cipher.o \ + $(MBEDTLS_LIB_DIR)/cipher_wrap.o \ + $(MBEDTLS_LIB_DIR)/ecdh.o \ + $(MBEDTLS_LIB_DIR)/ecdsa.o \ + $(MBEDTLS_LIB_DIR)/ecp.o \ + $(MBEDTLS_LIB_DIR)/ecp_curves.o \ + $(MBEDTLS_LIB_DIR)/ecp_curves_new.o \ + $(MBEDTLS_LIB_DIR)/gcm.o \ + mbedtls_lib_crypto-$(CONFIG_$(SPL_)MD5_MBEDTLS) += $(MBEDTLS_LIB_DIR)/md5.o mbedtls_lib_crypto-$(CONFIG_$(SPL_)SHA1_MBEDTLS) += $(MBEDTLS_LIB_DIR)/sha1.o mbedtls_lib_crypto-$(CONFIG_$(SPL_)SHA256_MBEDTLS) += \ @@ -54,3 +66,22 @@ mbedtls_lib_x509-$(CONFIG_$(SPL_)X509_CERTIFICATE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/x509_crt.o mbedtls_lib_x509-$(CONFIG_$(SPL_)PKCS7_MESSAGE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/pkcs7.o + +#mbedTLS TLS support +obj-$(CONFIG_MBEDTLS_LIB_TLS) += mbedtls_lib_tls.o +mbedtls_lib_tls-y := \ + $(MBEDTLS_LIB_DIR)/mps_reader.o \ + $(MBEDTLS_LIB_DIR)/mps_trace.o \ + $(MBEDTLS_LIB_DIR)/net_sockets.o \ + $(MBEDTLS_LIB_DIR)/pk_ecc.o \ + $(MBEDTLS_LIB_DIR)/ssl_cache.o \ + $(MBEDTLS_LIB_DIR)/ssl_ciphersuites.o \ + $(MBEDTLS_LIB_DIR)/ssl_client.o \ + $(MBEDTLS_LIB_DIR)/ssl_cookie.o \ + $(MBEDTLS_LIB_DIR)/ssl_debug_helpers_generated.o \ + $(MBEDTLS_LIB_DIR)/ssl_msg.o \ + $(MBEDTLS_LIB_DIR)/ssl_ticket.o \ + $(MBEDTLS_LIB_DIR)/ssl_tls.o \ + $(MBEDTLS_LIB_DIR)/ssl_tls12_client.o \ + $(MBEDTLS_LIB_DIR)/hmac_drbg.o \ + $(MBEDTLS_LIB_DIR)/ctr_drbg.o \ diff --git a/lib/mbedtls/mbedtls_def_config.h b/lib/mbedtls/mbedtls_def_config.h index 1af911c2003f..ac8f0bbf2c0e 100644 --- a/lib/mbedtls/mbedtls_def_config.h +++ b/lib/mbedtls/mbedtls_def_config.h @@ -87,4 +87,56 @@ #endif /* #if defined CONFIG_MBEDTLS_LIB_X509 */ +#if CONFIG_IS_ENABLED(MBEDTLS_LIB_TLS) +#include "rtc.h" + +/* Generic options */ +#define MBEDTLS_ENTROPY_HARDWARE_ALT +#define MBEDTLS_HAVE_TIME +#define MBEDTLS_PLATFORM_MS_TIME_ALT +#define MBEDTLS_PLATFORM_TIME_MACRO rtc_mktime +#define MBEDTLS_PLATFORM_C +#define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_TLS_C +#define MBEDTLS_CIPHER_C +#define MBEDTLS_MD_C +#define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_AES_C +#define MBEDTLS_ENTROPY_C +#define MBEDTLS_NO_PLATFORM_ENTROPY +#define MBEDTLS_SSL_PROTO_TLS1_2 +#define MBEDTLS_SSL_SERVER_NAME_INDICATION +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + +/* RSA */ +#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +#define MBEDTLS_GCM_C + +/* ECDSA */ +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECDH_C +#define MBEDTLS_ECDSA_DETERMINISTIC +#define MBEDTLS_HMAC_DRBG_C +#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +#define MBEDTLS_CAN_ECDH +#define MBEDTLS_PK_CAN_ECDSA_SIGN +#define MBEDTLS_ECP_C +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#define MBEDTLS_ECP_DP_BP512R1_ENABLED + +#endif /* #if defined CONFIG_MBEDTLS_LIB_TLS */ + #endif /* #if defined CONFIG_MBEDTLS_LIB */ From patchwork Fri Oct 18 14:21:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 836717 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp848076wrt; Fri, 18 Oct 2024 07:23:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXfKse95UL/UuBBq5bOe2ZsxJk590quwL8Vd4P4sDQ5xb/DIWxRRE8i6Fl1gLKJhw4jIMpXaw==@linaro.org X-Google-Smtp-Source: AGHT+IEdVQteJg7qAbowLGDdpnQpD5WkRAj70s/314+3PvPPYy6ZECoA4T4Xx9Hb7q2PShi6tROV X-Received: by 2002:a05:6e02:1fe7:b0:3a0:98cd:3754 with SMTP id e9e14a558f8ab-3a3f4050209mr29079415ab.4.1729261395580; Fri, 18 Oct 2024 07:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729261395; cv=none; d=google.com; s=arc-20240605; b=RNS6Bpmlp6n5ANkK87BRvHYmbzW/+3yuGFL94HZMX+vTLmH+bSiUpBGg2Odvi4fTUp m82JwkXJCktqM+zdaiZA6SLclN31oXPxyFr8xdSbvWuDAlP2VI8rtHiNjDr+S9WIRDBV q3KdxPb6YsNnbHhr333a9ga4hCFUl1cJWFPcnv0o4xpHd8a/qdQd5nPKc6zXc3g3ypfb RJglbXxmCYAuiAKbw0+a83OLV+/Az375ddf9KcZgaeS71GKi0VcTrjqAMXKfHawa/09O S6Jgb5o5OTQggjqgVjv/usHwhfZrZkaA7mYY7zFvpj7rHlQZWPlsNoQyDlNdIV1HokJi abzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dcQxmocUYN9YZanZXFkaHkeGtaePH92QkvXfFuthaH4=; fh=52ic37292onhEb00J+FR8ocz5bEDrjSRCxLT8xLL72I=; b=Y25DhslecSGVCbqX9dmXtG9Zk4hXEj3Qbxw1y3Vl607Su4G4a2hLon1yE4BReABvdG kU0rxAt3r2z/DYKFP9TxrIt7Iq+U/EBnT6O/iHrliQv3kyY1elxKKi1B3FzZ6PCWMAhs xGumKEC1TPvmjVu3Oi9cusNZbndpn4y1z87jq16GtSbcoGJxUO0SZdLz1V/kZQsuU5Y5 KqXQ4SsE5L7fmmkUW10HwPrXbX9I4opUr+DNGH9WbUYyyKcjGaM7fS+5BJONXV7xf6EI ZxTUJ2llHybjRus3EYA4GS2ekTfqNBS2dJk+Cofs3wb1PtXBWfORgXpBWeGpQpp6PvgP Mc4g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="VxJLNi3/"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a3f40374dbsi7816785ab.123.2024.10.18.07.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:15 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="VxJLNi3/"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99E5B89206; Fri, 18 Oct 2024 16:23:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="VxJLNi3/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2564489201; Fri, 18 Oct 2024 16:23:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 57F9988B23 for ; Fri, 18 Oct 2024 16:22:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-37d3ecad390so2376651f8f.1 for ; Fri, 18 Oct 2024 07:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729261376; x=1729866176; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dcQxmocUYN9YZanZXFkaHkeGtaePH92QkvXfFuthaH4=; b=VxJLNi3/E8C/kEYQK/3dm1+CCvCWfsbHoG7Q3uqWuq5MoNwnI9IVbmkF08c1CFyjjc Cm1WrB9ndFB31PHCa5Fqav6j+BOF36u0C4Ht21oYMUc6cSAIW5xpztZ9kMH3pcBSjR6l LpBXfXeEiuJbZugtGwCaRhOVTK6HOstd/CHbjNb7CBlB6CHqM4Z/IG83vsKjaeZCXvDJ jxCqu0RY7+2w9qEPJdDN5mKqWp3QXbwtJ+Xdln5o5kJ67aSJvEqOT0XoLze2HkbHKBoT tda/PjjDoiusf8oTwRe5mWCcO1uJY93YRBM6q+S7C/sICo2kbQk39qMfRkdyrFeO7mg1 7cZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729261376; x=1729866176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dcQxmocUYN9YZanZXFkaHkeGtaePH92QkvXfFuthaH4=; b=jZ1FdM/KdsSL1aUfdICltw+kkvQv5d7uF7GgGj/1uNP9Y/ysYVm+ex+68IsyFWYtgb xnmRIgTlRiJw9yVBw2/EWtM9RDkyl66PbSagBASrLRUgd7tax+M9UDv3xXIR3BYQW0QC csANnPoP150tIqlMx4qk/ru9s5z/b1EiN5Okz3tBhzTXGdAuwlIsYgM0fc5ZT0pQWd9u l8w0KtnR/fZX5Nq+iYAU69NKcbgkzWELrDIZ0NeuVT8U7BtW34bNJKc5o3Q1nggJECKk NC9fdPv8Ull/AeDkytWOQVuSG0/PWJy1lPA4NJY9UARmKXQJmD9SFMnpxpqSgWRfw/d8 rnHA== X-Forwarded-Encrypted: i=1; AJvYcCU5RGWhoJFRyb6lAMZ2nUPqT53u6Lc50ArEE54hYGPZ+VmYciLVJS4JpJxuEQjPHO+eaiBHRgw=@lists.denx.de X-Gm-Message-State: AOJu0Ywbdcj0drzPUBz1+42HIC/MLhEaUwqxUSsIWkYJ0CqKYdq9cPZG Iz/3ItTwWqntfzX0u2vc/pd+dWXyOtjhD48LlPfrfyI1L3LvajtGFu06u1+XXoc= X-Received: by 2002:a5d:5045:0:b0:37d:460d:2d07 with SMTP id ffacd0b85a97d-37d93d75a1cmr4819543f8f.10.1729261375594; Fri, 18 Oct 2024 07:22:55 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316067dc70sm28781665e9.10.2024.10.18.07.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:22:54 -0700 (PDT) From: Ilias Apalodimas To: jerome.forissier@linaro.org, raymond.mao@linaro.org Cc: xypron.glpk@gmx.de, Javier Tia , Ilias Apalodimas , Tom Rini , Joe Hershberger , Ramon Fried , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Wei Ming Chen , Jonathan Humphreys , Caleb Connolly , Masahisa Kojima , u-boot@lists.denx.de Subject: [PATCH 2/6] net: lwip: Update lwIP for mbedTLS > 3.0 support and enable https Date: Fri, 18 Oct 2024 17:21:56 +0300 Message-ID: <20241018142235.715571-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018142235.715571-1-ilias.apalodimas@linaro.org> References: <20241018142235.715571-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Javier Tia The current code support mbedTLS 2.28. Since we are using a newer version in U-Boot, update the necessary accessors and the lwIP codebase to work with mbedTLS 3.6.0. It's worth noting that the patches are already sent to lwIP [0] While at it enable LWIP_ALTCP_TLS and enable TLS support in lwIP [0] https://github.com/lwip-tcpip/lwip/pull/47 Signed-off-by: Javier Tia Signed-off-by: Ilias Apalodimas --- lib/lwip/Makefile | 3 ++ .../src/apps/altcp_tls/altcp_tls_mbedtls.c | 39 ++++++++++++------- lib/lwip/lwip/src/core/tcp_out.c | 10 +---- lib/lwip/u-boot/lwipopts.h | 6 +++ 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile index dfcd700ca474..19e5c6897f5a 100644 --- a/lib/lwip/Makefile +++ b/lib/lwip/Makefile @@ -53,3 +53,6 @@ obj-y += \ lwip/src/core/timeouts.o \ lwip/src/core/udp.o \ lwip/src/netif/ethernet.o + +obj-$(CONFIG_MBEDTLS_LIB_TLS) += lwip/src/apps/altcp_tls/altcp_tls_mbedtls.o \ + lwip/src/apps/altcp_tls/altcp_tls_mbedtls_mem.o diff --git a/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c b/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c index a8c2fc2ee2cd..ef19821b89e0 100644 --- a/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c +++ b/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c @@ -3,7 +3,7 @@ * Application layered TCP/TLS connection API (to be used from TCPIP thread) * * This file provides a TLS layer using mbedTLS - * + * * This version is currently compatible with the 2.x.x branch (current LTS). */ @@ -70,7 +70,6 @@ /* @todo: which includes are really needed? */ #include "mbedtls/entropy.h" #include "mbedtls/ctr_drbg.h" -#include "mbedtls/certs.h" #include "mbedtls/x509.h" #include "mbedtls/ssl.h" #include "mbedtls/net_sockets.h" @@ -81,8 +80,6 @@ #include "mbedtls/ssl_cache.h" #include "mbedtls/ssl_ticket.h" -#include "mbedtls/ssl_internal.h" /* to call mbedtls_flush_output after ERR_MEM */ - #include #ifndef ALTCP_MBEDTLS_ENTROPY_PTR @@ -132,6 +129,16 @@ static err_t altcp_mbedtls_lower_recv_process(struct altcp_pcb *conn, altcp_mbed static err_t altcp_mbedtls_handle_rx_appldata(struct altcp_pcb *conn, altcp_mbedtls_state_t *state); static int altcp_mbedtls_bio_send(void *ctx, const unsigned char *dataptr, size_t size); +static void +altcp_mbedtls_flush_output(altcp_mbedtls_state_t *state) +{ + if (state->ssl_context.MBEDTLS_PRIVATE(out_left) != 0) { + int flushed = mbedtls_ssl_send_alert_message(&state->ssl_context, 0, 0); + if (flushed) { + LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_send_alert_message failed: %d\n", flushed)); + } + } +} /* callback functions from inner/lower connection: */ @@ -524,14 +531,14 @@ altcp_mbedtls_lower_sent(void *arg, struct altcp_pcb *inner_conn, u16_t len) LWIP_ASSERT("state", state != NULL); LWIP_ASSERT("pcb mismatch", conn->inner_conn == inner_conn); /* calculate TLS overhead part to not send it to application */ - overhead = state->overhead_bytes_adjust + state->ssl_context.out_left; + overhead = state->overhead_bytes_adjust + state->ssl_context.MBEDTLS_PRIVATE(out_left); if ((unsigned)overhead > len) { overhead = len; } /* remove ACKed bytes from overhead adjust counter */ state->overhead_bytes_adjust -= len; /* try to send more if we failed before (may increase overhead adjust counter) */ - mbedtls_ssl_flush_output(&state->ssl_context); + altcp_mbedtls_flush_output(state); /* remove calculated overhead from ACKed bytes len */ app_len = len - (u16_t)overhead; /* update application write counter and inform application */ @@ -559,7 +566,7 @@ altcp_mbedtls_lower_poll(void *arg, struct altcp_pcb *inner_conn) if (conn->state) { altcp_mbedtls_state_t *state = (altcp_mbedtls_state_t *)conn->state; /* try to send more if we failed before */ - mbedtls_ssl_flush_output(&state->ssl_context); + altcp_mbedtls_flush_output(state); if (altcp_mbedtls_handle_rx_appldata(conn, state) == ERR_ABRT) { return ERR_ABRT; } @@ -683,7 +690,7 @@ altcp_tls_set_session(struct altcp_pcb *conn, struct altcp_tls_session *session) if (session && conn && conn->state) { altcp_mbedtls_state_t *state = (altcp_mbedtls_state_t *)conn->state; int ret = -1; - if (session->data.start) + if (session->data.MBEDTLS_PRIVATE(start)) ret = mbedtls_ssl_set_session(&state->ssl_context, &session->data); return ret < 0 ? ERR_VAL : ERR_OK; } @@ -776,7 +783,7 @@ altcp_tls_create_config(int is_server, u8_t cert_count, u8_t pkey_count, int hav struct altcp_tls_config *conf; mbedtls_x509_crt *mem; - if (TCP_WND < MBEDTLS_SSL_MAX_CONTENT_LEN) { + if (TCP_WND < MBEDTLS_SSL_IN_CONTENT_LEN || TCP_WND < MBEDTLS_SSL_OUT_CONTENT_LEN) { LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG|LWIP_DBG_LEVEL_SERIOUS, ("altcp_tls: TCP_WND is smaller than the RX decrypion buffer, connection RX might stall!\n")); } @@ -900,7 +907,7 @@ err_t altcp_tls_config_server_add_privkey_cert(struct altcp_tls_config *config, return ERR_VAL; } - ret = mbedtls_pk_parse_key(pkey, (const unsigned char *) privkey, privkey_len, privkey_pass, privkey_pass_len); + ret = mbedtls_pk_parse_key(pkey, (const unsigned char *) privkey, privkey_len, privkey_pass, privkey_pass_len, mbedtls_ctr_drbg_random, &altcp_tls_entropy_rng->ctr_drbg); if (ret != 0) { LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_pk_parse_public_key failed: %d\n", ret)); mbedtls_x509_crt_free(srvcert); @@ -1003,7 +1010,7 @@ altcp_tls_create_config_client_2wayauth(const u8_t *ca, size_t ca_len, const u8_ } mbedtls_pk_init(conf->pkey); - ret = mbedtls_pk_parse_key(conf->pkey, privkey, privkey_len, privkey_pass, privkey_pass_len); + ret = mbedtls_pk_parse_key(conf->pkey, privkey, privkey_len, privkey_pass, privkey_pass_len, mbedtls_ctr_drbg_random, &altcp_tls_entropy_rng->ctr_drbg); if (ret != 0) { LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_pk_parse_key failed: %d 0x%x\n", ret, -1*ret)); altcp_tls_free_config(conf); @@ -1189,7 +1196,7 @@ altcp_mbedtls_sndbuf(struct altcp_pcb *conn) size_t ret; #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /* @todo: adjust ssl_added to real value related to negotiated cipher */ - size_t max_frag_len = mbedtls_ssl_get_max_frag_len(&state->ssl_context); + size_t max_frag_len = mbedtls_ssl_get_max_in_record_payload(&state->ssl_context); max_len = LWIP_MIN(max_frag_len, max_len); #endif /* Adjust sndbuf of inner_conn with what added by SSL */ @@ -1232,9 +1239,9 @@ altcp_mbedtls_write(struct altcp_pcb *conn, const void *dataptr, u16_t len, u8_t /* HACK: if there is something left to send, try to flush it and only allow sending more if this succeeded (this is a hack because neither returning 0 nor MBEDTLS_ERR_SSL_WANT_WRITE worked for me) */ - if (state->ssl_context.out_left) { - mbedtls_ssl_flush_output(&state->ssl_context); - if (state->ssl_context.out_left) { + if (state->ssl_context.MBEDTLS_PRIVATE(out_left)) { + altcp_mbedtls_flush_output(state); + if (state->ssl_context.MBEDTLS_PRIVATE(out_left)) { return ERR_MEM; } } @@ -1284,6 +1291,8 @@ altcp_mbedtls_bio_send(void *ctx, const unsigned char *dataptr, size_t size) while (size_left) { u16_t write_len = (u16_t)LWIP_MIN(size_left, 0xFFFF); err_t err = altcp_write(conn->inner_conn, (const void *)dataptr, write_len, apiflags); + /* try to send data... */ + altcp_output(conn->inner_conn); if (err == ERR_OK) { written += write_len; size_left -= write_len; diff --git a/lib/lwip/lwip/src/core/tcp_out.c b/lib/lwip/lwip/src/core/tcp_out.c index 64579ee5cbd8..b5d312137368 100644 --- a/lib/lwip/lwip/src/core/tcp_out.c +++ b/lib/lwip/lwip/src/core/tcp_out.c @@ -1255,14 +1255,6 @@ tcp_output(struct tcp_pcb *pcb) LWIP_ASSERT("don't call tcp_output for listen-pcbs", pcb->state != LISTEN); - /* First, check if we are invoked by the TCP input processing - code. If so, we do not output anything. Instead, we rely on the - input processing code to call us when input processing is done - with. */ - if (tcp_input_pcb == pcb) { - return ERR_OK; - } - wnd = LWIP_MIN(pcb->snd_wnd, pcb->cwnd); seg = pcb->unsent; @@ -2036,7 +2028,7 @@ tcp_rst(const struct tcp_pcb *pcb, u32_t seqno, u32_t ackno, u16_t local_port, u16_t remote_port) { struct pbuf *p; - + p = tcp_rst_common(pcb, seqno, ackno, local_ip, remote_ip, local_port, remote_port); if (p != NULL) { tcp_output_control_segment(pcb, p, local_ip, remote_ip); diff --git a/lib/lwip/u-boot/lwipopts.h b/lib/lwip/u-boot/lwipopts.h index 9d618625facb..88d6faf327ae 100644 --- a/lib/lwip/u-boot/lwipopts.h +++ b/lib/lwip/u-boot/lwipopts.h @@ -154,4 +154,10 @@ #define MEMP_MEM_INIT 1 #define MEM_LIBC_MALLOC 1 +#if defined(CONFIG_MBEDTLS_LIB_TLS) +#define LWIP_ALTCP 1 +#define LWIP_ALTCP_TLS 1 +#define LWIP_ALTCP_TLS_MBEDTLS 1 +#endif + #endif /* LWIP_UBOOT_LWIPOPTS_H */ From patchwork Fri Oct 18 14:21:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 836718 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp848150wrt; Fri, 18 Oct 2024 07:23:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVz44+ne8Ub4kVNmV7OmXsLRg0XhZqKbFXtbdc1CrfKkFBB4ctQW5bdZKVvGcMyIds+BbKGYQ==@linaro.org X-Google-Smtp-Source: AGHT+IGlHC6Muw1gqaS1bYVQ/4Cdd1ssvFcJ4SsOR1NYGlOR2eOvgA867QrutllNuGorsJ2M88Q8 X-Received: by 2002:a05:6602:2c83:b0:832:13ce:1fa3 with SMTP id ca18e2360f4ac-83aba62260amr333703239f.8.1729261405030; Fri, 18 Oct 2024 07:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729261405; cv=none; d=google.com; s=arc-20240605; b=XAOhOoaa3gd2qWZaYtZmaY5+MqFno5wzGpD3d2kghGxSj82VIqAKBqZfS0tjY9Op+f VYYLfhUY3fy3iGD/6d2sfpdq8rD8lDLa20aTRiZUblXAqPoGPvtl3zGabgrxW6DG148m umf2J8+UlMP/bUWH63gKyqz7cGLzvoy6ai01IWAnJnnXTirk0qan3AIfjgQ8Bhgd9dV9 jCMvJJdZuduviuzOFa0xCDzilNQOmi6xAABuwXykY+TqTsh8T9F1B685ABQDxnsm8jvs XyV59ImJ/M2A0DsJuNA+TJsuC8lpiVRt/2agr+5tXvvG7E6qBN20D9VkODhP62SOy+aB j99Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kcu8YE5sVDxrapWp+sBeZLFxERfJYVHXUsD7NwBjx6k=; fh=IrphToqrcc7P+yS3l2tZeFPt6PP6dkjJAgZR29aHgL4=; b=b+tEFZRsyX1/cp/rycwt5l+YAmxgcUJ0Kwrukz7rPmPs+uXWegzDGE8zEJUskiPGUJ 6F27WrK10f/Emb2KsH4tIUB2smhd9Wdyzs84x2RECpjkQTJMSRYcxaGa4K2WsTnIjHpn j5k7x9Fmg2OIccykODvEUNhdewJwLMNxOD5vqu4YYldM9dQlijgVN+uZa7koT3wxscD2 Xi1Tr6y8xcfXAjqtNSt7JzvAp7LXnfKN8aSTbw4YN33MDkuVGI0MGqJDzQUqjmSwV1VM arrb5kDFkvNwdVVxHUdOZOuam06bbznm+0hYyy+x72KqakAS4pB2JZvyqzt9LN2HVXvU lexA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H9vOB6gq; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4dc10c2b9c4si875083173.101.2024.10.18.07.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:25 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H9vOB6gq; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0EC5989128; Fri, 18 Oct 2024 16:23:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="H9vOB6gq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 01D5B88FA4; Fri, 18 Oct 2024 16:23:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 90EB4891E7 for ; Fri, 18 Oct 2024 16:23:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4305413aec9so22895175e9.2 for ; Fri, 18 Oct 2024 07:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729261382; x=1729866182; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kcu8YE5sVDxrapWp+sBeZLFxERfJYVHXUsD7NwBjx6k=; b=H9vOB6gqOnkP4SB6xbS3B39/AKrVkxxr60COayiM7KGMJ3fTF2evQ7KVclSSFnDA1c +/ktjuPDVz9oEEihtKSpDO2K3ym5tVb825ZNqxLbglr7F8XImeDlL9ONOnGVg67U92lj 2ZTaYf8F2GCH0CdnlnU3KgXNJGs8VsHlFc8PXGmr7EDqWUwe/DwY4mZKNCdTYu/ArFBf iwwf5+6B074Rta0Dea5hvUEpo6S633hd3c2gX2MWSLg272LMNAjx6x7JCmBcv1khcrCs kcEt/4y3fVTqei7yWDO7edfcL7AQcuf0WhdGf7EoQKAOHU8jx//mCJ0IKqjQg68UOs7z zxHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729261382; x=1729866182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kcu8YE5sVDxrapWp+sBeZLFxERfJYVHXUsD7NwBjx6k=; b=Sv9MrBBxlCc8+X74wH2Lj5xt/Jfqckvt0Uxs2I59+1aYtiKz5igY3FoRYoKM3tpBei kWWtTLBRfpsWX0SQn5gfTuCsb2QrHsXlw4a8dERNkY5oHVDyNM0kdX61MDElKPvOcOMi GaZa7WcKMEC2+a8DAWb0C50wZwFxeXzqriJyQLbxWP7SIELqgczyscgC72vUuMFtEiPt BgFJgT6JCoAYZBVlZOoHpi4aTCEz8ruYFUYIpaKsI4upXp2bnJJ9p3J6Js7dvNkkLbDP lkk1sYfot4Y1ujYwhyWA/u0dF+CynpvbJ2ewYH8oc0SsDoTGVGFEaq9jFZpYca1KBAFy Wn3Q== X-Forwarded-Encrypted: i=1; AJvYcCW9dZHPargya1/tsQxTwD5BG54+KJKC+DERdqpNPQbiZC9+Osok4oaj4g6MATaQ/NOkV4LIuQ4=@lists.denx.de X-Gm-Message-State: AOJu0Yy6qqZxTld4tv4u8HJjK7vUYiZoRXuzAD6K7pzfzsQ3/XtCMYh1 PO4XoDWMF5JdHrAQxO9jVyz3zFFl9GqmM5/eF8hzFzZvRWKvhI7VysqOE/zYa8A= X-Received: by 2002:a05:600c:1d1a:b0:430:5654:45d0 with SMTP id 5b1f17b1804b1-431616418c0mr22389835e9.14.1729261381963; Fri, 18 Oct 2024 07:23:01 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316067dc70sm28781665e9.10.2024.10.18.07.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:01 -0700 (PDT) From: Ilias Apalodimas To: jerome.forissier@linaro.org, raymond.mao@linaro.org Cc: xypron.glpk@gmx.de, Javier Tia , Ilias Apalodimas , Tom Rini , Joe Hershberger , Ramon Fried , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Wei Ming Chen , Jonathan Humphreys , Masahisa Kojima , Caleb Connolly , u-boot@lists.denx.de Subject: [PATCH 3/6] net: lwip: Add Support Server Name Indication support Date: Fri, 18 Oct 2024 17:21:57 +0300 Message-ID: <20241018142235.715571-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018142235.715571-1-ilias.apalodimas@linaro.org> References: <20241018142235.715571-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Javier Tia SNI, or Server Name Indication, is an addition to the TLS encryption protocol that enables a client device to specify the domain name it is trying to reach in the first step of the TLS handshake, preventing common name mismatch errors and not reaching to HTTPS server that enforce this condition. Since most of the websites require it nowadays add support for it. It's worth noting that this is already sent to lwIP [0] [0] https://github.com/lwip-tcpip/lwip/pull/47 Signed-off-by: Javier Tia Signed-off-by: Ilias Apalodimas --- lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c | 11 +++++++---- lib/lwip/lwip/src/include/lwip/altcp_tls.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c b/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c index ef19821b89e0..24b432966312 100644 --- a/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c +++ b/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c @@ -106,6 +106,7 @@ struct altcp_tls_config { u8_t pkey_count; u8_t pkey_max; mbedtls_x509_crt *ca; + char host[256]; #if defined(MBEDTLS_SSL_CACHE_C) && ALTCP_MBEDTLS_USE_SESSION_CACHE /** Inter-connection cache for fast connection startup */ struct mbedtls_ssl_cache_context cache; @@ -642,6 +643,7 @@ altcp_mbedtls_setup(void *conf, struct altcp_pcb *conn, struct altcp_pcb *inner_ /* tell mbedtls about our I/O functions */ mbedtls_ssl_set_bio(&state->ssl_context, conn, altcp_mbedtls_bio_send, altcp_mbedtls_bio_recv, NULL); + mbedtls_ssl_set_hostname(&state->ssl_context, config->host); altcp_mbedtls_setup_callbacks(conn, inner_conn); conn->inner_conn = inner_conn; conn->fns = &altcp_mbedtls_functions; @@ -951,7 +953,7 @@ altcp_tls_create_config_server_privkey_cert(const u8_t *privkey, size_t privkey_ } static struct altcp_tls_config * -altcp_tls_create_config_client_common(const u8_t *ca, size_t ca_len, int is_2wayauth) +altcp_tls_create_config_client_common(const u8_t *ca, size_t ca_len, int is_2wayauth, char *host) { int ret; struct altcp_tls_config *conf = altcp_tls_create_config(0, (is_2wayauth) ? 1 : 0, (is_2wayauth) ? 1 : 0, ca != NULL); @@ -973,13 +975,14 @@ altcp_tls_create_config_client_common(const u8_t *ca, size_t ca_len, int is_2way mbedtls_ssl_conf_ca_chain(&conf->conf, conf->ca, NULL); } + memcpy(conf->host, host, sizeof(conf->host)); return conf; } struct altcp_tls_config * -altcp_tls_create_config_client(const u8_t *ca, size_t ca_len) +altcp_tls_create_config_client(const u8_t *ca, size_t ca_len, char *host) { - return altcp_tls_create_config_client_common(ca, ca_len, 0); + return altcp_tls_create_config_client_common(ca, ca_len, 0, host); } struct altcp_tls_config * @@ -995,7 +998,7 @@ altcp_tls_create_config_client_2wayauth(const u8_t *ca, size_t ca_len, const u8_ return NULL; } - conf = altcp_tls_create_config_client_common(ca, ca_len, 1); + conf = altcp_tls_create_config_client_common(ca, ca_len, 1, NULL); if (conf == NULL) { return NULL; } diff --git a/lib/lwip/lwip/src/include/lwip/altcp_tls.h b/lib/lwip/lwip/src/include/lwip/altcp_tls.h index fcb784d89d70..fb0618234481 100644 --- a/lib/lwip/lwip/src/include/lwip/altcp_tls.h +++ b/lib/lwip/lwip/src/include/lwip/altcp_tls.h @@ -92,7 +92,7 @@ struct altcp_tls_config *altcp_tls_create_config_server_privkey_cert(const u8_t /** @ingroup altcp_tls * Create an ALTCP_TLS client configuration handle */ -struct altcp_tls_config *altcp_tls_create_config_client(const u8_t *cert, size_t cert_len); +struct altcp_tls_config *altcp_tls_create_config_client(const u8_t *cert, size_t cert_len, char *host); /** @ingroup altcp_tls * Create an ALTCP_TLS client configuration handle with two-way server/client authentication From patchwork Fri Oct 18 14:21:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 836719 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp848235wrt; Fri, 18 Oct 2024 07:23:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVg7iPqCzJOXXj9XJN1vNFWWAqJWvqxxs5bP4+7fsHO5ds/xDuNgnlrq7X7550uhvx3s0a4Uw==@linaro.org X-Google-Smtp-Source: AGHT+IFhd4WjticdIkH9lKJ5kN5F8PA0wLmM1sdU3ErIOEq3s3IwDOJvg+S2EYTEMwUAQ55VpKh8 X-Received: by 2002:a92:8750:0:b0:3a3:f83c:9143 with SMTP id e9e14a558f8ab-3a3f83c9289mr2682825ab.11.1729261414567; Fri, 18 Oct 2024 07:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729261414; cv=none; d=google.com; s=arc-20240605; b=C6YJ8b5QtGS1LD3Xldg/a08CsmxrTpGYkuZTC7XhsCU0Id5+Om70Cebz5QIg4TDyMy 782phy4PI4V8+0xRKlizYZCVzjtwDiy3k02aDvA3/4PsgfpQdkAGWK3QaPrUc2gdQDJK HltbXY6BwZMdnjtFNtsepzAvbi2bvFm60rQgxUZlwC4jzTl6MyzoiA32NINYUfCHG5Vm 3aJhuwCIS3D5NcJSzGhjV3fBsPsI1KeZHMTIS8zmFCsyBSX8CaHM8Q7MUxCRlhGXvclw UdamkMbLm3EZf6pCbZ6se6vae+gJrgHaZq1c2Ptkm/i07zqiIYyf85h5QnI7yiFXGrKd luKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pCU7nA8SvaZ2L8wUys7hUgWu2VDwSSg5urQxqoVo4kA=; fh=K4I7uLKKETedYR+RjhTtiHC72sa3kTAKT7q3+CrqcUY=; b=k2z/tSfhmz+08Xh6/X3HmUr3+fDM6rhMpKh0k+mEt86oqKY0D0rNI2cXw4JJRHLuC9 b6hsjalwjOMw/8kWv7cbaachMwRMYBlQGplRY2MMRf6UxRpUpOadhMBo72HSFrRw77tR AlBmZ6qSvu+eguY0IRiuZLDO+SyqgrA64cpBIiup8pG57tPfHuB7M6HwBb3Zqr0JuGkf 110PZmYBwB1hB8CSFjxFueWzn1jBP7ZGrJ/s5BYFAkOqyemswlZ9Qhs6db83E9WK0RLE w1Vydq2HVs11uDf4xuBwsrOrUJKrvWENloafEuTnj2JpKNq0YDo9VOf3nkAhRmAg8JPo p/vw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zyWsYDlr; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a3f404c9f3si7281725ab.179.2024.10.18.07.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zyWsYDlr; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A60D88995; Fri, 18 Oct 2024 16:23:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zyWsYDlr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48EB1890A9; Fri, 18 Oct 2024 16:23:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C29AA89214 for ; Fri, 18 Oct 2024 16:23:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43161e7bb25so6992615e9.2 for ; Fri, 18 Oct 2024 07:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729261388; x=1729866188; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pCU7nA8SvaZ2L8wUys7hUgWu2VDwSSg5urQxqoVo4kA=; b=zyWsYDlrMKUPhSude3UPI3iw9l0FVcTtmP12/WVjSgLeAkOL5IM1qowmRbwqHGxpLu 05rP3k7m4mFKv1JmtRFsqFjaLOaAAdLqT2X6zkqLD+67QUYJFO/QY2+Nsf9bt6CVePR/ c2D/yaJRkQySdUeospAy9+OyQ+D0xCNExgCkDJxk0Pov9wDMN4uC/ezOPRSeA1jyiCx+ puoyq0LQIogbvWydrj/4r8iWZ9+ti6w75Mgn8B7tHt7EcU87s4PSln8xyFHIfR3mzCB0 /YnpBjjEcujVs8l6lmIv8g1axERQr9QfDF0xgpkvkDxMcK+fmX9ZN1GAZWQYjYOHj8/o 8EGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729261388; x=1729866188; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pCU7nA8SvaZ2L8wUys7hUgWu2VDwSSg5urQxqoVo4kA=; b=IkrLB7OU4vE8BAcffeDT02PnARgvGuzjgkpOW94Ljk8QeqwV713BQnS2CipHzOrLZE rMsLiTtN2mV+bKq8vilwK9XKDkrUMfZxoEV55GSxGKS7blj9upjFK42BFaZiLfXaGh8D aVt8Qzzx+N/28uDaOpllvObKaWoeaiM+slMDVBc+PSanA5iiaKTo0N/ycuU43UcF6t1Q gsBvNmsF1tr1c/+e3Cw7hKuW34tFafOSG28e/uXA95eXMvztWB+St+TiHavGEp578iMX IwAYTkCc5rf+n3yfzYXqJI+9j8oKPxzecvSh+EgayGTkir9DaNueuZ8czOOAJKGux6dV zJhg== X-Forwarded-Encrypted: i=1; AJvYcCUKaVUcl5OKVy9sU7q1HyBVB+0K2Yzv9AZJ06it5lle8GDbYsvyzmhGfUiQL/QvK963ZDo8sfA=@lists.denx.de X-Gm-Message-State: AOJu0YwcVDnVIgj56XQgFGXQwLkbymIZ4JVypVdlxds7K/30pJSK/ZeU mNIgbH2AE/Kwao4CLz+JfP5PIl8x4ocSLLfjtV05sQwrabBzRSLKEX8emY/r6A4= X-Received: by 2002:a05:600c:3b05:b0:431:5e53:2dc4 with SMTP id 5b1f17b1804b1-4316163612bmr22730135e9.6.1729261388126; Fri, 18 Oct 2024 07:23:08 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316067dc70sm28781665e9.10.2024.10.18.07.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:07 -0700 (PDT) From: Ilias Apalodimas To: jerome.forissier@linaro.org, raymond.mao@linaro.org Cc: xypron.glpk@gmx.de, Ilias Apalodimas , Tom Rini , Joe Hershberger , Ramon Fried , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Jonathan Humphreys , Wei Ming Chen , Masahisa Kojima , Caleb Connolly , Javier Tia , u-boot@lists.denx.de Subject: [PATCH 4/6] net: lwip: Enable https:// support for wget Date: Fri, 18 Oct 2024 17:21:58 +0300 Message-ID: <20241018142235.715571-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018142235.715571-1-ilias.apalodimas@linaro.org> References: <20241018142235.715571-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean With the recent changes of lwip & mbedTLS we can now download from https:// urls instead of just http://. Adjust our wget lwip version parsing to support both URLs. While at it adjust the default TCP window for QEMU since https seems to requite at least 16384 Signed-off-by: Ilias Apalodimas --- cmd/Kconfig | 19 ++++++++++++ net/lwip/Kconfig | 2 +- net/lwip/wget.c | 78 +++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 91 insertions(+), 8 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 8c677b1e4864..e58566a9ba34 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2118,6 +2118,25 @@ config CMD_WGET wget is a simple command to download kernel, or other files, from a http server over TCP. +config WGET_HTTPS + bool "wget https" + depends on CMD_WGET + depends on PROT_TCP_LWIP + depends on MBEDTLS_LIB + select SHA256 + select RSA + select ASYMMETRIC_KEY_TYPE + select ASYMMETRIC_PUBLIC_KEY_SUBTYPE + select X509_CERTIFICATE_PARSER + select PKCS7_MESSAGE_PARSER + select MBEDTLS_LIB_CRYPTO + select MBEDTLS_LIB_TLS + select RSA_VERIFY_WITH_PKEY + select X509_CERTIFICATE_PARSER + select PKCS7_MESSAGE_PARSER + help + Enable TLS over http for wget. + endif # if CMD_NET config CMD_PXE diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig index 8a67de4cf335..a9ae9bf7fa2a 100644 --- a/net/lwip/Kconfig +++ b/net/lwip/Kconfig @@ -37,7 +37,7 @@ config PROT_UDP_LWIP config LWIP_TCP_WND int "Value of TCP_WND" - default 8000 if ARCH_QEMU + default 32768 if ARCH_QEMU default 3000000 help Default value for TCP_WND in the lwIP configuration diff --git a/net/lwip/wget.c b/net/lwip/wget.c index b495ebd1aa96..b4f039d38962 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -7,13 +7,17 @@ #include #include #include +#include "lwip/altcp_tls.h" #include +#include #include #include #include +#include #define SERVER_NAME_SIZE 200 #define HTTP_PORT_DEFAULT 80 +#define HTTPS_PORT_DEFAULT 443 #define PROGRESS_PRINT_STEP_BYTES (100 * 1024) enum done_state { @@ -32,18 +36,53 @@ struct wget_ctx { enum done_state done; }; +bool wget_validate_uri(char *uri); + +int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, + size_t *olen) +{ + struct udevice *dev; + u64 rng = 0; + int err; + + *olen = 0; + + err = uclass_get_device(UCLASS_RNG, 0, &dev); + if (err) + return err; + err = dm_rng_read(dev, &rng, sizeof(rng)); + if (err) { + log_err("Failed to get an rng: %d\n", err); + return err; + } + + memcpy(output, &rng, len); + *olen = sizeof(rng); + + return 0; +} + static int parse_url(char *url, char *host, u16 *port, char **path) { char *p, *pp; long lport; + size_t prefix_len = 0; + + if (!wget_validate_uri(url)) { + log_err("Invalid URL. Use http(s)://\n"); + return -EINVAL; + } + *port = HTTP_PORT_DEFAULT; + prefix_len = strlen("http://"); p = strstr(url, "http://"); if (!p) { - log_err("only http:// is supported\n"); - return -EINVAL; + p = strstr(url, "https://"); + prefix_len = strlen("https://"); + *port = HTTPS_PORT_DEFAULT; } - p += strlen("http://"); + p += prefix_len; /* Parse hostname */ pp = strchr(p, ':'); @@ -67,9 +106,8 @@ static int parse_url(char *url, char *host, u16 *port, char **path) if (lport > 65535) return -EINVAL; *port = (u16)lport; - } else { - *port = HTTP_PORT_DEFAULT; } + if (*pp != '/') return -EINVAL; *path = pp; @@ -210,6 +248,9 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result, static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) { char server_name[SERVER_NAME_SIZE]; +#if defined CONFIG_WGET_HTTPS + altcp_allocator_t tls_allocator; +#endif httpc_connection_t conn; httpc_state_t *state; struct netif *netif; @@ -232,6 +273,22 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) return -1; memset(&conn, 0, sizeof(conn)); +#if defined CONFIG_WGET_HTTPS + if (port == HTTPS_PORT_DEFAULT) { + tls_allocator.alloc = &altcp_tls_alloc; + tls_allocator.arg = + altcp_tls_create_config_client(NULL, 0, server_name); + + if (!tls_allocator.arg) { + log_err("error: Cannot create a TLS connection\n"); + net_lwip_remove_netif(netif); + return -1; + } + + conn.altcp_allocator = &tls_allocator; + } +#endif + conn.result_fn = httpc_result_cb; ctx.path = path; if (httpc_get_file_dns(server_name, port, path, &conn, httpc_recv_cb, @@ -316,6 +373,7 @@ bool wget_validate_uri(char *uri) char c; bool ret = true; char *str_copy, *s, *authority; + size_t prefix_len = 0; for (c = 0x1; c < 0x21; c++) { if (strchr(uri, c)) { @@ -323,15 +381,21 @@ bool wget_validate_uri(char *uri) return false; } } + if (strchr(uri, 0x7f)) { log_err("invalid character is used\n"); return false; } - if (strncmp(uri, "http://", 7)) { - log_err("only http:// is supported\n"); + if (!strncmp(uri, "http://", strlen("http://"))) { + prefix_len = strlen("http://"); + } else if (!strncmp(uri, "https://", strlen("https://"))) { + prefix_len = strlen("https://"); + } else { + log_err("only http(s):// is supported\n"); return false; } + str_copy = strdup(uri); if (!str_copy) return false; From patchwork Fri Oct 18 14:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 836720 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp848306wrt; Fri, 18 Oct 2024 07:23:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUtRj91ytB8Z/U62HEj5WhruhAj546PclaQ4PR+hV8XFWRq6+ig7O2+oaaTiU+wga092BMQHg==@linaro.org X-Google-Smtp-Source: AGHT+IHgJHGBGb1jHkQrRnnfh+veivFaFJiAEH0Nk2N2i8r6tyPWev8p4TfD+5/Amo8bfXgcVzZt X-Received: by 2002:a05:6e02:1aaa:b0:3a0:9aef:4d0 with SMTP id e9e14a558f8ab-3a3f404facemr27161495ab.5.1729261423635; Fri, 18 Oct 2024 07:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729261423; cv=none; d=google.com; s=arc-20240605; b=K5MAHnpF3pIgTm+f2a07h7YSBamqY8r+Rj0N53jjZA5y46dJBDBzhGxyMQD++u9T1g JIR81z+w0vNw/Djl/Xjo+d2FYVhZvn0j+EJin/SINVQoJAuFlob7yhBy9E3jUobIWDCm JtqMuQBtqQnnXiR4EYPMA/DhYL1duL8+mngvGOS/zXfYodJigOWrDdAwr2Y0eoNnwpMF SX2Zb1zJIHwAbtxLBwcvhWGk7EiY2IO2rIVR/74o6ct+cJaDc7Z+u/600mPeUVmbHZNb i/ijOEQMAXl2GyMCUPC5hjEH0Uds3ZmnDma1Ez6tFx1M2QgG8kyh7Mq2IP6z4u1jwxdD X6+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wHhsNsS3i0bNroY4M/t+EzuYUrvezlw8l6YJyGkvFnU=; fh=7SPi/s12E5Q/X1Gvm1rgGRm5Bb6ZaGPS135vHMcjInM=; b=lOSQeapgqYyS+Sf9IKKovnL/gUtiYOnQIgc3zjC0JEnq3PS4gNcMIWdYWX8V7ataPt f1lQWatRcZBa4CFWv/V09Yjn4S1Fo4Av19H4TqT5c0+dYNtyskh652mSbCoXYJv5F6IG NTNdR03yUDbS4YcnxEayi5Ct7Sbu3NBgGO7BzCMVLjODcwfa8gGFUcbbXAMNvYyoFNqX HokBFu/PZerelCojiNqweSA/lMD4fBH5+NV90eNI1Cm2JskoV+RGCS9KfDbmcPfV0lVs d/GYTEyqCrBqPUruh+zcBfcvCTLLxSdz3rddfHYeQQDBXMgcIVqScS8Cfmrv2bErQpxD 7sOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xbnHKpvf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a3f3ffa961si7809385ab.90.2024.10.18.07.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:43 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xbnHKpvf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EFFDD890C4; Fri, 18 Oct 2024 16:23:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xbnHKpvf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C76DE88BB2; Fri, 18 Oct 2024 16:23:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E7B97887D1 for ; Fri, 18 Oct 2024 16:23:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so14028625e9.0 for ; Fri, 18 Oct 2024 07:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729261394; x=1729866194; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wHhsNsS3i0bNroY4M/t+EzuYUrvezlw8l6YJyGkvFnU=; b=xbnHKpvf9R7uFUqeuShCFfs09cEKhn6CpiGpxF9bVoFF9AKEmr4Ipj7ZeEdNa1IL3u GRfdbCHTj8f4HvQJJEZDnSFRW7RLEG72Ggx4EaNOQFaoFTrENxhH9JQx/siSCSaV/pcW rb4gvZx+k9MS4xHMY6VcmIbtq1bCMKoltzkoFgb3opQZXeiXmE9nP5Qxl8IS45ynREzx VYpabRVF1M8Ejn7Cld01iRBGCU55EZd1w8Sjaes+R3fXnrR/ikhXxJyfcjHzQBX+ibjb JuzUKYpWWroCkL0jmfyDCqHU6/qDPb7nnUfkeXB3N09l22aojzUQuG3wUBEjmNH4vbIw g8qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729261394; x=1729866194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wHhsNsS3i0bNroY4M/t+EzuYUrvezlw8l6YJyGkvFnU=; b=RS1dLfDt5c5Ly3zx7N/ij4qpwgP7ZhvBaTWY/dRHfLqpZgMdhfT6mn1+zHI11NlNfB UR7L5r5U8m7R6XzKXtQWb6CFSNHXt9CWSZMuuxYrjfK/bHpV3sgY4RobSNwS257Vl5RA rSphYGJP+pyF5cMMRA8ixvMUms9IunGTiFXG2egrVtVwfAQiPSCPWJ8cpyuEsSEJkW2w QDMWg+6WxQxUPRq75iBuAJSc3LA67zMFjX33IUE6pk8dMG/SBYdjZSkqBbvqBoXs9t0l a/n8GmyE3vbTws4g/r+bg4ul84Yl4mYFAl7zKt5qcL4dMxcz1HwyhoqbTnQUXnHsSpUt diAw== X-Forwarded-Encrypted: i=1; AJvYcCUAAKQ6BctdE/M/45m6TaLyjF3B/ZQb6iIgwVMCw2ALLHXSh45rWdESRGgPVlg2XvHffckXw3g=@lists.denx.de X-Gm-Message-State: AOJu0Yyhjdbo9LffRZDZd0Swa4dv//PdmBlmPxZy1GruS1glOtXSStD0 1k2X/Qu9/WpPmCqXtCOHhcFeDsyfZfY22Cw2NdgiV0khYOacTIBay6+AYLgeUD0= X-Received: by 2002:a05:600c:1c19:b0:42c:acb0:ddbd with SMTP id 5b1f17b1804b1-43161637396mr19666975e9.7.1729261394316; Fri, 18 Oct 2024 07:23:14 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316067dc70sm28781665e9.10.2024.10.18.07.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:13 -0700 (PDT) From: Ilias Apalodimas To: jerome.forissier@linaro.org, raymond.mao@linaro.org Cc: xypron.glpk@gmx.de, Ilias Apalodimas , Tom Rini , Joe Hershberger , Ramon Fried , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Wei Ming Chen , Jonathan Humphreys , Masahisa Kojima , Caleb Connolly , Javier Tia , u-boot@lists.denx.de Subject: [PATCH 5/6] configs: Enable htts for wget on qemu arm64 Date: Fri, 18 Oct 2024 17:21:59 +0300 Message-ID: <20241018142235.715571-6-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018142235.715571-1-ilias.apalodimas@linaro.org> References: <20241018142235.715571-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean QEMU already has an lwip variant of a defconfig. That defconfig is also configured with mbedTLS by default. So let's enable the remaining config options to enable wget for https:// as well and test that codepath in the CI Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass Reviewed-by: Peter Robinson Reviewed-by: Jerome Forissier --- configs/qemu_arm64_lwip_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/qemu_arm64_lwip_defconfig b/configs/qemu_arm64_lwip_defconfig index d3d8ef16e668..754c770c33fc 100644 --- a/configs/qemu_arm64_lwip_defconfig +++ b/configs/qemu_arm64_lwip_defconfig @@ -7,3 +7,4 @@ CONFIG_NET_LWIP=y CONFIG_CMD_DNS=y CONFIG_CMD_WGET=y CONFIG_EFI_HTTP_BOOT=y +CONFIG_WGET_HTTPS=y From patchwork Fri Oct 18 14:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 836721 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c9:0:b0:37d:45d0:187 with SMTP id f9csp848424wrt; Fri, 18 Oct 2024 07:23:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU8B9dGGs+cS/TQxCvLYvpdTAgP8LYqptdKf480Vh37Oj/rMUUePSHluuNQlsTs4cA9WAGyKg==@linaro.org X-Google-Smtp-Source: AGHT+IEEzM2OOWNEKXUibapOw68NQsneQbZTLDp3MjaD7RnmMEHnvm27JsdWO/aZiuxKKCD9hTIs X-Received: by 2002:a05:6e02:154c:b0:3a3:972a:3991 with SMTP id e9e14a558f8ab-3a3f40a859dmr30611015ab.16.1729261433435; Fri, 18 Oct 2024 07:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729261433; cv=none; d=google.com; s=arc-20240605; b=HXXQJWMoLDxjuE0gUDX225d0hKSYDYceaDLNNPPsk+Mx8p6HAQB8vNKomZPPnqIeWe hoihUssTDIZbkDG/LIkC95ec2CcqoTF+gktYsUF7rmkYt8ltVLD+A8CX/dWf6/qvoL52 /8M47PeR1Z8iUbOTU4wMENJjvSOI/J+bKe2pAz6EdCDcOE8MREtPb32Wh1JWHL4/gb8Z lQBEC89KjYWFlccO/4j+JgLY/5PxAvmjHPOxrKrnn5xbXwCKECcP1+AzOcavKeUnI5s4 pb0DpCXi1kt2IzcJmAC0Ut0doMv/g/322Hs4rRUig01hOhDdNMV3SS/IaHMiR82yta1g ePGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hERox0U5aHKC+DnPbgH6twbphvL01gqEqfrBF6WwKsU=; fh=gxOVEYoXNF+1RP1JoJt/uhCCBBoz9WlXdA6mt7jfcuo=; b=IOGi5WN3smqunyfw8i65ju6TuMcqu9VvWyg0y9MG4C7UOqIvEwiaLEX+J4BhWF9Pd6 IRqiwkFag4kJLVpWQwmNTBLk6CUXLcZc7I3+PBOr/HRJB56GHCtYGEv4eG6b+bHMxCQ4 H172Nd2B32fPSg9FpSqTQ3w2lqNSbg+r0tZiL9k36Wl3UtrJCow6cyb0WknZvYTlYwrc k0vKa/T7P4ayD6OlgxUnLF3RmUOO17DRADdB6Scck9adMx/J6riHw3ycE+FFieDFZQMN hStElW5M/gFnLXBZ1IHs+XERHvK+1E5x0fU6LAopS+s2j94gEPiVL29Lg16zN1TSxkSR m6gQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XdVhYigr; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a3f40374ffsi7435705ab.113.2024.10.18.07.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:53 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XdVhYigr; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 724F588717; Fri, 18 Oct 2024 16:23:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XdVhYigr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A932C88717; Fri, 18 Oct 2024 16:23:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C77E480AE6 for ; Fri, 18 Oct 2024 16:23:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4315839a7c9so22492955e9.3 for ; Fri, 18 Oct 2024 07:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729261401; x=1729866201; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hERox0U5aHKC+DnPbgH6twbphvL01gqEqfrBF6WwKsU=; b=XdVhYigrG5hysv05RnFFXVIAfvPzjkKtmgq6BFdgcmYEHoRjCjTwMPJqp+dZl9633I pyJEUdH+5OSLeNHXuGNZ1aIznjeWOLT0LDz59tG3GUsy3ln+1aE/gmqvMoTsKJ2+T8ZC v41vCP1G+6NI2UCeiQxGsh6BMQdypg/+Ym9QVoG6p7u22ubwH7uUq8ExohM3YtlBxzqO D0687399Js8hvakzEOhswTenays51LV2rBBI33wtP8tquEbZx4e3EgUggE4Jr/WHe73t 5xiiTAMUzkJF4EjagaW8LCPbvBi+rox/dHE8UGCdWy6QwxY0AS6BTQ1KEgLm5ZpXBQuY evxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729261401; x=1729866201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hERox0U5aHKC+DnPbgH6twbphvL01gqEqfrBF6WwKsU=; b=UfJ9T7Bxybb5scip7ZNy8YzD8Ara3A8vu4sm+mu9h/6kr6Y7HSK1kaqFNjhoS5Pd43 AaMSZA34n/ZgDRLss+t5wUJLB89g1zE6NHF5hKO5q2Y+DLFLh3xzb770L90Pn8nwXgDj nON3weMOwpTj1AclaKdsZLYmRK6L/kpMzamsy5WmeXlm1YMOM1QCNETkME+GZEfns1sX EISprCc7wL9gzURMW5Rm3kuB2SXoJCSTZBJoKqlzbU4nBk1ym7M9b64UEObjNOXdgFYA FnZCnI/W+OaOyR2iu7dFJo2s9fdnFgDQIE4m2o9BxqmAEW6/ZWmX9Eu/J6jKAO+v+6n9 9oRQ== X-Forwarded-Encrypted: i=1; AJvYcCWhAa6KiRsxUOdL4T8eZV7UTOb7xNfE2CU7kPQ+LddVOTaaD5wnWBUgFmshbGiMoaJdDby7sK8=@lists.denx.de X-Gm-Message-State: AOJu0Yx6LxzeO4G4GYEzRN9jcsHZgDqqg8Vz12reTJyWEE/A+0T78+KY QkuFIUU0ZI+a5QimjuomJ62wBvmZx9AExrs5R3fI1qqkMNf6JnRojVgwlD5DQq0= X-Received: by 2002:a05:600c:3553:b0:426:647b:1bfc with SMTP id 5b1f17b1804b1-431616a0b1emr21460105e9.30.1729261401215; Fri, 18 Oct 2024 07:23:21 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316067dc70sm28781665e9.10.2024.10.18.07.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 07:23:20 -0700 (PDT) From: Ilias Apalodimas To: jerome.forissier@linaro.org, raymond.mao@linaro.org Cc: xypron.glpk@gmx.de, Ilias Apalodimas , Tom Rini , Joe Hershberger , Ramon Fried , Simon Glass , Mattijs Korpershoek , AKASHI Takahiro , Wei Ming Chen , Jonathan Humphreys , Caleb Connolly , Masahisa Kojima , Javier Tia , u-boot@lists.denx.de Subject: [PATCH 6/6] doc: uefi: Describe UEFI HTTPs boot Date: Fri, 18 Oct 2024 17:22:00 +0300 Message-ID: <20241018142235.715571-7-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241018142235.715571-1-ilias.apalodimas@linaro.org> References: <20241018142235.715571-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We now can use a combination og lwIP & mbedTLS and download from https://. Describe the config options needed to enable it as well as some limitations Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass --- doc/develop/uefi/uefi.rst | 45 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index 0760ca91d4fc..198288a6889f 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -681,8 +681,8 @@ UEFI variables. Booting according to these variables is possible via:: As of U-Boot v2020.10 UEFI variables cannot be set at runtime. The U-Boot command 'efidebug' can be used to set the variables. -UEFI HTTP Boot -~~~~~~~~~~~~~~ +UEFI HTTP Boot using the legacy TCP stack +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HTTP Boot provides the capability for system deployment and configuration over the network. HTTP Boot can be activated by specifying:: @@ -715,6 +715,47 @@ We need to preset the "httpserverip" environment variable to proceed the wget:: setenv httpserverip 192.168.1.1 +UEFI HTTP(s) Boot using lwIP +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Similar to the above U-Boot can do EFI HTTP boot using lwIP. If we combine this +with mbedTLS we can also download from https:// + +HTTP(s) Boot can be activated by specifying:: + + CONFIG_EFI_HTTP_BOOT + CONFIG_NET_LWIP + CONFIG_MBEDTLS_LIB_TLS + +For QEMU targets there's a Kconfig that supports this by default:: + + make qemu_arm64_lwip_defconfig + +The commands and functionality are similar to the legacy stack, with the notable +exception of not having to define an "httpserverip" if you are trying to resolve +an IP. However, lwIP code doesn't yet support redirects:: + + => efidebug boot add -u 1 netinst https://cdimage.debian.org/cdimage/weekly-builds/arm64/iso-cd/debian-testing-arm64-netinst.iso + => dhcp + DHCP client bound to address 10.0.2.15 (3 ms) + => efidebug boot order 1 + => bootefi bootmgr + + HTTP server error 302 + Loading Boot0001 'netinst' failed + EFI boot manager: Cannot load any image + +If the url you specified isn't a redirect:: + + => efidebug boot add -u 1 netinst https://download.rockylinux.org/pub/rocky/9/isos/aarch64/Rocky-9.4-aarch64-minimal.iso + => dhcp + => bootefi bootmgr + ####################################### + +If the downloaded file extension is .iso or .img file, efibootmgr tries to +mount the image and boot with the default file(e.g. EFI/BOOT/BOOTAA64.EFI). +If the downloaded file is PE-COFF image, load the downloaded file and +start it. + Executing the built in hello world application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~