summaryrefslogtreecommitdiff
path: root/plugins/Kuzne4ikCrypt/src/GOST/28147_14.h
blob: fa6e08cbb2d1fe153b49235314152e7770991903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/** @file 
 * @brief Îáúÿâëåíèå ôóíêöèé ðåàëèçóþùèõ ïðåîáðàçîâàíèÿ èç àëãîðèòìà "Êóçíå÷èê"
 *
 * @copyright InfoTeCS. All rights reserved.
 */

#ifndef C_28147_14_H
#define C_28147_14_H

//#include "dll_import.h"
//#include "callback_print.h"


#ifdef __cplusplus
extern "C" {
#endif

/** @brief Ïðåîáðàçîâàíèå X
 *
 * @param[in] a âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] b âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int funcX(unsigned char* a, unsigned char* b, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå S
 * 
 * @param[in] indata âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int funcS(unsigned char* indata, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå îáðàòíîå ê ïðåîáðàçîâàíèþ  S
 * 
 * @param[in] indata âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int funcReverseS(unsigned char* indata, unsigned char*  outdata);

/** @brief Ïðåîáðàçîâàíèå R
 * 
 * @param[in] indata âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int funcR(unsigned char* indata, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå îáðàòíîå ê ïðåîáðàçîâàíèþ  R
 * 
 * @param[in] indata âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int funcReverseR(unsigned char* indata, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå L
 * 
 * @param[in] indata âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int  funcL(unsigned char* indata, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå îáðàòíîå ê ïðåîáðàçîâàíèþ  L
 * 
 * @param[in] indata âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int  funcReverseL(unsigned char* indata, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå LSX
 * 
 * @param[in] a âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] b âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int  funcLSX(unsigned char* a, unsigned char* b, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå îáðàòíîå ê ïðåîáðàçîâàíèþ  LSX
 * 
 * @param[in] a âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] b âõîäíîé ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[out] outdata ðåçóëüòàò ïàðàìåòð ïðåîáðàçîâàíèÿ
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int  funcReverseLSX(unsigned char* a, unsigned char* b, unsigned char* outdata);

/** @brief Ïðåîáðàçîâàíèå F
 * 
 * @param[in] inputKey Ïåðâûé êëþ÷  èç ïàðû êëþ÷åé ïîëó÷åííîé â ïðåäåäóùåé èòåðàöèè
 * @param[in] inputKeySecond Âòîðîé êëþ÷  èç ïàðû êëþ÷åé ïîëó÷åííîé â ïðåäåäóùåé èòåðàöèè
 * @param[in] iterationConst Èòåðàöèîííàÿ êîíñòàíòà
 * @param[out] outputKey Ïåðâûé êëþ÷
 * @param[out] outputKeySecond Âòîðîé êëþ÷
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int  funcF(unsigned char* inputKey, unsigned char* inputKeySecond, unsigned char* iterationConst, unsigned char* outputKey, unsigned char* outputKeySecond);

/** @brief Âû÷èñëåíèå èòåðàöèîííîé êîíñòàíòû Ñ 
 * 
 * @param[in] number íîìåð êîíñòàíòû
 * @param[out] output èòåðàöèîííàÿ êîíñòàíòà
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int  funcC(unsigned char number, unsigned char* outputW);

/** @brief Ðàçâåðòêà êëþ÷à
 * 
 * @param[in] masterKey Ìàñòåð êëþ÷
 * @param[out] keys ìàññèâ ðàçâåðíóòûõ êëþ÷åé
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int ExpandKey(unsigned char* masterKey, unsigned char* keys);

/** @brief Âûïîëíåíèå çàøèôðîâàíèÿ áëîêà
 * 
 * @param[in] plainText Èñõîäíûé áëîê
 * @param[out] chipherText Çàøèôðîâàííûé áëîê
 * @param[in] keys Ðàçâåðíóòûå êëþ÷è
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @param[in] print_uint ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int Encrypt_14(unsigned char* plainText, unsigned char* chipherText, unsigned char* keys);

/** @brief Âûïîëåíèå ðàñøèôðîâàíèÿ áëîêà
 * 
 * @param[in] chipherText Çàøèôðîâàííûé áëîê
 * @param[out] plainText Ðàñøèôðîâàííûé áëîê
 * @param[in] keys Ðàçâåðíóòûå êëþ÷è
 * @param[in] print ôóíêöèÿ ëîãèðîâàíèÿ
 * @param[in] print_uint ôóíêöèÿ ëîãèðîâàíèÿ
 * @return 0 åñëè âñå ïðåîáðàçîâàíèå ïðîøëî óñïåøíî
 * @return -1 åñëè ïðîèçîøëà îøèáêà
 */
int Decrypt_14(unsigned char* chipherText, unsigned char* plainText, unsigned char* keys);

#ifdef __cplusplus
}
#endif

#endif