Bug updates, now working correctly for all test cases
This commit is contained in:
parent
18c08450df
commit
70e1598c45
|
@ -10,7 +10,7 @@ package blake2b_pkg;
|
|||
64'h3c6ef372fe94f82b,
|
||||
64'hbb67ae8584caa73b,
|
||||
64'h6a09e667f3bcc908
|
||||
};
|
||||
};
|
||||
|
||||
// Sigma permutations used for G function blocks and input messages
|
||||
parameter [16*10-1:0][31:0] SIGMA = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Implemented from RFC-7693, The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)
|
||||
/* Implemented from RFC-7693, The BLAKE2b Cryptographic Hash and Message Authentication Code (MAC)
|
||||
* Parameters are passed in as an input. Inputs and outputs are AXI stream and respect flow control.
|
||||
* Only only hash is computed at a time, and takes 26 clocks * number of 128 Byte message blocks.
|
||||
*/
|
||||
|
@ -36,17 +36,15 @@ logic [7:0] byte_len_l;
|
|||
// Pipelining logic that has no reset
|
||||
always_ff @(posedge i_clk) begin
|
||||
|
||||
if (blake2_state == STATE_IDLE && ~i_block.rdy)
|
||||
if (blake2_state == STATE_IDLE)
|
||||
block_r <= 0;
|
||||
|
||||
if (i_block.val && i_block.rdy) begin
|
||||
if (i_block.val && i_block.rdy)
|
||||
block_r <= i_block.dat;
|
||||
end
|
||||
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
if (g_col == 0)
|
||||
v_tmp[i] <= g_out[blake2b_pkg::G_MAPPING[i]];
|
||||
for (int i = 0; i < 16; i++) begin
|
||||
v_tmp[blake2b_pkg::G_MAPPING[i]] <= g_out[i];
|
||||
end
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
if (blake2_state == STATE_ROUNDS)
|
||||
|
@ -99,28 +97,25 @@ always_ff @(posedge i_clk) begin
|
|||
end
|
||||
end
|
||||
// Here we do the compression over 12 rounds, each round can be done in two clock cycles
|
||||
// After we do 12 rounds we increment counter t
|
||||
STATE_ROUNDS: begin
|
||||
|
||||
// Update local work vector with output of G function blocks depending on column or diagonal operation
|
||||
for (int i = 0; i < 16; i++) begin
|
||||
for (int i = 0; i < 16; i++)
|
||||
v[i] <= g_out[16 + blake2b_pkg::G_MAPPING_DIAG[i]];
|
||||
end
|
||||
|
||||
if (g_col) begin
|
||||
if (g_col)
|
||||
round_cntr <= round_cntr + 1;
|
||||
end else begin
|
||||
else
|
||||
round_cntr_msg <= (round_cntr_msg + 1) % 10;
|
||||
end
|
||||
|
||||
if (round_cntr == ROUNDS-1)
|
||||
round_cntr_fin <= 1;
|
||||
|
||||
if (round_cntr_fin) begin
|
||||
if (block_eop_l)
|
||||
blake2_state <= STATE_FINAL_BLOCK;
|
||||
else begin
|
||||
else
|
||||
blake2_state <= STATE_NEXT_BLOCK;
|
||||
end
|
||||
end
|
||||
end
|
||||
STATE_NEXT_BLOCK: begin
|
||||
|
|
|
@ -37,6 +37,7 @@ task rfc_test();
|
|||
begin
|
||||
integer signed get_len;
|
||||
logic [common_pkg::MAX_SIM_BYTS*8-1:0] get_dat;
|
||||
$display("Running rfc_test...\n");
|
||||
expected = 'h239900d4ed8623b95a92f1dba88ad31895cc3345ded552c22d79ab2a39c5877dd1a2ffdb6fbb124bb7c45a68142f214ce9f6129fb697276a0d4d1c983fa580ba;
|
||||
i_byte_len = 3;
|
||||
i_block.put_stream("cba", i_byte_len);
|
||||
|
@ -51,6 +52,7 @@ task test_128_bytes();
|
|||
begin
|
||||
integer signed get_len;
|
||||
logic [common_pkg::MAX_SIM_BYTS*8-1:0] get_dat;
|
||||
$display("Running test_128_bytes...");
|
||||
expected = 'hd2a56bb7bb1ff1fffcf2f151522455e32969ddfeb409b105f45299b8cbd68eb370fd6d45d63981d23cd2686dfd9a76f5b1d134be076f7d08ecc457522042e34a;
|
||||
i_byte_len = 128;
|
||||
i_block.put_stream("monek14SFMpNgHz12zMfplMfcHkx6JhKhSWTNwzGiq8UiPa4n4Ehq363oHG92GPDVpvQut4ui5e6XxieeKTn1THLWiMZ0iaOFndxcT6FGPgmHXQ5zJU96X71zfWbvUQs", i_byte_len);
|
||||
|
@ -65,6 +67,7 @@ task test_140_bytes();
|
|||
begin
|
||||
integer signed get_len;
|
||||
logic [common_pkg::MAX_SIM_BYTS*8-1:0] get_dat;
|
||||
$display("Running test_140_bytes...");
|
||||
expected = 'h2012a869a3b89a69ffc954f6855c7f61a61190553dc487171ec3fe944d04c83cd4c842fff5a8258d5e14b05b7b6f30e8ddcb754d719137ec42fb5cdb562f8c89;
|
||||
i_byte_len = 140;
|
||||
i_block.put_stream("YbEAEzgJ1tgC3t6vDaJFqlWp1PaL482f7iZZzRj3xXpY2PPupwdTKAaBzB6KuN6j0alaoaFQfNboDbkNv5KDs5d7zN9JssrtOjGJdrVLfvb7uAdnVYoIgIv2zbXUQIPpwWdzEzj1CzX5", i_byte_len);
|
||||
|
|
Loading…
Reference in New Issue