Merged from silc_1_0_branch.
[silc.git] / lib / silccrypt / silccipher.c
index 3e2678ca2db2c601b5d0e23a7ccc41e0370807f2..53c938b69a17e475d44ba9f7392bf993911a99ea 100644 (file)
@@ -67,15 +67,6 @@ const SilcCipherObject silc_default_ciphers[] =
   { "rc6-128-cbc", 16, 128, silc_rc6_set_key, silc_rc6_set_key_with_string,
     silc_rc6_encrypt_cbc, silc_rc6_decrypt_cbc, 
     silc_rc6_context_len },
-  { "mars-256-cbc", 16, 256, silc_mars_set_key, silc_mars_set_key_with_string,
-    silc_mars_encrypt_cbc, silc_mars_decrypt_cbc, 
-    silc_mars_context_len },
-  { "mars-192-cbc", 16, 192, silc_mars_set_key, silc_mars_set_key_with_string,
-    silc_mars_encrypt_cbc, silc_mars_decrypt_cbc, 
-    silc_mars_context_len },
-  { "mars-128-cbc", 16, 128, silc_mars_set_key, silc_mars_set_key_with_string,
-    silc_mars_encrypt_cbc, silc_mars_decrypt_cbc, 
-    silc_mars_context_len },
   { "cast-256-cbc", 16, 256, silc_cast_set_key, silc_cast_set_key_with_string,
     silc_cast_encrypt_cbc, silc_cast_decrypt_cbc, 
     silc_cast_context_len },
@@ -324,7 +315,13 @@ bool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src,
                         unsigned char *dst, SilcUInt32 len, 
                         unsigned char *iv)
 {
-  return cipher->cipher->encrypt(cipher->context, src, dst, len, iv);
+#ifdef SILC_DEBUG
+  assert((len & (cipher->cipher->block_len - 1)) == 0);
+#endif
+  if (len & (cipher->cipher->block_len - 1))
+    return FALSE;
+  return cipher->cipher->encrypt(cipher->context, src, dst, len,
+                                iv ? iv : cipher->iv);
 }
 
 /* Decrypts */
@@ -333,7 +330,13 @@ bool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src,
                         unsigned char *dst, SilcUInt32 len, 
                         unsigned char *iv)
 {
-  return cipher->cipher->decrypt(cipher->context, src, dst, len, iv);
+#ifdef SILC_DEBUG
+  assert((len & (cipher->cipher->block_len - 1)) == 0);
+#endif
+  if (len & (cipher->cipher->block_len - 1))
+    return FALSE;
+  return cipher->cipher->decrypt(cipher->context, src, dst, len,
+                                iv ? iv : cipher->iv);
 }
 
 /* Sets the key for the cipher */