Commit 5985a1e4 authored by Konstantin Porotchkin's avatar Konstantin Porotchkin Committed by Manish Pandey
Browse files

tools: doimage: change the binary image alignment to 16



Change the binary image alignment from 4 to 16.
The PKCS signature verification fails for unaligned images.

Change-Id: Ieb08dc3ea128790f542ad93e3c948117567a65af
Signed-off-by: default avatarKonstantin Porotchkin <kostap@marvell.com>
parent a79df348
...@@ -1563,13 +1563,9 @@ error: ...@@ -1563,13 +1563,9 @@ error:
int write_boot_image(uint8_t *buf, uint32_t image_size, FILE *out_fd) int write_boot_image(uint8_t *buf, uint32_t image_size, FILE *out_fd)
{ {
int aligned_size;
int written; int written;
/* Image size must be aligned to 4 bytes */ written = fwrite(buf, image_size, 1, out_fd);
aligned_size = (image_size + 3) & (~0x3);
written = fwrite(buf, aligned_size, 1, out_fd);
if (written != 1) { if (written != 1) {
fprintf(stderr, "Error: Failed to write boot image\n"); fprintf(stderr, "Error: Failed to write boot image\n");
goto error; goto error;
...@@ -1591,7 +1587,7 @@ int main(int argc, char *argv[]) ...@@ -1591,7 +1587,7 @@ int main(int argc, char *argv[])
int ext_cnt = 0; int ext_cnt = 0;
int opt; int opt;
int ret = 0; int ret = 0;
int image_size; int image_size, file_size;
uint8_t *image_buf = NULL; uint8_t *image_buf = NULL;
int read; int read;
size_t len; size_t len;
...@@ -1687,16 +1683,18 @@ int main(int argc, char *argv[]) ...@@ -1687,16 +1683,18 @@ int main(int argc, char *argv[])
goto main_exit; goto main_exit;
} }
/* Read the input file to buffer */ /* Read the input file to buffer
image_size = get_file_size(in_file); * Always align the image to 16 byte boundary
image_buf = calloc((image_size + AES_BLOCK_SZ - 1) & */
~(AES_BLOCK_SZ - 1), 1); file_size = get_file_size(in_file);
image_size = (file_size + AES_BLOCK_SZ - 1) & ~(AES_BLOCK_SZ - 1);
image_buf = calloc(image_size, 1);
if (image_buf == NULL) { if (image_buf == NULL) {
fprintf(stderr, "Error: failed allocating input buffer\n"); fprintf(stderr, "Error: failed allocating input buffer\n");
return 1; return 1;
} }
read = fread(image_buf, image_size, 1, in_fd); read = fread(image_buf, file_size, 1, in_fd);
if (read != 1) { if (read != 1) {
fprintf(stderr, "Error: failed to read input file\n"); fprintf(stderr, "Error: failed to read input file\n");
goto main_exit; goto main_exit;
......
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