~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/crypto/compress.h

Version: ~ [ linux-6.1-rc7 ] ~ [ linux-6.0.10 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.80 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.156 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.225 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.267 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.300 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.334 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Compress: Compression algorithms under the cryptographic API.
  3  *
  4  * Copyright 2008 Sony Corporation
  5  *
  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.
  9  *
 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.
 14  *
 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/>.
 18  */
 19 
 20 #ifndef _CRYPTO_COMPRESS_H
 21 #define _CRYPTO_COMPRESS_H
 22 
 23 #include <linux/crypto.h>
 24 
 25 
 26 struct comp_request {
 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 */
 31 };
 32 
 33 enum zlib_comp_params {
 34         ZLIB_COMP_LEVEL = 1,            /* e.g. Z_DEFAULT_COMPRESSION */
 35         ZLIB_COMP_METHOD,               /* e.g. Z_DEFLATED */
 36         ZLIB_COMP_WINDOWBITS,           /* e.g. MAX_WBITS */
 37         ZLIB_COMP_MEMLEVEL,             /* e.g. DEF_MEM_LEVEL */
 38         ZLIB_COMP_STRATEGY,             /* e.g. Z_DEFAULT_STRATEGY */
 39         __ZLIB_COMP_MAX,
 40 };
 41 
 42 #define ZLIB_COMP_MAX   (__ZLIB_COMP_MAX - 1)
 43 
 44 
 45 enum zlib_decomp_params {
 46         ZLIB_DECOMP_WINDOWBITS = 1,     /* e.g. DEF_WBITS */
 47         __ZLIB_DECOMP_MAX,
 48 };
 49 
 50 #define ZLIB_DECOMP_MAX (__ZLIB_DECOMP_MAX - 1)
 51 
 52 
 53 struct crypto_pcomp {
 54         struct crypto_tfm base;
 55 };
 56 
 57 struct pcomp_alg {
 58         int (*compress_setup)(struct crypto_pcomp *tfm, const void *params,
 59                               unsigned int len);
 60         int (*compress_init)(struct crypto_pcomp *tfm);
 61         int (*compress_update)(struct crypto_pcomp *tfm,
 62                                struct comp_request *req);
 63         int (*compress_final)(struct crypto_pcomp *tfm,
 64                               struct comp_request *req);
 65         int (*decompress_setup)(struct crypto_pcomp *tfm, const void *params,
 66                                 unsigned int len);
 67         int (*decompress_init)(struct crypto_pcomp *tfm);
 68         int (*decompress_update)(struct crypto_pcomp *tfm,
 69                                  struct comp_request *req);
 70         int (*decompress_final)(struct crypto_pcomp *tfm,
 71                                 struct comp_request *req);
 72 
 73         struct crypto_alg base;
 74 };
 75 
 76 extern struct crypto_pcomp *crypto_alloc_pcomp(const char *alg_name, u32 type,
 77                                                u32 mask);
 78 
 79 static inline struct crypto_tfm *crypto_pcomp_tfm(struct crypto_pcomp *tfm)
 80 {
 81         return &tfm->base;
 82 }
 83 
 84 static inline void crypto_free_pcomp(struct crypto_pcomp *tfm)
 85 {
 86         crypto_destroy_tfm(tfm, crypto_pcomp_tfm(tfm));
 87 }
 88 
 89 static inline struct pcomp_alg *__crypto_pcomp_alg(struct crypto_alg *alg)
 90 {
 91         return container_of(alg, struct pcomp_alg, base);
 92 }
 93 
 94 static inline struct pcomp_alg *crypto_pcomp_alg(struct crypto_pcomp *tfm)
 95 {
 96         return __crypto_pcomp_alg(crypto_pcomp_tfm(tfm)->__crt_alg);
 97 }
 98 
 99 static inline int crypto_compress_setup(struct crypto_pcomp *tfm,
100                                         const void *params, unsigned int len)
101 {
102         return crypto_pcomp_alg(tfm)->compress_setup(tfm, params, len);
103 }
104 
105 static inline int crypto_compress_init(struct crypto_pcomp *tfm)
106 {
107         return crypto_pcomp_alg(tfm)->compress_init(tfm);
108 }
109 
110 static inline int crypto_compress_update(struct crypto_pcomp *tfm,
111                                          struct comp_request *req)
112 {
113         return crypto_pcomp_alg(tfm)->compress_update(tfm, req);
114 }
115 
116 static inline int crypto_compress_final(struct crypto_pcomp *tfm,
117                                         struct comp_request *req)
118 {
119         return crypto_pcomp_alg(tfm)->compress_final(tfm, req);
120 }
121 
122 static inline int crypto_decompress_setup(struct crypto_pcomp *tfm,
123                                           const void *params, unsigned int len)
124 {
125         return crypto_pcomp_alg(tfm)->decompress_setup(tfm, params, len);
126 }
127 
128 static inline int crypto_decompress_init(struct crypto_pcomp *tfm)
129 {
130         return crypto_pcomp_alg(tfm)->decompress_init(tfm);
131 }
132 
133 static inline int crypto_decompress_update(struct crypto_pcomp *tfm,
134                                            struct comp_request *req)
135 {
136         return crypto_pcomp_alg(tfm)->decompress_update(tfm, req);
137 }
138 
139 static inline int crypto_decompress_final(struct crypto_pcomp *tfm,
140                                           struct comp_request *req)
141 {
142         return crypto_pcomp_alg(tfm)->decompress_final(tfm, req);
143 }
144 
145 #endif  /* _CRYPTO_COMPRESS_H */
146 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp