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