summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/whrlpool
diff options
context:
space:
mode:
authormiod <>2016-11-04 17:30:30 +0000
committermiod <>2016-11-04 17:30:30 +0000
commit723502d9588ba0e1cc08af1b12654917da74d440 (patch)
tree77b413175d422148cfb0ef7b2062340230aa5413 /src/lib/libcrypto/whrlpool
parent391f8ce21bb7929810460a73e2fde2c80540848d (diff)
downloadopenbsd-723502d9588ba0e1cc08af1b12654917da74d440.tar.gz
openbsd-723502d9588ba0e1cc08af1b12654917da74d440.tar.bz2
openbsd-723502d9588ba0e1cc08af1b12654917da74d440.zip
Replace all uses of magic numbers when operating on OPENSSL_ia32_P[] by
meaningful constants in a private header file, so that reviewers can actually get a chance to figure out what the code is attempting to do without knowing all cpuid bits. While there, turn it from an array of two 32-bit ints into a properly aligned 64-bit int. Use of OPENSSL_ia32_P is now restricted to the assembler parts. C code will now always use OPENSSL_cpu_caps() and check for the proper bits in the whole 64-bit word it returns. i386 tests and ok jsing@
Diffstat (limited to 'src/lib/libcrypto/whrlpool')
-rw-r--r--src/lib/libcrypto/whrlpool/wp_block.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/libcrypto/whrlpool/wp_block.c b/src/lib/libcrypto/whrlpool/wp_block.c
index d8c1b89ba3..1e00a01330 100644
--- a/src/lib/libcrypto/whrlpool/wp_block.c
+++ b/src/lib/libcrypto/whrlpool/wp_block.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: wp_block.c,v 1.12 2016/09/04 14:06:46 jsing Exp $ */ 1/* $OpenBSD: wp_block.c,v 1.13 2016/11/04 17:30:30 miod Exp $ */
2/** 2/**
3 * The Whirlpool hashing function. 3 * The Whirlpool hashing function.
4 * 4 *
@@ -36,10 +36,12 @@
36 * 36 *
37 */ 37 */
38 38
39#include "wp_locl.h"
40#include <string.h> 39#include <string.h>
40#include <openssl/crypto.h>
41#include <machine/endian.h> 41#include <machine/endian.h>
42 42
43#include "wp_locl.h"
44
43typedef unsigned char u8; 45typedef unsigned char u8;
44#if defined(_LP64) 46#if defined(_LP64)
45typedef unsigned long u64; 47typedef unsigned long u64;
@@ -57,12 +59,15 @@ typedef unsigned long long u64;
57# define OPENSSL_SMALL_FOOTPRINT /* it appears that for elder non-MMX 59# define OPENSSL_SMALL_FOOTPRINT /* it appears that for elder non-MMX
58 CPUs this is actually faster! */ 60 CPUs this is actually faster! */
59# endif 61# endif
60# define GO_FOR_MMX(ctx,inp,num) do { \ 62#include "x86_arch.h"
61 extern unsigned int OPENSSL_ia32cap_P[]; \ 63# define GO_FOR_MMX(ctx,inp,num) \
64do { \
62 void whirlpool_block_mmx(void *,const void *,size_t); \ 65 void whirlpool_block_mmx(void *,const void *,size_t); \
63 if (!(OPENSSL_ia32cap_P[0] & (1<<23))) break; \ 66 if ((OPENSSL_cpu_caps() & CPUCAP_MASK_MMX) == 0) \
64 whirlpool_block_mmx(ctx->H.c,inp,num); return; \ 67 break; \
65 } while (0) 68 whirlpool_block_mmx(ctx->H.c,inp,num); \
69 return; \
70} while (0)
66# endif 71# endif
67#elif defined(__arm__) 72#elif defined(__arm__)
68# define SMALL_REGISTER_BANK 73# define SMALL_REGISTER_BANK