From patchwork Fri Jun 5 01:25:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1145 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 QGVRNvQr2l4zXgAAIUCqbw for ; Fri, 05 Jun 2020 07:26:44 -0400 Received: from proxy16.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id kHgnNPQr2l4caQAAIasKDg ; Fri, 05 Jun 2020 07:26:44 -0400 Received: from smtp39.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy16.mail.iad3b.rsapps.net with LMTP id +BH5LvQr2l7KSAAAPj+4aA ; Fri, 05 Jun 2020 07:26:44 -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: smtp39.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: 6efbeb9c-a71f-11ea-904f-5254002be87c-1-1 Received: from [216.105.38.7] ([216.105.38.7:35340] helo=lists.sourceforge.net) by smtp39.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id C2/51-18496-4FB2ADE5; Fri, 05 Jun 2020 07:26:44 -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 1jhATg-0005xY-3h; Fri, 05 Jun 2020 11:25:36 +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 1jhATe-0005xR-Ea for openvpn-devel@lists.sourceforge.net; Fri, 05 Jun 2020 11:25:34 +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=NXaEBFSrUyLwPVVcRrCDpEuXJNlzpJ7vOkonEEcZ+c4=; b=lexMWddxkfqFFeVMdJ+02D6ov6 HnODzUaad+dsm7ynkHRH9NC3BzRHEEVX6EtvRKD7w6G8I+HiTw+EuNzIESRq/0nZKR3mENDJN3KpF JafKpjSicnaJFzqPy0tpFH9I0YAfPB5iXs748Uc/+7uF5/sct03Sb3FlePF8bRApjGFc=; 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=NXaEBFSrUyLwPVVcRrCDpEuXJNlzpJ7vOkonEEcZ+c4=; b=UJFqU7bR5rMo06FI5MAOixB3kz ptecmnQONpRzEOPM6B5xs8ooh+MpaMopWcb3p1vqZLkAKwIrsxXeIXU1N+uEjJIh3qYufR89+XkG0 4JmIgwE+VM+TRSzPVKrfS6+68kR81wZKq94KZjeAGIla4BHnSjHaoMSAShgz8FmI+z4c=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jhATd-00CnhX-9U for openvpn-devel@lists.sourceforge.net; Fri, 05 Jun 2020 11:25:34 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1jhATP-0000na-K9 for openvpn-devel@lists.sourceforge.net; Fri, 05 Jun 2020 13:25:19 +0200 Received: (nullmailer pid 22764 invoked by uid 10006); Fri, 05 Jun 2020 11:25:19 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 5 Jun 2020 13:25:18 +0200 Message-Id: <20200605112519.22714-2-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200605112519.22714-1-arne@rfc2549.org> References: <20200605112519.22714-1-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: 1jhATd-00CnhX-9U Subject: [Openvpn-devel] [PATCH 2/3] Make cipher_kt_get also accept OpenVPN config cipher name 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 Basically calls to cipher_kt_get were calling translate_cipher_name_from_openvpn. The only two exception were the (broken) unit test and tls-crypt that uses cipher_kt_get("AES-256-CTR") Signed-off-by: Arne Schwabe Acked-by: Steffan Karger --- src/openvpn/crypto.c | 2 +- src/openvpn/crypto_backend.h | 3 ++- src/openvpn/crypto_mbedtls.c | 1 + src/openvpn/crypto_openssl.c | 1 + src/openvpn/ssl_ncp.c | 8 ++++---- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index ba1fc095..1ce98184 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -763,7 +763,7 @@ init_key_type(struct key_type *kt, const char *ciphername, CLEAR(*kt); if (strcmp(ciphername, "none") != 0) { - kt->cipher = cipher_kt_get(translate_cipher_name_from_openvpn(ciphername)); + kt->cipher = cipher_kt_get(ciphername); if (!kt->cipher) { msg(M_FATAL, "Cipher %s not supported", ciphername); diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h index d46cb63f..85cb084a 100644 --- a/src/openvpn/crypto_backend.h +++ b/src/openvpn/crypto_backend.h @@ -227,7 +227,8 @@ void cipher_des_encrypt_ecb(const unsigned char key[DES_KEY_LENGTH], * initialise encryption/decryption. * * @param ciphername Name of the cipher to retrieve parameters for (e.g. - * \c AES-128-CBC). + * \c AES-128-CBC). Will be translated to the library name + * from the openvpn config name if needed. * * @return A statically allocated structure containing parameters * for the given cipher, or NULL if no matching parameters diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index c8dcddc8..bb752557 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -465,6 +465,7 @@ cipher_kt_get(const char *ciphername) ASSERT(ciphername); + ciphername = translate_cipher_name_from_openvpn(ciphername); cipher = mbedtls_cipher_info_from_string(ciphername); if (NULL == cipher) diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 13ab4859..bbaa5742 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -580,6 +580,7 @@ cipher_kt_get(const char *ciphername) ASSERT(ciphername); + ciphername = translate_cipher_name_from_openvpn(ciphername); cipher = EVP_get_cipherbyname(ciphername); if (NULL == cipher) diff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c index 042b0ce0..ea1dc960 100644 --- a/src/openvpn/ssl_ncp.c +++ b/src/openvpn/ssl_ncp.c @@ -103,12 +103,12 @@ mutate_ncp_cipher_list(const char *list, struct gc_arena *gc) while (token) { /* - * Going through a roundtrip by using translate_cipher_name_from_openvpn - * and translate_cipher_name_to_openvpn also normalises the cipher name, + * Going through a roundtrip by using cipher_kt_get/cipher_kt_name + * (and translate_cipher_name_from_openvpn/ + * translate_cipher_name_to_openvpn) also normalises the cipher name, * e.g. replacing AeS-128-gCm with AES-128-GCM */ - const char *cipher_name = translate_cipher_name_from_openvpn(token); - const cipher_kt_t *ktc = cipher_kt_get(cipher_name); + const cipher_kt_t *ktc = cipher_kt_get(token); if (!ktc) { msg(M_WARN, "Unsupported cipher in --ncp-ciphers: %s", token);