Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Nikolay Borisov <nborisov@suse.com>
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 08:22:49 -0700	[thread overview]
Message-ID: <20190528152248.GB739@sol.localdomain> (raw)
In-Reply-To: <20190528121451.5954-1-nborisov@suse.com>

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.

Thanks,

- Eric

  reply	other threads:[~2019-05-28 15:22 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 [this message]
2019-05-28 16:49   ` Nikolay Borisov
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=20190528152248.GB739@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=jthumshirn@suse.de \
    --cc=linux-crypto@vger.kernel.org \
    --cc=nborisov@suse.com \
    --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