Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp513977yba; Mon, 1 Apr 2019 10:49:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqypUww7yz1vKiSAqozL5J+F2QGdECGNmuR7jHidjSbWJHzJq1vCFLSZnkmP1z+5kDfpc1dE X-Received: by 2002:a17:902:b602:: with SMTP id b2mr6324933pls.293.1554140963559; Mon, 01 Apr 2019 10:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554140963; cv=none; d=google.com; s=arc-20160816; b=RyLAXsptdfQi/tAUNf90CottCMbS+51gz7dRodHRfVIUeqQbPojKa7/hGJiDOmWSp9 oCrn6nG3nkUQDDiCBn2NNsyG+5iJLHc3TKV46rm2kOebWZuzSHC2SzITDGXlWwwmWwlm paVnJUlnXMtcr6nazRyCK1MyshiKDRpD9zxVA0rHYD++ZdSzAaGTk3HxH5jwyqZGxpah YkkmSV0RKkdWPLMKq7l+fpHRKcU1X1hhSu5mVBIaQKJKPQtIuBv5hqWE9AxVVnb6tBQR 7eRK1qfr2uedAmlgEcJc6KYUih07Vg3/W9NVj1/5VDXLRzlbfvdwvYIavTKgedtTtorT PSRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mPnYcqAfeUJ7Qrwu9kcR6/h96kRRErbZBJb4ZB954NQ=; b=JFfm9p805BkePuwMhBex9C1YaDHW/ubJUCfZMGgwLtmX7TUlX6fBfa6b6hB5ado2Me oCI7HkIhoeMgOP+rv8eJ8J/7jWQZ36/C1R5EqOEGkNzlb0yMLUt/jej+J6vCTZ8N9fw+ CfwSYHG6KY8kqA42SYdQSZMe37vVo++Sv7RXmbISC9IJ3ZjY5zNo0KpD87JZmoqqetpn OwZab411IAau+nhhliNO4u2aJLX5Wpgy/6rKugDI4kzmwsWf58sQCNH2kpvtv4mNvvzE 1D5mE8TXZiK2USCn+PuCrsrM/UAXoGj77Gt9ofpo9Y9+6AXwXqn7zxymdsMgAZDGsb6Y lqfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z8EkEhQq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 140si9179014pga.460.2019.04.01.10.49.08; Mon, 01 Apr 2019 10:49:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z8EkEhQq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733051AbfDARsd (ORCPT + 99 others); Mon, 1 Apr 2019 13:48:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:38260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733190AbfDARa7 (ORCPT ); Mon, 1 Apr 2019 13:30:59 -0400 Received: from gmail.com (unknown [104.132.1.77]) (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 DACD320856; Mon, 1 Apr 2019 17:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554139859; bh=RN2ZZbMjDHYlc4yGbJxOaRqQcwMFoBWlY+v/Kvr6xDY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=z8EkEhQqkR7yK8x7A1PLPZFVx3FIyY2cC0bbA9KFV6Br6yMMKIxAMAFsjIxneIcHz 2ovlNo7qQOKkU2bHfdGKg8Mt+R+fAtuLHNCE0zQAYdvaxTY1Ssl0EYURemOrds7ILE pC7301ZDQoPxE7cxHJXotQpZ2ae4Tws8TJSoI2n0= Date: Mon, 1 Apr 2019 10:30:57 -0700 From: Eric Biggers To: Lionel Debieve Cc: Herbert Xu , "David S . Miller" , Maxime Coquelin , Alexandre Torgue , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Benjamin Gaignard , Fabien Dessenne , Ludovic Barre , linux-stm32@st-md-mailman.stormreply.com Subject: Re: [PATCH 1/1] crypto: testmgr - call shash_init in crc32c algo Message-ID: <20190401173056.GD131675@gmail.com> References: <1554123264-24243-1-git-send-email-lionel.debieve@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1554123264-24243-1-git-send-email-lionel.debieve@st.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lionel, On Mon, Apr 01, 2019 at 02:54:24PM +0200, Lionel Debieve wrote: > In case of device call required in low level driver, > the context must be initialized before calling the final > function. > > Signed-off-by: Lionel Debieve > --- > crypto/testmgr.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/crypto/testmgr.c b/crypto/testmgr.c > index 8386038..4a00d7c 100644 > --- a/crypto/testmgr.c > +++ b/crypto/testmgr.c > @@ -2181,6 +2181,13 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, > shash->tfm = tfm; > shash->flags = 0; > > + err = crypto_shash_init(shash); > + if (err) { > + printk(KERN_ERR "alg: crc32c: init failed for " > + "%s: %d\n", driver, err); > + break; > + } > + > *ctx = 420553207; > err = crypto_shash_final(shash, (u8 *)&val); > if (err) { > -- > 2.7.4 > This defeats the point of the test, which is that crc32c implementations are expected to use the same shash_desc context format and be usable by calling crypto_shash_update() directly after initializing the context manually, without a prior crypto_shash_init(). See for example ext4_chksum() in fs/ext4/ext4.h: static inline u32 ext4_chksum(struct ext4_sb_info *sbi, u32 crc, const void *address, unsigned int length) { struct { struct shash_desc shash; char ctx[4]; } desc; BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver)!=sizeof(desc.ctx)); desc.shash.tfm = sbi->s_chksum_driver; desc.shash.flags = 0; *(u32 *)desc.ctx = crc; BUG_ON(crypto_shash_update(&desc.shash, address, length)); return *(u32 *)desc.ctx; } I think you need to fix the stm32 crc32 driver to not store anything extra in the shash_desc context, and only use hardware during ->update(). - Eric