linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: David Sterba <dsterba@suse.com>
Cc: linux-crypto@vger.kernel.org, ard.biesheuvel@linaro.org
Subject: Re: [PATCH v4 1/5] crypto: add blake2b generic implementation
Date: Fri, 11 Oct 2019 11:11:11 -0700	[thread overview]
Message-ID: <20191011181110.GC235973@gmail.com> (raw)
In-Reply-To: <6494ffe9b7940efa4de569d9371da7b1623e726b.1570812094.git.dsterba@suse.com>

On Fri, Oct 11, 2019 at 06:52:04PM +0200, David Sterba wrote:
> The patch brings support of several BLAKE2 variants (2b with various
> digest lengths).  The keyed digest is supported, using tfm->setkey call.
> The in-tree user will be btrfs (for checksumming), we're going to use
> the BLAKE2b-256 variant.
> 
> The code is reference implementation taken from the official sources and
> modified in terms of kernel coding style (whitespace, comments, uintXX_t
> -> uXX types, removed unused prototypes and #ifdefs, removed testing
> code, changed secure_zero_memory -> memzero_explicit, used own helpers
> for unaligned reads/writes and rotations).
> 
> Further changes removed sanity checks of key length or output size,
> these values are verified in the crypto API callbacks or hardcoded in
> shash_alg and not exposed to users.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  crypto/Kconfig           |  17 ++
>  crypto/Makefile          |   1 +
>  crypto/blake2b_generic.c | 418 +++++++++++++++++++++++++++++++++++++++
>  include/crypto/blake2b.h |  48 +++++
>  4 files changed, 484 insertions(+)
>  create mode 100644 crypto/blake2b_generic.c
>  create mode 100644 include/crypto/blake2b.h
> 
> diff --git a/crypto/Kconfig b/crypto/Kconfig
> index e801450bcb1c..192cbb824928 100644
> --- a/crypto/Kconfig
> +++ b/crypto/Kconfig
> @@ -691,6 +691,23 @@ config CRYPTO_XXHASH
>  	  xxHash non-cryptographic hash algorithm. Extremely fast, working at
>  	  speeds close to RAM limits.
>  
> +config CRYPTO_BLAKE2B
> +	tristate "BLAKE2b digest algorithm"
> +	select CRYPTO_HASH
> +	help
> +	  Implementation of cryptographic hash function BLAKE2b (or just BLAKE2),
> +	  optimized for 64bit platforms and can produce digests of any size
> +	  between 1 to 64.  The keyed hash is also implemented.
> +
> +	  This module provides the following algorithms:
> +
> +	  - blake2b-160
> +	  - blake2b-256
> +	  - blake2b-384
> +	  - blake2b-512
> +
> +	  See https://blake2.net for further information.
> +
>  config CRYPTO_CRCT10DIF
>  	tristate "CRCT10DIF algorithm"
>  	select CRYPTO_HASH
> 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 <sneves@dei.uc.pt>.  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.
> + */

Can you also adjust this comment to make it clear that this isn't the reference
implementation verbatim, but rather it's been modified for inclusion in the
kernel?

Thanks!

- Eric

  parent reply	other threads:[~2019-10-11 18:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 16:52 [PATCH v4 0/5] BLAKE2b generic implementation David Sterba
2019-10-11 16:52 ` [PATCH v4 1/5] crypto: add blake2b " David Sterba
2019-10-11 18:04   ` Eric Biggers
2019-10-13 17:44     ` David Sterba
2019-10-11 18:11   ` Eric Biggers [this message]
2019-10-11 16:52 ` [PATCH v4 2/5] crypto: add test vectors for blake2b-160 David Sterba
2019-10-11 16:52 ` [PATCH v4 3/5] crypto: add test vectors for blake2b-256 David Sterba
2019-10-11 16:52 ` [PATCH v4 4/5] crypto: add test vectors for blake2b-384 David Sterba
2019-10-11 16:52 ` [PATCH v4 5/5] crypto: add test vectors for blake2b-512 David Sterba
2019-10-11 17:15 ` [PATCH v4 0/5] BLAKE2b generic implementation David Sterba
2019-10-11 17:57 ` Eric Biggers
2019-10-13 19:50   ` David Sterba
2019-10-14  2:54     ` Eric Biggers

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=20191011181110.GC235973@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=dsterba@suse.com \
    --cc=linux-crypto@vger.kernel.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).