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: anubis - 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
8d905282 07d58e0a

+5 -9
+5 -9
crypto/anubis.c
··· 33 33 #include <linux/init.h> 34 34 #include <linux/module.h> 35 35 #include <linux/mm.h> 36 - #include <asm/byteorder.h> 36 + #include <linux/unaligned.h> 37 37 #include <linux/types.h> 38 38 39 39 #define ANUBIS_MIN_KEY_SIZE 16 ··· 463 463 unsigned int key_len) 464 464 { 465 465 struct anubis_ctx *ctx = crypto_tfm_ctx(tfm); 466 - const __be32 *key = (const __be32 *)in_key; 467 466 int N, R, i, r; 468 467 u32 kappa[ANUBIS_MAX_N]; 469 468 u32 inter[ANUBIS_MAX_N]; ··· 481 482 482 483 /* * map cipher key to initial key state (mu): */ 483 484 for (i = 0; i < N; i++) 484 - kappa[i] = be32_to_cpu(key[i]); 485 + kappa[i] = get_unaligned_be32(&in_key[4 * i]); 485 486 486 487 /* 487 488 * generate R + 1 round keys: ··· 569 570 } 570 571 571 572 static void anubis_crypt(u32 roundKey[ANUBIS_MAX_ROUNDS + 1][4], 572 - u8 *ciphertext, const u8 *plaintext, const int R) 573 + u8 *dst, const u8 *src, const int R) 573 574 { 574 - const __be32 *src = (const __be32 *)plaintext; 575 - __be32 *dst = (__be32 *)ciphertext; 576 575 int i, r; 577 576 u32 state[4]; 578 577 u32 inter[4]; ··· 580 583 * and add initial round key (sigma[K^0]): 581 584 */ 582 585 for (i = 0; i < 4; i++) 583 - state[i] = be32_to_cpu(src[i]) ^ roundKey[0][i]; 586 + state[i] = get_unaligned_be32(&src[4 * i]) ^ roundKey[0][i]; 584 587 585 588 /* 586 589 * R - 1 full rounds: ··· 651 654 */ 652 655 653 656 for (i = 0; i < 4; i++) 654 - dst[i] = cpu_to_be32(inter[i]); 657 + put_unaligned_be32(inter[i], &dst[4 * i]); 655 658 } 656 659 657 660 static void anubis_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) ··· 672 675 .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 673 676 .cra_blocksize = ANUBIS_BLOCK_SIZE, 674 677 .cra_ctxsize = sizeof (struct anubis_ctx), 675 - .cra_alignmask = 3, 676 678 .cra_module = THIS_MODULE, 677 679 .cra_u = { .cipher = { 678 680 .cia_min_keysize = ANUBIS_MIN_KEY_SIZE,