diff options
author | Qu Wenruo <wqu@suse.com> | 2020-06-24 19:02:48 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-09-08 03:57:27 +0300 |
commit | 565a4147d17ae3b05531b8c3081ca5fa5bcd72fd (patch) | |
tree | 4c79026f0d221a7ccd98145c335c8d4d03127949 /fs/btrfs/disk-io.c | |
parent | 3b4b40c0d6c02c9a4adc684cf125f628651caf4c (diff) | |
download | u-boot-565a4147d17ae3b05531b8c3081ca5fa5bcd72fd.tar.xz |
fs: btrfs: Add more checksum algorithms
This mostly crossports crypto/hash.[ch] from btrfs-progs.
The differences are:
- No blake2 support
No blake2 related library in U-Boot yet.
- Use uboot xxhash/sha256 directly
No need to implement the code as U-Boot has already provided the
interface.
This adds the support for the following csums:
- SHA256
- XXHASH
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c new file mode 100644 index 0000000000..58c32b548e --- /dev/null +++ b/fs/btrfs/disk-io.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <common.h> +#include <fs_internal.h> +#include "disk-io.h" +#include "crypto/hash.h" + +int btrfs_csum_data(u16 csum_type, const u8 *data, u8 *out, size_t len) +{ + memset(out, 0, BTRFS_CSUM_SIZE); + + switch (csum_type) { + case BTRFS_CSUM_TYPE_CRC32: + return hash_crc32c(data, len, out); + case BTRFS_CSUM_TYPE_XXHASH: + return hash_xxhash(data, len, out); + case BTRFS_CSUM_TYPE_SHA256: + return hash_sha256(data, len, out); + default: + printf("Unknown csum type %d\n", csum_type); + return -EINVAL; + } +} |