Blame SOURCES/0035-Modify-DH-enablement-patch-to-build-with-OpenSSL-1.1.patch

90e381
From 6c8dd87f311e411bcb1c72c1c780497881a5621c Mon Sep 17 00:00:00 2001
90e381
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
90e381
Date: Mon, 4 Sep 2017 11:32:03 +0200
90e381
Subject: [PATCH 35/59] Modify DH enablement patch to build with OpenSSL 1.1
90e381
90e381
---
90e381
 ssl.c | 41 ++++++++++++++++++++++++++++++++++++++---
90e381
 1 file changed, 38 insertions(+), 3 deletions(-)
90e381
90e381
diff --git a/ssl.c b/ssl.c
90e381
index ba8a613..09ec96a 100644
90e381
--- a/ssl.c
90e381
+++ b/ssl.c
90e381
@@ -88,19 +88,54 @@ static struct mystr debug_str;
90e381
 }
90e381
 #endif
90e381
 
90e381
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
90e381
+int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
90e381
+{
90e381
+  /* If the fields p and g in d are NULL, the corresponding input
90e381
+   * parameters MUST be non-NULL.  q may remain NULL.
90e381
+   */
90e381
+  if ((dh->p == NULL && p == NULL)
90e381
+      || (dh->g == NULL && g == NULL))
90e381
+    return 0;
90e381
+
90e381
+  if (p != NULL) {
90e381
+    BN_free(dh->p);
90e381
+    dh->p = p;
90e381
+  }
90e381
+  if (q != NULL) {
90e381
+    BN_free(dh->q);
90e381
+    dh->q = q;
90e381
+  }
90e381
+  if (g != NULL) {
90e381
+    BN_free(dh->g);
90e381
+    dh->g = g;
90e381
+  }
90e381
+
90e381
+  if (q != NULL) {
90e381
+    dh->length = BN_num_bits(q);
90e381
+  }
90e381
+
90e381
+  return 1;
90e381
+}
90e381
+#endif
90e381
+
90e381
 #if !defined(DH_get_dh)
90e381
   // Grab DH parameters
90e381
   DH *
90e381
   DH_get_dh(int size)
90e381
   {
90e381
+    BIGNUM *g = NULL;
90e381
+    BIGNUM *p = NULL;
90e381
     DH *dh = DH_new();
90e381
     if (!dh) {
90e381
       return NULL;
90e381
     }
90e381
-    dh->p = DH_get_prime(match_dh_bits(size));
90e381
-    BN_dec2bn(&dh->g, "2");
90e381
-    if (!dh->p || !dh->g)
90e381
+    p = DH_get_prime(match_dh_bits(size));
90e381
+    BN_dec2bn(&g, "2");
90e381
+    if (!p || !g || !DH_set0_pqg(dh, p, NULL, g))
90e381
     {
90e381
+      BN_free(g);
90e381
+      BN_free(p);
90e381
       DH_free(dh);
90e381
       return NULL;
90e381
     }
90e381
-- 
90e381
2.14.4
90e381