Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+6 -16
+6 -16
crypto/xcbc.c
··· 47 47 u8 *prev; 48 48 u8 *key; 49 49 u8 *consts; 50 - void (*xor)(u8 *a, const u8 *b, unsigned int bs); 51 50 unsigned int keylen; 52 51 unsigned int len; 53 52 }; 54 - 55 - static 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 53 63 54 static int _crypto_xcbc_digest_setkey(struct crypto_shash *parent, 64 55 struct crypto_xcbc_ctx *ctx) ··· 113 122 len -= bs - ctx->len; 114 123 p += bs - ctx->len; 115 124 116 - ctx->xor(ctx->prev, ctx->odds, bs); 125 + crypto_xor(ctx->prev, ctx->odds, bs); 117 126 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev); 118 127 119 128 /* clearing the length */ ··· 121 130 122 131 /* encrypting the rest of data */ 123 132 while (len > bs) { 124 - ctx->xor(ctx->prev, p, bs); 133 + crypto_xor(ctx->prev, p, bs); 125 134 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev); 126 135 p += bs; 127 136 len -= bs; ··· 153 162 crypto_cipher_encrypt_one(tfm, key2, 154 163 (u8 *)(ctx->consts + bs)); 155 164 156 - ctx->xor(ctx->prev, ctx->odds, bs); 157 - ctx->xor(ctx->prev, key2, bs); 165 + crypto_xor(ctx->prev, ctx->odds, bs); 166 + crypto_xor(ctx->prev, key2, bs); 158 167 _crypto_xcbc_digest_setkey(parent, ctx); 159 168 160 169 crypto_cipher_encrypt_one(tfm, out, ctx->prev); ··· 175 184 crypto_cipher_encrypt_one(tfm, key3, 176 185 (u8 *)(ctx->consts + bs * 2)); 177 186 178 - ctx->xor(ctx->prev, ctx->odds, bs); 179 - ctx->xor(ctx->prev, key3, bs); 187 + crypto_xor(ctx->prev, ctx->odds, bs); 188 + crypto_xor(ctx->prev, key3, bs); 180 189 181 190 _crypto_xcbc_digest_setkey(parent, ctx); 182 191 ··· 200 209 201 210 switch(bs) { 202 211 case 16: 203 - ctx->xor = xor_128; 204 212 break; 205 213 default: 206 214 return -EINVAL;