PolarSSL v1.2.5
test_suite_blowfish.c
Go to the documentation of this file.
1 #include "fct.h"
2 
3 #include "polarssl/blowfish.h"
4 
5 #include <polarssl/config.h>
6 
7 #ifdef _MSC_VER
8 #include <basetsd.h>
9 typedef UINT32 uint32_t;
10 #else
11 #include <inttypes.h>
12 #endif
13 
14 /*
15  * 32-bit integer manipulation macros (big endian)
16  */
17 #ifndef GET_UINT32_BE
18 #define GET_UINT32_BE(n,b,i) \
19 { \
20  (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
21  | ( (uint32_t) (b)[(i) + 1] << 16 ) \
22  | ( (uint32_t) (b)[(i) + 2] << 8 ) \
23  | ( (uint32_t) (b)[(i) + 3] ); \
24 }
25 #endif
26 
27 #ifndef PUT_UINT32_BE
28 #define PUT_UINT32_BE(n,b,i) \
29 { \
30  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
31  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
32  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
33  (b)[(i) + 3] = (unsigned char) ( (n) ); \
34 }
35 #endif
36 
37 int unhexify(unsigned char *obuf, const char *ibuf)
38 {
39  unsigned char c, c2;
40  int len = strlen(ibuf) / 2;
41  assert(!(strlen(ibuf) %1)); // must be even number of bytes
42 
43  while (*ibuf != 0)
44  {
45  c = *ibuf++;
46  if( c >= '0' && c <= '9' )
47  c -= '0';
48  else if( c >= 'a' && c <= 'f' )
49  c -= 'a' - 10;
50  else if( c >= 'A' && c <= 'F' )
51  c -= 'A' - 10;
52  else
53  assert( 0 );
54 
55  c2 = *ibuf++;
56  if( c2 >= '0' && c2 <= '9' )
57  c2 -= '0';
58  else if( c2 >= 'a' && c2 <= 'f' )
59  c2 -= 'a' - 10;
60  else if( c2 >= 'A' && c2 <= 'F' )
61  c2 -= 'A' - 10;
62  else
63  assert( 0 );
64 
65  *obuf++ = ( c << 4 ) | c2;
66  }
67 
68  return len;
69 }
70 
71 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
72 {
73  unsigned char l, h;
74 
75  while (len != 0)
76  {
77  h = (*ibuf) / 16;
78  l = (*ibuf) % 16;
79 
80  if( h < 10 )
81  *obuf++ = '0' + h;
82  else
83  *obuf++ = 'a' + h - 10;
84 
85  if( l < 10 )
86  *obuf++ = '0' + l;
87  else
88  *obuf++ = 'a' + l - 10;
89 
90  ++ibuf;
91  len--;
92  }
93 }
94 
104 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
105 {
106  size_t i;
107 
108  if( rng_state != NULL )
109  rng_state = NULL;
110 
111  for( i = 0; i < len; ++i )
112  output[i] = rand();
113 
114  return( 0 );
115 }
116 
122 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
123 {
124  if( rng_state != NULL )
125  rng_state = NULL;
126 
127  memset( output, 0, len );
128 
129  return( 0 );
130 }
131 
132 typedef struct
133 {
134  unsigned char *buf;
135  size_t length;
136 } rnd_buf_info;
137 
149 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
150 {
151  rnd_buf_info *info = (rnd_buf_info *) rng_state;
152  size_t use_len;
153 
154  if( rng_state == NULL )
155  return( rnd_std_rand( NULL, output, len ) );
156 
157  use_len = len;
158  if( len > info->length )
159  use_len = info->length;
160 
161  if( use_len )
162  {
163  memcpy( output, info->buf, use_len );
164  info->buf += use_len;
165  info->length -= use_len;
166  }
167 
168  if( len - use_len > 0 )
169  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
170 
171  return( 0 );
172 }
173 
181 typedef struct
182 {
183  uint32_t key[16];
184  uint32_t v0, v1;
186 
195 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
196 {
197  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
198  uint32_t i, *k, sum, delta=0x9E3779B9;
199  unsigned char result[4];
200 
201  if( rng_state == NULL )
202  return( rnd_std_rand( NULL, output, len ) );
203 
204  k = info->key;
205 
206  while( len > 0 )
207  {
208  size_t use_len = ( len > 4 ) ? 4 : len;
209  sum = 0;
210 
211  for( i = 0; i < 32; i++ )
212  {
213  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
214  sum += delta;
215  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
216  }
217 
218  PUT_UINT32_BE( info->v0, result, 0 );
219  memcpy( output, result, use_len );
220  len -= use_len;
221  }
222 
223  return( 0 );
224 }
225 
226 
228 {
229 #ifdef POLARSSL_BLOWFISH_C
230 
231 
232  FCT_SUITE_BGN(test_suite_blowfish)
233  {
234 
235  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_1)
236  {
237  unsigned char key_str[100];
238  unsigned char src_str[100];
239  unsigned char dst_str[100];
240  unsigned char output[100];
241  blowfish_context ctx;
242  int key_len;
243 
244  memset(key_str, 0x00, 100);
245  memset(src_str, 0x00, 100);
246  memset(dst_str, 0x00, 100);
247  memset(output, 0x00, 100);
248 
249  key_len = unhexify( key_str, "0000000000000000" );
250  unhexify( src_str, "0000000000000000" );
251 
252  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
253  if( 0 == 0 )
254  {
255  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
256  hexify( dst_str, output, 8 );
257 
258  fct_chk( strcmp( (char *) dst_str, "4ef997456198dd78" ) == 0 );
259  }
260  }
261  FCT_TEST_END();
262 
263 
264  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_2)
265  {
266  unsigned char key_str[100];
267  unsigned char src_str[100];
268  unsigned char dst_str[100];
269  unsigned char output[100];
270  blowfish_context ctx;
271  int key_len;
272 
273  memset(key_str, 0x00, 100);
274  memset(src_str, 0x00, 100);
275  memset(dst_str, 0x00, 100);
276  memset(output, 0x00, 100);
277 
278  key_len = unhexify( key_str, "ffffffffffffffff" );
279  unhexify( src_str, "ffffffffffffffff" );
280 
281  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
282  if( 0 == 0 )
283  {
284  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
285  hexify( dst_str, output, 8 );
286 
287  fct_chk( strcmp( (char *) dst_str, "51866fd5b85ecb8a" ) == 0 );
288  }
289  }
290  FCT_TEST_END();
291 
292 
293  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_3)
294  {
295  unsigned char key_str[100];
296  unsigned char src_str[100];
297  unsigned char dst_str[100];
298  unsigned char output[100];
299  blowfish_context ctx;
300  int key_len;
301 
302  memset(key_str, 0x00, 100);
303  memset(src_str, 0x00, 100);
304  memset(dst_str, 0x00, 100);
305  memset(output, 0x00, 100);
306 
307  key_len = unhexify( key_str, "3000000000000000" );
308  unhexify( src_str, "1000000000000001" );
309 
310  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
311  if( 0 == 0 )
312  {
313  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
314  hexify( dst_str, output, 8 );
315 
316  fct_chk( strcmp( (char *) dst_str, "7d856f9a613063f2" ) == 0 );
317  }
318  }
319  FCT_TEST_END();
320 
321 
322  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_4)
323  {
324  unsigned char key_str[100];
325  unsigned char src_str[100];
326  unsigned char dst_str[100];
327  unsigned char output[100];
328  blowfish_context ctx;
329  int key_len;
330 
331  memset(key_str, 0x00, 100);
332  memset(src_str, 0x00, 100);
333  memset(dst_str, 0x00, 100);
334  memset(output, 0x00, 100);
335 
336  key_len = unhexify( key_str, "1111111111111111" );
337  unhexify( src_str, "1111111111111111" );
338 
339  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
340  if( 0 == 0 )
341  {
342  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
343  hexify( dst_str, output, 8 );
344 
345  fct_chk( strcmp( (char *) dst_str, "2466dd878b963c9d" ) == 0 );
346  }
347  }
348  FCT_TEST_END();
349 
350 
351  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_5)
352  {
353  unsigned char key_str[100];
354  unsigned char src_str[100];
355  unsigned char dst_str[100];
356  unsigned char output[100];
357  blowfish_context ctx;
358  int key_len;
359 
360  memset(key_str, 0x00, 100);
361  memset(src_str, 0x00, 100);
362  memset(dst_str, 0x00, 100);
363  memset(output, 0x00, 100);
364 
365  key_len = unhexify( key_str, "0123456789abcdef" );
366  unhexify( src_str, "1111111111111111" );
367 
368  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
369  if( 0 == 0 )
370  {
371  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
372  hexify( dst_str, output, 8 );
373 
374  fct_chk( strcmp( (char *) dst_str, "61f9c3802281b096" ) == 0 );
375  }
376  }
377  FCT_TEST_END();
378 
379 
380  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_6)
381  {
382  unsigned char key_str[100];
383  unsigned char src_str[100];
384  unsigned char dst_str[100];
385  unsigned char output[100];
386  blowfish_context ctx;
387  int key_len;
388 
389  memset(key_str, 0x00, 100);
390  memset(src_str, 0x00, 100);
391  memset(dst_str, 0x00, 100);
392  memset(output, 0x00, 100);
393 
394  key_len = unhexify( key_str, "1111111111111111" );
395  unhexify( src_str, "0123456789abcdef" );
396 
397  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
398  if( 0 == 0 )
399  {
400  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
401  hexify( dst_str, output, 8 );
402 
403  fct_chk( strcmp( (char *) dst_str, "7d0cc630afda1ec7" ) == 0 );
404  }
405  }
406  FCT_TEST_END();
407 
408 
409  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_7)
410  {
411  unsigned char key_str[100];
412  unsigned char src_str[100];
413  unsigned char dst_str[100];
414  unsigned char output[100];
415  blowfish_context ctx;
416  int key_len;
417 
418  memset(key_str, 0x00, 100);
419  memset(src_str, 0x00, 100);
420  memset(dst_str, 0x00, 100);
421  memset(output, 0x00, 100);
422 
423  key_len = unhexify( key_str, "0000000000000000" );
424  unhexify( src_str, "0000000000000000" );
425 
426  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
427  if( 0 == 0 )
428  {
429  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
430  hexify( dst_str, output, 8 );
431 
432  fct_chk( strcmp( (char *) dst_str, "4ef997456198dd78" ) == 0 );
433  }
434  }
435  FCT_TEST_END();
436 
437 
438  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_8)
439  {
440  unsigned char key_str[100];
441  unsigned char src_str[100];
442  unsigned char dst_str[100];
443  unsigned char output[100];
444  blowfish_context ctx;
445  int key_len;
446 
447  memset(key_str, 0x00, 100);
448  memset(src_str, 0x00, 100);
449  memset(dst_str, 0x00, 100);
450  memset(output, 0x00, 100);
451 
452  key_len = unhexify( key_str, "fedcba9876543210" );
453  unhexify( src_str, "0123456789abcdef" );
454 
455  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
456  if( 0 == 0 )
457  {
458  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
459  hexify( dst_str, output, 8 );
460 
461  fct_chk( strcmp( (char *) dst_str, "0aceab0fc6a0a28d" ) == 0 );
462  }
463  }
464  FCT_TEST_END();
465 
466 
467  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_9)
468  {
469  unsigned char key_str[100];
470  unsigned char src_str[100];
471  unsigned char dst_str[100];
472  unsigned char output[100];
473  blowfish_context ctx;
474  int key_len;
475 
476  memset(key_str, 0x00, 100);
477  memset(src_str, 0x00, 100);
478  memset(dst_str, 0x00, 100);
479  memset(output, 0x00, 100);
480 
481  key_len = unhexify( key_str, "7ca110454a1a6e57" );
482  unhexify( src_str, "01a1d6d039776742" );
483 
484  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
485  if( 0 == 0 )
486  {
487  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
488  hexify( dst_str, output, 8 );
489 
490  fct_chk( strcmp( (char *) dst_str, "59c68245eb05282b" ) == 0 );
491  }
492  }
493  FCT_TEST_END();
494 
495 
496  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_10)
497  {
498  unsigned char key_str[100];
499  unsigned char src_str[100];
500  unsigned char dst_str[100];
501  unsigned char output[100];
502  blowfish_context ctx;
503  int key_len;
504 
505  memset(key_str, 0x00, 100);
506  memset(src_str, 0x00, 100);
507  memset(dst_str, 0x00, 100);
508  memset(output, 0x00, 100);
509 
510  key_len = unhexify( key_str, "0131d9619dc1376e" );
511  unhexify( src_str, "5cd54ca83def57da" );
512 
513  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
514  if( 0 == 0 )
515  {
516  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
517  hexify( dst_str, output, 8 );
518 
519  fct_chk( strcmp( (char *) dst_str, "b1b8cc0b250f09a0" ) == 0 );
520  }
521  }
522  FCT_TEST_END();
523 
524 
525  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_11)
526  {
527  unsigned char key_str[100];
528  unsigned char src_str[100];
529  unsigned char dst_str[100];
530  unsigned char output[100];
531  blowfish_context ctx;
532  int key_len;
533 
534  memset(key_str, 0x00, 100);
535  memset(src_str, 0x00, 100);
536  memset(dst_str, 0x00, 100);
537  memset(output, 0x00, 100);
538 
539  key_len = unhexify( key_str, "07a1133e4a0b2686" );
540  unhexify( src_str, "0248d43806f67172" );
541 
542  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
543  if( 0 == 0 )
544  {
545  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
546  hexify( dst_str, output, 8 );
547 
548  fct_chk( strcmp( (char *) dst_str, "1730e5778bea1da4" ) == 0 );
549  }
550  }
551  FCT_TEST_END();
552 
553 
554  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_12)
555  {
556  unsigned char key_str[100];
557  unsigned char src_str[100];
558  unsigned char dst_str[100];
559  unsigned char output[100];
560  blowfish_context ctx;
561  int key_len;
562 
563  memset(key_str, 0x00, 100);
564  memset(src_str, 0x00, 100);
565  memset(dst_str, 0x00, 100);
566  memset(output, 0x00, 100);
567 
568  key_len = unhexify( key_str, "3849674c2602319e" );
569  unhexify( src_str, "51454b582ddf440a" );
570 
571  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
572  if( 0 == 0 )
573  {
574  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
575  hexify( dst_str, output, 8 );
576 
577  fct_chk( strcmp( (char *) dst_str, "a25e7856cf2651eb" ) == 0 );
578  }
579  }
580  FCT_TEST_END();
581 
582 
583  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_13)
584  {
585  unsigned char key_str[100];
586  unsigned char src_str[100];
587  unsigned char dst_str[100];
588  unsigned char output[100];
589  blowfish_context ctx;
590  int key_len;
591 
592  memset(key_str, 0x00, 100);
593  memset(src_str, 0x00, 100);
594  memset(dst_str, 0x00, 100);
595  memset(output, 0x00, 100);
596 
597  key_len = unhexify( key_str, "04b915ba43feb5b6" );
598  unhexify( src_str, "42fd443059577fa2" );
599 
600  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
601  if( 0 == 0 )
602  {
603  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
604  hexify( dst_str, output, 8 );
605 
606  fct_chk( strcmp( (char *) dst_str, "353882b109ce8f1a" ) == 0 );
607  }
608  }
609  FCT_TEST_END();
610 
611 
612  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_14)
613  {
614  unsigned char key_str[100];
615  unsigned char src_str[100];
616  unsigned char dst_str[100];
617  unsigned char output[100];
618  blowfish_context ctx;
619  int key_len;
620 
621  memset(key_str, 0x00, 100);
622  memset(src_str, 0x00, 100);
623  memset(dst_str, 0x00, 100);
624  memset(output, 0x00, 100);
625 
626  key_len = unhexify( key_str, "0113b970fd34f2ce" );
627  unhexify( src_str, "059b5e0851cf143a" );
628 
629  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
630  if( 0 == 0 )
631  {
632  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
633  hexify( dst_str, output, 8 );
634 
635  fct_chk( strcmp( (char *) dst_str, "48f4d0884c379918" ) == 0 );
636  }
637  }
638  FCT_TEST_END();
639 
640 
641  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_15)
642  {
643  unsigned char key_str[100];
644  unsigned char src_str[100];
645  unsigned char dst_str[100];
646  unsigned char output[100];
647  blowfish_context ctx;
648  int key_len;
649 
650  memset(key_str, 0x00, 100);
651  memset(src_str, 0x00, 100);
652  memset(dst_str, 0x00, 100);
653  memset(output, 0x00, 100);
654 
655  key_len = unhexify( key_str, "0170f175468fb5e6" );
656  unhexify( src_str, "0756d8e0774761d2" );
657 
658  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
659  if( 0 == 0 )
660  {
661  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
662  hexify( dst_str, output, 8 );
663 
664  fct_chk( strcmp( (char *) dst_str, "432193b78951fc98" ) == 0 );
665  }
666  }
667  FCT_TEST_END();
668 
669 
670  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_16)
671  {
672  unsigned char key_str[100];
673  unsigned char src_str[100];
674  unsigned char dst_str[100];
675  unsigned char output[100];
676  blowfish_context ctx;
677  int key_len;
678 
679  memset(key_str, 0x00, 100);
680  memset(src_str, 0x00, 100);
681  memset(dst_str, 0x00, 100);
682  memset(output, 0x00, 100);
683 
684  key_len = unhexify( key_str, "43297fad38e373fe" );
685  unhexify( src_str, "762514b829bf486a" );
686 
687  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
688  if( 0 == 0 )
689  {
690  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
691  hexify( dst_str, output, 8 );
692 
693  fct_chk( strcmp( (char *) dst_str, "13f04154d69d1ae5" ) == 0 );
694  }
695  }
696  FCT_TEST_END();
697 
698 
699  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_17)
700  {
701  unsigned char key_str[100];
702  unsigned char src_str[100];
703  unsigned char dst_str[100];
704  unsigned char output[100];
705  blowfish_context ctx;
706  int key_len;
707 
708  memset(key_str, 0x00, 100);
709  memset(src_str, 0x00, 100);
710  memset(dst_str, 0x00, 100);
711  memset(output, 0x00, 100);
712 
713  key_len = unhexify( key_str, "07a7137045da2a16" );
714  unhexify( src_str, "3bdd119049372802" );
715 
716  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
717  if( 0 == 0 )
718  {
719  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
720  hexify( dst_str, output, 8 );
721 
722  fct_chk( strcmp( (char *) dst_str, "2eedda93ffd39c79" ) == 0 );
723  }
724  }
725  FCT_TEST_END();
726 
727 
728  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_18)
729  {
730  unsigned char key_str[100];
731  unsigned char src_str[100];
732  unsigned char dst_str[100];
733  unsigned char output[100];
734  blowfish_context ctx;
735  int key_len;
736 
737  memset(key_str, 0x00, 100);
738  memset(src_str, 0x00, 100);
739  memset(dst_str, 0x00, 100);
740  memset(output, 0x00, 100);
741 
742  key_len = unhexify( key_str, "04689104c2fd3b2f" );
743  unhexify( src_str, "26955f6835af609a" );
744 
745  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
746  if( 0 == 0 )
747  {
748  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
749  hexify( dst_str, output, 8 );
750 
751  fct_chk( strcmp( (char *) dst_str, "d887e0393c2da6e3" ) == 0 );
752  }
753  }
754  FCT_TEST_END();
755 
756 
757  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_19)
758  {
759  unsigned char key_str[100];
760  unsigned char src_str[100];
761  unsigned char dst_str[100];
762  unsigned char output[100];
763  blowfish_context ctx;
764  int key_len;
765 
766  memset(key_str, 0x00, 100);
767  memset(src_str, 0x00, 100);
768  memset(dst_str, 0x00, 100);
769  memset(output, 0x00, 100);
770 
771  key_len = unhexify( key_str, "37d06bb516cb7546" );
772  unhexify( src_str, "164d5e404f275232" );
773 
774  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
775  if( 0 == 0 )
776  {
777  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
778  hexify( dst_str, output, 8 );
779 
780  fct_chk( strcmp( (char *) dst_str, "5f99d04f5b163969" ) == 0 );
781  }
782  }
783  FCT_TEST_END();
784 
785 
786  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_20)
787  {
788  unsigned char key_str[100];
789  unsigned char src_str[100];
790  unsigned char dst_str[100];
791  unsigned char output[100];
792  blowfish_context ctx;
793  int key_len;
794 
795  memset(key_str, 0x00, 100);
796  memset(src_str, 0x00, 100);
797  memset(dst_str, 0x00, 100);
798  memset(output, 0x00, 100);
799 
800  key_len = unhexify( key_str, "1f08260d1ac2465e" );
801  unhexify( src_str, "6b056e18759f5cca" );
802 
803  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
804  if( 0 == 0 )
805  {
806  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
807  hexify( dst_str, output, 8 );
808 
809  fct_chk( strcmp( (char *) dst_str, "4a057a3b24d3977b" ) == 0 );
810  }
811  }
812  FCT_TEST_END();
813 
814 
815  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_21)
816  {
817  unsigned char key_str[100];
818  unsigned char src_str[100];
819  unsigned char dst_str[100];
820  unsigned char output[100];
821  blowfish_context ctx;
822  int key_len;
823 
824  memset(key_str, 0x00, 100);
825  memset(src_str, 0x00, 100);
826  memset(dst_str, 0x00, 100);
827  memset(output, 0x00, 100);
828 
829  key_len = unhexify( key_str, "584023641aba6176" );
830  unhexify( src_str, "004bd6ef09176062" );
831 
832  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
833  if( 0 == 0 )
834  {
835  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
836  hexify( dst_str, output, 8 );
837 
838  fct_chk( strcmp( (char *) dst_str, "452031c1e4fada8e" ) == 0 );
839  }
840  }
841  FCT_TEST_END();
842 
843 
844  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_22)
845  {
846  unsigned char key_str[100];
847  unsigned char src_str[100];
848  unsigned char dst_str[100];
849  unsigned char output[100];
850  blowfish_context ctx;
851  int key_len;
852 
853  memset(key_str, 0x00, 100);
854  memset(src_str, 0x00, 100);
855  memset(dst_str, 0x00, 100);
856  memset(output, 0x00, 100);
857 
858  key_len = unhexify( key_str, "025816164629b007" );
859  unhexify( src_str, "480d39006ee762f2" );
860 
861  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
862  if( 0 == 0 )
863  {
864  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
865  hexify( dst_str, output, 8 );
866 
867  fct_chk( strcmp( (char *) dst_str, "7555ae39f59b87bd" ) == 0 );
868  }
869  }
870  FCT_TEST_END();
871 
872 
873  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_23)
874  {
875  unsigned char key_str[100];
876  unsigned char src_str[100];
877  unsigned char dst_str[100];
878  unsigned char output[100];
879  blowfish_context ctx;
880  int key_len;
881 
882  memset(key_str, 0x00, 100);
883  memset(src_str, 0x00, 100);
884  memset(dst_str, 0x00, 100);
885  memset(output, 0x00, 100);
886 
887  key_len = unhexify( key_str, "49793ebc79b3258f" );
888  unhexify( src_str, "437540c8698f3cfa" );
889 
890  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
891  if( 0 == 0 )
892  {
893  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
894  hexify( dst_str, output, 8 );
895 
896  fct_chk( strcmp( (char *) dst_str, "53c55f9cb49fc019" ) == 0 );
897  }
898  }
899  FCT_TEST_END();
900 
901 
902  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_24)
903  {
904  unsigned char key_str[100];
905  unsigned char src_str[100];
906  unsigned char dst_str[100];
907  unsigned char output[100];
908  blowfish_context ctx;
909  int key_len;
910 
911  memset(key_str, 0x00, 100);
912  memset(src_str, 0x00, 100);
913  memset(dst_str, 0x00, 100);
914  memset(output, 0x00, 100);
915 
916  key_len = unhexify( key_str, "4fb05e1515ab73a7" );
917  unhexify( src_str, "072d43a077075292" );
918 
919  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
920  if( 0 == 0 )
921  {
922  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
923  hexify( dst_str, output, 8 );
924 
925  fct_chk( strcmp( (char *) dst_str, "7a8e7bfa937e89a3" ) == 0 );
926  }
927  }
928  FCT_TEST_END();
929 
930 
931  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_25)
932  {
933  unsigned char key_str[100];
934  unsigned char src_str[100];
935  unsigned char dst_str[100];
936  unsigned char output[100];
937  blowfish_context ctx;
938  int key_len;
939 
940  memset(key_str, 0x00, 100);
941  memset(src_str, 0x00, 100);
942  memset(dst_str, 0x00, 100);
943  memset(output, 0x00, 100);
944 
945  key_len = unhexify( key_str, "49e95d6d4ca229bf" );
946  unhexify( src_str, "02fe55778117f12a" );
947 
948  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
949  if( 0 == 0 )
950  {
951  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
952  hexify( dst_str, output, 8 );
953 
954  fct_chk( strcmp( (char *) dst_str, "cf9c5d7a4986adb5" ) == 0 );
955  }
956  }
957  FCT_TEST_END();
958 
959 
960  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_26)
961  {
962  unsigned char key_str[100];
963  unsigned char src_str[100];
964  unsigned char dst_str[100];
965  unsigned char output[100];
966  blowfish_context ctx;
967  int key_len;
968 
969  memset(key_str, 0x00, 100);
970  memset(src_str, 0x00, 100);
971  memset(dst_str, 0x00, 100);
972  memset(output, 0x00, 100);
973 
974  key_len = unhexify( key_str, "018310dc409b26d6" );
975  unhexify( src_str, "1d9d5c5018f728c2" );
976 
977  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
978  if( 0 == 0 )
979  {
980  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
981  hexify( dst_str, output, 8 );
982 
983  fct_chk( strcmp( (char *) dst_str, "d1abb290658bc778" ) == 0 );
984  }
985  }
986  FCT_TEST_END();
987 
988 
989  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_27)
990  {
991  unsigned char key_str[100];
992  unsigned char src_str[100];
993  unsigned char dst_str[100];
994  unsigned char output[100];
995  blowfish_context ctx;
996  int key_len;
997 
998  memset(key_str, 0x00, 100);
999  memset(src_str, 0x00, 100);
1000  memset(dst_str, 0x00, 100);
1001  memset(output, 0x00, 100);
1002 
1003  key_len = unhexify( key_str, "1c587f1c13924fef" );
1004  unhexify( src_str, "305532286d6f295a" );
1005 
1006  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1007  if( 0 == 0 )
1008  {
1009  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1010  hexify( dst_str, output, 8 );
1011 
1012  fct_chk( strcmp( (char *) dst_str, "55cb3774d13ef201" ) == 0 );
1013  }
1014  }
1015  FCT_TEST_END();
1016 
1017 
1018  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_28)
1019  {
1020  unsigned char key_str[100];
1021  unsigned char src_str[100];
1022  unsigned char dst_str[100];
1023  unsigned char output[100];
1024  blowfish_context ctx;
1025  int key_len;
1026 
1027  memset(key_str, 0x00, 100);
1028  memset(src_str, 0x00, 100);
1029  memset(dst_str, 0x00, 100);
1030  memset(output, 0x00, 100);
1031 
1032  key_len = unhexify( key_str, "0101010101010101" );
1033  unhexify( src_str, "0123456789abcdef" );
1034 
1035  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1036  if( 0 == 0 )
1037  {
1038  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1039  hexify( dst_str, output, 8 );
1040 
1041  fct_chk( strcmp( (char *) dst_str, "fa34ec4847b268b2" ) == 0 );
1042  }
1043  }
1044  FCT_TEST_END();
1045 
1046 
1047  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_29)
1048  {
1049  unsigned char key_str[100];
1050  unsigned char src_str[100];
1051  unsigned char dst_str[100];
1052  unsigned char output[100];
1053  blowfish_context ctx;
1054  int key_len;
1055 
1056  memset(key_str, 0x00, 100);
1057  memset(src_str, 0x00, 100);
1058  memset(dst_str, 0x00, 100);
1059  memset(output, 0x00, 100);
1060 
1061  key_len = unhexify( key_str, "1f1f1f1f0e0e0e0e" );
1062  unhexify( src_str, "0123456789abcdef" );
1063 
1064  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1065  if( 0 == 0 )
1066  {
1067  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1068  hexify( dst_str, output, 8 );
1069 
1070  fct_chk( strcmp( (char *) dst_str, "a790795108ea3cae" ) == 0 );
1071  }
1072  }
1073  FCT_TEST_END();
1074 
1075 
1076  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_30)
1077  {
1078  unsigned char key_str[100];
1079  unsigned char src_str[100];
1080  unsigned char dst_str[100];
1081  unsigned char output[100];
1082  blowfish_context ctx;
1083  int key_len;
1084 
1085  memset(key_str, 0x00, 100);
1086  memset(src_str, 0x00, 100);
1087  memset(dst_str, 0x00, 100);
1088  memset(output, 0x00, 100);
1089 
1090  key_len = unhexify( key_str, "e0fee0fef1fef1fe" );
1091  unhexify( src_str, "0123456789abcdef" );
1092 
1093  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1094  if( 0 == 0 )
1095  {
1096  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1097  hexify( dst_str, output, 8 );
1098 
1099  fct_chk( strcmp( (char *) dst_str, "c39e072d9fac631d" ) == 0 );
1100  }
1101  }
1102  FCT_TEST_END();
1103 
1104 
1105  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_31)
1106  {
1107  unsigned char key_str[100];
1108  unsigned char src_str[100];
1109  unsigned char dst_str[100];
1110  unsigned char output[100];
1111  blowfish_context ctx;
1112  int key_len;
1113 
1114  memset(key_str, 0x00, 100);
1115  memset(src_str, 0x00, 100);
1116  memset(dst_str, 0x00, 100);
1117  memset(output, 0x00, 100);
1118 
1119  key_len = unhexify( key_str, "0000000000000000" );
1120  unhexify( src_str, "ffffffffffffffff" );
1121 
1122  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1123  if( 0 == 0 )
1124  {
1125  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1126  hexify( dst_str, output, 8 );
1127 
1128  fct_chk( strcmp( (char *) dst_str, "014933e0cdaff6e4" ) == 0 );
1129  }
1130  }
1131  FCT_TEST_END();
1132 
1133 
1134  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_32)
1135  {
1136  unsigned char key_str[100];
1137  unsigned char src_str[100];
1138  unsigned char dst_str[100];
1139  unsigned char output[100];
1140  blowfish_context ctx;
1141  int key_len;
1142 
1143  memset(key_str, 0x00, 100);
1144  memset(src_str, 0x00, 100);
1145  memset(dst_str, 0x00, 100);
1146  memset(output, 0x00, 100);
1147 
1148  key_len = unhexify( key_str, "ffffffffffffffff" );
1149  unhexify( src_str, "0000000000000000" );
1150 
1151  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1152  if( 0 == 0 )
1153  {
1154  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1155  hexify( dst_str, output, 8 );
1156 
1157  fct_chk( strcmp( (char *) dst_str, "f21e9a77b71c49bc" ) == 0 );
1158  }
1159  }
1160  FCT_TEST_END();
1161 
1162 
1163  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_33)
1164  {
1165  unsigned char key_str[100];
1166  unsigned char src_str[100];
1167  unsigned char dst_str[100];
1168  unsigned char output[100];
1169  blowfish_context ctx;
1170  int key_len;
1171 
1172  memset(key_str, 0x00, 100);
1173  memset(src_str, 0x00, 100);
1174  memset(dst_str, 0x00, 100);
1175  memset(output, 0x00, 100);
1176 
1177  key_len = unhexify( key_str, "0123456789abcdef" );
1178  unhexify( src_str, "0000000000000000" );
1179 
1180  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1181  if( 0 == 0 )
1182  {
1183  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1184  hexify( dst_str, output, 8 );
1185 
1186  fct_chk( strcmp( (char *) dst_str, "245946885754369a" ) == 0 );
1187  }
1188  }
1189  FCT_TEST_END();
1190 
1191 
1192  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_34)
1193  {
1194  unsigned char key_str[100];
1195  unsigned char src_str[100];
1196  unsigned char dst_str[100];
1197  unsigned char output[100];
1198  blowfish_context ctx;
1199  int key_len;
1200 
1201  memset(key_str, 0x00, 100);
1202  memset(src_str, 0x00, 100);
1203  memset(dst_str, 0x00, 100);
1204  memset(output, 0x00, 100);
1205 
1206  key_len = unhexify( key_str, "fedcba9876543210" );
1207  unhexify( src_str, "ffffffffffffffff" );
1208 
1209  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1210  if( 0 == 0 )
1211  {
1212  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1213  hexify( dst_str, output, 8 );
1214 
1215  fct_chk( strcmp( (char *) dst_str, "6b5c5a9c5d9e0a5a" ) == 0 );
1216  }
1217  }
1218  FCT_TEST_END();
1219 
1220 
1221  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_1)
1222  {
1223  unsigned char key_str[100];
1224  unsigned char src_str[100];
1225  unsigned char dst_str[100];
1226  unsigned char output[100];
1227  blowfish_context ctx;
1228  int key_len;
1229 
1230  memset(key_str, 0x00, 100);
1231  memset(src_str, 0x00, 100);
1232  memset(dst_str, 0x00, 100);
1233  memset(output, 0x00, 100);
1234 
1235  key_len = unhexify( key_str, "0000000000000000" );
1236  unhexify( src_str, "4ef997456198dd78" );
1237 
1238  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1239  if( 0 == 0 )
1240  {
1241  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1242  hexify( dst_str, output, 8 );
1243 
1244  fct_chk( strcmp( (char *) dst_str, "0000000000000000" ) == 0 );
1245  }
1246  }
1247  FCT_TEST_END();
1248 
1249 
1250  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_2)
1251  {
1252  unsigned char key_str[100];
1253  unsigned char src_str[100];
1254  unsigned char dst_str[100];
1255  unsigned char output[100];
1256  blowfish_context ctx;
1257  int key_len;
1258 
1259  memset(key_str, 0x00, 100);
1260  memset(src_str, 0x00, 100);
1261  memset(dst_str, 0x00, 100);
1262  memset(output, 0x00, 100);
1263 
1264  key_len = unhexify( key_str, "ffffffffffffffff" );
1265  unhexify( src_str, "51866fd5b85ecb8a" );
1266 
1267  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1268  if( 0 == 0 )
1269  {
1270  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1271  hexify( dst_str, output, 8 );
1272 
1273  fct_chk( strcmp( (char *) dst_str, "ffffffffffffffff" ) == 0 );
1274  }
1275  }
1276  FCT_TEST_END();
1277 
1278 
1279  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_3)
1280  {
1281  unsigned char key_str[100];
1282  unsigned char src_str[100];
1283  unsigned char dst_str[100];
1284  unsigned char output[100];
1285  blowfish_context ctx;
1286  int key_len;
1287 
1288  memset(key_str, 0x00, 100);
1289  memset(src_str, 0x00, 100);
1290  memset(dst_str, 0x00, 100);
1291  memset(output, 0x00, 100);
1292 
1293  key_len = unhexify( key_str, "3000000000000000" );
1294  unhexify( src_str, "7d856f9a613063f2" );
1295 
1296  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1297  if( 0 == 0 )
1298  {
1299  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1300  hexify( dst_str, output, 8 );
1301 
1302  fct_chk( strcmp( (char *) dst_str, "1000000000000001" ) == 0 );
1303  }
1304  }
1305  FCT_TEST_END();
1306 
1307 
1308  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_4)
1309  {
1310  unsigned char key_str[100];
1311  unsigned char src_str[100];
1312  unsigned char dst_str[100];
1313  unsigned char output[100];
1314  blowfish_context ctx;
1315  int key_len;
1316 
1317  memset(key_str, 0x00, 100);
1318  memset(src_str, 0x00, 100);
1319  memset(dst_str, 0x00, 100);
1320  memset(output, 0x00, 100);
1321 
1322  key_len = unhexify( key_str, "1111111111111111" );
1323  unhexify( src_str, "2466dd878b963c9d" );
1324 
1325  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1326  if( 0 == 0 )
1327  {
1328  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1329  hexify( dst_str, output, 8 );
1330 
1331  fct_chk( strcmp( (char *) dst_str, "1111111111111111" ) == 0 );
1332  }
1333  }
1334  FCT_TEST_END();
1335 
1336 
1337  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_5)
1338  {
1339  unsigned char key_str[100];
1340  unsigned char src_str[100];
1341  unsigned char dst_str[100];
1342  unsigned char output[100];
1343  blowfish_context ctx;
1344  int key_len;
1345 
1346  memset(key_str, 0x00, 100);
1347  memset(src_str, 0x00, 100);
1348  memset(dst_str, 0x00, 100);
1349  memset(output, 0x00, 100);
1350 
1351  key_len = unhexify( key_str, "0123456789abcdef" );
1352  unhexify( src_str, "61f9c3802281b096" );
1353 
1354  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1355  if( 0 == 0 )
1356  {
1357  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1358  hexify( dst_str, output, 8 );
1359 
1360  fct_chk( strcmp( (char *) dst_str, "1111111111111111" ) == 0 );
1361  }
1362  }
1363  FCT_TEST_END();
1364 
1365 
1366  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_6)
1367  {
1368  unsigned char key_str[100];
1369  unsigned char src_str[100];
1370  unsigned char dst_str[100];
1371  unsigned char output[100];
1372  blowfish_context ctx;
1373  int key_len;
1374 
1375  memset(key_str, 0x00, 100);
1376  memset(src_str, 0x00, 100);
1377  memset(dst_str, 0x00, 100);
1378  memset(output, 0x00, 100);
1379 
1380  key_len = unhexify( key_str, "1111111111111111" );
1381  unhexify( src_str, "7d0cc630afda1ec7" );
1382 
1383  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1384  if( 0 == 0 )
1385  {
1386  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1387  hexify( dst_str, output, 8 );
1388 
1389  fct_chk( strcmp( (char *) dst_str, "0123456789abcdef" ) == 0 );
1390  }
1391  }
1392  FCT_TEST_END();
1393 
1394 
1395  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_7)
1396  {
1397  unsigned char key_str[100];
1398  unsigned char src_str[100];
1399  unsigned char dst_str[100];
1400  unsigned char output[100];
1401  blowfish_context ctx;
1402  int key_len;
1403 
1404  memset(key_str, 0x00, 100);
1405  memset(src_str, 0x00, 100);
1406  memset(dst_str, 0x00, 100);
1407  memset(output, 0x00, 100);
1408 
1409  key_len = unhexify( key_str, "0000000000000000" );
1410  unhexify( src_str, "4ef997456198dd78" );
1411 
1412  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1413  if( 0 == 0 )
1414  {
1415  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1416  hexify( dst_str, output, 8 );
1417 
1418  fct_chk( strcmp( (char *) dst_str, "0000000000000000" ) == 0 );
1419  }
1420  }
1421  FCT_TEST_END();
1422 
1423 
1424  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_8)
1425  {
1426  unsigned char key_str[100];
1427  unsigned char src_str[100];
1428  unsigned char dst_str[100];
1429  unsigned char output[100];
1430  blowfish_context ctx;
1431  int key_len;
1432 
1433  memset(key_str, 0x00, 100);
1434  memset(src_str, 0x00, 100);
1435  memset(dst_str, 0x00, 100);
1436  memset(output, 0x00, 100);
1437 
1438  key_len = unhexify( key_str, "fedcba9876543210" );
1439  unhexify( src_str, "0aceab0fc6a0a28d" );
1440 
1441  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1442  if( 0 == 0 )
1443  {
1444  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1445  hexify( dst_str, output, 8 );
1446 
1447  fct_chk( strcmp( (char *) dst_str, "0123456789abcdef" ) == 0 );
1448  }
1449  }
1450  FCT_TEST_END();
1451 
1452 
1453  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_9)
1454  {
1455  unsigned char key_str[100];
1456  unsigned char src_str[100];
1457  unsigned char dst_str[100];
1458  unsigned char output[100];
1459  blowfish_context ctx;
1460  int key_len;
1461 
1462  memset(key_str, 0x00, 100);
1463  memset(src_str, 0x00, 100);
1464  memset(dst_str, 0x00, 100);
1465  memset(output, 0x00, 100);
1466 
1467  key_len = unhexify( key_str, "7ca110454a1a6e57" );
1468  unhexify( src_str, "59c68245eb05282b" );
1469 
1470  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1471  if( 0 == 0 )
1472  {
1473  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1474  hexify( dst_str, output, 8 );
1475 
1476  fct_chk( strcmp( (char *) dst_str, "01a1d6d039776742" ) == 0 );
1477  }
1478  }
1479  FCT_TEST_END();
1480 
1481 
1482  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_10)
1483  {
1484  unsigned char key_str[100];
1485  unsigned char src_str[100];
1486  unsigned char dst_str[100];
1487  unsigned char output[100];
1488  blowfish_context ctx;
1489  int key_len;
1490 
1491  memset(key_str, 0x00, 100);
1492  memset(src_str, 0x00, 100);
1493  memset(dst_str, 0x00, 100);
1494  memset(output, 0x00, 100);
1495 
1496  key_len = unhexify( key_str, "0131d9619dc1376e" );
1497  unhexify( src_str, "b1b8cc0b250f09a0" );
1498 
1499  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1500  if( 0 == 0 )
1501  {
1502  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1503  hexify( dst_str, output, 8 );
1504 
1505  fct_chk( strcmp( (char *) dst_str, "5cd54ca83def57da" ) == 0 );
1506  }
1507  }
1508  FCT_TEST_END();
1509 
1510 
1511  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_11)
1512  {
1513  unsigned char key_str[100];
1514  unsigned char src_str[100];
1515  unsigned char dst_str[100];
1516  unsigned char output[100];
1517  blowfish_context ctx;
1518  int key_len;
1519 
1520  memset(key_str, 0x00, 100);
1521  memset(src_str, 0x00, 100);
1522  memset(dst_str, 0x00, 100);
1523  memset(output, 0x00, 100);
1524 
1525  key_len = unhexify( key_str, "07a1133e4a0b2686" );
1526  unhexify( src_str, "1730e5778bea1da4" );
1527 
1528  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1529  if( 0 == 0 )
1530  {
1531  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1532  hexify( dst_str, output, 8 );
1533 
1534  fct_chk( strcmp( (char *) dst_str, "0248d43806f67172" ) == 0 );
1535  }
1536  }
1537  FCT_TEST_END();
1538 
1539 
1540  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_12)
1541  {
1542  unsigned char key_str[100];
1543  unsigned char src_str[100];
1544  unsigned char dst_str[100];
1545  unsigned char output[100];
1546  blowfish_context ctx;
1547  int key_len;
1548 
1549  memset(key_str, 0x00, 100);
1550  memset(src_str, 0x00, 100);
1551  memset(dst_str, 0x00, 100);
1552  memset(output, 0x00, 100);
1553 
1554  key_len = unhexify( key_str, "3849674c2602319e" );
1555  unhexify( src_str, "a25e7856cf2651eb" );
1556 
1557  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1558  if( 0 == 0 )
1559  {
1560  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1561  hexify( dst_str, output, 8 );
1562 
1563  fct_chk( strcmp( (char *) dst_str, "51454b582ddf440a" ) == 0 );
1564  }
1565  }
1566  FCT_TEST_END();
1567 
1568 
1569  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_13)
1570  {
1571  unsigned char key_str[100];
1572  unsigned char src_str[100];
1573  unsigned char dst_str[100];
1574  unsigned char output[100];
1575  blowfish_context ctx;
1576  int key_len;
1577 
1578  memset(key_str, 0x00, 100);
1579  memset(src_str, 0x00, 100);
1580  memset(dst_str, 0x00, 100);
1581  memset(output, 0x00, 100);
1582 
1583  key_len = unhexify( key_str, "04b915ba43feb5b6" );
1584  unhexify( src_str, "353882b109ce8f1a" );
1585 
1586  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1587  if( 0 == 0 )
1588  {
1589  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1590  hexify( dst_str, output, 8 );
1591 
1592  fct_chk( strcmp( (char *) dst_str, "42fd443059577fa2" ) == 0 );
1593  }
1594  }
1595  FCT_TEST_END();
1596 
1597 
1598  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_14)
1599  {
1600  unsigned char key_str[100];
1601  unsigned char src_str[100];
1602  unsigned char dst_str[100];
1603  unsigned char output[100];
1604  blowfish_context ctx;
1605  int key_len;
1606 
1607  memset(key_str, 0x00, 100);
1608  memset(src_str, 0x00, 100);
1609  memset(dst_str, 0x00, 100);
1610  memset(output, 0x00, 100);
1611 
1612  key_len = unhexify( key_str, "0113b970fd34f2ce" );
1613  unhexify( src_str, "48f4d0884c379918" );
1614 
1615  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1616  if( 0 == 0 )
1617  {
1618  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1619  hexify( dst_str, output, 8 );
1620 
1621  fct_chk( strcmp( (char *) dst_str, "059b5e0851cf143a" ) == 0 );
1622  }
1623  }
1624  FCT_TEST_END();
1625 
1626 
1627  FCT_TEST_BGN(blowfish_ecb_encrypt_ssleay_reference_15)
1628  {
1629  unsigned char key_str[100];
1630  unsigned char src_str[100];
1631  unsigned char dst_str[100];
1632  unsigned char output[100];
1633  blowfish_context ctx;
1634  int key_len;
1635 
1636  memset(key_str, 0x00, 100);
1637  memset(src_str, 0x00, 100);
1638  memset(dst_str, 0x00, 100);
1639  memset(output, 0x00, 100);
1640 
1641  key_len = unhexify( key_str, "0170f175468fb5e6" );
1642  unhexify( src_str, "0756d8e0774761d2" );
1643 
1644  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1645  if( 0 == 0 )
1646  {
1647  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
1648  hexify( dst_str, output, 8 );
1649 
1650  fct_chk( strcmp( (char *) dst_str, "432193b78951fc98" ) == 0 );
1651  }
1652  }
1653  FCT_TEST_END();
1654 
1655 
1656  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_16)
1657  {
1658  unsigned char key_str[100];
1659  unsigned char src_str[100];
1660  unsigned char dst_str[100];
1661  unsigned char output[100];
1662  blowfish_context ctx;
1663  int key_len;
1664 
1665  memset(key_str, 0x00, 100);
1666  memset(src_str, 0x00, 100);
1667  memset(dst_str, 0x00, 100);
1668  memset(output, 0x00, 100);
1669 
1670  key_len = unhexify( key_str, "43297fad38e373fe" );
1671  unhexify( src_str, "13f04154d69d1ae5" );
1672 
1673  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1674  if( 0 == 0 )
1675  {
1676  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1677  hexify( dst_str, output, 8 );
1678 
1679  fct_chk( strcmp( (char *) dst_str, "762514b829bf486a" ) == 0 );
1680  }
1681  }
1682  FCT_TEST_END();
1683 
1684 
1685  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_17)
1686  {
1687  unsigned char key_str[100];
1688  unsigned char src_str[100];
1689  unsigned char dst_str[100];
1690  unsigned char output[100];
1691  blowfish_context ctx;
1692  int key_len;
1693 
1694  memset(key_str, 0x00, 100);
1695  memset(src_str, 0x00, 100);
1696  memset(dst_str, 0x00, 100);
1697  memset(output, 0x00, 100);
1698 
1699  key_len = unhexify( key_str, "07a7137045da2a16" );
1700  unhexify( src_str, "2eedda93ffd39c79" );
1701 
1702  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1703  if( 0 == 0 )
1704  {
1705  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1706  hexify( dst_str, output, 8 );
1707 
1708  fct_chk( strcmp( (char *) dst_str, "3bdd119049372802" ) == 0 );
1709  }
1710  }
1711  FCT_TEST_END();
1712 
1713 
1714  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_18)
1715  {
1716  unsigned char key_str[100];
1717  unsigned char src_str[100];
1718  unsigned char dst_str[100];
1719  unsigned char output[100];
1720  blowfish_context ctx;
1721  int key_len;
1722 
1723  memset(key_str, 0x00, 100);
1724  memset(src_str, 0x00, 100);
1725  memset(dst_str, 0x00, 100);
1726  memset(output, 0x00, 100);
1727 
1728  key_len = unhexify( key_str, "04689104c2fd3b2f" );
1729  unhexify( src_str, "d887e0393c2da6e3" );
1730 
1731  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1732  if( 0 == 0 )
1733  {
1734  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1735  hexify( dst_str, output, 8 );
1736 
1737  fct_chk( strcmp( (char *) dst_str, "26955f6835af609a" ) == 0 );
1738  }
1739  }
1740  FCT_TEST_END();
1741 
1742 
1743  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_19)
1744  {
1745  unsigned char key_str[100];
1746  unsigned char src_str[100];
1747  unsigned char dst_str[100];
1748  unsigned char output[100];
1749  blowfish_context ctx;
1750  int key_len;
1751 
1752  memset(key_str, 0x00, 100);
1753  memset(src_str, 0x00, 100);
1754  memset(dst_str, 0x00, 100);
1755  memset(output, 0x00, 100);
1756 
1757  key_len = unhexify( key_str, "37d06bb516cb7546" );
1758  unhexify( src_str, "5f99d04f5b163969" );
1759 
1760  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1761  if( 0 == 0 )
1762  {
1763  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1764  hexify( dst_str, output, 8 );
1765 
1766  fct_chk( strcmp( (char *) dst_str, "164d5e404f275232" ) == 0 );
1767  }
1768  }
1769  FCT_TEST_END();
1770 
1771 
1772  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_20)
1773  {
1774  unsigned char key_str[100];
1775  unsigned char src_str[100];
1776  unsigned char dst_str[100];
1777  unsigned char output[100];
1778  blowfish_context ctx;
1779  int key_len;
1780 
1781  memset(key_str, 0x00, 100);
1782  memset(src_str, 0x00, 100);
1783  memset(dst_str, 0x00, 100);
1784  memset(output, 0x00, 100);
1785 
1786  key_len = unhexify( key_str, "1f08260d1ac2465e" );
1787  unhexify( src_str, "4a057a3b24d3977b" );
1788 
1789  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1790  if( 0 == 0 )
1791  {
1792  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1793  hexify( dst_str, output, 8 );
1794 
1795  fct_chk( strcmp( (char *) dst_str, "6b056e18759f5cca" ) == 0 );
1796  }
1797  }
1798  FCT_TEST_END();
1799 
1800 
1801  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_21)
1802  {
1803  unsigned char key_str[100];
1804  unsigned char src_str[100];
1805  unsigned char dst_str[100];
1806  unsigned char output[100];
1807  blowfish_context ctx;
1808  int key_len;
1809 
1810  memset(key_str, 0x00, 100);
1811  memset(src_str, 0x00, 100);
1812  memset(dst_str, 0x00, 100);
1813  memset(output, 0x00, 100);
1814 
1815  key_len = unhexify( key_str, "584023641aba6176" );
1816  unhexify( src_str, "452031c1e4fada8e" );
1817 
1818  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1819  if( 0 == 0 )
1820  {
1821  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1822  hexify( dst_str, output, 8 );
1823 
1824  fct_chk( strcmp( (char *) dst_str, "004bd6ef09176062" ) == 0 );
1825  }
1826  }
1827  FCT_TEST_END();
1828 
1829 
1830  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_22)
1831  {
1832  unsigned char key_str[100];
1833  unsigned char src_str[100];
1834  unsigned char dst_str[100];
1835  unsigned char output[100];
1836  blowfish_context ctx;
1837  int key_len;
1838 
1839  memset(key_str, 0x00, 100);
1840  memset(src_str, 0x00, 100);
1841  memset(dst_str, 0x00, 100);
1842  memset(output, 0x00, 100);
1843 
1844  key_len = unhexify( key_str, "025816164629b007" );
1845  unhexify( src_str, "7555ae39f59b87bd" );
1846 
1847  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1848  if( 0 == 0 )
1849  {
1850  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1851  hexify( dst_str, output, 8 );
1852 
1853  fct_chk( strcmp( (char *) dst_str, "480d39006ee762f2" ) == 0 );
1854  }
1855  }
1856  FCT_TEST_END();
1857 
1858 
1859  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_23)
1860  {
1861  unsigned char key_str[100];
1862  unsigned char src_str[100];
1863  unsigned char dst_str[100];
1864  unsigned char output[100];
1865  blowfish_context ctx;
1866  int key_len;
1867 
1868  memset(key_str, 0x00, 100);
1869  memset(src_str, 0x00, 100);
1870  memset(dst_str, 0x00, 100);
1871  memset(output, 0x00, 100);
1872 
1873  key_len = unhexify( key_str, "49793ebc79b3258f" );
1874  unhexify( src_str, "53c55f9cb49fc019" );
1875 
1876  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1877  if( 0 == 0 )
1878  {
1879  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1880  hexify( dst_str, output, 8 );
1881 
1882  fct_chk( strcmp( (char *) dst_str, "437540c8698f3cfa" ) == 0 );
1883  }
1884  }
1885  FCT_TEST_END();
1886 
1887 
1888  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_24)
1889  {
1890  unsigned char key_str[100];
1891  unsigned char src_str[100];
1892  unsigned char dst_str[100];
1893  unsigned char output[100];
1894  blowfish_context ctx;
1895  int key_len;
1896 
1897  memset(key_str, 0x00, 100);
1898  memset(src_str, 0x00, 100);
1899  memset(dst_str, 0x00, 100);
1900  memset(output, 0x00, 100);
1901 
1902  key_len = unhexify( key_str, "4fb05e1515ab73a7" );
1903  unhexify( src_str, "7a8e7bfa937e89a3" );
1904 
1905  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1906  if( 0 == 0 )
1907  {
1908  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1909  hexify( dst_str, output, 8 );
1910 
1911  fct_chk( strcmp( (char *) dst_str, "072d43a077075292" ) == 0 );
1912  }
1913  }
1914  FCT_TEST_END();
1915 
1916 
1917  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_25)
1918  {
1919  unsigned char key_str[100];
1920  unsigned char src_str[100];
1921  unsigned char dst_str[100];
1922  unsigned char output[100];
1923  blowfish_context ctx;
1924  int key_len;
1925 
1926  memset(key_str, 0x00, 100);
1927  memset(src_str, 0x00, 100);
1928  memset(dst_str, 0x00, 100);
1929  memset(output, 0x00, 100);
1930 
1931  key_len = unhexify( key_str, "49e95d6d4ca229bf" );
1932  unhexify( src_str, "cf9c5d7a4986adb5" );
1933 
1934  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1935  if( 0 == 0 )
1936  {
1937  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1938  hexify( dst_str, output, 8 );
1939 
1940  fct_chk( strcmp( (char *) dst_str, "02fe55778117f12a" ) == 0 );
1941  }
1942  }
1943  FCT_TEST_END();
1944 
1945 
1946  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_26)
1947  {
1948  unsigned char key_str[100];
1949  unsigned char src_str[100];
1950  unsigned char dst_str[100];
1951  unsigned char output[100];
1952  blowfish_context ctx;
1953  int key_len;
1954 
1955  memset(key_str, 0x00, 100);
1956  memset(src_str, 0x00, 100);
1957  memset(dst_str, 0x00, 100);
1958  memset(output, 0x00, 100);
1959 
1960  key_len = unhexify( key_str, "018310dc409b26d6" );
1961  unhexify( src_str, "d1abb290658bc778" );
1962 
1963  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1964  if( 0 == 0 )
1965  {
1966  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1967  hexify( dst_str, output, 8 );
1968 
1969  fct_chk( strcmp( (char *) dst_str, "1d9d5c5018f728c2" ) == 0 );
1970  }
1971  }
1972  FCT_TEST_END();
1973 
1974 
1975  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_27)
1976  {
1977  unsigned char key_str[100];
1978  unsigned char src_str[100];
1979  unsigned char dst_str[100];
1980  unsigned char output[100];
1981  blowfish_context ctx;
1982  int key_len;
1983 
1984  memset(key_str, 0x00, 100);
1985  memset(src_str, 0x00, 100);
1986  memset(dst_str, 0x00, 100);
1987  memset(output, 0x00, 100);
1988 
1989  key_len = unhexify( key_str, "1c587f1c13924fef" );
1990  unhexify( src_str, "55cb3774d13ef201" );
1991 
1992  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
1993  if( 0 == 0 )
1994  {
1995  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
1996  hexify( dst_str, output, 8 );
1997 
1998  fct_chk( strcmp( (char *) dst_str, "305532286d6f295a" ) == 0 );
1999  }
2000  }
2001  FCT_TEST_END();
2002 
2003 
2004  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_28)
2005  {
2006  unsigned char key_str[100];
2007  unsigned char src_str[100];
2008  unsigned char dst_str[100];
2009  unsigned char output[100];
2010  blowfish_context ctx;
2011  int key_len;
2012 
2013  memset(key_str, 0x00, 100);
2014  memset(src_str, 0x00, 100);
2015  memset(dst_str, 0x00, 100);
2016  memset(output, 0x00, 100);
2017 
2018  key_len = unhexify( key_str, "0101010101010101" );
2019  unhexify( src_str, "fa34ec4847b268b2" );
2020 
2021  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2022  if( 0 == 0 )
2023  {
2024  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2025  hexify( dst_str, output, 8 );
2026 
2027  fct_chk( strcmp( (char *) dst_str, "0123456789abcdef" ) == 0 );
2028  }
2029  }
2030  FCT_TEST_END();
2031 
2032 
2033  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_29)
2034  {
2035  unsigned char key_str[100];
2036  unsigned char src_str[100];
2037  unsigned char dst_str[100];
2038  unsigned char output[100];
2039  blowfish_context ctx;
2040  int key_len;
2041 
2042  memset(key_str, 0x00, 100);
2043  memset(src_str, 0x00, 100);
2044  memset(dst_str, 0x00, 100);
2045  memset(output, 0x00, 100);
2046 
2047  key_len = unhexify( key_str, "1f1f1f1f0e0e0e0e" );
2048  unhexify( src_str, "a790795108ea3cae" );
2049 
2050  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2051  if( 0 == 0 )
2052  {
2053  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2054  hexify( dst_str, output, 8 );
2055 
2056  fct_chk( strcmp( (char *) dst_str, "0123456789abcdef" ) == 0 );
2057  }
2058  }
2059  FCT_TEST_END();
2060 
2061 
2062  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_30)
2063  {
2064  unsigned char key_str[100];
2065  unsigned char src_str[100];
2066  unsigned char dst_str[100];
2067  unsigned char output[100];
2068  blowfish_context ctx;
2069  int key_len;
2070 
2071  memset(key_str, 0x00, 100);
2072  memset(src_str, 0x00, 100);
2073  memset(dst_str, 0x00, 100);
2074  memset(output, 0x00, 100);
2075 
2076  key_len = unhexify( key_str, "e0fee0fef1fef1fe" );
2077  unhexify( src_str, "c39e072d9fac631d" );
2078 
2079  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2080  if( 0 == 0 )
2081  {
2082  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2083  hexify( dst_str, output, 8 );
2084 
2085  fct_chk( strcmp( (char *) dst_str, "0123456789abcdef" ) == 0 );
2086  }
2087  }
2088  FCT_TEST_END();
2089 
2090 
2091  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_31)
2092  {
2093  unsigned char key_str[100];
2094  unsigned char src_str[100];
2095  unsigned char dst_str[100];
2096  unsigned char output[100];
2097  blowfish_context ctx;
2098  int key_len;
2099 
2100  memset(key_str, 0x00, 100);
2101  memset(src_str, 0x00, 100);
2102  memset(dst_str, 0x00, 100);
2103  memset(output, 0x00, 100);
2104 
2105  key_len = unhexify( key_str, "0000000000000000" );
2106  unhexify( src_str, "014933e0cdaff6e4" );
2107 
2108  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2109  if( 0 == 0 )
2110  {
2111  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2112  hexify( dst_str, output, 8 );
2113 
2114  fct_chk( strcmp( (char *) dst_str, "ffffffffffffffff" ) == 0 );
2115  }
2116  }
2117  FCT_TEST_END();
2118 
2119 
2120  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_32)
2121  {
2122  unsigned char key_str[100];
2123  unsigned char src_str[100];
2124  unsigned char dst_str[100];
2125  unsigned char output[100];
2126  blowfish_context ctx;
2127  int key_len;
2128 
2129  memset(key_str, 0x00, 100);
2130  memset(src_str, 0x00, 100);
2131  memset(dst_str, 0x00, 100);
2132  memset(output, 0x00, 100);
2133 
2134  key_len = unhexify( key_str, "ffffffffffffffff" );
2135  unhexify( src_str, "f21e9a77b71c49bc" );
2136 
2137  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2138  if( 0 == 0 )
2139  {
2140  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2141  hexify( dst_str, output, 8 );
2142 
2143  fct_chk( strcmp( (char *) dst_str, "0000000000000000" ) == 0 );
2144  }
2145  }
2146  FCT_TEST_END();
2147 
2148 
2149  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_33)
2150  {
2151  unsigned char key_str[100];
2152  unsigned char src_str[100];
2153  unsigned char dst_str[100];
2154  unsigned char output[100];
2155  blowfish_context ctx;
2156  int key_len;
2157 
2158  memset(key_str, 0x00, 100);
2159  memset(src_str, 0x00, 100);
2160  memset(dst_str, 0x00, 100);
2161  memset(output, 0x00, 100);
2162 
2163  key_len = unhexify( key_str, "0123456789abcdef" );
2164  unhexify( src_str, "245946885754369a" );
2165 
2166  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2167  if( 0 == 0 )
2168  {
2169  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2170  hexify( dst_str, output, 8 );
2171 
2172  fct_chk( strcmp( (char *) dst_str, "0000000000000000" ) == 0 );
2173  }
2174  }
2175  FCT_TEST_END();
2176 
2177 
2178  FCT_TEST_BGN(blowfish_ecb_decrypt_ssleay_reference_34)
2179  {
2180  unsigned char key_str[100];
2181  unsigned char src_str[100];
2182  unsigned char dst_str[100];
2183  unsigned char output[100];
2184  blowfish_context ctx;
2185  int key_len;
2186 
2187  memset(key_str, 0x00, 100);
2188  memset(src_str, 0x00, 100);
2189  memset(dst_str, 0x00, 100);
2190  memset(output, 0x00, 100);
2191 
2192  key_len = unhexify( key_str, "fedcba9876543210" );
2193  unhexify( src_str, "6b5c5a9c5d9e0a5a" );
2194 
2195  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2196  if( 0 == 0 )
2197  {
2198  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_DECRYPT, src_str, output ) == 0 );
2199  hexify( dst_str, output, 8 );
2200 
2201  fct_chk( strcmp( (char *) dst_str, "ffffffffffffffff" ) == 0 );
2202  }
2203  }
2204  FCT_TEST_END();
2205 
2206 
2207  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_1)
2208  {
2209  unsigned char key_str[100];
2210  unsigned char src_str[100];
2211  unsigned char dst_str[100];
2212  unsigned char output[100];
2213  blowfish_context ctx;
2214  int key_len;
2215 
2216  memset(key_str, 0x00, 100);
2217  memset(src_str, 0x00, 100);
2218  memset(dst_str, 0x00, 100);
2219  memset(output, 0x00, 100);
2220 
2221  key_len = unhexify( key_str, "f0" );
2222  unhexify( src_str, "fedcba9876543210" );
2223 
2224  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH );
2226  {
2227  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2228  hexify( dst_str, output, 8 );
2229 
2230  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
2231  }
2232  }
2233  FCT_TEST_END();
2234 
2235 
2236  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_2)
2237  {
2238  unsigned char key_str[100];
2239  unsigned char src_str[100];
2240  unsigned char dst_str[100];
2241  unsigned char output[100];
2242  blowfish_context ctx;
2243  int key_len;
2244 
2245  memset(key_str, 0x00, 100);
2246  memset(src_str, 0x00, 100);
2247  memset(dst_str, 0x00, 100);
2248  memset(output, 0x00, 100);
2249 
2250  key_len = unhexify( key_str, "f0e1" );
2251  unhexify( src_str, "fedcba9876543210" );
2252 
2253  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH );
2255  {
2256  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2257  hexify( dst_str, output, 8 );
2258 
2259  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
2260  }
2261  }
2262  FCT_TEST_END();
2263 
2264 
2265  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_3)
2266  {
2267  unsigned char key_str[100];
2268  unsigned char src_str[100];
2269  unsigned char dst_str[100];
2270  unsigned char output[100];
2271  blowfish_context ctx;
2272  int key_len;
2273 
2274  memset(key_str, 0x00, 100);
2275  memset(src_str, 0x00, 100);
2276  memset(dst_str, 0x00, 100);
2277  memset(output, 0x00, 100);
2278 
2279  key_len = unhexify( key_str, "f0e1d2" );
2280  unhexify( src_str, "fedcba9876543210" );
2281 
2282  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH );
2284  {
2285  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2286  hexify( dst_str, output, 8 );
2287 
2288  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
2289  }
2290  }
2291  FCT_TEST_END();
2292 
2293 
2294  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_4)
2295  {
2296  unsigned char key_str[100];
2297  unsigned char src_str[100];
2298  unsigned char dst_str[100];
2299  unsigned char output[100];
2300  blowfish_context ctx;
2301  int key_len;
2302 
2303  memset(key_str, 0x00, 100);
2304  memset(src_str, 0x00, 100);
2305  memset(dst_str, 0x00, 100);
2306  memset(output, 0x00, 100);
2307 
2308  key_len = unhexify( key_str, "f0e1d2c3" );
2309  unhexify( src_str, "fedcba9876543210" );
2310 
2311  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2312  if( 0 == 0 )
2313  {
2314  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2315  hexify( dst_str, output, 8 );
2316 
2317  fct_chk( strcmp( (char *) dst_str, "be1e639408640f05" ) == 0 );
2318  }
2319  }
2320  FCT_TEST_END();
2321 
2322 
2323  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_5)
2324  {
2325  unsigned char key_str[100];
2326  unsigned char src_str[100];
2327  unsigned char dst_str[100];
2328  unsigned char output[100];
2329  blowfish_context ctx;
2330  int key_len;
2331 
2332  memset(key_str, 0x00, 100);
2333  memset(src_str, 0x00, 100);
2334  memset(dst_str, 0x00, 100);
2335  memset(output, 0x00, 100);
2336 
2337  key_len = unhexify( key_str, "f0e1d2c3b4" );
2338  unhexify( src_str, "fedcba9876543210" );
2339 
2340  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2341  if( 0 == 0 )
2342  {
2343  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2344  hexify( dst_str, output, 8 );
2345 
2346  fct_chk( strcmp( (char *) dst_str, "b39e44481bdb1e6e" ) == 0 );
2347  }
2348  }
2349  FCT_TEST_END();
2350 
2351 
2352  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_6)
2353  {
2354  unsigned char key_str[100];
2355  unsigned char src_str[100];
2356  unsigned char dst_str[100];
2357  unsigned char output[100];
2358  blowfish_context ctx;
2359  int key_len;
2360 
2361  memset(key_str, 0x00, 100);
2362  memset(src_str, 0x00, 100);
2363  memset(dst_str, 0x00, 100);
2364  memset(output, 0x00, 100);
2365 
2366  key_len = unhexify( key_str, "f0e1d2c3b4a5" );
2367  unhexify( src_str, "fedcba9876543210" );
2368 
2369  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2370  if( 0 == 0 )
2371  {
2372  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2373  hexify( dst_str, output, 8 );
2374 
2375  fct_chk( strcmp( (char *) dst_str, "9457aa83b1928c0d" ) == 0 );
2376  }
2377  }
2378  FCT_TEST_END();
2379 
2380 
2381  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_7)
2382  {
2383  unsigned char key_str[100];
2384  unsigned char src_str[100];
2385  unsigned char dst_str[100];
2386  unsigned char output[100];
2387  blowfish_context ctx;
2388  int key_len;
2389 
2390  memset(key_str, 0x00, 100);
2391  memset(src_str, 0x00, 100);
2392  memset(dst_str, 0x00, 100);
2393  memset(output, 0x00, 100);
2394 
2395  key_len = unhexify( key_str, "f0e1d2c3b4a596" );
2396  unhexify( src_str, "fedcba9876543210" );
2397 
2398  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2399  if( 0 == 0 )
2400  {
2401  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2402  hexify( dst_str, output, 8 );
2403 
2404  fct_chk( strcmp( (char *) dst_str, "8bb77032f960629d" ) == 0 );
2405  }
2406  }
2407  FCT_TEST_END();
2408 
2409 
2410  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_8)
2411  {
2412  unsigned char key_str[100];
2413  unsigned char src_str[100];
2414  unsigned char dst_str[100];
2415  unsigned char output[100];
2416  blowfish_context ctx;
2417  int key_len;
2418 
2419  memset(key_str, 0x00, 100);
2420  memset(src_str, 0x00, 100);
2421  memset(dst_str, 0x00, 100);
2422  memset(output, 0x00, 100);
2423 
2424  key_len = unhexify( key_str, "f0e1d2c3b4a59687" );
2425  unhexify( src_str, "fedcba9876543210" );
2426 
2427  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2428  if( 0 == 0 )
2429  {
2430  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2431  hexify( dst_str, output, 8 );
2432 
2433  fct_chk( strcmp( (char *) dst_str, "e87a244e2cc85e82" ) == 0 );
2434  }
2435  }
2436  FCT_TEST_END();
2437 
2438 
2439  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_9)
2440  {
2441  unsigned char key_str[100];
2442  unsigned char src_str[100];
2443  unsigned char dst_str[100];
2444  unsigned char output[100];
2445  blowfish_context ctx;
2446  int key_len;
2447 
2448  memset(key_str, 0x00, 100);
2449  memset(src_str, 0x00, 100);
2450  memset(dst_str, 0x00, 100);
2451  memset(output, 0x00, 100);
2452 
2453  key_len = unhexify( key_str, "f0e1d2c3b4a5968778" );
2454  unhexify( src_str, "fedcba9876543210" );
2455 
2456  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2457  if( 0 == 0 )
2458  {
2459  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2460  hexify( dst_str, output, 8 );
2461 
2462  fct_chk( strcmp( (char *) dst_str, "15750e7a4f4ec577" ) == 0 );
2463  }
2464  }
2465  FCT_TEST_END();
2466 
2467 
2468  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_10)
2469  {
2470  unsigned char key_str[100];
2471  unsigned char src_str[100];
2472  unsigned char dst_str[100];
2473  unsigned char output[100];
2474  blowfish_context ctx;
2475  int key_len;
2476 
2477  memset(key_str, 0x00, 100);
2478  memset(src_str, 0x00, 100);
2479  memset(dst_str, 0x00, 100);
2480  memset(output, 0x00, 100);
2481 
2482  key_len = unhexify( key_str, "f0e1d2c3b4a596877869" );
2483  unhexify( src_str, "fedcba9876543210" );
2484 
2485  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2486  if( 0 == 0 )
2487  {
2488  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2489  hexify( dst_str, output, 8 );
2490 
2491  fct_chk( strcmp( (char *) dst_str, "122ba70b3ab64ae0" ) == 0 );
2492  }
2493  }
2494  FCT_TEST_END();
2495 
2496 
2497  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_11)
2498  {
2499  unsigned char key_str[100];
2500  unsigned char src_str[100];
2501  unsigned char dst_str[100];
2502  unsigned char output[100];
2503  blowfish_context ctx;
2504  int key_len;
2505 
2506  memset(key_str, 0x00, 100);
2507  memset(src_str, 0x00, 100);
2508  memset(dst_str, 0x00, 100);
2509  memset(output, 0x00, 100);
2510 
2511  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a" );
2512  unhexify( src_str, "fedcba9876543210" );
2513 
2514  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2515  if( 0 == 0 )
2516  {
2517  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2518  hexify( dst_str, output, 8 );
2519 
2520  fct_chk( strcmp( (char *) dst_str, "3a833c9affc537f6" ) == 0 );
2521  }
2522  }
2523  FCT_TEST_END();
2524 
2525 
2526  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_12)
2527  {
2528  unsigned char key_str[100];
2529  unsigned char src_str[100];
2530  unsigned char dst_str[100];
2531  unsigned char output[100];
2532  blowfish_context ctx;
2533  int key_len;
2534 
2535  memset(key_str, 0x00, 100);
2536  memset(src_str, 0x00, 100);
2537  memset(dst_str, 0x00, 100);
2538  memset(output, 0x00, 100);
2539 
2540  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b" );
2541  unhexify( src_str, "fedcba9876543210" );
2542 
2543  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2544  if( 0 == 0 )
2545  {
2546  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2547  hexify( dst_str, output, 8 );
2548 
2549  fct_chk( strcmp( (char *) dst_str, "9409da87a90f6bf2" ) == 0 );
2550  }
2551  }
2552  FCT_TEST_END();
2553 
2554 
2555  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_13)
2556  {
2557  unsigned char key_str[100];
2558  unsigned char src_str[100];
2559  unsigned char dst_str[100];
2560  unsigned char output[100];
2561  blowfish_context ctx;
2562  int key_len;
2563 
2564  memset(key_str, 0x00, 100);
2565  memset(src_str, 0x00, 100);
2566  memset(dst_str, 0x00, 100);
2567  memset(output, 0x00, 100);
2568 
2569  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c" );
2570  unhexify( src_str, "fedcba9876543210" );
2571 
2572  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2573  if( 0 == 0 )
2574  {
2575  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2576  hexify( dst_str, output, 8 );
2577 
2578  fct_chk( strcmp( (char *) dst_str, "884f80625060b8b4" ) == 0 );
2579  }
2580  }
2581  FCT_TEST_END();
2582 
2583 
2584  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_14)
2585  {
2586  unsigned char key_str[100];
2587  unsigned char src_str[100];
2588  unsigned char dst_str[100];
2589  unsigned char output[100];
2590  blowfish_context ctx;
2591  int key_len;
2592 
2593  memset(key_str, 0x00, 100);
2594  memset(src_str, 0x00, 100);
2595  memset(dst_str, 0x00, 100);
2596  memset(output, 0x00, 100);
2597 
2598  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d" );
2599  unhexify( src_str, "fedcba9876543210" );
2600 
2601  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2602  if( 0 == 0 )
2603  {
2604  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2605  hexify( dst_str, output, 8 );
2606 
2607  fct_chk( strcmp( (char *) dst_str, "1f85031c19e11968" ) == 0 );
2608  }
2609  }
2610  FCT_TEST_END();
2611 
2612 
2613  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_15)
2614  {
2615  unsigned char key_str[100];
2616  unsigned char src_str[100];
2617  unsigned char dst_str[100];
2618  unsigned char output[100];
2619  blowfish_context ctx;
2620  int key_len;
2621 
2622  memset(key_str, 0x00, 100);
2623  memset(src_str, 0x00, 100);
2624  memset(dst_str, 0x00, 100);
2625  memset(output, 0x00, 100);
2626 
2627  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e" );
2628  unhexify( src_str, "fedcba9876543210" );
2629 
2630  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2631  if( 0 == 0 )
2632  {
2633  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2634  hexify( dst_str, output, 8 );
2635 
2636  fct_chk( strcmp( (char *) dst_str, "79d9373a714ca34f" ) == 0 );
2637  }
2638  }
2639  FCT_TEST_END();
2640 
2641 
2642  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_16)
2643  {
2644  unsigned char key_str[100];
2645  unsigned char src_str[100];
2646  unsigned char dst_str[100];
2647  unsigned char output[100];
2648  blowfish_context ctx;
2649  int key_len;
2650 
2651  memset(key_str, 0x00, 100);
2652  memset(src_str, 0x00, 100);
2653  memset(dst_str, 0x00, 100);
2654  memset(output, 0x00, 100);
2655 
2656  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f" );
2657  unhexify( src_str, "fedcba9876543210" );
2658 
2659  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2660  if( 0 == 0 )
2661  {
2662  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2663  hexify( dst_str, output, 8 );
2664 
2665  fct_chk( strcmp( (char *) dst_str, "93142887ee3be15c" ) == 0 );
2666  }
2667  }
2668  FCT_TEST_END();
2669 
2670 
2671  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_17)
2672  {
2673  unsigned char key_str[100];
2674  unsigned char src_str[100];
2675  unsigned char dst_str[100];
2676  unsigned char output[100];
2677  blowfish_context ctx;
2678  int key_len;
2679 
2680  memset(key_str, 0x00, 100);
2681  memset(src_str, 0x00, 100);
2682  memset(dst_str, 0x00, 100);
2683  memset(output, 0x00, 100);
2684 
2685  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f00" );
2686  unhexify( src_str, "fedcba9876543210" );
2687 
2688  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2689  if( 0 == 0 )
2690  {
2691  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2692  hexify( dst_str, output, 8 );
2693 
2694  fct_chk( strcmp( (char *) dst_str, "03429e838ce2d14b" ) == 0 );
2695  }
2696  }
2697  FCT_TEST_END();
2698 
2699 
2700  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_18)
2701  {
2702  unsigned char key_str[100];
2703  unsigned char src_str[100];
2704  unsigned char dst_str[100];
2705  unsigned char output[100];
2706  blowfish_context ctx;
2707  int key_len;
2708 
2709  memset(key_str, 0x00, 100);
2710  memset(src_str, 0x00, 100);
2711  memset(dst_str, 0x00, 100);
2712  memset(output, 0x00, 100);
2713 
2714  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f0011" );
2715  unhexify( src_str, "fedcba9876543210" );
2716 
2717  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2718  if( 0 == 0 )
2719  {
2720  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2721  hexify( dst_str, output, 8 );
2722 
2723  fct_chk( strcmp( (char *) dst_str, "a4299e27469ff67b" ) == 0 );
2724  }
2725  }
2726  FCT_TEST_END();
2727 
2728 
2729  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_19)
2730  {
2731  unsigned char key_str[100];
2732  unsigned char src_str[100];
2733  unsigned char dst_str[100];
2734  unsigned char output[100];
2735  blowfish_context ctx;
2736  int key_len;
2737 
2738  memset(key_str, 0x00, 100);
2739  memset(src_str, 0x00, 100);
2740  memset(dst_str, 0x00, 100);
2741  memset(output, 0x00, 100);
2742 
2743  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f001122" );
2744  unhexify( src_str, "fedcba9876543210" );
2745 
2746  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2747  if( 0 == 0 )
2748  {
2749  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2750  hexify( dst_str, output, 8 );
2751 
2752  fct_chk( strcmp( (char *) dst_str, "afd5aed1c1bc96a8" ) == 0 );
2753  }
2754  }
2755  FCT_TEST_END();
2756 
2757 
2758  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_20)
2759  {
2760  unsigned char key_str[100];
2761  unsigned char src_str[100];
2762  unsigned char dst_str[100];
2763  unsigned char output[100];
2764  blowfish_context ctx;
2765  int key_len;
2766 
2767  memset(key_str, 0x00, 100);
2768  memset(src_str, 0x00, 100);
2769  memset(dst_str, 0x00, 100);
2770  memset(output, 0x00, 100);
2771 
2772  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f00112233" );
2773  unhexify( src_str, "fedcba9876543210" );
2774 
2775  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2776  if( 0 == 0 )
2777  {
2778  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2779  hexify( dst_str, output, 8 );
2780 
2781  fct_chk( strcmp( (char *) dst_str, "10851c0e3858da9f" ) == 0 );
2782  }
2783  }
2784  FCT_TEST_END();
2785 
2786 
2787  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_21)
2788  {
2789  unsigned char key_str[100];
2790  unsigned char src_str[100];
2791  unsigned char dst_str[100];
2792  unsigned char output[100];
2793  blowfish_context ctx;
2794  int key_len;
2795 
2796  memset(key_str, 0x00, 100);
2797  memset(src_str, 0x00, 100);
2798  memset(dst_str, 0x00, 100);
2799  memset(output, 0x00, 100);
2800 
2801  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f0011223344" );
2802  unhexify( src_str, "fedcba9876543210" );
2803 
2804  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2805  if( 0 == 0 )
2806  {
2807  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2808  hexify( dst_str, output, 8 );
2809 
2810  fct_chk( strcmp( (char *) dst_str, "e6f51ed79b9db21f" ) == 0 );
2811  }
2812  }
2813  FCT_TEST_END();
2814 
2815 
2816  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_22)
2817  {
2818  unsigned char key_str[100];
2819  unsigned char src_str[100];
2820  unsigned char dst_str[100];
2821  unsigned char output[100];
2822  blowfish_context ctx;
2823  int key_len;
2824 
2825  memset(key_str, 0x00, 100);
2826  memset(src_str, 0x00, 100);
2827  memset(dst_str, 0x00, 100);
2828  memset(output, 0x00, 100);
2829 
2830  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f001122334455" );
2831  unhexify( src_str, "fedcba9876543210" );
2832 
2833  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2834  if( 0 == 0 )
2835  {
2836  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2837  hexify( dst_str, output, 8 );
2838 
2839  fct_chk( strcmp( (char *) dst_str, "64a6e14afd36b46f" ) == 0 );
2840  }
2841  }
2842  FCT_TEST_END();
2843 
2844 
2845  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_23)
2846  {
2847  unsigned char key_str[100];
2848  unsigned char src_str[100];
2849  unsigned char dst_str[100];
2850  unsigned char output[100];
2851  blowfish_context ctx;
2852  int key_len;
2853 
2854  memset(key_str, 0x00, 100);
2855  memset(src_str, 0x00, 100);
2856  memset(dst_str, 0x00, 100);
2857  memset(output, 0x00, 100);
2858 
2859  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566" );
2860  unhexify( src_str, "fedcba9876543210" );
2861 
2862  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2863  if( 0 == 0 )
2864  {
2865  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2866  hexify( dst_str, output, 8 );
2867 
2868  fct_chk( strcmp( (char *) dst_str, "80c7d7d45a5479ad" ) == 0 );
2869  }
2870  }
2871  FCT_TEST_END();
2872 
2873 
2874  FCT_TEST_BGN(blowfish_setkey_setkey_ssleay_reference_24)
2875  {
2876  unsigned char key_str[100];
2877  unsigned char src_str[100];
2878  unsigned char dst_str[100];
2879  unsigned char output[100];
2880  blowfish_context ctx;
2881  int key_len;
2882 
2883  memset(key_str, 0x00, 100);
2884  memset(src_str, 0x00, 100);
2885  memset(dst_str, 0x00, 100);
2886  memset(output, 0x00, 100);
2887 
2888  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f0011223344556677" );
2889  unhexify( src_str, "fedcba9876543210" );
2890 
2891  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2892  if( 0 == 0 )
2893  {
2894  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2895  hexify( dst_str, output, 8 );
2896 
2897  fct_chk( strcmp( (char *) dst_str, "05044b62fa52d080" ) == 0 );
2898  }
2899  }
2900  FCT_TEST_END();
2901 
2902 
2903  FCT_TEST_BGN(blowfish_setkey_setkey_440_bits)
2904  {
2905  unsigned char key_str[100];
2906  unsigned char src_str[100];
2907  unsigned char dst_str[100];
2908  unsigned char output[100];
2909  blowfish_context ctx;
2910  int key_len;
2911 
2912  memset(key_str, 0x00, 100);
2913  memset(src_str, 0x00, 100);
2914  memset(dst_str, 0x00, 100);
2915  memset(output, 0x00, 100);
2916 
2917  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566778899aabbccddeeff0123456789abcdef0102030405060708090a0b0c0d0e0f" );
2918  unhexify( src_str, "fedcba9876543210" );
2919 
2920  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2921  if( 0 == 0 )
2922  {
2923  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2924  hexify( dst_str, output, 8 );
2925 
2926  fct_chk( strcmp( (char *) dst_str, "9a2ab8f1b00c73d2" ) == 0 );
2927  }
2928  }
2929  FCT_TEST_END();
2930 
2931 
2932  FCT_TEST_BGN(blowfish_setkey_setkey_448_bits)
2933  {
2934  unsigned char key_str[100];
2935  unsigned char src_str[100];
2936  unsigned char dst_str[100];
2937  unsigned char output[100];
2938  blowfish_context ctx;
2939  int key_len;
2940 
2941  memset(key_str, 0x00, 100);
2942  memset(src_str, 0x00, 100);
2943  memset(dst_str, 0x00, 100);
2944  memset(output, 0x00, 100);
2945 
2946  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566778899aabbccddeeff0123456789abcdef0102030405060708090a0b0c0d0e0fff" );
2947  unhexify( src_str, "fedcba9876543210" );
2948 
2949  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == 0 );
2950  if( 0 == 0 )
2951  {
2952  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2953  hexify( dst_str, output, 8 );
2954 
2955  fct_chk( strcmp( (char *) dst_str, "2fb3ab7f0ee91b69" ) == 0 );
2956  }
2957  }
2958  FCT_TEST_END();
2959 
2960 
2961  FCT_TEST_BGN(blowfish_setkey_setkey_456_bits)
2962  {
2963  unsigned char key_str[100];
2964  unsigned char src_str[100];
2965  unsigned char dst_str[100];
2966  unsigned char output[100];
2967  blowfish_context ctx;
2968  int key_len;
2969 
2970  memset(key_str, 0x00, 100);
2971  memset(src_str, 0x00, 100);
2972  memset(dst_str, 0x00, 100);
2973  memset(output, 0x00, 100);
2974 
2975  key_len = unhexify( key_str, "f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566778899aabbccddeeff0123456789abcdef0102030405060708090a0b0c0d0e0fffff" );
2976  unhexify( src_str, "fedcba9876543210" );
2977 
2978  fct_chk( blowfish_setkey( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH );
2980  {
2981  fct_chk( blowfish_crypt_ecb( &ctx, BLOWFISH_ENCRYPT, src_str, output ) == 0 );
2982  hexify( dst_str, output, 8 );
2983 
2984  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
2985  }
2986  }
2987  FCT_TEST_END();
2988 
2989 
2990  FCT_TEST_BGN(blowfish_cbc_encrypt)
2991  {
2992  unsigned char key_str[100];
2993  unsigned char iv_str[100];
2994  unsigned char src_str[100];
2995  unsigned char dst_str[100];
2996  unsigned char output[100];
2997  blowfish_context ctx;
2998  int key_len, data_len;
2999 
3000  memset(key_str, 0x00, 100);
3001  memset(iv_str, 0x00, 100);
3002  memset(src_str, 0x00, 100);
3003  memset(dst_str, 0x00, 100);
3004  memset(output, 0x00, 100);
3005 
3006  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3007  unhexify( iv_str, "FEDCBA9876543210" );
3008  data_len = unhexify( src_str, "37363534333231204E6F77206973207468652074696D6520666F722000000000" );
3009 
3010  blowfish_setkey( &ctx, key_str, key_len * 8 );
3011 
3012  fct_chk( blowfish_crypt_cbc( &ctx, BLOWFISH_ENCRYPT, data_len , iv_str, src_str, output ) == 0 );
3013  if( 0 == 0 )
3014  {
3015  hexify( dst_str, output, data_len );
3016 
3017  fct_chk( strcmp( (char *) dst_str, "6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc" ) == 0 );
3018  }
3019  }
3020  FCT_TEST_END();
3021 
3022 
3023  FCT_TEST_BGN(blowfish_cbc_decrypt)
3024  {
3025  unsigned char key_str[100];
3026  unsigned char iv_str[100];
3027  unsigned char src_str[100];
3028  unsigned char dst_str[100];
3029  unsigned char output[100];
3030  blowfish_context ctx;
3031  int key_len, data_len;
3032 
3033  memset(key_str, 0x00, 100);
3034  memset(iv_str, 0x00, 100);
3035  memset(src_str, 0x00, 100);
3036  memset(dst_str, 0x00, 100);
3037  memset(output, 0x00, 100);
3038 
3039  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3040  unhexify( iv_str, "FEDCBA9876543210" );
3041  data_len = unhexify( src_str, "6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC" );
3042 
3043  blowfish_setkey( &ctx, key_str, key_len * 8 );
3044  fct_chk( blowfish_crypt_cbc( &ctx, BLOWFISH_DECRYPT, data_len , iv_str, src_str, output ) == 0 );
3045  if( 0 == 0)
3046  {
3047  hexify( dst_str, output, data_len );
3048 
3049  fct_chk( strcmp( (char *) dst_str, "37363534333231204e6f77206973207468652074696d6520666f722000000000" ) == 0 );
3050  }
3051  }
3052  FCT_TEST_END();
3053 
3054 
3055  FCT_TEST_BGN(blowfish_cbc_encrypt)
3056  {
3057  unsigned char key_str[100];
3058  unsigned char iv_str[100];
3059  unsigned char src_str[100];
3060  unsigned char dst_str[100];
3061  unsigned char output[100];
3062  blowfish_context ctx;
3063  int key_len, data_len;
3064 
3065  memset(key_str, 0x00, 100);
3066  memset(iv_str, 0x00, 100);
3067  memset(src_str, 0x00, 100);
3068  memset(dst_str, 0x00, 100);
3069  memset(output, 0x00, 100);
3070 
3071  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3072  unhexify( iv_str, "FEDCBA9876543210" );
3073  data_len = unhexify( src_str, "37363534333231204E6F77206973207468652074696D6520666F7220000000" );
3074 
3075  blowfish_setkey( &ctx, key_str, key_len * 8 );
3076 
3077  fct_chk( blowfish_crypt_cbc( &ctx, BLOWFISH_ENCRYPT, data_len , iv_str, src_str, output ) == POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH );
3079  {
3080  hexify( dst_str, output, data_len );
3081 
3082  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
3083  }
3084  }
3085  FCT_TEST_END();
3086 
3087 
3088  FCT_TEST_BGN(blowfish_cbc_decrypt)
3089  {
3090  unsigned char key_str[100];
3091  unsigned char iv_str[100];
3092  unsigned char src_str[100];
3093  unsigned char dst_str[100];
3094  unsigned char output[100];
3095  blowfish_context ctx;
3096  int key_len, data_len;
3097 
3098  memset(key_str, 0x00, 100);
3099  memset(iv_str, 0x00, 100);
3100  memset(src_str, 0x00, 100);
3101  memset(dst_str, 0x00, 100);
3102  memset(output, 0x00, 100);
3103 
3104  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3105  unhexify( iv_str, "FEDCBA9876543210" );
3106  data_len = unhexify( src_str, "6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC00" );
3107 
3108  blowfish_setkey( &ctx, key_str, key_len * 8 );
3109  fct_chk( blowfish_crypt_cbc( &ctx, BLOWFISH_DECRYPT, data_len , iv_str, src_str, output ) == POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH );
3111  {
3112  hexify( dst_str, output, data_len );
3113 
3114  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
3115  }
3116  }
3117  FCT_TEST_END();
3118 
3119 
3120  FCT_TEST_BGN(blowfish_cfb_encrypt)
3121  {
3122  unsigned char key_str[100];
3123  unsigned char iv_str[100];
3124  unsigned char src_str[100];
3125  unsigned char dst_str[100];
3126  unsigned char output[100];
3127  blowfish_context ctx;
3128  size_t iv_offset = 0;
3129  int key_len, src_len;
3130 
3131  memset(key_str, 0x00, 100);
3132  memset(iv_str, 0x00, 100);
3133  memset(src_str, 0x00, 100);
3134  memset(dst_str, 0x00, 100);
3135  memset(output, 0x00, 100);
3136 
3137  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3138  unhexify( iv_str, "FEDCBA9876543210" );
3139  src_len = unhexify( src_str, "37363534333231204E6F77206973207468652074696D6520666F722000" );
3140 
3141  blowfish_setkey( &ctx, key_str, key_len * 8 );
3142  fct_chk( blowfish_crypt_cfb64( &ctx, BLOWFISH_ENCRYPT, src_len, &iv_offset, iv_str, src_str, output ) == 0 );
3143  hexify( dst_str, output, src_len );
3144 
3145  fct_chk( strcmp( (char *) dst_str, "e73214a2822139caf26ecf6d2eb9e76e3da3de04d1517200519d57a6c3" ) == 0 );
3146  }
3147  FCT_TEST_END();
3148 
3149 
3150  FCT_TEST_BGN(blowfish_cfb_decrypt)
3151  {
3152  unsigned char key_str[100];
3153  unsigned char iv_str[100];
3154  unsigned char src_str[100];
3155  unsigned char dst_str[100];
3156  unsigned char output[100];
3157  blowfish_context ctx;
3158  size_t iv_offset = 0;
3159  int key_len, src_len;
3160 
3161  memset(key_str, 0x00, 100);
3162  memset(iv_str, 0x00, 100);
3163  memset(src_str, 0x00, 100);
3164  memset(dst_str, 0x00, 100);
3165  memset(output, 0x00, 100);
3166 
3167  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3168  unhexify( iv_str, "FEDCBA9876543210" );
3169  src_len = unhexify( src_str, "E73214A2822139CAF26ECF6D2EB9E76E3DA3DE04D1517200519D57A6C3" );
3170 
3171  blowfish_setkey( &ctx, key_str, key_len * 8 );
3172  fct_chk( blowfish_crypt_cfb64( &ctx, BLOWFISH_DECRYPT, src_len, &iv_offset, iv_str, src_str, output ) == 0 );
3173  hexify( dst_str, output, src_len );
3174 
3175  fct_chk( strcmp( (char *) dst_str, "37363534333231204e6f77206973207468652074696d6520666f722000" ) == 0 );
3176  }
3177  FCT_TEST_END();
3178 
3179 
3180  FCT_TEST_BGN(blowfish_ctr_encrypt)
3181  {
3182  unsigned char key_str[100];
3183  unsigned char iv_str[100];
3184  unsigned char stream_str[100];
3185  unsigned char src_str[100];
3186  unsigned char dst_str[100];
3187  unsigned char output[100];
3188  blowfish_context ctx;
3189  size_t iv_offset = 0;
3190  int key_len, src_len;
3191 
3192  memset(key_str, 0x00, 100);
3193  memset(iv_str, 0x00, 100);
3194  memset(stream_str, 0x00, 100);
3195  memset(src_str, 0x00, 100);
3196  memset(dst_str, 0x00, 100);
3197  memset(output, 0x00, 100);
3198 
3199  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3200  unhexify( iv_str, "FEDCBA9876543210" );
3201  src_len = unhexify( src_str, "37363534333231204E6F77206973207468652074696D6520666F722000" );
3202 
3203  blowfish_setkey( &ctx, key_str, key_len * 8 );
3204  fct_chk( blowfish_crypt_ctr( &ctx, src_len, &iv_offset, iv_str, stream_str, src_str, output ) == 0 );
3205  hexify( dst_str, output, src_len );
3206 
3207  fct_chk( strcmp( (char *) dst_str, "e73214a2822139ca60254740dd8c5b8acf5e9569c4affeb944b8fc020e" ) == 0 );
3208  }
3209  FCT_TEST_END();
3210 
3211 
3212  FCT_TEST_BGN(blowfish_ctr_decrypt)
3213  {
3214  unsigned char key_str[100];
3215  unsigned char iv_str[100];
3216  unsigned char stream_str[100];
3217  unsigned char src_str[100];
3218  unsigned char dst_str[100];
3219  unsigned char output[100];
3220  blowfish_context ctx;
3221  size_t iv_offset = 0;
3222  int key_len, src_len;
3223 
3224  memset(key_str, 0x00, 100);
3225  memset(iv_str, 0x00, 100);
3226  memset(stream_str, 0x00, 100);
3227  memset(src_str, 0x00, 100);
3228  memset(dst_str, 0x00, 100);
3229  memset(output, 0x00, 100);
3230 
3231  key_len = unhexify( key_str, "0123456789ABCDEFF0E1D2C3B4A59687" );
3232  unhexify( iv_str, "FEDCBA9876543210" );
3233  src_len = unhexify( src_str, "e73214a2822139ca60254740dd8c5b8acf5e9569c4affeb944b8fc020e" );
3234 
3235  blowfish_setkey( &ctx, key_str, key_len * 8 );
3236  fct_chk( blowfish_crypt_ctr( &ctx, src_len, &iv_offset, iv_str, stream_str, src_str, output ) == 0 );
3237  hexify( dst_str, output, src_len );
3238 
3239  fct_chk( strcmp( (char *) dst_str, "37363534333231204e6f77206973207468652074696d6520666f722000" ) == 0 );
3240  }
3241  FCT_TEST_END();
3242 
3243  }
3244  FCT_SUITE_END();
3245 
3246 #endif /* POLARSSL_BLOWFISH_C */
3247 
3248 }
3249 FCT_END();
3250