[Cryptech-Commits] [user/shatov/modexp_fpga_model] branch master updated: Generate additional quantities required for testing of CRT in hardware.
git at cryptech.is
git at cryptech.is
Thu Aug 10 12:59:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
meisterpaul1 at yandex.ru pushed a commit to branch master
in repository user/shatov/modexp_fpga_model.
The following commit(s) were added to refs/heads/master by this push:
new d16d1a5 Generate additional quantities required for testing of CRT in hardware.
d16d1a5 is described below
commit d16d1a541233ab2c950ec1b534a447636aaf44c1
Author: Pavel V. Shatov (Meister) <meisterpaul1 at yandex.ru>
AuthorDate: Thu Aug 10 15:58:05 2017 +0300
Generate additional quantities required for testing of CRT in hardware.
---
test/format_test_vectors.py | 37 +++++++++++++------
test/modexp_fpga_model_vectors.v | 80 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+), 11 deletions(-)
diff --git a/test/format_test_vectors.py b/test/format_test_vectors.py
index c56fe18..f9e4ba8 100644
--- a/test/format_test_vectors.py
+++ b/test/format_test_vectors.py
@@ -194,13 +194,17 @@ def calc_montgomery_n_coeff(k, n):
#
# format one test vector
#
-def format_verilog_include(f, key, n, m, d, s):
+def format_verilog_include(f, key, n, m, d, s, p, q, dp, dq, mp, mq):
# calculate factor to bring message into Montgomery domain
factor = calc_montgomery_factor(int(key), n)
+ factor_p = calc_montgomery_factor(int(key)//2, p);
+ factor_q = calc_montgomery_factor(int(key)//2, q);
- # calculate helper coefficient for Montgomery multiplication
+ # calculate helper coefficients for Montgomery multiplication
n_coeff = calc_montgomery_n_coeff(int(key), n)
+ p_coeff = calc_montgomery_n_coeff(int(key)//2, p)
+ q_coeff = calc_montgomery_n_coeff(int(key)//2, q)
# calculate the extra coefficient Montgomery multiplication brings in
coeff = modinv(1 << int(key), n)
@@ -209,14 +213,25 @@ def format_verilog_include(f, key, n, m, d, s):
m_factor = (m * factor * coeff) % n
# write all numbers
- format_verilog_concatenation(f, m, "localparam [" + str(int(key)-1) + ":0] M_" + str(key) + " =\n")
- format_verilog_concatenation(f, n, "localparam [" + str(int(key)-1) + ":0] N_" + str(key) + " =\n")
- format_verilog_concatenation(f, n_coeff, "localparam [" + str(int(key)-1) + ":0] N_COEFF_" + str(key) + " =\n")
- format_verilog_concatenation(f, factor, "localparam [" + str(int(key)-1) + ":0] FACTOR_" + str(key) + " =\n")
- format_verilog_concatenation(f, coeff, "localparam [" + str(int(key)-1) + ":0] COEFF_" + str(key) + " =\n")
- format_verilog_concatenation(f, m_factor, "localparam [" + str(int(key)-1) + ":0] M_FACTOR_" + str(key) + " =\n")
- format_verilog_concatenation(f, d, "localparam [" + str(int(key)-1) + ":0] D_" + str(key) + " =\n")
- format_verilog_concatenation(f, s, "localparam [" + str(int(key)-1) + ":0] S_" + str(key) + " =\n")
+ format_verilog_concatenation(f, m, "localparam [" + str(int(key)-1) + ":0] M_" + key + " =\n")
+ format_verilog_concatenation(f, n, "localparam [" + str(int(key)-1) + ":0] N_" + key + " =\n")
+ format_verilog_concatenation(f, n_coeff, "localparam [" + str(int(key)-1) + ":0] N_COEFF_" + key + " =\n")
+ format_verilog_concatenation(f, factor, "localparam [" + str(int(key)-1) + ":0] FACTOR_" + key + " =\n")
+ format_verilog_concatenation(f, coeff, "localparam [" + str(int(key)-1) + ":0] COEFF_" + key + " =\n")
+ format_verilog_concatenation(f, m_factor, "localparam [" + str(int(key)-1) + ":0] M_FACTOR_" + key + " =\n")
+ format_verilog_concatenation(f, d, "localparam [" + str(int(key)-1) + ":0] D_" + key + " =\n")
+ format_verilog_concatenation(f, s, "localparam [" + str(int(key)-1) + ":0] S_" + key + " =\n")
+
+ format_verilog_concatenation(f, p, "localparam [" + str(int(key)//2-1) + ":0] P_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, q, "localparam [" + str(int(key)//2-1) + ":0] Q_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, p_coeff, "localparam [" + str(int(key)//2-1) + ":0] P_COEFF_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, q_coeff, "localparam [" + str(int(key)//2-1) + ":0] Q_COEFF_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, factor_p, "localparam [" + str(int(key)//2-1) + ":0] FACTOR_P_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, factor_q, "localparam [" + str(int(key)//2-1) + ":0] FACTOR_Q_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, dp, "localparam [" + str(int(key)//2-1) + ":0] DP_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, dq, "localparam [" + str(int(key)//2-1) + ":0] DQ_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, mp, "localparam [" + str(int(key)//2-1) + ":0] MP_" + str(int(key)//2) + " =\n")
+ format_verilog_concatenation(f, mq, "localparam [" + str(int(key)//2-1) + ":0] MQ_" + str(int(key)//2) + " =\n")
#
@@ -359,7 +374,7 @@ if __name__ == "__main__":
# format numbers and write to file
format_c_header(file_h, key, modulus, message, secret, signature, prime1, prime2, exponent1, exponent2, message1, message2)
- format_verilog_include(file_v, key, modulus, message, secret, signature)
+ format_verilog_include(file_v, key, modulus, message, secret, signature, prime1, prime2, exponent1, exponent2, message1, message2)
# done
diff --git a/test/modexp_fpga_model_vectors.v b/test/modexp_fpga_model_vectors.v
index d5284c9..c86f7ba 100644
--- a/test/modexp_fpga_model_vectors.v
+++ b/test/modexp_fpga_model_vectors.v
@@ -40,6 +40,46 @@ localparam [383:0] S_384 =
32'ha76b945b, 32'h49a3f645, 32'h76801499, 32'hb98e6a16,
32'hd2467b6a, 32'h75b7d614, 32'h0fff0fde, 32'hb31d1819};
+localparam [191:0] P_192 =
+ {32'he9ac4cf6, 32'h03b2d80a, 32'h7f1d091e, 32'h49d5f1a0,
+ 32'hac2ae4ff, 32'hbf9bf375};
+
+localparam [191:0] Q_192 =
+ {32'hc1468f3e, 32'hc6909231, 32'h5a4d74ba, 32'h477b303f,
+ 32'h4b2e10d1, 32'h1f44e815};
+
+localparam [191:0] P_COEFF_192 =
+ {32'h8ba8d46c, 32'hb4ed830d, 32'hfbb97c6e, 32'h72d150d3,
+ 32'h72d21392, 32'h70d2fb23};
+
+localparam [191:0] Q_COEFF_192 =
+ {32'hd863905a, 32'hc1541c8a, 32'h25952b0e, 32'ha62b0348,
+ 32'h837f149f, 32'hd6cc58c3};
+
+localparam [191:0] FACTOR_P_192 =
+ {32'h886bad59, 32'h9bf7a46e, 32'h482ed232, 32'he55164cf,
+ 32'hcb46a9e8, 32'he9bd888b};
+
+localparam [191:0] FACTOR_Q_192 =
+ {32'h324b776e, 32'h3734d186, 32'h73dc8796, 32'h9e1aba2c,
+ 32'h4d5df285, 32'he97656b7};
+
+localparam [191:0] DP_192 =
+ {32'h69b6c286, 32'h95fbc613, 32'h51988034, 32'h8cb0d684,
+ 32'h9aff38e4, 32'h9ef9ddb5};
+
+localparam [191:0] DQ_192 =
+ {32'h1eda82b7, 32'h84bf4377, 32'h39712ff7, 32'h24be179f,
+ 32'ha302c190, 32'h80ab6159};
+
+localparam [191:0] MP_192 =
+ {32'h9e163bb5, 32'h35e718cb, 32'hcde52b7b, 32'h5db8552b,
+ 32'h46a300e0, 32'h34f91e6b};
+
+localparam [191:0] MQ_192 =
+ {32'h7b01a724, 32'h90f0d5f9, 32'h9e237ce5, 32'h6d31fd28,
+ 32'h4ecb9dad, 32'h58bf366a};
+
localparam [511:0] M_512 =
{32'h005536b6, 32'h43ea651f, 32'h2fd3c70a, 32'ha83659cb,
32'hd0c1f47b, 32'ha8033730, 32'h29c6b082, 32'h6db48613,
@@ -88,3 +128,43 @@ localparam [511:0] S_512 =
32'hfd1e029d, 32'hfe887387, 32'h4312635f, 32'hb2b54b8d,
32'h5d3b379e, 32'h161eaa4f, 32'hedfd932b, 32'h780f0203};
+localparam [255:0] P_256 =
+ {32'hfedea889, 32'h97cfdb79, 32'hcca87074, 32'he5abcda1,
+ 32'h3be201c4, 32'hc416fd15, 32'hf2130931, 32'h61ff5937};
+
+localparam [255:0] Q_256 =
+ {32'hf0889147, 32'h5aa60f93, 32'hb9927d86, 32'h8f795c5c,
+ 32'h8e98dcf2, 32'had3aad74, 32'h9441583a, 32'h967dce41};
+
+localparam [255:0] P_COEFF_256 =
+ {32'h7af63ffc, 32'h428d9408, 32'h86e79fb9, 32'h018dad77,
+ 32'h4ff704df, 32'h93effb1e, 32'h265d181a, 32'h47ae5379};
+
+localparam [255:0] Q_COEFF_256 =
+ {32'hd27f8aa0, 32'h9f2b9800, 32'h2dfd2392, 32'h4f868b9d,
+ 32'h0fc51e1d, 32'h022de65b, 32'ha55f9ad1, 32'h0676be3f};
+
+localparam [255:0] FACTOR_P_256 =
+ {32'h1a5f27a1, 32'h8d16b0cb, 32'h8c2751b8, 32'h106a099c,
+ 32'ha6efbadd, 32'hcb313a5f, 32'hf530eeb6, 32'hbbc7d8f5};
+
+localparam [255:0] FACTOR_Q_256 =
+ {32'h6794987c, 32'h932203a6, 32'h8c5b1e68, 32'h18d458e6,
+ 32'h6737f12a, 32'h664d4187, 32'hc4ec03ba, 32'h4bd3d0c2};
+
+localparam [255:0] DP_256 =
+ {32'h2504d437, 32'hfffbe9e5, 32'hfc0aef22, 32'h9b8563bd,
+ 32'haa83fe3b, 32'hc53b8d91, 32'h15731c5f, 32'hb6db2eeb};
+
+localparam [255:0] DQ_256 =
+ {32'hd3265fba, 32'h2eb65638, 32'h4d106ec7, 32'h000dfe69,
+ 32'h75f87505, 32'h47d299d0, 32'h1c115cdd, 32'h599ca8c1};
+
+localparam [255:0] MP_256 =
+ {32'h23359955, 32'hcad299b6, 32'h049bb248, 32'h3828b6a5,
+ 32'h74c85825, 32'h7dd8e109, 32'h07edbda9, 32'h4980c2c9};
+
+localparam [255:0] MQ_256 =
+ {32'h8578120b, 32'h91f4ca9e, 32'h371d3e70, 32'h0005bb89,
+ 32'hd31ed864, 32'h477bd9cf, 32'h65a1f03b, 32'h606d3bc8};
+
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list