aboutsummaryrefslogtreecommitdiff
path: root/sw/test-sha256
diff options
context:
space:
mode:
Diffstat (limited to 'sw/test-sha256')
-rw-r--r--sw/test-sha256/test-sha256.c89
1 files changed, 60 insertions, 29 deletions
diff --git a/sw/test-sha256/test-sha256.c b/sw/test-sha256/test-sha256.c
index d87a902..bc3190c 100644
--- a/sw/test-sha256/test-sha256.c
+++ b/sw/test-sha256/test-sha256.c
@@ -65,12 +65,56 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
+uint32_t get_w32(uint32_t addr)
+{
+ unsigned int read_addr;
+ unsigned int read_data;
+ eim_read_32(read_addr, &read_data);
+
+ return read_data;
+}
+
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
void test_single_block()
{
- // Single block test vector as specified by NIST.
- //tc0 = 512'h61626380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018;
- //res0 = 256'hBA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD;
+ uint32_t write_data;
+
+ write_data = 0x61626380;
+ eim_write_32(ADDR_BLOCK0, &write_data);
+ write_data = 0x00000000;
+ eim_write_32(ADDR_BLOCK1, &write_data);
+ eim_write_32(ADDR_BLOCK2, &write_data);
+ eim_write_32(ADDR_BLOCK3, &write_data);
+ eim_write_32(ADDR_BLOCK4, &write_data);
+ eim_write_32(ADDR_BLOCK5, &write_data);
+ eim_write_32(ADDR_BLOCK6, &write_data);
+ eim_write_32(ADDR_BLOCK7, &write_data);
+ eim_write_32(ADDR_BLOCK8, &write_data);
+ eim_write_32(ADDR_BLOCK9, &write_data);
+ eim_write_32(ADDR_BLOCK10, &write_data);
+ eim_write_32(ADDR_BLOCK11, &write_data);
+ eim_write_32(ADDR_BLOCK12, &write_data);
+ eim_write_32(ADDR_BLOCK13, &write_data);
+ eim_write_32(ADDR_BLOCK14, &write_data);
+ write_data = 0x00000018;
+ eim_write_32(ADDR_BLOCK15, &write_data);
+
+ write_data = 0x00000001;
+ eim_write_32(ADDR_CTRL, &write_data);
+
+ printf("digest0 = 0x%08x\n", get_w32(ADDR_DIGEST0));
+ printf("digest1 = 0x%08x\n", get_w32(ADDR_DIGEST1));
+ printf("digest2 = 0x%08x\n", get_w32(ADDR_DIGEST2));
+ printf("digest3 = 0x%08x\n", get_w32(ADDR_DIGEST3));
+ printf("digest4 = 0x%08x\n", get_w32(ADDR_DIGEST4));
+ printf("digest5 = 0x%08x\n", get_w32(ADDR_DIGEST5));
+ printf("digest6 = 0x%08x\n", get_w32(ADDR_DIGEST6));
+ printf("digest7 = 0x%08x\n", get_w32(ADDR_DIGEST7));
+ // What we want to see:
+ // res0 = 256'hBA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD;
}
@@ -88,42 +132,21 @@ void test_dual_block()
}
+
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void test_sha256()
{
- unsigned int write_addr;
- unsigned int write_data;
- unsigned int read_addr;
- unsigned int read_data;
- int ok;
- unsigned int i;
-
- // Dump register contents. See if we have the core.
- for (i = 0 ; i < 200 ; i += 4) {
- read_addr = SHA256_BASE + i;
- eim_read_32(read_addr, &read_data);
- printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
- }
-
- // Try to iniate block processing and then dump
- write_addr = SHA256_BASE + 0x20;
- write_data = 0x00000001;
- eim_write_32(write_addr, &write_data);
+ uint32_t i;
- // Dump register contents. See if we have the core.
- for (i = 0 ; i < 200 ; i += 4) {
- read_addr = SHA256_BASE + i;
- eim_read_32(read_addr, &read_data);
- printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
- }
+ test_single_block();
}
+
//------------------------------------------------------------------------------
-// main()
//------------------------------------------------------------------------------
-int main()
+int config_eim()
{
int ok;
unsigned int i;
@@ -139,6 +162,14 @@ int main()
printf("EIM Setup ok.\n");
}
+}
+
+//------------------------------------------------------------------------------
+// main()
+//------------------------------------------------------------------------------
+int main()
+{
+ config_eim();
test_sha256();
return 0;