common: android: crypto v2 hash need length in crypto_sha_init

if not set ctx.length, you will get zero length hash value.

Change-Id: I9e653c845a36b4caea986c328c48ea8b2835da75
Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
This commit is contained in:
Lin Jinhan 2020-10-30 09:58:59 +08:00
parent c48f1acf4a
commit 1817f8c289
1 changed files with 2 additions and 3 deletions

View File

@ -513,8 +513,7 @@ static int android_image_separate(struct andr_img_hdr *hdr,
return -ENODEV;
}
#ifdef CONFIG_ROCKCHIP_CRYPTO_V1
/* v1: requires total length before sha init */
/* v1 & v2: requires total length before sha init */
ctx.length += hdr->kernel_size + sizeof(hdr->kernel_size) +
hdr->ramdisk_size + sizeof(hdr->ramdisk_size) +
hdr->second_size + sizeof(hdr->second_size);
@ -523,7 +522,7 @@ static int android_image_separate(struct andr_img_hdr *hdr,
sizeof(hdr->recovery_dtbo_size);
if (hdr->header_version > 1)
ctx.length += hdr->dtb_size + sizeof(hdr->dtb_size);
#endif
crypto_sha_init(dev, &ctx);
/* load, never change order ! */