|
|
debe55 |
From c746b2a3bd8ae3b76740e2b4f2cf12646eedbb51 Mon Sep 17 00:00:00 2001
|
|
|
debe55 |
From: Jeremy Barton <jbarton@microsoft.com>
|
|
|
debe55 |
Date: Sat, 21 Aug 2021 05:05:19 -0700
|
|
|
debe55 |
Subject: [PATCH 10/11] Stop using ERR_GET_FUNC, since it has been removed in
|
|
|
debe55 |
OSSL3 Beta2. (#57869)
|
|
|
debe55 |
|
|
|
debe55 |
---
|
|
|
debe55 |
.../openssl.c | 25 +++++++++++--------
|
|
|
debe55 |
.../opensslshim.h | 2 ++
|
|
|
debe55 |
2 files changed, 16 insertions(+), 11 deletions(-)
|
|
|
debe55 |
|
|
|
debe55 |
diff --git a/src/Native/Unix/System.Security.Cryptography.Native/openssl.c b/src/Native/Unix/System.Security.Cryptography.Native/openssl.c
|
|
|
debe55 |
index 6792bdb1a1..e55486dc80 100644
|
|
|
debe55 |
--- a/src/Native/Unix/System.Security.Cryptography.Native/openssl.c
|
|
|
debe55 |
+++ b/src/Native/Unix/System.Security.Cryptography.Native/openssl.c
|
|
|
debe55 |
@@ -1064,27 +1064,30 @@ int32_t CryptoNative_LookupFriendlyNameByOid(const char* oidValue, const char**
|
|
|
debe55 |
return -2;
|
|
|
debe55 |
}
|
|
|
debe55 |
|
|
|
debe55 |
+ // First, check if oidValue parses as a dotted decimal OID. If not, we'll
|
|
|
debe55 |
+ // return not-found and let the system cache that.
|
|
|
debe55 |
+ int asnRet = a2d_ASN1_OBJECT(NULL, 0, oidValue, -1);
|
|
|
debe55 |
+
|
|
|
debe55 |
+ if (asnRet <= 0)
|
|
|
debe55 |
+ {
|
|
|
debe55 |
+ return 0;
|
|
|
debe55 |
+ }
|
|
|
debe55 |
+
|
|
|
debe55 |
// Do a lookup with no_name set. The purpose of this function is to map only the
|
|
|
debe55 |
// dotted decimal to the friendly name. "sha1" in should not result in "sha1" out.
|
|
|
debe55 |
oid = OBJ_txt2obj(oidValue, 1);
|
|
|
debe55 |
|
|
|
debe55 |
- if (!oid)
|
|
|
debe55 |
+ if (oid == NULL)
|
|
|
debe55 |
{
|
|
|
debe55 |
- unsigned long err = ERR_peek_last_error();
|
|
|
debe55 |
-
|
|
|
debe55 |
- // If the most recent error pushed onto the error queue is NOT from OID parsing
|
|
|
debe55 |
- // then signal for an exception to be thrown.
|
|
|
debe55 |
- if (err != 0 && ERR_GET_FUNC(err) != ASN1_F_A2D_ASN1_OBJECT)
|
|
|
debe55 |
- {
|
|
|
debe55 |
- return -1;
|
|
|
debe55 |
- }
|
|
|
debe55 |
-
|
|
|
debe55 |
- return 0;
|
|
|
debe55 |
+ // We know that the OID parsed (unless it underwent concurrent modification,
|
|
|
debe55 |
+ // which is unsupported), so any error in this stage should be an exception.
|
|
|
debe55 |
+ return -1;
|
|
|
debe55 |
}
|
|
|
debe55 |
|
|
|
debe55 |
// Look in the predefined, and late-registered, OIDs list to get the lookup table
|
|
|
debe55 |
// identifier for this OID. The OBJ_txt2obj object will not have ln set.
|
|
|
debe55 |
nid = OBJ_obj2nid(oid);
|
|
|
debe55 |
+ ASN1_OBJECT_free(oid);
|
|
|
debe55 |
|
|
|
debe55 |
if (nid == NID_undef)
|
|
|
debe55 |
{
|
|
|
debe55 |
diff --git a/src/Native/Unix/System.Security.Cryptography.Native/opensslshim.h b/src/Native/Unix/System.Security.Cryptography.Native/opensslshim.h
|
|
|
debe55 |
index b0d1a71671..c11285e7dd 100644
|
|
|
debe55 |
--- a/src/Native/Unix/System.Security.Cryptography.Native/opensslshim.h
|
|
|
debe55 |
+++ b/src/Native/Unix/System.Security.Cryptography.Native/opensslshim.h
|
|
|
debe55 |
@@ -148,6 +148,7 @@ void SSL_get0_alpn_selected(const SSL* ssl, const unsigned char** protocol, unsi
|
|
|
debe55 |
// that needs to be added.
|
|
|
debe55 |
|
|
|
debe55 |
#define FOR_ALL_OPENSSL_FUNCTIONS \
|
|
|
debe55 |
+ REQUIRED_FUNCTION(a2d_ASN1_OBJECT) \
|
|
|
debe55 |
REQUIRED_FUNCTION(ASN1_BIT_STRING_free) \
|
|
|
debe55 |
REQUIRED_FUNCTION(ASN1_d2i_bio) \
|
|
|
debe55 |
REQUIRED_FUNCTION(ASN1_i2d_bio) \
|
|
|
debe55 |
@@ -554,6 +555,7 @@ FOR_ALL_OPENSSL_FUNCTIONS
|
|
|
debe55 |
|
|
|
debe55 |
// Redefine all calls to OpenSSL functions as calls through pointers that are set
|
|
|
debe55 |
// to the functions from the libssl.so selected by the shim.
|
|
|
debe55 |
+#define a2d_ASN1_OBJECT a2d_ASN1_OBJECT_ptr
|
|
|
debe55 |
#define ASN1_BIT_STRING_free ASN1_BIT_STRING_free_ptr
|
|
|
debe55 |
#define ASN1_GENERALIZEDTIME_free ASN1_GENERALIZEDTIME_free_ptr
|
|
|
debe55 |
#define ASN1_d2i_bio ASN1_d2i_bio_ptr
|
|
|
debe55 |
--
|
|
|
debe55 |
2.31.1
|
|
|
debe55 |
|