mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-04 09:21:34 -04:00
bcachefs: use sha256() instead of crypto_shash API
Just use sha256() instead of the clunky crypto API. This is much simpler. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
committed by
Kent Overstreet
parent
39abc73b59
commit
71fbb0b86e
@@ -16,7 +16,7 @@ config BCACHEFS_FS
|
||||
select ZSTD_COMPRESS
|
||||
select ZSTD_DECOMPRESS
|
||||
select CRYPTO
|
||||
select CRYPTO_SHA256
|
||||
select CRYPTO_LIB_SHA256
|
||||
select CRYPTO_CHACHA20
|
||||
select CRYPTO_POLY1305
|
||||
select KEYS
|
||||
|
||||
@@ -979,7 +979,6 @@ struct bch_fs {
|
||||
mempool_t compress_workspace[BCH_COMPRESSION_OPT_NR];
|
||||
size_t zstd_workspace_size;
|
||||
|
||||
struct crypto_shash *sha256;
|
||||
struct crypto_sync_skcipher *chacha20;
|
||||
struct crypto_shash *poly1305;
|
||||
|
||||
|
||||
@@ -801,8 +801,6 @@ void bch2_fs_encryption_exit(struct bch_fs *c)
|
||||
crypto_free_shash(c->poly1305);
|
||||
if (c->chacha20)
|
||||
crypto_free_sync_skcipher(c->chacha20);
|
||||
if (c->sha256)
|
||||
crypto_free_shash(c->sha256);
|
||||
}
|
||||
|
||||
int bch2_fs_encryption_init(struct bch_fs *c)
|
||||
@@ -811,14 +809,6 @@ int bch2_fs_encryption_init(struct bch_fs *c)
|
||||
struct bch_key key;
|
||||
int ret = 0;
|
||||
|
||||
c->sha256 = crypto_alloc_shash("sha256", 0, 0);
|
||||
ret = PTR_ERR_OR_ZERO(c->sha256);
|
||||
if (ret) {
|
||||
c->sha256 = NULL;
|
||||
bch_err(c, "error requesting sha256 module: %s", bch2_err_str(ret));
|
||||
goto out;
|
||||
}
|
||||
|
||||
crypt = bch2_sb_field_get(c->disk_sb.sb, crypt);
|
||||
if (!crypt)
|
||||
goto out;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "super.h"
|
||||
|
||||
#include <linux/crc32c.h>
|
||||
#include <crypto/hash.h>
|
||||
#include <crypto/sha2.h>
|
||||
|
||||
static inline enum bch_str_hash_type
|
||||
@@ -55,13 +54,10 @@ bch2_hash_info_init(struct bch_fs *c, const struct bch_inode_unpacked *bi)
|
||||
};
|
||||
|
||||
if (unlikely(info.type == BCH_STR_HASH_siphash_old)) {
|
||||
SHASH_DESC_ON_STACK(desc, c->sha256);
|
||||
u8 digest[SHA256_DIGEST_SIZE];
|
||||
|
||||
desc->tfm = c->sha256;
|
||||
|
||||
crypto_shash_digest(desc, (void *) &bi->bi_hash_seed,
|
||||
sizeof(bi->bi_hash_seed), digest);
|
||||
sha256((const u8 *)&bi->bi_hash_seed,
|
||||
sizeof(bi->bi_hash_seed), digest);
|
||||
memcpy(&info.siphash_key, digest, sizeof(info.siphash_key));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Kent Overstreet <kent.overstreet@gmail.com>");
|
||||
MODULE_DESCRIPTION("bcachefs filesystem");
|
||||
MODULE_SOFTDEP("pre: sha256");
|
||||
MODULE_SOFTDEP("pre: chacha20");
|
||||
MODULE_SOFTDEP("pre: poly1305");
|
||||
MODULE_SOFTDEP("pre: xxhash");
|
||||
|
||||
Reference in New Issue
Block a user