diff --git a/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.peri.xml b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.peri.xml new file mode 100644 index 0000000..cdc4e3e --- /dev/null +++ b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.peri.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.sv b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.sv new file mode 100644 index 0000000..8667263 --- /dev/null +++ b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.sv @@ -0,0 +1,48 @@ +module chacha20poly1305_timing_test( + input logic i_clk, + input logic i_rst, + + input logic [255:0] i_key, + input logic [95:0] i_nonce, + + input logic i_encrypt, + + input logic [31:0] i_data, + input logic [1:0] i_countm1, + input logic i_last, + + input logic i_valid, + output logic o_ready, + + output logic [31:0] o_data, + output logic [1:0] o_data_countm1, + output logic o_data_last, + output logic o_data_valid, + input logic i_data_ready, + + // no backpressure for the poly1305 output + output logic [127:0] o_mac, + output logic o_mac_valid +); + +chacha20_poly1305_32_ll_core u_dut ( + .i_clk (i_clk), + .i_rst (i_rst), + .i_key (i_key), + .i_nonce (i_nonce), + .i_encrypt (i_encrypt), + .i_data (i_data), + .i_countm1 (i_countm1), + .i_last (i_last), + .i_valid (i_valid), + .o_ready (o_ready), + .o_data (o_data), + .o_data_countm1 (o_data_countm1), + .o_data_last (o_data_last), + .o_data_valid (o_data_valid), + .i_data_ready (i_data_ready), + .o_mac (o_mac), + .o_mac_valid (o_mac_valid) +); + +endmodule \ No newline at end of file diff --git a/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.xml b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.xml new file mode 100644 index 0000000..d8aa151 --- /dev/null +++ b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/chacha20poly1305_timing_test.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/constraints.sdc b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/constraints.sdc new file mode 100644 index 0000000..9bfa36e --- /dev/null +++ b/ChaCha20_Poly1305_64/chacha20poly1305_timing_test/constraints.sdc @@ -0,0 +1 @@ +create_clock -period 20 -name clk [get_ports i_clk] \ No newline at end of file diff --git a/ChaCha20_Poly1305_64/doc/notes3.md b/ChaCha20_Poly1305_64/doc/notes3.md index 78b1588..5f55e38 100644 --- a/ChaCha20_Poly1305_64/doc/notes3.md +++ b/ChaCha20_Poly1305_64/doc/notes3.md @@ -179,4 +179,39 @@ this is actually an embarassingly easy fix. so if you are just looking at wireguard itself, its max is 1420 + 32? or, is it that we set the MTU to 1420 which is the max sized of the -encrypted packet, so we can't add any padding? \ No newline at end of file +encrypted packet, so we can't add any padding? + +OK in the width expander we expand to 1420 max. + +we could have a check at the begining that checks the +total length. If it is larger than 1420 then we can +send the packet to the CPU to fragment or do something with +But really all computers that are on the network should +have the MTU set to 1420 so that we can avoid this. + + +One thing we still need to support is keepalive packets. These have +no payload, but still need to be decrypted. The input FSM will take +in just the encrypted wireguard packet, without the wireguard header. +It will then strip off the tag and put it in a fifo for the output fsm +to read. If it does this to a keepalive packet, there will be no data. +If this happens, the input FSM will send in 64 bytes of dummy data, +all zeroes, along with a keepalive signal. this signal will be stored +along with the packet and when it is output to the output fsm, it will +know to ignore the actual data. + +I think this can be done entirely outside of the crypto block. + +OK so that tells us what we need to do next, the pre and postformat FSM. + +preformat FSM removes the tag, postformat FSM adds the tag back for encyrpt, +or compares the tag with the expected tag for decrypt. + +We need a metadata FIFO which tells us whether to encyrpt or decrypt. + +ohhhh right. what I really wanted to do today was synthesize this block +and see what the timing looks like. + + +We pass timing at 67 MHz. Lets try to reduce the number of flop stages in +chacha to see if we can reduce the number of flops we use. \ No newline at end of file