From patchwork Thu Apr 22 05:17:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1761 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.58]) by backend30.mail.ord1d.rsapps.net with LMTP id qFAFEcOTgWCGPQAAIUCqbw (envelope-from ) for ; Thu, 22 Apr 2021 11:18:27 -0400 Received: from proxy2.mail.iad3a.rsapps.net ([172.27.255.58]) by director9.mail.ord1d.rsapps.net with LMTP id kLXgEMOTgWBfYgAAalYnBA (envelope-from ) for ; Thu, 22 Apr 2021 11:18:27 -0400 Received: from smtp17.gate.iad3a ([172.27.255.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.iad3a.rsapps.net with LMTPS id CFJBCsOTgWAGSwAABcWvHw (envelope-from ) for ; Thu, 22 Apr 2021 11:18:27 -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: smtp17.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: fbe97afa-a37d-11eb-b208-525400723ca9-1-1 Received: from [216.105.38.7] ([216.105.38.7:32954] helo=lists.sourceforge.net) by smtp17.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 44/BA-15159-2C391806; Thu, 22 Apr 2021 11:18:26 -0400 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.90_1) (envelope-from ) id 1lZb5O-0001CF-6J; Thu, 22 Apr 2021 15:17:46 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZb5K-0001Bx-Er for openvpn-devel@lists.sourceforge.net; Thu, 22 Apr 2021 15:17:42 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Pl8tTEGlG18l0q+NzThie2Oifi4X7Vcilnmw0/0BSjc=; b=hd4JsCVeSd135n125diLbTGQqz sEAKZEtFFoYmQkBHYOKXmejjAWPgRsyIMpMe7ZOExW6oFBVJvg0PCLSGDjvnOfysBMKv5mBVaDWTN bzvwo/DrxN9KxsocxfmdZ64PIpc3OvehSPcT2/n9NXnIxMqBuvOXiJ6dkUNIIRvTLsDE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Pl8tTEGlG18l0q+NzThie2Oifi4X7Vcilnmw0/0BSjc=; b=LonnCQb3xIkd0CoO0C5f6rMHuh IzKZ1GjcR2560OWvVOr20woXv2nEXGbkoxqpPedYbPP6B4xs2F+mQhwPRB05KwsE3d8HZYqiXTwWi CSpOA1AHWZYXvfjMT5Ba9A99WDks5zP0LafuUIKnh92EOvVwp5E2SQ5BJ3r5kuTkdpD4=; 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 1lZb5E-00DGRD-J8 for openvpn-devel@lists.sourceforge.net; Thu, 22 Apr 2021 15:17:43 +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 1lZb52-000B5Y-GR for openvpn-devel@lists.sourceforge.net; Thu, 22 Apr 2021 17:17:24 +0200 Received: (nullmailer pid 2132631 invoked by uid 10006); Thu, 22 Apr 2021 15:17:24 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Thu, 22 Apr 2021 17:17:22 +0200 Message-Id: <20210422151724.2132573-5-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422151724.2132573-1-arne@rfc2549.org> References: <20210422151724.2132573-1-arne@rfc2549.org> MIME-Version: 1.0 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: 1lZb5E-00DGRD-J8 Subject: [Openvpn-devel] [PATCH 5/7] Extracting key_state deferred auth status update into function 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 This extract the update of a deferred key status into into own function. Signed-off-by: Arne Schwabe --- src/openvpn/ssl_verify.c | 90 ++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index e000f75f7..912012eb7 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1073,6 +1073,56 @@ key_state_test_auth_control_file(struct auth_deferred_status *ads, bool cached) return ACF_DISABLED; } +/** + * This method takes a key_state and if updates the state + * of the key if it is deferred. + * @param cached If auth control files should be tried to be opened or th + * cached results should be used + * @param ks The key_state to update + */ +static void +update_key_auth_status(bool cached, struct key_state *ks) +{ + if (ks->authenticated == KS_AUTH_FALSE) + { + return; + } + else + { + enum auth_deferred_result auth_plugin = ACF_DISABLED; + enum auth_deferred_result auth_script = ACF_DISABLED; + enum auth_deferred_result auth_man = ACF_DISABLED; + auth_plugin = key_state_test_auth_control_file(&ks->plugin_auth, cached); + auth_script = key_state_test_auth_control_file(&ks->script_auth, cached); +#ifdef ENABLE_MANAGEMENT + auth_man = man_def_auth_test(ks); +#endif + ASSERT(auth_plugin < 4 && auth_script < 4 && auth_man < 4); + + if (auth_plugin == ACF_FAILED || auth_script == ACF_FAILED + || auth_man == ACF_FAILED) + { + ks->authenticated = KS_AUTH_FALSE; + return; + } + else if (auth_plugin == ACF_PENDING + || auth_script == ACF_PENDING + || auth_man == ACF_PENDING) + { + if (now < ks->auth_deferred_expire) + { + /* key state is remains in KS_DEFERRED */ + } + } + else + { + /* auth_plugin and auth_man are either ACF_DISABLED or ACF_SUCCEDED */ + ks->authenticated = KS_AUTH_TRUE; + } + } +} + + enum tls_auth_status tls_authentication_status(struct tls_multi *multi, const int latency) { @@ -1096,43 +1146,19 @@ tls_authentication_status(struct tls_multi *multi, const int latency) if (TLS_AUTHENTICATED(multi, ks)) { active++; + update_key_auth_status(cached, ks); + if (ks->authenticated == KS_AUTH_FALSE) { failed_auth = true; } - else + else if (ks->authenticated == KS_AUTH_DEFERRED) { - enum auth_deferred_result auth_plugin = ACF_DISABLED; - enum auth_deferred_result auth_script = ACF_DISABLED; - enum auth_deferred_result auth_man = ACF_DISABLED; - auth_plugin = key_state_test_auth_control_file(&ks->plugin_auth, cached); - auth_script = key_state_test_auth_control_file(&ks->script_auth, cached); -#ifdef ENABLE_MANAGEMENT - auth_man = man_def_auth_test(ks); -#endif - ASSERT(auth_plugin < 4 && auth_script < 4 && auth_man < 4); - - if (auth_plugin == ACF_FAILED || auth_script == ACF_FAILED - || auth_man == ACF_FAILED) - { - ks->authenticated = KS_AUTH_FALSE; - failed_auth = true; - } - else if (auth_plugin == ACF_PENDING - || auth_script == ACF_PENDING - || auth_man == ACF_PENDING) - { - if (now < ks->auth_deferred_expire) - { - deferred = true; - } - } - else - { - /* auth_plugin and auth_man are either ACF_DISABLED or ACF_SUCCEDED */ - success = true; - ks->authenticated = KS_AUTH_TRUE; - } + deferred = true; + } + else if (ks->authenticated == KS_AUTH_TRUE) + { + success = true; } } }