aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-07-06 12:35:14 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-07-06 12:35:14 +0200
commit697456be8bf1eb4585dd0d88b185659b4bc17fe9 (patch)
tree6d15a437391e68bf71f7a5e92b7a4929b611d2af
parent694ff57dc365f0b51eaea0afc1a808d3f3f6f28c (diff)
Debugged key unwrap. First testcase for unwerap passed. Added some more debug outputs.
-rw-r--r--src/rtl/keywrap_core.v18
-rw-r--r--src/tb/tb_keywrap.v1
2 files changed, 10 insertions, 9 deletions
diff --git a/src/rtl/keywrap_core.v b/src/rtl/keywrap_core.v
index 35bdfa6..1e8ac5b 100644
--- a/src/rtl/keywrap_core.v
+++ b/src/rtl/keywrap_core.v
@@ -233,10 +233,10 @@ module keywrap_core (
a_new = 64'h0;
a_we = 1'h0;
- core_addr = block_ctr_reg - 1'h1;
+ core_addr = block_ctr_reg;
core_we = 1'h0;
- xor_val = (rlen * iteration_ctr_reg) + {51'h0, block_ctr_reg};
+ xor_val = (rlen * iteration_ctr_reg) + {51'h0, (block_ctr_reg + 1'h1)};
if (encdec)
aes_block = {a_reg, core_rd_data};
@@ -274,13 +274,13 @@ module keywrap_core (
if (block_ctr_rst)
begin
- block_ctr_new = 13'h1;
+ block_ctr_new = 13'h0;
block_ctr_we = 1'h1;
end
if (block_ctr_set)
begin
- block_ctr_new = rlen;
+ block_ctr_new = (rlen - 1);
block_ctr_we = 1'h1;
end
@@ -320,7 +320,7 @@ module keywrap_core (
if (iteration_ctr_dec)
begin
- iteration_ctr_new = iteration_ctr_reg + 1'h1;
+ iteration_ctr_new = iteration_ctr_reg - 1'h1;
iteration_ctr_we = 1'h1;
end
@@ -458,7 +458,7 @@ module keywrap_core (
CTRL_NEXT_WCHECK:
begin
- if (block_ctr_reg < rlen)
+ if (block_ctr_reg < (rlen - 1))
begin
block_ctr_inc = 1'h1;
keywrap_core_ctrl_new = CTRL_NEXT_LOOP0;
@@ -483,10 +483,10 @@ module keywrap_core (
CTRL_NEXT_UCHECK:
begin
- if (block_ctr_reg > 1)
+ if (block_ctr_reg > 0)
begin
block_ctr_dec = 1'h1;
- keywrap_core_ctrl_new = CTRL_NEXT_LOOP;
+ keywrap_core_ctrl_new = CTRL_NEXT_LOOP0;
keywrap_core_ctrl_we = 1'h1;
end
@@ -494,7 +494,7 @@ module keywrap_core (
begin
block_ctr_set = 1'h1;
iteration_ctr_dec = 1'h1;
- keywrap_core_ctrl_new = CTRL_NEXT_LOOP;
+ keywrap_core_ctrl_new = CTRL_NEXT_LOOP0;
keywrap_core_ctrl_we = 1'h1;
end
diff --git a/src/tb/tb_keywrap.v b/src/tb/tb_keywrap.v
index a13521c..edbbbcf 100644
--- a/src/tb/tb_keywrap.v
+++ b/src/tb/tb_keywrap.v
@@ -272,6 +272,7 @@ module tb_keywrap();
dut.core.core_we, dut.core.core_addr);
$display("core_rd_data = 0x%0x core_wr_data = 0x%0x ",
dut.core.core_rd_data, dut.core.core_wr_data);
+ $display("xor_val = 0x%0x", dut.core.keywrap_logic.xor_val);
$display("");