From patchwork Sat Nov 6 22:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2061 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id sNQ9KUyWh2H2AwAAIUCqbw (envelope-from ) for ; Sun, 07 Nov 2021 04:03:08 -0500 Received: from proxy4.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id ONgWKUyWh2FyCwAAvGGmqA (envelope-from ) for ; Sun, 07 Nov 2021 04:03:08 -0500 Received: from smtp27.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.ord1d.rsapps.net with LMTPS id sDjaKEyWh2FHDAAAiYrejw (envelope-from ) for ; Sun, 07 Nov 2021 04:03:08 -0500 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: smtp27.gate.ord1d.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: 864623f2-3fa9-11ec-9b3c-5254003773d7-1-1 Received: from [216.105.38.7] ([216.105.38.7:59928] helo=lists.sourceforge.net) by smtp27.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 13/A9-02360-C4697816; Sun, 07 Nov 2021 04:03:08 -0500 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1mje3k-00065V-Qr; Sun, 07 Nov 2021 09:01:52 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mje3j-00065F-7e for openvpn-devel@lists.sourceforge.net; Sun, 07 Nov 2021 09:01:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: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=L2rfq3SnHh3QDKzhTljiYh28qVQbrwuHrsT2/e8/XwI=; b=UE3+wVD3XbMOjIC5bm4zpC1290 UDYPSvajF0bFwScLj0WengRlmZwR4A6MfTLOWiQDXsZU9AgkdaabUQVn2hRmpEgReKiW3i5A+iZkL P6LoGpfTAvm5dYYjCcJuU4/Lub+6CTlboXxPg9Tki3J1a4l0Y3UCAEKRgNKw5II+wiV8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Type: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=L2rfq3SnHh3QDKzhTljiYh28qVQbrwuHrsT2/e8/XwI=; b=i W2PMPdzJ/77TjSJYGtFRZbypzleVnwpdN2U3VR88p9/8LNlpODJx8okjHZFwIVJMe6grNfB5YxOiU MPclPJbuQV0h50Z2z5l3Xn7b3HapGvuDWGCm/jRr9dJv2Cikf7GZgIAne7VuR93595TgEHroPZMCU +u12DyO/ybedxdi0=; 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.3) id 1mje3d-004qvh-Ug for openvpn-devel@lists.sourceforge.net; Sun, 07 Nov 2021 09:01:51 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94.2 (FreeBSD)) (envelope-from ) id 1mje3V-0004Mr-RJ for openvpn-devel@lists.sourceforge.net; Sun, 07 Nov 2021 10:01:37 +0100 Received: (nullmailer pid 3150233 invoked by uid 10006); Sun, 07 Nov 2021 09:01:38 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Sun, 7 Nov 2021 10:01:38 +0100 Message-Id: <20211107090138.3150187-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: We already removed the check in d67658fee for OpenSSL 3.0. This removes the checks entirely for all crypto libraries. Signed-off-by: Arne Schwabe --- src/openvpn/crypto.c | 15 -------- src/openvpn/crypto_backend.h | 28 src/openvpn/crypto_mbedtls.c | 56 [...] Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-Headers-End: 1mje3d-004qvh-Ug Subject: [Openvpn-devel] [PATCH] Completely remove DES checks 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox We already removed the check in d67658fee for OpenSSL 3.0. This removes the checks entirely for all crypto libraries. Signed-off-by: Arne Schwabe Acked-by: Max Fillinger --- src/openvpn/crypto.c | 15 -------- src/openvpn/crypto_backend.h | 28 --------------- src/openvpn/crypto_mbedtls.c | 56 ------------------------------ src/openvpn/crypto_openssl.c | 66 ------------------------------------ 4 files changed, 165 deletions(-) diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 1d242ac5a..e267e7a06 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -986,21 +986,6 @@ check_key(struct key *key, const struct key_type *kt) { return false; } - - /* - * Check for weak or semi-weak DES keys. - */ - { - const int ndc = key_des_num_cblocks(kt->cipher); - if (ndc) - { - return key_des_check(key->cipher, kt->cipher_length, ndc); - } - else - { - return true; - } - } } return true; } diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h index 8bf6012a9..40984c559 100644 --- a/src/openvpn/crypto_backend.h +++ b/src/openvpn/crypto_backend.h @@ -156,34 +156,6 @@ bool crypto_pem_decode(const char *name, struct buffer *dst, */ int rand_bytes(uint8_t *output, int len); -/* - * - * Key functions, allow manipulation of keys. - * - */ - - -/** - * Return number of DES cblocks (1 cblock = length of a single-DES key) for the - * current key type or 0 if not a DES cipher. - * - * @param kt Type of key - * - * @return Number of DES cblocks that the key consists of, or 0. - */ -int key_des_num_cblocks(const cipher_kt_t *kt); - -/* - * Check the given DES key. Checks the given key's length, weakness and parity. - * - * @param key Key to check - * @param key_len Length of the key, in bytes - * @param ndc Number of DES cblocks that the key is made up of. - * - * @return \c true if the key is valid, \c false otherwise. - */ -bool key_des_check(uint8_t *key, int key_len, int ndc); - /** * Encrypt the given block, using DES ECB mode * diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index a31ff5561..781da1ca9 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -386,62 +386,6 @@ rand_bytes(uint8_t *output, int len) return 1; } -/* - * - * Key functions, allow manipulation of keys. - * - */ - - -int -key_des_num_cblocks(const mbedtls_cipher_info_t *kt) -{ - int ret = 0; - if (kt->type == MBEDTLS_CIPHER_DES_CBC) - { - ret = 1; - } - if (kt->type == MBEDTLS_CIPHER_DES_EDE_CBC) - { - ret = 2; - } - if (kt->type == MBEDTLS_CIPHER_DES_EDE3_CBC) - { - ret = 3; - } - - dmsg(D_CRYPTO_DEBUG, "CRYPTO INFO: n_DES_cblocks=%d", ret); - return ret; -} - -bool -key_des_check(uint8_t *key, int key_len, int ndc) -{ - int i; - struct buffer b; - - buf_set_read(&b, key, key_len); - - for (i = 0; i < ndc; ++i) - { - unsigned char *key = buf_read_alloc(&b, MBEDTLS_DES_KEY_SIZE); - if (!key) - { - msg(D_CRYPT_ERRORS, "CRYPTO INFO: check_key_DES: insufficient key material"); - goto err; - } - if (0 != mbedtls_des_key_check_weak(key)) - { - msg(D_CRYPT_ERRORS, "CRYPTO INFO: check_key_DES: weak key detected"); - goto err; - } - } - return true; - -err: - return false; -} - /* * * Generic cipher key type functions diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index bbfe15143..116c99c8e 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -552,72 +552,6 @@ rand_bytes(uint8_t *output, int len) return 1; } -/* - * - * Key functions, allow manipulation of keys. - * - */ - - -int -key_des_num_cblocks(const EVP_CIPHER *kt) -{ - int ret = 0; - const char *name = OBJ_nid2sn(EVP_CIPHER_nid(kt)); - if (name) - { - if (!strncmp(name, "DES-", 4)) - { - ret = EVP_CIPHER_key_length(kt) / sizeof(DES_cblock); - } - else if (!strncmp(name, "DESX-", 5)) - { - ret = 1; - } - } - dmsg(D_CRYPTO_DEBUG, "CRYPTO INFO: n_DES_cblocks=%d", ret); - return ret; -} - -bool -key_des_check(uint8_t *key, int key_len, int ndc) -{ -#if OPENSSL_VERSION_NUMBER < 0x30000000L - int i; - struct buffer b; - - buf_set_read(&b, key, key_len); - - for (i = 0; i < ndc; ++i) - { - DES_cblock *dc = (DES_cblock *) buf_read_alloc(&b, sizeof(DES_cblock)); - if (!dc) - { - crypto_msg(D_CRYPT_ERRORS, - "CRYPTO INFO: check_key_DES: insufficient key material"); - goto err; - } - if (DES_is_weak_key(dc)) - { - crypto_msg(D_CRYPT_ERRORS, - "CRYPTO INFO: check_key_DES: weak key detected"); - goto err; - } - } - return true; - -err: - ERR_clear_error(); - return false; -#else - /* DES is deprecated and the method to even check the keys is deprecated - * in OpenSSL 3.0. Instead of checking for the 16 weak/semi-weak keys - * we just accept them in OpenSSL 3.0 since the risk of randomly getting - * these is pretty low (and "all DES keys are weak" anyway) */ - return true; -#endif -} - /* * * Generic cipher key type functions