Gert Doering has uploaded a new patch set (#3) to the change originally created 
by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2203?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by Gert Doering


Change subject: proxy: drop always-on PROXY_DIGEST_AUTH guards
......................................................................

proxy: drop always-on PROXY_DIGEST_AUTH guards

PROXY_DIGEST_AUTH is unconditionally defined to 1. Remove it and its
#if blocks. In the digest branch of establish_http_proxy_passthru(),
also drop the re-check of auth_method == HTTP_AUTH_DIGEST, which the
enclosing condition already guarantees, and its dead else.

Change-Id: Ice2151259fcaa256d7aee588bc3d68c835ea9eb8
Signed-off-by: Razvan Cojocaru <[email protected]>
Acked-by: Gert Doering <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2203
Message-Id: <[email protected]>
URL: 
https://www.mail-archive.com/[email protected]/msg41494.html
Signed-off-by: Gert Doering <[email protected]>
---
M src/openvpn/httpdigest.c
M src/openvpn/httpdigest.h
M src/openvpn/proxy.c
M src/openvpn/syshead.h
4 files changed, 93 insertions(+), 121 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/03/2203/3

diff --git a/src/openvpn/httpdigest.c b/src/openvpn/httpdigest.c
index 9bfa074..a6803e9 100644
--- a/src/openvpn/httpdigest.c
+++ b/src/openvpn/httpdigest.c
@@ -26,8 +26,6 @@

 #include "syshead.h"

-#if PROXY_DIGEST_AUTH
-
 #include "crypto.h"
 #include "httpdigest.h"

@@ -141,5 +139,3 @@
     md_ctx_free(md5_ctx);
     CvtHex(RespHash, Response);
 }
-
-#endif /* if PROXY_DIGEST_AUTH */
diff --git a/src/openvpn/httpdigest.h b/src/openvpn/httpdigest.h
index 37f3d98..20db1c4 100644
--- a/src/openvpn/httpdigest.h
+++ b/src/openvpn/httpdigest.h
@@ -20,8 +20,6 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */

-#if PROXY_DIGEST_AUTH
-
 #define HASHLEN 16
 typedef unsigned char HASH[HASHLEN];
 #define HASHHEXLEN 32
@@ -42,5 +40,3 @@
                         const HASHHEX HEntity,     /* H(entity body) if 
qop="auth-int" */
                         HASHHEX Response           /* request-digest or 
response-digest */
 );
-
-#endif /* if PROXY_DIGEST_AUTH */
diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c
index cd9f3b2..437733e 100644
--- a/src/openvpn/proxy.c
+++ b/src/openvpn/proxy.c
@@ -348,14 +348,12 @@
                 *data = string_alloc(buf + 26, NULL);
                 ret = HTTP_AUTH_BASIC;
             }
-#if PROXY_DIGEST_AUTH
             else if (!strncmp(buf + 20, "Digest ", 7))
             {
                 msg(D_PROXY, "PROXY AUTH DIGEST: '%s'", buf);
                 *data = string_alloc(buf + 27, NULL);
                 ret = HTTP_AUTH_DIGEST;
             }
-#endif
         }
     }
 }
@@ -714,121 +712,108 @@
         {
             processed = true;
         }
-#if PROXY_DIGEST_AUTH
         else if (p->auth_method == HTTP_AUTH_DIGEST && !processed)
         {
             const char *pa = p->proxy_authenticate;
-            const int method = p->auth_method;
             ASSERT(pa);

-            if (method == HTTP_AUTH_DIGEST)
+            const char *http_method = "CONNECT";
+            const char *nonce_count = "00000001";
+            const char *qop = "auth";
+            const char *username = p->up.username;
+            const char *password = p->up.password;
+            char *opaque_kv = "";
+            char uri[128];
+            uint8_t cnonce_raw[8];
+            HASHHEX session_key;
+            HASHHEX response;
+
+            const char *realm = get_pa_var("realm", pa, &gc);
+            const char *nonce = get_pa_var("nonce", pa, &gc);
+            const char *algor = get_pa_var("algorithm", pa, &gc);
+            const char *opaque = get_pa_var("opaque", pa, &gc);
+
+            if (!realm || !nonce)
             {
-                const char *http_method = "CONNECT";
-                const char *nonce_count = "00000001";
-                const char *qop = "auth";
-                const char *username = p->up.username;
-                const char *password = p->up.password;
-                char *opaque_kv = "";
-                char uri[128];
-                uint8_t cnonce_raw[8];
-                uint8_t *cnonce;
-                HASHHEX session_key;
-                HASHHEX response;
-
-                const char *realm = get_pa_var("realm", pa, &gc);
-                const char *nonce = get_pa_var("nonce", pa, &gc);
-                const char *algor = get_pa_var("algorithm", pa, &gc);
-                const char *opaque = get_pa_var("opaque", pa, &gc);
-
-                if (!realm || !nonce)
-                {
-                    msg(D_LINK_ERRORS, "HTTP proxy: digest auth failed, 
malformed response "
-                                       "from server: realm= or nonce= 
missing");
-                    goto error;
-                }
-
-                /* generate a client nonce */
-                prng_bytes(cnonce_raw, sizeof(cnonce_raw));
-                cnonce = make_base64_string2(cnonce_raw, sizeof(cnonce_raw), 
&gc);
-
-
-                /* build the digest response */
-                snprintf(uri, sizeof(uri), "%s:%s", host, port);
-
-                if (opaque)
-                {
-                    const size_t len = strlen(opaque) + 16;
-                    opaque_kv = gc_malloc(len, false, &gc);
-                    snprintf(opaque_kv, len, ", opaque=\"%s\"", opaque);
-                }
-
-                DigestCalcHA1(algor, username, realm, password, nonce, (char 
*)cnonce, session_key);
-                DigestCalcResponse(session_key, nonce, nonce_count, (char 
*)cnonce, qop,
-                                   http_method, uri, NULL, response);
-
-                /* format HTTP CONNECT message */
-                snprintf(buf, sizeof(buf), "%s %s HTTP/%s", http_method, uri,
-                         p->options.http_version);
-
-                msg(D_PROXY, "Send to HTTP proxy: '%s'", buf);
-
-                /* send HTTP CONNECT message to proxy */
-                if (!send_line_crlf(sd, buf))
-                {
-                    goto error;
-                }
-
-                /* send HOST etc, */
-                if (!add_proxy_headers(p, sd, host))
-                {
-                    goto error;
-                }
-
-                /* send digest response */
-                if (!checked_snprintf(
-                        buf, sizeof(buf),
-                        "Proxy-Authorization: Digest username=\"%s\", 
realm=\"%s\", nonce=\"%s\", uri=\"%s\", qop=%s, nc=%s, cnonce=\"%s\", 
response=\"%s\"%s",
-                        username, realm, nonce, uri, qop, nonce_count, cnonce, 
response, opaque_kv))
-                {
-                    goto error;
-                }
-
-                msg(D_PROXY, "Send to HTTP proxy: '%s'", buf);
-                if (!send_line_crlf(sd, buf))
-                {
-                    goto error;
-                }
-                if (!send_crlf(sd))
-                {
-                    goto error;
-                }
-                /* clear any sensitive content in buf */
-                secure_memzero(buf, sizeof(buf));
-
-                /* receive reply from proxy */
-                if (!recv_line(sd, buf, sizeof(buf),
-                               
get_server_poll_remaining_time(server_poll_timeout), true, NULL,
-                               signal_received))
-                {
-                    goto error;
-                }
-
-                /* remove trailing CR, LF */
-                chomp(buf);
-
-                msg(D_PROXY, "HTTP proxy returned: '%s'", buf);
-
-                /* parse return string */
-                nparms = sscanf(buf, "%*s %d", &status);
-                processed = true;
-            }
-            else
-            {
-                msg(D_PROXY, "HTTP proxy: digest method not supported");
+                msg(D_LINK_ERRORS, "HTTP proxy: digest auth failed, malformed 
response "
+                                   "from server: realm= or nonce= missing");
                 goto error;
             }
+
+            /* generate a client nonce */
+            prng_bytes(cnonce_raw, sizeof(cnonce_raw));
+            uint8_t *cnonce = make_base64_string2(cnonce_raw, 
sizeof(cnonce_raw), &gc);
+
+            /* build the digest response */
+            snprintf(uri, sizeof(uri), "%s:%s", host, port);
+
+            if (opaque)
+            {
+                const size_t len = strlen(opaque) + 16;
+                opaque_kv = gc_malloc(len, false, &gc);
+                snprintf(opaque_kv, len, ", opaque=\"%s\"", opaque);
+            }
+
+            DigestCalcHA1(algor, username, realm, password, nonce, (char 
*)cnonce, session_key);
+            DigestCalcResponse(session_key, nonce, nonce_count, (char 
*)cnonce, qop,
+                               http_method, uri, NULL, response);
+
+            /* format HTTP CONNECT message */
+            snprintf(buf, sizeof(buf), "%s %s HTTP/%s", http_method, uri,
+                     p->options.http_version);
+
+            msg(D_PROXY, "Send to HTTP proxy: '%s'", buf);
+
+            /* send HTTP CONNECT message to proxy */
+            if (!send_line_crlf(sd, buf))
+            {
+                goto error;
+            }
+
+            /* send HOST etc, */
+            if (!add_proxy_headers(p, sd, host))
+            {
+                goto error;
+            }
+
+            /* send digest response */
+            if (!checked_snprintf(
+                    buf, sizeof(buf),
+                    "Proxy-Authorization: Digest username=\"%s\", 
realm=\"%s\", nonce=\"%s\", uri=\"%s\", qop=%s, nc=%s, cnonce=\"%s\", 
response=\"%s\"%s",
+                    username, realm, nonce, uri, qop, nonce_count, cnonce, 
response, opaque_kv))
+            {
+                goto error;
+            }
+
+            msg(D_PROXY, "Send to HTTP proxy: '%s'", buf);
+            if (!send_line_crlf(sd, buf))
+            {
+                goto error;
+            }
+            if (!send_crlf(sd))
+            {
+                goto error;
+            }
+            /* clear any sensitive content in buf */
+            secure_memzero(buf, sizeof(buf));
+
+            /* receive reply from proxy */
+            if (!recv_line(sd, buf, sizeof(buf),
+                           
get_server_poll_remaining_time(server_poll_timeout), true, NULL,
+                           signal_received))
+            {
+                goto error;
+            }
+
+            /* remove trailing CR, LF */
+            chomp(buf);
+
+            msg(D_PROXY, "HTTP proxy returned: '%s'", buf);
+
+            /* parse return string */
+            nparms = sscanf(buf, "%*s %d", &status);
+            processed = true;
         }
-#endif /* if PROXY_DIGEST_AUTH */
         else if (p->options.auth_retry)
         {
             /* figure out what kind of authentication the proxy needs */
diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h
index 65baee3..8f27436 100644
--- a/src/openvpn/syshead.h
+++ b/src/openvpn/syshead.h
@@ -480,11 +480,6 @@
 #endif

 /*
- * Should we include proxy digest auth functionality
- */
-#define PROXY_DIGEST_AUTH 1
-
-/*
  * Do we have CryptoAPI capability?
  */
 #if defined(_WIN32) && defined(ENABLE_CRYPTO_OPENSSL) && 
!defined(ENABLE_CRYPTO_WOLFSSL)

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2203?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ice2151259fcaa256d7aee588bc3d68c835ea9eb8
Gerrit-Change-Number: 2203
Gerrit-PatchSet: 3
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to