1From 7ff4eba20b5c4fc7365e5ee0dfb775ed29bdd5ce Mon Sep 17 00:00:00 2001
2From: Kai Kang <kai.kang@windriver.com>
3Date: Wed, 1 Nov 2017 09:23:41 -0400
4Subject: [PATCH] stunnel: fix compile error when openssl disable des support
5
6Upstream-Status: Pending
7
8When openssl disable des support with configure option 'no-des', it doesn't
9provide des related header file and functions. That causes stunnel compile
10failed. Fix it by checking macro OPENSSL_NO_DES to use openssl des related
11library conditionaly.
12
13Signed-off-by: Kai Kang <kai.kang@windriver.com>
14
15---
16 src/common.h   | 2 ++
17 src/protocol.c | 6 +++---
18 2 files changed, 5 insertions(+), 3 deletions(-)
19
20diff --git a/src/common.h b/src/common.h
21index bc37eb5..03ee3e5 100644
22--- a/src/common.h
23+++ b/src/common.h
24@@ -486,7 +486,9 @@ extern char *sys_errlist[];
25 #ifndef OPENSSL_NO_MD4
26 #include <openssl/md4.h>
27 #endif /* !defined(OPENSSL_NO_MD4) */
28+#ifndef OPENSSL_NO_DES
29 #include <openssl/des.h>
30+#endif
31 #ifndef OPENSSL_NO_DH
32 #include <openssl/dh.h>
33 #if OPENSSL_VERSION_NUMBER<0x10100000L
34diff --git a/src/protocol.c b/src/protocol.c
35index 804f115..d9b2b50 100644
36--- a/src/protocol.c
37+++ b/src/protocol.c
38@@ -66,7 +66,7 @@ NOEXPORT char *nntp_client(CLI *, SERVICE_OPTIONS *, const PHASE);
39 NOEXPORT char *ldap_client(CLI *, SERVICE_OPTIONS *, const PHASE);
40 NOEXPORT char *connect_server(CLI *, SERVICE_OPTIONS *, const PHASE);
41 NOEXPORT char *connect_client(CLI *, SERVICE_OPTIONS *, const PHASE);
42-#ifndef OPENSSL_NO_MD4
43+#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DES)
44 NOEXPORT void ntlm(CLI *, SERVICE_OPTIONS *);
45 NOEXPORT char *ntlm1(void);
46 NOEXPORT char *ntlm3(char *, char *, char *, char *);
47@@ -1351,7 +1351,7 @@ NOEXPORT char *connect_client(CLI *c, SERVICE_OPTIONS *opt, const PHASE phase) {
48     fd_printf(c, c->remote_fd.fd, "Host: %s", opt->protocol_host);
49     if(opt->protocol_username && opt->protocol_password) {
50         if(!strcasecmp(opt->protocol_authentication, "ntlm")) {
51-#ifndef OPENSSL_NO_MD4
52+#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DES)
53             ntlm(c, opt);
54 #else
55             s_log(LOG_ERR, "NTLM authentication is not available");
56@@ -1395,7 +1395,7 @@ NOEXPORT char *connect_client(CLI *c, SERVICE_OPTIONS *opt, const PHASE phase) {
57     return NULL;
58 }
59
60-#ifndef OPENSSL_NO_MD4
61+#if !defined(OPENSSL_NO_MD4) && !defined(OPENSSL_NO_DES)
62
63 /*
64  * NTLM code is based on the following documentation:
65