crypto.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  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 int crypto_ablkcipher_reqsize(struct crypto_ablkcipher *tfm)
  521. {
  522. return crypto_ablkcipher_crt(tfm)->reqsize;
  523. }
  524. static inline void ablkcipher_request_set_tfm(
  525. struct ablkcipher_request *req, struct crypto_ablkcipher *tfm)
  526. {
  527. req->base.tfm = crypto_ablkcipher_tfm(tfm);
  528. }
  529. static inline struct ablkcipher_request *ablkcipher_request_cast(
  530. struct crypto_async_request *req)
  531. {
  532. return container_of(req, struct ablkcipher_request, base);
  533. }
  534. static inline struct ablkcipher_request *ablkcipher_request_alloc(
  535. struct crypto_ablkcipher *tfm, gfp_t gfp)
  536. {
  537. struct ablkcipher_request *req;
  538. req = kmalloc(sizeof(struct ablkcipher_request) +
  539. crypto_ablkcipher_reqsize(tfm), gfp);
  540. if (likely(req))
  541. ablkcipher_request_set_tfm(req, tfm);
  542. return req;
  543. }
  544. static inline void ablkcipher_request_free(struct ablkcipher_request *req)
  545. {
  546. kfree(req);
  547. }
  548. static inline void ablkcipher_request_set_callback(
  549. struct ablkcipher_request *req,
  550. u32 flags, crypto_completion_t complete, void *data)
  551. {
  552. req->base.complete = complete;
  553. req->base.data = data;
  554. req->base.flags = flags;
  555. }
  556. static inline void ablkcipher_request_set_crypt(
  557. struct ablkcipher_request *req,
  558. struct scatterlist *src, struct scatterlist *dst,
  559. unsigned int nbytes, void *iv)
  560. {
  561. req->src = src;
  562. req->dst = dst;
  563. req->nbytes = nbytes;
  564. req->info = iv;
  565. }
  566. static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm)
  567. {
  568. return (struct crypto_aead *)tfm;
  569. }
  570. static inline struct crypto_aead *crypto_alloc_aead(const char *alg_name,
  571. u32 type, u32 mask)
  572. {
  573. type &= ~CRYPTO_ALG_TYPE_MASK;
  574. type |= CRYPTO_ALG_TYPE_AEAD;
  575. mask |= CRYPTO_ALG_TYPE_MASK;
  576. return __crypto_aead_cast(crypto_alloc_base(alg_name, type, mask));
  577. }
  578. static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
  579. {
  580. return &tfm->base;
  581. }
  582. static inline void crypto_free_aead(struct crypto_aead *tfm)
  583. {
  584. crypto_free_tfm(crypto_aead_tfm(tfm));
  585. }
  586. static inline struct aead_tfm *crypto_aead_crt(struct crypto_aead *tfm)
  587. {
  588. return &crypto_aead_tfm(tfm)->crt_aead;
  589. }
  590. static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm)
  591. {
  592. return crypto_aead_crt(tfm)->ivsize;
  593. }
  594. static inline unsigned int crypto_aead_authsize(struct crypto_aead *tfm)
  595. {
  596. return crypto_aead_crt(tfm)->authsize;
  597. }
  598. static inline unsigned int crypto_aead_blocksize(struct crypto_aead *tfm)
  599. {
  600. return crypto_tfm_alg_blocksize(crypto_aead_tfm(tfm));
  601. }
  602. static inline unsigned int crypto_aead_alignmask(struct crypto_aead *tfm)
  603. {
  604. return crypto_tfm_alg_alignmask(crypto_aead_tfm(tfm));
  605. }
  606. static inline u32 crypto_aead_get_flags(struct crypto_aead *tfm)
  607. {
  608. return crypto_tfm_get_flags(crypto_aead_tfm(tfm));
  609. }
  610. static inline void crypto_aead_set_flags(struct crypto_aead *tfm, u32 flags)
  611. {
  612. crypto_tfm_set_flags(crypto_aead_tfm(tfm), flags);
  613. }
  614. static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags)
  615. {
  616. crypto_tfm_clear_flags(crypto_aead_tfm(tfm), flags);
  617. }
  618. static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key,
  619. unsigned int keylen)
  620. {
  621. return crypto_aead_crt(tfm)->setkey(tfm, key, keylen);
  622. }
  623. static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req)
  624. {
  625. return __crypto_aead_cast(req->base.tfm);
  626. }
  627. static inline int crypto_aead_encrypt(struct aead_request *req)
  628. {
  629. return crypto_aead_crt(crypto_aead_reqtfm(req))->encrypt(req);
  630. }
  631. static inline int crypto_aead_decrypt(struct aead_request *req)
  632. {
  633. return crypto_aead_crt(crypto_aead_reqtfm(req))->decrypt(req);
  634. }
  635. static inline int crypto_aead_reqsize(struct crypto_aead *tfm)
  636. {
  637. return crypto_aead_crt(tfm)->reqsize;
  638. }
  639. static inline void aead_request_set_tfm(struct aead_request *req,
  640. struct crypto_aead *tfm)
  641. {
  642. req->base.tfm = crypto_aead_tfm(tfm);
  643. }
  644. static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
  645. gfp_t gfp)
  646. {
  647. struct aead_request *req;
  648. req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp);
  649. if (likely(req))
  650. aead_request_set_tfm(req, tfm);
  651. return req;
  652. }
  653. static inline void aead_request_free(struct aead_request *req)
  654. {
  655. kfree(req);
  656. }
  657. static inline void aead_request_set_callback(struct aead_request *req,
  658. u32 flags,
  659. crypto_completion_t complete,
  660. void *data)
  661. {
  662. req->base.complete = complete;
  663. req->base.data = data;
  664. req->base.flags = flags;
  665. }
  666. static inline void aead_request_set_crypt(struct aead_request *req,
  667. struct scatterlist *src,
  668. struct scatterlist *dst,
  669. unsigned int cryptlen, u8 *iv)
  670. {
  671. req->src = src;
  672. req->dst = dst;
  673. req->cryptlen = cryptlen;
  674. req->iv = iv;
  675. }
  676. static inline void aead_request_set_assoc(struct aead_request *req,
  677. struct scatterlist *assoc,
  678. unsigned int assoclen)
  679. {
  680. req->assoc = assoc;
  681. req->assoclen = assoclen;
  682. }
  683. static inline struct crypto_blkcipher *__crypto_blkcipher_cast(
  684. struct crypto_tfm *tfm)
  685. {
  686. return (struct crypto_blkcipher *)tfm;
  687. }
  688. static inline struct crypto_blkcipher *crypto_blkcipher_cast(
  689. struct crypto_tfm *tfm)
  690. {
  691. BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_BLKCIPHER);
  692. return __crypto_blkcipher_cast(tfm);
  693. }
  694. static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
  695. const char *alg_name, u32 type, u32 mask)
  696. {
  697. type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
  698. type |= CRYPTO_ALG_TYPE_BLKCIPHER;
  699. mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC;
  700. return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask));
  701. }
  702. static inline struct crypto_tfm *crypto_blkcipher_tfm(
  703. struct crypto_blkcipher *tfm)
  704. {
  705. return &tfm->base;
  706. }
  707. static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
  708. {
  709. crypto_free_tfm(crypto_blkcipher_tfm(tfm));
  710. }
  711. static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask)
  712. {
  713. type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
  714. type |= CRYPTO_ALG_TYPE_BLKCIPHER;
  715. mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC;
  716. return crypto_has_alg(alg_name, type, mask);
  717. }
  718. static inline const char *crypto_blkcipher_name(struct crypto_blkcipher *tfm)
  719. {
  720. return crypto_tfm_alg_name(crypto_blkcipher_tfm(tfm));
  721. }
  722. static inline struct blkcipher_tfm *crypto_blkcipher_crt(
  723. struct crypto_blkcipher *tfm)
  724. {
  725. return &crypto_blkcipher_tfm(tfm)->crt_blkcipher;
  726. }
  727. static inline struct blkcipher_alg *crypto_blkcipher_alg(
  728. struct crypto_blkcipher *tfm)
  729. {
  730. return &crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher;
  731. }
  732. static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm)
  733. {
  734. return crypto_blkcipher_alg(tfm)->ivsize;
  735. }
  736. static inline unsigned int crypto_blkcipher_blocksize(
  737. struct crypto_blkcipher *tfm)
  738. {
  739. return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm));
  740. }
  741. static inline unsigned int crypto_blkcipher_alignmask(
  742. struct crypto_blkcipher *tfm)
  743. {
  744. return crypto_tfm_alg_alignmask(crypto_blkcipher_tfm(tfm));
  745. }
  746. static inline u32 crypto_blkcipher_get_flags(struct crypto_blkcipher *tfm)
  747. {
  748. return crypto_tfm_get_flags(crypto_blkcipher_tfm(tfm));
  749. }
  750. static inline void crypto_blkcipher_set_flags(struct crypto_blkcipher *tfm,
  751. u32 flags)
  752. {
  753. crypto_tfm_set_flags(crypto_blkcipher_tfm(tfm), flags);
  754. }
  755. static inline void crypto_blkcipher_clear_flags(struct crypto_blkcipher *tfm,
  756. u32 flags)
  757. {
  758. crypto_tfm_clear_flags(crypto_blkcipher_tfm(tfm), flags);
  759. }
  760. static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm,
  761. const u8 *key, unsigned int keylen)
  762. {
  763. return crypto_blkcipher_crt(tfm)->setkey(crypto_blkcipher_tfm(tfm),
  764. key, keylen);
  765. }
  766. static inline int crypto_blkcipher_encrypt(struct blkcipher_desc *desc,
  767. struct scatterlist *dst,
  768. struct scatterlist *src,
  769. unsigned int nbytes)
  770. {
  771. desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
  772. return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
  773. }
  774. static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc,
  775. struct scatterlist *dst,
  776. struct scatterlist *src,
  777. unsigned int nbytes)
  778. {
  779. return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
  780. }
  781. static inline int crypto_blkcipher_decrypt(struct blkcipher_desc *desc,
  782. struct scatterlist *dst,
  783. struct scatterlist *src,
  784. unsigned int nbytes)
  785. {
  786. desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
  787. return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
  788. }
  789. static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc,
  790. struct scatterlist *dst,
  791. struct scatterlist *src,
  792. unsigned int nbytes)
  793. {
  794. return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
  795. }
  796. static inline void crypto_blkcipher_set_iv(struct crypto_blkcipher *tfm,
  797. const u8 *src, unsigned int len)
  798. {
  799. memcpy(crypto_blkcipher_crt(tfm)->iv, src, len);
  800. }
  801. static inline void crypto_blkcipher_get_iv(struct crypto_blkcipher *tfm,
  802. u8 *dst, unsigned int len)
  803. {
  804. memcpy(dst, crypto_blkcipher_crt(tfm)->iv, len);
  805. }
  806. static inline struct crypto_cipher *__crypto_cipher_cast(struct crypto_tfm *tfm)
  807. {
  808. return (struct crypto_cipher *)tfm;
  809. }
  810. static inline struct crypto_cipher *crypto_cipher_cast(struct crypto_tfm *tfm)
  811. {
  812. BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
  813. return __crypto_cipher_cast(tfm);
  814. }
  815. static inline struct crypto_cipher *crypto_alloc_cipher(const char *alg_name,
  816. u32 type, u32 mask)
  817. {
  818. type &= ~CRYPTO_ALG_TYPE_MASK;
  819. type |= CRYPTO_ALG_TYPE_CIPHER;
  820. mask |= CRYPTO_ALG_TYPE_MASK;
  821. return __crypto_cipher_cast(crypto_alloc_base(alg_name, type, mask));
  822. }
  823. static inline struct crypto_tfm *crypto_cipher_tfm(struct crypto_cipher *tfm)
  824. {
  825. return &tfm->base;
  826. }
  827. static inline void crypto_free_cipher(struct crypto_cipher *tfm)
  828. {
  829. crypto_free_tfm(crypto_cipher_tfm(tfm));
  830. }
  831. static inline int crypto_has_cipher(const char *alg_name, u32 type, u32 mask)
  832. {
  833. type &= ~CRYPTO_ALG_TYPE_MASK;
  834. type |= CRYPTO_ALG_TYPE_CIPHER;
  835. mask |= CRYPTO_ALG_TYPE_MASK;
  836. return crypto_has_alg(alg_name, type, mask);
  837. }
  838. static inline struct cipher_tfm *crypto_cipher_crt(struct crypto_cipher *tfm)
  839. {
  840. return &crypto_cipher_tfm(tfm)->crt_cipher;
  841. }
  842. static inline unsigned int crypto_cipher_blocksize(struct crypto_cipher *tfm)
  843. {
  844. return crypto_tfm_alg_blocksize(crypto_cipher_tfm(tfm));
  845. }
  846. static inline unsigned int crypto_cipher_alignmask(struct crypto_cipher *tfm)
  847. {
  848. return crypto_tfm_alg_alignmask(crypto_cipher_tfm(tfm));
  849. }
  850. static inline u32 crypto_cipher_get_flags(struct crypto_cipher *tfm)
  851. {
  852. return crypto_tfm_get_flags(crypto_cipher_tfm(tfm));
  853. }
  854. static inline void crypto_cipher_set_flags(struct crypto_cipher *tfm,
  855. u32 flags)
  856. {
  857. crypto_tfm_set_flags(crypto_cipher_tfm(tfm), flags);
  858. }
  859. static inline void crypto_cipher_clear_flags(struct crypto_cipher *tfm,
  860. u32 flags)
  861. {
  862. crypto_tfm_clear_flags(crypto_cipher_tfm(tfm), flags);
  863. }
  864. static inline int crypto_cipher_setkey(struct crypto_cipher *tfm,
  865. const u8 *key, unsigned int keylen)
  866. {
  867. return crypto_cipher_crt(tfm)->cit_setkey(crypto_cipher_tfm(tfm),
  868. key, keylen);
  869. }
  870. static inline void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
  871. u8 *dst, const u8 *src)
  872. {
  873. crypto_cipher_crt(tfm)->cit_encrypt_one(crypto_cipher_tfm(tfm),
  874. dst, src);
  875. }
  876. static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
  877. u8 *dst, const u8 *src)
  878. {
  879. crypto_cipher_crt(tfm)->cit_decrypt_one(crypto_cipher_tfm(tfm),
  880. dst, src);
  881. }
  882. static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm)
  883. {
  884. return (struct crypto_hash *)tfm;
  885. }
  886. static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm)
  887. {
  888. BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_HASH) &
  889. CRYPTO_ALG_TYPE_HASH_MASK);
  890. return __crypto_hash_cast(tfm);
  891. }
  892. static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
  893. u32 type, u32 mask)
  894. {
  895. type &= ~CRYPTO_ALG_TYPE_MASK;
  896. type |= CRYPTO_ALG_TYPE_HASH;
  897. mask |= CRYPTO_ALG_TYPE_HASH_MASK;
  898. return __crypto_hash_cast(crypto_alloc_base(alg_name, type, mask));
  899. }
  900. static inline struct crypto_tfm *crypto_hash_tfm(struct crypto_hash *tfm)
  901. {
  902. return &tfm->base;
  903. }
  904. static inline void crypto_free_hash(struct crypto_hash *tfm)
  905. {
  906. crypto_free_tfm(crypto_hash_tfm(tfm));
  907. }
  908. static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask)
  909. {
  910. type &= ~CRYPTO_ALG_TYPE_MASK;
  911. type |= CRYPTO_ALG_TYPE_HASH;
  912. mask |= CRYPTO_ALG_TYPE_HASH_MASK;
  913. return crypto_has_alg(alg_name, type, mask);
  914. }
  915. static inline struct hash_tfm *crypto_hash_crt(struct crypto_hash *tfm)
  916. {
  917. return &crypto_hash_tfm(tfm)->crt_hash;
  918. }
  919. static inline unsigned int crypto_hash_blocksize(struct crypto_hash *tfm)
  920. {
  921. return crypto_tfm_alg_blocksize(crypto_hash_tfm(tfm));
  922. }
  923. static inline unsigned int crypto_hash_alignmask(struct crypto_hash *tfm)
  924. {
  925. return crypto_tfm_alg_alignmask(crypto_hash_tfm(tfm));
  926. }
  927. static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm)
  928. {
  929. return crypto_hash_crt(tfm)->digestsize;
  930. }
  931. static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm)
  932. {
  933. return crypto_tfm_get_flags(crypto_hash_tfm(tfm));
  934. }
  935. static inline void crypto_hash_set_flags(struct crypto_hash *tfm, u32 flags)
  936. {
  937. crypto_tfm_set_flags(crypto_hash_tfm(tfm), flags);
  938. }
  939. static inline void crypto_hash_clear_flags(struct crypto_hash *tfm, u32 flags)
  940. {
  941. crypto_tfm_clear_flags(crypto_hash_tfm(tfm), flags);
  942. }
  943. static inline int crypto_hash_init(struct hash_desc *desc)
  944. {
  945. return crypto_hash_crt(desc->tfm)->init(desc);
  946. }
  947. static inline int crypto_hash_update(struct hash_desc *desc,
  948. struct scatterlist *sg,
  949. unsigned int nbytes)
  950. {
  951. return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes);
  952. }
  953. static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
  954. {
  955. return crypto_hash_crt(desc->tfm)->final(desc, out);
  956. }
  957. static inline int crypto_hash_digest(struct hash_desc *desc,
  958. struct scatterlist *sg,
  959. unsigned int nbytes, u8 *out)
  960. {
  961. return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out);
  962. }
  963. static inline int crypto_hash_setkey(struct crypto_hash *hash,
  964. const u8 *key, unsigned int keylen)
  965. {
  966. return crypto_hash_crt(hash)->setkey(hash, key, keylen);
  967. }
  968. static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
  969. {
  970. return (struct crypto_comp *)tfm;
  971. }
  972. static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm)
  973. {
  974. BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) &
  975. CRYPTO_ALG_TYPE_MASK);
  976. return __crypto_comp_cast(tfm);
  977. }
  978. static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
  979. u32 type, u32 mask)
  980. {
  981. type &= ~CRYPTO_ALG_TYPE_MASK;
  982. type |= CRYPTO_ALG_TYPE_COMPRESS;
  983. mask |= CRYPTO_ALG_TYPE_MASK;
  984. return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask));
  985. }
  986. static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm)
  987. {
  988. return &tfm->base;
  989. }
  990. static inline void crypto_free_comp(struct crypto_comp *tfm)
  991. {
  992. crypto_free_tfm(crypto_comp_tfm(tfm));
  993. }
  994. static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask)
  995. {
  996. type &= ~CRYPTO_ALG_TYPE_MASK;
  997. type |= CRYPTO_ALG_TYPE_COMPRESS;
  998. mask |= CRYPTO_ALG_TYPE_MASK;
  999. return crypto_has_alg(alg_name, type, mask);
  1000. }
  1001. static inline const char *crypto_comp_name(struct crypto_comp *tfm)
  1002. {
  1003. return crypto_tfm_alg_name(crypto_comp_tfm(tfm));
  1004. }
  1005. static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm)
  1006. {
  1007. return &crypto_comp_tfm(tfm)->crt_compress;
  1008. }
  1009. static inline int crypto_comp_compress(struct crypto_comp *tfm,
  1010. const u8 *src, unsigned int slen,
  1011. u8 *dst, unsigned int *dlen)
  1012. {
  1013. return crypto_comp_crt(tfm)->cot_compress(crypto_comp_tfm(tfm),
  1014. src, slen, dst, dlen);
  1015. }
  1016. static inline int crypto_comp_decompress(struct crypto_comp *tfm,
  1017. const u8 *src, unsigned int slen,
  1018. u8 *dst, unsigned int *dlen)
  1019. {
  1020. return crypto_comp_crt(tfm)->cot_decompress(crypto_comp_tfm(tfm),
  1021. src, slen, dst, dlen);
  1022. }
  1023. #endif /* _LINUX_CRYPTO_H */