From patchwork Thu Nov 14 14:29:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 843127 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp308191wrc; Thu, 14 Nov 2024 06:29:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXA8Lzfnqhqa1aheXXlaukUJx8Lid6iN5XTGcQwvps7gthrqvYMmQZp0p0lkUtJiapLTjLf7g==@linaro.org X-Google-Smtp-Source: AGHT+IEzLrC3KzkkMXDG8p/z9fLDvAkcn3HBA/c5qjBN46Z/M1NziEY3oO9ViyEYf8BOHAmq2dOX X-Received: by 2002:a17:906:99c4:b0:a99:f91e:4abb with SMTP id a640c23a62f3a-aa1f8076d32mr677729666b.27.1731594568820; Thu, 14 Nov 2024 06:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731594568; cv=none; d=google.com; s=arc-20240605; b=cXGxR76eWlCCyFnd5KFloZeoI2iUtpryxDKFHP+8+5q/veTo84NejKajuNvNeIbrwT epilPRur27RxCfv+HoePSlJWGJb2D7Hs+rfIDHWxLUnkJO7E9Ia34+rkOchBwtjOtd2b qKi7yvDsvpMaOLEAip0TV0UXxS2+FxtAv0/tLWEnoEA/7/JDLPjIVzFlX/KB/LpA9QMI 2xPcxUtBNJ/o1lkLvz5+3Zy7AAvCWpnxOR1esS/TZteHCRPqc2jDvi++7v283Kd94Yuf EpL0g50Y5poVSLEZuh0ZGaut4n7G+Ne3/yjWElWM6y1d1fFi0pujW0PBtK3wPX6ltvcZ GFPw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=+ZKQ8GXO8x6Nz17B2GQZy1jFMfkUvyujZeaj0wCbMuI=; fh=k4dkYPrFw40H59VNT4YVzl/6qhIcLtr+y6sanpA+S5Q=; b=dA36ctipgJld57IFefjePAq5zWZuTxqMV0JulyYaCO0xaEfTOzKsq8IFB/H7Jj82aN dl216dSdhuPgoCtdTOpiVNEU8yrbx1QGYYRC350PPkWUAiS3Zr4kcC+q41sHHCI1urVm Y2FC2Uj3TeQVFg5jnLJWqMAKRA7LeSWWSCtm0sgAQNuC0w7AqBcdLbYd9Cj8KW1+T1o7 aTVEVT/Isu2ZaOZPwrpokvkkOv34tWuGJ2E6UmgLFO4J5kP8LsQ0xiImU6WfamsVfRqV cCt2OQZK8TvtgXGMYw1HtCYJs126uNMXThFSgD9EoEccOjPZuOiwBybh7oeyklVupfRm eoiw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G1EZHFMg; 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 a640c23a62f3a-aa20df3d01fsi78478766b.126.2024.11.14.06.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 06:29:28 -0800 (PST) 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=G1EZHFMg; 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 08AC2895EB; Thu, 14 Nov 2024 15:29:28 +0100 (CET) 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="G1EZHFMg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8474B895C9; Thu, 14 Nov 2024 15:29:26 +0100 (CET) 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-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (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 240EF895AC for ; Thu, 14 Nov 2024 15:29:24 +0100 (CET) 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-lj1-x233.google.com with SMTP id 38308e7fff4ca-2fb56cb61baso5137581fa.1 for ; Thu, 14 Nov 2024 06:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731594563; x=1732199363; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+ZKQ8GXO8x6Nz17B2GQZy1jFMfkUvyujZeaj0wCbMuI=; b=G1EZHFMgeHYeJZhlV7zI6C+QBp8+Fw1z0oFMZCYnNAUv9sgoz25jvG5rL25pwZRVaI uRmgGApurFUX9vDz25Zylab4YfUIhjdy+tu2/7el5e9DU3pU5dRXDF1yE2TfntsYxStW NM/UbzRuzma1u9eUs3x0yF8MAhVyhhnil94JPpDkbnMd5MEAI2UkjF586b6G6r1ZcEWS MzVRng9kVSG/YoQnPKUPwo/qcQudDNcT3kGnQqXLcuyWb4E1MDLptBDMtvYsQiPEMURQ OHB30UppZtV93tjC+GB5ORWJuagLi9Deb6yCShp7aCJB+zPZoN53sLvxcb2xsKa9/GOv VpQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731594563; x=1732199363; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+ZKQ8GXO8x6Nz17B2GQZy1jFMfkUvyujZeaj0wCbMuI=; b=qo2g39tEqwuOZMQERjyrGhH09AzIqaVaVtnWJQd+sdgwjHhlNNVVdNVob0a3vrWZwa DXTwe/KOtLWIyYAWgFH1uC/zsyzk0u0qaDRJNrtXNUn3nKM4jW/ZnXFF8MzNYplKBWmd ywrSdm0fHpLuqTXzcYT0rulCBtvwM6EhdhCsWf/Yp/g6NUcvycOcKnJxrgrBCa19+y1b uE8C4j9QNpYkF0AefNrDaBtqglKN4Wdc5GK3XFe+bP8pM2uUIr/KvKMbSiwCA5mySM1H zJ1FrrdJzTyzledGkx6vn03zhyMWCEiKSflyNxMHI1NQrT2rre1PGYeB1f4mPU7hX+0S x66Q== X-Forwarded-Encrypted: i=1; AJvYcCWnr19dmNSKOEpvlInE0gOd0JLqdHm3f+sW/197B1Rd4a5HHyUPqdt9NlkGd3p0jt9YPgtBLnc=@lists.denx.de X-Gm-Message-State: AOJu0YzetyE6l462lyGb+Q0zaWeNYtnJF96D3OFRUZGn6vYDEcbPOqil za6waPmI70DflTs2lWFqF3RynfOykwh3fV8L6E4RA6f0gLXCRO6zI5VBcQANt7c= X-Received: by 2002:a2e:bea0:0:b0:2fb:44ca:801c with SMTP id 38308e7fff4ca-2ff4c633543mr41840251fa.35.1731594562909; Thu, 14 Nov 2024 06:29:22 -0800 (PST) Received: from localhost.localdomain (ppp078087235066.access.hol.gr. [78.87.235.66]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf79b89bcesm615806a12.3.2024.11.14.06.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 06:29:21 -0800 (PST) From: Ilias Apalodimas To: jerome.forissier@linaro.org Cc: Ilias Apalodimas , Simon Glass , Joe Hershberger , Ramon Fried , Tom Rini , u-boot@lists.denx.de Subject: [PATCH v2] net: lwip: provide entropy to MBed TLS in one go Date: Thu, 14 Nov 2024 16:29:15 +0200 Message-ID: <20241114142917.481564-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 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 currently provide entropy to mbedTLS using 8b chunks. Take into account the 'len' parameter passed by MBed TLS to the entropy gathering function instead. Note that the current code works because len is always 128 (defined at compile time), therefore mbedtls_hardware_poll() is called repeatedly and the buffer is filled correctly. But passing 'len' to dm_rng_read() is both better and simpler. Reviewed-by: Jerome Forissier Suggested-by: Simon Glass Signed-off-by: Ilias Apalodimas --- Changes since v1: - Update the commit message and title and picked up r-b from Jerome - v1 can be found here https://lore.kernel.org/u-boot/42870ab3-1621-491f-a221-8ced932ed703@linaro.org/ net/lwip/wget.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.45.2 diff --git a/net/lwip/wget.c b/net/lwip/wget.c index ba8579899002..4fd552fd306e 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -42,7 +42,6 @@ int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen) { struct udevice *dev; - u64 rng = 0; int ret; *olen = 0; @@ -52,12 +51,11 @@ int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, log_err("Failed to get an rng: %d\n", ret); return ret; } - ret = dm_rng_read(dev, &rng, sizeof(rng)); + ret = dm_rng_read(dev, output, len); if (ret) return ret; - memcpy(output, &rng, len); - *olen = sizeof(rng); + *olen = len; return 0; }