From patchwork Mon Sep 7 06:22:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1418 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.50]) by backend30.mail.ord1d.rsapps.net with LMTP id GIMmKn5eVl+bCwAAIUCqbw (envelope-from ) for ; Mon, 07 Sep 2020 12:23:26 -0400 Received: from proxy15.mail.iad3a.rsapps.net ([172.27.255.50]) by director9.mail.ord1d.rsapps.net with LMTP id yMf6KX5eVl+RegAAalYnBA (envelope-from ) for ; Mon, 07 Sep 2020 12:23:26 -0400 Received: from smtp50.gate.iad3a ([172.27.255.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.iad3a.rsapps.net with LMTPS id qHBqIn5eVl9TGQAAHi9b9g (envelope-from ) for ; Mon, 07 Sep 2020 12:23:26 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp50.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 746905e6-f126-11ea-80bc-525400c2fb51-1-1 Received: from [216.105.38.7] ([216.105.38.7:50736] helo=lists.sourceforge.net) by smtp50.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A1/F2-03190-D7E565F5; Mon, 07 Sep 2020 12:23:26 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kFJuh-0005vF-1B; Mon, 07 Sep 2020 16:22:39 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFJue-0005uf-NN for openvpn-devel@lists.sourceforge.net; Mon, 07 Sep 2020 16:22:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=L1a/KL/5l1DaUniZrdlTZr28AWKd1KpYa1iAwU6t7xQ=; b=Q2KCW20jNklwJ5y0GJ65AmlZ7I HdYwCBmXT91FXoDL2mxA6i+ifvtve59xbD4MlCiosdtxiTuEasUYzSaZUf1kVKydu/uUT7TZQRbZR KTWiUwGpCHaHfEe4trL+WrMFddWbqfahyyFNiHGzc/dQy8hvBL+d1D/WwcKjnCXBNPjQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=L1a/KL/5l1DaUniZrdlTZr28AWKd1KpYa1iAwU6t7xQ=; b=AnROg+XI7+8UymwjPDZV8J3gKs sYeU3mvLsIyQEiIIKu0EheedfldR8gPzwu3WJnye3EU1qZ0weDBOKdaomY08eoZuv7/Lht4GGbfch TdDE0hp+PnFXsyYHEP4fUoruADhIiLcYir/5XBhYkH6Cf+X5MiZS6jewxx6hSB65xubQ=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kFJub-00FgaT-Qx for openvpn-devel@lists.sourceforge.net; Mon, 07 Sep 2020 16:22:36 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1kFJuP-000Nb9-CG for openvpn-devel@lists.sourceforge.net; Mon, 07 Sep 2020 18:22:21 +0200 Received: (nullmailer pid 20975 invoked by uid 10006); Mon, 07 Sep 2020 16:22:21 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 7 Sep 2020 18:22:19 +0200 Message-Id: <20200907162221.20928-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200825073643.15920-2-arne@rfc2549.org> References: <20200825073643.15920-2-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1kFJub-00FgaT-Qx Subject: [Openvpn-devel] [PATCH 3/5] Allow running a default configuration with TLS libraries without BF-CBC X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Modern TLS libraries might drop Blowfish by default or distributions might disable Blowfish in OpenSSL/mbed TLS. We still signal OCC options with BF-CBC compatible strings. To avoid requiring BF-CBC for this, special case this one usage of BF-CBC enough to avoid a hard requirement on Blowfish in the default configuration. Signed-off-by: Arne Schwabe --- src/openvpn/init.c | 18 +++++++++------ src/openvpn/options.c | 51 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index dff090b1..1e0baf2a 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -2752,14 +2752,18 @@ do_init_crypto_tls_c1(struct context *c) #endif /* if P2MP */ } - /* Do not warn if we only have BF-CBC in options->ciphername - * because it is still the default cipher */ - bool warn = !streq(options->ciphername, "BF-CBC") - || options->enable_ncp_fallback; - /* Get cipher & hash algorithms */ - init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname, - options->keysize, true, warn); + if (!options->ncp_enabled || options->enable_ncp_fallback + || !streq(options->ciphername, "BF-CBC")) + { + /* Get cipher & hash algorithms + * skip BF-CBC for NCP setups when cipher as this is the default + * and is also special cased later to allow it to be not available + * as we need to construct a fake BF-CBC occ string + */ + init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname, + options->keysize, true, true); + } /* Initialize PRNG with config-specified digest */ prng_init(options->prng_hash, options->prng_nonce_secret_len); diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 90e78a7b..01da88ad 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3640,11 +3640,32 @@ calc_options_string_link_mtu(const struct options *o, const struct frame *frame) { struct frame fake_frame = *frame; struct key_type fake_kt; - init_key_type(&fake_kt, o->ciphername, o->authname, o->keysize, true, - false); + frame_remove_from_extra_frame(&fake_frame, crypto_max_overhead()); - crypto_adjust_frame_parameters(&fake_frame, &fake_kt, o->replay, - cipher_kt_mode_ofb_cfb(fake_kt.cipher)); + + /* o->ciphername can be still BF-CBC and our SSL library might not like + * like it, workaround this important corner case in the name of + * compatibility and not stopping openvpn on our default configuration + */ + if ((strcmp(o->ciphername, "BF-CBC") == 0) + && cipher_kt_get(o->ciphername) == NULL) + { + init_key_type(&fake_kt, "none", o->authname, o->keysize, true, + false); + + crypto_adjust_frame_parameters(&fake_frame, &fake_kt, o->replay, + cipher_kt_mode_ofb_cfb(fake_kt.cipher)); + /* 64 bit block size, 64 bit IV size */ + frame_add_to_extra_frame(&fake_frame, 64/8 + 64/8); + } + else + { + init_key_type(&fake_kt, o->ciphername, o->authname, o->keysize, true, + false); + + crypto_adjust_frame_parameters(&fake_frame, &fake_kt, o->replay, + cipher_kt_mode_ofb_cfb(fake_kt.cipher)); + } frame_finalize(&fake_frame, o->ce.link_mtu_defined, o->ce.link_mtu, o->ce.tun_mtu_defined, o->ce.tun_mtu); msg(D_MTU_DEBUG, "%s: link-mtu %u -> %d", __func__, (unsigned int) link_mtu, @@ -3812,18 +3833,32 @@ options_string(const struct options *o, + (TLS_SERVER == true) <= 1); - init_key_type(&kt, o->ciphername, o->authname, o->keysize, true, - false); + /* Skip resolving BF-CBC to allow SSL libraries without BF-CBC + * to work here in the default configuration */ + const char *ciphername = o->ciphername; + int keysize; + + if (strcmp(o->ciphername, "BF-CBC") == 0) { + init_key_type(&kt, "none", o->authname, o->keysize, true, + false); + ciphername = cipher_kt_name(kt.cipher); + keysize = 128; + } + else + { + init_key_type(&kt, o->ciphername, o->authname, o->keysize, true, + false); + keysize = kt.cipher_length * 8; + } /* Only announce the cipher to our peer if we are willing to * support it */ - const char *ciphername = cipher_kt_name(kt.cipher); if (p2p_nopull || !o->ncp_enabled || tls_item_in_cipher_list(ciphername, o->ncp_ciphers)) { buf_printf(&out, ",cipher %s", ciphername); } buf_printf(&out, ",auth %s", md_kt_name(kt.digest)); - buf_printf(&out, ",keysize %d", kt.cipher_length * 8); + buf_printf(&out, ",keysize %d", keysize); if (o->shared_secret_file) { buf_printf(&out, ",secret");