cipher_algorithms.h
Go to the documentation of this file.
1 /**
2  * @file cipher_algorithms.h
3  * @brief Collection of cipher algorithms
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _CIPHER_ALGORITHMS_H
32 #define _CIPHER_ALGORITHMS_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //RC2 cipher support?
38 #if (RC2_SUPPORT == ENABLED)
39  #include "cipher/rc2.h"
40 #endif
41 
42 //RC4 cipher support?
43 #if (RC4_SUPPORT == ENABLED)
44  #include "cipher/rc4.h"
45 #endif
46 
47 //RC6 cipher support?
48 #if (RC6_SUPPORT == ENABLED)
49  #include "cipher/rc6.h"
50 #endif
51 
52 //CAST-128 cipher support?
53 #if (CAST128_SUPPORT == ENABLED)
54  #include "cipher/cast128.h"
55 #endif
56 
57 //CAST-256 cipher support?
58 #if (CAST256_SUPPORT == ENABLED)
59  #include "cipher/cast256.h"
60 #endif
61 
62 //IDEA cipher support?
63 #if (IDEA_SUPPORT == ENABLED)
64  #include "cipher/idea.h"
65 #endif
66 
67 //DES cipher support?
68 #if (DES_SUPPORT == ENABLED)
69  #include "cipher/des.h"
70 #endif
71 
72 //Triple DES cipher support?
73 #if (DES3_SUPPORT == ENABLED)
74  #include "cipher/des3.h"
75 #endif
76 
77 //AES cipher support?
78 #if (AES_SUPPORT == ENABLED)
79  #include "cipher/aes.h"
80 #endif
81 
82 //Blowfish cipher support?
83 #if (BLOWFISH_SUPPORT == ENABLED)
84  #include "cipher/blowfish.h"
85 #endif
86 
87 //Twofish cipher support?
88 #if (TWOFISH_SUPPORT == ENABLED)
89  #include "cipher/twofish.h"
90 #endif
91 
92 //MARS cipher support?
93 #if (MARS_SUPPORT == ENABLED)
94  #include "cipher/mars.h"
95 #endif
96 
97 //Serpent cipher support?
98 #if (SERPENT_SUPPORT == ENABLED)
99  #include "cipher/serpent.h"
100 #endif
101 
102 //Camellia cipher support?
103 #if (CAMELLIA_SUPPORT == ENABLED)
104  #include "cipher/camellia.h"
105 #endif
106 
107 //ARIA cipher support?
108 #if (ARIA_SUPPORT == ENABLED)
109  #include "cipher/aria.h"
110 #endif
111 
112 //SEED cipher support?
113 #if (SEED_SUPPORT == ENABLED)
114  #include "cipher/seed.h"
115 #endif
116 
117 //SM4 cipher support?
118 #if (SM4_SUPPORT == ENABLED)
119  #include "cipher/sm4.h"
120 #endif
121 
122 //PRESENT cipher support?
123 #if (PRESENT_SUPPORT == ENABLED)
124  #include "cipher/present.h"
125 #endif
126 
127 //TEA cipher support?
128 #if (TEA_SUPPORT == ENABLED)
129  #include "cipher/tea.h"
130 #endif
131 
132 //XTEA cipher support?
133 #if (XTEA_SUPPORT == ENABLED)
134  #include "cipher/xtea.h"
135 #endif
136 
137 //Trivium cipher support?
138 #if (TRIVIUM_SUPPORT == ENABLED)
139  #include "cipher/trivium.h"
140 #endif
141 
142 //ZUC cipher support?
143 #if (ZUC_SUPPORT == ENABLED)
144  #include "cipher/zuc.h"
145 #endif
146 
147 //Salsa20 cipher support?
148 #if (SALSA20_SUPPORT == ENABLED)
149  #include "cipher/salsa20.h"
150 #endif
151 
152 //ChaCha cipher support?
153 #if (CHACHA_SUPPORT == ENABLED)
154  #include "cipher/chacha.h"
155 #endif
156 
157 //Maximum block size
158 #if (RC6_SUPPORT == ENABLED)
159  #define MAX_CIPHER_BLOCK_SIZE RC6_BLOCK_SIZE
160 #elif (CAST256_SUPPORT == ENABLED)
161  #define MAX_CIPHER_BLOCK_SIZE CAST256_BLOCK_SIZE
162 #elif (AES_SUPPORT == ENABLED)
163  #define MAX_CIPHER_BLOCK_SIZE AES_BLOCK_SIZE
164 #elif (TWOFISH_SUPPORT == ENABLED)
165  #define MAX_CIPHER_BLOCK_SIZE TWOFISH_BLOCK_SIZE
166 #elif (MARS_SUPPORT == ENABLED)
167  #define MAX_CIPHER_BLOCK_SIZE MARS_BLOCK_SIZE
168 #elif (SERPENT_SUPPORT == ENABLED)
169  #define MAX_CIPHER_BLOCK_SIZE SERPENT_BLOCK_SIZE
170 #elif (CAMELLIA_SUPPORT == ENABLED)
171  #define MAX_CIPHER_BLOCK_SIZE CAMELLIA_BLOCK_SIZE
172 #elif (ARIA_SUPPORT == ENABLED)
173  #define MAX_CIPHER_BLOCK_SIZE ARIA_BLOCK_SIZE
174 #elif (SEED_SUPPORT == ENABLED)
175  #define MAX_CIPHER_BLOCK_SIZE SEED_BLOCK_SIZE
176 #elif (SM4_SUPPORT == ENABLED)
177  #define MAX_CIPHER_BLOCK_SIZE SM4_BLOCK_SIZE
178 #elif (RC2_SUPPORT == ENABLED)
179  #define MAX_CIPHER_BLOCK_SIZE RC2_BLOCK_SIZE
180 #elif (CAST128_SUPPORT == ENABLED)
181  #define MAX_CIPHER_BLOCK_SIZE CAST128_BLOCK_SIZE
182 #elif (IDEA_SUPPORT == ENABLED)
183  #define MAX_CIPHER_BLOCK_SIZE IDEA_BLOCK_SIZE
184 #elif (DES_SUPPORT == ENABLED)
185  #define MAX_CIPHER_BLOCK_SIZE DES_BLOCK_SIZE
186 #elif (DES3_SUPPORT == ENABLED)
187  #define MAX_CIPHER_BLOCK_SIZE DES3_BLOCK_SIZE
188 #elif (BLOWFISH_SUPPORT == ENABLED)
189  #define MAX_CIPHER_BLOCK_SIZE BLOWFISH_BLOCK_SIZE
190 #elif (PRESENT_SUPPORT == ENABLED)
191  #define MAX_CIPHER_BLOCK_SIZE PRESENT_BLOCK_SIZE
192 #elif (TEA_SUPPORT == ENABLED)
193  #define MAX_CIPHER_BLOCK_SIZE TEA_BLOCK_SIZE
194 #elif (XTEA_SUPPORT == ENABLED)
195  #define MAX_CIPHER_BLOCK_SIZE XTEA_BLOCK_SIZE
196 #endif
197 
198 //C++ guard
199 #ifdef __cplusplus
200 extern "C" {
201 #endif
202 
203 
204 /**
205  * @brief Generic cipher algorithm context
206  **/
207 
208 typedef union
209 {
210 #if (RC2_SUPPORT == ENABLED)
212 #endif
213 #if (RC4_SUPPORT == ENABLED)
215 #endif
216 #if (RC6_SUPPORT == ENABLED)
218 #endif
219 #if (CAST128_SUPPORT == ENABLED)
221 #endif
222 #if (CAST256_SUPPORT == ENABLED)
224 #endif
225 #if (IDEA_SUPPORT == ENABLED)
227 #endif
228 #if (DES_SUPPORT == ENABLED)
230 #endif
231 #if (DES3_SUPPORT == ENABLED)
233 #endif
234 #if (AES_SUPPORT == ENABLED)
236 #endif
237 #if (BLOWFISH_SUPPORT == ENABLED)
239 #endif
240 #if (TWOFISH_SUPPORT == ENABLED)
242 #endif
243 #if (MARS_SUPPORT == ENABLED)
245 #endif
246 #if (SERPENT_SUPPORT == ENABLED)
248 #endif
249 #if (CAMELLIA_SUPPORT == ENABLED)
251 #endif
252 #if (ARIA_SUPPORT == ENABLED)
254 #endif
255 #if (SEED_SUPPORT == ENABLED)
257 #endif
258 #if (SM4_SUPPORT == ENABLED)
260 #endif
261 #if (PRESENT_SUPPORT == ENABLED)
263 #endif
264 #if (TEA_SUPPORT == ENABLED)
266 #endif
267 #if (XTEA_SUPPORT == ENABLED)
269 #endif
270 #if (TRIVIUM_SUPPORT == ENABLED)
272 #endif
273 #if (ZUC_SUPPORT == ENABLED)
275 #endif
276 } CipherContext;
277 
278 
279 //C++ guard
280 #ifdef __cplusplus
281 }
282 #endif
283 
284 #endif
Des3Context des3Context
SeedContext seedContext
PRESENT encryption algorithm.
RC6-32/20 block cipher.
TriviumContext triviumContext
Cast128Context cast128Context
ARIA encryption algorithm.
Serpent algorithm context.
Definition: serpent.h:53
Generic cipher algorithm context.
CamelliaContext camelliaContext
SM4 algorithm context.
Definition: sm4.h:58
Twofish algorithm context.
Definition: twofish.h:53
ZUC stream cipher (ZUC-128 and ZUC-256)
Rc6Context rc6Context
AesContext aesContext
Sm4Context sm4Context
AES algorithm context.
Definition: aes.h:58
XteaContext xteaContext
TEA (Tiny Encryption Algorithm)
ChaCha encryption algorithm.
RC2 algorithm context.
Definition: rc2.h:53
PresentContext presentContext
RC4 algorithm context.
Definition: rc4.h:51
RC6 algorithm context.
Definition: rc6.h:58
MarsContext marsContext
DES algorithm context.
Definition: des.h:58
CAST-256 encryption algorithm.
SEED algorithm context.
Definition: seed.h:53
SerpentContext serpentContext
Rc4Context rc4Context
CAST-128 encryption algorithm.
Serpent encryption algorithm.
AES (Advanced Encryption Standard)
TeaContext teaContext
Cast256Context cast256Context
General definitions for cryptographic algorithms.
XTEA algorithm context.
Definition: xtea.h:60
SM4 encryption algorithm.
TwofishContext twofishContext
Rc2Context rc2Context
IDEA encryption algorithm.
Trivium algorithm context.
Definition: trivium.h:48
Blowfish encryption algorithm.
CAST-128 algorithm context.
Definition: cast128.h:53
SEED encryption algorithm.
Twofish encryption algorithm.
DES (Data Encryption Standard)
IdeaContext ideaContext
AriaContext ariaContext
BlowfishContext blowfishContext
Trivium stream cipher.
DesContext desContext
Triple DES algorithm context.
Definition: des3.h:59
ZUC algorithm context.
Definition: zuc.h:48
MARS algorithm context.
Definition: mars.h:53
IDEA algorithm context.
Definition: idea.h:53
Blowfish algorithm context.
Definition: blowfish.h:53
Camellia algorithm context.
Definition: camellia.h:66
MARS encryption algorithm.
TEA algorithm context.
Definition: tea.h:60
CAST-256 algorithm context.
Definition: cast256.h:53
ARIA algorithm context.
Definition: aria.h:53
XTEA (eXtended TEA)
ZucContext zucContext
Salsa20 encryption algorithm.
RC4 encryption algorithm.
Triple DES (Triple Data Encryption Algorithm)
PRESENT algorithm context.
Definition: present.h:53
RC2 block cipher.
Camellia encryption algorithm.