2 * Compress: Compression algorithms under the cryptographic API.
4 * Copyright 2008 Sony Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program.
17 * If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _CRYPTO_COMPRESS_H
21 #define _CRYPTO_COMPRESS_H
23 #include <linux/crypto.h>
27 const void *next_in; /* next input byte */
28 void *next_out; /* next output byte */
29 unsigned int avail_in; /* bytes available at next_in */
30 unsigned int avail_out; /* bytes available at next_out */
34 struct crypto_tfm base;
38 int (*compress_setup)(struct crypto_pcomp *tfm, void *params,
40 int (*compress_init)(struct crypto_pcomp *tfm);
41 int (*compress_update)(struct crypto_pcomp *tfm,
42 struct comp_request *req);
43 int (*compress_final)(struct crypto_pcomp *tfm,
44 struct comp_request *req);
45 int (*decompress_setup)(struct crypto_pcomp *tfm, void *params,
47 int (*decompress_init)(struct crypto_pcomp *tfm);
48 int (*decompress_update)(struct crypto_pcomp *tfm,
49 struct comp_request *req);
50 int (*decompress_final)(struct crypto_pcomp *tfm,
51 struct comp_request *req);
53 struct crypto_alg base;
56 extern struct crypto_pcomp *crypto_alloc_pcomp(const char *alg_name, u32 type,
59 static inline struct crypto_tfm *crypto_pcomp_tfm(struct crypto_pcomp *tfm)
64 static inline void crypto_free_pcomp(struct crypto_pcomp *tfm)
66 crypto_destroy_tfm(tfm, crypto_pcomp_tfm(tfm));
69 static inline struct pcomp_alg *__crypto_pcomp_alg(struct crypto_alg *alg)
71 return container_of(alg, struct pcomp_alg, base);
74 static inline struct pcomp_alg *crypto_pcomp_alg(struct crypto_pcomp *tfm)
76 return __crypto_pcomp_alg(crypto_pcomp_tfm(tfm)->__crt_alg);
79 static inline int crypto_compress_setup(struct crypto_pcomp *tfm,
80 void *params, unsigned int len)
82 return crypto_pcomp_alg(tfm)->compress_setup(tfm, params, len);
85 static inline int crypto_compress_init(struct crypto_pcomp *tfm)
87 return crypto_pcomp_alg(tfm)->compress_init(tfm);
90 static inline int crypto_compress_update(struct crypto_pcomp *tfm,
91 struct comp_request *req)
93 return crypto_pcomp_alg(tfm)->compress_update(tfm, req);
96 static inline int crypto_compress_final(struct crypto_pcomp *tfm,
97 struct comp_request *req)
99 return crypto_pcomp_alg(tfm)->compress_final(tfm, req);
102 static inline int crypto_decompress_setup(struct crypto_pcomp *tfm,
103 void *params, unsigned int len)
105 return crypto_pcomp_alg(tfm)->decompress_setup(tfm, params, len);
108 static inline int crypto_decompress_init(struct crypto_pcomp *tfm)
110 return crypto_pcomp_alg(tfm)->decompress_init(tfm);
113 static inline int crypto_decompress_update(struct crypto_pcomp *tfm,
114 struct comp_request *req)
116 return crypto_pcomp_alg(tfm)->decompress_update(tfm, req);
119 static inline int crypto_decompress_final(struct crypto_pcomp *tfm,
120 struct comp_request *req)
122 return crypto_pcomp_alg(tfm)->decompress_final(tfm, req);
125 #endif /* _CRYPTO_COMPRESS_H */