Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4244303img; Tue, 26 Mar 2019 06:00:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVWLvC3L4rQ3WYuNNouO22dydtPpdh4/3tIqGhFw/uqSNHeIyc4SLiYDWaqLcNxn2lv3an X-Received: by 2002:aa7:8d01:: with SMTP id j1mr30324716pfe.122.1553605214179; Tue, 26 Mar 2019 06:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553605214; cv=none; d=google.com; s=arc-20160816; b=Py7opGGi7KFFpIUzfg9cGJxDlrjbScAjtgrKJrcCtV/ensEwsq9mvMR/8neeVjrZC9 d5nsJggulnKIDuHKlrFMuGHmP1bULZJTUSIDbZEdQoQCNUm1dXTS0jCJAqzQ2o+5d1OS NJaL0xr6S3eGF49fGRg0QhTs5wdCPeeqLmLZFHbnuPc/ScdWXhKxmdJC72rBeZyoVeBX dGfpka9qx72Sp26dZ2rNPgNzKCd1Dog6CFlfrF0kP24mXMhXnnqjJPFq3F9vUDFuuGnv NZitWx15ZOrB7xsCOW+Jiy+4lCAgpqM/zhBP8yKk4mkXi5uzJndmiDPH0oWjA1KlIc4a stig== 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 :references:in-reply-to:message-id:date:subject:to:from; bh=Gf+iGL7c/hns5hXx1kYD+aLsIKIHDy6OveRBcOrbQsE=; b=G8apYD5+ALyYEdse6zw3nt1YJLzsPBSrQvhELTlNarYUbk5yYMVDfUa6VywG7d3hwV NVRnrTUU+xcmnFVNiEwQMYsv4p7nVsJ4VxLM5igIZdHLc1A7aVBAIXHhSpQREzREl7je 8/NBG5xLusoeeike8O4UMZZ5Ih85XSielTZ0g9DB9RAXVyHkq703kmmhmnN3iPlGl8xK 9a0vFimCEkn3WCykcuhxnKgm0oZk/f4HF7SZOlzXvB+w/9am3nRAKQZF+6hTWCL1s7Z/ KO2oI9ACG92p3KhI9gdivi1CYeu6Yd+IptxbD0LlhblcACU8b3f2EU5uKRTfTv5Bux9e A81w== 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 s26si15477859pfm.143.2019.03.26.05.59.58; Tue, 26 Mar 2019 06:00:14 -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 S1731557AbfCZM7A (ORCPT + 99 others); Tue, 26 Mar 2019 08:59:00 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:44488 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbfCZM66 (ORCPT ); Tue, 26 Mar 2019 08:58:58 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 4918072CCAC; Tue, 26 Mar 2019 15:58:56 +0300 (MSK) Received: from beacon.altlinux.org (unknown [185.6.174.98]) by imap.altlinux.org (Postfix) with ESMTPSA id 701DB4A4AE9; Tue, 26 Mar 2019 15:58:55 +0300 (MSK) From: Vitaly Chikunov To: Herbert Xu , David Howells , Mimi Zohar , Dmitry Kasatkin , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 01/10] crypto: akcipher - default implementations for request callbacks Date: Tue, 26 Mar 2019 15:58:33 +0300 Message-Id: <20190326125842.24110-2-vt@altlinux.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190326125842.24110-1-vt@altlinux.org> References: <20190326125842.24110-1-vt@altlinux.org> 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 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