23 #define pr_fmt(fmt) "%s: " fmt, __func__
26 #include <linux/module.h>
31 #include <linux/net.h>
74 struct zlib_ctx *ctx = crypto_tfm_ctx(tfm);
77 zlib_decomp_exit(ctx);
84 struct zlib_ctx *ctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
87 int window_bits, mem_level;
133 struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
143 static int zlib_compress_update(
struct crypto_pcomp *tfm,
147 struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
162 pr_debug(
"zlib_deflate could not make progress\n");
166 pr_debug(
"zlib_deflate failed %d\n", ret);
171 pr_debug(
"avail_in %u, avail_out %u (consumed %u, produced %u)\n",
181 static int zlib_compress_final(
struct crypto_pcomp *tfm,
185 struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
196 pr_debug(
"zlib_deflate failed %d\n", ret);
201 pr_debug(
"avail_in %u, avail_out %u (consumed %u, produced %u)\n",
212 static int zlib_decompress_setup(
struct crypto_pcomp *tfm,
void *params,
215 struct zlib_ctx *ctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
224 zlib_decomp_exit(ctx);
244 static int zlib_decompress_init(
struct crypto_pcomp *tfm)
247 struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
257 static int zlib_decompress_update(
struct crypto_pcomp *tfm,
261 struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
277 pr_debug(
"zlib_inflate could not make progress\n");
281 pr_debug(
"zlib_inflate failed %d\n", ret);
286 pr_debug(
"avail_in %u, avail_out %u (consumed %u, produced %u)\n",
296 static int zlib_decompress_final(
struct crypto_pcomp *tfm,
300 struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
317 const void *saved_next_in = stream->
next_in;
323 stream->
next_in = saved_next_in;
329 pr_debug(
"zlib_inflate failed %d\n", ret);
334 pr_debug(
"avail_in %u, avail_out %u (consumed %u, produced %u)\n",
346 .compress_setup = zlib_compress_setup,
347 .compress_init = zlib_compress_init,
348 .compress_update = zlib_compress_update,
349 .compress_final = zlib_compress_final,
350 .decompress_setup = zlib_decompress_setup,
351 .decompress_init = zlib_decompress_init,
352 .decompress_update = zlib_decompress_update,
353 .decompress_final = zlib_decompress_final,
358 .cra_ctxsize =
sizeof(
struct zlib_ctx),
360 .cra_init = zlib_init,
361 .cra_exit = zlib_exit,
365 static int __init zlib_mod_init(
void)
370 static void __exit zlib_mod_fini(
void)