From patchwork Wed Jan 17 02:10:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Deloget X-Patchwork-Id: 193 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director2.mail.ord1d.rsapps.net ([172.28.255.1]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id q79gHptLX1qvRgAAgoeIoA for ; Wed, 17 Jan 2018 08:11:55 -0500 Received: from proxy1.mail.ord1c.rsapps.net ([172.28.255.1]) by director2.mail.ord1d.rsapps.net (Dovecot) with LMTP id nWP2A5tLX1oMcAAAgYhSiA ; Wed, 17 Jan 2018 08:11:55 -0500 Received: from smtp2.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.ord1c.rsapps.net (Dovecot) with LMTP id JSo1DZtLX1rrAwAA2VeTtA ; Wed, 17 Jan 2018 08:11:55 -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.34.181.88] Authentication-Results: smtp2.gate.ord1c.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; 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; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=none (p=nil; dis=none) header.from=free.fr X-Classification-ID: fd92adf0-fb87-11e7-9e5e-842b2b4e7063-1-1 Received: from [216.34.181.88] ([216.34.181.88:19856] helo=lists.sourceforge.net) by smtp2.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 2E/DD-09820-B9B4F5A5; Wed, 17 Jan 2018 08:11:55 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1ebnUi-0001jf-Em; Wed, 17 Jan 2018 13:11:08 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ebnUg-0001jW-IJ for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2018 13:11:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=hET0cRclvNsCXg0r5o8AuvlCOhGywVpc5Yd4gr2/bhU=; b=bwtUu910fulasfnk3WiVHXq8wo ExuJiBbXQ/njXbxmMjpxxZJpWpsMFjwvkTKWtGdSZ+UM1+sQrKPmpe++5MqgB+iTVgtm/si3bEy3I tSOyulgUlE6dH/SO+OC4NTwS7Z47YvUWnO4+qvoOT7RdGqWJgb8dLYGr/JzpXAkffcU0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=hET0cRclvNsCXg0r5o8AuvlCOhGywVpc5Yd4gr2/bhU=; b=PsfCrnYWQyuuhM9iC+KvFgiCsH xqaTdgNDBoXdXeR3HCKuhfnd9YSorxhpu0mfrYvEZdqB+KX4l6y8sAvr+faa9x0glA71ObAFJEryz Um8U28aM/Dv5MYloErb3GNtAgq95vCUY/OoDcB5DOodw3NbxsJBhFpE9rljdEucjUdGA=; Received: from mail-wr0-f196.google.com ([209.85.128.196]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) id 1ebnUf-0003T9-LI for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2018 13:11:06 +0000 Received: by mail-wr0-f196.google.com with SMTP id f11so8285606wre.4 for ; Wed, 17 Jan 2018 05:11:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=hET0cRclvNsCXg0r5o8AuvlCOhGywVpc5Yd4gr2/bhU=; b=Dwxmo1P1BQ7+nxjhDEFakw/2XjQ/+jxCx1v8L4XBtQeLw1Cv4iSdIw/9gwRWufboFX xwdDorPHcYxg2rfaOufgzYrTpP9D0D1b7YZd+2AxUlsQHjgsHd2e/12OCJ5XyPhthZ+h I8krus7WfmbaQjq7Rcj30YqaFVdB4igxevLuUR0IMz7tuUXIP10FyyH/KFb2Pvmy9yNu mSPsVcqb1JT08FAZfuN/zfd0ayaK3zrxepDTuUhTNPBKrJ4xestKjP0ab6/jFA34Fj5P JZbabODJrx2V4BS1Y1nICAfCUHmRMOmEhgBSy7HAYoPjbWI7nq3gagoM3sZzjktkUZwn +Q6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=hET0cRclvNsCXg0r5o8AuvlCOhGywVpc5Yd4gr2/bhU=; b=bGCaln4U/bEdClJ8oCcY3n28JpyzbNePvIQscincAI7up/ZCIXXn8TADVzcOTkUAuv T/xgAjthdSPMTJtD5t6AskuiCGCP/RchSX3qcddIY4tYzJNFUsHtvMHLyGUYB5RHzT3j fijPbxOqtpk9DlpqoMhtJhaiOu4qTz8L1bBAP/mbQCdMFfhIoXqFxb05CIPFtolQUEw7 hDRmKR4X7h+parpNVVt9Tn9lRI7d0bYiPcm7ps5m8Rlk9z5EZh5ee9Gkfxf1MG5xd6rb R3Mwg0yml3/NnISmT8kexP47FnJEvEgWt6F8MNT+iOE5x6/HiLlbmjfHFd/wgjvMx2rM XoMA== X-Gm-Message-State: AKwxytfV4m+CzVtfpVubbdCToBWM2P1ey6u2oNAy52RGUfHSHqq6WzfX Tto8PAOzFjG3k+lQkn9acFs8+Xs8 X-Google-Smtp-Source: ACJfBovMsOf/8Rp8wcF/78rLf13xwA94L4OECKzmna3Aw+ygRGupiFQoXNI2wU+G42BHcpCHiE2QjA== X-Received: by 10.223.136.110 with SMTP id e43mr2486599wre.98.1516194659336; Wed, 17 Jan 2018 05:10:59 -0800 (PST) Received: from edt-thinkpad.eho.intranet ([2a01:cb1c:53c:ce00:e53a:b249:c0f2:2f2a]) by smtp.gmail.com with ESMTPSA id q186sm5074508wmb.6.2018.01.17.05.10.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2018 05:10:58 -0800 (PST) From: Emmanuel Deloget To: openvpn-devel@lists.sourceforge.net Date: Wed, 17 Jan 2018 14:10:45 +0100 Message-Id: <20180117131046.32402-1-logout@free.fr> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (logout[at]free.fr) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.128.196 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (emmanueldeloget53[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1ebnUf-0003T9-LI Subject: [Openvpn-devel] [PATCH v3 1/2] OpenSSL: remove some EVP_PKEY type 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Calling EVP_KEY_id() before EVP_PKEY_get0_*() is unnecessary as the same check is also performed in the later. We also make the code a bit better by not calling the various EVP_PKEY_get0_*() functions twice (this needs a bit or reordering to avoid introducing yet another #ifndef OPENSSL_NO_EC in the code). Signed-off-by: Emmanuel Deloget --- src/openvpn/ssl_openssl.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 86318d4c..7061f536 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -1699,22 +1699,13 @@ print_details(struct key_state_ssl *ks_ssl, const char *prefix) EVP_PKEY *pkey = X509_get_pubkey(cert); if (pkey != NULL) { - if ((EVP_PKEY_id(pkey) == EVP_PKEY_RSA) && (EVP_PKEY_get0_RSA(pkey) != NULL)) - { - RSA *rsa = EVP_PKEY_get0_RSA(pkey); - openvpn_snprintf(s2, sizeof(s2), ", %d bit RSA", - RSA_bits(rsa)); - } - else if ((EVP_PKEY_id(pkey) == EVP_PKEY_DSA) && (EVP_PKEY_get0_DSA(pkey) != NULL)) - { - DSA *dsa = EVP_PKEY_get0_DSA(pkey); - openvpn_snprintf(s2, sizeof(s2), ", %d bit DSA", - DSA_bits(dsa)); - } + RSA *rsa = EVP_PKEY_get0_RSA(pkey); + DSA *dsa = EVP_PKEY_get0_DSA(pkey); #ifndef OPENSSL_NO_EC - else if ((EVP_PKEY_id(pkey) == EVP_PKEY_EC) && (EVP_PKEY_get0_EC_KEY(pkey) != NULL)) + EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); + + if (ec != NULL) { - EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); const EC_GROUP *group = EC_KEY_get0_group(ec); const char* curve; @@ -1726,9 +1717,19 @@ print_details(struct key_state_ssl *ks_ssl, const char *prefix) openvpn_snprintf(s2, sizeof(s2), ", %d bit EC, curve: %s", EC_GROUP_order_bits(group), curve); - - } + } else #endif + if (rsa != NULL) + { + openvpn_snprintf(s2, sizeof(s2), ", %d bit RSA", + RSA_bits(rsa)); + } + else if (dsa != NULL) + { + openvpn_snprintf(s2, sizeof(s2), ", %d bit DSA", + DSA_bits(dsa)); + } + EVP_PKEY_free(pkey); } X509_free(cert);