From e107985964d5c90b8ec078a2fed1f13cd56d25ae Mon Sep 17 00:00:00 2001 From: Ole Reinhardt Date: Thu, 6 Jan 2022 10:18:20 +0100 Subject: [PATCH] Fix u-boot build with newer openssl libraries --- tools/mxsimage.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/mxsimage.c b/tools/mxsimage.c index 98fc64491c..04fe91b3f9 100644 --- a/tools/mxsimage.c +++ b/tools/mxsimage.c @@ -144,8 +144,8 @@ struct sb_image_ctx { struct sb_dcd_ctx *dcd_head; struct sb_dcd_ctx *dcd_tail; - EVP_CIPHER_CTX cipher_ctx; - EVP_MD_CTX md_ctx; + EVP_CIPHER_CTX *cipher_ctx; + EVP_MD_CTX *md_ctx; uint8_t digest[32]; struct sb_key_dictionary_key sb_dict_key; @@ -1322,7 +1322,7 @@ static int sb_postfill_image_header(struct sb_image_ctx *ictx) struct sb_boot_image_header *hdr = &ictx->payload; struct sb_section_ctx *sctx = ictx->sect_head; uint32_t kd_size, sections_blocks; - EVP_MD_CTX md_ctx; + EVP_MD_CTX *md_ctx = EVP_MD_CTX_new(); /* The main SB header size in blocks. */ hdr->image_blocks = hdr->header_blocks; @@ -1340,6 +1340,7 @@ static int sb_postfill_image_header(struct sb_image_ctx *ictx) if (!ictx->sect_boot_found) { fprintf(stderr, "ERR: No bootable section selected!\n"); + EVP_CIPHER_CTX_free(md_ctx); return -EINVAL; } hdr->first_boot_section_id = ictx->sect_boot; @@ -1367,6 +1368,7 @@ static int sb_postfill_image_header(struct sb_image_ctx *ictx) sizeof(hdr->digest)); EVP_DigestFinal(&md_ctx, hdr->digest, NULL); + EVP_CIPHER_CTX_free(md_ctx); return 0; } @@ -1621,7 +1623,7 @@ static int sb_verify_image_header(struct sb_image_ctx *ictx, struct tm tm; int sz, ret = 0; unsigned char digest[20]; - EVP_MD_CTX md_ctx; + EVP_MD_CTX *md_ctx = EVP_MD_CTX_new(); unsigned long size; /* Start image-wide crypto. */ @@ -1633,6 +1635,7 @@ static int sb_verify_image_header(struct sb_image_ctx *ictx, size = fread(&ictx->payload, 1, sizeof(ictx->payload), fp); if (size != sizeof(ictx->payload)) { fprintf(stderr, "ERR: SB image header too short!\n"); + EVP_CIPHER_CTX_free(md_ctx); return -EINVAL; } @@ -1643,6 +1646,7 @@ static int sb_verify_image_header(struct sb_image_ctx *ictx, sizeof(struct sb_boot_image_header) - sizeof(hdr->digest)); EVP_DigestFinal(&md_ctx, digest, NULL); + EVP_CIPHER_CTX_free(md_ctx); sb_aes_init(ictx, NULL, 1); sb_encrypt_sb_header(ictx); -- 2.39.2