From patchwork Thu Feb 15 23:31:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 10223929 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA933601E7 for ; Thu, 15 Feb 2018 23:31:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B76B829461 for ; Thu, 15 Feb 2018 23:31:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC0C929468; Thu, 15 Feb 2018 23:31:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19FA729461 for ; Thu, 15 Feb 2018 23:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1165021AbeBOXbw (ORCPT ); Thu, 15 Feb 2018 18:31:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:57346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163785AbeBOXbu (ORCPT ); Thu, 15 Feb 2018 18:31:50 -0500 Received: from saruman (jahogan.plus.com [212.159.75.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 144FD21775; Thu, 15 Feb 2018 23:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 144FD21775 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jhogan@kernel.org Date: Thu, 15 Feb 2018 23:31:45 +0000 From: James Hogan To: Eric Biggers Cc: linux-mips@linux-mips.org, Marcin Nowakowski , Ralf Baechle , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org Subject: Re: [PATCH v3 2/3] MIPS: crypto: Add crc32 and crc32c hw accelerated module Message-ID: <20180215233145.GA16654@saruman> References: <77eab2cb46e52be3639610a7ad574bac7bf78d73.1518214143.git-series.jhogan@kernel.org> <20180215222214.GB49445@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180215222214.GB49445@gmail.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Cheers James 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),