aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/cast6.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/cast6.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/cast6.c')
-rw-r--r--crypto/cast6.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/crypto/cast6.c b/crypto/cast6.c
index 9e28740ba775..08e33bfc3ad1 100644
--- a/crypto/cast6.c
+++ b/crypto/cast6.c
@@ -381,13 +381,13 @@ static inline void W(u32 *key, unsigned int i) {
381 key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); 381 key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]);
382} 382}
383 383
384static int 384static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
385cast6_setkey(void *ctx, const u8 * in_key, unsigned key_len, u32 * flags) 385 unsigned key_len, u32 *flags)
386{ 386{
387 int i; 387 int i;
388 u32 key[8]; 388 u32 key[8];
389 __be32 p_key[8]; /* padded key */ 389 __be32 p_key[8]; /* padded key */
390 struct cast6_ctx *c = (struct cast6_ctx *) ctx; 390 struct cast6_ctx *c = crypto_tfm_ctx(tfm);
391 391
392 if (key_len < 16 || key_len > 32 || key_len % 4 != 0) { 392 if (key_len < 16 || key_len > 32 || key_len % 4 != 0) {
393 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; 393 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
@@ -444,8 +444,9 @@ static inline void QBAR (u32 * block, u8 * Kr, u32 * Km) {
444 block[2] ^= F1(block[3], Kr[0], Km[0]); 444 block[2] ^= F1(block[3], Kr[0], Km[0]);
445} 445}
446 446
447static void cast6_encrypt (void * ctx, u8 * outbuf, const u8 * inbuf) { 447static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
448 struct cast6_ctx * c = (struct cast6_ctx *)ctx; 448{
449 struct cast6_ctx *c = crypto_tfm_ctx(tfm);
449 const __be32 *src = (const __be32 *)inbuf; 450 const __be32 *src = (const __be32 *)inbuf;
450 __be32 *dst = (__be32 *)outbuf; 451 __be32 *dst = (__be32 *)outbuf;
451 u32 block[4]; 452 u32 block[4];
@@ -476,8 +477,8 @@ static void cast6_encrypt (void * ctx, u8 * outbuf, const u8 * inbuf) {
476 dst[3] = cpu_to_be32(block[3]); 477 dst[3] = cpu_to_be32(block[3]);
477} 478}
478 479
479static void cast6_decrypt (void * ctx, u8 * outbuf, const u8 * inbuf) { 480static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) {
480 struct cast6_ctx * c = (struct cast6_ctx *)ctx; 481 struct cast6_ctx * c = crypto_tfm_ctx(tfm);
481 const __be32 *src = (const __be32 *)inbuf; 482 const __be32 *src = (const __be32 *)inbuf;
482 __be32 *dst = (__be32 *)outbuf; 483 __be32 *dst = (__be32 *)outbuf;
483 u32 block[4]; 484 u32 block[4];