[sw/test] Remove sha256_test
This is now covered by dif_hmac_smoketest.c
Signed-off-by: Miguel Osorio <miguelosorio@google.com>
diff --git a/hw/top_earlgrey/dv/chip_sim_cfg.hjson b/hw/top_earlgrey/dv/chip_sim_cfg.hjson
index 65f6f48..7ba7496 100644
--- a/hw/top_earlgrey/dv/chip_sim_cfg.hjson
+++ b/hw/top_earlgrey/dv/chip_sim_cfg.hjson
@@ -224,9 +224,9 @@
en_run_modes: ["sw_test_mode"]
}
{
- name: chip_hmac_sha256_encr
+ name: chip_dif_hmac_smoketest
uvm_test_seq: chip_sw_base_vseq
- sw_images: ["sw/device/tests/sha256_test:1"]
+ sw_images: ["sw/device/tests/dif_hmac_smoketest:1"]
en_run_modes: ["sw_test_mode"]
}
{
diff --git a/sw/device/boot_rom/bootstrap.c b/sw/device/boot_rom/bootstrap.c
index 3607719..dba8003 100644
--- a/sw/device/boot_rom/bootstrap.c
+++ b/sw/device/boot_rom/bootstrap.c
@@ -14,7 +14,6 @@
#include "sw/device/lib/dif/dif_hmac.h"
#include "sw/device/lib/dif/dif_spi_device.h"
#include "sw/device/lib/flash_ctrl.h"
-#include "sw/device/lib/runtime/check.h"
#include "sw/device/lib/runtime/hart.h"
#include "sw/device/lib/runtime/log.h"
#include "sw/device/lib/testing/check.h"
@@ -70,7 +69,12 @@
*/
static void compute_sha256(const dif_hmac_t *hmac, const void *data, size_t len,
dif_hmac_digest_t *digest) {
- CHECK(dif_hmac_mode_sha256_start(hmac) == kDifHmacOk);
+ const dif_hmac_transaction_t config = {
+ .digest_endianness = kDifHmacEndiannessLittle,
+ .message_endianness = kDifHmacEndiannessLittle,
+ };
+ CHECK(dif_hmac_mode_sha256_start(hmac, config) == kDifHmacOk,
+ "Error on hmac start.");
const char *data8 = (const char *)data;
size_t data_left = len;
while (data_left > 0) {
@@ -85,10 +89,10 @@
data_left -= bytes_sent;
}
- CHECK(dif_hmac_process(hmac) == kDifHmacOk);
+ CHECK(dif_hmac_process(hmac) == kDifHmacOk, "Error processing digest.");
dif_hmac_digest_result_t digest_result = kDifHmacDigestProcessing;
while (digest_result == kDifHmacDigestProcessing) {
- digest_result = dif_hmac_digest_read(hmac, digest);
+ digest_result = dif_hmac_finish(hmac, digest);
}
CHECK(digest_result == kDifHmacDigestOk, "Error reading the digest.");
}
@@ -212,8 +216,6 @@
dif_hmac_t hmac;
dif_hmac_config_t config = {
.base_addr = mmio_region_from_addr(TOP_EARLGREY_HMAC_BASE_ADDR),
- .message_endianness = kDifHmacEndiannessBig,
- .digest_endianness = kDifHmacEndiannessBig,
};
CHECK(dif_hmac_init(&config, &hmac) == kDifHmacOk,
"Failed to configure HMAC.");
diff --git a/sw/device/tests/meson.build b/sw/device/tests/meson.build
index 022bc97..0c67b4f 100644
--- a/sw/device/tests/meson.build
+++ b/sw/device/tests/meson.build
@@ -50,23 +50,6 @@
}
}
-sha256_test_lib = declare_dependency(
- link_with: static_library(
- 'sha256_test_lib',
- sources: ['sha256_test.c'],
- dependencies: [
- sw_lib_dif_hmac,
- sw_lib_flash_ctrl,
- sw_lib_runtime_log,
- ],
- ),
-)
-sw_tests += {
- 'sha256_test': {
- 'library': sha256_test_lib,
- }
-}
-
usbdev_test_lib = declare_dependency(
link_with: static_library(
'usbdev_test_lib',
diff --git a/sw/device/tests/sha256_test.c b/sw/device/tests/sha256_test.c
deleted file mode 100644
index ca81b47..0000000
--- a/sw/device/tests/sha256_test.c
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright lowRISC contributors.
-// Licensed under the Apache License, Version 2.0, see LICENSE for details.
-// SPDX-License-Identifier: Apache-2.0
-
-#include "sw/device/lib/base/mmio.h"
-#include "sw/device/lib/dif/dif_hmac.h"
-#include "sw/device/lib/flash_ctrl.h"
-#include "sw/device/lib/runtime/check.h"
-#include "sw/device/lib/runtime/log.h"
-#include "sw/device/lib/testing/test_main.h"
-
-#include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" // Generated.
-
-static dif_hmac_t hmac0;
-
-static const size_t kDataLen = 142;
-static const char kData[142] =
- "Every one suspects himself of at least one of "
- "the cardinal virtues, and this is mine: I am "
- "one of the few honest people that I have ever "
- "known";
-
-static const uint32_t kExpectedDigest[8] = {0xdc96c23d, 0xaf36e268, 0xcb68ff71,
- 0xe92f76e2, 0xb8a8379d, 0x426dc745,
- 0x19f5cff7, 0x4ec9c6d6};
-
-const test_config_t kTestConfig;
-
-/**
- * Computes the SHA256 of the given data.
- */
-static void compute_sha256(const dif_hmac_t *hmac, const void *data, size_t len,
- dif_hmac_digest_t *digest) {
- CHECK(dif_hmac_mode_sha256_start(hmac) == kDifHmacOk);
- const char *data8 = (const char *)data;
- size_t data_left = len;
- while (data_left > 0) {
- size_t bytes_sent;
- dif_hmac_fifo_result_t result =
- dif_hmac_fifo_push(hmac, data8, data_left, &bytes_sent);
- if (result == kDifHmacFifoOk) {
- break;
- }
- CHECK(result == kDifHmacFifoFull, "Error while pushing to FIFO.");
- data8 += bytes_sent;
- data_left -= bytes_sent;
- }
-
- CHECK(dif_hmac_process(hmac) == kDifHmacOk);
- dif_hmac_digest_result_t digest_result = kDifHmacDigestProcessing;
- while (digest_result == kDifHmacDigestProcessing) {
- digest_result = dif_hmac_digest_read(hmac, digest);
- }
- CHECK(digest_result == kDifHmacDigestOk, "Error reading the digest.");
-}
-
-const test_config_t kTestConfig = {};
-
-bool test_main(void) {
- dif_hmac_config_t config = {
- .base_addr = mmio_region_from_addr(TOP_EARLGREY_HMAC_BASE_ADDR),
- .message_endianness = kDifHmacEndiannessBig,
- .digest_endianness = kDifHmacEndiannessBig,
- };
- CHECK(dif_hmac_init(&config, &hmac0) == kDifHmacOk);
-
- dif_hmac_digest_t digest;
- compute_sha256(&hmac0, kData, kDataLen, &digest);
-
- for (uint32_t i = 0; i < 8; ++i) {
- uint32_t got = digest.digest[i];
- uint32_t want = kExpectedDigest[i];
- if (got != want) {
- LOG_ERROR("Digest mismatch at index %d: wanted 0x%x, got 0x%x.", i, want,
- got);
- // TODO: Document why this is called, or delete it.
- flash_write_scratch_reg(got);
- return false;
- }
- }
-
- return true;
-}
diff --git a/test/systemtest/config.py b/test/systemtest/config.py
index cfbe80c..9ec2008 100644
--- a/test/systemtest/config.py
+++ b/test/systemtest/config.py
@@ -87,9 +87,6 @@
"name": "pmp_smoketest_tor",
},
{
- "name": "sha256_test",
- },
- {
"name": "usbdev_test",
"targets": ["sim_verilator"],
},