asserts
[oweals/gnunet.git] / src / util / crypto_aes.c
index 28a65dfcaf3a785e1957168a8b5f35146302d8fc..a44c2d13373834a01130fa192039aaf3d00e35ec 100644 (file)
@@ -72,13 +72,13 @@ GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionKey
  * @param result the output parameter in which to store the encrypted result
  * @returns the size of the encrypted block, -1 for errors
  */
-int
+ssize_t
 GNUNET_CRYPTO_aes_encrypt (const void *block,
-                           uint16_t len,
+                           size_t len,
                            const struct GNUNET_CRYPTO_AesSessionKey
-                           *sessionkey,
+                           * sessionkey,
                            const struct GNUNET_CRYPTO_AesInitializationVector
-                           *iv, void *result)
+                           * iv, void *result)
 {
   gcry_cipher_hd_t handle;
   int rc;
@@ -88,7 +88,7 @@ GNUNET_CRYPTO_aes_encrypt (const void *block,
              (sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH)))
     {
       GNUNET_break (0);
-      return GNUNET_SYSERR;
+      return -1;
     }
   GNUNET_assert (0 == gcry_cipher_open (&handle,
                                         GCRY_CIPHER_AES256,
@@ -106,19 +106,22 @@ 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,
+ssize_t
+GNUNET_CRYPTO_aes_decrypt (const void *block,
+                           size_t size,
+                           const struct GNUNET_CRYPTO_AesSessionKey
+                           * sessionkey,
                            const struct GNUNET_CRYPTO_AesInitializationVector
-                           *iv, void *result)
+                           * iv, void *result)
 {
   gcry_cipher_hd_t handle;
   int rc;
@@ -128,7 +131,7 @@ GNUNET_CRYPTO_aes_decrypt (const struct GNUNET_CRYPTO_AesSessionKey
              (sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH)))
     {
       GNUNET_break (0);
-      return GNUNET_SYSERR;
+      return -1;
     }
   GNUNET_assert (0 == gcry_cipher_open (&handle,
                                         GCRY_CIPHER_AES256,