From 9d7cdac233aa666fa03af73241d2f780057e3a0a Mon Sep 17 00:00:00 2001 From: bsdevlin Date: Fri, 22 Feb 2019 15:54:04 -0500 Subject: [PATCH] Added test for personalization string --- ip_cores/blake2b/src/rtl/blake2b_pipe_top.sv | 2 +- ip_cores/blake2b/src/tb/blake2b_top_tb.sv | 26 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ip_cores/blake2b/src/rtl/blake2b_pipe_top.sv b/ip_cores/blake2b/src/rtl/blake2b_pipe_top.sv index d91666e..f991d54 100644 --- a/ip_cores/blake2b/src/rtl/blake2b_pipe_top.sv +++ b/ip_cores/blake2b/src/rtl/blake2b_pipe_top.sv @@ -57,7 +57,7 @@ logic [NUM_PIPE-1:0][MSG_LEN*8-1:0] msg; logic [MSG_LEN*8-1:0] msg_fixed; logic [7:0] byte_len; logic [NUM_PIPE-1:0][CTL_BITS-1:0] ctl; -logic [NUM_PIPE-1:0] eop_l, sop_l, valid; +logic [NUM_PIPE-1:0] valid; generate genvar g0, g1, g2, g3; diff --git a/ip_cores/blake2b/src/tb/blake2b_top_tb.sv b/ip_cores/blake2b/src/tb/blake2b_top_tb.sv index 7fbfe49..8648f0e 100644 --- a/ip_cores/blake2b/src/tb/blake2b_top_tb.sv +++ b/ip_cores/blake2b/src/tb/blake2b_top_tb.sv @@ -147,6 +147,31 @@ begin end endtask +// This is a test for hashing 144 bytes plus using personal string and encoding digest length +task test_144_encode_len_person_bytes(); + begin + integer signed get_len; + // 50 bytes needed for Equihash (n=200, k=9) + logic [7:0] digest_len = 'd50; + logic [127:0] POW_TAG = {32'd9, 32'd200, "WoPhsacZ"}; // ZcashPoW is reversed here + logic [common_pkg::MAX_SIM_BYTS*8-1:0] get_dat, in_dat; + $display("Running test_144_encode_len_person_bytes..."); + expected = 'ha6e2f3b234b93dab4c9a246731f31b6215dda0a3cc548c5443b3dbaa0b452265f5d0eb8ca4d7a31747967f8ecc1f0f8b021a; + in_dat = 'h000009df030000000000000000000000000000000000000000000000000001a450b5b21b1e03c3bf5813853f0000000000000000000000000000000000000000000000000000000000000000508093fb69a9d9cdf502cc6432d3c2b8bcf81d239e6b3bd59d34122355311630000000488f10fdd62f4d7868c6c21c628bc3d5dfa0f32ff719425110a4d1d61300000004; + + i_byte_len = 144; + parameters = {32'd0, 8'd1, 8'd1, 8'd0, digest_len}; + parameters[48*8 +: 16*8] = POW_TAG; + + i_block.put_stream(in_dat, i_byte_len); + out_hash.get_stream(get_dat, get_len); + // Zero out bytes above digest length + for (int i = digest_len; i < common_pkg::MAX_SIM_BYTS; i++) get_dat[i*8 +: 8] = 0; + common_pkg::compare_and_print(get_dat, expected); + $display("test_144_encode_len_person_bytes PASSED"); + end +endtask + // Main testbench calls initial begin i_block.reset_source(); @@ -159,6 +184,7 @@ initial begin test_128_bytes(); test_129_bytes(); test_140_bytes(); + test_144_encode_len_person_bytes(); #10us $finish();