URL
https://opencores.org/ocsvn/hight/hight/trunk
Subversion Repositories hight
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 1 to Rev 2
- ↔ Reverse comparison
Rev 1 → Rev 2
/hight/trunk/testbench/tb_RF.v
0,0 → 1,326
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Testbench of round function module for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
`timescale 1ns/1ps |
|
module tb_RF; |
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
reg i_op ; |
|
reg[31:0] i_rsk ; |
|
reg[63:0] i_rf_in ; |
|
reg i_rf_final ; |
|
wire[63:0] o_rf_out ; |
|
|
|
//===================================== |
// |
// PORT MAPPING |
// |
//===================================== |
// uud0 |
RF uut0_RF( |
.i_op (i_op ), |
.i_rsk (i_rsk ), |
.i_rf_in (i_rf_in ), |
.i_rf_final(i_rf_final), |
|
.o_rf_out (o_rf_out ) |
); |
//===================================== |
// |
// STIMULUS |
// |
//===================================== |
|
// stimulus |
integer i; |
initial begin |
|
|
$display("============== TEST VECTORS 1 =============="); |
// encryption & inter |
i_op = 1'b0; |
i_rf_final = 1'b0; |
i_rf_in = 64'h0000001100220033; |
i_rsk = 32'he7135b59; |
|
#50; |
|
$display("Encryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h00ce1138223f33e7) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// encryption & final |
i_op = 1'b0; |
i_rf_final = 1'b1; |
i_rf_in = 64'h5d3846d148a1def3; |
i_rsk = 32'hd1357c79; |
|
#50; |
|
$display("Encryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h003818d1d9a103f3) ? "Correct" : |
"Wrong", o_rf_out ); |
|
#50; |
|
// decryption & inter |
i_op = 1'b1; |
i_rf_final = 1'b0; |
i_rf_in = 64'h003818d1d9a103f3; |
i_rsk = 32'h797c35d1; |
|
#50; |
|
$display("decryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'hf35d3846d148a1de)? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// decryption & final |
i_op = 1'b1; |
i_rf_final = 1'b1; |
i_rf_in = 64'he700ce1138223f33; |
i_rsk = 32'h595b13e7; |
|
#50; |
|
$display("decryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h0000001100220033) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
$display("============== TEST VECTORS 2 =============="); |
// encryption & inter |
i_op = 1'b0; |
i_rf_final = 1'b0; |
i_rf_in = 64'h00ee222144886643; |
i_rsk = 32'h4e587e5a; |
|
#50; |
|
$display("Encryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'hee2d21b1880a435f) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// encryption & final |
i_op = 1'b0; |
i_rf_final = 1'b1; |
i_rf_in = 64'hf7fdf850f8529dd8; |
i_rsk = 32'he2345934; |
|
#50; |
|
$display("Encryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h23fd9f50e552e6d8) ? "Correct" : |
"Wrong", o_rf_out ); |
|
#50; |
|
// decryption & inter |
i_op = 1'b1; |
i_rf_final = 1'b0; |
i_rf_in = 64'h23fd9f50e552e6d8; |
i_rsk = 32'h345934e2; |
|
#50; |
|
$display("decryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'hd8f7fdf850f8529d)? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// decryption & final |
i_op = 1'b1; |
i_rf_final = 1'b1; |
i_rf_in = 64'h5fee2d21b1880a43; |
i_rsk = 32'h5a7e584e; |
|
#50; |
|
$display("decryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h00ee222144886643) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
$display("============== TEST VECTORS 3 =============="); |
// encryption & inter |
i_op = 1'b0; |
i_rf_final = 1'b0; |
i_rf_in = 64'h0123456889a9cdf2; |
i_rsk = 32'h27437b69; |
|
#50; |
|
$display("Encryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h23e16815a93af283) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// encryption & final |
i_op = 1'b0; |
i_rf_final = 1'b1; |
i_rf_in = 64'h21630d95692db157; |
i_rsk = 32'h61356c59; |
|
#50; |
|
$display("Encryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h7a63b2958d2df457) ? "Correct" : |
"Wrong", o_rf_out ); |
|
#50; |
|
// decryption & inter |
i_op = 1'b1; |
i_rf_final = 1'b0; |
i_rf_in = 64'h7a63b2958d2df457; |
i_rsk = 32'h596c3561; |
|
#50; |
|
$display("decryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h5721630d95692db1)? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// decryption & final |
i_op = 1'b1; |
i_rf_final = 1'b1; |
i_rf_in = 64'h8323e16815a93af2; |
i_rsk = 32'h697b4327; |
|
#50; |
|
$display("decryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h0123456889a9cdf2) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
$display("============== TEST VECTORS 4 =============="); |
// encryption & inter |
i_op = 1'b0; |
i_rf_final = 1'b0; |
i_rf_in = 64'hb4366bbdeb6b4ad0; |
i_rsk = 32'h38789841; |
|
#50; |
|
$display("Encryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'h368cbd8d6b48d053) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// encryption & final |
i_op = 1'b0; |
i_rf_final = 1'b1; |
i_rf_in = 64'h7d193f3390b731df; |
i_rsk = 32'hd75d461a; |
|
#50; |
|
$display("Encryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'hcc197a3320b71fdf) ? "Correct" : |
"Wrong", o_rf_out ); |
|
#50; |
|
// decryption & inter |
i_op = 1'b1; |
i_rf_final = 1'b0; |
i_rf_in = 64'hcc197a3320b71fdf; |
i_rsk = 32'h1a465dd7; |
|
#50; |
|
$display("decryption&inter : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'hdf7d193f3390b731)? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
// decryption & final |
i_op = 1'b1; |
i_rf_final = 1'b1; |
i_rf_in = 64'h53368cbd8d6b48d0; |
i_rsk = 32'h41987838; |
|
#50; |
|
$display("decryption&final : i_rf_in = %16h , i_rsk = %8h o_rf_out : (%s) = %16h", |
i_rf_in, i_rsk, (o_rf_out == 64'hb4366bbdeb6b4ad0) ? "Correct" : |
"Wrong", o_rf_out ); |
#50; |
|
$finish; |
|
end |
|
|
// vcd dump |
initial begin |
$dumpfile("dump/sim_tb_RF.vcd"); |
$dumpvars(0, tb_RF); |
end |
|
|
endmodule |
|
|
/hight/trunk/testbench/tb_WF.v
0,0 → 1,239
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Testbench of whitening function for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
`timescale 1ns/1ps |
|
module tb_WF; |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
|
reg i_op ; |
reg[63:0] i_wf_in ; |
reg[31:0] i_wk ; |
|
wire[63:0] o_wf_out ; |
|
//===================================== |
// |
// |
// |
//===================================== |
// uud0 |
WF uut0_WF( |
.i_op (i_op ), |
.i_wf_in (i_wf_in ), |
.i_wk (i_wk ), |
|
.o_wf_out(o_wf_out) |
); |
|
|
|
//===================================== |
// |
// STIMULUS |
// |
//===================================== |
|
|
// stimulus |
integer i; |
initial begin |
#1000; |
|
|
$display("//===============================//"); |
$display("//========= SIM START ===========//"); |
$display("//===============================//"); |
$display("********** Test vectors 1 *********"); |
i_op = 1'b0; |
i_wf_in = 64'h00_00_00_00_00_00_00_00 ; |
i_wk = 32'h00_11_22_33 ; |
#50; |
$display ("Encryption(I) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'h0000001100220033) ? "Correct" : "Wrong", o_wf_out ); |
#50; |
|
i_op = 1'b0; |
i_wf_in = 64'h00_38_18_d1_d9_a1_03_f3; |
i_wk = 32'hcc_dd_ee_ff; |
#50; |
$display ("Encryption(F) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'h00f418aed94f03f2) ? "Correct" : "Wrong", o_wf_out ); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'h00_f4_18_ae_d9_4f_03_f2 ; |
i_wk = 32'hcc_dd_ee_ff ; |
#50; |
$display ("Decryption (F-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'h003818d1d9a103f3) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'h00_00_00_11_00_22_00_33; |
i_wk = 32'h00_11_22_33; |
#50; |
$display ("Decryption (I-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'h0000000000000000) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
|
|
|
$display("********** Test vectors 2 *********"); |
i_op = 1'b0; |
i_wf_in = 64'h00_11_22_33_44_55_66_77 ; |
i_wk = 32'hff_ee_dd_cc ; |
#50; |
$display ("Encryption(I) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'h00ee222144886643) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b0; |
i_wf_in = 64'h23_fd_9f_50_e5_52_e6_d8; |
i_wk = 32'h33_22_11_00; |
#50; |
$display ("Encryption(F) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'h23ce9f72e543e6d8) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'h23_ce_9f_72_e5_43_e6_d8 ; |
i_wk = 32'h33_22_11_00 ; |
#50; |
$display ("Decryption(F-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'h23fd9f50e552e6d8) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'h00_ee_22_21_44_88_66_43; |
i_wk = 32'hff_ee_dd_cc; |
#50; |
$display ("Decryption(I-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'h0011223344556677) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
|
|
|
$display("********** Test vectors 3 *********"); |
i_op = 1'b0; |
i_wf_in = 64'h01_23_45_67_89_ab_cd_ef ; |
i_wk = 32'h00_01_02_03 ; |
#50; |
$display ("Encryption(I) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'h0123456889a9cdf2) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b0; |
i_wf_in = 64'h7a_63_b2_95_8d_2d_f4_57; |
i_wk = 32'h0c_0d_0e_0f; |
#50; |
$display ("Encryption(F) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'h7a6fb2a28d23f466) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'h7a_6f_b2_a2_8d_23_f4_66 ; |
i_wk = 32'h0c_0d_0e_0f ; |
#50; |
$display ("Decryption(F-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'h7a63b2958d2df457) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'h01_23_45_68_89_a9_cd_f2; |
i_wk = 32'h00_01_02_03; |
#50; |
$display ("Decryption(I-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'h0123456789abcdef) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
|
|
|
$display("********** Test vectors 4 *********"); |
i_op = 1'b0; |
i_wf_in = 64'hb4_1e_6b_e2_eb_a8_4a_14 ; |
i_wk = 32'h28_db_c3_bc ; |
#50; |
$display ("Encryption(I) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'hb4366bbdeb6b4ad0) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b0; |
i_wf_in = 64'hcc_19_7a_33_20_b7_1f_df; |
i_wk = 32'h1d_42_2b_e7; |
#50; |
$display ("Encryption(F) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h" , i_wf_in, i_wk, (o_wf_out == 64'hcc047a75209c1fc6) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'hcc_04_7a_75_20_9c_1f_c6 ; |
i_wk = 32'h1d_42_2b_e7 ; |
#50; |
$display ("Decryption(F-) : i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'hcc197a3320b71fdf) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
i_op = 1'b1; |
i_wf_in = 64'hb4_36_6b_bd_eb_6b_4a_d0; |
i_wk = 32'h28_db_c3_bc; |
#50; |
$display ("Decryption(I-): i_wf_in = %16h, i_wk = %8h ==> o_wf_out (%s) = %16h ", i_wf_in, i_wk, (o_wf_out == 64'hb41e6be2eba84a14) ? "Correct" : "Wrong", o_wf_out); |
#50; |
|
|
|
|
$display("========== SIM END =========="); |
$finish; |
end |
|
// vcd dump |
initial begin |
$dumpfile("dump/sim_tb_WF.vcd"); |
$dumpvars(0, tb_WF); |
end |
|
|
endmodule |
|
/hight/trunk/testbench/tb_HIGHT_CORE_TOP.v
0,0 → 1,659
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Testbench of top module for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
`timescale 1ns/1ps |
|
module tb_HIGHT_CORE_TOP; |
|
event do_finish; |
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
parameter HP_CLK = 5; // Half period of Clock |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
reg rstn ; |
reg clk ; |
|
reg i_mk_rdy ; |
reg[127:0] i_mk ; |
|
reg i_post_rdy ; |
|
reg i_op ; |
|
reg i_text_val ; |
reg[63:0] i_text_in ; |
|
wire o_text_done ; |
wire[63:0] o_text_out ; |
|
wire o_rdy ; |
|
|
//===================================== |
// |
// PORT MAPPING |
// |
//===================================== |
// uut |
HIGHT_CORE_TOP uut_HIGHT_CORE_TOP( |
.rstn (rstn ) , |
.clk (clk ) , |
|
.i_mk_rdy (i_mk_rdy ) , |
.i_mk (i_mk ) , |
|
.i_post_rdy (i_post_rdy ) , |
|
.i_op (i_op ) , |
|
.i_text_val (i_text_val ) , |
.i_text_in (i_text_in ) , |
|
.o_text_done (o_text_done) , |
.o_text_out (o_text_out ) , |
|
.o_rdy (o_rdy ) |
); |
|
|
//===================================== |
// |
// STIMULUS |
// |
//===================================== |
// clock generation |
initial begin |
clk = 1'b0; |
forever clk = #(HP_CLK) ~clk; |
end |
|
// reset generation |
initial begin |
rstn = 1'b1; |
@(posedge clk); |
@(negedge clk); |
rstn = 1'b0; |
repeat(2) @(negedge clk); |
rstn = 1'b1; |
end |
|
// input generation |
initial begin |
$display("===== SIM START ====="); |
// insert your code |
|
/******** Encryption w/ test vectr 1 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'h0011_2233_4455_6677_8899_aabb_ccdd_eeff; |
i_op = 1'b0; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'h0000_0000_0000_0000; |
|
// reset time |
@(negedge rstn); |
@(posedge rstn); |
@(negedge clk); |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(10) @(posedge clk); |
|
|
|
/******** Decryption w/ test vectr 1 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'h0011_2233_4455_6677_8899_aabb_ccdd_eeff; |
i_op = 1'b1; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'h00f4_18ae_d94f_03f2; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(20) @(posedge clk); |
|
|
|
/******** Encryption w/ test vectr 2 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'hffee_ddcc_bbaa_9988_7766_5544_3322_1100; |
i_op = 1'b0; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'h0011_2233_4455_6677; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(10) @(posedge clk); |
|
|
|
/******** Decryption w/ test vectr 2 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'hffee_ddcc_bbaa_9988_7766_5544_3322_1100; |
i_op = 1'b1; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'h23ce_9f72_e543_e6d8; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(20) @(posedge clk); |
|
|
/******** Encryption w/ test vectr 3 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'h0001_0203_0405_0607_0809_0a0b_0c0d_0e0f; |
i_op = 1'b0; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'h0123_4567_89ab_cdef; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(10) @(posedge clk); |
|
|
|
/******** Decryption w/ test vectr 3 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'h0001_0203_0405_0607_0809_0a0b_0c0d_0e0f; |
i_op = 1'b1; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'h7a6f_b2a2_8d23_f466; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(20) @(posedge clk); |
|
/******** Encryption w/ test vectr 4 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'h28db_c3bc_49ff_d87d_cfa5_09b1_1d42_2be7; |
i_op = 1'b0; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'hb41e_6be2_eba8_4a14; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(10) @(posedge clk); |
|
|
|
/******** Decryption w/ test vectr 4 *******/ |
// initial input value |
i_mk_rdy = 1'b1; |
i_mk = 128'h28db_c3bc_49ff_d87d_cfa5_09b1_1d42_2be7; |
i_op = 1'b1; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
i_text_in = 64'hcc04_7a75_209c_1fc6; |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate == uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
// delay |
repeat(10) @(posedge clk); |
-> do_finish; |
end |
|
// state monitoring |
reg[20*8:1] state; |
always @(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate) begin |
case(uut_HIGHT_CORE_TOP.u_CONTROL.r_pstate) |
uut_HIGHT_CORE_TOP.u_CONTROL.S_IDLE : state <= "IDLE "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_KEY_CONFIG : state <= "KEY_CONFIG"; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RDY : state <= "RDY "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_WF1 : state <= "WF1 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF1 : state <= "RF1 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF2 : state <= "RF2 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF3 : state <= "RF3 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF4 : state <= "RF4 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF5 : state <= "RF5 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF6 : state <= "RF6 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF7 : state <= "RF7 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF8 : state <= "RF8 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF9 : state <= "RF9 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF10 : state <= "RF10 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF11 : state <= "RF11 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF12 : state <= "RF12 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF13 : state <= "RF13 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF14 : state <= "RF14 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF15 : state <= "RF15 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF16 : state <= "RF16 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF17 : state <= "RF17 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF18 : state <= "RF18 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF19 : state <= "RF19 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF20 : state <= "RF20 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF21 : state <= "RF21 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF22 : state <= "RF22 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF23 : state <= "RF23 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF24 : state <= "RF24 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF25 : state <= "RF25 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF26 : state <= "RF26 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF27 : state <= "RF27 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF28 : state <= "RF28 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF29 : state <= "RF29 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF30 : state <= "RF30 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF31 : state <= "RF31 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_RF32 : state <= "RF32 "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_DONE : state <= "DONE "; |
uut_HIGHT_CORE_TOP.u_CONTROL.S_ERROR : state <= "ERROR "; |
endcase |
end |
|
// finish |
initial begin |
@do_finish |
$finish; |
end |
|
// vcd dump |
initial begin |
$dumpfile("dump/sim_tb_HIGHT_CORE_TOP.vcd"); |
$dumpvars(0, tb_HIGHT_CORE_TOP); |
end |
|
endmodule |
|
|
/hight/trunk/testbench/tb_CONTROL.v
0,0 → 1,248
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Testbench of CONTROL module for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
`timescale 1ns/1ps |
|
module tb_CONTROL; |
|
event do_finish; |
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
parameter HP_CLK = 5; // Half period of clock |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
reg rstn ; |
reg clk ; |
|
reg i_mk_rdy ; |
reg i_post_rdy ; |
reg i_text_val ; |
|
wire o_rdy ; |
wire o_text_done ; |
|
wire[2:0] o_xf_sel ; |
wire o_rf_final ; |
|
wire o_key_sel ; |
wire[4:0] o_rnd_idx ; |
wire o_wf_post_pre ; |
|
|
//===================================== |
// |
// PORT MAPPING |
// |
//===================================== |
CONTROL uut_CONTROL( |
.rstn (rstn ) , |
.clk (clk ) , |
|
.i_mk_rdy (i_mk_rdy ) , |
.i_post_rdy (i_post_rdy ) , |
.i_text_val (i_text_val ) , |
|
.o_rdy (o_rdy ) , |
.o_text_done (o_text_done ) , |
|
.o_xf_sel (o_xf_sel ) , |
.o_rf_final (o_rf_final ) , |
|
.o_key_sel (o_key_sel ) , |
.o_rnd_idx (o_rnd_idx ) , |
.o_wf_post_pre (o_wf_post_pre) |
); |
|
|
//===================================== |
// |
// STIMULUS |
// |
//===================================== |
// clock generation |
initial begin |
clk = 1'b0; |
forever clk = #(HP_CLK) ~clk; |
end |
|
// reset generation |
initial begin |
rstn = 1'b1; |
@(posedge clk); |
@(negedge clk); |
rstn = 1'b0; |
repeat(2) @(negedge clk); |
rstn = 1'b1; |
end |
|
// input generation |
initial begin |
$display("===== SIM START ====="); |
// insert your code |
|
// initial input value |
i_mk_rdy = 1'b1; |
i_post_rdy = 1'b1; |
i_text_val = 1'b0; |
|
// reset time |
@(negedge rstn); |
@(posedge rstn); |
@(negedge clk); |
|
// Key Config Phase |
@(negedge clk); |
i_mk_rdy = 1'b0; |
repeat(4) @(posedge clk); |
@(negedge clk); |
i_mk_rdy = 1'b1; |
|
//// first ciphering //// |
// insert 2 clock delay |
@(posedge clk); |
repeat(2) @(posedge clk); |
|
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait text done |
wait(o_text_done) |
@(posedge clk); |
|
// post rdy inactive |
@(negedge clk); |
i_post_rdy = 1'b0; |
|
|
//// second ciphering //// |
// insert text |
@(negedge clk); |
i_text_val = 1'b1; |
@(negedge clk); |
i_text_val = 1'b0; |
|
// wait done state |
wait(uut_CONTROL.r_pstate == uut_CONTROL.S_DONE) |
@(posedge clk); |
|
// insert 3clk delay |
repeat(3) @(posedge clk); |
|
// post rdy active |
i_post_rdy = 1'b1; |
|
repeat(10) @(posedge clk); |
-> do_finish; |
end |
|
// state monitoring |
reg[20*8:1] state; |
always @(uut_CONTROL.r_pstate) begin |
case(uut_CONTROL.r_pstate) |
uut_CONTROL.S_IDLE : state <= "IDLE "; |
uut_CONTROL.S_KEY_CONFIG : state <= "KEY_CONFIG"; |
uut_CONTROL.S_RDY : state <= "RDY "; |
uut_CONTROL.S_WF1 : state <= "WF1 "; |
uut_CONTROL.S_RF1 : state <= "RF1 "; |
uut_CONTROL.S_RF2 : state <= "RF2 "; |
uut_CONTROL.S_RF3 : state <= "RF3 "; |
uut_CONTROL.S_RF4 : state <= "RF4 "; |
uut_CONTROL.S_RF5 : state <= "RF5 "; |
uut_CONTROL.S_RF6 : state <= "RF6 "; |
uut_CONTROL.S_RF7 : state <= "RF7 "; |
uut_CONTROL.S_RF8 : state <= "RF8 "; |
uut_CONTROL.S_RF9 : state <= "RF9 "; |
uut_CONTROL.S_RF10 : state <= "RF10 "; |
uut_CONTROL.S_RF11 : state <= "RF11 "; |
uut_CONTROL.S_RF12 : state <= "RF12 "; |
uut_CONTROL.S_RF13 : state <= "RF13 "; |
uut_CONTROL.S_RF14 : state <= "RF14 "; |
uut_CONTROL.S_RF15 : state <= "RF15 "; |
uut_CONTROL.S_RF16 : state <= "RF16 "; |
uut_CONTROL.S_RF17 : state <= "RF17 "; |
uut_CONTROL.S_RF18 : state <= "RF18 "; |
uut_CONTROL.S_RF19 : state <= "RF19 "; |
uut_CONTROL.S_RF20 : state <= "RF20 "; |
uut_CONTROL.S_RF21 : state <= "RF21 "; |
uut_CONTROL.S_RF22 : state <= "RF22 "; |
uut_CONTROL.S_RF23 : state <= "RF23 "; |
uut_CONTROL.S_RF24 : state <= "RF24 "; |
uut_CONTROL.S_RF25 : state <= "RF25 "; |
uut_CONTROL.S_RF26 : state <= "RF26 "; |
uut_CONTROL.S_RF27 : state <= "RF27 "; |
uut_CONTROL.S_RF28 : state <= "RF28 "; |
uut_CONTROL.S_RF29 : state <= "RF29 "; |
uut_CONTROL.S_RF30 : state <= "RF30 "; |
uut_CONTROL.S_RF31 : state <= "RF31 "; |
uut_CONTROL.S_RF32 : state <= "RF32 "; |
uut_CONTROL.S_DONE : state <= "DONE "; |
uut_CONTROL.S_ERROR : state <= "ERROR "; |
endcase |
end |
|
// finish |
initial begin |
@do_finish |
$finish; |
end |
|
// vcd dump |
initial begin |
$dumpfile("dump/sim_tb_CONTROL.vcd"); |
$dumpvars(0, tb_CONTROL); |
end |
|
endmodule |
|
|
/hight/trunk/testbench/README.md
0,0 → 1,248
README |
/hight/trunk/_run_sim_tb_CONTROL
0,0 → 1,23
#!/bin/bash |
|
if [[ -d ./sim/modelsim/work ]] |
then |
rm -r ./sim/modelsim/work |
fi |
|
vlib ./sim/modelsim/work |
|
vlog -work sim/modelsim/work \ |
./testbench/tb_CONTROL.v \ |
./rtl/CONTROL.v |
|
vsim -c \ |
-lib ./sim/modelsim/work \ |
-do ./scr/sim_tb_CONTROL.do |
|
rm ./transcript |
|
|
vcd2wlf ./dump/sim_tb_CONTROL.vcd \ |
./dump/sim_tb_CONTROL.wlf |
|
/hight/trunk/log/README.md
0,0 → 1,23
README |
/hight/trunk/rtl/CRYPTO_PATH.v
0,0 → 1,155
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Main datapath for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module CRYPTO_PATH( |
rstn , |
clk , |
|
i_op , |
|
i_wrsk , |
|
i_text_in , |
|
i_xf_sel , |
i_rf_final , |
|
o_text_out |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input rstn ; |
input clk ; |
|
input i_op ; |
|
input[31:0] i_wrsk ; |
|
input[63:0] i_text_in ; |
|
input[2:0] i_xf_sel ; |
input i_rf_final ; |
|
output[63:0] o_text_out ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
// xf register |
reg[63:0] r_xf ; |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
// wf_in mux |
wire[63:0] w_wf_in_mux ; |
// w_wf_out |
wire[63:0] w_wf_out ; |
// w_rf_out |
wire[63:0] w_rf_out ; |
// xf mux |
wire[63:0] w_xf_mux ; |
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
// WF(WhiteningFunction) instance |
WF u_WF( |
.i_op ( i_op ) , |
.i_wk ( i_wrsk ) , |
.i_wf_in ( w_wf_in_mux ) , |
|
.o_wf_out ( w_wf_out ) |
); |
|
// RF(RoundFunction) instance |
RF u_RF( |
.i_op ( i_op ) , |
.i_rf_final ( i_rf_final ) , |
.i_rf_in ( r_xf ) , |
.i_rsk ( i_wrsk ) , |
|
.o_rf_out ( w_rf_out ) |
); |
|
// wf_in mux |
assign w_wf_in_mux = (~i_xf_sel[2]) ? r_xf : // i_xf_sel[2] == 0 |
i_text_in ; // i_xf_sel[2] == 1 |
|
// xf mux |
assign w_xf_mux = (i_xf_sel[1:0] == 2'b00) ? r_xf : // i_xf_sel[1:0] == 0 |
(i_xf_sel[1:0] == 2'b01) ? w_wf_out : // i_xf_sel[1:0] == 1 |
w_rf_out ; // i_xf_sel[1:0] == 2, 3 |
|
// xf register |
always @(negedge rstn or posedge clk) |
if(~rstn) |
r_xf <= #1 64'h0 ; |
else |
r_xf <= #1 w_xf_mux ; |
|
// o_text_out |
assign o_text_out = r_xf; |
|
endmodule |
|
|
/hight/trunk/rtl/WF.v
0,0 → 1,123
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Whitening function of main datapath for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module WF( |
|
i_op , |
|
i_wf_in , |
|
i_wk , |
|
o_wf_out |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
|
input i_op ; |
|
input[63:0] i_wf_in ; |
|
input[31:0] i_wk ; |
|
output[63:0] o_wf_out ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
// w_wf_out |
wire[63:0] w_wf_out ; |
// w_rf_out(7:0) |
wire[7:0] w_wf_out7 ; |
wire[7:0] w_wf_out6 ; |
wire[7:0] w_wf_out5 ; |
wire[7:0] w_wf_out4 ; |
wire[7:0] w_wf_out3 ; |
wire[7:0] w_wf_out2 ; |
wire[7:0] w_wf_out1 ; |
wire[7:0] w_wf_out0 ; |
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
|
assign w_wf_out7 = i_wf_in[63:56]; |
assign w_wf_out6 = i_wf_in[55:48] ^ i_wk[31:24]; |
assign w_wf_out5 = i_wf_in[47:40]; |
assign w_wf_out4 = (i_op == 0) ? (i_wf_in[39:32] + i_wk[23:16]) : |
(i_wf_in[39:32] - i_wk[23:16]) ; |
assign w_wf_out3 = i_wf_in[31:24]; |
assign w_wf_out2 = i_wf_in[23:16] ^ i_wk[15:8]; |
assign w_wf_out1 = i_wf_in[15:8]; |
assign w_wf_out0 = (i_op == 0) ? (i_wf_in[7:0] + i_wk[7:0]) : |
(i_wf_in[7:0] - i_wk[7:0]) ; |
|
assign w_wf_out = {w_wf_out7, w_wf_out6, w_wf_out5, w_wf_out4, w_wf_out3, w_wf_out2, w_wf_out1, w_wf_out0}; |
assign o_wf_out = w_wf_out; |
|
endmodule |
|
|
/hight/trunk/rtl/HIGHT_CORE_TOP.v
0,0 → 1,181
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Top module for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module HIGHT_CORE_TOP( |
rstn , |
clk , |
|
i_mk_rdy , |
i_mk , |
|
i_post_rdy , |
|
i_op , |
|
i_text_val , |
i_text_in , |
|
o_text_done , |
o_text_out , |
|
o_rdy |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input rstn ; |
input clk ; |
|
input i_mk_rdy ; |
input[127:0] i_mk ; |
|
input i_post_rdy ; |
|
input i_op ; |
|
input i_text_val ; |
input[63:0] i_text_in ; |
|
output o_text_done ; |
output[63:0] o_text_out ; |
|
output o_rdy ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
wire[31:0] w_rnd_key ; |
|
wire[2:0] w_xf_sel ; |
wire w_rf_final ; |
|
wire w_key_sel ; |
wire[4:0] w_rnd_idx ; |
wire w_wf_post_pre ; |
|
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
// CYPTO_PATH instance |
CRYPTO_PATH u_CRYPTO_PATH( |
.rstn ( rstn ) , |
.clk ( clk ) , |
|
.i_op ( i_op ) , |
|
.i_wrsk ( w_rnd_key ) , |
|
.i_text_in ( i_text_in ) , |
|
.i_xf_sel ( w_xf_sel ) , |
.i_rf_final ( w_rf_final ) , |
|
.o_text_out ( o_text_out ) |
); |
|
|
// KEY_SCHED instance |
KEY_SCHED u_KEY_SCHED( |
.rstn ( rstn ) , |
.clk ( clk ) , |
|
.i_mk ( i_mk ) , |
|
.i_op ( i_op ) , |
|
.i_key_sel ( w_key_sel ) , |
.i_rnd_idx ( w_rnd_idx ) , |
.i_wf_post_pre ( w_wf_post_pre ) , |
|
.o_rnd_key ( w_rnd_key ) |
); |
|
|
// CONTROL instance |
CONTROL u_CONTROL( |
.rstn ( rstn ) , |
.clk ( clk ) , |
|
.i_mk_rdy ( i_mk_rdy ) , |
.i_post_rdy ( i_post_rdy ) , |
.i_text_val ( i_text_val ) , |
|
|
.o_rdy ( o_rdy ) , |
.o_text_done ( o_text_done ) , |
|
.o_xf_sel ( w_xf_sel ) , |
.o_rf_final ( w_rf_final ) , |
|
.o_key_sel ( w_key_sel ) , |
.o_rnd_idx ( w_rnd_idx ) , |
.o_wf_post_pre ( w_wf_post_pre ) |
); |
|
|
endmodule |
|
|
/hight/trunk/rtl/KEY_SCHED.v
0,0 → 1,193
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Key scheduler for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module KEY_SCHED( |
rstn , |
clk , |
|
i_mk , |
|
i_op , |
|
i_key_sel , |
i_rnd_idx , |
i_wf_post_pre , |
|
o_rnd_key |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input rstn ; |
input clk ; |
|
input[127:0] i_mk ; |
|
input i_op ; |
|
input i_key_sel ; |
input[4:0] i_rnd_idx ; |
input i_wf_post_pre ; |
|
output[31:0] o_rnd_key ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
// r_rnd_key_3x ~ r_rnd_key_0x register |
reg[7:0] r_rnd_key_3x ; |
reg[7:0] r_rnd_key_2x ; |
reg[7:0] r_rnd_key_1x ; |
reg[7:0] r_rnd_key_0x ; |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
// w_wk3x ~ w_wk0x |
wire[7:0] w_wk3x ; |
wire[7:0] w_wk2x ; |
wire[7:0] w_wk1x ; |
wire[7:0] w_wk0x ; |
|
// w_sk3x ~ w_sk0x |
wire[7:0] w_sk3x ; |
wire[7:0] w_sk2x ; |
wire[7:0] w_sk1x ; |
wire[7:0] w_sk0x ; |
|
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
// WKG(Whitening Key Generator) instance |
WKG u_WKG( |
.i_op (i_op ) , |
|
.i_wf_post_pre (i_wf_post_pre) , |
|
.i_mk3to0 (i_mk[31:0] ) , |
.i_mk15to12 (i_mk[127:96] ) , |
|
.o_wk3_7 (w_wk3x ) , |
.o_wk2_6 (w_wk2x ) , |
.o_wk1_5 (w_wk1x ) , |
.o_wk0_4 (w_wk0x ) |
); |
|
// SKG(SubKey Generator) instance |
SKG u_SKG( |
.i_op (i_op ) , |
.i_rnd_idx (i_rnd_idx ) , |
.i_mk (i_mk ) , |
|
.o_sk3x (w_sk3x ) , |
.o_sk2x (w_sk2x ) , |
.o_sk1x (w_sk1x ) , |
.o_sk0x (w_sk0x ) |
); |
|
// r_rnd_key_3x ~ r_rnd_key_0x register |
always @(negedge rstn or posedge clk) |
if(~rstn) begin |
r_rnd_key_3x <= #1 8'h00; |
r_rnd_key_2x <= #1 8'h00; |
r_rnd_key_1x <= #1 8'h00; |
r_rnd_key_0x <= #1 8'h00; |
end |
else begin |
if(~i_key_sel) begin |
r_rnd_key_3x <= #1 w_wk3x; |
r_rnd_key_2x <= #1 w_wk2x; |
r_rnd_key_1x <= #1 w_wk1x; |
r_rnd_key_0x <= #1 w_wk0x; |
end |
else begin |
r_rnd_key_3x <= #1 w_sk3x; |
r_rnd_key_2x <= #1 w_sk2x; |
r_rnd_key_1x <= #1 w_sk1x; |
r_rnd_key_0x <= #1 w_sk0x; |
end |
end |
|
// o_rnd_key |
assign o_rnd_key = {r_rnd_key_3x,r_rnd_key_2x,r_rnd_key_1x,r_rnd_key_0x}; |
|
endmodule |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/hight/trunk/rtl/CONTROL.v
0,0 → 1,472
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Control module for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module CONTROL( |
rstn , |
clk , |
|
i_mk_rdy , |
i_post_rdy , |
i_text_val , |
|
o_rdy , |
o_text_done , |
|
o_xf_sel , |
o_rf_final , |
|
o_key_sel , |
o_rnd_idx , |
o_wf_post_pre |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
localparam S_IDLE = 6'b1_10000; |
localparam S_KEY_CONFIG = 6'b1_00000; |
localparam S_RDY = 6'b0_00000; |
localparam S_WF1 = 6'b0_00001; |
localparam S_RF1 = 6'b0_00010; |
localparam S_RF2 = 6'b0_00011; |
localparam S_RF3 = 6'b0_00100; |
localparam S_RF4 = 6'b0_00101; |
localparam S_RF5 = 6'b0_00110; |
localparam S_RF6 = 6'b0_00111; |
localparam S_RF7 = 6'b0_01000; |
localparam S_RF8 = 6'b0_01001; |
localparam S_RF9 = 6'b0_01010; |
localparam S_RF10 = 6'b0_01011; |
localparam S_RF11 = 6'b0_01100; |
localparam S_RF12 = 6'b0_01101; |
localparam S_RF13 = 6'b0_01110; |
localparam S_RF14 = 6'b0_01111; |
localparam S_RF15 = 6'b0_10000; |
localparam S_RF16 = 6'b0_10001; |
localparam S_RF17 = 6'b0_10010; |
localparam S_RF18 = 6'b0_10011; |
localparam S_RF19 = 6'b0_10100; |
localparam S_RF20 = 6'b0_10101; |
localparam S_RF21 = 6'b0_10110; |
localparam S_RF22 = 6'b0_10111; |
localparam S_RF23 = 6'b0_11000; |
localparam S_RF24 = 6'b0_11001; |
localparam S_RF25 = 6'b0_11010; |
localparam S_RF26 = 6'b0_11011; |
localparam S_RF27 = 6'b0_11100; |
localparam S_RF28 = 6'b0_11101; |
localparam S_RF29 = 6'b0_11110; |
localparam S_RF30 = 6'b0_11111; |
localparam S_RF31 = 6'b1_11111; |
localparam S_RF32 = 6'b1_11110; |
localparam S_DONE = 6'b1_11100; |
localparam S_ERROR = 6'b1_01010; |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input rstn ; |
input clk ; |
|
input i_mk_rdy ; |
input i_post_rdy ; |
input i_text_val ; |
|
output o_rdy ; |
output o_text_done ; |
|
output[2:0] o_xf_sel ; |
output o_rf_final ; |
|
output o_key_sel ; |
output[4:0] o_rnd_idx ; |
output o_wf_post_pre ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
// state register |
reg[5:0] r_pstate ; |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
// nstate |
reg[5:0] w_nstate ; |
|
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
// state register |
always @(negedge rstn or posedge clk) |
if(~rstn) |
r_pstate <= #1 S_IDLE ; |
else |
r_pstate <= #1 w_nstate; |
|
|
// nstate |
always @(i_mk_rdy or i_text_val or i_post_rdy or r_pstate) |
case(r_pstate) |
S_IDLE : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RDY; |
else |
w_nstate <= S_KEY_CONFIG; |
end |
S_KEY_CONFIG : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RDY; |
else |
w_nstate <= r_pstate; |
end |
S_RDY : |
begin |
if(i_text_val) |
if(i_mk_rdy) |
w_nstate <= S_WF1; |
else // ~i_mk_rdy |
w_nstate <= S_ERROR; |
else // ~i_text_val |
if(i_mk_rdy) |
w_nstate <= r_pstate; |
else // ~i_mk_rdy |
w_nstate <= S_KEY_CONFIG; |
end |
S_WF1 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF1; |
else |
w_nstate <= S_ERROR; |
end |
S_RF1 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF2; |
else |
w_nstate <= S_ERROR; |
end |
S_RF2 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF3; |
else |
w_nstate <= S_ERROR; |
end |
S_RF3 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF4; |
else |
w_nstate <= S_ERROR; |
end |
S_RF4 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF5; |
else |
w_nstate <= S_ERROR; |
end |
S_RF5 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF6; |
else |
w_nstate <= S_ERROR; |
end |
S_RF6 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF7; |
else |
w_nstate <= S_ERROR; |
end |
S_RF7 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF8; |
else |
w_nstate <= S_ERROR; |
end |
S_RF8 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF9; |
else |
w_nstate <= S_ERROR; |
end |
S_RF9 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF10; |
else |
w_nstate <= S_ERROR; |
end |
S_RF10 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF11; |
else |
w_nstate <= S_ERROR; |
end |
S_RF11 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF12; |
else |
w_nstate <= S_ERROR; |
end |
S_RF12 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF13; |
else |
w_nstate <= S_ERROR; |
end |
S_RF13 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF14; |
else |
w_nstate <= S_ERROR; |
end |
S_RF14 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF15; |
else |
w_nstate <= S_ERROR; |
end |
S_RF15 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF16; |
else |
w_nstate <= S_ERROR; |
end |
S_RF16 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF17; |
else |
w_nstate <= S_ERROR; |
end |
S_RF17 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF18; |
else |
w_nstate <= S_ERROR; |
end |
S_RF18 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF19; |
else |
w_nstate <= S_ERROR; |
end |
S_RF19 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF20; |
else |
w_nstate <= S_ERROR; |
end |
S_RF20 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF21; |
else |
w_nstate <= S_ERROR; |
end |
S_RF21 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF22; |
else |
w_nstate <= S_ERROR; |
end |
S_RF22 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF23; |
else |
w_nstate <= S_ERROR; |
end |
S_RF23 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF24; |
else |
w_nstate <= S_ERROR; |
end |
S_RF24 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF25; |
else |
w_nstate <= S_ERROR; |
end |
S_RF25 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF26; |
else |
w_nstate <= S_ERROR; |
end |
S_RF26 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF27; |
else |
w_nstate <= S_ERROR; |
end |
S_RF27 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF28; |
else |
w_nstate <= S_ERROR; |
end |
S_RF28 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF29; |
else |
w_nstate <= S_ERROR; |
end |
S_RF29 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF30; |
else |
w_nstate <= S_ERROR; |
end |
S_RF30 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF31; |
else |
w_nstate <= S_ERROR; |
end |
S_RF31 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_RF32; |
else |
w_nstate <= S_ERROR; |
end |
S_RF32 : |
begin |
if(i_mk_rdy) |
w_nstate <= S_DONE; |
else |
w_nstate <= S_ERROR; |
end |
S_DONE : |
begin |
if(i_post_rdy) |
if(i_mk_rdy) |
w_nstate <= S_RDY; |
else |
w_nstate <= S_KEY_CONFIG; |
else |
w_nstate <= r_pstate; |
end |
S_ERROR : |
begin |
w_nstate <= S_IDLE; |
end |
default : |
begin |
w_nstate <= S_ERROR; |
end |
endcase |
|
|
// o_rdy |
assign o_rdy = i_mk_rdy & (r_pstate == S_RDY); |
|
// o_text_done |
assign o_text_done = (r_pstate == S_DONE) & i_post_rdy; |
|
// o_xf_sel |
assign o_xf_sel[2] = (r_pstate == S_RDY) & i_text_val; |
assign o_xf_sel[1:0] = ((r_pstate == S_RDY) & i_text_val) ? 2'b01 : |
(((r_pstate != S_RDY) & ~r_pstate[5]) | (r_pstate == S_RF31)) ? 2'b10 : |
(r_pstate == S_RF32) ? 2'b01 : |
2'b00 ; |
// o_rf_final |
assign o_rf_final = (r_pstate == S_RF31); |
|
// o_key_sel |
assign o_key_sel = ((r_pstate == S_RDY) & i_text_val) | ((r_pstate != S_RDY) & (~r_pstate[5])); |
|
// o_rnd_idx |
assign o_rnd_idx = r_pstate[4:0]; |
|
// o_wf_post_pre |
assign o_wf_post_pre = (r_pstate == S_RF31); |
|
endmodule |
|
|
|
|
/hight/trunk/rtl/rtl.f
0,0 → 1,9
./rtl/HIGHT_CORE_TOP.v |
./rtl/CONTROL.v |
./rtl/CRYPTO_PATH.v |
./rtl/RF.v |
./rtl/WF.v |
./rtl/KEY_SCHED.v |
./rtl/WKG.v |
./rtl/SKG.v |
|
/hight/trunk/rtl/SKG.v
0,0 → 1,470
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Subkey generator of key scheduler for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module SKG( |
i_op , |
i_rnd_idx , |
i_mk , |
|
o_sk3x , |
o_sk2x , |
o_sk1x , |
o_sk0x |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input i_op ; |
input[4:0] i_rnd_idx ; |
input[127:0] i_mk ; |
|
output[7:0] o_sk3x ; |
output[7:0] o_sk2x ; |
output[7:0] o_sk1x ; |
output[7:0] o_sk0x ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
// w_mk15 ~ w_mk0 |
wire[7:0] w_mk15 = i_mk[127:120]; |
wire[7:0] w_mk14 = i_mk[119:112]; |
wire[7:0] w_mk13 = i_mk[111:104]; |
wire[7:0] w_mk12 = i_mk[103: 96]; |
wire[7:0] w_mk11 = i_mk[ 95: 88]; |
wire[7:0] w_mk10 = i_mk[ 87: 80]; |
wire[7:0] w_mk9 = i_mk[ 79: 72]; |
wire[7:0] w_mk8 = i_mk[ 71: 64]; |
wire[7:0] w_mk7 = i_mk[ 63: 56]; |
wire[7:0] w_mk6 = i_mk[ 55: 48]; |
wire[7:0] w_mk5 = i_mk[ 47: 40]; |
wire[7:0] w_mk4 = i_mk[ 39: 32]; |
wire[7:0] w_mk3 = i_mk[ 31: 24]; |
wire[7:0] w_mk2 = i_mk[ 23: 16]; |
wire[7:0] w_mk1 = i_mk[ 15: 8]; |
wire[7:0] w_mk0 = i_mk[ 7: 0]; |
|
// w_base |
wire[4:0] w_base; |
|
// w_d3x ~ w_d0x |
reg[6:0] w_d3x; |
reg[6:0] w_d2x; |
reg[6:0] w_d1x; |
reg[6:0] w_d0x; |
|
// w_mk3x ~ w_mk0x |
reg[7:0] w_mk3x; |
reg[7:0] w_mk2x; |
reg[7:0] w_mk1x; |
reg[7:0] w_mk0x; |
|
// w_sk3x_tmp ~ w_sk0x_tmp |
wire[7:0] w_sk3x_tmp; |
wire[7:0] w_sk2x_tmp; |
wire[7:0] w_sk1x_tmp; |
wire[7:0] w_sk0x_tmp; |
|
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
// w_base |
assign w_base = (~i_op) ? i_rnd_idx : |
5'd31 - i_rnd_idx ; |
|
// w_d3x |
always @(w_base) |
case(w_base) |
5'd00 : w_d3x <= 7'h1b; // idx : 3 |
5'd01 : w_d3x <= 7'h41; // idx : 7 |
5'd02 : w_d3x <= 7'h4c; // idx : 11 |
5'd03 : w_d3x <= 7'h2c; // idx : 15 |
5'd04 : w_d3x <= 7'h4a; // idx : 19 |
5'd05 : w_d3x <= 7'h1c; // idx : 23 |
5'd06 : w_d3x <= 7'h79; // idx : 27 |
5'd07 : w_d3x <= 7'h37; // idx : 31 |
5'd08 : w_d3x <= 7'h0b; // idx : 35 |
5'd09 : w_d3x <= 7'h50; // idx : 39 |
5'd10 : w_d3x <= 7'h55; // idx : 43 |
5'd11 : w_d3x <= 7'h7d; // idx : 47 |
5'd12 : w_d3x <= 7'h17; // idx : 51 |
5'd13 : w_d3x <= 7'h29; // idx : 55 |
5'd14 : w_d3x <= 7'h62; // idx : 59 |
5'd15 : w_d3x <= 7'h76; // idx : 63 |
5'd16 : w_d3x <= 7'h47; // idx : 67 |
5'd17 : w_d3x <= 7'h7c; // idx : 71 |
5'd18 : w_d3x <= 7'h1f; // idx : 75 |
5'd19 : w_d3x <= 7'h61; // idx : 79 |
5'd20 : w_d3x <= 7'h6e; // idx : 83 |
5'd21 : w_d3x <= 7'h1e; // idx : 87 |
5'd22 : w_d3x <= 7'h69; // idx : 91 |
5'd23 : w_d3x <= 7'h26; // idx : 95 |
5'd24 : w_d3x <= 7'h12; // idx : 99 |
5'd25 : w_d3x <= 7'h01; // idx : 103 |
5'd26 : w_d3x <= 7'h08; // idx : 107 |
5'd27 : w_d3x <= 7'h48; // idx : 111 |
5'd28 : w_d3x <= 7'h0c; // idx : 115 |
5'd29 : w_d3x <= 7'h68; // idx : 119 |
5'd30 : w_d3x <= 7'h2e; // idx : 123 |
5'd31 : w_d3x <= 7'h5a; // idx : 127 |
endcase |
|
// w_d2x |
always @(w_base) |
case(w_base) |
5'd00 : w_d2x <= 7'h36; // idx : 2 |
5'd01 : w_d2x <= 7'h03; // idx : 6 |
5'd02 : w_d2x <= 7'h18; // idx : 10 |
5'd03 : w_d2x <= 7'h59; // idx : 14 |
5'd04 : w_d2x <= 7'h15; // idx : 18 |
5'd05 : w_d2x <= 7'h39; // idx : 22 |
5'd06 : w_d2x <= 7'h73; // idx : 26 |
5'd07 : w_d2x <= 7'h6f; // idx : 30 |
5'd08 : w_d2x <= 7'h16; // idx : 34 |
5'd09 : w_d2x <= 7'h21; // idx : 38 |
5'd10 : w_d2x <= 7'h2a; // idx : 42 |
5'd11 : w_d2x <= 7'h7a; // idx : 46 |
5'd12 : w_d2x <= 7'h2f; // idx : 50 |
5'd13 : w_d2x <= 7'h52; // idx : 54 |
5'd14 : w_d2x <= 7'h45; // idx : 58 |
5'd15 : w_d2x <= 7'h6c; // idx : 62 |
5'd16 : w_d2x <= 7'h0e; // idx : 66 |
5'd17 : w_d2x <= 7'h78; // idx : 70 |
5'd18 : w_d2x <= 7'h3f; // idx : 74 |
5'd19 : w_d2x <= 7'h43; // idx : 78 |
5'd20 : w_d2x <= 7'h5c; // idx : 82 |
5'd21 : w_d2x <= 7'h3d; // idx : 86 |
5'd22 : w_d2x <= 7'h53; // idx : 90 |
5'd23 : w_d2x <= 7'h4d; // idx : 94 |
5'd24 : w_d2x <= 7'h24; // idx : 98 |
5'd25 : w_d2x <= 7'h02; // idx : 102 |
5'd26 : w_d2x <= 7'h10; // idx : 106 |
5'd27 : w_d2x <= 7'h11; // idx : 110 |
5'd28 : w_d2x <= 7'h19; // idx : 114 |
5'd29 : w_d2x <= 7'h51; // idx : 118 |
5'd30 : w_d2x <= 7'h5d; // idx : 122 |
5'd31 : w_d2x <= 7'h35; // idx : 126 |
endcase |
|
// w_d1x |
always @(w_base) |
case(w_base) |
5'd00 : w_d1x <= 7'h6d; // idx : 1 |
5'd01 : w_d1x <= 7'h06; // idx : 5 |
5'd02 : w_d1x <= 7'h30; // idx : 9 |
5'd03 : w_d1x <= 7'h33; // idx : 13 |
5'd04 : w_d1x <= 7'h2b; // idx : 17 |
5'd05 : w_d1x <= 7'h72; // idx : 21 |
5'd06 : w_d1x <= 7'h67; // idx : 25 |
5'd07 : w_d1x <= 7'h5e; // idx : 29 |
5'd08 : w_d1x <= 7'h2d; // idx : 33 |
5'd09 : w_d1x <= 7'h42; // idx : 37 |
5'd10 : w_d1x <= 7'h54; // idx : 41 |
5'd11 : w_d1x <= 7'h75; // idx : 45 |
5'd12 : w_d1x <= 7'h5f; // idx : 49 |
5'd13 : w_d1x <= 7'h25; // idx : 53 |
5'd14 : w_d1x <= 7'h0a; // idx : 57 |
5'd15 : w_d1x <= 7'h58; // idx : 61 |
5'd16 : w_d1x <= 7'h1d; // idx : 65 |
5'd17 : w_d1x <= 7'h71; // idx : 69 |
5'd18 : w_d1x <= 7'h7f; // idx : 73 |
5'd19 : w_d1x <= 7'h07; // idx : 77 |
5'd20 : w_d1x <= 7'h38; // idx : 81 |
5'd21 : w_d1x <= 7'h7b; // idx : 85 |
5'd22 : w_d1x <= 7'h27; // idx : 89 |
5'd23 : w_d1x <= 7'h1a; // idx : 93 |
5'd24 : w_d1x <= 7'h49; // idx : 97 |
5'd25 : w_d1x <= 7'h04; // idx : 101 |
5'd26 : w_d1x <= 7'h20; // idx : 105 |
5'd27 : w_d1x <= 7'h22; // idx : 109 |
5'd28 : w_d1x <= 7'h32; // idx : 113 |
5'd29 : w_d1x <= 7'h23; // idx : 117 |
5'd30 : w_d1x <= 7'h3a; // idx : 121 |
5'd31 : w_d1x <= 7'h6b; // idx : 125 |
endcase |
|
// w_d0x |
always @(w_base) |
case(w_base) |
5'd00 : w_d0x <= 7'h5a; // idx : 0 |
5'd01 : w_d0x <= 7'h0d; // idx : 4 |
5'd02 : w_d0x <= 7'h60; // idx : 8 |
5'd03 : w_d0x <= 7'h66; // idx : 12 |
5'd04 : w_d0x <= 7'h56; // idx : 16 |
5'd05 : w_d0x <= 7'h65; // idx : 20 |
5'd06 : w_d0x <= 7'h4e; // idx : 24 |
5'd07 : w_d0x <= 7'h3c; // idx : 28 |
5'd08 : w_d0x <= 7'h5b; // idx : 32 |
5'd09 : w_d0x <= 7'h05; // idx : 36 |
5'd10 : w_d0x <= 7'h28; // idx : 40 |
5'd11 : w_d0x <= 7'h6a; // idx : 44 |
5'd12 : w_d0x <= 7'h3e; // idx : 48 |
5'd13 : w_d0x <= 7'h4b; // idx : 52 |
5'd14 : w_d0x <= 7'h14; // idx : 56 |
5'd15 : w_d0x <= 7'h31; // idx : 60 |
5'd16 : w_d0x <= 7'h3b; // idx : 64 |
5'd17 : w_d0x <= 7'h63; // idx : 68 |
5'd18 : w_d0x <= 7'h7e; // idx : 72 |
5'd19 : w_d0x <= 7'h0f; // idx : 76 |
5'd20 : w_d0x <= 7'h70; // idx : 80 |
5'd21 : w_d0x <= 7'h77; // idx : 84 |
5'd22 : w_d0x <= 7'h4f; // idx : 88 |
5'd23 : w_d0x <= 7'h34; // idx : 92 |
5'd24 : w_d0x <= 7'h13; // idx : 96 |
5'd25 : w_d0x <= 7'h09; // idx : 100 |
5'd26 : w_d0x <= 7'h40; // idx : 104 |
5'd27 : w_d0x <= 7'h44; // idx : 108 |
5'd28 : w_d0x <= 7'h64; // idx : 112 |
5'd29 : w_d0x <= 7'h46; // idx : 116 |
5'd30 : w_d0x <= 7'h74; // idx : 120 |
5'd31 : w_d0x <= 7'h57; // idx : 124 |
endcase |
|
// w_mk3x |
always @(*) |
case(w_base) |
5'd00 : w_mk3x <= w_mk3 ; // idx : 3 |
5'd01 : w_mk3x <= w_mk7 ; // idx : 7 |
5'd02 : w_mk3x <= w_mk11; // idx : 11 |
5'd03 : w_mk3x <= w_mk15; // idx : 15 |
5'd04 : w_mk3x <= w_mk2 ; // idx : 19 |
5'd05 : w_mk3x <= w_mk6 ; // idx : 23 |
5'd06 : w_mk3x <= w_mk10; // idx : 27 |
5'd07 : w_mk3x <= w_mk14; // idx : 31 |
5'd08 : w_mk3x <= w_mk1 ; // idx : 35 |
5'd09 : w_mk3x <= w_mk5 ; // idx : 39 |
5'd10 : w_mk3x <= w_mk9 ; // idx : 43 |
5'd11 : w_mk3x <= w_mk13; // idx : 47 |
5'd12 : w_mk3x <= w_mk0 ; // idx : 51 |
5'd13 : w_mk3x <= w_mk4 ; // idx : 55 |
5'd14 : w_mk3x <= w_mk8 ; // idx : 59 |
5'd15 : w_mk3x <= w_mk12; // idx : 63 |
5'd16 : w_mk3x <= w_mk7 ; // idx : 67 |
5'd17 : w_mk3x <= w_mk3 ; // idx : 71 |
5'd18 : w_mk3x <= w_mk15; // idx : 75 |
5'd19 : w_mk3x <= w_mk11; // idx : 79 |
5'd20 : w_mk3x <= w_mk6 ; // idx : 83 |
5'd21 : w_mk3x <= w_mk2 ; // idx : 87 |
5'd22 : w_mk3x <= w_mk14; // idx : 91 |
5'd23 : w_mk3x <= w_mk10; // idx : 95 |
5'd24 : w_mk3x <= w_mk5 ; // idx : 99 |
5'd25 : w_mk3x <= w_mk1 ; // idx : 103 |
5'd26 : w_mk3x <= w_mk13; // idx : 107 |
5'd27 : w_mk3x <= w_mk9 ; // idx : 111 |
5'd28 : w_mk3x <= w_mk4 ; // idx : 115 |
5'd29 : w_mk3x <= w_mk0 ; // idx : 119 |
5'd30 : w_mk3x <= w_mk12; // idx : 123 |
5'd31 : w_mk3x <= w_mk8 ; // idx : 127 |
endcase |
|
// w_mk2x |
always @(*) |
case(w_base) |
5'd00 : w_mk2x <= w_mk2 ; // idx : 2 |
5'd01 : w_mk2x <= w_mk6 ; // idx : 6 |
5'd02 : w_mk2x <= w_mk10; // idx : 10 |
5'd03 : w_mk2x <= w_mk14; // idx : 14 |
5'd04 : w_mk2x <= w_mk1 ; // idx : 18 |
5'd05 : w_mk2x <= w_mk5 ; // idx : 22 |
5'd06 : w_mk2x <= w_mk9 ; // idx : 26 |
5'd07 : w_mk2x <= w_mk13; // idx : 30 |
5'd08 : w_mk2x <= w_mk0 ; // idx : 34 |
5'd09 : w_mk2x <= w_mk4 ; // idx : 38 |
5'd10 : w_mk2x <= w_mk8 ; // idx : 42 |
5'd11 : w_mk2x <= w_mk12; // idx : 46 |
5'd12 : w_mk2x <= w_mk7 ; // idx : 50 |
5'd13 : w_mk2x <= w_mk3 ; // idx : 54 |
5'd14 : w_mk2x <= w_mk15; // idx : 58 |
5'd15 : w_mk2x <= w_mk11; // idx : 62 |
5'd16 : w_mk2x <= w_mk6 ; // idx : 66 |
5'd17 : w_mk2x <= w_mk2 ; // idx : 70 |
5'd18 : w_mk2x <= w_mk14; // idx : 74 |
5'd19 : w_mk2x <= w_mk10; // idx : 78 |
5'd20 : w_mk2x <= w_mk5 ; // idx : 82 |
5'd21 : w_mk2x <= w_mk1 ; // idx : 86 |
5'd22 : w_mk2x <= w_mk13; // idx : 90 |
5'd23 : w_mk2x <= w_mk9 ; // idx : 94 |
5'd24 : w_mk2x <= w_mk4 ; // idx : 98 |
5'd25 : w_mk2x <= w_mk0 ; // idx : 102 |
5'd26 : w_mk2x <= w_mk12; // idx : 106 |
5'd27 : w_mk2x <= w_mk8 ; // idx : 110 |
5'd28 : w_mk2x <= w_mk3 ; // idx : 114 |
5'd29 : w_mk2x <= w_mk7 ; // idx : 118 |
5'd30 : w_mk2x <= w_mk11; // idx : 122 |
5'd31 : w_mk2x <= w_mk15; // idx : 126 |
endcase |
|
// w_mk1x |
always @(*) |
case(w_base) |
5'd00 : w_mk1x <= w_mk1 ; // idx : 1 |
5'd01 : w_mk1x <= w_mk5 ; // idx : 5 |
5'd02 : w_mk1x <= w_mk9 ; // idx : 9 |
5'd03 : w_mk1x <= w_mk13; // idx : 13 |
5'd04 : w_mk1x <= w_mk0 ; // idx : 17 |
5'd05 : w_mk1x <= w_mk4 ; // idx : 21 |
5'd06 : w_mk1x <= w_mk8 ; // idx : 25 |
5'd07 : w_mk1x <= w_mk12; // idx : 29 |
5'd08 : w_mk1x <= w_mk7 ; // idx : 33 |
5'd09 : w_mk1x <= w_mk3 ; // idx : 37 |
5'd10 : w_mk1x <= w_mk15; // idx : 41 |
5'd11 : w_mk1x <= w_mk11; // idx : 45 |
5'd12 : w_mk1x <= w_mk6 ; // idx : 49 |
5'd13 : w_mk1x <= w_mk2 ; // idx : 53 |
5'd14 : w_mk1x <= w_mk14; // idx : 57 |
5'd15 : w_mk1x <= w_mk10; // idx : 61 |
5'd16 : w_mk1x <= w_mk5 ; // idx : 65 |
5'd17 : w_mk1x <= w_mk1 ; // idx : 69 |
5'd18 : w_mk1x <= w_mk13; // idx : 73 |
5'd19 : w_mk1x <= w_mk9 ; // idx : 77 |
5'd20 : w_mk1x <= w_mk4 ; // idx : 81 |
5'd21 : w_mk1x <= w_mk0 ; // idx : 85 |
5'd22 : w_mk1x <= w_mk12; // idx : 89 |
5'd23 : w_mk1x <= w_mk8 ; // idx : 93 |
5'd24 : w_mk1x <= w_mk3 ; // idx : 97 |
5'd25 : w_mk1x <= w_mk7 ; // idx : 101 |
5'd26 : w_mk1x <= w_mk11; // idx : 105 |
5'd27 : w_mk1x <= w_mk15; // idx : 109 |
5'd28 : w_mk1x <= w_mk2 ; // idx : 113 |
5'd29 : w_mk1x <= w_mk6 ; // idx : 117 |
5'd30 : w_mk1x <= w_mk10; // idx : 121 |
5'd31 : w_mk1x <= w_mk14; // idx : 125 |
endcase |
|
// w_mk0x |
always @(*) |
case(w_base) |
5'd00 : w_mk0x <= w_mk0 ; // idx : 0 |
5'd01 : w_mk0x <= w_mk4 ; // idx : 4 |
5'd02 : w_mk0x <= w_mk8 ; // idx : 8 |
5'd03 : w_mk0x <= w_mk12; // idx : 12 |
5'd04 : w_mk0x <= w_mk7 ; // idx : 16 |
5'd05 : w_mk0x <= w_mk3 ; // idx : 20 |
5'd06 : w_mk0x <= w_mk15; // idx : 24 |
5'd07 : w_mk0x <= w_mk11; // idx : 28 |
5'd08 : w_mk0x <= w_mk6 ; // idx : 32 |
5'd09 : w_mk0x <= w_mk2 ; // idx : 36 |
5'd10 : w_mk0x <= w_mk14; // idx : 40 |
5'd11 : w_mk0x <= w_mk10; // idx : 44 |
5'd12 : w_mk0x <= w_mk5 ; // idx : 48 |
5'd13 : w_mk0x <= w_mk1 ; // idx : 52 |
5'd14 : w_mk0x <= w_mk13; // idx : 56 |
5'd15 : w_mk0x <= w_mk9 ; // idx : 60 |
5'd16 : w_mk0x <= w_mk4 ; // idx : 64 |
5'd17 : w_mk0x <= w_mk0 ; // idx : 68 |
5'd18 : w_mk0x <= w_mk12; // idx : 72 |
5'd19 : w_mk0x <= w_mk8 ; // idx : 76 |
5'd20 : w_mk0x <= w_mk3 ; // idx : 80 |
5'd21 : w_mk0x <= w_mk7 ; // idx : 84 |
5'd22 : w_mk0x <= w_mk11; // idx : 88 |
5'd23 : w_mk0x <= w_mk15; // idx : 92 |
5'd24 : w_mk0x <= w_mk2 ; // idx : 96 |
5'd25 : w_mk0x <= w_mk6 ; // idx : 100 |
5'd26 : w_mk0x <= w_mk10; // idx : 104 |
5'd27 : w_mk0x <= w_mk14; // idx : 108 |
5'd28 : w_mk0x <= w_mk1 ; // idx : 112 |
5'd29 : w_mk0x <= w_mk5 ; // idx : 116 |
5'd30 : w_mk0x <= w_mk9 ; // idx : 120 |
5'd31 : w_mk0x <= w_mk13; // idx : 124 |
endcase |
|
// w_sk3x_tmp |
assign w_sk3x_tmp = {1'b0,w_d3x} + w_mk3x; |
|
// w_sk2x_tmp |
assign w_sk2x_tmp = {1'b0,w_d2x} + w_mk2x; |
|
// w_sk1x_tmp |
assign w_sk1x_tmp = {1'b0,w_d1x} + w_mk1x; |
|
// w_sk0x_tmp |
assign w_sk0x_tmp = {1'b0,w_d0x} + w_mk0x; |
|
// o_sk3x |
assign o_sk3x = (~i_op) ? w_sk3x_tmp : // i_op == 0 |
w_sk0x_tmp ; // i_op == 1 |
|
// o_sk2x |
assign o_sk2x = (~i_op) ? w_sk2x_tmp : // i_op == 0 |
w_sk1x_tmp ; // i_op == 1 |
|
// o_sk1x |
assign o_sk1x = (~i_op) ? w_sk1x_tmp : // i_op == 0 |
w_sk2x_tmp ; // i_op == 1 |
|
// o_sk0x |
assign o_sk0x = (~i_op) ? w_sk0x_tmp : // i_op == 0 |
w_sk3x_tmp ; // i_op == 1 |
|
endmodule |
|
|
|
|
|
|
|
|
/hight/trunk/rtl/RF.v
0,0 → 1,173
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Round function of main datapath for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module RF( |
i_op , |
|
i_rsk , |
|
i_rf_in , |
|
i_rf_final , |
|
o_rf_out |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input i_op ; |
|
input[31:0] i_rsk ; |
|
input[63:0] i_rf_in ; |
|
input i_rf_final ; |
|
output[63:0] o_rf_out ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
// w_rf_out |
wire[63:0] w_rf_out ; |
// w_rf_out (7 ~ 0) |
wire[7:0] w_rf_out7 ; |
wire[7:0] w_rf_out6 ; |
wire[7:0] w_rf_out5 ; |
wire[7:0] w_rf_out4 ; |
wire[7:0] w_rf_out3 ; |
wire[7:0] w_rf_out2 ; |
wire[7:0] w_rf_out1 ; |
wire[7:0] w_rf_out0 ; |
// w_f_function |
wire[7:0] w_f0_6 ; |
wire[7:0] w_f1_4 ; |
wire[7:0] w_f0_2 ; |
wire[7:0] w_f1_0 ; |
// w_rf_median_value |
wire[7:0] w_rf_mv[0:3]; |
//===================================== |
// |
// MAIN |
// |
//===================================== |
|
assign w_f0_6 = {i_rf_in[54:48],i_rf_in[55]} ^ |
{i_rf_in[53:48],i_rf_in[55:54]} ^ |
{i_rf_in[48] ,i_rf_in[55:49]}; |
assign w_f1_4 = {i_rf_in[36:32],i_rf_in[39:37]} ^ |
{i_rf_in[35:32],i_rf_in[39:36]} ^ |
{i_rf_in[33:32],i_rf_in[39:34]}; |
assign w_f0_2 = {i_rf_in[22:16],i_rf_in[23]} ^ |
{i_rf_in[21:16],i_rf_in[23:22]} ^ |
{i_rf_in[16] ,i_rf_in[23:17]}; |
assign w_f1_0 = {i_rf_in[4:0] ,i_rf_in[7:5]} ^ |
{i_rf_in[3:0] ,i_rf_in[7:4]} ^ |
{i_rf_in[1:0] ,i_rf_in[7:2]}; |
|
assign w_rf_mv[3] = (i_op == 0) ? i_rf_in[63:56] ^ (w_f0_6 + i_rsk[31:24]): |
i_rf_in[63:56] ^ (w_f0_6 + i_rsk[7:0]); |
|
assign w_rf_mv[2] = (i_op == 0) ? i_rf_in[47:40] + (w_f1_4 ^ i_rsk[23:16]): |
i_rf_in[47:40] - (w_f1_4 ^ i_rsk[15:8]); |
|
assign w_rf_mv[1] = (i_op == 0) ? i_rf_in[31:24] ^ (w_f0_2 + i_rsk[15:8]): |
i_rf_in[31:24] ^ (w_f0_2 + i_rsk[23:16]); |
|
assign w_rf_mv[0] = (i_op == 0) ? i_rf_in[15:8] + (w_f1_0 ^ i_rsk[7:0]): |
i_rf_in[15:8] - (w_f1_0 ^ i_rsk[31:24]); |
|
assign w_rf_out7 = (i_rf_final == 1) ? w_rf_mv[3] : |
(i_op == 0) ? i_rf_in[55:48] : |
i_rf_in[7:0]; |
assign w_rf_out6 = (i_rf_final == 1) ? i_rf_in[55:48] : |
(i_op == 0) ? w_rf_mv[2] : |
w_rf_mv[3]; |
assign w_rf_out5 = (i_rf_final == 1) ? w_rf_mv[2] : |
(i_op == 0) ? i_rf_in[39:32] : |
i_rf_in[55:48]; |
assign w_rf_out4 = (i_rf_final == 1) ? i_rf_in[39:32] : |
(i_op == 0) ? w_rf_mv[1] : |
w_rf_mv[2]; |
assign w_rf_out3 = (i_rf_final == 1) ? w_rf_mv[1] : |
(i_op == 0) ? i_rf_in[23:16] : |
i_rf_in[39:32]; |
assign w_rf_out2 = (i_rf_final == 1) ? i_rf_in[23:16] : |
(i_op == 0) ? w_rf_mv[0] : |
w_rf_mv[1]; |
|
assign w_rf_out1 = (i_rf_final == 1) ? w_rf_mv[0] : |
(i_op == 0) ? i_rf_in[7:0] : |
i_rf_in[23:16]; |
|
assign w_rf_out0 = (i_rf_final == 1) ? i_rf_in[7:0] : |
(i_op == 0) ? w_rf_mv[3] : |
w_rf_mv[0]; |
|
assign w_rf_out = {w_rf_out7, w_rf_out6, w_rf_out5, w_rf_out4, w_rf_out3, w_rf_out2, w_rf_out1, w_rf_out0}; |
assign o_rf_out = w_rf_out; |
|
|
endmodule |
|
|
/hight/trunk/rtl/WKG.v
0,0 → 1,129
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Whitening key generator of key scheduler //// |
//// for HIGHT Crypto Core //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
module WKG( |
i_op , |
|
i_wf_post_pre , |
|
i_mk3to0 , |
i_mk15to12 , |
|
o_wk3_7 , |
o_wk2_6 , |
o_wk1_5 , |
o_wk0_4 |
); |
|
|
//===================================== |
// |
// PARAMETERS |
// |
//===================================== |
|
|
//===================================== |
// |
// I/O PORTS |
// |
//===================================== |
input i_op ; |
|
input i_wf_post_pre ; |
|
input[31:0] i_mk3to0 ; |
input[31:0] i_mk15to12 ; |
|
output[7:0] o_wk3_7 ; |
output[7:0] o_wk2_6 ; |
output[7:0] o_wk1_5 ; |
output[7:0] o_wk0_4 ; |
|
|
//===================================== |
// |
// REGISTERS |
// |
//===================================== |
|
|
//===================================== |
// |
// WIRES |
// |
//===================================== |
wire w_out_sel; |
|
|
//===================================== |
// |
// MAIN |
// |
//===================================== |
// w_out_sel |
assign w_out_sel = i_op ^ i_wf_post_pre; // 0 if 2 signals have same value |
// 1 if 2 signals hava different value |
|
// o_wk3_7 |
assign o_wk3_7 = (~w_out_sel) ? i_mk15to12[31:24] : // w_out_sel == 0 |
i_mk3to0[31:24] ; // w_out_sel == 1 |
// o_wk2_6 |
assign o_wk2_6 = (~w_out_sel) ? i_mk15to12[23:16] : // w_out_sel == 0 |
i_mk3to0[23:16] ; // w_out_sel == 1 |
// o_wk1_5 |
assign o_wk1_5 = (~w_out_sel) ? i_mk15to12[15:8] : // w_out_sel == 0 |
i_mk3to0[15:8] ; // w_out_sel == 1 |
// o_wk0_4 |
assign o_wk0_4 = (~w_out_sel) ? i_mk15to12[7:0] : // w_out_sel == 0 |
i_mk3to0[7:0] ; // w_out_sel == 1 |
|
endmodule |
|
|
|
|
|
|
|
|
/hight/trunk/rtl/README.md
0,0 → 1,129
README |
/hight/trunk/LICENSE
0,0 → 1,505
GNU LESSER GENERAL PUBLIC LICENSE |
Version 2.1, February 1999 |
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
Everyone is permitted to copy and distribute verbatim copies |
of this license document, but changing it is not allowed. |
|
(This is the first released version of the Lesser GPL. It also counts |
as the successor of the GNU Library Public License, version 2, hence |
the version number 2.1.) |
|
Preamble |
|
The licenses for most software are designed to take away your |
freedom to share and change it. By contrast, the GNU General Public |
Licenses are intended to guarantee your freedom to share and change |
free software--to make sure the software is free for all its users. |
|
This license, the Lesser General Public License, applies to some |
specially designated software packages--typically libraries--of the |
Free Software Foundation and other authors who decide to use it. You |
can use it too, but we suggest you first think carefully about whether |
this license or the ordinary General Public License is the better |
strategy to use in any particular case, based on the explanations below. |
|
When we speak of free software, we are referring to freedom of use, |
not price. Our General Public Licenses are designed to make sure that |
you have the freedom to distribute copies of free software (and charge |
for this service if you wish); that you receive source code or can get |
it if you want it; that you can change the software and use pieces of |
it in new free programs; and that you are informed that you can do |
these things. |
|
To protect your rights, we need to make restrictions that forbid |
distributors to deny you these rights or to ask you to surrender these |
rights. These restrictions translate to certain responsibilities for |
you if you distribute copies of the library or if you modify it. |
|
For example, if you distribute copies of the library, whether gratis |
or for a fee, you must give the recipients all the rights that we gave |
you. You must make sure that they, too, receive or can get the source |
code. If you link other code with the library, you must provide |
complete object files to the recipients, so that they can relink them |
with the library after making changes to the library and recompiling |
it. And you must show them these terms so they know their rights. |
|
We protect your rights with a two-step method: (1) we copyright the |
library, and (2) we offer you this license, which gives you legal |
permission to copy, distribute and/or modify the library. |
|
To protect each distributor, we want to make it very clear that |
there is no warranty for the free library. Also, if the library is |
modified by someone else and passed on, the recipients should know |
that what they have is not the original version, so that the original |
author's reputation will not be affected by problems that might be |
introduced by others. |
|
Finally, software patents pose a constant threat to the existence of |
any free program. We wish to make sure that a company cannot |
effectively restrict the users of a free program by obtaining a |
restrictive license from a patent holder. Therefore, we insist that |
any patent license obtained for a version of the library must be |
consistent with the full freedom of use specified in this license. |
|
Most GNU software, including some libraries, is covered by the |
ordinary GNU General Public License. This license, the GNU Lesser |
General Public License, applies to certain designated libraries, and |
is quite different from the ordinary General Public License. We use |
this license for certain libraries in order to permit linking those |
libraries into non-free programs. |
|
When a program is linked with a library, whether statically or using |
a shared library, the combination of the two is legally speaking a |
combined work, a derivative of the original library. The ordinary |
General Public License therefore permits such linking only if the |
entire combination fits its criteria of freedom. The Lesser General |
Public License permits more lax criteria for linking other code with |
the library. |
|
We call this license the "Lesser" General Public License because it |
does Less to protect the user's freedom than the ordinary General |
Public License. It also provides other free software developers Less |
of an advantage over competing non-free programs. These disadvantages |
are the reason we use the ordinary General Public License for many |
libraries. However, the Lesser license provides advantages in certain |
special circumstances. |
|
For example, on rare occasions, there may be a special need to |
encourage the widest possible use of a certain library, so that it becomes |
a de-facto standard. To achieve this, non-free programs must be |
allowed to use the library. A more frequent case is that a free |
library does the same job as widely used non-free libraries. In this |
case, there is little to gain by limiting the free library to free |
software only, so we use the Lesser General Public License. |
|
In other cases, permission to use a particular library in non-free |
programs enables a greater number of people to use a large body of |
free software. For example, permission to use the GNU C Library in |
non-free programs enables many more people to use the whole GNU |
operating system, as well as its variant, the GNU/Linux operating |
system. |
|
Although the Lesser General Public License is Less protective of the |
users' freedom, it does ensure that the user of a program that is |
linked with the Library has the freedom and the wherewithal to run |
that program using a modified version of the Library. |
|
The precise terms and conditions for copying, distribution and |
modification follow. Pay close attention to the difference between a |
"work based on the library" and a "work that uses the library". The |
former contains code derived from the library, whereas the latter must |
be combined with the library in order to run. |
|
GNU LESSER GENERAL PUBLIC LICENSE |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
|
0. This License Agreement applies to any software library or other |
program which contains a notice placed by the copyright holder or |
other authorized party saying it may be distributed under the terms of |
this Lesser General Public License (also called "this License"). |
Each licensee is addressed as "you". |
|
A "library" means a collection of software functions and/or data |
prepared so as to be conveniently linked with application programs |
(which use some of those functions and data) to form executables. |
|
The "Library", below, refers to any such software library or work |
which has been distributed under these terms. A "work based on the |
Library" means either the Library or any derivative work under |
copyright law: that is to say, a work containing the Library or a |
portion of it, either verbatim or with modifications and/or translated |
straightforwardly into another language. (Hereinafter, translation is |
included without limitation in the term "modification".) |
|
"Source code" for a work means the preferred form of the work for |
making modifications to it. For a library, complete source code means |
all the source code for all modules it contains, plus any associated |
interface definition files, plus the scripts used to control compilation |
and installation of the library. |
|
Activities other than copying, distribution and modification are not |
covered by this License; they are outside its scope. The act of |
running a program using the Library is not restricted, and output from |
such a program is covered only if its contents constitute a work based |
on the Library (independent of the use of the Library in a tool for |
writing it). Whether that is true depends on what the Library does |
and what the program that uses the Library does. |
|
1. You may copy and distribute verbatim copies of the Library's |
complete source code as you receive it, in any medium, provided that |
you conspicuously and appropriately publish on each copy an |
appropriate copyright notice and disclaimer of warranty; keep intact |
all the notices that refer to this License and to the absence of any |
warranty; and distribute a copy of this License along with the |
Library. |
|
You may charge a fee for the physical act of transferring a copy, |
and you may at your option offer warranty protection in exchange for a |
fee. |
|
2. You may modify your copy or copies of the Library or any portion |
of it, thus forming a work based on the Library, and copy and |
distribute such modifications or work under the terms of Section 1 |
above, provided that you also meet all of these conditions: |
|
a) The modified work must itself be a software library. |
|
b) You must cause the files modified to carry prominent notices |
stating that you changed the files and the date of any change. |
|
c) You must cause the whole of the work to be licensed at no |
charge to all third parties under the terms of this License. |
|
d) If a facility in the modified Library refers to a function or a |
table of data to be supplied by an application program that uses |
the facility, other than as an argument passed when the facility |
is invoked, then you must make a good faith effort to ensure that, |
in the event an application does not supply such function or |
table, the facility still operates, and performs whatever part of |
its purpose remains meaningful. |
|
(For example, a function in a library to compute square roots has |
a purpose that is entirely well-defined independent of the |
application. Therefore, Subsection 2d requires that any |
application-supplied function or table used by this function must |
be optional: if the application does not supply it, the square |
root function must still compute square roots.) |
|
These requirements apply to the modified work as a whole. If |
identifiable sections of that work are not derived from the Library, |
and can be reasonably considered independent and separate works in |
themselves, then this License, and its terms, do not apply to those |
sections when you distribute them as separate works. But when you |
distribute the same sections as part of a whole which is a work based |
on the Library, the distribution of the whole must be on the terms of |
this License, whose permissions for other licensees extend to the |
entire whole, and thus to each and every part regardless of who wrote |
it. |
|
Thus, it is not the intent of this section to claim rights or contest |
your rights to work written entirely by you; rather, the intent is to |
exercise the right to control the distribution of derivative or |
collective works based on the Library. |
|
In addition, mere aggregation of another work not based on the Library |
with the Library (or with a work based on the Library) on a volume of |
a storage or distribution medium does not bring the other work under |
the scope of this License. |
|
3. You may opt to apply the terms of the ordinary GNU General Public |
License instead of this License to a given copy of the Library. To do |
this, you must alter all the notices that refer to this License, so |
that they refer to the ordinary GNU General Public License, version 2, |
instead of to this License. (If a newer version than version 2 of the |
ordinary GNU General Public License has appeared, then you can specify |
that version instead if you wish.) Do not make any other change in |
these notices. |
|
Once this change is made in a given copy, it is irreversible for |
that copy, so the ordinary GNU General Public License applies to all |
subsequent copies and derivative works made from that copy. |
|
This option is useful when you wish to copy part of the code of |
the Library into a program that is not a library. |
|
4. You may copy and distribute the Library (or a portion or |
derivative of it, under Section 2) in object code or executable form |
under the terms of Sections 1 and 2 above provided that you accompany |
it with the complete corresponding machine-readable source code, which |
must be distributed under the terms of Sections 1 and 2 above on a |
medium customarily used for software interchange. |
|
If distribution of object code is made by offering access to copy |
from a designated place, then offering equivalent access to copy the |
source code from the same place satisfies the requirement to |
distribute the source code, even though third parties are not |
compelled to copy the source along with the object code. |
|
5. A program that contains no derivative of any portion of the |
Library, but is designed to work with the Library by being compiled or |
linked with it, is called a "work that uses the Library". Such a |
work, in isolation, is not a derivative work of the Library, and |
therefore falls outside the scope of this License. |
|
However, linking a "work that uses the Library" with the Library |
creates an executable that is a derivative of the Library (because it |
contains portions of the Library), rather than a "work that uses the |
library". The executable is therefore covered by this License. |
Section 6 states terms for distribution of such executables. |
|
When a "work that uses the Library" uses material from a header file |
that is part of the Library, the object code for the work may be a |
derivative work of the Library even though the source code is not. |
Whether this is true is especially significant if the work can be |
linked without the Library, or if the work is itself a library. The |
threshold for this to be true is not precisely defined by law. |
|
If such an object file uses only numerical parameters, data |
structure layouts and accessors, and small macros and small inline |
functions (ten lines or less in length), then the use of the object |
file is unrestricted, regardless of whether it is legally a derivative |
work. (Executables containing this object code plus portions of the |
Library will still fall under Section 6.) |
|
Otherwise, if the work is a derivative of the Library, you may |
distribute the object code for the work under the terms of Section 6. |
Any executables containing that work also fall under Section 6, |
whether or not they are linked directly with the Library itself. |
|
6. As an exception to the Sections above, you may also combine or |
link a "work that uses the Library" with the Library to produce a |
work containing portions of the Library, and distribute that work |
under terms of your choice, provided that the terms permit |
modification of the work for the customer's own use and reverse |
engineering for debugging such modifications. |
|
You must give prominent notice with each copy of the work that the |
Library is used in it and that the Library and its use are covered by |
this License. You must supply a copy of this License. If the work |
during execution displays copyright notices, you must include the |
copyright notice for the Library among them, as well as a reference |
directing the user to the copy of this License. Also, you must do one |
of these things: |
|
a) Accompany the work with the complete corresponding |
machine-readable source code for the Library including whatever |
changes were used in the work (which must be distributed under |
Sections 1 and 2 above); and, if the work is an executable linked |
with the Library, with the complete machine-readable "work that |
uses the Library", as object code and/or source code, so that the |
user can modify the Library and then relink to produce a modified |
executable containing the modified Library. (It is understood |
that the user who changes the contents of definitions files in the |
Library will not necessarily be able to recompile the application |
to use the modified definitions.) |
|
b) Use a suitable shared library mechanism for linking with the |
Library. A suitable mechanism is one that (1) uses at run time a |
copy of the library already present on the user's computer system, |
rather than copying library functions into the executable, and (2) |
will operate properly with a modified version of the library, if |
the user installs one, as long as the modified version is |
interface-compatible with the version that the work was made with. |
|
c) Accompany the work with a written offer, valid for at |
least three years, to give the same user the materials |
specified in Subsection 6a, above, for a charge no more |
than the cost of performing this distribution. |
|
d) If distribution of the work is made by offering access to copy |
from a designated place, offer equivalent access to copy the above |
specified materials from the same place. |
|
e) Verify that the user has already received a copy of these |
materials or that you have already sent this user a copy. |
|
For an executable, the required form of the "work that uses the |
Library" must include any data and utility programs needed for |
reproducing the executable from it. However, as a special exception, |
the materials to be distributed need not include anything that is |
normally distributed (in either source or binary form) with the major |
components (compiler, kernel, and so on) of the operating system on |
which the executable runs, unless that component itself accompanies |
the executable. |
|
It may happen that this requirement contradicts the license |
restrictions of other proprietary libraries that do not normally |
accompany the operating system. Such a contradiction means you cannot |
use both them and the Library together in an executable that you |
distribute. |
|
7. You may place library facilities that are a work based on the |
Library side-by-side in a single library together with other library |
facilities not covered by this License, and distribute such a combined |
library, provided that the separate distribution of the work based on |
the Library and of the other library facilities is otherwise |
permitted, and provided that you do these two things: |
|
a) Accompany the combined library with a copy of the same work |
based on the Library, uncombined with any other library |
facilities. This must be distributed under the terms of the |
Sections above. |
|
b) Give prominent notice with the combined library of the fact |
that part of it is a work based on the Library, and explaining |
where to find the accompanying uncombined form of the same work. |
|
8. You may not copy, modify, sublicense, link with, or distribute |
the Library except as expressly provided under this License. Any |
attempt otherwise to copy, modify, sublicense, link with, or |
distribute the Library is void, and will automatically terminate your |
rights under this License. However, parties who have received copies, |
or rights, from you under this License will not have their licenses |
terminated so long as such parties remain in full compliance. |
|
9. You are not required to accept this License, since you have not |
signed it. However, nothing else grants you permission to modify or |
distribute the Library or its derivative works. These actions are |
prohibited by law if you do not accept this License. Therefore, by |
modifying or distributing the Library (or any work based on the |
Library), you indicate your acceptance of this License to do so, and |
all its terms and conditions for copying, distributing or modifying |
the Library or works based on it. |
|
10. Each time you redistribute the Library (or any work based on the |
Library), the recipient automatically receives a license from the |
original licensor to copy, distribute, link with or modify the Library |
subject to these terms and conditions. You may not impose any further |
restrictions on the recipients' exercise of the rights granted herein. |
You are not responsible for enforcing compliance by third parties with |
this License. |
|
11. If, as a consequence of a court judgment or allegation of patent |
infringement or for any other reason (not limited to patent issues), |
conditions are imposed on you (whether by court order, agreement or |
otherwise) that contradict the conditions of this License, they do not |
excuse you from the conditions of this License. If you cannot |
distribute so as to satisfy simultaneously your obligations under this |
License and any other pertinent obligations, then as a consequence you |
may not distribute the Library at all. For example, if a patent |
license would not permit royalty-free redistribution of the Library by |
all those who receive copies directly or indirectly through you, then |
the only way you could satisfy both it and this License would be to |
refrain entirely from distribution of the Library. |
|
If any portion of this section is held invalid or unenforceable under any |
particular circumstance, the balance of the section is intended to apply, |
and the section as a whole is intended to apply in other circumstances. |
|
It is not the purpose of this section to induce you to infringe any |
patents or other property right claims or to contest validity of any |
such claims; this section has the sole purpose of protecting the |
integrity of the free software distribution system which is |
implemented by public license practices. Many people have made |
generous contributions to the wide range of software distributed |
through that system in reliance on consistent application of that |
system; it is up to the author/donor to decide if he or she is willing |
to distribute software through any other system and a licensee cannot |
impose that choice. |
|
This section is intended to make thoroughly clear what is believed to |
be a consequence of the rest of this License. |
|
12. If the distribution and/or use of the Library is restricted in |
certain countries either by patents or by copyrighted interfaces, the |
original copyright holder who places the Library under this License may add |
an explicit geographical distribution limitation excluding those countries, |
so that distribution is permitted only in or among countries not thus |
excluded. In such case, this License incorporates the limitation as if |
written in the body of this License. |
|
13. The Free Software Foundation may publish revised and/or new |
versions of the Lesser General Public License from time to time. |
Such new versions will be similar in spirit to the present version, |
but may differ in detail to address new problems or concerns. |
|
Each version is given a distinguishing version number. If the Library |
specifies a version number of this License which applies to it and |
"any later version", you have the option of following the terms and |
conditions either of that version or of any later version published by |
the Free Software Foundation. If the Library does not specify a |
license version number, you may choose any version ever published by |
the Free Software Foundation. |
|
14. If you wish to incorporate parts of the Library into other free |
programs whose distribution conditions are incompatible with these, |
write to the author to ask for permission. For software which is |
copyrighted by the Free Software Foundation, write to the Free |
Software Foundation; we sometimes make exceptions for this. Our |
decision will be guided by the two goals of preserving the free status |
of all derivatives of our free software and of promoting the sharing |
and reuse of software generally. |
|
NO WARRANTY |
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO |
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. |
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR |
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY |
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE |
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME |
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN |
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY |
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU |
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR |
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE |
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
DAMAGES. |
|
END OF TERMS AND CONDITIONS |
|
How to Apply These Terms to Your New Libraries |
|
If you develop a new library, and you want it to be of the greatest |
possible use to the public, we recommend making it free software that |
everyone can redistribute and change. You can do so by permitting |
redistribution under these terms (or, alternatively, under the terms of the |
ordinary General Public License). |
|
To apply these terms, attach the following notices to the library. It is |
safest to attach them to the start of each source file to most effectively |
convey the exclusion of warranty; and each file should have at least the |
"copyright" line and a pointer to where the full notice is found. |
|
{description} |
Copyright (C) {year} {fullname} |
|
This library is free software; you can redistribute it and/or |
modify it under the terms of the GNU Lesser General Public |
License as published by the Free Software Foundation; either |
version 2.1 of the License, or (at your option) any later version. |
|
This library is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Lesser General Public License for more details. |
|
You should have received a copy of the GNU Lesser General Public |
License along with this library; if not, write to the Free Software |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
USA |
|
Also add information on how to contact you by electronic and paper mail. |
|
You should also get your employer (if you work as a programmer) or your |
school, if any, to sign a "copyright disclaimer" for the library, if |
necessary. Here is a sample; alter the names: |
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the |
library `Frob' (a library for tweaking knobs) written by James Random |
Hacker. |
|
{signature of Ty Coon}, 1 April 1990 |
Ty Coon, President of Vice |
|
That's all there is to it! |
|
/hight/trunk/doc/checklist.txt
0,0 → 1,191
< CHECKLIST > |
|
|
I. Integer modeling by C |
|
- define struct type hight_data ... OK |
|
- declare hight function prototype ... OK |
|
- verify DeltaGen() function ... OK |
|
- verify SubKeyGen() function |
|
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
- verify WhiteningKeyGen() function ... OK |
|
- verify InitialWhiteningFunction() function |
|
<Encrytion only> : legacy code |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... OK->X |
* test vector 2 ... |
* test vector 3 ... |
* test vector 4 ... |
|
- verify FinalWhiteningFunction() function |
|
<Encrytion only> : legacy code |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... |
* test vector 2 ... |
* test vector 3 ... |
* test vector 4 ... |
|
- verify InterRoundFunction() function |
|
* test F0(X) founction 1 ... OK |
* test F0(X) founction 2 ... OK |
* test F0(X) founction 3 ... OK |
* test F0(X) founction 4 ... OK |
|
* test F1(X) founction 1 ... OK |
* test F1(X) founction 2 ... OK |
* test F1(X) founction 3 ... OK |
* test F1(X) founction 4 ... OK |
|
<Encrytion only> : legacy code |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... |
* test vector 2 ... |
* test vector 3 ... |
* test vector 4 ... |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... |
* test vector 2 ... |
* test vector 3 ... |
* test vector 4 ... |
|
|
- verify FinalRoundFunction() function |
|
<Encrytion only> : legacy code |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... |
* test vector 2 ... |
* test vector 3 ... |
* test vector 4 ... |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... |
* test vector 2 ... |
* test vector 3 ... |
* test vector 4 ... |
|
- verify HightEncryptionTest() function : legacy code |
|
<Encrytion only> |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
- verify HightDecryptionTest() function : legacy code |
|
<Decrytion only> |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
- verify HightTop() function |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : Encrytion->Decryption> |
* random test 1 ... |
|
|
II. RTL design |
|
- verify WF module |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
- verify RF module |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
- verify HIGHT_CORE_TOP module |
|
<Operation selectable : i_op = Encrytion > |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
<Operation selectable : i_op = Decryption> |
* test vector 1 ... OK |
* test vector 2 ... OK |
* test vector 3 ... OK |
* test vector 4 ... OK |
|
|
|
/hight/trunk/doc/README.md
0,0 → 1,191
README |
/hight/trunk/dump/sim_tb_CONTROL_wave.do
0,0 → 1,31
onerror {resume} |
quietly WaveActivateNextPane {} 0 |
add wave -noupdate -format Logic /tb_CONTROL/rstn |
add wave -noupdate -format Logic /tb_CONTROL/clk |
add wave -noupdate -color White -format Logic /tb_CONTROL/i_mk_rdy |
add wave -noupdate -color White -format Logic /tb_CONTROL/i_text_val |
add wave -noupdate -color White -format Logic /tb_CONTROL/o_rdy |
add wave -noupdate -color White -format Logic /tb_CONTROL/i_post_rdy |
add wave -noupdate -color White -format Logic /tb_CONTROL/o_text_done |
add wave -noupdate -color Yellow -format Logic /tb_CONTROL/o_rf_final |
add wave -noupdate -color Yellow -format Logic /tb_CONTROL/o_key_sel |
add wave -noupdate -color Yellow -format Logic /tb_CONTROL/o_wf_post_pre |
add wave -noupdate -format Literal -radix unsigned /tb_CONTROL/o_rnd_idx |
add wave -noupdate -format Literal /tb_CONTROL/o_xf_sel |
add wave -noupdate -color {Medium Violet Red} -format Literal -radix ascii /tb_CONTROL/state |
TreeUpdate [SetDefaultTree] |
WaveRestoreCursors {{Cursor 1} {87818 ps} 0} {{Cursor 2} {849919 ps} 0} |
configure wave -namecolwidth 211 |
configure wave -valuecolwidth 62 |
configure wave -justifyvalue left |
configure wave -signalnamewidth 0 |
configure wave -snapdistance 10 |
configure wave -datasetprefix 0 |
configure wave -rowmargin 4 |
configure wave -childrowmargin 2 |
configure wave -gridoffset 0 |
configure wave -gridperiod 1 |
configure wave -griddelta 40 |
configure wave -timeline 0 |
update |
WaveRestoreZoom {0 ps} {1004659 ps} |
/hight/trunk/dump/README.md
0,0 → 1,31
README |
/hight/trunk/dump/sim_tb_HIGHT_CORE_TOP_wave.do
0,0 → 1,64
onerror {resume} |
quietly WaveActivateNextPane {} 0 |
add wave -noupdate /tb_HIGHT_CORE_TOP/rstn |
add wave -noupdate /tb_HIGHT_CORE_TOP/clk |
add wave -noupdate -color Coral /tb_HIGHT_CORE_TOP/i_op |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/i_mk |
add wave -noupdate -color White /tb_HIGHT_CORE_TOP/i_mk_rdy |
add wave -noupdate -color White /tb_HIGHT_CORE_TOP/i_post_rdy |
add wave -noupdate -color White -radix binary /tb_HIGHT_CORE_TOP/o_rdy |
add wave -noupdate -color Yellow /tb_HIGHT_CORE_TOP/i_text_val |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/i_text_in |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/o_text_out |
add wave -noupdate -color Yellow -radix hexadecimal /tb_HIGHT_CORE_TOP/o_text_done |
add wave -noupdate -color {Medium Violet Red} -radix ascii /tb_HIGHT_CORE_TOP/state |
add wave -noupdate -divider CRYPTO_PATH |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/rstn |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/clk |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/i_op |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/i_rf_final |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/r_xf |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/i_xf_sel |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/i_text_in |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/i_wrsk |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CRYPTO_PATH/o_text_out |
add wave -noupdate -divider KEY_SCHED |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/rstn |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/clk |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/i_op |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/i_mk |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/i_rnd_idx |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/i_key_sel |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/i_wf_post_pre |
add wave -noupdate -radix hexadecimal /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_KEY_SCHED/o_rnd_key |
add wave -noupdate -divider CONTROL |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/rstn |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/clk |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/i_mk_rdy |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/i_post_rdy |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/i_text_val |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_rdy |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_text_done |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_rf_final |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_wf_post_pre |
add wave -noupdate -radix binary /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_key_sel |
add wave -noupdate -radix unsigned /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_rnd_idx |
add wave -noupdate /tb_HIGHT_CORE_TOP/uut_HIGHT_CORE_TOP/u_CONTROL/o_xf_sel |
TreeUpdate [SetDefaultTree] |
WaveRestoreCursors {{Cursor 1} {1478519 ps} 0} |
quietly wave cursor active 0 |
configure wave -namecolwidth 450 |
configure wave -valuecolwidth 214 |
configure wave -justifyvalue left |
configure wave -signalnamewidth 0 |
configure wave -snapdistance 10 |
configure wave -datasetprefix 0 |
configure wave -rowmargin 4 |
configure wave -childrowmargin 2 |
configure wave -gridoffset 0 |
configure wave -gridperiod 1 |
configure wave -griddelta 40 |
configure wave -timeline 0 |
configure wave -timelineunits ps |
update |
WaveRestoreZoom {0 ps} {1958250 ps} |
/hight/trunk/scr/sim_tb_RF.do
0,0 → 1,4
vsim tb_RF |
|
run -al |
|
/hight/trunk/scr/sim_tb_WF.do
0,0 → 1,4
vsim tb_WF |
|
run -al |
|
/hight/trunk/scr/sim_tb_HIGHT_CORE_TOP.do
0,0 → 1,4
vsim tb_HIGHT_CORE_TOP |
|
run -al |
|
/hight/trunk/scr/README.md
0,0 → 1,4
README |
/hight/trunk/scr/sim_tb_CONTROL.do
0,0 → 1,4
vsim tb_CONTROL |
|
run -al |
|
/hight/trunk/_run_sim_tb_RF
0,0 → 1,23
#!/bin/bash |
|
if [[ -d ./sim/modelsim/work ]] |
then |
rm -r ./sim/modelsim/work |
fi |
|
vlib ./sim/modelsim/work |
|
vlog -work sim/modelsim/work \ |
./testbench/tb_RF.v \ |
./rtl/RF.v |
|
vsim -c \ |
-lib ./sim/modelsim/work \ |
-do ./scr/sim_tb_RF.do |
|
rm ./transcript |
|
|
vcd2wlf ./dump/sim_tb_RF.vcd \ |
./dump/sim_tb_RF.wlf |
|
/hight/trunk/sim/modelsim/README.md
0,0 → 1,23
README |
/hight/trunk/sim/README.md
0,0 → 1,23
README |
/hight/trunk/sw/hight_unit_test.c
0,0 → 1,2484
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Source file of unit test functions for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#include "hight.h" |
#include <stdio.h> |
|
extern HIGHT_DATA *p_hight_data; |
|
/* ===================================== |
|
DeltaGenTest() |
|
=======================================*/ |
void DeltaGenTest() |
{ |
int i; |
|
printf("\n\n===== DeltaGenTest =====\n\n"); |
|
DeltaGen(p_hight_data->delta); |
|
for (i=0; i<128; i++){ |
printf("%02X ", p_hight_data->delta[i]); |
if(i%8 == 7) |
printf("\n"); |
} |
} |
|
|
/* ===================================== |
|
SubKeyGenTest() |
|
=======================================*/ |
void SubKeyGenTest() |
{ |
int i ; |
|
printf("\n\n===== SubKeyGenTest =====\n\n"); |
|
/* |
// Test vectors 1 |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x11; |
p_hight_data->i_mk[13] = 0x22; |
p_hight_data->i_mk[12] = 0x33; |
p_hight_data->i_mk[11] = 0x44; |
p_hight_data->i_mk[10] = 0x55; |
p_hight_data->i_mk[9] = 0x66; |
p_hight_data->i_mk[8] = 0x77; |
p_hight_data->i_mk[7] = 0x88; |
p_hight_data->i_mk[6] = 0x99; |
p_hight_data->i_mk[5] = 0xaa; |
p_hight_data->i_mk[4] = 0xbb; |
p_hight_data->i_mk[3] = 0xcc; |
p_hight_data->i_mk[2] = 0xdd; |
p_hight_data->i_mk[1] = 0xee; |
p_hight_data->i_mk[0] = 0xff; |
*/ |
|
/* |
// Test vectors 2 |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
*/ |
|
|
/* |
// Test vector 3 |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
*/ |
|
// Test vector 4 |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
DeltaGen(p_hight_data->delta); |
|
SubKeyGen(p_hight_data->i_mk, |
p_hight_data->delta, |
p_hight_data->sk); |
|
for (i=0; i<128; i+=4){ |
printf("%02x ", p_hight_data->sk[i+3]); |
printf("%02x ", p_hight_data->sk[i+2]); |
printf("%02x ", p_hight_data->sk[i+1]); |
printf("%02x ", p_hight_data->sk[i]); |
printf("\n"); |
} |
} |
|
|
/* ===================================== |
|
WhiteningKeyGenTest() |
|
=======================================*/ |
void WhiteningKeyGenTest () |
{ |
p_hight_data->i_mk[0] = 0; |
p_hight_data->i_mk[1] = 1; |
p_hight_data->i_mk[2] = 2; |
p_hight_data->i_mk[3] = 3; |
p_hight_data->i_mk[4] = -1; |
p_hight_data->i_mk[5] = -1; |
p_hight_data->i_mk[6] = -1; |
p_hight_data->i_mk[7] = -1; |
p_hight_data->i_mk[8] = -1; |
p_hight_data->i_mk[9] = -1; |
p_hight_data->i_mk[10] = -1; |
p_hight_data->i_mk[11] = -1; |
p_hight_data->i_mk[12] = 12; |
p_hight_data->i_mk[13] = 13; |
p_hight_data->i_mk[14] = 14; |
p_hight_data->i_mk[15] = 15; |
|
printf("\n\n===== WhiteningKeyGenTest =====\n\n"); |
|
WhiteningKeyGen(p_hight_data->i_mk, p_hight_data->wk); |
|
if ( p_hight_data->wk[0] == 12) |
printf("wk[0] = %d (Correct) \n",p_hight_data->wk[0]); |
else |
printf("wk[0] = %d (Wrong => expected = 12) \n",p_hight_data->wk[0]); |
|
if ( p_hight_data->wk[1] == 13) |
printf("wk[1] = %d (Correct) \n",p_hight_data->wk[1]); |
else |
printf("wk[1] = %d (Wrong => expected = 13) \n",p_hight_data->wk[1]); |
|
if ( p_hight_data->wk[2] == 14) |
printf("wk[2] = %d (Correct) \n",p_hight_data->wk[2]); |
else |
printf("wk[2] = %d (Wrong => expected = 14) \n",p_hight_data->wk[2]); |
|
if ( p_hight_data->wk[3] == 15) |
printf("wk[3] = %d (Correct) \n",p_hight_data->wk[3]); |
else |
printf("wk[3] = %d (Wrong => expected = 15) \n",p_hight_data->wk[3]); |
|
if ( p_hight_data->wk[4] == 0) |
printf("wk[4] = %d (Correct) \n",p_hight_data->wk[4]); |
else |
printf("wk[4] = %d (Wrong => expected = 0) \n",p_hight_data->wk[4]); |
|
if ( p_hight_data->wk[5] == 1) |
printf("wk[5] = %d (Correct) \n",p_hight_data->wk[5]); |
else |
printf("wk[5] = %d (Wrong => expected = 1) \n",p_hight_data->wk[5]); |
|
if ( p_hight_data->wk[6] == 2) |
printf("wk[6] = %d (Correct) \n",p_hight_data->wk[6]); |
else |
printf("wk[6] = %d (Wrong => expected = 2) \n",p_hight_data->wk[6]); |
|
if ( p_hight_data->wk[7] == 3) |
printf("wk[7] = %d (Correct) \n",p_hight_data->wk[7]); |
else |
printf("wk[7] = %d (Wrong => expected = [3]) \n",p_hight_data->wk[7]); |
} |
|
|
/* ===================================== |
|
InitialWhiteningFunctionTest() |
|
=======================================*/ |
void InitialWhiteningFunctionTest () |
{ |
byte expected_iwf[8] = {0}; |
int i_op = -1; |
int i; |
|
printf("\n\n===== InitialWhiteningFunctionTest =====\n\n"); |
|
///////////////////////////////////////////////// |
// |
// Encryption vector |
// |
///////////////////////////////////////////////// |
printf("\n\n===== Encryption operation =====\n\n"); |
|
#if 0 |
// Test vectors 1 |
printf("test vectors 1\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x11; |
p_hight_data->i_mk[13] = 0x22; |
p_hight_data->i_mk[12] = 0x33; |
p_hight_data->i_mk[11] = 0x44; |
p_hight_data->i_mk[10] = 0x55; |
p_hight_data->i_mk[9] = 0x66; |
p_hight_data->i_mk[8] = 0x77; |
p_hight_data->i_mk[7] = 0x88; |
p_hight_data->i_mk[6] = 0x99; |
p_hight_data->i_mk[5] = 0xaa; |
p_hight_data->i_mk[4] = 0xbb; |
p_hight_data->i_mk[3] = 0xcc; |
p_hight_data->i_mk[2] = 0xdd; |
p_hight_data->i_mk[1] = 0xee; |
p_hight_data->i_mk[0] = 0xff; |
|
//PlainText |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0x00; |
p_hight_data->i_pct[5] = 0x00; |
p_hight_data->i_pct[4] = 0x00; |
p_hight_data->i_pct[3] = 0x00; |
p_hight_data->i_pct[2] = 0x00; |
p_hight_data->i_pct[1] = 0x00; |
p_hight_data->i_pct[0] = 0x00; |
|
// expected iwf |
expected_iwf[7] = 0x00; |
expected_iwf[6] = 0x00; |
expected_iwf[5] = 0x00; |
expected_iwf[4] = 0x11; |
expected_iwf[3] = 0x00; |
expected_iwf[2] = 0x22; |
expected_iwf[1] = 0x00; |
expected_iwf[0] = 0x33; |
|
#elif 0 |
// Test vectors 2 |
printf("test vectors 2\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
|
//PlainText |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0x11; |
p_hight_data->i_pct[5] = 0x22; |
p_hight_data->i_pct[4] = 0x33; |
p_hight_data->i_pct[3] = 0x44; |
p_hight_data->i_pct[2] = 0x55; |
p_hight_data->i_pct[1] = 0x66; |
p_hight_data->i_pct[0] = 0x77; |
|
// expected iwf |
expected_iwf[7] = 0x00; |
expected_iwf[6] = 0xee; |
expected_iwf[5] = 0x22; |
expected_iwf[4] = 0x21; |
expected_iwf[3] = 0x44; |
expected_iwf[2] = 0x88; |
expected_iwf[1] = 0x66; |
expected_iwf[0] = 0x43; |
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
|
//PlainText |
p_hight_data->i_pct[7] = 0x01; |
p_hight_data->i_pct[6] = 0x23; |
p_hight_data->i_pct[5] = 0x45; |
p_hight_data->i_pct[4] = 0x67; |
p_hight_data->i_pct[3] = 0x89; |
p_hight_data->i_pct[2] = 0xab; |
p_hight_data->i_pct[1] = 0xcd; |
p_hight_data->i_pct[0] = 0xef; |
|
// expected iwf |
expected_iwf[7] = 0x01; |
expected_iwf[6] = 0x23; |
expected_iwf[5] = 0x45; |
expected_iwf[4] = 0x68; |
expected_iwf[3] = 0x89; |
expected_iwf[2] = 0xa9; |
expected_iwf[1] = 0xcd; |
expected_iwf[0] = 0xf2; |
|
#elif 0 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
//PlainText |
p_hight_data->i_pct[7] = 0xb4; |
p_hight_data->i_pct[6] = 0x1e; |
p_hight_data->i_pct[5] = 0x6b; |
p_hight_data->i_pct[4] = 0xe2; |
p_hight_data->i_pct[3] = 0xeb; |
p_hight_data->i_pct[2] = 0xa8; |
p_hight_data->i_pct[1] = 0x4a; |
p_hight_data->i_pct[0] = 0x14; |
|
// expected iwf |
expected_iwf[7] = 0xb4; |
expected_iwf[6] = 0x36; |
expected_iwf[5] = 0x6b; |
expected_iwf[4] = 0xbd; |
expected_iwf[3] = 0xeb; |
expected_iwf[2] = 0x6b; |
expected_iwf[1] = 0x4a; |
expected_iwf[0] = 0xd0; |
#endif |
|
|
///////////////////////////////////////////////// |
// |
// Decrytion vector |
// |
///////////////////////////////////////////////// |
|
printf("\n\n===== Decrytion operation =====\n\n"); |
|
#if 1 |
// Test vectors 1 |
printf("test vectors 1\n"); |
|
i_op = DEC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x11; |
p_hight_data->i_mk[13] = 0x22; |
p_hight_data->i_mk[12] = 0x33; |
p_hight_data->i_mk[11] = 0x44; |
p_hight_data->i_mk[10] = 0x55; |
p_hight_data->i_mk[9] = 0x66; |
p_hight_data->i_mk[8] = 0x77; |
p_hight_data->i_mk[7] = 0x88; |
p_hight_data->i_mk[6] = 0x99; |
p_hight_data->i_mk[5] = 0xaa; |
p_hight_data->i_mk[4] = 0xbb; |
p_hight_data->i_mk[3] = 0xcc; |
p_hight_data->i_mk[2] = 0xdd; |
p_hight_data->i_mk[1] = 0xee; |
p_hight_data->i_mk[0] = 0xff; |
|
// Round32 output |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0xf4; |
p_hight_data->i_pct[5] = 0x18; |
p_hight_data->i_pct[4] = 0xae; |
p_hight_data->i_pct[3] = 0xd9; |
p_hight_data->i_pct[2] = 0x4f; |
p_hight_data->i_pct[1] = 0x03; |
p_hight_data->i_pct[0] = 0xf2; |
|
// expected iwf |
expected_iwf[7] = 0x00; |
expected_iwf[6] = 0x38; |
expected_iwf[5] = 0x18; |
expected_iwf[4] = 0xd1; |
expected_iwf[3] = 0xd9; |
expected_iwf[2] = 0xa1; |
expected_iwf[1] = 0x03; |
expected_iwf[0] = 0xf3; |
|
|
#elif 0 |
// Test vectors 2 |
printf("test vectors 2\n"); |
|
i_op = DEC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
|
//Round32 output |
p_hight_data->rf[32][7] = 0x00; |
p_hight_data->rf[32][6] = 0xee; |
p_hight_data->rf[32][5] = 0x22; |
p_hight_data->rf[32][4] = 0x21; |
p_hight_data->rf[32][3] = 0x44; |
p_hight_data->rf[32][2] = 0x88; |
p_hight_data->rf[32][1] = 0x66; |
p_hight_data->rf[32][0] = 0x43; |
|
// expected iwf |
expected_iwf[7] = 0x00; |
expected_iwf[6] = 0x11; |
expected_iwf[5] = 0x22; |
expected_iwf[4] = 0x33; |
expected_iwf[3] = 0x44; |
expected_iwf[2] = 0x55; |
expected_iwf[1] = 0x66; |
expected_iwf[0] = 0x77; |
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
i_op = DEC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
|
//Round32 output |
p_hight_data->rf[32][7] = 0x01; |
p_hight_data->rf[32][6] = 0x23; |
p_hight_data->rf[32][5] = 0x45; |
p_hight_data->rf[32][4] = 0x68; |
p_hight_data->rf[32][3] = 0x89; |
p_hight_data->rf[32][2] = 0xa9; |
p_hight_data->rf[32][1] = 0xcd; |
p_hight_data->rf[32][0] = 0xf2; |
|
// expected iwf |
expected_iwf[7] = 0x01; |
expected_iwf[6] = 0x23; |
expected_iwf[5] = 0x45; |
expected_iwf[4] = 0x67; |
expected_iwf[3] = 0x89; |
expected_iwf[2] = 0xab; |
expected_iwf[1] = 0xcd; |
expected_iwf[0] = 0xef; |
|
#elif 0 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
i_op = DEC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
//Round32 output |
p_hight_data->rf[32][7] = 0xb4; |
p_hight_data->rf[32][6] = 0x36; |
p_hight_data->rf[32][5] = 0x6b; |
p_hight_data->rf[32][4] = 0xbd; |
p_hight_data->rf[32][3] = 0xeb; |
p_hight_data->rf[32][2] = 0x6b; |
p_hight_data->rf[32][1] = 0x4a; |
p_hight_data->rf[32][0] = 0xd0; |
|
// expected iwf |
expected_iwf[7] = 0xb4; |
expected_iwf[6] = 0x1e; |
expected_iwf[5] = 0x6b; |
expected_iwf[4] = 0xe2; |
expected_iwf[3] = 0xeb; |
expected_iwf[2] = 0xa8; |
expected_iwf[1] = 0x4a; |
expected_iwf[0] = 0x14; |
#endif |
|
|
|
///////////////////////////////////////////////// |
// |
// Run test |
// |
///////////////////////////////////////////////// |
WhiteningKeyGen(p_hight_data->i_mk, p_hight_data->wk); |
|
InitialWhiteningFunction(i_op ,p_hight_data->i_pct, p_hight_data->wk, p_hight_data->iwf); |
|
printf("\n>> operation : %s <<<\n", (i_op == ENC) ? "encryption" : "decrytion"); |
|
printf("\n>>> %s text <<<\n", (i_op == ENC) ? "plain" : "cipher"); |
for(i=7; i>=0; i--) { |
printf("pct[%02d] = %02x\n", i, p_hight_data->i_pct[i]); |
} |
|
printf("\n>>> master key <<<\n"); |
for(i=15; i>=0; i--) { |
printf("mk[%02d] = %02x\n", i, p_hight_data->i_mk[i]); |
} |
|
printf("\n>>> InitialWhiteningFunction result <<<\n"); |
for(i=7; i>=0; i--) { |
printf("iwf[%02d] = %02x ",i, p_hight_data->iwf[i]); |
if(p_hight_data->iwf[i] == expected_iwf[i]) |
printf("Correct\n"); |
else |
printf("Wrong (expected = %02x) \n", expected_iwf[i]); |
} |
} |
|
|
/* ===================================== |
|
FinalWhiteningFunctionTest() |
|
=======================================*/ |
void FinalWhiteningFunctionTest () |
{ |
byte expected_fwf[8] = {0}; |
int i_op = -1; |
int i; |
|
printf("\n\n===== FinalWhiteningFunctionTest =====\n\n"); |
|
///////////////////////////////////////////////// |
// |
// Encryption vector |
// |
///////////////////////////////////////////////// |
printf("\n\n===== Encryption operation =====\n\n"); |
|
#if 0 |
// Test vectors 1 |
printf("test vectors 1\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00 ; |
p_hight_data->i_mk[14] = 0x11 ; |
p_hight_data->i_mk[13] = 0x22 ; |
p_hight_data->i_mk[12] = 0x33 ; |
p_hight_data->i_mk[11] = 0x44 ; |
p_hight_data->i_mk[10] = 0x55 ; |
p_hight_data->i_mk[9] = 0x66 ; |
p_hight_data->i_mk[8] = 0x77 ; |
p_hight_data->i_mk[7] = 0x88 ; |
p_hight_data->i_mk[6] = 0x99 ; |
p_hight_data->i_mk[5] = 0xaa ; |
p_hight_data->i_mk[4] = 0xbb ; |
p_hight_data->i_mk[3] = 0xcc ; |
p_hight_data->i_mk[2] = 0xdd ; |
p_hight_data->i_mk[1] = 0xee ; |
p_hight_data->i_mk[0] = 0xff; |
|
// Round32 output |
p_hight_data->rf[32][7] = 0x00; |
p_hight_data->rf[32][6] = 0x38; |
p_hight_data->rf[32][5] = 0x18; |
p_hight_data->rf[32][4] = 0xd1; |
p_hight_data->rf[32][3] = 0xd9; |
p_hight_data->rf[32][2] = 0xa1; |
p_hight_data->rf[32][1] = 0x03; |
p_hight_data->rf[32][0] = 0xf3; |
|
// expected fwf |
expected_fwf[7] = 0x00; |
expected_fwf[6] = 0xf4; |
expected_fwf[5] = 0x18; |
expected_fwf[4] = 0xae; |
expected_fwf[3] = 0xd9; |
expected_fwf[2] = 0x4f; |
expected_fwf[1] = 0x03; |
expected_fwf[0] = 0xf2; |
|
#elif 0 |
// Test vectors 2 |
printf("test vectors 2\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
|
//Round32 output |
p_hight_data->rf[32][7] = 0x23; |
p_hight_data->rf[32][6] = 0xfd; |
p_hight_data->rf[32][5] = 0x9f; |
p_hight_data->rf[32][4] = 0x50; |
p_hight_data->rf[32][3] = 0xe5; |
p_hight_data->rf[32][2] = 0x52; |
p_hight_data->rf[32][1] = 0xe6; |
p_hight_data->rf[32][0] = 0xd8; |
|
// expected fwf |
expected_fwf[7] = 0x23; |
expected_fwf[6] = 0xce; |
expected_fwf[5] = 0x9f; |
expected_fwf[4] = 0x72; |
expected_fwf[3] = 0xe5; |
expected_fwf[2] = 0x43; |
expected_fwf[1] = 0xe6; |
expected_fwf[0] = 0xd8; |
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
|
//Round32 output |
p_hight_data->rf[1][7] = 0x7a; |
p_hight_data->rf[1][6] = 0x63; |
p_hight_data->rf[1][5] = 0xb2; |
p_hight_data->rf[1][4] = 0x95; |
p_hight_data->rf[1][3] = 0x8d; |
p_hight_data->rf[1][2] = 0x2d; |
p_hight_data->rf[1][1] = 0xf4; |
p_hight_data->rf[1][0] = 0x57; |
|
// expected fwf |
expected_fwf[7] = 0x7a; |
expected_fwf[6] = 0x6f; |
expected_fwf[5] = 0xb2; |
expected_fwf[4] = 0xa2; |
expected_fwf[3] = 0x8d; |
expected_fwf[2] = 0x23; |
expected_fwf[1] = 0xf4; |
expected_fwf[0] = 0x66; |
|
#elif 0 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
i_op = ENC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
//Round32 output |
p_hight_data->rf[32][7] = 0xcc; |
p_hight_data->rf[32][6] = 0x19; |
p_hight_data->rf[32][5] = 0x7a; |
p_hight_data->rf[32][4] = 0x33; |
p_hight_data->rf[32][3] = 0x20; |
p_hight_data->rf[32][2] = 0xb7; |
p_hight_data->rf[32][1] = 0x1f; |
p_hight_data->rf[32][0] = 0xdf; |
|
// expected fwf |
expected_fwf[7] = 0xcc; |
expected_fwf[6] = 0x04; |
expected_fwf[5] = 0x7a; |
expected_fwf[4] = 0x75; |
expected_fwf[3] = 0x20; |
expected_fwf[2] = 0x9c; |
expected_fwf[1] = 0x1f; |
expected_fwf[0] = 0xc6; |
#endif |
|
/* |
///////////////////////////////////////////////// |
// |
// Decrytion vector |
// |
///////////////////////////////////////////////// |
printf("\n\n===== Decrytion operation =====\n\n"); |
|
#if 0 |
|
// Test vectors 1 |
printf("test vectors 1\n"); |
|
i_op = DEC; |
|
// MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x11; |
p_hight_data->i_mk[13] = 0x22; |
p_hight_data->i_mk[12] = 0x33; |
p_hight_data->i_mk[11] = 0x44; |
p_hight_data->i_mk[10] = 0x55; |
p_hight_data->i_mk[9] = 0x66; |
p_hight_data->i_mk[8] = 0x77; |
p_hight_data->i_mk[7] = 0x88; |
p_hight_data->i_mk[6] = 0x99; |
p_hight_data->i_mk[5] = 0xaa; |
p_hight_data->i_mk[4] = 0xbb; |
p_hight_data->i_mk[3] = 0xcc; |
p_hight_data->i_mk[2] = 0xdd; |
p_hight_data->i_mk[1] = 0xee; |
p_hight_data->i_mk[0] = 0xff; |
|
// CipherText |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0xf4; |
p_hight_data->i_pct[5] = 0x18; |
p_hight_data->i_pct[4] = 0xae; |
p_hight_data->i_pct[3] = 0xd9; |
p_hight_data->i_pct[2] = 0x4f; |
p_hight_data->i_pct[1] = 0x03; |
p_hight_data->i_pct[0] = 0xf2; |
|
// expected fwf |
expected_fwf[7] = 0x00; |
expected_fwf[6] = 0x38; |
expected_fwf[5] = 0x18; |
expected_fwf[4] = 0xd1; |
expected_fwf[3] = 0xd9; |
expected_fwf[2] = 0xa1; |
expected_fwf[1] = 0x03; |
expected_fwf[0] = 0xf3; |
|
#elif 0 |
// Test vectors 2 |
printf("test vectors 2\n"); |
|
i_op = DEC; |
|
// MasterKey |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
|
// CipherText |
p_hight_data->i_pct[7] = 0x23; |
p_hight_data->i_pct[6] = 0xce; |
p_hight_data->i_pct[5] = 0x9f; |
p_hight_data->i_pct[4] = 0x72; |
p_hight_data->i_pct[3] = 0xe5; |
p_hight_data->i_pct[2] = 0x43; |
p_hight_data->i_pct[1] = 0xe6; |
p_hight_data->i_pct[0] = 0xd8; |
|
// expected fwf |
expected_fwf[7] = 0x23; |
expected_fwf[6] = 0xfd; |
expected_fwf[5] = 0x9f; |
expected_fwf[4] = 0x50; |
expected_fwf[3] = 0xe5; |
expected_fwf[2] = 0x52; |
expected_fwf[1] = 0xe6; |
expected_fwf[0] = 0xd8; |
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
i_op = DEC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
|
//CipherText |
p_hight_data->i_pct[7] = 0x7a; |
p_hight_data->i_pct[6] = 0x6f; |
p_hight_data->i_pct[5] = 0xb2; |
p_hight_data->i_pct[4] = 0xa2; |
p_hight_data->i_pct[3] = 0x8d; |
p_hight_data->i_pct[2] = 0x23; |
p_hight_data->i_pct[1] = 0xf4; |
p_hight_data->i_pct[0] = 0x66; |
|
// expected fwf |
expected_fwf[7] = 0x7a; |
expected_fwf[6] = 0x63; |
expected_fwf[5] = 0xb2; |
expected_fwf[4] = 0x95; |
expected_fwf[3] = 0x8d; |
expected_fwf[2] = 0x2d; |
expected_fwf[1] = 0xf4; |
expected_fwf[0] = 0x57; |
|
#elif 1 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
i_op = DEC; |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
//CipherText |
p_hight_data->i_pct[7] = 0xcc; |
p_hight_data->i_pct[6] = 0x04; |
p_hight_data->i_pct[5] = 0x7a; |
p_hight_data->i_pct[4] = 0x75; |
p_hight_data->i_pct[3] = 0x20; |
p_hight_data->i_pct[2] = 0x9c; |
p_hight_data->i_pct[1] = 0x1f; |
p_hight_data->i_pct[0] = 0xc6; |
|
// expected fwf |
expected_fwf[7] = 0xcc; |
expected_fwf[6] = 0x19; |
expected_fwf[5] = 0x7a; |
expected_fwf[4] = 0x33; |
expected_fwf[3] = 0x20; |
expected_fwf[2] = 0xb7; |
expected_fwf[1] = 0x1f; |
expected_fwf[0] = 0xdf; |
#endif |
*/ |
|
|
WhiteningKeyGen(p_hight_data->i_mk, p_hight_data->wk); |
|
FinalWhiteningFunction(i_op, p_hight_data->rf[32], p_hight_data->wk, p_hight_data->fwf); |
|
|
printf("\n>> operation : %s <<<\n", (i_op == ENC) ? "encryption" : "decrytion"); |
|
printf("\n>>> master key <<<\n"); |
for(i=15; i>=0; i--) { |
printf("mk[%02d] = %02x\n", i, p_hight_data->i_mk[i]); |
} |
|
printf("\n>>> round32 output <<<\n"); |
for(i=7; i>=0; i--) { |
printf("rf[32][%02d] = %02x\n", i, p_hight_data->rf[32][i]); |
} |
|
printf("\n>>> FinalWhiteningFunction result <<<\n"); |
for(i=7; i>=0; i--) { |
printf("fwf[%02d] = %02x ",i, p_hight_data->fwf[i]); |
if(p_hight_data->fwf[i] == expected_fwf[i]) |
printf("Correct\n"); |
else |
printf("Wrong (expected = %02x) \n", expected_fwf[i]); |
} |
} |
|
/* ===================================== |
|
InterRoundFunctionTest() |
|
=======================================*/ |
void InterRoundFunctionTest() |
{ |
#define IRF_TV1 |
//#define IRF_TV2 |
//#define IRF_TV3 |
//#define IRF_TV4 |
|
#define IRF_ENC |
//#define IRF_DEC |
|
//#define ROUND_FUNCTION_DUMP |
|
#ifdef ROUND_FUNCTION_DUMP |
FILE *fp= fopen("roundfunction_4.txt","w+"); |
#endif |
int i,j; |
int i_op = -1; |
byte expected_rf[32][8]; |
|
/* |
// F0(X) & F1(X) |
int a, b, c; |
|
a = 0xa1; |
//a = 0xc4; |
//a = 0x48 ; |
//a = 0x8 ; |
|
b = ((a<<1 | a>>7) ^ (a<<2 | a>>6) ^ (a<<7 | a>>1)); |
printf("\n\n%02x\n%02x\n" ,a,b); |
|
c = (a<<3 | a>>5) ^ (a<<4 | a>>4) ^ (a<<6 | a>>2); |
printf("%x" ,c); |
|
*/ |
|
printf("\n\n===== InterRoundFunctionTest =====\n\n"); |
|
#if defined(IRF_TV1) |
// Test vectors 1 |
|
p_hight_data-> sk[3] = 0xe7; |
p_hight_data-> sk[2] = 0x13; |
p_hight_data-> sk[1] = 0x5b; |
p_hight_data-> sk[0] = 0x59; |
|
p_hight_data-> sk[7] = 0xc9; |
p_hight_data-> sk[6] = 0x9c; |
p_hight_data-> sk[5] = 0xb0; |
p_hight_data-> sk[4] = 0xc8; |
|
p_hight_data-> sk[11] = 0x90; |
p_hight_data-> sk[10] = 0x6d; |
p_hight_data-> sk[9] = 0x96; |
p_hight_data-> sk[8] = 0xd7; |
|
p_hight_data-> sk[15] = 0x2c; |
p_hight_data-> sk[14] = 0x6a; |
p_hight_data-> sk[13] = 0x55; |
p_hight_data-> sk[12] = 0x99; |
|
p_hight_data-> sk[19] = 0x27; |
p_hight_data-> sk[18] = 0x03; |
p_hight_data-> sk[17] = 0x2a; |
p_hight_data-> sk[16] = 0xde; |
|
p_hight_data-> sk[23] = 0xb5; |
p_hight_data-> sk[22] = 0xe3; |
p_hight_data-> sk[21] = 0x2d; |
p_hight_data-> sk[20] = 0x31; |
|
p_hight_data-> sk[27] = 0xce; |
p_hight_data-> sk[26] = 0xd9; |
p_hight_data-> sk[25] = 0xde; |
p_hight_data-> sk[24] = 0x4e; |
|
p_hight_data-> sk[31] = 0x48; |
p_hight_data-> sk[30] = 0x91; |
p_hight_data-> sk[29] = 0x91; |
p_hight_data-> sk[28] = 0x80; |
|
p_hight_data-> sk[35] = 0xf9; |
p_hight_data-> sk[34] = 0x15; |
p_hight_data-> sk[33] = 0xb5; |
p_hight_data-> sk[32] = 0xf4; |
|
p_hight_data-> sk[39] = 0xfa; |
p_hight_data-> sk[38] = 0xdc; |
p_hight_data-> sk[37] = 0x0e; |
p_hight_data-> sk[36] = 0xe2; |
|
p_hight_data-> sk[43] = 0xbb; |
p_hight_data-> sk[42] = 0xa1; |
p_hight_data-> sk[41] = 0x54; |
p_hight_data-> sk[40] = 0x39; |
|
p_hight_data-> sk[47] = 0x9f; |
p_hight_data-> sk[46] = 0xad; |
p_hight_data-> sk[45] = 0xb9; |
p_hight_data-> sk[44] = 0xbf; |
|
p_hight_data-> sk[51] = 0x16; |
p_hight_data-> sk[50] = 0xb7; |
p_hight_data-> sk[49] = 0xf8; |
p_hight_data-> sk[48] = 0xe8; |
|
p_hight_data-> sk[55] = 0xe4; |
p_hight_data-> sk[54] = 0x1e; |
p_hight_data-> sk[53] = 0x02; |
p_hight_data-> sk[52] = 0x39; |
|
p_hight_data-> sk[59] = 0xd9; |
p_hight_data-> sk[58] = 0x45; |
p_hight_data-> sk[57] = 0x1b; |
p_hight_data-> sk[56] = 0x36; |
|
p_hight_data-> sk[63] = 0xa9; |
p_hight_data-> sk[62] = 0xb0; |
p_hight_data-> sk[61] = 0xad; |
p_hight_data-> sk[60] = 0x97; |
|
p_hight_data-> sk[67] = 0xcf; |
p_hight_data-> sk[66] = 0xa7; |
p_hight_data-> sk[65] = 0xc7; |
p_hight_data-> sk[64] = 0xf6; |
|
p_hight_data-> sk[71] = 0x48; |
p_hight_data-> sk[70] = 0x55; |
p_hight_data-> sk[69] = 0x5f; |
p_hight_data-> sk[68] = 0x62; |
|
p_hight_data-> sk[75] = 0x1f; |
p_hight_data-> sk[74] = 0x50; |
p_hight_data-> sk[73] = 0xa1; |
p_hight_data-> sk[72] = 0xb1; |
|
p_hight_data-> sk[79] = 0xa5; |
p_hight_data-> sk[78] = 0x98; |
p_hight_data-> sk[77] = 0x6d; |
p_hight_data-> sk[76] = 0x86; |
|
p_hight_data-> sk[83] = 0x07; |
p_hight_data-> sk[82] = 0x06; |
p_hight_data-> sk[81] = 0xf3; |
p_hight_data-> sk[80] = 0x3c; |
|
p_hight_data-> sk[87] = 0xfb; |
p_hight_data-> sk[86] = 0x2b; |
p_hight_data-> sk[85] = 0x7a; |
p_hight_data-> sk[84] = 0xff; |
|
p_hight_data-> sk[91] = 0x7a; |
p_hight_data-> sk[90] = 0x75; |
p_hight_data-> sk[89] = 0x5a; |
p_hight_data-> sk[88] = 0x93; |
|
p_hight_data-> sk[95] = 0x7b; |
p_hight_data-> sk[94] = 0xb3; |
p_hight_data-> sk[93] = 0x91; |
p_hight_data-> sk[92] = 0x34; |
|
p_hight_data-> sk[99] = 0xbc; |
p_hight_data-> sk[98] = 0xdf; |
p_hight_data-> sk[97] = 0x15; |
p_hight_data-> sk[96] = 0xf0; |
|
p_hight_data-> sk[103] = 0xef; |
p_hight_data-> sk[102] = 0x01; |
p_hight_data-> sk[101] = 0x8c; |
p_hight_data-> sk[100] = 0xa2; |
|
p_hight_data-> sk[107] = 0x2a; |
p_hight_data-> sk[106] = 0x43; |
p_hight_data-> sk[105] = 0x64; |
p_hight_data-> sk[104] = 0x95; |
|
p_hight_data-> sk[111] = 0xae; |
p_hight_data-> sk[110] = 0x88; |
p_hight_data-> sk[109] = 0x22; |
p_hight_data-> sk[108] = 0x55; |
|
p_hight_data-> sk[115] = 0xc7; |
p_hight_data-> sk[114] = 0xe5; |
p_hight_data-> sk[113] = 0x0f; |
p_hight_data-> sk[112] = 0x52; |
|
p_hight_data-> sk[119] = 0x67; |
p_hight_data-> sk[118] = 0xd9; |
p_hight_data-> sk[117] = 0xbc; |
p_hight_data-> sk[116] = 0xf0; |
|
p_hight_data-> sk[123] = 0x61; |
p_hight_data-> sk[122] = 0xa1; |
p_hight_data-> sk[121] = 0x8f; |
p_hight_data-> sk[120] = 0xda; |
|
p_hight_data-> sk[127] = 0xd1; |
p_hight_data-> sk[126] = 0x35; |
p_hight_data-> sk[125] = 0x7c; |
p_hight_data-> sk[124] = 0x79; |
|
expected_rf[1][7] = 0x00; |
expected_rf[1][6] = 0xce; |
expected_rf[1][5] = 0x11; |
expected_rf[1][4] = 0x38; |
expected_rf[1][3] = 0x22; |
expected_rf[1][2] = 0x3f; |
expected_rf[1][1] = 0x33; |
expected_rf[1][0] = 0xe7; |
|
expected_rf[2][7] = 0xce; |
expected_rf[2][6] = 0xe1; |
expected_rf[2][5] = 0x38; |
expected_rf[2][4] = 0xef; |
expected_rf[2][3] = 0x3f; |
expected_rf[2][2] = 0xa3; |
expected_rf[2][1] = 0xe7; |
expected_rf[2][0] = 0x8a; |
|
expected_rf[3][7] = 0xe1; |
expected_rf[3][6] = 0x4f; |
expected_rf[3][5] = 0xef; |
expected_rf[3][4] = 0x91; |
expected_rf[3][3] = 0xa3; |
expected_rf[3][2] = 0x70; |
expected_rf[3][1] = 0x8a; |
expected_rf[3][0] = 0x8a; |
|
expected_rf[4][7] = 0x4f; |
expected_rf[4][6] = 0x8a; |
expected_rf[4][5] = 0x91; |
expected_rf[4][4] = 0xcd; |
expected_rf[4][3] = 0x70; |
expected_rf[4][2] = 0x51; |
expected_rf[4][1] = 0x8a; |
expected_rf[4][0] = 0xd1; |
|
expected_rf[5][7] = 0x8a; |
expected_rf[5][6] = 0x53; |
expected_rf[5][5] = 0xcd; |
expected_rf[5][4] = 0x09; |
expected_rf[5][3] = 0x51; |
expected_rf[5][2] = 0xc3; |
expected_rf[5][1] = 0xd1; |
expected_rf[5][0] = 0xee; |
|
expected_rf[6][7] = 0x53; |
expected_rf[6][6] = 0x46; |
expected_rf[6][5] = 0x09; |
expected_rf[6][4] = 0xc7; |
expected_rf[6][3] = 0xc3; |
expected_rf[6][2] = 0xe4; |
expected_rf[6][1] = 0xee; |
expected_rf[6][0] = 0x7d; |
|
expected_rf[7][7] = 0x46; |
expected_rf[7][6] = 0x73; |
expected_rf[7][5] = 0xc7; |
expected_rf[7][4] = 0xc5; |
expected_rf[7][3] = 0xe4; |
expected_rf[7][2] = 0x1b; |
expected_rf[7][1] = 0x7d; |
expected_rf[7][0] = 0xd7; |
|
expected_rf[8][7] = 0x73; |
expected_rf[8][6] = 0x59; |
expected_rf[8][5] = 0xc5; |
expected_rf[8][4] = 0x8c; |
expected_rf[8][3] = 0x1b; |
expected_rf[8][2] = 0x33; |
expected_rf[8][1] = 0xd7; |
expected_rf[8][0] = 0x9c; |
|
expected_rf[9][7] = 0x59; |
expected_rf[9][6] = 0x5f; |
expected_rf[9][5] = 0x8c; |
expected_rf[9][4] = 0xf3; |
expected_rf[9][3] = 0x33; |
expected_rf[9][2] = 0xd5; |
expected_rf[9][1] = 0x9c; |
expected_rf[9][0] = 0x07; |
|
expected_rf[10][7] = 0x5f; |
expected_rf[10][6] = 0x0c; |
expected_rf[10][5] = 0xf3; |
expected_rf[10][4] = 0x17; |
expected_rf[10][3] = 0xd5; |
expected_rf[10][2] = 0x07; |
expected_rf[10][1] = 0x07; |
expected_rf[10][0] = 0x3f; |
|
expected_rf[11][7] = 0x0c; |
expected_rf[11][6] = 0xa0; |
expected_rf[11][5] = 0x17; |
expected_rf[11][4] = 0x30; |
expected_rf[11][3] = 0x07; |
expected_rf[11][2] = 0x03; |
expected_rf[11][1] = 0x3f; |
expected_rf[11][0] = 0xb6; |
|
expected_rf[12][7] = 0xa0; |
expected_rf[12][6] = 0x3a; |
expected_rf[12][5] = 0x30; |
expected_rf[12][4] = 0x43; |
expected_rf[12][3] = 0x03; |
expected_rf[12][2] = 0x0b; |
expected_rf[12][1] = 0xb6; |
expected_rf[12][0] = 0x3e; |
|
expected_rf[13][7] = 0x3a; |
expected_rf[13][6] = 0x79; |
expected_rf[13][5] = 0x43; |
expected_rf[13][4] = 0xb4; |
expected_rf[13][3] = 0x0b; |
expected_rf[13][2] = 0x2b; |
expected_rf[13][1] = 0x3e; |
expected_rf[13][0] = 0x37; |
|
expected_rf[14][7] = 0x79; |
expected_rf[14][6] = 0x20; |
expected_rf[14][5] = 0xb4; |
expected_rf[14][4] = 0x7a; |
expected_rf[14][3] = 0x2b; |
expected_rf[14][2] = 0x7c; |
expected_rf[14][1] = 0x37; |
expected_rf[14][0] = 0xb5; |
|
expected_rf[15][7] = 0x20; |
expected_rf[15][6] = 0x63; |
expected_rf[15][5] = 0x7a; |
expected_rf[15][4] = 0x79; |
expected_rf[15][3] = 0x7c; |
expected_rf[15][2] = 0xe4; |
expected_rf[15][1] = 0xb5; |
expected_rf[15][0] = 0xd0; |
|
expected_rf[16][7] = 0x63; |
expected_rf[16][6] = 0x2c; |
expected_rf[16][5] = 0x79; |
expected_rf[16][4] = 0xa9; |
expected_rf[16][3] = 0xe4; |
expected_rf[16][2] = 0xdd; |
expected_rf[16][1] = 0xd0; |
expected_rf[16][0] = 0x83; |
|
expected_rf[17][7] = 0x2c; |
expected_rf[17][6] = 0x93; |
expected_rf[17][5] = 0xa9; |
expected_rf[17][4] = 0x0d; |
expected_rf[17][3] = 0xdd; |
expected_rf[17][2] = 0x02; |
expected_rf[17][1] = 0x83; |
expected_rf[17][0] = 0xae; |
|
expected_rf[18][7] = 0x93; |
expected_rf[18][6] = 0x57; |
expected_rf[18][5] = 0x0d; |
expected_rf[18][4] = 0xb1; |
expected_rf[18][3] = 0x02; |
expected_rf[18][2] = 0xd9; |
expected_rf[18][1] = 0xae; |
expected_rf[18][0] = 0xc4; |
|
expected_rf[19][7] = 0x57; |
expected_rf[19][6] = 0xb7; |
expected_rf[19][5] = 0xb1; |
expected_rf[19][4] = 0xdb; |
expected_rf[19][3] = 0xd9; |
expected_rf[19][2] = 0x98; |
expected_rf[19][1] = 0xc4; |
expected_rf[19][0] = 0xe4; |
|
expected_rf[20][7] = 0xb7; |
expected_rf[20][6] = 0xbe; |
expected_rf[20][5] = 0xdb; |
expected_rf[20][4] = 0x55; |
expected_rf[20][3] = 0x98; |
expected_rf[20][2] = 0x9a; |
expected_rf[20][1] = 0xe4; |
expected_rf[20][0] = 0x58; |
|
expected_rf[21][7] = 0xbe; |
expected_rf[21][6] = 0x87; |
expected_rf[21][5] = 0x55; |
expected_rf[21][4] = 0x9d; |
expected_rf[21][3] = 0x9a; |
expected_rf[21][2] = 0x51; |
expected_rf[21][1] = 0x58; |
expected_rf[21][0] = 0x68; |
|
expected_rf[22][7] = 0x87; |
expected_rf[22][6] = 0xce; |
expected_rf[22][5] = 0x9d; |
expected_rf[22][4] = 0x53; |
expected_rf[22][3] = 0x51; |
expected_rf[22][2] = 0x78; |
expected_rf[22][1] = 0x68; |
expected_rf[22][0] = 0x73; |
|
expected_rf[23][7] = 0xce; |
expected_rf[23][6] = 0xab; |
expected_rf[23][5] = 0x53; |
expected_rf[23][4] = 0xd6; |
expected_rf[23][3] = 0x78; |
expected_rf[23][2] = 0x4b; |
expected_rf[23][1] = 0x73; |
expected_rf[23][0] = 0xbc; |
|
expected_rf[24][7] = 0xab; |
expected_rf[24][6] = 0x30; |
expected_rf[24][5] = 0xd6; |
expected_rf[24][4] = 0xd7; |
expected_rf[24][3] = 0x4b; |
expected_rf[24][2] = 0xa8; |
expected_rf[24][1] = 0xbc; |
expected_rf[24][0] = 0x69; |
|
expected_rf[25][7] = 0x30; |
expected_rf[25][6] = 0xbf; |
expected_rf[25][5] = 0xd7; |
expected_rf[25][4] = 0xf7; |
expected_rf[25][3] = 0xa8; |
expected_rf[25][2] = 0x33; |
expected_rf[25][1] = 0x69; |
expected_rf[25][0] = 0xdf; |
|
expected_rf[26][7] = 0xbf; |
expected_rf[26][6] = 0x13; |
expected_rf[26][5] = 0xf7; |
expected_rf[26][4] = 0x17; |
expected_rf[26][3] = 0x33; |
expected_rf[26][2] = 0xbf; |
expected_rf[26][1] = 0xdf; |
expected_rf[26][0] = 0x7d; |
|
expected_rf[27][7] = 0x13; |
expected_rf[27][6] = 0x46; |
expected_rf[27][5] = 0x17; |
expected_rf[27][4] = 0xf1; |
expected_rf[27][3] = 0xbf; |
expected_rf[27][2] = 0xd5; |
expected_rf[27][1] = 0x7d; |
expected_rf[27][0] = 0xb2; |
|
expected_rf[28][7] = 0x46; |
expected_rf[28][6] = 0x7b; |
expected_rf[28][5] = 0xf1; |
expected_rf[28][4] = 0x87; |
expected_rf[28][3] = 0xd5; |
expected_rf[28][2] = 0xc4; |
expected_rf[28][1] = 0xb2; |
expected_rf[28][0] = 0x77; |
|
expected_rf[29][7] = 0x7b; |
expected_rf[29][6] = 0x31; |
expected_rf[29][5] = 0x87; |
expected_rf[29][4] = 0xd2; |
expected_rf[29][3] = 0xc4; |
expected_rf[29][2] = 0xf5; |
expected_rf[29][1] = 0x77; |
expected_rf[29][0] = 0x2b; |
|
expected_rf[30][7] = 0x31; |
expected_rf[30][6] = 0x5d; |
expected_rf[30][5] = 0xd2; |
expected_rf[30][4] = 0x46; |
expected_rf[30][3] = 0xf5; |
expected_rf[30][2] = 0x48; |
expected_rf[30][1] = 0x2b; |
expected_rf[30][0] = 0xde; |
|
expected_rf[31][7] = 0x5d; |
expected_rf[31][6] = 0x38; |
expected_rf[31][5] = 0x46; |
expected_rf[31][4] = 0xd1; |
expected_rf[31][3] = 0x48; |
expected_rf[31][2] = 0xa1; |
expected_rf[31][1] = 0xde; |
expected_rf[31][0] = 0xf3; |
|
#elif defined(IRF_TV2) |
printf("IRF_TV2"); |
|
#elif defined(IRF_TV3) |
printf("IRF_TV3"); |
|
#elif defined(IRF_TV4) |
printf("IRF_TV4"); |
|
#endif |
|
|
|
#if defined(IRF_ENC) |
///////////////////////////////////////////////// |
// |
// Encryption vector |
// |
///////////////////////////////////////////////// |
printf("\n\n===== Encryption operation =====\n\n"); |
|
#if defined(IRF_TV1) |
|
// Test vectors 1 |
printf("test vectors 1\n"); |
|
i_op = ENC; |
|
p_hight_data-> iwf[7] = 0x00; |
p_hight_data-> iwf[6] = 0x00; |
p_hight_data-> iwf[5] = 0x00; |
p_hight_data-> iwf[4] = 0x11; |
p_hight_data-> iwf[3] = 0x00; |
p_hight_data-> iwf[2] = 0x22; |
p_hight_data-> iwf[1] = 0x00; |
p_hight_data-> iwf[0] = 0x33; |
|
#elif defined(IRF_TV2) |
printf("IRF_TV2"); |
|
#elif defined(IRF_TV3) |
printf("IRF_TV3"); |
|
#elif defined(IRF_TV4) |
printf("IRF_TV4"); |
|
#endif |
#endif |
|
#if defined(IRF_DEC) && !defined(IRF_ENC) |
///////////////////////////////////////////////// |
// |
// Decrytion vector |
// |
///////////////////////////////////////////////// |
|
printf("\n\n===== Decrytion operation =====\n\n"); |
|
#if defined(IRF_TV1) |
// Test vectors 1 |
printf("test vectors 1\n"); |
|
i_op = DEC; |
|
/* ?? |
p_hight_data-> fwf[7] = ; |
p_hight_data-> fwf[6] = ; |
p_hight_data-> fwf[5] = ; |
p_hight_data-> fwf[4] = ; |
p_hight_data-> fwf[3] = ; |
p_hight_data-> fwf[2] = ; |
p_hight_data-> fwf[1] = ; |
p_hight_data-> fwf[0] = ; |
*/ |
|
#elif defined(IRF_TV2) |
printf("IRF_TV2"); |
|
#elif defined(IRF_TV3) |
printf("IRF_TV3"); |
|
#elif defined(IRF_TV4) |
printf("IRF_TV4"); |
|
#endif |
#endif |
|
///////////////////////////////////////////////// |
// |
// Run test |
// |
///////////////////////////////////////////////// |
if(i_op == -1) { |
printf("Wrong operation\n"); |
printf("You should set operation mode for ENC or DEC"); |
return; |
} |
|
// RoundFunction1 |
if(i_op == ENC) { |
InterRoundFunction(i_op, |
p_hight_data->iwf, |
p_hight_data->sk, |
p_hight_data->rf[1]); |
} else { // DEC |
|
|
InterRoundFunction(i_op, |
p_hight_data->fwf, |
p_hight_data->sk, |
p_hight_data->rf[1]); |
} |
|
// RoundFunction2~31 |
for(i=1; i<31; i++){ |
if(i_op == ENC) { |
InterRoundFunction(i_op, |
p_hight_data->rf[i], |
p_hight_data->sk+(i*4), |
p_hight_data->rf[i+1]); |
} else { // DEC |
InterRoundFunction(i_op, |
p_hight_data->rf[i], |
p_hight_data->sk+((32-i)*4), |
p_hight_data->rf[i+1]); |
} |
} |
|
|
// RoundFunction 1 |
printf("\n>> operation : %s <<<\n", (i_op == ENC) ? "encryption" : "decrytion"); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>> operation : %s <<<\n", (i_op == ENC) ? "encryption" : "decrytion"); |
#endif |
|
printf("\n\n===== RoundFunction 1 =====\n\n"); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n\n===== RoundFunction 1 =====\n\n"); |
#endif |
|
printf("\n>>> InitialWhiteningFunction <<<\n"); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>>> InitialWhiteningFunction <<<\n"); |
#endif |
|
for(i=7; i>=0; i--){ |
printf("iwf[%02d] = %02x\n",i, p_hight_data->iwf[i]); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"iwf[%02d] = %02x\n",i, p_hight_data->iwf[i]); |
#endif |
} |
|
printf("\n>>> Sub Key <<<\n"); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>>> Sub Key <<<\n"); |
#endif |
|
for(i=3; i>=0; i--){ |
printf("sk[%02d] = %02x\n", i, p_hight_data->sk[i]); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"sk[%02d] = %02x\n", i, p_hight_data->sk[i]); |
#endif |
} |
|
printf("\n>>> Round #1 Result <<<\n"); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>>> Round #1 Result <<<\n"); |
#endif |
|
for(i=7; i>=0; i--){ |
if((i_op == ENC) ? p_hight_data->rf[1][i] == expected_rf[1][i]: |
p_hight_data->rf[1][i] == expected_rf[31][i]){ |
printf("rf[1][%02d] = %02x : Correct\n", i, p_hight_data->rf[1][i]); |
|
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"rf[1][%02d] = %02x : Correct\n", i, p_hight_data->rf[1][i]); |
#endif |
} else { |
printf("rf[1][%02d] = %02x : Wrong (expected = %02x) \n",i, p_hight_data->rf[1][i], |
(i_op == ENC) ? expected_rf[1][i]: expected_rf[31][i]); |
|
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"rf[1][%02d] : Wrong (expected = %02x) \n",i, (i_op == ENC) ? expected_rf[1][i]: |
expected_rf[31][i]); |
#endif |
} |
} |
|
// RoundFunction 2~31 |
for(i=2; i<32; i++){ |
|
printf("\n\n===== RoundFunction %d =====\n\n",i); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n\n===== RoundFunction %d =====\n\n",i); |
#endif |
|
printf("\n>>> Round #%d Result <<<\n", i-1); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>>> Round #%d Result <<<\n", i-1); |
#endif |
|
for(j=7; j>=0; j--){ |
printf("rf[%02d][%02d] = %02x\n",i-1, j, p_hight_data->rf[i-1][j]); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"rf[%02d][%02d] = %02x\n",i-1, j, p_hight_data->rf[i-1][j]); |
#endif |
} |
|
printf("\n>>> Sub Key <<<\n"); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>>> Sub Key <<<\n"); |
#endif |
printf("\n sk[%02d] = %02x\n sk[%02d] = %02x\n sk[%02d] = %02x\n sk[%02d] = %02x\n ", |
(i-1)*4+3, p_hight_data->sk[(i-1)*4+3],(i-1)*4+2, p_hight_data->sk[(i-1)*4+2],(i-1)*4+1, p_hight_data->sk[(i-1)*4+1],(i-1)*4, p_hight_data->sk[(i-1)*4]); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n sk[%02d] = %02x\n sk[%02d] = %02x\n sk[%02d] = %02x\n sk[%02d] = %02x\n ", |
(i-1)*4+3, p_hight_data->sk[(i-1)*4+3],(i-1)*4+2, p_hight_data->sk[(i-1)*4+2],(i-1)*4+1, p_hight_data->sk[(i-1)*4+1],(i-1)*4, p_hight_data->sk[(i-1)*4]); |
#endif |
printf("\n>>> Round #%d Result <<<\n",i); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"\n>>> Round #%d Result <<<\n",i); |
#endif |
|
for(j=7; j>=0; j--){ |
if(p_hight_data->rf[i][j] == expected_rf[i][j]){ |
printf("rf[%02d][%02d] = %02x : Correct\n", i,j,p_hight_data->rf[i][j]); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"rf[%02d][%02d] = %02x : Correct\n", i,j,p_hight_data->rf[i][j]); |
#endif |
} else { |
printf("rf[%02d][%02d] : Wrong (expected = %02x) \n", i,j,expected_rf[i][j]); |
#ifdef ROUND_FUNCTION_DUMP |
fprintf(fp,"rf[%02d][%02d] : Wrong (expected = %02x) \n", i,j,expected_rf[i][j]); |
#endif |
} |
} |
} |
|
|
#if defined(IRF_DEC) |
// RoundFunction32 |
FinalRoundFunction(i_op, |
p_hight_data->rf[31], |
p_hight_data->sk, |
p_hight_data->rf[32]); |
|
printf("\n>>> Round 32 Result <<<\n"); |
|
for(i=7; i>=0; i--){ |
printf("rf[32][%02d] = %02x\n" , i, p_hight_data->rf[32][i]); |
} |
#endif |
|
#ifdef ROUND_FUNCTION_DUMP |
fclose(fp); |
#endif |
} |
|
|
/* ===================================== |
|
FinalRoundFunctionTest () |
|
=======================================*/ |
void FinalRoundFunctionTest() |
{ |
int i; |
byte expected_rf[33][8]; |
|
|
printf("\n\n===== FinalRoundFunctionTest =====\n\n"); |
|
#if 0 |
|
// Test vector 1 |
printf("test vectors 1\n"); |
|
p_hight_data->rf[31][7] = 0x5d; |
p_hight_data->rf[31][6] = 0x38; |
p_hight_data->rf[31][5] = 0x46; |
p_hight_data->rf[31][4] = 0xd1; |
p_hight_data->rf[31][3] = 0x48; |
p_hight_data->rf[31][2] = 0xa1; |
p_hight_data->rf[31][1] = 0xde; |
p_hight_data->rf[31][0] = 0xf3; |
|
p_hight_data-> sk[127] = 0xd1; |
p_hight_data-> sk[126] = 0x35; |
p_hight_data-> sk[125] = 0x7c; |
p_hight_data-> sk[124] = 0x79; |
|
expected_rf[32][7] = 0x00; |
expected_rf[32][6] = 0x38; |
expected_rf[32][5] = 0x18; |
expected_rf[32][4] = 0xd1; |
expected_rf[32][3] = 0xd9; |
expected_rf[32][2] = 0xa1; |
expected_rf[32][1] = 0x03; |
expected_rf[32][0] = 0xf3; |
|
#elif 0 |
// Test vector 2 |
printf("test vectors 2\n"); |
|
p_hight_data->rf[31][7] = 0xf7; |
p_hight_data->rf[31][6] = 0xfd; |
p_hight_data->rf[31][5] = 0xf8; |
p_hight_data->rf[31][4] = 0x50; |
p_hight_data->rf[31][3] = 0xf8; |
p_hight_data->rf[31][2] = 0x52; |
p_hight_data->rf[31][1] = 0x9d; |
p_hight_data->rf[31][0] = 0xd8; |
|
p_hight_data-> sk[127] = 0xe2; |
p_hight_data-> sk[126] = 0x34; |
p_hight_data-> sk[125] = 0x59; |
p_hight_data-> sk[124] = 0x34; |
|
expected_rf[32][7] = 0x23; |
expected_rf[32][6] = 0xfd; |
expected_rf[32][5] = 0x9f; |
expected_rf[32][4] = 0x50; |
expected_rf[32][3] = 0xe5; |
expected_rf[32][2] = 0x52; |
expected_rf[32][1] = 0xe6; |
expected_rf[32][0] = 0xd8; |
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
p_hight_data->rf[31][7] = 0x21; |
p_hight_data->rf[31][6] = 0x63; |
p_hight_data->rf[31][5] = 0x0d; |
p_hight_data->rf[31][4] = 0x95; |
p_hight_data->rf[31][3] = 0x69; |
p_hight_data->rf[31][2] = 0x2d; |
p_hight_data->rf[31][1] = 0xb1; |
p_hight_data->rf[31][0] = 0x57; |
|
p_hight_data-> sk[127] = 0x61; |
p_hight_data-> sk[126] = 0x35; |
p_hight_data-> sk[125] = 0x6c; |
p_hight_data-> sk[124] = 0x59; |
|
expected_rf[32][7] = 0x7a; |
expected_rf[32][6] = 0x63; |
expected_rf[32][5] = 0xb2; |
expected_rf[32][4] = 0x95; |
expected_rf[32][3] = 0x8d; |
expected_rf[32][2] = 0x2d; |
expected_rf[32][1] = 0xf4; |
expected_rf[32][0] = 0x57; |
#elif 4 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
p_hight_data->rf[31][7] = 0x7d; |
p_hight_data->rf[31][6] = 0x19; |
p_hight_data->rf[31][5] = 0x3f; |
p_hight_data->rf[31][4] = 0x33; |
p_hight_data->rf[31][3] = 0x90; |
p_hight_data->rf[31][2] = 0xb7; |
p_hight_data->rf[31][1] = 0x31; |
p_hight_data->rf[31][0] = 0xdf; |
|
p_hight_data-> sk[127] = 0xd7; |
p_hight_data-> sk[126] = 0x5d; |
p_hight_data-> sk[125] = 0x46; |
p_hight_data-> sk[124] = 0x1a; |
|
expected_rf[32][7] = 0xcc; |
expected_rf[32][6] = 0x19; |
expected_rf[32][5] = 0x7a; |
expected_rf[32][4] = 0x33; |
expected_rf[32][3] = 0x20; |
expected_rf[32][2] = 0xb7; |
expected_rf[32][1] = 0x1f; |
expected_rf[32][0] = 0xdf; |
|
#endif |
|
|
|
// RoundFunction32 |
for(i=31; i<32; i++){ |
FinalRoundFunction(ENC, |
p_hight_data->rf[i], |
p_hight_data->sk+(i*4), |
p_hight_data->rf[i+1]); |
} |
|
// RoundFunction 1 |
printf("\n\n===== RoundFunction 32 =====\n\n"); |
|
printf("\n>>> Round 31 Result <<<\n"); |
|
for(i=7; i>=0; i--){ |
printf("rf[31][%02d] = %02x\n",i, p_hight_data->rf[31][i]); |
} |
|
printf("\n>>> Sub Key <<<\n"); |
|
for(i=127; i>=124; i--){ |
printf("sk[%02d] = %02x\n", i, p_hight_data->sk[i]); |
} |
|
printf("\n>>> Round 32 Result <<<\n"); |
|
for(i=7; i>=0; i--){ |
if(p_hight_data->rf[32][i] == expected_rf[32][i]) |
printf("rf[32][%02d] = %02x : Correct\n", i, p_hight_data->rf[32][i]); |
else |
printf("rf[32][%02d] = %02x: Wrong (expected = %02x) \n",i, p_hight_data->rf[32][i], expected_rf[32][i]); |
} |
} |
|
|
/* ===================================== |
|
HightEncryptionTest() |
|
=======================================*/ |
void HightEncryptionTest() |
{ |
int i; |
byte expected_c_text[8] ={0}; |
|
printf("\n\n===== HightEncryptionTest =====\n\n"); |
|
#if 1 |
|
// Test vector 1 |
printf("test vectors 1\n"); |
|
//Master Key |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x11; |
p_hight_data->i_mk[13] = 0x22; |
p_hight_data->i_mk[12] = 0x33; |
p_hight_data->i_mk[11] = 0x44; |
p_hight_data->i_mk[10] = 0x55; |
p_hight_data->i_mk[9] = 0x66; |
p_hight_data->i_mk[8] = 0x77; |
p_hight_data->i_mk[7] = 0x88; |
p_hight_data->i_mk[6] = 0x99; |
p_hight_data->i_mk[5] = 0xaa; |
p_hight_data->i_mk[4] = 0xbb; |
p_hight_data->i_mk[3] = 0xcc; |
p_hight_data->i_mk[2] = 0xdd; |
p_hight_data->i_mk[1] = 0xee; |
p_hight_data->i_mk[0] = 0xff; |
|
// Plain Text |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0x00; |
p_hight_data->i_pct[5] = 0x00; |
p_hight_data->i_pct[4] = 0x00; |
p_hight_data->i_pct[3] = 0x00; |
p_hight_data->i_pct[2] = 0x00; |
p_hight_data->i_pct[1] = 0x00; |
p_hight_data->i_pct[0] = 0x00; |
|
// Expected Ciphered Text |
expected_c_text[7] = 0x00; |
expected_c_text[6] = 0xf4; |
expected_c_text[5] = 0x18; |
expected_c_text[4] = 0xae; |
expected_c_text[3] = 0xd9; |
expected_c_text[2] = 0x4f; |
expected_c_text[1] = 0x03; |
expected_c_text[0] = 0xf2; |
|
#elif 0 |
// Test vectors 2 |
printf("test vectors 2\n"); |
|
//MasterKey |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
|
//PlainText |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0x11; |
p_hight_data->i_pct[5] = 0x22; |
p_hight_data->i_pct[4] = 0x33; |
p_hight_data->i_pct[3] = 0x44; |
p_hight_data->i_pct[2] = 0x55; |
p_hight_data->i_pct[1] = 0x66; |
p_hight_data->i_pct[0] = 0x77; |
|
// Expected Ciphered Text |
expected_c_text[7] = 0x23; |
expected_c_text[6] = 0xce; |
expected_c_text[5] = 0x9f; |
expected_c_text[4] = 0x72; |
expected_c_text[3] = 0xe5; |
expected_c_text[2] = 0x43; |
expected_c_text[1] = 0xe6; |
expected_c_text[0] = 0xd8; |
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
|
//PlainText |
p_hight_data->i_pct[7] = 0x01; |
p_hight_data->i_pct[6] = 0x23; |
p_hight_data->i_pct[5] = 0x45; |
p_hight_data->i_pct[4] = 0x67; |
p_hight_data->i_pct[3] = 0x89; |
p_hight_data->i_pct[2] = 0xab; |
p_hight_data->i_pct[1] = 0xcd; |
p_hight_data->i_pct[0] = 0xef; |
|
// Expected Ciphered Text |
expected_c_text[7] = 0x7a; |
expected_c_text[6] = 0x6f; |
expected_c_text[5] = 0xb2; |
expected_c_text[4] = 0xa2; |
expected_c_text[3] = 0x8d; |
expected_c_text[2] = 0x23; |
expected_c_text[1] = 0xf4; |
expected_c_text[0] = 0x66; |
|
#elif 0 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
//PlainText |
p_hight_data->i_pct[7] = 0xb4; |
p_hight_data->i_pct[6] = 0x1e; |
p_hight_data->i_pct[5] = 0x6b; |
p_hight_data->i_pct[4] = 0xe2; |
p_hight_data->i_pct[3] = 0xeb; |
p_hight_data->i_pct[2] = 0xa8; |
p_hight_data->i_pct[1] = 0x4a; |
p_hight_data->i_pct[0] = 0x14; |
|
// Expected Ciphered Text |
expected_c_text[7] = 0xcc; |
expected_c_text[6] = 0x04; |
expected_c_text[5] = 0x7a; |
expected_c_text[4] = 0x75; |
expected_c_text[3] = 0x20; |
expected_c_text[2] = 0x9c; |
expected_c_text[1] = 0x1f; |
expected_c_text[0] = 0xc6; |
|
|
#endif |
|
WhiteningKeyGen(p_hight_data->i_mk, p_hight_data->wk); |
|
DeltaGen(p_hight_data->delta); |
|
SubKeyGen(p_hight_data->i_mk, |
p_hight_data->delta, |
p_hight_data->sk); |
|
InitialWhiteningFunction(ENC, p_hight_data->i_pct, p_hight_data->wk, p_hight_data->iwf); |
|
// RoundFunction1 |
InterRoundFunction(ENC, |
p_hight_data->iwf, |
p_hight_data->sk, |
p_hight_data->rf[1]); |
|
// InterRoundFunction2~31 |
for(i=1; i<31; i++){ |
InterRoundFunction(ENC, |
p_hight_data->rf[i], |
p_hight_data->sk+(i*4), |
p_hight_data->rf[i+1]); |
} |
// RoundFunction32 |
FinalRoundFunction(ENC, |
p_hight_data->rf[31], |
p_hight_data->sk+(31*4), |
p_hight_data->rf[32]); |
|
FinalWhiteningFunction(ENC, p_hight_data->rf[32], p_hight_data->wk, p_hight_data->fwf); |
|
for(i=7; i>=0; i--) { |
p_hight_data->o_cpt[i] = p_hight_data->fwf[i]; |
} |
|
printf("\n>>> plaint text <<<\n"); |
for(i=7; i>=0; i--) { |
printf("pt[%02d] = %02x\n", i, p_hight_data->i_pct[i]); |
} |
|
printf("\n>>> master key <<<\n"); |
for(i=15; i>=0; i--) { |
printf("mk[%02d] = %02x\n", i, p_hight_data->i_mk[i]); |
} |
|
printf("\n>>> HightEncryption result <<<\n"); |
for(i=7; i>=0; i--) { |
if(p_hight_data->o_cpt[i] == expected_c_text[i]) |
printf("o_c_text[%02d] = %02x : Correct\n", i , p_hight_data->o_cpt[i]); |
else |
printf("o_c_text[%02d] = %02x : Wrong (expected = %02x) \n", i, p_hight_data->o_cpt[i], expected_c_text[i]); |
} |
|
} |
|
/* ===================================== |
|
HightDecryptionTest() |
|
=======================================*/ |
void HightDecryptionTest() |
{ |
int i; |
byte expected_p_text[8] ={0}; |
byte dec_sk[128] = {0}; |
|
printf("\n\n===== HightDecryptionTest =====\n\n"); |
|
#if 0 |
|
// Test vector 1 |
printf("test vectors 1\n"); |
|
//Master Key |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x11; |
p_hight_data->i_mk[13] = 0x22; |
p_hight_data->i_mk[12] = 0x33; |
p_hight_data->i_mk[11] = 0x44; |
p_hight_data->i_mk[10] = 0x55; |
p_hight_data->i_mk[9] = 0x66; |
p_hight_data->i_mk[8] = 0x77; |
p_hight_data->i_mk[7] = 0x88; |
p_hight_data->i_mk[6] = 0x99; |
p_hight_data->i_mk[5] = 0xaa; |
p_hight_data->i_mk[4] = 0xbb; |
p_hight_data->i_mk[3] = 0xcc; |
p_hight_data->i_mk[2] = 0xdd; |
p_hight_data->i_mk[1] = 0xee; |
p_hight_data->i_mk[0] = 0xff; |
|
// Cipher Text |
p_hight_data->i_pct[7] = 0x00; |
p_hight_data->i_pct[6] = 0xf4; |
p_hight_data->i_pct[5] = 0x18; |
p_hight_data->i_pct[4] = 0xae; |
p_hight_data->i_pct[3] = 0xd9; |
p_hight_data->i_pct[2] = 0x4f; |
p_hight_data->i_pct[1] = 0x03; |
p_hight_data->i_pct[0] = 0xf2; |
|
// Expected plain Text |
expected_p_text[7] = 0x00; |
expected_p_text[6] = 0x00; |
expected_p_text[5] = 0x00; |
expected_p_text[4] = 0x00; |
expected_p_text[3] = 0x00; |
expected_p_text[2] = 0x00; |
expected_p_text[1] = 0x00; |
expected_p_text[0] = 0x00; |
|
#elif 0 |
// Test vector 2 |
printf("test vectors 2\n"); |
|
//MasterKey |
p_hight_data->i_mk[15] = 0xff; |
p_hight_data->i_mk[14] = 0xee; |
p_hight_data->i_mk[13] = 0xdd; |
p_hight_data->i_mk[12] = 0xcc; |
p_hight_data->i_mk[11] = 0xbb; |
p_hight_data->i_mk[10] = 0xaa; |
p_hight_data->i_mk[9] = 0x99; |
p_hight_data->i_mk[8] = 0x88; |
p_hight_data->i_mk[7] = 0x77; |
p_hight_data->i_mk[6] = 0x66; |
p_hight_data->i_mk[5] = 0x55; |
p_hight_data->i_mk[4] = 0x44; |
p_hight_data->i_mk[3] = 0x33; |
p_hight_data->i_mk[2] = 0x22; |
p_hight_data->i_mk[1] = 0x11; |
p_hight_data->i_mk[0] = 0x00; |
|
// Cipher Text |
p_hight_data->i_pct[7] = 0x23; |
p_hight_data->i_pct[6] = 0xce; |
p_hight_data->i_pct[5] = 0x9f; |
p_hight_data->i_pct[4] = 0x72; |
p_hight_data->i_pct[3] = 0xe5; |
p_hight_data->i_pct[2] = 0x43; |
p_hight_data->i_pct[1] = 0xe6; |
p_hight_data->i_pct[0] = 0xd8; |
|
// Expected Plain Text |
expected_p_text[7] = 0x00; |
expected_p_text[6] = 0x11; |
expected_p_text[5] = 0x22; |
expected_p_text[4] = 0x33; |
expected_p_text[3] = 0x44; |
expected_p_text[2] = 0x55; |
expected_p_text[1] = 0x66; |
expected_p_text[0] = 0x77; |
|
|
#elif 0 |
// Test vector 3 |
printf("test vectors 3\n"); |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x00; |
p_hight_data->i_mk[14] = 0x01; |
p_hight_data->i_mk[13] = 0x02; |
p_hight_data->i_mk[12] = 0x03; |
p_hight_data->i_mk[11] = 0x04; |
p_hight_data->i_mk[10] = 0x05; |
p_hight_data->i_mk[9] = 0x06; |
p_hight_data->i_mk[8] = 0x07; |
p_hight_data->i_mk[7] = 0x08; |
p_hight_data->i_mk[6] = 0x09; |
p_hight_data->i_mk[5] = 0x0a; |
p_hight_data->i_mk[4] = 0x0b; |
p_hight_data->i_mk[3] = 0x0c; |
p_hight_data->i_mk[2] = 0x0d; |
p_hight_data->i_mk[1] = 0x0e; |
p_hight_data->i_mk[0] = 0x0f; |
|
// Cipher Text |
p_hight_data->i_pct[7] = 0x7a; |
p_hight_data->i_pct[6] = 0x6f; |
p_hight_data->i_pct[5] = 0xb2; |
p_hight_data->i_pct[4] = 0xa2; |
p_hight_data->i_pct[3] = 0x8d; |
p_hight_data->i_pct[2] = 0x23; |
p_hight_data->i_pct[1] = 0xf4; |
p_hight_data->i_pct[0] = 0x66; |
|
// Expected plain Text |
expected_p_text[7] = 0x01; |
expected_p_text[6] = 0x23; |
expected_p_text[5] = 0x45; |
expected_p_text[4] = 0x67; |
expected_p_text[3] = 0x89; |
expected_p_text[2] = 0xab; |
expected_p_text[1] = 0xcd; |
expected_p_text[0] = 0xef; |
|
#elif 1 |
// Test vector 4 |
printf("test vectors 4\n"); |
|
//MasterKey |
p_hight_data->i_mk[15] = 0x28; |
p_hight_data->i_mk[14] = 0xdb; |
p_hight_data->i_mk[13] = 0xc3; |
p_hight_data->i_mk[12] = 0xbc; |
p_hight_data->i_mk[11] = 0x49; |
p_hight_data->i_mk[10] = 0xff; |
p_hight_data->i_mk[9] = 0xd8; |
p_hight_data->i_mk[8] = 0x7d; |
p_hight_data->i_mk[7] = 0xcf; |
p_hight_data->i_mk[6] = 0xa5; |
p_hight_data->i_mk[5] = 0x09; |
p_hight_data->i_mk[4] = 0xb1; |
p_hight_data->i_mk[3] = 0x1d; |
p_hight_data->i_mk[2] = 0x42; |
p_hight_data->i_mk[1] = 0x2b; |
p_hight_data->i_mk[0] = 0xe7; |
|
// Cipher Text |
p_hight_data->i_pct[7] = 0xcc; |
p_hight_data->i_pct[6] = 0x04; |
p_hight_data->i_pct[5] = 0x7a; |
p_hight_data->i_pct[4] = 0x75; |
p_hight_data->i_pct[3] = 0x20; |
p_hight_data->i_pct[2] = 0x9c; |
p_hight_data->i_pct[1] = 0x1f; |
p_hight_data->i_pct[0] = 0xc6; |
|
// Expected plain Text |
expected_p_text[7] = 0xb4; |
expected_p_text[6] = 0x1e; |
expected_p_text[5] = 0x6b; |
expected_p_text[4] = 0xe2; |
expected_p_text[3] = 0xeb; |
expected_p_text[2] = 0xa8; |
expected_p_text[1] = 0x4a; |
expected_p_text[0] = 0x14; |
|
#endif |
|
WhiteningKeyGen(p_hight_data->i_mk, p_hight_data->wk); |
|
DeltaGen(p_hight_data->delta); |
|
SubKeyGen(p_hight_data->i_mk, |
p_hight_data->delta, |
p_hight_data->sk); |
|
// Reverse of sk |
for(i=0; i<=127; i++){ |
dec_sk[127-i] = p_hight_data->sk[i]; |
} |
|
FinalWhiteningFunction(DEC, p_hight_data->i_pct, p_hight_data->wk, p_hight_data->fwf); |
|
// RoundFunction1 |
InterRoundFunction(DEC, |
p_hight_data->fwf, |
dec_sk,//p_hight_data->sk+124, |
p_hight_data->rf[1]); |
|
// InterRoundFunction2~31 |
for(i=1; i<31; i++){ |
InterRoundFunction(DEC, |
p_hight_data->rf[i], |
dec_sk+i*4, //p_hight_data->sk+((31-i)*4), |
p_hight_data->rf[i+1]); |
} |
// RoundFunction32 |
FinalRoundFunction(DEC, |
p_hight_data->rf[31], |
dec_sk+124, //p_hight_data->sk, |
p_hight_data->rf[32]); |
|
InitialWhiteningFunction(DEC, p_hight_data->rf[32], p_hight_data->wk, p_hight_data->iwf); |
|
for(i=7; i>=0; i--) { |
p_hight_data->o_cpt[i] = p_hight_data->iwf[i]; |
} |
|
printf("\n>>> Cipher text <<<\n"); |
for(i=7; i>=0; i--) { |
printf("pt[%02d] = %02x\n", i, p_hight_data->i_pct[i]); |
} |
|
printf("\n>>> Master key <<<\n"); |
for(i=15; i>=0; i--) { |
printf("mk[%02d] = %02x\n", i, p_hight_data->i_mk[i]); |
} |
|
printf("\n>>> HightDecryption result <<<\n"); |
for(i=7; i>=0; i--) { |
if(p_hight_data->o_cpt[i] == expected_p_text[i]) |
printf("o_c_text[%02d] = %02x : Correct\n", i , p_hight_data->o_cpt[i]); |
else |
printf("o_c_text[%02d] = %02x : Wrong (expected = %02x) \n", i, p_hight_data->o_cpt[i], expected_p_text[i]); |
} |
|
printf("\n\n==== Verbose Log ====\n"); |
|
printf("\n>>> FinalWhiFunction <<<\n"); |
printf("Final : %02x %02x %02x %02x %02x %02x %02x %02x \n", |
p_hight_data->fwf[7], p_hight_data->fwf[6], p_hight_data->fwf[5], p_hight_data->fwf[4], |
p_hight_data->fwf[3], p_hight_data->fwf[2], p_hight_data->fwf[1], p_hight_data->fwf[0]); |
|
printf("\n>>> RoundFunction <<<\n"); |
for(i=1; i<=32; i++){ |
printf("Round[%02d] : %02x %02x %02x %02x %02x %02x %02x %02x\n", |
i, p_hight_data->rf[i][7], p_hight_data->rf[i][6], |
p_hight_data->rf[i][5], p_hight_data->rf[i][4], |
p_hight_data->rf[i][3], p_hight_data->rf[i][2], |
p_hight_data->rf[i][1], p_hight_data->rf[i][0]); |
} |
|
printf("\n>>> InitialWhiteningFunction <<<\n"); |
printf("Initial : %02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_data->iwf[7], p_hight_data->iwf[6], p_hight_data->iwf[5], p_hight_data->iwf[4], |
p_hight_data->iwf[3], p_hight_data->iwf[2], p_hight_data->iwf[1], p_hight_data->iwf[0]); |
|
|
} |
|
|
/hight/trunk/sw/hight_test.c
0,0 → 1,311
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Source file of top test function for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#include "hight.h" |
#include "hight_test.h" |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
|
const byte vec_pt[4][8] = { // vec_pt[vec_num-1] |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, |
{0x77,0x66,0x55,0x44,0x33,0x22,0x11,0x00}, |
{0xef,0xcd,0xab,0x89,0x67,0x45,0x23,0x01}, |
{0x14,0x4a,0xa8,0xeb,0xe2,0x6b,0x1e,0xb4} |
}; |
|
const byte vec_mk[4][16] = { // vec_mk[vec_num-1] |
{0xff,0xee,0xdd,0xcc,0xbb,0xaa,0x99,0x88,0x77,0x66,0x55,0x44,0x33,0x22,0x11,0x00}, |
{0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff}, |
{0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00}, |
{0xe7,0x2b,0x42,0x1d,0xb1,0x09,0xa5,0xcf,0x7d,0xd8,0xff,0x49,0xbc,0xc3,0xdb,0x28} |
}; |
|
const byte vec_ct[4][8] = { // vec_ct[vec_num-1] |
{0xf2,0x03,0x4f,0xd9,0xae,0x18,0xf4,0x00}, |
{0xd8,0xe6,0x43,0xe5,0x72,0x9f,0xce,0x23}, |
{0x66,0xf4,0x23,0x8d,0xa2,0xb2,0x6f,0x7a}, |
{0xc6,0x1f,0x9c,0x20,0x75,0x7a,0x04,0xcc} |
}; |
|
|
/* ===================================== |
|
HightTopTest |
|
=======================================*/ |
void HightTopTest(const char *vec_id, int op_mode, int dump_opt, const char *dump_fname, HIGHT_DATA *p_hight_vec) |
{ |
enum{SUCC=0,FAIL}; |
|
FILE *fdump = NULL; |
int compResult = FAIL; |
int i; |
byte expected1[8] = {0}; |
byte expected2[8] = {0}; |
|
// setup input vectors |
if(!strcmp(vec_id, "v1")) { |
if(op_mode == ENC) { |
memcpy(p_hight_vec->i_pct, vec_pt[0], 8); |
} else if(op_mode == DEC) { |
memcpy(p_hight_vec->i_pct, vec_ct[0], 8); |
} else { |
printf("Error\n"); |
return; |
} |
memcpy(p_hight_vec->i_mk, vec_mk[0], 16); |
|
} else if (!strcmp(vec_id, "v2")) { |
if(op_mode == ENC) { |
memcpy(p_hight_vec->i_pct, vec_pt[1], 8); |
} else if(op_mode == DEC) { |
memcpy(p_hight_vec->i_pct, vec_ct[1], 8); |
} else { |
printf("Error!!\n"); |
return; |
} |
memcpy(p_hight_vec->i_mk, vec_mk[1], 16); |
|
} else if (!strcmp(vec_id, "v3")) { |
if(op_mode == ENC) { |
memcpy(p_hight_vec->i_pct, vec_pt[2], 8); |
} else if(op_mode == DEC) { |
memcpy(p_hight_vec->i_pct, vec_ct[2], 8); |
} else { |
printf("Error!!!\n"); |
return; |
} |
memcpy(p_hight_vec->i_mk, vec_mk[2], 16); |
|
} else if (!strcmp(vec_id, "v4")) { |
if(op_mode == ENC) { |
memcpy(p_hight_vec->i_pct, vec_pt[3], 8); |
} else if(op_mode == DEC) { |
memcpy(p_hight_vec->i_pct, vec_ct[3], 8); |
} else { |
printf("Error!!!!\n"); |
return; |
} |
memcpy(p_hight_vec->i_mk, vec_mk[3], 16); |
|
} else if (!strcmp(vec_id, "rv")) { |
|
} else { |
printf("Error!!!!!!!!\n"); |
return; |
} |
|
// Run !!! |
HightTop(op_mode, p_hight_vec); |
|
// Compare |
if(op_mode == ENC) { |
compResult = (((!strcmp(vec_id, "v1") && !memcmp(vec_ct[0], p_hight_vec->o_cpt, 8)) || |
(!strcmp(vec_id, "v2") && !memcmp(vec_ct[1], p_hight_vec->o_cpt, 8)) || |
(!strcmp(vec_id, "v3") && !memcmp(vec_ct[2], p_hight_vec->o_cpt, 8)) || |
(!strcmp(vec_id, "v4") && !memcmp(vec_ct[3], p_hight_vec->o_cpt, 8))) ? SUCC : FAIL); |
} else if(op_mode == DEC) { |
compResult = (((!strcmp(vec_id, "v1") && !memcmp(vec_pt[0], p_hight_vec->o_cpt, 8)) || |
(!strcmp(vec_id, "v2") && !memcmp(vec_pt[1], p_hight_vec->o_cpt, 8)) || |
(!strcmp(vec_id, "v3") && !memcmp(vec_pt[2], p_hight_vec->o_cpt, 8)) || |
(!strcmp(vec_id, "v4") && !memcmp(vec_pt[3], p_hight_vec->o_cpt, 8))) ? SUCC : FAIL); |
} else { |
printf("Error!!!\n"); |
return; |
} |
|
// Display result |
// * ^.~ * |
printf("//===== %s =====//\n", (op_mode == ENC) ? "Encryption" : |
(op_mode == DEC) ? "Decryption" : "==Error=="); |
printf("// %s [7..0]\n", (op_mode == ENC) ? "Plain text" : |
(op_mode == DEC) ? "Cipher text" : "Error~"); |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->i_pct[7], |
p_hight_vec->i_pct[6], |
p_hight_vec->i_pct[5], |
p_hight_vec->i_pct[4], |
p_hight_vec->i_pct[3], |
p_hight_vec->i_pct[2], |
p_hight_vec->i_pct[1], |
p_hight_vec->i_pct[0]); |
// * ^.~ * |
printf("// Master key [15..0]\n"); |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->i_mk[15], |
p_hight_vec->i_mk[14], |
p_hight_vec->i_mk[13], |
p_hight_vec->i_mk[12], |
p_hight_vec->i_mk[11], |
p_hight_vec->i_mk[10], |
p_hight_vec->i_mk[9], |
p_hight_vec->i_mk[8], |
p_hight_vec->i_mk[7], |
p_hight_vec->i_mk[6], |
p_hight_vec->i_mk[5], |
p_hight_vec->i_mk[4], |
p_hight_vec->i_mk[3], |
p_hight_vec->i_mk[2], |
p_hight_vec->i_mk[1], |
p_hight_vec->i_mk[0]); |
// * ^.~ * |
printf("// Whitening key [7..0]\n"); |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->wk[7], |
p_hight_vec->wk[6], |
p_hight_vec->wk[5], |
p_hight_vec->wk[4], |
p_hight_vec->wk[3], |
p_hight_vec->wk[2], |
p_hight_vec->wk[1], |
p_hight_vec->wk[0]); |
// * ^.~ * |
printf("// Delta [0..127]\n"); |
for(i=0; i<128; i+=8) |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->delta[i], |
p_hight_vec->delta[i+1], |
p_hight_vec->delta[i+2], |
p_hight_vec->delta[i+3], |
p_hight_vec->delta[i+4], |
p_hight_vec->delta[i+5], |
p_hight_vec->delta[i+6], |
p_hight_vec->delta[i+7]); |
// * ^.~ * |
printf("// Sub key [0..127]\n"); |
for(i=0; i<128; i+=8) |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->sk[i], |
p_hight_vec->sk[i+1], |
p_hight_vec->sk[i+2], |
p_hight_vec->sk[i+3], |
p_hight_vec->sk[i+4], |
p_hight_vec->sk[i+5], |
p_hight_vec->sk[i+6], |
p_hight_vec->sk[i+7]); |
// * ^.~ * |
printf("// %s whitening function(1st) [7..0]\n", (op_mode == ENC) ? "Initial" : |
(op_mode == DEC) ? "Final" : "Error~"); |
if(op_mode == ENC){ |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->iwf[7], |
p_hight_vec->iwf[6], |
p_hight_vec->iwf[5], |
p_hight_vec->iwf[4], |
p_hight_vec->iwf[3], |
p_hight_vec->iwf[2], |
p_hight_vec->iwf[1], |
p_hight_vec->iwf[0]); |
} else if(op_mode == DEC){ |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->fwf[7], |
p_hight_vec->fwf[6], |
p_hight_vec->fwf[5], |
p_hight_vec->fwf[4], |
p_hight_vec->fwf[3], |
p_hight_vec->fwf[2], |
p_hight_vec->fwf[1], |
p_hight_vec->fwf[0]); |
} |
|
// * ^.~ * |
printf("// Round function 1~32 [7..0]\n"); |
for(i=1; i<=32; i++) |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->rf[i][7], |
p_hight_vec->rf[i][6], |
p_hight_vec->rf[i][5], |
p_hight_vec->rf[i][4], |
p_hight_vec->rf[i][3], |
p_hight_vec->rf[i][2], |
p_hight_vec->rf[i][1], |
p_hight_vec->rf[i][0]); |
|
// * ^.~ * |
printf("// %s whitening function(2nd) [7..0]\n", (op_mode == ENC) ? "Final" : |
(op_mode == DEC) ? "Initial" : "Error~"); |
if(op_mode == ENC){ |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->fwf[7], |
p_hight_vec->fwf[6], |
p_hight_vec->fwf[5], |
p_hight_vec->fwf[4], |
p_hight_vec->fwf[3], |
p_hight_vec->fwf[2], |
p_hight_vec->fwf[1], |
p_hight_vec->fwf[0]); |
} else if(op_mode == DEC){ |
printf("%02x %02x %02x %02x %02x %02x %02x %02x\n", |
p_hight_vec->iwf[7], |
p_hight_vec->iwf[6], |
p_hight_vec->iwf[5], |
p_hight_vec->iwf[4], |
p_hight_vec->iwf[3], |
p_hight_vec->iwf[2], |
p_hight_vec->iwf[1], |
p_hight_vec->iwf[0]); |
} |
|
// * ^.~ * |
printf("// %s [7..0]\n", (op_mode == ENC) ? "Cipher text" : |
(op_mode == DEC) ? "Plain text" : "Error~"); |
printf("%02x %02x %02x %02x %02x %02x %02x %02x (%s)\n\n\n", |
p_hight_vec->o_cpt[7], |
p_hight_vec->o_cpt[6], |
p_hight_vec->o_cpt[5], |
p_hight_vec->o_cpt[4], |
p_hight_vec->o_cpt[3], |
p_hight_vec->o_cpt[2], |
p_hight_vec->o_cpt[1], |
p_hight_vec->o_cpt[0], |
(compResult == SUCC) ? "Correct" : "Wrong"); |
// Dump |
if(dump_opt) { |
if(!(fdump = fopen(dump_fname, "w+"))){ |
printf("fail to create dump file... Error!!!\n"); |
return; |
} |
|
fclose(fdump); |
} |
} |
/hight/trunk/sw/hight.c
0,0 → 1,356
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Source file of hight core functions for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#include "hight.h" |
#include <stdio.h> |
#include <string.h> |
|
//#define SUB_KEY_GEN_DUMP |
|
|
/* ===================================== |
|
WhiteningKeyGen (WKG) |
|
=======================================*/ |
void WhiteningKeyGen(byte *i_mk, byte *o_wk) |
{ |
|
|
o_wk[0] = i_mk[12]; |
o_wk[1] = i_mk[13]; |
o_wk[2] = i_mk[14]; |
o_wk[3] = i_mk[15]; |
o_wk[4] = i_mk[ 0]; |
o_wk[5] = i_mk[ 1]; |
o_wk[6] = i_mk[ 2]; |
o_wk[7] = i_mk[ 3]; |
} |
|
|
|
/* ===================================== |
|
DeltaGen (DG) |
|
=======================================*/ |
void DeltaGen(byte *o_delta) |
{ |
static byte s[133]; |
int i; |
|
s[0] = 0 ; |
s[1] = 1 ; |
s[2] = 0 ; |
s[3] = 1 ; |
s[4] = 1 ; |
s[5] = 0 ; |
s[6] = 1 ; |
|
|
for(i=1; i<128; i++){ |
s[i+6]= s[i+2]^s[i-1]; |
} |
|
o_delta[0] = s[0]|s[1]<<1|s[2]<<2|s[3]<<3|s[4]<<4|s[5]<<5|s[6]<<6; |
for(i=1; i<128; i++){ |
o_delta[i] = s[i]|s[i+1]<<1|s[i+2]<<2|s[i+3]<<3|s[i+4]<<4|s[i+5]<<5|s[i+6]<<6; |
} |
} |
|
|
|
/* ===================================== |
|
SubKeyGen (SKG) |
|
=======================================*/ |
void SubKeyGen(byte *i_mk, byte *i_delta, byte *o_sk) |
{ |
int i, j; |
#ifdef SUB_KEY_GEN_DUMP |
FILE *fp = fopen("result.txt", "w+"); |
#endif |
|
/* |
// print delta values |
for (i=0; i<128; i++){ |
printf("%02X ", i_delta[i]); |
if(i%8 == 7) |
printf("\n"); |
} |
*/ |
|
for(i=0; i<8; i++){ |
for(j=0; j<8; j++){ |
o_sk[16*i+j]=(byte)(i_mk[(j-i)&7]+i_delta[16*i+j]); |
#ifdef SUB_KEY_GEN_DUMP |
fprintf(fp, "rk[%d]:%02X = (mk[%d]:%02X + delta[%d]:%02X\n", 16*i+j, o_sk[16*i+j], |
(j-i)&7, i_mk[(j-i)&7], |
16*i+j, i_delta[16*i+j]); // comp |
#endif |
} |
for(j=0; j<8; j++){ |
o_sk[16*i+j+8]=(byte)(i_mk[((j-i)&7)+8]+i_delta[16*i+j+8]); |
#ifdef SUB_KEY_GEN_DUMP |
fprintf(fp, "rk[%d]:%02X = (mk[%d]:%02X + delta[%d]:%02X\n", 16*i+j+8, o_sk[16*i+j+8], |
((j-i)&7)+8, i_mk[((j-i)&7)+8], |
16*i+j+8, i_delta[16*i+j+8]); // comp |
#endif |
} |
} |
|
#ifdef SUB_KEY_GEN_DUMP |
fclose(fp); // comp |
#endif |
} |
|
|
/* ===================================== |
|
InitialWhiteningFunction (IWF) |
|
=======================================*/ |
void InitialWhiteningFunction(int i_op, byte *i_pc_text, byte *i_wk, byte *o_xx) |
{ |
o_xx[7] = i_pc_text[7]; |
o_xx[6] = (i_op == ENC) ? i_pc_text[6] ^ i_wk[3] : |
i_pc_text[6] ^ i_wk[3] ; // op == DEC |
o_xx[5] = i_pc_text[5]; |
o_xx[4] = (i_op == ENC) ? (i_pc_text[4] + i_wk[2])&0xff : |
(i_pc_text[4] - i_wk[2])&0xff ; // op == DEC |
o_xx[3] = i_pc_text[3]; |
o_xx[2] = (i_op == ENC) ? i_pc_text[2] ^ i_wk[1] : |
i_pc_text[2] ^ i_wk[1] ; // op == DEC |
o_xx[1] = i_pc_text[1]; |
o_xx[0] = (i_op == ENC) ? (i_pc_text[0] + i_wk[0])&0xff : |
(i_pc_text[0] - i_wk[0])&0xff ; // op == DEC |
|
} |
|
|
/* ===================================== |
|
InterRoundFunction (IRF) |
|
=======================================*/ |
void InterRoundFunction(int i_op, byte *i_xx, byte *i_rsk, byte*o_xx) |
{ |
o_xx[7] = (i_op == ENC) ? i_xx[6] : |
i_xx[0] ; |
|
o_xx[6] = (i_op == ENC) ? i_xx[5] + (((i_xx[4]<<3 | i_xx[4]>>5) ^ (i_xx[4]<<4 | i_xx[4]>>4) |
^ (i_xx[4]<<6 | i_xx[4]>>2))^i_rsk[2])&0xff : |
i_xx[7] ^ (((i_xx[6]<<1 | i_xx[6]>>7) ^ (i_xx[6]<<2 | i_xx[6]>>6) |
^ (i_xx[6]<<7 | i_xx[6]>>1))+i_rsk[0]&0xff) ; |
|
o_xx[5] = (i_op == ENC) ? i_xx[4] : |
i_xx[6] ; |
|
o_xx[4] = (i_op == ENC) ? i_xx[3] ^ (((i_xx[2]<<1 | i_xx[2]>>7) ^ (i_xx[2]<<2 | i_xx[2]>>6) |
^ (i_xx[2]<<7 | i_xx[2]>>1))+i_rsk[1]&0xff) : |
i_xx[5] - (((i_xx[4]<<3 | i_xx[4]>>5) ^ (i_xx[4]<<4 | i_xx[4]>>4) |
^ (i_xx[4]<<6 | i_xx[4]>>2))^i_rsk[1])&0xff ; |
|
o_xx[3] = (i_op == ENC) ? i_xx[2] : |
i_xx[4] ; |
|
o_xx[2] = (i_op == ENC) ? i_xx[1] + (((i_xx[0]<<3 | i_xx[0]>>5) ^ (i_xx[0]<<4 | i_xx[0]>>4) |
^ (i_xx[0]<<6 | i_xx[0]>>2))^i_rsk[0])&0xff : |
i_xx[3] ^ (((i_xx[2]<<1 | i_xx[2]>>7) ^ (i_xx[2]<<2 | i_xx[2]>>6) |
^ (i_xx[2]<<7 | i_xx[2]>>1))+i_rsk[2]&0xff) ; |
o_xx[1] = (i_op == ENC) ? i_xx[0] : |
i_xx[2] ; |
|
o_xx[0] = (i_op == ENC) ? i_xx[7] ^ (((i_xx[6]<<1 | i_xx[6]>>7) ^ (i_xx[6]<<2 | i_xx[6]>>6) |
^ (i_xx[6]<<7 | i_xx[6]>>1))+i_rsk[3]&0xff) : |
i_xx[1] - (((i_xx[0]<<3 | i_xx[0]>>5) ^ (i_xx[0]<<4 | i_xx[0]>>4) |
^ (i_xx[0]<<6 | i_xx[0]>>2))^i_rsk[3])&0xff ; |
} |
|
|
/* ===================================== |
|
FinalRoundFunction (FRF) |
|
=======================================*/ |
void FinalRoundFunction(int i_op, byte *i_xx, byte *i_rsk, byte *o_rf) |
{ |
|
o_rf[7] = (i_op == ENC) ? i_xx[7] ^ (((i_xx[6]<<1 | i_xx[6]>>7) ^ (i_xx[6]<<2 | i_xx[6]>>6) ^ |
(i_xx[6]<<7 | i_xx[6]>>1))+i_rsk[3]&0xff) : |
i_xx[7] ^ (((i_xx[6]<<1 | i_xx[6]>>7) ^ (i_xx[6]<<2 | i_xx[6]>>6) ^ |
(i_xx[6]<<7 | i_xx[6]>>1))+i_rsk[0]&0xff) ; |
|
o_rf[6] = i_xx[6]; |
|
o_rf[5] = (i_op == ENC) ? i_xx[5] + (((i_xx[4]<<3 | i_xx[4]>>5) ^ (i_xx[4]<<4 | i_xx[4]>>4) ^ |
(i_xx[4]<<6 | i_xx[4]>>2))^i_rsk[2])&0xff : |
i_xx[5] - (((i_xx[4]<<3 | i_xx[4]>>5) ^ (i_xx[4]<<4 | i_xx[4]>>4) ^ |
(i_xx[4]<<6 | i_xx[4]>>2))^i_rsk[1])&0xff; |
|
o_rf[4] = i_xx[4]; |
|
o_rf[3] = (i_op == ENC) ? i_xx[3] ^ (((i_xx[2]<<1 | i_xx[2]>>7) ^ (i_xx[2]<<2 | i_xx[2]>>6) ^ |
(i_xx[2]<<7 | i_xx[2]>>1))+i_rsk[1]&0xff) : |
i_xx[3] ^ (((i_xx[2]<<1 | i_xx[2]>>7) ^ (i_xx[2]<<2 | i_xx[2]>>6) ^ |
(i_xx[2]<<7 | i_xx[2]>>1))+i_rsk[2]&0xff); |
|
o_rf[2] = i_xx[2]; |
|
o_rf[1] = (i_op == ENC) ? i_xx[1] + (((i_xx[0]<<3 | i_xx[0]>>5) ^ (i_xx[0]<<4 | i_xx[0]>>4) ^ |
(i_xx[0]<<6 | i_xx[0]>>2))^i_rsk[0])&0xff : |
i_xx[1] - (((i_xx[0]<<3 | i_xx[0]>>5) ^ (i_xx[0]<<4 | i_xx[0]>>4) ^ |
(i_xx[0]<<6 | i_xx[0]>>2))^i_rsk[3])&0xff; |
|
o_rf[0] = i_xx[0]; |
|
} |
|
|
/* ===================================== |
|
FinalWhiteningFunction (FWF) |
|
=======================================*/ |
void FinalWhiteningFunction(int i_op, byte *i_rf, byte *i_wk, byte *o_cp_text) |
{ |
|
o_cp_text[7] = (i_op == ENC) ? i_rf[7] : |
i_rf[7] ; |
o_cp_text[6] = (i_op == ENC) ? i_rf[6] ^ i_wk[7] : |
i_rf[6] ^ i_wk[7] ; // op == DEC ; |
o_cp_text[5] = (i_op == ENC) ? i_rf[5] : |
i_rf[5]; |
o_cp_text[4] = (i_op == ENC) ? (i_rf[4] + i_wk[6])&0xff : |
(i_rf[4] - i_wk[6])&0xff ; |
o_cp_text[3] = (i_op == ENC) ? i_rf[3] : |
i_rf[3] ; |
o_cp_text[2] = (i_op == ENC) ? i_rf[2] ^ i_wk[5] : |
i_rf[2] ^ i_wk[5] ; // op == DEC |
o_cp_text[1] = (i_op == ENC) ? i_rf[1] : |
i_rf[1] ; |
o_cp_text[0] = (i_op == ENC) ? (i_rf[0] + i_wk[4])&0xff : |
(i_rf[0] - i_wk[4])&0xff ; // op == DEC; |
|
} |
|
|
/* ===================================== |
|
HightTop (HT) |
|
=======================================*/ |
void HightTop(int i_op, HIGHT_DATA *p_hight_data) |
{ |
int i; |
byte w_sk[128] = {0}; |
byte w_wf1[8] = {0}; |
byte w_wf2[8] = {0}; |
|
// Whitening Key Generation |
WhiteningKeyGen(p_hight_data->i_mk, p_hight_data->wk); |
|
// Delta Generation |
DeltaGen(p_hight_data->delta); |
|
// Sub Key Generation |
SubKeyGen(p_hight_data->i_mk, |
p_hight_data->delta, |
p_hight_data->sk); |
|
// re-arrange subkey index |
if(i_op == ENC) { |
for(i=0; i<=127; i++) |
w_sk[i] = p_hight_data->sk[i]; |
} else if(i_op == DEC) { |
for(i=0; i<=127; i++) |
w_sk[127-i] = p_hight_data->sk[i]; |
} else { |
printf("Error\n"); |
} |
|
// select proper WF related to i_op |
if(i_op == ENC) { |
InitialWhiteningFunction(i_op, p_hight_data->i_pct, p_hight_data->wk, p_hight_data->iwf); |
memcpy(w_wf1, p_hight_data->iwf, 8); |
} else if(i_op == DEC) { |
FinalWhiteningFunction(i_op, p_hight_data->i_pct, p_hight_data->wk, p_hight_data->fwf); |
memcpy(w_wf1, p_hight_data->fwf, 8); |
} else { |
printf("Error\n"); |
} |
|
|
// RoundFunction1 |
InterRoundFunction(i_op, |
w_wf1, |
w_sk, |
p_hight_data->rf[1]); |
|
// InterRoundFunction2~31 |
for(i=1; i<31; i++){ |
InterRoundFunction(i_op, |
p_hight_data->rf[i], |
w_sk+(i*4), |
p_hight_data->rf[i+1]); |
} |
// RoundFunction32 |
FinalRoundFunction(i_op, |
p_hight_data->rf[31], |
w_sk+(31*4), |
p_hight_data->rf[32]); |
|
// select proper WF related to i_op |
if(i_op == ENC){ |
FinalWhiteningFunction(i_op, p_hight_data->rf[32], p_hight_data->wk, p_hight_data->fwf); |
memcpy(w_wf2, p_hight_data->fwf, 8); |
} else if(i_op == DEC) { |
InitialWhiteningFunction(i_op, p_hight_data->rf[32], p_hight_data->wk, p_hight_data->iwf); |
memcpy(w_wf2, p_hight_data->iwf, 8); |
} else { |
printf("Error\n"); |
} |
|
// assign output |
memcpy(p_hight_data->o_cpt, w_wf2, 8); |
} |
/hight/trunk/sw/main.c
0,0 → 1,104
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Main source file for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#include <stdlib.h> |
#include "hight.h" |
#include "hight_unit_test.h" |
#include "hight_test.h" |
|
HIGHT_DATA *p_hight_data; |
|
|
/* ===================================== |
|
main() |
|
=======================================*/ |
int main (int argc, char *argv[]) |
{ |
p_hight_data = (HIGHT_DATA *)malloc(sizeof(HIGHT_DATA)*1); |
|
// DeltaGenTest |
//DeltaGenTest(); |
|
// SubKeyGenTest |
//SubKeyGenTest(); |
|
// WhiteningKeyGenTest |
//WhiteningKeyGenTest(); |
|
// InitialWhiteningFunctionTest |
//InitialWhiteningFunctionTest(); |
|
// FinalWhiteningFunctionTest |
//FinalWhiteningFunctionTest(); |
|
// InterRoundFunctionTest |
//InterRoundFunctionTest(); |
|
// FinalRoundFunctionTest |
//FinalRoundFunctionTest(); |
|
//HightEncryptionTest |
//HightEncryptionTest(); |
|
//HightDecryptionTest |
//HightDecryptionTest(); |
|
HightTopTest("v1", ENC, 0, "", p_hight_data); |
HightTopTest("v1", DEC, 0, "", p_hight_data); |
|
HightTopTest("v2", ENC, 0, "", p_hight_data); |
HightTopTest("v2", DEC, 0, "", p_hight_data); |
|
HightTopTest("v3", ENC, 0, "", p_hight_data); |
HightTopTest("v3", DEC, 0, "", p_hight_data); |
|
HightTopTest("v4", ENC, 0, "", p_hight_data); |
HightTopTest("v4", DEC, 0, "", p_hight_data); |
|
free(p_hight_data); |
|
return 0; |
} |
|
|
/hight/trunk/sw/hight_unit_test.h
0,0 → 1,119
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Header file of unit test functions for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#ifndef __HIGHT_UNIT_TEST_H__ |
#define __HIGHT_UNIT_TEST_H__ |
|
/* ===================================== |
|
DeltaGenTest() |
|
=======================================*/ |
void DeltaGenTest(); |
|
|
/* ===================================== |
|
SubKeyGenTest() |
|
=======================================*/ |
void SubKeyGenTest(); |
|
|
/* ===================================== |
|
WhiteningKeyGenTest() |
|
=======================================*/ |
void WhiteningKeyGenTest (); |
|
|
/* ===================================== |
|
InitialWhiteningFunctionTest() |
|
=======================================*/ |
void InitialWhiteningFunctionTest (); |
|
|
/* ===================================== |
|
FinalWhiteningFunctionTest() |
|
=======================================*/ |
void FinalWhiteningFunctionTest (); |
|
|
/* ===================================== |
|
InterRoundFunctionTest() |
|
=======================================*/ |
void InterRoundFunctionTest(); |
|
|
/* ===================================== |
|
FinalRoundFunctionTest () |
|
=======================================*/ |
void FinalRoundFunctionTest(); |
|
|
/* ===================================== |
|
HightEncryptionTest() |
|
=======================================*/ |
void HightEncryptionTest(); |
|
|
/* ===================================== |
|
HightDecryptionTest() |
|
=======================================*/ |
void HightDecryptionTest(); |
|
#endif |
|
|
/hight/trunk/sw/hight_test.h
0,0 → 1,53
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Header file of top test function for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#ifndef __HIGHT_TEST_H__ |
#define __HGITH_TEST_H__ |
|
/* ===================================== |
|
HightTopTest |
|
=======================================*/ |
void HightTopTest(const char *vec_id, int op_mode, int dump_opt, const char *dump_fname, HIGHT_DATA *p_hight_vec); |
|
#endif |
/hight/trunk/sw/hight.h
0,0 → 1,131
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Header file of hight core functions for HIGHT Integer Model //// |
//// //// |
//// This file is part of the HIGHT Crypto Core project //// |
//// http://github.com/OpenSoCPlus/hight_crypto_core //// |
//// http://www.opencores.org/project,hight //// |
//// //// |
//// Description //// |
//// __description__ //// |
//// //// |
//// Author(s): //// |
//// - JoonSoo Ha, json.ha@gmail.com //// |
//// - Younjoo Kim, younjookim.kr@gmail.com //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG //// |
//// //// |
//// This source file may be used and distributed without //// |
//// restriction provided that this copyright statement is not //// |
//// removed from the file and that any derivative work contains //// |
//// the original copyright notice and the associated disclaimer. //// |
//// //// |
//// This source file is free software; you can redistribute it //// |
//// and/or modify it under the terms of the GNU Lesser General //// |
//// Public License as published by the Free Software Foundation; //// |
//// either version 2.1 of the License, or (at your option) any //// |
//// later version. //// |
//// //// |
//// This source is distributed in the hope that it will be //// |
//// useful, but WITHOUT ANY WARRANTY; without even the implied //// |
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// |
//// PURPOSE. See the GNU Lesser General Public License for more //// |
//// details. //// |
//// //// |
//// You should have received a copy of the GNU Lesser General //// |
//// Public License along with this source; if not, download it //// |
//// from http://www.opencores.org/lgpl.shtml //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
#ifndef __HIGHT_H__ |
#define __HIGHT_H__ |
|
#define byte unsigned char |
//#define ROUND_FUNCTION_DUMP |
|
typedef struct _HIGHT_DATA { |
byte i_pct[8]; // plain or cipher text input data |
byte i_mk[16]; // master key input data |
byte wk[8]; // generated white key |
byte delta[128]; // generated delta |
byte sk[128]; // generated sub key |
byte iwf[8]; // result data of intial white function |
byte rf[33][8]; // result data of each round function |
// rf[0][x]s are unused |
byte fwf[8]; // result data of final white function |
byte o_cpt[8]; // cipher or plain text output data |
} HIGHT_DATA; |
|
enum HIGHT_OP{ENC=0, DEC}; |
|
/* ===================================== |
|
WhiteningKeyGen (WKG) |
|
=======================================*/ |
void WhiteningKeyGen(byte *i_mk, byte *o_wk); |
|
|
|
/* ===================================== |
|
DeltaGen (DG) |
|
=======================================*/ |
void DeltaGen(byte *o_delta); |
|
|
|
/* ===================================== |
|
SubKeyGen (SKG) |
|
=======================================*/ |
void SubKeyGen(byte *i_mk, byte *i_delta, byte *o_sk); |
|
|
|
/* ===================================== |
|
InitialWhiteningFunction (IWF) |
|
=======================================*/ |
void InitialWhiteningFunction(int i_op, byte *i_pc_text, byte *i_wk, byte *o_xx); |
|
|
/* ===================================== |
|
InterRoundFunction (IRF) |
|
=======================================*/ |
void InterRoundFunction(int i_op, byte *i_xx, byte *i_rsk, byte *o_xx); |
|
|
/* ===================================== |
|
FinalRoundFunction (FRF) |
|
=======================================*/ |
void FinalRoundFunction(int i_op, byte *i_xx, byte *i_rsk, byte *o_rf); |
|
|
/* ===================================== |
|
FinalWhiteningFunction (FWF) |
|
=======================================*/ |
void FinalWhiteningFunction(int i_op, byte *i_rf, byte *i_wk, byte *o_cp_text); |
|
|
|
/* ===================================== |
|
HightTop (HT) |
|
=======================================*/ |
void HightTop(int i_op, HIGHT_DATA *p_hight_data); |
|
#endif |
/hight/trunk/sw/README.md
0,0 → 1,131
README.md |
/hight/trunk/sw/Makefile
0,0 → 1,21
CC = gcc |
OBJS = hight.o hight_unit_test.o hight_test.o main.o |
TARGET = hight |
|
.SUFFIXES : .c .o |
|
all : $(TARGET) |
|
$(TARGET) : $(OBJS) |
$(CC) -o $@ $(OBJS) |
|
clean : |
rm -f $(OBJS) $(TARGET) |
|
run : |
./$(TARGET) |tee run.log |
|
rclean : |
rm -f run.log |
|
|
/hight/trunk/README.md
0,0 → 1,12
HIGHT_Crypto_Core |
================= |
|
Contributors |
------------- |
* JoonSoo Ha |
* Younjoo Kim |
|
More Informatoin |
---------------- |
* [Project Page] (http://opensocplus.github.io/hight_crypto_core) |
* [OpenSoCPlus Main Page] (http://opensocplus.github.io) |
/hight/trunk/_run_sim_tb_WF
0,0 → 1,23
#!/bin/bash |
|
if [[ -d ./sim/modelsim/work ]] |
then |
rm -r ./sim/modelsim/work |
fi |
|
vlib ./sim/modelsim/work |
|
vlog -work sim/modelsim/work \ |
./testbench/tb_WF.v \ |
./rtl/WF.v |
|
vsim -c \ |
-lib ./sim/modelsim/work \ |
-do ./scr/sim_tb_WF.do |
|
rm ./transcript |
|
|
vcd2wlf ./dump/sim_tb_WF.vcd \ |
./dump/sim_tb_WF.wlf |
|
/hight/trunk/fpga/README.md
0,0 → 1,23
README |
/hight/trunk/_run_sim_tb_HIGHT_CORE_TOP
0,0 → 1,26
#!/bin/bash |
|
if [[ -d ./sim/modelsim/work ]] |
then |
rm -r ./sim/modelsim/work |
fi |
|
vlib ./sim/modelsim/work |
|
vlog -work sim/modelsim/work \ |
./testbench/tb_HIGHT_CORE_TOP.v \ |
-f ./rtl/rtl.f |
|
vsim -c \ |
-lib ./sim/modelsim/work \ |
-do ./scr/sim_tb_HIGHT_CORE_TOP.do |
|
rm ./transcript |
|
|
vcd2wlf ./dump/sim_tb_HIGHT_CORE_TOP.vcd \ |
./dump/sim_tb_HIGHT_CORE_TOP.wlf |
|
|
|
|