aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/cipher.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-05-16 08:09:29 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-06-26 03:34:39 -0400
commit6c2bb98bc33ae33c7a33a133a4cd5a06395fece5 (patch)
tree96684cd2c473cd05d651ce1fa3dd72b1b4b19b09 /crypto/cipher.c
parent43600106e32809a4dead79fec67a63e9860e3d5d (diff)
[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/cipher.c')
-rw-r--r--crypto/cipher.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/cipher.c b/crypto/cipher.c
index 65bcea0cd17c..b899eb97abd7 100644
--- a/crypto/cipher.c
+++ b/crypto/cipher.c
@@ -187,7 +187,7 @@ static unsigned int cbc_process_encrypt(const struct cipher_desc *desc,
187 void (*xor)(u8 *, const u8 *) = tfm->crt_u.cipher.cit_xor_block; 187 void (*xor)(u8 *, const u8 *) = tfm->crt_u.cipher.cit_xor_block;
188 int bsize = crypto_tfm_alg_blocksize(tfm); 188 int bsize = crypto_tfm_alg_blocksize(tfm);
189 189
190 void (*fn)(void *, u8 *, const u8 *) = desc->crfn; 190 void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn;
191 u8 *iv = desc->info; 191 u8 *iv = desc->info;
192 unsigned int done = 0; 192 unsigned int done = 0;
193 193
@@ -195,7 +195,7 @@ static unsigned int cbc_process_encrypt(const struct cipher_desc *desc,
195 195
196 do { 196 do {
197 xor(iv, src); 197 xor(iv, src);
198 fn(crypto_tfm_ctx(tfm), dst, iv); 198 fn(tfm, dst, iv);
199 memcpy(iv, dst, bsize); 199 memcpy(iv, dst, bsize);
200 200
201 src += bsize; 201 src += bsize;
@@ -218,7 +218,7 @@ static unsigned int cbc_process_decrypt(const struct cipher_desc *desc,
218 u8 *buf = (u8 *)ALIGN((unsigned long)stack, alignmask + 1); 218 u8 *buf = (u8 *)ALIGN((unsigned long)stack, alignmask + 1);
219 u8 **dst_p = src == dst ? &buf : &dst; 219 u8 **dst_p = src == dst ? &buf : &dst;
220 220
221 void (*fn)(void *, u8 *, const u8 *) = desc->crfn; 221 void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn;
222 u8 *iv = desc->info; 222 u8 *iv = desc->info;
223 unsigned int done = 0; 223 unsigned int done = 0;
224 224
@@ -227,7 +227,7 @@ static unsigned int cbc_process_decrypt(const struct cipher_desc *desc,
227 do { 227 do {
228 u8 *tmp_dst = *dst_p; 228 u8 *tmp_dst = *dst_p;
229 229
230 fn(crypto_tfm_ctx(tfm), tmp_dst, src); 230 fn(tfm, tmp_dst, src);
231 xor(tmp_dst, iv); 231 xor(tmp_dst, iv);
232 memcpy(iv, src, bsize); 232 memcpy(iv, src, bsize);
233 if (tmp_dst != dst) 233 if (tmp_dst != dst)
@@ -245,13 +245,13 @@ static unsigned int ecb_process(const struct cipher_desc *desc, u8 *dst,
245{ 245{
246 struct crypto_tfm *tfm = desc->tfm; 246 struct crypto_tfm *tfm = desc->tfm;
247 int bsize = crypto_tfm_alg_blocksize(tfm); 247 int bsize = crypto_tfm_alg_blocksize(tfm);
248 void (*fn)(void *, u8 *, const u8 *) = desc->crfn; 248 void (*fn)(struct crypto_tfm *, u8 *, const u8 *) = desc->crfn;
249 unsigned int done = 0; 249 unsigned int done = 0;
250 250
251 nbytes -= bsize; 251 nbytes -= bsize;
252 252
253 do { 253 do {
254 fn(crypto_tfm_ctx(tfm), dst, src); 254 fn(tfm, dst, src);
255 255
256 src += bsize; 256 src += bsize;
257 dst += bsize; 257 dst += bsize;
@@ -268,7 +268,7 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
268 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; 268 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
269 return -EINVAL; 269 return -EINVAL;
270 } else 270 } else
271 return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen, 271 return cia->cia_setkey(tfm, key, keylen,
272 &tfm->crt_flags); 272 &tfm->crt_flags);
273} 273}
274 274