Remove extern declarations of OPENSSL_ia32cap_P
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 24 Aug 2019 09:28:19 +0000 (11:28 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 1 Sep 2019 13:41:58 +0000 (15:41 +0200)
Use the header file internal/cryptlib.h instead.
Remove checks for OPENSSL_NO_ASM and I386_ONLY
in cryptlib.c, to match the checks in other
places where OPENSSL_ia32cap_P is used and
assumed to be initialized.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/9688)

crypto/cryptlib.c
crypto/engine/eng_rdrand.c
crypto/evp/e_aes_cbc_hmac_sha1.c
crypto/evp/e_aes_cbc_hmac_sha256.c
crypto/evp/e_rc4_hmac_md5.c
crypto/include/internal/ciphermode_platform.h
crypto/modes/gcm128.c
crypto/rand/rand_lib.c
crypto/whrlpool/wp_block.c
include/internal/cryptlib.h
test/rdrand_sanitytest.c

index 0048a3d2100bbb03f6ef6b317506e9b9b3c28fe5..7e89bbd6b5709382cbabbbfb2e0fbab68b3aaaf8 100644 (file)
@@ -18,7 +18,7 @@
 
 extern unsigned int OPENSSL_ia32cap_P[4];
 
-# if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
+# if defined(OPENSSL_CPUID_OBJ)
 
 /*
  * Purpose of these minimalistic and character-type-agnostic subroutines
index 2fcc0edff291dbdf4dc35d575956ec7981bf787b..7dd3b9fdf6fa1b6d7e9eb9788fd8ccad9a87d68e 100644 (file)
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "internal/engine.h"
+#include "internal/cryptlib.h"
 #include <openssl/rand.h>
 #include <openssl/err.h>
 #include <openssl/crypto.h>
@@ -79,8 +80,6 @@ static ENGINE *ENGINE_rdrand(void)
 
 void engine_load_rdrand_int(void)
 {
-    extern unsigned int OPENSSL_ia32cap_P[];
-
     if (OPENSSL_ia32cap_P[1] & (1 << (62 - 32))) {
         ENGINE *toadd = ENGINE_rdrand();
         if (!toadd)
index 8d557e512e76cb899a114001201d1b9ff7487225..9e393f0b88a774b1aa300467c900a18925e9ee84 100644 (file)
@@ -15,6 +15,7 @@
 #include <openssl/aes.h>
 #include <openssl/sha.h>
 #include <openssl/rand.h>
+#include "internal/cryptlib.h"
 #include "internal/modes_int.h"
 #include "internal/evp_int.h"
 #include "internal/constant_time_locl.h"
@@ -35,7 +36,6 @@ typedef struct {
         defined(__x86_64)       || defined(__x86_64__)  || \
         defined(_M_AMD64)       || defined(_M_X64)      )
 
-extern unsigned int OPENSSL_ia32cap_P[];
 # define AESNI_CAPABLE   (1<<(57-32))
 
 int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
index 6efd3000b8663c417dc117c3e19d2e825b259aca..e434ec009f4015c088dcb833ee2fac83a28f4017 100644 (file)
@@ -15,6 +15,7 @@
 #include <openssl/aes.h>
 #include <openssl/sha.h>
 #include <openssl/rand.h>
+#include "internal/cryptlib.h"
 #include "internal/modes_int.h"
 #include "internal/constant_time_locl.h"
 #include "internal/evp_int.h"
@@ -35,7 +36,6 @@ typedef struct {
         defined(__x86_64)       || defined(__x86_64__)  || \
         defined(_M_AMD64)       || defined(_M_X64)      )
 
-extern unsigned int OPENSSL_ia32cap_P[];
 # define AESNI_CAPABLE   (1<<(57-32))
 
 int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
index d22abbb325c66d7701435c4b797b532a6604a5d7..4d61faff61e807ef0da423bb0d06d157cf2e3197 100644 (file)
@@ -71,7 +71,6 @@ static int rc4_hmac_md5_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
                                                        * rc4_md5-x86_64.pl */
         md5_off = MD5_CBLOCK - key->md.num, blocks;
     unsigned int l;
-    extern unsigned int OPENSSL_ia32cap_P[];
 # endif
     size_t plen = key->payload_length;
 
index 40d012a8d16e0eeb7edb1e1e2622837cdac129d0..f357ea5c84edfebe77b6f28bcda1706b764fa150 100644 (file)
@@ -101,7 +101,6 @@ void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len,
          defined(_M_AMD64)       || defined(_M_X64)      )
 
 /* AES-NI section */
-extern unsigned int OPENSSL_ia32cap_P[];
 
 #  define AESNI_CAPABLE   (OPENSSL_ia32cap_P[1]&(1<<(57-32)))
 #  ifdef VPAES_ASM
index 371bf7637d8aad0e35289e582d2eebb21467b760..f37653be6727bf34eaffe4544d96c4875edf810c 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <string.h>
 #include <openssl/crypto.h>
+#include "internal/cryptlib.h"
 #include "internal/modes_int.h"
 
 #if defined(BSWAP4) && defined(STRICT_ALIGNMENT)
@@ -635,7 +636,6 @@ static void gcm_gmult_1bit(u64 Xi[2], const u64 H[2])
          defined(_M_IX86)       || defined(_M_AMD64)    || defined(_M_X64))
 #  define GHASH_ASM_X86_OR_64
 #  define GCM_FUNCREF_4BIT
-extern unsigned int OPENSSL_ia32cap_P[];
 
 void gcm_init_clmul(u128 Htable[16], const u64 Xi[2]);
 void gcm_gmult_clmul(u64 Xi[2], const u128 Htable[16]);
index 8b44b5502d2fce9e55e574b37fe982a5747259da..c865ece97849c36e67dea16d7b2bc4b4a7199324 100644 (file)
@@ -69,8 +69,6 @@ size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool)
 size_t OPENSSL_ia32_rdseed_bytes(unsigned char *buf, size_t len);
 size_t OPENSSL_ia32_rdrand_bytes(unsigned char *buf, size_t len);
 
-extern unsigned int OPENSSL_ia32cap_P[];
-
 /*
  * Acquire entropy using Intel-specific cpu instructions
  *
index 574ac124d4e35442a6f795449c50eaf61da2d2ac..c2c0b72681dd80583959639daf2dd2328873525d 100644 (file)
@@ -36,6 +36,7 @@
  *
  */
 
+#include "internal/cryptlib.h"
 #include "wp_locl.h"
 #include <string.h>
 
@@ -75,7 +76,6 @@ typedef unsigned long long u64;
 #   define OPENSSL_SMALL_FOOTPRINT
 #  endif
 #  define GO_FOR_MMX(ctx,inp,num)     do {                    \
-        extern unsigned long OPENSSL_ia32cap_P[];               \
         void whirlpool_block_mmx(void *,const void *,size_t);   \
         if (!(OPENSSL_ia32cap_P[0] & (1<<23)))  break;          \
         whirlpool_block_mmx(ctx->H.c,inp,num);  return;         \
index d54ca24ee166bdc520a22c89853e3aa6723f236f..d591f203d2f700981e019b7f22334d7e2f08dd59 100644 (file)
@@ -84,7 +84,11 @@ DEFINE_LHASH_OF(MEM);
 # define HEX_SIZE(type)          (sizeof(type)*2)
 
 void OPENSSL_cpuid_setup(void);
+#if defined(__i386)   || defined(__i386__)   || defined(_M_IX86) || \
+    defined(__x86_64) || defined(__x86_64__) || \
+    defined(_M_AMD64) || defined(_M_X64)
 extern unsigned int OPENSSL_ia32cap_P[];
+#endif
 void OPENSSL_showfatal(const char *fmta, ...);
 int do_ex_data_init(OPENSSL_CTX *ctx);
 void crypto_cleanup_all_ex_data_int(OPENSSL_CTX *ctx);
index 851e14ccf7b2d12a65c84b33a4db77c1747c65e0..dcc9d2800ae0d436ef6ed8ece7484193ad973306 100644 (file)
@@ -11,7 +11,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "testutil.h"
-#include <openssl/opensslconf.h>
+#include "internal/cryptlib.h"
 
 #if (defined(__i386)   || defined(__i386__)   || defined(_M_IX86) || \
      defined(__x86_64) || defined(__x86_64__) || \
 size_t OPENSSL_ia32_rdrand_bytes(unsigned char *buf, size_t len);
 size_t OPENSSL_ia32_rdseed_bytes(unsigned char *buf, size_t len);
 
-void OPENSSL_cpuid_setup(void);
-
-extern unsigned int OPENSSL_ia32cap_P[4];
-
 static int sanity_check_bytes(size_t (*rng)(unsigned char *, size_t),
     int rounds, int min_failures, int max_retries, int max_zero_words)
 {