summaryrefslogtreecommitdiff
path: root/crypto/tea.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-05-16 22:09:29 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2006-06-26 17:34:39 +1000
commit6c2bb98bc33ae33c7a33a133a4cd5a06395fece5 (patch)
tree96684cd2c473cd05d651ce1fa3dd72b1b4b19b09 /crypto/tea.c
parent43600106e32809a4dead79fec67a63e9860e3d5d (diff)
downloadlinux-next-6c2bb98bc33ae33c7a33a133a4cd5a06395fece5.tar.gz
[CRYPTO] all: Pass tfm instead of ctx to algorithms
Up until now algorithms have been happy to get a context pointer since they know everything that's in the tfm already (e.g., alignment, block size). However, once we have parameterised algorithms, such information will be specific to each tfm. So the algorithm API needs to be changed to pass the tfm structure instead of the context pointer. This patch is basically a text substitution. The only tricky bit is the assembly routines that need to get the context pointer offset through asm-offsets.h. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tea.c')
-rw-r--r--crypto/tea.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/crypto/tea.c b/crypto/tea.c
index a6a02b30e470..5367adc82fc9 100644
--- a/crypto/tea.c
+++ b/crypto/tea.c
@@ -45,10 +45,10 @@ struct xtea_ctx {
u32 KEY[4];
};
-static int tea_setkey(void *ctx_arg, const u8 *in_key,
- unsigned int key_len, u32 *flags)
-{
- struct tea_ctx *ctx = ctx_arg;
+static int tea_setkey(struct crypto_tfm *tfm, const u8 *in_key,
+ unsigned int key_len, u32 *flags)
+{
+ struct tea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *key = (const __le32 *)in_key;
if (key_len != 16)
@@ -66,12 +66,11 @@ static int tea_setkey(void *ctx_arg, const u8 *in_key,
}
-static void tea_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
-{
+static void tea_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
u32 y, z, n, sum = 0;
u32 k0, k1, k2, k3;
-
- struct tea_ctx *ctx = ctx_arg;
+ struct tea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *in = (const __le32 *)src;
__le32 *out = (__le32 *)dst;
@@ -95,11 +94,11 @@ static void tea_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
out[1] = cpu_to_le32(z);
}
-static void tea_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
-{
+static void tea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
u32 y, z, n, sum;
u32 k0, k1, k2, k3;
- struct tea_ctx *ctx = ctx_arg;
+ struct tea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *in = (const __le32 *)src;
__le32 *out = (__le32 *)dst;
@@ -125,10 +124,10 @@ static void tea_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
out[1] = cpu_to_le32(z);
}
-static int xtea_setkey(void *ctx_arg, const u8 *in_key,
- unsigned int key_len, u32 *flags)
-{
- struct xtea_ctx *ctx = ctx_arg;
+static int xtea_setkey(struct crypto_tfm *tfm, const u8 *in_key,
+ unsigned int key_len, u32 *flags)
+{
+ struct xtea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *key = (const __le32 *)in_key;
if (key_len != 16)
@@ -146,12 +145,11 @@ static int xtea_setkey(void *ctx_arg, const u8 *in_key,
}
-static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
-{
+static void xtea_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
u32 y, z, sum = 0;
u32 limit = XTEA_DELTA * XTEA_ROUNDS;
-
- struct xtea_ctx *ctx = ctx_arg;
+ struct xtea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *in = (const __le32 *)src;
__le32 *out = (__le32 *)dst;
@@ -168,10 +166,10 @@ static void xtea_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
out[1] = cpu_to_le32(z);
}
-static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
-{
+static void xtea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
u32 y, z, sum;
- struct tea_ctx *ctx = ctx_arg;
+ struct tea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *in = (const __le32 *)src;
__le32 *out = (__le32 *)dst;
@@ -191,12 +189,11 @@ static void xtea_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
}
-static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
-{
+static void xeta_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
u32 y, z, sum = 0;
u32 limit = XTEA_DELTA * XTEA_ROUNDS;
-
- struct xtea_ctx *ctx = ctx_arg;
+ struct xtea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *in = (const __le32 *)src;
__le32 *out = (__le32 *)dst;
@@ -213,10 +210,10 @@ static void xeta_encrypt(void *ctx_arg, u8 *dst, const u8 *src)
out[1] = cpu_to_le32(z);
}
-static void xeta_decrypt(void *ctx_arg, u8 *dst, const u8 *src)
-{
+static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
+{
u32 y, z, sum;
- struct tea_ctx *ctx = ctx_arg;
+ struct tea_ctx *ctx = crypto_tfm_ctx(tfm);
const __le32 *in = (const __le32 *)src;
__le32 *out = (__le32 *)dst;