aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-22 01:04:37 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-22 02:38:10 -0400
commitb588ef6e69bfc0944a17dc673ee166a00fa23de2 (patch)
tree9e30920adb557dd7041979a9ead05c8bce89fea0 /crypto
parent6fba00d176ab73b15bb8e31f261582943429a92b (diff)
crypto: xcbc - Use crypto_xor
This patch replaces the local xor function with the generic crypto_xor function. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/xcbc.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 3b991bf2fd9..9d502e67a5c 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -47,19 +47,10 @@ struct crypto_xcbc_ctx {
47 u8 *prev; 47 u8 *prev;
48 u8 *key; 48 u8 *key;
49 u8 *consts; 49 u8 *consts;
50 void (*xor)(u8 *a, const u8 *b, unsigned int bs);
51 unsigned int keylen; 50 unsigned int keylen;
52 unsigned int len; 51 unsigned int len;
53}; 52};
54 53
55static void xor_128(u8 *a, const u8 *b, unsigned int bs)
56{
57 ((u32 *)a)[0] ^= ((u32 *)b)[0];
58 ((u32 *)a)[1] ^= ((u32 *)b)[1];
59 ((u32 *)a)[2] ^= ((u32 *)b)[2];
60 ((u32 *)a)[3] ^= ((u32 *)b)[3];
61}
62
63static int _crypto_xcbc_digest_setkey(struct crypto_shash *parent, 54static int _crypto_xcbc_digest_setkey(struct crypto_shash *parent,
64 struct crypto_xcbc_ctx *ctx) 55 struct crypto_xcbc_ctx *ctx)
65{ 56{
@@ -122,7 +113,7 @@ static int crypto_xcbc_digest_update(struct shash_desc *pdesc, const u8 *p,
122 len -= bs - ctx->len; 113 len -= bs - ctx->len;
123 p += bs - ctx->len; 114 p += bs - ctx->len;
124 115
125 ctx->xor(ctx->prev, ctx->odds, bs); 116 crypto_xor(ctx->prev, ctx->odds, bs);
126 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev); 117 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev);
127 118
128 /* clearing the length */ 119 /* clearing the length */
@@ -130,7 +121,7 @@ static int crypto_xcbc_digest_update(struct shash_desc *pdesc, const u8 *p,
130 121
131 /* encrypting the rest of data */ 122 /* encrypting the rest of data */
132 while (len > bs) { 123 while (len > bs) {
133 ctx->xor(ctx->prev, p, bs); 124 crypto_xor(ctx->prev, p, bs);
134 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev); 125 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev);
135 p += bs; 126 p += bs;
136 len -= bs; 127 len -= bs;
@@ -162,8 +153,8 @@ static int crypto_xcbc_digest_final(struct shash_desc *pdesc, u8 *out)
162 crypto_cipher_encrypt_one(tfm, key2, 153 crypto_cipher_encrypt_one(tfm, key2,
163 (u8 *)(ctx->consts + bs)); 154 (u8 *)(ctx->consts + bs));
164 155
165 ctx->xor(ctx->prev, ctx->odds, bs); 156 crypto_xor(ctx->prev, ctx->odds, bs);
166 ctx->xor(ctx->prev, key2, bs); 157 crypto_xor(ctx->prev, key2, bs);
167 _crypto_xcbc_digest_setkey(parent, ctx); 158 _crypto_xcbc_digest_setkey(parent, ctx);
168 159
169 crypto_cipher_encrypt_one(tfm, out, ctx->prev); 160 crypto_cipher_encrypt_one(tfm, out, ctx->prev);
@@ -184,8 +175,8 @@ static int crypto_xcbc_digest_final(struct shash_desc *pdesc, u8 *out)
184 crypto_cipher_encrypt_one(tfm, key3, 175 crypto_cipher_encrypt_one(tfm, key3,
185 (u8 *)(ctx->consts + bs * 2)); 176 (u8 *)(ctx->consts + bs * 2));
186 177
187 ctx->xor(ctx->prev, ctx->odds, bs); 178 crypto_xor(ctx->prev, ctx->odds, bs);
188 ctx->xor(ctx->prev, key3, bs); 179 crypto_xor(ctx->prev, key3, bs);
189 180
190 _crypto_xcbc_digest_setkey(parent, ctx); 181 _crypto_xcbc_digest_setkey(parent, ctx);
191 182
@@ -209,7 +200,6 @@ static int xcbc_init_tfm(struct crypto_tfm *tfm)
209 200
210 switch(bs) { 201 switch(bs) {
211 case 16: 202 case 16:
212 ctx->xor = xor_128;
213 break; 203 break;
214 default: 204 default:
215 return -EINVAL; 205 return -EINVAL;