X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilccrypt%2Fsilccipher.c;h=53c938b69a17e475d44ba9f7392bf993911a99ea;hp=72d984b35cebbcf324ae9fac7ba17814134668ec;hb=382d15d447b7a95390decfa783836ae4fe255b3d;hpb=3cf38201f9ffaad2da53757ed48a5546e1d03636 diff --git a/lib/silccrypt/silccipher.c b/lib/silccrypt/silccipher.c index 72d984b3..53c938b6 100644 --- a/lib/silccrypt/silccipher.c +++ b/lib/silccrypt/silccipher.c @@ -315,6 +315,11 @@ bool silc_cipher_encrypt(SilcCipher cipher, const unsigned char *src, unsigned char *dst, SilcUInt32 len, unsigned char *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); } @@ -325,6 +330,11 @@ bool silc_cipher_decrypt(SilcCipher cipher, const unsigned char *src, unsigned char *dst, SilcUInt32 len, unsigned char *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); }