Re: DH_get0_pqg not defined on 5.8 master if you build without TLS transport

Robert Story <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Organization FreeSNMP
Message-ID <[email protected]>
On Wed 2017-12-20 12:13:48-0500 Bill wrote:
> > The attached patch against master builds with and without TLS
> > transports on CentOS 6 (openssl 1.0) and Fedora 27 (openssl 1.1).
> 
> Can you attach "git show" instead of "git log", or point me to your
> repo if it's public and I'll cherry-pick your changes over?

attached

-- 
Robert Story <http://www.isi.edu/~rstory>
USC Information Sciences Institute <http://www.isi.edu/>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
openssl-compat-rs.patch (text/x-patch, 3.2 KB)
commit 89c9d93f2f24cea7f8dac12d36f31daf12419203
Author: Robert Story <[email protected]>
Date:   Wed Dec 20 11:33:28 2017 -0500

    align prototype and function; remove duplicate function

diff --git a/include/net-snmp/library/snmp_openssl.h b/include/net-snmp/library/snmp_openssl.h
index 8a90d3d8e..d4c8361cd 100644
--- a/include/net-snmp/library/snmp_openssl.h
+++ b/include/net-snmp/library/snmp_openssl.h
@@ -78,7 +78,7 @@ extern          "C" {
 #endif
 #ifndef HAVE_X509_GET_SIGNATURE_NID
     NETSNMP_IMPORT
-    int X509_get_signature_nid(const X509_REQ *req);
+    int X509_get_signature_nid(const X509 *req);
 #endif
 #ifndef HAVE_TLS_METHOD
     NETSNMP_IMPORT
diff --git a/snmplib/snmp_openssl.c b/snmplib/snmp_openssl.c
index d7ec88fcf..a38612d39 100644
--- a/snmplib/snmp_openssl.c
+++ b/snmplib/snmp_openssl.c
@@ -203,7 +203,7 @@ static ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne)
 #endif
 
 #ifndef HAVE_X509_GET_SIGNATURE_NID
-static int X509_get_signature_nid(const X509 *x)
+int X509_get_signature_nid(const X509 *x)
 {
     return OBJ_obj2nid(x->sig_alg->algorithm);
 }
@@ -1006,13 +1006,6 @@ ASN1_STRING *X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne)
 }
 #endif
 
-#ifndef HAVE_X509_GET_SIGNATURE_NID
-int X509_get_signature_nid(const X509_REQ *req)
-{
-    return OBJ_obj2nid(req->sig_alg.algorithm);
-}
-#endif
-
 #ifndef HAVE_TLS_METHOD
 const SSL_METHOD *TLS_method(void)
 {

commit 18eb1be3052fe63c6e8ada1cea2409e146be9bab
Author: Robert Story <[email protected]>
Date:   Wed Dec 20 11:07:24 2017 -0500

    move compat funcs for apps to top of file

diff --git a/snmplib/snmp_openssl.c b/snmplib/snmp_openssl.c
index f44449077..d7ec88fcf 100644
--- a/snmplib/snmp_openssl.c
+++ b/snmplib/snmp_openssl.c
@@ -17,6 +17,39 @@
 
 #include <net-snmp/net-snmp-features.h>
 
+/** OpenSSL DH compat functions */
+#if defined(HAVE_OPENSSL_DH_H)
+
+#include <string.h>
+#include <openssl/dh.h>
+
+#ifndef HAVE_DH_GET0_PQG
+void
+DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
+{
+   if (p != NULL)
+       *p = dh->p;
+   if (q != NULL)
+       *q = dh->q;
+   if (g != NULL)
+       *g = dh->g;
+}
+#endif
+
+#ifndef HAVE_DH_GET0_KEY
+void
+DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
+{
+   if (pub_key != NULL)
+       *pub_key = dh->pub_key;
+   if (priv_key != NULL)
+       *priv_key = dh->priv_key;
+}
+#endif
+
+#endif /* #if defined(HAVE_OPENSSL_DH_H) */
+
+
 #if defined(NETSNMP_USE_OPENSSL) && defined(HAVE_LIBSSL) && !defined(NETSNMP_FEATURE_REMOVE_CERT_UTIL)
 
 netsnmp_feature_require(container_free_all)
@@ -948,30 +981,6 @@ DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
 }
 #endif
 
-#ifndef HAVE_DH_GET0_PQG
-void
-DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
-{
-   if (p != NULL)
-       *p = dh->p;
-   if (q != NULL)
-       *q = dh->q;
-   if (g != NULL)
-       *g = dh->g;
-}
-#endif
-
-#ifndef HAVE_DH_GET0_KEY
-void
-DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
-{
-   if (pub_key != NULL)
-       *pub_key = dh->pub_key;
-   if (priv_key != NULL)
-       *priv_key = dh->priv_key;
-}
-#endif
-
 #ifndef HAVE_ASN1_STRING_GET0_DATA
 const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
 {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.