PolarSSL v1.3.9
test_suite_pkcs5.c
Go to the documentation of this file.
1#if !defined(POLARSSL_CONFIG_FILE)
2#include <polarssl/config.h>
3#else
4#include POLARSSL_CONFIG_FILE
5#endif
6
7#ifdef POLARSSL_PKCS5_C
8
9#include <polarssl/pkcs5.h>
10#endif /* POLARSSL_PKCS5_C */
11
12
13#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
14#include "polarssl/memory.h"
15#endif
16
17#if defined(POLARSSL_PLATFORM_C)
18#include "polarssl/platform.h"
19#else
20#define polarssl_malloc malloc
21#define polarssl_free free
22#endif
23
24#ifdef _MSC_VER
25#include <basetsd.h>
26typedef UINT32 uint32_t;
27#else
28#include <inttypes.h>
29#endif
30
31#include <assert.h>
32#include <stdlib.h>
33#include <string.h>
34
35/*
36 * 32-bit integer manipulation macros (big endian)
37 */
38#ifndef GET_UINT32_BE
39#define GET_UINT32_BE(n,b,i) \
40{ \
41 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
42 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
43 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
44 | ( (uint32_t) (b)[(i) + 3] ); \
45}
46#endif
47
48#ifndef PUT_UINT32_BE
49#define PUT_UINT32_BE(n,b,i) \
50{ \
51 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
52 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
53 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
54 (b)[(i) + 3] = (unsigned char) ( (n) ); \
55}
56#endif
57
58static int unhexify(unsigned char *obuf, const char *ibuf)
59{
60 unsigned char c, c2;
61 int len = strlen(ibuf) / 2;
62 assert(!(strlen(ibuf) %1)); // must be even number of bytes
63
64 while (*ibuf != 0)
65 {
66 c = *ibuf++;
67 if( c >= '0' && c <= '9' )
68 c -= '0';
69 else if( c >= 'a' && c <= 'f' )
70 c -= 'a' - 10;
71 else if( c >= 'A' && c <= 'F' )
72 c -= 'A' - 10;
73 else
74 assert( 0 );
75
76 c2 = *ibuf++;
77 if( c2 >= '0' && c2 <= '9' )
78 c2 -= '0';
79 else if( c2 >= 'a' && c2 <= 'f' )
80 c2 -= 'a' - 10;
81 else if( c2 >= 'A' && c2 <= 'F' )
82 c2 -= 'A' - 10;
83 else
84 assert( 0 );
85
86 *obuf++ = ( c << 4 ) | c2;
87 }
88
89 return len;
90}
91
92static void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
93{
94 unsigned char l, h;
95
96 while (len != 0)
97 {
98 h = (*ibuf) / 16;
99 l = (*ibuf) % 16;
100
101 if( h < 10 )
102 *obuf++ = '0' + h;
103 else
104 *obuf++ = 'a' + h - 10;
105
106 if( l < 10 )
107 *obuf++ = '0' + l;
108 else
109 *obuf++ = 'a' + l - 10;
110
111 ++ibuf;
112 len--;
113 }
114}
115
123static unsigned char *zero_alloc( size_t len )
124{
125 void *p;
126 size_t actual_len = len != 0 ? len : 1;
127
128 p = polarssl_malloc( actual_len );
129 assert( p != NULL );
130
131 memset( p, 0x00, actual_len );
132
133 return( p );
134}
135
146static unsigned char *unhexify_alloc( const char *ibuf, size_t *olen )
147{
148 unsigned char *obuf;
149
150 *olen = strlen(ibuf) / 2;
151
152 if( *olen == 0 )
153 return( zero_alloc( *olen ) );
154
155 obuf = polarssl_malloc( *olen );
156 assert( obuf != NULL );
157
158 (void) unhexify( obuf, ibuf );
159
160 return( obuf );
161}
162
172static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
173{
174#if !defined(__OpenBSD__)
175 size_t i;
176
177 if( rng_state != NULL )
178 rng_state = NULL;
179
180 for( i = 0; i < len; ++i )
181 output[i] = rand();
182#else
183 if( rng_state != NULL )
184 rng_state = NULL;
185
186 arc4random_buf( output, len );
187#endif /* !OpenBSD */
188
189 return( 0 );
190}
191
197static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
198{
199 if( rng_state != NULL )
200 rng_state = NULL;
201
202 memset( output, 0, len );
203
204 return( 0 );
205}
206
207typedef struct
208{
209 unsigned char *buf;
210 size_t length;
212
224static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
225{
226 rnd_buf_info *info = (rnd_buf_info *) rng_state;
227 size_t use_len;
228
229 if( rng_state == NULL )
230 return( rnd_std_rand( NULL, output, len ) );
231
232 use_len = len;
233 if( len > info->length )
234 use_len = info->length;
235
236 if( use_len )
237 {
238 memcpy( output, info->buf, use_len );
239 info->buf += use_len;
240 info->length -= use_len;
241 }
242
243 if( len - use_len > 0 )
244 return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
245
246 return( 0 );
247}
248
256typedef struct
257{
258 uint32_t key[16];
259 uint32_t v0, v1;
261
270static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
271{
272 rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
273 uint32_t i, *k, sum, delta=0x9E3779B9;
274 unsigned char result[4], *out = output;
275
276 if( rng_state == NULL )
277 return( rnd_std_rand( NULL, output, len ) );
278
279 k = info->key;
280
281 while( len > 0 )
282 {
283 size_t use_len = ( len > 4 ) ? 4 : len;
284 sum = 0;
285
286 for( i = 0; i < 32; i++ )
287 {
288 info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
289 sum += delta;
290 info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
291 }
292
293 PUT_UINT32_BE( info->v0, result, 0 );
294 memcpy( out, result, use_len );
295 len -= use_len;
296 out += 4;
297 }
298
299 return( 0 );
300}
301
302
303#include <stdio.h>
304#include <string.h>
305
306#if defined(POLARSSL_PLATFORM_C)
307#include "polarssl/platform.h"
308#else
309#define polarssl_printf printf
310#define polarssl_malloc malloc
311#define polarssl_free free
312#endif
313
314static int test_errors = 0;
315
316#ifdef POLARSSL_PKCS5_C
317
318#define TEST_SUITE_ACTIVE
319
320static int test_assert( int correct, const char *test )
321{
322 if( correct )
323 return( 0 );
324
325 test_errors++;
326 if( test_errors == 1 )
327 printf( "FAILED\n" );
328 printf( " %s\n", test );
329
330 return( 1 );
331}
332
333#define TEST_ASSERT( TEST ) \
334 do { test_assert( (TEST) ? 1 : 0, #TEST ); \
335 if( test_errors) goto exit; \
336 } while (0)
337
338int verify_string( char **str )
339{
340 if( (*str)[0] != '"' ||
341 (*str)[strlen( *str ) - 1] != '"' )
342 {
343 printf( "Expected string (with \"\") for parameter and got: %s\n", *str );
344 return( -1 );
345 }
346
347 (*str)++;
348 (*str)[strlen( *str ) - 1] = '\0';
349
350 return( 0 );
351}
352
353int verify_int( char *str, int *value )
354{
355 size_t i;
356 int minus = 0;
357 int digits = 1;
358 int hex = 0;
359
360 for( i = 0; i < strlen( str ); i++ )
361 {
362 if( i == 0 && str[i] == '-' )
363 {
364 minus = 1;
365 continue;
366 }
367
368 if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) &&
369 str[i - 1] == '0' && str[i] == 'x' )
370 {
371 hex = 1;
372 continue;
373 }
374
375 if( ! ( ( str[i] >= '0' && str[i] <= '9' ) ||
376 ( hex && ( ( str[i] >= 'a' && str[i] <= 'f' ) ||
377 ( str[i] >= 'A' && str[i] <= 'F' ) ) ) ) )
378 {
379 digits = 0;
380 break;
381 }
382 }
383
384 if( digits )
385 {
386 if( hex )
387 *value = strtol( str, NULL, 16 );
388 else
389 *value = strtol( str, NULL, 10 );
390
391 return( 0 );
392 }
393
394 if( strcmp( str, "POLARSSL_ERR_PKCS5_INVALID_FORMAT + POLARSSL_ERR_ASN1_UNEXPECTED_TAG" ) == 0 )
395 {
397 return( 0 );
398 }
399 if( strcmp( str, "ASN1_CONSTRUCTED | ASN1_SEQUENCE" ) == 0 )
400 {
401 *value = ( ASN1_CONSTRUCTED | ASN1_SEQUENCE );
402 return( 0 );
403 }
404 if( strcmp( str, "POLARSSL_MD_SHA1" ) == 0 )
405 {
406 *value = ( POLARSSL_MD_SHA1 );
407 return( 0 );
408 }
409 if( strcmp( str, "POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH" ) == 0 )
410 {
412 return( 0 );
413 }
414 if( strcmp( str, "POLARSSL_ERR_PKCS5_INVALID_FORMAT" ) == 0 )
415 {
417 return( 0 );
418 }
419 if( strcmp( str, "POLARSSL_ERR_PKCS5_INVALID_FORMAT + POLARSSL_ERR_ASN1_LENGTH_MISMATCH" ) == 0 )
420 {
422 return( 0 );
423 }
424 if( strcmp( str, "POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE" ) == 0 )
425 {
427 return( 0 );
428 }
429 if( strcmp( str, "POLARSSL_ERR_PKCS5_INVALID_FORMAT + POLARSSL_ERR_ASN1_OUT_OF_DATA" ) == 0 )
430 {
432 return( 0 );
433 }
434 if( strcmp( str, "ASN1_SEQUENCE" ) == 0 )
435 {
436 *value = ( ASN1_SEQUENCE );
437 return( 0 );
438 }
439
440
441 printf( "Expected integer for parameter and got: %s\n", str );
442 return( -1 );
443}
444
445void test_suite_pbkdf2_hmac( int hash, char *hex_password_string,
446 char *hex_salt_string, int it_cnt, int key_len,
447 char *result_key_string )
448{
449 unsigned char pw_str[100];
450 unsigned char salt_str[100];
451 unsigned char dst_str[100];
452
453 md_context_t ctx;
454 const md_info_t *info;
455
456 int pw_len, salt_len;
457 unsigned char key[100];
458
459 md_init( &ctx );
460
461 memset(pw_str, 0x00, 100);
462 memset(salt_str, 0x00, 100);
463 memset(dst_str, 0x00, 100);
464
465 pw_len = unhexify( pw_str, hex_password_string );
466 salt_len = unhexify( salt_str, hex_salt_string );
467
468
469 info = md_info_from_type( hash );
470 TEST_ASSERT( info != NULL );
471 if( info == NULL )
472 return;
473 TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 );
474 TEST_ASSERT( pkcs5_pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len,
475 it_cnt, key_len, key ) == 0 );
476
477 hexify( dst_str, key, key_len );
478 TEST_ASSERT( strcmp( (char *) dst_str, result_key_string ) == 0 );
479
480exit:
481 md_free( &ctx );
482}
483
484void test_suite_pkcs5_pbes2( int params_tag, char *params_hex, char *pw_hex,
485 char *data_hex, int ref_ret, char *ref_out_hex )
486{
487 int my_ret;
488 asn1_buf params;
489 unsigned char *my_out = NULL, *ref_out = NULL, *data = NULL, *pw = NULL;
490 size_t ref_out_len, data_len, pw_len;
491
492 params.tag = params_tag;
493 params.p = unhexify_alloc( params_hex, &params.len );
494
495 data = unhexify_alloc( data_hex, &data_len );
496 pw = unhexify_alloc( pw_hex, &pw_len );
497 ref_out = unhexify_alloc( ref_out_hex, &ref_out_len );
498 my_out = zero_alloc( ref_out_len );
499
500 my_ret = pkcs5_pbes2( &params, PKCS5_DECRYPT,
501 pw, pw_len, data, data_len, my_out );
502 TEST_ASSERT( my_ret == ref_ret );
503
504 if( ref_ret == 0 )
505 TEST_ASSERT( memcmp( my_out, ref_out, ref_out_len ) == 0 );
506
507exit:
508 polarssl_free( params.p );
509 polarssl_free( data );
510 polarssl_free( pw );
511 polarssl_free( ref_out );
512 polarssl_free( my_out );
513}
514
515
516#endif /* POLARSSL_PKCS5_C */
517
518
519int dep_check( char *str )
520{
521 if( str == NULL )
522 return( 1 );
523
524 if( strcmp( str, "POLARSSL_SHA1_C" ) == 0 )
525 {
526#if defined(POLARSSL_SHA1_C)
527 return( 0 );
528#else
529 return( 1 );
530#endif
531 }
532 if( strcmp( str, "POLARSSL_DES_C" ) == 0 )
533 {
534#if defined(POLARSSL_DES_C)
535 return( 0 );
536#else
537 return( 1 );
538#endif
539 }
540
541
542 return( 1 );
543}
544
545int dispatch_test(int cnt, char *params[50])
546{
547 int ret;
548 ((void) cnt);
549 ((void) params);
550
551#if defined(TEST_SUITE_ACTIVE)
552 if( strcmp( params[0], "pbkdf2_hmac" ) == 0 )
553 {
554
555 int param1;
556 char *param2 = params[2];
557 char *param3 = params[3];
558 int param4;
559 int param5;
560 char *param6 = params[6];
561
562 if( cnt != 7 )
563 {
564 fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 7 );
565 return( 2 );
566 }
567
568 if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
569 if( verify_string( &param2 ) != 0 ) return( 2 );
570 if( verify_string( &param3 ) != 0 ) return( 2 );
571 if( verify_int( params[4], &param4 ) != 0 ) return( 2 );
572 if( verify_int( params[5], &param5 ) != 0 ) return( 2 );
573 if( verify_string( &param6 ) != 0 ) return( 2 );
574
575 test_suite_pbkdf2_hmac( param1, param2, param3, param4, param5, param6 );
576 return ( 0 );
577
578 return ( 3 );
579 }
580 else
581 if( strcmp( params[0], "pkcs5_pbes2" ) == 0 )
582 {
583
584 int param1;
585 char *param2 = params[2];
586 char *param3 = params[3];
587 char *param4 = params[4];
588 int param5;
589 char *param6 = params[6];
590
591 if( cnt != 7 )
592 {
593 fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 7 );
594 return( 2 );
595 }
596
597 if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
598 if( verify_string( &param2 ) != 0 ) return( 2 );
599 if( verify_string( &param3 ) != 0 ) return( 2 );
600 if( verify_string( &param4 ) != 0 ) return( 2 );
601 if( verify_int( params[5], &param5 ) != 0 ) return( 2 );
602 if( verify_string( &param6 ) != 0 ) return( 2 );
603
604 test_suite_pkcs5_pbes2( param1, param2, param3, param4, param5, param6 );
605 return ( 0 );
606
607 return ( 3 );
608 }
609 else
610
611 {
612 fprintf( stdout, "FAILED\nSkipping unknown test function '%s'\n", params[0] );
613 fflush( stdout );
614 return( 1 );
615 }
616#else
617 return( 3 );
618#endif
619 return( ret );
620}
621
622int get_line( FILE *f, char *buf, size_t len )
623{
624 char *ret;
625
626 ret = fgets( buf, len, f );
627 if( ret == NULL )
628 return( -1 );
629
630 if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
631 buf[strlen(buf) - 1] = '\0';
632 if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
633 buf[strlen(buf) - 1] = '\0';
634
635 return( 0 );
636}
637
638int parse_arguments( char *buf, size_t len, char *params[50] )
639{
640 int cnt = 0, i;
641 char *cur = buf;
642 char *p = buf, *q;
643
644 params[cnt++] = cur;
645
646 while( *p != '\0' && p < buf + len )
647 {
648 if( *p == '\\' )
649 {
650 p++;
651 p++;
652 continue;
653 }
654 if( *p == ':' )
655 {
656 if( p + 1 < buf + len )
657 {
658 cur = p + 1;
659 params[cnt++] = cur;
660 }
661 *p = '\0';
662 }
663
664 p++;
665 }
666
667 // Replace newlines, question marks and colons in strings
668 for( i = 0; i < cnt; i++ )
669 {
670 p = params[i];
671 q = params[i];
672
673 while( *p != '\0' )
674 {
675 if( *p == '\\' && *(p + 1) == 'n' )
676 {
677 p += 2;
678 *(q++) = '\n';
679 }
680 else if( *p == '\\' && *(p + 1) == ':' )
681 {
682 p += 2;
683 *(q++) = ':';
684 }
685 else if( *p == '\\' && *(p + 1) == '?' )
686 {
687 p += 2;
688 *(q++) = '?';
689 }
690 else
691 *(q++) = *(p++);
692 }
693 *q = '\0';
694 }
695
696 return( cnt );
697}
698
699int main()
700{
701 int ret, i, cnt, total_errors = 0, total_tests = 0, total_skipped = 0;
702 const char *filename = "/builddir/build/BUILD/polarssl-1.3.9/tests/suites/test_suite_pkcs5.data";
703 FILE *file;
704 char buf[5000];
705 char *params[50];
706
707#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
708 unsigned char alloc_buf[1000000];
709 memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
710#endif
711
712 file = fopen( filename, "r" );
713 if( file == NULL )
714 {
715 fprintf( stderr, "Failed to open\n" );
716 return( 1 );
717 }
718
719 while( !feof( file ) )
720 {
721 int skip = 0;
722
723 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
724 break;
725 fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
726 fprintf( stdout, " " );
727 for( i = strlen( buf ) + 1; i < 67; i++ )
728 fprintf( stdout, "." );
729 fprintf( stdout, " " );
730 fflush( stdout );
731
732 total_tests++;
733
734 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
735 break;
736 cnt = parse_arguments( buf, strlen(buf), params );
737
738 if( strcmp( params[0], "depends_on" ) == 0 )
739 {
740 for( i = 1; i < cnt; i++ )
741 if( dep_check( params[i] ) != 0 )
742 skip = 1;
743
744 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
745 break;
746 cnt = parse_arguments( buf, strlen(buf), params );
747 }
748
749 if( skip == 0 )
750 {
751 test_errors = 0;
752 ret = dispatch_test( cnt, params );
753 }
754
755 if( skip == 1 || ret == 3 )
756 {
757 total_skipped++;
758 fprintf( stdout, "----\n" );
759 fflush( stdout );
760 }
761 else if( ret == 0 && test_errors == 0 )
762 {
763 fprintf( stdout, "PASS\n" );
764 fflush( stdout );
765 }
766 else if( ret == 2 )
767 {
768 fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
769 fclose(file);
770 exit( 2 );
771 }
772 else
773 total_errors++;
774
775 if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
776 break;
777 if( strlen(buf) != 0 )
778 {
779 fprintf( stderr, "Should be empty %d\n", (int) strlen(buf) );
780 return( 1 );
781 }
782 }
783 fclose(file);
784
785 fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");
786 if( total_errors == 0 )
787 fprintf( stdout, "PASSED" );
788 else
789 fprintf( stdout, "FAILED" );
790
791 fprintf( stdout, " (%d / %d tests (%d skipped))\n",
792 total_tests - total_errors, total_tests, total_skipped );
793
794#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
795#if defined(POLARSSL_MEMORY_DEBUG)
796 memory_buffer_alloc_status();
797#endif
799#endif
800
801 return( total_errors != 0 );
802}
803
804
Configuration options (set of defines)
#define POLARSSL_ERR_ASN1_OUT_OF_DATA
Out of data when parsing an ASN1 data structure.
Definition asn1.h:54
int tag
ASN1 type, e.g.
Definition asn1.h:126
#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG
ASN1 tag was of an unexpected value.
Definition asn1.h:55
size_t len
ASN1 length, e.g.
Definition asn1.h:127
unsigned char * p
ASN1 data, e.g.
Definition asn1.h:128
#define ASN1_CONSTRUCTED
Definition asn1.h:92
#define ASN1_SEQUENCE
Definition asn1.h:82
#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH
Actual length differs from expected length.
Definition asn1.h:57
const md_info_t * md_info_from_type(md_type_t md_type)
Returns the message digest information associated with the given digest type.
int md_init_ctx(md_context_t *ctx, const md_info_t *md_info)
Initialises and fills the message digest context structure with the appropriate values.
void md_free(md_context_t *ctx)
Free and clear the message-specific context of ctx.
void md_init(md_context_t *ctx)
Initialize a md_context (as NONE)
@ POLARSSL_MD_SHA1
Definition md.h:56
Memory allocation layer (Deprecated to platform layer)
void memory_buffer_alloc_free(void)
Free the mutex for thread-safety and clear remaining memory.
int memory_buffer_alloc_init(unsigned char *buf, size_t len)
Initialize use of stack-based memory allocator.
PKCS#5 functions.
int pkcs5_pbes2(asn1_buf *pbe_params, int mode, const unsigned char *pwd, size_t pwdlen, const unsigned char *data, size_t datalen, unsigned char *output)
PKCS#5 PBES2 function.
#define POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH
Given private key password does not allow for correct decryption.
Definition pkcs5.h:47
#define POLARSSL_ERR_PKCS5_INVALID_FORMAT
Unexpected ASN.1 data.
Definition pkcs5.h:45
#define PKCS5_DECRYPT
Definition pkcs5.h:49
int pkcs5_pbkdf2_hmac(md_context_t *ctx, const unsigned char *password, size_t plen, const unsigned char *salt, size_t slen, unsigned int iteration_count, uint32_t key_length, unsigned char *output)
PKCS#5 PBKDF2 using HMAC.
#define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE
Requested encryption or digest alg not available.
Definition pkcs5.h:46
PolarSSL Platform abstraction layer.
Type-length-value structure that allows for ASN1 using DER.
Definition asn1.h:125
Generic message digest context.
Definition md.h:132
Message digest information.
Definition md.h:74
unsigned char * buf
Info structure for the pseudo random function.
int verify_int(char *str, int *value)
static int test_assert(int correct, const char *test)
int verify_string(char **str)
#define TEST_ASSERT(TEST)
static unsigned char * unhexify_alloc(const char *ibuf, size_t *olen)
Allocate and fill a buffer from hex data.
int dep_check(char *str)
int dispatch_test(int cnt, char *params[50])
#define polarssl_malloc
static void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
int parse_arguments(char *buf, size_t len, char *params[50])
#define polarssl_free
#define PUT_UINT32_BE(n, b, i)
static int rnd_pseudo_rand(void *rng_state, unsigned char *output, size_t len)
This function returns random based on a pseudo random function.
int get_line(FILE *f, char *buf, size_t len)
static int test_errors
static int rnd_buffer_rand(void *rng_state, unsigned char *output, size_t len)
This function returns random based on a buffer it receives.
static int unhexify(unsigned char *obuf, const char *ibuf)
static unsigned char * zero_alloc(size_t len)
Allocate and zeroize a buffer.
static int rnd_std_rand(void *rng_state, unsigned char *output, size_t len)
This function just returns data from rand().
int main()
static int rnd_zero_rand(void *rng_state, unsigned char *output, size_t len)
This function only returns zeros.