crypto.h 31 KB

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