From e9bb743b6b83d04c2de1b6de264f3ffbc6127c5f Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Wed, 6 Oct 2021 11:01:29 +0530
Subject: [PATCH] openssl.recipe: Back-port to 1.0.2u

Needed a bunch of patches from master, and some hacks.
---
 recipes/librtmp.recipe                        |   1 -
 .../librtmp/0003-Port-to-openssl-1.1.1.patch  | 220 -----
 recipes/openssl.recipe                        |  69 +-
 ...nfigure-Hacks-for-latest-Android-NDK.patch |  33 +
 ...ate.crt-from-PREFIX-etc-ssl-on-macOS.patch | 135 ----
 ...win-Don-t-use-disallowed-APIs-on-UWP.patch |  51 --
 ...rmv4.pl-adapt-for-use-in-Linux-kerne.patch | 179 +++++
 ....tmpl-Generate-and-install-pkgconfig.patch |  95 ---
 ...ly-pack-implement-support-for-Thumb2.patch | 757 ++++++++++++++++++
 ...ild-with-APPCONTAINER-for-UWP-compat.patch |  57 --
 ...dows-makefile.tmpl-Fix-ONECORE-build.patch |  34 -
 ....tmpl-Do-not-prefix-import-libraries.patch |  28 -
 12 files changed, 989 insertions(+), 670 deletions(-)
 delete mode 100644 recipes/librtmp/0003-Port-to-openssl-1.1.1.patch
 create mode 100644 recipes/openssl/0001-Configure-Hacks-for-latest-Android-NDK.patch
 delete mode 100644 recipes/openssl/0001-Load-ca-certificate.crt-from-PREFIX-etc-ssl-on-macOS.patch
 delete mode 100644 recipes/openssl/0001-crypto-win-Don-t-use-disallowed-APIs-on-UWP.patch
 create mode 100644 recipes/openssl/0001-sha-asm-sha512-armv4.pl-adapt-for-use-in-Linux-kerne.patch
 delete mode 100644 recipes/openssl/0001-windows-makefile.tmpl-Generate-and-install-pkgconfig.patch
 create mode 100644 recipes/openssl/0002-ARMv4-assembly-pack-implement-support-for-Thumb2.patch
 delete mode 100644 recipes/openssl/0002-win-onecore-Build-with-APPCONTAINER-for-UWP-compat.patch
 delete mode 100644 recipes/openssl/0002-windows-makefile.tmpl-Fix-ONECORE-build.patch
 delete mode 100644 recipes/openssl/0003-windows-makefile.tmpl-Do-not-prefix-import-libraries.patch

diff --git a/recipes/librtmp.recipe b/recipes/librtmp.recipe
index 85816598..6ca4f276 100644
--- a/recipes/librtmp.recipe
+++ b/recipes/librtmp.recipe
@@ -19,7 +19,6 @@ class Recipe(recipe.Recipe):
         name + '/0002-ios-Remove-flags-incompatible-with-fembed-bitcode.patch',
         # vcpkg patches, porting to openssl and fixing windows bugs, since
         # upstream is non-existent
-        name + '/0003-Port-to-openssl-1.1.1.patch',
         name + '/0004-Port-to-newer-MSVC.patch',
         name + '/0005-Fix-debug-build.patch',
         name + '/0006-Add-license-for-vcpkg-changes.patch',
diff --git a/recipes/librtmp/0003-Port-to-openssl-1.1.1.patch b/recipes/librtmp/0003-Port-to-openssl-1.1.1.patch
deleted file mode 100644
index c7fd13d7..00000000
--- a/recipes/librtmp/0003-Port-to-openssl-1.1.1.patch
+++ /dev/null
@@ -1,220 +0,0 @@
-From 510ef57a1106f9542e8598dc861880a2b3204f51 Mon Sep 17 00:00:00 2001
-From: Nirbheek Chauhan <nirbheek@centricular.com>
-Date: Sat, 29 Feb 2020 04:06:38 +0530
-Subject: [PATCH 3/6] Port to openssl-1.1.1
-
-Patches by Neumann-A at vcpkg:
-https://github.com/microsoft/vcpkg/pull/8566/commits/6ccdbe4cb490b5dc444d96e5a0358bb5bacdfbfd
-
-Latest version of patches are:
-https://github.com/microsoft/vcpkg/blob/master/ports/librtmp/dh.patch
-https://github.com/microsoft/vcpkg/blob/master/ports/librtmp/handshake.patch
-https://github.com/microsoft/vcpkg/blob/master/ports/librtmp/hashswf.patch
----
- librtmp/dh.h        | 57 ++++++++++++++++++++++++++++-----------------
- librtmp/handshake.h | 10 ++++----
- librtmp/hashswf.c   | 10 ++++----
- 3 files changed, 46 insertions(+), 31 deletions(-)
-
-diff --git a/librtmp/dh.h b/librtmp/dh.h
-index 5fc3f32..a5dead5 100644
---- a/librtmp/dh.h
-+++ b/librtmp/dh.h
-@@ -181,11 +181,14 @@ typedef BIGNUM * MP_t;
- #define MP_setbin(u,buf,len)	BN_bn2bin(u,buf)
- #define MP_getbin(u,buf,len)	u = BN_bin2bn(buf,len,0)
- 
-+
- #define MDH	DH
- #define MDH_new()	DH_new()
- #define MDH_free(dh)	DH_free(dh)
- #define MDH_generate_key(dh)	DH_generate_key(dh)
- #define MDH_compute_key(secret, seclen, pub, dh)	DH_compute_key(secret, pub, dh)
-+#define MPH_set_pqg(dh, p, q, g, res)  res = DH_set0_pqg(dh, p, q, g)
-+#define MPH_set_length(dh, len, res)  res = DH_set_length(dh,len)
- 
- #endif
- 
-@@ -194,7 +197,7 @@ typedef BIGNUM * MP_t;
- 
- /* RFC 2631, Section 2.1.5, http://www.ietf.org/rfc/rfc2631.txt */
- static int
--isValidPublicKey(MP_t y, MP_t p, MP_t q)
-+isValidPublicKey(const MP_t y,const MP_t p, MP_t q)
- {
-   int ret = TRUE;
-   MP_t bn;
-@@ -253,20 +256,33 @@ DHInit(int nKeyBits)
-   if (!dh)
-     goto failed;
- 
--  MP_new(dh->g);
-+  MP_t g,p;
-+  MP_new(g);
- 
--  if (!dh->g)
-+  if (!g) 
-+  {
-     goto failed;
-+  }
- 
--  MP_gethex(dh->p, P1024, res);	/* prime P1024, see dhgroups.h */
-+  DH_get0_pqg(dh, (BIGNUM const**)&p, NULL, NULL);
-+  MP_gethex(p, P1024, res);	/* prime P1024, see dhgroups.h */
-   if (!res)
-     {
-       goto failed;
-     }
- 
--  MP_set_w(dh->g, 2);	/* base 2 */
--
--  dh->length = nKeyBits;
-+  MP_set_w(g, 2);	/* base 2 */
-+  MPH_set_pqg(dh,p,NULL,g, res);
-+  if (!res)
-+  {
-+    MP_free(g);
-+    goto failed;
-+  }
-+  MPH_set_length(dh,nKeyBits, res);
-+  if (!res)
-+  {
-+    goto failed;
-+  }
-   return dh;
- 
- failed:
-@@ -292,14 +308,11 @@ DHGenerateKey(MDH *dh)
- 
-       MP_gethex(q1, Q1024, res);
-       assert(res);
--
--      res = isValidPublicKey(dh->pub_key, dh->p, q1);
-+      res = isValidPublicKey(DH_get0_pub_key(dh), DH_get0_p(dh), q1);
-       if (!res)
--	{
--	  MP_free(dh->pub_key);
--	  MP_free(dh->priv_key);
--	  dh->pub_key = dh->priv_key = 0;
--	}
-+        {
-+              MDH_free(dh); // Cannot set priv_key to nullptr so there is no way to generate a new pub/priv key pair in openssl 1.1.1.
-+        }
- 
-       MP_free(q1);
-     }
-@@ -314,15 +327,16 @@ static int
- DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen)
- {
-   int len;
--  if (!dh || !dh->pub_key)
-+  MP_t pub = DH_get0_pub_key(dh);
-+  if (!dh || !pub)
-     return 0;
- 
--  len = MP_bytes(dh->pub_key);
-+  len = MP_bytes(pub);
-   if (len <= 0 || len > (int) nPubkeyLen)
-     return 0;
- 
-   memset(pubkey, 0, nPubkeyLen);
--  MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len);
-+  MP_setbin(pub, pubkey + (nPubkeyLen - len), len);
-   return 1;
- }
- 
-@@ -330,15 +344,16 @@ DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen)
- static int
- DHGetPrivateKey(MDH *dh, uint8_t *privkey, size_t nPrivkeyLen)
- {
--  if (!dh || !dh->priv_key)
-+  MP_t priv = DH_get0_priv_key(dh);
-+  if (!dh || !priv)
-     return 0;
- 
--  int len = MP_bytes(dh->priv_key);
-+  int len = MP_bytes(priv);
-   if (len <= 0 || len > (int) nPrivkeyLen)
-     return 0;
- 
-   memset(privkey, 0, nPrivkeyLen);
--  MP_setbin(dh->priv_key, privkey + (nPrivkeyLen - len), len);
-+  MP_setbin(priv, privkey + (nPrivkeyLen - len), len);
-   return 1;
- }
- #endif
-@@ -364,7 +379,7 @@ DHComputeSharedSecretKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen,
-   MP_gethex(q1, Q1024, len);
-   assert(len);
- 
--  if (isValidPublicKey(pubkeyBn, dh->p, q1))
-+  if (isValidPublicKey(pubkeyBn, DH_get0_p(dh), q1))
-     res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh);
-   else
-     res = -1;
-diff --git a/librtmp/handshake.h b/librtmp/handshake.h
-index 0438486..5313943 100644
---- a/librtmp/handshake.h
-+++ b/librtmp/handshake.h
-@@ -69,9 +69,9 @@ typedef struct arcfour_ctx*	RC4_handle;
- #if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH)
- #error Your OpenSSL is too old, need 0.9.8 or newer with SHA256
- #endif
--#define HMAC_setup(ctx, key, len)	HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
--#define HMAC_crunch(ctx, buf, len)	HMAC_Update(&ctx, buf, len)
--#define HMAC_finish(ctx, dig, dlen)	HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx)
-+#define HMAC_setup(ctx, key, len)	ctx = HMAC_CTX_new(); HMAC_Init_ex(ctx, key, len, EVP_sha256(), 0)
-+#define HMAC_crunch(ctx, buf, len)	HMAC_Update(ctx, buf, len)
-+#define HMAC_finish(ctx, dig, dlen)	HMAC_Final(ctx, dig, &dlen); HMAC_CTX_free(ctx)
- 
- typedef RC4_KEY *	RC4_handle;
- #define RC4_alloc(h)	*h = malloc(sizeof(RC4_KEY))
-@@ -117,7 +117,7 @@ static void InitRC4Encryption
- {
-   uint8_t digest[SHA256_DIGEST_LENGTH];
-   unsigned int digestLen = 0;
--  HMAC_CTX ctx;
-+  HMAC_CTX *ctx;
- 
-   RC4_alloc(rc4keyIn);
-   RC4_alloc(rc4keyOut);
-@@ -266,7 +266,7 @@ HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key,
- 	   size_t keylen, uint8_t *digest)
- {
-   unsigned int digestLen;
--  HMAC_CTX ctx;
-+  HMAC_CTX *ctx;
- 
-   HMAC_setup(ctx, key, keylen);
-   HMAC_crunch(ctx, message, messageLen);
-diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
-index 32b2eed..537e571 100644
---- a/librtmp/hashswf.c
-+++ b/librtmp/hashswf.c
-@@ -57,10 +57,10 @@
- #include <openssl/sha.h>
- #include <openssl/hmac.h>
- #include <openssl/rc4.h>
--#define HMAC_setup(ctx, key, len)	HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, (unsigned char *)key, len, EVP_sha256(), 0)
--#define HMAC_crunch(ctx, buf, len)	HMAC_Update(&ctx, (unsigned char *)buf, len)
--#define HMAC_finish(ctx, dig, dlen)	HMAC_Final(&ctx, (unsigned char *)dig, &dlen);
--#define HMAC_close(ctx)	HMAC_CTX_cleanup(&ctx)
-+#define HMAC_setup(ctx, key, len)	ctx = HMAC_CTX_new(); HMAC_Init_ex(ctx, (unsigned char *)key, len, EVP_sha256(), 0)
-+#define HMAC_crunch(ctx, buf, len)	HMAC_Update(ctx, (unsigned char *)buf, len)
-+#define HMAC_finish(ctx, dig, dlen)	HMAC_Final(ctx, (unsigned char *)dig, &dlen);
-+#define HMAC_close(ctx)	HMAC_CTX_free(ctx)
- #endif
- 
- extern void RTMP_TLS_Init();
-@@ -298,7 +298,7 @@ leave:
- struct info
- {
-   z_stream *zs;
--  HMAC_CTX ctx;
-+  HMAC_CTX *ctx;
-   int first;
-   int zlib;
-   int size;
--- 
-2.24.1
-
diff --git a/recipes/openssl.recipe b/recipes/openssl.recipe
index db3d68e8..a1627403 100644
--- a/recipes/openssl.recipe
+++ b/recipes/openssl.recipe
@@ -8,11 +8,11 @@ class Recipe(recipe.Recipe):
     # Note: openssl helpfully moves tarballs somewhere else (old/x.y.z/)
     # whenever a new release comes out, so make sure to mirror to fdo when
     # bumping the release!
-    version = '1.1.1k'
+    version = '1.0.2u'
     licenses = [{License.OPENSSL: ['LICENSE']}]
     stype = SourceType.TARBALL
-    url = 'https://ftp.openssl.org/source/{0}-{1}.tar.gz'.format(name, version)
-    tarball_checksum = '892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5'
+    url = 'https://ftp.openssl.org/source/old/1.0.2/{0}-{1}.tar.gz'.format(name, version)
+    tarball_checksum = 'ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16'
     deps = ['ca-certificates', 'zlib']
     # Parallel make fails randomly due to undefined macros, probably races
     allow_parallel_build = False
@@ -21,23 +21,17 @@ class Recipe(recipe.Recipe):
     # Can build for MSVC and UWP
     can_msvc = True
 
-    patches = [
-        # Portable prefix with SSL certs
-        'openssl/0001-Load-ca-certificate.crt-from-PREFIX-etc-ssl-on-macOS.patch',
-        # MSVC and UWP support
-        'openssl/0001-windows-makefile.tmpl-Generate-and-install-pkgconfig.patch',
-        'openssl/0002-windows-makefile.tmpl-Fix-ONECORE-build.patch',
-        'openssl/0003-windows-makefile.tmpl-Do-not-prefix-import-libraries.patch',
-        # https://github.com/openssl/openssl/pull/12400
-        'openssl/0001-crypto-win-Don-t-use-disallowed-APIs-on-UWP.patch',
-        'openssl/0002-win-onecore-Build-with-APPCONTAINER-for-UWP-compat.patch',
-    ]
-
     files_bins = ['openssl']
     files_libs = ['libcrypto', 'libssl']
     files_devel = ['include/openssl', 'lib/pkgconfig/openssl.pc',
                    'lib/pkgconfig/libssl.pc', 'lib/pkgconfig/libcrypto.pc']
 
+    patches = [
+        name + '/0001-sha-asm-sha512-armv4.pl-adapt-for-use-in-Linux-kerne.patch',
+        name + '/0002-ARMv4-assembly-pack-implement-support-for-Thumb2.patch',
+        name + '/0001-Configure-Hacks-for-latest-Android-NDK.patch',
+    ]
+
     def _get_openssl_platform(self):
         # map platforms
         if self.config.target_platform == Platform.IOS:
@@ -57,13 +51,13 @@ class Recipe(recipe.Recipe):
             if self.config.target_arch == Architecture.ARM:
                 return 'android-arm'
             if self.config.target_arch == Architecture.ARMv7:
-                return 'android-arm'
+                return 'android-armv7'
             if self.config.target_arch == Architecture.ARM64:
-                return 'android-arm64'
+                return 'android64-aarch64'
             if self.config.target_arch == Architecture.X86:
                 return 'android-x86'
             if self.config.target_arch == Architecture.X86_64:
-                return 'android-x86_64'
+                return 'android'
             raise InvalidRecipeError(self, "Unknown Android platform")
         if self.config.target_platform == Platform.DARWIN:
             if self.config.target_arch == Architecture.X86:
@@ -86,27 +80,10 @@ class Recipe(recipe.Recipe):
                 return 'linux-aarch64'
             raise InvalidRecipeError(self, "Unknown Linux platform")
         if self.config.target_platform == Platform.WINDOWS:
-            if self.using_uwp():
-                if self.config.target_arch == Architecture.X86:
-                    return 'VC-WIN32-ONECORE'
-                if self.config.target_arch == Architecture.X86_64:
-                    return 'VC-WIN64A-ONECORE'
-                if self.config.target_arch == Architecture.ARM:
-                    return 'VC-WIN32-ARM'
-                if self.config.target_arch == Architecture.ARMv7:
-                    return 'VC-WIN32-ARM'
-                if self.config.target_arch == Architecture.ARM64:
-                    return 'VC-WIN64-ARM'
-            elif self.using_msvc():
-                if self.config.target_arch == Architecture.X86:
-                    return 'VC-WIN32'
-                if self.config.target_arch == Architecture.X86_64:
-                    return 'VC-WIN64A'
-            else:
-                if self.config.target_arch == Architecture.X86:
-                    return 'mingw'
-                if self.config.target_arch == Architecture.X86_64:
-                    return 'mingw64'
+            if self.config.target_arch == Architecture.X86:
+                return 'mingw'
+            if self.config.target_arch == Architecture.X86_64:
+                return 'mingw64'
             raise InvalidRecipeError(self, "Unknown Windows platform")
         raise InvalidRecipeError(self, "Unknown target platform {}"
                                  .format(self.config.target_platform))
@@ -129,10 +106,10 @@ class Recipe(recipe.Recipe):
             self.make = ['nmake', 'CFLAG=' + cflags, 'LDFLAG=' + ldflags]
             self.make_install = ['nmake', 'install_sw']
         else:
-            cflags += '-fPIC -DOPENSSL_PIC'
-            ldflags += '-fPIC'
+            cflags += ' -fPIC -DOPENSSL_PIC'
+            ldflags += ' -fPIC'
             ranlib = self.get_env('RANLIB')
-            ar = self.get_env('AR')
+            ar = self.get_env('AR') + ' r'
             # Need to add CFLAGS to CC because CFLAG is not used everywhere in the
             # build, and we can't pass arguments via Configure because on Darwin,
             # Configure reads the `-arch x86_64` as meaning that you want to use
@@ -140,15 +117,9 @@ class Recipe(recipe.Recipe):
             cc = self.get_env('CC') + ' ' + self.get_env('CFLAGS')
             ld = self.get_env('LD') + ' ' + self.get_env('LDFLAGS')
             # NOTE: CFLAG and LDFLAG are not typos!
-            self.make += ['AR=' + ar, 'RANLIB=' + ranlib, 'CC=' + cc, 'LD=' + ld,
-                          'CFLAG=' + cflags, 'LDFLAG=' + ldflags]
+            self.make += ['AR=' + ar, 'RANLIB=' + ranlib, 'CC=' + cc, 'LD=' + ld]
             self.make_install = ['make', 'install_sw', 'RANLIB=' + ranlib]
 
-        # We probably don't need and can't use the tools on these platforms
-        if self.config.target_platform in (Platform.IOS, Platform.ANDROID):
-            self.make += ['build_libs', 'openssl.pc', 'libssl.pc', 'libcrypto.pc']
-            self.make_install = ['make', 'install_dev', 'RANLIB=' + ranlib]
-
         if self.config.platform == Platform.WINDOWS:
             # Msys ships with a too-old perl, so we modify PATH to use the
             # mingw-perl that was downloaded and installed by bootstrap.
diff --git a/recipes/openssl/0001-Configure-Hacks-for-latest-Android-NDK.patch b/recipes/openssl/0001-Configure-Hacks-for-latest-Android-NDK.patch
new file mode 100644
index 00000000..c5a76801
--- /dev/null
+++ b/recipes/openssl/0001-Configure-Hacks-for-latest-Android-NDK.patch
@@ -0,0 +1,33 @@
+From 6f3249497eb32504a501083d2af1598a165dd218 Mon Sep 17 00:00:00 2001
+From: Nirbheek Chauhan <nirbheek@centricular.com>
+Date: Wed, 6 Oct 2021 10:20:40 +0530
+Subject: [PATCH] Configure: Hacks for latest Android NDK
+
+---
+ Configure | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/Configure b/Configure
+index 494e0b3d24..0494f0a352 100755
+--- a/Configure
++++ b/Configure
+@@ -471,11 +471,11 @@ my %table=(
+ "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}",
+ 
+ # Android: linux-* but without pointers to headers and libs.
+-"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+-"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+-"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+-"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+-"android64-aarch64","gcc:-mandroid -fPIC -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-pie%-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"android","gcc:-I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"android-x86","gcc:-I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"android-armv7","gcc:-march=armv7-a -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"android-mips","gcc:-I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
++"android64-aarch64","gcc:-fPIC -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-pie%-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+ 
+ #### *BSD [do see comment about ${BSDthreads} above!]
+ "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+-- 
+2.31.1
+
diff --git a/recipes/openssl/0001-Load-ca-certificate.crt-from-PREFIX-etc-ssl-on-macOS.patch b/recipes/openssl/0001-Load-ca-certificate.crt-from-PREFIX-etc-ssl-on-macOS.patch
deleted file mode 100644
index 421bb6b8..00000000
--- a/recipes/openssl/0001-Load-ca-certificate.crt-from-PREFIX-etc-ssl-on-macOS.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-From 903e3b9db2a2425a75f36df4edcc40876e9a0ada Mon Sep 17 00:00:00 2001
-From: Cerbero Build System <cerbero@gstreamer.freedesktop.org>
-Date: Tue, 31 Mar 2020 12:41:07 +0530
-Subject: [PATCH] Load ca-certificate.crt from PREFIX/etc/ssl on macOS and
- Windows
-
-PREFIX is automatically detected based on the location of the crypto
-library.
----
- crypto/dllmain.c      | 31 +++++++++++++++++++++++++++++++
- crypto/x509/by_file.c | 41 ++++++++++++++++++++++++++++++++++++++++-
- 2 files changed, 71 insertions(+), 1 deletion(-)
-
-diff --git a/crypto/dllmain.c b/crypto/dllmain.c
-index e821789..67568e3 100644
---- a/crypto/dllmain.c
-+++ b/crypto/dllmain.c
-@@ -20,6 +20,36 @@
-  */
- # endif
- 
-+HMODULE __priv_crypto_dll_handle = NULL;
-+
-+char *
-+_get_portable_X509_cert_file (void)
-+{
-+    int ret;
-+    char *p;
-+    char filename[MAX_PATH];
-+    char certfile[MAX_PATH];
-+
-+    /* Get absolute location of crypto.dll: PREFIX/bin/crypto.dll */
-+    if (!GetModuleFileNameA(__priv_crypto_dll_handle, filename, MAX_PATH))
-+        return NULL;
-+
-+    /* Get DLL directory: PREFIX/bin */
-+    if ((p = strrchr(filename, '\\')) == NULL)
-+        return NULL;
-+    *p = '\0';
-+
-+    /* Get parent directory: PREFIX */
-+    if ((p = strrchr(filename, '\\')) == NULL)
-+        return NULL;
-+    *p = '\0';
-+
-+    /* Path to the cert bundle; filename is from the ca-certificates recipe */
-+    if (_snprintf(certfile, MAX_PATH, "%s\\etc\\ssl\\certs\\ca-certificates.crt", filename) < 0)
-+        return NULL;
-+    return _strdup(certfile);
-+}
-+
- /*
-  * All we really need to do is remove the 'error' state when a thread
-  * detaches
-@@ -31,6 +61,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-     switch (fdwReason) {
-     case DLL_PROCESS_ATTACH:
-         OPENSSL_cpuid_setup();
-+        __priv_crypto_dll_handle = (HMODULE) hinstDLL;
-         break;
-     case DLL_THREAD_ATTACH:
-         break;
-diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c
-index 237b362..25ce782 100644
---- a/crypto/x509/by_file.c
-+++ b/crypto/x509/by_file.c
-@@ -17,6 +17,40 @@
- #include <openssl/pem.h>
- #include "x509_local.h"
- 
-+#ifdef _WIN32
-+/* defined in crypto/dllmain.c */
-+char* _get_portable_X509_cert_file (void);
-+#elif defined(__APPLE__)
-+#include <dlfcn.h>
-+char *
-+_get_portable_X509_cert_file (void)
-+{
-+    char *p;
-+    char certfile[PATH_MAX];
-+
-+    Dl_info info;
-+    if (!dladdr(_get_portable_X509_cert_file, &info))
-+        return NULL;
-+
-+    /* Get dylib directory: PREFIX/lib */
-+    if ((p = strrchr(info.dli_fname, '/')) == NULL)
-+        return NULL;
-+    *p = '\0';
-+
-+    /* Get parent directory: PREFIX */
-+    if ((p = strrchr(info.dli_fname, '/')) == NULL)
-+        return NULL;
-+    *p = '\0';
-+
-+    /* Path to the cert bundle; filename is from the ca-certificates recipe */
-+    if (snprintf(certfile, PATH_MAX, "%s/etc/ssl/certs/ca-certificates.crt", info.dli_fname) < 0)
-+        return NULL;
-+    return strdup(certfile);
-+}
-+#else
-+#define _get_portable_X509_cert_file() NULL
-+#endif
-+
- static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
-                         long argl, char **ret);
- static X509_LOOKUP_METHOD x509_file_lookup = {
-@@ -46,11 +80,15 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp,
-     switch (cmd) {
-     case X509_L_FILE_LOAD:
-         if (argl == X509_FILETYPE_DEFAULT) {
-+            char *portable_file;
-             file = ossl_safe_getenv(X509_get_default_cert_file_env());
-+            portable_file = _get_portable_X509_cert_file();
-             if (file)
-                 ok = (X509_load_cert_crl_file(ctx, file,
-                                               X509_FILETYPE_PEM) != 0);
--
-+            else if (portable_file)
-+                ok = (X509_load_cert_crl_file(ctx, portable_file,
-+                                              X509_FILETYPE_PEM) != 0);
-             else
-                 ok = (X509_load_cert_crl_file
-                       (ctx, X509_get_default_cert_file(),
-@@ -59,6 +97,7 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp,
-             if (!ok) {
-                 X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS);
-             }
-+            free (portable_file);
-         } else {
-             if (argl == X509_FILETYPE_PEM)
-                 ok = (X509_load_cert_crl_file(ctx, argp,
--- 
-2.21.1 (Apple Git-122.3)
-
diff --git a/recipes/openssl/0001-crypto-win-Don-t-use-disallowed-APIs-on-UWP.patch b/recipes/openssl/0001-crypto-win-Don-t-use-disallowed-APIs-on-UWP.patch
deleted file mode 100644
index 5653c38c..00000000
--- a/recipes/openssl/0001-crypto-win-Don-t-use-disallowed-APIs-on-UWP.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From f198066024d3371be78819b18e737caf63a26aa0 Mon Sep 17 00:00:00 2001
-From: Nirbheek Chauhan <nirbheek@centricular.com>
-Date: Wed, 8 Jul 2020 23:10:34 +0530
-Subject: [PATCH 1/2] crypto/win: Don't use disallowed APIs on UWP
-
-CreateFiber and ConvertThreadToFiber are not allowed in Windows Store
-(Universal Windows Platform) apps since they have been replaced by
-their Ex variants which have a new dwFlags parameter.
-
-This flag allows the fiber to do floating-point arithmetic in the
-fiber on x86, which would silently cause corruption otherwise since
-the floating-point state is not switched by default.
-
-Switch to these "new" APIs which were added in Vista.
-
-See: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createfiberex#parameters
----
- crypto/async/arch/async_win.c | 2 +-
- crypto/async/arch/async_win.h | 3 ++-
- 2 files changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/crypto/async/arch/async_win.c b/crypto/async/arch/async_win.c
-index 1f360d8..30aa018 100644
---- a/crypto/async/arch/async_win.c
-+++ b/crypto/async/arch/async_win.c
-@@ -34,7 +34,7 @@ void async_local_cleanup(void)
- 
- int async_fibre_init_dispatcher(async_fibre *fibre)
- {
--    fibre->fibre = ConvertThreadToFiber(NULL);
-+    fibre->fibre = ConvertThreadToFiberEx(NULL, FIBER_FLAG_FLOAT_SWITCH);
-     if (fibre->fibre == NULL) {
-         fibre->converted = 0;
-         fibre->fibre = GetCurrentFiber();
-diff --git a/crypto/async/arch/async_win.h b/crypto/async/arch/async_win.h
-index 61cfdd7..9f09caa 100644
---- a/crypto/async/arch/async_win.h
-+++ b/crypto/async/arch/async_win.h
-@@ -27,7 +27,8 @@ typedef struct async_fibre_st {
- # define async_fibre_swapcontext(o,n,r) \
-         (SwitchToFiber((n)->fibre), 1)
- # define async_fibre_makecontext(c) \
--        ((c)->fibre = CreateFiber(0, async_start_func_win, 0))
-+        ((c)->fibre = CreateFiberEx(0, 0, FIBER_FLAG_FLOAT_SWITCH, \
-+                async_start_func_win, 0))
- # define async_fibre_free(f)             (DeleteFiber((f)->fibre))
- 
- int async_fibre_init_dispatcher(async_fibre *fibre);
--- 
-2.26.2
-
diff --git a/recipes/openssl/0001-sha-asm-sha512-armv4.pl-adapt-for-use-in-Linux-kerne.patch b/recipes/openssl/0001-sha-asm-sha512-armv4.pl-adapt-for-use-in-Linux-kerne.patch
new file mode 100644
index 00000000..bfcbdc64
--- /dev/null
+++ b/recipes/openssl/0001-sha-asm-sha512-armv4.pl-adapt-for-use-in-Linux-kerne.patch
@@ -0,0 +1,179 @@
+From 4af9f6f3cea09af281074a1948d46d5c312a1a26 Mon Sep 17 00:00:00 2001
+From: Andy Polyakov <appro@openssl.org>
+Date: Sat, 28 Mar 2015 15:27:34 +0100
+Subject: [PATCH 1/2] sha/asm/sha512-armv4.pl: adapt for use in Linux kernel
+ context.
+
+Follow-up to sha256-armv4.pl in cooperation with Ard Biesheuvel
+(Linaro) and Sami Tolvanen (Google).
+
+Reviewed-by: Rich Salz <rsalz@openssl.org>
+---
+ crypto/sha/asm/sha512-armv4.pl | 65 +++++++++++++++++++++++++++++-----
+ 1 file changed, 56 insertions(+), 9 deletions(-)
+
+diff --git a/crypto/sha/asm/sha512-armv4.pl b/crypto/sha/asm/sha512-armv4.pl
+index fb7dc50..7e540f8 100644
+--- a/crypto/sha/asm/sha512-armv4.pl
++++ b/crypto/sha/asm/sha512-armv4.pl
+@@ -5,6 +5,8 @@
+ # project. The module is, however, dual licensed under OpenSSL and
+ # CRYPTOGAMS licenses depending on where you obtain it. For further
+ # details see http://www.openssl.org/~appro/cryptogams/.
++#
++# Permission to use under GPL terms is granted.
+ # ====================================================================
+ 
+ # SHA512 block procedure for ARMv4. September 2007.
+@@ -143,6 +145,9 @@ $code.=<<___;
+ 	teq	$t0,#$magic
+ 
+ 	ldr	$t3,[sp,#$Coff+0]	@ c.lo
++#if __ARM_ARCH__>=7
++	it	eq			@ Thumb2 thing, sanity check in ARM
++#endif
+ 	orreq	$Ktbl,$Ktbl,#1
+ 	@ Sigma0(x)	(ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39))
+ 	@ LO		lo>>28^hi<<4  ^ hi>>2^lo<<30 ^ hi>>7^lo<<25
+@@ -180,7 +185,17 @@ $code.=<<___;
+ ___
+ }
+ $code=<<___;
+-#include "arm_arch.h"
++#ifndef __KERNEL__
++# include "arm_arch.h"
++# define VFP_ABI_PUSH	vstmdb	sp!,{d8-d15}
++# define VFP_ABI_POP	vldmia	sp!,{d8-d15}
++#else
++# define __ARM_ARCH__ __LINUX_ARM_ARCH__
++# define __ARM_MAX_ARCH__ 7
++# define VFP_ABI_PUSH
++# define VFP_ABI_POP
++#endif
++
+ #ifdef __ARMEL__
+ # define LO 0
+ # define HI 4
+@@ -192,7 +207,18 @@ $code=<<___;
+ #endif
+ 
+ .text
++#if __ARM_ARCH__<7
+ .code	32
++#else
++.syntax unified
++# ifdef __thumb2__
++#  define adrl adr
++.thumb
++# else
++.code   32
++# endif
++#endif
++
+ .type	K512,%object
+ .align	5
+ K512:
+@@ -237,7 +263,7 @@ WORD64(0x3c9ebe0a,0x15c9bebc, 0x431d67c4,0x9c100d4c)
+ WORD64(0x4cc5d4be,0xcb3e42b6, 0x597f299c,0xfc657e2a)
+ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817)
+ .size	K512,.-K512
+-#if __ARM_MAX_ARCH__>=7
++#if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__)
+ .LOPENSSL_armcap:
+ .word	OPENSSL_armcap_P-sha512_block_data_order
+ .skip	32-4
+@@ -248,14 +274,18 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817)
+ .global	sha512_block_data_order
+ .type	sha512_block_data_order,%function
+ sha512_block_data_order:
++#if __ARM_ARCH__<7
+ 	sub	r3,pc,#8		@ sha512_block_data_order
+-	add	$len,$inp,$len,lsl#7	@ len to point at the end of inp
+-#if __ARM_MAX_ARCH__>=7
++#else
++	adr	r3,sha512_block_data_order
++#endif
++#if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__)
+ 	ldr	r12,.LOPENSSL_armcap
+ 	ldr	r12,[r3,r12]		@ OPENSSL_armcap_P
+ 	tst	r12,#1
+ 	bne	.LNEON
+ #endif
++	add	$len,$inp,$len,lsl#7	@ len to point at the end of inp
+ 	stmdb	sp!,{r4-r12,lr}
+ 	sub	$Ktbl,r3,#672		@ K512
+ 	sub	sp,sp,#9*8
+@@ -369,6 +399,9 @@ $code.=<<___;
+ ___
+ 	&BODY_00_15(0x17);
+ $code.=<<___;
++#if __ARM_ARCH__>=7
++	ittt	eq			@ Thumb2 thing, sanity check in ARM
++#endif
+ 	ldreq	$t0,[sp,#`$Xoff+8*(16-1)`+0]
+ 	ldreq	$t1,[sp,#`$Xoff+8*(16-1)`+4]
+ 	beq	.L16_79
+@@ -453,6 +486,7 @@ $code.=<<___;
+ 	moveq	pc,lr			@ be binary compatible with V4, yet
+ 	bx	lr			@ interoperable with Thumb ISA:-)
+ #endif
++.size	sha512_block_data_order,.-sha512_block_data_order
+ ___
+ 
+ {
+@@ -559,11 +593,15 @@ $code.=<<___;
+ .arch	armv7-a
+ .fpu	neon
+ 
++.global	sha512_block_data_order_neon
++.type	sha512_block_data_order_neon,%function
+ .align	4
++sha512_block_data_order_neon:
+ .LNEON:
+ 	dmb				@ errata #451034 on early Cortex A8
+-	vstmdb	sp!,{d8-d15}		@ ABI specification says so
+-	sub	$Ktbl,r3,#672		@ K512
++	add	$len,$inp,$len,lsl#7	@ len to point at the end of inp
++	VFP_ABI_PUSH
++	adrl	$Ktbl,K512
+ 	vldmia	$ctx,{$A-$H}		@ load context
+ .Loop_neon:
+ ___
+@@ -588,16 +626,16 @@ $code.=<<___;
+ 	sub		$Ktbl,#640	@ rewind K512
+ 	bne		.Loop_neon
+ 
+-	vldmia	sp!,{d8-d15}		@ epilogue
++	VFP_ABI_POP
+ 	ret				@ bx lr
++.size	sha512_block_data_order_neon,.-sha512_block_data_order_neon
+ #endif
+ ___
+ }
+ $code.=<<___;
+-.size	sha512_block_data_order,.-sha512_block_data_order
+ .asciz	"SHA512 block transform for ARMv4/NEON, CRYPTOGAMS by <appro\@openssl.org>"
+ .align	2
+-#if __ARM_MAX_ARCH__>=7
++#if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__)
+ .comm	OPENSSL_armcap_P,4,4
+ #endif
+ ___
+@@ -605,5 +643,14 @@ ___
+ $code =~ s/\`([^\`]*)\`/eval $1/gem;
+ $code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm;	# make it possible to compile with -march=armv4
+ $code =~ s/\bret\b/bx	lr/gm;
++
++open SELF,$0;
++while(<SELF>) {
++	next if (/^#!/);
++	last if (!s/^#/@/ and !/^$/);
++	print;
++}
++close SELF;
++
+ print $code;
+ close STDOUT; # enforce flush
+-- 
+2.31.1
+
diff --git a/recipes/openssl/0001-windows-makefile.tmpl-Generate-and-install-pkgconfig.patch b/recipes/openssl/0001-windows-makefile.tmpl-Generate-and-install-pkgconfig.patch
deleted file mode 100644
index 723dd2d1..00000000
--- a/recipes/openssl/0001-windows-makefile.tmpl-Generate-and-install-pkgconfig.patch
+++ /dev/null
@@ -1,95 +0,0 @@
-From 96881a7b26d569b08dc5847204856ebb5fc532f9 Mon Sep 17 00:00:00 2001
-From: Nirbheek Chauhan <nirbheek@centricular.com>
-Date: Tue, 9 Jun 2020 15:14:32 +0530
-Subject: [PATCH] windows-makefile.tmpl: Generate and install pkgconfig files
-
-Copied from unix-makefile.tmpl
----
- Configurations/windows-makefile.tmpl | 50 +++++++++++++++++++++++++++-
- 1 file changed, 49 insertions(+), 1 deletion(-)
-
-diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
-index 8ef70b8..bc1e199 100644
---- a/Configurations/windows-makefile.tmpl
-+++ b/Configurations/windows-makefile.tmpl
-@@ -314,7 +314,7 @@ PROCESSOR= {- $config{processor} -}
- {- dependmagic('build_programs'); -}: build_programs_nodep
- 
- build_generated: $(GENERATED_MANDATORY)
--build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
-+build_libs_nodep: libcrypto.pc libssl.pc openssl.pc $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
- build_engines_nodep: $(ENGINES)
- build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
- 
-@@ -371,6 +371,7 @@ clean: libclean
- 	-del /Q /S /F engines\*.lib engines\*.exp
- 	-del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
- 	-del /Q /S /F test\*.exp
-+	-del /Q /S /F openssl.pc libcrypto.pc libssl.pc
- 	-rmdir /Q /S test\test-runs
- 
- distclean: clean
-@@ -426,6 +427,14 @@ install_dev: install_runtime_libs
- 	@"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
- 	@if "$(SHLIBS)"=="" \
- 	 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
-+	@ : {- output_on() if $disabled{shared}; "" -}
-+	@$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(libdir)\pkgconfig"
-+	@$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)\pkgconfig\libcrypto.pc"
-+	@"$(PERL)" "$(SRCDIR)\util\copy.pl" libcrypto.pc "$(DESTDIR)$(libdir)\pkgconfig"
-+	@$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)\pkgconfig\libssl.pc"
-+	@"$(PERL)" "$(SRCDIR)\util\copy.pl" libssl.pc "$(DESTDIR)$(libdir)\pkgconfig"
-+	@$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)\pkgconfig\openssl.pc"
-+	@"$(PERL)" "$(SRCDIR)\util\copy.pl" openssl.pc "$(DESTDIR)$(libdir)\pkgconfig"
- 
- uninstall_dev:
- 
-@@ -472,6 +481,45 @@ install_html_docs:
- uninstall_html_docs:
- 
- # Building targets ###################################################
-+#
-+libcrypto.pc libssl.pc openssl.pc: configdata.pm
-+libcrypto.pc:
-+	@$(ECHO) "prefix=$(INSTALLTOP)" > libcrypto.pc
-+	@$(ECHO) "exec_prefix=$${prefix}" >> libcrypto.pc
-+	@$(ECHO) "libdir=$${exec_prefix}/$(LIBDIR)" >> libcrypto.pc
-+	@$(ECHO) "includedir=$${prefix}/include" >> libcrypto.pc
-+	@$(ECHO) "enginesdir=$${libdir}/engines-{- $sover_dirname -}" >> libcrypto.pc
-+	@$(ECHO) "" >> libcrypto.pc
-+	@$(ECHO) "Name: OpenSSL-libcrypto" >> libcrypto.pc
-+	@$(ECHO) "Description: OpenSSL cryptography library" >> libcrypto.pc
-+	@$(ECHO) "Version: $(VERSION)" >> libcrypto.pc
-+	@$(ECHO) "Libs: -L$${libdir} -lcrypto" >> libcrypto.pc
-+	@$(ECHO) "Libs.private: $(LIB_EX_LIBS)" >> libcrypto.pc
-+	@$(ECHO) "Cflags: -I$${includedir}" >> libcrypto.pc
-+
-+libssl.pc:
-+	@$(ECHO) "prefix=$(INSTALLTOP)" > libssl.pc
-+	@$(ECHO) "exec_prefix=$${prefix}" >> libssl.pc
-+	@$(ECHO) "libdir=$${exec_prefix}/$(LIBDIR)" >> libssl.pc
-+	@$(ECHO) "includedir=$${prefix}/include" >> libssl.pc
-+	@$(ECHO) "" >> libssl.pc
-+	@$(ECHO) "Name: OpenSSL-libssl" >> libssl.pc
-+	@$(ECHO) "Description: Secure Sockets Layer and cryptography libraries" >> libssl.pc
-+	@$(ECHO) "Version: $(VERSION)" >> libssl.pc
-+	@$(ECHO) "Requires.private: libcrypto" >> libssl.pc
-+	@$(ECHO) "Libs: -L$${libdir} -lssl" >> libssl.pc
-+	@$(ECHO) "Cflags: -I$${includedir}" >> libssl.pc
-+
-+openssl.pc:
-+	@$(ECHO) "prefix=$(INSTALLTOP)" > openssl.pc
-+	@$(ECHO) "exec_prefix=$${prefix}" >> openssl.pc
-+	@$(ECHO) "libdir=$${exec_prefix}/$(LIBDIR)" >> openssl.pc
-+	@$(ECHO) "includedir=$${prefix}/include" >> openssl.pc
-+	@$(ECHO) "" >> openssl.pc
-+	@$(ECHO) "Name: OpenSSL" >> openssl.pc
-+	@$(ECHO) "Description: Secure Sockets Layer and cryptography libraries and tools" >> openssl.pc
-+	@$(ECHO) "Version: $(VERSION)" >> openssl.pc
-+	@$(ECHO) "Requires: libssl libcrypto" >> openssl.pc
- 
- configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
- 	@$(ECHO) "Detected changed: $?"
--- 
-2.27.0.windows.1
-
diff --git a/recipes/openssl/0002-ARMv4-assembly-pack-implement-support-for-Thumb2.patch b/recipes/openssl/0002-ARMv4-assembly-pack-implement-support-for-Thumb2.patch
new file mode 100644
index 00000000..7ec3fd12
--- /dev/null
+++ b/recipes/openssl/0002-ARMv4-assembly-pack-implement-support-for-Thumb2.patch
@@ -0,0 +1,757 @@
+From 4761cad72b61c048e30e17c4b8da04f4e62e6191 Mon Sep 17 00:00:00 2001
+From: Andy Polyakov <appro@openssl.org>
+Date: Wed, 23 Sep 2015 18:41:27 +0200
+Subject: [PATCH 2/2] ARMv4 assembly pack: implement support for Thumb2.
+
+As some of ARM processors, more specifically Cortex-Mx series, are
+Thumb2-only, we need to support Thumb2-only builds even in assembly.
+
+Reviewed-by: Tim Hudson <tjh@openssl.org>
+---
+ crypto/aes/asm/aes-armv4.pl        | 24 +++++++--------
+ crypto/armv4cpuid.S                | 24 +++++++++++++++
+ crypto/bn/asm/armv4-gf2m.pl        | 36 +++++++++++++++++++----
+ crypto/bn/asm/armv4-mont.pl        | 38 +++++++++++++++++++-----
+ crypto/modes/asm/ghash-armv4.pl    | 45 ++++++++++++++++++++++++----
+ crypto/sha/asm/sha1-armv4-large.pl | 47 ++++++++++++++++++++++++++----
+ crypto/sha/asm/sha256-armv4.pl     | 14 ++++-----
+ crypto/sha/asm/sha512-armv4.pl     | 17 +++++------
+ 8 files changed, 189 insertions(+), 56 deletions(-)
+
+diff --git a/crypto/aes/asm/aes-armv4.pl b/crypto/aes/asm/aes-armv4.pl
+index c1b5e35..a9e01bb 100644
+--- a/crypto/aes/asm/aes-armv4.pl
++++ b/crypto/aes/asm/aes-armv4.pl
+@@ -58,15 +58,11 @@ $code=<<___;
+ #endif
+ 
+ .text
+-#if __ARM_ARCH__<7
+-.code	32
+-#else
++#if defined(__thumb2__) && !defined(__APPLE__)
+ .syntax	unified
+-# ifdef __thumb2__
+ .thumb
+-# else
++#else
+ .code	32
+-# endif
+ #endif
+ 
+ .type	AES_Te,%object
+@@ -181,7 +177,7 @@ AES_Te:
+ .type   AES_encrypt,%function
+ .align	5
+ AES_encrypt:
+-#if __ARM_ARCH__<7
++#ifndef	__thumb2__
+ 	sub	r3,pc,#8		@ AES_encrypt
+ #else
+ 	adr	r3,.
+@@ -427,19 +423,19 @@ _armv4_AES_encrypt:
+ .align	5
+ private_AES_set_encrypt_key:
+ _armv4_AES_set_encrypt_key:
+-#if __ARM_ARCH__<7
++#ifndef	__thumb2__
+ 	sub	r3,pc,#8		@ AES_set_encrypt_key
+ #else
+ 	adr	r3,.
+ #endif
+ 	teq	r0,#0
+-#if __ARM_ARCH__>=7
++#ifdef	__thumb2__
+ 	itt	eq			@ Thumb2 thing, sanity check in ARM
+ #endif
+ 	moveq	r0,#-1
+ 	beq	.Labrt
+ 	teq	r2,#0
+-#if __ARM_ARCH__>=7
++#ifdef	__thumb2__
+ 	itt	eq			@ Thumb2 thing, sanity check in ARM
+ #endif
+ 	moveq	r0,#-1
+@@ -450,7 +446,7 @@ _armv4_AES_set_encrypt_key:
+ 	teq	r1,#192
+ 	beq	.Lok
+ 	teq	r1,#256
+-#if __ARM_ARCH__>=7
++#ifdef	__thumb2__
+ 	itt	ne			@ Thumb2 thing, sanity check in ARM
+ #endif
+ 	movne	r0,#-1
+@@ -607,7 +603,7 @@ _armv4_AES_set_encrypt_key:
+ 	str	$s2,[$key,#-16]
+ 	subs	$rounds,$rounds,#1
+ 	str	$s3,[$key,#-12]
+-#if __ARM_ARCH__>=7
++#ifdef	__thumb2__
+ 	itt	eq				@ Thumb2 thing, sanity check in ARM
+ #endif
+ 	subeq	r2,$key,#216
+@@ -679,7 +675,7 @@ _armv4_AES_set_encrypt_key:
+ 	str	$s2,[$key,#-24]
+ 	subs	$rounds,$rounds,#1
+ 	str	$s3,[$key,#-20]
+-#if __ARM_ARCH__>=7
++#ifdef	__thumb2__
+ 	itt	eq				@ Thumb2 thing, sanity check in ARM
+ #endif
+ 	subeq	r2,$key,#256
+@@ -949,7 +945,7 @@ AES_Td:
+ .type   AES_decrypt,%function
+ .align	5
+ AES_decrypt:
+-#if __ARM_ARCH__<7
++#ifndef	__thumb2__
+ 	sub	r3,pc,#8		@ AES_decrypt
+ #else
+ 	adr	r3,.
+diff --git a/crypto/armv4cpuid.S b/crypto/armv4cpuid.S
+index 65010ae..44ed229 100644
+--- a/crypto/armv4cpuid.S
++++ b/crypto/armv4cpuid.S
+@@ -1,7 +1,12 @@
+ #include "arm_arch.h"
+ 
+ .text
++#if defined(__thumb2__) && !defined(__APPLE__)
++.syntax	unified
++.thumb
++#else
+ .code	32
++#endif
+ 
+ .align	5
+ .global	OPENSSL_atomic_add
+@@ -45,6 +50,9 @@ OPENSSL_atomic_add:
+ OPENSSL_cleanse:
+ 	eor	ip,ip,ip
+ 	cmp	r1,#7
++#ifdef	__thumb2__
++	itt	hs
++#endif
+ 	subhs	r1,r1,#4
+ 	bhs	.Lot
+ 	cmp	r1,#0
+@@ -98,27 +106,43 @@ _armv7_tick:
+ .global	_armv8_aes_probe
+ .type	_armv8_aes_probe,%function
+ _armv8_aes_probe:
++#if defined(__thumb2__) && !defined(__APPLE__)
++	.byte	0xb0,0xff,0x00,0x03	@ aese.8	q0,q0
++#else
+ 	.byte	0x00,0x03,0xb0,0xf3	@ aese.8	q0,q0
++#endif
+ 	bx	lr
+ .size	_armv8_aes_probe,.-_armv8_aes_probe
+ 
+ .global	_armv8_sha1_probe
+ .type	_armv8_sha1_probe,%function
+ _armv8_sha1_probe:
++#if defined(__thumb2__) && !defined(__APPLE__)
++	.byte	0x00,0xef,0x40,0x0c	@ sha1c.32	q0,q0,q0
++#else
+ 	.byte	0x40,0x0c,0x00,0xf2	@ sha1c.32	q0,q0,q0
++#endif
+ 	bx	lr
+ .size	_armv8_sha1_probe,.-_armv8_sha1_probe
+ 
+ .global	_armv8_sha256_probe
+ .type	_armv8_sha256_probe,%function
+ _armv8_sha256_probe:
++#if defined(__thumb2__) && !defined(__APPLE__)
++	.byte	0x00,0xff,0x40,0x0c	@ sha256h.32	q0,q0,q0
++#else
+ 	.byte	0x40,0x0c,0x00,0xf3	@ sha256h.32	q0,q0,q0
++#endif
+ 	bx	lr
+ .size	_armv8_sha256_probe,.-_armv8_sha256_probe
+ .global	_armv8_pmull_probe
+ .type	_armv8_pmull_probe,%function
+ _armv8_pmull_probe:
++#if defined(__thumb2__) && !defined(__APPLE__)
++	.byte	0xa0,0xef,0x00,0x0e	@ vmull.p64	q0,d0,d0
++#else
+ 	.byte	0x00,0x0e,0xa0,0xf2	@ vmull.p64	q0,d0,d0
++#endif
+ 	bx	lr
+ .size	_armv8_pmull_probe,.-_armv8_pmull_probe
+ #endif
+diff --git a/crypto/bn/asm/armv4-gf2m.pl b/crypto/bn/asm/armv4-gf2m.pl
+index 72381a7..a64c57b 100644
+--- a/crypto/bn/asm/armv4-gf2m.pl
++++ b/crypto/bn/asm/armv4-gf2m.pl
+@@ -39,7 +39,12 @@ $code=<<___;
+ #include "arm_arch.h"
+ 
+ .text
++#if defined(__thumb2__) && !defined(__APPLE__)
++.syntax	unified
++.thumb
++#else
+ .code	32
++#endif
+ ___
+ ################
+ # private interface to mul_1x1_ialu
+@@ -120,11 +125,17 @@ mul_1x1_ialu:
+ 	eor	$hi,$hi,$t0,lsr#8
+ 	ldr	$t0,[sp,$i0]		@ tab[b >> 30      ]
+ 
++#ifdef	__thumb2__
++	itt	ne
++#endif
+ 	eorne	$lo,$lo,$b,lsl#30
+ 	eorne	$hi,$hi,$b,lsr#2
+ 	tst	$a,#1<<31
+ 	eor	$lo,$lo,$t1,lsl#27
+ 	eor	$hi,$hi,$t1,lsr#5
++#ifdef	__thumb2__
++	itt	ne
++#endif
+ 	eorne	$lo,$lo,$b,lsl#31
+ 	eorne	$hi,$hi,$b,lsr#1
+ 	eor	$lo,$lo,$t0,lsl#30
+@@ -144,20 +155,33 @@ $code.=<<___;
+ .align	5
+ bn_GF2m_mul_2x2:
+ #if __ARM_MAX_ARCH__>=7
++	stmdb	sp!,{r10,lr}
+ 	ldr	r12,.LOPENSSL_armcap
+-.Lpic:	ldr	r12,[pc,r12]
+-	tst	r12,#1
++	adr	r10,.LOPENSSL_armcap
++	ldr	r12,[r12,r10]
++#ifdef	__APPLE__
++	ldr	r12,[r12]
++#endif
++	tst	r12,#ARMV7_NEON
++	itt	ne
++	ldrne	r10,[sp],#8
+ 	bne	.LNEON
++	stmdb	sp!,{r4-r9}
++#else
++	stmdb	sp!,{r4-r10,lr}
+ #endif
+ ___
+ $ret="r10";	# reassigned 1st argument
+ $code.=<<___;
+-	stmdb	sp!,{r4-r10,lr}
+ 	mov	$ret,r0			@ reassign 1st argument
+ 	mov	$b,r3			@ $b=b1
++	sub	r7,sp,#36
++	mov	r8,sp
++	and	r7,r7,#-32
+ 	ldr	r3,[sp,#32]		@ load b0
+ 	mov	$mask,#7<<2
+-	sub	sp,sp,#32		@ allocate tab[8]
++	mov	sp,r7			@ allocate tab[8]
++	str	r8,[r7,#32]
+ 
+ 	bl	mul_1x1_ialu		@ a1·b1
+ 	str	$lo,[$ret,#8]
+@@ -181,6 +205,7 @@ ___
+ $code.=<<___;
+ 	ldmia	$ret,{@r[0]-@r[3]}
+ 	eor	$lo,$lo,$hi
++	ldr	sp,[sp,#32]		@ destroy tab[8]
+ 	eor	$hi,$hi,@r[1]
+ 	eor	$lo,$lo,@r[0]
+ 	eor	$hi,$hi,@r[2]
+@@ -188,7 +213,6 @@ $code.=<<___;
+ 	eor	$hi,$hi,@r[3]
+ 	str	$hi,[$ret,#8]
+ 	eor	$lo,$lo,$hi
+-	add	sp,sp,#32		@ destroy tab[8]
+ 	str	$lo,[$ret,#4]
+ 
+ #if __ARM_ARCH__>=5
+@@ -267,7 +291,7 @@ $code.=<<___;
+ #if __ARM_MAX_ARCH__>=7
+ .align	5
+ .LOPENSSL_armcap:
+-.word	OPENSSL_armcap_P-(.Lpic+8)
++.word	OPENSSL_armcap_P-.
+ #endif
+ .asciz	"GF(2^m) Multiplication for ARMv4/NEON, CRYPTOGAMS by <appro\@openssl.org>"
+ .align	5
+diff --git a/crypto/bn/asm/armv4-mont.pl b/crypto/bn/asm/armv4-mont.pl
+index 8961180..4fc7f48 100644
+--- a/crypto/bn/asm/armv4-mont.pl
++++ b/crypto/bn/asm/armv4-mont.pl
+@@ -70,12 +70,17 @@ $code=<<___;
+ #include "arm_arch.h"
+ 
+ .text
++#if defined(__thumb2__) && !defined(__APPLE__)
++.syntax	unified
++.thumb
++#else
+ .code	32
++#endif
+ 
+ #if __ARM_MAX_ARCH__>=7
+ .align	5
+ .LOPENSSL_armcap:
+-.word	OPENSSL_armcap_P-bn_mul_mont
++.word	OPENSSL_armcap_P-.Lbn_mul_mont
+ #endif
+ 
+ .global	bn_mul_mont
+@@ -83,12 +88,13 @@ $code=<<___;
+ 
+ .align	5
+ bn_mul_mont:
++.Lbn_mul_mont:
+ 	ldr	ip,[sp,#4]		@ load num
+ 	stmdb	sp!,{r0,r2}		@ sp points at argument block
+ #if __ARM_MAX_ARCH__>=7
+ 	tst	ip,#7
+ 	bne	.Lialu
+-	adr	r0,bn_mul_mont
++	adr	r0,.Lbn_mul_mont
+ 	ldr	r2,.LOPENSSL_armcap
+ 	ldr	r0,[r0,r2]
+ 	tst	r0,#1			@ NEON available?
+@@ -101,6 +107,9 @@ bn_mul_mont:
+ #endif
+ 	cmp	ip,#2
+ 	mov	$num,ip			@ load num
++#ifdef	__thumb2__
++	ittt	lt
++#endif
+ 	movlt	r0,#0
+ 	addlt	sp,sp,#2*4
+ 	blt	.Labrt
+@@ -148,10 +157,11 @@ bn_mul_mont:
+ 	ldr	$n0,[$_n0]		@ restore n0
+ 	adc	$nhi,$nhi,#0
+ 	str	$nlo,[$num]		@ tp[num-1]=
++	mov	$tj,sp
+ 	str	$nhi,[$num,#4]		@ tp[num]=
+ 
+ .Louter:
+-	sub	$tj,$num,sp		@ "original" $num-1 value
++	sub	$tj,$num,$tj		@ "original" $num-1 value
+ 	sub	$ap,$ap,$tj		@ "rewind" ap to &ap[1]
+ 	ldr	$bi,[$tp,#4]!		@ *(++bp)
+ 	sub	$np,$np,$tj		@ "rewind" np to &np[1]
+@@ -196,11 +206,16 @@ bn_mul_mont:
+ 	str	$nhi,[$num,#4]		@ tp[num]=
+ 
+ 	cmp	$tp,$tj
++#ifdef	__thumb2__
++	itt	ne
++#endif
++	movne	$tj,sp
+ 	bne	.Louter
+ 
+ 	ldr	$rp,[$_rp]		@ pull rp
++	mov	$aj,sp
+ 	add	$num,$num,#4		@ $num to point at &tp[num]
+-	sub	$aj,$num,sp		@ "original" num value
++	sub	$aj,$num,$aj		@ "original" num value
+ 	mov	$tp,sp			@ "rewind" $tp
+ 	mov	$ap,$tp			@ "borrow" $ap
+ 	sub	$np,$np,$aj		@ "rewind" $np to &np[0]
+@@ -227,7 +242,8 @@ bn_mul_mont:
+ 	teq	$tp,$num		@ preserve carry
+ 	bne	.Lcopy
+ 
+-	add	sp,$num,#4		@ skip over tp[num+1]
++	mov	sp,$num
++	add	sp,sp,#4		@ skip over tp[num+1]
+ 	ldmia	sp!,{r4-r12,lr}		@ restore registers
+ 	add	sp,sp,#2*4		@ skip over {r0,r2}
+ 	mov	r0,#1
+@@ -268,6 +284,7 @@ bn_mul8x_mont_neon:
+ 	stmdb	sp!,{r4-r11}
+ 	vstmdb	sp!,{d8-d15}		@ ABI specification says so
+ 	ldmia	ip,{r4-r5}		@ load rest of parameter block
++	mov	ip,sp
+ 
+ 	sub		$toutptr,sp,#16
+ 	vld1.32		{${Bi}[0]}, [$bptr,:32]!
+@@ -623,8 +640,9 @@ bn_mul8x_mont_neon:
+ 	bne	.LNEON_sub
+ 
+ 	ldr	r10, [$aptr]				@ load top-most bit
++	mov	r11,sp
+ 	veor	q0,q0,q0
+-	sub	r11,$bptr,sp				@ this is num*4
++	sub	r11,$bptr,r11				@ this is num*4
+ 	veor	q1,q1,q1
+ 	mov	$aptr,sp
+ 	sub	$rptr,$rptr,r11				@ rewind $rptr
+@@ -634,27 +652,33 @@ bn_mul8x_mont_neon:
+ .LNEON_copy_n_zap:
+ 	ldmia	$aptr!, {r4-r7}
+ 	ldmia	$rptr,  {r8-r11}
++	it	cc
+ 	movcc	r8, r4
+ 	vst1.64	{q0-q1}, [$nptr,:256]!			@ wipe
++	itt	cc
+ 	movcc	r9, r5
+ 	movcc	r10,r6
+ 	vst1.64	{q0-q1}, [$nptr,:256]!			@ wipe
++	it	cc
+ 	movcc	r11,r7
+ 	ldmia	$aptr, {r4-r7}
+ 	stmia	$rptr!, {r8-r11}
+ 	sub	$aptr,$aptr,#16
+ 	ldmia	$rptr, {r8-r11}
++	it	cc
+ 	movcc	r8, r4
+ 	vst1.64	{q0-q1}, [$aptr,:256]!			@ wipe
++	itt	cc
+ 	movcc	r9, r5
+ 	movcc	r10,r6
+ 	vst1.64	{q0-q1}, [$nptr,:256]!			@ wipe
++	it	cc
+ 	movcc	r11,r7
+ 	teq	$aptr,$bptr				@ preserves carry
+ 	stmia	$rptr!, {r8-r11}
+ 	bne	.LNEON_copy_n_zap
+ 
+-	sub	sp,ip,#96
++	mov	sp,ip
+         vldmia  sp!,{d8-d15}
+         ldmia   sp!,{r4-r11}
+ 	ret						@ bx lr
+diff --git a/crypto/modes/asm/ghash-armv4.pl b/crypto/modes/asm/ghash-armv4.pl
+index 8ccc963..99f79f4 100644
+--- a/crypto/modes/asm/ghash-armv4.pl
++++ b/crypto/modes/asm/ghash-armv4.pl
+@@ -124,7 +124,12 @@ $code=<<___;
+ #include "arm_arch.h"
+ 
+ .text
++#if defined(__thumb2__) && !defined(__APPLE__)
++.syntax	unified
++.thumb
++#else
+ .code	32
++#endif
+ 
+ #ifdef __clang__
+ #define ldrplb	ldrbpl
+@@ -142,19 +147,27 @@ rem_4bit:
+ 
+ .type	rem_4bit_get,%function
+ rem_4bit_get:
+-	sub	$rem_4bit,pc,#8
+-	sub	$rem_4bit,$rem_4bit,#32	@ &rem_4bit
++#if defined(__thumb2__)
++	adr	$rem_4bit,rem_4bit
++#else
++	sub	$rem_4bit,pc,#8+32	@ &rem_4bit
++#endif
+ 	b	.Lrem_4bit_got
+ 	nop
++	nop
+ .size	rem_4bit_get,.-rem_4bit_get
+ 
+ .global	gcm_ghash_4bit
+ .type	gcm_ghash_4bit,%function
++.align	4
+ gcm_ghash_4bit:
+-	sub	r12,pc,#8
++#if defined(__thumb2__)
++	adr	r12,rem_4bit
++#else
++	sub	r12,pc,#8+48		@ &rem_4bit
++#endif
+ 	add	$len,$inp,$len		@ $len to point at the end
+ 	stmdb	sp!,{r3-r11,lr}		@ save $len/end too
+-	sub	r12,r12,#48		@ &rem_4bit
+ 
+ 	ldmia	r12,{r4-r11}		@ copy rem_4bit ...
+ 	stmdb	sp!,{r4-r11}		@ ... to stack
+@@ -201,6 +214,9 @@ gcm_ghash_4bit:
+ 	eor	$Zlh,$Zlh,$Zhl,lsl#28
+ 	ldrh	$Tll,[sp,$nlo]		@ rem_4bit[rem]
+ 	eor	$Zhl,$Thl,$Zhl,lsr#4
++#ifdef	__thumb2__
++	it	pl
++#endif
+ 	ldrplb	$nlo,[$inp,$cnt]
+ 	eor	$Zhl,$Zhl,$Zhh,lsl#28
+ 	eor	$Zhh,$Thh,$Zhh,lsr#4
+@@ -211,6 +227,9 @@ gcm_ghash_4bit:
+ 	add	$nhi,$nhi,$nhi
+ 	ldmia	$Thh,{$Tll-$Thh}	@ load Htbl[nhi]
+ 	eor	$Zll,$Tll,$Zll,lsr#4
++#ifdef	__thumb2__
++	it	pl
++#endif
+ 	ldrplb	$Tll,[$Xi,$cnt]
+ 	eor	$Zll,$Zll,$Zlh,lsl#28
+ 	eor	$Zlh,$Tlh,$Zlh,lsr#4
+@@ -218,8 +237,14 @@ gcm_ghash_4bit:
+ 	eor	$Zlh,$Zlh,$Zhl,lsl#28
+ 	eor	$Zhl,$Thl,$Zhl,lsr#4
+ 	eor	$Zhl,$Zhl,$Zhh,lsl#28
++#ifdef	__thumb2__
++	it	pl
++#endif
+ 	eorpl	$nlo,$nlo,$Tll
+ 	eor	$Zhh,$Thh,$Zhh,lsr#4
++#ifdef	__thumb2__
++	itt	pl
++#endif
+ 	andpl	$nhi,$nlo,#0xf0
+ 	andpl	$nlo,$nlo,#0x0f
+ 	eor	$Zhh,$Zhh,$Tlh,lsl#16	@ ^= rem_4bit[rem]
+@@ -229,7 +254,11 @@ gcm_ghash_4bit:
+ 	add	$inp,$inp,#16
+ 	mov	$nhi,$Zll
+ ___
+-	&Zsmash("cmp\t$inp,$len","ldrneb\t$nlo,[$inp,#15]");
++	&Zsmash("cmp\t$inp,$len","\n".
++				 "#ifdef __thumb2__\n".
++				 "	it	ne\n".
++				 "#endif\n".
++				 "	ldrneb	$nlo,[$inp,#15]");
+ $code.=<<___;
+ 	bne	.Louter
+ 
+@@ -287,6 +316,9 @@ gcm_gmult_4bit:
+ 	eor	$Zlh,$Zlh,$Zhl,lsl#28
+ 	ldrh	$Tll,[$rem_4bit,$nlo]	@ rem_4bit[rem]
+ 	eor	$Zhl,$Thl,$Zhl,lsr#4
++#ifdef	__thumb2__
++	it	pl
++#endif
+ 	ldrplb	$nlo,[$Xi,$cnt]
+ 	eor	$Zhl,$Zhl,$Zhh,lsl#28
+ 	eor	$Zhh,$Thh,$Zhh,lsr#4
+@@ -304,6 +336,9 @@ gcm_gmult_4bit:
+ 	eor	$Zhl,$Thl,$Zhl,lsr#4
+ 	eor	$Zhl,$Zhl,$Zhh,lsl#28
+ 	eor	$Zhh,$Thh,$Zhh,lsr#4
++#ifdef	__thumb2__
++	itt	pl
++#endif
+ 	andpl	$nhi,$nlo,#0xf0
+ 	andpl	$nlo,$nlo,#0x0f
+ 	eor	$Zhh,$Zhh,$Tll,lsl#16	@ ^= rem_4bit[rem]
+diff --git a/crypto/sha/asm/sha1-armv4-large.pl b/crypto/sha/asm/sha1-armv4-large.pl
+index b2c3032..d3de7f7 100644
+--- a/crypto/sha/asm/sha1-armv4-large.pl
++++ b/crypto/sha/asm/sha1-armv4-large.pl
+@@ -167,7 +167,12 @@ $code=<<___;
+ #include "arm_arch.h"
+ 
+ .text
++#if defined(__thumb2__) && !defined(__APPLE__)
++.syntax	unified
++.thumb
++#else
+ .code	32
++#endif
+ 
+ .global	sha1_block_data_order
+ .type	sha1_block_data_order,%function
+@@ -175,7 +180,8 @@ $code=<<___;
+ .align	5
+ sha1_block_data_order:
+ #if __ARM_MAX_ARCH__>=7
+-	sub	r3,pc,#8		@ sha1_block_data_order
++.Lsha1_block:
++	adr	r3,.Lsha1_block
+ 	ldr	r12,.LOPENSSL_armcap
+ 	ldr	r12,[r3,r12]		@ OPENSSL_armcap_P
+ 	tst	r12,#ARMV8_SHA1
+@@ -199,7 +205,12 @@ for($i=0;$i<5;$i++) {
+ 	&BODY_00_15(@V);	unshift(@V,pop(@V));
+ }
+ $code.=<<___;
++#if defined(__thumb2__) && !defined(__APPLE__)
++	mov	$t3,sp
++	teq	$Xi,$t3
++#else
+ 	teq	$Xi,sp
++#endif
+ 	bne	.L_00_15		@ [((11+4)*5+2)*3]
+ 	sub	sp,sp,#25*4
+ ___
+@@ -218,7 +229,12 @@ for($i=0;$i<5;$i++) {
+ 	&BODY_20_39(@V);	unshift(@V,pop(@V));
+ }
+ $code.=<<___;
++#if defined(__thumb2__) && !defined(__APPLE__)
++	mov	$t3,sp
++	teq	$Xi,$t3
++#else
+ 	teq	$Xi,sp			@ preserve carry
++#endif
+ 	bne	.L_20_39_or_60_79	@ [+((12+3)*5+2)*4]
+ 	bcs	.L_done			@ [+((12+3)*5+2)*4], spare 300 bytes
+ 
+@@ -230,7 +246,12 @@ for($i=0;$i<5;$i++) {
+ 	&BODY_40_59(@V);	unshift(@V,pop(@V));
+ }
+ $code.=<<___;
++#if defined(__thumb2__) && !defined(__APPLE__)
++	mov	$t3,sp
++	teq	$Xi,$t3
++#else
+ 	teq	$Xi,sp
++#endif
+ 	bne	.L_40_59		@ [+((12+5)*5+2)*4]
+ 
+ 	ldr	$K,.LK_60_79
+@@ -266,7 +287,7 @@ $code.=<<___;
+ .LK_60_79:	.word	0xca62c1d6
+ #if __ARM_MAX_ARCH__>=7
+ .LOPENSSL_armcap:
+-.word	OPENSSL_armcap_P-sha1_block_data_order
++.word	OPENSSL_armcap_P-.Lsha1_block
+ #endif
+ .asciz	"SHA1 block transform for ARMv4/NEON/ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
+ .align	5
+@@ -441,6 +462,7 @@ sub Xuplast_80 ()
+ 
+ 	&teq		($inp,$len);
+ 	&sub		($K_XX_XX,$K_XX_XX,16);	# rewind $K_XX_XX
++	&it		("eq");
+ 	&subeq		($inp,$inp,64);		# reload last block to avoid SEGV
+ 	&vld1_8		("{@X[-4&7]-@X[-3&7]}","[$inp]!");
+ 	 eval(shift(@insns));
+@@ -491,12 +513,12 @@ sha1_block_data_order_neon:
+ 	@ dmb				@ errata #451034 on early Cortex A8
+ 	@ vstmdb	sp!,{d8-d15}	@ ABI specification says so
+ 	mov	$saved_sp,sp
+-	sub	sp,sp,#64		@ alloca
++	sub	$Xfer,sp,#64
+ 	adr	$K_XX_XX,.LK_00_19
+-	bic	sp,sp,#15		@ align for 128-bit stores
++	bic	$Xfer,$Xfer,#15		@ align for 128-bit stores
+ 
+ 	ldmia	$ctx,{$a,$b,$c,$d,$e}	@ load context
+-	mov	$Xfer,sp
++	mov	sp,$Xfer		@ alloca
+ 
+ 	vld1.8		{@X[-4&7]-@X[-3&7]},[$inp]!	@ handles unaligned
+ 	veor		$zero,$zero,$zero
+@@ -543,10 +565,13 @@ $code.=<<___;
+ 	add	$b,$b,$t0
+ 	add	$c,$c,$t1
+ 	add	$d,$d,$Xfer
++	it	eq
+ 	moveq	sp,$saved_sp
+ 	add	$e,$e,$Ki
++	it	ne
+ 	ldrne	$Ki,[sp]
+ 	stmia	$ctx,{$a,$b,$c,$d,$e}
++	itt	ne
+ 	addne	$Xfer,sp,#3*16
+ 	bne	.Loop_neon
+ 
+@@ -567,6 +592,13 @@ my ($W0,$W1,$ABCD_SAVE)=map("q$_",(12..14));
+ 
+ $code.=<<___;
+ #if __ARM_MAX_ARCH__>=7
++
++# if defined(__thumb2__) && !defined(__APPLE__)
++#  define INST(a,b,c,d)	.byte	c,d|0xf,a,b
++# else
++#  define INST(a,b,c,d)	.byte	a,b,c,d|0x10
++# endif
++
+ .type	sha1_block_data_order_armv8,%function
+ .align	5
+ sha1_block_data_order_armv8:
+@@ -660,7 +692,10 @@ ___
+ 	    # since ARMv7 instructions are always encoded little-endian.
+ 	    # correct solution is to use .inst directive, but older
+ 	    # assemblers don't implement it:-(
+-	    sprintf ".byte\t0x%02x,0x%02x,0x%02x,0x%02x\t@ %s %s",
++
++	    # this fix-up provides Thumb encoding in conjunction with INST
++	    $word &= ~0x10000000 if (($word & 0x0f000000) == 0x02000000);
++	    sprintf "INST(0x%02x,0x%02x,0x%02x,0x%02x)\t@ %s %s",
+ 			$word&0xff,($word>>8)&0xff,
+ 			($word>>16)&0xff,($word>>24)&0xff,
+ 			$mnemonic,$arg;
+diff --git a/crypto/sha/asm/sha256-armv4.pl b/crypto/sha/asm/sha256-armv4.pl
+index 750216e..08efab1 100644
+--- a/crypto/sha/asm/sha256-armv4.pl
++++ b/crypto/sha/asm/sha256-armv4.pl
+@@ -161,15 +161,12 @@ $code=<<___;
+ #endif
+ 
+ .text
+-#if __ARM_ARCH__<7
+-.code	32
+-#else
++#if defined(__thumb2__) && !defined(__APPLE__)
+ .syntax unified
+-# ifdef __thumb2__
+ .thumb
+-# else
++# define adrl adr
++#else
+ .code   32
+-# endif
+ #endif
+ 
+ .type	K256,%object
+@@ -202,10 +199,11 @@ K256:
+ .global	sha256_block_data_order
+ .type	sha256_block_data_order,%function
+ sha256_block_data_order:
+-#if __ARM_ARCH__<7
++.Lsha256_block_data_order:
++#if __ARM_ARCH__<7 && !defined(__thumb2__)
+ 	sub	r3,pc,#8		@ sha256_block_data_order
+ #else
+-	adr	r3,.
++	adr	r3,.Lsha256_block_data_order
+ #endif
+ #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__)
+ 	ldr	r12,.LOPENSSL_armcap
+diff --git a/crypto/sha/asm/sha512-armv4.pl b/crypto/sha/asm/sha512-armv4.pl
+index 7e540f8..d49286a 100644
+--- a/crypto/sha/asm/sha512-armv4.pl
++++ b/crypto/sha/asm/sha512-armv4.pl
+@@ -207,16 +207,12 @@ $code=<<___;
+ #endif
+ 
+ .text
+-#if __ARM_ARCH__<7
+-.code	32
+-#else
++#if defined(__thumb2__) && !defined(__APPLE__)
+ .syntax unified
+-# ifdef __thumb2__
+-#  define adrl adr
+ .thumb
+-# else
+-.code   32
+-# endif
++# define adrl adr
++#else
++.code	32
+ #endif
+ 
+ .type	K512,%object
+@@ -274,10 +270,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817)
+ .global	sha512_block_data_order
+ .type	sha512_block_data_order,%function
+ sha512_block_data_order:
+-#if __ARM_ARCH__<7
++.Lsha512_block_data_order:
++#if __ARM_ARCH__<7 && !defined(__thumb2__)
+ 	sub	r3,pc,#8		@ sha512_block_data_order
+ #else
+-	adr	r3,sha512_block_data_order
++	adr	r3,.Lsha512_block_data_order
+ #endif
+ #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__)
+ 	ldr	r12,.LOPENSSL_armcap
+-- 
+2.31.1
+
diff --git a/recipes/openssl/0002-win-onecore-Build-with-APPCONTAINER-for-UWP-compat.patch b/recipes/openssl/0002-win-onecore-Build-with-APPCONTAINER-for-UWP-compat.patch
deleted file mode 100644
index 481a9631..00000000
--- a/recipes/openssl/0002-win-onecore-Build-with-APPCONTAINER-for-UWP-compat.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From c17b1751f3758890a8a5837466e4ddc1e6f2f3f0 Mon Sep 17 00:00:00 2001
-From: Nirbheek Chauhan <nirbheek@centricular.com>
-Date: Wed, 8 Jul 2020 23:23:04 +0530
-Subject: [PATCH 2/2] win-onecore: Build with /APPCONTAINER for UWP compat
-
-When targeting the win-onecore configuration, we must link with
-/APPCONTAINER which is a requirement for submitting apps to the
-Windows Store.
-
-Without this, the Windows App Certificate Kit will reject the app:
-https://docs.microsoft.com/en-us/cpp/build/reference/appcontainer-windows-store-app
----
- Configurations/50-win-onecore.conf | 9 +++++----
- 1 file changed, 5 insertions(+), 4 deletions(-)
-
-diff --git a/Configurations/50-win-onecore.conf b/Configurations/50-win-onecore.conf
-index c595279..fb2d961 100644
---- a/Configurations/50-win-onecore.conf
-+++ b/Configurations/50-win-onecore.conf
-@@ -16,13 +16,14 @@ my %targets = (
-         # /NODEFAULTLIB:kernel32.lib is needed, because MSVCRT.LIB has
-         # hidden reference to kernel32.lib, but we don't actually want
-         # it in "onecore" build.
--        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
-+        # /APPCONTAINER is needed for Universal Windows Platform compat
-+        lflags          => add("/NODEFAULTLIB:kernel32.lib /APPCONTAINER"),
-         defines         => add("OPENSSL_SYS_WIN_CORE"),
-         ex_libs         => "onecore.lib",
-     },
-     "VC-WIN64A-ONECORE" => {
-         inherit_from    => [ "VC-WIN64A" ],
--        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
-+        lflags          => add("/NODEFAULTLIB:kernel32.lib /APPCONTAINER"),
-         defines         => add("OPENSSL_SYS_WIN_CORE"),
-         ex_libs         => "onecore.lib",
-     },
-@@ -48,7 +49,7 @@ my %targets = (
-         defines         => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE",
-                                "OPENSSL_SYS_WIN_CORE"),
-         bn_ops          => "BN_LLONG RC4_CHAR EXPORT_VAR_AS_FN",
--        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
-+        lflags          => add("/NODEFAULTLIB:kernel32.lib /APPCONTAINER"),
-         ex_libs         => "onecore.lib",
-         multilib        => "-arm",
-     },
-@@ -57,7 +58,7 @@ my %targets = (
-         defines         => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE",
-                                "OPENSSL_SYS_WIN_CORE"),
-         bn_ops          => "SIXTY_FOUR_BIT RC4_CHAR EXPORT_VAR_AS_FN",
--        lflags          => add("/NODEFAULTLIB:kernel32.lib"),
-+        lflags          => add("/NODEFAULTLIB:kernel32.lib /APPCONTAINER"),
-         ex_libs         => "onecore.lib",
-         multilib        => "-arm64",
-     },
--- 
-2.26.2
-
diff --git a/recipes/openssl/0002-windows-makefile.tmpl-Fix-ONECORE-build.patch b/recipes/openssl/0002-windows-makefile.tmpl-Fix-ONECORE-build.patch
deleted file mode 100644
index 8a254fc5..00000000
--- a/recipes/openssl/0002-windows-makefile.tmpl-Fix-ONECORE-build.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 5c5959292e59650051418a7db487ac07ef701700 Mon Sep 17 00:00:00 2001
-From: Nirbheek Chauhan <nirbheek@centricular.com>
-Date: Tue, 9 Jun 2020 18:21:10 +0530
-Subject: [PATCH 2/3] windows-makefile.tmpl: Fix ONECORE build
-
-setargv.obj is not buildable:
-
-```
-        link /nologo /debug /subsystem:console /opt:ref /NODEFAULTLIB:kernel32.lib /nologo /debug /out:apps\openssl.exe @C:/Users/nirbheek/AppData/Local/Temp\nm76E2.tmp
-LINK : fatal error LNK1181: cannot open input file 'setargv.obj'
-NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\link.EXE"' : return code '0x49d'
-Stop.
-NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\nmake.exe"' : return code '0x2'
-Stop.
-```
----
- Configurations/windows-makefile.tmpl | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
-index ca05fa4..e573f58 100644
---- a/Configurations/windows-makefile.tmpl
-+++ b/Configurations/windows-makefile.tmpl
-@@ -752,7 +752,6 @@ $bin$exeext: $deps
- 	IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
- 	\$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
- $objs
--setargv.obj
- $linklibs\$(BIN_EX_LIBS)
- <<
- 	IF EXIST $bin$exeext.manifest \\
--- 
-2.27.0.windows.1
-
diff --git a/recipes/openssl/0003-windows-makefile.tmpl-Do-not-prefix-import-libraries.patch b/recipes/openssl/0003-windows-makefile.tmpl-Do-not-prefix-import-libraries.patch
deleted file mode 100644
index 8dbc3dc7..00000000
--- a/recipes/openssl/0003-windows-makefile.tmpl-Do-not-prefix-import-libraries.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 1802e7c87fd9a6ba76e04b32ba258079ee94b2d4 Mon Sep 17 00:00:00 2001
-From: Nirbheek Chauhan <nirbheek@centricular.com>
-Date: Tue, 9 Jun 2020 18:55:35 +0530
-Subject: [PATCH 3/3] windows-makefile.tmpl: Do not prefix import libraries
- with 'lib'
-
-We want ssl.lib and crypto.lib, which matches libssl.dll.a and
-libcrypto.dll.a since all of them can be found by GCC with -lfoo
----
- Configurations/windows-makefile.tmpl | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
-index e573f58..c70f821 100644
---- a/Configurations/windows-makefile.tmpl
-+++ b/Configurations/windows-makefile.tmpl
-@@ -48,7 +48,7 @@
-  sub shlib_import {
-      my $lib = shift;
-      return () if $disabled{shared} || $lib =~ /\.a$/;
--     return $lib . $shlibextimport;
-+     return substr($lib, 3) . $shlibextimport;
-  }
- 
-  sub dso {
--- 
-2.27.0.windows.1
-
-- 
2.31.1

