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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: aria - stop using cra_alignmask

Instead of specifying a nonzero alignmask, use the unaligned access
helpers. This eliminates unnecessary alignment operations on most CPUs,
which can handle unaligned accesses efficiently, and brings us a step
closer to eventually removing support for the alignmask field.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
6c178fd6 8d905282

+17 -20
+17 -20
crypto/aria_generic.c
··· 15 15 */ 16 16 17 17 #include <crypto/aria.h> 18 + #include <linux/unaligned.h> 18 19 19 20 static const u32 key_rc[20] = { 20 21 0x517cc1b7, 0x27220a94, 0xfe13abe8, 0xfa9a6ee0, ··· 28 27 static void aria_set_encrypt_key(struct aria_ctx *ctx, const u8 *in_key, 29 28 unsigned int key_len) 30 29 { 31 - const __be32 *key = (const __be32 *)in_key; 32 30 u32 w0[4], w1[4], w2[4], w3[4]; 33 31 u32 reg0, reg1, reg2, reg3; 34 32 const u32 *ck; ··· 35 35 36 36 ck = &key_rc[(key_len - 16) / 2]; 37 37 38 - w0[0] = be32_to_cpu(key[0]); 39 - w0[1] = be32_to_cpu(key[1]); 40 - w0[2] = be32_to_cpu(key[2]); 41 - w0[3] = be32_to_cpu(key[3]); 38 + w0[0] = get_unaligned_be32(&in_key[0]); 39 + w0[1] = get_unaligned_be32(&in_key[4]); 40 + w0[2] = get_unaligned_be32(&in_key[8]); 41 + w0[3] = get_unaligned_be32(&in_key[12]); 42 42 43 43 reg0 = w0[0] ^ ck[0]; 44 44 reg1 = w0[1] ^ ck[1]; ··· 48 48 aria_subst_diff_odd(&reg0, &reg1, &reg2, &reg3); 49 49 50 50 if (key_len > 16) { 51 - w1[0] = be32_to_cpu(key[4]); 52 - w1[1] = be32_to_cpu(key[5]); 51 + w1[0] = get_unaligned_be32(&in_key[16]); 52 + w1[1] = get_unaligned_be32(&in_key[20]); 53 53 if (key_len > 24) { 54 - w1[2] = be32_to_cpu(key[6]); 55 - w1[3] = be32_to_cpu(key[7]); 54 + w1[2] = get_unaligned_be32(&in_key[24]); 55 + w1[3] = get_unaligned_be32(&in_key[28]); 56 56 } else { 57 57 w1[2] = 0; 58 58 w1[3] = 0; ··· 195 195 static void __aria_crypt(struct aria_ctx *ctx, u8 *out, const u8 *in, 196 196 u32 key[][ARIA_RD_KEY_WORDS]) 197 197 { 198 - const __be32 *src = (const __be32 *)in; 199 - __be32 *dst = (__be32 *)out; 200 198 u32 reg0, reg1, reg2, reg3; 201 199 int rounds, rkidx = 0; 202 200 203 201 rounds = ctx->rounds; 204 202 205 - reg0 = be32_to_cpu(src[0]); 206 - reg1 = be32_to_cpu(src[1]); 207 - reg2 = be32_to_cpu(src[2]); 208 - reg3 = be32_to_cpu(src[3]); 203 + reg0 = get_unaligned_be32(&in[0]); 204 + reg1 = get_unaligned_be32(&in[4]); 205 + reg2 = get_unaligned_be32(&in[8]); 206 + reg3 = get_unaligned_be32(&in[12]); 209 207 210 208 aria_add_round_key(key[rkidx], &reg0, &reg1, &reg2, &reg3); 211 209 rkidx++; ··· 239 241 (u8)(s1[get_u8(reg3, 2)]), 240 242 (u8)(s2[get_u8(reg3, 3)])); 241 243 242 - dst[0] = cpu_to_be32(reg0); 243 - dst[1] = cpu_to_be32(reg1); 244 - dst[2] = cpu_to_be32(reg2); 245 - dst[3] = cpu_to_be32(reg3); 244 + put_unaligned_be32(reg0, &out[0]); 245 + put_unaligned_be32(reg1, &out[4]); 246 + put_unaligned_be32(reg2, &out[8]); 247 + put_unaligned_be32(reg3, &out[12]); 246 248 } 247 249 248 250 void aria_encrypt(void *_ctx, u8 *out, const u8 *in) ··· 282 284 .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 283 285 .cra_blocksize = ARIA_BLOCK_SIZE, 284 286 .cra_ctxsize = sizeof(struct aria_ctx), 285 - .cra_alignmask = 3, 286 287 .cra_module = THIS_MODULE, 287 288 .cra_u = { 288 289 .cipher = {