fix
[oweals/gnunet.git] / src / util / test_crypto_aes.c
index fb0d05683db92460613e797461637bb60ea9d937..e928b96a7ab8b41d7af4d18dc1726d6d7e1fd6dc 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -39,22 +39,21 @@ testSymcipher ()
   char res[100];
 
   GNUNET_CRYPTO_aes_create_session_key (&key);
-  size = GNUNET_CRYPTO_aes_encrypt (TESTSTRING,
-                                    strlen (TESTSTRING) + 1,
-                                    &key,
-                                    (const struct
-                                     GNUNET_CRYPTO_AesInitializationVector *)
-                                    INITVALUE, result);
+  size =
+    GNUNET_CRYPTO_aes_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &key,
+                              (const struct
+                               GNUNET_CRYPTO_AesInitializationVector *)
+                              INITVALUE, result);
   if (size == -1)
     {
       printf ("symciphertest failed: encryptBlock returned %d\n", size);
       return 1;
     }
-  size = GNUNET_CRYPTO_aes_decrypt (result, size,
-                                    &key,
-                                    (const struct
-                                     GNUNET_CRYPTO_AesInitializationVector *)
-                                    INITVALUE, res);
+  size =
+    GNUNET_CRYPTO_aes_decrypt (result, size, &key,
+                              (const struct
+                               GNUNET_CRYPTO_AesInitializationVector *)
+                              INITVALUE, res);
   if (strlen (TESTSTRING) + 1 != size)
     {
       printf ("symciphertest failed: decryptBlock returned %d\n", size);
@@ -89,7 +88,7 @@ verifyCrypto ()
   unsigned char encrresult[] =
     { 167, 102, 230, 233, 127, 195, 176, 107, 17, 91, 199, 127, 96, 113, 75,
     195, 245, 217, 61, 236, 159, 165, 103, 121, 203, 99, 202, 41, 23, 222, 25,
-    102, 1
+    102
   };
 
   res = NULL;
@@ -101,20 +100,18 @@ verifyCrypto ()
 
   if (ntohl (key.crc32) != (unsigned int) 38125195LL)
     {
-      printf ("Static key has different CRC: %u - %u\n",
-              ntohl (key.crc32), key.crc32);
+      printf ("Static key has different CRC: %u - %u\n", ntohl (key.crc32),
+             key.crc32);
 
       ret = 1;
       goto error;
     }
 
   if (GNUNET_CRYPTO_AES_KEY_LENGTH !=
-      GNUNET_CRYPTO_aes_encrypt (plain,
-                                 GNUNET_CRYPTO_AES_KEY_LENGTH,
-                                 &key,
-                                 (const struct
-                                  GNUNET_CRYPTO_AesInitializationVector *)
-                                 "testtesttesttest", result))
+      GNUNET_CRYPTO_aes_encrypt (plain, GNUNET_CRYPTO_AES_KEY_LENGTH, &key,
+                                (const struct
+                                 GNUNET_CRYPTO_AesInitializationVector *)
+                                "testtesttesttest", result))
     {
       printf ("Wrong return value from encrypt block.\n");
       ret = 1;
@@ -131,12 +128,10 @@ verifyCrypto ()
   res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH);
 
   if (GNUNET_CRYPTO_AES_KEY_LENGTH !=
-      GNUNET_CRYPTO_aes_decrypt (result,
-                                 GNUNET_CRYPTO_AES_KEY_LENGTH,
-                                 &key,
-                                 (const struct
-                                  GNUNET_CRYPTO_AesInitializationVector *)
-                                 "testtesttesttest", res))
+      GNUNET_CRYPTO_aes_decrypt (result, GNUNET_CRYPTO_AES_KEY_LENGTH, &key,
+                                (const struct
+                                 GNUNET_CRYPTO_AesInitializationVector *)
+                                "testtesttesttest", res))
     {
       printf ("Wrong return value from decrypt block.\n");
       ret = 1;
@@ -165,7 +160,7 @@ main (int argc, char *argv[])
   GNUNET_log_setup ("test-crypto-aes", "WARNING", NULL);
   GNUNET_CRYPTO_random_disable_entropy_gathering ();
   GNUNET_assert (strlen (INITVALUE) >
-                 sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
+                sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
   failureCount += testSymcipher ();
   failureCount += verifyCrypto ();