[Cryptech-Commits] [test/novena_base] 01/01: (1) Adding symbols for all registers in the sha256 api.

git at cryptech.is git at cryptech.is
Wed Feb 4 16:55:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

joachim at secworks.se pushed a commit to branch sha256_core
in repository test/novena_base.

commit 39140593d239f5043a762334d8505af8c8de349b
Author: Joachim Strömbergson <joachim at secworks.se>
Date:   Wed Feb 4 17:54:42 2015 +0100

    (1) Adding symbols for all registers in the sha256 api.
---
 sw/test-sha256/test-sha256.c | 115 +++++++++++++++++--------------------------
 1 file changed, 45 insertions(+), 70 deletions(-)

diff --git a/sw/test-sha256/test-sha256.c b/sw/test-sha256/test-sha256.c
index 9f7b331..9b0fa1d 100644
--- a/sw/test-sha256/test-sha256.c
+++ b/sw/test-sha256/test-sha256.c
@@ -18,53 +18,49 @@
 
 //------------------------------------------------------------------------------
 // Defines
+//
+// Symbolic names for the SHA256 core API.
 //------------------------------------------------------------------------------
 #define SHA256_PREFIX (0x0000)
-#define SHA_BASE (EIM_BASE_ADDR + SHA256_PREFIX)
-
-#define DEMO_ADDER_BASE_ADDR (EIM_BASE_ADDR + 0x0000)
-#define DEMO_ADDER_X_REG     (DEMO_ADDER_BASE_ADDR + 0)
-#define DEMO_ADDER_Y_REG     (DEMO_ADDER_BASE_ADDR + 4)
-
-
-//------------------------------------------------------------------------------
-// Testing Parameters
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-void test_regs() 
-{
-  unsigned int read_addr;
-  unsigned int read_data;
-  unsigned int write_addr;
-  unsigned int write_data;
-  unsigned int i;
-
-//
-//  for (i = 0 ; i < 0x40000 ; i += 4) {
-//    read_addr = EIM_BASE_ADDR + i;
-//    eim_read_32(read_addr, &read_data);
-//    printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-//  }
-
-  read_addr = DEMO_ADDER_X_REG;
-  eim_read_32(read_addr, &read_data);
-  printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-
-  read_addr = DEMO_ADDER_Y_REG;
-  eim_read_32(read_addr, &read_data);
-  printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-
-  write_addr = DEMO_ADDER_Y_REG;
-  write_data = 0xaa55aa55;
-  eim_write_32(write_addr, &write_data);
-
-  read_addr = DEMO_ADDER_Y_REG;
-  eim_read_32(read_addr, &read_data);
-  printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-}
+#define SHA256_BASE (EIM_BASE_ADDR + SHA256_PREFIX)
+
+#define ADDR_NAME0       (SHA256_BASE + (0x00 << 2))
+#define ADDR_NAME1       (SHA256_BASE + (0x01 << 2))
+#define ADDR_VERSION     (SHA256_BASE + (0x02 << 2))
+
+#define ADDR_CTRL        (SHA256_BASE + (0x08 << 2))
+#define CTRL_INIT_BIT    0
+#define CTRL_NEXT_BIT    1
+
+#define ADDR_STATUS      (SHA256_BASE + (0x09 << 2))
+#define STATUS_READY_BIT 0
+#define STATUS_VALID_BIT 1
+
+#define ADDR_BLOCK0      (SHA256_BASE + (0x10 << 2))
+#define ADDR_BLOCK1      (SHA256_BASE + (0x11 << 2))
+#define ADDR_BLOCK2      (SHA256_BASE + (0x12 << 2))
+#define ADDR_BLOCK3      (SHA256_BASE + (0x13 << 2))
+#define ADDR_BLOCK4      (SHA256_BASE + (0x14 << 2))
+#define ADDR_BLOCK5      (SHA256_BASE + (0x15 << 2))
+#define ADDR_BLOCK6      (SHA256_BASE + (0x16 << 2))
+#define ADDR_BLOCK7      (SHA256_BASE + (0x17 << 2))
+#define ADDR_BLOCK8      (SHA256_BASE + (0x18 << 2))
+#define ADDR_BLOCK9      (SHA256_BASE + (0x19 << 2))
+#define ADDR_BLOCK10     (SHA256_BASE + (0x1a << 2))
+#define ADDR_BLOCK11     (SHA256_BASE + (0x1b << 2))
+#define ADDR_BLOCK12     (SHA256_BASE + (0x1c << 2))
+#define ADDR_BLOCK13     (SHA256_BASE + (0x1d << 2))
+#define ADDR_BLOCK14     (SHA256_BASE + (0x1e << 2))
+#define ADDR_BLOCK15     (SHA256_BASE + (0x1f << 2))
+
+#define ADDR_DIGEST0     (SHA256_BASE + (0x20 << 2))
+#define ADDR_DIGEST1     (SHA256_BASE + (0x21 << 2))
+#define ADDR_DIGEST2     (SHA256_BASE + (0x22 << 2))
+#define ADDR_DIGEST3     (SHA256_BASE + (0x23 << 2))
+#define ADDR_DIGEST4     (SHA256_BASE + (0x24 << 2))
+#define ADDR_DIGEST5     (SHA256_BASE + (0x25 << 2))
+#define ADDR_DIGEST6     (SHA256_BASE + (0x26 << 2))
+#define ADDR_DIGEST7     (SHA256_BASE + (0x27 << 2))
 
 
 //------------------------------------------------------------------------------
@@ -80,40 +76,19 @@ void test_sha256()
 
   // Dump register contents. See if we have the core.
   for (i = 0 ; i < 200 ; i += 4) {
-    read_addr = SHA_BASE + i;
+    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 = SHA_BASE + 0x20;
+  // Try to iniate block processing and then dump
+  write_addr = SHA256_BASE + 0x20;
   write_data = 0x00000001;
   eim_write_32(write_addr, &write_data);
 
   // Dump register contents. See if we have the core.
   for (i = 0 ; i < 200 ; i += 4) {
-    read_addr = SHA_BASE + i;
-    eim_read_32(read_addr, &read_data);
-    printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-  }
-
-  // Dump register contents. See if we have the core.
-  for (i = 0 ; i < 200 ; i += 4) {
-    read_addr = SHA_BASE + i;
-    eim_read_32(read_addr, &read_data);
-    printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-  }
-
-  // Dump register contents. See if we have the core.
-  for (i = 0 ; i < 200 ; i += 4) {
-    read_addr = SHA_BASE + i;
-    eim_read_32(read_addr, &read_data);
-    printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
-  }
-
-  // Dump register contents. See if we have the core.
-  for (i = 0 ; i < 200 ; i += 4) {
-    read_addr = SHA_BASE + i;
+    read_addr = SHA256_BASE + i;
     eim_read_32(read_addr, &read_data);
     printf("address 0x%08x = 0x%08x\n", read_addr, read_data);
   }



More information about the Commits mailing list