All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Chikunov <vt@altlinux.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	David Howells <dhowells@redhat.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	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	[thread overview]
Message-ID: <20190326125842.24110-2-vt@altlinux.org> (raw)
In-Reply-To: <20190326125842.24110-1-vt@altlinux.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 <vt@altlinux.org>
---
 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


WARNING: multiple messages have this Message-ID (diff)
From: Vitaly Chikunov <vt@altlinux.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	David Howells <dhowells@redhat.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	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 12:58:33 +0000	[thread overview]
Message-ID: <20190326125842.24110-2-vt@altlinux.org> (raw)
In-Reply-To: <20190326125842.24110-1-vt@altlinux.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 <vt@altlinux.org>
---
 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

  reply	other threads:[~2019-03-26 12:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 12:58 [PATCH v8 00/10] crypto: add EC-RDSA (GOST 34.10) algorithm Vitaly Chikunov
2019-03-26 12:58 ` Vitaly Chikunov
2019-03-26 12:58 ` Vitaly Chikunov [this message]
2019-03-26 12:58   ` [PATCH v8 01/10] crypto: akcipher - default implementations for request callbacks Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 02/10] crypto: rsa - unimplement sign/verify for raw RSA backends Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 03/10] crypto: akcipher - new verify API for public key algorithms Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 16:00   ` Denis Kenzior
2019-03-26 16:00     ` Denis Kenzior
2019-03-26 12:58 ` [PATCH v8 04/10] KEYS: do not kmemdup digest in {public,tpm}_key_verify_signature Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 16:15   ` Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 05/10] X.509: parse public key parameters from x509 for akcipher Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 16:14   ` Denis Kenzior
2019-03-26 16:14     ` Denis Kenzior
2019-03-26 12:58 ` [PATCH v8 06/10] crypto: Kconfig - create Public-key cryptography section Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 07/10] crypto: ecc - make ecc into separate module Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 08/10] crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 09/10] crypto: ecrdsa - add EC-RDSA test vectors to testmgr Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-26 12:58 ` [PATCH v8 10/10] integrity: support EC-RDSA signatures for asymmetric_verify Vitaly Chikunov
2019-03-26 12:58   ` Vitaly Chikunov
2019-03-27 18:10   ` Mimi Zohar
2019-03-27 18:10     ` Mimi Zohar
2019-03-27 20:14     ` Vitaly Chikunov
2019-03-27 20:14       ` Vitaly Chikunov
2019-03-27 20:21       ` Mimi Zohar
2019-03-27 20:21         ` Mimi Zohar
2019-03-28  6:16         ` Vitaly Chikunov
2019-03-28  6:16           ` Vitaly Chikunov
2019-04-08 16:05 ` [PATCH v8 00/10] crypto: add EC-RDSA (GOST 34.10) algorithm Vitaly Chikunov
2019-04-09  6:17   ` Herbert Xu
2019-04-09 14:02     ` Vitaly Chikunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190326125842.24110-2-vt@altlinux.org \
    --to=vt@altlinux.org \
    --cc=dhowells@redhat.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.