fuck! don't perform ssl handshake for blocked hosts!
[mediator.git] / src / libpolarssl / md_wrap.c
blobf554333e782ee96e3ad70862cd82bcd27f92af12
1 /**
2 * \file md_wrap.c
4 * \brief Generic message digest wrapper for mbed TLS
6 * \author Adriaan de Jong <dejong@fox-it.com>
8 * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
10 * This file is part of mbed TLS (https://tls.mbed.org)
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #if !defined(POLARSSL_CONFIG_FILE)
28 #include "polarssl/config.h"
29 #else
30 #include POLARSSL_CONFIG_FILE
31 #endif
33 #if defined(POLARSSL_MD_C)
35 #include "polarssl/md_wrap.h"
37 #if defined(POLARSSL_MD2_C)
38 #include "polarssl/md2.h"
39 #endif
41 #if defined(POLARSSL_MD4_C)
42 #include "polarssl/md4.h"
43 #endif
45 #if defined(POLARSSL_MD5_C)
46 #include "polarssl/md5.h"
47 #endif
49 #if defined(POLARSSL_RIPEMD160_C)
50 #include "polarssl/ripemd160.h"
51 #endif
53 #if defined(POLARSSL_SHA1_C)
54 #include "polarssl/sha1.h"
55 #endif
57 #if defined(POLARSSL_SHA256_C)
58 #include "polarssl/sha256.h"
59 #endif
61 #if defined(POLARSSL_SHA512_C)
62 #include "polarssl/sha512.h"
63 #endif
65 #if defined(POLARSSL_PLATFORM_C)
66 #include "polarssl/platform.h"
67 #else
68 #include <stdlib.h>
69 #define polarssl_malloc malloc
70 #define polarssl_free free
71 #endif
73 /* Implementation that should never be optimized out by the compiler */
74 static void polarssl_zeroize( void *v, size_t n ) {
75 volatile unsigned char *p = v; while( n-- ) *p++ = 0;
78 #if defined(POLARSSL_MD2_C)
80 static void md2_starts_wrap( void *ctx )
82 md2_starts( (md2_context *) ctx );
85 static void md2_update_wrap( void *ctx, const unsigned char *input,
86 size_t ilen )
88 md2_update( (md2_context *) ctx, input, ilen );
91 static void md2_finish_wrap( void *ctx, unsigned char *output )
93 md2_finish( (md2_context *) ctx, output );
96 static int md2_file_wrap( const char *path, unsigned char *output )
98 #if defined(POLARSSL_FS_IO)
99 return md2_file( path, output );
100 #else
101 ((void) path);
102 ((void) output);
103 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
104 #endif
107 static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key,
108 size_t keylen )
110 md2_hmac_starts( (md2_context *) ctx, key, keylen );
113 static void md2_hmac_update_wrap( void *ctx, const unsigned char *input,
114 size_t ilen )
116 md2_hmac_update( (md2_context *) ctx, input, ilen );
119 static void md2_hmac_finish_wrap( void *ctx, unsigned char *output )
121 md2_hmac_finish( (md2_context *) ctx, output );
124 static void md2_hmac_reset_wrap( void *ctx )
126 md2_hmac_reset( (md2_context *) ctx );
129 static void * md2_ctx_alloc( void )
131 return polarssl_malloc( sizeof( md2_context ) );
134 static void md2_ctx_free( void *ctx )
136 polarssl_zeroize( ctx, sizeof( md2_context ) );
137 polarssl_free( ctx );
140 static void md2_process_wrap( void *ctx, const unsigned char *data )
142 ((void) data);
144 md2_process( (md2_context *) ctx );
147 const md_info_t md2_info = {
148 POLARSSL_MD_MD2,
149 "MD2",
151 md2_starts_wrap,
152 md2_update_wrap,
153 md2_finish_wrap,
154 md2,
155 md2_file_wrap,
156 md2_hmac_starts_wrap,
157 md2_hmac_update_wrap,
158 md2_hmac_finish_wrap,
159 md2_hmac_reset_wrap,
160 md2_hmac,
161 md2_ctx_alloc,
162 md2_ctx_free,
163 md2_process_wrap,
166 #endif /* POLARSSL_MD2_C */
168 #if defined(POLARSSL_MD4_C)
170 static void md4_starts_wrap( void *ctx )
172 md4_starts( (md4_context *) ctx );
175 static void md4_update_wrap( void *ctx, const unsigned char *input,
176 size_t ilen )
178 md4_update( (md4_context *) ctx, input, ilen );
181 static void md4_finish_wrap( void *ctx, unsigned char *output )
183 md4_finish( (md4_context *) ctx, output );
186 static int md4_file_wrap( const char *path, unsigned char *output )
188 #if defined(POLARSSL_FS_IO)
189 return md4_file( path, output );
190 #else
191 ((void) path);
192 ((void) output);
193 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
194 #endif
197 static void md4_hmac_starts_wrap( void *ctx, const unsigned char *key,
198 size_t keylen )
200 md4_hmac_starts( (md4_context *) ctx, key, keylen );
203 static void md4_hmac_update_wrap( void *ctx, const unsigned char *input,
204 size_t ilen )
206 md4_hmac_update( (md4_context *) ctx, input, ilen );
209 static void md4_hmac_finish_wrap( void *ctx, unsigned char *output )
211 md4_hmac_finish( (md4_context *) ctx, output );
214 static void md4_hmac_reset_wrap( void *ctx )
216 md4_hmac_reset( (md4_context *) ctx );
219 static void *md4_ctx_alloc( void )
221 return polarssl_malloc( sizeof( md4_context ) );
224 static void md4_ctx_free( void *ctx )
226 polarssl_zeroize( ctx, sizeof( md4_context ) );
227 polarssl_free( ctx );
230 static void md4_process_wrap( void *ctx, const unsigned char *data )
232 md4_process( (md4_context *) ctx, data );
235 const md_info_t md4_info = {
236 POLARSSL_MD_MD4,
237 "MD4",
239 md4_starts_wrap,
240 md4_update_wrap,
241 md4_finish_wrap,
242 md4,
243 md4_file_wrap,
244 md4_hmac_starts_wrap,
245 md4_hmac_update_wrap,
246 md4_hmac_finish_wrap,
247 md4_hmac_reset_wrap,
248 md4_hmac,
249 md4_ctx_alloc,
250 md4_ctx_free,
251 md4_process_wrap,
254 #endif /* POLARSSL_MD4_C */
256 #if defined(POLARSSL_MD5_C)
258 static void md5_starts_wrap( void *ctx )
260 md5_starts( (md5_context *) ctx );
263 static void md5_update_wrap( void *ctx, const unsigned char *input,
264 size_t ilen )
266 md5_update( (md5_context *) ctx, input, ilen );
269 static void md5_finish_wrap( void *ctx, unsigned char *output )
271 md5_finish( (md5_context *) ctx, output );
274 static int md5_file_wrap( const char *path, unsigned char *output )
276 #if defined(POLARSSL_FS_IO)
277 return md5_file( path, output );
278 #else
279 ((void) path);
280 ((void) output);
281 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
282 #endif
285 static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key,
286 size_t keylen )
288 md5_hmac_starts( (md5_context *) ctx, key, keylen );
291 static void md5_hmac_update_wrap( void *ctx, const unsigned char *input,
292 size_t ilen )
294 md5_hmac_update( (md5_context *) ctx, input, ilen );
297 static void md5_hmac_finish_wrap( void *ctx, unsigned char *output )
299 md5_hmac_finish( (md5_context *) ctx, output );
302 static void md5_hmac_reset_wrap( void *ctx )
304 md5_hmac_reset( (md5_context *) ctx );
307 static void * md5_ctx_alloc( void )
309 return polarssl_malloc( sizeof( md5_context ) );
312 static void md5_ctx_free( void *ctx )
314 polarssl_zeroize( ctx, sizeof( md5_context ) );
315 polarssl_free( ctx );
318 static void md5_process_wrap( void *ctx, const unsigned char *data )
320 md5_process( (md5_context *) ctx, data );
323 const md_info_t md5_info = {
324 POLARSSL_MD_MD5,
325 "MD5",
327 md5_starts_wrap,
328 md5_update_wrap,
329 md5_finish_wrap,
330 md5,
331 md5_file_wrap,
332 md5_hmac_starts_wrap,
333 md5_hmac_update_wrap,
334 md5_hmac_finish_wrap,
335 md5_hmac_reset_wrap,
336 md5_hmac,
337 md5_ctx_alloc,
338 md5_ctx_free,
339 md5_process_wrap,
342 #endif /* POLARSSL_MD5_C */
344 #if defined(POLARSSL_RIPEMD160_C)
346 static void ripemd160_starts_wrap( void *ctx )
348 ripemd160_starts( (ripemd160_context *) ctx );
351 static void ripemd160_update_wrap( void *ctx, const unsigned char *input,
352 size_t ilen )
354 ripemd160_update( (ripemd160_context *) ctx, input, ilen );
357 static void ripemd160_finish_wrap( void *ctx, unsigned char *output )
359 ripemd160_finish( (ripemd160_context *) ctx, output );
362 static int ripemd160_file_wrap( const char *path, unsigned char *output )
364 #if defined(POLARSSL_FS_IO)
365 return ripemd160_file( path, output );
366 #else
367 ((void) path);
368 ((void) output);
369 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
370 #endif
373 static void ripemd160_hmac_starts_wrap( void *ctx, const unsigned char *key,
374 size_t keylen )
376 ripemd160_hmac_starts( (ripemd160_context *) ctx, key, keylen );
379 static void ripemd160_hmac_update_wrap( void *ctx, const unsigned char *input,
380 size_t ilen )
382 ripemd160_hmac_update( (ripemd160_context *) ctx, input, ilen );
385 static void ripemd160_hmac_finish_wrap( void *ctx, unsigned char *output )
387 ripemd160_hmac_finish( (ripemd160_context *) ctx, output );
390 static void ripemd160_hmac_reset_wrap( void *ctx )
392 ripemd160_hmac_reset( (ripemd160_context *) ctx );
395 static void * ripemd160_ctx_alloc( void )
397 ripemd160_context *ctx;
398 ctx = polarssl_malloc( sizeof( ripemd160_context ) );
400 if( ctx == NULL )
401 return( NULL );
403 ripemd160_init( ctx );
405 return( ctx );
408 static void ripemd160_ctx_free( void *ctx )
410 ripemd160_free( (ripemd160_context *) ctx );
411 polarssl_free( ctx );
414 static void ripemd160_process_wrap( void *ctx, const unsigned char *data )
416 ripemd160_process( (ripemd160_context *) ctx, data );
419 const md_info_t ripemd160_info = {
420 POLARSSL_MD_RIPEMD160,
421 "RIPEMD160",
423 ripemd160_starts_wrap,
424 ripemd160_update_wrap,
425 ripemd160_finish_wrap,
426 ripemd160,
427 ripemd160_file_wrap,
428 ripemd160_hmac_starts_wrap,
429 ripemd160_hmac_update_wrap,
430 ripemd160_hmac_finish_wrap,
431 ripemd160_hmac_reset_wrap,
432 ripemd160_hmac,
433 ripemd160_ctx_alloc,
434 ripemd160_ctx_free,
435 ripemd160_process_wrap,
438 #endif /* POLARSSL_RIPEMD160_C */
440 #if defined(POLARSSL_SHA1_C)
442 static void sha1_starts_wrap( void *ctx )
444 sha1_starts( (sha1_context *) ctx );
447 static void sha1_update_wrap( void *ctx, const unsigned char *input,
448 size_t ilen )
450 sha1_update( (sha1_context *) ctx, input, ilen );
453 static void sha1_finish_wrap( void *ctx, unsigned char *output )
455 sha1_finish( (sha1_context *) ctx, output );
458 static int sha1_file_wrap( const char *path, unsigned char *output )
460 #if defined(POLARSSL_FS_IO)
461 return sha1_file( path, output );
462 #else
463 ((void) path);
464 ((void) output);
465 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
466 #endif
469 static void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key,
470 size_t keylen )
472 sha1_hmac_starts( (sha1_context *) ctx, key, keylen );
475 static void sha1_hmac_update_wrap( void *ctx, const unsigned char *input,
476 size_t ilen )
478 sha1_hmac_update( (sha1_context *) ctx, input, ilen );
481 static void sha1_hmac_finish_wrap( void *ctx, unsigned char *output )
483 sha1_hmac_finish( (sha1_context *) ctx, output );
486 static void sha1_hmac_reset_wrap( void *ctx )
488 sha1_hmac_reset( (sha1_context *) ctx );
491 static void * sha1_ctx_alloc( void )
493 sha1_context *ctx;
494 ctx = polarssl_malloc( sizeof( sha1_context ) );
496 if( ctx == NULL )
497 return( NULL );
499 sha1_init( ctx );
501 return( ctx );
504 static void sha1_ctx_free( void *ctx )
506 sha1_free( (sha1_context *) ctx );
507 polarssl_free( ctx );
510 static void sha1_process_wrap( void *ctx, const unsigned char *data )
512 sha1_process( (sha1_context *) ctx, data );
515 const md_info_t sha1_info = {
516 POLARSSL_MD_SHA1,
517 "SHA1",
519 sha1_starts_wrap,
520 sha1_update_wrap,
521 sha1_finish_wrap,
522 sha1,
523 sha1_file_wrap,
524 sha1_hmac_starts_wrap,
525 sha1_hmac_update_wrap,
526 sha1_hmac_finish_wrap,
527 sha1_hmac_reset_wrap,
528 sha1_hmac,
529 sha1_ctx_alloc,
530 sha1_ctx_free,
531 sha1_process_wrap,
534 #endif /* POLARSSL_SHA1_C */
537 * Wrappers for generic message digests
539 #if defined(POLARSSL_SHA256_C)
541 static void sha224_starts_wrap( void *ctx )
543 sha256_starts( (sha256_context *) ctx, 1 );
546 static void sha224_update_wrap( void *ctx, const unsigned char *input,
547 size_t ilen )
549 sha256_update( (sha256_context *) ctx, input, ilen );
552 static void sha224_finish_wrap( void *ctx, unsigned char *output )
554 sha256_finish( (sha256_context *) ctx, output );
557 static void sha224_wrap( const unsigned char *input, size_t ilen,
558 unsigned char *output )
560 sha256( input, ilen, output, 1 );
563 static int sha224_file_wrap( const char *path, unsigned char *output )
565 #if defined(POLARSSL_FS_IO)
566 return sha256_file( path, output, 1 );
567 #else
568 ((void) path);
569 ((void) output);
570 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
571 #endif
574 static void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key,
575 size_t keylen )
577 sha256_hmac_starts( (sha256_context *) ctx, key, keylen, 1 );
580 static void sha224_hmac_update_wrap( void *ctx, const unsigned char *input,
581 size_t ilen )
583 sha256_hmac_update( (sha256_context *) ctx, input, ilen );
586 static void sha224_hmac_finish_wrap( void *ctx, unsigned char *output )
588 sha256_hmac_finish( (sha256_context *) ctx, output );
591 static void sha224_hmac_reset_wrap( void *ctx )
593 sha256_hmac_reset( (sha256_context *) ctx );
596 static void sha224_hmac_wrap( const unsigned char *key, size_t keylen,
597 const unsigned char *input, size_t ilen,
598 unsigned char *output )
600 sha256_hmac( key, keylen, input, ilen, output, 1 );
603 static void * sha224_ctx_alloc( void )
605 return polarssl_malloc( sizeof( sha256_context ) );
608 static void sha224_ctx_free( void *ctx )
610 polarssl_zeroize( ctx, sizeof( sha256_context ) );
611 polarssl_free( ctx );
614 static void sha224_process_wrap( void *ctx, const unsigned char *data )
616 sha256_process( (sha256_context *) ctx, data );
619 const md_info_t sha224_info = {
620 POLARSSL_MD_SHA224,
621 "SHA224",
623 sha224_starts_wrap,
624 sha224_update_wrap,
625 sha224_finish_wrap,
626 sha224_wrap,
627 sha224_file_wrap,
628 sha224_hmac_starts_wrap,
629 sha224_hmac_update_wrap,
630 sha224_hmac_finish_wrap,
631 sha224_hmac_reset_wrap,
632 sha224_hmac_wrap,
633 sha224_ctx_alloc,
634 sha224_ctx_free,
635 sha224_process_wrap,
638 static void sha256_starts_wrap( void *ctx )
640 sha256_starts( (sha256_context *) ctx, 0 );
643 static void sha256_update_wrap( void *ctx, const unsigned char *input,
644 size_t ilen )
646 sha256_update( (sha256_context *) ctx, input, ilen );
649 static void sha256_finish_wrap( void *ctx, unsigned char *output )
651 sha256_finish( (sha256_context *) ctx, output );
654 static void sha256_wrap( const unsigned char *input, size_t ilen,
655 unsigned char *output )
657 sha256( input, ilen, output, 0 );
660 static int sha256_file_wrap( const char *path, unsigned char *output )
662 #if defined(POLARSSL_FS_IO)
663 return sha256_file( path, output, 0 );
664 #else
665 ((void) path);
666 ((void) output);
667 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
668 #endif
671 static void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key,
672 size_t keylen )
674 sha256_hmac_starts( (sha256_context *) ctx, key, keylen, 0 );
677 static void sha256_hmac_update_wrap( void *ctx, const unsigned char *input,
678 size_t ilen )
680 sha256_hmac_update( (sha256_context *) ctx, input, ilen );
683 static void sha256_hmac_finish_wrap( void *ctx, unsigned char *output )
685 sha256_hmac_finish( (sha256_context *) ctx, output );
688 static void sha256_hmac_reset_wrap( void *ctx )
690 sha256_hmac_reset( (sha256_context *) ctx );
693 static void sha256_hmac_wrap( const unsigned char *key, size_t keylen,
694 const unsigned char *input, size_t ilen,
695 unsigned char *output )
697 sha256_hmac( key, keylen, input, ilen, output, 0 );
700 static void * sha256_ctx_alloc( void )
702 sha256_context *ctx;
703 ctx = polarssl_malloc( sizeof( sha256_context ) );
705 if( ctx == NULL )
706 return( NULL );
708 sha256_init( ctx );
710 return( ctx );
713 static void sha256_ctx_free( void *ctx )
715 sha256_free( (sha256_context *) ctx );
716 polarssl_free( ctx );
719 static void sha256_process_wrap( void *ctx, const unsigned char *data )
721 sha256_process( (sha256_context *) ctx, data );
724 const md_info_t sha256_info = {
725 POLARSSL_MD_SHA256,
726 "SHA256",
728 sha256_starts_wrap,
729 sha256_update_wrap,
730 sha256_finish_wrap,
731 sha256_wrap,
732 sha256_file_wrap,
733 sha256_hmac_starts_wrap,
734 sha256_hmac_update_wrap,
735 sha256_hmac_finish_wrap,
736 sha256_hmac_reset_wrap,
737 sha256_hmac_wrap,
738 sha256_ctx_alloc,
739 sha256_ctx_free,
740 sha256_process_wrap,
743 #endif /* POLARSSL_SHA256_C */
745 #if defined(POLARSSL_SHA512_C)
747 static void sha384_starts_wrap( void *ctx )
749 sha512_starts( (sha512_context *) ctx, 1 );
752 static void sha384_update_wrap( void *ctx, const unsigned char *input,
753 size_t ilen )
755 sha512_update( (sha512_context *) ctx, input, ilen );
758 static void sha384_finish_wrap( void *ctx, unsigned char *output )
760 sha512_finish( (sha512_context *) ctx, output );
763 static void sha384_wrap( const unsigned char *input, size_t ilen,
764 unsigned char *output )
766 sha512( input, ilen, output, 1 );
769 static int sha384_file_wrap( const char *path, unsigned char *output )
771 #if defined(POLARSSL_FS_IO)
772 return sha512_file( path, output, 1 );
773 #else
774 ((void) path);
775 ((void) output);
776 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
777 #endif
780 static void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key,
781 size_t keylen )
783 sha512_hmac_starts( (sha512_context *) ctx, key, keylen, 1 );
786 static void sha384_hmac_update_wrap( void *ctx, const unsigned char *input,
787 size_t ilen )
789 sha512_hmac_update( (sha512_context *) ctx, input, ilen );
792 static void sha384_hmac_finish_wrap( void *ctx, unsigned char *output )
794 sha512_hmac_finish( (sha512_context *) ctx, output );
797 static void sha384_hmac_reset_wrap( void *ctx )
799 sha512_hmac_reset( (sha512_context *) ctx );
802 static void sha384_hmac_wrap( const unsigned char *key, size_t keylen,
803 const unsigned char *input, size_t ilen,
804 unsigned char *output )
806 sha512_hmac( key, keylen, input, ilen, output, 1 );
809 static void * sha384_ctx_alloc( void )
811 return polarssl_malloc( sizeof( sha512_context ) );
814 static void sha384_ctx_free( void *ctx )
816 polarssl_zeroize( ctx, sizeof( sha512_context ) );
817 polarssl_free( ctx );
820 static void sha384_process_wrap( void *ctx, const unsigned char *data )
822 sha512_process( (sha512_context *) ctx, data );
825 const md_info_t sha384_info = {
826 POLARSSL_MD_SHA384,
827 "SHA384",
829 sha384_starts_wrap,
830 sha384_update_wrap,
831 sha384_finish_wrap,
832 sha384_wrap,
833 sha384_file_wrap,
834 sha384_hmac_starts_wrap,
835 sha384_hmac_update_wrap,
836 sha384_hmac_finish_wrap,
837 sha384_hmac_reset_wrap,
838 sha384_hmac_wrap,
839 sha384_ctx_alloc,
840 sha384_ctx_free,
841 sha384_process_wrap,
844 static void sha512_starts_wrap( void *ctx )
846 sha512_starts( (sha512_context *) ctx, 0 );
849 static void sha512_update_wrap( void *ctx, const unsigned char *input,
850 size_t ilen )
852 sha512_update( (sha512_context *) ctx, input, ilen );
855 static void sha512_finish_wrap( void *ctx, unsigned char *output )
857 sha512_finish( (sha512_context *) ctx, output );
860 static void sha512_wrap( const unsigned char *input, size_t ilen,
861 unsigned char *output )
863 sha512( input, ilen, output, 0 );
866 static int sha512_file_wrap( const char *path, unsigned char *output )
868 #if defined(POLARSSL_FS_IO)
869 return sha512_file( path, output, 0 );
870 #else
871 ((void) path);
872 ((void) output);
873 return( POLARSSL_ERR_MD_FEATURE_UNAVAILABLE );
874 #endif
877 static void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key,
878 size_t keylen )
880 sha512_hmac_starts( (sha512_context *) ctx, key, keylen, 0 );
883 static void sha512_hmac_update_wrap( void *ctx, const unsigned char *input,
884 size_t ilen )
886 sha512_hmac_update( (sha512_context *) ctx, input, ilen );
889 static void sha512_hmac_finish_wrap( void *ctx, unsigned char *output )
891 sha512_hmac_finish( (sha512_context *) ctx, output );
894 static void sha512_hmac_reset_wrap( void *ctx )
896 sha512_hmac_reset( (sha512_context *) ctx );
899 static void sha512_hmac_wrap( const unsigned char *key, size_t keylen,
900 const unsigned char *input, size_t ilen,
901 unsigned char *output )
903 sha512_hmac( key, keylen, input, ilen, output, 0 );
906 static void * sha512_ctx_alloc( void )
908 sha512_context *ctx;
909 ctx = polarssl_malloc( sizeof( sha512_context ) );
911 if( ctx == NULL )
912 return( NULL );
914 sha512_init( ctx );
916 return( ctx );
919 static void sha512_ctx_free( void *ctx )
921 sha512_free( (sha512_context *) ctx );
922 polarssl_free( ctx );
925 static void sha512_process_wrap( void *ctx, const unsigned char *data )
927 sha512_process( (sha512_context *) ctx, data );
930 const md_info_t sha512_info = {
931 POLARSSL_MD_SHA512,
932 "SHA512",
934 sha512_starts_wrap,
935 sha512_update_wrap,
936 sha512_finish_wrap,
937 sha512_wrap,
938 sha512_file_wrap,
939 sha512_hmac_starts_wrap,
940 sha512_hmac_update_wrap,
941 sha512_hmac_finish_wrap,
942 sha512_hmac_reset_wrap,
943 sha512_hmac_wrap,
944 sha512_ctx_alloc,
945 sha512_ctx_free,
946 sha512_process_wrap,
949 #endif /* POLARSSL_SHA512_C */
951 #endif /* POLARSSL_MD_C */