mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 15:28:50 +00:00
fs/btrfs: add dependency on BLAKE2 hash
Now btrfs can utilize the newly intorudced BLAKE2 hash. Signed-off-by: Qu Wenruo <wqu@suse.com>
This commit is contained in:
parent
7c3fd5c25d
commit
1617165a17
4 changed files with 18 additions and 0 deletions
|
@ -6,6 +6,7 @@ config FS_BTRFS
|
||||||
select ZSTD
|
select ZSTD
|
||||||
select RBTREE
|
select RBTREE
|
||||||
select SHA256
|
select SHA256
|
||||||
|
select BLAKE2
|
||||||
help
|
help
|
||||||
This provides a single-device read-only BTRFS support. BTRFS is a
|
This provides a single-device read-only BTRFS support. BTRFS is a
|
||||||
next-generation Linux file system based on the copy-on-write
|
next-generation Linux file system based on the copy-on-write
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <linux/unaligned/access_ok.h>
|
#include <linux/unaligned/access_ok.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <u-boot/sha256.h>
|
#include <u-boot/sha256.h>
|
||||||
|
#include <u-boot/blake2.h>
|
||||||
#include <u-boot/crc.h>
|
#include <u-boot/crc.h>
|
||||||
|
|
||||||
static u32 btrfs_crc32c_table[256];
|
static u32 btrfs_crc32c_table[256];
|
||||||
|
@ -39,6 +40,19 @@ int hash_xxhash(const u8 *buf, size_t length, u8 *out)
|
||||||
return 0;
|
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)
|
int hash_crc32c(const u8 *buf, size_t length, u8 *out)
|
||||||
{
|
{
|
||||||
u32 crc;
|
u32 crc;
|
||||||
|
|
|
@ -9,6 +9,7 @@ void btrfs_hash_init(void);
|
||||||
int hash_crc32c(const u8 *buf, size_t length, u8 *out);
|
int hash_crc32c(const u8 *buf, size_t length, u8 *out);
|
||||||
int hash_xxhash(const u8 *buf, size_t length, u8 *out);
|
int hash_xxhash(const u8 *buf, size_t length, u8 *out);
|
||||||
int hash_sha256(const u8 *buf, size_t length, u8 *out);
|
int hash_sha256(const u8 *buf, size_t length, u8 *out);
|
||||||
|
int hash_blake2(const u8 *buf, size_t length, u8 *out);
|
||||||
|
|
||||||
u32 crc32c(u32 seed, const void * data, size_t len);
|
u32 crc32c(u32 seed, const void * data, size_t len);
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,8 @@ int btrfs_csum_data(u16 csum_type, const u8 *data, u8 *out, size_t len)
|
||||||
return hash_xxhash(data, len, out);
|
return hash_xxhash(data, len, out);
|
||||||
case BTRFS_CSUM_TYPE_SHA256:
|
case BTRFS_CSUM_TYPE_SHA256:
|
||||||
return hash_sha256(data, len, out);
|
return hash_sha256(data, len, out);
|
||||||
|
case BTRFS_CSUM_TYPE_BLAKE2:
|
||||||
|
return hash_blake2(data, len, out);
|
||||||
default:
|
default:
|
||||||
printf("Unknown csum type %d\n", csum_type);
|
printf("Unknown csum type %d\n", csum_type);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue