1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#include <linux/init.h>
31#include <linux/module.h>
32#include <linux/crypto.h>
33#include <linux/sw842.h>
34
35struct crypto842_ctx {
36 char wmem[SW842_MEM_COMPRESS];
37};
38
39static int crypto842_compress(struct crypto_tfm *tfm,
40 const u8 *src, unsigned int slen,
41 u8 *dst, unsigned int *dlen)
42{
43 struct crypto842_ctx *ctx = crypto_tfm_ctx(tfm);
44
45 return sw842_compress(src, slen, dst, dlen, ctx->wmem);
46}
47
48static int crypto842_decompress(struct crypto_tfm *tfm,
49 const u8 *src, unsigned int slen,
50 u8 *dst, unsigned int *dlen)
51{
52 return sw842_decompress(src, slen, dst, dlen);
53}
54
55static struct crypto_alg alg = {
56 .cra_name = "842",
57 .cra_driver_name = "842-generic",
58 .cra_priority = 100,
59 .cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
60 .cra_ctxsize = sizeof(struct crypto842_ctx),
61 .cra_module = THIS_MODULE,
62 .cra_u = { .compress = {
63 .coa_compress = crypto842_compress,
64 .coa_decompress = crypto842_decompress } }
65};
66
67static int __init crypto842_mod_init(void)
68{
69 return crypto_register_alg(&alg);
70}
71module_init(crypto842_mod_init);
72
73static void __exit crypto842_mod_exit(void)
74{
75 crypto_unregister_alg(&alg);
76}
77module_exit(crypto842_mod_exit);
78
79MODULE_LICENSE("GPL");
80MODULE_DESCRIPTION("842 Software Compression Algorithm");
81MODULE_ALIAS_CRYPTO("842");
82MODULE_ALIAS_CRYPTO("842-generic");
83MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
84