From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58BE83B0AFD for ; Tue, 31 Mar 2026 08:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774945279; cv=none; b=lpF3aprj9lt4KD6YG55iQa8lmhaQGhJoXCGJzj3ka7CABdPYmnLlml0u9/h2FRaKbz1TJctxA0FkEnKWOZodgGTLQGE4RT+Ti+vw9VD70MSOrtOR/1/Q+dzbaLBuYDKm0b0R4tQX0hHsDbRP2sC6dWt/DZP39USlJGp9euk2wtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774945279; c=relaxed/simple; bh=rASOBVFE3DzESvbGeqECsrlRzkoHgAZdUxmPO0hhxic=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VgYKV9XPPhi4T6hjfwBcjl9XJYub24O+wBDV80F/5jXAqyFxIkOrjig9Z8BDU3MbsgnhXY0ubm1qiII1Zb9288UcxoAapOiMecCrGi8z2Hl/lFT6dPnuELv+ZQ9v2q4XTpW9Wia7tum8L17VrybvwLZNI7xVxPkpDd/4dduWqao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fnfrYlt8; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fnfrYlt8" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4836d9d54f6so7221715e9.1 for ; Tue, 31 Mar 2026 01:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774945277; x=1775550077; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kgfma63aNvj8LoqZ/8WsKQp6E4V/1m+2J06vQ5c8LKw=; b=fnfrYlt86IEnCrtXzLk8kKzQv9W64/l4DkNZTj87IBhZpDgCdDxktYIBtVV/aQbnDp azbgudHoeIWRy3JrE7mSgxw0+99y4tPUKjf3sI/hxbxxHN8Pta8rmoZbQvJblU8wiew9 8nGxkxVjGzQHcSqovZtz+CNw/iVlm/fwFq+NbsifI+TpP1MPzWwHIIKskkxyANz5l9se ZTgcMKyYsl4laAJh1uO8wYUEqVa5HMNDWzMM8kNPD8VbYvBRK+1dGmqHMNFXWFa7EIav QYkZxe7MAzPZ5Ok84TZ6WHe2TuVzflP27M+0wC/u8flpxQc6EyfnMbACYb8WYVJWGRgw ho/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774945277; x=1775550077; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kgfma63aNvj8LoqZ/8WsKQp6E4V/1m+2J06vQ5c8LKw=; b=n4umntmhACzDLQK06u9AuRdor4KLn/pkwsrXCav+e1S+tVypZvtZDFt5pRZJmyJOML LjItFKpOm51t/AjqndeLXcb4PUZD5c7DfEgwA2vTwMqljtckvu1Je1PXZBDzkHgiUsFa 0hUYFoGIWasuqoAmvoTzXbAh8nWOqaIcOXJ3H5Zb2oWPreHossIl5vsR748ccqAam7DU k2vjHtoFOuu5d0+DWNYRoUT58buYaN9wjHEMGULQxNcOjJYko1nr6uJAYYg2UlUTWBRc y8OeApogzMxgqGp9Pqn416l3fG+E2hHcjYVgLgOWFSxW1gNbYkg0hk4Absluq0naB8pO obdg== X-Forwarded-Encrypted: i=1; AJvYcCVvXRe+gp+ehBSXhsLm0+FnctlJ+ERq81bVB+hPpHlUGNL5u+Y5PeJNqrrKwwoY1CMSSSGZxBDCHqN7F3c=@vger.kernel.org X-Gm-Message-State: AOJu0YxlXWq0hllb70lYxn9ncD78Xni5P24akYtaZU5YKj3LzFWROe/i cB+RcxqXYSF4/3Xm9HpS+gd5N+wyMP/hk8JkdYMmGZFdPe4v1H5W0tW6 X-Gm-Gg: ATEYQzzhnvdTeBLYR2I6d2Ri2zT+7THc0rXLWR3KQY+JVPCq9YkyepGFGLCVQWpdT69 NFlTNrfNMzSfJWVtbNt2e5bzpbpIrjFmuEaNzFLvT4npo6XloAKAJ93xbxyUIRC5RIGeGpB/+VE MZdHm2DiG1vtQzlCmZIdXPS0cmepX2JeBftN3SjHI0sApT3EmPCl6Tbs/Q9nHN0LbkOsJ2KTaTm RGecsG5rKPjYuIBOTe71j/C6/Yv4v1oNmK2TYnoT6K+O/UDOEgh3LL0crXTOc0kkEYo2wWBfFrT H8TVgdJqIrSI81FzbDwpNZBFaYeO5iFHZdQn4WFoDwYFvJu+LD2/RJCP2NKE5Q6a2wpRKZnTjTo TdG6oxSHf4nSX08JrQNZ4AEOeA3ikaOcRK433uFCnPam1SJf4dOGBvKLZsAIq+fJ4uHLAxYXTC6 dVHZudJDvTEw+j014m9m6FIRTCknetNM+sDCx6SgGqo9hQF6MWFns1RyJ1cpeAYak= X-Received: by 2002:a05:600c:5251:b0:487:22de:25 with SMTP id 5b1f17b1804b1-487283d4939mr133907515e9.7.1774945276289; Tue, 31 Mar 2026 01:21:16 -0700 (PDT) Received: from menon.v.cablecom.net (84-74-0-139.dclient.hispeed.ch. [84.74.0.139]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887ad8d28bsm14542485e9.10.2026.03.31.01.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 01:21:15 -0700 (PDT) From: Lothar Rubusch To: herbert@gondor.apana.org.au, davem@davemloft.net, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, ardb@kernel.org, linusw@kernel.org Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, l.rubusch@gmail.com Subject: [PATCH v2 0/3] crypto: atmel-sha204a - multiple RNG fixes Date: Tue, 31 Mar 2026 08:21:02 +0000 Message-Id: <20260331082105.697468-1-l.rubusch@gmail.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When testing the RNG functionality on the Atmel SHA204a hardware, I found the following issues: rngtest reported failures and hexdump reveiled only the first 8 bytes out of 32 provided actually entropy. Having a closer look into it, I found a (small) memory leak, missing to free work_data, miss-reading of the count field into the entropy fields and parts of the 32 random bytes staying 0 due to reading the slow i2c device. The series proposes fixes and how fixed functionality can be/was verified. Executing rngtest afterward showed a decent result, due to the i2c bus a bit slow. All setups require selecting the Atmel-sha204a as active RNG. $ cat /sys/class/misc/hw_random/rng_available 3f104000.rng 1-0064 none $ echo 1-0064 > /sys/class/misc/hw_random/rng_current $ cat /sys/class/misc/hw_random/rng_current 1-0064 Testing RNG properties currently shows problematic results: $ rngtest < /dev/hwrng rngtest 2.6 Copyright (c) 2004 by Henrique de Moraes Holschuh This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. rngtest: starting FIPS tests... rngtest: bits received from input: 1040032 rngtest: FIPS 140-2 successes: 0 rngtest: FIPS 140-2 failures: 52 rngtest: FIPS 140-2(2001-10-10) Monobit: 52 rngtest: FIPS 140-2(2001-10-10) Poker: 52 rngtest: FIPS 140-2(2001-10-10) Runs: 52 rngtest: FIPS 140-2(2001-10-10) Long run: 52 rngtest: FIPS 140-2(2001-10-10) Continuous run: 52 rngtest: input channel speed: (min=7.631; avg=7.804; max=7.827)Kibits/s rngtest: FIPS tests speed: (min=32.273; avg=32.701; max=33.056)Mibits/s rngtest: Program run time: 130177956 microseconds Signed-off-by: Lothar Rubusch --- v1 -> v2: Removal of C++ style comment (I saw it too late, sry for that) --- Lothar Rubusch (3): crypto: atmel-sha204a - fix memory leak at non-blocking RNG work_data crypto: atmel-sha204a - fix truncated 32-byte blocking read crypto: atmel-sha204a - fix non-blocking read logic drivers/crypto/atmel-sha204a.c | 61 ++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 21 deletions(-) base-commit: 5c52607c43c397b79a9852ce33fc61de58c3645c -- 2.39.5