Commit 3cc85a72 authored by Marek Vasut's avatar Marek Vasut

mxssb: Store image digest in image context

We need to store image digest in image context to let it
traverse between the image creation function and image write
function.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent 5e771d1a
......@@ -71,6 +71,7 @@ struct sb_image_ctx {
EVP_CIPHER_CTX cipher_ctx;
EVP_MD_CTX md_ctx;
int section_count;
uint8_t digest[32];
struct sb_key_dictionary_key sb_dict_key;
......@@ -433,13 +434,10 @@ static int sb_create_image(struct sb_image_ctx *ictx, uint8_t **image)
/*
* Dump the SHA1 of the whole image.
*/
uint8_t digest[32];
sb_aes_reinit(ictx, sb_header->iv);
memset(digest, 0, sizeof(digest));
EVP_DigestFinal(&ictx->md_ctx, digest, NULL);
sb_aes_encrypt(ictx, digest, digest, sizeof(digest));
EVP_DigestFinal(&ictx->md_ctx, ictx->digest, NULL);
sb_aes_encrypt(ictx, ictx->digest, ictx->digest, sizeof(ictx->digest));
/* Stop the encryption session. */
sb_aes_deinit(&ictx->cipher_ctx);
......@@ -478,7 +476,7 @@ static int sb_create_image(struct sb_image_ctx *ictx, uint8_t **image)
sctx = sctx->sect;
};
sb_emit_data(*image, &image_offset, digest, sizeof(digest));
sb_emit_data(*image, &image_offset, ictx->digest, sizeof(ictx->digest));
return 0;
}
......
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