9e7e9b62a3dcd9b31fe479992f6c554e02e3549e
[safe/jmp/linux-2.6] / include / linux / crypto.h
1 /*
2  * Scatterlist Cryptographic API.
3  *
4  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5  * Copyright (c) 2002 David S. Miller (davem@redhat.com)
6  * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
7  *
8  * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
9  * and Nettle, by Niels Möller.
10  * 
11  * This program is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU General Public License as published by the Free
13  * Software Foundation; either version 2 of the License, or (at your option) 
14  * any later version.
15  *
16  */
17 #ifndef _LINUX_CRYPTO_H
18 #define _LINUX_CRYPTO_H
19
20 #include <asm/atomic.h>
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/list.h>
24 #include <linux/slab.h>
25 #include <linux/string.h>
26 #include <linux/uaccess.h>
27
28 /*
29  * Algorithm masks and types.
30  */
31 #define CRYPTO_ALG_TYPE_MASK            0x0000000f
32 #define CRYPTO_ALG_TYPE_CIPHER          0x00000001
33 #define CRYPTO_ALG_TYPE_COMPRESS        0x00000002
34 #define CRYPTO_ALG_TYPE_AEAD            0x00000003
35 #define CRYPTO_ALG_TYPE_BLKCIPHER       0x00000004
36 #define CRYPTO_ALG_TYPE_ABLKCIPHER      0x00000005
37 #define CRYPTO_ALG_TYPE_GIVCIPHER       0x00000006
38 #define CRYPTO_ALG_TYPE_DIGEST          0x00000008
39 #define CRYPTO_ALG_TYPE_HASH            0x00000008
40 #define CRYPTO_ALG_TYPE_SHASH           0x00000009
41 #define CRYPTO_ALG_TYPE_AHASH           0x0000000a
42 #define CRYPTO_ALG_TYPE_RNG             0x0000000c
43 #define CRYPTO_ALG_TYPE_PCOMPRESS       0x0000000f
44
45 #define CRYPTO_ALG_TYPE_HASH_MASK       0x0000000e
46 #define CRYPTO_ALG_TYPE_AHASH_MASK      0x0000000c
47 #define CRYPTO_ALG_TYPE_BLKCIPHER_MASK  0x0000000c
48
49 #define CRYPTO_ALG_LARVAL               0x00000010
50 #define CRYPTO_ALG_DEAD                 0x00000020
51 #define CRYPTO_ALG_DYING                0x00000040
52 #define CRYPTO_ALG_ASYNC                0x00000080
53
54 /*
55  * Set this bit if and only if the algorithm requires another algorithm of
56  * the same type to handle corner cases.
57  */
58 #define CRYPTO_ALG_NEED_FALLBACK        0x00000100
59
60 /*
61  * This bit is set for symmetric key ciphers that have already been wrapped
62  * with a generic IV generator to prevent them from being wrapped again.
63  */
64 #define CRYPTO_ALG_GENIV                0x00000200
65
66 /*
67  * Set if the algorithm has passed automated run-time testing.  Note that
68  * if there is no run-time testing for a given algorithm it is considered
69  * to have passed.
70  */
71
72 #define CRYPTO_ALG_TESTED               0x00000400
73
74 /*
75  * Transform masks and values (for crt_flags).
76  */
77 #define CRYPTO_TFM_REQ_MASK             0x000fff00
78 #define CRYPTO_TFM_RES_MASK             0xfff00000
79
80 #define CRYPTO_TFM_REQ_WEAK_KEY         0x00000100
81 #define CRYPTO_TFM_REQ_MAY_SLEEP        0x00000200
82 #define CRYPTO_TFM_REQ_MAY_BACKLOG      0x00000400
83 #define CRYPTO_TFM_RES_WEAK_KEY         0x00100000
84 #define CRYPTO_TFM_RES_BAD_KEY_LEN      0x00200000
85 #define CRYPTO_TFM_RES_BAD_KEY_SCHED    0x00400000
86 #define CRYPTO_TFM_RES_BAD_BLOCK_LEN    0x00800000
87 #define CRYPTO_TFM_RES_BAD_FLAGS        0x01000000
88
89 /*
90  * Miscellaneous stuff.
91  */
92 #define CRYPTO_MAX_ALG_NAME             64
93
94 /*
95  * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual
96  * declaration) is used to ensure that the crypto_tfm context structure is
97  * aligned correctly for the given architecture so that there are no alignment
98  * faults for C data types.  In particular, this is required on platforms such
99  * as arm where pointers are 32-bit aligned but there are data types such as
100  * u64 which require 64-bit alignment.
101  */
102 #if defined(ARCH_KMALLOC_MINALIGN)
103 #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN
104 #elif defined(ARCH_SLAB_MINALIGN)
105 #define CRYPTO_MINALIGN ARCH_SLAB_MINALIGN
106 #else
107 #define CRYPTO_MINALIGN __alignof__(unsigned long long)
108 #endif
109
110 #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN)))
111
112 struct scatterlist;
113 struct crypto_ablkcipher;
114 struct crypto_async_request;
115 struct crypto_aead;
116 struct crypto_blkcipher;
117 struct crypto_hash;
118 struct crypto_ahash;
119 struct crypto_rng;
120 struct crypto_tfm;
121 struct crypto_type;
122 struct aead_givcrypt_request;
123 struct ahash_request;
124 struct skcipher_givcrypt_request;
125
126 typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);
127
128 struct crypto_async_request {
129         struct list_head list;
130         crypto_completion_t complete;
131         void *data;
132         struct crypto_tfm *tfm;
133
134         u32 flags;
135 };
136
137 struct ablkcipher_request {
138         struct crypto_async_request base;
139
140         unsigned int nbytes;
141
142         void *info;
143
144         struct scatterlist *src;
145         struct scatterlist *dst;
146
147         void *__ctx[] CRYPTO_MINALIGN_ATTR;
148 };
149
150 /**
151  *      struct aead_request - AEAD request
152  *      @base: Common attributes for async crypto requests
153  *      @assoclen: Length in bytes of associated data for authentication
154  *      @cryptlen: Length of data to be encrypted or decrypted
155  *      @iv: Initialisation vector
156  *      @assoc: Associated data
157  *      @src: Source data
158  *      @dst: Destination data
159  *      @__ctx: Start of private context data
160  */
161 struct aead_request {
162         struct crypto_async_request base;
163
164         unsigned int assoclen;
165         unsigned int cryptlen;
166
167         u8 *iv;
168
169         struct scatterlist *assoc;
170         struct scatterlist *src;
171         struct scatterlist *dst;
172
173         void *__ctx[] CRYPTO_MINALIGN_ATTR;
174 };
175
176 struct blkcipher_desc {
177         struct crypto_blkcipher *tfm;
178         void *info;
179         u32 flags;
180 };
181
182 struct cipher_desc {
183         struct crypto_tfm *tfm;
184         void (*crfn)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
185         unsigned int (*prfn)(const struct cipher_desc *desc, u8 *dst,
186                              const u8 *src, unsigned int nbytes);
187         void *info;
188 };
189
190 struct hash_desc {
191         struct crypto_hash *tfm;
192         u32 flags;
193 };
194
195 /*
196  * Algorithms: modular crypto algorithm implementations, managed
197  * via crypto_register_alg() and crypto_unregister_alg().
198  */
199 struct ablkcipher_alg {
200         int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key,
201                       unsigned int keylen);
202         int (*encrypt)(struct ablkcipher_request *req);
203         int (*decrypt)(struct ablkcipher_request *req);
204         int (*givencrypt)(struct skcipher_givcrypt_request *req);
205         int (*givdecrypt)(struct skcipher_givcrypt_request *req);
206
207         const char *geniv;
208
209         unsigned int min_keysize;
210         unsigned int max_keysize;
211         unsigned int ivsize;
212 };
213
214 struct old_ahash_alg {
215         int (*init)(struct ahash_request *req);
216         int (*reinit)(struct ahash_request *req);
217         int (*update)(struct ahash_request *req);
218         int (*final)(struct ahash_request *req);
219         int (*digest)(struct ahash_request *req);
220         int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
221                         unsigned int keylen);
222
223         unsigned int digestsize;
224 };
225
226 struct aead_alg {
227         int (*setkey)(struct crypto_aead *tfm, const u8 *key,
228                       unsigned int keylen);
229         int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize);
230         int (*encrypt)(struct aead_request *req);
231         int (*decrypt)(struct aead_request *req);
232         int (*givencrypt)(struct aead_givcrypt_request *req);
233         int (*givdecrypt)(struct aead_givcrypt_request *req);
234
235         const char *geniv;
236
237         unsigned int ivsize;
238         unsigned int maxauthsize;
239 };
240
241 struct blkcipher_alg {
242         int (*setkey)(struct crypto_tfm *tfm, const u8 *key,
243                       unsigned int keylen);
244         int (*encrypt)(struct blkcipher_desc *desc,
245                        struct scatterlist *dst, struct scatterlist *src,
246                        unsigned int nbytes);
247         int (*decrypt)(struct blkcipher_desc *desc,
248                        struct scatterlist *dst, struct scatterlist *src,
249                        unsigned int nbytes);
250
251         const char *geniv;
252
253         unsigned int min_keysize;
254         unsigned int max_keysize;
255         unsigned int ivsize;
256 };
257
258 struct cipher_alg {
259         unsigned int cia_min_keysize;
260         unsigned int cia_max_keysize;
261         int (*cia_setkey)(struct crypto_tfm *tfm, const u8 *key,
262                           unsigned int keylen);
263         void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
264         void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
265 };
266
267 struct digest_alg {
268         unsigned int dia_digestsize;
269         void (*dia_init)(struct crypto_tfm *tfm);
270         void (*dia_update)(struct crypto_tfm *tfm, const u8 *data,
271                            unsigned int len);
272         void (*dia_final)(struct crypto_tfm *tfm, u8 *out);
273         int (*dia_setkey)(struct crypto_tfm *tfm, const u8 *key,
274                           unsigned int keylen);
275 };
276
277 struct hash_alg {
278         int (*init)(struct hash_desc *desc);
279         int (*update)(struct hash_desc *desc, struct scatterlist *sg,
280                       unsigned int nbytes);
281         int (*final)(struct hash_desc *desc, u8 *out);
282         int (*digest)(struct hash_desc *desc, struct scatterlist *sg,
283                       unsigned int nbytes, u8 *out);
284         int (*setkey)(struct crypto_hash *tfm, const u8 *key,
285                       unsigned int keylen);
286
287         unsigned int digestsize;
288 };
289
290 struct compress_alg {
291         int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src,
292                             unsigned int slen, u8 *dst, unsigned int *dlen);
293         int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src,
294                               unsigned int slen, u8 *dst, unsigned int *dlen);
295 };
296
297 struct rng_alg {
298         int (*rng_make_random)(struct crypto_rng *tfm, u8 *rdata,
299                                unsigned int dlen);
300         int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
301
302         unsigned int seedsize;
303 };
304
305
306 #define cra_ablkcipher  cra_u.ablkcipher
307 #define cra_aead        cra_u.aead
308 #define cra_blkcipher   cra_u.blkcipher
309 #define cra_cipher      cra_u.cipher
310 #define cra_digest      cra_u.digest
311 #define cra_hash        cra_u.hash
312 #define cra_ahash       cra_u.ahash
313 #define cra_compress    cra_u.compress
314 #define cra_rng         cra_u.rng
315
316 struct crypto_alg {
317         struct list_head cra_list;
318         struct list_head cra_users;
319
320         u32 cra_flags;
321         unsigned int cra_blocksize;
322         unsigned int cra_ctxsize;
323         unsigned int cra_alignmask;
324
325         int cra_priority;
326         atomic_t cra_refcnt;
327
328         char cra_name[CRYPTO_MAX_ALG_NAME];
329         char cra_driver_name[CRYPTO_MAX_ALG_NAME];
330
331         const struct crypto_type *cra_type;
332
333         union {
334                 struct ablkcipher_alg ablkcipher;
335                 struct aead_alg aead;
336                 struct blkcipher_alg blkcipher;
337                 struct cipher_alg cipher;
338                 struct digest_alg digest;
339                 struct hash_alg hash;
340                 struct old_ahash_alg ahash;
341                 struct compress_alg compress;
342                 struct rng_alg rng;
343         } cra_u;
344
345         int (*cra_init)(struct crypto_tfm *tfm);
346         void (*cra_exit)(struct crypto_tfm *tfm);
347         void (*cra_destroy)(struct crypto_alg *alg);
348         
349         struct module *cra_module;
350 };
351
352 /*
353  * Algorithm registration interface.
354  */
355 int crypto_register_alg(struct crypto_alg *alg);
356 int crypto_unregister_alg(struct crypto_alg *alg);
357
358 /*
359  * Algorithm query interface.
360  */
361 int crypto_has_alg(const char *name, u32 type, u32 mask);
362
363 /*
364  * Transforms: user-instantiated objects which encapsulate algorithms
365  * and core processing logic.  Managed via crypto_alloc_*() and
366  * crypto_free_*(), as well as the various helpers below.
367  */
368
369 struct ablkcipher_tfm {
370         int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key,
371                       unsigned int keylen);
372         int (*encrypt)(struct ablkcipher_request *req);
373         int (*decrypt)(struct ablkcipher_request *req);
374         int (*givencrypt)(struct skcipher_givcrypt_request *req);
375         int (*givdecrypt)(struct skcipher_givcrypt_request *req);
376
377         struct crypto_ablkcipher *base;
378
379         unsigned int ivsize;
380         unsigned int reqsize;
381 };
382
383 struct aead_tfm {
384         int (*setkey)(struct crypto_aead *tfm, const u8 *key,
385                       unsigned int keylen);
386         int (*encrypt)(struct aead_request *req);
387         int (*decrypt)(struct aead_request *req);
388         int (*givencrypt)(struct aead_givcrypt_request *req);
389         int (*givdecrypt)(struct aead_givcrypt_request *req);
390
391         struct crypto_aead *base;
392
393         unsigned int ivsize;
394         unsigned int authsize;
395         unsigned int reqsize;
396 };
397
398 struct blkcipher_tfm {
399         void *iv;
400         int (*setkey)(struct crypto_tfm *tfm, const u8 *key,
401                       unsigned int keylen);
402         int (*encrypt)(struct blkcipher_desc *desc, struct scatterlist *dst,
403                        struct scatterlist *src, unsigned int nbytes);
404         int (*decrypt)(struct blkcipher_desc *desc, struct scatterlist *dst,
405                        struct scatterlist *src, unsigned int nbytes);
406 };
407
408 struct cipher_tfm {
409         int (*cit_setkey)(struct crypto_tfm *tfm,
410                           const u8 *key, unsigned int keylen);
411         void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
412         void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
413 };
414
415 struct hash_tfm {
416         int (*init)(struct hash_desc *desc);
417         int (*update)(struct hash_desc *desc,
418                       struct scatterlist *sg, unsigned int nsg);
419         int (*final)(struct hash_desc *desc, u8 *out);
420         int (*digest)(struct hash_desc *desc, struct scatterlist *sg,
421                       unsigned int nsg, u8 *out);
422         int (*setkey)(struct crypto_hash *tfm, const u8 *key,
423                       unsigned int keylen);
424         unsigned int digestsize;
425 };
426
427 struct compress_tfm {
428         int (*cot_compress)(struct crypto_tfm *tfm,
429                             const u8 *src, unsigned int slen,
430                             u8 *dst, unsigned int *dlen);
431         int (*cot_decompress)(struct crypto_tfm *tfm,
432                               const u8 *src, unsigned int slen,
433                               u8 *dst, unsigned int *dlen);
434 };
435
436 struct rng_tfm {
437         int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
438                               unsigned int dlen);
439         int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
440 };
441
442 #define crt_ablkcipher  crt_u.ablkcipher
443 #define crt_aead        crt_u.aead
444 #define crt_blkcipher   crt_u.blkcipher
445 #define crt_cipher      crt_u.cipher
446 #define crt_hash        crt_u.hash
447 #define crt_compress    crt_u.compress
448 #define crt_rng         crt_u.rng
449
450 struct crypto_tfm {
451
452         u32 crt_flags;
453         
454         union {
455                 struct ablkcipher_tfm ablkcipher;
456                 struct aead_tfm aead;
457                 struct blkcipher_tfm blkcipher;
458                 struct cipher_tfm cipher;
459                 struct hash_tfm hash;
460                 struct compress_tfm compress;
461                 struct rng_tfm rng;
462         } crt_u;
463
464         void (*exit)(struct crypto_tfm *tfm);
465         
466         struct crypto_alg *__crt_alg;
467
468         void *__crt_ctx[] CRYPTO_MINALIGN_ATTR;
469 };
470
471 struct crypto_ablkcipher {
472         struct crypto_tfm base;
473 };
474
475 struct crypto_aead {
476         struct crypto_tfm base;
477 };
478
479 struct crypto_blkcipher {
480         struct crypto_tfm base;
481 };
482
483 struct crypto_cipher {
484         struct crypto_tfm base;
485 };
486
487 struct crypto_comp {
488         struct crypto_tfm base;
489 };
490
491 struct crypto_hash {
492         struct crypto_tfm base;
493 };
494
495 struct crypto_rng {
496         struct crypto_tfm base;
497 };
498
499 enum {
500         CRYPTOA_UNSPEC,
501         CRYPTOA_ALG,
502         CRYPTOA_TYPE,
503         CRYPTOA_U32,
504         __CRYPTOA_MAX,
505 };
506
507 #define CRYPTOA_MAX (__CRYPTOA_MAX - 1)
508
509 /* Maximum number of (rtattr) parameters for each template. */
510 #define CRYPTO_MAX_ATTRS 32
511
512 struct crypto_attr_alg {
513         char name[CRYPTO_MAX_ALG_NAME];
514 };
515
516 struct crypto_attr_type {
517         u32 type;
518         u32 mask;
519 };
520
521 struct crypto_attr_u32 {
522         u32 num;
523 };
524
525 /* 
526  * Transform user interface.
527  */
528  
529 struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
530 void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);
531
532 static inline void crypto_free_tfm(struct crypto_tfm *tfm)
533 {
534         return crypto_destroy_tfm(tfm, tfm);
535 }
536
537 int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
538
539 /*
540  * Transform helpers which query the underlying algorithm.
541  */
542 static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm)
543 {
544         return tfm->__crt_alg->cra_name;
545 }
546
547 static inline const char *crypto_tfm_alg_driver_name(struct crypto_tfm *tfm)
548 {
549         return tfm->__crt_alg->cra_driver_name;
550 }
551
552 static inline int crypto_tfm_alg_priority(struct crypto_tfm *tfm)
553 {
554         return tfm->__crt_alg->cra_priority;
555 }
556
557 static inline const char *crypto_tfm_alg_modname(struct crypto_tfm *tfm)
558 {
559         return module_name(tfm->__crt_alg->cra_module);
560 }
561
562 static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
563 {
564         return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
565 }
566
567 static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
568 {
569         return tfm->__crt_alg->cra_blocksize;
570 }
571
572 static inline unsigned int crypto_tfm_alg_alignmask(struct crypto_tfm *tfm)
573 {
574         return tfm->__crt_alg->cra_alignmask;
575 }
576
577 static inline u32 crypto_tfm_get_flags(struct crypto_tfm *tfm)
578 {
579         return tfm->crt_flags;
580 }
581
582 static inline void crypto_tfm_set_flags(struct crypto_tfm *tfm, u32 flags)
583 {
584         tfm->crt_flags |= flags;
585 }
586
587 static inline void crypto_tfm_clear_flags(struct crypto_tfm *tfm, u32 flags)
588 {
589         tfm->crt_flags &= ~flags;
590 }
591
592 static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
593 {
594         return tfm->__crt_ctx;
595 }
596
597 static inline unsigned int crypto_tfm_ctx_alignment(void)
598 {
599         struct crypto_tfm *tfm;
600         return __alignof__(tfm->__crt_ctx);
601 }
602
603 /*
604  * API wrappers.
605  */
606 static inline struct crypto_ablkcipher *__crypto_ablkcipher_cast(
607         struct crypto_tfm *tfm)
608 {
609         return (struct crypto_ablkcipher *)tfm;
610 }
611
612 static inline u32 crypto_skcipher_type(u32 type)
613 {
614         type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV);
615         type |= CRYPTO_ALG_TYPE_BLKCIPHER;
616         return type;
617 }
618
619 static inline u32 crypto_skcipher_mask(u32 mask)
620 {
621         mask &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV);
622         mask |= CRYPTO_ALG_TYPE_BLKCIPHER_MASK;
623         return mask;
624 }
625
626 struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
627                                                   u32 type, u32 mask);
628
629 static inline struct crypto_tfm *crypto_ablkcipher_tfm(
630         struct crypto_ablkcipher *tfm)
631 {
632         return &tfm->base;
633 }
634
635 static inline void crypto_free_ablkcipher(struct crypto_ablkcipher *tfm)
636 {
637         crypto_free_tfm(crypto_ablkcipher_tfm(tfm));
638 }
639
640 static inline int crypto_has_ablkcipher(const char *alg_name, u32 type,
641                                         u32 mask)
642 {
643         return crypto_has_alg(alg_name, crypto_skcipher_type(type),
644                               crypto_skcipher_mask(mask));
645 }
646
647 static inline struct ablkcipher_tfm *crypto_ablkcipher_crt(
648         struct crypto_ablkcipher *tfm)
649 {
650         return &crypto_ablkcipher_tfm(tfm)->crt_ablkcipher;
651 }
652
653 static inline unsigned int crypto_ablkcipher_ivsize(
654         struct crypto_ablkcipher *tfm)
655 {
656         return crypto_ablkcipher_crt(tfm)->ivsize;
657 }
658
659 static inline unsigned int crypto_ablkcipher_blocksize(
660         struct crypto_ablkcipher *tfm)
661 {
662         return crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(tfm));
663 }
664
665 static inline unsigned int crypto_ablkcipher_alignmask(
666         struct crypto_ablkcipher *tfm)
667 {
668         return crypto_tfm_alg_alignmask(crypto_ablkcipher_tfm(tfm));
669 }
670
671 static inline u32 crypto_ablkcipher_get_flags(struct crypto_ablkcipher *tfm)
672 {
673         return crypto_tfm_get_flags(crypto_ablkcipher_tfm(tfm));
674 }
675
676 static inline void crypto_ablkcipher_set_flags(struct crypto_ablkcipher *tfm,
677                                                u32 flags)
678 {
679         crypto_tfm_set_flags(crypto_ablkcipher_tfm(tfm), flags);
680 }
681
682 static inline void crypto_ablkcipher_clear_flags(struct crypto_ablkcipher *tfm,
683                                                  u32 flags)
684 {
685         crypto_tfm_clear_flags(crypto_ablkcipher_tfm(tfm), flags);
686 }
687
688 static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm,
689                                            const u8 *key, unsigned int keylen)
690 {
691         struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(tfm);
692
693         return crt->setkey(crt->base, key, keylen);
694 }
695
696 static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm(
697         struct ablkcipher_request *req)
698 {
699         return __crypto_ablkcipher_cast(req->base.tfm);
700 }
701
702 static inline int crypto_ablkcipher_encrypt(struct ablkcipher_request *req)
703 {
704         struct ablkcipher_tfm *crt =
705                 crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req));
706         return crt->encrypt(req);
707 }
708
709 static inline int crypto_ablkcipher_decrypt(struct ablkcipher_request *req)
710 {
711         struct ablkcipher_tfm *crt =
712                 crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req));
713         return crt->decrypt(req);
714 }
715
716 static inline unsigned int crypto_ablkcipher_reqsize(
717         struct crypto_ablkcipher *tfm)
718 {
719         return crypto_ablkcipher_crt(tfm)->reqsize;
720 }
721
722 static inline void ablkcipher_request_set_tfm(
723         struct ablkcipher_request *req, struct crypto_ablkcipher *tfm)
724 {
725         req->base.tfm = crypto_ablkcipher_tfm(crypto_ablkcipher_crt(tfm)->base);
726 }
727
728 static inline struct ablkcipher_request *ablkcipher_request_cast(
729         struct crypto_async_request *req)
730 {
731         return container_of(req, struct ablkcipher_request, base);
732 }
733
734 static inline struct ablkcipher_request *ablkcipher_request_alloc(
735         struct crypto_ablkcipher *tfm, gfp_t gfp)
736 {
737         struct ablkcipher_request *req;
738
739         req = kmalloc(sizeof(struct ablkcipher_request) +
740                       crypto_ablkcipher_reqsize(tfm), gfp);
741
742         if (likely(req))
743                 ablkcipher_request_set_tfm(req, tfm);
744
745         return req;
746 }
747
748 static inline void ablkcipher_request_free(struct ablkcipher_request *req)
749 {
750         kzfree(req);
751 }
752
753 static inline void ablkcipher_request_set_callback(
754         struct ablkcipher_request *req,
755         u32 flags, crypto_completion_t complete, void *data)
756 {
757         req->base.complete = complete;
758         req->base.data = data;
759         req->base.flags = flags;
760 }
761
762 static inline void ablkcipher_request_set_crypt(
763         struct ablkcipher_request *req,
764         struct scatterlist *src, struct scatterlist *dst,
765         unsigned int nbytes, void *iv)
766 {
767         req->src = src;
768         req->dst = dst;
769         req->nbytes = nbytes;
770         req->info = iv;
771 }
772
773 static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm)
774 {
775         return (struct crypto_aead *)tfm;
776 }
777
778 struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask);
779
780 static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
781 {
782         return &tfm->base;
783 }
784
785 static inline void crypto_free_aead(struct crypto_aead *tfm)
786 {
787         crypto_free_tfm(crypto_aead_tfm(tfm));
788 }
789
790 static inline struct aead_tfm *crypto_aead_crt(struct crypto_aead *tfm)
791 {
792         return &crypto_aead_tfm(tfm)->crt_aead;
793 }
794
795 static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm)
796 {
797         return crypto_aead_crt(tfm)->ivsize;
798 }
799
800 static inline unsigned int crypto_aead_authsize(struct crypto_aead *tfm)
801 {
802         return crypto_aead_crt(tfm)->authsize;
803 }
804
805 static inline unsigned int crypto_aead_blocksize(struct crypto_aead *tfm)
806 {
807         return crypto_tfm_alg_blocksize(crypto_aead_tfm(tfm));
808 }
809
810 static inline unsigned int crypto_aead_alignmask(struct crypto_aead *tfm)
811 {
812         return crypto_tfm_alg_alignmask(crypto_aead_tfm(tfm));
813 }
814
815 static inline u32 crypto_aead_get_flags(struct crypto_aead *tfm)
816 {
817         return crypto_tfm_get_flags(crypto_aead_tfm(tfm));
818 }
819
820 static inline void crypto_aead_set_flags(struct crypto_aead *tfm, u32 flags)
821 {
822         crypto_tfm_set_flags(crypto_aead_tfm(tfm), flags);
823 }
824
825 static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags)
826 {
827         crypto_tfm_clear_flags(crypto_aead_tfm(tfm), flags);
828 }
829
830 static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key,
831                                      unsigned int keylen)
832 {
833         struct aead_tfm *crt = crypto_aead_crt(tfm);
834
835         return crt->setkey(crt->base, key, keylen);
836 }
837
838 int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize);
839
840 static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req)
841 {
842         return __crypto_aead_cast(req->base.tfm);
843 }
844
845 static inline int crypto_aead_encrypt(struct aead_request *req)
846 {
847         return crypto_aead_crt(crypto_aead_reqtfm(req))->encrypt(req);
848 }
849
850 static inline int crypto_aead_decrypt(struct aead_request *req)
851 {
852         return crypto_aead_crt(crypto_aead_reqtfm(req))->decrypt(req);
853 }
854
855 static inline unsigned int crypto_aead_reqsize(struct crypto_aead *tfm)
856 {
857         return crypto_aead_crt(tfm)->reqsize;
858 }
859
860 static inline void aead_request_set_tfm(struct aead_request *req,
861                                         struct crypto_aead *tfm)
862 {
863         req->base.tfm = crypto_aead_tfm(crypto_aead_crt(tfm)->base);
864 }
865
866 static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
867                                                       gfp_t gfp)
868 {
869         struct aead_request *req;
870
871         req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp);
872
873         if (likely(req))
874                 aead_request_set_tfm(req, tfm);
875
876         return req;
877 }
878
879 static inline void aead_request_free(struct aead_request *req)
880 {
881         kzfree(req);
882 }
883
884 static inline void aead_request_set_callback(struct aead_request *req,
885                                              u32 flags,
886                                              crypto_completion_t complete,
887                                              void *data)
888 {
889         req->base.complete = complete;
890         req->base.data = data;
891         req->base.flags = flags;
892 }
893
894 static inline void aead_request_set_crypt(struct aead_request *req,
895                                           struct scatterlist *src,
896                                           struct scatterlist *dst,
897                                           unsigned int cryptlen, u8 *iv)
898 {
899         req->src = src;
900         req->dst = dst;
901         req->cryptlen = cryptlen;
902         req->iv = iv;
903 }
904
905 static inline void aead_request_set_assoc(struct aead_request *req,
906                                           struct scatterlist *assoc,
907                                           unsigned int assoclen)
908 {
909         req->assoc = assoc;
910         req->assoclen = assoclen;
911 }
912
913 static inline struct crypto_blkcipher *__crypto_blkcipher_cast(
914         struct crypto_tfm *tfm)
915 {
916         return (struct crypto_blkcipher *)tfm;
917 }
918
919 static inline struct crypto_blkcipher *crypto_blkcipher_cast(
920         struct crypto_tfm *tfm)
921 {
922         BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_BLKCIPHER);
923         return __crypto_blkcipher_cast(tfm);
924 }
925
926 static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
927         const char *alg_name, u32 type, u32 mask)
928 {
929         type &= ~CRYPTO_ALG_TYPE_MASK;
930         type |= CRYPTO_ALG_TYPE_BLKCIPHER;
931         mask |= CRYPTO_ALG_TYPE_MASK;
932
933         return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask));
934 }
935
936 static inline struct crypto_tfm *crypto_blkcipher_tfm(
937         struct crypto_blkcipher *tfm)
938 {
939         return &tfm->base;
940 }
941
942 static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
943 {
944         crypto_free_tfm(crypto_blkcipher_tfm(tfm));
945 }
946
947 static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask)
948 {
949         type &= ~CRYPTO_ALG_TYPE_MASK;
950         type |= CRYPTO_ALG_TYPE_BLKCIPHER;
951         mask |= CRYPTO_ALG_TYPE_MASK;
952
953         return crypto_has_alg(alg_name, type, mask);
954 }
955
956 static inline const char *crypto_blkcipher_name(struct crypto_blkcipher *tfm)
957 {
958         return crypto_tfm_alg_name(crypto_blkcipher_tfm(tfm));
959 }
960
961 static inline struct blkcipher_tfm *crypto_blkcipher_crt(
962         struct crypto_blkcipher *tfm)
963 {
964         return &crypto_blkcipher_tfm(tfm)->crt_blkcipher;
965 }
966
967 static inline struct blkcipher_alg *crypto_blkcipher_alg(
968         struct crypto_blkcipher *tfm)
969 {
970         return &crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher;
971 }
972
973 static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm)
974 {
975         return crypto_blkcipher_alg(tfm)->ivsize;
976 }
977
978 static inline unsigned int crypto_blkcipher_blocksize(
979         struct crypto_blkcipher *tfm)
980 {
981         return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm));
982 }
983
984 static inline unsigned int crypto_blkcipher_alignmask(
985         struct crypto_blkcipher *tfm)
986 {
987         return crypto_tfm_alg_alignmask(crypto_blkcipher_tfm(tfm));
988 }
989
990 static inline u32 crypto_blkcipher_get_flags(struct crypto_blkcipher *tfm)
991 {
992         return crypto_tfm_get_flags(crypto_blkcipher_tfm(tfm));
993 }
994
995 static inline void crypto_blkcipher_set_flags(struct crypto_blkcipher *tfm,
996                                               u32 flags)
997 {
998         crypto_tfm_set_flags(crypto_blkcipher_tfm(tfm), flags);
999 }
1000
1001 static inline void crypto_blkcipher_clear_flags(struct crypto_blkcipher *tfm,
1002                                                 u32 flags)
1003 {
1004         crypto_tfm_clear_flags(crypto_blkcipher_tfm(tfm), flags);
1005 }
1006
1007 static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm,
1008                                           const u8 *key, unsigned int keylen)
1009 {
1010         return crypto_blkcipher_crt(tfm)->setkey(crypto_blkcipher_tfm(tfm),
1011                                                  key, keylen);
1012 }
1013
1014 static inline int crypto_blkcipher_encrypt(struct blkcipher_desc *desc,
1015                                            struct scatterlist *dst,
1016                                            struct scatterlist *src,
1017                                            unsigned int nbytes)
1018 {
1019         desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
1020         return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
1021 }
1022
1023 static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc,
1024                                               struct scatterlist *dst,
1025                                               struct scatterlist *src,
1026                                               unsigned int nbytes)
1027 {
1028         return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
1029 }
1030
1031 static inline int crypto_blkcipher_decrypt(struct blkcipher_desc *desc,
1032                                            struct scatterlist *dst,
1033                                            struct scatterlist *src,
1034                                            unsigned int nbytes)
1035 {
1036         desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
1037         return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
1038 }
1039
1040 static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc,
1041                                               struct scatterlist *dst,
1042                                               struct scatterlist *src,
1043                                               unsigned int nbytes)
1044 {
1045         return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
1046 }
1047
1048 static inline void crypto_blkcipher_set_iv(struct crypto_blkcipher *tfm,
1049                                            const u8 *src, unsigned int len)
1050 {
1051         memcpy(crypto_blkcipher_crt(tfm)->iv, src, len);
1052 }
1053
1054 static inline void crypto_blkcipher_get_iv(struct crypto_blkcipher *tfm,
1055                                            u8 *dst, unsigned int len)
1056 {
1057         memcpy(dst, crypto_blkcipher_crt(tfm)->iv, len);
1058 }
1059
1060 static inline struct crypto_cipher *__crypto_cipher_cast(struct crypto_tfm *tfm)
1061 {
1062         return (struct crypto_cipher *)tfm;
1063 }
1064
1065 static inline struct crypto_cipher *crypto_cipher_cast(struct crypto_tfm *tfm)
1066 {
1067         BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
1068         return __crypto_cipher_cast(tfm);
1069 }
1070
1071 static inline struct crypto_cipher *crypto_alloc_cipher(const char *alg_name,
1072                                                         u32 type, u32 mask)
1073 {
1074         type &= ~CRYPTO_ALG_TYPE_MASK;
1075         type |= CRYPTO_ALG_TYPE_CIPHER;
1076         mask |= CRYPTO_ALG_TYPE_MASK;
1077
1078         return __crypto_cipher_cast(crypto_alloc_base(alg_name, type, mask));
1079 }
1080
1081 static inline struct crypto_tfm *crypto_cipher_tfm(struct crypto_cipher *tfm)
1082 {
1083         return &tfm->base;
1084 }
1085
1086 static inline void crypto_free_cipher(struct crypto_cipher *tfm)
1087 {
1088         crypto_free_tfm(crypto_cipher_tfm(tfm));
1089 }
1090
1091 static inline int crypto_has_cipher(const char *alg_name, u32 type, u32 mask)
1092 {
1093         type &= ~CRYPTO_ALG_TYPE_MASK;
1094         type |= CRYPTO_ALG_TYPE_CIPHER;
1095         mask |= CRYPTO_ALG_TYPE_MASK;
1096
1097         return crypto_has_alg(alg_name, type, mask);
1098 }
1099
1100 static inline struct cipher_tfm *crypto_cipher_crt(struct crypto_cipher *tfm)
1101 {
1102         return &crypto_cipher_tfm(tfm)->crt_cipher;
1103 }
1104
1105 static inline unsigned int crypto_cipher_blocksize(struct crypto_cipher *tfm)
1106 {
1107         return crypto_tfm_alg_blocksize(crypto_cipher_tfm(tfm));
1108 }
1109
1110 static inline unsigned int crypto_cipher_alignmask(struct crypto_cipher *tfm)
1111 {
1112         return crypto_tfm_alg_alignmask(crypto_cipher_tfm(tfm));
1113 }
1114
1115 static inline u32 crypto_cipher_get_flags(struct crypto_cipher *tfm)
1116 {
1117         return crypto_tfm_get_flags(crypto_cipher_tfm(tfm));
1118 }
1119
1120 static inline void crypto_cipher_set_flags(struct crypto_cipher *tfm,
1121                                            u32 flags)
1122 {
1123         crypto_tfm_set_flags(crypto_cipher_tfm(tfm), flags);
1124 }
1125
1126 static inline void crypto_cipher_clear_flags(struct crypto_cipher *tfm,
1127                                              u32 flags)
1128 {
1129         crypto_tfm_clear_flags(crypto_cipher_tfm(tfm), flags);
1130 }
1131
1132 static inline int crypto_cipher_setkey(struct crypto_cipher *tfm,
1133                                        const u8 *key, unsigned int keylen)
1134 {
1135         return crypto_cipher_crt(tfm)->cit_setkey(crypto_cipher_tfm(tfm),
1136                                                   key, keylen);
1137 }
1138
1139 static inline void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
1140                                              u8 *dst, const u8 *src)
1141 {
1142         crypto_cipher_crt(tfm)->cit_encrypt_one(crypto_cipher_tfm(tfm),
1143                                                 dst, src);
1144 }
1145
1146 static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
1147                                              u8 *dst, const u8 *src)
1148 {
1149         crypto_cipher_crt(tfm)->cit_decrypt_one(crypto_cipher_tfm(tfm),
1150                                                 dst, src);
1151 }
1152
1153 static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm)
1154 {
1155         return (struct crypto_hash *)tfm;
1156 }
1157
1158 static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm)
1159 {
1160         BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_HASH) &
1161                CRYPTO_ALG_TYPE_HASH_MASK);
1162         return __crypto_hash_cast(tfm);
1163 }
1164
1165 static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
1166                                                     u32 type, u32 mask)
1167 {
1168         type &= ~CRYPTO_ALG_TYPE_MASK;
1169         mask &= ~CRYPTO_ALG_TYPE_MASK;
1170         type |= CRYPTO_ALG_TYPE_HASH;
1171         mask |= CRYPTO_ALG_TYPE_HASH_MASK;
1172
1173         return __crypto_hash_cast(crypto_alloc_base(alg_name, type, mask));
1174 }
1175
1176 static inline struct crypto_tfm *crypto_hash_tfm(struct crypto_hash *tfm)
1177 {
1178         return &tfm->base;
1179 }
1180
1181 static inline void crypto_free_hash(struct crypto_hash *tfm)
1182 {
1183         crypto_free_tfm(crypto_hash_tfm(tfm));
1184 }
1185
1186 static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask)
1187 {
1188         type &= ~CRYPTO_ALG_TYPE_MASK;
1189         mask &= ~CRYPTO_ALG_TYPE_MASK;
1190         type |= CRYPTO_ALG_TYPE_HASH;
1191         mask |= CRYPTO_ALG_TYPE_HASH_MASK;
1192
1193         return crypto_has_alg(alg_name, type, mask);
1194 }
1195
1196 static inline struct hash_tfm *crypto_hash_crt(struct crypto_hash *tfm)
1197 {
1198         return &crypto_hash_tfm(tfm)->crt_hash;
1199 }
1200
1201 static inline unsigned int crypto_hash_blocksize(struct crypto_hash *tfm)
1202 {
1203         return crypto_tfm_alg_blocksize(crypto_hash_tfm(tfm));
1204 }
1205
1206 static inline unsigned int crypto_hash_alignmask(struct crypto_hash *tfm)
1207 {
1208         return crypto_tfm_alg_alignmask(crypto_hash_tfm(tfm));
1209 }
1210
1211 static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm)
1212 {
1213         return crypto_hash_crt(tfm)->digestsize;
1214 }
1215
1216 static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm)
1217 {
1218         return crypto_tfm_get_flags(crypto_hash_tfm(tfm));
1219 }
1220
1221 static inline void crypto_hash_set_flags(struct crypto_hash *tfm, u32 flags)
1222 {
1223         crypto_tfm_set_flags(crypto_hash_tfm(tfm), flags);
1224 }
1225
1226 static inline void crypto_hash_clear_flags(struct crypto_hash *tfm, u32 flags)
1227 {
1228         crypto_tfm_clear_flags(crypto_hash_tfm(tfm), flags);
1229 }
1230
1231 static inline int crypto_hash_init(struct hash_desc *desc)
1232 {
1233         return crypto_hash_crt(desc->tfm)->init(desc);
1234 }
1235
1236 static inline int crypto_hash_update(struct hash_desc *desc,
1237                                      struct scatterlist *sg,
1238                                      unsigned int nbytes)
1239 {
1240         return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes);
1241 }
1242
1243 static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
1244 {
1245         return crypto_hash_crt(desc->tfm)->final(desc, out);
1246 }
1247
1248 static inline int crypto_hash_digest(struct hash_desc *desc,
1249                                      struct scatterlist *sg,
1250                                      unsigned int nbytes, u8 *out)
1251 {
1252         return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out);
1253 }
1254
1255 static inline int crypto_hash_setkey(struct crypto_hash *hash,
1256                                      const u8 *key, unsigned int keylen)
1257 {
1258         return crypto_hash_crt(hash)->setkey(hash, key, keylen);
1259 }
1260
1261 static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
1262 {
1263         return (struct crypto_comp *)tfm;
1264 }
1265
1266 static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm)
1267 {
1268         BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) &
1269                CRYPTO_ALG_TYPE_MASK);
1270         return __crypto_comp_cast(tfm);
1271 }
1272
1273 static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
1274                                                     u32 type, u32 mask)
1275 {
1276         type &= ~CRYPTO_ALG_TYPE_MASK;
1277         type |= CRYPTO_ALG_TYPE_COMPRESS;
1278         mask |= CRYPTO_ALG_TYPE_MASK;
1279
1280         return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask));
1281 }
1282
1283 static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm)
1284 {
1285         return &tfm->base;
1286 }
1287
1288 static inline void crypto_free_comp(struct crypto_comp *tfm)
1289 {
1290         crypto_free_tfm(crypto_comp_tfm(tfm));
1291 }
1292
1293 static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask)
1294 {
1295         type &= ~CRYPTO_ALG_TYPE_MASK;
1296         type |= CRYPTO_ALG_TYPE_COMPRESS;
1297         mask |= CRYPTO_ALG_TYPE_MASK;
1298
1299         return crypto_has_alg(alg_name, type, mask);
1300 }
1301
1302 static inline const char *crypto_comp_name(struct crypto_comp *tfm)
1303 {
1304         return crypto_tfm_alg_name(crypto_comp_tfm(tfm));
1305 }
1306
1307 static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm)
1308 {
1309         return &crypto_comp_tfm(tfm)->crt_compress;
1310 }
1311
1312 static inline int crypto_comp_compress(struct crypto_comp *tfm,
1313                                        const u8 *src, unsigned int slen,
1314                                        u8 *dst, unsigned int *dlen)
1315 {
1316         return crypto_comp_crt(tfm)->cot_compress(crypto_comp_tfm(tfm),
1317                                                   src, slen, dst, dlen);
1318 }
1319
1320 static inline int crypto_comp_decompress(struct crypto_comp *tfm,
1321                                          const u8 *src, unsigned int slen,
1322                                          u8 *dst, unsigned int *dlen)
1323 {
1324         return crypto_comp_crt(tfm)->cot_decompress(crypto_comp_tfm(tfm),
1325                                                     src, slen, dst, dlen);
1326 }
1327
1328 #endif  /* _LINUX_CRYPTO_H */
1329