summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2022-08-18 14:22:23 -0500
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-02 23:46:48 +0000
commit97c4de9fdb47232a5ff14682ebd9e7c2d9c40f38 (patch)
tree692ee62ce6bf9b24a1c35627af7f8769c6bf1c58
parentb9d1609c4c96c592ac9bf2c64b54c784412b5617 (diff)
downloadchrome-ec-97c4de9fdb47232a5ff14682ebd9e7c2d9c40f38.tar.gz
usb_spi: move validate_ranges_sha print to usb_spi_sha256_update
A future cl will call usb_spi_sha256_update in more places. Move the range print statement into usb_spi_sha256_update, so we don't need to print the range in multiple places later. BUG=b:236844541 TEST=make -j BOARD=cr50 Change-Id: I9475d14ea0d65be1ad68f606252d50d9af964253 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840652 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--board/cr50/usb_spi.c9
-rw-r--r--board/cr50/usb_spi_board.h2
-rw-r--r--common/ap_ro_integrity_check.c9
3 files changed, 10 insertions, 10 deletions
diff --git a/board/cr50/usb_spi.c b/board/cr50/usb_spi.c
index 964077cb4e..3516fa717a 100644
--- a/board/cr50/usb_spi.c
+++ b/board/cr50/usb_spi.c
@@ -705,10 +705,15 @@ int usb_spi_read_buffer(void *buf, unsigned int offset, size_t bytes)
}
int usb_spi_sha256_update(struct sha256_ctx *ctx, uint32_t offset,
- uint32_t size)
+ uint32_t size, bool print_range)
{
uint8_t data[SPI_HASH_CHUNK_SIZE];
+ if (print_range) {
+ CPRINTS("%s: %x:%x", __func__, offset, size);
+ /* Make sure the message gets out before verification starts. */
+ cflush();
+ }
while (size) {
const int this_chunk = MIN(size, SPI_HASH_CHUNK_SIZE);
@@ -761,7 +766,7 @@ static enum vendor_cmd_rc spi_hash_sha256(uint8_t *dest, uint32_t offset,
if (usb_spi_sha256_start(&sha) != EC_SUCCESS)
return VENDOR_RC_INTERNAL_ERROR;
- if (usb_spi_sha256_update(&sha, offset, size) != EC_SUCCESS)
+ if (usb_spi_sha256_update(&sha, offset, size, false) != EC_SUCCESS)
return VENDOR_RC_READ_FLASH_FAIL;
usb_spi_sha256_final(&sha, dest, SHA256_DIGEST_SIZE);
diff --git a/board/cr50/usb_spi_board.h b/board/cr50/usb_spi_board.h
index 064b261709..d1dd59239f 100644
--- a/board/cr50/usb_spi_board.h
+++ b/board/cr50/usb_spi_board.h
@@ -6,7 +6,7 @@
int usb_spi_sha256_start(struct sha256_ctx *ctx);
int usb_spi_sha256_update(struct sha256_ctx *ctx, uint32_t offset,
- uint32_t size);
+ uint32_t size, bool print_range);
void usb_spi_sha256_final(struct sha256_ctx *ctx, void *digest,
size_t digest_size);
diff --git a/common/ap_ro_integrity_check.c b/common/ap_ro_integrity_check.c
index c0303115cf..2e6b93fa2a 100644
--- a/common/ap_ro_integrity_check.c
+++ b/common/ap_ro_integrity_check.c
@@ -464,14 +464,9 @@ enum ap_ro_check_result validate_ranges_sha(const struct ro_range *ranges,
struct sha256_ctx ctx;
usb_spi_sha256_start(&ctx);
- for (i = 0; i < count; i++) {
- CPRINTS("%s: %x:%x", __func__, ranges[i].flash_offset,
- ranges[i].range_size);
- /* Make sure the message gets out before verification starts. */
- cflush();
+ for (i = 0; i < count; i++)
usb_spi_sha256_update(&ctx, ranges[i].flash_offset,
- ranges[i].range_size);
- }
+ ranges[i].range_size, true);
usb_spi_sha256_final(&ctx, digest, sizeof(digest));
if (DCRYPTO_equals(digest, expected_digest, sizeof(digest)) !=