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: khazad - 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
7e006158 5e252f49

+6 -11
+6 -11
crypto/khazad.c
··· 23 23 #include <linux/init.h> 24 24 #include <linux/module.h> 25 25 #include <linux/mm.h> 26 - #include <asm/byteorder.h> 26 + #include <linux/unaligned.h> 27 27 #include <linux/types.h> 28 28 29 29 #define KHAZAD_KEY_SIZE 16 ··· 757 757 unsigned int key_len) 758 758 { 759 759 struct khazad_ctx *ctx = crypto_tfm_ctx(tfm); 760 - const __be32 *key = (const __be32 *)in_key; 761 760 int r; 762 761 const u64 *S = T7; 763 762 u64 K2, K1; 764 763 765 - /* key is supposed to be 32-bit aligned */ 766 - K2 = ((u64)be32_to_cpu(key[0]) << 32) | be32_to_cpu(key[1]); 767 - K1 = ((u64)be32_to_cpu(key[2]) << 32) | be32_to_cpu(key[3]); 764 + K2 = get_unaligned_be64(&in_key[0]); 765 + K1 = get_unaligned_be64(&in_key[8]); 768 766 769 767 /* setup the encrypt key */ 770 768 for (r = 0; r <= KHAZAD_ROUNDS; r++) { ··· 798 800 } 799 801 800 802 static void khazad_crypt(const u64 roundKey[KHAZAD_ROUNDS + 1], 801 - u8 *ciphertext, const u8 *plaintext) 803 + u8 *dst, const u8 *src) 802 804 { 803 - const __be64 *src = (const __be64 *)plaintext; 804 - __be64 *dst = (__be64 *)ciphertext; 805 805 int r; 806 806 u64 state; 807 807 808 - state = be64_to_cpu(*src) ^ roundKey[0]; 808 + state = get_unaligned_be64(src) ^ roundKey[0]; 809 809 810 810 for (r = 1; r < KHAZAD_ROUNDS; r++) { 811 811 state = T0[(int)(state >> 56) ] ^ ··· 827 831 (T7[(int)(state ) & 0xff] & 0x00000000000000ffULL) ^ 828 832 roundKey[KHAZAD_ROUNDS]; 829 833 830 - *dst = cpu_to_be64(state); 834 + put_unaligned_be64(state, dst); 831 835 } 832 836 833 837 static void khazad_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) ··· 848 852 .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 849 853 .cra_blocksize = KHAZAD_BLOCK_SIZE, 850 854 .cra_ctxsize = sizeof (struct khazad_ctx), 851 - .cra_alignmask = 7, 852 855 .cra_module = THIS_MODULE, 853 856 .cra_u = { .cipher = { 854 857 .cia_min_keysize = KHAZAD_KEY_SIZE,