- Fixed cipher interface for encrypt/decrypt functions

diff --git a/library/aes.c b/library/aes.c
index 373b2a0..bf7b337 100644
--- a/library/aes.c
+++ b/library/aes.c
@@ -647,7 +647,7 @@
 /*
  * AES-ECB block encryption/decryption
  */
-void aes_crypt_ecb( aes_context *ctx,
+int aes_crypt_ecb( aes_context *ctx,
                     int mode,
                     const unsigned char input[16],
                     unsigned char output[16] )
@@ -659,7 +659,11 @@
     if( padlock_supports( PADLOCK_ACE ) )
     {
         if( padlock_xcryptecb( ctx, mode, input, output ) == 0 )
-            return;
+            return( 0 );
+
+        // If padlock data misaligned, we just fall back to
+        // unaccelerated mode
+        //
     }
 #endif
 
@@ -743,12 +747,14 @@
     PUT_ULONG_LE( X1, output,  4 );
     PUT_ULONG_LE( X2, output,  8 );
     PUT_ULONG_LE( X3, output, 12 );
+
+    return( 0 );
 }
 
 /*
  * AES-CBC buffer encryption/decryption
  */
-void aes_crypt_cbc( aes_context *ctx,
+int aes_crypt_cbc( aes_context *ctx,
                     int mode,
                     int length,
                     unsigned char iv[16],
@@ -758,11 +764,18 @@
     int i;
     unsigned char temp[16];
 
+    if( length % 16 )
+        return( POLARSSL_ERR_AES_INVALID_INPUT_LENGTH );
+
 #if defined(POLARSSL_PADLOCK_C) && defined(POLARSSL_HAVE_X86)
     if( padlock_supports( PADLOCK_ACE ) )
     {
         if( padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 )
-            return;
+            return( 0 );
+        
+        // If padlock data misaligned, we just fall back to
+        // unaccelerated mode
+        //
     }
 #endif
 
@@ -798,12 +811,14 @@
             length -= 16;
         }
     }
+
+    return( 0 );
 }
 
 /*
  * AES-CFB128 buffer encryption/decryption
  */
-void aes_crypt_cfb128( aes_context *ctx,
+int aes_crypt_cfb128( aes_context *ctx,
                        int mode,
                        int length,
                        int *iv_off,
@@ -841,6 +856,8 @@
     }
 
     *iv_off = n;
+
+    return( 0 );
 }
 
 #if defined(POLARSSL_SELF_TEST)
diff --git a/library/arc4.c b/library/arc4.c
index fb4542f..5e70311 100644
--- a/library/arc4.c
+++ b/library/arc4.c
@@ -63,7 +63,7 @@
 /*
  * ARC4 cipher function
  */
-void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen )
+int arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen )
 {
     int i, x, y, a, b;
     unsigned char *m;
@@ -86,6 +86,8 @@
 
     ctx->x = x;
     ctx->y = y;
+
+    return( 0 );
 }
 
 #if defined(POLARSSL_SELF_TEST)
diff --git a/library/camellia.c b/library/camellia.c
index 7c499cd..7656084 100644
--- a/library/camellia.c
+++ b/library/camellia.c
@@ -458,7 +458,7 @@
 /*
  * Camellia-ECB block encryption/decryption
  */
-void camellia_crypt_ecb( camellia_context *ctx,
+int camellia_crypt_ecb( camellia_context *ctx,
                     int mode,
                     const unsigned char input[16],
                     unsigned char output[16] )
@@ -513,12 +513,14 @@
     PUT_ULONG_BE( X[3], output,  4 );
     PUT_ULONG_BE( X[0], output,  8 );
     PUT_ULONG_BE( X[1], output, 12 );
+
+    return( 0 );
 }
 
 /*
  * Camellia-CBC buffer encryption/decryption
  */
-void camellia_crypt_cbc( camellia_context *ctx,
+int camellia_crypt_cbc( camellia_context *ctx,
                     int mode,
                     int length,
                     unsigned char iv[16],
@@ -528,6 +530,9 @@
     int i;
     unsigned char temp[16];
 
+    if( length % 16 )
+        return( POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH );
+
     if( mode == CAMELLIA_DECRYPT )
     {
         while( length > 0 )
@@ -560,12 +565,14 @@
             length -= 16;
         }
     }
+
+    return( 0 );
 }
 
 /*
  * Camellia-CFB128 buffer encryption/decryption
  */
-void camellia_crypt_cfb128( camellia_context *ctx,
+int camellia_crypt_cfb128( camellia_context *ctx,
                        int mode,
                        int length,
                        int *iv_off,
@@ -603,6 +610,8 @@
     }
 
     *iv_off = n;
+
+    return( 0 );
 }
 
 #if defined(POLARSSL_SELF_TEST)
diff --git a/library/des.c b/library/des.c
index 79ebd38..d2f7662 100644
--- a/library/des.c
+++ b/library/des.c
@@ -476,7 +476,7 @@
 /*
  * DES-ECB block encryption/decryption
  */
-void des_crypt_ecb( des_context *ctx,
+int des_crypt_ecb( des_context *ctx,
                     const unsigned char input[8],
                     unsigned char output[8] )
 {
@@ -500,12 +500,14 @@
 
     PUT_ULONG_BE( Y, output, 0 );
     PUT_ULONG_BE( X, output, 4 );
+
+    return( 0 );
 }
 
 /*
  * DES-CBC buffer encryption/decryption
  */
-void des_crypt_cbc( des_context *ctx,
+int des_crypt_cbc( des_context *ctx,
                     int mode,
                     int length,
                     unsigned char iv[8],
@@ -515,6 +517,9 @@
     int i;
     unsigned char temp[8];
 
+    if( length % 8 )
+        return( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH );
+
     if( mode == DES_ENCRYPT )
     {
         while( length > 0 )
@@ -547,12 +552,14 @@
             length -= 8;
         }
     }
+
+    return( 0 );
 }
 
 /*
  * 3DES-ECB block encryption/decryption
  */
-void des3_crypt_ecb( des3_context *ctx,
+int des3_crypt_ecb( des3_context *ctx,
                      const unsigned char input[8],
                      unsigned char output[8] )
 {
@@ -588,12 +595,14 @@
 
     PUT_ULONG_BE( Y, output, 0 );
     PUT_ULONG_BE( X, output, 4 );
+
+    return( 0 );
 }
 
 /*
  * 3DES-CBC buffer encryption/decryption
  */
-void des3_crypt_cbc( des3_context *ctx,
+int des3_crypt_cbc( des3_context *ctx,
                      int mode,
                      int length,
                      unsigned char iv[8],
@@ -603,6 +612,9 @@
     int i;
     unsigned char temp[8];
 
+    if( length % 8 )
+        return( POLARSSL_ERR_DES_INVALID_INPUT_LENGTH );
+
     if( mode == DES_ENCRYPT )
     {
         while( length > 0 )
@@ -635,6 +647,8 @@
             length -= 8;
         }
     }
+
+    return( 0 );
 }
 
 #if defined(POLARSSL_SELF_TEST)
diff --git a/library/padlock.c b/library/padlock.c
index 9d62d0a..4c30ddd 100644
--- a/library/padlock.c
+++ b/library/padlock.c
@@ -126,7 +126,7 @@
 
     if( ( (long) input  & 15 ) != 0 ||
         ( (long) output & 15 ) != 0 )
-        return( 1 );
+        return( POLARSSL_ERR_PADLOCK_DATA_MISALIGNED );
 
     rk = ctx->rk;
     iw = PADLOCK_ALIGN16( buf );
diff --git a/library/xtea.c b/library/xtea.c
index 5e479d2..f7df144 100644
--- a/library/xtea.c
+++ b/library/xtea.c
@@ -68,7 +68,7 @@
 /*
  * XTEA encrypt function
  */
-void xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8],
+int xtea_crypt_ecb( xtea_context *ctx, int mode, unsigned char input[8],
                      unsigned char output[8])
 {
     uint32_t *k, v0, v1, i;
@@ -103,6 +103,8 @@
 
     PUT_ULONG_BE( v0, output, 0 );
     PUT_ULONG_BE( v1, output, 4 );
+
+    return( 0 );
 }
 
 #if defined(POLARSSL_SELF_TEST)