lkml.org 
[lkml]   [2005]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [RFC] CryptoAPI & Compression
From
Hi Artem:

On Fri, Mar 25, 2005 at 04:08:20PM +0000, Artem B. Bityuckiy wrote:
>
> I'm working on cleaning-up the JFFS3 compression stuff. JFFS3 contains a
> number of compressors which actually shouldn't be there as they are
> platform-independent and generic. So we want to move them to the generic
> part of the Linux kernel instead of storing them in fs/jffs2/. And we
> were going to use CryptoAPI to access the compressors.

Sounds good.

> In JFFS2 we need something more flexible. Te following is what we want:
>
> int crypto_compress_ext(struct crypto_tfm *tfm,
> const u8 *src, unsigned int *slen,
> u8 *dst, unsigned int *dlen);

Compressing part of the input could be significantly different from
compressing all of the input depending on the algorithm. In particular
it could be most costly to do so and/or result in worse compression.

So while I'm happy to add such an interface I think we should keep
crypto_comp_compress as well for full compression.

I've whipped up something quick and called it crypto_comp_pcompress.
How does this interface look to you?

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
===== crypto/compress.c 1.7 vs edited =====
--- 1.7/crypto/compress.c 2003-03-29 22:16:58 +11:00
+++ edited/crypto/compress.c 2005-03-26 15:33:19 +11:00
@@ -18,6 +18,17 @@
#include <linux/string.h>
#include "internal.h"

+static int crypto_pcompress(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int *slen,
+ u8 *dst, unsigned int *dlen)
+{
+ if (!tfm->__crt_alg->cra_compress.coa_pcompress)
+ return -ENOSYS;
+ return tfm->__crt_alg->cra_compress.coa_pcompress(crypto_tfm_ctx(tfm),
+ src, slen, dst,
+ dlen);
+}
+
static int crypto_compress(struct crypto_tfm *tfm,
const u8 *src, unsigned int slen,
u8 *dst, unsigned int *dlen)
@@ -50,6 +61,7 @@
if (ret)
goto out;

+ ops->cot_pcompress = crypto_pcompress;
ops->cot_compress = crypto_compress;
ops->cot_decompress = crypto_decompress;

===== include/linux/crypto.h 1.32 vs edited =====
--- 1.32/include/linux/crypto.h 2005-01-26 16:53:19 +11:00
+++ edited/include/linux/crypto.h 2005-03-26 15:25:39 +11:00
@@ -87,6 +87,8 @@
struct compress_alg {
int (*coa_init)(void *ctx);
void (*coa_exit)(void *ctx);
+ int (*coa_pcompress)(void *ctx, const u8 *src, unsigned int *slen,
+ u8 *dst, unsigned int *dlen);
int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
u8 *dst, unsigned int *dlen);
int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
@@ -178,6 +180,9 @@
};

struct compress_tfm {
+ int (*cot_pcompress)(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int *slen,
+ u8 *dst, unsigned int *dlen);
int (*cot_compress)(struct crypto_tfm *tfm,
const u8 *src, unsigned int slen,
u8 *dst, unsigned int *dlen);
@@ -363,6 +368,14 @@
{
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
memcpy(dst, tfm->crt_cipher.cit_iv, len);
+}
+
+static inline int crypto_comp_pcompress(struct crypto_tfm *tfm,
+ const u8 *src, unsigned int *slen,
+ u8 *dst, unsigned int *dlen)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
+ return tfm->crt_compress.cot_pcompress(tfm, src, slen, dst, dlen);
}

static inline int crypto_comp_compress(struct crypto_tfm *tfm,
\
 
 \ /
  Last update: 2005-04-06 13:30    [W:0.165 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site