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