From: "Horia Geantă" <horia.geanta@nxp.com>
To: "Andrei Botila (OSS)" <andrei.botila@oss.nxp.com>,
Aymen Sghaier <aymen.sghaier@nxp.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 01/12] crypto: caam/jr - add fallback for XTS with more than 8B IV
Date: Mon, 21 Sep 2020 14:46:10 +0300 [thread overview]
Message-ID: <3e51633c-c020-8e5e-d54a-90282d5e2cda@nxp.com> (raw)
In-Reply-To: <20200921073205.24742-2-andrei.botila@oss.nxp.com>
On 9/21/2020 10:32 AM, Andrei Botila (OSS) wrote:
> +static bool xts_skcipher_ivsize(struct skcipher_request *req)
> +{
> + struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
> + unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
> + u64 size = 0;
> +
> + size = get_unaligned((u64 *)(req->iv + (ivsize / 2)));
> +
> + return !!size;
Just get rid of the "size" local variable and return !!get_unaligned(...).
Also the function should be inline.
> @@ -3344,13 +3379,30 @@ static int caam_cra_init(struct crypto_skcipher *tfm)
> struct caam_skcipher_alg *caam_alg =
> container_of(alg, typeof(*caam_alg), skcipher);
> struct caam_ctx *ctx = crypto_skcipher_ctx(tfm);
> -
> - crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx));
> + u32 alg_aai = caam_alg->caam.class1_alg_type & OP_ALG_AAI_MASK;
>
> ctx->enginectx.op.do_one_request = skcipher_do_one_req;
>
> - return caam_init_common(crypto_skcipher_ctx(tfm), &caam_alg->caam,
> - false);
> + if (alg_aai == OP_ALG_AAI_XTS) {
> + const char *tfm_name = crypto_tfm_alg_name(&tfm->base);
> + struct crypto_skcipher *fallback;
> +
> + fallback = crypto_alloc_skcipher(tfm_name, 0,
> + CRYPTO_ALG_NEED_FALLBACK);
> + if (IS_ERR(fallback)) {
> + dev_err(ctx->jrdev, "Failed to allocate %s fallback: %ld\n",
> + tfm_name, PTR_ERR(fallback));
> + return PTR_ERR(fallback);
> + }
> +
> + ctx->fallback = fallback;
> + crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx) +
> + crypto_skcipher_reqsize(fallback));
> + } else {
> + crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx));
> + }
> +
> + return caam_init_common(ctx, &caam_alg->caam, false);
In case caam_init_common() fails, fallback should be freed for XTS path.
Horia
next prev parent reply other threads:[~2020-09-21 11:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 7:31 [PATCH v2 00/12] crypto: caam - xts(aes) updates Andrei Botila
2020-09-21 7:31 ` [PATCH v2 01/12] crypto: caam/jr - add fallback for XTS with more than 8B IV Andrei Botila
2020-09-21 11:46 ` Horia Geantă [this message]
2020-09-21 7:31 ` [PATCH v2 02/12] crypto: caam/qi " Andrei Botila
2020-09-21 7:31 ` [PATCH v2 03/12] crypto: caam/qi2 " Andrei Botila
2020-09-21 7:31 ` [PATCH v2 04/12] crypto: caam/jr - add support for more XTS key lengths Andrei Botila
2020-09-21 7:31 ` [PATCH v2 05/12] crypto: caam/qi " Andrei Botila
2020-09-21 7:31 ` [PATCH v2 06/12] crypto: caam/qi2 " Andrei Botila
2020-09-21 7:32 ` [PATCH v2 07/12] crypto: caam/jr - add xts check for block length equal to zero Andrei Botila
2020-09-21 7:32 ` [PATCH v2 08/12] crypto: caam/qi " Andrei Botila
2020-09-21 7:32 ` [PATCH v2 09/12] crypto: caam/qi2 " Andrei Botila
2020-09-21 7:32 ` [PATCH v2 10/12] crypto: caam/jr - add support for XTS with 16B IV Andrei Botila
2020-09-21 7:32 ` [PATCH v2 11/12] crypto: caam/qi " Andrei Botila
2020-09-21 7:32 ` [PATCH v2 12/12] crypto: caam/qi2 " Andrei Botila
2020-09-21 11:46 ` [PATCH v2 00/12] crypto: caam - xts(aes) updates Horia Geantă
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=3e51633c-c020-8e5e-d54a-90282d5e2cda@nxp.com \
--to=horia.geanta@nxp.com \
--cc=andrei.botila@oss.nxp.com \
--cc=aymen.sghaier@nxp.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®