cleaner crypto api
authorChristian Grothoff <christian@grothoff.org>
Sat, 5 Sep 2009 20:38:19 +0000 (20:38 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 5 Sep 2009 20:38:19 +0000 (20:38 +0000)
src/core/gnunet-service-core.c
src/include/gnunet_crypto_lib.h
src/util/crypto_aes.c
src/util/test_crypto_aes.c
src/util/test_crypto_aes_weak.c

index ec2f08f657e73e71ac90e0b54390ad8e4ca2df6a..4012ac3a86b4aa2f72efef0bcf8d38bc22e48eb1 100644 (file)
@@ -1264,10 +1264,10 @@ do_decrypt (struct Neighbour *n,
       return GNUNET_SYSERR;
     }
   if (size !=
-      GNUNET_CRYPTO_aes_decrypt (&n->decrypt_key,
-                                 in,
+      GNUNET_CRYPTO_aes_decrypt (in,
                                  (uint16_t) size,
-                                 (const struct
+                                 &n->decrypt_key,
+                                (const struct
                                   GNUNET_CRYPTO_AesInitializationVector *) iv,
                                  out))
     {
index 168c79b2a52d59cfeabb49e70165abe994d41810..396f47355722c2ab00f76830733c8eb7fa6ba769 100644 (file)
@@ -273,17 +273,16 @@ int GNUNET_CRYPTO_aes_encrypt (const void *block,
 /**
  * Decrypt a given block with the sessionkey.
  *
- * @param sessionkey the key used to decrypt
  * @param block the data to decrypt, encoded as returned by encrypt
  * @param size how big is the block?
+ * @param sessionkey the key used to decrypt
  * @param iv the initialization vector to use
  * @param result address to store the result at
  * @return -1 on failure, size of decrypted block on success
  */
-int GNUNET_CRYPTO_aes_decrypt (const struct GNUNET_CRYPTO_AesSessionKey
-                               *sessionkey, const void *block, uint16_t size,
-                               const struct
-                               GNUNET_CRYPTO_AesInitializationVector *iv,
+int GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
+                               const struct GNUNET_CRYPTO_AesSessionKey *sessionkey, 
+                               const struct GNUNET_CRYPTO_AesInitializationVector *iv,
                                void *result);
 
 
index 28a65dfcaf3a785e1957168a8b5f35146302d8fc..8fa935d9f7ce90a22fc5e95716e9d221b9546ba8 100644 (file)
@@ -106,18 +106,20 @@ GNUNET_CRYPTO_aes_encrypt (const void *block,
 
 /**
  * Decrypt a given block with the sessionkey.
- * @param sessionkey the key used to decrypt
+ *
  * @param block the data to decrypt, encoded as returned by encrypt
  * @param size the size of the block to decrypt
+ * @param sessionkey the key used to decrypt
  * @param iv the initialization vector to use, use INITVALUE
  *        for streams.
  * @param result address to store the result at
  * @return -1 on failure, size of decrypted block on success
  */
 int
-GNUNET_CRYPTO_aes_decrypt (const struct GNUNET_CRYPTO_AesSessionKey
-                           *sessionkey, const void *block, uint16_t size,
-                           const struct GNUNET_CRYPTO_AesInitializationVector
+GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
+                           const struct GNUNET_CRYPTO_AesSessionKey
+                           *sessionkey, 
+                          const struct GNUNET_CRYPTO_AesInitializationVector
                            *iv, void *result)
 {
   gcry_cipher_hd_t handle;
index cdae243e01d26dfba56dcedc7fc27e804df95546..f876e417592feddf85713b668639814204e714d6 100644 (file)
@@ -50,9 +50,9 @@ testSymcipher ()
       printf ("symciphertest failed: encryptBlock returned %d\n", size);
       return 1;
     }
-  size = GNUNET_CRYPTO_aes_decrypt (&key,
-                                    result, size,
-                                    (const struct
+  size = GNUNET_CRYPTO_aes_decrypt (result, size,
+                                    &key,
+                                   (const struct
                                      GNUNET_CRYPTO_AesInitializationVector *)
                                     INITVALUE, res);
   if (strlen (TESTSTRING) + 1 != size)
@@ -131,10 +131,10 @@ verifyCrypto ()
   res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH);
 
   if (GNUNET_CRYPTO_AES_KEY_LENGTH !=
-      GNUNET_CRYPTO_aes_decrypt (&key,
-                                 result,
+      GNUNET_CRYPTO_aes_decrypt (result,
                                  GNUNET_CRYPTO_AES_KEY_LENGTH,
-                                 (const struct
+                                 &key,
+                                (const struct
                                   GNUNET_CRYPTO_AesInitializationVector *)
                                  "testtesttesttest", res))
     {
index 27ee5796803a288e0a7fbabfa6f4ca1af5e47b6b..2ce553a21513b74083f3085e22db1ba9ad06d1d6 100644 (file)
@@ -103,7 +103,7 @@ testWeakKey ()
       return 1;
     }
 
-  size = GNUNET_CRYPTO_aes_decrypt (&weak_key, result, size, &INITVALUE, res);
+  size = GNUNET_CRYPTO_aes_decrypt (result, size, &weak_key, &INITVALUE, res);
 
   if ((strlen (WEAK_KEY_TESTSTRING) + 1) != size)
     {