crypto.h
Go to the documentation of this file.
1 /**
2  * @file crypto.h
3  * @brief General definitions for cryptographic 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.2
29  **/
30 
31 #ifndef _CRYPTO_H
32 #define _CRYPTO_H
33 
34 //Dependencies
35 #include "os_port.h"
36 #include "crypto_config.h"
37 #include "crypto_legacy.h"
38 #include "cpu_endian.h"
39 #include "error.h"
40 
41 
42 /*
43  * CycloneCRYPTO Open is licensed under GPL version 2. In particular:
44  *
45  * - If you link your program to CycloneCRYPTO Open, the result is a derivative
46  * work that can only be distributed under the same GPL license terms.
47  *
48  * - If additions or changes to CycloneCRYPTO Open are made, the result is a
49  * derivative work that can only be distributed under the same license terms.
50  *
51  * - The GPL license requires that you make the source code available to
52  * whoever you make the binary available to.
53  *
54  * - If you sell or distribute a hardware product that runs CycloneCRYPTO Open,
55  * the GPL license requires you to provide public and full access to all
56  * source code on a nondiscriminatory basis.
57  *
58  * If you fully understand and accept the terms of the GPL license, then edit
59  * the os_port_config.h header and add the following directive:
60  *
61  * #define GPL_LICENSE_TERMS_ACCEPTED
62  */
63 
64 #ifndef GPL_LICENSE_TERMS_ACCEPTED
65  #error Before compiling CycloneCRYPTO Open, you must accept the terms of the GPL license
66 #endif
67 
68 //Version string
69 #define CYCLONE_CRYPTO_VERSION_STRING "2.4.2"
70 //Major version
71 #define CYCLONE_CRYPTO_MAJOR_VERSION 2
72 //Minor version
73 #define CYCLONE_CRYPTO_MINOR_VERSION 4
74 //Revision number
75 #define CYCLONE_CRYPTO_REV_NUMBER 2
76 
77 //Static memory allocation
78 #ifndef CRYPTO_STATIC_MEM_SUPPORT
79  #define CRYPTO_STATIC_MEM_SUPPORT DISABLED
80 #elif (CRYPTO_STATIC_MEM_SUPPORT != ENABLED && CRYPTO_STATIC_MEM_SUPPORT != DISABLED)
81  #error CRYPTO_STATIC_MEM_SUPPORT parameter is not valid
82 #endif
83 
84 //Multiple precision integer support
85 #ifndef MPI_SUPPORT
86  #define MPI_SUPPORT ENABLED
87 #elif (MPI_SUPPORT != ENABLED && MPI_SUPPORT != DISABLED)
88  #error MPI_SUPPORT parameter is not valid
89 #endif
90 
91 //Assembly optimizations for time-critical routines
92 #ifndef MPI_ASM_SUPPORT
93  #define MPI_ASM_SUPPORT DISABLED
94 #elif (MPI_ASM_SUPPORT != ENABLED && MPI_ASM_SUPPORT != DISABLED)
95  #error MPI_ASM_SUPPORT parameter is not valid
96 #endif
97 
98 //Base64 encoding support
99 #ifndef BASE64_SUPPORT
100  #define BASE64_SUPPORT ENABLED
101 #elif (BASE64_SUPPORT != ENABLED && BASE64_SUPPORT != DISABLED)
102  #error BASE64_SUPPORT parameter is not valid
103 #endif
104 
105 //Base64url encoding support
106 #ifndef BASE64URL_SUPPORT
107  #define BASE64URL_SUPPORT ENABLED
108 #elif (BASE64URL_SUPPORT != ENABLED && BASE64URL_SUPPORT != DISABLED)
109  #error BASE64URL_SUPPORT parameter is not valid
110 #endif
111 
112 //Radix64 encoding support
113 #ifndef RADIX64_SUPPORT
114  #define RADIX64_SUPPORT ENABLED
115 #elif (RADIX64_SUPPORT != ENABLED && RADIX64_SUPPORT != DISABLED)
116  #error RADIX64_SUPPORT parameter is not valid
117 #endif
118 
119 //MD2 hash support
120 #ifndef MD2_SUPPORT
121  #define MD2_SUPPORT DISABLED
122 #elif (MD2_SUPPORT != ENABLED && MD2_SUPPORT != DISABLED)
123  #error MD2_SUPPORT parameter is not valid
124 #endif
125 
126 //MD4 hash support
127 #ifndef MD4_SUPPORT
128  #define MD4_SUPPORT DISABLED
129 #elif (MD4_SUPPORT != ENABLED && MD4_SUPPORT != DISABLED)
130  #error MD4_SUPPORT parameter is not valid
131 #endif
132 
133 //MD5 hash support
134 #ifndef MD5_SUPPORT
135  #define MD5_SUPPORT DISABLED
136 #elif (MD5_SUPPORT != ENABLED && MD5_SUPPORT != DISABLED)
137  #error MD5_SUPPORT parameter is not valid
138 #endif
139 
140 //RIPEMD-128 hash support
141 #ifndef RIPEMD128_SUPPORT
142  #define RIPEMD128_SUPPORT DISABLED
143 #elif (RIPEMD128_SUPPORT != ENABLED && RIPEMD128_SUPPORT != DISABLED)
144  #error RIPEMD128_SUPPORT parameter is not valid
145 #endif
146 
147 //RIPEMD-160 hash support
148 #ifndef RIPEMD160_SUPPORT
149  #define RIPEMD160_SUPPORT DISABLED
150 #elif (RIPEMD160_SUPPORT != ENABLED && RIPEMD160_SUPPORT != DISABLED)
151  #error RIPEMD160_SUPPORT parameter is not valid
152 #endif
153 
154 //SHA-1 hash support
155 #ifndef SHA1_SUPPORT
156  #define SHA1_SUPPORT ENABLED
157 #elif (SHA1_SUPPORT != ENABLED && SHA1_SUPPORT != DISABLED)
158  #error SHA1_SUPPORT parameter is not valid
159 #endif
160 
161 //SHA-224 hash support
162 #ifndef SHA224_SUPPORT
163  #define SHA224_SUPPORT ENABLED
164 #elif (SHA224_SUPPORT != ENABLED && SHA224_SUPPORT != DISABLED)
165  #error SHA224_SUPPORT parameter is not valid
166 #endif
167 
168 //SHA-256 hash support
169 #ifndef SHA256_SUPPORT
170  #define SHA256_SUPPORT ENABLED
171 #elif (SHA256_SUPPORT != ENABLED && SHA256_SUPPORT != DISABLED)
172  #error SHA256_SUPPORT parameter is not valid
173 #endif
174 
175 //SHA-384 hash support
176 #ifndef SHA384_SUPPORT
177  #define SHA384_SUPPORT ENABLED
178 #elif (SHA384_SUPPORT != ENABLED && SHA384_SUPPORT != DISABLED)
179  #error SHA384_SUPPORT parameter is not valid
180 #endif
181 
182 //SHA-512 hash support
183 #ifndef SHA512_SUPPORT
184  #define SHA512_SUPPORT ENABLED
185 #elif (SHA512_SUPPORT != ENABLED && SHA512_SUPPORT != DISABLED)
186  #error SHA512_SUPPORT parameter is not valid
187 #endif
188 
189 //SHA-512/224 hash support
190 #ifndef SHA512_224_SUPPORT
191  #define SHA512_224_SUPPORT DISABLED
192 #elif (SHA512_224_SUPPORT != ENABLED && SHA512_224_SUPPORT != DISABLED)
193  #error SHA512_224_SUPPORT parameter is not valid
194 #endif
195 
196 //SHA-512/256 hash support
197 #ifndef SHA512_256_SUPPORT
198  #define SHA512_256_SUPPORT DISABLED
199 #elif (SHA512_256_SUPPORT != ENABLED && SHA512_256_SUPPORT != DISABLED)
200  #error SHA512_256_SUPPORT parameter is not valid
201 #endif
202 
203 //SHA3-224 hash support
204 #ifndef SHA3_224_SUPPORT
205  #define SHA3_224_SUPPORT DISABLED
206 #elif (SHA3_224_SUPPORT != ENABLED && SHA3_224_SUPPORT != DISABLED)
207  #error SHA3_224_SUPPORT parameter is not valid
208 #endif
209 
210 //SHA3-256 hash support
211 #ifndef SHA3_256_SUPPORT
212  #define SHA3_256_SUPPORT DISABLED
213 #elif (SHA3_256_SUPPORT != ENABLED && SHA3_256_SUPPORT != DISABLED)
214  #error SHA3_256_SUPPORT parameter is not valid
215 #endif
216 
217 //SHA3-384 hash support
218 #ifndef SHA3_384_SUPPORT
219  #define SHA3_384_SUPPORT DISABLED
220 #elif (SHA3_384_SUPPORT != ENABLED && SHA3_384_SUPPORT != DISABLED)
221  #error SHA3_384_SUPPORT parameter is not valid
222 #endif
223 
224 //SHA3-512 hash support
225 #ifndef SHA3_512_SUPPORT
226  #define SHA3_512_SUPPORT DISABLED
227 #elif (SHA3_512_SUPPORT != ENABLED && SHA3_512_SUPPORT != DISABLED)
228  #error SHA3_512_SUPPORT parameter is not valid
229 #endif
230 
231 //SHAKE support
232 #ifndef SHAKE_SUPPORT
233  #define SHAKE_SUPPORT DISABLED
234 #elif (SHAKE_SUPPORT != ENABLED && SHAKE_SUPPORT != DISABLED)
235  #error SHAKE_SUPPORT parameter is not valid
236 #endif
237 
238 //cSHAKE support
239 #ifndef CSHAKE_SUPPORT
240  #define CSHAKE_SUPPORT DISABLED
241 #elif (CSHAKE_SUPPORT != ENABLED && CSHAKE_SUPPORT != DISABLED)
242  #error CSHAKE_SUPPORT parameter is not valid
243 #endif
244 
245 //Keccak support
246 #ifndef KECCAK_SUPPORT
247  #define KECCAK_SUPPORT DISABLED
248 #elif (KECCAK_SUPPORT != ENABLED && KECCAK_SUPPORT != DISABLED)
249  #error KECCAK_SUPPORT parameter is not valid
250 #endif
251 
252 //BLAKE2b support
253 #ifndef BLAKE2B_SUPPORT
254  #define BLAKE2B_SUPPORT DISABLED
255 #elif (BLAKE2B_SUPPORT != ENABLED && BLAKE2B_SUPPORT != DISABLED)
256  #error BLAKE2B_SUPPORT parameter is not valid
257 #endif
258 
259 //BLAKE2b-160 hash support
260 #ifndef BLAKE2B160_SUPPORT
261  #define BLAKE2B160_SUPPORT DISABLED
262 #elif (BLAKE2B160_SUPPORT != ENABLED && BLAKE2B160_SUPPORT != DISABLED)
263  #error BLAKE2B160_SUPPORT parameter is not valid
264 #endif
265 
266 //BLAKE2b-256 hash support
267 #ifndef BLAKE2B256_SUPPORT
268  #define BLAKE2B256_SUPPORT DISABLED
269 #elif (BLAKE2B256_SUPPORT != ENABLED && BLAKE2B256_SUPPORT != DISABLED)
270  #error BLAKE2B256_SUPPORT parameter is not valid
271 #endif
272 
273 //BLAKE2b-384 hash support
274 #ifndef BLAKE2B384_SUPPORT
275  #define BLAKE2B384_SUPPORT DISABLED
276 #elif (BLAKE2B384_SUPPORT != ENABLED && BLAKE2B384_SUPPORT != DISABLED)
277  #error BLAKE2B384_SUPPORT parameter is not valid
278 #endif
279 
280 //BLAKE2b-512 hash support
281 #ifndef BLAKE2B512_SUPPORT
282  #define BLAKE2B512_SUPPORT DISABLED
283 #elif (BLAKE2B512_SUPPORT != ENABLED && BLAKE2B512_SUPPORT != DISABLED)
284  #error BLAKE2B512_SUPPORT parameter is not valid
285 #endif
286 
287 //BLAKE2s support
288 #ifndef BLAKE2S_SUPPORT
289  #define BLAKE2S_SUPPORT DISABLED
290 #elif (BLAKE2S_SUPPORT != ENABLED && BLAKE2S_SUPPORT != DISABLED)
291  #error BLAKE2S_SUPPORT parameter is not valid
292 #endif
293 
294 //BLAKE2s-128 hash support
295 #ifndef BLAKE2S128_SUPPORT
296  #define BLAKE2S128_SUPPORT DISABLED
297 #elif (BLAKE2S128_SUPPORT != ENABLED && BLAKE2S128_SUPPORT != DISABLED)
298  #error BLAKE2S128_SUPPORT parameter is not valid
299 #endif
300 
301 //BLAKE2s-160 hash support
302 #ifndef BLAKE2S160_SUPPORT
303  #define BLAKE2S160_SUPPORT DISABLED
304 #elif (BLAKE2S160_SUPPORT != ENABLED && BLAKE2S160_SUPPORT != DISABLED)
305  #error BLAKE2S160_SUPPORT parameter is not valid
306 #endif
307 
308 //BLAKE2s-224 hash support
309 #ifndef BLAKE2S224_SUPPORT
310  #define BLAKE2S224_SUPPORT DISABLED
311 #elif (BLAKE2S224_SUPPORT != ENABLED && BLAKE2S224_SUPPORT != DISABLED)
312  #error BLAKE2S224_SUPPORT parameter is not valid
313 #endif
314 
315 //BLAKE2s-256 hash support
316 #ifndef BLAKE2S256_SUPPORT
317  #define BLAKE2S256_SUPPORT DISABLED
318 #elif (BLAKE2S256_SUPPORT != ENABLED && BLAKE2S256_SUPPORT != DISABLED)
319  #error BLAKE2S256_SUPPORT parameter is not valid
320 #endif
321 
322 //SM3 hash support
323 #ifndef SM3_SUPPORT
324  #define SM3_SUPPORT DISABLED
325 #elif (SM3_SUPPORT != ENABLED && SM3_SUPPORT != DISABLED)
326  #error SM3_SUPPORT parameter is not valid
327 #endif
328 
329 //Tiger hash support
330 #ifndef TIGER_SUPPORT
331  #define TIGER_SUPPORT DISABLED
332 #elif (TIGER_SUPPORT != ENABLED && TIGER_SUPPORT != DISABLED)
333  #error TIGER_SUPPORT parameter is not valid
334 #endif
335 
336 //Whirlpool hash support
337 #ifndef WHIRLPOOL_SUPPORT
338  #define WHIRLPOOL_SUPPORT DISABLED
339 #elif (WHIRLPOOL_SUPPORT != ENABLED && WHIRLPOOL_SUPPORT != DISABLED)
340  #error WHIRLPOOL_SUPPORT parameter is not valid
341 #endif
342 
343 //CMAC support
344 #ifndef CMAC_SUPPORT
345  #define CMAC_SUPPORT DISABLED
346 #elif (CMAC_SUPPORT != ENABLED && CMAC_SUPPORT != DISABLED)
347  #error CMAC_SUPPORT parameter is not valid
348 #endif
349 
350 //HMAC support
351 #ifndef HMAC_SUPPORT
352  #define HMAC_SUPPORT ENABLED
353 #elif (HMAC_SUPPORT != ENABLED && HMAC_SUPPORT != DISABLED)
354  #error HMAC_SUPPORT parameter is not valid
355 #endif
356 
357 //GMAC support
358 #ifndef GMAC_SUPPORT
359  #define GMAC_SUPPORT DISABLED
360 #elif (GMAC_SUPPORT != ENABLED && GMAC_SUPPORT != DISABLED)
361  #error GMAC_SUPPORT parameter is not valid
362 #endif
363 
364 //KMAC support
365 #ifndef KMAC_SUPPORT
366  #define KMAC_SUPPORT DISABLED
367 #elif (KMAC_SUPPORT != ENABLED && KMAC_SUPPORT != DISABLED)
368  #error KMAC_SUPPORT parameter is not valid
369 #endif
370 
371 //XCBC-MAC support
372 #ifndef XCBC_MAC_SUPPORT
373  #define XCBC_MAC_SUPPORT DISABLED
374 #elif (XCBC_MAC_SUPPORT != ENABLED && XCBC_MAC_SUPPORT != DISABLED)
375  #error XCBC_MAC_SUPPORT parameter is not valid
376 #endif
377 
378 //RC2 block cipher support
379 #ifndef RC2_SUPPORT
380  #define RC2_SUPPORT DISABLED
381 #elif (RC2_SUPPORT != ENABLED && RC2_SUPPORT != DISABLED)
382  #error RC2_SUPPORT parameter is not valid
383 #endif
384 
385 //RC4 stream cipher support
386 #ifndef RC4_SUPPORT
387  #define RC4_SUPPORT DISABLED
388 #elif (RC4_SUPPORT != ENABLED && RC4_SUPPORT != DISABLED)
389  #error RC4_SUPPORT parameter is not valid
390 #endif
391 
392 //RC6 block cipher support
393 #ifndef RC6_SUPPORT
394  #define RC6_SUPPORT DISABLED
395 #elif (RC6_SUPPORT != ENABLED && RC6_SUPPORT != DISABLED)
396  #error RC6_SUPPORT parameter is not valid
397 #endif
398 
399 //CAST-128 block cipher support
400 #ifndef CAST128_SUPPORT
401  #define CAST128_SUPPORT DISABLED
402 #elif (CAST128_SUPPORT != ENABLED && CAST128_SUPPORT != DISABLED)
403  #error CAST128_SUPPORT parameter is not valid
404 #endif
405 
406 //CAST-256 block cipher support
407 #ifndef CAST256_SUPPORT
408  #define CAST256_SUPPORT DISABLED
409 #elif (CAST256_SUPPORT != ENABLED && CAST256_SUPPORT != DISABLED)
410  #error CAST256_SUPPORT parameter is not valid
411 #endif
412 
413 //IDEA block cipher support
414 #ifndef IDEA_SUPPORT
415  #define IDEA_SUPPORT DISABLED
416 #elif (IDEA_SUPPORT != ENABLED && IDEA_SUPPORT != DISABLED)
417  #error IDEA_SUPPORT parameter is not valid
418 #endif
419 
420 //DES block cipher support
421 #ifndef DES_SUPPORT
422  #define DES_SUPPORT DISABLED
423 #elif (DES_SUPPORT != ENABLED && DES_SUPPORT != DISABLED)
424  #error DES_SUPPORT parameter is not valid
425 #endif
426 
427 //Triple DES block cipher support
428 #ifndef DES3_SUPPORT
429  #define DES3_SUPPORT DISABLED
430 #elif (DES3_SUPPORT != ENABLED && DES3_SUPPORT != DISABLED)
431  #error DES3_SUPPORT parameter is not valid
432 #endif
433 
434 //AES block cipher support
435 #ifndef AES_SUPPORT
436  #define AES_SUPPORT ENABLED
437 #elif (AES_SUPPORT != ENABLED && AES_SUPPORT != DISABLED)
438  #error AES_SUPPORT parameter is not valid
439 #endif
440 
441 //Blowfish block cipher support
442 #ifndef BLOWFISH_SUPPORT
443  #define BLOWFISH_SUPPORT DISABLED
444 #elif (BLOWFISH_SUPPORT != ENABLED && BLOWFISH_SUPPORT != DISABLED)
445  #error BLOWFISH_SUPPORT parameter is not valid
446 #endif
447 
448 //Twofish block cipher support
449 #ifndef TWOFISH_SUPPORT
450  #define TWOFISH_SUPPORT DISABLED
451 #elif (TWOFISH_SUPPORT != ENABLED && TWOFISH_SUPPORT != DISABLED)
452  #error TWOFISH_SUPPORT parameter is not valid
453 #endif
454 
455 //MARS block cipher support
456 #ifndef MARS_SUPPORT
457  #define MARS_SUPPORT DISABLED
458 #elif (MARS_SUPPORT != ENABLED && MARS_SUPPORT != DISABLED)
459  #error MARS_SUPPORT parameter is not valid
460 #endif
461 
462 //Serpent block cipher support
463 #ifndef SERPENT_SUPPORT
464  #define SERPENT_SUPPORT DISABLED
465 #elif (SERPENT_SUPPORT != ENABLED && SERPENT_SUPPORT != DISABLED)
466  #error SERPENT_SUPPORT parameter is not valid
467 #endif
468 
469 //Camellia block cipher support
470 #ifndef CAMELLIA_SUPPORT
471  #define CAMELLIA_SUPPORT DISABLED
472 #elif (CAMELLIA_SUPPORT != ENABLED && CAMELLIA_SUPPORT != DISABLED)
473  #error CAMELLIA_SUPPORT parameter is not valid
474 #endif
475 
476 //ARIA block cipher support
477 #ifndef ARIA_SUPPORT
478  #define ARIA_SUPPORT DISABLED
479 #elif (ARIA_SUPPORT != ENABLED && ARIA_SUPPORT != DISABLED)
480  #error ARIA_SUPPORT parameter is not valid
481 #endif
482 
483 //SEED block cipher support
484 #ifndef SEED_SUPPORT
485  #define SEED_SUPPORT DISABLED
486 #elif (SEED_SUPPORT != ENABLED && SEED_SUPPORT != DISABLED)
487  #error SEED_SUPPORT parameter is not valid
488 #endif
489 
490 //SM4 block cipher support
491 #ifndef SM4_SUPPORT
492  #define SM4_SUPPORT DISABLED
493 #elif (SM4_SUPPORT != ENABLED && SM4_SUPPORT != DISABLED)
494  #error SM4_SUPPORT parameter is not valid
495 #endif
496 
497 //PRESENT block cipher support
498 #ifndef PRESENT_SUPPORT
499  #define PRESENT_SUPPORT DISABLED
500 #elif (PRESENT_SUPPORT != ENABLED && PRESENT_SUPPORT != DISABLED)
501  #error PRESENT_SUPPORT parameter is not valid
502 #endif
503 
504 //TEA block cipher support
505 #ifndef TEA_SUPPORT
506  #define TEA_SUPPORT DISABLED
507 #elif (TEA_SUPPORT != ENABLED && TEA_SUPPORT != DISABLED)
508  #error TEA_SUPPORT parameter is not valid
509 #endif
510 
511 //XTEA block cipher support
512 #ifndef XTEA_SUPPORT
513  #define XTEA_SUPPORT DISABLED
514 #elif (XTEA_SUPPORT != ENABLED && XTEA_SUPPORT != DISABLED)
515  #error XTEA_SUPPORT parameter is not valid
516 #endif
517 
518 //Trivium stream cipher support
519 #ifndef TRIVIUM_SUPPORT
520  #define TRIVIUM_SUPPORT DISABLED
521 #elif (TRIVIUM_SUPPORT != ENABLED && TRIVIUM_SUPPORT != DISABLED)
522  #error TRIVIUM_SUPPORT parameter is not valid
523 #endif
524 
525 //ZUC stream cipher support
526 #ifndef ZUC_SUPPORT
527  #define ZUC_SUPPORT DISABLED
528 #elif (ZUC_SUPPORT != ENABLED && ZUC_SUPPORT != DISABLED)
529  #error ZUC_SUPPORT parameter is not valid
530 #endif
531 
532 //ECB mode support
533 #ifndef ECB_SUPPORT
534  #define ECB_SUPPORT ENABLED
535 #elif (ECB_SUPPORT != ENABLED && ECB_SUPPORT != DISABLED)
536  #error ECB_SUPPORT parameter is not valid
537 #endif
538 
539 //CBC mode support
540 #ifndef CBC_SUPPORT
541  #define CBC_SUPPORT ENABLED
542 #elif (CBC_SUPPORT != ENABLED && CBC_SUPPORT != DISABLED)
543  #error CBC_SUPPORT parameter is not valid
544 #endif
545 
546 //CFB mode support
547 #ifndef CFB_SUPPORT
548  #define CFB_SUPPORT ENABLED
549 #elif (CFB_SUPPORT != ENABLED && CFB_SUPPORT != DISABLED)
550  #error CFB_SUPPORT parameter is not valid
551 #endif
552 
553 //OFB mode support
554 #ifndef OFB_SUPPORT
555  #define OFB_SUPPORT ENABLED
556 #elif (OFB_SUPPORT != ENABLED && OFB_SUPPORT != DISABLED)
557  #error OFB_SUPPORT parameter is not valid
558 #endif
559 
560 //CTR mode support
561 #ifndef CTR_SUPPORT
562  #define CTR_SUPPORT ENABLED
563 #elif (CTR_SUPPORT != ENABLED && CTR_SUPPORT != DISABLED)
564  #error CTR_SUPPORT parameter is not valid
565 #endif
566 
567 //XTS mode support
568 #ifndef XTS_SUPPORT
569  #define XTS_SUPPORT ENABLED
570 #elif (XTS_SUPPORT != ENABLED && XTS_SUPPORT != DISABLED)
571  #error XTS_SUPPORT parameter is not valid
572 #endif
573 
574 //CCM mode support
575 #ifndef CCM_SUPPORT
576  #define CCM_SUPPORT ENABLED
577 #elif (CCM_SUPPORT != ENABLED && CCM_SUPPORT != DISABLED)
578  #error CCM_SUPPORT parameter is not valid
579 #endif
580 
581 //GCM mode support
582 #ifndef GCM_SUPPORT
583  #define GCM_SUPPORT ENABLED
584 #elif (GCM_SUPPORT != ENABLED && GCM_SUPPORT != DISABLED)
585  #error GCM_SUPPORT parameter is not valid
586 #endif
587 
588 //Salsa20 stream cipher support
589 #ifndef SALSA20_SUPPORT
590  #define SALSA20_SUPPORT DISABLED
591 #elif (SALSA20_SUPPORT != ENABLED && SALSA20_SUPPORT != DISABLED)
592  #error SALSA20_SUPPORT parameter is not valid
593 #endif
594 
595 //ChaCha stream cipher support
596 #ifndef CHACHA_SUPPORT
597  #define CHACHA_SUPPORT DISABLED
598 #elif (CHACHA_SUPPORT != ENABLED && CHACHA_SUPPORT != DISABLED)
599  #error CHACHA_SUPPORT parameter is not valid
600 #endif
601 
602 //Poly1305 support
603 #ifndef POLY1305_SUPPORT
604  #define POLY1305_SUPPORT DISABLED
605 #elif (POLY1305_SUPPORT != ENABLED && POLY1305_SUPPORT != DISABLED)
606  #error POLY1305_SUPPORT parameter is not valid
607 #endif
608 
609 //ChaCha20Poly1305 support
610 #ifndef CHACHA20_POLY1305_SUPPORT
611  #define CHACHA20_POLY1305_SUPPORT DISABLED
612 #elif (CHACHA20_POLY1305_SUPPORT != ENABLED && CHACHA20_POLY1305_SUPPORT != DISABLED)
613  #error CHACHA20_POLY1305_SUPPORT parameter is not valid
614 #endif
615 
616 //Diffie-Hellman support
617 #ifndef DH_SUPPORT
618  #define DH_SUPPORT DISABLED
619 #elif (DH_SUPPORT != ENABLED && DH_SUPPORT != DISABLED)
620  #error DH_SUPPORT parameter is not valid
621 #endif
622 
623 //RSA support
624 #ifndef RSA_SUPPORT
625  #define RSA_SUPPORT ENABLED
626 #elif (RSA_SUPPORT != ENABLED && RSA_SUPPORT != DISABLED)
627  #error RSA_SUPPORT parameter is not valid
628 #endif
629 
630 //DSA support
631 #ifndef DSA_SUPPORT
632  #define DSA_SUPPORT DISABLED
633 #elif (DSA_SUPPORT != ENABLED && DSA_SUPPORT != DISABLED)
634  #error DSA_SUPPORT parameter is not valid
635 #endif
636 
637 //Elliptic curve cryptography support
638 #ifndef EC_SUPPORT
639  #define EC_SUPPORT ENABLED
640 #elif (EC_SUPPORT != ENABLED && EC_SUPPORT != DISABLED)
641  #error EC_SUPPORT parameter is not valid
642 #endif
643 
644 //ECDH support
645 #ifndef ECDH_SUPPORT
646  #define ECDH_SUPPORT ENABLED
647 #elif (ECDH_SUPPORT != ENABLED && ECDH_SUPPORT != DISABLED)
648  #error ECDH_SUPPORT parameter is not valid
649 #endif
650 
651 //ECDSA support
652 #ifndef ECDSA_SUPPORT
653  #define ECDSA_SUPPORT ENABLED
654 #elif (ECDSA_SUPPORT != ENABLED && ECDSA_SUPPORT != DISABLED)
655  #error ECDSA_SUPPORT parameter is not valid
656 #endif
657 
658 //ML-KEM-512 key encapsulation mechanism support
659 #ifndef MLKEM512_SUPPORT
660  #define MLKEM512_SUPPORT DISABLED
661 #elif (MLKEM512_SUPPORT != ENABLED && MLKEM512_SUPPORT != DISABLED)
662  #error MLKEM512_SUPPORT parameter is not valid
663 #endif
664 
665 //ML-KEM-768 key encapsulation mechanism support
666 #ifndef MLKEM768_SUPPORT
667  #define MLKEM768_SUPPORT DISABLED
668 #elif (MLKEM768_SUPPORT != ENABLED && MLKEM768_SUPPORT != DISABLED)
669  #error MLKEM768_SUPPORT parameter is not valid
670 #endif
671 
672 //ML-KEM-1024 key encapsulation mechanism support
673 #ifndef MLKEM1024_SUPPORT
674  #define MLKEM1024_SUPPORT DISABLED
675 #elif (MLKEM1024_SUPPORT != ENABLED && MLKEM1024_SUPPORT != DISABLED)
676  #error MLKEM1024_SUPPORT parameter is not valid
677 #endif
678 
679 //Streamlined NTRU Prime 761 key encapsulation mechanism support
680 #ifndef SNTRUP761_SUPPORT
681  #define SNTRUP761_SUPPORT DISABLED
682 #elif (SNTRUP761_SUPPORT != ENABLED && SNTRUP761_SUPPORT != DISABLED)
683  #error SNTRUP761_SUPPORT parameter is not valid
684 #endif
685 
686 //HKDF support
687 #ifndef HKDF_SUPPORT
688  #define HKDF_SUPPORT DISABLED
689 #elif (HKDF_SUPPORT != ENABLED && HKDF_SUPPORT != DISABLED)
690  #error HKDF_SUPPORT parameter is not valid
691 #endif
692 
693 //PBKDF support
694 #ifndef PBKDF_SUPPORT
695  #define PBKDF_SUPPORT DISABLED
696 #elif (PBKDF_SUPPORT != ENABLED && PBKDF_SUPPORT != DISABLED)
697  #error PBKDF_SUPPORT parameter is not valid
698 #endif
699 
700 //Concat KDF support
701 #ifndef CONCAT_KDF_SUPPORT
702  #define CONCAT_KDF_SUPPORT DISABLED
703 #elif (CONCAT_KDF_SUPPORT != ENABLED && CONCAT_KDF_SUPPORT != DISABLED)
704  #error CONCAT_KDF_SUPPORT parameter is not valid
705 #endif
706 
707 //bcrypt support
708 #ifndef BCRYPT_SUPPORT
709  #define BCRYPT_SUPPORT DISABLED
710 #elif (BCRYPT_SUPPORT != ENABLED && BCRYPT_SUPPORT != DISABLED)
711  #error BCRYPT_SUPPORT parameter is not valid
712 #endif
713 
714 //scrypt support
715 #ifndef SCRYPT_SUPPORT
716  #define SCRYPT_SUPPORT DISABLED
717 #elif (SCRYPT_SUPPORT != ENABLED && SCRYPT_SUPPORT != DISABLED)
718  #error SCRYPT_SUPPORT parameter is not valid
719 #endif
720 
721 //MD5-crypt support
722 #ifndef MD5_CRYPT_SUPPORT
723  #define MD5_CRYPT_SUPPORT DISABLED
724 #elif (MD5_CRYPT_SUPPORT != ENABLED && MD5_CRYPT_SUPPORT != DISABLED)
725  #error MD5_CRYPT_SUPPORT parameter is not valid
726 #endif
727 
728 //SHA-crypt support
729 #ifndef SHA_CRYPT_SUPPORT
730  #define SHA_CRYPT_SUPPORT DISABLED
731 #elif (SHA_CRYPT_SUPPORT != ENABLED && SHA_CRYPT_SUPPORT != DISABLED)
732  #error SHA_CRYPT_SUPPORT parameter is not valid
733 #endif
734 
735 //Yarrow PRNG support
736 #ifndef YARROW_SUPPORT
737  #define YARROW_SUPPORT ENABLED
738 #elif (YARROW_SUPPORT != ENABLED && YARROW_SUPPORT != DISABLED)
739  #error YARROW_SUPPORT parameter is not valid
740 #endif
741 
742 //Object identifier support
743 #ifndef OID_SUPPORT
744  #define OID_SUPPORT ENABLED
745 #elif (OID_SUPPORT != ENABLED && OID_SUPPORT != DISABLED)
746  #error OID_SUPPORT parameter is not valid
747 #endif
748 
749 //ASN.1 syntax support
750 #ifndef ASN1_SUPPORT
751  #define ASN1_SUPPORT ENABLED
752 #elif (ASN1_SUPPORT != ENABLED && ASN1_SUPPORT != DISABLED)
753  #error ASN1_SUPPORT parameter is not valid
754 #endif
755 
756 //PEM file support
757 #ifndef PEM_SUPPORT
758  #define PEM_SUPPORT ENABLED
759 #elif (PEM_SUPPORT != ENABLED && PEM_SUPPORT != DISABLED)
760  #error PEM_SUPPORT parameter is not valid
761 #endif
762 
763 //X.509 certificate support
764 #ifndef X509_SUPPORT
765  #define X509_SUPPORT ENABLED
766 #elif (X509_SUPPORT != ENABLED && X509_SUPPORT != DISABLED)
767  #error X509_SUPPORT parameter is not valid
768 #endif
769 
770 //PKCS #5 support
771 #ifndef PKCS5_SUPPORT
772  #define PKCS5_SUPPORT DISABLED
773 #elif (PKCS5_SUPPORT != ENABLED && PKCS5_SUPPORT != DISABLED)
774  #error PKCS5_SUPPORT parameter is not valid
775 #endif
776 
777 //Allocate memory block
778 #ifndef cryptoAllocMem
779  #define cryptoAllocMem(size) osAllocMem(size)
780 #endif
781 
782 //Deallocate memory block
783 #ifndef cryptoFreeMem
784  #define cryptoFreeMem(p) osFreeMem(p)
785 #endif
786 
787 //Rotate left operation
788 #define ROL8(a, n) (((a) << (n)) | ((a) >> (8 - (n))))
789 #define ROL16(a, n) (((a) << (n)) | ((a) >> (16 - (n))))
790 #define ROL32(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
791 #define ROL64(a, n) (((a) << (n)) | ((a) >> (64 - (n))))
792 
793 //Rotate right operation
794 #define ROR8(a, n) (((a) >> (n)) | ((a) << (8 - (n))))
795 #define ROR16(a, n) (((a) >> (n)) | ((a) << (16 - (n))))
796 #define ROR32(a, n) (((a) >> (n)) | ((a) << (32 - (n))))
797 #define ROR64(a, n) (((a) >> (n)) | ((a) << (64 - (n))))
798 
799 //Shift left operation
800 #define SHL8(a, n) ((a) << (n))
801 #define SHL16(a, n) ((a) << (n))
802 #define SHL32(a, n) ((a) << (n))
803 #define SHL64(a, n) ((a) << (n))
804 
805 //Shift right operation
806 #define SHR8(a, n) ((a) >> (n))
807 #define SHR16(a, n) ((a) >> (n))
808 #define SHR32(a, n) ((a) >> (n))
809 #define SHR64(a, n) ((a) >> (n))
810 
811 //Micellaneous macros
812 #define _U8(x) ((uint8_t) (x))
813 #define _U16(x) ((uint16_t) (x))
814 #define _U32(x) ((uint32_t) (x))
815 #define _U64(x) ((uint64_t) (x))
816 
817 //Test if a 8-bit integer is zero
818 #define CRYPTO_TEST_Z_8(a) \
819  _U8((_U8((_U8(a) | (~_U8(a) + 1U))) >> 7U) ^ 1U)
820 
821 //Test if a 8-bit integer is nonzero
822 #define CRYPTO_TEST_NZ_8(a) \
823  _U8(_U8((_U8(a) | (~_U8(a) + 1U))) >> 7U)
824 
825 //Test if two 8-bit integers are equal
826 #define CRYPTO_TEST_EQ_8(a, b) \
827  _U8((_U8(((_U8(a) ^ _U8(b)) | (~(_U8(a) ^ _U8(b)) + 1U))) >> 7U) ^ 1U)
828 
829 //Test if two 8-bit integers are not equal
830 #define CRYPTO_TEST_NEQ_8(a, b) \
831  _U8(_U8(((_U8(a) ^ _U8(b)) | (~(_U8(a) ^ _U8(b)) + 1U))) >> 7U)
832 
833 //Test if a 8-bit integer is lower than another 8-bit integer
834 #define CRYPTO_TEST_LT_8(a, b) \
835  _U8(_U8((((_U8(a) - _U8(b)) ^ _U8(b)) | (_U8(a) ^ _U8(b))) ^ _U8(a)) >> 7U)
836 
837 //Test if a 8-bit integer is lower or equal than another 8-bit integer
838 #define CRYPTO_TEST_LTE_8(a, b) \
839  _U8((_U8((((_U8(b) - _U8(a)) ^ _U8(a)) | (_U8(a) ^ _U8(b))) ^ _U8(b)) >> 7U) ^ 1U)
840 
841 //Test if a 8-bit integer is greater than another 8-bit integer
842 #define CRYPTO_TEST_GT_8(a, b) \
843  _U8(_U8((((_U8(b) - _U8(a)) ^ _U8(a)) | (_U8(a) ^ _U8(b))) ^ _U8(b)) >> 7U)
844 
845 //Test if a 8-bit integer is greater or equal than another 8-bit integer
846 #define CRYPTO_TEST_GTE_8(a, b) \
847  _U8((_U8((((_U8(a) - _U8(b)) ^ _U8(b)) | (_U8(a) ^ _U8(b))) ^ _U8(a)) >> 7U) ^ 1U)
848 
849 //Select between two 8-bit integers
850 #define CRYPTO_SELECT_8(a, b, c) \
851  _U8((_U8(a) & (_U8(c) - 1U)) | (_U8(b) & ~(_U8(c) - 1U)))
852 
853 //Test if a 16-bit integer is zero
854 #define CRYPTO_TEST_Z_16(a) \
855  _U16((_U16((_U16(a) | (~_U16(a) + 1U))) >> 15U) ^ 1U)
856 
857 //Test if a 16-bit integer is nonzero
858 #define CRYPTO_TEST_NZ_16(a) \
859  _U16(_U16((_U16(a) | (~_U16(a) + 1U))) >> 15U)
860 
861 //Test if two 16-bit integers are equal
862 #define CRYPTO_TEST_EQ_16(a, b) \
863  _U16((_U16(((_U16(a) ^ _U16(b)) | (~(_U16(a) ^ _U16(b)) + 1U))) >> 15U) ^ 1U)
864 
865 //Test if two 16-bit integers are not equal
866 #define CRYPTO_TEST_NEQ_16(a, b) \
867  _U16(_U16(((_U16(a) ^ _U16(b)) | (~(_U16(a) ^ _U16(b)) + 1U))) >> 15U)
868 
869 //Test if a 16-bit integer is lower than another 16-bit integer
870 #define CRYPTO_TEST_LT_16(a, b) \
871  _U16(_U16((((_U16(a) - _U16(b)) ^ _U16(b)) | (_U16(a) ^ _U16(b))) ^ _U16(a)) >> 15U)
872 
873 //Test if a 16-bit integer is lower or equal than another 16-bit integer
874 #define CRYPTO_TEST_LTE_16(a, b) \
875  _U16((_U16((((_U16(b) - _U16(a)) ^ _U16(a)) | (_U16(a) ^ _U16(b))) ^ _U16(b)) >> 15U) ^ 1U)
876 
877 //Test if a 16-bit integer is greater than another 16-bit integer
878 #define CRYPTO_TEST_GT_16(a, b) \
879  _U16(_U16((((_U16(b) - _U16(a)) ^ _U16(a)) | (_U16(a) ^ _U16(b))) ^ _U16(b)) >> 15U)
880 
881 //Test if a 16-bit integer is greater or equal than another 16-bit integer
882 #define CRYPTO_TEST_GTE_16(a, b) \
883  _U16((_U16((((_U16(a) - _U16(b)) ^ _U16(b)) | (_U16(a) ^ _U16(b))) ^ _U16(a)) >> 15U) ^ 1U)
884 
885 //Select between two 16-bit integers
886 #define CRYPTO_SELECT_16(a, b, c) \
887  _U16((_U16(a) & (_U16(c) - 1U)) | (_U16(b) & ~(_U16(c) - 1U)))
888 
889 //Test if a 32-bit integer is zero
890 #define CRYPTO_TEST_Z_32(a) \
891  _U32((_U32((_U32(a) | (~_U32(a) + 1U))) >> 31U) ^ 1U)
892 
893 //Test if a 32-bit integer is nonzero
894 #define CRYPTO_TEST_NZ_32(a) \
895  _U32(_U32((_U32(a) | (~_U32(a) + 1U))) >> 31U)
896 
897 //Test if two 32-bit integers are equal
898 #define CRYPTO_TEST_EQ_32(a, b) \
899  _U32((_U32(((_U32(a) ^ _U32(b)) | (~(_U32(a) ^ _U32(b)) + 1U))) >> 31U) ^ 1U)
900 
901 //Test if two 32-bit integers are not equal
902 #define CRYPTO_TEST_NEQ_32(a, b) \
903  _U32(_U32(((_U32(a) ^ _U32(b)) | (~(_U32(a) ^ _U32(b)) + 1U))) >> 31U)
904 
905 //Test if a 32-bit integer is lower than another 32-bit integer
906 #define CRYPTO_TEST_LT_32(a, b) \
907  _U32(_U32((((_U32(a) - _U32(b)) ^ _U32(b)) | (_U32(a) ^ _U32(b))) ^ _U32(a)) >> 31U)
908 
909 //Test if a 32-bit integer is lower or equal than another 32-bit integer
910 #define CRYPTO_TEST_LTE_32(a, b) \
911  _U32((_U32((((_U32(b) - _U32(a)) ^ _U32(a)) | (_U32(a) ^ _U32(b))) ^ _U32(b)) >> 31U) ^ 1U)
912 
913 //Test if a 32-bit integer is greater than another 32-bit integer
914 #define CRYPTO_TEST_GT_32(a, b) \
915  _U32(_U32((((_U32(b) - _U32(a)) ^ _U32(a)) | (_U32(a) ^ _U32(b))) ^ _U32(b)) >> 31U)
916 
917 //Test if a 32-bit integer is greater or equal than another 32-bit integer
918 #define CRYPTO_TEST_GTE_32(a, b) \
919  _U32((_U32((((_U32(a) - _U32(b)) ^ _U32(b)) | (_U32(a) ^ _U32(b))) ^ _U32(a)) >> 31U) ^ 1U)
920 
921 //Select between two 32-bit integers
922 #define CRYPTO_SELECT_32(a, b, c) \
923  _U32((_U32(a) & (_U32(c) - 1U)) | (_U32(b) & ~(_U32(c) - 1U)))
924 
925 //Select between two 64-bit integers
926 #define CRYPTO_SELECT_64(a, b, c) \
927  _U64((_U64(a) & (_U64(c) - 1U)) | (_U64(b) & ~(_U64(c) - 1U)))
928 
929 //Forward declaration of PrngAlgo structure
930 struct _PrngAlgo;
931 #define PrngAlgo struct _PrngAlgo
932 
933 //C++ guard
934 #ifdef __cplusplus
935 extern "C" {
936 #endif
937 
938 
939 /**
940  * @brief Encryption algorithm type
941  **/
942 
943 typedef enum
944 {
948 
949 
950 /**
951  * @brief Cipher operation modes
952  **/
953 
954 typedef enum
955 {
966 } CipherMode;
967 
968 
969 //Common API for hash algorithms
970 typedef error_t (*HashAlgoCompute)(const void *data, size_t length,
971  uint8_t *digest);
972 
973 typedef void (*HashAlgoInit)(void *context);
974 
975 typedef void (*HashAlgoUpdate)(void *context, const void *data, size_t length);
976 
977 typedef void (*HashAlgoFinal)(void *context, uint8_t *digest);
978 
979 typedef void (*HashAlgoFinalRaw)(void *context, uint8_t *digest);
980 
981 //Common API for encryption algorithms
982 typedef error_t (*CipherAlgoInit)(void *context, const uint8_t *key,
983  size_t keyLen);
984 
985 typedef void (*CipherAlgoEncryptStream)(void *context, const uint8_t *input,
986  uint8_t *output, size_t length);
987 
988 typedef void (*CipherAlgoDecryptStream)(void *context, const uint8_t *input,
989  uint8_t *output, size_t length);
990 
991 typedef void (*CipherAlgoEncryptBlock)(void *context, const uint8_t *input,
992  uint8_t *output);
993 
994 typedef void (*CipherAlgoDecryptBlock)(void *context, const uint8_t *input,
995  uint8_t *output);
996 
997 typedef void (*CipherAlgoDeinit)(void *context);
998 
999 //Common interface for key encapsulation mechanisms (KEM)
1000 typedef error_t (*KemAlgoGenerateKeyPair)(const PrngAlgo *prngAlgo,
1001  void *prngContext, uint8_t *pk, uint8_t *sk);
1002 
1003 typedef error_t (*KemAlgoEncapsulate)(const PrngAlgo *prngAlgo,
1004  void *prngContext, uint8_t *ct, uint8_t *ss, const uint8_t *pk);
1005 
1006 typedef error_t (*KemAlgoDecapsulate)(uint8_t *ss, const uint8_t *ct,
1007  const uint8_t *sk);
1008 
1009 //Common API for pseudo-random number generators (PRNG)
1010 typedef error_t (*PrngAlgoInit)(void *context);
1011 
1012 typedef error_t (*PrngAlgoSeed)(void *context, const uint8_t *input,
1013  size_t length);
1014 
1015 typedef error_t (*PrngAlgoAddEntropy)(void *context, uint_t source,
1016  const uint8_t *input, size_t length, size_t entropy);
1017 
1018 typedef error_t (*PrngAlgoRead)(void *context, uint8_t *output, size_t length);
1019 
1020 typedef void (*PrngAlgoDeinit)(void *context);
1021 
1022 
1023 /**
1024  * @brief Common interface for hash algorithms
1025  **/
1026 
1027 typedef struct
1028 {
1029  const char_t *name;
1030  const uint8_t *oid;
1031  size_t oidSize;
1032  size_t contextSize;
1033  size_t blockSize;
1034  size_t digestSize;
1035  size_t minPadSize;
1042 } HashAlgo;
1043 
1044 
1045 /**
1046  * @brief Common interface for encryption algorithms
1047  **/
1048 
1049 typedef struct
1050 {
1051  const char_t *name;
1052  size_t contextSize;
1054  size_t blockSize;
1061 } CipherAlgo;
1062 
1063 
1064 /**
1065  * @brief Common interface for key encapsulation mechanisms (KEM)
1066  **/
1067 
1068 typedef struct
1069 {
1070  const char_t *name;
1078 } KemAlgo;
1079 
1080 
1081 /**
1082  * @brief Common interface for pseudo-random number generators (PRNG)
1083  **/
1084 
1086 {
1087  const char_t *name;
1088  size_t contextSize;
1094 };
1095 
1096 
1097 //C++ guard
1098 #ifdef __cplusplus
1099 }
1100 #endif
1101 
1102 #endif
void(* CipherAlgoDecryptStream)(void *context, const uint8_t *input, uint8_t *output, size_t length)
Definition: crypto.h:988
HashAlgoInit init
Definition: crypto.h:1038
int bool_t
Definition: compiler_port.h:53
void(* HashAlgoInit)(void *context)
Definition: crypto.h:973
@ CIPHER_MODE_CBC
Definition: crypto.h:959
const uint8_t * oid
Definition: crypto.h:1030
void(* CipherAlgoEncryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:991
CipherAlgoDecryptBlock decryptBlock
Definition: crypto.h:1059
#define PrngAlgo
Definition: crypto.h:931
@ CIPHER_MODE_OFB
Definition: crypto.h:961
@ CIPHER_MODE_GCM
Definition: crypto.h:964
Legacy definitions.
size_t contextSize
Definition: crypto.h:1088
@ CIPHER_ALGO_TYPE_BLOCK
Definition: crypto.h:946
uint8_t data[]
Definition: ethernet.h:222
size_t digestSize
Definition: crypto.h:1034
const char_t * name
Definition: crypto.h:1051
HashAlgoUpdate update
Definition: crypto.h:1039
CipherAlgoType
Encryption algorithm type.
Definition: crypto.h:944
size_t blockSize
Definition: crypto.h:1054
error_t(* PrngAlgoAddEntropy)(void *context, uint_t source, const uint8_t *input, size_t length, size_t entropy)
Definition: crypto.h:1015
size_t blockSize
Definition: crypto.h:1033
size_t publicKeySize
Definition: crypto.h:1071
@ CIPHER_MODE_CTR
Definition: crypto.h:962
@ CIPHER_MODE_ECB
Definition: crypto.h:958
CipherAlgoEncryptBlock encryptBlock
Definition: crypto.h:1058
void(* HashAlgoUpdate)(void *context, const void *data, size_t length)
Definition: crypto.h:975
size_t contextSize
Definition: crypto.h:1032
size_t oidSize
Definition: crypto.h:1031
CipherAlgoInit init
Definition: crypto.h:1055
CipherAlgoEncryptStream encryptStream
Definition: crypto.h:1056
PrngAlgoSeed seed
Definition: crypto.h:1090
error_t
Error codes.
Definition: error.h:43
@ CIPHER_MODE_CFB
Definition: crypto.h:960
HashAlgoCompute compute
Definition: crypto.h:1037
size_t sharedSecretSize
Definition: crypto.h:1074
CipherAlgoType type
Definition: crypto.h:1053
void(* CipherAlgoDecryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:994
const char_t * name
Definition: crypto.h:1029
void(* CipherAlgoEncryptStream)(void *context, const uint8_t *input, uint8_t *output, size_t length)
Definition: crypto.h:985
CipherAlgoDecryptStream decryptStream
Definition: crypto.h:1057
KemAlgoDecapsulate decapsulate
Definition: crypto.h:1077
Error codes description.
uint8_t length
Definition: tcp.h:368
@ CIPHER_MODE_STREAM
Definition: crypto.h:957
Byte order conversion.
CipherMode
Cipher operation modes.
Definition: crypto.h:955
error_t(* PrngAlgoRead)(void *context, uint8_t *output, size_t length)
Definition: crypto.h:1018
size_t secretKeySize
Definition: crypto.h:1072
const char_t * name
Definition: crypto.h:1087
error_t(* CipherAlgoInit)(void *context, const uint8_t *key, size_t keyLen)
Definition: crypto.h:982
void(* HashAlgoFinal)(void *context, uint8_t *digest)
Definition: crypto.h:977
void(* PrngAlgoDeinit)(void *context)
Definition: crypto.h:1020
char char_t
Definition: compiler_port.h:48
error_t(* KemAlgoGenerateKeyPair)(const PrngAlgo *prngAlgo, void *prngContext, uint8_t *pk, uint8_t *sk)
Definition: crypto.h:1000
@ CIPHER_MODE_CCM
Definition: crypto.h:963
size_t contextSize
Definition: crypto.h:1052
PrngAlgoInit init
Definition: crypto.h:1089
Common interface for pseudo-random number generators (PRNG)
Definition: crypto.h:1086
KemAlgoGenerateKeyPair generateKeyPair
Definition: crypto.h:1075
PrngAlgoRead read
Definition: crypto.h:1092
KemAlgoEncapsulate encapsulate
Definition: crypto.h:1076
Common interface for key encapsulation mechanisms (KEM)
Definition: crypto.h:1069
CipherAlgoDeinit deinit
Definition: crypto.h:1060
size_t ciphertextSize
Definition: crypto.h:1073
size_t minPadSize
Definition: crypto.h:1035
Common interface for encryption algorithms.
Definition: crypto.h:1050
error_t(* KemAlgoDecapsulate)(uint8_t *ss, const uint8_t *ct, const uint8_t *sk)
Definition: crypto.h:1006
error_t(* KemAlgoEncapsulate)(const PrngAlgo *prngAlgo, void *prngContext, uint8_t *ct, uint8_t *ss, const uint8_t *pk)
Definition: crypto.h:1003
@ CIPHER_ALGO_TYPE_STREAM
Definition: crypto.h:945
Common interface for hash algorithms.
Definition: crypto.h:1028
PrngAlgoDeinit deinit
Definition: crypto.h:1093
@ CIPHER_MODE_NULL
Definition: crypto.h:956
@ CIPHER_MODE_CHACHA20_POLY1305
Definition: crypto.h:965
bool_t bigEndian
Definition: crypto.h:1036
unsigned int uint_t
Definition: compiler_port.h:50
void(* CipherAlgoDeinit)(void *context)
Definition: crypto.h:997
error_t(* HashAlgoCompute)(const void *data, size_t length, uint8_t *digest)
Definition: crypto.h:970
error_t(* PrngAlgoSeed)(void *context, const uint8_t *input, size_t length)
Definition: crypto.h:1012
error_t(* PrngAlgoInit)(void *context)
Definition: crypto.h:1010
void(* HashAlgoFinalRaw)(void *context, uint8_t *digest)
Definition: crypto.h:979
PrngAlgoAddEntropy addEntropy
Definition: crypto.h:1091
RTOS abstraction layer.
HashAlgoFinalRaw finalRaw
Definition: crypto.h:1041
const char_t * name
Definition: crypto.h:1070