Commit 156bf0c8 authored by Marek Vasut's avatar Marek Vasut
Browse files

mxssb: Reorder the malloc and SB header crypto init



Swap the malloc upwards as it can now no longer depends on SB header
crypto init which filled the SB header with additional data. Now
the SB header crypto operation and malloc of the image are truly
separate entities. This also groups the SB header crypto operation
together nicely.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent 1343518e
......@@ -449,18 +449,17 @@ static int sb_create_image(struct sb_image_ctx *ctx, uint8_t **image)
EVP_MD_CTX_init(&ctx->md_ctx);
EVP_DigestInit(&ctx->md_ctx, EVP_sha1());
/* Allocate the resulting SB image. */
*image = malloc(sb_header->image_blocks * SB_BLOCK_SIZE);
if (!*image)
return -ENOMEM;
/*
* SB image header.
*/
sb_aes_init(&ctx->cipher_ctx, NULL);
sb_encrypt_sb_header(&ctx->cipher_ctx, &ctx->md_ctx, sb_header);
/* Allocate the resulting SB image. */
*image = malloc(sb_header->image_blocks * SB_BLOCK_SIZE);
if (!*image)
return -ENOMEM;
sb_emit_data(*image, &image_offset, sb_header, sizeof(*sb_header));
/*
......
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