Skip to contentSkip to conversation

crypto: Add zstd support

PATCH RESEND In review Nick Terrell 2 participants 2 messages Mar 30, 2018 – Apr 20, 2018

Subsystems (3)
lore
Share & tools
lore

Nick Terrell

author maintainer
#0 lore raw

PATCH RESEND 1/1 crypto: Add zstd support

Adds zstd support to crypto and scompress. Only supports the default level.

Previously we held off on this patch, since there weren't any users. Now zram is ready for zstd support, but depends on CONFIG_CRYPTO_ZSTD, which isn't defined until this patch is in. I also see a patch adding zstd to pstore [0], which depends on crypto zstd.

[0] lkml.kernel.org/r/9c9416b2dff19f05fb4c35879aaa83d11ff72c92.1521626182.git.geliangtang@gmail.com

---
 crypto/Kconfig   |   9 ++
 crypto/Makefile  |   1 +
 crypto/testmgr.c |  10 +++
 crypto/testmgr.h |  71 +++++++++++++++
 crypto/zstd.c    | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 356 insertions(+)
 create mode 100644 crypto/zstd.c
crypto/Kconfig +9 -0
index b75264b..500583c 100644
@@ -1677,6 +1677,15 @@ config CRYPTO_LZ4HC
 	help
 	  This is the LZ4 high compression mode algorithm.
 
+config CRYPTO_ZSTD
+	tristate "Zstd compression algorithm"
+	select CRYPTO_ALGAPI
+	select CRYPTO_ACOMP2
+	select ZSTD_COMPRESS
+	select ZSTD_DECOMPRESS
+	help
+	  This is the zstd algorithm.
+
 comment "Random Number Generation"
 
 config CRYPTO_ANSI_CPRNG
crypto/Makefile +1 -0
index cdbc03b..2900ab1 100644
@@ -136,6 +136,7 @@ obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
 obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
 obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o
 obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
+obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 
 ecdh_generic-y := ecc.o
 ecdh_generic-y += ecdh.o
crypto/testmgr.c +10 -0
index d5e23a1..71b2798 100644
@@ -3576,6 +3576,16 @@ static const struct alg_test_desc alg_test_descs[] = {
 				.decomp = __VECS(zlib_deflate_decomp_tv_template)
 			}
 		}
+	}, {
+		.alg = "zstd",
+		.test = alg_test_comp,
+		.fips_allowed = 1,
+		.suite = {
+			.comp = {
+				.comp = __VECS(zstd_comp_tv_template),
+				.decomp = __VECS(zstd_decomp_tv_template)
+			}
+		}
 	}
 };
 
crypto/testmgr.h +71 -0

75 lines not on this page · raw message

crypto/zstd.c new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
2.9.5
maintainer
#1 lore raw
Quoted 11 lines · Nick Terrell

Adds zstd support to crypto and scompress. Only supports the default level.

Previously we held off on this patch, since there weren't any users. Now zram is ready for zstd support, but depends on CONFIG_CRYPTO_ZSTD, which isn't defined until this patch is in. I also see a patch adding zstd to pstore [0], which depends on crypto zstd.

[0] lkml.kernel.org/r/9c9416b2dff19f05fb4c35879aaa83d11ff72c92.1521626182.git.geliangtang@gmail.com

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt