1
2
3
4
5
6
7
8
9#ifndef _CRYPTO_SCOMP_INT_H
10#define _CRYPTO_SCOMP_INT_H
11#include <linux/crypto.h>
12
13#define SCOMP_SCRATCH_SIZE 131072
14
15struct crypto_scomp {
16 struct crypto_tfm base;
17};
18
19
20
21
22
23
24
25
26
27
28struct scomp_alg {
29 void *(*alloc_ctx)(struct crypto_scomp *tfm);
30 void (*free_ctx)(struct crypto_scomp *tfm, void *ctx);
31 int (*compress)(struct crypto_scomp *tfm, const u8 *src,
32 unsigned int slen, u8 *dst, unsigned int *dlen,
33 void *ctx);
34 int (*decompress)(struct crypto_scomp *tfm, const u8 *src,
35 unsigned int slen, u8 *dst, unsigned int *dlen,
36 void *ctx);
37 struct crypto_alg base;
38};
39
40static inline struct scomp_alg *__crypto_scomp_alg(struct crypto_alg *alg)
41{
42 return container_of(alg, struct scomp_alg, base);
43}
44
45static inline struct crypto_scomp *__crypto_scomp_tfm(struct crypto_tfm *tfm)
46{
47 return container_of(tfm, struct crypto_scomp, base);
48}
49
50static inline struct crypto_tfm *crypto_scomp_tfm(struct crypto_scomp *tfm)
51{
52 return &tfm->base;
53}
54
55static inline void crypto_free_scomp(struct crypto_scomp *tfm)
56{
57 crypto_destroy_tfm(tfm, crypto_scomp_tfm(tfm));
58}
59
60static inline struct scomp_alg *crypto_scomp_alg(struct crypto_scomp *tfm)
61{
62 return __crypto_scomp_alg(crypto_scomp_tfm(tfm)->__crt_alg);
63}
64
65static inline void *crypto_scomp_alloc_ctx(struct crypto_scomp *tfm)
66{
67 return crypto_scomp_alg(tfm)->alloc_ctx(tfm);
68}
69
70static inline void crypto_scomp_free_ctx(struct crypto_scomp *tfm,
71 void *ctx)
72{
73 return crypto_scomp_alg(tfm)->free_ctx(tfm, ctx);
74}
75
76static inline int crypto_scomp_compress(struct crypto_scomp *tfm,
77 const u8 *src, unsigned int slen,
78 u8 *dst, unsigned int *dlen, void *ctx)
79{
80 return crypto_scomp_alg(tfm)->compress(tfm, src, slen, dst, dlen, ctx);
81}
82
83static inline int crypto_scomp_decompress(struct crypto_scomp *tfm,
84 const u8 *src, unsigned int slen,
85 u8 *dst, unsigned int *dlen,
86 void *ctx)
87{
88 return crypto_scomp_alg(tfm)->decompress(tfm, src, slen, dst, dlen,
89 ctx);
90}
91
92int crypto_init_scomp_ops_async(struct crypto_tfm *tfm);
93struct acomp_req *crypto_acomp_scomp_alloc_ctx(struct acomp_req *req);
94void crypto_acomp_scomp_free_ctx(struct acomp_req *req);
95
96
97
98
99
100
101
102
103
104
105
106int crypto_register_scomp(struct scomp_alg *alg);
107
108
109
110
111
112
113
114
115
116void crypto_unregister_scomp(struct scomp_alg *alg);
117
118int crypto_register_scomps(struct scomp_alg *algs, int count);
119void crypto_unregister_scomps(struct scomp_alg *algs, int count);
120
121#endif
122