PolarSSL v1.3.9
md_wrap.c
Go to the documentation of this file.
1
30#if !defined(POLARSSL_CONFIG_FILE)
31#include "polarssl/config.h"
32#else
33#include POLARSSL_CONFIG_FILE
34#endif
35
36#if defined(POLARSSL_MD_C)
37
38#include "polarssl/md_wrap.h"
39
40#if defined(POLARSSL_MD2_C)
41#include "polarssl/md2.h"
42#endif
43
44#if defined(POLARSSL_MD4_C)
45#include "polarssl/md4.h"
46#endif
47
48#if defined(POLARSSL_MD5_C)
49#include "polarssl/md5.h"
50#endif
51
52#if defined(POLARSSL_RIPEMD160_C)
53#include "polarssl/ripemd160.h"
54#endif
55
56#if defined(POLARSSL_SHA1_C)
57#include "polarssl/sha1.h"
58#endif
59
60#if defined(POLARSSL_SHA256_C)
61#include "polarssl/sha256.h"
62#endif
63
64#if defined(POLARSSL_SHA512_C)
65#include "polarssl/sha512.h"
66#endif
67
68#if defined(POLARSSL_PLATFORM_C)
69#include "polarssl/platform.h"
70#else
71#define polarssl_malloc malloc
72#define polarssl_free free
73#endif
74
75#include <stdlib.h>
76
77/* Implementation that should never be optimized out by the compiler */
78static void polarssl_zeroize( void *v, size_t n ) {
79 volatile unsigned char *p = v; while( n-- ) *p++ = 0;
80}
81
82#if defined(POLARSSL_MD2_C)
83
84static void md2_starts_wrap( void *ctx )
85{
86 md2_starts( (md2_context *) ctx );
87}
88
89static void md2_update_wrap( void *ctx, const unsigned char *input,
90 size_t ilen )
91{
92 md2_update( (md2_context *) ctx, input, ilen );
93}
94
95static void md2_finish_wrap( void *ctx, unsigned char *output )
96{
97 md2_finish( (md2_context *) ctx, output );
98}
99
100static int md2_file_wrap( const char *path, unsigned char *output )
101{
102#if defined(POLARSSL_FS_IO)
103 return md2_file( path, output );
104#else
105 ((void) path);
106 ((void) output);
108#endif
109}
110
111static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key,
112 size_t keylen )
113{
114 md2_hmac_starts( (md2_context *) ctx, key, keylen );
115}
116
117static void md2_hmac_update_wrap( void *ctx, const unsigned char *input,
118 size_t ilen )
119{
120 md2_hmac_update( (md2_context *) ctx, input, ilen );
121}
122
123static void md2_hmac_finish_wrap( void *ctx, unsigned char *output )
124{
125 md2_hmac_finish( (md2_context *) ctx, output );
126}
127
128static void md2_hmac_reset_wrap( void *ctx )
129{
130 md2_hmac_reset( (md2_context *) ctx );
131}
132
133static void * md2_ctx_alloc( void )
134{
135 return polarssl_malloc( sizeof( md2_context ) );
136}
137
138static void md2_ctx_free( void *ctx )
139{
140 polarssl_zeroize( ctx, sizeof( md2_context ) );
141 polarssl_free( ctx );
142}
143
144static void md2_process_wrap( void *ctx, const unsigned char *data )
145{
146 ((void) data);
147
148 md2_process( (md2_context *) ctx );
149}
150
151const md_info_t md2_info = {
153 "MD2",
154 16,
155 md2_starts_wrap,
156 md2_update_wrap,
157 md2_finish_wrap,
158 md2,
159 md2_file_wrap,
160 md2_hmac_starts_wrap,
161 md2_hmac_update_wrap,
162 md2_hmac_finish_wrap,
163 md2_hmac_reset_wrap,
164 md2_hmac,
165 md2_ctx_alloc,
166 md2_ctx_free,
167 md2_process_wrap,
168};
169
170#endif /* POLARSSL_MD2_C */
171
172#if defined(POLARSSL_MD4_C)
173
174static void md4_starts_wrap( void *ctx )
175{
176 md4_starts( (md4_context *) ctx );
177}
178
179static void md4_update_wrap( void *ctx, const unsigned char *input,
180 size_t ilen )
181{
182 md4_update( (md4_context *) ctx, input, ilen );
183}
184
185static void md4_finish_wrap( void *ctx, unsigned char *output )
186{
187 md4_finish( (md4_context *) ctx, output );
188}
189
190static int md4_file_wrap( const char *path, unsigned char *output )
191{
192#if defined(POLARSSL_FS_IO)
193 return md4_file( path, output );
194#else
195 ((void) path);
196 ((void) output);
198#endif
199}
200
201static void md4_hmac_starts_wrap( void *ctx, const unsigned char *key,
202 size_t keylen )
203{
204 md4_hmac_starts( (md4_context *) ctx, key, keylen );
205}
206
207static void md4_hmac_update_wrap( void *ctx, const unsigned char *input,
208 size_t ilen )
209{
210 md4_hmac_update( (md4_context *) ctx, input, ilen );
211}
212
213static void md4_hmac_finish_wrap( void *ctx, unsigned char *output )
214{
215 md4_hmac_finish( (md4_context *) ctx, output );
216}
217
218static void md4_hmac_reset_wrap( void *ctx )
219{
220 md4_hmac_reset( (md4_context *) ctx );
221}
222
223static void *md4_ctx_alloc( void )
224{
225 return polarssl_malloc( sizeof( md4_context ) );
226}
227
228static void md4_ctx_free( void *ctx )
229{
230 polarssl_zeroize( ctx, sizeof( md4_context ) );
231 polarssl_free( ctx );
232}
233
234static void md4_process_wrap( void *ctx, const unsigned char *data )
235{
236 md4_process( (md4_context *) ctx, data );
237}
238
239const md_info_t md4_info = {
241 "MD4",
242 16,
243 md4_starts_wrap,
244 md4_update_wrap,
245 md4_finish_wrap,
246 md4,
247 md4_file_wrap,
248 md4_hmac_starts_wrap,
249 md4_hmac_update_wrap,
250 md4_hmac_finish_wrap,
251 md4_hmac_reset_wrap,
252 md4_hmac,
253 md4_ctx_alloc,
254 md4_ctx_free,
255 md4_process_wrap,
256};
257
258#endif /* POLARSSL_MD4_C */
259
260#if defined(POLARSSL_MD5_C)
261
262static void md5_starts_wrap( void *ctx )
263{
264 md5_starts( (md5_context *) ctx );
265}
266
267static void md5_update_wrap( void *ctx, const unsigned char *input,
268 size_t ilen )
269{
270 md5_update( (md5_context *) ctx, input, ilen );
271}
272
273static void md5_finish_wrap( void *ctx, unsigned char *output )
274{
275 md5_finish( (md5_context *) ctx, output );
276}
277
278static int md5_file_wrap( const char *path, unsigned char *output )
279{
280#if defined(POLARSSL_FS_IO)
281 return md5_file( path, output );
282#else
283 ((void) path);
284 ((void) output);
286#endif
287}
288
289static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key,
290 size_t keylen )
291{
292 md5_hmac_starts( (md5_context *) ctx, key, keylen );
293}
294
295static void md5_hmac_update_wrap( void *ctx, const unsigned char *input,
296 size_t ilen )
297{
298 md5_hmac_update( (md5_context *) ctx, input, ilen );
299}
300
301static void md5_hmac_finish_wrap( void *ctx, unsigned char *output )
302{
303 md5_hmac_finish( (md5_context *) ctx, output );
304}
305
306static void md5_hmac_reset_wrap( void *ctx )
307{
308 md5_hmac_reset( (md5_context *) ctx );
309}
310
311static void * md5_ctx_alloc( void )
312{
313 return polarssl_malloc( sizeof( md5_context ) );
314}
315
316static void md5_ctx_free( void *ctx )
317{
318 polarssl_zeroize( ctx, sizeof( md5_context ) );
319 polarssl_free( ctx );
320}
321
322static void md5_process_wrap( void *ctx, const unsigned char *data )
323{
324 md5_process( (md5_context *) ctx, data );
325}
326
327const md_info_t md5_info = {
329 "MD5",
330 16,
331 md5_starts_wrap,
332 md5_update_wrap,
333 md5_finish_wrap,
334 md5,
335 md5_file_wrap,
336 md5_hmac_starts_wrap,
337 md5_hmac_update_wrap,
338 md5_hmac_finish_wrap,
339 md5_hmac_reset_wrap,
340 md5_hmac,
341 md5_ctx_alloc,
342 md5_ctx_free,
343 md5_process_wrap,
344};
345
346#endif /* POLARSSL_MD5_C */
347
348#if defined(POLARSSL_RIPEMD160_C)
349
350static void ripemd160_starts_wrap( void *ctx )
351{
353}
354
355static void ripemd160_update_wrap( void *ctx, const unsigned char *input,
356 size_t ilen )
357{
358 ripemd160_update( (ripemd160_context *) ctx, input, ilen );
359}
360
361static void ripemd160_finish_wrap( void *ctx, unsigned char *output )
362{
363 ripemd160_finish( (ripemd160_context *) ctx, output );
364}
365
366static int ripemd160_file_wrap( const char *path, unsigned char *output )
367{
368#if defined(POLARSSL_FS_IO)
369 return ripemd160_file( path, output );
370#else
371 ((void) path);
372 ((void) output);
374#endif
375}
376
377static void ripemd160_hmac_starts_wrap( void *ctx, const unsigned char *key,
378 size_t keylen )
379{
380 ripemd160_hmac_starts( (ripemd160_context *) ctx, key, keylen );
381}
382
383static void ripemd160_hmac_update_wrap( void *ctx, const unsigned char *input,
384 size_t ilen )
385{
386 ripemd160_hmac_update( (ripemd160_context *) ctx, input, ilen );
387}
388
389static void ripemd160_hmac_finish_wrap( void *ctx, unsigned char *output )
390{
391 ripemd160_hmac_finish( (ripemd160_context *) ctx, output );
392}
393
394static void ripemd160_hmac_reset_wrap( void *ctx )
395{
397}
398
399static void * ripemd160_ctx_alloc( void )
400{
403
404 if( ctx == NULL )
405 return( NULL );
406
407 ripemd160_init( ctx );
408
409 return( ctx );
410}
411
412static void ripemd160_ctx_free( void *ctx )
413{
415 polarssl_free( ctx );
416}
417
418static void ripemd160_process_wrap( void *ctx, const unsigned char *data )
419{
420 ripemd160_process( (ripemd160_context *) ctx, data );
421}
422
425 "RIPEMD160",
426 20,
427 ripemd160_starts_wrap,
428 ripemd160_update_wrap,
429 ripemd160_finish_wrap,
430 ripemd160,
431 ripemd160_file_wrap,
432 ripemd160_hmac_starts_wrap,
433 ripemd160_hmac_update_wrap,
434 ripemd160_hmac_finish_wrap,
435 ripemd160_hmac_reset_wrap,
437 ripemd160_ctx_alloc,
438 ripemd160_ctx_free,
439 ripemd160_process_wrap,
440};
441
442#endif /* POLARSSL_RIPEMD160_C */
443
444#if defined(POLARSSL_SHA1_C)
445
446static void sha1_starts_wrap( void *ctx )
447{
448 sha1_starts( (sha1_context *) ctx );
449}
450
451static void sha1_update_wrap( void *ctx, const unsigned char *input,
452 size_t ilen )
453{
454 sha1_update( (sha1_context *) ctx, input, ilen );
455}
456
457static void sha1_finish_wrap( void *ctx, unsigned char *output )
458{
459 sha1_finish( (sha1_context *) ctx, output );
460}
461
462static int sha1_file_wrap( const char *path, unsigned char *output )
463{
464#if defined(POLARSSL_FS_IO)
465 return sha1_file( path, output );
466#else
467 ((void) path);
468 ((void) output);
470#endif
471}
472
473static void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key,
474 size_t keylen )
475{
476 sha1_hmac_starts( (sha1_context *) ctx, key, keylen );
477}
478
479static void sha1_hmac_update_wrap( void *ctx, const unsigned char *input,
480 size_t ilen )
481{
482 sha1_hmac_update( (sha1_context *) ctx, input, ilen );
483}
484
485static void sha1_hmac_finish_wrap( void *ctx, unsigned char *output )
486{
487 sha1_hmac_finish( (sha1_context *) ctx, output );
488}
489
490static void sha1_hmac_reset_wrap( void *ctx )
491{
492 sha1_hmac_reset( (sha1_context *) ctx );
493}
494
495static void * sha1_ctx_alloc( void )
496{
497 sha1_context *ctx;
498 ctx = (sha1_context *) polarssl_malloc( sizeof( sha1_context ) );
499
500 if( ctx == NULL )
501 return( NULL );
502
503 sha1_init( ctx );
504
505 return( ctx );
506}
507
508static void sha1_ctx_free( void *ctx )
509{
510 sha1_free( (sha1_context *) ctx );
511 polarssl_free( ctx );
512}
513
514static void sha1_process_wrap( void *ctx, const unsigned char *data )
515{
516 sha1_process( (sha1_context *) ctx, data );
517}
518
519const md_info_t sha1_info = {
521 "SHA1",
522 20,
523 sha1_starts_wrap,
524 sha1_update_wrap,
525 sha1_finish_wrap,
526 sha1,
527 sha1_file_wrap,
528 sha1_hmac_starts_wrap,
529 sha1_hmac_update_wrap,
530 sha1_hmac_finish_wrap,
531 sha1_hmac_reset_wrap,
532 sha1_hmac,
533 sha1_ctx_alloc,
534 sha1_ctx_free,
535 sha1_process_wrap,
536};
537
538#endif /* POLARSSL_SHA1_C */
539
540/*
541 * Wrappers for generic message digests
542 */
543#if defined(POLARSSL_SHA256_C)
544
545static void sha224_starts_wrap( void *ctx )
546{
547 sha256_starts( (sha256_context *) ctx, 1 );
548}
549
550static void sha224_update_wrap( void *ctx, const unsigned char *input,
551 size_t ilen )
552{
553 sha256_update( (sha256_context *) ctx, input, ilen );
554}
555
556static void sha224_finish_wrap( void *ctx, unsigned char *output )
557{
558 sha256_finish( (sha256_context *) ctx, output );
559}
560
561static void sha224_wrap( const unsigned char *input, size_t ilen,
562 unsigned char *output )
563{
564 sha256( input, ilen, output, 1 );
565}
566
567static int sha224_file_wrap( const char *path, unsigned char *output )
568{
569#if defined(POLARSSL_FS_IO)
570 return sha256_file( path, output, 1 );
571#else
572 ((void) path);
573 ((void) output);
575#endif
576}
577
578static void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key,
579 size_t keylen )
580{
581 sha256_hmac_starts( (sha256_context *) ctx, key, keylen, 1 );
582}
583
584static void sha224_hmac_update_wrap( void *ctx, const unsigned char *input,
585 size_t ilen )
586{
587 sha256_hmac_update( (sha256_context *) ctx, input, ilen );
588}
589
590static void sha224_hmac_finish_wrap( void *ctx, unsigned char *output )
591{
592 sha256_hmac_finish( (sha256_context *) ctx, output );
593}
594
595static void sha224_hmac_reset_wrap( void *ctx )
596{
598}
599
600static void sha224_hmac_wrap( const unsigned char *key, size_t keylen,
601 const unsigned char *input, size_t ilen,
602 unsigned char *output )
603{
604 sha256_hmac( key, keylen, input, ilen, output, 1 );
605}
606
607static void * sha224_ctx_alloc( void )
608{
609 return polarssl_malloc( sizeof( sha256_context ) );
610}
611
612static void sha224_ctx_free( void *ctx )
613{
614 polarssl_zeroize( ctx, sizeof( sha256_context ) );
615 polarssl_free( ctx );
616}
617
618static void sha224_process_wrap( void *ctx, const unsigned char *data )
619{
620 sha256_process( (sha256_context *) ctx, data );
621}
622
623const md_info_t sha224_info = {
625 "SHA224",
626 28,
627 sha224_starts_wrap,
628 sha224_update_wrap,
629 sha224_finish_wrap,
630 sha224_wrap,
631 sha224_file_wrap,
632 sha224_hmac_starts_wrap,
633 sha224_hmac_update_wrap,
634 sha224_hmac_finish_wrap,
635 sha224_hmac_reset_wrap,
636 sha224_hmac_wrap,
637 sha224_ctx_alloc,
638 sha224_ctx_free,
639 sha224_process_wrap,
640};
641
642static void sha256_starts_wrap( void *ctx )
643{
644 sha256_starts( (sha256_context *) ctx, 0 );
645}
646
647static void sha256_update_wrap( void *ctx, const unsigned char *input,
648 size_t ilen )
649{
650 sha256_update( (sha256_context *) ctx, input, ilen );
651}
652
653static void sha256_finish_wrap( void *ctx, unsigned char *output )
654{
655 sha256_finish( (sha256_context *) ctx, output );
656}
657
658static void sha256_wrap( const unsigned char *input, size_t ilen,
659 unsigned char *output )
660{
661 sha256( input, ilen, output, 0 );
662}
663
664static int sha256_file_wrap( const char *path, unsigned char *output )
665{
666#if defined(POLARSSL_FS_IO)
667 return sha256_file( path, output, 0 );
668#else
669 ((void) path);
670 ((void) output);
672#endif
673}
674
675static void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key,
676 size_t keylen )
677{
678 sha256_hmac_starts( (sha256_context *) ctx, key, keylen, 0 );
679}
680
681static void sha256_hmac_update_wrap( void *ctx, const unsigned char *input,
682 size_t ilen )
683{
684 sha256_hmac_update( (sha256_context *) ctx, input, ilen );
685}
686
687static void sha256_hmac_finish_wrap( void *ctx, unsigned char *output )
688{
689 sha256_hmac_finish( (sha256_context *) ctx, output );
690}
691
692static void sha256_hmac_reset_wrap( void *ctx )
693{
695}
696
697static void sha256_hmac_wrap( const unsigned char *key, size_t keylen,
698 const unsigned char *input, size_t ilen,
699 unsigned char *output )
700{
701 sha256_hmac( key, keylen, input, ilen, output, 0 );
702}
703
704static void * sha256_ctx_alloc( void )
705{
706 sha256_context *ctx;
707 ctx = (sha256_context *) polarssl_malloc( sizeof( sha256_context ) );
708
709 if( ctx == NULL )
710 return( NULL );
711
712 sha256_init( ctx );
713
714 return( ctx );
715}
716
717static void sha256_ctx_free( void *ctx )
718{
719 sha256_free( (sha256_context *) ctx );
720 polarssl_free( ctx );
721}
722
723static void sha256_process_wrap( void *ctx, const unsigned char *data )
724{
725 sha256_process( (sha256_context *) ctx, data );
726}
727
728const md_info_t sha256_info = {
730 "SHA256",
731 32,
732 sha256_starts_wrap,
733 sha256_update_wrap,
734 sha256_finish_wrap,
735 sha256_wrap,
736 sha256_file_wrap,
737 sha256_hmac_starts_wrap,
738 sha256_hmac_update_wrap,
739 sha256_hmac_finish_wrap,
740 sha256_hmac_reset_wrap,
741 sha256_hmac_wrap,
742 sha256_ctx_alloc,
743 sha256_ctx_free,
744 sha256_process_wrap,
745};
746
747#endif /* POLARSSL_SHA256_C */
748
749#if defined(POLARSSL_SHA512_C)
750
751static void sha384_starts_wrap( void *ctx )
752{
753 sha512_starts( (sha512_context *) ctx, 1 );
754}
755
756static void sha384_update_wrap( void *ctx, const unsigned char *input,
757 size_t ilen )
758{
759 sha512_update( (sha512_context *) ctx, input, ilen );
760}
761
762static void sha384_finish_wrap( void *ctx, unsigned char *output )
763{
764 sha512_finish( (sha512_context *) ctx, output );
765}
766
767static void sha384_wrap( const unsigned char *input, size_t ilen,
768 unsigned char *output )
769{
770 sha512( input, ilen, output, 1 );
771}
772
773static int sha384_file_wrap( const char *path, unsigned char *output )
774{
775#if defined(POLARSSL_FS_IO)
776 return sha512_file( path, output, 1 );
777#else
778 ((void) path);
779 ((void) output);
781#endif
782}
783
784static void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key,
785 size_t keylen )
786{
787 sha512_hmac_starts( (sha512_context *) ctx, key, keylen, 1 );
788}
789
790static void sha384_hmac_update_wrap( void *ctx, const unsigned char *input,
791 size_t ilen )
792{
793 sha512_hmac_update( (sha512_context *) ctx, input, ilen );
794}
795
796static void sha384_hmac_finish_wrap( void *ctx, unsigned char *output )
797{
798 sha512_hmac_finish( (sha512_context *) ctx, output );
799}
800
801static void sha384_hmac_reset_wrap( void *ctx )
802{
804}
805
806static void sha384_hmac_wrap( const unsigned char *key, size_t keylen,
807 const unsigned char *input, size_t ilen,
808 unsigned char *output )
809{
810 sha512_hmac( key, keylen, input, ilen, output, 1 );
811}
812
813static void * sha384_ctx_alloc( void )
814{
815 return polarssl_malloc( sizeof( sha512_context ) );
816}
817
818static void sha384_ctx_free( void *ctx )
819{
820 polarssl_zeroize( ctx, sizeof( sha512_context ) );
821 polarssl_free( ctx );
822}
823
824static void sha384_process_wrap( void *ctx, const unsigned char *data )
825{
826 sha512_process( (sha512_context *) ctx, data );
827}
828
829const md_info_t sha384_info = {
831 "SHA384",
832 48,
833 sha384_starts_wrap,
834 sha384_update_wrap,
835 sha384_finish_wrap,
836 sha384_wrap,
837 sha384_file_wrap,
838 sha384_hmac_starts_wrap,
839 sha384_hmac_update_wrap,
840 sha384_hmac_finish_wrap,
841 sha384_hmac_reset_wrap,
842 sha384_hmac_wrap,
843 sha384_ctx_alloc,
844 sha384_ctx_free,
845 sha384_process_wrap,
846};
847
848static void sha512_starts_wrap( void *ctx )
849{
850 sha512_starts( (sha512_context *) ctx, 0 );
851}
852
853static void sha512_update_wrap( void *ctx, const unsigned char *input,
854 size_t ilen )
855{
856 sha512_update( (sha512_context *) ctx, input, ilen );
857}
858
859static void sha512_finish_wrap( void *ctx, unsigned char *output )
860{
861 sha512_finish( (sha512_context *) ctx, output );
862}
863
864static void sha512_wrap( const unsigned char *input, size_t ilen,
865 unsigned char *output )
866{
867 sha512( input, ilen, output, 0 );
868}
869
870static int sha512_file_wrap( const char *path, unsigned char *output )
871{
872#if defined(POLARSSL_FS_IO)
873 return sha512_file( path, output, 0 );
874#else
875 ((void) path);
876 ((void) output);
878#endif
879}
880
881static void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key,
882 size_t keylen )
883{
884 sha512_hmac_starts( (sha512_context *) ctx, key, keylen, 0 );
885}
886
887static void sha512_hmac_update_wrap( void *ctx, const unsigned char *input,
888 size_t ilen )
889{
890 sha512_hmac_update( (sha512_context *) ctx, input, ilen );
891}
892
893static void sha512_hmac_finish_wrap( void *ctx, unsigned char *output )
894{
895 sha512_hmac_finish( (sha512_context *) ctx, output );
896}
897
898static void sha512_hmac_reset_wrap( void *ctx )
899{
901}
902
903static void sha512_hmac_wrap( const unsigned char *key, size_t keylen,
904 const unsigned char *input, size_t ilen,
905 unsigned char *output )
906{
907 sha512_hmac( key, keylen, input, ilen, output, 0 );
908}
909
910static void * sha512_ctx_alloc( void )
911{
912 sha512_context *ctx;
913 ctx = (sha512_context *) polarssl_malloc( sizeof( sha512_context ) );
914
915 if( ctx == NULL )
916 return( NULL );
917
918 sha512_init( ctx );
919
920 return( ctx );
921}
922
923static void sha512_ctx_free( void *ctx )
924{
925 sha512_free( (sha512_context *) ctx );
926 polarssl_free( ctx );
927}
928
929static void sha512_process_wrap( void *ctx, const unsigned char *data )
930{
931 sha512_process( (sha512_context *) ctx, data );
932}
933
934const md_info_t sha512_info = {
936 "SHA512",
937 64,
938 sha512_starts_wrap,
939 sha512_update_wrap,
940 sha512_finish_wrap,
941 sha512_wrap,
942 sha512_file_wrap,
943 sha512_hmac_starts_wrap,
944 sha512_hmac_update_wrap,
945 sha512_hmac_finish_wrap,
946 sha512_hmac_reset_wrap,
947 sha512_hmac_wrap,
948 sha512_ctx_alloc,
949 sha512_ctx_free,
950 sha512_process_wrap,
951};
952
953#endif /* POLARSSL_SHA512_C */
954
955#endif /* POLARSSL_MD_C */
Configuration options (set of defines)
MD2 message digest algorithm (hash function)
void md2_update(md2_context *ctx, const unsigned char *input, size_t ilen)
MD2 process buffer.
void md2_hmac_reset(md2_context *ctx)
MD2 HMAC context reset.
void md2(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD2( input buffer )
void md2_hmac_finish(md2_context *ctx, unsigned char output[16])
MD2 HMAC final digest.
void md2_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16])
Output = HMAC-MD2( hmac key, input buffer )
void md2_process(md2_context *ctx)
void md2_hmac_update(md2_context *ctx, const unsigned char *input, size_t ilen)
MD2 HMAC process buffer.
int md2_file(const char *path, unsigned char output[16])
Output = MD2( file contents )
void md2_finish(md2_context *ctx, unsigned char output[16])
MD2 final digest.
void md2_starts(md2_context *ctx)
MD2 context setup.
void md2_hmac_starts(md2_context *ctx, const unsigned char *key, size_t keylen)
MD2 HMAC context setup.
MD4 message digest algorithm (hash function)
void md4_starts(md4_context *ctx)
MD4 context setup.
void md4_process(md4_context *ctx, const unsigned char data[64])
void md4_hmac_reset(md4_context *ctx)
MD4 HMAC context reset.
void md4_update(md4_context *ctx, const unsigned char *input, size_t ilen)
MD4 process buffer.
int md4_file(const char *path, unsigned char output[16])
Output = MD4( file contents )
void md4_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16])
Output = HMAC-MD4( hmac key, input buffer )
void md4_hmac_starts(md4_context *ctx, const unsigned char *key, size_t keylen)
MD4 HMAC context setup.
void md4_finish(md4_context *ctx, unsigned char output[16])
MD4 final digest.
void md4_hmac_update(md4_context *ctx, const unsigned char *input, size_t ilen)
MD4 HMAC process buffer.
void md4_hmac_finish(md4_context *ctx, unsigned char output[16])
MD4 HMAC final digest.
void md4(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD4( input buffer )
MD5 message digest algorithm (hash function)
void md5_hmac_finish(md5_context *ctx, unsigned char output[16])
MD5 HMAC final digest.
void md5_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[16])
Output = HMAC-MD5( hmac key, input buffer )
void md5_process(md5_context *ctx, const unsigned char data[64])
void md5_update(md5_context *ctx, const unsigned char *input, size_t ilen)
MD5 process buffer.
void md5_finish(md5_context *ctx, unsigned char output[16])
MD5 final digest.
void md5(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD5( input buffer )
void md5_hmac_update(md5_context *ctx, const unsigned char *input, size_t ilen)
MD5 HMAC process buffer.
void md5_starts(md5_context *ctx)
MD5 context setup.
int md5_file(const char *path, unsigned char output[16])
Output = MD5( file contents )
void md5_hmac_starts(md5_context *ctx, const unsigned char *key, size_t keylen)
MD5 HMAC context setup.
void md5_hmac_reset(md5_context *ctx)
MD5 HMAC context reset.
#define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE
The selected feature is not available.
Definition md.h:42
@ POLARSSL_MD_MD5
Definition md.h:55
@ POLARSSL_MD_SHA224
Definition md.h:57
@ POLARSSL_MD_SHA1
Definition md.h:56
@ POLARSSL_MD_SHA384
Definition md.h:59
@ POLARSSL_MD_MD2
Definition md.h:53
@ POLARSSL_MD_MD4
Definition md.h:54
@ POLARSSL_MD_RIPEMD160
Definition md.h:61
@ POLARSSL_MD_SHA512
Definition md.h:60
@ POLARSSL_MD_SHA256
Definition md.h:58
Message digest wrappers.
const md_info_t md5_info
const md_info_t sha256_info
const md_info_t sha224_info
const md_info_t ripemd160_info
const md_info_t sha1_info
const md_info_t sha384_info
const md_info_t sha512_info
PolarSSL Platform abstraction layer.
RIPE MD-160 message digest.
int ripemd160_file(const char *path, unsigned char output[20])
Output = RIPEMD-160( file contents )
void ripemd160_hmac_reset(ripemd160_context *ctx)
RIPEMD-160 HMAC context reset.
void ripemd160_hmac_starts(ripemd160_context *ctx, const unsigned char *key, size_t keylen)
RIPEMD-160 HMAC context setup.
void ripemd160_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[20])
Output = HMAC-RIPEMD-160( hmac key, input buffer )
void ripemd160_init(ripemd160_context *ctx)
Initialize RIPEMD-160 context.
void ripemd160_free(ripemd160_context *ctx)
Clear RIPEMD-160 context.
void ripemd160_hmac_finish(ripemd160_context *ctx, unsigned char output[20])
RIPEMD-160 HMAC final digest.
void ripemd160_hmac_update(ripemd160_context *ctx, const unsigned char *input, size_t ilen)
RIPEMD-160 HMAC process buffer.
void ripemd160(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = RIPEMD-160( input buffer )
void ripemd160_starts(ripemd160_context *ctx)
RIPEMD-160 context setup.
void ripemd160_process(ripemd160_context *ctx, const unsigned char data[64])
void ripemd160_finish(ripemd160_context *ctx, unsigned char output[20])
RIPEMD-160 final digest.
void ripemd160_update(ripemd160_context *ctx, const unsigned char *input, size_t ilen)
RIPEMD-160 process buffer.
SHA-1 cryptographic hash function.
void sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = SHA-1( input buffer )
void sha1_starts(sha1_context *ctx)
SHA-1 context setup.
void sha1_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[20])
Output = HMAC-SHA-1( hmac key, input buffer )
int sha1_file(const char *path, unsigned char output[20])
Output = SHA-1( file contents )
void sha1_update(sha1_context *ctx, const unsigned char *input, size_t ilen)
SHA-1 process buffer.
void sha1_hmac_finish(sha1_context *ctx, unsigned char output[20])
SHA-1 HMAC final digest.
void sha1_hmac_update(sha1_context *ctx, const unsigned char *input, size_t ilen)
SHA-1 HMAC process buffer.
void sha1_init(sha1_context *ctx)
Initialize SHA-1 context.
void sha1_finish(sha1_context *ctx, unsigned char output[20])
SHA-1 final digest.
void sha1_hmac_starts(sha1_context *ctx, const unsigned char *key, size_t keylen)
SHA-1 HMAC context setup.
void sha1_free(sha1_context *ctx)
Clear SHA-1 context.
void sha1_hmac_reset(sha1_context *ctx)
SHA-1 HMAC context reset.
void sha1_process(sha1_context *ctx, const unsigned char data[64])
SHA-224 and SHA-256 cryptographic hash function.
void sha256_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 final digest.
int sha256_file(const char *path, unsigned char output[32], int is224)
Output = SHA-256( file contents )
void sha256_hmac_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 HMAC final digest.
void sha256_hmac_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 HMAC process buffer.
void sha256_free(sha256_context *ctx)
Clear SHA-256 context.
void sha256(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = SHA-256( input buffer )
void sha256_process(sha256_context *ctx, const unsigned char data[64])
void sha256_hmac_reset(sha256_context *ctx)
SHA-256 HMAC context reset.
void sha256_hmac_starts(sha256_context *ctx, const unsigned char *key, size_t keylen, int is224)
SHA-256 HMAC context setup.
void sha256_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = HMAC-SHA-256( hmac key, input buffer )
void sha256_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 process buffer.
void sha256_starts(sha256_context *ctx, int is224)
SHA-256 context setup.
void sha256_init(sha256_context *ctx)
Initialize SHA-256 context.
SHA-384 and SHA-512 cryptographic hash function.
void sha512_hmac_reset(sha512_context *ctx)
SHA-512 HMAC context reset.
void sha512_free(sha512_context *ctx)
Clear SHA-512 context.
void sha512_process(sha512_context *ctx, const unsigned char data[128])
void sha512_starts(sha512_context *ctx, int is384)
SHA-512 context setup.
void sha512_hmac_finish(sha512_context *ctx, unsigned char output[64])
SHA-512 HMAC final digest.
void sha512_hmac_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 HMAC process buffer.
void sha512(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = SHA-512( input buffer )
void sha512_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = HMAC-SHA-512( hmac key, input buffer )
int sha512_file(const char *path, unsigned char output[64], int is384)
Output = SHA-512( file contents )
void sha512_finish(sha512_context *ctx, unsigned char output[64])
SHA-512 final digest.
void sha512_hmac_starts(sha512_context *ctx, const unsigned char *key, size_t keylen, int is384)
SHA-512 HMAC context setup.
void sha512_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 process buffer.
void sha512_init(sha512_context *ctx)
Initialize SHA-512 context.
MD2 context structure.
Definition md2.h:52
MD4 context structure.
Definition md4.h:59
MD5 context structure.
Definition md5.h:59
Message digest information.
Definition md.h:74
RIPEMD-160 context structure.
Definition ripemd160.h:59
SHA-1 context structure.
Definition sha1.h:59
SHA-256 context structure.
Definition sha256.h:59
SHA-512 context structure.
Definition sha512.h:60
#define polarssl_malloc
#define polarssl_free