Go to the documentation of this file.
36 #include "crypto_config.h"
64 #ifndef GPL_LICENSE_TERMS_ACCEPTED
65 #error Before compiling CycloneCRYPTO Open, you must accept the terms of the GPL license
69 #define CYCLONE_CRYPTO_VERSION_STRING "2.5.0"
71 #define CYCLONE_CRYPTO_MAJOR_VERSION 2
73 #define CYCLONE_CRYPTO_MINOR_VERSION 5
75 #define CYCLONE_CRYPTO_REV_NUMBER 0
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
86 #define MPI_SUPPORT ENABLED
87 #elif (MPI_SUPPORT != ENABLED && MPI_SUPPORT != DISABLED)
88 #error MPI_SUPPORT parameter is not valid
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
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
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
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
121 #define MD2_SUPPORT DISABLED
122 #elif (MD2_SUPPORT != ENABLED && MD2_SUPPORT != DISABLED)
123 #error MD2_SUPPORT parameter is not valid
128 #define MD4_SUPPORT DISABLED
129 #elif (MD4_SUPPORT != ENABLED && MD4_SUPPORT != DISABLED)
130 #error MD4_SUPPORT parameter is not valid
135 #define MD5_SUPPORT DISABLED
136 #elif (MD5_SUPPORT != ENABLED && MD5_SUPPORT != DISABLED)
137 #error MD5_SUPPORT parameter is not valid
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
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
156 #define SHA1_SUPPORT ENABLED
157 #elif (SHA1_SUPPORT != ENABLED && SHA1_SUPPORT != DISABLED)
158 #error SHA1_SUPPORT parameter is not valid
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
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
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
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
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
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
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
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
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
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
232 #ifndef ASCON_HASH256_SUPPORT
233 #define ASCON_HASH256_SUPPORT DISABLED
234 #elif (ASCON_HASH256_SUPPORT != ENABLED && ASCON_HASH256_SUPPORT != DISABLED)
235 #error ASCON_HASH256_SUPPORT parameter is not valid
239 #ifndef BLAKE2B_SUPPORT
240 #define BLAKE2B_SUPPORT DISABLED
241 #elif (BLAKE2B_SUPPORT != ENABLED && BLAKE2B_SUPPORT != DISABLED)
242 #error BLAKE2B_SUPPORT parameter is not valid
246 #ifndef BLAKE2B160_SUPPORT
247 #define BLAKE2B160_SUPPORT DISABLED
248 #elif (BLAKE2B160_SUPPORT != ENABLED && BLAKE2B160_SUPPORT != DISABLED)
249 #error BLAKE2B160_SUPPORT parameter is not valid
253 #ifndef BLAKE2B256_SUPPORT
254 #define BLAKE2B256_SUPPORT DISABLED
255 #elif (BLAKE2B256_SUPPORT != ENABLED && BLAKE2B256_SUPPORT != DISABLED)
256 #error BLAKE2B256_SUPPORT parameter is not valid
260 #ifndef BLAKE2B384_SUPPORT
261 #define BLAKE2B384_SUPPORT DISABLED
262 #elif (BLAKE2B384_SUPPORT != ENABLED && BLAKE2B384_SUPPORT != DISABLED)
263 #error BLAKE2B384_SUPPORT parameter is not valid
267 #ifndef BLAKE2B512_SUPPORT
268 #define BLAKE2B512_SUPPORT DISABLED
269 #elif (BLAKE2B512_SUPPORT != ENABLED && BLAKE2B512_SUPPORT != DISABLED)
270 #error BLAKE2B512_SUPPORT parameter is not valid
274 #ifndef BLAKE2S_SUPPORT
275 #define BLAKE2S_SUPPORT DISABLED
276 #elif (BLAKE2S_SUPPORT != ENABLED && BLAKE2S_SUPPORT != DISABLED)
277 #error BLAKE2S_SUPPORT parameter is not valid
281 #ifndef BLAKE2S128_SUPPORT
282 #define BLAKE2S128_SUPPORT DISABLED
283 #elif (BLAKE2S128_SUPPORT != ENABLED && BLAKE2S128_SUPPORT != DISABLED)
284 #error BLAKE2S128_SUPPORT parameter is not valid
288 #ifndef BLAKE2S160_SUPPORT
289 #define BLAKE2S160_SUPPORT DISABLED
290 #elif (BLAKE2S160_SUPPORT != ENABLED && BLAKE2S160_SUPPORT != DISABLED)
291 #error BLAKE2S160_SUPPORT parameter is not valid
295 #ifndef BLAKE2S224_SUPPORT
296 #define BLAKE2S224_SUPPORT DISABLED
297 #elif (BLAKE2S224_SUPPORT != ENABLED && BLAKE2S224_SUPPORT != DISABLED)
298 #error BLAKE2S224_SUPPORT parameter is not valid
302 #ifndef BLAKE2S256_SUPPORT
303 #define BLAKE2S256_SUPPORT DISABLED
304 #elif (BLAKE2S256_SUPPORT != ENABLED && BLAKE2S256_SUPPORT != DISABLED)
305 #error BLAKE2S256_SUPPORT parameter is not valid
310 #define SM3_SUPPORT DISABLED
311 #elif (SM3_SUPPORT != ENABLED && SM3_SUPPORT != DISABLED)
312 #error SM3_SUPPORT parameter is not valid
316 #ifndef TIGER_SUPPORT
317 #define TIGER_SUPPORT DISABLED
318 #elif (TIGER_SUPPORT != ENABLED && TIGER_SUPPORT != DISABLED)
319 #error TIGER_SUPPORT parameter is not valid
323 #ifndef WHIRLPOOL_SUPPORT
324 #define WHIRLPOOL_SUPPORT DISABLED
325 #elif (WHIRLPOOL_SUPPORT != ENABLED && WHIRLPOOL_SUPPORT != DISABLED)
326 #error WHIRLPOOL_SUPPORT parameter is not valid
330 #ifndef KECCAK_SUPPORT
331 #define KECCAK_SUPPORT DISABLED
332 #elif (KECCAK_SUPPORT != ENABLED && KECCAK_SUPPORT != DISABLED)
333 #error KECCAK_SUPPORT parameter is not valid
337 #ifndef SHAKE_SUPPORT
338 #define SHAKE_SUPPORT DISABLED
339 #elif (SHAKE_SUPPORT != ENABLED && SHAKE_SUPPORT != DISABLED)
340 #error SHAKE_SUPPORT parameter is not valid
344 #ifndef CSHAKE_SUPPORT
345 #define CSHAKE_SUPPORT DISABLED
346 #elif (CSHAKE_SUPPORT != ENABLED && CSHAKE_SUPPORT != DISABLED)
347 #error CSHAKE_SUPPORT parameter is not valid
351 #ifndef ASCON_XOF128_SUPPORT
352 #define ASCON_XOF128_SUPPORT DISABLED
353 #elif (ASCON_XOF128_SUPPORT != ENABLED && ASCON_XOF128_SUPPORT != DISABLED)
354 #error ASCON_XOF128_SUPPORT parameter is not valid
358 #ifndef ASCON_CXOF128_SUPPORT
359 #define ASCON_CXOF128_SUPPORT DISABLED
360 #elif (ASCON_CXOF128_SUPPORT != ENABLED && ASCON_CXOF128_SUPPORT != DISABLED)
361 #error ASCON_CXOF128_SUPPORT parameter is not valid
366 #define CMAC_SUPPORT DISABLED
367 #elif (CMAC_SUPPORT != ENABLED && CMAC_SUPPORT != DISABLED)
368 #error CMAC_SUPPORT parameter is not valid
373 #define HMAC_SUPPORT ENABLED
374 #elif (HMAC_SUPPORT != ENABLED && HMAC_SUPPORT != DISABLED)
375 #error HMAC_SUPPORT parameter is not valid
380 #define GMAC_SUPPORT DISABLED
381 #elif (GMAC_SUPPORT != ENABLED && GMAC_SUPPORT != DISABLED)
382 #error GMAC_SUPPORT parameter is not valid
387 #define KMAC_SUPPORT DISABLED
388 #elif (KMAC_SUPPORT != ENABLED && KMAC_SUPPORT != DISABLED)
389 #error KMAC_SUPPORT parameter is not valid
393 #ifndef XCBC_MAC_SUPPORT
394 #define XCBC_MAC_SUPPORT DISABLED
395 #elif (XCBC_MAC_SUPPORT != ENABLED && XCBC_MAC_SUPPORT != DISABLED)
396 #error XCBC_MAC_SUPPORT parameter is not valid
400 #ifndef POLY1305_SUPPORT
401 #define POLY1305_SUPPORT DISABLED
402 #elif (POLY1305_SUPPORT != ENABLED && POLY1305_SUPPORT != DISABLED)
403 #error POLY1305_SUPPORT parameter is not valid
408 #define RC2_SUPPORT DISABLED
409 #elif (RC2_SUPPORT != ENABLED && RC2_SUPPORT != DISABLED)
410 #error RC2_SUPPORT parameter is not valid
415 #define RC4_SUPPORT DISABLED
416 #elif (RC4_SUPPORT != ENABLED && RC4_SUPPORT != DISABLED)
417 #error RC4_SUPPORT parameter is not valid
422 #define RC6_SUPPORT DISABLED
423 #elif (RC6_SUPPORT != ENABLED && RC6_SUPPORT != DISABLED)
424 #error RC6_SUPPORT parameter is not valid
428 #ifndef CAST128_SUPPORT
429 #define CAST128_SUPPORT DISABLED
430 #elif (CAST128_SUPPORT != ENABLED && CAST128_SUPPORT != DISABLED)
431 #error CAST128_SUPPORT parameter is not valid
435 #ifndef CAST256_SUPPORT
436 #define CAST256_SUPPORT DISABLED
437 #elif (CAST256_SUPPORT != ENABLED && CAST256_SUPPORT != DISABLED)
438 #error CAST256_SUPPORT parameter is not valid
443 #define IDEA_SUPPORT DISABLED
444 #elif (IDEA_SUPPORT != ENABLED && IDEA_SUPPORT != DISABLED)
445 #error IDEA_SUPPORT parameter is not valid
450 #define DES_SUPPORT DISABLED
451 #elif (DES_SUPPORT != ENABLED && DES_SUPPORT != DISABLED)
452 #error DES_SUPPORT parameter is not valid
457 #define DES3_SUPPORT DISABLED
458 #elif (DES3_SUPPORT != ENABLED && DES3_SUPPORT != DISABLED)
459 #error DES3_SUPPORT parameter is not valid
464 #define AES_SUPPORT ENABLED
465 #elif (AES_SUPPORT != ENABLED && AES_SUPPORT != DISABLED)
466 #error AES_SUPPORT parameter is not valid
470 #ifndef BLOWFISH_SUPPORT
471 #define BLOWFISH_SUPPORT DISABLED
472 #elif (BLOWFISH_SUPPORT != ENABLED && BLOWFISH_SUPPORT != DISABLED)
473 #error BLOWFISH_SUPPORT parameter is not valid
477 #ifndef TWOFISH_SUPPORT
478 #define TWOFISH_SUPPORT DISABLED
479 #elif (TWOFISH_SUPPORT != ENABLED && TWOFISH_SUPPORT != DISABLED)
480 #error TWOFISH_SUPPORT parameter is not valid
485 #define MARS_SUPPORT DISABLED
486 #elif (MARS_SUPPORT != ENABLED && MARS_SUPPORT != DISABLED)
487 #error MARS_SUPPORT parameter is not valid
491 #ifndef SERPENT_SUPPORT
492 #define SERPENT_SUPPORT DISABLED
493 #elif (SERPENT_SUPPORT != ENABLED && SERPENT_SUPPORT != DISABLED)
494 #error SERPENT_SUPPORT parameter is not valid
498 #ifndef CAMELLIA_SUPPORT
499 #define CAMELLIA_SUPPORT DISABLED
500 #elif (CAMELLIA_SUPPORT != ENABLED && CAMELLIA_SUPPORT != DISABLED)
501 #error CAMELLIA_SUPPORT parameter is not valid
506 #define ARIA_SUPPORT DISABLED
507 #elif (ARIA_SUPPORT != ENABLED && ARIA_SUPPORT != DISABLED)
508 #error ARIA_SUPPORT parameter is not valid
513 #define SEED_SUPPORT DISABLED
514 #elif (SEED_SUPPORT != ENABLED && SEED_SUPPORT != DISABLED)
515 #error SEED_SUPPORT parameter is not valid
520 #define SM4_SUPPORT DISABLED
521 #elif (SM4_SUPPORT != ENABLED && SM4_SUPPORT != DISABLED)
522 #error SM4_SUPPORT parameter is not valid
526 #ifndef PRESENT_SUPPORT
527 #define PRESENT_SUPPORT DISABLED
528 #elif (PRESENT_SUPPORT != ENABLED && PRESENT_SUPPORT != DISABLED)
529 #error PRESENT_SUPPORT parameter is not valid
534 #define TEA_SUPPORT DISABLED
535 #elif (TEA_SUPPORT != ENABLED && TEA_SUPPORT != DISABLED)
536 #error TEA_SUPPORT parameter is not valid
541 #define XTEA_SUPPORT DISABLED
542 #elif (XTEA_SUPPORT != ENABLED && XTEA_SUPPORT != DISABLED)
543 #error XTEA_SUPPORT parameter is not valid
547 #ifndef CHACHA_SUPPORT
548 #define CHACHA_SUPPORT DISABLED
549 #elif (CHACHA_SUPPORT != ENABLED && CHACHA_SUPPORT != DISABLED)
550 #error CHACHA_SUPPORT parameter is not valid
554 #ifndef SALSA20_SUPPORT
555 #define SALSA20_SUPPORT DISABLED
556 #elif (SALSA20_SUPPORT != ENABLED && SALSA20_SUPPORT != DISABLED)
557 #error SALSA20_SUPPORT parameter is not valid
561 #ifndef TRIVIUM_SUPPORT
562 #define TRIVIUM_SUPPORT DISABLED
563 #elif (TRIVIUM_SUPPORT != ENABLED && TRIVIUM_SUPPORT != DISABLED)
564 #error TRIVIUM_SUPPORT parameter is not valid
569 #define ZUC_SUPPORT DISABLED
570 #elif (ZUC_SUPPORT != ENABLED && ZUC_SUPPORT != DISABLED)
571 #error ZUC_SUPPORT parameter is not valid
576 #define ECB_SUPPORT ENABLED
577 #elif (ECB_SUPPORT != ENABLED && ECB_SUPPORT != DISABLED)
578 #error ECB_SUPPORT parameter is not valid
583 #define CBC_SUPPORT ENABLED
584 #elif (CBC_SUPPORT != ENABLED && CBC_SUPPORT != DISABLED)
585 #error CBC_SUPPORT parameter is not valid
590 #define CFB_SUPPORT ENABLED
591 #elif (CFB_SUPPORT != ENABLED && CFB_SUPPORT != DISABLED)
592 #error CFB_SUPPORT parameter is not valid
597 #define OFB_SUPPORT ENABLED
598 #elif (OFB_SUPPORT != ENABLED && OFB_SUPPORT != DISABLED)
599 #error OFB_SUPPORT parameter is not valid
604 #define CTR_SUPPORT ENABLED
605 #elif (CTR_SUPPORT != ENABLED && CTR_SUPPORT != DISABLED)
606 #error CTR_SUPPORT parameter is not valid
611 #define XTS_SUPPORT ENABLED
612 #elif (XTS_SUPPORT != ENABLED && XTS_SUPPORT != DISABLED)
613 #error XTS_SUPPORT parameter is not valid
618 #define CCM_SUPPORT ENABLED
619 #elif (CCM_SUPPORT != ENABLED && CCM_SUPPORT != DISABLED)
620 #error CCM_SUPPORT parameter is not valid
625 #define GCM_SUPPORT ENABLED
626 #elif (GCM_SUPPORT != ENABLED && GCM_SUPPORT != DISABLED)
627 #error GCM_SUPPORT parameter is not valid
632 #define SIV_SUPPORT DISABLED
633 #elif (SIV_SUPPORT != ENABLED && SIV_SUPPORT != DISABLED)
634 #error SIV_SUPPORT parameter is not valid
638 #ifndef ASCON_AEAD128_SUPPORT
639 #define ASCON_AEAD128_SUPPORT DISABLED
640 #elif (ASCON_AEAD128_SUPPORT != ENABLED && ASCON_AEAD128_SUPPORT != DISABLED)
641 #error ASCON_AEAD128_SUPPORT parameter is not valid
645 #ifndef CHACHA20_POLY1305_SUPPORT
646 #define CHACHA20_POLY1305_SUPPORT DISABLED
647 #elif (CHACHA20_POLY1305_SUPPORT != ENABLED && CHACHA20_POLY1305_SUPPORT != DISABLED)
648 #error CHACHA20_POLY1305_SUPPORT parameter is not valid
653 #define DH_SUPPORT DISABLED
654 #elif (DH_SUPPORT != ENABLED && DH_SUPPORT != DISABLED)
655 #error DH_SUPPORT parameter is not valid
660 #define RSA_SUPPORT ENABLED
661 #elif (RSA_SUPPORT != ENABLED && RSA_SUPPORT != DISABLED)
662 #error RSA_SUPPORT parameter is not valid
667 #define DSA_SUPPORT DISABLED
668 #elif (DSA_SUPPORT != ENABLED && DSA_SUPPORT != DISABLED)
669 #error DSA_SUPPORT parameter is not valid
674 #define EC_SUPPORT ENABLED
675 #elif (EC_SUPPORT != ENABLED && EC_SUPPORT != DISABLED)
676 #error EC_SUPPORT parameter is not valid
681 #define ECDH_SUPPORT ENABLED
682 #elif (ECDH_SUPPORT != ENABLED && ECDH_SUPPORT != DISABLED)
683 #error ECDH_SUPPORT parameter is not valid
687 #ifndef ECDSA_SUPPORT
688 #define ECDSA_SUPPORT ENABLED
689 #elif (ECDSA_SUPPORT != ENABLED && ECDSA_SUPPORT != DISABLED)
690 #error ECDSA_SUPPORT parameter is not valid
695 #define KEM_SUPPORT DISABLED
696 #elif (KEM_SUPPORT != ENABLED && KEM_SUPPORT != DISABLED)
697 #error KEM_SUPPORT parameter is not valid
701 #ifndef MLKEM512_SUPPORT
702 #define MLKEM512_SUPPORT DISABLED
703 #elif (MLKEM512_SUPPORT != ENABLED && MLKEM512_SUPPORT != DISABLED)
704 #error MLKEM512_SUPPORT parameter is not valid
708 #ifndef MLKEM768_SUPPORT
709 #define MLKEM768_SUPPORT DISABLED
710 #elif (MLKEM768_SUPPORT != ENABLED && MLKEM768_SUPPORT != DISABLED)
711 #error MLKEM768_SUPPORT parameter is not valid
715 #ifndef MLKEM1024_SUPPORT
716 #define MLKEM1024_SUPPORT DISABLED
717 #elif (MLKEM1024_SUPPORT != ENABLED && MLKEM1024_SUPPORT != DISABLED)
718 #error MLKEM1024_SUPPORT parameter is not valid
722 #ifndef SNTRUP761_SUPPORT
723 #define SNTRUP761_SUPPORT DISABLED
724 #elif (SNTRUP761_SUPPORT != ENABLED && SNTRUP761_SUPPORT != DISABLED)
725 #error SNTRUP761_SUPPORT parameter is not valid
730 #define HKDF_SUPPORT DISABLED
731 #elif (HKDF_SUPPORT != ENABLED && HKDF_SUPPORT != DISABLED)
732 #error HKDF_SUPPORT parameter is not valid
736 #ifndef PBKDF_SUPPORT
737 #define PBKDF_SUPPORT DISABLED
738 #elif (PBKDF_SUPPORT != ENABLED && PBKDF_SUPPORT != DISABLED)
739 #error PBKDF_SUPPORT parameter is not valid
743 #ifndef CONCAT_KDF_SUPPORT
744 #define CONCAT_KDF_SUPPORT DISABLED
745 #elif (CONCAT_KDF_SUPPORT != ENABLED && CONCAT_KDF_SUPPORT != DISABLED)
746 #error CONCAT_KDF_SUPPORT parameter is not valid
750 #ifndef BCRYPT_SUPPORT
751 #define BCRYPT_SUPPORT DISABLED
752 #elif (BCRYPT_SUPPORT != ENABLED && BCRYPT_SUPPORT != DISABLED)
753 #error BCRYPT_SUPPORT parameter is not valid
757 #ifndef SCRYPT_SUPPORT
758 #define SCRYPT_SUPPORT DISABLED
759 #elif (SCRYPT_SUPPORT != ENABLED && SCRYPT_SUPPORT != DISABLED)
760 #error SCRYPT_SUPPORT parameter is not valid
764 #ifndef MD5_CRYPT_SUPPORT
765 #define MD5_CRYPT_SUPPORT DISABLED
766 #elif (MD5_CRYPT_SUPPORT != ENABLED && MD5_CRYPT_SUPPORT != DISABLED)
767 #error MD5_CRYPT_SUPPORT parameter is not valid
771 #ifndef SHA_CRYPT_SUPPORT
772 #define SHA_CRYPT_SUPPORT DISABLED
773 #elif (SHA_CRYPT_SUPPORT != ENABLED && SHA_CRYPT_SUPPORT != DISABLED)
774 #error SHA_CRYPT_SUPPORT parameter is not valid
778 #ifndef YARROW_SUPPORT
779 #define YARROW_SUPPORT ENABLED
780 #elif (YARROW_SUPPORT != ENABLED && YARROW_SUPPORT != DISABLED)
781 #error YARROW_SUPPORT parameter is not valid
786 #define OID_SUPPORT ENABLED
787 #elif (OID_SUPPORT != ENABLED && OID_SUPPORT != DISABLED)
788 #error OID_SUPPORT parameter is not valid
793 #define ASN1_SUPPORT ENABLED
794 #elif (ASN1_SUPPORT != ENABLED && ASN1_SUPPORT != DISABLED)
795 #error ASN1_SUPPORT parameter is not valid
800 #define PEM_SUPPORT ENABLED
801 #elif (PEM_SUPPORT != ENABLED && PEM_SUPPORT != DISABLED)
802 #error PEM_SUPPORT parameter is not valid
807 #define X509_SUPPORT ENABLED
808 #elif (X509_SUPPORT != ENABLED && X509_SUPPORT != DISABLED)
809 #error X509_SUPPORT parameter is not valid
813 #ifndef PKCS5_SUPPORT
814 #define PKCS5_SUPPORT DISABLED
815 #elif (PKCS5_SUPPORT != ENABLED && PKCS5_SUPPORT != DISABLED)
816 #error PKCS5_SUPPORT parameter is not valid
820 #ifndef cryptoAllocMem
821 #define cryptoAllocMem(size) osAllocMem(size)
825 #ifndef cryptoFreeMem
826 #define cryptoFreeMem(p) osFreeMem(p)
830 #define ROL8(a, n) (((a) << (n)) | ((a) >> (8 - (n))))
831 #define ROL16(a, n) (((a) << (n)) | ((a) >> (16 - (n))))
832 #define ROL32(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
833 #define ROL64(a, n) (((a) << (n)) | ((a) >> (64 - (n))))
836 #define ROR8(a, n) (((a) >> (n)) | ((a) << (8 - (n))))
837 #define ROR16(a, n) (((a) >> (n)) | ((a) << (16 - (n))))
838 #define ROR32(a, n) (((a) >> (n)) | ((a) << (32 - (n))))
839 #define ROR64(a, n) (((a) >> (n)) | ((a) << (64 - (n))))
842 #define SHL8(a, n) ((a) << (n))
843 #define SHL16(a, n) ((a) << (n))
844 #define SHL32(a, n) ((a) << (n))
845 #define SHL64(a, n) ((a) << (n))
848 #define SHR8(a, n) ((a) >> (n))
849 #define SHR16(a, n) ((a) >> (n))
850 #define SHR32(a, n) ((a) >> (n))
851 #define SHR64(a, n) ((a) >> (n))
854 #define _U8(x) ((uint8_t) (x))
855 #define _U16(x) ((uint16_t) (x))
856 #define _U32(x) ((uint32_t) (x))
857 #define _U64(x) ((uint64_t) (x))
860 #define CRYPTO_TEST_Z_8(a) \
861 _U8((_U8((_U8(a) | (~_U8(a) + 1U))) >> 7U) ^ 1U)
864 #define CRYPTO_TEST_NZ_8(a) \
865 _U8(_U8((_U8(a) | (~_U8(a) + 1U))) >> 7U)
868 #define CRYPTO_TEST_EQ_8(a, b) \
869 _U8((_U8(((_U8(a) ^ _U8(b)) | (~(_U8(a) ^ _U8(b)) + 1U))) >> 7U) ^ 1U)
872 #define CRYPTO_TEST_NEQ_8(a, b) \
873 _U8(_U8(((_U8(a) ^ _U8(b)) | (~(_U8(a) ^ _U8(b)) + 1U))) >> 7U)
876 #define CRYPTO_TEST_LT_8(a, b) \
877 _U8(_U8((((_U8(a) - _U8(b)) ^ _U8(b)) | (_U8(a) ^ _U8(b))) ^ _U8(a)) >> 7U)
880 #define CRYPTO_TEST_LTE_8(a, b) \
881 _U8((_U8((((_U8(b) - _U8(a)) ^ _U8(a)) | (_U8(a) ^ _U8(b))) ^ _U8(b)) >> 7U) ^ 1U)
884 #define CRYPTO_TEST_GT_8(a, b) \
885 _U8(_U8((((_U8(b) - _U8(a)) ^ _U8(a)) | (_U8(a) ^ _U8(b))) ^ _U8(b)) >> 7U)
888 #define CRYPTO_TEST_GTE_8(a, b) \
889 _U8((_U8((((_U8(a) - _U8(b)) ^ _U8(b)) | (_U8(a) ^ _U8(b))) ^ _U8(a)) >> 7U) ^ 1U)
892 #define CRYPTO_SELECT_8(a, b, c) \
893 _U8((_U8(a) & (_U8(c) - 1U)) | (_U8(b) & ~(_U8(c) - 1U)))
896 #define CRYPTO_TEST_Z_16(a) \
897 _U16((_U16((_U16(a) | (~_U16(a) + 1U))) >> 15U) ^ 1U)
900 #define CRYPTO_TEST_NZ_16(a) \
901 _U16(_U16((_U16(a) | (~_U16(a) + 1U))) >> 15U)
904 #define CRYPTO_TEST_EQ_16(a, b) \
905 _U16((_U16(((_U16(a) ^ _U16(b)) | (~(_U16(a) ^ _U16(b)) + 1U))) >> 15U) ^ 1U)
908 #define CRYPTO_TEST_NEQ_16(a, b) \
909 _U16(_U16(((_U16(a) ^ _U16(b)) | (~(_U16(a) ^ _U16(b)) + 1U))) >> 15U)
912 #define CRYPTO_TEST_LT_16(a, b) \
913 _U16(_U16((((_U16(a) - _U16(b)) ^ _U16(b)) | (_U16(a) ^ _U16(b))) ^ _U16(a)) >> 15U)
916 #define CRYPTO_TEST_LTE_16(a, b) \
917 _U16((_U16((((_U16(b) - _U16(a)) ^ _U16(a)) | (_U16(a) ^ _U16(b))) ^ _U16(b)) >> 15U) ^ 1U)
920 #define CRYPTO_TEST_GT_16(a, b) \
921 _U16(_U16((((_U16(b) - _U16(a)) ^ _U16(a)) | (_U16(a) ^ _U16(b))) ^ _U16(b)) >> 15U)
924 #define CRYPTO_TEST_GTE_16(a, b) \
925 _U16((_U16((((_U16(a) - _U16(b)) ^ _U16(b)) | (_U16(a) ^ _U16(b))) ^ _U16(a)) >> 15U) ^ 1U)
928 #define CRYPTO_SELECT_16(a, b, c) \
929 _U16((_U16(a) & (_U16(c) - 1U)) | (_U16(b) & ~(_U16(c) - 1U)))
932 #define CRYPTO_TEST_Z_32(a) \
933 _U32((_U32((_U32(a) | (~_U32(a) + 1U))) >> 31U) ^ 1U)
936 #define CRYPTO_TEST_NZ_32(a) \
937 _U32(_U32((_U32(a) | (~_U32(a) + 1U))) >> 31U)
940 #define CRYPTO_TEST_EQ_32(a, b) \
941 _U32((_U32(((_U32(a) ^ _U32(b)) | (~(_U32(a) ^ _U32(b)) + 1U))) >> 31U) ^ 1U)
944 #define CRYPTO_TEST_NEQ_32(a, b) \
945 _U32(_U32(((_U32(a) ^ _U32(b)) | (~(_U32(a) ^ _U32(b)) + 1U))) >> 31U)
948 #define CRYPTO_TEST_LT_32(a, b) \
949 _U32(_U32((((_U32(a) - _U32(b)) ^ _U32(b)) | (_U32(a) ^ _U32(b))) ^ _U32(a)) >> 31U)
952 #define CRYPTO_TEST_LTE_32(a, b) \
953 _U32((_U32((((_U32(b) - _U32(a)) ^ _U32(a)) | (_U32(a) ^ _U32(b))) ^ _U32(b)) >> 31U) ^ 1U)
956 #define CRYPTO_TEST_GT_32(a, b) \
957 _U32(_U32((((_U32(b) - _U32(a)) ^ _U32(a)) | (_U32(a) ^ _U32(b))) ^ _U32(b)) >> 31U)
960 #define CRYPTO_TEST_GTE_32(a, b) \
961 _U32((_U32((((_U32(a) - _U32(b)) ^ _U32(b)) | (_U32(a) ^ _U32(b))) ^ _U32(a)) >> 31U) ^ 1U)
964 #define CRYPTO_SELECT_32(a, b, c) \
965 _U32((_U32(a) & (_U32(c) - 1U)) | (_U32(b) & ~(_U32(c) - 1U)))
968 #define CRYPTO_SELECT_64(a, b, c) \
969 _U64((_U64(a) & (_U64(c) - 1U)) | (_U64(b) & ~(_U64(c) - 1U)))
973 #define PrngAlgo struct _PrngAlgo
1040 uint8_t *output,
size_t length);
1043 uint8_t *output,
size_t length);
1055 void *prngContext, uint8_t *pk, uint8_t *sk);
1058 void *prngContext, uint8_t *ct, uint8_t *ss,
const uint8_t *pk);
1070 const uint8_t *input,
size_t length,
size_t entropy);
void(* CipherAlgoDecryptStream)(void *context, const uint8_t *input, uint8_t *output, size_t length)
void(* HashAlgoInit)(void *context)
void(* CipherAlgoEncryptBlock)(void *context, const uint8_t *input, uint8_t *output)
CipherAlgoDecryptBlock decryptBlock
CipherAlgoType
Encryption algorithm type.
error_t(* PrngAlgoAddEntropy)(void *context, uint_t source, const uint8_t *input, size_t length, size_t entropy)
CipherAlgoEncryptBlock encryptBlock
void(* HashAlgoUpdate)(void *context, const void *data, size_t length)
CipherAlgoEncryptStream encryptStream
void(* CipherAlgoDecryptBlock)(void *context, const uint8_t *input, uint8_t *output)
void(* CipherAlgoEncryptStream)(void *context, const uint8_t *input, uint8_t *output, size_t length)
CipherAlgoDecryptStream decryptStream
KemAlgoDecapsulate decapsulate
CipherMode
Cipher operation modes.
error_t(* PrngAlgoRead)(void *context, uint8_t *output, size_t length)
@ CIPHER_MODE_ASCON_AEAD128
error_t(* CipherAlgoInit)(void *context, const uint8_t *key, size_t keyLen)
void(* HashAlgoFinal)(void *context, uint8_t *digest)
void(* PrngAlgoDeinit)(void *context)
error_t(* KemAlgoGenerateKeyPair)(const PrngAlgo *prngAlgo, void *prngContext, uint8_t *pk, uint8_t *sk)
Common interface for pseudo-random number generators (PRNG)
KemAlgoGenerateKeyPair generateKeyPair
KemAlgoEncapsulate encapsulate
Common interface for key encapsulation mechanisms (KEM)
Common interface for encryption algorithms.
error_t(* KemAlgoDecapsulate)(uint8_t *ss, const uint8_t *ct, const uint8_t *sk)
error_t(* KemAlgoEncapsulate)(const PrngAlgo *prngAlgo, void *prngContext, uint8_t *ct, uint8_t *ss, const uint8_t *pk)
@ CIPHER_ALGO_TYPE_STREAM
Common interface for hash algorithms.
@ CIPHER_MODE_CHACHA20_POLY1305
void(* CipherAlgoDeinit)(void *context)
error_t(* HashAlgoCompute)(const void *data, size_t length, uint8_t *digest)
error_t(* PrngAlgoSeed)(void *context, const uint8_t *input, size_t length)
error_t(* PrngAlgoInit)(void *context)
void(* HashAlgoFinalRaw)(void *context, uint8_t *digest)
PrngAlgoAddEntropy addEntropy
HashAlgoFinalRaw finalRaw