crypto.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  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_ABLKCIPHER 0x00000005
  35. #define CRYPTO_ALG_TYPE_COMPRESS 0x00000008
  36. #define CRYPTO_ALG_TYPE_AEAD 0x00000009
  37. #define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e
  38. #define CRYPTO_ALG_TYPE_BLKCIPHER_MASK 0x0000000c
  39. #define CRYPTO_ALG_LARVAL 0x00000010
  40. #define CRYPTO_ALG_DEAD 0x00000020
  41. #define CRYPTO_ALG_DYING 0x00000040
  42. #define CRYPTO_ALG_ASYNC 0x00000080
  43. /*
  44. * Set this bit if and only if the algorithm requires another algorithm of
  45. * the same type to handle corner cases.
  46. */
  47. #define CRYPTO_ALG_NEED_FALLBACK 0x00000100
  48. /*
  49. * Transform masks and values (for crt_flags).
  50. */
  51. #define CRYPTO_TFM_REQ_MASK 0x000fff00
  52. #define CRYPTO_TFM_RES_MASK 0xfff00000
  53. #define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
  54. #define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200
  55. #define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
  56. #define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
  57. #define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
  58. #define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
  59. #define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
  60. #define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
  61. /*
  62. * Miscellaneous stuff.
  63. */
  64. #define CRYPTO_MAX_ALG_NAME 64
  65. /*
  66. * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual
  67. * declaration) is used to ensure that the crypto_tfm context structure is
  68. * aligned correctly for the given architecture so that there are no alignment
  69. * faults for C data types. In particular, this is required on platforms such
  70. * as arm where pointers are 32-bit aligned but there are data types such as
  71. * u64 which require 64-bit alignment.
  72. */
  73. #if defined(ARCH_KMALLOC_MINALIGN)
  74. #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN
  75. #elif defined(ARCH_SLAB_MINALIGN)
  76. #define CRYPTO_MINALIGN ARCH_SLAB_MINALIGN
  77. #endif
  78. #ifdef CRYPTO_MINALIGN
  79. #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN)))
  80. #else
  81. #define CRYPTO_MINALIGN_ATTR
  82. #endif
  83. struct scatterlist;
  84. struct crypto_ablkcipher;
  85. struct crypto_async_request;
  86. struct crypto_aead;
  87. struct crypto_blkcipher;
  88. struct crypto_hash;
  89. struct crypto_tfm;
  90. struct crypto_type;
  91. typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);
  92. struct crypto_async_request {
  93. struct list_head list;
  94. crypto_completion_t complete;
  95. void *data;
  96. struct crypto_tfm *tfm;
  97. u32 flags;
  98. };
  99. struct ablkcipher_request {
  100. struct crypto_async_request base;
  101. unsigned int nbytes;
  102. void *info;
  103. struct scatterlist *src;
  104. struct scatterlist *dst;
  105. void *__ctx[] CRYPTO_MINALIGN_ATTR;
  106. };
  107. /**
  108. * struct aead_request - AEAD request
  109. * @base: Common attributes for async crypto requests
  110. * @assoclen: Length in bytes of associated data for authentication
  111. * @cryptlen: Length of data to be encrypted or decrypted
  112. * @iv: Initialisation vector
  113. * @assoc: Associated data
  114. * @src: Source data
  115. * @dst: Destination data
  116. * @__ctx: Start of private context data
  117. */
  118. struct aead_request {
  119. struct crypto_async_request base;
  120. unsigned int assoclen;
  121. unsigned int cryptlen;
  122. u8 *iv;
  123. struct scatterlist *assoc;
  124. struct scatterlist *src;
  125. struct scatterlist *dst;
  126. void *__ctx[] CRYPTO_MINALIGN_ATTR;
  127. };
  128. struct blkcipher_desc {
  129. struct crypto_blkcipher *tfm;
  130. void *info;
  131. u32 flags;
  132. };
  133. struct cipher_desc {
  134. struct crypto_tfm *tfm;
  135. void (*crfn)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
  136. unsigned int (*prfn)(const struct cipher_desc *desc, u8 *dst,
  137. const u8 *src, unsigned int nbytes);
  138. void *info;
  139. };
  140. struct hash_desc {
  141. struct crypto_hash *tfm;
  142. u32 flags;
  143. };
  144. /*
  145. * Algorithms: modular crypto algorithm implementations, managed
  146. * via crypto_register_alg() and crypto_unregister_alg().
  147. */
  148. struct ablkcipher_alg {
  149. int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key,
  150. unsigned int keylen);
  151. int (*encrypt)(struct ablkcipher_request *req);
  152. int (*decrypt)(struct ablkcipher_request *req);
  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_U32,
  359. __CRYPTOA_MAX,
  360. };
  361. #define CRYPTOA_MAX (__CRYPTOA_MAX - 1)
  362. /* Maximum number of (rtattr) parameters for each template. */
  363. #define CRYPTO_MAX_ATTRS 32
  364. struct crypto_attr_alg {
  365. char name[CRYPTO_MAX_ALG_NAME];
  366. };
  367. struct crypto_attr_type {
  368. u32 type;
  369. u32 mask;
  370. };
  371. struct crypto_attr_u32 {
  372. u32 num;
  373. };
  374. /*
  375. * Transform user interface.
  376. */
  377. struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
  378. struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
  379. void crypto_free_tfm(struct crypto_tfm *tfm);
  380. /*
  381. * Transform helpers which query the underlying algorithm.
  382. */
  383. static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm)
  384. {
  385. return tfm->__crt_alg->cra_name;
  386. }
  387. static inline const char *crypto_tfm_alg_driver_name(struct crypto_tfm *tfm)
  388. {
  389. return tfm->__crt_alg->cra_driver_name;
  390. }
  391. static inline int crypto_tfm_alg_priority(struct crypto_tfm *tfm)
  392. {
  393. return tfm->__crt_alg->cra_priority;
  394. }
  395. static inline const char *crypto_tfm_alg_modname(struct crypto_tfm *tfm)
  396. {
  397. return module_name(tfm->__crt_alg->cra_module);
  398. }
  399. static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
  400. {
  401. return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
  402. }
  403. static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
  404. {
  405. return tfm->__crt_alg->cra_blocksize;
  406. }
  407. static inline unsigned int crypto_tfm_alg_alignmask(struct crypto_tfm *tfm)
  408. {
  409. return tfm->__crt_alg->cra_alignmask;
  410. }
  411. static inline u32 crypto_tfm_get_flags(struct crypto_tfm *tfm)
  412. {
  413. return tfm->crt_flags;
  414. }
  415. static inline void crypto_tfm_set_flags(struct crypto_tfm *tfm, u32 flags)
  416. {
  417. tfm->crt_flags |= flags;
  418. }
  419. static inline void crypto_tfm_clear_flags(struct crypto_tfm *tfm, u32 flags)
  420. {
  421. tfm->crt_flags &= ~flags;
  422. }
  423. static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
  424. {
  425. return tfm->__crt_ctx;
  426. }
  427. static inline unsigned int crypto_tfm_ctx_alignment(void)
  428. {
  429. struct crypto_tfm *tfm;
  430. return __alignof__(tfm->__crt_ctx);
  431. }
  432. /*
  433. * API wrappers.
  434. */
  435. static inline struct crypto_ablkcipher *__crypto_ablkcipher_cast(
  436. struct crypto_tfm *tfm)
  437. {
  438. return (struct crypto_ablkcipher *)tfm;
  439. }
  440. static inline struct crypto_ablkcipher *crypto_alloc_ablkcipher(
  441. const char *alg_name, u32 type, u32 mask)
  442. {
  443. type &= ~CRYPTO_ALG_TYPE_MASK;
  444. type |= CRYPTO_ALG_TYPE_BLKCIPHER;
  445. mask |= CRYPTO_ALG_TYPE_BLKCIPHER_MASK;
  446. return __crypto_ablkcipher_cast(
  447. crypto_alloc_base(alg_name, type, mask));
  448. }
  449. static inline struct crypto_tfm *crypto_ablkcipher_tfm(
  450. struct crypto_ablkcipher *tfm)
  451. {
  452. return &tfm->base;
  453. }
  454. static inline void crypto_free_ablkcipher(struct crypto_ablkcipher *tfm)
  455. {
  456. crypto_free_tfm(crypto_ablkcipher_tfm(tfm));
  457. }
  458. static inline int crypto_has_ablkcipher(const char *alg_name, u32 type,
  459. u32 mask)
  460. {
  461. type &= ~CRYPTO_ALG_TYPE_MASK;
  462. type |= CRYPTO_ALG_TYPE_BLKCIPHER;
  463. mask |= CRYPTO_ALG_TYPE_BLKCIPHER_MASK;
  464. return crypto_has_alg(alg_name, type, mask);
  465. }
  466. static inline struct ablkcipher_tfm *crypto_ablkcipher_crt(
  467. struct crypto_ablkcipher *tfm)
  468. {
  469. return &crypto_ablkcipher_tfm(tfm)->crt_ablkcipher;
  470. }
  471. static inline unsigned int crypto_ablkcipher_ivsize(
  472. struct crypto_ablkcipher *tfm)
  473. {
  474. return crypto_ablkcipher_crt(tfm)->ivsize;
  475. }
  476. static inline unsigned int crypto_ablkcipher_blocksize(
  477. struct crypto_ablkcipher *tfm)
  478. {
  479. return crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(tfm));
  480. }
  481. static inline unsigned int crypto_ablkcipher_alignmask(
  482. struct crypto_ablkcipher *tfm)
  483. {
  484. return crypto_tfm_alg_alignmask(crypto_ablkcipher_tfm(tfm));
  485. }
  486. static inline u32 crypto_ablkcipher_get_flags(struct crypto_ablkcipher *tfm)
  487. {
  488. return crypto_tfm_get_flags(crypto_ablkcipher_tfm(tfm));
  489. }
  490. static inline void crypto_ablkcipher_set_flags(struct crypto_ablkcipher *tfm,
  491. u32 flags)
  492. {
  493. crypto_tfm_set_flags(crypto_ablkcipher_tfm(tfm), flags);
  494. }
  495. static inline void crypto_ablkcipher_clear_flags(struct crypto_ablkcipher *tfm,
  496. u32 flags)
  497. {
  498. crypto_tfm_clear_flags(crypto_ablkcipher_tfm(tfm), flags);
  499. }
  500. static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm,
  501. const u8 *key, unsigned int keylen)
  502. {
  503. return crypto_ablkcipher_crt(tfm)->setkey(tfm, key, keylen);
  504. }
  505. static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm(
  506. struct ablkcipher_request *req)
  507. {
  508. return __crypto_ablkcipher_cast(req->base.tfm);
  509. }
  510. static inline int crypto_ablkcipher_encrypt(struct ablkcipher_request *req)
  511. {
  512. struct ablkcipher_tfm *crt =
  513. crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req));
  514. return crt->encrypt(req);
  515. }
  516. static inline int crypto_ablkcipher_decrypt(struct ablkcipher_request *req)
  517. {
  518. struct ablkcipher_tfm *crt =
  519. crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req));
  520. return crt->decrypt(req);
  521. }
  522. static inline unsigned int crypto_ablkcipher_reqsize(
  523. struct crypto_ablkcipher *tfm)
  524. {
  525. return crypto_ablkcipher_crt(tfm)->reqsize;
  526. }
  527. static inline void ablkcipher_request_set_tfm(
  528. struct ablkcipher_request *req, struct crypto_ablkcipher *tfm)
  529. {
  530. req->base.tfm = crypto_ablkcipher_tfm(tfm);
  531. }
  532. static inline struct ablkcipher_request *ablkcipher_request_cast(
  533. struct crypto_async_request *req)
  534. {
  535. return container_of(req, struct ablkcipher_request, base);
  536. }
  537. static inline struct ablkcipher_request *ablkcipher_request_alloc(
  538. struct crypto_ablkcipher *tfm, gfp_t gfp)
  539. {
  540. struct ablkcipher_request *req;
  541. req = kmalloc(sizeof(struct ablkcipher_request) +
  542. crypto_ablkcipher_reqsize(tfm), gfp);
  543. if (likely(req))
  544. ablkcipher_request_set_tfm(req, tfm);
  545. return req;
  546. }
  547. static inline void ablkcipher_request_free(struct ablkcipher_request *req)
  548. {
  549. kfree(req);
  550. }
  551. static inline void ablkcipher_request_set_callback(
  552. struct ablkcipher_request *req,
  553. u32 flags, crypto_completion_t complete, void *data)
  554. {
  555. req->base.complete = complete;
  556. req->base.data = data;
  557. req->base.flags = flags;
  558. }
  559. static inline void ablkcipher_request_set_crypt(
  560. struct ablkcipher_request *req,
  561. struct scatterlist *src, struct scatterlist *dst,
  562. unsigned int nbytes, void *iv)
  563. {
  564. req->src = src;
  565. req->dst = dst;
  566. req->nbytes = nbytes;
  567. req->info = iv;
  568. }
  569. static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm)
  570. {
  571. return (struct crypto_aead *)tfm;
  572. }
  573. static inline struct crypto_aead *crypto_alloc_aead(const char *alg_name,
  574. u32 type, u32 mask)
  575. {
  576. type &= ~CRYPTO_ALG_TYPE_MASK;
  577. type |= CRYPTO_ALG_TYPE_AEAD;
  578. mask |= CRYPTO_ALG_TYPE_MASK;
  579. return __crypto_aead_cast(crypto_alloc_base(alg_name, type, mask));
  580. }
  581. static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
  582. {
  583. return &tfm->base;
  584. }
  585. static inline void crypto_free_aead(struct crypto_aead *tfm)
  586. {
  587. crypto_free_tfm(crypto_aead_tfm(tfm));
  588. }
  589. static inline struct aead_tfm *crypto_aead_crt(struct crypto_aead *tfm)
  590. {
  591. return &crypto_aead_tfm(tfm)->crt_aead;
  592. }
  593. static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm)
  594. {
  595. return crypto_aead_crt(tfm)->ivsize;
  596. }
  597. static inline unsigned int crypto_aead_authsize(struct crypto_aead *tfm)
  598. {
  599. return crypto_aead_crt(tfm)->authsize;
  600. }
  601. static inline unsigned int crypto_aead_blocksize(struct crypto_aead *tfm)
  602. {
  603. return crypto_tfm_alg_blocksize(crypto_aead_tfm(tfm));
  604. }
  605. static inline unsigned int crypto_aead_alignmask(struct crypto_aead *tfm)
  606. {
  607. return crypto_tfm_alg_alignmask(crypto_aead_tfm(tfm));
  608. }
  609. static inline u32 crypto_aead_get_flags(struct crypto_aead *tfm)
  610. {
  611. return crypto_tfm_get_flags(crypto_aead_tfm(tfm));
  612. }
  613. static inline void crypto_aead_set_flags(struct crypto_aead *tfm, u32 flags)
  614. {
  615. crypto_tfm_set_flags(crypto_aead_tfm(tfm), flags);
  616. }
  617. static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags)
  618. {
  619. crypto_tfm_clear_flags(crypto_aead_tfm(tfm), flags);
  620. }
  621. static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key,
  622. unsigned int keylen)
  623. {
  624. return crypto_aead_crt(tfm)->setkey(tfm, key, keylen);
  625. }
  626. static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req)
  627. {
  628. return __crypto_aead_cast(req->base.tfm);
  629. }
  630. static inline int crypto_aead_encrypt(struct aead_request *req)
  631. {
  632. return crypto_aead_crt(crypto_aead_reqtfm(req))->encrypt(req);
  633. }
  634. static inline int crypto_aead_decrypt(struct aead_request *req)
  635. {
  636. return crypto_aead_crt(crypto_aead_reqtfm(req))->decrypt(req);
  637. }
  638. static inline unsigned int crypto_aead_reqsize(struct crypto_aead *tfm)
  639. {
  640. return crypto_aead_crt(tfm)->reqsize;
  641. }
  642. static inline void aead_request_set_tfm(struct aead_request *req,
  643. struct crypto_aead *tfm)
  644. {
  645. req->base.tfm = crypto_aead_tfm(tfm);
  646. }
  647. static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
  648. gfp_t gfp)
  649. {
  650. struct aead_request *req;
  651. req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp);
  652. if (likely(req))
  653. aead_request_set_tfm(req, tfm);
  654. return req;
  655. }
  656. static inline void aead_request_free(struct aead_request *req)
  657. {
  658. kfree(req);
  659. }
  660. static inline void aead_request_set_callback(struct aead_request *req,
  661. u32 flags,
  662. crypto_completion_t complete,
  663. void *data)
  664. {
  665. req->base.complete = complete;
  666. req->base.data = data;
  667. req->base.flags = flags;
  668. }
  669. static inline void aead_request_set_crypt(struct aead_request *req,
  670. struct scatterlist *src,
  671. struct scatterlist *dst,
  672. unsigned int cryptlen, u8 *iv)
  673. {
  674. req->src = src;
  675. req->dst = dst;
  676. req->cryptlen = cryptlen;
  677. req->iv = iv;
  678. }
  679. static inline void aead_request_set_assoc(struct aead_request *req,
  680. struct scatterlist *assoc,
  681. unsigned int assoclen)
  682. {
  683. req->assoc = assoc;
  684. req->assoclen = assoclen;
  685. }
  686. static inline struct crypto_blkcipher *__crypto_blkcipher_cast(
  687. struct crypto_tfm *tfm)
  688. {
  689. return (struct crypto_blkcipher *)tfm;
  690. }
  691. static inline struct crypto_blkcipher *crypto_blkcipher_cast(
  692. struct crypto_tfm *tfm)
  693. {
  694. BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_BLKCIPHER);
  695. return __crypto_blkcipher_cast(tfm);
  696. }
  697. static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
  698. const char *alg_name, u32 type, u32 mask)
  699. {
  700. type &= ~CRYPTO_ALG_TYPE_MASK;
  701. type |= CRYPTO_ALG_TYPE_BLKCIPHER;
  702. mask |= CRYPTO_ALG_TYPE_MASK;
  703. return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask));
  704. }
  705. static inline struct crypto_tfm *crypto_blkcipher_tfm(
  706. struct crypto_blkcipher *tfm)
  707. {
  708. return &tfm->base;
  709. }
  710. static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
  711. {
  712. crypto_free_tfm(crypto_blkcipher_tfm(tfm));
  713. }
  714. static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask)
  715. {
  716. type &= ~CRYPTO_ALG_TYPE_MASK;
  717. type |= CRYPTO_ALG_TYPE_BLKCIPHER;
  718. mask |= CRYPTO_ALG_TYPE_MASK;
  719. return crypto_has_alg(alg_name, type, mask);
  720. }
  721. static inline const char *crypto_blkcipher_name(struct crypto_blkcipher *tfm)
  722. {
  723. return crypto_tfm_alg_name(crypto_blkcipher_tfm(tfm));
  724. }
  725. static inline struct blkcipher_tfm *crypto_blkcipher_crt(
  726. struct crypto_blkcipher *tfm)
  727. {
  728. return &crypto_blkcipher_tfm(tfm)->crt_blkcipher;
  729. }
  730. static inline struct blkcipher_alg *crypto_blkcipher_alg(
  731. struct crypto_blkcipher *tfm)
  732. {
  733. return &crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher;
  734. }
  735. static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm)
  736. {
  737. return crypto_blkcipher_alg(tfm)->ivsize;
  738. }
  739. static inline unsigned int crypto_blkcipher_blocksize(
  740. struct crypto_blkcipher *tfm)
  741. {
  742. return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm));
  743. }
  744. static inline unsigned int crypto_blkcipher_alignmask(
  745. struct crypto_blkcipher *tfm)
  746. {
  747. return crypto_tfm_alg_alignmask(crypto_blkcipher_tfm(tfm));
  748. }
  749. static inline u32 crypto_blkcipher_get_flags(struct crypto_blkcipher *tfm)
  750. {
  751. return crypto_tfm_get_flags(crypto_blkcipher_tfm(tfm));
  752. }
  753. static inline void crypto_blkcipher_set_flags(struct crypto_blkcipher *tfm,
  754. u32 flags)
  755. {
  756. crypto_tfm_set_flags(crypto_blkcipher_tfm(tfm), flags);
  757. }
  758. static inline void crypto_blkcipher_clear_flags(struct crypto_blkcipher *tfm,
  759. u32 flags)
  760. {
  761. crypto_tfm_clear_flags(crypto_blkcipher_tfm(tfm), flags);
  762. }
  763. static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm,
  764. const u8 *key, unsigned int keylen)
  765. {
  766. return crypto_blkcipher_crt(tfm)->setkey(crypto_blkcipher_tfm(tfm),
  767. key, keylen);
  768. }
  769. static inline int crypto_blkcipher_encrypt(struct blkcipher_desc *desc,
  770. struct scatterlist *dst,
  771. struct scatterlist *src,
  772. unsigned int nbytes)
  773. {
  774. desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
  775. return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
  776. }
  777. static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc,
  778. struct scatterlist *dst,
  779. struct scatterlist *src,
  780. unsigned int nbytes)
  781. {
  782. return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
  783. }
  784. static inline int crypto_blkcipher_decrypt(struct blkcipher_desc *desc,
  785. struct scatterlist *dst,
  786. struct scatterlist *src,
  787. unsigned int nbytes)
  788. {
  789. desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
  790. return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
  791. }
  792. static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc,
  793. struct scatterlist *dst,
  794. struct scatterlist *src,
  795. unsigned int nbytes)
  796. {
  797. return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
  798. }
  799. static inline void crypto_blkcipher_set_iv(struct crypto_blkcipher *tfm,
  800. const u8 *src, unsigned int len)
  801. {
  802. memcpy(crypto_blkcipher_crt(tfm)->iv, src, len);
  803. }
  804. static inline void crypto_blkcipher_get_iv(struct crypto_blkcipher *tfm,
  805. u8 *dst, unsigned int len)
  806. {
  807. memcpy(dst, crypto_blkcipher_crt(tfm)->iv, len);
  808. }
  809. static inline struct crypto_cipher *__crypto_cipher_cast(struct crypto_tfm *tfm)
  810. {
  811. return (struct crypto_cipher *)tfm;
  812. }
  813. static inline struct crypto_cipher *crypto_cipher_cast(struct crypto_tfm *tfm)
  814. {
  815. BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
  816. return __crypto_cipher_cast(tfm);
  817. }
  818. static inline struct crypto_cipher *crypto_alloc_cipher(const char *alg_name,
  819. u32 type, u32 mask)
  820. {
  821. type &= ~CRYPTO_ALG_TYPE_MASK;
  822. type |= CRYPTO_ALG_TYPE_CIPHER;
  823. mask |= CRYPTO_ALG_TYPE_MASK;
  824. return __crypto_cipher_cast(crypto_alloc_base(alg_name, type, mask));
  825. }
  826. static inline struct crypto_tfm *crypto_cipher_tfm(struct crypto_cipher *tfm)
  827. {
  828. return &tfm->base;
  829. }
  830. static inline void crypto_free_cipher(struct crypto_cipher *tfm)
  831. {
  832. crypto_free_tfm(crypto_cipher_tfm(tfm));
  833. }
  834. static inline int crypto_has_cipher(const char *alg_name, u32 type, u32 mask)
  835. {
  836. type &= ~CRYPTO_ALG_TYPE_MASK;
  837. type |= CRYPTO_ALG_TYPE_CIPHER;
  838. mask |= CRYPTO_ALG_TYPE_MASK;
  839. return crypto_has_alg(alg_name, type, mask);
  840. }
  841. static inline struct cipher_tfm *crypto_cipher_crt(struct crypto_cipher *tfm)
  842. {
  843. return &crypto_cipher_tfm(tfm)->crt_cipher;
  844. }
  845. static inline unsigned int crypto_cipher_blocksize(struct crypto_cipher *tfm)
  846. {
  847. return crypto_tfm_alg_blocksize(crypto_cipher_tfm(tfm));
  848. }
  849. static inline unsigned int crypto_cipher_alignmask(struct crypto_cipher *tfm)
  850. {
  851. return crypto_tfm_alg_alignmask(crypto_cipher_tfm(tfm));
  852. }
  853. static inline u32 crypto_cipher_get_flags(struct crypto_cipher *tfm)
  854. {
  855. return crypto_tfm_get_flags(crypto_cipher_tfm(tfm));
  856. }
  857. static inline void crypto_cipher_set_flags(struct crypto_cipher *tfm,
  858. u32 flags)
  859. {
  860. crypto_tfm_set_flags(crypto_cipher_tfm(tfm), flags);
  861. }
  862. static inline void crypto_cipher_clear_flags(struct crypto_cipher *tfm,
  863. u32 flags)
  864. {
  865. crypto_tfm_clear_flags(crypto_cipher_tfm(tfm), flags);
  866. }
  867. static inline int crypto_cipher_setkey(struct crypto_cipher *tfm,
  868. const u8 *key, unsigned int keylen)
  869. {
  870. return crypto_cipher_crt(tfm)->cit_setkey(crypto_cipher_tfm(tfm),
  871. key, keylen);
  872. }
  873. static inline void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
  874. u8 *dst, const u8 *src)
  875. {
  876. crypto_cipher_crt(tfm)->cit_encrypt_one(crypto_cipher_tfm(tfm),
  877. dst, src);
  878. }
  879. static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
  880. u8 *dst, const u8 *src)
  881. {
  882. crypto_cipher_crt(tfm)->cit_decrypt_one(crypto_cipher_tfm(tfm),
  883. dst, src);
  884. }
  885. static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm)
  886. {
  887. return (struct crypto_hash *)tfm;
  888. }
  889. static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm)
  890. {
  891. BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_HASH) &
  892. CRYPTO_ALG_TYPE_HASH_MASK);
  893. return __crypto_hash_cast(tfm);
  894. }
  895. static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
  896. u32 type, u32 mask)
  897. {
  898. type &= ~CRYPTO_ALG_TYPE_MASK;
  899. type |= CRYPTO_ALG_TYPE_HASH;
  900. mask |= CRYPTO_ALG_TYPE_HASH_MASK;
  901. return __crypto_hash_cast(crypto_alloc_base(alg_name, type, mask));
  902. }
  903. static inline struct crypto_tfm *crypto_hash_tfm(struct crypto_hash *tfm)
  904. {
  905. return &tfm->base;
  906. }
  907. static inline void crypto_free_hash(struct crypto_hash *tfm)
  908. {
  909. crypto_free_tfm(crypto_hash_tfm(tfm));
  910. }
  911. static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask)
  912. {
  913. type &= ~CRYPTO_ALG_TYPE_MASK;
  914. type |= CRYPTO_ALG_TYPE_HASH;
  915. mask |= CRYPTO_ALG_TYPE_HASH_MASK;
  916. return crypto_has_alg(alg_name, type, mask);
  917. }
  918. static inline struct hash_tfm *crypto_hash_crt(struct crypto_hash *tfm)
  919. {
  920. return &crypto_hash_tfm(tfm)->crt_hash;
  921. }
  922. static inline unsigned int crypto_hash_blocksize(struct crypto_hash *tfm)
  923. {
  924. return crypto_tfm_alg_blocksize(crypto_hash_tfm(tfm));
  925. }
  926. static inline unsigned int crypto_hash_alignmask(struct crypto_hash *tfm)
  927. {
  928. return crypto_tfm_alg_alignmask(crypto_hash_tfm(tfm));
  929. }
  930. static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm)
  931. {
  932. return crypto_hash_crt(tfm)->digestsize;
  933. }
  934. static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm)
  935. {
  936. return crypto_tfm_get_flags(crypto_hash_tfm(tfm));
  937. }
  938. static inline void crypto_hash_set_flags(struct crypto_hash *tfm, u32 flags)
  939. {
  940. crypto_tfm_set_flags(crypto_hash_tfm(tfm), flags);
  941. }
  942. static inline void crypto_hash_clear_flags(struct crypto_hash *tfm, u32 flags)
  943. {
  944. crypto_tfm_clear_flags(crypto_hash_tfm(tfm), flags);
  945. }
  946. static inline int crypto_hash_init(struct hash_desc *desc)
  947. {
  948. return crypto_hash_crt(desc->tfm)->init(desc);
  949. }
  950. static inline int crypto_hash_update(struct hash_desc *desc,
  951. struct scatterlist *sg,
  952. unsigned int nbytes)
  953. {
  954. return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes);
  955. }
  956. static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
  957. {
  958. return crypto_hash_crt(desc->tfm)->final(desc, out);
  959. }
  960. static inline int crypto_hash_digest(struct hash_desc *desc,
  961. struct scatterlist *sg,
  962. unsigned int nbytes, u8 *out)
  963. {
  964. return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out);
  965. }
  966. static inline int crypto_hash_setkey(struct crypto_hash *hash,
  967. const u8 *key, unsigned int keylen)
  968. {
  969. return crypto_hash_crt(hash)->setkey(hash, key, keylen);
  970. }
  971. static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
  972. {
  973. return (struct crypto_comp *)tfm;
  974. }
  975. static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm)
  976. {
  977. BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) &
  978. CRYPTO_ALG_TYPE_MASK);
  979. return __crypto_comp_cast(tfm);
  980. }
  981. static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
  982. u32 type, u32 mask)
  983. {
  984. type &= ~CRYPTO_ALG_TYPE_MASK;
  985. type |= CRYPTO_ALG_TYPE_COMPRESS;
  986. mask |= CRYPTO_ALG_TYPE_MASK;
  987. return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask));
  988. }
  989. static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm)
  990. {
  991. return &tfm->base;
  992. }
  993. static inline void crypto_free_comp(struct crypto_comp *tfm)
  994. {
  995. crypto_free_tfm(crypto_comp_tfm(tfm));
  996. }
  997. static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask)
  998. {
  999. type &= ~CRYPTO_ALG_TYPE_MASK;
  1000. type |= CRYPTO_ALG_TYPE_COMPRESS;
  1001. mask |= CRYPTO_ALG_TYPE_MASK;
  1002. return crypto_has_alg(alg_name, type, mask);
  1003. }
  1004. static inline const char *crypto_comp_name(struct crypto_comp *tfm)
  1005. {
  1006. return crypto_tfm_alg_name(crypto_comp_tfm(tfm));
  1007. }
  1008. static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm)
  1009. {
  1010. return &crypto_comp_tfm(tfm)->crt_compress;
  1011. }
  1012. static inline int crypto_comp_compress(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_compress(crypto_comp_tfm(tfm),
  1017. src, slen, dst, dlen);
  1018. }
  1019. static inline int crypto_comp_decompress(struct crypto_comp *tfm,
  1020. const u8 *src, unsigned int slen,
  1021. u8 *dst, unsigned int *dlen)
  1022. {
  1023. return crypto_comp_crt(tfm)->cot_decompress(crypto_comp_tfm(tfm),
  1024. src, slen, dst, dlen);
  1025. }
  1026. #endif /* _LINUX_CRYPTO_H */