Commit 5e771d1a authored by Marek Vasut's avatar Marek Vasut

mxssb: Store the key dictionary in image context

Store image dictionary in image context, as this is where it should
be according to the documentation. We also need it here 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 1545df4f
......@@ -72,6 +72,8 @@ struct sb_image_ctx {
EVP_MD_CTX md_ctx;
int section_count;
struct sb_key_dictionary_key sb_dict_key;
struct sb_boot_image_header payload;
};
......@@ -319,10 +321,10 @@ static void sb_encrypt_sb_sections_header(struct sb_image_ctx *ictx,
}
static void sb_encrypt_key_dictionary_key(struct sb_image_ctx *ictx,
struct sb_key_dictionary_key *sb_dict_key,
uint8_t cbc_mac[sizeof(struct sb_key_dictionary_key)])
{
EVP_MD_CTX *md_ctx = &ictx->md_ctx;
struct sb_key_dictionary_key *sb_dict_key = &ictx->sb_dict_key;
/*
* The key in the key dictionary contains CBC-MAC from the SB image
......@@ -394,13 +396,9 @@ static int sb_create_image(struct sb_image_ctx *ictx, uint8_t **image)
/*
* Key dictionary.
*/
struct sb_key_dictionary_key sb_dict_key;
memset(&sb_dict_key, 0, sizeof(sb_dict_key));
sb_aes_reinit(ictx, sb_header->iv);
sb_encrypt_key_dictionary_key(ictx,
&sb_dict_key, sb_section_header_cbc_mac);
sb_encrypt_key_dictionary_key(ictx, sb_section_header_cbc_mac);
/*
* Section tags.
......@@ -449,6 +447,7 @@ static int sb_create_image(struct sb_image_ctx *ictx, uint8_t **image)
/*
* Export the image
*/
struct sb_key_dictionary_key *sb_dict_key = &ictx->sb_dict_key;
/* Allocate the resulting SB image. */
*image = malloc(sb_header->image_blocks * SB_BLOCK_SIZE);
......@@ -462,7 +461,7 @@ static int sb_create_image(struct sb_image_ctx *ictx, uint8_t **image)
sizeof(struct sb_sections_header));
sctx = sctx->sect;
};
sb_emit_data(*image, &image_offset, &sb_dict_key, sizeof(sb_dict_key));
sb_emit_data(*image, &image_offset, sb_dict_key, sizeof(*sb_dict_key));
sctx = ictx->sect;
while (sctx) {
cctx = sctx->cmd;
......
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