Skip to content

Commit 4bf4b50

Browse files
ebiggersKent Overstreet
authored andcommitted
bcachefs: use library APIs for ChaCha20 and Poly1305
Just use the ChaCha20 and Poly1305 libraries instead of the clunky crypto API. This is much simpler. It is also slightly faster, since the libraries provide more direct access to the same architecture-optimized ChaCha20 and Poly1305 code. I've tested that existing encrypted bcachefs filesystems can be continue to be accessed with this patch applied. Reviewed-by: Ard Biesheuvel <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 1ec94a9 commit 4bf4b50

File tree

7 files changed

+65
-202
lines changed

7 files changed

+65
-202
lines changed

fs/bcachefs/Kconfig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ config BCACHEFS_FS
1515
select ZLIB_INFLATE
1616
select ZSTD_COMPRESS
1717
select ZSTD_DECOMPRESS
18-
select CRYPTO
1918
select CRYPTO_LIB_SHA256
20-
select CRYPTO_CHACHA20
21-
select CRYPTO_POLY1305
19+
select CRYPTO_LIB_CHACHA
20+
select CRYPTO_LIB_POLY1305
2221
select KEYS
2322
select RAID6_PQ
2423
select XOR_BLOCKS

fs/bcachefs/bcachefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,8 @@ struct bch_fs {
981981
mempool_t compress_workspace[BCH_COMPRESSION_OPT_NR];
982982
size_t zstd_workspace_size;
983983

984-
struct crypto_sync_skcipher *chacha20;
985-
struct crypto_shash *poly1305;
984+
struct bch_key chacha20_key;
985+
bool chacha20_key_set;
986986

987987
atomic64_t key_version;
988988

fs/bcachefs/btree_node_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
183183
return;
184184

185185
if (bch2_csum_type_is_encryption(BSET_CSUM_TYPE(&bn->keys))) {
186-
if (!c->chacha20)
186+
if (!c->chacha20_key_set)
187187
return;
188188

189189
struct nonce nonce = btree_nonce(&bn->keys, 0);

0 commit comments

Comments
 (0)