Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1280965img; Fri, 22 Mar 2019 21:45:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJb4PKmm+V2D5dmcKk+pbebR02EX0jc94DyRP/5oaQaUxjW+TRUBlovcRxvR5b/NuN8+dA X-Received: by 2002:a17:902:b60c:: with SMTP id b12mr12993528pls.261.1553316315897; Fri, 22 Mar 2019 21:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553316315; cv=none; d=google.com; s=arc-20160816; b=UQtCMTZ1m6pzi4ywfT8nnrlUiW7Ysbb9/L0pd9vvzzk0vNRLdRDN6vbAdPWeR77pkP 4MBTfj1BnYrWSklVkRnvALpfst6wNgmXWs3bW24QW0nRuR1a57hwu7CmAXLZ7SrRxnKr Pj91CvCxh+/VYkbC7IQX8TAoU6ka04/XJAo36/iPIR8Kg1TVjTmxWjpnRh3AHzAmEumO MLHgQpwrwavHqhiL0yyJnVl3l9ioCfPG3bL2X0AharzwDNyYXY79qLXV9M9Fm4L2PofH Imv9RP5jMlu1D8X9UE6qSuJrqaQvivQrcJW1GNvvTBnNDwMJq4wNDhMEsxl4JY5Z03Hd dAJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=ZRhPTdj9+6wuR5lnu4L4iwExf+rBhMAblm+lTabS3GM=; b=b/5ZnpNER16bGQfU4RONBL2QiOG6C2pd9B8HhFqA9iLnF1rg8NBjU1D3SPzEDVkagP W8zN130GpAtU9We/5xvYAAuPYOk0PM8iLLV3JoouGI1AYM8RykQeaIJUU3pjNC21RZCE caYEPsjgrI0GATfpJxeyi/rWuI0OVMwujiD4wETxoIagf+WcnF0XGPGAKlyueh19QxkR uqnJrebfT1gMZlMnSkY38p0kUKi93+GLcRcPQxSulO9k/upeR+wa060Z3EfZeJWnHjGo c/C3WzRLI23gR2TVZEt3AVyKlNAU4TeAYbCIm4sUqgnicFzpFtCZ1Fec4pORP50Dk8bS gBUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si8734035ply.361.2019.03.22.21.44.25; Fri, 22 Mar 2019 21:45:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726073AbfCWEnO (ORCPT + 99 others); Sat, 23 Mar 2019 00:43:14 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:58100 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbfCWEnO (ORCPT ); Sat, 23 Mar 2019 00:43:14 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id EEFA972CCAC; Sat, 23 Mar 2019 07:43:10 +0300 (MSK) Received: from beacon.altlinux.org (unknown [185.6.174.98]) by imap.altlinux.org (Postfix) with ESMTPSA id C89F04A4A16; Sat, 23 Mar 2019 07:43:10 +0300 (MSK) From: Vitaly Chikunov To: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v7.1] crypto: akcipher - default implementations for request callbacks Date: Sat, 23 Mar 2019 07:43:08 +0300 Message-Id: <20190323044308.20935-1-vt@altlinux.org> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Herbert, This is reworked version of "[PATCH v7 02/11] crypto: akcipher - check the presence of callback before the call". All checks inside of akcipher wrappers for the callbacks handling akcipher_requests are removed and replaced with default akcipher_default_op() callback. Checks in crypto_akcipher_maxsize() are just removed altogether without any replacement, because this callback is always defined. Also, sanity checks for (!req->dst && req->dst_len) which was introduced in "[PATCH v7 04/11] crypto: akcipher - new verify API for public key algorithms" are removed, assuming this should be checked in the drivers if needed. Commit "PATCH v7 01/11] KEYS: report to keyctl only actually supported key ops" is also will be removed in the next patchset, as you agreed. Thanks, --- commit --- Because with the introduction of EC-RDSA and change in workings of RSA in regard to sign/verify, akcipher could have not all callbacks defined, check the presence of callbacks in crypto_register_akcipher() and provide default implementation if the callback is not implemented. This is suggested by Herbert Xu instead of checking the presence of the callback on every request. Signed-off-by: Vitaly Chikunov --- crypto/akcipher.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crypto/akcipher.c b/crypto/akcipher.c index 0cbeae137e0a..780daa436dac 100644 --- a/crypto/akcipher.c +++ b/crypto/akcipher.c @@ -119,10 +119,24 @@ static void akcipher_prepare_alg(struct akcipher_alg *alg) base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER; } +static int akcipher_default_op(struct akcipher_request *req) +{ + return -ENOSYS; +} + int crypto_register_akcipher(struct akcipher_alg *alg) { struct crypto_alg *base = &alg->base; + if (!alg->sign) + alg->sign = akcipher_default_op; + if (!alg->verify) + alg->verify = akcipher_default_op; + if (!alg->encrypt) + alg->encrypt = akcipher_default_op; + if (!alg->decrypt) + alg->decrypt = akcipher_default_op; + akcipher_prepare_alg(alg); return crypto_register_alg(base); } -- 2.11.0