From patchwork Mon Jan 19 11:37:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4715 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:9186:b0:80a:3855:ce6a with SMTP id j6csp3134108maf; Mon, 19 Jan 2026 03:38:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUX45B3uoqV0EJzcJFiWxUkfJ1CBzfOgLxzeBi92X0iKP+4w58soQLg0Dv0CUuBvPygWjEntfhVEO8=@openvpn.net X-Received: by 2002:a05:6808:199c:b0:450:1179:5f43 with SMTP id 5614622812f47-45c9c098258mr4322079b6e.37.1768822693996; Mon, 19 Jan 2026 03:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1768822693; cv=none; d=google.com; s=arc-20240605; b=VECo7kE0O3tVWdsPaS50Xz5Ir8iA1OCh7Z/2uYn0MU0Q82DcwlJzabKrf8UdJNhZcI Li7FGKl91AvanaQtz+B3Q9BVtW6Uh+ybVpdEu2TZKjrAcHeA544wbekY5HRf8067mxc1 Zm6vmGS6PM+PyaFPtgubxuc4YRAeo8doOTSe4M8Sc/GC4iLjljK2MRWpYrzGT2lBbRkR UGvtkzElauwajCskGPhajY7+/Qg6D3rOOHXH8Zw88cB3MaaAVnQuGjJWakfiCgUJkrJc l0I/6zmdsYxx48D6efVFT7L1xU+tx8EtZyoKZTgjuKA9EJx4dZEneB07zRgcGCMyawCh f/5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=W4XJ5BPMThaukzdTdE2DCVAGyCz6o1m2QLkqnSK/dqI=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=b324lgDIrzIrSn3tJxssW3IqfYWCh2LvGFUM1agb531JOqRWbtgZgDRjjxwVUVK+gh Rzwjf7xo/ucoLEz1C0QZa3EG498UfkmGXSWeoTUz/SSsV8Pezof423wgXNQgvArF46/a wZH+Snz4Xiw1Nk/naahiKCtqBIxAuU9vlbmUKWnYHD/hXMZGK2awIhqclCQK9lw7Knu0 lkLedAk6Pk753Z+97jQhYEGXfFMjxAtX4vWJMmogi8wTIA7RVQ2uZUO5GTWUtlpGrlfM 4GN7WLtaMVYbGppvtsZzAgT4CE8Ni8NCZgWdI9eZKB/N3Lzmk2sc7sxHuJXtDiEGzRPC oSDA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=bEWf1pfA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HRrowd4v; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VeyUSzwj; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-45c9e36f91csi6092530b6e.83.2026.01.19.03.38.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jan 2026 03:38:13 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=bEWf1pfA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HRrowd4v; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VeyUSzwj; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=W4XJ5BPMThaukzdTdE2DCVAGyCz6o1m2QLkqnSK/dqI=; b=bEWf1pfAQPncRr15ZZ9uyAc1r1 DNM5Y4M8Y0Thp3z+jPignJZCUusZ1awsX8bFeBTwO+x0IXTU5+Wq//eppfp6FaXkKoq5rdIs0Awz6 qDJTPfhqYX8QYn9z6VNjVtnaKNZM8d+CyHY6GYRM2AwsJorwtkOUM3x0KlzNCKiMbp5A=; 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.95) (envelope-from ) id 1vhna7-0007TH-P2; Mon, 19 Jan 2026 11:38:03 +0000 Received: from [172.30.29.66] (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.95) (envelope-from ) id 1vhna5-0007T9-Rc for openvpn-devel@lists.sourceforge.net; Mon, 19 Jan 2026 11:38:01 +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=fTojY3f9xPk9zP7JwpH0vweUbyxF+n+yugJJ6nnbWUE=; b=HRrowd4vu+ZpwvEDIElU9Qddv9 YNtCbXwE5+B2eiHhZmsnQ50HiaXErFmyodoXvBE32aG0nMkE/Syl2rl95gFaXmRRQiX9YRgNuCifI rne8QvZZvuJSaunWu22tnzE7eto1Qk8d3D+GWxelIy3x9M/eBmXYDon0/Lft/WFMkzWU=; 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=fTojY3f9xPk9zP7JwpH0vweUbyxF+n+yugJJ6nnbWUE=; b=VeyUSzwjD50WQqWXJ8pHyWGkHz wbtmQLQRHGDLY36LCl/buhKxvTVnl9ODMWTNBYev9c0jGq8ZZ8lZ4SVjg4v1rn+FroniXSuPWKKSk uJl6Cm2njqesI2VJ9ncqNm6QLaUHd5w76J8ETGVYJnOqtNWuUckOuNreZB4JHd+3vofU=; Received: from [193.149.48.134] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vhna4-000825-8N for openvpn-devel@lists.sourceforge.net; Mon, 19 Jan 2026 11:38:01 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 60JBbm1s010925 for ; Mon, 19 Jan 2026 12:37:48 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 60JBbmxe010924 for openvpn-devel@lists.sourceforge.net; Mon, 19 Jan 2026 12:37:48 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 19 Jan 2026 12:37:42 +0100 Message-ID: <20260119113747.10912-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.51.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", 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: From: Frank Lichtenheld Due to the differences in the types of APIs between xkey provider and Windows cryptoapi we can't avoid the casts. And they should be safe generally since the involved sizes should be small compared to [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1vhna4-000825-8N Subject: [Openvpn-devel] [PATCH v1] cryptoapi: Avoid conversion warnings 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 X-GMAIL-THRID: =?utf-8?q?1854482038537757171?= X-GMAIL-MSGID: =?utf-8?q?1854745025560167450?= From: Frank Lichtenheld Due to the differences in the types of APIs between xkey provider and Windows cryptoapi we can't avoid the casts. And they should be safe generally since the involved sizes should be small compared to the maximum values. So just add asserts and explicit cast to avoid the warnings. Change-Id: I789022af7c4977c4dff4f7671f491fe5836828fa Signed-off-by: Frank Lichtenheld Acked-by: Selva Nair Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1464 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1464 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Selva Nair diff --git a/src/openvpn/cryptoapi.c b/src/openvpn/cryptoapi.c index b18b9d4..49f5bbb 100644 --- a/src/openvpn/cryptoapi.c +++ b/src/openvpn/cryptoapi.c @@ -61,7 +61,7 @@ return 0; } -#else /* HAVE_XKEY_PROVIDER */ +#else /* HAVE_XKEY_PROVIDER */ static XKEY_EXTERNAL_SIGN_fn xkey_cng_sign; @@ -341,21 +341,18 @@ return rv; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** Sign hash in tbs using EC key in cd and NCryptSignHash */ static int xkey_cng_ec_sign(CAPI_DATA *cd, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen) { - DWORD len = *siglen; + ASSERT(*siglen <= UINT_MAX); + ASSERT(tbslen <= UINT_MAX); + DWORD len = (DWORD)*siglen; msg(D_LOW, "Signing using NCryptSignHash with EC key"); - DWORD status = NCryptSignHash(cd->crypt_prov, NULL, (BYTE *)tbs, tbslen, sig, len, &len, 0); + DWORD status = NCryptSignHash(cd->crypt_prov, NULL, (BYTE *)tbs, (DWORD)tbslen, sig, len, &len, 0); if (status != ERROR_SUCCESS) { @@ -383,7 +380,9 @@ ASSERT(cd); ASSERT(sig); + ASSERT(*siglen <= UINT_MAX); ASSERT(tbs); + ASSERT(tbslen <= INT_MAX); DWORD status = ERROR_SUCCESS; DWORD len = 0; @@ -406,10 +405,10 @@ } else if (!strcmp(sigalg.padmode, "pss")) { - int saltlen = tbslen; /* digest size by default */ + int saltlen = (int)tbslen; /* digest size by default */ if (!strcmp(sigalg.saltlen, "max")) { - saltlen = xkey_max_saltlen(EVP_PKEY_bits(cd->pubkey), tbslen); + saltlen = xkey_max_saltlen(EVP_PKEY_bits(cd->pubkey), saltlen); if (saltlen < 0) { msg(M_NONFATAL, "Error in cryptoapicert: invalid salt length (%d)", saltlen); @@ -420,8 +419,8 @@ msg(D_LOW, "Signing using NCryptSignHash with PSS padding: hashalg <%s>, saltlen <%d>", sigalg.mdname, saltlen); - BCRYPT_PSS_PADDING_INFO padinfo = { hashalg, - (DWORD)saltlen }; /* cast is safe as saltlen >= 0 */ + /* cast is safe as saltlen >= 0 */ + BCRYPT_PSS_PADDING_INFO padinfo = { hashalg, (DWORD)saltlen }; status = NCryptSignHash(cd->crypt_prov, &padinfo, (BYTE *)tbs, (DWORD)tbslen, sig, (DWORD)*siglen, &len, BCRYPT_PAD_PSS); } @@ -442,10 +441,6 @@ return (*siglen > 0); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /** Dispatch sign op to xkey_cng__sign */ static int xkey_cng_sign(void *handle, unsigned char *sig, size_t *siglen, const unsigned char *tbs,