[svn] / ecrypt / trunk / test / ecrypt-test.c  

svn: ecrypt/trunk/test/ecrypt-test.c

Diff for /ecrypt/trunk/test/ecrypt-test.c between version 34 and 48

version 34, Thu Jun 30 07:16:40 2005 UTC version 48, Thu Aug 4 20:07:05 2005 UTC
Line 1 
Line 1 
 /* ecrypt-test.c */  /* ecrypt-test.c */
   
 /*  /*
  * API conformance test and test vector generation (DRAFT)   * API conformance test, test vector generation, and speed measurement (DRAFT)
  *   *
  * Based on the NESSIE test suite (http://www.cryptonessie.org/)   * Based on the NESSIE test suite (http://www.cryptonessie.org/)
  */   */
Line 18 
Line 18 
 #error self-synchronising stream ciphers are not supported yet  #error self-synchronising stream ciphers are not supported yet
 #endif  #endif
   
 #if defined(ECRYPT_SYNC_AE) || defined(ECRYPT_SSYN_AE)  
 #define ECRYPT_AE  
 #endif  
   
 #include <stdio.h>  #include <stdio.h>
   #include <stdlib.h>
 #include <string.h>  #include <string.h>
   #include <time.h>
 #define MAXKEYSIZEB ((ECRYPT_MAXKEYSIZE + 7) / 8)  
 #define MAXIVSIZEB ((ECRYPT_MAXIVSIZE + 7) / 8)  
 #define MAXMACSIZEB ((ECRYPT_MAXMACSIZE + 7) / 8)  
   
 /* ------------------------------------------------------------------------- */  /* ------------------------------------------------------------------------- */
   
Line 85 
Line 79 
   
 /* ------------------------------------------------------------------------- */  /* ------------------------------------------------------------------------- */
   
 #define TEST_STREAM_SIZEB 0x200  double cpu_speed = 0.0;
 #define LONG_TEST_STREAM_SIZEB 0x20000  double test_time = 3.0;
 #define TEST_CHUNK 64  
   
 #ifdef ECRYPT_LONG_VECTORS  int test_packet = 1;
 #define TEST_STEP 1  int test_setup = 1;
 #else  int output_vectors = 0;
 #define TEST_STEP 9  int single_key = 0;
 #endif  
   
 #ifdef ECRYPT_AE  int errors = 0;
   
   /* ------------------------------------------------------------------------- */
   
   void check_status()
   {
     const double sec = (double)clock() / (double)CLOCKS_PER_SEC;
   
     if (errors >= 10)
       {
         fprintf(stderr, "Too many errors (%d errors). Aborting test.\n", errors);
         exit(1);
       }
   
     if (sec > test_time)
       {
         fprintf(stderr, "Time out (%.2f seconds). Aborting test.\n", sec);
         exit(2);
       }
   }
   
   /* ------------------------------------------------------------------------- */
   
   #if defined(ECRYPT_SYNC_AE) || defined(ECRYPT_SSYN_AE)
   
   #define ECRYPT_AE
   
 #define CTX ECRYPT_AE_ctx  #define CTX ECRYPT_AE_ctx
 #define IVSETUP ECRYPT_AE_ivsetup  #define IVSETUP ECRYPT_AE_ivsetup
Line 131 
Line 148 
   
 #define FINALIZE(ctx, checkmac)  #define FINALIZE(ctx, checkmac)
   
   #define ECRYPT_MAXMACSIZE 0
   #define ECRYPT_MACSIZE(i) (i)
   
   #endif
   
   #define NONZEROSIZE(s) (((s) <= 0) ? 4 : (s))
   
   #define MAXKEYSIZEB NONZEROSIZE((ECRYPT_MAXKEYSIZE + 7) / 8)
   #define MAXIVSIZEB NONZEROSIZE((ECRYPT_MAXIVSIZE + 7) / 8)
   #define MAXMACSIZEB NONZEROSIZE((ECRYPT_MAXMACSIZE + 7) / 8)
   
   /* ------------------------------------------------------------------------- */
   
   void print_header(FILE *fd)
   {
     fprintf(fd,
             "****************************************"
             "****************************************\n");
     fprintf(fd,
             "*                          ECRYPT Stream"
             " Cipher Project                        *\n");
     fprintf(fd,
             "****************************************"
             "****************************************\n");
   }
   
   void print_primitive(FILE *fd, int keysize, int ivsize, int macsize)
   {
     fprintf(fd, "\n");
     fprintf(fd, "Primitive Name: %s\n", ECRYPT_NAME);
     fprintf(fd, "================%.*s\n", (int)strlen(ECRYPT_NAME),
             "==========================================");
     fprintf(fd, "Key size: %d bits\n", keysize);
     fprintf(fd, "IV size: %d bits\n", ivsize);
   #ifdef ECRYPT_AE
     fprintf(fd, "MAC size: %d bits\n", macsize);
   #endif
     fprintf(fd, "\n");
     fprintf(fd, "Preferred block length: %d bytes\n", ECRYPT_BLOCKLENGTH);
     fprintf(fd, "\n");
   }
   
   /* ------------------------------------------------------------------------- */
   
   #define TEST_STREAM_SIZEB 0x200
   #define LONG_TEST_STREAM_SIZEB 0x20000
   #define TEST_CHUNK 64
   
   #ifdef ECRYPT_LONG_VECTORS
   #define TEST_STEP 1
   #else
   #define TEST_STEP 9
 #endif  #endif
   
 typedef struct  typedef struct
Line 165 
Line 234 
   
 } test_struct;  } test_struct;
   
 int errors = 0;  
   
 void encrypt_and_check(test_struct* t, void (*print)(test_struct*, int))  void encrypt_and_check(test_struct* t, void (*print)(test_struct*, int))
 {  {
   u8* plaintext;    u8* plaintext;
Line 378 
Line 445 
 #endif  #endif
   
   fprintf(t->fd, "\n");    fprintf(t->fd, "\n");
   
     check_status();
 }  }
   
 void print_stream(test_struct* t, int type)  void print_stream(test_struct* t, int type)
Line 488 
Line 557 
   test_struct t;    test_struct t;
   int i, v;    int i, v;
   
   fprintf(fd,    print_primitive(fd, keysize, ivsize, macsize);
           "****************************************"  
           "****************************************\n");  
   fprintf(fd,  
           "*                          ECRYPT Stream"  
           " Cipher Project                        *\n");  
   fprintf(fd,  
           "****************************************"  
           "****************************************\n");  
   fprintf(fd, "\n");  
   fprintf(fd, "Primitive Name: %s\n", ECRYPT_NAME);  
   fprintf(fd, "================%.*s\n", (int)strlen(ECRYPT_NAME),  
           "==========================================");  
   fprintf(fd, "Key size: %d bits\n", keysize);  
   fprintf(fd, "IV size: %d bits\n", ivsize);  
 #ifdef ECRYPT_AE  
   fprintf(fd, "MAC size: %d bits\n", macsize);  
 #endif  
   fprintf(fd, "\n");  
   fprintf(fd, "Preferred block length: %d bytes\n", ECRYPT_BLOCKLENGTH);  
   fprintf(fd, "\n");  
   
   memset(t.plaintext, 0, sizeof(t.plaintext));    memset(t.plaintext, 0, sizeof(t.plaintext));
   memset(t.ciphertext, 0, sizeof(t.ciphertext));    memset(t.ciphertext, 0, sizeof(t.ciphertext));
Line 808 
Line 857 
     }      }
 #endif  #endif
   
     check_status();
   
   memset(ciphertext, 0, sizeof(ciphertext));    memset(ciphertext, 0, sizeof(ciphertext));
   
   KEYSETUP(&ctx[0], key[0], keysize, ivsize, macsize);    KEYSETUP(&ctx[0], key[0], keysize, ivsize, macsize);
Line 878 
Line 929 
     }      }
 #endif  #endif
   
     check_status();
   
 #define B ECRYPT_BLOCKLENGTH  #define B ECRYPT_BLOCKLENGTH
   
   memset(ciphertext, 0, sizeof(ciphertext));    memset(ciphertext, 0, sizeof(ciphertext));
Line 952 
Line 1005 
     }      }
 #endif  #endif
   
     check_status();
   
 #ifdef ECRYPT_SUPPORTS_AAD  #ifdef ECRYPT_SUPPORTS_AAD
   
   KEYSETUP(&ctx[0], key[0], keysize, ivsize, macsize);    KEYSETUP(&ctx[0], key[0], keysize, ivsize, macsize);
Line 997 
Line 1052 
       fprintf(fd, "\n");        fprintf(fd, "\n");
       fflush(fd);        fflush(fd);
     }      }
   
     check_status();
 #endif  #endif
 }  }
   
 /* ------------------------------------------------------------------------- */  /* ------------------------------------------------------------------------- */
   
 int main()  #define KEYS_TO_TEST 100
   #define TEST_TARGET 0x1000
   #define TEST_BLOCKS (TEST_TARGET + ECRYPT_BLOCKLENGTH - 1) / ECRYPT_BLOCKLENGTH
   
   #define TEST_SPEED(LOOP, TEST)                                                \
     do {                                                                        \
                                                                                 \
       for (keys_to_test = 1; 1; keys_to_test *= 10)                             \
         {                                                                       \
           /* First test a few times to let data enter the cache */              \
           for(i = j = 0; i < keys_to_test; i++, j++)                            \
             TEST;                                                               \
                                                                                 \
           /* And then compute how many tests can be made in 1/10th second */    \
           start = clock();                                                      \
                                                                                 \
           for(i = 0; clock() < start + CLOCKS_PER_SEC / 10; )                   \
             for(j = 0; j < keys_to_test; j++, i++)                              \
               TEST;                                                             \
                                                                                 \
            if ((i < 10) || (keys_to_test * 10 > KEYS_TO_TEST))                  \
              break;                                                             \
         }                                                                       \
                                                                                 \
       start = clock();                                                          \
                                                                                 \
       for(i = 0; clock() < start + CLOCKS_PER_SEC; )                            \
         for(j = 0; j < keys_to_test; j++, i++)                                  \
           TEST;                                                                 \
                                                                                 \
       /* Now test for about test_time seconds under keys_to_test keys */        \
                                                                                 \
       tests = test_time * i * CLOCKS_PER_SEC / (clock() - start);               \
       tests_per_key = tests / keys_to_test;                                     \
                                                                                 \
       /* truncate to multiples of 100 keys */                                   \
       if (tests_per_key > 500)                                                  \
         tests_per_key = tests_per_key - tests_per_key % 100;                    \
                                                                                 \
       /* truncate to multiples of 10 keys */                                    \
       if (tests_per_key > 50)                                                   \
         tests_per_key = tests_per_key - tests_per_key % 10;                     \
                                                                                 \
       /* Perform at least one test per key */                                   \
       if (tests_per_key < 1)                                                    \
         tests_per_key = 1;                                                      \
                                                                                 \
       tests = tests_per_key * keys_to_test;                                     \
                                                                                 \
       start = clock();                                                          \
                                                                                 \
       LOOP                                                                      \
         TEST;                                                                   \
                                                                                 \
       finish = clock();                                                         \
                                                                                 \
       clocks = (int)(finish - start);                                           \
       usec = (double)clocks                                                     \
         / (double)CLOCKS_PER_SEC                                                \
         / (double)tests                                                         \
         * 1000000.0;                                                            \
                                                                                 \
     } while (0)
   
   #define FOR_I_FOR_J                                                           \
       for(i = 0; i < keys_to_test; i++)                                         \
         for(j = 0; j < tests_per_key; j++)
   
   #define FOR_J_FOR_I                                                           \
       for(j = 0; j < tests_per_key; j++)                                        \
         for(i = 0; i < keys_to_test; i++)
   
   void test_speed(FILE *fd, int keysize, int ivsize, int macsize)
   {
     CTX ctx[KEYS_TO_TEST];
   
     u8 key[KEYS_TO_TEST][MAXKEYSIZEB];
     u8 iv[KEYS_TO_TEST][MAXIVSIZEB];
     u8 text[2][TEST_BLOCKS * ECRYPT_BLOCKLENGTH];
   #ifdef ECRYPT_AE
     u8 mac[MAXMACSIZEB];
   #endif
   
     int tests, tests_per_key, keys_to_test;
     clock_t start, finish;
     int clocks;
     double usec, usec_enc, size;
   
     static const int sizes[3] = {40, 576, 1500};
     static const double ratios[3] = {7.0, 4.0, 1.0};
     double usecs[3];
   
     int i, j, k;
   
     print_primitive(fd, keysize, ivsize, macsize);
   
     fprintf(fd, "CPU speed: %.1f MHz\n", cpu_speed);
   
     /* get clock tick resolution */
   
     for(start = clock(); (finish = clock()) == start; );
   
     clocks = (int)(finish - start);
   
     fprintf(fd,
       "Clock tick resolution: %d (%f seconds, %.1f ticks/second)\n"
       "Expected measurement accuracy: %.4f%% (if run alone on the cpu)\n",
       clocks, (double)clocks / (double)CLOCKS_PER_SEC,
       (double)CLOCKS_PER_SEC / (double)clocks,
       100.0 * (double)clocks / (double)CLOCKS_PER_SEC / test_time);
   
     fprintf(fd, "\n");
   
     fprintf(fd, "Testing memory requirements:\n\n");
     fflush(fd);
   
     fprintf(fd, "Size of %s: %d bytes\n\n", QUOTE(CTX), (int)sizeof(CTX));
   
     for(i = 0; i < KEYS_TO_TEST; i++)
       {
         for(j = 0; j < MAXKEYSIZEB; j++)
           key[i][j] = U8V(rand());
   
         for(j = 0; j < MAXIVSIZEB; j++)
           iv[i][j] = U8V(rand());
   
         KEYSETUP(&ctx[i], key[i], keysize, ivsize, macsize);
         IVSETUP(&ctx[i], iv[i]);
       }
   
     for(i = 0; i < TEST_BLOCKS * ECRYPT_BLOCKLENGTH; i++)
       text[0][i] = U8V(rand());
   
     fprintf(fd, "Testing stream encryption speed:\n\n");
     fflush(fd);
   
     TEST_SPEED(FOR_I_FOR_J, do
       {
         ENCRYPT_BLOCKS(&ctx[i % KEYS_TO_TEST],
           text[i % 2], text[(i + 1) % 2], TEST_BLOCKS);
   
       } while (0));
   
     fprintf(fd,
       "Encrypted %d blocks of %d bytes (under %d keys, %d blocks/key)\n",
       tests, TEST_BLOCKS * ECRYPT_BLOCKLENGTH, keys_to_test, tests_per_key);
   
     fprintf(fd, "Total time: %d clock ticks (%.2f seconds)\n",
       clocks, (double)clocks / (double)CLOCKS_PER_SEC);
   
     usec /= (double)(TEST_BLOCKS * ECRYPT_BLOCKLENGTH);
     usec_enc = usec;
   
     fprintf(fd, "Encryption speed (cycles/byte): %.2f\n", usec * cpu_speed);
     fprintf(fd, "Encryption speed (Mbps): %.2f\n", 8.0 / usec);
   
     fprintf(fd, "\n");
   
     for(i = 0; i < KEYS_TO_TEST; i++)
       FINALIZE(&ctx[i], mac);
   
     if (test_packet)
       {
         fprintf(fd, "Testing packet encryption speed:\n\n");
         fflush(fd);
   
         for (k = 0; k < 3; k++)
           {
             TEST_SPEED(FOR_I_FOR_J, do
             {
               ENCRYPT_PACKET(&ctx[i % KEYS_TO_TEST], iv[j % KEYS_TO_TEST],
                 NULL, 0, text[i % 2], text[(i + 1) % 2], sizes[k], mac);
   
             } while (0));
   
             usecs[k] = usec;
   
             fprintf(fd, "Encrypted %d packets of %d bytes "
               "(under %d keys, %d packets/key)\n",
               tests, sizes[k], keys_to_test, tests_per_key);
   
             fprintf(fd, "Total time: %d clock ticks (%.2f seconds)\n",
               (int)clocks, (double)clocks / (double)CLOCKS_PER_SEC);
   
             fprintf(fd, "Encryption speed (cycles/packet): %.2f\n",
               usec * cpu_speed);
   
             usec /= (double)sizes[k];
   
             fprintf(fd, "Encryption speed (cycles/byte): %.2f\n",
               usec * cpu_speed);
             fprintf(fd, "Encryption speed (Mbps): %.2f\n", 8.0 / usec);
             fprintf(fd, "Overhead: %.1f%%\n", 100.0 * (usec / usec_enc - 1.0));
   
             fprintf(fd, "\n");
             fflush(fd);
           }
   
         fprintf(fd, "Weighted average (Simple Imix):\n");
   
         usec = size = 0;
   
         for (k = 0; k < 3; k++)
 {  {
             usec += ratios[k] * usecs[k];
             size += ratios[k] * sizes[k];
           }
   
         usec /= size;
   
         fprintf(fd, "Encryption speed (cycles/byte): %.2f\n", usec * cpu_speed);
         fprintf(fd, "Encryption speed (Mbps): %.2f\n", 8.0 / usec);
         fprintf(fd, "Overhead: %.1f%%\n", 100.0 * (usec / usec_enc - 1.0));
   
         fprintf(fd, "\n");
       }
   
     if (test_setup)
       {
         fprintf(fd, "Testing key setup speed:\n\n");
         fflush(fd);
   
         TEST_SPEED(FOR_J_FOR_I, do
         {
           KEYSETUP(&ctx[0], key[i % KEYS_TO_TEST], keysize, ivsize, macsize);
   
         } while (0));
   
         fprintf(fd,
           "Did %d key setups (under %d keys, %d setups/key)\n",
           tests, keys_to_test, tests_per_key);
   
         fprintf(fd, "Total time: %d clock ticks (%.2f seconds)\n",
           clocks, (double)clocks / (double)CLOCKS_PER_SEC);
   
         fprintf(fd, "Key setup speed (cycles/setup): %.2f\n", usec * cpu_speed);
         fprintf(fd, "Key setup speed (setups/second): %.2f\n", 1000000.0 / usec);
   
         fprintf(fd, "\n");
   
 #ifndef ECRYPT_AE  #ifndef ECRYPT_AE
 #define ECRYPT_MAXMACSIZE 0        fprintf(fd, "Testing IV setup speed:\n\n");
 #define ECRYPT_MACSIZE(i) (i)  #else
         fprintf(fd, "Testing speed of IV setup + finalize:\n\n");
 #endif  #endif
         fflush(fd);
   
   int keysize;        TEST_SPEED(FOR_I_FOR_J, do
   int ivsize;        {
   int macsize;          IVSETUP(&ctx[i % KEYS_TO_TEST], iv[j % KEYS_TO_TEST]);
           FINALIZE(&ctx[i % KEYS_TO_TEST], mac);
   
         } while (0));
   
         fprintf(fd,
           "Did %d IV setups (under %d keys, %d setups/key)\n",
           tests, keys_to_test, tests_per_key);
   
         fprintf(fd, "Total time: %d clock ticks (%.2f seconds)\n",
           clocks, (double)clocks / (double)CLOCKS_PER_SEC);
   
         fprintf(fd, "IV setup speed (cycles/setup): %.2f\n", usec * cpu_speed);
         fprintf(fd, "IV setup speed (setups/second): %.2f\n", 1000000.0 / usec);
   
         fprintf(fd, "\n");
         fflush(fd);
       }
   
     fprintf(fd, "\nEnd of performance measurements\n");
     fflush(fd);
   }
   
   /* ------------------------------------------------------------------------- */
   
   void run_tests(FILE *fd, int keysize, int ivsize, int macsize)
   {
     if (output_vectors)
       {
         test_if_conform_to_api(fd, keysize, ivsize, macsize);
   
         if (errors == 0)
           test_vectors(fd, keysize, ivsize, macsize);
       }
   
     if (cpu_speed > 0)
       test_speed(fd, keysize, ivsize, macsize);
   }
   
   /* ------------------------------------------------------------------------- */
   
   int main(int argc, char *argv[])
   {
     int keysize = ECRYPT_KEYSIZE(0);
     int ivsize = ECRYPT_IVSIZE(0);
     int macsize = ECRYPT_MACSIZE(0);
   
   int k, i, m;    int k, i, m;
   
     while((argc > 1) && (argv[1][0] == '-'))
       {
         switch (argv[1][1])
           {
           case 'v':
             output_vectors = 1;
             break;
           case 'c':
             argc--;
             argv++;
   
             if (argc > 1)
               cpu_speed = atof(argv[1]);
   
             break;
           case 't':
             argc--;
             argv++;
   
             if (argc > 1)
               test_time = atof(argv[1]);
   
             break;
           case 'p':
             test_packet = 0;
             break;
           case 'k':
             test_setup = 0;
             break;
           case 's':
             single_key = 1;
             break;
           }
   
         argc--;
         argv++;
       }
   
     if (!output_vectors && (cpu_speed <= 0))
       {
         printf("Usage: ecrypt-test [OPTIONS]\n"
                "\n"
                "  -v      generate test vectors\n"
                "  -c MHZ  perform speed measurements assuming the given "
                "clock frequency\n"
                "  -t SEC  limit the duration of the tests (default: 3 seconds)\n"
                "  -p      do not test packet encryption speed\n"
                "  -k      do not test key and IV setup speed\n"
                "  -s      perform tests for a single key and IV length\n");
   
         exit(1);
       }
   
     print_header(stdout);
   
   ECRYPT_init();    ECRYPT_init();
   
   for (k = 0; (keysize = ECRYPT_KEYSIZE(k)) <= ECRYPT_MAXKEYSIZE; k++)    for (k = 0; ECRYPT_KEYSIZE(k) <= ECRYPT_MAXKEYSIZE; k++)
     {      {
       if ((k > 0) && (keysize <= ECRYPT_KEYSIZE(k - 1)))        if ((k > 0) && (ECRYPT_KEYSIZE(k) <= ECRYPT_KEYSIZE(k - 1)))
         {          {
           ++errors;            ++errors;
           fprintf(stderr,            fprintf(stdout,
             "*** ERROR: ECRYPT_KEYSIZE(i) does not conform to API.\n");              "*** ERROR: ECRYPT_KEYSIZE(i) does not conform to API.\n");
           break;            break;
         }          }
   
         if (abs(ECRYPT_KEYSIZE(k) - 128) < abs(keysize - 128))
           keysize = ECRYPT_KEYSIZE(k);
       }
   
     for (i = 0; ECRYPT_IVSIZE(i) <= ECRYPT_MAXIVSIZE; i++)
       {
         if ((i > 0) && (ECRYPT_IVSIZE(i) <= ECRYPT_IVSIZE(i - 1)))
           {
             ++errors;
             fprintf(stdout,
               "*** ERROR: ECRYPT_IVSIZE(i) does not conform to API.\n");
             break;
           }
   
         if (abs(ECRYPT_IVSIZE(i) - 64) < abs(ivsize - 64))
           ivsize = ECRYPT_IVSIZE(i);
       }
   
     for (m = 0; ECRYPT_MACSIZE(m) <= ECRYPT_MAXMACSIZE; m++)
       {
         if ((m > 0) && (ECRYPT_MACSIZE(m) <= ECRYPT_MACSIZE(m - 1)))
           {
             ++errors;
             fprintf(stdout,
               "*** ERROR: ECRYPT_MACSIZE(i) does not conform to API.\n");
             break;
           }
   
         if (abs(ECRYPT_MACSIZE(m) - 64) < abs(macsize - 64))
           macsize = ECRYPT_MACSIZE(m);
       }
   
     check_status();
   
     if (single_key)
       run_tests(stdout, keysize, ivsize, macsize);
     else
       for (k = 0; (keysize=ECRYPT_KEYSIZE(k)) <= ECRYPT_MAXKEYSIZE; k++)
         {
           if ((k > 0) && (keysize <= ECRYPT_KEYSIZE(k - 1)))
             break;
   
       /* Only powers of 2 or multiples of 80 larger than 64 */        /* Only powers of 2 or multiples of 80 larger than 64 */
       if (((keysize & (keysize - 1)) && (keysize % 80)) || (keysize < 64))        if (((keysize & (keysize - 1)) && (keysize % 80)) || (keysize < 64))
         continue;          continue;
Line 1038 
Line 1477 
       for (i = 0; (ivsize = ECRYPT_IVSIZE(i)) <= ECRYPT_MAXIVSIZE; i++)        for (i = 0; (ivsize = ECRYPT_IVSIZE(i)) <= ECRYPT_MAXIVSIZE; i++)
         {          {
           if ((i > 0) && (ivsize <= ECRYPT_IVSIZE(i - 1)))            if ((i > 0) && (ivsize <= ECRYPT_IVSIZE(i - 1)))
             {  
               ++errors;  
               fprintf(stderr,  
                 "*** ERROR: ECRYPT_IVSIZE(i) does not conform to API.\n");  
               break;                break;
             }  
   
           /* Only powers of 2 larger than 32 or multiples of 80 */            /* Only powers of 2 larger than 32 or multiples of 80 */
           if (((ivsize & (ivsize - 1)) || (ivsize < 32)) && (ivsize % 80))            if (((ivsize & (ivsize - 1)) || (ivsize < 32)) && (ivsize % 80))
Line 1056 
Line 1490 
           for (m = 0; (macsize = ECRYPT_MACSIZE(m)) <= ECRYPT_MAXMACSIZE; m++)            for (m = 0; (macsize = ECRYPT_MACSIZE(m)) <= ECRYPT_MAXMACSIZE; m++)
             {              {
               if ((m > 0) && (macsize <= ECRYPT_MACSIZE(m - 1)))                if ((m > 0) && (macsize <= ECRYPT_MACSIZE(m - 1)))
                 {  
                   ++errors;  
                   fprintf(stderr,  
                     "*** ERROR: ECRYPT_MACSIZE(i) does not conform to API.\n");  
                   break;                    break;
                 }  
   
               /* Only multiples of 32 */                /* Only multiples of 32 */
               if (macsize % 32)                if (macsize % 32)
Line 1071 
Line 1500 
               if (macsize > 256)                if (macsize > 256)
                 break;                  break;
   
               test_if_conform_to_api(stderr, keysize, ivsize, macsize);                  run_tests(stdout, keysize, ivsize, macsize);
   
               if (errors == 0)  
                 test_vectors(stdout, keysize, ivsize, macsize);  
             }              }
         }          }
     }      }
   
     fprintf(stderr, "Elapsed time: %.2f seconds.\n",
       (double)clock() / (double)CLOCKS_PER_SEC);
   fprintf(stderr, "There were %d errors.\n", errors);    fprintf(stderr, "There were %d errors.\n", errors);
   
     if (errors)
       return 1;
     else
   return 0;    return 0;
 }  }


Generate output suitable for use with a patch program
Legend:
Removed from v.34  
changed lines
  Added in v.48

eSTREAM Project

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help