From patchwork Thu Oct 8 00:59:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1508 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id OIDMG7z/fl+cPgAAIUCqbw (envelope-from ) for ; Thu, 08 Oct 2020 08:02:04 -0400 Received: from proxy8.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id YMSIG7z/fl8kXAAAIasKDg (envelope-from ) for ; Thu, 08 Oct 2020 08:02:04 -0400 Received: from smtp29.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.iad3b.rsapps.net with LMTPS id 8PhYE7z/fl9FawAAoCsc3g (envelope-from ) for ; Thu, 08 Oct 2020 08:02:04 -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: smtp29.gate.iad3b.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: 13e6ddb0-095e-11eb-b888-525400534f55-1-1 Received: from [216.105.38.7] ([216.105.38.7:53374] helo=lists.sourceforge.net) by smtp29.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 97/36-11147-BBFFE7F5; Thu, 08 Oct 2020 08:02:03 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kQUaz-0006lN-Ks; Thu, 08 Oct 2020 12:00:29 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQUay-0006lF-EH for openvpn-devel@lists.sourceforge.net; Thu, 08 Oct 2020 12:00:28 +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=pSxw6lXPrIvzvLnV3auEzpoYCtcLau5yzZCNz6QKxWE=; b=OpQj3msTw5esikNzWUEvt+q81M bsuwhxlVR7fo+4xIDMArFaljJrBWbr4WsWfZCVwDQ/HdzrufiJrJ6nkf8RWfFXo+xtmhcdMWgW4MW L1ld10mHFAFJQbhioLll3Cq9HiJVFMK1q259clIjQMmV32c6D2JrNCidOgWi+QC7FQaQ=; 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=pSxw6lXPrIvzvLnV3auEzpoYCtcLau5yzZCNz6QKxWE=; b=dMc013pfzWLHw+D/us6xd986CA IQkK0NSlOAZJBD3LCpTQMkZ5mqIeZ3ufNbl1sIg3pg3LqGqrTyS0zmbAzrCpb3FRG5HYuMIDp9Jbv HcOfKk3s/R3dUzkyOU80qVTSh4KsaMsCYenIO1JwL6NAzgxR8TcnenEd/zO+7nky9EKQ=; 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 1kQUal-007Ajb-HI for openvpn-devel@lists.sourceforge.net; Thu, 08 Oct 2020 12:00:28 +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 1kQUaV-000K90-Od for openvpn-devel@lists.sourceforge.net; Thu, 08 Oct 2020 13:59:59 +0200 Received: (nullmailer pid 21198 invoked by uid 10006); Thu, 08 Oct 2020 11:59:59 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Thu, 8 Oct 2020 13:59:59 +0200 Message-Id: <20201008115959.21151-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930131317.1299-2-arne@rfc2549.org> References: <20200930131317.1299-2-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 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: 1kQUal-007Ajb-HI Subject: [Openvpn-devel] [PATCH v3] Allow 'none' cipher being specified in --data-ciphers 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 Although we want to get rid of none as cipher, we still have not deprecated it. In order to use it currently you need --ncp-disable together with --cipher none to use the none cipher otherwise OpenVPN will spit out an error about an unrecognised cipher in --data-ciphers. In our current situation allowing none to be specified in data-ciphers is the lesser evil. This commit also fixes that we use '[null-cipher]' instead 'none' when setting remote_cipher. Note that negotiating to cipher 'none' can the same the same problems with frame size calculation as any other non AEAD cipher. If --cipher none is also specified in the configuration, the workaround of commit e539c95dc will also apply to cipher none. Patch V2: Also work correctly if remote_cipher is NULL. Patch V3: fix unit tests, add note about corner case Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/ssl.c | 8 ++++++++ src/openvpn/ssl_ncp.c | 16 +++++++++++++++- tests/unit_tests/openvpn/test_ncp.c | 14 ++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 3535fc72..f90c6a85 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2554,6 +2554,14 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessio multi->remote_ciphername = options_string_extract_option(options, "cipher", NULL); + /* In OCC we send '[null-cipher]' instead 'none' */ + if (multi->remote_ciphername + && strcmp(multi->remote_ciphername, "[null-cipher]") == 0) + { + free(multi->remote_ciphername); + multi->remote_ciphername = string_alloc("none", NULL); + } + if (tls_session_user_pass_enabled(session)) { /* Perform username/password authentication */ diff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c index 55496395..c8229044 100644 --- a/src/openvpn/ssl_ncp.c +++ b/src/openvpn/ssl_ncp.c @@ -110,7 +110,15 @@ mutate_ncp_cipher_list(const char *list, struct gc_arena *gc) * e.g. replacing AeS-128-gCm with AES-128-GCM */ const cipher_kt_t *ktc = cipher_kt_get(token); - if (!ktc) + if (strcmp(token, "none") == 0) + { + msg(M_WARN, "WARNING: cipher 'none' specified for --data-ciphers. " + "This allows negotiation of NO encryption and " + "tunnelled data WILL then be transmitted in clear text " + "over the network! " + "PLEASE DO RECONSIDER THIS SETTING!"); + } + if (!ktc && strcmp(token, "none")!= 0) { msg(M_WARN, "Unsupported cipher in --data-ciphers: %s", token); error_found = true; @@ -118,6 +126,12 @@ mutate_ncp_cipher_list(const char *list, struct gc_arena *gc) else { const char *ovpn_cipher_name = cipher_kt_name(ktc); + if (ktc == NULL) + { + /* NULL resolves to [null-cipher] but we need none for + * data-ciphers */ + ovpn_cipher_name = "none"; + } if (buf_len(&new_list)> 0) { diff --git a/tests/unit_tests/openvpn/test_ncp.c b/tests/unit_tests/openvpn/test_ncp.c index a4334c89..4077be5e 100644 --- a/tests/unit_tests/openvpn/test_ncp.c +++ b/tests/unit_tests/openvpn/test_ncp.c @@ -50,7 +50,9 @@ test_check_ncp_ciphers_list(void **state) struct gc_arena gc = gc_new(); bool have_chacha = cipher_kt_get("CHACHA20-POLY1305"); - + assert_string_equal(mutate_ncp_cipher_list("none", &gc), "none"); + assert_string_equal(mutate_ncp_cipher_list("AES-256-GCM:none", &gc), + "AES-256-GCM:none"); assert_string_equal(mutate_ncp_cipher_list(aes_ciphers, &gc), aes_ciphers); @@ -139,7 +141,7 @@ test_poor_man(void **state) char *best_cipher; const char *serverlist = "CHACHA20_POLY1305:AES-128-GCM"; - const char *serverlistbfcbc = "CHACHA20_POLY1305:AES-128-GCM:BF-CBC"; + const char *serverlistbfcbc = "CHACHA20_POLY1305:AES-128-GCM:BF-CBC:none"; best_cipher = ncp_get_best_cipher(serverlist, "IV_YOLO=NO\nIV_BAR=7", @@ -166,6 +168,14 @@ test_poor_man(void **state) assert_string_equal(best_cipher, "AES-128-GCM"); + best_cipher = ncp_get_best_cipher(serverlist, NULL, + "none", &gc); + assert_ptr_equal(best_cipher, NULL); + + best_cipher = ncp_get_best_cipher(serverlistbfcbc, NULL, + "none", &gc); + assert_string_equal(best_cipher, "none"); + best_cipher = ncp_get_best_cipher(serverlist, NULL,NULL, &gc); assert_ptr_equal(best_cipher, NULL);