From a2673b5e2e95bcf54a1746bfd409cca688275e75 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Wed, 6 Mar 2024 19:17:17 +0100
Subject: [PATCH 46/49] 0116-version-aliasing.patch

Patch-name: 0116-version-aliasing.patch
Patch-id: 116
Patch-status: |
    # Add version aliasing due to
    # https://github.com/openssl/openssl/issues/23534
From-dist-git-commit: 4334bc837fbc64d14890fdc51679a80770d498ce
---
 crypto/evp/digest.c                    | 7 ++++++-
 crypto/evp/evp_enc.c                   | 7 ++++++-
 test/recipes/01-test_symbol_presence.t | 1 +
 util/libcrypto.num                     | 2 ++
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 42331703da..3a280acc0e 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -553,7 +553,12 @@ legacy:
     return ret;
 }
 
-EVP_MD_CTX *EVP_MD_CTX_dup(const EVP_MD_CTX *in)
+EVP_MD_CTX
+#if !defined(FIPS_MODULE)
+__attribute__ ((symver ("EVP_MD_CTX_dup@@OPENSSL_3.1.0"),
+                    symver ("EVP_MD_CTX_dup@OPENSSL_3.2.0")))
+#endif
+*EVP_MD_CTX_dup(const EVP_MD_CTX *in)
 {
     EVP_MD_CTX *out = EVP_MD_CTX_new();
 
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index e9faf31057..5a29b8dbb7 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -1444,7 +1444,12 @@ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
 #endif /* FIPS_MODULE */
 }
 
-EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in)
+EVP_CIPHER_CTX
+#if !defined(FIPS_MODULE)
+__attribute__ ((symver ("EVP_CIPHER_CTX_dup@@OPENSSL_3.1.0"),
+                    symver ("EVP_CIPHER_CTX_dup@OPENSSL_3.2.0")))
+#endif
+*EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in)
 {
     EVP_CIPHER_CTX *out = EVP_CIPHER_CTX_new();
 
diff --git a/test/recipes/01-test_symbol_presence.t b/test/recipes/01-test_symbol_presence.t
index 222b1886ae..7e2f65cccb 100644
--- a/test/recipes/01-test_symbol_presence.t
+++ b/test/recipes/01-test_symbol_presence.t
@@ -185,6 +185,8 @@ foreach (sort keys %stlibname) {
     }
 }
 my @duplicates = sort grep { $symbols{$_} > 1 } keys %symbols;
+@duplicates = grep {($_ ne "OPENSSL_ia32cap_P") && ($_ ne "EVP_CIPHER_CTX_dup") && ($_ ne "EVP_MD_CTX_dup") } @duplicates;
+@duplicates = grep {($_ ne "OPENSSL_strcasecmp") && ($_ ne "OPENSSL_strncasecmp") } @duplicates;
 if (@duplicates) {
     note "Duplicates:";
     note join('\n', @duplicates);
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 8046454025..068e9904e2 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -5435,7 +5435,9 @@ X509_PUBKEY_set0_public_key             5562	3_2_0	EXIST::FUNCTION:
 OSSL_STACK_OF_X509_free                 5563	3_2_0	EXIST::FUNCTION:
 OSSL_trace_string                       5564	3_2_0	EXIST::FUNCTION:
 EVP_MD_CTX_dup                          5565	3_2_0	EXIST::FUNCTION:
+EVP_MD_CTX_dup                          ?	    3_1_0	EXIST::FUNCTION:
 EVP_CIPHER_CTX_dup                      5566	3_2_0	EXIST::FUNCTION:
+EVP_CIPHER_CTX_dup                      ?    	3_1_0	EXIST::FUNCTION:
 BN_signed_bin2bn                        5567	3_2_0	EXIST::FUNCTION:
 BN_signed_bn2bin                        5568	3_2_0	EXIST::FUNCTION:
 BN_signed_lebin2bn                      5569	3_2_0	EXIST::FUNCTION:
-- 
2.44.0

