--- 2/crypto/cipher.c	2004-11-30 23:34:30.000000000 +0100
+++ 3/crypto/cipher.c	2004-11-30 23:34:43.000000000 +0100
@@ -4,6 +4,7 @@
  * Cipher operations.
  *
  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2004 Clemens Fruhwirth <clemens@endorphin.org>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -189,6 +190,14 @@
 	return -ENOSYS;
 }
 
+static int nocrypt_tweaks(struct crypto_tfm *tfm,
+                          struct scatterlist *dst,
+                          struct scatterlist *src,
+                          unsigned int nbytes, struct scatterlist *tweaksg)
+{
+	return -ENOSYS;
+}
+
 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags)
 {
 	u32 mode = flags & CRYPTO_TFM_MODE_MASK;
@@ -218,6 +227,12 @@
 		ops->cit_decrypt = cbc_decrypt;
 		ops->cit_encrypt_iv = cbc_encrypt_iv;
 		ops->cit_decrypt_iv = cbc_decrypt_iv;
+		ops->cit_encrypt_tweaks = nocrypt_tweaks;
+		ops->cit_decrypt_tweaks = nocrypt_tweaks;
+		ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm);
+		ops->cit_iv = kmalloc(ops->cit_ivsize, GFP_KERNEL);
+		if (ops->cit_iv == NULL)
+			ret = -ENOMEM;
 		break;
 		
 	case CRYPTO_TFM_MODE_CFB:
@@ -225,6 +240,8 @@
 		ops->cit_decrypt = nocrypt;
 		ops->cit_encrypt_iv = nocrypt_iv;
 		ops->cit_decrypt_iv = nocrypt_iv;
+		ops->cit_encrypt_tweaks = nocrypt_tweaks;
+		ops->cit_decrypt_tweaks = nocrypt_tweaks;
 		break;
 	
 	case CRYPTO_TFM_MODE_CTR:
@@ -232,6 +249,8 @@
 		ops->cit_decrypt = nocrypt;
 		ops->cit_encrypt_iv = nocrypt_iv;
 		ops->cit_decrypt_iv = nocrypt_iv;
+		ops->cit_encrypt_tweaks = nocrypt_tweaks;
+		ops->cit_decrypt_tweaks = nocrypt_tweaks;
 		break;
 
 	default:
@@ -257,10 +276,6 @@
 	    		goto out;
 	    	}
 	    	
-		ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm);
-	    	ops->cit_iv = kmalloc(ops->cit_ivsize, GFP_KERNEL);
-		if (ops->cit_iv == NULL)
-			ret = -ENOMEM;
 	}
 
 out:	
--- 2/include/linux/crypto.h	2004-11-23 16:44:32.000000000 +0100
+++ 3/include/linux/crypto.h	2004-11-23 16:57:16.000000000 +0100
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  * Copyright (c) 2002 David S. Miller (davem@redhat.com)
+ * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
  *
  * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
  * and Nettle, by Niels Möller.
@@ -38,6 +39,11 @@
 #define CRYPTO_TFM_REQ_MASK		0x000fff00
 #define CRYPTO_TFM_RES_MASK		0xfff00000
 
+/*
+ * Available cipher modes
+ * Also modify api.c:crypto_tfm_cmctx_size, when adding new modes 
+ */
+
 #define CRYPTO_TFM_MODE_ECB		0x00000001
 #define CRYPTO_TFM_MODE_CBC		0x00000002
 #define CRYPTO_TFM_MODE_CFB		0x00000004
@@ -130,6 +136,8 @@
 struct cipher_tfm {
 	void *cit_iv;
 	unsigned int cit_ivsize;
+	unsigned int cit_tweaksize;
+	unsigned int cit_bytes_per_tweak;
 	u32 cit_mode;
 	int (*cit_setkey)(struct crypto_tfm *tfm,
 	                  const u8 *key, unsigned int keylen);
@@ -141,6 +149,10 @@
 	                      struct scatterlist *dst,
 	                      struct scatterlist *src,
 	                      unsigned int nbytes, u8 *iv);
+	int (*cit_encrypt_tweaks)(struct crypto_tfm *tfm,
+	                      struct scatterlist *dst,
+	                      struct scatterlist *src,
+	                      unsigned int nbytes, struct scatterlist *tweaks);
 	int (*cit_decrypt)(struct crypto_tfm *tfm,
 			   struct scatterlist *dst,
 			   struct scatterlist *src,
@@ -149,6 +161,10 @@
 			   struct scatterlist *dst,
 			   struct scatterlist *src,
 			   unsigned int nbytes, u8 *iv);
+	int (*cit_decrypt_tweaks)(struct crypto_tfm *tfm,
+			   struct scatterlist *dst,
+			   struct scatterlist *src,
+			   unsigned int nbytes, struct scatterlist *tweaks);
 	void (*cit_xor_block)(u8 *dst, const u8 *src);
 };
 
@@ -354,6 +370,25 @@
 	memcpy(dst, tfm->crt_cipher.cit_iv, len);
 }
 
+static inline int crypto_cipher_encrypt_tweaks(struct crypto_tfm *tfm,
+                                        struct scatterlist *dst,
+                                        struct scatterlist *src,
+                                        unsigned int nbytes, struct scatterlist *tweaksg)
+{
+	BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+	return tfm->crt_cipher.cit_encrypt_tweaks(tfm, dst, src, nbytes, tweaksg);
+}
+
+static inline int crypto_cipher_decrypt_tweaks(struct crypto_tfm *tfm,
+                                        struct scatterlist *dst,
+                                        struct scatterlist *src,
+                                        unsigned int nbytes, struct scatterlist *tweaksg)
+{
+	BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
+	return tfm->crt_cipher.cit_decrypt_tweaks(tfm, dst, src, nbytes, tweaksg);
+}
+
+
 static inline int crypto_comp_compress(struct crypto_tfm *tfm,
                                        const u8 *src, unsigned int slen,
                                        u8 *dst, unsigned int *dlen)
