summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2024-10-19 13:06:12 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2024-10-19 13:06:12 +0000
commit8467e02dc5fdf1f3bfb905d9c8638e1ba1978fe0 (patch)
treede85a5ba3b364f23d14ec70d26aad91229c5ef7e /lib
parent048c089830ea45f36f95288a319c5ee2cecc14db (diff)
Remove IA32 specific code from cryptlib.c.
Move the IA32 specific code to arch/{amd64,i386}/crypto_cpu_caps.c, rather than polluting cryptlib.c with machine dependent code. A stub version of crypto_cpu_caps_ia32() still remains for now.
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/arch/amd64/crypto_arch.h3
-rw-r--r--lib/libcrypto/arch/amd64/crypto_cpu_caps.c10
-rw-r--r--lib/libcrypto/arch/i386/crypto_arch.h3
-rw-r--r--lib/libcrypto/arch/i386/crypto_cpu_caps.c10
-rw-r--r--lib/libcrypto/cryptlib.c44
5 files changed, 29 insertions, 41 deletions
diff --git a/lib/libcrypto/arch/amd64/crypto_arch.h b/lib/libcrypto/arch/amd64/crypto_arch.h
index 6feeaa209e8..64b2da587b3 100644
--- a/lib/libcrypto/arch/amd64/crypto_arch.h
+++ b/lib/libcrypto/arch/amd64/crypto_arch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto_arch.h,v 1.2 2024/10/18 13:36:24 jsing Exp $ */
+/* $OpenBSD: crypto_arch.h,v 1.3 2024/10/19 13:06:11 jsing Exp $ */
/*
* Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
*
@@ -19,6 +19,7 @@
#define HEADER_CRYPTO_ARCH_H
#define HAVE_CRYPTO_CPU_CAPS_INIT
+#define HAVE_CRYPTO_CPU_CAPS_IA32
#ifndef OPENSSL_NO_ASM
diff --git a/lib/libcrypto/arch/amd64/crypto_cpu_caps.c b/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
index 8cbf24edbd6..b0da0d636cd 100644
--- a/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
+++ b/lib/libcrypto/arch/amd64/crypto_cpu_caps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto_cpu_caps.c,v 1.1 2024/10/18 13:36:24 jsing Exp $ */
+/* $OpenBSD: crypto_cpu_caps.c,v 1.2 2024/10/19 13:06:11 jsing Exp $ */
/*
* Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
*
@@ -22,7 +22,7 @@
#include "x86_arch.h"
/* Legacy architecture specific capabilities, used by perlasm. */
-extern uint64_t OPENSSL_ia32cap_P;
+uint64_t OPENSSL_ia32cap_P;
/* Machine independent CPU capabilities. */
extern uint64_t crypto_cpu_caps;
@@ -112,3 +112,9 @@ crypto_cpu_caps_init(void)
OPENSSL_ia32cap_P = caps;
}
+
+uint64_t
+crypto_cpu_caps_ia32(void)
+{
+ return OPENSSL_ia32cap_P;
+}
diff --git a/lib/libcrypto/arch/i386/crypto_arch.h b/lib/libcrypto/arch/i386/crypto_arch.h
index d566d8064a2..64b2da587b3 100644
--- a/lib/libcrypto/arch/i386/crypto_arch.h
+++ b/lib/libcrypto/arch/i386/crypto_arch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto_arch.h,v 1.2 2024/10/18 14:44:02 jsing Exp $ */
+/* $OpenBSD: crypto_arch.h,v 1.3 2024/10/19 13:06:11 jsing Exp $ */
/*
* Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
*
@@ -19,6 +19,7 @@
#define HEADER_CRYPTO_ARCH_H
#define HAVE_CRYPTO_CPU_CAPS_INIT
+#define HAVE_CRYPTO_CPU_CAPS_IA32
#ifndef OPENSSL_NO_ASM
diff --git a/lib/libcrypto/arch/i386/crypto_cpu_caps.c b/lib/libcrypto/arch/i386/crypto_cpu_caps.c
index e5b36a15cc1..b0da0d636cd 100644
--- a/lib/libcrypto/arch/i386/crypto_cpu_caps.c
+++ b/lib/libcrypto/arch/i386/crypto_cpu_caps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto_cpu_caps.c,v 1.1 2024/10/18 14:44:02 jsing Exp $ */
+/* $OpenBSD: crypto_cpu_caps.c,v 1.2 2024/10/19 13:06:11 jsing Exp $ */
/*
* Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
*
@@ -22,7 +22,7 @@
#include "x86_arch.h"
/* Legacy architecture specific capabilities, used by perlasm. */
-extern uint64_t OPENSSL_ia32cap_P;
+uint64_t OPENSSL_ia32cap_P;
/* Machine independent CPU capabilities. */
extern uint64_t crypto_cpu_caps;
@@ -112,3 +112,9 @@ crypto_cpu_caps_init(void)
OPENSSL_ia32cap_P = caps;
}
+
+uint64_t
+crypto_cpu_caps_ia32(void)
+{
+ return OPENSSL_ia32cap_P;
+}
diff --git a/lib/libcrypto/cryptlib.c b/lib/libcrypto/cryptlib.c
index 60f14eba125..8cb05e8cbfa 100644
--- a/lib/libcrypto/cryptlib.c
+++ b/lib/libcrypto/cryptlib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptlib.c,v 1.56 2024/10/17 14:27:57 jsing Exp $ */
+/* $OpenBSD: cryptlib.c,v 1.57 2024/10/19 13:06:11 jsing Exp $ */
/* ====================================================================
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
@@ -330,40 +330,6 @@ CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
return id->val;
}
-#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
- defined(__INTEL__) || \
- defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
-
-uint64_t OPENSSL_ia32cap_P;
-
-uint64_t
-crypto_cpu_caps_ia32(void)
-{
- return OPENSSL_ia32cap_P;
-}
-
-#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM)
-#define OPENSSL_CPUID_SETUP
-void
-OPENSSL_cpuid_setup(void)
-{
- uint64_t OPENSSL_ia32_cpuid(void);
-
- OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid();
-
- if ((OPENSSL_ia32cap_P & CPUCAP_MASK_AESNI) != 0)
- crypto_cpu_caps |= CRYPTO_CPU_CAPS_ACCELERATED_AES;
-}
-#endif
-
-#else
-uint64_t
-crypto_cpu_caps_ia32(void)
-{
- return 0;
-}
-#endif
-
#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
void
OPENSSL_cpuid_setup(void)
@@ -379,6 +345,14 @@ crypto_cpu_caps_init(void)
}
#endif
+#ifndef HAVE_CRYPTO_CPU_CAPS_IA32
+uint64_t
+crypto_cpu_caps_ia32(void)
+{
+ return 0;
+}
+#endif
+
uint64_t
OPENSSL_cpu_caps(void)
{