Index: trunk/src/libs/openssl-3.1.0/Config.kmk
===================================================================
--- trunk/src/libs/openssl-3.1.0/Config.kmk	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/Config.kmk	(revision 100882)
@@ -56,5 +56,5 @@
 VBOX_PATH_CRYPTO_DES        := $(VBOX_PATH_CRYPTO)/des
 VBOX_PATH_CRYPTO_CAMELLIA   := $(VBOX_PATH_CRYPTO)/camellia
-VBOX_INST_CRYPTO_HEADERS    := obj/$(if-expr "$(CURSUBDIR)" == ".",,$(CURSUBDIR)/)crypto-3.0.7-headers/include/openssl/
+VBOX_INST_CRYPTO_HEADERS    := obj/$(if-expr "$(CURSUBDIR)" == ".",,$(CURSUBDIR)/)crypto-3.1.0-headers/include/openssl/
 VBOX_PATH_CRYPTO_HEADERS    := $(abspath $(PATH_OUT))/$(patsubst %/,%,$(VBOX_INST_CRYPTO_HEADERS))
 VBOX_PATH_CRYPTO_PROVIDERS  := $(VBOX_PATH_OPENSSL)/providers
Index: trunk/src/libs/openssl-3.1.0/crypto/Makefile.kmk
===================================================================
--- trunk/src/libs/openssl-3.1.0/crypto/Makefile.kmk	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/crypto/Makefile.kmk	(revision 100882)
@@ -100,4 +100,6 @@
 	sparse_array.c \
 	threads_iprt.c \
+	threads_none.c \
+	threads_win.c \
 	trace.c \
 	uid.c
Index: trunk/src/libs/openssl-3.1.0/crypto/asn1/Makefile.kmk
===================================================================
--- trunk/src/libs/openssl-3.1.0/crypto/asn1/Makefile.kmk	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/crypto/asn1/Makefile.kmk	(revision 100882)
@@ -64,4 +64,5 @@
 	bio_asn1.c \
 	bio_ndef.c \
+	d2i_param.c \
 	d2i_pr.c \
 	d2i_pu.c \
Index: trunk/src/libs/openssl-3.1.0/crypto/bn/Makefile.kmk
===================================================================
--- trunk/src/libs/openssl-3.1.0/crypto/bn/Makefile.kmk	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/crypto/bn/Makefile.kmk	(revision 100882)
@@ -65,4 +65,5 @@
 	bn_word.c \
 	bn_x931p.c \
+	rsa_sup_mul.c \
 	rsaz_exp.c \
 	rsaz_exp_x2.c
@@ -76,4 +77,7 @@
  	asm/x86_64-gcc.c \
  	$(VBOX_PATH_CRYPTO_GENASM)/rsaz-avx2.S \
+ 	$(VBOX_PATH_CRYPTO_GENASM)/rsaz-2k-avx512.S \
+ 	$(VBOX_PATH_CRYPTO_GENASM)/rsaz-3k-avx512.S \
+ 	$(VBOX_PATH_CRYPTO_GENASM)/rsaz-4k-avx512.S \
  	$(VBOX_PATH_CRYPTO_GENASM)/rsaz-avx512.S \
  	$(VBOX_PATH_CRYPTO_GENASM)/rsaz-x86_64.S \
@@ -93,4 +97,5 @@
 		$(VBOX_PATH_CRYPTO_BN)/asm/x86-mont.pl \
 		$(VBOX_PATH_CRYPTO_BN)/asm/x86-gf2m.pl \
+		$(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl \
 		$(VBOX_PATH_CRYPTO_BN)/asm/rsaz-avx2.pl \
 		$(VBOX_PATH_CRYPTO_BN)/asm/rsaz-x86_64.pl \
@@ -102,4 +107,7 @@
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86-mont.pl elf -fPIC $(VBOX_PATH_CRYPTO)/genasm-elf/x86-mont.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86-gf2m.pl elf -fPIC $(VBOX_PATH_CRYPTO)/genasm-elf/x86-gf2m.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-elf/rsaz-2k-avx512.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-elf/rsaz-3k-avx512.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-elf/rsaz-4k-avx512.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-avx2.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/rsaz-avx2.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-x86_64.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/rsaz-x86_64.S
@@ -107,8 +115,12 @@
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86_64-mont.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/x86_64-mont.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86_64-mont5.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/x86_64-mont5.S
+
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/bn-586.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/bn-586.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/co-586.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/co-586.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86-mont.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/x86-mont.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86-gf2m.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/x86-gf2m.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/rsaz-2k-avx512.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/rsaz-3k-avx512.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/rsaz-4k-avx512.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-avx2.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/rsaz-avx2.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-x86_64.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/rsaz-x86_64.S
@@ -116,8 +128,12 @@
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86_64-mont.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/x86_64-mont.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86_64-mont5.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/x86_64-mont5.S
+
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/bn-586.pl win32n $(VBOX_PATH_CRYPTO)/genasm-nasm/bn-586.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/co-586.pl win32n $(VBOX_PATH_CRYPTO)/genasm-nasm/co-586.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86-mont.pl win32n $(VBOX_PATH_CRYPTO)/genasm-nasm/x86-mont.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/x86-gf2m.pl win32n $(VBOX_PATH_CRYPTO)/genasm-nasm/x86-gf2m.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-nasm/rsaz-2k-avx512.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-nasm/rsaz-3k-avx512.S
+	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-4k-avx512.pl macosx $(VBOX_PATH_CRYPTO)/genasm-nasm/rsaz-4k-avx512.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-avx2.pl nasm $(VBOX_PATH_CRYPTO)/genasm-nasm/rsaz-avx2.S
 	perl $(VBOX_PATH_CRYPTO_BN)/asm/rsaz-x86_64.pl nasm $(VBOX_PATH_CRYPTO)/genasm-nasm/rsaz-x86_64.S
Index: trunk/src/libs/openssl-3.1.0/crypto/mem.c
===================================================================
--- trunk/src/libs/openssl-3.1.0/crypto/mem.c	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/crypto/mem.c	(revision 100882)
@@ -8,5 +8,5 @@
  */
 
-#include "e_os.h"
+#include "internal/e_os.h"
 #include "internal/cryptlib.h"
 #include <stdio.h>
Index: trunk/src/libs/openssl-3.1.0/crypto/modes/Makefile.kmk
===================================================================
--- trunk/src/libs/openssl-3.1.0/crypto/modes/Makefile.kmk	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/crypto/modes/Makefile.kmk	(revision 100882)
@@ -49,5 +49,6 @@
  crypto_modes_SOURCES.amd64 += \
  	$(VBOX_PATH_CRYPTO_GENASM)/ghash-x86_64.S \
- 	$(VBOX_PATH_CRYPTO_GENASM)/aesni-gcm-x86_64.S
+ 	$(VBOX_PATH_CRYPTO_GENASM)/aesni-gcm-x86_64.S \
+ 	$(VBOX_PATH_CRYPTO_GENASM)/aes-gcm-avx512.S
 endif
 $(evalcall VBOX_OPENSSL_X86,crypto_modes)
@@ -57,14 +58,20 @@
 		$(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86.pl \
 		$(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86_64.pl \
-		$(VBOX_PATH_CRYPTO_MODES)/asm/aesni-gcm-x86_64.pl
+		$(VBOX_PATH_CRYPTO_MODES)/asm/aesni-gcm-x86_64.pl \
+		$(VBOX_PATH_CRYPTO_MODES)/asm/aes-gcm-avx512.pl
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86.pl elf -fPIC $(VBOX_PATH_CRYPTO)/genasm-elf/ghash-x86.S
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86_64.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/ghash-x86_64.S
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/aesni-gcm-x86_64.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/aesni-gcm-x86_64.S
+	perl $(VBOX_PATH_CRYPTO_MODES)/asm/aes-gcm-avx512.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/aes-gcm-avx512.S
+
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/ghash-x86.S
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86_64.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/ghash-x86_64.S
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/aesni-gcm-x86_64.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/aesni-gcm-x86_64.S
+	perl $(VBOX_PATH_CRYPTO_MODES)/asm/aes-gcm-avx512.pl elf $(VBOX_PATH_CRYPTO)/genasm-macosx/aes-gcm-avx512.S
+
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86.pl win32n $(VBOX_PATH_CRYPTO)/genasm-nasm/ghash-x86.S
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/ghash-x86_64.pl nasm $(VBOX_PATH_CRYPTO)/genasm-nasm/ghash-x86_64.S
 	perl $(VBOX_PATH_CRYPTO_MODES)/asm/aesni-gcm-x86_64.pl nasm $(VBOX_PATH_CRYPTO)/genasm-nasm/aesni-gcm-x86_64.S
+	perl $(VBOX_PATH_CRYPTO_MODES)/asm/aes-gcm-avx512.pl elf $(VBOX_PATH_CRYPTO)/genasm-nasm/aes-gcm-avx512.S
 
 include $(FILE_KBUILD_SUB_FOOTER)
Index: trunk/src/libs/openssl-3.1.0/crypto/threads_iprt.c
===================================================================
--- trunk/src/libs/openssl-3.1.0/crypto/threads_iprt.c	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/crypto/threads_iprt.c	(revision 100882)
@@ -143,4 +143,16 @@
 }
 
+int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
+{
+/** @todo Implement function */
+/*    if (*once != 0)
+        return 1;
+
+    init();
+    *once = 1;
+*/
+    return 1;
+}
+
 int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
 {
Index: trunk/src/libs/openssl-3.1.0/include/internal/sockets.h
===================================================================
--- trunk/src/libs/openssl-3.1.0/include/internal/sockets.h	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/include/internal/sockets.h	(revision 100882)
@@ -10,7 +10,5 @@
 #ifndef OSSL_INTERNAL_SOCKETS_H
 # define OSSL_INTERNAL_SOCKETS_H
-# ifndef RT_WITHOUT_PRAGMA_ONCE                                                                         /* VBOX */
 # pragma once
-# endif                                                                                                 /* VBOX */
 
 # include <openssl/opensslconf.h>
@@ -114,9 +112,4 @@
 #   define INVALID_SOCKET      (-1)
 #  endif
-
-#  ifdef RT_OS_OS2              /* VBOX */
-#   define socklen_t int        /* VBOX */
-#   undef AF_INET6              /* VBOX */
-#  endif                        /* VBOX */
 # endif
 
Index: trunk/src/libs/openssl-3.1.0/include/internal/thread_once.h
===================================================================
--- trunk/src/libs/openssl-3.1.0/include/internal/thread_once.h	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/include/internal/thread_once.h	(revision 100882)
@@ -10,7 +10,5 @@
 #ifndef OSSL_INTERNAL_THREAD_ONCE_H
 # define OSSL_INTERNAL_THREAD_ONCE_H
-# ifndef RT_WITHOUT_PRAGMA_ONCE                                                                         /* VBOX */
 # pragma once
-# endif                                                                                                 /* VBOX */
 
 # include <openssl/crypto.h>
@@ -23,5 +21,4 @@
  */
 # if !defined(FIPS_MODULE) || defined(ALLOW_RUN_ONCE_IN_FIPS)
-#  ifndef VBOX
 /*
  * DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly
@@ -119,48 +116,4 @@
     static int initalt(void)
 
-#else /* VBOX */
-
-/*
- * PFNRTONCE returns an IPRT status code but the OpenSSL once functions
- * return 1 for success and 0 for failure. We need to translate between
- * these errors back (here) and force (in RUN_ONCE()).
- */
-#  define DEFINE_RUN_ONCE(init)                                       \
-    static int init(void);                                            \
-    int init##_ossl_ret_ = 0;                                         \
-    DECLCALLBACK(int) init##_ossl_(void *pvUser)               \
-    {                                                                 \
-        init##_ossl_ret_ = init();                                    \
-        return init##_ossl_ret_ ? VINF_SUCCESS : VERR_INTERNAL_ERROR; \
-    }                                                                 \
-    static int init(void)
-
-#  define DECLARE_RUN_ONCE(init)                \
-    extern int init##_ossl_ret_;                \
-    extern DECLCALLBACK(int) init##_ossl_(void *pvUser);
-
-#  undef DEFINE_RUN_ONCE_STATIC_ALT  /* currently unused */
-
-#  define DEFINE_RUN_ONCE_STATIC(init)            \
-    static int init(void);                                            \
-    static int init##_ossl_ret_ = 0;                                  \
-    static DECLCALLBACK(int) init##_ossl_(void *pvUser)               \
-    {                                                                 \
-        init##_ossl_ret_ = init();                                    \
-        return init##_ossl_ret_ ? VINF_SUCCESS : VERR_INTERNAL_ERROR; \
-    }                                                                 \
-    static int init(void)
-
-#  define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init)            \
-    static int initalt(void);                                         \
-    static DECLCALLBACK(int) initalt##_ossl_(void *pvUser)            \
-    {                                                                 \
-        init##_ossl_ret_ = initalt();                                 \
-        return init##_ossl_ret_ ? VINF_SUCCESS : VERR_INTERNAL_ERROR; \
-    }                                                                 \
-    static int initalt(void)
-
-#endif /* VBOX */
-
 /*
  * RUN_ONCE - use CRYPTO_THREAD_run_once, and check if the init succeeded
@@ -174,5 +127,4 @@
  * (*) by convention, since the init function must return 1 on success.
  */
-#  ifndef VBOX
 #  define RUN_ONCE(once, init)                                            \
     (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)
@@ -195,13 +147,5 @@
 #  define RUN_ONCE_ALT(once, initalt, init)                               \
     (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)
-#  else
-#  define RUN_ONCE(once, init)                                                 \
-    (RT_SUCCESS_NP(RTOnce(once, init##_ossl_, NULL)) ? init##_ossl_ret_ : 0)
-
-#  define RUN_ONCE_ALT(once, initalt, init)                               \
-    (RT_SUCCESS_NP(RTOnce(once, initalt##_ossl_, NULL)) ? init##_ossl_ret_ : 0)
-#  endif /* VBOX */
 
 # endif /* FIPS_MODULE */
 #endif /* OSSL_INTERNAL_THREAD_ONCE_H */
-
Index: trunk/src/libs/openssl-3.1.0/include/internal/tsan_assist.h
===================================================================
--- trunk/src/libs/openssl-3.1.0/include/internal/tsan_assist.h	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/include/internal/tsan_assist.h	(revision 100882)
@@ -57,6 +57,5 @@
 #  define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed)
 #  define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed)
-#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)
-#  define tsan_decr(ptr) atomic_fetch_add_explicit((ptr), -1, memory_order_relaxed)
+#  define tsan_add(ptr, n) atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed)
 #  define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire)
 #  define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release)
@@ -70,6 +69,5 @@
 #  define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED)
 #  define tsan_store(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELAXED)
-#  define tsan_counter(ptr) __atomic_fetch_add((ptr), 1, __ATOMIC_RELAXED)
-#  define tsan_decr(ptr) __atomic_fetch_add((ptr), -1, __ATOMIC_RELAXED)
+#  define tsan_add(ptr, n) __atomic_fetch_add((ptr), (n), __ATOMIC_RELAXED)
 #  define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE)
 #  define tsan_st_rel(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELEASE)
@@ -114,11 +112,8 @@
 # ifdef _WIN64
 #  pragma intrinsic(_InterlockedExchangeAdd64)
-#  define tsan_counter(ptr) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((__int64 volatile *)(ptr), 1) \
-                                                 : _InterlockedExchangeAdd((long volatile *)(ptr), 1))
-#  define tsan_decr(ptr) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((__int64 volatile *)(ptr), -1) \
-                                                 : _InterlockedExchangeAdd((long volatile *)(ptr), -1))
+#  define tsan_add(ptr, n) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), (n)) \
+                                                : _InterlockedExchangeAdd((ptr), (n)))
 # else
-#  define tsan_counter(ptr) _InterlockedExchangeAdd((ptr), 1)
-#  define tsan_decr(ptr) _InterlockedExchangeAdd((ptr), -1)
+#  define tsan_add(ptr, n) _InterlockedExchangeAdd((ptr), (n))
 # endif
 # if !defined(_ISO_VOLATILE)
@@ -140,6 +135,5 @@
 # define tsan_load(ptr) (*(ptr))
 # define tsan_store(ptr, val) (*(ptr) = (val))
-# define tsan_counter(ptr) ((*(ptr))++)
-# define tsan_decr(ptr) ((*(ptr))--)
+# define tsan_add(ptr, n) (*(ptr) += (n))
 /*
  * Lack of tsan_ld_acq and tsan_ld_rel means that compiler support is not
@@ -149,2 +143,6 @@
 
 #endif
+
+#define tsan_counter(ptr) tsan_add((ptr), 1)
+#define tsan_decr(ptr) tsan_add((ptr), -1)
+
Index: trunk/src/libs/openssl-3.1.0/ssl/ssl_sess.c
===================================================================
--- trunk/src/libs/openssl-3.1.0/ssl/ssl_sess.c	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/ssl/ssl_sess.c	(revision 100882)
@@ -14,5 +14,5 @@
 #endif
 #include <stdio.h>
-#include "e_os.h"
+#include "internal/e_os.h"
 #include <openssl/rand.h>
 #include <openssl/engine.h>
Index: trunk/src/libs/openssl-3.1.0/ssl/t1_lib.c
===================================================================
--- trunk/src/libs/openssl-3.1.0/ssl/t1_lib.c	(revision 100881)
+++ trunk/src/libs/openssl-3.1.0/ssl/t1_lib.c	(revision 100882)
@@ -9,5 +9,5 @@
 
 #include <stdio.h>
-#include "e_os.h"
+#include "internal/e_os.h"
 #include <stdlib.h>
 #include <openssl/objects.h>
