1 |
2 |
truemind |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Header file of hight core functions for HIGHT Integer Model ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the HIGHT Crypto Core project ////
|
6 |
|
|
//// http://github.com/OpenSoCPlus/hight_crypto_core ////
|
7 |
|
|
//// http://www.opencores.org/project,hight ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// Description ////
|
10 |
|
|
//// __description__ ////
|
11 |
|
|
//// ////
|
12 |
|
|
//// Author(s): ////
|
13 |
|
|
//// - JoonSoo Ha, json.ha@gmail.com ////
|
14 |
|
|
//// - Younjoo Kim, younjookim.kr@gmail.com ////
|
15 |
|
|
//// ////
|
16 |
|
|
//////////////////////////////////////////////////////////////////////
|
17 |
|
|
//// ////
|
18 |
|
|
//// Copyright (C) 2015 Authors, OpenSoCPlus and OPENCORES.ORG ////
|
19 |
|
|
//// ////
|
20 |
|
|
//// This source file may be used and distributed without ////
|
21 |
|
|
//// restriction provided that this copyright statement is not ////
|
22 |
|
|
//// removed from the file and that any derivative work contains ////
|
23 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
24 |
|
|
//// ////
|
25 |
|
|
//// This source file is free software; you can redistribute it ////
|
26 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
27 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
28 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
29 |
|
|
//// later version. ////
|
30 |
|
|
//// ////
|
31 |
|
|
//// This source is distributed in the hope that it will be ////
|
32 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
33 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
34 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
35 |
|
|
//// details. ////
|
36 |
|
|
//// ////
|
37 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
38 |
|
|
//// Public License along with this source; if not, download it ////
|
39 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
40 |
|
|
//// ////
|
41 |
|
|
//////////////////////////////////////////////////////////////////////
|
42 |
|
|
|
43 |
|
|
#ifndef __HIGHT_H__
|
44 |
|
|
#define __HIGHT_H__
|
45 |
|
|
|
46 |
|
|
#define byte unsigned char
|
47 |
|
|
//#define ROUND_FUNCTION_DUMP
|
48 |
|
|
|
49 |
|
|
typedef struct _HIGHT_DATA {
|
50 |
|
|
byte i_pct[8]; // plain or cipher text input data
|
51 |
|
|
byte i_mk[16]; // master key input data
|
52 |
|
|
byte wk[8]; // generated white key
|
53 |
|
|
byte delta[128]; // generated delta
|
54 |
|
|
byte sk[128]; // generated sub key
|
55 |
|
|
byte iwf[8]; // result data of intial white function
|
56 |
|
|
byte rf[33][8]; // result data of each round function
|
57 |
|
|
// rf[0][x]s are unused
|
58 |
|
|
byte fwf[8]; // result data of final white function
|
59 |
|
|
byte o_cpt[8]; // cipher or plain text output data
|
60 |
|
|
} HIGHT_DATA;
|
61 |
|
|
|
62 |
|
|
enum HIGHT_OP{ENC=0, DEC};
|
63 |
|
|
|
64 |
|
|
/* =====================================
|
65 |
|
|
|
66 |
|
|
WhiteningKeyGen (WKG)
|
67 |
|
|
|
68 |
|
|
=======================================*/
|
69 |
|
|
void WhiteningKeyGen(byte *i_mk, byte *o_wk);
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
/* =====================================
|
74 |
|
|
|
75 |
|
|
DeltaGen (DG)
|
76 |
|
|
|
77 |
|
|
=======================================*/
|
78 |
|
|
void DeltaGen(byte *o_delta);
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
/* =====================================
|
83 |
|
|
|
84 |
|
|
SubKeyGen (SKG)
|
85 |
|
|
|
86 |
|
|
=======================================*/
|
87 |
|
|
void SubKeyGen(byte *i_mk, byte *i_delta, byte *o_sk);
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
/* =====================================
|
92 |
|
|
|
93 |
|
|
InitialWhiteningFunction (IWF)
|
94 |
|
|
|
95 |
|
|
=======================================*/
|
96 |
|
|
void InitialWhiteningFunction(int i_op, byte *i_pc_text, byte *i_wk, byte *o_xx);
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
/* =====================================
|
100 |
|
|
|
101 |
|
|
InterRoundFunction (IRF)
|
102 |
|
|
|
103 |
|
|
=======================================*/
|
104 |
|
|
void InterRoundFunction(int i_op, byte *i_xx, byte *i_rsk, byte *o_xx);
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
/* =====================================
|
108 |
|
|
|
109 |
|
|
FinalRoundFunction (FRF)
|
110 |
|
|
|
111 |
|
|
=======================================*/
|
112 |
|
|
void FinalRoundFunction(int i_op, byte *i_xx, byte *i_rsk, byte *o_rf);
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
/* =====================================
|
116 |
|
|
|
117 |
|
|
FinalWhiteningFunction (FWF)
|
118 |
|
|
|
119 |
|
|
=======================================*/
|
120 |
|
|
void FinalWhiteningFunction(int i_op, byte *i_rf, byte *i_wk, byte *o_cp_text);
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
/* =====================================
|
125 |
|
|
|
126 |
|
|
HightTop (HT)
|
127 |
|
|
|
128 |
|
|
=======================================*/
|
129 |
|
|
void HightTop(int i_op, HIGHT_DATA *p_hight_data);
|
130 |
|
|
|
131 |
|
|
#endif
|