xfrm_algo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. /*
  2. * xfrm algorithm interface
  3. *
  4. * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/pfkeyv2.h>
  14. #include <linux/crypto.h>
  15. #include <linux/scatterlist.h>
  16. #include <net/xfrm.h>
  17. #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
  18. #include <net/esp.h>
  19. #endif
  20. /*
  21. * Algorithms supported by IPsec. These entries contain properties which
  22. * are used in key negotiation and xfrm processing, and are used to verify
  23. * that instantiated crypto transforms have correct parameters for IPsec
  24. * purposes.
  25. */
  26. static struct xfrm_algo_desc aead_list[] = {
  27. {
  28. .name = "rfc4106(gcm(aes))",
  29. .uinfo = {
  30. .aead = {
  31. .icv_truncbits = 64,
  32. }
  33. },
  34. .pfkey_supported = 1,
  35. .desc = {
  36. .sadb_alg_id = SADB_X_EALG_AES_GCM_ICV8,
  37. .sadb_alg_ivlen = 8,
  38. .sadb_alg_minbits = 128,
  39. .sadb_alg_maxbits = 256
  40. }
  41. },
  42. {
  43. .name = "rfc4106(gcm(aes))",
  44. .uinfo = {
  45. .aead = {
  46. .icv_truncbits = 96,
  47. }
  48. },
  49. .pfkey_supported = 1,
  50. .desc = {
  51. .sadb_alg_id = SADB_X_EALG_AES_GCM_ICV12,
  52. .sadb_alg_ivlen = 8,
  53. .sadb_alg_minbits = 128,
  54. .sadb_alg_maxbits = 256
  55. }
  56. },
  57. {
  58. .name = "rfc4106(gcm(aes))",
  59. .uinfo = {
  60. .aead = {
  61. .icv_truncbits = 128,
  62. }
  63. },
  64. .pfkey_supported = 1,
  65. .desc = {
  66. .sadb_alg_id = SADB_X_EALG_AES_GCM_ICV16,
  67. .sadb_alg_ivlen = 8,
  68. .sadb_alg_minbits = 128,
  69. .sadb_alg_maxbits = 256
  70. }
  71. },
  72. {
  73. .name = "rfc4309(ccm(aes))",
  74. .uinfo = {
  75. .aead = {
  76. .icv_truncbits = 64,
  77. }
  78. },
  79. .pfkey_supported = 1,
  80. .desc = {
  81. .sadb_alg_id = SADB_X_EALG_AES_CCM_ICV8,
  82. .sadb_alg_ivlen = 8,
  83. .sadb_alg_minbits = 128,
  84. .sadb_alg_maxbits = 256
  85. }
  86. },
  87. {
  88. .name = "rfc4309(ccm(aes))",
  89. .uinfo = {
  90. .aead = {
  91. .icv_truncbits = 96,
  92. }
  93. },
  94. .pfkey_supported = 1,
  95. .desc = {
  96. .sadb_alg_id = SADB_X_EALG_AES_CCM_ICV12,
  97. .sadb_alg_ivlen = 8,
  98. .sadb_alg_minbits = 128,
  99. .sadb_alg_maxbits = 256
  100. }
  101. },
  102. {
  103. .name = "rfc4309(ccm(aes))",
  104. .uinfo = {
  105. .aead = {
  106. .icv_truncbits = 128,
  107. }
  108. },
  109. .pfkey_supported = 1,
  110. .desc = {
  111. .sadb_alg_id = SADB_X_EALG_AES_CCM_ICV16,
  112. .sadb_alg_ivlen = 8,
  113. .sadb_alg_minbits = 128,
  114. .sadb_alg_maxbits = 256
  115. }
  116. },
  117. {
  118. .name = "rfc4543(gcm(aes))",
  119. .uinfo = {
  120. .aead = {
  121. .icv_truncbits = 128,
  122. }
  123. },
  124. .pfkey_supported = 1,
  125. .desc = {
  126. .sadb_alg_id = SADB_X_EALG_NULL_AES_GMAC,
  127. .sadb_alg_ivlen = 8,
  128. .sadb_alg_minbits = 128,
  129. .sadb_alg_maxbits = 256
  130. }
  131. },
  132. };
  133. static struct xfrm_algo_desc aalg_list[] = {
  134. {
  135. .name = "digest_null",
  136. .uinfo = {
  137. .auth = {
  138. .icv_truncbits = 0,
  139. .icv_fullbits = 0,
  140. }
  141. },
  142. .pfkey_supported = 1,
  143. .desc = {
  144. .sadb_alg_id = SADB_X_AALG_NULL,
  145. .sadb_alg_ivlen = 0,
  146. .sadb_alg_minbits = 0,
  147. .sadb_alg_maxbits = 0
  148. }
  149. },
  150. {
  151. .name = "hmac(md5)",
  152. .compat = "md5",
  153. .uinfo = {
  154. .auth = {
  155. .icv_truncbits = 96,
  156. .icv_fullbits = 128,
  157. }
  158. },
  159. .pfkey_supported = 1,
  160. .desc = {
  161. .sadb_alg_id = SADB_AALG_MD5HMAC,
  162. .sadb_alg_ivlen = 0,
  163. .sadb_alg_minbits = 128,
  164. .sadb_alg_maxbits = 128
  165. }
  166. },
  167. {
  168. .name = "hmac(sha1)",
  169. .compat = "sha1",
  170. .uinfo = {
  171. .auth = {
  172. .icv_truncbits = 96,
  173. .icv_fullbits = 160,
  174. }
  175. },
  176. .pfkey_supported = 1,
  177. .desc = {
  178. .sadb_alg_id = SADB_AALG_SHA1HMAC,
  179. .sadb_alg_ivlen = 0,
  180. .sadb_alg_minbits = 160,
  181. .sadb_alg_maxbits = 160
  182. }
  183. },
  184. {
  185. .name = "hmac(sha256)",
  186. .compat = "sha256",
  187. .uinfo = {
  188. .auth = {
  189. .icv_truncbits = 96,
  190. .icv_fullbits = 256,
  191. }
  192. },
  193. .pfkey_supported = 1,
  194. .desc = {
  195. .sadb_alg_id = SADB_X_AALG_SHA2_256HMAC,
  196. .sadb_alg_ivlen = 0,
  197. .sadb_alg_minbits = 256,
  198. .sadb_alg_maxbits = 256
  199. }
  200. },
  201. {
  202. .name = "hmac(sha384)",
  203. .uinfo = {
  204. .auth = {
  205. .icv_truncbits = 192,
  206. .icv_fullbits = 384,
  207. }
  208. },
  209. .pfkey_supported = 1,
  210. .desc = {
  211. .sadb_alg_id = SADB_X_AALG_SHA2_384HMAC,
  212. .sadb_alg_ivlen = 0,
  213. .sadb_alg_minbits = 384,
  214. .sadb_alg_maxbits = 384
  215. }
  216. },
  217. {
  218. .name = "hmac(sha512)",
  219. .uinfo = {
  220. .auth = {
  221. .icv_truncbits = 256,
  222. .icv_fullbits = 512,
  223. }
  224. },
  225. .pfkey_supported = 1,
  226. .desc = {
  227. .sadb_alg_id = SADB_X_AALG_SHA2_512HMAC,
  228. .sadb_alg_ivlen = 0,
  229. .sadb_alg_minbits = 512,
  230. .sadb_alg_maxbits = 512
  231. }
  232. },
  233. {
  234. .name = "hmac(rmd160)",
  235. .compat = "rmd160",
  236. .uinfo = {
  237. .auth = {
  238. .icv_truncbits = 96,
  239. .icv_fullbits = 160,
  240. }
  241. },
  242. .pfkey_supported = 1,
  243. .desc = {
  244. .sadb_alg_id = SADB_X_AALG_RIPEMD160HMAC,
  245. .sadb_alg_ivlen = 0,
  246. .sadb_alg_minbits = 160,
  247. .sadb_alg_maxbits = 160
  248. }
  249. },
  250. {
  251. .name = "xcbc(aes)",
  252. .uinfo = {
  253. .auth = {
  254. .icv_truncbits = 96,
  255. .icv_fullbits = 128,
  256. }
  257. },
  258. .pfkey_supported = 1,
  259. .desc = {
  260. .sadb_alg_id = SADB_X_AALG_AES_XCBC_MAC,
  261. .sadb_alg_ivlen = 0,
  262. .sadb_alg_minbits = 128,
  263. .sadb_alg_maxbits = 128
  264. }
  265. },
  266. {
  267. /* rfc4494 */
  268. .name = "cmac(aes)",
  269. .uinfo = {
  270. .auth = {
  271. .icv_truncbits = 96,
  272. .icv_fullbits = 128,
  273. }
  274. },
  275. .pfkey_supported = 0,
  276. },
  277. };
  278. static struct xfrm_algo_desc ealg_list[] = {
  279. {
  280. .name = "ecb(cipher_null)",
  281. .compat = "cipher_null",
  282. .uinfo = {
  283. .encr = {
  284. .blockbits = 8,
  285. .defkeybits = 0,
  286. }
  287. },
  288. .pfkey_supported = 1,
  289. .desc = {
  290. .sadb_alg_id = SADB_EALG_NULL,
  291. .sadb_alg_ivlen = 0,
  292. .sadb_alg_minbits = 0,
  293. .sadb_alg_maxbits = 0
  294. }
  295. },
  296. {
  297. .name = "cbc(des)",
  298. .compat = "des",
  299. .uinfo = {
  300. .encr = {
  301. .blockbits = 64,
  302. .defkeybits = 64,
  303. }
  304. },
  305. .pfkey_supported = 1,
  306. .desc = {
  307. .sadb_alg_id = SADB_EALG_DESCBC,
  308. .sadb_alg_ivlen = 8,
  309. .sadb_alg_minbits = 64,
  310. .sadb_alg_maxbits = 64
  311. }
  312. },
  313. {
  314. .name = "cbc(des3_ede)",
  315. .compat = "des3_ede",
  316. .uinfo = {
  317. .encr = {
  318. .blockbits = 64,
  319. .defkeybits = 192,
  320. }
  321. },
  322. .pfkey_supported = 1,
  323. .desc = {
  324. .sadb_alg_id = SADB_EALG_3DESCBC,
  325. .sadb_alg_ivlen = 8,
  326. .sadb_alg_minbits = 192,
  327. .sadb_alg_maxbits = 192
  328. }
  329. },
  330. {
  331. .name = "cbc(cast5)",
  332. .compat = "cast5",
  333. .uinfo = {
  334. .encr = {
  335. .blockbits = 64,
  336. .defkeybits = 128,
  337. }
  338. },
  339. .pfkey_supported = 1,
  340. .desc = {
  341. .sadb_alg_id = SADB_X_EALG_CASTCBC,
  342. .sadb_alg_ivlen = 8,
  343. .sadb_alg_minbits = 40,
  344. .sadb_alg_maxbits = 128
  345. }
  346. },
  347. {
  348. .name = "cbc(blowfish)",
  349. .compat = "blowfish",
  350. .uinfo = {
  351. .encr = {
  352. .blockbits = 64,
  353. .defkeybits = 128,
  354. }
  355. },
  356. .pfkey_supported = 1,
  357. .desc = {
  358. .sadb_alg_id = SADB_X_EALG_BLOWFISHCBC,
  359. .sadb_alg_ivlen = 8,
  360. .sadb_alg_minbits = 40,
  361. .sadb_alg_maxbits = 448
  362. }
  363. },
  364. {
  365. .name = "cbc(aes)",
  366. .compat = "aes",
  367. .uinfo = {
  368. .encr = {
  369. .blockbits = 128,
  370. .defkeybits = 128,
  371. }
  372. },
  373. .pfkey_supported = 1,
  374. .desc = {
  375. .sadb_alg_id = SADB_X_EALG_AESCBC,
  376. .sadb_alg_ivlen = 8,
  377. .sadb_alg_minbits = 128,
  378. .sadb_alg_maxbits = 256
  379. }
  380. },
  381. {
  382. .name = "cbc(serpent)",
  383. .compat = "serpent",
  384. .uinfo = {
  385. .encr = {
  386. .blockbits = 128,
  387. .defkeybits = 128,
  388. }
  389. },
  390. .pfkey_supported = 1,
  391. .desc = {
  392. .sadb_alg_id = SADB_X_EALG_SERPENTCBC,
  393. .sadb_alg_ivlen = 8,
  394. .sadb_alg_minbits = 128,
  395. .sadb_alg_maxbits = 256,
  396. }
  397. },
  398. {
  399. .name = "cbc(camellia)",
  400. .compat = "camellia",
  401. .uinfo = {
  402. .encr = {
  403. .blockbits = 128,
  404. .defkeybits = 128,
  405. }
  406. },
  407. .pfkey_supported = 1,
  408. .desc = {
  409. .sadb_alg_id = SADB_X_EALG_CAMELLIACBC,
  410. .sadb_alg_ivlen = 8,
  411. .sadb_alg_minbits = 128,
  412. .sadb_alg_maxbits = 256
  413. }
  414. },
  415. {
  416. .name = "cbc(twofish)",
  417. .compat = "twofish",
  418. .uinfo = {
  419. .encr = {
  420. .blockbits = 128,
  421. .defkeybits = 128,
  422. }
  423. },
  424. .pfkey_supported = 1,
  425. .desc = {
  426. .sadb_alg_id = SADB_X_EALG_TWOFISHCBC,
  427. .sadb_alg_ivlen = 8,
  428. .sadb_alg_minbits = 128,
  429. .sadb_alg_maxbits = 256
  430. }
  431. },
  432. {
  433. .name = "rfc3686(ctr(aes))",
  434. .uinfo = {
  435. .encr = {
  436. .blockbits = 128,
  437. .defkeybits = 160, /* 128-bit key + 32-bit nonce */
  438. }
  439. },
  440. .pfkey_supported = 1,
  441. .desc = {
  442. .sadb_alg_id = SADB_X_EALG_AESCTR,
  443. .sadb_alg_ivlen = 8,
  444. .sadb_alg_minbits = 160,
  445. .sadb_alg_maxbits = 288
  446. }
  447. },
  448. };
  449. static struct xfrm_algo_desc calg_list[] = {
  450. {
  451. .name = "deflate",
  452. .uinfo = {
  453. .comp = {
  454. .threshold = 90,
  455. }
  456. },
  457. .pfkey_supported = 1,
  458. .desc = { .sadb_alg_id = SADB_X_CALG_DEFLATE }
  459. },
  460. {
  461. .name = "lzs",
  462. .uinfo = {
  463. .comp = {
  464. .threshold = 90,
  465. }
  466. },
  467. .pfkey_supported = 1,
  468. .desc = { .sadb_alg_id = SADB_X_CALG_LZS }
  469. },
  470. {
  471. .name = "lzjh",
  472. .uinfo = {
  473. .comp = {
  474. .threshold = 50,
  475. }
  476. },
  477. .pfkey_supported = 1,
  478. .desc = { .sadb_alg_id = SADB_X_CALG_LZJH }
  479. },
  480. };
  481. static inline int aead_entries(void)
  482. {
  483. return ARRAY_SIZE(aead_list);
  484. }
  485. static inline int aalg_entries(void)
  486. {
  487. return ARRAY_SIZE(aalg_list);
  488. }
  489. static inline int ealg_entries(void)
  490. {
  491. return ARRAY_SIZE(ealg_list);
  492. }
  493. static inline int calg_entries(void)
  494. {
  495. return ARRAY_SIZE(calg_list);
  496. }
  497. struct xfrm_algo_list {
  498. struct xfrm_algo_desc *algs;
  499. int entries;
  500. u32 type;
  501. u32 mask;
  502. };
  503. static const struct xfrm_algo_list xfrm_aead_list = {
  504. .algs = aead_list,
  505. .entries = ARRAY_SIZE(aead_list),
  506. .type = CRYPTO_ALG_TYPE_AEAD,
  507. .mask = CRYPTO_ALG_TYPE_MASK,
  508. };
  509. static const struct xfrm_algo_list xfrm_aalg_list = {
  510. .algs = aalg_list,
  511. .entries = ARRAY_SIZE(aalg_list),
  512. .type = CRYPTO_ALG_TYPE_HASH,
  513. .mask = CRYPTO_ALG_TYPE_HASH_MASK,
  514. };
  515. static const struct xfrm_algo_list xfrm_ealg_list = {
  516. .algs = ealg_list,
  517. .entries = ARRAY_SIZE(ealg_list),
  518. .type = CRYPTO_ALG_TYPE_BLKCIPHER,
  519. .mask = CRYPTO_ALG_TYPE_BLKCIPHER_MASK,
  520. };
  521. static const struct xfrm_algo_list xfrm_calg_list = {
  522. .algs = calg_list,
  523. .entries = ARRAY_SIZE(calg_list),
  524. .type = CRYPTO_ALG_TYPE_COMPRESS,
  525. .mask = CRYPTO_ALG_TYPE_MASK,
  526. };
  527. static struct xfrm_algo_desc *xfrm_find_algo(
  528. const struct xfrm_algo_list *algo_list,
  529. int match(const struct xfrm_algo_desc *entry, const void *data),
  530. const void *data, int probe)
  531. {
  532. struct xfrm_algo_desc *list = algo_list->algs;
  533. int i, status;
  534. for (i = 0; i < algo_list->entries; i++) {
  535. if (!match(list + i, data))
  536. continue;
  537. if (list[i].available)
  538. return &list[i];
  539. if (!probe)
  540. break;
  541. status = crypto_has_alg(list[i].name, algo_list->type,
  542. algo_list->mask);
  543. if (!status)
  544. break;
  545. list[i].available = status;
  546. return &list[i];
  547. }
  548. return NULL;
  549. }
  550. static int xfrm_alg_id_match(const struct xfrm_algo_desc *entry,
  551. const void *data)
  552. {
  553. return entry->desc.sadb_alg_id == (unsigned long)data;
  554. }
  555. struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id)
  556. {
  557. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_id_match,
  558. (void *)(unsigned long)alg_id, 1);
  559. }
  560. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byid);
  561. struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id)
  562. {
  563. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_id_match,
  564. (void *)(unsigned long)alg_id, 1);
  565. }
  566. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byid);
  567. struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id)
  568. {
  569. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_id_match,
  570. (void *)(unsigned long)alg_id, 1);
  571. }
  572. EXPORT_SYMBOL_GPL(xfrm_calg_get_byid);
  573. static int xfrm_alg_name_match(const struct xfrm_algo_desc *entry,
  574. const void *data)
  575. {
  576. const char *name = data;
  577. return name && (!strcmp(name, entry->name) ||
  578. (entry->compat && !strcmp(name, entry->compat)));
  579. }
  580. struct xfrm_algo_desc *xfrm_aalg_get_byname(const char *name, int probe)
  581. {
  582. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_name_match, name,
  583. probe);
  584. }
  585. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname);
  586. struct xfrm_algo_desc *xfrm_ealg_get_byname(const char *name, int probe)
  587. {
  588. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_name_match, name,
  589. probe);
  590. }
  591. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname);
  592. struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe)
  593. {
  594. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_name_match, name,
  595. probe);
  596. }
  597. EXPORT_SYMBOL_GPL(xfrm_calg_get_byname);
  598. struct xfrm_aead_name {
  599. const char *name;
  600. int icvbits;
  601. };
  602. static int xfrm_aead_name_match(const struct xfrm_algo_desc *entry,
  603. const void *data)
  604. {
  605. const struct xfrm_aead_name *aead = data;
  606. const char *name = aead->name;
  607. return aead->icvbits == entry->uinfo.aead.icv_truncbits && name &&
  608. !strcmp(name, entry->name);
  609. }
  610. struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, int probe)
  611. {
  612. struct xfrm_aead_name data = {
  613. .name = name,
  614. .icvbits = icv_len,
  615. };
  616. return xfrm_find_algo(&xfrm_aead_list, xfrm_aead_name_match, &data,
  617. probe);
  618. }
  619. EXPORT_SYMBOL_GPL(xfrm_aead_get_byname);
  620. struct xfrm_algo_desc *xfrm_aalg_get_byidx(unsigned int idx)
  621. {
  622. if (idx >= aalg_entries())
  623. return NULL;
  624. return &aalg_list[idx];
  625. }
  626. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byidx);
  627. struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx)
  628. {
  629. if (idx >= ealg_entries())
  630. return NULL;
  631. return &ealg_list[idx];
  632. }
  633. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byidx);
  634. /*
  635. * Probe for the availability of crypto algorithms, and set the available
  636. * flag for any algorithms found on the system. This is typically called by
  637. * pfkey during userspace SA add, update or register.
  638. */
  639. void xfrm_probe_algs(void)
  640. {
  641. int i, status;
  642. BUG_ON(in_softirq());
  643. for (i = 0; i < aalg_entries(); i++) {
  644. status = crypto_has_hash(aalg_list[i].name, 0,
  645. CRYPTO_ALG_ASYNC);
  646. if (aalg_list[i].available != status)
  647. aalg_list[i].available = status;
  648. }
  649. for (i = 0; i < ealg_entries(); i++) {
  650. status = crypto_has_ablkcipher(ealg_list[i].name, 0, 0);
  651. if (ealg_list[i].available != status)
  652. ealg_list[i].available = status;
  653. }
  654. for (i = 0; i < calg_entries(); i++) {
  655. status = crypto_has_comp(calg_list[i].name, 0,
  656. CRYPTO_ALG_ASYNC);
  657. if (calg_list[i].available != status)
  658. calg_list[i].available = status;
  659. }
  660. }
  661. EXPORT_SYMBOL_GPL(xfrm_probe_algs);
  662. int xfrm_count_pfkey_auth_supported(void)
  663. {
  664. int i, n;
  665. for (i = 0, n = 0; i < aalg_entries(); i++)
  666. if (aalg_list[i].available && aalg_list[i].pfkey_supported)
  667. n++;
  668. return n;
  669. }
  670. EXPORT_SYMBOL_GPL(xfrm_count_pfkey_auth_supported);
  671. int xfrm_count_pfkey_enc_supported(void)
  672. {
  673. int i, n;
  674. for (i = 0, n = 0; i < ealg_entries(); i++)
  675. if (ealg_list[i].available && ealg_list[i].pfkey_supported)
  676. n++;
  677. return n;
  678. }
  679. EXPORT_SYMBOL_GPL(xfrm_count_pfkey_enc_supported);
  680. #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
  681. void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
  682. {
  683. if (tail != skb) {
  684. skb->data_len += len;
  685. skb->len += len;
  686. }
  687. return skb_put(tail, len);
  688. }
  689. EXPORT_SYMBOL_GPL(pskb_put);
  690. #endif
  691. MODULE_LICENSE("GPL");