Skip to contentSkip to conversation

crypto: Add LZO compression support to the crypto interface

PATCH In review Richard Purdie 2 participants 3 messages May 1, 2007 – May 4, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/5 crypto: Add LZO compression support to the crypto interface

crypto: Add LZO compression support to the crypto interface

Add LZO1X compression support to the crypto interface, including a couple of tests.

Also convert test_deflate into a more generic test_compress() and avoid duplicating the data for compression and decompression tests since this can always work both ways in the compression case.

---
 crypto/Kconfig      |    8 +++
 crypto/Makefile     |    1 +
 crypto/crypto_lzo.c |  123 +++++++++++++++++++++++++++++++++++++++++++++++++++
 crypto/tcrypt.c     |   43 ++++++++----------
 crypto/tcrypt.h     |   75 +++++++++++++++++--------------
 5 files changed, 193 insertions(+), 57 deletions(-)
crypto/Kconfig +8 -0
index 086fcec..8a479d5 100644
@@ -406,6 +406,14 @@ config CRYPTO_DEFLATE
 	  
 	  You will most probably want this if using IPSec.
 
+config CRYPTO_LZO
+	tristate "LZO compression algorithm"
+	depends on CRYPTO
+	select LZO
+	help
+	  Enable use of the LZO compression algorithm through the crypto
+	  subsystem.
+
 config CRYPTO_MICHAEL_MIC
 	tristate "Michael MIC keyed digest algorithm"
 	select CRYPTO_ALGAPI
crypto/Makefile +1 -0
index 12f93f5..b4bc7ca 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_CRYPTO_TEA) += tea.o
 obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
 obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
+obj-$(CONFIG_CRYPTO_LZO) += crypto_lzo.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
 
crypto/crypto_lzo.c new file +123 -0

123 lines not on this page · raw message

crypto/tcrypt.c +19 -24

104 lines not on this page · raw message

crypto/tcrypt.h +42 -33

91 lines not on this page · raw message

#1 lore raw

crypto/crypto_lzo.c line 43

Quoted 8 lines · Richard Purdie
crypto/crypto_lzo.c new file +8 -0
+static int lzo_init(struct crypto_tfm *tfm)
+{
+       struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       ctx->lzo_mem = vmalloc(LZO1X_MEM_COMPRESS);
+
+       if (!ctx->lzo_mem) {
+               vfree(ctx->lzo_mem);

Heh. What's (why's) this? You _can_ {k, v}free NULL but doing so after explicitly checking for it is ... ... insane!

Quoted 1 line

+ return -ENOMEM;

Yeah. Just return -ENOMEM; and be done with it.

#2 lore raw
Quoted 12 lines · Satyam Sharma

crypto/crypto_lzo.c line 43

Quoted 8 lines · Richard Purdie
crypto/crypto_lzo.c new file +8 -0
+static int lzo_init(struct crypto_tfm *tfm)
+{
+       struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       ctx->lzo_mem = vmalloc(LZO1X_MEM_COMPRESS);
+
+       if (!ctx->lzo_mem) {
+               vfree(ctx->lzo_mem);

Heh. What's (why's) this? You _can_ {k, v}free NULL but doing so after explicitly checking for it is ... ... insane!

True, there used to be two buffers allocated there and I've missed a sensible cleanup when I removed one. I'll fix it, thanks.

Cheers,

Richard