RapidIO: add mport driver for Tsi721 bridge
[deliverable/linux.git] / crypto / pcompress.c
CommitLineData
a1d2f095
GU
1/*
2 * Cryptographic API.
3 *
4 * Partial (de)compression operations.
5 *
6 * Copyright 2008 Sony Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program.
19 * If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include <linux/crypto.h>
23#include <linux/errno.h>
24#include <linux/module.h>
25#include <linux/seq_file.h>
26#include <linux/string.h>
a55465dc
SK
27#include <linux/cryptouser.h>
28#include <net/netlink.h>
a1d2f095
GU
29
30#include <crypto/compress.h>
2f6ceb79 31#include <crypto/internal/compress.h>
a1d2f095
GU
32
33#include "internal.h"
34
35
36static int crypto_pcomp_init(struct crypto_tfm *tfm, u32 type, u32 mask)
37{
38 return 0;
39}
40
2ca33da1 41static unsigned int crypto_pcomp_extsize(struct crypto_alg *alg)
a1d2f095
GU
42{
43 return alg->cra_ctxsize;
44}
45
2ca33da1 46static int crypto_pcomp_init_tfm(struct crypto_tfm *tfm)
a1d2f095
GU
47{
48 return 0;
49}
50
a55465dc
SK
51static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg)
52{
53 struct crypto_report_comp rpcomp;
54
55 snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "pcomp");
56
57 NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
58 sizeof(struct crypto_report_comp), &rpcomp);
59
60 return 0;
61
62nla_put_failure:
63 return -EMSGSIZE;
64}
65
a1d2f095
GU
66static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
67 __attribute__ ((unused));
68static void crypto_pcomp_show(struct seq_file *m, struct crypto_alg *alg)
69{
70 seq_printf(m, "type : pcomp\n");
71}
72
73static const struct crypto_type crypto_pcomp_type = {
74 .extsize = crypto_pcomp_extsize,
75 .init = crypto_pcomp_init,
76 .init_tfm = crypto_pcomp_init_tfm,
77#ifdef CONFIG_PROC_FS
78 .show = crypto_pcomp_show,
79#endif
a55465dc 80 .report = crypto_pcomp_report,
a1d2f095
GU
81 .maskclear = ~CRYPTO_ALG_TYPE_MASK,
82 .maskset = CRYPTO_ALG_TYPE_MASK,
83 .type = CRYPTO_ALG_TYPE_PCOMPRESS,
84 .tfmsize = offsetof(struct crypto_pcomp, base),
85};
86
87struct crypto_pcomp *crypto_alloc_pcomp(const char *alg_name, u32 type,
88 u32 mask)
89{
90 return crypto_alloc_tfm(alg_name, &crypto_pcomp_type, type, mask);
91}
92EXPORT_SYMBOL_GPL(crypto_alloc_pcomp);
93
94int crypto_register_pcomp(struct pcomp_alg *alg)
95{
96 struct crypto_alg *base = &alg->base;
97
98 base->cra_type = &crypto_pcomp_type;
99 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
100 base->cra_flags |= CRYPTO_ALG_TYPE_PCOMPRESS;
101
102 return crypto_register_alg(base);
103}
104EXPORT_SYMBOL_GPL(crypto_register_pcomp);
105
106int crypto_unregister_pcomp(struct pcomp_alg *alg)
107{
108 return crypto_unregister_alg(&alg->base);
109}
110EXPORT_SYMBOL_GPL(crypto_unregister_pcomp);
111
112MODULE_LICENSE("GPL");
113MODULE_DESCRIPTION("Partial (de)compression type");
114MODULE_AUTHOR("Sony Corporation");
This page took 0.161883 seconds and 5 git commands to generate.