diff options
author | Qu Wenruo <wqu@suse.com> | 2021-12-27 14:12:08 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-01-18 08:31:02 -0500 |
commit | 1617165a172ea1768c9cb12cde536f1da252546e (patch) | |
tree | 9c4af983adca444808b7e3ff629a377c222150cc /fs/btrfs/crypto/hash.c | |
parent | 7c3fd5c25dd005c5eef54cc629fcbfcf48a04e9a (diff) |
fs/btrfs: add dependency on BLAKE2 hash
Now btrfs can utilize the newly intorudced BLAKE2 hash.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Diffstat (limited to 'fs/btrfs/crypto/hash.c')
-rw-r--r-- | fs/btrfs/crypto/hash.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/btrfs/crypto/hash.c b/fs/btrfs/crypto/hash.c index fb51f6386c..891a2974be 100644 --- a/fs/btrfs/crypto/hash.c +++ b/fs/btrfs/crypto/hash.c @@ -4,6 +4,7 @@ #include <linux/unaligned/access_ok.h> #include <linux/types.h> #include <u-boot/sha256.h> +#include <u-boot/blake2.h> #include <u-boot/crc.h> static u32 btrfs_crc32c_table[256]; @@ -39,6 +40,19 @@ int hash_xxhash(const u8 *buf, size_t length, u8 *out) return 0; } +/* We use the full CSUM_SIZE(32) for BLAKE2B */ +#define BTRFS_BLAKE2_HASH_SIZE 32 +int hash_blake2(const u8 *buf, size_t length, u8 *out) +{ + blake2b_state S; + + blake2b_init(&S, BTRFS_BLAKE2_HASH_SIZE); + blake2b_update(&S, buf, length); + blake2b_final(&S, out, BTRFS_BLAKE2_HASH_SIZE); + + return 0; +} + int hash_crc32c(const u8 *buf, size_t length, u8 *out) { u32 crc; |