PolarSSL v1.3.1
test_suite_hmac_shax.c
Go to the documentation of this file.
1 #include <polarssl/config.h>
2 
3 
4 #include <polarssl/sha1.h>
5 #include <polarssl/sha256.h>
6 #include <polarssl/sha512.h>
7 
8 
9 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
10 #include "polarssl/memory.h"
11 #endif
12 
13 #ifdef _MSC_VER
14 #include <basetsd.h>
15 typedef UINT32 uint32_t;
16 #else
17 #include <inttypes.h>
18 #endif
19 
20 #include <assert.h>
21 #include <stdlib.h>
22 #include <string.h>
23 
24 /*
25  * 32-bit integer manipulation macros (big endian)
26  */
27 #ifndef GET_UINT32_BE
28 #define GET_UINT32_BE(n,b,i) \
29 { \
30  (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
31  | ( (uint32_t) (b)[(i) + 1] << 16 ) \
32  | ( (uint32_t) (b)[(i) + 2] << 8 ) \
33  | ( (uint32_t) (b)[(i) + 3] ); \
34 }
35 #endif
36 
37 #ifndef PUT_UINT32_BE
38 #define PUT_UINT32_BE(n,b,i) \
39 { \
40  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
41  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
42  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
43  (b)[(i) + 3] = (unsigned char) ( (n) ); \
44 }
45 #endif
46 
47 static int unhexify(unsigned char *obuf, const char *ibuf)
48 {
49  unsigned char c, c2;
50  int len = strlen(ibuf) / 2;
51  assert(!(strlen(ibuf) %1)); // must be even number of bytes
52 
53  while (*ibuf != 0)
54  {
55  c = *ibuf++;
56  if( c >= '0' && c <= '9' )
57  c -= '0';
58  else if( c >= 'a' && c <= 'f' )
59  c -= 'a' - 10;
60  else if( c >= 'A' && c <= 'F' )
61  c -= 'A' - 10;
62  else
63  assert( 0 );
64 
65  c2 = *ibuf++;
66  if( c2 >= '0' && c2 <= '9' )
67  c2 -= '0';
68  else if( c2 >= 'a' && c2 <= 'f' )
69  c2 -= 'a' - 10;
70  else if( c2 >= 'A' && c2 <= 'F' )
71  c2 -= 'A' - 10;
72  else
73  assert( 0 );
74 
75  *obuf++ = ( c << 4 ) | c2;
76  }
77 
78  return len;
79 }
80 
81 static void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
82 {
83  unsigned char l, h;
84 
85  while (len != 0)
86  {
87  h = (*ibuf) / 16;
88  l = (*ibuf) % 16;
89 
90  if( h < 10 )
91  *obuf++ = '0' + h;
92  else
93  *obuf++ = 'a' + h - 10;
94 
95  if( l < 10 )
96  *obuf++ = '0' + l;
97  else
98  *obuf++ = 'a' + l - 10;
99 
100  ++ibuf;
101  len--;
102  }
103 }
104 
114 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
115 {
116  size_t i;
117 
118  if( rng_state != NULL )
119  rng_state = NULL;
120 
121  for( i = 0; i < len; ++i )
122  output[i] = rand();
123 
124  return( 0 );
125 }
126 
132 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
133 {
134  if( rng_state != NULL )
135  rng_state = NULL;
136 
137  memset( output, 0, len );
138 
139  return( 0 );
140 }
141 
142 typedef struct
143 {
144  unsigned char *buf;
145  size_t length;
146 } rnd_buf_info;
147 
159 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
160 {
161  rnd_buf_info *info = (rnd_buf_info *) rng_state;
162  size_t use_len;
163 
164  if( rng_state == NULL )
165  return( rnd_std_rand( NULL, output, len ) );
166 
167  use_len = len;
168  if( len > info->length )
169  use_len = info->length;
170 
171  if( use_len )
172  {
173  memcpy( output, info->buf, use_len );
174  info->buf += use_len;
175  info->length -= use_len;
176  }
177 
178  if( len - use_len > 0 )
179  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
180 
181  return( 0 );
182 }
183 
191 typedef struct
192 {
193  uint32_t key[16];
194  uint32_t v0, v1;
196 
205 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
206 {
207  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
208  uint32_t i, *k, sum, delta=0x9E3779B9;
209  unsigned char result[4];
210 
211  if( rng_state == NULL )
212  return( rnd_std_rand( NULL, output, len ) );
213 
214  k = info->key;
215 
216  while( len > 0 )
217  {
218  size_t use_len = ( len > 4 ) ? 4 : len;
219  sum = 0;
220 
221  for( i = 0; i < 32; i++ )
222  {
223  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
224  sum += delta;
225  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
226  }
227 
228  PUT_UINT32_BE( info->v0, result, 0 );
229  memcpy( output, result, use_len );
230  len -= use_len;
231  }
232 
233  return( 0 );
234 }
235 
245 static int not_rnd( void *in, unsigned char *out, size_t len )
246 {
247  unsigned char *obuf;
248  const char *ibuf = in;
249  unsigned char c, c2;
250  assert( len == strlen(ibuf) / 2 );
251  assert(!(strlen(ibuf) %1)); // must be even number of bytes
252 
253  obuf = out + (len - 1); // sic
254  while (*ibuf != 0)
255  {
256  c = *ibuf++;
257  if( c >= '0' && c <= '9' )
258  c -= '0';
259  else if( c >= 'a' && c <= 'f' )
260  c -= 'a' - 10;
261  else if( c >= 'A' && c <= 'F' )
262  c -= 'A' - 10;
263  else
264  assert( 0 );
265 
266  c2 = *ibuf++;
267  if( c2 >= '0' && c2 <= '9' )
268  c2 -= '0';
269  else if( c2 >= 'a' && c2 <= 'f' )
270  c2 -= 'a' - 10;
271  else if( c2 >= 'A' && c2 <= 'F' )
272  c2 -= 'A' - 10;
273  else
274  assert( 0 );
275 
276  *obuf-- = ( c << 4 ) | c2; // sic
277  }
278 
279  return( 0 );
280 }
281 
282 
283 #include <stdio.h>
284 #include <string.h>
285 
286 static int test_errors = 0;
287 
288 
289 #define TEST_SUITE_ACTIVE
290 
291 static int test_assert( int correct, char *test )
292 {
293  if( correct )
294  return( 0 );
295 
296  test_errors++;
297  if( test_errors == 1 )
298  printf( "FAILED\n" );
299  printf( " %s\n", test );
300 
301  return( 1 );
302 }
303 
304 #define TEST_ASSERT( TEST ) \
305  do { test_assert( (TEST) ? 1 : 0, #TEST ); \
306  if( test_errors) return; \
307  } while (0)
308 
309 int verify_string( char **str )
310 {
311  if( (*str)[0] != '"' ||
312  (*str)[strlen( *str ) - 1] != '"' )
313  {
314  printf( "Expected string (with \"\") for parameter and got: %s\n", *str );
315  return( -1 );
316  }
317 
318  (*str)++;
319  (*str)[strlen( *str ) - 1] = '\0';
320 
321  return( 0 );
322 }
323 
324 int verify_int( char *str, int *value )
325 {
326  size_t i;
327  int minus = 0;
328  int digits = 1;
329  int hex = 0;
330 
331  for( i = 0; i < strlen( str ); i++ )
332  {
333  if( i == 0 && str[i] == '-' )
334  {
335  minus = 1;
336  continue;
337  }
338 
339  if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) &&
340  str[i - 1] == '0' && str[i] == 'x' )
341  {
342  hex = 1;
343  continue;
344  }
345 
346  if( str[i] < '0' || str[i] > '9' )
347  {
348  digits = 0;
349  break;
350  }
351  }
352 
353  if( digits )
354  {
355  if( hex )
356  *value = strtol( str, NULL, 16 );
357  else
358  *value = strtol( str, NULL, 10 );
359 
360  return( 0 );
361  }
362 
363 
364 
365  printf( "Expected integer for parameter and got: %s\n", str );
366  return( -1 );
367 }
368 
369 #ifdef POLARSSL_SHA1_C
370 void test_suite_sha1_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
371  char *hex_hash_string)
372 {
373  unsigned char src_str[10000];
374  unsigned char key_str[10000];
375  unsigned char hash_str[10000];
376  unsigned char output[41];
377  int key_len, src_len;
378 
379  memset(src_str, 0x00, 10000);
380  memset(key_str, 0x00, 10000);
381  memset(hash_str, 0x00, 10000);
382  memset(output, 0x00, 41);
383 
384  key_len = unhexify( key_str, hex_key_string );
385  src_len = unhexify( src_str, hex_src_string );
386 
387  sha1_hmac( key_str, key_len, src_str, src_len, output );
388  hexify( hash_str, output, 20 );
389 
390  TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
391 }
392 #endif /* POLARSSL_SHA1_C */
393 
394 #ifdef POLARSSL_SHA256_C
395 void test_suite_sha224_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
396  char *hex_hash_string)
397 {
398  unsigned char src_str[10000];
399  unsigned char key_str[10000];
400  unsigned char hash_str[10000];
401  unsigned char output[57];
402  int key_len, src_len;
403 
404  memset(src_str, 0x00, 10000);
405  memset(key_str, 0x00, 10000);
406  memset(hash_str, 0x00, 10000);
407  memset(output, 0x00, 57);
408 
409  key_len = unhexify( key_str, hex_key_string );
410  src_len = unhexify( src_str, hex_src_string );
411 
412  sha256_hmac( key_str, key_len, src_str, src_len, output, 1 );
413  hexify( hash_str, output, 28 );
414 
415  TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
416 }
417 #endif /* POLARSSL_SHA256_C */
418 
419 #ifdef POLARSSL_SHA256_C
420 void test_suite_sha256_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
421  char *hex_hash_string)
422 {
423  unsigned char src_str[10000];
424  unsigned char key_str[10000];
425  unsigned char hash_str[10000];
426  unsigned char output[65];
427  int key_len, src_len;
428 
429  memset(src_str, 0x00, 10000);
430  memset(key_str, 0x00, 10000);
431  memset(hash_str, 0x00, 10000);
432  memset(output, 0x00, 65);
433 
434  key_len = unhexify( key_str, hex_key_string );
435  src_len = unhexify( src_str, hex_src_string );
436 
437  sha256_hmac( key_str, key_len, src_str, src_len, output, 0 );
438  hexify( hash_str, output, 32 );
439 
440  TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
441 }
442 #endif /* POLARSSL_SHA256_C */
443 
444 #ifdef POLARSSL_SHA512_C
445 void test_suite_sha384_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
446  char *hex_hash_string)
447 {
448  unsigned char src_str[10000];
449  unsigned char key_str[10000];
450  unsigned char hash_str[10000];
451  unsigned char output[97];
452  int key_len, src_len;
453 
454  memset(src_str, 0x00, 10000);
455  memset(key_str, 0x00, 10000);
456  memset(hash_str, 0x00, 10000);
457  memset(output, 0x00, 97);
458 
459  key_len = unhexify( key_str, hex_key_string );
460  src_len = unhexify( src_str, hex_src_string );
461 
462  sha512_hmac( key_str, key_len, src_str, src_len, output, 1 );
463  hexify( hash_str, output, 48 );
464 
465  TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
466 }
467 #endif /* POLARSSL_SHA512_C */
468 
469 #ifdef POLARSSL_SHA512_C
470 void test_suite_sha512_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
471  char *hex_hash_string)
472 {
473  unsigned char src_str[10000];
474  unsigned char key_str[10000];
475  unsigned char hash_str[10000];
476  unsigned char output[129];
477  int key_len, src_len;
478 
479  memset(src_str, 0x00, 10000);
480  memset(key_str, 0x00, 10000);
481  memset(hash_str, 0x00, 10000);
482  memset(output, 0x00, 129);
483 
484  key_len = unhexify( key_str, hex_key_string );
485  src_len = unhexify( src_str, hex_src_string );
486 
487  sha512_hmac( key_str, key_len, src_str, src_len, output, 0 );
488  hexify( hash_str, output, 64 );
489 
490  TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
491 }
492 #endif /* POLARSSL_SHA512_C */
493 
494 
495 
496 
497 int dep_check( char *str )
498 {
499  if( str == NULL )
500  return( 1 );
501 
502  if( strcmp( str, "POLARSSL_SHA256_C" ) == 0 )
503  {
504 #if defined(POLARSSL_SHA256_C)
505  return( 0 );
506 #else
507  return( 1 );
508 #endif
509  }
510  if( strcmp( str, "POLARSSL_SHA1_C" ) == 0 )
511  {
512 #if defined(POLARSSL_SHA1_C)
513  return( 0 );
514 #else
515  return( 1 );
516 #endif
517  }
518  if( strcmp( str, "POLARSSL_SHA512_C" ) == 0 )
519  {
520 #if defined(POLARSSL_SHA512_C)
521  return( 0 );
522 #else
523  return( 1 );
524 #endif
525  }
526 
527 
528  return( 1 );
529 }
530 
531 int dispatch_test(int cnt, char *params[50])
532 {
533  int ret;
534  ((void) cnt);
535  ((void) params);
536 
537 #if defined(TEST_SUITE_ACTIVE)
538  if( strcmp( params[0], "sha1_hmac" ) == 0 )
539  {
540  #ifdef POLARSSL_SHA1_C
541 
542  int param1;
543  char *param2 = params[2];
544  char *param3 = params[3];
545  char *param4 = params[4];
546 
547  if( cnt != 5 )
548  {
549  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 5 );
550  return( 2 );
551  }
552 
553  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
554  if( verify_string( &param2 ) != 0 ) return( 2 );
555  if( verify_string( &param3 ) != 0 ) return( 2 );
556  if( verify_string( &param4 ) != 0 ) return( 2 );
557 
558  test_suite_sha1_hmac( param1, param2, param3, param4 );
559  return ( 0 );
560  #endif /* POLARSSL_SHA1_C */
561 
562  return ( 3 );
563  }
564  else
565  if( strcmp( params[0], "sha224_hmac" ) == 0 )
566  {
567  #ifdef POLARSSL_SHA256_C
568 
569  int param1;
570  char *param2 = params[2];
571  char *param3 = params[3];
572  char *param4 = params[4];
573 
574  if( cnt != 5 )
575  {
576  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 5 );
577  return( 2 );
578  }
579 
580  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
581  if( verify_string( &param2 ) != 0 ) return( 2 );
582  if( verify_string( &param3 ) != 0 ) return( 2 );
583  if( verify_string( &param4 ) != 0 ) return( 2 );
584 
585  test_suite_sha224_hmac( param1, param2, param3, param4 );
586  return ( 0 );
587  #endif /* POLARSSL_SHA256_C */
588 
589  return ( 3 );
590  }
591  else
592  if( strcmp( params[0], "sha256_hmac" ) == 0 )
593  {
594  #ifdef POLARSSL_SHA256_C
595 
596  int param1;
597  char *param2 = params[2];
598  char *param3 = params[3];
599  char *param4 = params[4];
600 
601  if( cnt != 5 )
602  {
603  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 5 );
604  return( 2 );
605  }
606 
607  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
608  if( verify_string( &param2 ) != 0 ) return( 2 );
609  if( verify_string( &param3 ) != 0 ) return( 2 );
610  if( verify_string( &param4 ) != 0 ) return( 2 );
611 
612  test_suite_sha256_hmac( param1, param2, param3, param4 );
613  return ( 0 );
614  #endif /* POLARSSL_SHA256_C */
615 
616  return ( 3 );
617  }
618  else
619  if( strcmp( params[0], "sha384_hmac" ) == 0 )
620  {
621  #ifdef POLARSSL_SHA512_C
622 
623  int param1;
624  char *param2 = params[2];
625  char *param3 = params[3];
626  char *param4 = params[4];
627 
628  if( cnt != 5 )
629  {
630  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 5 );
631  return( 2 );
632  }
633 
634  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
635  if( verify_string( &param2 ) != 0 ) return( 2 );
636  if( verify_string( &param3 ) != 0 ) return( 2 );
637  if( verify_string( &param4 ) != 0 ) return( 2 );
638 
639  test_suite_sha384_hmac( param1, param2, param3, param4 );
640  return ( 0 );
641  #endif /* POLARSSL_SHA512_C */
642 
643  return ( 3 );
644  }
645  else
646  if( strcmp( params[0], "sha512_hmac" ) == 0 )
647  {
648  #ifdef POLARSSL_SHA512_C
649 
650  int param1;
651  char *param2 = params[2];
652  char *param3 = params[3];
653  char *param4 = params[4];
654 
655  if( cnt != 5 )
656  {
657  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 5 );
658  return( 2 );
659  }
660 
661  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
662  if( verify_string( &param2 ) != 0 ) return( 2 );
663  if( verify_string( &param3 ) != 0 ) return( 2 );
664  if( verify_string( &param4 ) != 0 ) return( 2 );
665 
666  test_suite_sha512_hmac( param1, param2, param3, param4 );
667  return ( 0 );
668  #endif /* POLARSSL_SHA512_C */
669 
670  return ( 3 );
671  }
672  else
673 
674  {
675  fprintf( stdout, "FAILED\nSkipping unknown test function '%s'\n", params[0] );
676  fflush( stdout );
677  return( 1 );
678  }
679 #else
680  return( 3 );
681 #endif
682  return( ret );
683 }
684 
685 int get_line( FILE *f, char *buf, size_t len )
686 {
687  char *ret;
688 
689  ret = fgets( buf, len, f );
690  if( ret == NULL )
691  return( -1 );
692 
693  if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
694  buf[strlen(buf) - 1] = '\0';
695  if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
696  buf[strlen(buf) - 1] = '\0';
697 
698  return( 0 );
699 }
700 
701 int parse_arguments( char *buf, size_t len, char *params[50] )
702 {
703  int cnt = 0, i;
704  char *cur = buf;
705  char *p = buf, *q;
706 
707  params[cnt++] = cur;
708 
709  while( *p != '\0' && p < buf + len )
710  {
711  if( *p == '\\' )
712  {
713  *p++;
714  *p++;
715  continue;
716  }
717  if( *p == ':' )
718  {
719  if( p + 1 < buf + len )
720  {
721  cur = p + 1;
722  params[cnt++] = cur;
723  }
724  *p = '\0';
725  }
726 
727  *p++;
728  }
729 
730  // Replace newlines, question marks and colons in strings
731  for( i = 0; i < cnt; i++ )
732  {
733  p = params[i];
734  q = params[i];
735 
736  while( *p != '\0' )
737  {
738  if( *p == '\\' && *(p + 1) == 'n' )
739  {
740  p += 2;
741  *(q++) = '\n';
742  }
743  else if( *p == '\\' && *(p + 1) == ':' )
744  {
745  p += 2;
746  *(q++) = ':';
747  }
748  else if( *p == '\\' && *(p + 1) == '?' )
749  {
750  p += 2;
751  *(q++) = '?';
752  }
753  else
754  *(q++) = *(p++);
755  }
756  *q = '\0';
757  }
758 
759  return( cnt );
760 }
761 
762 int main()
763 {
764  int ret, i, cnt, total_errors = 0, total_tests = 0, total_skipped = 0;
765  const char *filename = "/home/iurt/rpmbuild/BUILD/polarssl-1.3.1/tests/suites/test_suite_hmac_shax.data";
766  FILE *file;
767  char buf[5000];
768  char *params[50];
769 
770 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
771  unsigned char alloc_buf[1000000];
772  memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
773 #endif
774 
775  file = fopen( filename, "r" );
776  if( file == NULL )
777  {
778  fprintf( stderr, "Failed to open\n" );
779  return( 1 );
780  }
781 
782  while( !feof( file ) )
783  {
784  int skip = 0;
785 
786  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
787  break;
788  fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
789  fprintf( stdout, " " );
790  for( i = strlen( buf ) + 1; i < 67; i++ )
791  fprintf( stdout, "." );
792  fprintf( stdout, " " );
793  fflush( stdout );
794 
795  total_tests++;
796 
797  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
798  break;
799  cnt = parse_arguments( buf, strlen(buf), params );
800 
801  if( strcmp( params[0], "depends_on" ) == 0 )
802  {
803  for( i = 1; i < cnt; i++ )
804  if( dep_check( params[i] ) != 0 )
805  skip = 1;
806 
807  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
808  break;
809  cnt = parse_arguments( buf, strlen(buf), params );
810  }
811 
812  if( skip == 0 )
813  {
814  test_errors = 0;
815  ret = dispatch_test( cnt, params );
816  }
817 
818  if( skip == 1 || ret == 3 )
819  {
820  total_skipped++;
821  fprintf( stdout, "----\n" );
822  fflush( stdout );
823  }
824  else if( ret == 0 && test_errors == 0 )
825  {
826  fprintf( stdout, "PASS\n" );
827  fflush( stdout );
828  }
829  else if( ret == 2 )
830  {
831  fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
832  fclose(file);
833  exit( 2 );
834  }
835  else
836  total_errors++;
837 
838  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
839  break;
840  if( strlen(buf) != 0 )
841  {
842  fprintf( stderr, "Should be empty %d\n", (int) strlen(buf) );
843  return( 1 );
844  }
845  }
846  fclose(file);
847 
848  fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");
849  if( total_errors == 0 )
850  fprintf( stdout, "PASSED" );
851  else
852  fprintf( stdout, "FAILED" );
853 
854  fprintf( stdout, " (%d / %d tests (%d skipped))\n",
855  total_tests - total_errors, total_tests, total_skipped );
856 
857 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
858 #if defined(POLARSSL_MEMORY_DEBUG)
859  memory_buffer_alloc_status();
860 #endif
861  memory_buffer_alloc_free();
862 #endif
863 
864  return( total_errors != 0 );
865 }
866 
867