Skip to contentSkip to conversation

Remove AUTO_USERID feature

PATCH In review Arne Schwabe 3 participants 7 messages Oct 8, 2018 – Oct 9, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]...

#1 lore raw

PATCH 2/4 Remove AUTO_USERID feature

There is no user facing way to enable this feature and way that feature works (username build from MAC of primary net device) is questionable.

It also does not compile anymore.

---
 src/openvpn/errlevel.h |  1 -
 src/openvpn/misc.c     | 45 ------------------------------------------
 src/openvpn/misc.h     |  5 -----
 src/openvpn/ssl.c      |  4 ----
 src/openvpn/syshead.h  |  9 ---------
 5 files changed, 64 deletions(-)
src/openvpn/errlevel.h +0 -1
index 5ca4fa8f..c30284fc 100644
@@ -139,7 +139,6 @@
 #define D_PACKET_TRUNC_DEBUG LOGLEV(7, 70, M_DEBUG)  /* PACKET_TRUNCATION_CHECK verbose */
 #define D_PING               LOGLEV(7, 70, M_DEBUG)  /* PING send/receive messages */
 #define D_PS_PROXY_DEBUG     LOGLEV(7, 70, M_DEBUG)  /* port share proxy debug */
-#define D_AUTO_USERID        LOGLEV(7, 70, M_DEBUG)  /* AUTO_USERID debugging */
 #define D_TLS_KEYSELECT      LOGLEV(7, 70, M_DEBUG)  /* show information on key selection for data channel */
 #define D_ARGV_PARSE_CMD     LOGLEV(7, 70, M_DEBUG)  /* show parse_line() errors in argv_parse_cmd */
 #define D_CRYPTO_DEBUG       LOGLEV(7, 70, M_DEBUG)  /* show detailed info from crypto.c routines */
src/openvpn/misc.c +0 -45

51 lines not on this page · raw message

src/openvpn/misc.h +0 -5
index 7092685f..fad53de8 100644
@@ -158,11 +158,6 @@ void configure_path(void);
 
 const char *sanitize_control_message(const char *str, struct gc_arena *gc);
 
-#if AUTO_USERID
-void get_user_pass_auto_userid(struct user_pass *up, const char *tag);
-
-#endif
-
 /*
  * /sbin/ip path, may be overridden
  */
src/openvpn/ssl.c +0 -4
index 0a947c6e..5a136d69 100644
@@ -410,9 +410,6 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info *
     auth_user_pass_enabled = true;
     if (!auth_user_pass.defined && !auth_token.defined)
     {
-#if AUTO_USERID
-        get_user_pass_auto_userid(&auth_user_pass, auth_file);
-#else
 #ifdef ENABLE_MANAGEMENT
         if (auth_challenge) /* dynamic challenge/response */
         {
@@ -438,7 +435,6 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info *
         else
 #endif /* ifdef ENABLE_MANAGEMENT */
         get_user_pass(&auth_user_pass, auth_file, UP_TYPE_AUTH, GET_USER_PASS_MANAGEMENT);
-#endif /* if AUTO_USERID */
     }
 }
 
src/openvpn/syshead.h +0 -9
index 807f7b9b..d2a50341 100644
@@ -643,15 +643,6 @@ socket_defined(const socket_descriptor_t sd)
 #define CONNECT_NONBLOCK
 #endif
 
-/*
- * Do we have the capability to support the AUTO_USERID feature?
- */
-#if defined(ENABLE_AUTO_USERID)
-#define AUTO_USERID 1
-#else
-#define AUTO_USERID 0
-#endif
-
 /*
  * Compression support
  */
Signature · 1 line
2.19.0
#2 lore raw

Hi,

Quoted 4 lines · Arne Schwabe

There is no user facing way to enable this feature and way that feature works (username build from MAC of primary net device) is questionable.

It also does not compile anymore.

Feature-ACK, but the patch itself puzzles me.

Quoted 5 lines
src/openvpn/misc.c +0 -1
@@ -455,51 +455,6 @@ get_auth_challenge(const char *auth_challenge, struct gc_arena *gc)
 
 #endif /* ifdef ENABLE_MANAGEMENT */
 
-#if AUTO_USERID

[..]

src/openvpn/ssl.c auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * · line 413

Quoted 12 lines
src/openvpn/ssl.c +0 -3
index 0a947c6e..5a136d69 100644
@@ -410,9 +410,6 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info *
     auth_user_pass_enabled = true;
     if (!auth_user_pass.defined && !auth_token.defined)
     {
-#if AUTO_USERID
-        get_user_pass_auto_userid(&auth_user_pass, auth_file);
-#else
 #ifdef ENABLE_MANAGEMENT

These hunks have "ENABLE_MANAGEMENT" in the context, while all my branches (2.3, 2.4, master) have "ENABLE_CLIENT_CR" here.

This is not really needed to remove the (questionable) feature - and I can just adjust the patch on the fly - but I wonder where these are coming from in your tree, and whether I missed (or messed up) something...

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#3 lore raw

Am 08.10.18 um 21:37 schrieb Gert Doering:

Quoted 32 lines

Hi,

Quoted 4 lines · Arne Schwabe

There is no user facing way to enable this feature and way that feature works (username build from MAC of primary net device) is questionable.

It also does not compile anymore.

Feature-ACK, but the patch itself puzzles me.

Quoted 5 lines
src/openvpn/misc.c +0 -1
@@ -455,51 +455,6 @@ get_auth_challenge(const char *auth_challenge, struct gc_arena *gc)
 
 #endif /* ifdef ENABLE_MANAGEMENT */
 
-#if AUTO_USERID

[..]

src/openvpn/ssl.c auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * · line 413

Quoted 12 lines
src/openvpn/ssl.c +0 -3
index 0a947c6e..5a136d69 100644
@@ -410,9 +410,6 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info *
     auth_user_pass_enabled = true;
     if (!auth_user_pass.defined && !auth_token.defined)
     {
-#if AUTO_USERID
-        get_user_pass_auto_userid(&auth_user_pass, auth_file);
-#else
 #ifdef ENABLE_MANAGEMENT

These hunks have "ENABLE_MANAGEMENT" in the context, while all my branches (2.3, 2.4, master) have "ENABLE_CLIENT_CR" here.

Quoted 4 lines

This is not really needed to remove the (questionable) feature - and I can just adjust the patch on the fly - but I wonder where these are coming from in your tree, and whether I missed (or messed up) something...

You are missing patch 1/4:

[PATCH 1/4] Remove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR

Is being held until the list moderator can review it for approval.

The reason it is being held:

Message body is too big: 309191 bytes with a limit of 256 KB

But since it now does not apply anymore since 2/4 got in first, I will resend that mail and canceld the message request.

Arne

Acked-by on v1 2/4
#4 lore raw
In reply to Arne Schwabe

For the reasons given - it's code that has not been activated anywhere in the last 5+ years, there is no way to turn it on by configure, and it's likely not working right on half the platforms. And less #ifdef!

I had to whack the patch to make it apply - no changes to the actual code, but the context was full of ENABLE_MANAGEMENT where our tree has ENABLE_CLIENT_CR. I seem to remember that there was a patch to get rid of the letter (because it is auto-defined #if ENABLE_MANAGEMENT) but we seem to have lost track of it... only your tree remembers.

Your patch has been applied to the master branch.

commit 00d78cd57fa52aa5a65df1707922791e72313663

Author: Arne Schwabe
Date:   Mon Oct 8 20:16:16 2018 +0200
     Remove AUTO_USERID feature

     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg17664.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
Quoted 5 lines · Gert Doering

For the reasons given - it's code that has not been activated anywhere in the last 5+ years, there is no way to turn it on by configure, and it's likely not working right on half the platforms. And less #ifdef!

And to add a bit more background; we discussed this with James directly, who also said this AUTO_USERID feature is not used anywhere he was aware of; most likely for specific use case for a side project he was involved in. Anyhow, James didn't think this feature had any value any more.

Arne: Lately you've often forgotten to add -s to git commit. Please double check your patches in this regard.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#6 lore raw

PATCH 3/4 Add support for OpenSSL TLS 1.3 when using management-external-key

In reply to a message not in the archive

For TLS 1.0 to 1.2 OpenSSL calls us and requires a PKCS1 padded response, for TLS 1.3 it requires to an unpadded response. Since we can PCKS1 pad an unpadded response, we prefer to always query for an unpadded response from the management interface and add the PCKS1 padding ourselves when needed.

This patch adds an 'unpadded' parameter to the management-external-key option to signal that it is uses the new unpadded API. Since we cannot support TLS 1.3 without unpadded queries we disable TLS 1.3 otherwise. We also do the same for cryptoapi since it uses the same API.

Using the management api client version instead might seem like the more logical way but since we only now that version very late, it would extra logic and complexity to deal with this asynchronous behaviour .

---
 doc/management-notes.txt  |  7 ++++-
 src/openvpn/manage.h      |  9 ++++---
 src/openvpn/options.c     | 57 +++++++++++++++++++++++++++++++++++++--
 src/openvpn/ssl_openssl.c | 26 +++++++++++++-----
 4 files changed, 85 insertions(+), 14 deletions(-)
doc/management-notes.txt +6 -1
index 17645c1d..7e61ff50 100644
@@ -832,7 +832,12 @@ END
 
 Base 64 encoded output of RSA_private_encrypt for RSA or ECDSA_sign()
 for EC using OpenSSL or mbedtls_pk_sign() using mbed TLS will provide a
-correct signature.
+correct signature. With the 'nopadding' argument to the
+external-management-interface the interface expects unpadded signatures
+(RSA_NO_PADDING in OpenSSL). When the 'nopadding' keyword is missing the
+interfaces expects PKCS1 padded signatures for RSA keys (RSA_PKCS1_PADDING).
+EC signatures are always unpadded. To support TLS 1.3 using unpadded
+signatures is required.
 
 This capability is intended to allow the use of arbitrary cryptographic
 service providers with OpenVPN via the management interface.
src/openvpn/manage.h +5 -4
index d24abe09..4fe66abf 100644
@@ -343,10 +343,11 @@ struct management *management_init(void);
 #endif
 #define MF_UNIX_SOCK       (1<<8)
 #define MF_EXTERNAL_KEY    (1<<9)
-#define MF_UP_DOWN          (1<<10)
-#define MF_QUERY_REMOTE     (1<<11)
-#define MF_QUERY_PROXY      (1<<12)
-#define MF_EXTERNAL_CERT    (1<<13)
+#define MF_EXTERNAL_KEY_NOPADDING   (1<<10)
+#define MF_UP_DOWN          (1<<11)
+#define MF_QUERY_REMOTE     (1<<12)
+#define MF_QUERY_PROXY      (1<<13)
+#define MF_EXTERNAL_CERT    (1<<14)
 
 bool management_open(struct management *man,
                      const char *addr,
src/openvpn/options.c +55 -2

81 lines not on this page · raw message

src/openvpn/ssl_openssl.c +19 -7
index 3f1f4658..30320453 100644
@@ -1100,15 +1100,27 @@ openvpn_extkey_rsa_finish(RSA *rsa)
  */
 static int
 get_sig_from_man(const unsigned char *dgst, unsigned int dgstlen,
-                 unsigned char *sig, unsigned int siglen)
+                 unsigned char *sig, unsigned int siglen, bool pkcs1pad)
 {
     char *in_b64 = NULL;
     char *out_b64 = NULL;
     int len = -1;
+    int bencret = -1;
 
-    /* convert 'dgst' to base64 */
-    if (management
-        && openvpn_base64_encode(dgst, dgstlen, &in_b64) > 0)
+    if ((management->settings.flags & MF_EXTERNAL_KEY_NOPADDING) > 2 && pkcs1pad)
+    {
+        /*
+         * Add PKCS1 signature and replace input with it
+         * Use our output buffer also als temporary buffer
+         */
+        RSA_padding_add_PKCS1_type_1(sig, siglen, dgst, dgstlen);
+        bencret = openvpn_base64_encode(sig, siglen, &in_b64);
+    }
+    else
+    {
+        bencret = openvpn_base64_encode(dgst, dgstlen, &in_b64);
+    }
+    if (management && bencret > 0)
     {
         out_b64 = management_query_pk_sig(management, in_b64);
     }
@@ -1129,13 +1141,13 @@ rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, i
     unsigned int len = RSA_size(rsa);
     int ret = -1;
 
-    if (padding != RSA_PKCS1_PADDING)
+    if (padding != RSA_PKCS1_PADDING && padding != RSA_NO_PADDING)
     {
         RSAerr(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE);
         return -1;
     }
 
-    ret = get_sig_from_man(from, flen, to, len);
+    ret = get_sig_from_man(from, flen, to, len, padding == RSA_PKCS1_PADDING);
 
     return (ret == len)? ret : -1;
 }
@@ -1229,7 +1241,7 @@ ecdsa_sign(int type, const unsigned char *dgst, int dgstlen, unsigned char *sig,
            unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *ec)
 {
     int capacity = ECDSA_size(ec);
-    int len = get_sig_from_man(dgst, dgstlen, sig, capacity);
+    int len = get_sig_from_man(dgst, dgstlen, sig, capacity, false);
 
     if (len > 0)
     {
Signature · 1 line
2.19.0
#7 lore raw

PATCH 4/4 Implement the nopadding option to management-external-key for mbed TLS

In reply to a message not in the archive

Although mbed TLS does not have a TLS 1.3 API yet and we do not really know how mbed TLS will handle querying for TLS 1.3 signatures, being able to use the same API with OpenSSL and mbed TLS is a nice feature.

Since mbed TLS does not expose a way to do pkcs1 padding, copy the trimmed down version of the pkcs1 copy to the OpenVPN source code.

---
 src/openvpn/options.c     | 11 ++----
 src/openvpn/ssl_mbedtls.c | 72 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 10 deletions(-)
src/openvpn/options.c +2 -9
index 61762791..fb7d8333 100644
@@ -3025,11 +3025,11 @@ options_postprocess_verify(const struct options *o)
     }
 }
 
-#if defined(ENABLE_CRYPTOAPI) || (defined(ENABLE_CRYPTO_OPENSSL) && defined(ENABLE_MANAGEMENT))
+#if defined(ENABLE_CRYPTOAPI) || defined(ENABLE_MANAGEMENT)
 static void
 disable_tls13_if_avilable(struct options *o, const char* msg)
 {
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(ENABLE_CRYPTO_MBEDTLS)
     const int tls_version_max =
         (o->ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT) &
             SSLF_TLS_VERSION_MAX_MASK;
@@ -3134,13 +3134,6 @@ options_postprocess_mutate(struct options *o)
     }
 #endif
 
-#if defined(ENABLE_CRYPTO_MBEDTLS) && defined(MANAGMENT_EXTERNAL_KEY)
-    if (o->management_flags & MF_EXTERNAL_KEY_NOPADDING)
-    {
-        msg(M_FATAL, "mbed TLS does not support the 'nopadding' argument for the --management-external-key option");
-    }
-#endif
-
 #if defined(ENABLE_CRYPTOAPI)
     if (o->cryptoapi_cert)
     {
src/openvpn/ssl_mbedtls.c +71 -1

84 lines not on this page · raw message

Signature · 1 line
2.19.0