PolarSSL v1.3.2
test_suite_gcm.aes128_de.c
Go to the documentation of this file.
1 #include <polarssl/config.h>
2 
3 #ifdef POLARSSL_GCM_C
4 
5 #include <polarssl/gcm.h>
6 #endif /* POLARSSL_GCM_C */
7 
8 
9 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
10 #include "polarssl/memory.h"
11 #endif
12 
13 #if defined(WANT_NOT_RND_MPI)
14 #if defined(POLARSSL_BIGNUM_C)
15 #include "polarssl/bignum.h"
16 #else
17 #error "not_rnd_mpi() need bignum.c"
18 #endif
19 #endif
20 
21 #ifdef _MSC_VER
22 #include <basetsd.h>
23 typedef UINT32 uint32_t;
24 #else
25 #include <inttypes.h>
26 #endif
27 
28 #include <assert.h>
29 #include <stdlib.h>
30 #include <string.h>
31 
32 /*
33  * 32-bit integer manipulation macros (big endian)
34  */
35 #ifndef GET_UINT32_BE
36 #define GET_UINT32_BE(n,b,i) \
37 { \
38  (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
39  | ( (uint32_t) (b)[(i) + 1] << 16 ) \
40  | ( (uint32_t) (b)[(i) + 2] << 8 ) \
41  | ( (uint32_t) (b)[(i) + 3] ); \
42 }
43 #endif
44 
45 #ifndef PUT_UINT32_BE
46 #define PUT_UINT32_BE(n,b,i) \
47 { \
48  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
49  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
50  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
51  (b)[(i) + 3] = (unsigned char) ( (n) ); \
52 }
53 #endif
54 
55 static int unhexify(unsigned char *obuf, const char *ibuf)
56 {
57  unsigned char c, c2;
58  int len = strlen(ibuf) / 2;
59  assert(!(strlen(ibuf) %1)); // must be even number of bytes
60 
61  while (*ibuf != 0)
62  {
63  c = *ibuf++;
64  if( c >= '0' && c <= '9' )
65  c -= '0';
66  else if( c >= 'a' && c <= 'f' )
67  c -= 'a' - 10;
68  else if( c >= 'A' && c <= 'F' )
69  c -= 'A' - 10;
70  else
71  assert( 0 );
72 
73  c2 = *ibuf++;
74  if( c2 >= '0' && c2 <= '9' )
75  c2 -= '0';
76  else if( c2 >= 'a' && c2 <= 'f' )
77  c2 -= 'a' - 10;
78  else if( c2 >= 'A' && c2 <= 'F' )
79  c2 -= 'A' - 10;
80  else
81  assert( 0 );
82 
83  *obuf++ = ( c << 4 ) | c2;
84  }
85 
86  return len;
87 }
88 
89 static void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
90 {
91  unsigned char l, h;
92 
93  while (len != 0)
94  {
95  h = (*ibuf) / 16;
96  l = (*ibuf) % 16;
97 
98  if( h < 10 )
99  *obuf++ = '0' + h;
100  else
101  *obuf++ = 'a' + h - 10;
102 
103  if( l < 10 )
104  *obuf++ = '0' + l;
105  else
106  *obuf++ = 'a' + l - 10;
107 
108  ++ibuf;
109  len--;
110  }
111 }
112 
122 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
123 {
124  size_t i;
125 
126  if( rng_state != NULL )
127  rng_state = NULL;
128 
129  for( i = 0; i < len; ++i )
130  output[i] = rand();
131 
132  return( 0 );
133 }
134 
140 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
141 {
142  if( rng_state != NULL )
143  rng_state = NULL;
144 
145  memset( output, 0, len );
146 
147  return( 0 );
148 }
149 
150 typedef struct
151 {
152  unsigned char *buf;
153  size_t length;
154 } rnd_buf_info;
155 
167 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
168 {
169  rnd_buf_info *info = (rnd_buf_info *) rng_state;
170  size_t use_len;
171 
172  if( rng_state == NULL )
173  return( rnd_std_rand( NULL, output, len ) );
174 
175  use_len = len;
176  if( len > info->length )
177  use_len = info->length;
178 
179  if( use_len )
180  {
181  memcpy( output, info->buf, use_len );
182  info->buf += use_len;
183  info->length -= use_len;
184  }
185 
186  if( len - use_len > 0 )
187  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
188 
189  return( 0 );
190 }
191 
199 typedef struct
200 {
201  uint32_t key[16];
202  uint32_t v0, v1;
204 
213 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
214 {
215  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
216  uint32_t i, *k, sum, delta=0x9E3779B9;
217  unsigned char result[4];
218 
219  if( rng_state == NULL )
220  return( rnd_std_rand( NULL, output, len ) );
221 
222  k = info->key;
223 
224  while( len > 0 )
225  {
226  size_t use_len = ( len > 4 ) ? 4 : len;
227  sum = 0;
228 
229  for( i = 0; i < 32; i++ )
230  {
231  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
232  sum += delta;
233  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
234  }
235 
236  PUT_UINT32_BE( info->v0, result, 0 );
237  memcpy( output, result, use_len );
238  len -= use_len;
239  }
240 
241  return( 0 );
242 }
243 
244 #if defined(WANT_NOT_RND_MPI)
245 
253 #define ciL (sizeof(t_uint)) /* chars in limb */
254 #define CHARS_TO_LIMBS(i) (((i) + ciL - 1) / ciL)
255 static int not_rnd_mpi( void *in, unsigned char *out, size_t len )
256 {
257  char *str = (char *) in;
258  mpi X;
259 
260  /*
261  * The 'in' pointer we get is from an MPI prepared by mpi_fill_random(),
262  * just reconstruct the rest in order to be able to call mpi_read_string()
263  */
264  X.s = 1;
265  X.p = (t_uint *) out;
266  X.n = CHARS_TO_LIMBS( len );
267 
268  /*
269  * If str is too long, mpi_read_string() will try to allocate a new buffer
270  * for X.p, which we want to avoid at all costs.
271  */
272  assert( strlen( str ) / 2 == len );
273 
274  return( mpi_read_string( &X, 16, str ) );
275 }
276 #endif /* WANT_NOT_RND_MPI */
277 
278 
279 #include <stdio.h>
280 #include <string.h>
281 
282 static int test_errors = 0;
283 
284 #ifdef POLARSSL_GCM_C
285 
286 #define TEST_SUITE_ACTIVE
287 
288 static int test_assert( int correct, char *test )
289 {
290  if( correct )
291  return( 0 );
292 
293  test_errors++;
294  if( test_errors == 1 )
295  printf( "FAILED\n" );
296  printf( " %s\n", test );
297 
298  return( 1 );
299 }
300 
301 #define TEST_ASSERT( TEST ) \
302  do { test_assert( (TEST) ? 1 : 0, #TEST ); \
303  if( test_errors) return; \
304  } while (0)
305 
306 int verify_string( char **str )
307 {
308  if( (*str)[0] != '"' ||
309  (*str)[strlen( *str ) - 1] != '"' )
310  {
311  printf( "Expected string (with \"\") for parameter and got: %s\n", *str );
312  return( -1 );
313  }
314 
315  (*str)++;
316  (*str)[strlen( *str ) - 1] = '\0';
317 
318  return( 0 );
319 }
320 
321 int verify_int( char *str, int *value )
322 {
323  size_t i;
324  int minus = 0;
325  int digits = 1;
326  int hex = 0;
327 
328  for( i = 0; i < strlen( str ); i++ )
329  {
330  if( i == 0 && str[i] == '-' )
331  {
332  minus = 1;
333  continue;
334  }
335 
336  if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) &&
337  str[i - 1] == '0' && str[i] == 'x' )
338  {
339  hex = 1;
340  continue;
341  }
342 
343  if( str[i] < '0' || str[i] > '9' )
344  {
345  digits = 0;
346  break;
347  }
348  }
349 
350  if( digits )
351  {
352  if( hex )
353  *value = strtol( str, NULL, 16 );
354  else
355  *value = strtol( str, NULL, 10 );
356 
357  return( 0 );
358  }
359 
360  if( strcmp( str, "POLARSSL_CIPHER_ID_AES" ) == 0 )
361  {
362  *value = ( POLARSSL_CIPHER_ID_AES );
363  return( 0 );
364  }
365 
366 
367  printf( "Expected integer for parameter and got: %s\n", str );
368  return( -1 );
369 }
370 
371 void test_suite_gcm_encrypt_and_tag( int cipher_id,
372  char *hex_key_string, char *hex_src_string,
373  char *hex_iv_string, char *hex_add_string,
374  char *hex_dst_string, int tag_len_bits,
375  char *hex_tag_string, int init_result )
376 {
377  unsigned char key_str[128];
378  unsigned char src_str[128];
379  unsigned char dst_str[257];
380  unsigned char iv_str[128];
381  unsigned char add_str[128];
382  unsigned char tag_str[128];
383  unsigned char output[128];
384  unsigned char tag_output[16];
385  gcm_context ctx;
386  unsigned int key_len;
387  size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8;
388 
389  memset(key_str, 0x00, 128);
390  memset(src_str, 0x00, 128);
391  memset(dst_str, 0x00, 257);
392  memset(iv_str, 0x00, 128);
393  memset(add_str, 0x00, 128);
394  memset(tag_str, 0x00, 128);
395  memset(output, 0x00, 128);
396  memset(tag_output, 0x00, 16);
397 
398  key_len = unhexify( key_str, hex_key_string );
399  pt_len = unhexify( src_str, hex_src_string );
400  iv_len = unhexify( iv_str, hex_iv_string );
401  add_len = unhexify( add_str, hex_add_string );
402 
403  TEST_ASSERT( gcm_init( &ctx, cipher_id, key_str, key_len * 8 ) == init_result );
404  if( init_result == 0 )
405  {
406  TEST_ASSERT( gcm_crypt_and_tag( &ctx, GCM_ENCRYPT, pt_len, iv_str, iv_len, add_str, add_len, src_str, output, tag_len, tag_output ) == 0 );
407  hexify( dst_str, output, pt_len );
408  hexify( tag_str, tag_output, tag_len );
409 
410  TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
411  TEST_ASSERT( strcmp( (char *) tag_str, hex_tag_string ) == 0 );
412  }
413 
414  gcm_free( &ctx );
415 }
416 
417 void test_suite_gcm_decrypt_and_verify( int cipher_id,
418  char *hex_key_string, char *hex_src_string,
419  char *hex_iv_string, char *hex_add_string,
420  int tag_len_bits, char *hex_tag_string,
421  char *pt_result, int init_result )
422 {
423  unsigned char key_str[128];
424  unsigned char src_str[128];
425  unsigned char dst_str[257];
426  unsigned char iv_str[128];
427  unsigned char add_str[128];
428  unsigned char tag_str[128];
429  unsigned char output[128];
430  gcm_context ctx;
431  unsigned int key_len;
432  size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8;
433  int ret;
434 
435  memset(key_str, 0x00, 128);
436  memset(src_str, 0x00, 128);
437  memset(dst_str, 0x00, 257);
438  memset(iv_str, 0x00, 128);
439  memset(add_str, 0x00, 128);
440  memset(tag_str, 0x00, 128);
441  memset(output, 0x00, 128);
442 
443  key_len = unhexify( key_str, hex_key_string );
444  pt_len = unhexify( src_str, hex_src_string );
445  iv_len = unhexify( iv_str, hex_iv_string );
446  add_len = unhexify( add_str, hex_add_string );
447  unhexify( tag_str, hex_tag_string );
448 
449  TEST_ASSERT( gcm_init( &ctx, cipher_id, key_str, key_len * 8 ) == init_result );
450  if( init_result == 0 )
451  {
452  ret = gcm_auth_decrypt( &ctx, pt_len, iv_str, iv_len, add_str, add_len, tag_str, tag_len, src_str, output );
453 
454  if( strcmp( "FAIL", pt_result ) == 0 )
455  {
457  }
458  else
459  {
460  TEST_ASSERT( ret == 0 );
461  hexify( dst_str, output, pt_len );
462 
463  TEST_ASSERT( strcmp( (char *) dst_str, pt_result ) == 0 );
464  }
465  }
466 
467  gcm_free( &ctx );
468 }
469 
470 #ifdef POLARSSL_SELF_TEST
471 void test_suite_gcm_selftest()
472 {
473  TEST_ASSERT( gcm_self_test( 0 ) == 0 );
474 }
475 #endif /* POLARSSL_SELF_TEST */
476 
477 
478 #endif /* POLARSSL_GCM_C */
479 
480 
481 int dep_check( char *str )
482 {
483  if( str == NULL )
484  return( 1 );
485 
486  if( strcmp( str, "POLARSSL_AES_C" ) == 0 )
487  {
488 #if defined(POLARSSL_AES_C)
489  return( 0 );
490 #else
491  return( 1 );
492 #endif
493  }
494 
495 
496  return( 1 );
497 }
498 
499 int dispatch_test(int cnt, char *params[50])
500 {
501  int ret;
502  ((void) cnt);
503  ((void) params);
504 
505 #if defined(TEST_SUITE_ACTIVE)
506  if( strcmp( params[0], "gcm_encrypt_and_tag" ) == 0 )
507  {
508 
509  int param1;
510  char *param2 = params[2];
511  char *param3 = params[3];
512  char *param4 = params[4];
513  char *param5 = params[5];
514  char *param6 = params[6];
515  int param7;
516  char *param8 = params[8];
517  int param9;
518 
519  if( cnt != 10 )
520  {
521  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 10 );
522  return( 2 );
523  }
524 
525  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
526  if( verify_string( &param2 ) != 0 ) return( 2 );
527  if( verify_string( &param3 ) != 0 ) return( 2 );
528  if( verify_string( &param4 ) != 0 ) return( 2 );
529  if( verify_string( &param5 ) != 0 ) return( 2 );
530  if( verify_string( &param6 ) != 0 ) return( 2 );
531  if( verify_int( params[7], &param7 ) != 0 ) return( 2 );
532  if( verify_string( &param8 ) != 0 ) return( 2 );
533  if( verify_int( params[9], &param9 ) != 0 ) return( 2 );
534 
535  test_suite_gcm_encrypt_and_tag( param1, param2, param3, param4, param5, param6, param7, param8, param9 );
536  return ( 0 );
537 
538  return ( 3 );
539  }
540  else
541  if( strcmp( params[0], "gcm_decrypt_and_verify" ) == 0 )
542  {
543 
544  int param1;
545  char *param2 = params[2];
546  char *param3 = params[3];
547  char *param4 = params[4];
548  char *param5 = params[5];
549  int param6;
550  char *param7 = params[7];
551  char *param8 = params[8];
552  int param9;
553 
554  if( cnt != 10 )
555  {
556  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 10 );
557  return( 2 );
558  }
559 
560  if( verify_int( params[1], &param1 ) != 0 ) return( 2 );
561  if( verify_string( &param2 ) != 0 ) return( 2 );
562  if( verify_string( &param3 ) != 0 ) return( 2 );
563  if( verify_string( &param4 ) != 0 ) return( 2 );
564  if( verify_string( &param5 ) != 0 ) return( 2 );
565  if( verify_int( params[6], &param6 ) != 0 ) return( 2 );
566  if( verify_string( &param7 ) != 0 ) return( 2 );
567  if( verify_string( &param8 ) != 0 ) return( 2 );
568  if( verify_int( params[9], &param9 ) != 0 ) return( 2 );
569 
570  test_suite_gcm_decrypt_and_verify( param1, param2, param3, param4, param5, param6, param7, param8, param9 );
571  return ( 0 );
572 
573  return ( 3 );
574  }
575  else
576  if( strcmp( params[0], "gcm_selftest" ) == 0 )
577  {
578  #ifdef POLARSSL_SELF_TEST
579 
580 
581  if( cnt != 1 )
582  {
583  fprintf( stderr, "\nIncorrect argument count (%d != %d)\n", cnt, 1 );
584  return( 2 );
585  }
586 
587 
588  test_suite_gcm_selftest( );
589  return ( 0 );
590  #endif /* POLARSSL_SELF_TEST */
591 
592  return ( 3 );
593  }
594  else
595 
596  {
597  fprintf( stdout, "FAILED\nSkipping unknown test function '%s'\n", params[0] );
598  fflush( stdout );
599  return( 1 );
600  }
601 #else
602  return( 3 );
603 #endif
604  return( ret );
605 }
606 
607 int get_line( FILE *f, char *buf, size_t len )
608 {
609  char *ret;
610 
611  ret = fgets( buf, len, f );
612  if( ret == NULL )
613  return( -1 );
614 
615  if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
616  buf[strlen(buf) - 1] = '\0';
617  if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
618  buf[strlen(buf) - 1] = '\0';
619 
620  return( 0 );
621 }
622 
623 int parse_arguments( char *buf, size_t len, char *params[50] )
624 {
625  int cnt = 0, i;
626  char *cur = buf;
627  char *p = buf, *q;
628 
629  params[cnt++] = cur;
630 
631  while( *p != '\0' && p < buf + len )
632  {
633  if( *p == '\\' )
634  {
635  *p++;
636  *p++;
637  continue;
638  }
639  if( *p == ':' )
640  {
641  if( p + 1 < buf + len )
642  {
643  cur = p + 1;
644  params[cnt++] = cur;
645  }
646  *p = '\0';
647  }
648 
649  *p++;
650  }
651 
652  // Replace newlines, question marks and colons in strings
653  for( i = 0; i < cnt; i++ )
654  {
655  p = params[i];
656  q = params[i];
657 
658  while( *p != '\0' )
659  {
660  if( *p == '\\' && *(p + 1) == 'n' )
661  {
662  p += 2;
663  *(q++) = '\n';
664  }
665  else if( *p == '\\' && *(p + 1) == ':' )
666  {
667  p += 2;
668  *(q++) = ':';
669  }
670  else if( *p == '\\' && *(p + 1) == '?' )
671  {
672  p += 2;
673  *(q++) = '?';
674  }
675  else
676  *(q++) = *(p++);
677  }
678  *q = '\0';
679  }
680 
681  return( cnt );
682 }
683 
684 int main()
685 {
686  int ret, i, cnt, total_errors = 0, total_tests = 0, total_skipped = 0;
687  const char *filename = "/tmp/B.6b9404fc-5e27-486e-9bbd-77463d7343ee/BUILD/polarssl-1.3.2/tests/suites/test_suite_gcm.aes128_de.data";
688  FILE *file;
689  char buf[5000];
690  char *params[50];
691 
692 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
693  unsigned char alloc_buf[1000000];
694  memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
695 #endif
696 
697  file = fopen( filename, "r" );
698  if( file == NULL )
699  {
700  fprintf( stderr, "Failed to open\n" );
701  return( 1 );
702  }
703 
704  while( !feof( file ) )
705  {
706  int skip = 0;
707 
708  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
709  break;
710  fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
711  fprintf( stdout, " " );
712  for( i = strlen( buf ) + 1; i < 67; i++ )
713  fprintf( stdout, "." );
714  fprintf( stdout, " " );
715  fflush( stdout );
716 
717  total_tests++;
718 
719  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
720  break;
721  cnt = parse_arguments( buf, strlen(buf), params );
722 
723  if( strcmp( params[0], "depends_on" ) == 0 )
724  {
725  for( i = 1; i < cnt; i++ )
726  if( dep_check( params[i] ) != 0 )
727  skip = 1;
728 
729  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
730  break;
731  cnt = parse_arguments( buf, strlen(buf), params );
732  }
733 
734  if( skip == 0 )
735  {
736  test_errors = 0;
737  ret = dispatch_test( cnt, params );
738  }
739 
740  if( skip == 1 || ret == 3 )
741  {
742  total_skipped++;
743  fprintf( stdout, "----\n" );
744  fflush( stdout );
745  }
746  else if( ret == 0 && test_errors == 0 )
747  {
748  fprintf( stdout, "PASS\n" );
749  fflush( stdout );
750  }
751  else if( ret == 2 )
752  {
753  fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
754  fclose(file);
755  exit( 2 );
756  }
757  else
758  total_errors++;
759 
760  if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
761  break;
762  if( strlen(buf) != 0 )
763  {
764  fprintf( stderr, "Should be empty %d\n", (int) strlen(buf) );
765  return( 1 );
766  }
767  }
768  fclose(file);
769 
770  fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");
771  if( total_errors == 0 )
772  fprintf( stdout, "PASSED" );
773  else
774  fprintf( stdout, "FAILED" );
775 
776  fprintf( stdout, " (%d / %d tests (%d skipped))\n",
777  total_tests - total_errors, total_tests, total_skipped );
778 
779 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
780 #if defined(POLARSSL_MEMORY_DEBUG)
781  memory_buffer_alloc_status();
782 #endif
783  memory_buffer_alloc_free();
784 #endif
785 
786  return( total_errors != 0 );
787 }
788 
789 
static int test_errors
int gcm_auth_decrypt(gcm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *tag, size_t tag_len, const unsigned char *input, unsigned char *output)
GCM buffer authenticated decryption using a block cipher.
Memory allocation layer.
uint32_t t_uint
Definition: bignum.h:149
Info structure for the pseudo random function.
int s
Definition: bignum.h:173
int gcm_self_test(int verbose)
Checkup routine.
Configuration options (set of defines)
MPI structure.
Definition: bignum.h:171
static int test_assert(int correct, char *test)
int main(int argc, char *argv[])
#define GCM_ENCRYPT
Definition: gcm.h:40
static int rnd_zero_rand(void *rng_state, unsigned char *output, size_t len)
This function only returns zeros.
Multi-precision integer library.
int dep_check(char *str)
#define TEST_ASSERT(TEST)
static int rnd_std_rand(void *rng_state, unsigned char *output, size_t len)
This function just returns data from rand().
int gcm_crypt_and_tag(gcm_context *ctx, int mode, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, size_t tag_len, unsigned char *tag)
GCM buffer encryption/decryption using a block cipher.
#define PUT_UINT32_BE(n, b, i)
GCM context structure.
Definition: gcm.h:53
int gcm_init(gcm_context *ctx, cipher_id_t cipher, const unsigned char *key, unsigned int keysize)
GCM initialization (encryption)
static int unhexify(unsigned char *obuf, const char *ibuf)
int parse_arguments(char *buf, size_t len, char *params[50])
#define POLARSSL_ERR_GCM_AUTH_FAILED
Authenticated decryption failed.
Definition: gcm.h:43
int mpi_read_string(mpi *X, int radix, const char *s)
Import from an ASCII string.
static int rnd_buffer_rand(void *rng_state, unsigned char *output, size_t len)
This function returns random based on a buffer it receives.
t_uint * p
Definition: bignum.h:175
int verify_string(char **str)
void gcm_free(gcm_context *ctx)
Free a GCM context and underlying cipher sub-context.
int dispatch_test(int cnt, char *params[50])
size_t n
Definition: bignum.h:174
Galois/Counter mode for 128-bit block ciphers.
unsigned char * buf
static void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
int verify_int(char *str, int *value)
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)