[CRYPTO] cipher: Removed special IV checks for ECB
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 14 Jul 2006 00:42:27 +0000 (10:42 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 21 Sep 2006 01:41:03 +0000 (11:41 +1000)
This patch makes IV operations on ECB fail through nocrypt_iv rather than
calling BUG().  This is needed to generalise CBC/ECB using the template
mechanism.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/cipher.c
include/linux/crypto.h

index 56406a4a88d4dd3d310bcd196245732a60d5e87d..aebc4a2adc8059a0aa4188338bd05c90aa1eb498 100644 (file)
@@ -399,6 +399,8 @@ int crypto_init_cipher_ops(struct crypto_tfm *tfm)
        case CRYPTO_TFM_MODE_ECB:
                ops->cit_encrypt = ecb_encrypt;
                ops->cit_decrypt = ecb_decrypt;
+               ops->cit_encrypt_iv = nocrypt_iv;
+               ops->cit_decrypt_iv = nocrypt_iv;
                break;
                
        case CRYPTO_TFM_MODE_CBC:
index 053bfab43e8d960a9b596826bed498ce3e1caf69..dbdfc7c79367365ee6ac9a8cd01aaf8bf6281f58 100644 (file)
@@ -422,7 +422,6 @@ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
                                            unsigned int nbytes, u8 *iv)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
        return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);
 }                                        
 
@@ -441,7 +440,6 @@ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
                                            unsigned int nbytes, u8 *iv)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
-       BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
        return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);
 }