mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 02:04:55 +00:00
crypto: produce consistent hash for zero-length data
In real-world use-cases, hashing zero-length data likely never happens. However, it is relevant when testing cbootimage with a dummy zero-length bootloader binary, e.g.: touch u-boot.bin cbootimage -t30 ../tamonten-ng/tegra30.img.cfg tegra30-tec-ng.img In this scenario, it's useful to create a consistent hash, so that one can compare the resultant images before and after applying patches, to check for regressions. Hence, zero out the hash data so it has consistent content if it isn't written to. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Thierry Reding <treding@nvidia.com>
This commit is contained in:
@@ -280,7 +280,7 @@ sign_bct(build_image_context *context,
|
||||
bct) != 0)
|
||||
return -ENODATA;
|
||||
|
||||
hash_buffer = malloc(hash_size);
|
||||
hash_buffer = calloc(1, hash_size);
|
||||
if (hash_buffer == NULL)
|
||||
return -ENOMEM;
|
||||
e = sign_data_block(bct + Offset, length, hash_buffer);
|
||||
|
||||
@@ -391,7 +391,7 @@ write_bootloaders(build_image_context *context)
|
||||
g_soc_config->get_value(token_bootloaders_max,
|
||||
&bootloaders_max, context->bct);
|
||||
|
||||
hash_buffer = malloc(hash_size);
|
||||
hash_buffer = calloc(1, hash_size);
|
||||
if (hash_buffer == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user