Fix remaining issues with OFB/CFB cipher modes
PATCH 1/1 Fix remaining issues with OFB/CFB cipher modes
Hi,
OFB and CFB cipher modes have been broken for a long time, see trac ticket #89
(https://community.openvpn.net/openvpn/ticket/89). Commit be46a2c enables support for OFB and CFB again, but leaves some minor problems around. The following patches resolve the remaining issues.
Patches 1-3 fix some minor issues I encountered while testing OFB/CFB.
Patch 4 extends the t_lpback tests to prevent further regression.
-Steffan
PATCH 1/4 Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
Makes OFB/CFB compile time configurable, and fixes output of --show-ciphers to also show OFB/CFB ciphers along the way (becasue crypto.h was not included from crypto_openssl.c).
--- configure.ac | 8 ++++++++ src/openvpn/crypto.c | 2 +- src/openvpn/crypto.h | 2 -- src/openvpn/crypto_openssl.c | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-)
configure.ac +8 -0
@@ -72,6 +72,13 @@ AC_ARG_ENABLE( ) AC_ARG_ENABLE( + [ofb-cfb], + [AS_HELP_STRING([--enable-ofb-cfb], [enable support for OFB and CFB cipher modes @<:@default=yes@:>@])], + , + [enable_crypto_ofb_cfb="yes"] +) + +AC_ARG_ENABLE( [ssl], [AS_HELP_STRING([--disable-ssl], [disable SSL support for TLS-based key exchange @<:@default=yes@:>@])], ,
@@ -1093,6 +1100,7 @@ fi if test "${enable_crypto}" = "yes"; then test "${have_crypto_crypto}" != "yes" && AC_MSG_ERROR([${with_crypto_library} crypto is required but missing]) + test "${enable_crypto_ofb_cfb}" = "yes" && AC_DEFINE([ENABLE_OFB_CFB_MODE], [1], [Enable OFB and CFB cipher modes]) OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CRYPTO_CFLAGS}" OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_CRYPTO_LIBS}" AC_DEFINE([ENABLE_CRYPTO], [1], [Enable crypto library])
src/openvpn/crypto.c +1 -1
@@ -428,7 +428,7 @@ init_key_type (struct key_type *kt, const char *ciphername, {const unsigned int mode =cipher_kt_mode (kt->cipher);if (!(mode ==OPENVPN_MODE_CBC -#ifdef ALLOW_NON_CBC_CIPHERS +#ifdef ENABLE_OFB_CFB_MODE || (cfb_ofb_allowed && (mode ==OPENVPN_MODE_CFB || mode ==OPENVPN_MODE_OFB )) #endif ))
src/openvpn/crypto.h +0 -2
@@ -32,8 +32,6 @@#ifdef ENABLE_CRYPTO -#define ALLOW_NON_CBC_CIPHERS -#include "crypto_backend.h" #include "basic.h" #include "buffer.h"
src/openvpn/crypto_openssl.c +1 -1
@@ -263,7 +263,7 @@ show_available_ciphers () {const unsigned int mode =EVP_CIPHER_mode (cipher);if (mode ==EVP_CIPH_CBC_MODE -#ifdef ALLOW_NON_CBC_CIPHERS +#ifdef ENABLE_OFB_CFB_MODE || mode ==EVP_CIPH_CFB_MODE || mode ==EVP_CIPH_OFB_MODE #endif )
Signature · 1 line
1.9.1
Re: [Openvpn-devel] [PATCH 1/4] Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 5 lines
Makes OFB/CFB compile time configurable, and fixes output of --show-ciphers to also show OFB/CFB ciphers along the way (becasue
crypto.hwas not included fromcrypto_openssl.c).
ACK. But maybe we should just always enable this mode instead of having another configure option.
Arne
Re: [Openvpn-devel] [PATCH 1/4] Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
Quoted 9 lines · Arne Schwabe
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 5 lines
Makes OFB/CFB compile time configurable, and fixes output of --show-ciphers to also show OFB/CFB ciphers along the way (becasue
crypto.hwas not included fromcrypto_openssl.c).ACK. But maybe we should just always enable this mode instead of having another configure option.
Thanks. Just to make this clear to others too: OFB/CFB was and after this still is enabled by default. Still, I'd prefer to have this option, because it makes my life easier for OpenVPN-NL, where everything not-CBC is disabled (and I'm the one maintaining this code, so in the end it is my problem anyway ;-) ).
-Steffan
Re: [Openvpn-devel] [PATCH 1/4] Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
In reply to Arne SchwabeQuoted 8 lines · Arne Schwabe
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 5 lines
Makes OFB/CFB compile time configurable, and fixes output of --show-ciphers to also show OFB/CFB ciphers along the way (becasue
crypto.hwas not included fromcrypto_openssl.c).ACK. But maybe we should just always enable this mode instead of having another configure option.
Thanks. Just to make this clear to others too: OFB/CFB was and after this still is enabled by default. Still, I'd prefer to have this option, because it makes my life easier for OpenVPN-NL, where everything not-CBC is disabled (and I'm the one maintaining this code, so in the end it is my problem anyway ;) ).
-Steffan
[Openvpn-devel] [PATCH applied] Re: Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
In reply to Steffan KargerYour patch has been applied to the master branch.
commit c353af2f474f79bfd7b2b67ecc02e91152500209
Author: Steffan Karger Date: Sun Jun 8 18:16:12 2014 +0200
Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8781
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 2/4 Add proper check for crypto modes (CBC or OFB/CFB)
In reply to Steffan KargerOpenSSL has added AEAD-CBC mode ciphers like AES-128-CBC-HMAC-SHA1, which have mode EVP_CIPH_CBC_MODE, but require a different API (the AEAD API). So, add extra checks to filter out those AEAD-mode ciphers.
Adding these made the crypto library agnostic function cfb_ofb_mode() superfuous, so removed that on the go.
Also update all cipher mode checks to use the new cipher_kt_mode_*() functions for consistency.
--- src/openvpn/crypto.c | 36 +++++++++++++++--------------------- src/openvpn/crypto.h | 2 -- src/openvpn/crypto_backend.h | 30 ++++++++++++++++++++++++++++++ src/openvpn/crypto_openssl.c | 35 ++++++++++++++++++++++++++++++++--- src/openvpn/crypto_polarssl.c | 21 +++++++++++++++++++++ src/openvpn/init.c | 2 +- 6 files changed, 99 insertions(+), 27 deletions(-)
src/openvpn/crypto.c +15 -21
@@ -100,10 +100,10 @@ openvpn_encrypt (struct buffer *buf, struct buffer work, {uint8_t iv_buf[OPENVPN_MAX_IV_LENGTH ];const int iv_size =cipher_ctx_iv_length (ctx->cipher); -const unsigned int mode =cipher_ctx_mode (ctx->cipher); +const cipher_kt_t *cipher_kt =cipher_ctx_get_cipher_kt (ctx->cipher);int outlen; -if (mode ==OPENVPN_MODE_CBC ) +if (cipher_kt_mode_cbc (cipher_kt)) {CLEAR (iv_buf);
@@ -119,7 +119,7 @@ openvpn_encrypt (struct buffer *buf, struct buffer work,ASSERT (packet_id_write (&pin, buf,BOOL_CAST (opt->flags &CO_PACKET_ID_LONG_FORM ), true)); } } -else if (mode ==OPENVPN_MODE_CFB || mode ==OPENVPN_MODE_OFB ) +else if (cipher_kt_mode_ofb_cfb (cipher_kt)) {struct packet_id_net pin;struct buffer b;
@@ -171,7 +171,10 @@ openvpn_encrypt (struct buffer *buf, struct buffer work,/* Flush the encryption buffer */ ASSERT (cipher_ctx_final (ctx->cipher,BPTR (&work) + outlen, &outlen)); work.len += outlen; -ASSERT (mode !=OPENVPN_MODE_CBC || outlen == iv_size); + +/* For all CBC mode ciphers, check the last block is complete */ +ASSERT (cipher_kt_mode (cipher_kt) !=OPENVPN_MODE_CBC || + outlen == iv_size);/* prepend the IV to the ciphertext */ if (opt->flags &CO_USE_IV )
@@ -272,8 +275,8 @@ openvpn_decrypt (struct buffer *buf, struct buffer work,if (ctx->cipher) { -const unsigned int mode =cipher_ctx_mode (ctx->cipher);const int iv_size =cipher_ctx_iv_length (ctx->cipher); +const cipher_kt_t *cipher_kt =cipher_ctx_get_cipher_kt (ctx->cipher);uint8_t iv_buf[OPENVPN_MAX_IV_LENGTH ];int outlen;
@@ -320,7 +323,7 @@ openvpn_decrypt (struct buffer *buf, struct buffer work,/* Get packet ID from plaintext buffer or IV, depending on cipher mode */ { -if (mode ==OPENVPN_MODE_CBC ) +if (cipher_kt_mode_cbc (cipher_kt)) {if (opt->packet_id) {
@@ -329,7 +332,7 @@ openvpn_decrypt (struct buffer *buf, struct buffer work, have_pin = true; } } -else if (mode ==OPENVPN_MODE_CFB || mode ==OPENVPN_MODE_OFB ) +else if (cipher_kt_mode_ofb_cfb (cipher_kt)) {struct buffer b;
@@ -426,10 +429,9 @@ init_key_type (struct key_type *kt, const char *ciphername,/* check legal cipher mode */ { -const unsigned int mode =cipher_kt_mode (kt->cipher); -if (!(mode ==OPENVPN_MODE_CBC +if (!(cipher_kt_mode_cbc (kt->cipher) #ifdef ENABLE_OFB_CFB_MODE - || (cfb_ofb_allowed && (mode ==OPENVPN_MODE_CFB || mode ==OPENVPN_MODE_OFB )) + || (cfb_ofb_allowed &&cipher_kt_mode_ofb_cfb (kt->cipher)) #endif )) #ifdef ENABLE_SMALL
@@ -606,18 +608,10 @@ fixup_key (struct key *key, const struct key_type *kt)void check_replay_iv_consistency (const struct key_type *kt,bool packet_id,bool use_iv) { -if (cfb_ofb_mode (kt) && !(packet_id && use_iv)) -msg (M_FATAL ,"--no-replay or --no-iv cannot be used with a CFB or OFB mode cipher" ); -} +ASSERT (kt); -bool -cfb_ofb_mode (const struct key_type * kt) -{ -if (kt && kt->cipher) { -const unsigned int mode =cipher_kt_mode (kt->cipher); -return mode ==OPENVPN_MODE_CFB || mode ==OPENVPN_MODE_OFB ; - } -return false; +if (cipher_kt_mode_ofb_cfb (kt->cipher) && !(packet_id && use_iv)) +msg (M_FATAL ,"--no-replay or --no-iv cannot be used with a CFB or OFB mode cipher" ); }/*
src/openvpn/crypto.h +0 -2
@@ -187,8 +187,6 @@ bool write_key (const struct key *key, const struct key_type *kt,int read_key (struct key *key,const struct key_type *kt,struct buffer *buf); -bool cfb_ofb_mode (const struct key_type * kt); -void init_key_type (struct key_type *kt,const char *ciphername,bool ciphername_defined,const char *authname,bool authname_defined,int keysize,bool cfb_ofb_allowed,bool warn);
src/openvpn/crypto_backend.h +30 -0
@@ -230,6 +230,26 @@ int cipher_kt_block_size (const cipher_kt_t *cipher_kt);*/ int cipher_kt_mode (const cipher_kt_t *cipher_kt); +/** +* Check of the supplied cipher is a supported CBC mode cipher. +* +* @param cipher Static cipher parameters. May not be NULL. +* +* @return true iff the cipher is a CBC mode cipher. +*/ +bool cipher_kt_mode_cbc (const cipher_kt_t *cipher) + __attribute__((nonnull)); + +/** +* Check of the supplied cipher is a supported OFB or CFB mode cipher. +* +* @param cipher Static cipher parameters. May not be NULL. +* +* @return true iff the cipher is a OFB or CFB mode cipher. +*/ +bool cipher_kt_mode_ofb_cfb (const cipher_kt_t *cipher) + __attribute__((nonnull)); +/** *
@@ -288,6 +308,16 @@ int cipher_ctx_block_size (const cipher_ctx_t *ctx);int cipher_ctx_mode (const cipher_ctx_t *ctx);/** +* Returns the static cipher parameters for this context. +* +* @param ctx Cipher's context. May not be NULL. +* +* @return Static cipher parameters for the supplied context. +*/ +const cipher_kt_t *cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx) + __attribute__((nonnull)); + +/** * Resets the given cipher context, setting the IV to the specified value. * Preserves the associated key information. *
src/openvpn/crypto_openssl.c +32 -3
@@ -261,10 +261,9 @@ show_available_ciphers ()const EVP_CIPHER *cipher =EVP_get_cipherbynid (nid);if (cipher) { -const unsigned int mode =EVP_CIPHER_mode (cipher); -if (mode ==EVP_CIPH_CBC_MODE +if (cipher_kt_mode_cbc (cipher) #ifdef ENABLE_OFB_CFB_MODE - || mode ==EVP_CIPH_CFB_MODE || mode ==EVP_CIPH_OFB_MODE + ||cipher_kt_mode_ofb_cfb (cipher) #endif ) printf ("%s %d bit default key (%s)\n",
@@ -483,6 +482,29 @@ cipher_kt_mode (const EVP_CIPHER *cipher_kt)return EVP_CIPHER_mode (cipher_kt); } +bool +cipher_kt_mode_cbc (const cipher_kt_t *cipher) +{ + return cipher_kt_mode(cipher) == OPENVPN_MODE_CBC +#ifdef EVP_CIPH_FLAG_AEAD_CIPHER +/* Exclude AEAD cipher modes, they require a different API */ + && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) +#endif + ; +} + +bool +cipher_kt_mode_ofb_cfb (const cipher_kt_t *cipher) +{ +return (cipher_kt_mode (cipher) ==OPENVPN_MODE_OFB || + cipher_kt_mode(cipher) == OPENVPN_MODE_CFB) +#ifdef EVP_CIPH_FLAG_AEAD_CIPHER +/* Exclude AEAD cipher modes, they require a different API */ + && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) +#endif + ; +} +/* * * Generic cipher context functions
@@ -536,6 +558,13 @@ cipher_ctx_mode (const EVP_CIPHER_CTX *ctx)return EVP_CIPHER_CTX_mode (ctx); } +const cipher_kt_t * +cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx) +{ +return EVP_CIPHER_CTX_cipher (ctx); +} + +int cipher_ctx_reset (EVP_CIPHER_CTX *ctx,uint8_t *iv_buf) {
src/openvpn/crypto_polarssl.c +21 -0
@@ -416,6 +416,19 @@ cipher_kt_mode (const cipher_info_t *cipher_kt)return cipher_kt->mode; } +bool +cipher_kt_mode_cbc (const cipher_kt_t *cipher) +{ +return cipher_kt_mode (cipher) ==OPENVPN_MODE_CBC ; +} + +bool +cipher_kt_mode_ofb_cfb (const cipher_kt_t *cipher) +{ +return (cipher_kt_mode (cipher) ==OPENVPN_MODE_OFB || +cipher_kt_mode (cipher) ==OPENVPN_MODE_CFB ); +} +/* *
@@ -464,6 +477,14 @@ int cipher_ctx_mode (const cipher_context_t *ctx)return cipher_kt_mode (ctx->cipher_info); } +const cipher_kt_t * +cipher_ctx_get_cipher_kt (const cipher_ctx_t *ctx) +{ +ASSERT (NULL != ctx); + +return ctx->cipher_info; +} +int cipher_ctx_reset (cipher_context_t *ctx,uint8_t *iv_buf) {int retval =cipher_reset (ctx);
src/openvpn/init.c +1 -1
@@ -2186,7 +2186,7 @@ do_init_crypto_tls (struct context *c, const unsigned int flags) options->use_iv);/* In short form, unique datagram identifier is 32 bits, in long form 64 bits */ - packet_id_long_form =cfb_ofb_mode (&c->c1.ks.key_type); + packet_id_long_form =cipher_kt_mode_ofb_cfb (c->c1.ks.key_type.cipher);/* Compute MTU parameters */ crypto_adjust_frame_parameters (&c->c2.frame,
Signature · 1 line
1.9.1
Re: [Openvpn-devel] [PATCH 2/4] Add proper check for crypto modes (CBC or OFB/CFB)
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 11 lines
OpenSSL has added AEAD-CBC mode ciphers like AES-128-CBC-HMAC-SHA1, which have mode
EVP_CIPH_CBC_MODE, but require a different API (the AEAD API). So, add extra checks to filter out those AEAD-mode ciphers.Adding these made the crypto library agnostic function
cfb_ofb_mode()superfuous, so removed that on the go.Also update all cipher mode checks to use the new cipher_kt_mode_*() functions for consistency.
ACK. Apart from the AEAD changes is also only refactoring.
Arne
[Openvpn-devel] [PATCH applied] Re: Add proper check for crypto modes (CBC or OFB/CFB)
In reply to Steffan KargerYour patch has been applied to the master branch.
commit a4b27b6481c7496f2a8705c993edfe150a3541cb
Author: Steffan Karger Date: Sun Jun 8 18:16:13 2014 +0200
Add proper check for crypto modes (CBC or OFB/CFB)
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8779
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 3/4 Improve --show-ciphers to show if a cipher can be used in static key mode
In reply to Steffan KargerAlso remove the bulky warning from init_key_type() and add the information to the --show-ciphers output.
--- src/openvpn/crypto.c | 4 ---- src/openvpn/crypto_openssl.c | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-)
src/openvpn/crypto.c +0 -4
@@ -434,11 +434,7 @@ init_key_type (struct key_type *kt, const char *ciphername, || (cfb_ofb_allowed && cipher_kt_mode_ofb_cfb(kt->cipher)) #endif )) -#ifdef ENABLE_SMALL msg (M_FATAL, "Cipher '%s' mode not supported", ciphername); -#else -msg (M_FATAL ,"Cipher '%s' uses a mode not supported by " PACKAGE_NAME " in your current configuration. CBC mode is always supported, while CFB and OFB modes are supported only when using SSL/TLS authentication and key exchange mode, and when " PACKAGE_NAME " has been built with ALLOW_NON_CBC_CIPHERS." , ciphername); -#endif } }else
src/openvpn/crypto_openssl.c +13 -6
@@ -40,6 +40,7 @@#include "basic.h" #include "buffer.h" #include "integer.h" +#include "crypto.h" #include "crypto_backend.h" #include <openssl/objects.h> #include <openssl/evp.h>
@@ -253,7 +254,7 @@ show_available_ciphers ()"used as a parameter to the --cipher option. The default\n" "key size is shown as well as whether or not it can be\n" "changed with the --keysize directive. Using a CBC mode\n" - "is recommended.\n\n"); + "is recommended. In static key mode only CBC mode is allowed.\n\n");#endif for (nid =0 ; nid <10000 ; ++nid)/* is there a better way to get the size of the nid list? */
@@ -266,11 +267,17 @@ show_available_ciphers () ||cipher_kt_mode_ofb_cfb (cipher)#endif ) -printf ("%s %d bit default key (%s)\n" , -OBJ_nid2sn (nid), -EVP_CIPHER_key_length (cipher) *8 , - ((EVP_CIPHER_flags (cipher) &EVP_CIPH_VARIABLE_LENGTH ) ? -"variable" :"fixed" )); + { +const char *var_key_size = + (EVP_CIPHER_flags (cipher) &EVP_CIPH_VARIABLE_LENGTH ) ? +"variable" :"fixed" ; +const char *ssl_only =cipher_kt_mode_ofb_cfb (cipher) ? +" (SSL mode only)" :"" ; + +printf ("%s %d bit default key (%s)%s\n" ,OBJ_nid2sn (nid), +EVP_CIPHER_key_length (cipher) *8 , var_key_size, + ssl_only); + } } }printf ("\n" );
Signature · 1 line
1.9.1
Re: [Openvpn-devel] [PATCH 3/4] Improve --show-ciphers to show if a cipher can be used in static key mode
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 4 lines
Also remove the bulky warning from
init_key_type()and add the information to the --show-ciphers output.
It does what it says but I think most users will be confused about what (SSL mode only) is about. Most people which are not familar with openvpn will not parse it as "non --static mode".
Arne
Re: [Openvpn-devel] [PATCH 3/4] Improve --show-ciphers to show if a cipher can be used in static key mode
Quoted 7 lines · Arne Schwabe
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 3 lines
Also remove the bulky warning from
init_key_type()and add the information to the --show-ciphers output.It does what it says but I think most users will be confused about what (SSL mode only) is about. Most people which are not familar with openvpn will not parse it as "non --static mode".
Hmm, you're right. I'm not very good at this sort of thing. What about "(no static key mode)"? Any other suggestions?
-Steffan
Re: [Openvpn-devel] [PATCH 3/4] Improve --show-ciphers to show if a cipher can be used in static key mode
Am 07.07.14 19:37, schrieb Steffan Karger:
Quoted 11 lines · Arne Schwabe
Quoted 7 lines
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 3 lines
Also remove the bulky warning from
init_key_type()and add the information to the --show-ciphers output.It does what it says but I think most users will be confused about what (SSL mode only) is about. Most people which are not familar with openvpn will not parse it as "non --static mode".
Hmm, you're right. I'm not very good at this sort of thing. What about "(no static key mode)"? Any other suggestions?
Maybe (tls-client/tls-server mode only) or (Not in --static mode)? That way the users knows what option you are referring to?
Arne
Re: [Openvpn-devel] [PATCH 3/4] Improve --show-ciphers to show if a cipher can be used in static key mode
Quoted 6 lines · Arne Schwabe
Am 07.07.14 19:37, schrieb Steffan Karger:
Quoted 5 lines · Arne Schwabe
Quoted 4 lines
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 3 lines
Also remove the bulky warning from
init_key_type()and add the information to the --show-ciphers output.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
It does what it says but I think most users will be confused about what (SSL mode only) is about. Most people which are not familar with openvpn will not parse it as "non --static mode".
Hmm, you're right. I'm not very good at this sort of thing. What about "(no static key mode)"? Any other suggestions?
Maybe (tls-client/tls-server mode only) or (Not in --static mode)? That way the users knows what option you are referring to?
Well, users will probably use 'client' or 'server' in their configs, which expands to tls-client or tls-server. Also, --static is actually called --secret, which is not very descriptive either (otherwise that would be great). Gah.
So, "(client/server mode only)"?
-Steffan
Re: [Openvpn-devel] [PATCH 3/4] Improve --show-ciphers to show if a cipher can be used in static key mode
Quoted 16 lines · Steffan Karger
Quoted 6 lines · Arne Schwabe
Am 07.07.14 19:37, schrieb Steffan Karger:
Quoted 5 lines · Arne Schwabe
Quoted 4 lines
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 3 lines
Also remove the bulky warning from
init_key_type()and add the information to the --show-ciphers output.Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
It does what it says but I think most users will be confused about what (SSL mode only) is about. Most people which are not familar with openvpn will not parse it as "non --static mode".
Hmm, you're right. I'm not very good at this sort of thing. What about "(no static key mode)"? Any other suggestions?
Maybe (tls-client/tls-server mode only) or (Not in --static mode)? That way the users knows what option you are referring to?
Quoted 6 lines
Well, users will probably use 'client' or 'server' in their configs, which expands to tls-client or tls-server. Also, --static is actually called --secret, which is not very descriptive either (otherwise that would be great). Gah.
So, "(client/server mode only)"?
After some discussion on IRC, settled for "(TLS client/server mode)". Updated patch attached.
-Steffan
From 630ecfa6a73a99e2d2b4498c9706ba0cbe1478e7 Mon Sep 17 00:00:00 2001
From: Steffan Karger <[email protected]...>
Date: Sun, 8 Jun 2014 17:04:32 +0200
Subject: [PATCH 3/4] Improve --show-ciphers to show if a cipher can be used in
static key mode
Also remove the bulky warning from init_key_type() and add the information to the --show-ciphers output.
--- src/openvpn/crypto.c | 4 ---- src/openvpn/crypto_openssl.c | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-)
src/openvpn/crypto.c +0 -4
@@ -434,11 +434,7 @@ init_key_type (struct key_type *kt, const char *ciphername, || (cfb_ofb_allowed && cipher_kt_mode_ofb_cfb(kt->cipher)) #endif )) -#ifdef ENABLE_SMALL msg (M_FATAL, "Cipher '%s' mode not supported", ciphername); -#else -msg (M_FATAL ,"Cipher '%s' uses a mode not supported by " PACKAGE_NAME " in your current configuration. CBC mode is always supported, while CFB and OFB modes are supported only when using SSL/TLS authentication and key exchange mode, and when " PACKAGE_NAME " has been built with ALLOW_NON_CBC_CIPHERS." , ciphername); -#endif } }else
src/openvpn/crypto_openssl.c +13 -6
@@ -40,6 +40,7 @@#include "basic.h" #include "buffer.h" #include "integer.h" +#include "crypto.h" #include "crypto_backend.h" #include <openssl/objects.h> #include <openssl/evp.h>
@@ -253,7 +254,7 @@ show_available_ciphers ()"used as a parameter to the --cipher option. The default\n" "key size is shown as well as whether or not it can be\n" "changed with the --keysize directive. Using a CBC mode\n" - "is recommended.\n\n"); + "is recommended. In static key mode only CBC mode is allowed.\n\n");#endif for (nid =0 ; nid <10000 ; ++nid)/* is there a better way to get the size of the nid list? */
@@ -266,11 +267,17 @@ show_available_ciphers () ||cipher_kt_mode_ofb_cfb (cipher)#endif ) -printf ("%s %d bit default key (%s)\n" , -OBJ_nid2sn (nid), -EVP_CIPHER_key_length (cipher) *8 , - ((EVP_CIPHER_flags (cipher) &EVP_CIPH_VARIABLE_LENGTH ) ? -"variable" :"fixed" )); + { +const char *var_key_size = + (EVP_CIPHER_flags (cipher) &EVP_CIPH_VARIABLE_LENGTH ) ? +"variable" :"fixed" ; +const char *ssl_only =cipher_kt_mode_ofb_cfb (cipher) ? +" (TLS client/server mode)" :"" ; + +printf ("%s %d bit default key (%s)%s\n" ,OBJ_nid2sn (nid), +EVP_CIPHER_key_length (cipher) *8 , var_key_size, + ssl_only); + } } }printf ("\n" );
Signature · 1 line
1.9.1
[Openvpn-devel] [PATCH applied] Re: Improve --show-ciphers to show if a cipher can be used in static key mode
Your patch has been applied to the master branch.
commit d344820faeae987f52e574e15812c86aa5c59ae6
Author: Steffan Karger Date: Sun Jun 8 17:04:32 2014 +0200
Improve --show-ciphers to show if a cipher can be used in static key mode
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8852
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 4/4 Extend t_lpback tests to test all ciphers reported by --show-ciphers
In reply to Steffan Karger... instead of just BF-CBC. Should catch more mistakes.
--- tests/t_lpback.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
tests/t_lpback.sh +26 -4
@@ -2,6 +2,7 @@ # # t_lpback.sh - script to test OpenVPN's crypto loopback # Copyright (C) 2005 Matthias Andree +# Copyright (C) 2014 Steffan Karger # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License
@@ -18,15 +19,36 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. -set -e +set -eu top_builddir="${top_builddir:-..}" trap "rm -f key.$$ log.$$ ; trap 0 ; exit 77" 1 2 15 trap "rm -f key.$$ log.$$ ; exit 1" 0 3 + +# Get list of supported ciphers from openvpn --show-ciphers output +CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | tail -n+7 | sed 's/ .*//' | sed '/^\s*$/d' | sort) + +# SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is +# broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude +# that cipher from this test. +CIPHERS=$(echo "$CIPHERS" | sed '/.*DES-EDE3-CFB1.*/d') + "${top_builddir}/src/openvpn/openvpn" --genkey --secret key.$$ set +e -( "${top_builddir}/src/openvpn/openvpn" --test-crypto --secret key.$$ ) >log.$$ 2>&1 -e=$? -if [ $e != 0 ] ; then cat log.$$ ; fi + +e=0 +for cipher in ${CIPHERS} +do + echo -n "Testing cipher ${cipher}... " + ( "${top_builddir}/src/openvpn/openvpn" --test-crypto --secret key.$$ --cipher ${cipher} ) >log.$$ 2>&1 + if [ $? != 0 ] ; then + echo "FAILED" + cat log.$$ + e=1 + else + echo "OK" + fi +done + rm key.$$ log.$$ trap 0 exit $e
Signature · 1 line
1.9.1
Re: [Openvpn-devel] [PATCH 4/4] Extend t_lpback tests to test all ciphers reported by --show-ciphers
Am 08.06.14 18:16, schrieb Steffan Karger:
Quoted 3 lines
... instead of just BF-CBC. Should catch more mistakes.
ACK
Arne
[Openvpn-devel] [PATCH applied] Re: Extend t_lpback tests to test all ciphers reported by --show-ciphers
In reply to Steffan KargerYour patch has been applied to the master branch.
(It might break the script on some of the more obscure platforms that haven't learned the new POSIXly "tail -n+7" yet. But if so, buildbot will tell us, and we can then still fix it, like by using "sed -e '1,6d'" instead...)
commit b2bff9fa15695f2850999688b0ca6047016fd7f5
Author: Steffan Karger Date: Sun Jun 8 18:16:15 2014 +0200
Extend t_lpback tests to test all ciphers reported by --show-ciphers
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8777
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: Extend t_lpback tests to test all ciphers reported by --show-ciphers
Hi,
Quoted 1 line · Gert Doering
Your patch has been applied to the master branch.
Thanks. These are actually bugfixes for stuff that should just work in 2.3 too, so I suggest to apply these patches, including the preceding OFB/CFB fix by Heiko (be46a2c083a6bd77754bc1674249eab583d25dac) to the release/2.3 branch too. That will close trac ticket #89.
-Steffan
Re: [Openvpn-devel] [PATCH applied] Re: Extend t_lpback tests to test all ciphers reported by --show-ciphers
Hi,
Quoted 7 lines · Steffan Karger
Quoted 1 line · Gert Doering
Your patch has been applied to the master branch.
Thanks. These are actually bugfixes for stuff that should just work in 2.3 too, so I suggest to apply these patches, including the preceding OFB/CFB fix by Heiko (
be46a2c083a6bd77754bc1674249eab583d25dac) to the release/2.3 branch too. That will close trac ticket #89.
OK. Patch series cherry-picked to release/2.3 as well, git log below.
Will be pushed in a minute, as soon as "make check" succeeded.
gert
$ git log --pretty=short commit 9ce3670aee49d8c4407983af014663dc6185f166 Author: Gert Doering <[email protected]...>
Fix t_lpback.sh platform-dependent failures
commit e97aa06dc058dd099cf3a5facde73aa92d61277c
Author: Steffan Karger <[email protected]...>
Extend t_lpback tests to test all ciphers reported by --show-ciphers
commit d66ba9b212e95cdd1880be58036e62d59e5dbb6a
Author: Steffan Karger <[email protected]...>
Improve --show-ciphers to show if a cipher can be used in static key mode
commit deff485f85e0eb9502f1ed2cdda2dd41a429fe58
Author: Steffan Karger <[email protected]...>
Add proper check for crypto modes (CBC or OFB/CFB)
commit f71a780fa5224c5de0859aad1a34ebd8a92165a0
Author: Steffan Karger <[email protected]...>
Rename ALLOW_NON_CBC_CIPHERS to ENABLE_OFB_CFB_MODE, and add to configure.
commit f1b532d5646143897e291a6c0d3842badf6cc677
Author: Heiko Hund <[email protected]...>
refine assertion to allow other modes than CBC
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...PATCH 1/1 Fix t_lpback.sh platform-dependent failures
In reply to Steffan Kargercommit e97aa06dc058 introduced "full openvpn cipher testing", but fails on OpenSSL 0.9.8 with DES-CFB1 (skip), on NetBSD for RC5-* (needs extra library, libcrypto_rc5.a) and on Solaris for POSIXly "tail" (rewrite).
--- tests/t_lpback.sh | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
tests/t_lpback.sh +5 -2
@@ -25,12 +25,15 @@ trap "rm -f key.$$ log.$$ ; trap 0 ; exit 77" 1 2 15 trap "rm -f key.$$ log.$$ ; exit 1" 0 3 # Get list of supported ciphers from openvpn --show-ciphers output -CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | tail -n+7 | sed 's/ .*//' | sed '/^\s*$/d' | sort) +CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | \ + sed -e '1,/^$/d' -e s'/ .*//' -e '/^\s*$/d' | sort) # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude # that cipher from this test. -CIPHERS=$(echo "$CIPHERS" | sed '/.*DES-EDE3-CFB1.*/d') +# GD, 2014-07-06 so is DES-CFB1 +# GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5) +CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' ) "${top_builddir}/src/openvpn/openvpn" --genkey --secret key.$$ set +e
Signature · 1 line
1.5.6.5
Re: [Openvpn-devel] [PATCH] Fix t_lpback.sh platform-dependent failures
ACK
Quoted 31 lines · Gert Doering
commit
e97aa06dc058introduced "full openvpn cipher testing", but fails on OpenSSL 0.9.8 with DES-CFB1 (skip), on NetBSD for RC5-* (needs extra library, libcrypto_rc5.a) and on Solaris for POSIXly "tail" (rewrite).Signed-off-by Gert Doering <[email protected]...>--- tests/t_lpback.sh | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)tests/t_lpback.sh +5
-2@@ -25,12 +25,15 @@ trap "rm -f key.$$ log.$$ ; trap 0 ; exit 77" 1 2 15 trap "rm -f key.$$ log.$$ ; exit 1" 0 3 # Get list of supported ciphers from openvpn --show-ciphers output -CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | tail -n+7 | sed 's/ .*//' | sed '/^\s*$/d' | sort) +CIPHERS=$(${top_builddir}/src/openvpn/openvpn --show-ciphers | \ + sed -e '1,/^$/d' -e s'/ .*//' -e '/^\s*$/d' | sort) # SK, 2014-06-04: currently the DES-EDE3-CFB1 implementation of OpenSSL is # broken (see http://rt.openssl.org/Ticket/Display.html?id=2867), so exclude # that cipher from this test. -CIPHERS=$(echo "$CIPHERS" | sed '/.*DES-EDE3-CFB1.*/d') +# GD, 2014-07-06 so is DES-CFB1 +# GD, 2014-07-06 do not test RC5-* either (fails on NetBSD w/o libcrypto_rc5) +CIPHERS=$(echo "$CIPHERS" | egrep -v '^(DES-EDE3-CFB1|DES-CFB1|RC5-)' ) "${top_builddir}/src/openvpn/openvpn" --genkey --secret key.$$ set +e
[Openvpn-devel] [PATCH applied] Re: Fix t_lpback.sh platform-dependent failures
In reply to Gert DoeringPatch has been applied to the master and release/2.3 branch.
commit bbae238d5084012525a61a0e3ab947c414a555ae (master) commit 9ce3670aee49d8c4407983af014663dc6185f166 (release/2.3)
Author: Gert Doering Date: Tue Jul 8 16:45:58 2014 +0200
Fix t_lpback.sh platform-dependent failures
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Steffan Karger <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8861--
kind regards,
Gert Doering