diff options
-rw-r--r-- | board/cr50/usb_spi.c | 9 | ||||
-rw-r--r-- | board/cr50/usb_spi_board.h | 2 | ||||
-rw-r--r-- | common/ap_ro_integrity_check.c | 9 |
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)) != |