From: Eric Biggers <ebiggers@kernel.org>
To: Artur Rojek <artur@conclusive.pl>
Cc: Johannes Berg <johannes@sipsolutions.net>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-wireless@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Jakub Klama <jakub@conclusive.pl>,
Wojciech Kloska <wojciech@conclusive.pl>,
Ulf Axelsson <ulf.axelsson@nordicsemi.no>
Subject: Re: [RFC PATCH 1/2] net: wireless: Add Nordic nRF70 series Wi-Fi driver
Date: Mon, 28 Apr 2025 22:04:30 -0700 [thread overview]
Message-ID: <20250429050430.GA7003@sol.localdomain> (raw)
In-Reply-To: <20250324211045.3508952-2-artur@conclusive.pl>
On Mon, Mar 24, 2025 at 10:10:44PM +0100, Artur Rojek wrote:
> +static int nrf70_verify_firmware(struct device *dev,
> + const struct nrf70_fw_header *fw)
> +{
> + struct crypto_shash *alg;
> + u8 hash[NRF70_FW_HASH_LEN];
> + int ret;
> +
> + alg = crypto_alloc_shash("sha256", 0, 0);
> + if (IS_ERR(alg)) {
> + ret = PTR_ERR(alg);
> + dev_err(dev, "Unable to allocate shash memory: %d\n", ret);
> + goto out;
> + };
> +
> + if (crypto_shash_digestsize(alg) != NRF70_FW_HASH_LEN) {
> + dev_err(dev, "Incorrect digest size\n");
> + ret = -EFAULT;
> + goto out;
> + }
> +
> + ret = crypto_shash_tfm_digest(alg, fw->data, fw->length, hash);
> + if (ret) {
> + dev_err(dev, "Unable to compute hash\n");
> + goto out;
> + }
> +
> + if (memcmp(fw->hash, hash, sizeof(hash))) {
> + dev_err(dev, "Invalid firmware checksum\n");
> + ret = -EFAULT;
> + }
> +
> +out:
> + crypto_free_shash(alg);
> +
> + return ret;
> +}
You can just use sha256() here (and select CRYPTO_LIB_SHA256 from your kconfig
option). It's much simpler than crypto_shash.
- Eric
next prev parent reply other threads:[~2025-04-29 5:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 21:10 [RFC PATCH 0/2] Nordic nRF70 series Artur Rojek
2025-03-24 21:10 ` [RFC PATCH 1/2] net: wireless: Add Nordic nRF70 series Wi-Fi driver Artur Rojek
2025-04-01 14:11 ` Sascha Hauer
2025-04-18 12:46 ` Artur Rojek
2025-04-24 13:16 ` Sascha Hauer
2025-04-29 5:04 ` Eric Biggers [this message]
2025-03-24 21:10 ` [RFC PATCH 2/2] dt-bindings: wireless: Document Nordic nRF70 bindings Artur Rojek
2025-03-24 23:05 ` Rob Herring (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250429050430.GA7003@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=artur@conclusive.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jakub@conclusive.pl \
--cc=johannes@sipsolutions.net \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ulf.axelsson@nordicsemi.no \
--cc=wojciech@conclusive.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox