From patchwork Fri Jun 5 01:25:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1143 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id iCJAKd8r2l6aZAAAIUCqbw for ; Fri, 05 Jun 2020 07:26:23 -0400 Received: from proxy7.mail.iad3b.rsapps.net ([172.31.255.6]) by director11.mail.ord1d.rsapps.net with LMTP id mLCpJt8r2l63JwAAvGGmqA ; Fri, 05 Jun 2020 07:26:23 -0400 Received: from smtp18.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.iad3b.rsapps.net with LMTP id SNGnIN8r2l4yBQAAQkQ5tQ ; Fri, 05 Jun 2020 07:26:23 -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: smtp18.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: 625bcd1c-a71f-11ea-becf-5254009ad1d4-1-1 Received: from [216.105.38.7] ([216.105.38.7:45214] helo=lists.sourceforge.net) by smtp18.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id BD/0D-26475-EDB2ADE5; Fri, 05 Jun 2020 07:26:23 -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 1jhATb-00063J-Th; Fri, 05 Jun 2020 11:25:31 +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 1jhATY-00062g-Uv for openvpn-devel@lists.sourceforge.net; Fri, 05 Jun 2020 11:25:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zcVptuUUCoTh/w0sr0R9ahyqQ2vJ2tpnfiWHfRUIhHE=; b=PCJZDfChiuYlVw6ifGF4btjvWm bYSkP8VUdKHt3cKCh59Bp8hPRkVq8iU9RhYHg/QcqS7AckMnYH68pG51dF1cRknOxNA96Pha2YtU6 ja2rKRli0w/nk5K3AQrXykAI3akKvHrVWUd8NwyFXOowFIxLxvSD/QlaTWLsZjYD4xuo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=zcVptuUUCoTh/w0sr0R9ahyqQ2vJ2tpnfiWHfRUIhHE=; b=T5imhYssn180IR1kNcRZTYThME EFK9w3WnEeowpQKxL/EZde4g251r/ukSx+qG2MbntFzcWQirFB90pM8tc8OGc/HO05ljeKmUr3TVi QKtBbVDtzMK5dLlNVcEq8ud+ox/FTD07Xgq2SZv2j2eHtIL9EYm1efhYsWwD0eUevUjg=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jhATW-009nec-Tq for openvpn-devel@lists.sourceforge.net; Fri, 05 Jun 2020 11:25:28 +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-0000nX-IE for openvpn-devel@lists.sourceforge.net; Fri, 05 Jun 2020 13:25:19 +0200 Received: (nullmailer pid 22761 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:17 +0200 Message-Id: <20200605112519.22714-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 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: 1jhATW-009nec-Tq Subject: [Openvpn-devel] [PATCH 1/3] Make cipher_kt_name always return normalised 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 The mbed TLS variant of the call already returned the normalised name while the OpenSSL variant did not. On top of that, all calls but one to cipher_kt_name were translate_cipher_name_to_openvpn. This commit moves the call of translate_cipher_name_to_openvpn into cipher_kt_name or avoids calling it twice in the case of mbed TLS. The one case that did not translate_cipher_name_to_openvpn is an internal ssl_openssl.c method that should call EVP_CIPHER_name anyway. Also simplify cipher_name_cmp function that is only used by openvpn --show-ciphers with the modified cipher_kt_name function. Signed-off-by: Arne Schwabe Acked-by: Steffan Karger --- src/openvpn/crypto.c | 4 ++-- src/openvpn/crypto_backend.h | 2 ++ src/openvpn/crypto_openssl.c | 13 +++++-------- src/openvpn/options.c | 3 +-- src/openvpn/ssl_ncp.c | 3 +-- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 2388027c..ba1fc095 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -847,7 +847,7 @@ init_key_ctx(struct key_ctx *ctx, const struct key *key, cipher_ctx_init(ctx->cipher, key->cipher, kt->cipher_length, kt->cipher, enc); - const char *ciphername = translate_cipher_name_to_openvpn(cipher_kt_name(kt->cipher)); + const char *ciphername = cipher_kt_name(kt->cipher); msg(D_HANDSHAKE, "%s: Cipher '%s' initialized with %d bit key", prefix, ciphername, @@ -1810,7 +1810,7 @@ print_cipher(const cipher_kt_t *cipher) " by default" : ""; printf("%s (%d bit key%s, ", - translate_cipher_name_to_openvpn(cipher_kt_name(cipher)), + cipher_kt_name(cipher), cipher_kt_key_size(cipher) * 8, var_key_size); if (cipher_kt_block_size(cipher) == 1) diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h index 1d206a8c..d46cb63f 100644 --- a/src/openvpn/crypto_backend.h +++ b/src/openvpn/crypto_backend.h @@ -237,6 +237,8 @@ const cipher_kt_t *cipher_kt_get(const char *ciphername); /** * Retrieve a string describing the cipher (e.g. \c AES-128-CBC). + * The returned name is normalised to the OpenVPN config name in case the + * name differs from the name used by the crypto library. * * @param cipher_kt Static cipher parameters * diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index a5b2c45a..13ab4859 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -266,12 +266,7 @@ cipher_name_cmp(const void *a, const void *b) const EVP_CIPHER *const *cipher_a = a; const EVP_CIPHER *const *cipher_b = b; - const char *cipher_name_a = - translate_cipher_name_to_openvpn(EVP_CIPHER_name(*cipher_a)); - const char *cipher_name_b = - translate_cipher_name_to_openvpn(EVP_CIPHER_name(*cipher_b)); - - return strcmp(cipher_name_a, cipher_name_b); + return strcmp(cipher_kt_name(*cipher_a), cipher_kt_name(*cipher_b)); } void @@ -613,7 +608,9 @@ cipher_kt_name(const EVP_CIPHER *cipher_kt) { return "[null-cipher]"; } - return EVP_CIPHER_name(cipher_kt); + + const char *name = EVP_CIPHER_name(cipher_kt); + return translate_cipher_name_to_openvpn(name); } int @@ -644,7 +641,7 @@ cipher_kt_block_size(const EVP_CIPHER *cipher) int block_size = EVP_CIPHER_block_size(cipher); - orig_name = cipher_kt_name(cipher); + orig_name = EVP_CIPHER_name(cipher); if (!orig_name) { goto cleanup; diff --git a/src/openvpn/options.c b/src/openvpn/options.c index d1e68a51..ec912d34 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3779,8 +3779,7 @@ options_string(const struct options *o, init_key_type(&kt, o->ciphername, o->authname, o->keysize, true, false); - buf_printf(&out, ",cipher %s", - translate_cipher_name_to_openvpn(cipher_kt_name(kt.cipher))); + buf_printf(&out, ",cipher %s", cipher_kt_name(kt.cipher)); buf_printf(&out, ",auth %s", md_kt_name(kt.digest)); buf_printf(&out, ",keysize %d", kt.cipher_length * 8); if (o->shared_secret_file) diff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c index 9ed6ff5f..042b0ce0 100644 --- a/src/openvpn/ssl_ncp.c +++ b/src/openvpn/ssl_ncp.c @@ -116,8 +116,7 @@ mutate_ncp_cipher_list(const char *list, struct gc_arena *gc) } else { - const char *ovpn_cipher_name = - translate_cipher_name_to_openvpn(cipher_kt_name(ktc)); + const char *ovpn_cipher_name = cipher_kt_name(ktc); if (buf_len(&new_list)> 0) {