diff mbox series

[v3,9/31] crypto: cryptd - Add support for chaining

Message ID E1k0Jt4-0006Lq-5D@fornost.hmeau.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series crypto: skcipher - Add support for no chaining and partial chaining | expand

Commit Message

Herbert Xu July 28, 2020, 7:18 a.m. UTC
This patch makes cryptd pass along the CRYPTO_TFM_REQ_MORE flag to
its child skcipher as well as inheriting the final chunk size from
it.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

 crypto/cryptd.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index a1bea0f4baa88..510c23b320082 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -261,13 +261,16 @@  static void cryptd_skcipher_encrypt(struct crypto_async_request *base,
 	struct cryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
 	struct crypto_sync_skcipher *child = ctx->child;
 	SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, child);
+	unsigned int flags = req->base.flags;
 
 	if (unlikely(err == -EINPROGRESS))
 		goto out;
 
+	flags &= CRYPTO_TFM_REQ_MORE;
+	flags |= CRYPTO_TFM_REQ_MAY_SLEEP;
+
 	skcipher_request_set_sync_tfm(subreq, child);
-	skcipher_request_set_callback(subreq, CRYPTO_TFM_REQ_MAY_SLEEP,
-				      NULL, NULL);
+	skcipher_request_set_callback(subreq, flags, NULL, NULL);
 	skcipher_request_set_crypt(subreq, req->src, req->dst, req->cryptlen,
 				   req->iv);
 
@@ -289,13 +292,16 @@  static void cryptd_skcipher_decrypt(struct crypto_async_request *base,
 	struct cryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
 	struct crypto_sync_skcipher *child = ctx->child;
 	SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, child);
+	unsigned int flags = req->base.flags;
 
 	if (unlikely(err == -EINPROGRESS))
 		goto out;
 
+	flags &= CRYPTO_TFM_REQ_MORE;
+	flags |= CRYPTO_TFM_REQ_MAY_SLEEP;
+
 	skcipher_request_set_sync_tfm(subreq, child);
-	skcipher_request_set_callback(subreq, CRYPTO_TFM_REQ_MAY_SLEEP,
-				      NULL, NULL);
+	skcipher_request_set_callback(subreq, flags, NULL, NULL);
 	skcipher_request_set_crypt(subreq, req->src, req->dst, req->cryptlen,
 				   req->iv);
 
@@ -400,6 +406,7 @@  static int cryptd_create_skcipher(struct crypto_template *tmpl,
 		(alg->base.cra_flags & CRYPTO_ALG_INTERNAL);
 	inst->alg.ivsize = crypto_skcipher_alg_ivsize(alg);
 	inst->alg.chunksize = crypto_skcipher_alg_chunksize(alg);
+	inst->alg.final_chunksize = crypto_skcipher_alg_final_chunksize(alg);
 	inst->alg.min_keysize = crypto_skcipher_alg_min_keysize(alg);
 	inst->alg.max_keysize = crypto_skcipher_alg_max_keysize(alg);