Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11049218 authored by Joonsoo Kim's avatar Joonsoo Kim Committed by Herbert Xu
Browse files

crypto: compress - remove unused pcomp interface



It is unused now, so remove it.

Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 10cff58c
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -84,15 +84,6 @@ config CRYPTO_RNG_DEFAULT
	tristate
	select CRYPTO_DRBG_MENU

config CRYPTO_PCOMP
	tristate
	select CRYPTO_PCOMP2
	select CRYPTO_ALGAPI

config CRYPTO_PCOMP2
	tristate
	select CRYPTO_ALGAPI2

config CRYPTO_AKCIPHER2
	tristate
	select CRYPTO_ALGAPI2
@@ -122,7 +113,6 @@ config CRYPTO_MANAGER2
	select CRYPTO_AEAD2
	select CRYPTO_HASH2
	select CRYPTO_BLKCIPHER2
	select CRYPTO_PCOMP2
	select CRYPTO_AKCIPHER2

config CRYPTO_USER
@@ -1504,15 +1494,6 @@ config CRYPTO_DEFLATE

	  You will most probably want this if using IPSec.

config CRYPTO_ZLIB
	tristate "Zlib compression algorithm"
	select CRYPTO_PCOMP
	select ZLIB_INFLATE
	select ZLIB_DEFLATE
	select NLATTR
	help
	  This is the zlib algorithm.

config CRYPTO_LZO
	tristate "LZO compression algorithm"
	select CRYPTO_ALGAPI
+0 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ crypto_hash-y += ahash.o
crypto_hash-y += shash.o
obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o

obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o
obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o

$(obj)/rsapubkey-asn1.o: $(obj)/rsapubkey-asn1.c $(obj)/rsapubkey-asn1.h
@@ -99,7 +98,6 @@ obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o
obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o
obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
obj-$(CONFIG_CRYPTO_ZLIB) += zlib.o
obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
obj-$(CONFIG_CRYPTO_CRC32C) += crc32c_generic.o
obj-$(CONFIG_CRYPTO_CRC32) += crc32.o

crypto/pcompress.c

deleted100644 → 0
+0 −115
Original line number Diff line number Diff line
/*
 * Cryptographic API.
 *
 * Partial (de)compression operations.
 *
 * Copyright 2008 Sony Corporation
 *
 * 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; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 */

#include <linux/crypto.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/cryptouser.h>
#include <net/netlink.h>

#include <crypto/compress.h>
#include <crypto/internal/compress.h>

#include "internal.h"


static int crypto_pcomp_init(struct crypto_tfm *tfm, u32 type, u32 mask)
{
	return 0;
}

static int crypto_pcomp_init_tfm(struct crypto_tfm *tfm)
{
	return 0;
}

#ifdef CONFIG_NET
static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg)
{
	struct crypto_report_comp rpcomp;

	strncpy(rpcomp.type, "pcomp", sizeof(rpcomp.type));
	if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS,
		    sizeof(struct crypto_report_comp), &rpcomp))
		goto nla_put_failure;
	return 0;

nla_put_failure:
	return -EMSGSIZE;
}
#else
static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg)
{
	return -ENOSYS;
}
#endif

static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
	__attribute__ ((unused));
static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
{
	seq_printf(m, "type         : pcomp\n");
}

static const struct crypto_type crypto_pcomp_type = {
	.extsize	= crypto_alg_extsize,
	.init		= crypto_pcomp_init,
	.init_tfm	= crypto_pcomp_init_tfm,
#ifdef CONFIG_PROC_FS
	.show		= crypto_pcomp_show,
#endif
	.report		= crypto_pcomp_report,
	.maskclear	= ~CRYPTO_ALG_TYPE_MASK,
	.maskset	= CRYPTO_ALG_TYPE_MASK,
	.type		= CRYPTO_ALG_TYPE_PCOMPRESS,
	.tfmsize	= offsetof(struct crypto_pcomp, base),
};

struct crypto_pcomp *crypto_alloc_pcomp(const char *alg_name, u32 type,
					u32 mask)
{
	return crypto_alloc_tfm(alg_name, &crypto_pcomp_type, type, mask);
}
EXPORT_SYMBOL_GPL(crypto_alloc_pcomp);

int crypto_register_pcomp(struct pcomp_alg *alg)
{
	struct crypto_alg *base = &alg->base;

	base->cra_type = &crypto_pcomp_type;
	base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
	base->cra_flags |= CRYPTO_ALG_TYPE_PCOMPRESS;

	return crypto_register_alg(base);
}
EXPORT_SYMBOL_GPL(crypto_register_pcomp);

int crypto_unregister_pcomp(struct pcomp_alg *alg)
{
	return crypto_unregister_alg(&alg->base);
}
EXPORT_SYMBOL_GPL(crypto_unregister_pcomp);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Partial (de)compression type");
MODULE_AUTHOR("Sony Corporation");
+0 −223
Original line number Diff line number Diff line
@@ -96,13 +96,6 @@ struct comp_test_suite {
	} comp, decomp;
};

struct pcomp_test_suite {
	struct {
		struct pcomp_testvec *vecs;
		unsigned int count;
	} comp, decomp;
};

struct hash_test_suite {
	struct hash_testvec *vecs;
	unsigned int count;
@@ -133,7 +126,6 @@ struct alg_test_desc {
		struct aead_test_suite aead;
		struct cipher_test_suite cipher;
		struct comp_test_suite comp;
		struct pcomp_test_suite pcomp;
		struct hash_test_suite hash;
		struct cprng_test_suite cprng;
		struct drbg_test_suite drbg;
@@ -1293,183 +1285,6 @@ static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate,
	return ret;
}

static int test_pcomp(struct crypto_pcomp *tfm,
		      struct pcomp_testvec *ctemplate,
		      struct pcomp_testvec *dtemplate, int ctcount,
		      int dtcount)
{
	const char *algo = crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm));
	unsigned int i;
	char result[COMP_BUF_SIZE];
	int res;

	for (i = 0; i < ctcount; i++) {
		struct comp_request req;
		unsigned int produced = 0;

		res = crypto_compress_setup(tfm, ctemplate[i].params,
					    ctemplate[i].paramsize);
		if (res) {
			pr_err("alg: pcomp: compression setup failed on test "
			       "%d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}

		res = crypto_compress_init(tfm);
		if (res) {
			pr_err("alg: pcomp: compression init failed on test "
			       "%d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}

		memset(result, 0, sizeof(result));

		req.next_in = ctemplate[i].input;
		req.avail_in = ctemplate[i].inlen / 2;
		req.next_out = result;
		req.avail_out = ctemplate[i].outlen / 2;

		res = crypto_compress_update(tfm, &req);
		if (res < 0 && (res != -EAGAIN || req.avail_in)) {
			pr_err("alg: pcomp: compression update failed on test "
			       "%d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}
		if (res > 0)
			produced += res;

		/* Add remaining input data */
		req.avail_in += (ctemplate[i].inlen + 1) / 2;

		res = crypto_compress_update(tfm, &req);
		if (res < 0 && (res != -EAGAIN || req.avail_in)) {
			pr_err("alg: pcomp: compression update failed on test "
			       "%d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}
		if (res > 0)
			produced += res;

		/* Provide remaining output space */
		req.avail_out += COMP_BUF_SIZE - ctemplate[i].outlen / 2;

		res = crypto_compress_final(tfm, &req);
		if (res < 0) {
			pr_err("alg: pcomp: compression final failed on test "
			       "%d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}
		produced += res;

		if (COMP_BUF_SIZE - req.avail_out != ctemplate[i].outlen) {
			pr_err("alg: comp: Compression test %d failed for %s: "
			       "output len = %d (expected %d)\n", i + 1, algo,
			       COMP_BUF_SIZE - req.avail_out,
			       ctemplate[i].outlen);
			return -EINVAL;
		}

		if (produced != ctemplate[i].outlen) {
			pr_err("alg: comp: Compression test %d failed for %s: "
			       "returned len = %u (expected %d)\n", i + 1,
			       algo, produced, ctemplate[i].outlen);
			return -EINVAL;
		}

		if (memcmp(result, ctemplate[i].output, ctemplate[i].outlen)) {
			pr_err("alg: pcomp: Compression test %d failed for "
			       "%s\n", i + 1, algo);
			hexdump(result, ctemplate[i].outlen);
			return -EINVAL;
		}
	}

	for (i = 0; i < dtcount; i++) {
		struct comp_request req;
		unsigned int produced = 0;

		res = crypto_decompress_setup(tfm, dtemplate[i].params,
					      dtemplate[i].paramsize);
		if (res) {
			pr_err("alg: pcomp: decompression setup failed on "
			       "test %d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}

		res = crypto_decompress_init(tfm);
		if (res) {
			pr_err("alg: pcomp: decompression init failed on test "
			       "%d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}

		memset(result, 0, sizeof(result));

		req.next_in = dtemplate[i].input;
		req.avail_in = dtemplate[i].inlen / 2;
		req.next_out = result;
		req.avail_out = dtemplate[i].outlen / 2;

		res = crypto_decompress_update(tfm, &req);
		if (res < 0 && (res != -EAGAIN || req.avail_in)) {
			pr_err("alg: pcomp: decompression update failed on "
			       "test %d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}
		if (res > 0)
			produced += res;

		/* Add remaining input data */
		req.avail_in += (dtemplate[i].inlen + 1) / 2;

		res = crypto_decompress_update(tfm, &req);
		if (res < 0 && (res != -EAGAIN || req.avail_in)) {
			pr_err("alg: pcomp: decompression update failed on "
			       "test %d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}
		if (res > 0)
			produced += res;

		/* Provide remaining output space */
		req.avail_out += COMP_BUF_SIZE - dtemplate[i].outlen / 2;

		res = crypto_decompress_final(tfm, &req);
		if (res < 0 && (res != -EAGAIN || req.avail_in)) {
			pr_err("alg: pcomp: decompression final failed on "
			       "test %d for %s: error=%d\n", i + 1, algo, res);
			return res;
		}
		if (res > 0)
			produced += res;

		if (COMP_BUF_SIZE - req.avail_out != dtemplate[i].outlen) {
			pr_err("alg: comp: Decompression test %d failed for "
			       "%s: output len = %d (expected %d)\n", i + 1,
			       algo, COMP_BUF_SIZE - req.avail_out,
			       dtemplate[i].outlen);
			return -EINVAL;
		}

		if (produced != dtemplate[i].outlen) {
			pr_err("alg: comp: Decompression test %d failed for "
			       "%s: returned len = %u (expected %d)\n", i + 1,
			       algo, produced, dtemplate[i].outlen);
			return -EINVAL;
		}

		if (memcmp(result, dtemplate[i].output, dtemplate[i].outlen)) {
			pr_err("alg: pcomp: Decompression test %d failed for "
			       "%s\n", i + 1, algo);
			hexdump(result, dtemplate[i].outlen);
			return -EINVAL;
		}
	}

	return 0;
}


static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template,
		      unsigned int tcount)
{
@@ -1640,28 +1455,6 @@ static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
	return err;
}

static int alg_test_pcomp(const struct alg_test_desc *desc, const char *driver,
			  u32 type, u32 mask)
{
	struct crypto_pcomp *tfm;
	int err;

	tfm = crypto_alloc_pcomp(driver, type, mask);
	if (IS_ERR(tfm)) {
		pr_err("alg: pcomp: Failed to load transform for %s: %ld\n",
		       driver, PTR_ERR(tfm));
		return PTR_ERR(tfm);
	}

	err = test_pcomp(tfm, desc->suite.pcomp.comp.vecs,
			 desc->suite.pcomp.decomp.vecs,
			 desc->suite.pcomp.comp.count,
			 desc->suite.pcomp.decomp.count);

	crypto_free_pcomp(tfm);
	return err;
}

static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
			 u32 type, u32 mask)
{
@@ -3839,22 +3632,6 @@ static const struct alg_test_desc alg_test_descs[] = {
				}
			}
		}
	}, {
		.alg = "zlib",
		.test = alg_test_pcomp,
		.fips_allowed = 1,
		.suite = {
			.pcomp = {
				.comp = {
					.vecs = zlib_comp_tv_template,
					.count = ZLIB_COMP_TEST_VECTORS
				},
				.decomp = {
					.vecs = zlib_decomp_tv_template,
					.count = ZLIB_DECOMP_TEST_VECTORS
				}
			}
		}
	}
};

+0 −144
Original line number Diff line number Diff line
@@ -25,9 +25,6 @@
#define _CRYPTO_TESTMGR_H
#include <linux/netlink.h>
#include <linux/zlib.h>
#include <crypto/compress.h>
#define MAX_DIGEST_SIZE		64
#define MAX_TAP			8
@@ -32268,14 +32265,6 @@ struct comp_testvec {
	char output[COMP_BUF_SIZE];
};
struct pcomp_testvec {
	const void *params;
	unsigned int paramsize;
	int inlen, outlen;
	char input[COMP_BUF_SIZE];
	char output[COMP_BUF_SIZE];
};
/*
 * Deflate test vectors (null-terminated strings).
 * Params: winbits=-11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL.
@@ -32356,139 +32345,6 @@ static struct comp_testvec deflate_decomp_tv_template[] = {
	},
};
#define ZLIB_COMP_TEST_VECTORS 2
#define ZLIB_DECOMP_TEST_VECTORS 2
static const struct {
	struct nlattr nla;
	int val;
} deflate_comp_params[] = {
	{
		.nla = {
			.nla_len	= NLA_HDRLEN + sizeof(int),
			.nla_type	= ZLIB_COMP_LEVEL,
		},
		.val			= Z_DEFAULT_COMPRESSION,
	}, {
		.nla = {
			.nla_len	= NLA_HDRLEN + sizeof(int),
			.nla_type	= ZLIB_COMP_METHOD,
		},
		.val			= Z_DEFLATED,
	}, {
		.nla = {
			.nla_len	= NLA_HDRLEN + sizeof(int),
			.nla_type	= ZLIB_COMP_WINDOWBITS,
		},
		.val			= -11,
	}, {
		.nla = {
			.nla_len	= NLA_HDRLEN + sizeof(int),
			.nla_type	= ZLIB_COMP_MEMLEVEL,
		},
		.val			= MAX_MEM_LEVEL,
	}, {
		.nla = {
			.nla_len	= NLA_HDRLEN + sizeof(int),
			.nla_type	= ZLIB_COMP_STRATEGY,
		},
		.val			= Z_DEFAULT_STRATEGY,
	}
};
static const struct {
	struct nlattr nla;
	int val;
} deflate_decomp_params[] = {
	{
		.nla = {
			.nla_len	= NLA_HDRLEN + sizeof(int),
			.nla_type	= ZLIB_DECOMP_WINDOWBITS,
		},
		.val			= -11,
	}
};
static struct pcomp_testvec zlib_comp_tv_template[] = {
	{
		.params = &deflate_comp_params,
		.paramsize = sizeof(deflate_comp_params),
		.inlen	= 70,
		.outlen	= 38,
		.input	= "Join us now and share the software "
			"Join us now and share the software ",
		.output	= "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
			  "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
			  "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
			  "\x48\x55\x28\xce\x4f\x2b\x29\x07"
			  "\x71\xbc\x08\x2b\x01\x00",
	}, {
		.params = &deflate_comp_params,
		.paramsize = sizeof(deflate_comp_params),
		.inlen	= 191,
		.outlen	= 122,
		.input	= "This document describes a compression method based on the DEFLATE"
			"compression algorithm.  This document defines the application of "
			"the DEFLATE algorithm to the IP Payload Compression Protocol.",
		.output	= "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
			  "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
			  "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
			  "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
			  "\x68\x12\x51\xae\x76\x67\xd6\x27"
			  "\x19\x88\x1a\xde\x85\xab\x21\xf2"
			  "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
			  "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
			  "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
			  "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
			  "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
			  "\x52\x37\xed\x0e\x52\x6b\x59\x02"
			  "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
			  "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
			  "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
			  "\xfa\x02",
	},
};
static struct pcomp_testvec zlib_decomp_tv_template[] = {
	{
		.params = &deflate_decomp_params,
		.paramsize = sizeof(deflate_decomp_params),
		.inlen	= 122,
		.outlen	= 191,
		.input	= "\x5d\x8d\x31\x0e\xc2\x30\x10\x04"
			  "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09"
			  "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8"
			  "\x24\xdb\x67\xd9\x47\xc1\xef\x49"
			  "\x68\x12\x51\xae\x76\x67\xd6\x27"
			  "\x19\x88\x1a\xde\x85\xab\x21\xf2"
			  "\x08\x5d\x16\x1e\x20\x04\x2d\xad"
			  "\xf3\x18\xa2\x15\x85\x2d\x69\xc4"
			  "\x42\x83\x23\xb6\x6c\x89\x71\x9b"
			  "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f"
			  "\xed\x62\xa9\x4c\x80\xff\x13\xaf"
			  "\x52\x37\xed\x0e\x52\x6b\x59\x02"
			  "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98"
			  "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a"
			  "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79"
			  "\xfa\x02",
		.output	= "This document describes a compression method based on the DEFLATE"
			"compression algorithm.  This document defines the application of "
			"the DEFLATE algorithm to the IP Payload Compression Protocol.",
	}, {
		.params = &deflate_decomp_params,
		.paramsize = sizeof(deflate_decomp_params),
		.inlen	= 38,
		.outlen	= 70,
		.input	= "\xf3\xca\xcf\xcc\x53\x28\x2d\x56"
			  "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51"
			  "\x28\xce\x48\x2c\x4a\x55\x28\xc9"
			  "\x48\x55\x28\xce\x4f\x2b\x29\x07"
			  "\x71\xbc\x08\x2b\x01\x00",
		.output	= "Join us now and share the software "
			"Join us now and share the software ",
	},
};
/*
 * LZO test vectors (null-terminated strings).
 */
Loading