This source file includes following definitions.
- main
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 #include <config.h>
  19 
  20 #include "gc.h"
  21 
  22 #include <stdio.h>
  23 #include <string.h>
  24 
  25 int
  26 main (int argc, char *argv[])
     
  27 {
  28   Gc_rc rc;
  29 
  30   rc = gc_init ();
  31   if (rc != GC_OK)
  32     {
  33       printf ("gc_init() failed\n");
  34       return 1;
  35     }
  36 
  37   
  38 
  39 
  40   {
  41     int i;
  42     char key[8] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
  43     char input[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  44     char result[8] = { 0x24, 0x6e, 0x9d, 0xb9, 0xc5, 0x50, 0x38, 0x1a };
  45     char temp1[8], temp2[8], temp3[8];
  46     gc_cipher_handle ctx_array[64];
  47 
  48     for (i = 0; i < 64; ++i)
  49       {
  50         gc_cipher_handle ctx;
  51 
  52         rc = gc_cipher_open (GC_DES, GC_ECB, &ctx);
  53         if (rc != GC_OK)
  54           return 1;
  55 
  56         rc = gc_cipher_setkey (ctx, 8, key);
  57         if (rc != GC_OK)
  58           return 1;
  59 
  60         memcpy (temp1, input, 8);
  61         rc = gc_cipher_encrypt_inline (ctx, 8, temp1);
  62         if (rc != GC_OK)
  63           return 1;
  64 
  65         memcpy (temp2, temp1, 8);
  66         rc = gc_cipher_encrypt_inline (ctx, 8, temp2);
  67         if (rc != GC_OK)
  68           return 1;
  69 
  70         rc = gc_cipher_setkey (ctx, 8, temp2);
  71         if (rc != GC_OK)
  72           return 1;
  73 
  74         memcpy (temp3, temp1, 8);
  75         rc = gc_cipher_decrypt_inline (ctx, 8, temp3);
  76         if (rc != GC_OK)
  77           return 1;
  78 
  79         memcpy (key, temp3, 8);
  80         memcpy (input, temp1, 8);
  81 
  82         ctx_array[i] = ctx;
  83       }
  84     if (memcmp (temp3, result, 8))
  85       return 1;
  86 
  87     for (i = 0; i < 64; ++i)
  88       gc_cipher_close (ctx_array[i]);
  89   }
  90 
  91   gc_done ();
  92 
  93   return 0;
  94 }