From ebb79f1644550c41d07893e00c59ac402f72fe79 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 10 Jun 2019 14:56:11 +0200 Subject: [PATCH] btrfs-progs: add crc32c to hash wrappers Unify the interface for crc32c too. Signed-off-by: David Sterba --- crypto/hash.c | 11 +++++++++++ crypto/hash.h | 1 + 2 files changed, 12 insertions(+) diff --git a/crypto/hash.c b/crypto/hash.c index 8c428cba..dbabfadf 100644 --- a/crypto/hash.c +++ b/crypto/hash.c @@ -1,6 +1,17 @@ #include "crypto/hash.h" +#include "crypto/crc32c.h" #include "crypto/xxhash.h" +int hash_crc32c(const u8* buf, size_t length, u8 *out) +{ + u32 crc = ~0; + + crc = crc32c(~0, buf, length); + put_unaligned_le32(~crc, out); + + return 0; +} + int hash_xxhash(const u8 *buf, size_t length, u8 *out) { XXH64_hash_t hash; diff --git a/crypto/hash.h b/crypto/hash.h index 45c1ef17..7298d69d 100644 --- a/crypto/hash.h +++ b/crypto/hash.h @@ -5,6 +5,7 @@ #define CRYPTO_HASH_SIZE_MAX 32 +int hash_crc32c(const u8 *buf, size_t length, u8 *out); int hash_xxhash(const u8 *buf, size_t length, u8 *out); #endif