From patchwork Sun Feb 24 06:08:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Chikunov X-Patchwork-Id: 10827725 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 674001823 for ; Sun, 24 Feb 2019 06:09:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 595BC2B035 for ; Sun, 24 Feb 2019 06:09:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D7FC2B03E; Sun, 24 Feb 2019 06:09:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED0682B107 for ; Sun, 24 Feb 2019 06:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbfBXGIz (ORCPT ); Sun, 24 Feb 2019 01:08:55 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:43652 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbfBXGIz (ORCPT ); Sun, 24 Feb 2019 01:08:55 -0500 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id D109E72CCAE; Sun, 24 Feb 2019 09:08:52 +0300 (MSK) Received: from beacon.altlinux.org (unknown [185.6.174.98]) by imap.altlinux.org (Postfix) with ESMTPSA id A1C594A4AE7; Sun, 24 Feb 2019 09:08:52 +0300 (MSK) From: Vitaly Chikunov To: Herbert Xu , David Howells , Mimi Zohar , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 01/10] KEYS: report to keyctl only actually supported key ops Date: Sun, 24 Feb 2019 09:08:19 +0300 Message-Id: <20190224060828.2527-2-vt@altlinux.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190224060828.2527-1-vt@altlinux.org> References: <20190224060828.2527-1-vt@altlinux.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Because with the introduction of EC-RDSA and change in workings of RSA in regard to sign/verify, akcipher may have not all callbacks defined, report to keyctl only actually supported ops determined by the presence of the akcipher callbacks. Cc: David Howells Cc: keyrings@vger.kernel.org Signed-off-by: Vitaly Chikunov --- crypto/asymmetric_keys/public_key.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index f5d85b47fcc6..c2e4e73fcf06 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -130,11 +130,17 @@ static int software_key_query(const struct kernel_pkey_params *params, info->max_sig_size = len; info->max_enc_size = len; info->max_dec_size = len; - info->supported_ops = (KEYCTL_SUPPORTS_ENCRYPT | - KEYCTL_SUPPORTS_VERIFY); - if (pkey->key_is_private) - info->supported_ops |= (KEYCTL_SUPPORTS_DECRYPT | - KEYCTL_SUPPORTS_SIGN); + info->supported_ops = 0; + if (crypto_akcipher_alg(tfm)->verify) + info->supported_ops |= KEYCTL_SUPPORTS_VERIFY; + if (crypto_akcipher_alg(tfm)->encrypt) + info->supported_ops |= KEYCTL_SUPPORTS_ENCRYPT; + if (pkey->key_is_private) { + if (crypto_akcipher_alg(tfm)->decrypt) + info->supported_ops |= KEYCTL_SUPPORTS_DECRYPT; + if (crypto_akcipher_alg(tfm)->sign) + info->supported_ops |= KEYCTL_SUPPORTS_SIGN; + } ret = 0; error_free_tfm: