Add LZO compression support to cryptoapi
Hello Herbert!
I'm Zoltan Sogor at University of Szeged, Hungary, and we are working on new flash file system (UBIFS) cooperating with Nokia Corp. We would like to use cryptoapi in UBIFS compression/encrypt mechanism.
I've ported LZO compressor into cryptoapi. If you think the patch is good, please apply it.
If you have any problem with the patch, your feedbacks are welcome.
Thanks,
Zoltan
Quoted 1 line
From
57c2ed2d2bf37607ce5e9abcc878b6b4f35d7cd0Mon Sep 17 00:00:00 2001
From: Zoltan Sogor <[email protected]>
Date: Tue, 27 Nov 2007 10:11:50 +0100
Subject: [PATCH] Cryptoapi: add LZO compression algorithm support
Add LZO compression algorithm support
--- crypto/Kconfig | 8 ++++ crypto/Makefile | 1 + crypto/lzo.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 0 deletions(-)
crypto/Kconfig +8 -0
@@ -502,6 +502,14 @@ config CRYPTO_AUTHENC Authenc: Combined mode wrapper for IPsec. This is required for IPSec. +config CRYPTO_LZO + tristate "LZO compression algorithm" + select CRYPTO_ALGAPI + select LZO_COMPRESS + select LZO_DECOMPRESS + help + This is the LZO algorithm. + source "drivers/crypto/Kconfig" endif # if CRYPTO
crypto/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o +obj-$(CONFIG_CRYPTO_LZO) += lzo.o obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
crypto/lzo.c new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
1.4.4.4
Herbert Xu
maintainerHi Zoltan:
Quoted 9 lines · Zoltan Sogor
I'm Zoltan Sogor at University of Szeged, Hungary, and we are working on new flash file system (UBIFS) cooperating with Nokia Corp. We would like to use cryptoapi in UBIFS compression/encrypt mechanism.
I've ported LZO compressor into cryptoapi. If you think the patch is good, please apply it.
If you have any problem with the patch, your feedbacks are welcome.
Thanks for your patch! There's just one thing missing, tcrypt vectors. Please resubmit with them (you can model it after deflate) and I'll add this to cryptodev-2.6.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHi Herbert!
Quoted 6 lines · Herbert Xu
Hi Zoltan:
Quoted 2 lines · Zoltan Sogor
I'm Zoltan Sogor at University of Szeged, Hungary, and we are working on new flash file system (UBIFS) cooperating with Nokia Corp. We would like to use cryptoapi in UBIFS compression/encrypt mechanism.
Quoted 9 lines
Quoted 4 lines
I've ported LZO compressor into cryptoapi. If you think the patch is good, please apply it.
If you have any problem with the patch, your feedbacks are welcome.
Thanks for your patch! There's just one thing missing, tcrypt vectors. Please resubmit with them (you can model it after deflate) and I'll add this to cryptodev-2.6.
I've modified the patch as you suggested and added an other patch which adds a common compression test function (modifies deflate test case to use the common function).
Cheers,
Quoted 1 line
From
1b959d0efbcd30bc32d5350cd03774e2e5a34558Mon Sep 17 00:00:00 2001
From: Zoltan Sogor <[email protected]>
Date: Wed, 5 Dec 2007 10:57:09 +0100
Subject: [PATCH] Cryptoapi: add LZO compression algorithm support
Add LZO compression algorithm support
--- crypto/Kconfig | 8 ++++ crypto/Makefile | 1 + crypto/lzo.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ crypto/tcrypt.c | 9 ++++- crypto/tcrypt.h | 82 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+), 1 deletions(-)
crypto/Kconfig +8 -0
@@ -502,6 +502,14 @@ config CRYPTO_AUTHENC Authenc: Combined mode wrapper for IPsec. This is required for IPSec. +config CRYPTO_LZO + tristate "LZO compression algorithm" + select CRYPTO_ALGAPI + select LZO_COMPRESS + select LZO_DECOMPRESS + help + This is the LZO algorithm. + source "drivers/crypto/Kconfig" endif # if CRYPTO
crypto/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o +obj-$(CONFIG_CRYPTO_LZO) += lzo.o obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
crypto/lzo.c new file +106 -0
106 lines not on this page · raw message
crypto/tcrypt.c +8 -1
@@ -78,7 +78,7 @@ static char *check[] = {"twofish" ,"serpent" ,"sha384" ,"sha512" ,"md4" ,"aes" ,"cast6" ,"arc4" ,"michael_mic" ,"deflate" ,"crc32c" ,"tea" ,"xtea" ,"khazad" ,"wp512" ,"wp384" ,"wp256" ,"tnepres" ,"xeta" ,"fcrypt" , -"camellia" ,"seed" ,NULL +"camellia" ,"seed" ,"lzo" ,NULL };static void hexdump (unsigned char *buf,unsigned int len)
@@ -1063,6 +1063,8 @@ static void do_test(void)test_comp ("deflate" , deflate_comp_tv_template, deflate_decomp_tv_template,DEFLATE_COMP_TEST_VECTORS ,DEFLATE_DECOMP_TEST_VECTORS ); +test_comp ("lzo" , lzo_comp_tv_template, lzo_decomp_tv_template, +LZO_COMP_TEST_VECTORS ,LZO_DECOMP_TEST_VECTORS );test_hash ("crc32c" , crc32c_tv_template,CRC32C_TEST_VECTORS );test_hash ("hmac(md5)" , hmac_md5_tv_template,HMAC_MD5_TEST_VECTORS );
@@ -1299,6 +1301,11 @@ static void do_test(void) CAMELLIA_CBC_DEC_TEST_VECTORS);break ; +case 33 : +test_comp ("lzo" , lzo_comp_tv_template, lzo_decomp_tv_template, +LZO_COMP_TEST_VECTORS ,LZO_DECOMP_TEST_VECTORS ); +break ; +case 100 :test_hash ("hmac(md5)" , hmac_md5_tv_template,HMAC_MD5_TEST_VECTORS );
crypto/tcrypt.h +82 -0
88 lines not on this page · raw message
Signature · 1 line
1.4.4.4
Quoted 1 line
From
ba9a8daafbc91d9ae1011fc5f60270f8998753afMon Sep 17 00:00:00 2001
From: Zoltan Sogor <[email protected]>
Date: Wed, 5 Dec 2007 10:41:30 +0100
Subject: [PATCH] Cryptoapi: add common compression tester function
Add common compression tester function
Modify deflate test case to use the common compressor test function
--- crypto/tcrypt.c | 33 ++++++++++++++++++++------------- 1 files changed, 20 insertions(+), 13 deletions(-)
crypto/tcrypt.c +20 -13
@@ -800,7 +800,8 @@ out:crypto_free_hash (tfm); } -static void test_deflate (void ) +static void test_comp (char *algo,struct comp_testvec *ctemplate, +struct comp_testvec *dtemplate,int ctcount,int dtcount) {unsigned int i;char result[COMP_BUF_SIZE ];
@@ -808,25 +809,26 @@ static void test_deflate(void)struct comp_testvec *tv;unsigned int tsize; -printk ("\ntesting deflate compression\n" ); +printk ("\ntesting %s compression\n" , algo); - tsize =sizeof (deflate_comp_tv_template); + tsize =sizeof (struct comp_testvec ); + tsize *= ctcount;if (tsize >TVMEMSIZE ) {printk ("template (%u) too big for tvmem (%u)\n" , tsize,TVMEMSIZE );return ; } -memcpy (tvmem, deflate_comp_tv_template, tsize); +memcpy (tvmem, ctemplate, tsize); tv = (void *)tvmem; - tfm =crypto_alloc_comp ("deflate" ,0 ,CRYPTO_ALG_ASYNC ); + tfm =crypto_alloc_comp (algo,0 ,CRYPTO_ALG_ASYNC );if (IS_ERR (tfm)) { -printk ("failed to load transform for deflate\n" ); +printk ("failed to load transform for %s\n" , algo);return ; } -for (i =0 ; i <DEFLATE_COMP_TEST_VECTORS ; i++) { +for (i =0 ; i < ctcount; i++) {int ilen, ret, dlen =COMP_BUF_SIZE ;printk ("test %u:\n" , i +1 );
@@ -845,19 +847,20 @@ static void test_deflate(void) ilen, dlen); } -printk ("\ntesting deflate decompression\n" ); +printk ("\ntesting %s decompression\n" , algo); - tsize =sizeof (deflate_decomp_tv_template); + tsize =sizeof (struct comp_testvec ); + tsize *= dtcount;if (tsize >TVMEMSIZE ) {printk ("template (%u) too big for tvmem (%u)\n" , tsize,TVMEMSIZE ); goto out; } -memcpy (tvmem, deflate_decomp_tv_template, tsize); +memcpy (tvmem, dtemplate, tsize); tv = (void *)tvmem; -for (i =0 ; i <DEFLATE_DECOMP_TEST_VECTORS ; i++) { +for (i =0 ; i < dtcount; i++) {int ilen, ret, dlen =COMP_BUF_SIZE ;printk ("test %u:\n" , i +1 );
@@ -1057,7 +1060,9 @@ static void do_test(void)test_hash ("tgr192" , tgr192_tv_template,TGR192_TEST_VECTORS );test_hash ("tgr160" , tgr160_tv_template,TGR160_TEST_VECTORS );test_hash ("tgr128" , tgr128_tv_template,TGR128_TEST_VECTORS ); -test_deflate (); +test_comp ("deflate" , deflate_comp_tv_template, + deflate_decomp_tv_template,DEFLATE_COMP_TEST_VECTORS , +DEFLATE_DECOMP_TEST_VECTORS );test_hash ("crc32c" , crc32c_tv_template,CRC32C_TEST_VECTORS );test_hash ("hmac(md5)" , hmac_md5_tv_template,HMAC_MD5_TEST_VECTORS );
@@ -1167,7 +1172,9 @@ static void do_test(void)break ;case 13 : -test_deflate (); +test_comp ("deflate" , deflate_comp_tv_template, + deflate_decomp_tv_template,DEFLATE_COMP_TEST_VECTORS , +DEFLATE_DECOMP_TEST_VECTORS );break ;case 14 :
Signature · 1 line
1.4.4.4
Herbert Xu
maintainerQuoted 4 lines · Zoltan Sogor
I've modified the patch as you suggested and added an other patch which adds a common compression test function (modifies deflate test case to use the common function).
Both applied to cryptodev-2.6. Thanks a lot Zoltan!
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt