From 470a0a36d579980431361f23e8f319d5c68aa4af Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 23 Aug 2018 18:08:03 -0700 Subject: crypto: use unaligned helpers This is not useful for WireGuard, but for the general use case we probably want it this way, and the speed difference is mostly lost in the noise. Signed-off-by: Jason A. Donenfeld --- src/crypto/curve25519-fiat32.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/crypto/curve25519-fiat32.h') diff --git a/src/crypto/curve25519-fiat32.h b/src/crypto/curve25519-fiat32.h index f1e21a4..c5593ea 100644 --- a/src/crypto/curve25519-fiat32.h +++ b/src/crypto/curve25519-fiat32.h @@ -23,14 +23,14 @@ typedef struct fe_loose { u32 v[10]; } fe_loose; static __always_inline void fe_frombytes_impl(u32 h[10], const u8 *s) { /* Ignores top bit of s. */ - u32 a0 = le32_to_cpup((__force __le32 *)(s)); - u32 a1 = le32_to_cpup((__force __le32 *)(s+4)); - u32 a2 = le32_to_cpup((__force __le32 *)(s+8)); - u32 a3 = le32_to_cpup((__force __le32 *)(s+12)); - u32 a4 = le32_to_cpup((__force __le32 *)(s+16)); - u32 a5 = le32_to_cpup((__force __le32 *)(s+20)); - u32 a6 = le32_to_cpup((__force __le32 *)(s+24)); - u32 a7 = le32_to_cpup((__force __le32 *)(s+28)); + u32 a0 = get_unaligned_le32(s); + u32 a1 = get_unaligned_le32(s+4); + u32 a2 = get_unaligned_le32(s+8); + u32 a3 = get_unaligned_le32(s+12); + u32 a4 = get_unaligned_le32(s+16); + u32 a5 = get_unaligned_le32(s+20); + u32 a6 = get_unaligned_le32(s+24); + u32 a7 = get_unaligned_le32(s+28); h[0] = a0&((1<<26)-1); /* 26 used, 32-26 left. 26 */ h[1] = (a0>>26) | ((a1&((1<<19)-1))<< 6); /* (32-26) + 19 = 6+19 = 25 */ h[2] = (a1>>19) | ((a2&((1<<13)-1))<<13); /* (32-19) + 13 = 13+13 = 26 */ -- cgit v1.2.3