linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Hogan <jhogan@kernel.org>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: linux-mips@linux-mips.org,
	Marcin Nowakowski <marcin.nowakowski@mips.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	linux-crypto@vger.kernel.org
Subject: Re: [PATCH v3 2/3] MIPS: crypto: Add crc32 and crc32c hw accelerated module
Date: Thu, 15 Feb 2018 23:31:45 +0000	[thread overview]
Message-ID: <20180215233145.GA16654@saruman> (raw)
In-Reply-To: <20180215222214.GB49445@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3439 bytes --]

On Thu, Feb 15, 2018 at 02:22:14PM -0800, Eric Biggers wrote:
> On Fri, Feb 09, 2018 at 10:11:06PM +0000, James Hogan wrote:
> > +static struct shash_alg crc32_alg = {
> > +	.digestsize		=	CHKSUM_DIGEST_SIZE,
> > +	.setkey			=	chksum_setkey,
> > +	.init			=	chksum_init,
> > +	.update			=	chksum_update,
> > +	.final			=	chksum_final,
> > +	.finup			=	chksum_finup,
> > +	.digest			=	chksum_digest,
> > +	.descsize		=	sizeof(struct chksum_desc_ctx),
> > +	.base			=	{
> > +		.cra_name		=	"crc32",
> > +		.cra_driver_name	=	"crc32-mips-hw",
> > +		.cra_priority		=	300,
> > +		.cra_blocksize		=	CHKSUM_BLOCK_SIZE,
> > +		.cra_alignmask		=	0,
> > +		.cra_ctxsize		=	sizeof(struct chksum_ctx),
> > +		.cra_module		=	THIS_MODULE,
> > +		.cra_init		=	chksum_cra_init,
> > +	}
> > +};
> > +
> > +
> > +static struct shash_alg crc32c_alg = {
> > +       .digestsize             =       CHKSUM_DIGEST_SIZE,
> > +       .setkey                 =       chksum_setkey,
> > +       .init                   =       chksum_init,
> > +       .update                 =       chksumc_update,
> > +       .final                  =       chksumc_final,
> > +       .finup                  =       chksumc_finup,
> > +       .digest                 =       chksumc_digest,
> > +       .descsize               =       sizeof(struct chksum_desc_ctx),
> > +       .base                   =       {
> > +               .cra_name               =       "crc32c",
> > +               .cra_driver_name        =       "crc32c-mips-hw",
> > +               .cra_priority           =       300,
> > +               .cra_blocksize          =       CHKSUM_BLOCK_SIZE,
> > +               .cra_alignmask          =       0,
> > +               .cra_ctxsize            =       sizeof(struct chksum_ctx),
> > +               .cra_module             =       THIS_MODULE,
> > +               .cra_init               =       chksum_cra_init,
> > +       }
> > +};
>
> Does this actually work on the latest kernel?  Now hash algorithms must have
> CRYPTO_ALG_OPTIONAL_KEY in .cra_flags if they have a .setkey method but don't
> require it to be called, otherwise the crypto API will think it's a keyed hash
> and not allow it to be used without a key.  I had to add this flag to the other
> CRC32 and CRC32C algorithms (commit a208fa8f33031).  One of the CRC32C test
> vectors even doesn't set a key so it should be causing the self-tests to fail
> for "crc32c-mips-hw".  (We should add such a test vector for CRC32 too, though.)

Thanks Eric. It does indeed fail now with:

alg: hash: digest failed on test 1 for crc32c-mips-hw: ret=161

I'll squash in the following change:

diff --git a/arch/mips/crypto/crc32-mips.c b/arch/mips/crypto/crc32-mips.c
index 8d4122f37fa5..7d1d2425746f 100644
--- a/arch/mips/crypto/crc32-mips.c
+++ b/arch/mips/crypto/crc32-mips.c
@@ -284,6 +284,7 @@ static struct shash_alg crc32_alg = {
 		.cra_name		=	"crc32",
 		.cra_driver_name	=	"crc32-mips-hw",
 		.cra_priority		=	300,
+		.cra_flags		=	CRYPTO_ALG_OPTIONAL_KEY,
 		.cra_blocksize		=	CHKSUM_BLOCK_SIZE,
 		.cra_alignmask		=	0,
 		.cra_ctxsize		=	sizeof(struct chksum_ctx),
@@ -305,6 +306,7 @@ static struct shash_alg crc32c_alg = {
 		.cra_name		=	"crc32c",
 		.cra_driver_name	=	"crc32c-mips-hw",
 		.cra_priority		=	300,
+		.cra_flags		=	CRYPTO_ALG_OPTIONAL_KEY,
 		.cra_blocksize		=	CHKSUM_BLOCK_SIZE,
 		.cra_alignmask		=	0,
 		.cra_ctxsize		=	sizeof(struct chksum_ctx),

Cheers
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2018-02-15 23:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 22:11 [PATCH v3 0/3] MIPS CRC instruction support James Hogan
2018-02-09 22:11 ` [PATCH v3 2/3] MIPS: crypto: Add crc32 and crc32c hw accelerated module James Hogan
2018-02-14 14:22   ` James Hogan
2018-02-15  8:33   ` Herbert Xu
2018-02-15 22:09     ` James Hogan
2018-02-15 22:22   ` Eric Biggers
2018-02-15 23:31     ` James Hogan [this message]

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=20180215233145.GA16654@saruman \
    --to=jhogan@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers3@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=marcin.nowakowski@mips.com \
    --cc=ralf@linux-mips.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;
as well as URLs for NNTP newsgroup(s).