crypto: cast6 - Fix checkpatch errors

Signed-off-by: Richard Hartmann <richih.mailinglist@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Richard Hartmann 2010-02-16 20:29:45 +08:00 committed by Herbert Xu
parent a1f4c9222d
commit 87c3be87e9

View file

@ -35,12 +35,12 @@ struct cast6_ctx {
u8 Kr[12][4]; u8 Kr[12][4];
}; };
#define F1(D,r,m) ( (I = ((m) + (D))), (I=rol32(I,(r))), \ #define F1(D, r, m) ((I = ((m) + (D))), (I = rol32(I, (r))), \
(((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]) ) (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
#define F2(D,r,m) ( (I = ((m) ^ (D))), (I=rol32(I,(r))), \ #define F2(D, r, m) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \
(((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]) ) (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
#define F3(D,r,m) ( (I = ((m) - (D))), (I=rol32(I,(r))), \ #define F3(D, r, m) ((I = ((m) - (D))), (I = rol32(I, (r))), \
(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]) ) (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
static const u32 s1[256] = { static const u32 s1[256] = {
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f,
@ -369,7 +369,8 @@ static const u8 Tr[4][8] = {
}; };
/* forward octave */ /* forward octave */
static void W(u32 *key, unsigned int i) { static void W(u32 *key, unsigned int i)
{
u32 I; u32 I;
key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]); key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]);
key[5] ^= F2(key[6], Tr[i % 4][1], Tm[i][1]); key[5] ^= F2(key[6], Tr[i % 4][1], Tm[i][1]);
@ -395,8 +396,8 @@ static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
return -EINVAL; return -EINVAL;
} }
memset (p_key, 0, 32); memset(p_key, 0, 32);
memcpy (p_key, in_key, key_len); memcpy(p_key, in_key, key_len);
key[0] = be32_to_cpu(p_key[0]); /* A */ key[0] = be32_to_cpu(p_key[0]); /* A */
key[1] = be32_to_cpu(p_key[1]); /* B */ key[1] = be32_to_cpu(p_key[1]); /* B */
@ -407,11 +408,9 @@ static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
key[6] = be32_to_cpu(p_key[6]); /* G */ key[6] = be32_to_cpu(p_key[6]); /* G */
key[7] = be32_to_cpu(p_key[7]); /* H */ key[7] = be32_to_cpu(p_key[7]); /* H */
for (i = 0; i < 12; i++) { for (i = 0; i < 12; i++) {
W (key, 2 * i); W(key, 2 * i);
W (key, 2 * i + 1); W(key, 2 * i + 1);
c->Kr[i][0] = key[0] & 0x1f; c->Kr[i][0] = key[0] & 0x1f;
c->Kr[i][1] = key[2] & 0x1f; c->Kr[i][1] = key[2] & 0x1f;
@ -428,7 +427,8 @@ static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
} }
/*forward quad round*/ /*forward quad round*/
static void Q (u32 * block, u8 * Kr, u32 * Km) { static void Q(u32 *block, u8 *Kr, u32 *Km)
{
u32 I; u32 I;
block[2] ^= F1(block[3], Kr[0], Km[0]); block[2] ^= F1(block[3], Kr[0], Km[0]);
block[1] ^= F2(block[2], Kr[1], Km[1]); block[1] ^= F2(block[2], Kr[1], Km[1]);
@ -437,12 +437,13 @@ static void Q (u32 * block, u8 * Kr, u32 * Km) {
} }
/*reverse quad round*/ /*reverse quad round*/
static void QBAR (u32 * block, u8 * Kr, u32 * Km) { static void QBAR(u32 *block, u8 *Kr, u32 *Km)
{
u32 I; u32 I;
block[3] ^= F1(block[0], Kr[3], Km[3]); block[3] ^= F1(block[0], Kr[3], Km[3]);
block[0] ^= F3(block[1], Kr[2], Km[2]); block[0] ^= F3(block[1], Kr[2], Km[2]);
block[1] ^= F2(block[2], Kr[1], Km[1]); block[1] ^= F2(block[2], Kr[1], Km[1]);
block[2] ^= F1(block[3], Kr[0], Km[0]); block[2] ^= F1(block[3], Kr[0], Km[0]);
} }
static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
@ -451,26 +452,26 @@ static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
const __be32 *src = (const __be32 *)inbuf; const __be32 *src = (const __be32 *)inbuf;
__be32 *dst = (__be32 *)outbuf; __be32 *dst = (__be32 *)outbuf;
u32 block[4]; u32 block[4];
u32 * Km; u32 *Km;
u8 * Kr; u8 *Kr;
block[0] = be32_to_cpu(src[0]); block[0] = be32_to_cpu(src[0]);
block[1] = be32_to_cpu(src[1]); block[1] = be32_to_cpu(src[1]);
block[2] = be32_to_cpu(src[2]); block[2] = be32_to_cpu(src[2]);
block[3] = be32_to_cpu(src[3]); block[3] = be32_to_cpu(src[3]);
Km = c->Km[0]; Kr = c->Kr[0]; Q (block, Kr, Km); Km = c->Km[0]; Kr = c->Kr[0]; Q(block, Kr, Km);
Km = c->Km[1]; Kr = c->Kr[1]; Q (block, Kr, Km); Km = c->Km[1]; Kr = c->Kr[1]; Q(block, Kr, Km);
Km = c->Km[2]; Kr = c->Kr[2]; Q (block, Kr, Km); Km = c->Km[2]; Kr = c->Kr[2]; Q(block, Kr, Km);
Km = c->Km[3]; Kr = c->Kr[3]; Q (block, Kr, Km); Km = c->Km[3]; Kr = c->Kr[3]; Q(block, Kr, Km);
Km = c->Km[4]; Kr = c->Kr[4]; Q (block, Kr, Km); Km = c->Km[4]; Kr = c->Kr[4]; Q(block, Kr, Km);
Km = c->Km[5]; Kr = c->Kr[5]; Q (block, Kr, Km); Km = c->Km[5]; Kr = c->Kr[5]; Q(block, Kr, Km);
Km = c->Km[6]; Kr = c->Kr[6]; QBAR (block, Kr, Km); Km = c->Km[6]; Kr = c->Kr[6]; QBAR(block, Kr, Km);
Km = c->Km[7]; Kr = c->Kr[7]; QBAR (block, Kr, Km); Km = c->Km[7]; Kr = c->Kr[7]; QBAR(block, Kr, Km);
Km = c->Km[8]; Kr = c->Kr[8]; QBAR (block, Kr, Km); Km = c->Km[8]; Kr = c->Kr[8]; QBAR(block, Kr, Km);
Km = c->Km[9]; Kr = c->Kr[9]; QBAR (block, Kr, Km); Km = c->Km[9]; Kr = c->Kr[9]; QBAR(block, Kr, Km);
Km = c->Km[10]; Kr = c->Kr[10]; QBAR (block, Kr, Km); Km = c->Km[10]; Kr = c->Kr[10]; QBAR(block, Kr, Km);
Km = c->Km[11]; Kr = c->Kr[11]; QBAR (block, Kr, Km); Km = c->Km[11]; Kr = c->Kr[11]; QBAR(block, Kr, Km);
dst[0] = cpu_to_be32(block[0]); dst[0] = cpu_to_be32(block[0]);
dst[1] = cpu_to_be32(block[1]); dst[1] = cpu_to_be32(block[1]);
@ -478,31 +479,32 @@ static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
dst[3] = cpu_to_be32(block[3]); dst[3] = cpu_to_be32(block[3]);
} }
static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) { static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
struct cast6_ctx * c = crypto_tfm_ctx(tfm); {
struct cast6_ctx *c = crypto_tfm_ctx(tfm);
const __be32 *src = (const __be32 *)inbuf; const __be32 *src = (const __be32 *)inbuf;
__be32 *dst = (__be32 *)outbuf; __be32 *dst = (__be32 *)outbuf;
u32 block[4]; u32 block[4];
u32 * Km; u32 *Km;
u8 * Kr; u8 *Kr;
block[0] = be32_to_cpu(src[0]); block[0] = be32_to_cpu(src[0]);
block[1] = be32_to_cpu(src[1]); block[1] = be32_to_cpu(src[1]);
block[2] = be32_to_cpu(src[2]); block[2] = be32_to_cpu(src[2]);
block[3] = be32_to_cpu(src[3]); block[3] = be32_to_cpu(src[3]);
Km = c->Km[11]; Kr = c->Kr[11]; Q (block, Kr, Km); Km = c->Km[11]; Kr = c->Kr[11]; Q(block, Kr, Km);
Km = c->Km[10]; Kr = c->Kr[10]; Q (block, Kr, Km); Km = c->Km[10]; Kr = c->Kr[10]; Q(block, Kr, Km);
Km = c->Km[9]; Kr = c->Kr[9]; Q (block, Kr, Km); Km = c->Km[9]; Kr = c->Kr[9]; Q(block, Kr, Km);
Km = c->Km[8]; Kr = c->Kr[8]; Q (block, Kr, Km); Km = c->Km[8]; Kr = c->Kr[8]; Q(block, Kr, Km);
Km = c->Km[7]; Kr = c->Kr[7]; Q (block, Kr, Km); Km = c->Km[7]; Kr = c->Kr[7]; Q(block, Kr, Km);
Km = c->Km[6]; Kr = c->Kr[6]; Q (block, Kr, Km); Km = c->Km[6]; Kr = c->Kr[6]; Q(block, Kr, Km);
Km = c->Km[5]; Kr = c->Kr[5]; QBAR (block, Kr, Km); Km = c->Km[5]; Kr = c->Kr[5]; QBAR(block, Kr, Km);
Km = c->Km[4]; Kr = c->Kr[4]; QBAR (block, Kr, Km); Km = c->Km[4]; Kr = c->Kr[4]; QBAR(block, Kr, Km);
Km = c->Km[3]; Kr = c->Kr[3]; QBAR (block, Kr, Km); Km = c->Km[3]; Kr = c->Kr[3]; QBAR(block, Kr, Km);
Km = c->Km[2]; Kr = c->Kr[2]; QBAR (block, Kr, Km); Km = c->Km[2]; Kr = c->Kr[2]; QBAR(block, Kr, Km);
Km = c->Km[1]; Kr = c->Kr[1]; QBAR (block, Kr, Km); Km = c->Km[1]; Kr = c->Kr[1]; QBAR(block, Kr, Km);
Km = c->Km[0]; Kr = c->Kr[0]; QBAR (block, Kr, Km); Km = c->Km[0]; Kr = c->Kr[0]; QBAR(block, Kr, Km);
dst[0] = cpu_to_be32(block[0]); dst[0] = cpu_to_be32(block[0]);
dst[1] = cpu_to_be32(block[1]); dst[1] = cpu_to_be32(block[1]);