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