Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2400880ybp; Thu, 10 Oct 2019 06:57:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYr3rsnzoml/4HuTR4wwD8k6OYCwbFD93jlUO0fNt3m90Bkz/vewlyGdovk0C6H9CIYe1m X-Received: by 2002:a17:906:5a98:: with SMTP id l24mr8441745ejq.40.1570715829285; Thu, 10 Oct 2019 06:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570715829; cv=none; d=google.com; s=arc-20160816; b=JSQlWd9jf1uKX7xW19GnNp6sLQ01zr80OyIPHv+pUPydt6k1UPpC+spjbc3TvEHpt2 BKo1o9JRY5n2bJkI2WUrIvFD00IrW5xew4DctIte4qGqLu4bBCgt4JKJUMagc0udsCM1 NYS1gC5kKBiA83mkSW4m0OWFsnRBc4g8gxaMah+ZgTdSe9rM3lsFG7EYUzhe2VHpdkZx TsG+rnMkFYqmbGeDiVcl759R8dZdKOjTKB+SB4ZSnw7YiuYK3I1UgDv5rvTiffA8vFQh tbhGaQG+d6BP/he5AeH6Z3vUmhST9WULPaR+DihrawsKBY6L2/ReYfvrcG9POJFqmf8G foIA== 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:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=bxreTJP2y4RGzvjE7Q2ISmr/ZBskb7YJnDn+R9X/QpM=; b=A3sYjmaRItFdNZ11/pNjEU2J0RqIQNo3990ryWkxuHtdcx41sSjRfDPycWFb13u/qF 8dQUXqGRZoBFCoZD9380utYQYgzxVcZ2rrnPUqZWDuUwfts1GonQnJ2jOkk0Hc/zWkSU BCpgB0UBFIipRrScoaTT1EQYwE/xKkp+h2enQZMs9r8C07Jhig3Z5L32EajeWnA2f781 z+oePgw6zRuPQB13FARVjIibwD1OXYhkHY/4jZ45bzf1w7QxVpWJyt8QEglT8z3N8guR 7AGCE9AQALcqWz91p/NyB83AXnoQ2J9wqrOtonNU/Lahc5fEBzr2MWwsvmHS1pMB2RM9 GwwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si3075296ejq.343.2019.10.10.06.56.44; Thu, 10 Oct 2019 06:57:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725923AbfJJN4j (ORCPT + 99 others); Thu, 10 Oct 2019 09:56:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:46282 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725862AbfJJN4j (ORCPT ); Thu, 10 Oct 2019 09:56:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 826A5AEF6; Thu, 10 Oct 2019 13:56:37 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id B9764DA7E3; Thu, 10 Oct 2019 15:56:51 +0200 (CEST) Date: Thu, 10 Oct 2019 15:56:51 +0200 From: David Sterba To: Ard Biesheuvel Cc: David Sterba , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" Subject: Re: [PATCH v2] crypto: add blake2b generic implementation Message-ID: <20191010135651.GS2751@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Ard Biesheuvel , David Sterba , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi, On Wed, Oct 09, 2019 at 03:47:09PM +0200, Ard Biesheuvel wrote: > I have a couple more comments - apologies for not spotting these the > first time around. No problem, there was a lot of churn since v1. > > +enum { > > + BLAKE2_DUMMY_2 = 1 / (sizeof(struct blake2b_param) == BLAKE2B_OUTBYTES) > > +}; > > + > > Please use BUILD_BUG_ON() to do compile time sanity checks. > (You'll have to move it into a C function though) Fixed. > > +int blake2b_init_key(struct blake2b_state *S, size_t outlen, const void *key, > > This should be static, and given that it is not used anywhere, you > should either remove it or wire it up. > > Given that blake2 can be used as a keyed hash as well as an unkeyed > hash, I propose that you implement the setkey() hook, and add > CRYPTO_ALG_OPTIONAL_KEY to the cra_flags to convey that setkey() is > optional. Ok, setkey will be in v3. > > +int blake2b_init(struct blake2b_state *S, size_t outlen); > > +int blake2b_init_key(struct blake2b_state *S, size_t outlen, const void *key, size_t keylen); > > +int blake2b_update(struct blake2b_state *S, const void *in, size_t inlen); > > +int blake2b_final(struct blake2b_state *S, void *out, size_t outlen); > > Drop these please. Done, with the additional 'static' fixups.