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: Konstantin Porotchkin <kostap@marvell.com>
This commit is contained in:
parent
a79df348a5
commit
5985a1e426
|
@ -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[])
|
||||||
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[])
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue