diff -ruNp 914-crypto-api-work-old/crypto/lzf.c 914-crypto-api-work-new/crypto/lzf.c
--- 914-crypto-api-work-old/crypto/lzf.c	1970-01-01 10:00:00.000000000 +1000
+++ 914-crypto-api-work-new/crypto/lzf.c	2004-12-04 19:28:04.308067256 +1100
@@ -0,0 +1,187 @@
+/* 
+ * Cryptographic API.
+ *
+ * LZF algorithm, implemented here initialy for use
+ * by Software Suspend 2. The LZF algorithm itself is found
+ * in /lib/lzf/, see there for its copyright notice.
+ *
+ * This cryptoapi interface
+ * 
+ * Copyright (c) 2004 Nigel Cunningham <ncunningham@linuxmail.org>
+ *
+ * based on the deflate.c file:
+ * 
+ * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) 
+ * any later version.
+ */
+#if 0
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/crypto.h>
+#include <linux/zlib.h>
+#include <linux/vmalloc.h>
+#include <linux/interrupt.h>
+#include <linux/mm.h>
+#include <linux/net.h>
+#include <linux/slab.h>
+#endif
+#include <linuz/lzf.h>
+
+struct lzf_ctx {
+	void * hbuf;
+	char * compress_buffer_page;
+	char * decompress_buffer_page;
+	int compress_bufofs;
+	int decompress_bufofs;
+};
+
+static int lzf_cyrpto_init(struct lzf_ctx *ctx)
+{
+	/* Get LZF ready to go */
+	ctx->hbuf = lzf_compress_init();
+	if (!ctx->hbuf)
+		return -ENOMEM;
+
+	/* Allocate compression buffer */
+	ctx->compress_buffer_page = (char *) get_zeroed_page(GFP_ATOMIC);
+
+	if (!ctx->compress_buffer_page) {
+		lzf_compress_cleanup(ctx->hbuf);
+		return -ENOMEM;
+	}
+
+	ctx->compress_bufofs = 0;
+
+	/* Allocate decompression buffer */
+	ctx->decompress_buffer_page = (char *) get_zeroed_page(GFP_ATOMIC);
+
+	if (!ctx->decompress_buffer_page) {
+		free_pages(ctx->compress_buffer_page, 0);
+		lzf_compress_cleanup(ctx->hbuf);
+		return -ENOMEM;
+	}
+
+	ctx->decompress_bufofs = PAGE_SIZE;
+
+	return 0;
+}
+
+static void lzf_cryto_exit(struct lzf_ctx *ctx)
+{
+	free_pages(ctx->compress_buffer_page, 0);
+	free_pages(ctx->decompress_buffer_page, 0);
+	lzf_compress_cleanup(ctx->hbuf);
+
+	/* Protect against use after freeing */
+	ctx->compress_buffer_page = NULL;
+	ctx->decompress_buffer_page = NULL;
+	ctx->hbuf = NULL;
+}
+
+static int lzf_compress(void *ctx, const u8 *src, unsigned int slen,
+	                    u8 *dst, unsigned int *dlen)
+{
+	int ret = 0;
+	struct lzf_ctx *dctx = ctx;
+	char * buffer_page = dctx->compress_buffer_page;
+	int compress_bufofs = dctx->compress_bufofs;
+
+	len = lzf_compress(buffer_start, PAGE_SIZE, page_buffer,
+			PAGE_SIZE - 3, ctx->compress_buffer_page);
+	ret = zlib_deflateReset(stream);
+	if (ret != Z_OK) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	stream->next_in = (u8 *)src;
+	stream->avail_in = slen;
+	stream->next_out = (u8 *)dst;
+	stream->avail_out = *dlen;
+
+	ret = zlib_deflate(stream, Z_FINISH);
+	if (ret != Z_STREAM_END) {
+		ret = -EINVAL;
+		goto out;
+	}
+	ret = 0;
+	*dlen = stream->total_out;
+out:
+	return ret;
+}
+ 
+static int lzf_decompress(void *ctx, const u8 *src, unsigned int slen,
+                              u8 *dst, unsigned int *dlen)
+{
+	
+	int ret = 0;
+	struct lzf_ctx *dctx = ctx;
+	struct z_stream_s *stream = &dctx->decomp_stream;
+
+	ret = zlib_inflateReset(stream);
+	if (ret != Z_OK) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	stream->next_in = (u8 *)src;
+	stream->avail_in = slen;
+	stream->next_out = (u8 *)dst;
+	stream->avail_out = *dlen;
+
+	ret = zlib_inflate(stream, Z_SYNC_FLUSH);
+	/*
+	 * Work around a bug in zlib, which sometimes wants to taste an extra
+	 * byte when being used in the (undocumented) raw deflate mode.
+	 * (From USAGI).
+	 */
+	if (ret == Z_OK && !stream->avail_in && stream->avail_out) {
+		u8 zerostuff = 0;
+		stream->next_in = &zerostuff;
+		stream->avail_in = 1; 
+		ret = zlib_inflate(stream, Z_FINISH);
+	}
+	if (ret != Z_STREAM_END) {
+		ret = -EINVAL;
+		goto out;
+	}
+	ret = 0;
+	*dlen = stream->total_out;
+out:
+	return ret;
+}
+
+static struct crypto_alg alg = {
+	.cra_name		= "lzf",
+	.cra_flags		= CRYPTO_ALG_TYPE_COMPRESS,
+	.cra_ctxsize		= 0,
+	.cra_module		= THIS_MODULE,
+	.cra_list		= LIST_HEAD_INIT(alg.cra_list),
+	.cra_u			= { .compress = {
+	.coa_init		= lzf_crypto_init,
+	.coa_exit		= lzf_crypto_exit,
+	.coa_compress 		= lzf_compress,
+	.coa_decompress  	= lzf_decompress } }
+};
+
+static int __init init(void)
+{
+	return crypto_register_alg(&alg);
+}
+
+static void __exit fini(void)
+{
+	crypto_unregister_alg(&alg);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Deflate Compression Algorithm for IPCOMP");
+MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
+
