diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2023-04-12 04:54:17 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2023-04-12 04:54:17 +0000 |
commit | 19b19965bdd40c85aacd06622bee5576ed2dc57f (patch) | |
tree | ec0a3f8411047a696d71e343c93350ded947a368 /lib/libcrypto/md32_common.h | |
parent | 0e62b81c95b61ac66c2d4df0ba3575c9550c1b90 (diff) |
Provide and use crypto_ro{l,r}_u{32,64}().
Various code in libcrypto needs bitwise rotation - rather than defining
different versions across the code base, provide a common set that can
be reused. Any sensible compiler optimises these to a single instruction
where the architecture supports it, which means we can ditch the inline
assembly.
On the chance that we need to provide a platform specific versions, this
follows the approach used in BN where a MD crypto_arch.h header could be
added in the future, which would then provide more specific versions of
these functions.
ok tb@
Diffstat (limited to 'lib/libcrypto/md32_common.h')
-rw-r--r-- | lib/libcrypto/md32_common.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/libcrypto/md32_common.h b/lib/libcrypto/md32_common.h index a8b0d9ab740..cce4cfb0f7e 100644 --- a/lib/libcrypto/md32_common.h +++ b/lib/libcrypto/md32_common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md32_common.h,v 1.23 2022/12/26 07:18:50 jmc Exp $ */ +/* $OpenBSD: md32_common.h,v 1.24 2023/04/12 04:54:15 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -111,6 +111,8 @@ #include <openssl/opensslconf.h> +#include "crypto_internal.h" + #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN) #error "DATA_ORDER must be defined!" #endif @@ -139,15 +141,7 @@ #error "HASH_BLOCK_DATA_ORDER must be defined!" #endif -/* - * This common idiom is recognized by the compiler and turned into a - * CPU-specific intrinsic as appropriate. - * e.g. GCC optimizes to roll on amd64 at -O0 - */ -static inline uint32_t ROTATE(uint32_t a, uint32_t n) -{ - return (a<<n)|(a>>(32-n)); -} +#define ROTATE(a, n) crypto_rol_u32(a, n) #if defined(DATA_ORDER_IS_BIG_ENDIAN) |