mirror of
https://xff.cz/git/u-boot/
synced 2025-11-02 19:36:22 +01:00
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>
This commit is contained in:
22
fs/btrfs/disk-io.c
Normal file
22
fs/btrfs/disk-io.c
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user