From: Eric Biggers <ebiggers@google.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: [v2 PATCH 6/16] crypto: cryptd - Add support for skcipher
Date: Sun, 13 Nov 2016 17:45:47 -0800 [thread overview]
Message-ID: <20161114014547.GB4778@google.com> (raw)
In-Reply-To: <E1c5tE9-00029x-Rk@gondolin.me.apana.org.au>
On Sun, Nov 13, 2016 at 07:45:37PM +0800, Herbert Xu wrote:
> +static void cryptd_skcipher_encrypt(struct crypto_async_request *base,
> + int err)
> +{
> + struct skcipher_request *req = skcipher_request_cast(base);
> + struct cryptd_skcipher_request_ctx *rctx = skcipher_request_ctx(req);
> + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
> + struct cryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
> + struct crypto_skcipher *child = ctx->child;
> + SKCIPHER_REQUEST_ON_STACK(subreq, child);
> +
> + if (unlikely(err == -EINPROGRESS))
> + goto out;
> +
> + skcipher_request_set_tfm(subreq, child);
> + skcipher_request_set_callback(subreq, CRYPTO_TFM_REQ_MAY_SLEEP,
> + NULL, NULL);
> + skcipher_request_set_crypt(subreq, req->src, req->dst, req->cryptlen,
> + req->iv);
> +
> + err = crypto_skcipher_encrypt(subreq);
> + skcipher_request_zero(subreq);
> +
> + req->base.complete = rctx->complete;
> +
> +out:
> + cryptd_skcipher_complete(req, err);
> +}
> +
> +static void cryptd_skcipher_decrypt(struct crypto_async_request *base,
> + int err)
> +{
> + struct skcipher_request *req = skcipher_request_cast(base);
> + struct cryptd_skcipher_request_ctx *rctx = skcipher_request_ctx(req);
> + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
> + struct cryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
> + struct crypto_skcipher *child = ctx->child;
> + SKCIPHER_REQUEST_ON_STACK(subreq, child);
> +
> + if (unlikely(err == -EINPROGRESS))
> + goto out;
> +
> + skcipher_request_set_tfm(subreq, child);
> + skcipher_request_set_callback(subreq, CRYPTO_TFM_REQ_MAY_SLEEP,
> + NULL, NULL);
> + skcipher_request_set_crypt(subreq, req->src, req->dst, req->cryptlen,
> + req->iv);
> +
> + err = crypto_skcipher_decrypt(subreq);
> + skcipher_request_zero(subreq);
> +
> + req->base.complete = rctx->complete;
> +
> +out:
> + cryptd_skcipher_complete(req, err);
> +}
cryptd_skcipher_encrypt() and cryptd_skcipher_decrypt() are identical except for
whether crypto_skcipher_encrypt() or crypto_skcipher_decrypt() is used. I
suggest having them wrap a function cryptd_skcipher_crypt() that takes in a
function pointer to crypto_skcipher_encrypt or crypto_skcipher_decrypt.
Alternatively a bool would be okay too.
Eric
next prev parent reply other threads:[~2016-11-14 1:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-13 11:43 [v2 PATCH 0/16] crypto: skcipher - skcipher algorithm conversion part 3 Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 1/16] crypto: skcipher - Add skcipher walk interface Herbert Xu
2016-11-14 1:35 ` Eric Biggers
2016-11-15 13:58 ` Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 2/16] crypto: aes-ce-ccm - Use " Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 3/16] crypto: lrw - Convert to skcipher Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 4/16] crypto: xts " Herbert Xu
2016-11-14 2:10 ` Eric Biggers
2016-11-15 14:41 ` Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 5/16] crypto: api - Do not clear type bits in crypto_larval_lookup Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 6/16] crypto: cryptd - Add support for skcipher Herbert Xu
2016-11-14 1:45 ` Eric Biggers [this message]
2016-11-13 11:45 ` [v2 PATCH 7/16] crypto: simd - Add simd skcipher helper Herbert Xu
2016-11-14 2:27 ` Eric Biggers
2016-11-15 14:55 ` Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 8/16] crypto: pcbc - Convert to skcipher Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 9/16] crypto: glue_helper - Add skcipher xts helpers Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 10/16] crypto: testmgr - Do not test internal algorithms Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 11/16] crypto: aesni - Convert to skcipher Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 12/16] crypto: arm64/aes " Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 13/16] crypto: aes-ce " Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 14/16] crypto: cbc " Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 15/16] crypto: cbc - Export CBC implementation Herbert Xu
2016-11-13 11:45 ` [v2 PATCH 16/16] crypto: aesbs - Convert to skcipher Herbert Xu
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=20161114014547.GB4778@google.com \
--to=ebiggers@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).