Commit 2164960d authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

efi: use sha256() instead of open coding

Now that there's a function that calculates the SHA-256 digest of a
buffer in one step, use it instead of sha256_init() + sha256_update() +
sha256_final().
Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
Tested-by: default avatarHans de Goede <hdegoede@redhat.com>
Cc: linux-efi@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9ea9c58b
......@@ -37,9 +37,8 @@ static const struct dmi_system_id * const embedded_fw_table[] = {
static int __init efi_check_md_for_embedded_firmware(
efi_memory_desc_t *md, const struct efi_embedded_fw_desc *desc)
{
struct sha256_state sctx;
struct efi_embedded_fw *fw;
u8 sha256[32];
u8 hash[32];
u64 i, size;
u8 *map;
......@@ -54,10 +53,8 @@ static int __init efi_check_md_for_embedded_firmware(
if (memcmp(map + i, desc->prefix, EFI_EMBEDDED_FW_PREFIX_LEN))
continue;
sha256_init(&sctx);
sha256_update(&sctx, map + i, desc->length);
sha256_final(&sctx, sha256);
if (memcmp(sha256, desc->sha256, 32) == 0)
sha256(map + i, desc->length, hash);
if (memcmp(hash, desc->sha256, 32) == 0)
break;
}
if ((i + desc->length) > size) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment