crypto.h 31 KB

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