From: Nikolay Borisov <nborisov@suse.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
linux-crypto@vger.kernel.org, terrelln@fb.com,
jthumshirn@suse.de
Subject: Re: [PATCH v2] crypto: xxhash - Implement xxhash support
Date: Tue, 28 May 2019 19:49:58 +0300 [thread overview]
Message-ID: <e7f5ac70-ff22-4471-2682-52c8cd246bf0@suse.com> (raw)
In-Reply-To: <20190528152248.GB739@sol.localdomain>
On 28.05.19 г. 18:22 ч., Eric Biggers wrote:
> On Tue, May 28, 2019 at 03:14:51PM +0300, Nikolay Borisov wrote:
>> xxhash is currently implemented as a self-contained module in /lib.
>> This patch enables that module to be used as part of the generic kernel
>> crypto framework. It adds a simple wrapper to the 64bit version.
>>
>
> Thanks, this looks a lot better. A couple minor comments below.
>
>> +static int xxhash64_init(struct shash_desc *desc)
>> +{
>> + struct xxhash64_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
>> + struct xxhash64_desc_ctx *dctx = shash_desc_ctx(desc);
>> +
>> + xxh64_reset(&dctx->xxhstate, tctx->seed);
>> +
>> + return 0;
>> +}
>> +
>> +static int xxhash64_setkey(struct crypto_shash *tfm, const u8 *key,
>> + unsigned int keylen)
>> +{
>> + struct xxhash64_tfm_ctx *tctx = crypto_shash_ctx(tfm);
>> +
>> + if (keylen != sizeof(tctx->seed)) {
>> + crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
>> + return -EINVAL;
>> + }
>> + tctx->seed = get_unaligned_le64(key);
>> + return 0;
>> +}
>
> Can you please move xxhash64_setkey() to before xxhash64_init() to match the
> order in which the functions get called?
>
> Sometimes people get confused and think that crypto_shash_init() comes before
> crypto_shash_setkey(), so it's helpful to keep definitions in order.
>
>> +module_init(xxhash_mod_init);
>
> Can you change this to subsys_initcall? We're using subsys_initcall for the
> generic implementations of crypto algorithms now, so that when other
> implementations (e.g. assembly language implementations) are added, the crypto
> self-tests can compare them to the generic implementations.
Will fix those but wanted to ask you whether it's really necessary to
use get_unaligned in setkey given generic code guarantees the buffer is
going to be aligned. E.g. wouldn't cpu_to_le64(*(u64 *)key)) be
"cheaper"? In any case this is a minor point but just want to be sure I
have correctly understood the generic code?
>
> Thanks,
>
> - Eric
>
next prev parent reply other threads:[~2019-05-28 16:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 12:14 [PATCH v2] crypto: xxhash - Implement xxhash support Nikolay Borisov
2019-05-28 15:22 ` Eric Biggers
2019-05-28 16:49 ` Nikolay Borisov [this message]
2019-05-28 16:55 ` 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=e7f5ac70-ff22-4471-2682-52c8cd246bf0@suse.com \
--to=nborisov@suse.com \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=jthumshirn@suse.de \
--cc=linux-crypto@vger.kernel.org \
--cc=terrelln@fb.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