From: Eric Biggers <ebiggers@kernel.org>
To: Nathan Huckleberry <nhuck@google.com>
Cc: linux-crypto@vger.kernel.org,
linux-fscrypt.vger.kernel.org@google.com,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-arm-kernel@lists.infradead.org,
Paul Crowley <paulcrowley@google.com>,
Sami Tolvanen <samitolvanen@google.com>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH v5 3/8] crypto: hctr2 - Add HCTR2 support
Date: Mon, 2 May 2022 11:25:44 -0700 [thread overview]
Message-ID: <YnAiKL7AvTP3y+LM@sol.localdomain> (raw)
In-Reply-To: <20220427003759.1115361-4-nhuck@google.com>
On Wed, Apr 27, 2022 at 12:37:54AM +0000, Nathan Huckleberry wrote:
> +static int hctr2_create_common(struct crypto_template *tmpl,
> + struct rtattr **tb,
> + const char *xctr_name,
> + const char *polyval_name)
> +{
> + u32 mask;
> + struct skcipher_instance *inst;
> + struct hctr2_instance_ctx *ictx;
> + struct skcipher_alg *xctr_alg;
> + struct crypto_alg *blockcipher_alg;
> + struct shash_alg *polyval_alg;
> + char blockcipher_name[CRYPTO_MAX_ALG_NAME];
> + int len;
> + int err;
> +
> + err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SKCIPHER, &mask);
> + if (err)
> + return err;
> +
> + inst = kzalloc(sizeof(*inst) + sizeof(*ictx), GFP_KERNEL);
> + if (!inst)
> + return -ENOMEM;
> + ictx = skcipher_instance_ctx(inst);
> +
> + /* Stream cipher, xctr(block_cipher) */
> + err = crypto_grab_skcipher(&ictx->xctr_spawn,
> + skcipher_crypto_instance(inst),
> + xctr_name, 0, mask);
> + if (err)
> + goto err_free_inst;
> + xctr_alg = crypto_spawn_skcipher_alg(&ictx->xctr_spawn);
> +
> + err = -EINVAL;
> + if (strncmp(xctr_alg->base.cra_name, "xctr(", 5))
> + goto err_free_inst;
> + len = strscpy(blockcipher_name, xctr_name + 5,
> + sizeof(blockcipher_name));
Found a bug here; 'xctr_name' in the strscpy() statement needs to be
xctr_alg->base.cra_name. Otherwise something like
'hctr2_base(xctr-aes-aesni,polyval-clmulni)' doesn't work, as it will try to
extract the block cipher name from the driver name "xctr-aes-aesni" instead of
from the algorithm name "xctr(aes)" as intended.
- Eric
next prev parent reply other threads:[~2022-05-02 18:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 0:37 [PATCH v5 0/8] crypto: HCTR2 support Nathan Huckleberry
2022-04-27 0:37 ` [PATCH v5 1/8] crypto: xctr - Add XCTR support Nathan Huckleberry
2022-04-27 0:37 ` [PATCH v5 2/8] crypto: polyval - Add POLYVAL support Nathan Huckleberry
2022-04-27 0:37 ` [PATCH v5 3/8] crypto: hctr2 - Add HCTR2 support Nathan Huckleberry
2022-05-01 18:33 ` Eric Biggers
2022-05-02 18:25 ` Eric Biggers [this message]
2022-04-27 0:37 ` [PATCH v5 4/8] crypto: x86/aesni-xctr: Add accelerated implementation of XCTR Nathan Huckleberry
2022-05-01 21:31 ` Eric Biggers
2022-04-27 0:37 ` [PATCH v5 5/8] crypto: arm64/aes-xctr: " Nathan Huckleberry
2022-05-01 22:08 ` Eric Biggers
2022-04-27 0:37 ` [PATCH v5 6/8] crypto: x86/polyval: Add PCLMULQDQ accelerated implementation of POLYVAL Nathan Huckleberry
2022-05-01 20:43 ` Eric Biggers
2022-05-02 18:08 ` Eric Biggers
2022-04-27 0:37 ` [PATCH v5 7/8] crypto: arm64/polyval: Add PMULL " Nathan Huckleberry
2022-05-01 20:21 ` Eric Biggers
2022-05-02 18:11 ` Eric Biggers
2022-04-27 0:37 ` [PATCH v5 8/8] fscrypt: Add HCTR2 support for filename encryption Nathan Huckleberry
2022-05-01 18:37 ` Eric Biggers
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=YnAiKL7AvTP3y+LM@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=ardb@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-fscrypt.vger.kernel.org@google.com \
--cc=nhuck@google.com \
--cc=paulcrowley@google.com \
--cc=samitolvanen@google.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 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).