ReactOS 0.4.17-dev-806-gffa4164
cipher_wrap.c
Go to the documentation of this file.
1
51#if !defined(MBEDTLS_CONFIG_FILE)
52#include "mbedtls/config.h"
53#else
54#include MBEDTLS_CONFIG_FILE
55#endif
56
57#if defined(MBEDTLS_CIPHER_C)
58
60
61#if defined(MBEDTLS_CHACHAPOLY_C)
62#include "mbedtls/chachapoly.h"
63#endif
64
65#if defined(MBEDTLS_AES_C)
66#include "mbedtls/aes.h"
67#endif
68
69#if defined(MBEDTLS_ARC4_C)
70#include "mbedtls/arc4.h"
71#endif
72
73#if defined(MBEDTLS_CAMELLIA_C)
74#include "mbedtls/camellia.h"
75#endif
76
77#if defined(MBEDTLS_ARIA_C)
78#include "mbedtls/aria.h"
79#endif
80
81#if defined(MBEDTLS_DES_C)
82#include "mbedtls/des.h"
83#endif
84
85#if defined(MBEDTLS_BLOWFISH_C)
86#include "mbedtls/blowfish.h"
87#endif
88
89#if defined(MBEDTLS_CHACHA20_C)
90#include "mbedtls/chacha20.h"
91#endif
92
93#if defined(MBEDTLS_GCM_C)
94#include "mbedtls/gcm.h"
95#endif
96
97#if defined(MBEDTLS_CCM_C)
98#include "mbedtls/ccm.h"
99#endif
100
101#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
102#include <string.h>
103#endif
104
105#if defined(MBEDTLS_PLATFORM_C)
106#include "mbedtls/platform.h"
107#else
108#include <stdlib.h>
109#define mbedtls_calloc calloc
110#define mbedtls_free free
111#endif
112
113#if defined(MBEDTLS_GCM_C)
114/* shared by all GCM ciphers */
115static void *gcm_ctx_alloc( void )
116{
117 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) );
118
119 if( ctx != NULL )
121
122 return( ctx );
123}
124
125static void gcm_ctx_free( void *ctx )
126{
128 mbedtls_free( ctx );
129}
130#endif /* MBEDTLS_GCM_C */
131
132#if defined(MBEDTLS_CCM_C)
133/* shared by all CCM ciphers */
134static void *ccm_ctx_alloc( void )
135{
136 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) );
137
138 if( ctx != NULL )
140
141 return( ctx );
142}
143
144static void ccm_ctx_free( void *ctx )
145{
147 mbedtls_free( ctx );
148}
149#endif /* MBEDTLS_CCM_C */
150
151#if defined(MBEDTLS_AES_C)
152
153static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
154 const unsigned char *input, unsigned char *output )
155{
157}
158
159#if defined(MBEDTLS_CIPHER_MODE_CBC)
160static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
161 unsigned char *iv, const unsigned char *input, unsigned char *output )
162{
164 output );
165}
166#endif /* MBEDTLS_CIPHER_MODE_CBC */
167
168#if defined(MBEDTLS_CIPHER_MODE_CFB)
169static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
170 size_t length, size_t *iv_off, unsigned char *iv,
171 const unsigned char *input, unsigned char *output )
172{
174 input, output );
175}
176#ifdef __REACTOS__
177static int aes_crypt_cfb8_wrap( void *ctx, mbedtls_operation_t operation,
178 size_t length, size_t *iv_off, unsigned char *iv,
179 const unsigned char *input, unsigned char *output )
180{
182 input, output );
183}
184#endif
185#endif /* MBEDTLS_CIPHER_MODE_CFB */
186
187#if defined(MBEDTLS_CIPHER_MODE_OFB)
188static int aes_crypt_ofb_wrap( void *ctx, size_t length, size_t *iv_off,
189 unsigned char *iv, const unsigned char *input, unsigned char *output )
190{
192 iv, input, output );
193}
194#endif /* MBEDTLS_CIPHER_MODE_OFB */
195
196#if defined(MBEDTLS_CIPHER_MODE_CTR)
197static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
198 unsigned char *nonce_counter, unsigned char *stream_block,
199 const unsigned char *input, unsigned char *output )
200{
201 return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter,
202 stream_block, input, output );
203}
204#endif /* MBEDTLS_CIPHER_MODE_CTR */
205
206#if defined(MBEDTLS_CIPHER_MODE_XTS)
207static int aes_crypt_xts_wrap( void *ctx, mbedtls_operation_t operation,
208 size_t length,
209 const unsigned char data_unit[16],
210 const unsigned char *input,
211 unsigned char *output )
212{
213 mbedtls_aes_xts_context *xts_ctx = ctx;
214 int mode;
215
216 switch( operation )
217 {
218 case MBEDTLS_ENCRYPT:
220 break;
221 case MBEDTLS_DECRYPT:
223 break;
224 default:
226 }
227
228 return mbedtls_aes_crypt_xts( xts_ctx, mode, length,
229 data_unit, input, output );
230}
231#endif /* MBEDTLS_CIPHER_MODE_XTS */
232
233static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
234 unsigned int key_bitlen )
235{
236 return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_bitlen );
237}
238
239static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
240 unsigned int key_bitlen )
241{
242 return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen );
243}
244
245static void * aes_ctx_alloc( void )
246{
248
249 if( aes == NULL )
250 return( NULL );
251
252 mbedtls_aes_init( aes );
253
254 return( aes );
255}
256
257static void aes_ctx_free( void *ctx )
258{
260 mbedtls_free( ctx );
261}
262
263static const mbedtls_cipher_base_t aes_info = {
265 aes_crypt_ecb_wrap,
266#if defined(MBEDTLS_CIPHER_MODE_CBC)
267 aes_crypt_cbc_wrap,
268#endif
269#if defined(MBEDTLS_CIPHER_MODE_CFB)
270 aes_crypt_cfb128_wrap,
271#endif
272#if defined(MBEDTLS_CIPHER_MODE_OFB)
273 aes_crypt_ofb_wrap,
274#endif
275#if defined(MBEDTLS_CIPHER_MODE_CTR)
276 aes_crypt_ctr_wrap,
277#endif
278#if defined(MBEDTLS_CIPHER_MODE_XTS)
279 NULL,
280#endif
281#if defined(MBEDTLS_CIPHER_MODE_STREAM)
282 NULL,
283#endif
284 aes_setkey_enc_wrap,
285 aes_setkey_dec_wrap,
286 aes_ctx_alloc,
287 aes_ctx_free
288};
289
290#ifdef __REACTOS__
291static const mbedtls_cipher_base_t cfb8_aes_info = {
293 aes_crypt_ecb_wrap,
294#if defined(MBEDTLS_CIPHER_MODE_CBC)
295 aes_crypt_cbc_wrap,
296#endif
297#if defined(MBEDTLS_CIPHER_MODE_CFB)
298 aes_crypt_cfb8_wrap,
299#endif
300#if defined(MBEDTLS_CIPHER_MODE_OFB)
301 aes_crypt_ofb_wrap,
302#endif
303#if defined(MBEDTLS_CIPHER_MODE_CTR)
304 aes_crypt_ctr_wrap,
305#endif
306#if defined(MBEDTLS_CIPHER_MODE_XTS)
307 NULL,
308#endif
309#if defined(MBEDTLS_CIPHER_MODE_STREAM)
310 NULL,
311#endif
312 aes_setkey_enc_wrap,
313 aes_setkey_dec_wrap,
314 aes_ctx_alloc,
315 aes_ctx_free
316};
317#endif
318
319static const mbedtls_cipher_info_t aes_128_ecb_info = {
322 128,
323 "AES-128-ECB",
324 0,
325 0,
326 16,
327 &aes_info
328};
329
330static const mbedtls_cipher_info_t aes_192_ecb_info = {
333 192,
334 "AES-192-ECB",
335 0,
336 0,
337 16,
338 &aes_info
339};
340
341static const mbedtls_cipher_info_t aes_256_ecb_info = {
344 256,
345 "AES-256-ECB",
346 0,
347 0,
348 16,
349 &aes_info
350};
351
352#if defined(MBEDTLS_CIPHER_MODE_CBC)
353static const mbedtls_cipher_info_t aes_128_cbc_info = {
356 128,
357 "AES-128-CBC",
358 16,
359 0,
360 16,
361 &aes_info
362};
363
364static const mbedtls_cipher_info_t aes_192_cbc_info = {
367 192,
368 "AES-192-CBC",
369 16,
370 0,
371 16,
372 &aes_info
373};
374
375static const mbedtls_cipher_info_t aes_256_cbc_info = {
378 256,
379 "AES-256-CBC",
380 16,
381 0,
382 16,
383 &aes_info
384};
385#endif /* MBEDTLS_CIPHER_MODE_CBC */
386
387#if defined(MBEDTLS_CIPHER_MODE_CFB)
388#ifdef __REACTOS__
389static const mbedtls_cipher_info_t aes_128_cfb8_info = {
390 MBEDTLS_CIPHER_AES_128_CFB8,
392 128,
393 "AES-128-CFB8",
394 16,
395 0,
396 16,
397 &cfb8_aes_info
398};
399
400static const mbedtls_cipher_info_t aes_192_cfb8_info = {
401 MBEDTLS_CIPHER_AES_192_CFB8,
403 192,
404 "AES-192-CFB8",
405 16,
406 0,
407 16,
408 &cfb8_aes_info
409};
410
411static const mbedtls_cipher_info_t aes_256_cfb8_info = {
412 MBEDTLS_CIPHER_AES_256_CFB8,
414 256,
415 "AES-256-CFB8",
416 16,
417 0,
418 16,
419 &cfb8_aes_info
420};
421#endif
422
423static const mbedtls_cipher_info_t aes_128_cfb128_info = {
426 128,
427 "AES-128-CFB128",
428 16,
429 0,
430 16,
431 &aes_info
432};
433
434static const mbedtls_cipher_info_t aes_192_cfb128_info = {
437 192,
438 "AES-192-CFB128",
439 16,
440 0,
441 16,
442 &aes_info
443};
444
445static const mbedtls_cipher_info_t aes_256_cfb128_info = {
448 256,
449 "AES-256-CFB128",
450 16,
451 0,
452 16,
453 &aes_info
454};
455#endif /* MBEDTLS_CIPHER_MODE_CFB */
456
457#if defined(MBEDTLS_CIPHER_MODE_OFB)
458static const mbedtls_cipher_info_t aes_128_ofb_info = {
461 128,
462 "AES-128-OFB",
463 16,
464 0,
465 16,
466 &aes_info
467};
468
469static const mbedtls_cipher_info_t aes_192_ofb_info = {
472 192,
473 "AES-192-OFB",
474 16,
475 0,
476 16,
477 &aes_info
478};
479
480static const mbedtls_cipher_info_t aes_256_ofb_info = {
483 256,
484 "AES-256-OFB",
485 16,
486 0,
487 16,
488 &aes_info
489};
490#endif /* MBEDTLS_CIPHER_MODE_OFB */
491
492#if defined(MBEDTLS_CIPHER_MODE_CTR)
493static const mbedtls_cipher_info_t aes_128_ctr_info = {
496 128,
497 "AES-128-CTR",
498 16,
499 0,
500 16,
501 &aes_info
502};
503
504static const mbedtls_cipher_info_t aes_192_ctr_info = {
507 192,
508 "AES-192-CTR",
509 16,
510 0,
511 16,
512 &aes_info
513};
514
515static const mbedtls_cipher_info_t aes_256_ctr_info = {
518 256,
519 "AES-256-CTR",
520 16,
521 0,
522 16,
523 &aes_info
524};
525#endif /* MBEDTLS_CIPHER_MODE_CTR */
526
527#if defined(MBEDTLS_CIPHER_MODE_XTS)
528static int xts_aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
529 unsigned int key_bitlen )
530{
531 mbedtls_aes_xts_context *xts_ctx = ctx;
532 return( mbedtls_aes_xts_setkey_enc( xts_ctx, key, key_bitlen ) );
533}
534
535static int xts_aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
536 unsigned int key_bitlen )
537{
538 mbedtls_aes_xts_context *xts_ctx = ctx;
539 return( mbedtls_aes_xts_setkey_dec( xts_ctx, key, key_bitlen ) );
540}
541
542static void *xts_aes_ctx_alloc( void )
543{
544 mbedtls_aes_xts_context *xts_ctx = mbedtls_calloc( 1, sizeof( *xts_ctx ) );
545
546 if( xts_ctx != NULL )
547 mbedtls_aes_xts_init( xts_ctx );
548
549 return( xts_ctx );
550}
551
552static void xts_aes_ctx_free( void *ctx )
553{
554 mbedtls_aes_xts_context *xts_ctx = ctx;
555
556 if( xts_ctx == NULL )
557 return;
558
559 mbedtls_aes_xts_free( xts_ctx );
560 mbedtls_free( xts_ctx );
561}
562
563static const mbedtls_cipher_base_t xts_aes_info = {
565 NULL,
566#if defined(MBEDTLS_CIPHER_MODE_CBC)
567 NULL,
568#endif
569#if defined(MBEDTLS_CIPHER_MODE_CFB)
570 NULL,
571#endif
572#if defined(MBEDTLS_CIPHER_MODE_OFB)
573 NULL,
574#endif
575#if defined(MBEDTLS_CIPHER_MODE_CTR)
576 NULL,
577#endif
578#if defined(MBEDTLS_CIPHER_MODE_XTS)
579 aes_crypt_xts_wrap,
580#endif
581#if defined(MBEDTLS_CIPHER_MODE_STREAM)
582 NULL,
583#endif
584 xts_aes_setkey_enc_wrap,
585 xts_aes_setkey_dec_wrap,
586 xts_aes_ctx_alloc,
587 xts_aes_ctx_free
588};
589
590static const mbedtls_cipher_info_t aes_128_xts_info = {
593 256,
594 "AES-128-XTS",
595 16,
596 0,
597 16,
598 &xts_aes_info
599};
600
601static const mbedtls_cipher_info_t aes_256_xts_info = {
604 512,
605 "AES-256-XTS",
606 16,
607 0,
608 16,
609 &xts_aes_info
610};
611#endif /* MBEDTLS_CIPHER_MODE_XTS */
612
613#if defined(MBEDTLS_GCM_C)
614static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key,
615 unsigned int key_bitlen )
616{
618 key, key_bitlen );
619}
620
621static const mbedtls_cipher_base_t gcm_aes_info = {
623 NULL,
624#if defined(MBEDTLS_CIPHER_MODE_CBC)
625 NULL,
626#endif
627#if defined(MBEDTLS_CIPHER_MODE_CFB)
628 NULL,
629#endif
630#if defined(MBEDTLS_CIPHER_MODE_OFB)
631 NULL,
632#endif
633#if defined(MBEDTLS_CIPHER_MODE_CTR)
634 NULL,
635#endif
636#if defined(MBEDTLS_CIPHER_MODE_XTS)
637 NULL,
638#endif
639#if defined(MBEDTLS_CIPHER_MODE_STREAM)
640 NULL,
641#endif
642 gcm_aes_setkey_wrap,
643 gcm_aes_setkey_wrap,
644 gcm_ctx_alloc,
645 gcm_ctx_free,
646};
647
648static const mbedtls_cipher_info_t aes_128_gcm_info = {
651 128,
652 "AES-128-GCM",
653 12,
655 16,
656 &gcm_aes_info
657};
658
659static const mbedtls_cipher_info_t aes_192_gcm_info = {
662 192,
663 "AES-192-GCM",
664 12,
666 16,
667 &gcm_aes_info
668};
669
670static const mbedtls_cipher_info_t aes_256_gcm_info = {
673 256,
674 "AES-256-GCM",
675 12,
677 16,
678 &gcm_aes_info
679};
680#endif /* MBEDTLS_GCM_C */
681
682#if defined(MBEDTLS_CCM_C)
683static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key,
684 unsigned int key_bitlen )
685{
687 key, key_bitlen );
688}
689
690static const mbedtls_cipher_base_t ccm_aes_info = {
692 NULL,
693#if defined(MBEDTLS_CIPHER_MODE_CBC)
694 NULL,
695#endif
696#if defined(MBEDTLS_CIPHER_MODE_CFB)
697 NULL,
698#endif
699#if defined(MBEDTLS_CIPHER_MODE_OFB)
700 NULL,
701#endif
702#if defined(MBEDTLS_CIPHER_MODE_CTR)
703 NULL,
704#endif
705#if defined(MBEDTLS_CIPHER_MODE_XTS)
706 NULL,
707#endif
708#if defined(MBEDTLS_CIPHER_MODE_STREAM)
709 NULL,
710#endif
711 ccm_aes_setkey_wrap,
712 ccm_aes_setkey_wrap,
713 ccm_ctx_alloc,
714 ccm_ctx_free,
715};
716
717static const mbedtls_cipher_info_t aes_128_ccm_info = {
720 128,
721 "AES-128-CCM",
722 12,
724 16,
725 &ccm_aes_info
726};
727
728static const mbedtls_cipher_info_t aes_192_ccm_info = {
731 192,
732 "AES-192-CCM",
733 12,
735 16,
736 &ccm_aes_info
737};
738
739static const mbedtls_cipher_info_t aes_256_ccm_info = {
742 256,
743 "AES-256-CCM",
744 12,
746 16,
747 &ccm_aes_info
748};
749#endif /* MBEDTLS_CCM_C */
750
751#endif /* MBEDTLS_AES_C */
752
753#if defined(MBEDTLS_CAMELLIA_C)
754
755static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
756 const unsigned char *input, unsigned char *output )
757{
759 output );
760}
761
762#if defined(MBEDTLS_CIPHER_MODE_CBC)
763static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
764 size_t length, unsigned char *iv,
765 const unsigned char *input, unsigned char *output )
766{
768 input, output );
769}
770#endif /* MBEDTLS_CIPHER_MODE_CBC */
771
772#if defined(MBEDTLS_CIPHER_MODE_CFB)
773static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
774 size_t length, size_t *iv_off, unsigned char *iv,
775 const unsigned char *input, unsigned char *output )
776{
778 iv_off, iv, input, output );
779}
780#endif /* MBEDTLS_CIPHER_MODE_CFB */
781
782#if defined(MBEDTLS_CIPHER_MODE_CTR)
783static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
784 unsigned char *nonce_counter, unsigned char *stream_block,
785 const unsigned char *input, unsigned char *output )
786{
788 nonce_counter, stream_block, input, output );
789}
790#endif /* MBEDTLS_CIPHER_MODE_CTR */
791
792static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key,
793 unsigned int key_bitlen )
794{
796}
797
798static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key,
799 unsigned int key_bitlen )
800{
802}
803
804static void * camellia_ctx_alloc( void )
805{
808
809 if( ctx == NULL )
810 return( NULL );
811
813
814 return( ctx );
815}
816
817static void camellia_ctx_free( void *ctx )
818{
820 mbedtls_free( ctx );
821}
822
823static const mbedtls_cipher_base_t camellia_info = {
825 camellia_crypt_ecb_wrap,
826#if defined(MBEDTLS_CIPHER_MODE_CBC)
827 camellia_crypt_cbc_wrap,
828#endif
829#if defined(MBEDTLS_CIPHER_MODE_CFB)
830 camellia_crypt_cfb128_wrap,
831#endif
832#if defined(MBEDTLS_CIPHER_MODE_OFB)
833 NULL,
834#endif
835#if defined(MBEDTLS_CIPHER_MODE_CTR)
836 camellia_crypt_ctr_wrap,
837#endif
838#if defined(MBEDTLS_CIPHER_MODE_XTS)
839 NULL,
840#endif
841#if defined(MBEDTLS_CIPHER_MODE_STREAM)
842 NULL,
843#endif
844 camellia_setkey_enc_wrap,
845 camellia_setkey_dec_wrap,
846 camellia_ctx_alloc,
847 camellia_ctx_free
848};
849
850static const mbedtls_cipher_info_t camellia_128_ecb_info = {
853 128,
854 "CAMELLIA-128-ECB",
855 0,
856 0,
857 16,
858 &camellia_info
859};
860
861static const mbedtls_cipher_info_t camellia_192_ecb_info = {
864 192,
865 "CAMELLIA-192-ECB",
866 0,
867 0,
868 16,
869 &camellia_info
870};
871
872static const mbedtls_cipher_info_t camellia_256_ecb_info = {
875 256,
876 "CAMELLIA-256-ECB",
877 0,
878 0,
879 16,
880 &camellia_info
881};
882
883#if defined(MBEDTLS_CIPHER_MODE_CBC)
884static const mbedtls_cipher_info_t camellia_128_cbc_info = {
887 128,
888 "CAMELLIA-128-CBC",
889 16,
890 0,
891 16,
892 &camellia_info
893};
894
895static const mbedtls_cipher_info_t camellia_192_cbc_info = {
898 192,
899 "CAMELLIA-192-CBC",
900 16,
901 0,
902 16,
903 &camellia_info
904};
905
906static const mbedtls_cipher_info_t camellia_256_cbc_info = {
909 256,
910 "CAMELLIA-256-CBC",
911 16,
912 0,
913 16,
914 &camellia_info
915};
916#endif /* MBEDTLS_CIPHER_MODE_CBC */
917
918#if defined(MBEDTLS_CIPHER_MODE_CFB)
919static const mbedtls_cipher_info_t camellia_128_cfb128_info = {
922 128,
923 "CAMELLIA-128-CFB128",
924 16,
925 0,
926 16,
927 &camellia_info
928};
929
930static const mbedtls_cipher_info_t camellia_192_cfb128_info = {
933 192,
934 "CAMELLIA-192-CFB128",
935 16,
936 0,
937 16,
938 &camellia_info
939};
940
941static const mbedtls_cipher_info_t camellia_256_cfb128_info = {
944 256,
945 "CAMELLIA-256-CFB128",
946 16,
947 0,
948 16,
949 &camellia_info
950};
951#endif /* MBEDTLS_CIPHER_MODE_CFB */
952
953#if defined(MBEDTLS_CIPHER_MODE_CTR)
954static const mbedtls_cipher_info_t camellia_128_ctr_info = {
957 128,
958 "CAMELLIA-128-CTR",
959 16,
960 0,
961 16,
962 &camellia_info
963};
964
965static const mbedtls_cipher_info_t camellia_192_ctr_info = {
968 192,
969 "CAMELLIA-192-CTR",
970 16,
971 0,
972 16,
973 &camellia_info
974};
975
976static const mbedtls_cipher_info_t camellia_256_ctr_info = {
979 256,
980 "CAMELLIA-256-CTR",
981 16,
982 0,
983 16,
984 &camellia_info
985};
986#endif /* MBEDTLS_CIPHER_MODE_CTR */
987
988#if defined(MBEDTLS_GCM_C)
989static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
990 unsigned int key_bitlen )
991{
993 key, key_bitlen );
994}
995
996static const mbedtls_cipher_base_t gcm_camellia_info = {
998 NULL,
999#if defined(MBEDTLS_CIPHER_MODE_CBC)
1000 NULL,
1001#endif
1002#if defined(MBEDTLS_CIPHER_MODE_CFB)
1003 NULL,
1004#endif
1005#if defined(MBEDTLS_CIPHER_MODE_OFB)
1006 NULL,
1007#endif
1008#if defined(MBEDTLS_CIPHER_MODE_CTR)
1009 NULL,
1010#endif
1011#if defined(MBEDTLS_CIPHER_MODE_XTS)
1012 NULL,
1013#endif
1014#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1015 NULL,
1016#endif
1017 gcm_camellia_setkey_wrap,
1018 gcm_camellia_setkey_wrap,
1019 gcm_ctx_alloc,
1020 gcm_ctx_free,
1021};
1022
1023static const mbedtls_cipher_info_t camellia_128_gcm_info = {
1026 128,
1027 "CAMELLIA-128-GCM",
1028 12,
1030 16,
1031 &gcm_camellia_info
1032};
1033
1034static const mbedtls_cipher_info_t camellia_192_gcm_info = {
1037 192,
1038 "CAMELLIA-192-GCM",
1039 12,
1041 16,
1042 &gcm_camellia_info
1043};
1044
1045static const mbedtls_cipher_info_t camellia_256_gcm_info = {
1048 256,
1049 "CAMELLIA-256-GCM",
1050 12,
1052 16,
1053 &gcm_camellia_info
1054};
1055#endif /* MBEDTLS_GCM_C */
1056
1057#if defined(MBEDTLS_CCM_C)
1058static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
1059 unsigned int key_bitlen )
1060{
1062 key, key_bitlen );
1063}
1064
1065static const mbedtls_cipher_base_t ccm_camellia_info = {
1067 NULL,
1068#if defined(MBEDTLS_CIPHER_MODE_CBC)
1069 NULL,
1070#endif
1071#if defined(MBEDTLS_CIPHER_MODE_CFB)
1072 NULL,
1073#endif
1074#if defined(MBEDTLS_CIPHER_MODE_OFB)
1075 NULL,
1076#endif
1077#if defined(MBEDTLS_CIPHER_MODE_CTR)
1078 NULL,
1079#endif
1080#if defined(MBEDTLS_CIPHER_MODE_XTS)
1081 NULL,
1082#endif
1083#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1084 NULL,
1085#endif
1086 ccm_camellia_setkey_wrap,
1087 ccm_camellia_setkey_wrap,
1088 ccm_ctx_alloc,
1089 ccm_ctx_free,
1090};
1091
1092static const mbedtls_cipher_info_t camellia_128_ccm_info = {
1095 128,
1096 "CAMELLIA-128-CCM",
1097 12,
1099 16,
1100 &ccm_camellia_info
1101};
1102
1103static const mbedtls_cipher_info_t camellia_192_ccm_info = {
1106 192,
1107 "CAMELLIA-192-CCM",
1108 12,
1110 16,
1111 &ccm_camellia_info
1112};
1113
1114static const mbedtls_cipher_info_t camellia_256_ccm_info = {
1117 256,
1118 "CAMELLIA-256-CCM",
1119 12,
1121 16,
1122 &ccm_camellia_info
1123};
1124#endif /* MBEDTLS_CCM_C */
1125
1126#endif /* MBEDTLS_CAMELLIA_C */
1127
1128#if defined(MBEDTLS_ARIA_C)
1129
1130static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
1131 const unsigned char *input, unsigned char *output )
1132{
1133 (void) operation;
1135 output );
1136}
1137
1138#if defined(MBEDTLS_CIPHER_MODE_CBC)
1139static int aria_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
1140 size_t length, unsigned char *iv,
1141 const unsigned char *input, unsigned char *output )
1142{
1144 input, output );
1145}
1146#endif /* MBEDTLS_CIPHER_MODE_CBC */
1147
1148#if defined(MBEDTLS_CIPHER_MODE_CFB)
1149static int aria_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
1150 size_t length, size_t *iv_off, unsigned char *iv,
1151 const unsigned char *input, unsigned char *output )
1152{
1154 iv_off, iv, input, output );
1155}
1156#endif /* MBEDTLS_CIPHER_MODE_CFB */
1157
1158#if defined(MBEDTLS_CIPHER_MODE_CTR)
1159static int aria_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
1160 unsigned char *nonce_counter, unsigned char *stream_block,
1161 const unsigned char *input, unsigned char *output )
1162{
1164 nonce_counter, stream_block, input, output );
1165}
1166#endif /* MBEDTLS_CIPHER_MODE_CTR */
1167
1168static int aria_setkey_dec_wrap( void *ctx, const unsigned char *key,
1169 unsigned int key_bitlen )
1170{
1171 return mbedtls_aria_setkey_dec( (mbedtls_aria_context *) ctx, key, key_bitlen );
1172}
1173
1174static int aria_setkey_enc_wrap( void *ctx, const unsigned char *key,
1175 unsigned int key_bitlen )
1176{
1177 return mbedtls_aria_setkey_enc( (mbedtls_aria_context *) ctx, key, key_bitlen );
1178}
1179
1180static void * aria_ctx_alloc( void )
1181{
1183 ctx = mbedtls_calloc( 1, sizeof( mbedtls_aria_context ) );
1184
1185 if( ctx == NULL )
1186 return( NULL );
1187
1189
1190 return( ctx );
1191}
1192
1193static void aria_ctx_free( void *ctx )
1194{
1196 mbedtls_free( ctx );
1197}
1198
1199static const mbedtls_cipher_base_t aria_info = {
1201 aria_crypt_ecb_wrap,
1202#if defined(MBEDTLS_CIPHER_MODE_CBC)
1203 aria_crypt_cbc_wrap,
1204#endif
1205#if defined(MBEDTLS_CIPHER_MODE_CFB)
1206 aria_crypt_cfb128_wrap,
1207#endif
1208#if defined(MBEDTLS_CIPHER_MODE_OFB)
1209 NULL,
1210#endif
1211#if defined(MBEDTLS_CIPHER_MODE_CTR)
1212 aria_crypt_ctr_wrap,
1213#endif
1214#if defined(MBEDTLS_CIPHER_MODE_XTS)
1215 NULL,
1216#endif
1217#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1218 NULL,
1219#endif
1220 aria_setkey_enc_wrap,
1221 aria_setkey_dec_wrap,
1222 aria_ctx_alloc,
1223 aria_ctx_free
1224};
1225
1226static const mbedtls_cipher_info_t aria_128_ecb_info = {
1229 128,
1230 "ARIA-128-ECB",
1231 0,
1232 0,
1233 16,
1234 &aria_info
1235};
1236
1237static const mbedtls_cipher_info_t aria_192_ecb_info = {
1240 192,
1241 "ARIA-192-ECB",
1242 0,
1243 0,
1244 16,
1245 &aria_info
1246};
1247
1248static const mbedtls_cipher_info_t aria_256_ecb_info = {
1251 256,
1252 "ARIA-256-ECB",
1253 0,
1254 0,
1255 16,
1256 &aria_info
1257};
1258
1259#if defined(MBEDTLS_CIPHER_MODE_CBC)
1260static const mbedtls_cipher_info_t aria_128_cbc_info = {
1263 128,
1264 "ARIA-128-CBC",
1265 16,
1266 0,
1267 16,
1268 &aria_info
1269};
1270
1271static const mbedtls_cipher_info_t aria_192_cbc_info = {
1274 192,
1275 "ARIA-192-CBC",
1276 16,
1277 0,
1278 16,
1279 &aria_info
1280};
1281
1282static const mbedtls_cipher_info_t aria_256_cbc_info = {
1285 256,
1286 "ARIA-256-CBC",
1287 16,
1288 0,
1289 16,
1290 &aria_info
1291};
1292#endif /* MBEDTLS_CIPHER_MODE_CBC */
1293
1294#if defined(MBEDTLS_CIPHER_MODE_CFB)
1295static const mbedtls_cipher_info_t aria_128_cfb128_info = {
1298 128,
1299 "ARIA-128-CFB128",
1300 16,
1301 0,
1302 16,
1303 &aria_info
1304};
1305
1306static const mbedtls_cipher_info_t aria_192_cfb128_info = {
1309 192,
1310 "ARIA-192-CFB128",
1311 16,
1312 0,
1313 16,
1314 &aria_info
1315};
1316
1317static const mbedtls_cipher_info_t aria_256_cfb128_info = {
1320 256,
1321 "ARIA-256-CFB128",
1322 16,
1323 0,
1324 16,
1325 &aria_info
1326};
1327#endif /* MBEDTLS_CIPHER_MODE_CFB */
1328
1329#if defined(MBEDTLS_CIPHER_MODE_CTR)
1330static const mbedtls_cipher_info_t aria_128_ctr_info = {
1333 128,
1334 "ARIA-128-CTR",
1335 16,
1336 0,
1337 16,
1338 &aria_info
1339};
1340
1341static const mbedtls_cipher_info_t aria_192_ctr_info = {
1344 192,
1345 "ARIA-192-CTR",
1346 16,
1347 0,
1348 16,
1349 &aria_info
1350};
1351
1352static const mbedtls_cipher_info_t aria_256_ctr_info = {
1355 256,
1356 "ARIA-256-CTR",
1357 16,
1358 0,
1359 16,
1360 &aria_info
1361};
1362#endif /* MBEDTLS_CIPHER_MODE_CTR */
1363
1364#if defined(MBEDTLS_GCM_C)
1365static int gcm_aria_setkey_wrap( void *ctx, const unsigned char *key,
1366 unsigned int key_bitlen )
1367{
1369 key, key_bitlen );
1370}
1371
1372static const mbedtls_cipher_base_t gcm_aria_info = {
1374 NULL,
1375#if defined(MBEDTLS_CIPHER_MODE_CBC)
1376 NULL,
1377#endif
1378#if defined(MBEDTLS_CIPHER_MODE_CFB)
1379 NULL,
1380#endif
1381#if defined(MBEDTLS_CIPHER_MODE_OFB)
1382 NULL,
1383#endif
1384#if defined(MBEDTLS_CIPHER_MODE_CTR)
1385 NULL,
1386#endif
1387#if defined(MBEDTLS_CIPHER_MODE_XTS)
1388 NULL,
1389#endif
1390#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1391 NULL,
1392#endif
1393 gcm_aria_setkey_wrap,
1394 gcm_aria_setkey_wrap,
1395 gcm_ctx_alloc,
1396 gcm_ctx_free,
1397};
1398
1399static const mbedtls_cipher_info_t aria_128_gcm_info = {
1402 128,
1403 "ARIA-128-GCM",
1404 12,
1406 16,
1407 &gcm_aria_info
1408};
1409
1410static const mbedtls_cipher_info_t aria_192_gcm_info = {
1413 192,
1414 "ARIA-192-GCM",
1415 12,
1417 16,
1418 &gcm_aria_info
1419};
1420
1421static const mbedtls_cipher_info_t aria_256_gcm_info = {
1424 256,
1425 "ARIA-256-GCM",
1426 12,
1428 16,
1429 &gcm_aria_info
1430};
1431#endif /* MBEDTLS_GCM_C */
1432
1433#if defined(MBEDTLS_CCM_C)
1434static int ccm_aria_setkey_wrap( void *ctx, const unsigned char *key,
1435 unsigned int key_bitlen )
1436{
1438 key, key_bitlen );
1439}
1440
1441static const mbedtls_cipher_base_t ccm_aria_info = {
1443 NULL,
1444#if defined(MBEDTLS_CIPHER_MODE_CBC)
1445 NULL,
1446#endif
1447#if defined(MBEDTLS_CIPHER_MODE_CFB)
1448 NULL,
1449#endif
1450#if defined(MBEDTLS_CIPHER_MODE_OFB)
1451 NULL,
1452#endif
1453#if defined(MBEDTLS_CIPHER_MODE_CTR)
1454 NULL,
1455#endif
1456#if defined(MBEDTLS_CIPHER_MODE_XTS)
1457 NULL,
1458#endif
1459#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1460 NULL,
1461#endif
1462 ccm_aria_setkey_wrap,
1463 ccm_aria_setkey_wrap,
1464 ccm_ctx_alloc,
1465 ccm_ctx_free,
1466};
1467
1468static const mbedtls_cipher_info_t aria_128_ccm_info = {
1471 128,
1472 "ARIA-128-CCM",
1473 12,
1475 16,
1476 &ccm_aria_info
1477};
1478
1479static const mbedtls_cipher_info_t aria_192_ccm_info = {
1482 192,
1483 "ARIA-192-CCM",
1484 12,
1486 16,
1487 &ccm_aria_info
1488};
1489
1490static const mbedtls_cipher_info_t aria_256_ccm_info = {
1493 256,
1494 "ARIA-256-CCM",
1495 12,
1497 16,
1498 &ccm_aria_info
1499};
1500#endif /* MBEDTLS_CCM_C */
1501
1502#endif /* MBEDTLS_ARIA_C */
1503
1504#if defined(MBEDTLS_DES_C)
1505
1506static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
1507 const unsigned char *input, unsigned char *output )
1508{
1509 ((void) operation);
1510 return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output );
1511}
1512
1513static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
1514 const unsigned char *input, unsigned char *output )
1515{
1516 ((void) operation);
1518}
1519
1520#if defined(MBEDTLS_CIPHER_MODE_CBC)
1521static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
1522 unsigned char *iv, const unsigned char *input, unsigned char *output )
1523{
1525 output );
1526}
1527#endif /* MBEDTLS_CIPHER_MODE_CBC */
1528
1529#if defined(MBEDTLS_CIPHER_MODE_CBC)
1530static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
1531 unsigned char *iv, const unsigned char *input, unsigned char *output )
1532{
1534 output );
1535}
1536#endif /* MBEDTLS_CIPHER_MODE_CBC */
1537
1538static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
1539 unsigned int key_bitlen )
1540{
1541 ((void) key_bitlen);
1542
1544}
1545
1546static int des_setkey_enc_wrap( void *ctx, const unsigned char *key,
1547 unsigned int key_bitlen )
1548{
1549 ((void) key_bitlen);
1550
1552}
1553
1554static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key,
1555 unsigned int key_bitlen )
1556{
1557 ((void) key_bitlen);
1558
1560}
1561
1562static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key,
1563 unsigned int key_bitlen )
1564{
1565 ((void) key_bitlen);
1566
1568}
1569
1570static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key,
1571 unsigned int key_bitlen )
1572{
1573 ((void) key_bitlen);
1574
1576}
1577
1578static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key,
1579 unsigned int key_bitlen )
1580{
1581 ((void) key_bitlen);
1582
1584}
1585
1586static void * des_ctx_alloc( void )
1587{
1589
1590 if( des == NULL )
1591 return( NULL );
1592
1593 mbedtls_des_init( des );
1594
1595 return( des );
1596}
1597
1598static void des_ctx_free( void *ctx )
1599{
1601 mbedtls_free( ctx );
1602}
1603
1604static void * des3_ctx_alloc( void )
1605{
1607 des3 = mbedtls_calloc( 1, sizeof( mbedtls_des3_context ) );
1608
1609 if( des3 == NULL )
1610 return( NULL );
1611
1612 mbedtls_des3_init( des3 );
1613
1614 return( des3 );
1615}
1616
1617static void des3_ctx_free( void *ctx )
1618{
1620 mbedtls_free( ctx );
1621}
1622
1623static const mbedtls_cipher_base_t des_info = {
1625 des_crypt_ecb_wrap,
1626#if defined(MBEDTLS_CIPHER_MODE_CBC)
1627 des_crypt_cbc_wrap,
1628#endif
1629#if defined(MBEDTLS_CIPHER_MODE_CFB)
1630 NULL,
1631#endif
1632#if defined(MBEDTLS_CIPHER_MODE_OFB)
1633 NULL,
1634#endif
1635#if defined(MBEDTLS_CIPHER_MODE_CTR)
1636 NULL,
1637#endif
1638#if defined(MBEDTLS_CIPHER_MODE_XTS)
1639 NULL,
1640#endif
1641#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1642 NULL,
1643#endif
1644 des_setkey_enc_wrap,
1645 des_setkey_dec_wrap,
1646 des_ctx_alloc,
1647 des_ctx_free
1648};
1649
1650static const mbedtls_cipher_info_t des_ecb_info = {
1654 "DES-ECB",
1655 0,
1656 0,
1657 8,
1658 &des_info
1659};
1660
1661#if defined(MBEDTLS_CIPHER_MODE_CBC)
1662static const mbedtls_cipher_info_t des_cbc_info = {
1666 "DES-CBC",
1667 8,
1668 0,
1669 8,
1670 &des_info
1671};
1672#endif /* MBEDTLS_CIPHER_MODE_CBC */
1673
1674static const mbedtls_cipher_base_t des_ede_info = {
1676 des3_crypt_ecb_wrap,
1677#if defined(MBEDTLS_CIPHER_MODE_CBC)
1678 des3_crypt_cbc_wrap,
1679#endif
1680#if defined(MBEDTLS_CIPHER_MODE_CFB)
1681 NULL,
1682#endif
1683#if defined(MBEDTLS_CIPHER_MODE_OFB)
1684 NULL,
1685#endif
1686#if defined(MBEDTLS_CIPHER_MODE_CTR)
1687 NULL,
1688#endif
1689#if defined(MBEDTLS_CIPHER_MODE_XTS)
1690 NULL,
1691#endif
1692#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1693 NULL,
1694#endif
1695 des3_set2key_enc_wrap,
1696 des3_set2key_dec_wrap,
1697 des3_ctx_alloc,
1698 des3_ctx_free
1699};
1700
1701static const mbedtls_cipher_info_t des_ede_ecb_info = {
1705 "DES-EDE-ECB",
1706 0,
1707 0,
1708 8,
1709 &des_ede_info
1710};
1711
1712#if defined(MBEDTLS_CIPHER_MODE_CBC)
1713static const mbedtls_cipher_info_t des_ede_cbc_info = {
1717 "DES-EDE-CBC",
1718 8,
1719 0,
1720 8,
1721 &des_ede_info
1722};
1723#endif /* MBEDTLS_CIPHER_MODE_CBC */
1724
1725static const mbedtls_cipher_base_t des_ede3_info = {
1727 des3_crypt_ecb_wrap,
1728#if defined(MBEDTLS_CIPHER_MODE_CBC)
1729 des3_crypt_cbc_wrap,
1730#endif
1731#if defined(MBEDTLS_CIPHER_MODE_CFB)
1732 NULL,
1733#endif
1734#if defined(MBEDTLS_CIPHER_MODE_OFB)
1735 NULL,
1736#endif
1737#if defined(MBEDTLS_CIPHER_MODE_CTR)
1738 NULL,
1739#endif
1740#if defined(MBEDTLS_CIPHER_MODE_XTS)
1741 NULL,
1742#endif
1743#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1744 NULL,
1745#endif
1746 des3_set3key_enc_wrap,
1747 des3_set3key_dec_wrap,
1748 des3_ctx_alloc,
1749 des3_ctx_free
1750};
1751
1752static const mbedtls_cipher_info_t des_ede3_ecb_info = {
1756 "DES-EDE3-ECB",
1757 0,
1758 0,
1759 8,
1760 &des_ede3_info
1761};
1762#if defined(MBEDTLS_CIPHER_MODE_CBC)
1763static const mbedtls_cipher_info_t des_ede3_cbc_info = {
1767 "DES-EDE3-CBC",
1768 8,
1769 0,
1770 8,
1771 &des_ede3_info
1772};
1773#endif /* MBEDTLS_CIPHER_MODE_CBC */
1774#endif /* MBEDTLS_DES_C */
1775
1776#if defined(MBEDTLS_BLOWFISH_C)
1777
1778static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
1779 const unsigned char *input, unsigned char *output )
1780{
1782 output );
1783}
1784
1785#if defined(MBEDTLS_CIPHER_MODE_CBC)
1786static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
1787 size_t length, unsigned char *iv, const unsigned char *input,
1788 unsigned char *output )
1789{
1791 input, output );
1792}
1793#endif /* MBEDTLS_CIPHER_MODE_CBC */
1794
1795#if defined(MBEDTLS_CIPHER_MODE_CFB)
1796static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation,
1797 size_t length, size_t *iv_off, unsigned char *iv,
1798 const unsigned char *input, unsigned char *output )
1799{
1801 iv_off, iv, input, output );
1802}
1803#endif /* MBEDTLS_CIPHER_MODE_CFB */
1804
1805#if defined(MBEDTLS_CIPHER_MODE_CTR)
1806static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
1807 unsigned char *nonce_counter, unsigned char *stream_block,
1808 const unsigned char *input, unsigned char *output )
1809{
1811 nonce_counter, stream_block, input, output );
1812}
1813#endif /* MBEDTLS_CIPHER_MODE_CTR */
1814
1815static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
1816 unsigned int key_bitlen )
1817{
1818 return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_bitlen );
1819}
1820
1821static void * blowfish_ctx_alloc( void )
1822{
1825
1826 if( ctx == NULL )
1827 return( NULL );
1828
1830
1831 return( ctx );
1832}
1833
1834static void blowfish_ctx_free( void *ctx )
1835{
1837 mbedtls_free( ctx );
1838}
1839
1840static const mbedtls_cipher_base_t blowfish_info = {
1842 blowfish_crypt_ecb_wrap,
1843#if defined(MBEDTLS_CIPHER_MODE_CBC)
1844 blowfish_crypt_cbc_wrap,
1845#endif
1846#if defined(MBEDTLS_CIPHER_MODE_CFB)
1847 blowfish_crypt_cfb64_wrap,
1848#endif
1849#if defined(MBEDTLS_CIPHER_MODE_OFB)
1850 NULL,
1851#endif
1852#if defined(MBEDTLS_CIPHER_MODE_CTR)
1853 blowfish_crypt_ctr_wrap,
1854#endif
1855#if defined(MBEDTLS_CIPHER_MODE_XTS)
1856 NULL,
1857#endif
1858#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1859 NULL,
1860#endif
1861 blowfish_setkey_wrap,
1862 blowfish_setkey_wrap,
1863 blowfish_ctx_alloc,
1864 blowfish_ctx_free
1865};
1866
1867static const mbedtls_cipher_info_t blowfish_ecb_info = {
1870 128,
1871 "BLOWFISH-ECB",
1872 0,
1874 8,
1875 &blowfish_info
1876};
1877
1878#if defined(MBEDTLS_CIPHER_MODE_CBC)
1879static const mbedtls_cipher_info_t blowfish_cbc_info = {
1882 128,
1883 "BLOWFISH-CBC",
1884 8,
1886 8,
1887 &blowfish_info
1888};
1889#endif /* MBEDTLS_CIPHER_MODE_CBC */
1890
1891#if defined(MBEDTLS_CIPHER_MODE_CFB)
1892static const mbedtls_cipher_info_t blowfish_cfb64_info = {
1895 128,
1896 "BLOWFISH-CFB64",
1897 8,
1899 8,
1900 &blowfish_info
1901};
1902#endif /* MBEDTLS_CIPHER_MODE_CFB */
1903
1904#if defined(MBEDTLS_CIPHER_MODE_CTR)
1905static const mbedtls_cipher_info_t blowfish_ctr_info = {
1908 128,
1909 "BLOWFISH-CTR",
1910 8,
1912 8,
1913 &blowfish_info
1914};
1915#endif /* MBEDTLS_CIPHER_MODE_CTR */
1916#endif /* MBEDTLS_BLOWFISH_C */
1917
1918#if defined(MBEDTLS_ARC4_C)
1919static int arc4_crypt_stream_wrap( void *ctx, size_t length,
1920 const unsigned char *input,
1921 unsigned char *output )
1922{
1923 return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) );
1924}
1925
1926static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
1927 unsigned int key_bitlen )
1928{
1929 /* we get key_bitlen in bits, arc4 expects it in bytes */
1930 if( key_bitlen % 8 != 0 )
1932
1933 mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_bitlen / 8 );
1934 return( 0 );
1935}
1936
1937static void * arc4_ctx_alloc( void )
1938{
1940 ctx = mbedtls_calloc( 1, sizeof( mbedtls_arc4_context ) );
1941
1942 if( ctx == NULL )
1943 return( NULL );
1944
1946
1947 return( ctx );
1948}
1949
1950static void arc4_ctx_free( void *ctx )
1951{
1953 mbedtls_free( ctx );
1954}
1955
1956static const mbedtls_cipher_base_t arc4_base_info = {
1958 NULL,
1959#if defined(MBEDTLS_CIPHER_MODE_CBC)
1960 NULL,
1961#endif
1962#if defined(MBEDTLS_CIPHER_MODE_CFB)
1963 NULL,
1964#endif
1965#if defined(MBEDTLS_CIPHER_MODE_OFB)
1966 NULL,
1967#endif
1968#if defined(MBEDTLS_CIPHER_MODE_CTR)
1969 NULL,
1970#endif
1971#if defined(MBEDTLS_CIPHER_MODE_XTS)
1972 NULL,
1973#endif
1974#if defined(MBEDTLS_CIPHER_MODE_STREAM)
1975 arc4_crypt_stream_wrap,
1976#endif
1977 arc4_setkey_wrap,
1978 arc4_setkey_wrap,
1979 arc4_ctx_alloc,
1980 arc4_ctx_free
1981};
1982
1983static const mbedtls_cipher_info_t arc4_128_info = {
1986 128,
1987 "ARC4-128",
1988 0,
1989 0,
1990 1,
1991 &arc4_base_info
1992};
1993#endif /* MBEDTLS_ARC4_C */
1994
1995#if defined(MBEDTLS_CHACHA20_C)
1996
1997static int chacha20_setkey_wrap( void *ctx, const unsigned char *key,
1998 unsigned int key_bitlen )
1999{
2000 if( key_bitlen != 256U )
2002
2005
2006 return( 0 );
2007}
2008
2009static int chacha20_stream_wrap( void *ctx, size_t length,
2010 const unsigned char *input,
2011 unsigned char *output )
2012{
2013 int ret;
2014
2018
2019 return( ret );
2020}
2021
2022static void * chacha20_ctx_alloc( void )
2023{
2026
2027 if( ctx == NULL )
2028 return( NULL );
2029
2031
2032 return( ctx );
2033}
2034
2035static void chacha20_ctx_free( void *ctx )
2036{
2038 mbedtls_free( ctx );
2039}
2040
2041static const mbedtls_cipher_base_t chacha20_base_info = {
2043 NULL,
2044#if defined(MBEDTLS_CIPHER_MODE_CBC)
2045 NULL,
2046#endif
2047#if defined(MBEDTLS_CIPHER_MODE_CFB)
2048 NULL,
2049#endif
2050#if defined(MBEDTLS_CIPHER_MODE_OFB)
2051 NULL,
2052#endif
2053#if defined(MBEDTLS_CIPHER_MODE_CTR)
2054 NULL,
2055#endif
2056#if defined(MBEDTLS_CIPHER_MODE_XTS)
2057 NULL,
2058#endif
2059#if defined(MBEDTLS_CIPHER_MODE_STREAM)
2060 chacha20_stream_wrap,
2061#endif
2062 chacha20_setkey_wrap,
2063 chacha20_setkey_wrap,
2064 chacha20_ctx_alloc,
2065 chacha20_ctx_free
2066};
2067static const mbedtls_cipher_info_t chacha20_info = {
2070 256,
2071 "CHACHA20",
2072 12,
2073 0,
2074 1,
2075 &chacha20_base_info
2076};
2077#endif /* MBEDTLS_CHACHA20_C */
2078
2079#if defined(MBEDTLS_CHACHAPOLY_C)
2080
2081static int chachapoly_setkey_wrap( void *ctx,
2082 const unsigned char *key,
2083 unsigned int key_bitlen )
2084{
2085 if( key_bitlen != 256U )
2087
2090
2091 return( 0 );
2092}
2093
2094static void * chachapoly_ctx_alloc( void )
2095{
2098
2099 if( ctx == NULL )
2100 return( NULL );
2101
2103
2104 return( ctx );
2105}
2106
2107static void chachapoly_ctx_free( void *ctx )
2108{
2110 mbedtls_free( ctx );
2111}
2112
2113static const mbedtls_cipher_base_t chachapoly_base_info = {
2115 NULL,
2116#if defined(MBEDTLS_CIPHER_MODE_CBC)
2117 NULL,
2118#endif
2119#if defined(MBEDTLS_CIPHER_MODE_CFB)
2120 NULL,
2121#endif
2122#if defined(MBEDTLS_CIPHER_MODE_OFB)
2123 NULL,
2124#endif
2125#if defined(MBEDTLS_CIPHER_MODE_CTR)
2126 NULL,
2127#endif
2128#if defined(MBEDTLS_CIPHER_MODE_XTS)
2129 NULL,
2130#endif
2131#if defined(MBEDTLS_CIPHER_MODE_STREAM)
2132 NULL,
2133#endif
2134 chachapoly_setkey_wrap,
2135 chachapoly_setkey_wrap,
2136 chachapoly_ctx_alloc,
2137 chachapoly_ctx_free
2138};
2139static const mbedtls_cipher_info_t chachapoly_info = {
2142 256,
2143 "CHACHA20-POLY1305",
2144 12,
2145 0,
2146 1,
2147 &chachapoly_base_info
2148};
2149#endif /* MBEDTLS_CHACHAPOLY_C */
2150
2151#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
2152static int null_crypt_stream( void *ctx, size_t length,
2153 const unsigned char *input,
2154 unsigned char *output )
2155{
2156 ((void) ctx);
2157 memmove( output, input, length );
2158 return( 0 );
2159}
2160
2161static int null_setkey( void *ctx, const unsigned char *key,
2162 unsigned int key_bitlen )
2163{
2164 ((void) ctx);
2165 ((void) key);
2166 ((void) key_bitlen);
2167
2168 return( 0 );
2169}
2170
2171static void * null_ctx_alloc( void )
2172{
2173 return( (void *) 1 );
2174}
2175
2176static void null_ctx_free( void *ctx )
2177{
2178 ((void) ctx);
2179}
2180
2181static const mbedtls_cipher_base_t null_base_info = {
2183 NULL,
2184#if defined(MBEDTLS_CIPHER_MODE_CBC)
2185 NULL,
2186#endif
2187#if defined(MBEDTLS_CIPHER_MODE_CFB)
2188 NULL,
2189#endif
2190#if defined(MBEDTLS_CIPHER_MODE_OFB)
2191 NULL,
2192#endif
2193#if defined(MBEDTLS_CIPHER_MODE_CTR)
2194 NULL,
2195#endif
2196#if defined(MBEDTLS_CIPHER_MODE_XTS)
2197 NULL,
2198#endif
2199#if defined(MBEDTLS_CIPHER_MODE_STREAM)
2200 null_crypt_stream,
2201#endif
2202 null_setkey,
2203 null_setkey,
2204 null_ctx_alloc,
2205 null_ctx_free
2206};
2207
2208static const mbedtls_cipher_info_t null_cipher_info = {
2211 0,
2212 "NULL",
2213 0,
2214 0,
2215 1,
2216 &null_base_info
2217};
2218#endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */
2219
2221{
2222#if defined(MBEDTLS_AES_C)
2223 { MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info },
2224 { MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info },
2225 { MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info },
2226#if defined(MBEDTLS_CIPHER_MODE_CBC)
2227 { MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info },
2228 { MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info },
2229 { MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info },
2230#endif
2231#if defined(MBEDTLS_CIPHER_MODE_CFB)
2232#ifdef __REACTOS__
2233 { MBEDTLS_CIPHER_AES_128_CFB8, &aes_128_cfb8_info },
2234 { MBEDTLS_CIPHER_AES_192_CFB8, &aes_192_cfb8_info },
2235 { MBEDTLS_CIPHER_AES_256_CFB8, &aes_256_cfb8_info },
2236#endif
2237 { MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info },
2238 { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info },
2239 { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info },
2240#endif
2241#if defined(MBEDTLS_CIPHER_MODE_OFB)
2242 { MBEDTLS_CIPHER_AES_128_OFB, &aes_128_ofb_info },
2243 { MBEDTLS_CIPHER_AES_192_OFB, &aes_192_ofb_info },
2244 { MBEDTLS_CIPHER_AES_256_OFB, &aes_256_ofb_info },
2245#endif
2246#if defined(MBEDTLS_CIPHER_MODE_CTR)
2247 { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info },
2248 { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info },
2249 { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info },
2250#endif
2251#if defined(MBEDTLS_CIPHER_MODE_XTS)
2252 { MBEDTLS_CIPHER_AES_128_XTS, &aes_128_xts_info },
2253 { MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info },
2254#endif
2255#if defined(MBEDTLS_GCM_C)
2256 { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info },
2257 { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info },
2258 { MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info },
2259#endif
2260#if defined(MBEDTLS_CCM_C)
2261 { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info },
2262 { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info },
2263 { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info },
2264#endif
2265#endif /* MBEDTLS_AES_C */
2266
2267#if defined(MBEDTLS_ARC4_C)
2268 { MBEDTLS_CIPHER_ARC4_128, &arc4_128_info },
2269#endif
2270
2271#if defined(MBEDTLS_BLOWFISH_C)
2272 { MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info },
2273#if defined(MBEDTLS_CIPHER_MODE_CBC)
2274 { MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info },
2275#endif
2276#if defined(MBEDTLS_CIPHER_MODE_CFB)
2277 { MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info },
2278#endif
2279#if defined(MBEDTLS_CIPHER_MODE_CTR)
2280 { MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info },
2281#endif
2282#endif /* MBEDTLS_BLOWFISH_C */
2283
2284#if defined(MBEDTLS_CAMELLIA_C)
2285 { MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info },
2286 { MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info },
2287 { MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info },
2288#if defined(MBEDTLS_CIPHER_MODE_CBC)
2289 { MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info },
2290 { MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info },
2291 { MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info },
2292#endif
2293#if defined(MBEDTLS_CIPHER_MODE_CFB)
2294 { MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info },
2295 { MBEDTLS_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info },
2296 { MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info },
2297#endif
2298#if defined(MBEDTLS_CIPHER_MODE_CTR)
2299 { MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info },
2300 { MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info },
2301 { MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info },
2302#endif
2303#if defined(MBEDTLS_GCM_C)
2304 { MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info },
2305 { MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info },
2306 { MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info },
2307#endif
2308#if defined(MBEDTLS_CCM_C)
2309 { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info },
2310 { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info },
2311 { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info },
2312#endif
2313#endif /* MBEDTLS_CAMELLIA_C */
2314
2315#if defined(MBEDTLS_ARIA_C)
2316 { MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info },
2317 { MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info },
2318 { MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info },
2319#if defined(MBEDTLS_CIPHER_MODE_CBC)
2320 { MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info },
2321 { MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info },
2322 { MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info },
2323#endif
2324#if defined(MBEDTLS_CIPHER_MODE_CFB)
2325 { MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info },
2326 { MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info },
2327 { MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info },
2328#endif
2329#if defined(MBEDTLS_CIPHER_MODE_CTR)
2330 { MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info },
2331 { MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info },
2332 { MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info },
2333#endif
2334#if defined(MBEDTLS_GCM_C)
2335 { MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info },
2336 { MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info },
2337 { MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info },
2338#endif
2339#if defined(MBEDTLS_CCM_C)
2340 { MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info },
2341 { MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info },
2342 { MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info },
2343#endif
2344#endif /* MBEDTLS_ARIA_C */
2345
2346#if defined(MBEDTLS_DES_C)
2347 { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info },
2348 { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info },
2349 { MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info },
2350#if defined(MBEDTLS_CIPHER_MODE_CBC)
2351 { MBEDTLS_CIPHER_DES_CBC, &des_cbc_info },
2352 { MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info },
2353 { MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info },
2354#endif
2355#endif /* MBEDTLS_DES_C */
2356
2357#if defined(MBEDTLS_CHACHA20_C)
2358 { MBEDTLS_CIPHER_CHACHA20, &chacha20_info },
2359#endif
2360
2361#if defined(MBEDTLS_CHACHAPOLY_C)
2362 { MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info },
2363#endif
2364
2365#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
2366 { MBEDTLS_CIPHER_NULL, &null_cipher_info },
2367#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
2368
2370};
2371
2372#define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0]
2373int mbedtls_cipher_supported[NUM_CIPHERS];
2374
2375#endif /* MBEDTLS_CIPHER_C */
This file contains AES definitions and functions.
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
This function performs an AES single-block encryption or decryption operation.
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
void mbedtls_aes_xts_init(mbedtls_aes_xts_context *ctx)
This function initializes the specified AES XTS context.
int mbedtls_aes_crypt_ofb(mbedtls_aes_context *ctx, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-OFB (Output Feedback Mode) encryption or decryption operation.
int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CBC encryption or decryption operation on full blocks.
int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CTR encryption or decryption operation.
int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits)
This function prepares an XTS context for decryption and sets the decryption key.
int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context *ctx, int mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output)
This function performs an AES-XTS encryption or decryption operation for an entire XTS data unit.
void mbedtls_aes_xts_free(mbedtls_aes_xts_context *ctx)
This function releases and clears the specified AES XTS context.
int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CFB128 encryption or decryption operation.
int mbedtls_aes_crypt_cfb8(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CFB8 encryption or decryption operation.
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
#define MBEDTLS_AES_DECRYPT
Definition: aes.h:81
#define MBEDTLS_AES_ENCRYPT
Definition: aes.h:80
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the encryption key.
void mbedtls_aes_free(mbedtls_aes_context *ctx)
This function releases and clears the specified AES context.
int mbedtls_aes_xts_setkey_enc(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits)
This function prepares an XTS context for encryption and sets the encryption key.
ARIA block cipher.
int mbedtls_aria_crypt_cbc(mbedtls_aria_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output)
This function performs an ARIA-CBC encryption or decryption operation on full blocks.
int mbedtls_aria_crypt_cfb128(mbedtls_aria_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output)
This function performs an ARIA-CFB128 encryption or decryption operation.
void mbedtls_aria_init(mbedtls_aria_context *ctx)
This function initializes the specified ARIA context.
int mbedtls_aria_setkey_dec(mbedtls_aria_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
int mbedtls_aria_crypt_ecb(mbedtls_aria_context *ctx, const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], unsigned char output[MBEDTLS_ARIA_BLOCKSIZE])
This function performs an ARIA single-block encryption or decryption operation.
void mbedtls_aria_free(mbedtls_aria_context *ctx)
This function releases and clears the specified ARIA context.
int mbedtls_aria_setkey_enc(mbedtls_aria_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the encryption key.
int mbedtls_aria_crypt_ctr(mbedtls_aria_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE], unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char *input, unsigned char *output)
This function performs an ARIA-CTR encryption or decryption operation.
operation
Definition: copy.c:29
Blowfish block cipher.
int mbedtls_blowfish_crypt_cbc(mbedtls_blowfish_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Perform a Blowfish-CBC buffer encryption/decryption operation.
int mbedtls_blowfish_setkey(mbedtls_blowfish_context *ctx, const unsigned char *key, unsigned int keybits)
Perform a Blowfish key schedule operation.
int mbedtls_blowfish_crypt_ctr(mbedtls_blowfish_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Perform a Blowfish-CTR buffer encryption/decryption operation.
void mbedtls_blowfish_init(mbedtls_blowfish_context *ctx)
Initialize a Blowfish context.
void mbedtls_blowfish_free(mbedtls_blowfish_context *ctx)
Clear a Blowfish context.
int mbedtls_blowfish_crypt_cfb64(mbedtls_blowfish_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Perform a Blowfish CFB buffer encryption/decryption operation.
int mbedtls_blowfish_crypt_ecb(mbedtls_blowfish_context *ctx, int mode, const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE])
Perform a Blowfish-ECB block encryption/decryption operation.
Camellia block cipher.
int mbedtls_camellia_setkey_enc(mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits)
Perform a CAMELLIA key schedule operation for encryption.
int mbedtls_camellia_crypt_ecb(mbedtls_camellia_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
Perform a CAMELLIA-ECB block encryption/decryption operation.
int mbedtls_camellia_setkey_dec(mbedtls_camellia_context *ctx, const unsigned char *key, unsigned int keybits)
Perform a CAMELLIA key schedule operation for decryption.
int mbedtls_camellia_crypt_cbc(mbedtls_camellia_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
Perform a CAMELLIA-CBC buffer encryption/decryption operation.
void mbedtls_camellia_init(mbedtls_camellia_context *ctx)
Initialize a CAMELLIA context.
void mbedtls_camellia_free(mbedtls_camellia_context *ctx)
Clear a CAMELLIA context.
int mbedtls_camellia_crypt_ctr(mbedtls_camellia_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
Perform a CAMELLIA-CTR buffer encryption/decryption operation.
int mbedtls_camellia_crypt_cfb128(mbedtls_camellia_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
Perform a CAMELLIA-CFB128 buffer encryption/decryption operation.
This file provides an API for the CCM authenticated encryption mode for block ciphers.
void mbedtls_ccm_free(mbedtls_ccm_context *ctx)
This function releases and clears the specified CCM context and underlying cipher sub-context.
int mbedtls_ccm_setkey(mbedtls_ccm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits)
This function initializes the CCM context set in the ctx parameter and sets the encryption key.
void mbedtls_ccm_init(mbedtls_ccm_context *ctx)
This function initializes the specified CCM context, to make references valid, and prepare the contex...
This file contains ChaCha20 definitions and functions.
void mbedtls_chacha20_free(mbedtls_chacha20_context *ctx)
This function releases and clears the specified ChaCha20 context.
int mbedtls_chacha20_setkey(mbedtls_chacha20_context *ctx, const unsigned char key[32])
This function sets the encryption/decryption key.
void mbedtls_chacha20_init(mbedtls_chacha20_context *ctx)
This function initializes the specified ChaCha20 context.
#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA
Definition: chacha20.h:71
int mbedtls_chacha20_update(mbedtls_chacha20_context *ctx, size_t size, const unsigned char *input, unsigned char *output)
This function encrypts or decrypts data.
This file contains the AEAD-ChaCha20-Poly1305 definitions and functions.
void mbedtls_chachapoly_init(mbedtls_chachapoly_context *ctx)
This function initializes the specified ChaCha20-Poly1305 context.
int mbedtls_chachapoly_setkey(mbedtls_chachapoly_context *ctx, const unsigned char key[32])
This function sets the ChaCha20-Poly1305 symmetric encryption key.
void mbedtls_chachapoly_free(mbedtls_chachapoly_context *ctx)
This function releases and clears the specified ChaCha20-Poly1305 context.
@ MBEDTLS_CIPHER_AES_128_ECB
Definition: cipher.h:132
@ MBEDTLS_CIPHER_ARIA_256_CTR
Definition: cipher.h:195
@ MBEDTLS_CIPHER_CAMELLIA_128_GCM
Definition: cipher.h:164
@ MBEDTLS_CIPHER_AES_128_XTS
Definition: cipher.h:205
@ MBEDTLS_CIPHER_CHACHA20
Definition: cipher.h:207
@ MBEDTLS_CIPHER_DES_EDE3_CBC
Definition: cipher.h:172
@ MBEDTLS_CIPHER_DES_ECB
Definition: cipher.h:167
@ MBEDTLS_CIPHER_ARIA_128_GCM
Definition: cipher.h:196
@ MBEDTLS_CIPHER_AES_128_CBC
Definition: cipher.h:135
@ MBEDTLS_CIPHER_AES_192_GCM
Definition: cipher.h:150
@ MBEDTLS_CIPHER_BLOWFISH_CTR
Definition: cipher.h:176
@ MBEDTLS_CIPHER_AES_128_OFB
Definition: cipher.h:202
@ MBEDTLS_CIPHER_ARIA_192_ECB
Definition: cipher.h:185
@ MBEDTLS_CIPHER_CAMELLIA_256_GCM
Definition: cipher.h:166
@ MBEDTLS_CIPHER_DES_EDE_ECB
Definition: cipher.h:169
@ MBEDTLS_CIPHER_BLOWFISH_CFB64
Definition: cipher.h:175
@ MBEDTLS_CIPHER_ARIA_256_CFB128
Definition: cipher.h:192
@ MBEDTLS_CIPHER_ARIA_192_CBC
Definition: cipher.h:188
@ MBEDTLS_CIPHER_CAMELLIA_192_CBC
Definition: cipher.h:156
@ MBEDTLS_CIPHER_ARIA_128_CTR
Definition: cipher.h:193
@ MBEDTLS_CIPHER_ARIA_192_CCM
Definition: cipher.h:200
@ MBEDTLS_CIPHER_CAMELLIA_192_GCM
Definition: cipher.h:165
@ MBEDTLS_CIPHER_AES_192_OFB
Definition: cipher.h:203
@ MBEDTLS_CIPHER_AES_256_ECB
Definition: cipher.h:134
@ MBEDTLS_CIPHER_AES_256_CTR
Definition: cipher.h:148
@ MBEDTLS_CIPHER_AES_192_CCM
Definition: cipher.h:179
@ MBEDTLS_CIPHER_AES_128_CFB128
Definition: cipher.h:143
@ MBEDTLS_CIPHER_CAMELLIA_192_CFB128
Definition: cipher.h:159
@ MBEDTLS_CIPHER_CAMELLIA_128_CCM
Definition: cipher.h:181
@ MBEDTLS_CIPHER_AES_128_CTR
Definition: cipher.h:146
@ MBEDTLS_CIPHER_ARIA_192_GCM
Definition: cipher.h:197
@ MBEDTLS_CIPHER_AES_256_XTS
Definition: cipher.h:206
@ MBEDTLS_CIPHER_AES_192_CFB128
Definition: cipher.h:144
@ MBEDTLS_CIPHER_ARIA_256_ECB
Definition: cipher.h:186
@ MBEDTLS_CIPHER_CAMELLIA_256_CCM
Definition: cipher.h:183
@ MBEDTLS_CIPHER_AES_256_GCM
Definition: cipher.h:151
@ MBEDTLS_CIPHER_DES_CBC
Definition: cipher.h:168
@ MBEDTLS_CIPHER_CAMELLIA_128_CFB128
Definition: cipher.h:158
@ MBEDTLS_CIPHER_CAMELLIA_128_CBC
Definition: cipher.h:155
@ MBEDTLS_CIPHER_AES_256_CCM
Definition: cipher.h:180
@ MBEDTLS_CIPHER_CAMELLIA_256_CFB128
Definition: cipher.h:160
@ MBEDTLS_CIPHER_ARIA_192_CTR
Definition: cipher.h:194
@ MBEDTLS_CIPHER_BLOWFISH_CBC
Definition: cipher.h:174
@ MBEDTLS_CIPHER_CAMELLIA_256_ECB
Definition: cipher.h:154
@ MBEDTLS_CIPHER_AES_128_GCM
Definition: cipher.h:149
@ MBEDTLS_CIPHER_CAMELLIA_192_ECB
Definition: cipher.h:153
@ MBEDTLS_CIPHER_AES_256_CFB128
Definition: cipher.h:145
@ MBEDTLS_CIPHER_NONE
Definition: cipher.h:130
@ MBEDTLS_CIPHER_CHACHA20_POLY1305
Definition: cipher.h:208
@ MBEDTLS_CIPHER_CAMELLIA_128_ECB
Definition: cipher.h:152
@ MBEDTLS_CIPHER_AES_192_CBC
Definition: cipher.h:136
@ MBEDTLS_CIPHER_CAMELLIA_192_CCM
Definition: cipher.h:182
@ MBEDTLS_CIPHER_ARIA_128_CCM
Definition: cipher.h:199
@ MBEDTLS_CIPHER_AES_192_CTR
Definition: cipher.h:147
@ MBEDTLS_CIPHER_AES_128_CCM
Definition: cipher.h:178
@ MBEDTLS_CIPHER_DES_EDE_CBC
Definition: cipher.h:170
@ MBEDTLS_CIPHER_NULL
Definition: cipher.h:131
@ MBEDTLS_CIPHER_ARIA_256_CBC
Definition: cipher.h:189
@ MBEDTLS_CIPHER_AES_256_OFB
Definition: cipher.h:204
@ MBEDTLS_CIPHER_ARIA_192_CFB128
Definition: cipher.h:191
@ MBEDTLS_CIPHER_CAMELLIA_128_CTR
Definition: cipher.h:161
@ MBEDTLS_CIPHER_BLOWFISH_ECB
Definition: cipher.h:173
@ MBEDTLS_CIPHER_AES_256_CBC
Definition: cipher.h:137
@ MBEDTLS_CIPHER_ARC4_128
Definition: cipher.h:177
@ MBEDTLS_CIPHER_CAMELLIA_192_CTR
Definition: cipher.h:162
@ MBEDTLS_CIPHER_AES_192_ECB
Definition: cipher.h:133
@ MBEDTLS_CIPHER_ARIA_256_GCM
Definition: cipher.h:198
@ MBEDTLS_CIPHER_DES_EDE3_ECB
Definition: cipher.h:171
@ MBEDTLS_CIPHER_ARIA_128_CBC
Definition: cipher.h:187
@ MBEDTLS_CIPHER_CAMELLIA_256_CTR
Definition: cipher.h:163
@ MBEDTLS_CIPHER_ARIA_128_ECB
Definition: cipher.h:184
@ MBEDTLS_CIPHER_CAMELLIA_256_CBC
Definition: cipher.h:157
@ MBEDTLS_CIPHER_ARIA_256_CCM
Definition: cipher.h:201
@ MBEDTLS_CIPHER_ARIA_128_CFB128
Definition: cipher.h:190
@ MBEDTLS_KEY_LENGTH_DES
Definition: cipher.h:246
@ MBEDTLS_KEY_LENGTH_DES_EDE
Definition: cipher.h:248
@ MBEDTLS_KEY_LENGTH_DES_EDE3
Definition: cipher.h:250
#define MBEDTLS_CIPHER_VARIABLE_IV_LEN
Definition: cipher.h:95
#define MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
Definition: cipher.h:85
#define MBEDTLS_CIPHER_VARIABLE_KEY_LEN
Definition: cipher.h:96
mbedtls_operation_t
Definition: cipher.h:236
@ MBEDTLS_DECRYPT
Definition: cipher.h:238
@ MBEDTLS_ENCRYPT
Definition: cipher.h:239
@ MBEDTLS_MODE_ECB
Definition: cipher.h:214
@ MBEDTLS_MODE_CCM
Definition: cipher.h:221
@ MBEDTLS_MODE_STREAM
Definition: cipher.h:220
@ MBEDTLS_MODE_CFB
Definition: cipher.h:216
@ MBEDTLS_MODE_CTR
Definition: cipher.h:218
@ MBEDTLS_MODE_GCM
Definition: cipher.h:219
@ MBEDTLS_MODE_CBC
Definition: cipher.h:215
@ MBEDTLS_MODE_OFB
Definition: cipher.h:217
@ MBEDTLS_MODE_CHACHAPOLY
Definition: cipher.h:223
@ MBEDTLS_MODE_XTS
Definition: cipher.h:222
@ MBEDTLS_CIPHER_ID_3DES
Definition: cipher.h:114
@ MBEDTLS_CIPHER_ID_CAMELLIA
Definition: cipher.h:115
@ MBEDTLS_CIPHER_ID_DES
Definition: cipher.h:113
@ MBEDTLS_CIPHER_ID_ARC4
Definition: cipher.h:117
@ MBEDTLS_CIPHER_ID_NULL
Definition: cipher.h:111
@ MBEDTLS_CIPHER_ID_AES
Definition: cipher.h:112
@ MBEDTLS_CIPHER_ID_ARIA
Definition: cipher.h:118
@ MBEDTLS_CIPHER_ID_CHACHA20
Definition: cipher.h:119
@ MBEDTLS_CIPHER_ID_BLOWFISH
Definition: cipher.h:116
Cipher wrappers.
const mbedtls_cipher_definition_t mbedtls_cipher_definitions[]
int mbedtls_cipher_supported[]
#define NULL
Definition: types.h:112
return ret
Definition: mutex.c:147
This file contains GCM definitions and functions.
void mbedtls_gcm_init(mbedtls_gcm_context *ctx)
This function initializes the specified GCM context, to make references valid, and prepares the conte...
int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits)
This function associates a GCM context with a cipher algorithm and a key.
void mbedtls_gcm_free(mbedtls_gcm_context *ctx)
This function clears a GCM context and the underlying cipher sub-context.
GLenum mode
Definition: glext.h:6217
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLenum GLenum input
Definition: glext.h:9031
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
The ARCFOUR stream cipher.
int mbedtls_arc4_crypt(mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
ARC4 cipher function.
void mbedtls_arc4_setup(mbedtls_arc4_context *ctx, const unsigned char *key, unsigned int keylen)
ARC4 key schedule.
void mbedtls_arc4_init(mbedtls_arc4_context *ctx)
Initialize ARC4 context.
void mbedtls_arc4_free(mbedtls_arc4_context *ctx)
Clear ARC4 context.
Configuration options (set of defines)
DES block cipher.
void mbedtls_des_init(mbedtls_des_context *ctx)
Initialize DES context.
int mbedtls_des_setkey_dec(mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE])
DES key schedule (56-bit, decryption)
void mbedtls_des3_free(mbedtls_des3_context *ctx)
Clear Triple-DES context.
int mbedtls_des3_set2key_dec(mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE *2])
Triple-DES key schedule (112-bit, decryption)
int mbedtls_des3_crypt_cbc(mbedtls_des3_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
3DES-CBC buffer encryption/decryption
int mbedtls_des_setkey_enc(mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE])
DES key schedule (56-bit, encryption)
int mbedtls_des3_set3key_enc(mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE *3])
Triple-DES key schedule (168-bit, encryption)
int mbedtls_des3_crypt_ecb(mbedtls_des3_context *ctx, const unsigned char input[8], unsigned char output[8])
3DES-ECB block encryption/decryption
int mbedtls_des_crypt_cbc(mbedtls_des_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
DES-CBC buffer encryption/decryption.
int mbedtls_des3_set2key_enc(mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE *2])
Triple-DES key schedule (112-bit, encryption)
int mbedtls_des_crypt_ecb(mbedtls_des_context *ctx, const unsigned char input[8], unsigned char output[8])
DES-ECB block encryption/decryption.
void mbedtls_des3_init(mbedtls_des3_context *ctx)
Initialize Triple-DES context.
int mbedtls_des3_set3key_dec(mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE *3])
Triple-DES key schedule (168-bit, decryption)
void mbedtls_des_free(mbedtls_des_context *ctx)
Clear DES context.
This file contains the definitions and functions of the Mbed TLS platform abstraction layer.
#define mbedtls_free
Definition: platform.h:168
#define mbedtls_calloc
Definition: platform.h:169
Definition: copy.c:22
The AES context-type definition.
Definition: aes.h:113
The AES XTS context-type definition.
Definition: aes.h:132
ARC4 context structure.
Definition: arc4.h:83
The ARIA context-type definition.
Definition: aria.h:103
Blowfish context structure.
Definition: blowfish.h:93
CAMELLIA context structure.
Definition: camellia.h:89
The CCM context-type definition. The CCM context is passed to the APIs called.
Definition: ccm.h:104
Triple-DES context structure.
Definition: des.h:101
DES context structure.
Definition: des.h:92
The GCM context structure.
Definition: gcm.h:91