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 7/16] crypto: simd - Add simd skcipher helper
Date: Sun, 13 Nov 2016 18:27:40 -0800 [thread overview]
Message-ID: <20161114022740.GD4778@google.com> (raw)
In-Reply-To: <E1c5tEA-0002AE-UP@gondolin.me.apana.org.au>
On Sun, Nov 13, 2016 at 07:45:38PM +0800, Herbert Xu wrote:
> This patch adds the simd skcipher helper which is meant to be
> a replacement for ablk helper. It replaces the underlying blkcipher
> interface with skcipher, and also presents the top-level algorithm
> as an skcipher.
I assume this means it's planned for all users of ablk_helper to be migrated to
crypto_simd, and ablk_helper will be removed?
> + salg = kzalloc(sizeof(*alg), GFP_KERNEL);
> + if (!salg) {
> + salg = ERR_PTR(-ENOMEM);
> + goto out_put_tfm;
> + }
Shouldn't this be 'sizeof(*salg)'?
> + tfm = crypto_alloc_skcipher(basename, CRYPTO_ALG_INTERNAL,
> + CRYPTO_ALG_INTERNAL | CRYPTO_ALG_ASYNC);
> + if (IS_ERR(tfm))
> + return ERR_CAST(tfm);
> +
> + ialg = crypto_skcipher_alg(tfm);
It seems this really just needs an algorithm and not a transform. Perhaps it
should be calling crypto_find_alg() directly?
> + err = -ENAMETOOLONG;
> + if (snprintf(alg->base.cra_name, CRYPTO_MAX_ALG_NAME, "%s", algname) >=
> + CRYPTO_MAX_ALG_NAME)
> + goto out_free_salg;
> +
> + if (snprintf(alg->base.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s",
> + drvname) >= CRYPTO_MAX_ALG_NAME)
> + goto out_free_salg;
Could use strscpy() or strlcpy() here.
> +static int simd_skcipher_encrypt(struct skcipher_request *req)
> +{
> + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
> + struct simd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
> + struct skcipher_request *subreq;
> + struct crypto_skcipher *child;
> +
> + subreq = skcipher_request_ctx(req);
> + *subreq = *req;
> +
> + if (!may_use_simd() ||
> + (in_atomic() && cryptd_skcipher_queued(ctx->cryptd_tfm)))
> + child = &ctx->cryptd_tfm->base;
> + else
> + child = cryptd_skcipher_child(ctx->cryptd_tfm);
> +
> + skcipher_request_set_tfm(subreq, child);
> +
> + return crypto_skcipher_encrypt(subreq);
> +}
> +
> +static int simd_skcipher_decrypt(struct skcipher_request *req)
> +{
> + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
> + struct simd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
> + struct skcipher_request *subreq;
> + struct crypto_skcipher *child;
> +
> + subreq = skcipher_request_ctx(req);
> + *subreq = *req;
> +
> + if (!may_use_simd() ||
> + (in_atomic() && cryptd_skcipher_queued(ctx->cryptd_tfm)))
> + child = &ctx->cryptd_tfm->base;
> + else
> + child = cryptd_skcipher_child(ctx->cryptd_tfm);
> +
> + skcipher_request_set_tfm(subreq, child);
> +
> + return crypto_skcipher_decrypt(subreq);
> +}
These are the same except for the
crypto_skcipher_encrypt/crypto_skcipher_decrypt at the end, so they could be
mostly shared.
next prev parent reply other threads:[~2016-11-14 2:27 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
2016-11-13 11:45 ` [v2 PATCH 7/16] crypto: simd - Add simd skcipher helper Herbert Xu
2016-11-14 2:27 ` Eric Biggers [this message]
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=20161114022740.GD4778@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 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.