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