Skip to content

Commit 91d6893

Browse files
kdaveherbertx
authored andcommitted
crypto: blake2b - add blake2b generic implementation
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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 1751354 commit 91d6893

3 files changed

Lines changed: 453 additions & 0 deletions

File tree

‎crypto/Kconfig‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,23 @@ config CRYPTO_XXHASH
639639
xxHash non-cryptographic hash algorithm. Extremely fast, working at
640640
speeds close to RAM limits.
641641

642+
config CRYPTO_BLAKE2B
643+
tristate "BLAKE2b digest algorithm"
644+
select CRYPTO_HASH
645+
help
646+
Implementation of cryptographic hash function BLAKE2b (or just BLAKE2),
647+
optimized for 64bit platforms and can produce digests of any size
648+
between 1 to 64. The keyed hash is also implemented.
649+
650+
This module provides the following algorithms:
651+
652+
- blake2b-160
653+
- blake2b-256
654+
- blake2b-384
655+
- blake2b-512
656+
657+
See https://blake2.net for further information.
658+
642659
config CRYPTO_CRCT10DIF
643660
tristate "CRCT10DIF algorithm"
644661
select CRYPTO_HASH

‎crypto/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o
7474
obj-$(CONFIG_CRYPTO_WP512) += wp512.o
7575
CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
7676
obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
77+
obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o
7778
obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
7879
obj-$(CONFIG_CRYPTO_ECB) += ecb.o
7980
obj-$(CONFIG_CRYPTO_CBC) += cbc.o

0 commit comments

Comments
 (0)