Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1240909ybp; Fri, 11 Oct 2019 11:05:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7cxKmavexUQj6gIkyZbLuxQOoydUhcFU0cNDKKRivM/oVL2r9ZQANRcUGg9vRHP3BQQae X-Received: by 2002:a05:6402:3046:: with SMTP id bu6mr14924230edb.276.1570817112648; Fri, 11 Oct 2019 11:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570817112; cv=none; d=google.com; s=arc-20160816; b=gghr9LatBNg0a+xi+216qrPDaFTVkiGWN6WUUzwhElRRGPV56Nt/sod7zY6ru/+MdW 9v5+AxzSiHsxZ8Lcuom/mZDEqzDZVDTVOAoQMwJJwR0QdMFrnqZgmqIFHMMfwH0ECPDo kHybqI2BaQvTR6CJ0+HBB3/o4GlwfJ370KoPs8ELNe7lnpHpA/I2gxTxNM8zfc5c0qJ9 cazU94YWTewBxyAd7xAREQSbOSROi2xeIlMQTxVqcW25nFq2SrcL/4n0DExwFXcxZtjv 50mK51rQjWHYX8FrJ+H2p+MF3wHUREGhAQhiTrlknaw2t1WFPrB/5sm7OudSDg4qewV9 jp6g== 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 :message-id:subject:cc:to:from:date:dkim-signature; bh=qnwGsXCtfFN3TqZ4hFzDhGGEOuWM3QSxzFq9ZhUOgMc=; b=yV37b75HaS3ERjfilP0InjrYlVBF25yQraKaNTyFKuFt2y3tr6X6xhwtX7S6kkwayD f9g4frhCvqKmCefeZbzKnp8gmxsO1ZvQt5no419zzUn8SZqHOKlub5dItLnvXBE9T3ny MFxy9sTpAa+H2Se6TQef7FtkpfyGuZpr5kOvjTee6BqJs6I5+gNdFOGzZPiWj+0No7Bc TP3PKb0c8FX5FM6X5OQEMXomx+Qn9dBsyWxfHoPaglBiFruc8lYvTUtD89XKmGTSer70 jodjyqw0hSXnRfKjg0uTiaBw91lX+EeZQgwD0TSICz58/hsF8fJN3Yss8AS5pzo0Rn36 ERiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xaWUUYnE; 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; 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 k53si6642481edb.303.2019.10.11.11.04.46; Fri, 11 Oct 2019 11:05:12 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xaWUUYnE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728587AbfJKSEn (ORCPT + 99 others); Fri, 11 Oct 2019 14:04:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728470AbfJKSEn (ORCPT ); Fri, 11 Oct 2019 14:04:43 -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 068CC20659; Fri, 11 Oct 2019 18:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570817082; bh=N/VcmY3IQiznewIHsfVNXHOUII7hSi60s1YWdvm/NZA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xaWUUYnEj7yTbr6H10WuTCzg0JGu73+KAOGVOH3q69bc+f3ZtPWQU4TtpeaITlYq9 PSqWc1TsjAEK3tc9ZrLovm0rRvJ9whZDCXqnhrLtwZ/bzQk328+sNmQUmdf70IVO0f OIPaM34chq0kNc5uuxdnJqp3zs60hREQ9ps1cbQY= Date: Fri, 11 Oct 2019 11:04:40 -0700 From: Eric Biggers To: David Sterba Cc: linux-crypto@vger.kernel.org, ard.biesheuvel@linaro.org Subject: Re: [PATCH v4 1/5] crypto: add blake2b generic implementation Message-ID: <20191011180439.GB235973@gmail.com> Mail-Followup-To: David Sterba , linux-crypto@vger.kernel.org, ard.biesheuvel@linaro.org References: <6494ffe9b7940efa4de569d9371da7b1623e726b.1570812094.git.dsterba@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6494ffe9b7940efa4de569d9371da7b1623e726b.1570812094.git.dsterba@suse.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Oct 11, 2019 at 06:52:04PM +0200, David Sterba wrote: > diff --git a/crypto/Makefile b/crypto/Makefile > index 9479e1a45d8c..2318420d3e71 100644 > --- a/crypto/Makefile > +++ b/crypto/Makefile > @@ -74,6 +74,7 @@ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o > obj-$(CONFIG_CRYPTO_WP512) += wp512.o > CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149 > obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o > +obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o > obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o > obj-$(CONFIG_CRYPTO_ECB) += ecb.o > obj-$(CONFIG_CRYPTO_CBC) += cbc.o > diff --git a/crypto/blake2b_generic.c b/crypto/blake2b_generic.c > new file mode 100644 > index 000000000000..e31fb669383b > --- /dev/null > +++ b/crypto/blake2b_generic.c > @@ -0,0 +1,418 @@ > +// SPDX-License-Identifier: (GPL-2.0-only OR Apache-2.0) > +/* > + * BLAKE2b reference source code package - reference C implementations > + * > + * Copyright 2012, Samuel Neves . You may use this under the > + * terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at > + * your option. The terms of these licenses can be found at: > + * > + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 > + * - OpenSSL license : https://www.openssl.org/source/license.html > + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 > + * > + * More information about the BLAKE2 hash function can be found at > + * https://blake2.net. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +struct blake2b_param > +{ It should be 'struct blake2b_param {' checkpatch.pl should warn about this. Can you fix the checkpatch warnings that make sense to fix? > +/* init xors IV with input parameter block */ > +static int blake2b_init_param(struct blake2b_state *S, > + const struct blake2b_param *P) > +{ > + const u8 *p = (const u8 *)(P); > + size_t i; > + > + blake2b_init0(S); > + > + /* IV XOR ParamBlock */ > + for (i = 0; i < 8; ++i) > + S->h[i] ^= get_unaligned_le64(p + sizeof(S->h[i]) * i); > + > + S->outlen = P->digest_length; > + return 0; > +} No need for this to have a return value anymore. Same with: blake2b_init_param() blake2b_update() blake2b_init() blake2b_init_key() blake2b_final() The code would be more readable if they returned void, since otherwise it gives the impression that errors can occur. > +static int blake2b_update(struct blake2b_state *S, const void *pin, size_t inlen) > +{ > + const unsigned char *in = (const unsigned char *)pin; Convention is to use 'u8', not 'unsigned char'. > +MODULE_ALIAS_CRYPTO("blake2b"); > +MODULE_ALIAS_CRYPTO("blake2b-generic"); Should remove these module aliases now that the "blake2b" algorithm was removed. - Eric