From: Niels Möller Date: Mon, 28 Nov 2022 19:03:02 +0000 (+0100) Subject: Use bswap-internal.h and bswap64_if_le. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21cdfd4aeed83e1b00cb9e2aaf6533b67fd07eb1;p=thirdparty%2Fnettle.git Use bswap-internal.h and bswap64_if_le. --- diff --git a/ocb.c b/ocb.c index 3a96cf0c..e3b1ae34 100644 --- a/ocb.c +++ b/ocb.c @@ -39,25 +39,7 @@ #include "ocb.h" #include "block-internal.h" - -/* FIXME: Duplicated in nist-keywrap.c */ -#if WORDS_BIGENDIAN -#define bswap_if_le(x) (x) -#elif HAVE_BUILTIN_BSWAP64 -#define bswap_if_le(x) (__builtin_bswap64 (x)) -#else -static uint64_t -bswap_if_le (uint64_t x) -{ - x = ((x >> 32) & UINT64_C (0xffffffff)) - | ((x & UINT64_C (0xffffffff)) << 32); - x = ((x >> 16) & UINT64_C (0xffff0000ffff)) - | ((x & UINT64_C (0xffff0000ffff)) << 16); - x = ((x >> 8) & UINT64_C (0xff00ff00ff00ff)) - | ((x & UINT64_C (0xff00ff00ff00ff)) << 8); - return x; -} -#endif +#include "bswap-internal.h" /* Returns 64 bits from the concatenation (u0, u1), starting from bit offset. */ static inline uint64_t @@ -65,9 +47,9 @@ extract(uint64_t u0, uint64_t u1, unsigned offset) { if (offset == 0) return u0; - u0 = bswap_if_le(u0); - u1 = bswap_if_le(u1); - return bswap_if_le((u0 << offset) | (u1 >> (64 - offset))); + u0 = bswap64_if_le(u0); + u1 = bswap64_if_le(u1); + return bswap64_if_le((u0 << offset) | (u1 >> (64 - offset))); } void