From patchwork Sun Aug 7 00:04:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2636 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director15.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id IIYSM1OO72LvPgAAIUCqbw (envelope-from ) for ; Sun, 07 Aug 2022 06:05:07 -0400 Received: from proxy8.mail.iad3b.rsapps.net ([172.31.255.6]) by director15.mail.ord1d.rsapps.net with LMTP id MBkBM1OO72J3IgAAIcMcQg (envelope-from ) for ; Sun, 07 Aug 2022 06:05:07 -0400 Received: from smtp28.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 CBQmLFOO72JmTgAAoCsc3g (envelope-from ) for ; Sun, 07 Aug 2022 06:05:07 -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: smtp28.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 69b7eb92-1638-11ed-8dba-525400c8cd63-1-1 Received: from [216.105.38.7] ([216.105.38.7:34130] helo=lists.sourceforge.net) by smtp28.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id DD/07-32059-35E8FE26; Sun, 07 Aug 2022 06:05:07 -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.94.2) (envelope-from ) id 1oKd8f-000427-3L; Sun, 07 Aug 2022 10:04:05 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oKd8I-00041d-8Q for openvpn-devel@lists.sourceforge.net; Sun, 07 Aug 2022 10:03:43 +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:Cc:To:From:Sender:Reply-To: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=ZSZwINH1S+PZglZYrcYhJz5WfPRgm+sY/VdzD0D7D44=; b=jkGq0Q/n72QxDgwnNUjEwwL1pA Jots8pKzHrKziXEOZjrijuC2wOvg1K7pHlAkV5ZlyMsoyHRd1ueUMVNIgF24BaTby7SqExp5K07rj zpcCmpFDeYawTNYbKFB1n2TA5rqCO7QXlPZDW7wWRYAXRkAc5bNeEqEs3Suif8QOo5Kw=; 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:Cc:To:From:Sender:Reply-To: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=ZSZwINH1S+PZglZYrcYhJz5WfPRgm+sY/VdzD0D7D44=; b=DY8aayARJ4fk91j8TDbZJil50n Alppb2KvC51gnP7g9OPB2wmYIaNGhBIolDlqAtiRW4V4Pm/Qh9TK0WsPR+8Gzl/VrCyyzOPpqrcTw MWdlKHiiGG+JpB1K6zA2GLIcA3vo4rif66jCVdpkOKH4hrPsLYy2qUo0fZZ7/Ci1ESkU=; Received: from [5.148.176.60] (helo=s2.neomailbox.net) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1oKd8I-0001Mh-69 for openvpn-devel@lists.sourceforge.net; Sun, 07 Aug 2022 10:03:42 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sun, 7 Aug 2022 12:04:04 +0200 Message-Id: <20220807100404.8618-1-a@unstable.cc> In-Reply-To: <20220624083809.23487-19-a@unstable.cc> References: MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-2.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: Other platforms may need more complex logic to decide whether a cipher is supported or not, therefore turn hardcoded list into a function that can be implemented by each platform independently. Signed-off-by: Lev Stipakov Signed-off-by: Antonio Quartulli --- Content analysis details: (1.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1oKd8I-0001Mh-69 Subject: [Openvpn-devel] [PATCH v2 18/18] dco: turn supported ciphers list into a 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: , Cc: Lev Stipakov , Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Other platforms may need more complex logic to decide whether a cipher is supported or not, therefore turn hardcoded list into a function that can be implemented by each platform independently. Signed-off-by: Lev Stipakov Signed-off-by: Antonio Quartulli --- Changes from v1: * rebased --- src/openvpn/dco.c | 4 ++-- src/openvpn/dco.h | 13 +++++++++++++ src/openvpn/dco_linux.c | 6 ++++++ src/openvpn/dco_linux.h | 1 - 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 09855643..889ae270 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -306,7 +306,7 @@ dco_check_option_conflict(int msglevel, const struct options *o) /* At this point the ciphers have already been normalised */ if (o->enable_ncp_fallback - && !tls_item_in_cipher_list(o->ciphername, DCO_SUPPORTED_CIPHERS)) + && !tls_item_in_cipher_list(o->ciphername, dco_get_supported_ciphers())) { msg(msglevel, "Note: --data-cipher-fallback with cipher '%s' " "disables data channel offload.", o->ciphername); @@ -358,7 +358,7 @@ dco_check_option_conflict(int msglevel, const struct options *o) const char *token; while ((token = strsep(&tmp_ciphers, ":"))) { - if (!tls_item_in_cipher_list(token, DCO_SUPPORTED_CIPHERS)) + if (!tls_item_in_cipher_list(token, dco_get_supported_ciphers())) { msg(msglevel, "Note: cipher '%s' in --data-ciphers is not supported " "by ovpn-dco, disabling data channel offload.", token); diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index 72569083..6b5c016a 100644 --- a/src/openvpn/dco.h +++ b/src/openvpn/dco.h @@ -213,6 +213,13 @@ void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, */ void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi); +/** + * Retrieve the list of ciphers supported by the current platform + * + * @return list of colon-separated ciphers + */ +const char *dco_get_supported_ciphers(); + #else /* if defined(ENABLE_DCO) */ typedef void *dco_context_t; @@ -320,5 +327,11 @@ dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi) { } +static inline const char * +dco_get_supported_ciphers() +{ + return ""; +} + #endif /* defined(ENABLE_DCO) */ #endif /* ifndef DCO_H */ diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 5e77139a..f86ea819 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -931,4 +931,10 @@ dco_event_set(dco_context_t *dco, struct event_set *es, void *arg) } } +const char * +dco_get_supported_ciphers() +{ + return "AES-128-GCM:AES-256-GCM:AES-192-GCM:CHACHA20-POLY1305"; +} + #endif /* defined(ENABLE_DCO) && defined(TARGET_LINUX) */ diff --git a/src/openvpn/dco_linux.h b/src/openvpn/dco_linux.h index e0e59fa6..416ea30a 100644 --- a/src/openvpn/dco_linux.h +++ b/src/openvpn/dco_linux.h @@ -34,7 +34,6 @@ typedef enum ovpn_key_slot dco_key_slot_t; typedef enum ovpn_cipher_alg dco_cipher_t; -#define DCO_SUPPORTED_CIPHERS "AES-128-GCM:AES-256-GCM:AES-192-GCM:CHACHA20-POLY1305" typedef struct {