[Cryptech-Commits] [user/js/keywrap] 02/02: Updated top level wrapper to better match the planned API. Updated core interface. Connected core into the top level wrapper.

git at cryptech.is git at cryptech.is
Thu Jun 28 11:19:32 UTC 2018


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

joachim at secworks.se pushed a commit to branch master
in repository user/js/keywrap.

commit 0b3c532bdf44271250206301d099f697f4cc1a43
Author: Joachim Strömbergson <joachim at secworks.se>
AuthorDate: Thu Jun 28 13:19:21 2018 +0200

    Updated top level wrapper to better match the planned API. Updated core interface. Connected core into the top level wrapper.
---
 src/rtl/keywrap.v      | 98 ++++++++++++++++++++++++++++++--------------------
 src/rtl/keywrap_core.v | 10 ++++--
 2 files changed, 66 insertions(+), 42 deletions(-)

diff --git a/src/rtl/keywrap.v b/src/rtl/keywrap.v
index 67c70af..6020731 100644
--- a/src/rtl/keywrap.v
+++ b/src/rtl/keywrap.v
@@ -73,6 +73,8 @@ module keywrap(
   localparam CTRL_ENCDEC_BIT  = 0;
   localparam CTRL_KEYLEN_BIT  = 1;
 
+  localparam ADDR_RLEN        = 8'h0c;
+
   localparam ADDR_KEY0        = 8'h10;
   localparam ADDR_KEY7        = 8'h17;
 
@@ -82,7 +84,7 @@ module keywrap(
 
   localparam CORE_NAME0       = 32'h6b657920; // "key "
   localparam CORE_NAME1       = 32'h77726170; // "wrap"
-  localparam CORE_VERSION     = 32'h302e3130; // "0.10"
+  localparam CORE_VERSION     = 32'h302e3230; // "0.20"
 
 
   //----------------------------------------------------------------
@@ -98,11 +100,14 @@ module keywrap(
   reg keylen_reg;
   reg config_we;
 
+  reg [12 : 0] rlen_reg;
+  reg [12 : 0] rlen_we;
+
   reg [31 : 0] key_reg [0 : 7];
   reg          key_we;
 
-  reg           valid_reg;
-  reg           ready_reg;
+  reg valid_reg;
+  reg ready_reg;
 
 
   //----------------------------------------------------------------
@@ -111,15 +116,11 @@ module keywrap(
   reg [31 : 0]   tmp_read_data;
   reg            tmp_error;
 
-  wire           core_encdec;
-  wire           core_init;
-  wire           core_next;
   wire           core_ready;
   wire [255 : 0] core_key;
-  wire           core_keylen;
-  wire [127 : 0] core_block;
-  wire [127 : 0] core_result;
-  wire           core_valid;
+  wire           core_api_cs;
+  wire           core_api_we;
+  wire [31 : 0]  core_api_rd_data;
 
 
   //----------------------------------------------------------------
@@ -131,13 +132,6 @@ module keywrap(
   assign core_key = {key_reg[0], key_reg[1], key_reg[2], key_reg[3],
                      key_reg[4], key_reg[5], key_reg[6], key_reg[7]};
 
-  assign core_block  = {block_reg[0], block_reg[1],
-                        block_reg[2], block_reg[3]};
-  assign core_init   = init_reg;
-  assign core_next   = next_reg;
-  assign core_encdec = encdec_reg;
-  assign core_keylen = keylen_reg;
-
 
   //----------------------------------------------------------------
   // core instantiation.
@@ -146,17 +140,21 @@ module keywrap(
                     .clk(clk),
                     .reset_n(reset_n),
 
-                    .encdec(core_encdec),
-                    .init(core_init),
-                    .next(core_next),
+                    .init(init_reg),
+                    .start(next_reg),
+                    .encdec(encdec_reg),
+
                     .ready(core_ready),
 
+                    .rlen(rlen_reg)
+
                     .key(core_key),
-                    .keylen(core_keylen),
+                    .keylen(keylen_reg),
 
-                    .block(core_block),
-                    .result(core_result),
-                    .result_valid(core_valid)
+                    .api_cs(core_api_cs),
+                    .api_we(core_api_we),
+                    .api_wr_data(write_data),
+                    .api_rd_data(core_api_rd_data)
                    );
 
 
@@ -172,13 +170,13 @@ module keywrap(
           for (i = 0 ; i < 8 ; i = i + 1)
             key_reg[i] <= 32'h0;
 
-          init_reg   <= 1'b0;
-          next_reg   <= 1'b0;
-          encdec_reg <= 1'b0;
-          keylen_reg <= 1'b0;
-
-          valid_reg  <= 1'b0;
-          ready_reg  <= 1'b0;
+          init_reg   <= 1'h0;
+          next_reg   <= 1'h0;
+          encdec_reg <= 1'h0;
+          keylen_reg <= 1'h0;
+          rlen_reg   <= 13'h0;
+          valid_reg  <= 1'h0;
+          ready_reg  <= 1'h0;
         end
       else
         begin
@@ -193,6 +191,9 @@ module keywrap(
               keylen_reg <= write_data[CTRL_KEYLEN_BIT];
             end
 
+          if (rlen_we)
+            rlen_reg <= write_data[12 : 0];
+
           if (key_we)
             key_reg[address[2 : 0]] <= write_data;
         end
@@ -206,12 +207,16 @@ module keywrap(
   //----------------------------------------------------------------
   always @*
     begin : api
-      init_new      = 1'b0;
-      next_new      = 1'b0;
-      config_we     = 1'b0;
-      key_we        = 1'b0;
-      tmp_read_data = 32'h0;
-      tmp_error     = 1'b0;
+      init_new         = 1'h0;
+      next_new         = 1'h0;
+      config_we        = 1'h0;
+      rlen_we          = 1'h0;
+      key_we           = 1'h0;
+      core_api_cs      = 1'h0;
+      core_api_we      = 1'h0;
+      core_api_rd_data = 32'h0;
+      tmp_read_data    = 32'h0;
+      tmp_error        = 1'h0;
 
       if (cs)
         begin
@@ -224,10 +229,19 @@ module keywrap(
                 end
 
               if (address == ADDR_CONFIG)
-                config_we = 1'b1;
+                config_we = 1'h1;
+
+              if (address == ADDR_RLEN)
+                config_we = 1'h1;
 
               if ((address >= ADDR_KEY0) && (address <= ADDR_KEY7))
-                key_we = 1'b1;
+                key_we = 1'h1;
+
+              if (address == ADDR_WRITE_DATA)
+                begin
+                  core_api_cs = 1'h1;
+                  core_api_we = 1'h1;
+                end
             end // if (we)
 
           else
@@ -239,6 +253,12 @@ module keywrap(
                 ADDR_CTRL:    tmp_read_data = {28'h0, keylen_reg, encdec_reg, next_reg, init_reg};
                 ADDR_STATUS:  tmp_read_data = {30'h0, valid_reg, ready_reg};
 
+              if (address == ADDR_READ_DATA)
+                begin
+                  core_api_cs   = 1'h1;
+                  tmp_read_data = core_api_rd_data;
+                end
+
                 default:
                   begin
                   end
diff --git a/src/rtl/keywrap_core.v b/src/rtl/keywrap_core.v
index 61f7859..9695b0b 100644
--- a/src/rtl/keywrap_core.v
+++ b/src/rtl/keywrap_core.v
@@ -44,15 +44,19 @@ module keywrap_core (
                      input wire           clk,
                      input wire           reset_n,
 
-                     input wire           encdec,
                      input wire           init,
+                     input wire           next,
+                     input wire           encdec,
+
                      output wire          ready,
+
+                     input wire [12 : 0]  rlen,
+
                      input wire [255 : 0] key,
                      input wire           keylen,
-                     input wire [13 : 0]  message_len,
 
+                     input wire           api_cs,
                      input wire           api_we,
-                     input wire [13 : 0]  api_addr,
                      input wire [31 : 0]  api_wr_data,
                      output wire [31 : 0] api_rd_data
                     );



More information about the Commits mailing list