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