From 71751d30ca6bdae6c62e41b8bdd20eb69cecd556 Mon Sep 17 00:00:00 2001
From: Kai Kang <kai.kang@windriver.com>
Date: Wed, 1 Nov 2017 09:23:41 -0400
Subject: [PATCH] stunnel: fix compile error when openssl disable des support

Upstream-Status: Pending

When openssl disable des support with configure option 'no-des', it doesn't
provide des related header file and functions. That causes stunnel compile
failed. Fix it by checking macro OPENSSL_NO_DES to use openssl des related
library conditionaly.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 src/common.h   | 2 ++
 src/protocol.c | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/common.h b/src/common.h
index f112cf9..8d4be01 100644
--- a/src/common.h
+++ b/src/common.h
@@ -496,7 +496,9 @@ extern char *sys_errlist[];
 #ifndef OPENSSL_NO_MD4
 #include <openssl/md4.h>
 #endif /* !defined(OPENSSL_NO_MD4) */
+#ifndef OPENSSL_NO_DES
 #include <openssl/des.h>
+#endif
 #ifndef OPENSSL_NO_DH
 #include <openssl/dh.h>
 #if OPENSSL_VERSION_NUMBER<0x10100000L
diff --git a/src/protocol.c b/src/protocol.c
index 616a65f..5ccbcb0 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -82,7 +82,7 @@ NOEXPORT void ldap_client_middle(CLI *);
 NOEXPORT void connect_server_early(CLI *);
 NOEXPORT const char *connect_client_init(SERVICE_OPTIONS *);
 NOEXPORT void connect_client_middle(CLI *);
-#ifndef OPENSSL_NO_MD4
+#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DES)
 NOEXPORT void ntlm(CLI *);
 NOEXPORT char *ntlm1(void);
 NOEXPORT char *ntlm3(char *, char *, char *, char *);
@@ -1391,7 +1391,7 @@ NOEXPORT void connect_client_middle(CLI *c) {
     fd_printf(c, c->remote_fd.fd, "Host: %s", c->opt->protocol_host);
     if(c->opt->protocol_username && c->opt->protocol_password) {
         if(!strcasecmp(c->opt->protocol_authentication, "ntlm")) {
-#ifndef OPENSSL_NO_MD4
+#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DES)
             ntlm(c);
 #else
             s_log(LOG_ERR, "NTLM authentication is not available");
@@ -1434,7 +1434,7 @@ NOEXPORT void connect_client_middle(CLI *c) {
     str_free(line);
 }
 
-#ifndef OPENSSL_NO_MD4
+#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DES)
 
 /*
  * NTLM code is based on the following documentation:
