xfrm_algo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  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 = 128,
  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. static struct xfrm_algo_desc ealg_list[] = {
  268. {
  269. .name = "ecb(cipher_null)",
  270. .compat = "cipher_null",
  271. .uinfo = {
  272. .encr = {
  273. .blockbits = 8,
  274. .defkeybits = 0,
  275. }
  276. },
  277. .pfkey_supported = 1,
  278. .desc = {
  279. .sadb_alg_id = SADB_EALG_NULL,
  280. .sadb_alg_ivlen = 0,
  281. .sadb_alg_minbits = 0,
  282. .sadb_alg_maxbits = 0
  283. }
  284. },
  285. {
  286. .name = "cbc(des)",
  287. .compat = "des",
  288. .uinfo = {
  289. .encr = {
  290. .blockbits = 64,
  291. .defkeybits = 64,
  292. }
  293. },
  294. .pfkey_supported = 1,
  295. .desc = {
  296. .sadb_alg_id = SADB_EALG_DESCBC,
  297. .sadb_alg_ivlen = 8,
  298. .sadb_alg_minbits = 64,
  299. .sadb_alg_maxbits = 64
  300. }
  301. },
  302. {
  303. .name = "cbc(des3_ede)",
  304. .compat = "des3_ede",
  305. .uinfo = {
  306. .encr = {
  307. .blockbits = 64,
  308. .defkeybits = 192,
  309. }
  310. },
  311. .pfkey_supported = 1,
  312. .desc = {
  313. .sadb_alg_id = SADB_EALG_3DESCBC,
  314. .sadb_alg_ivlen = 8,
  315. .sadb_alg_minbits = 192,
  316. .sadb_alg_maxbits = 192
  317. }
  318. },
  319. {
  320. .name = "cbc(cast5)",
  321. .compat = "cast5",
  322. .uinfo = {
  323. .encr = {
  324. .blockbits = 64,
  325. .defkeybits = 128,
  326. }
  327. },
  328. .pfkey_supported = 1,
  329. .desc = {
  330. .sadb_alg_id = SADB_X_EALG_CASTCBC,
  331. .sadb_alg_ivlen = 8,
  332. .sadb_alg_minbits = 40,
  333. .sadb_alg_maxbits = 128
  334. }
  335. },
  336. {
  337. .name = "cbc(blowfish)",
  338. .compat = "blowfish",
  339. .uinfo = {
  340. .encr = {
  341. .blockbits = 64,
  342. .defkeybits = 128,
  343. }
  344. },
  345. .pfkey_supported = 1,
  346. .desc = {
  347. .sadb_alg_id = SADB_X_EALG_BLOWFISHCBC,
  348. .sadb_alg_ivlen = 8,
  349. .sadb_alg_minbits = 40,
  350. .sadb_alg_maxbits = 448
  351. }
  352. },
  353. {
  354. .name = "cbc(aes)",
  355. .compat = "aes",
  356. .uinfo = {
  357. .encr = {
  358. .blockbits = 128,
  359. .defkeybits = 128,
  360. }
  361. },
  362. .pfkey_supported = 1,
  363. .desc = {
  364. .sadb_alg_id = SADB_X_EALG_AESCBC,
  365. .sadb_alg_ivlen = 8,
  366. .sadb_alg_minbits = 128,
  367. .sadb_alg_maxbits = 256
  368. }
  369. },
  370. {
  371. .name = "cbc(serpent)",
  372. .compat = "serpent",
  373. .uinfo = {
  374. .encr = {
  375. .blockbits = 128,
  376. .defkeybits = 128,
  377. }
  378. },
  379. .pfkey_supported = 1,
  380. .desc = {
  381. .sadb_alg_id = SADB_X_EALG_SERPENTCBC,
  382. .sadb_alg_ivlen = 8,
  383. .sadb_alg_minbits = 128,
  384. .sadb_alg_maxbits = 256,
  385. }
  386. },
  387. {
  388. .name = "cbc(camellia)",
  389. .compat = "camellia",
  390. .uinfo = {
  391. .encr = {
  392. .blockbits = 128,
  393. .defkeybits = 128,
  394. }
  395. },
  396. .pfkey_supported = 1,
  397. .desc = {
  398. .sadb_alg_id = SADB_X_EALG_CAMELLIACBC,
  399. .sadb_alg_ivlen = 8,
  400. .sadb_alg_minbits = 128,
  401. .sadb_alg_maxbits = 256
  402. }
  403. },
  404. {
  405. .name = "cbc(twofish)",
  406. .compat = "twofish",
  407. .uinfo = {
  408. .encr = {
  409. .blockbits = 128,
  410. .defkeybits = 128,
  411. }
  412. },
  413. .pfkey_supported = 1,
  414. .desc = {
  415. .sadb_alg_id = SADB_X_EALG_TWOFISHCBC,
  416. .sadb_alg_ivlen = 8,
  417. .sadb_alg_minbits = 128,
  418. .sadb_alg_maxbits = 256
  419. }
  420. },
  421. {
  422. .name = "rfc3686(ctr(aes))",
  423. .uinfo = {
  424. .encr = {
  425. .blockbits = 128,
  426. .defkeybits = 160, /* 128-bit key + 32-bit nonce */
  427. }
  428. },
  429. .pfkey_supported = 1,
  430. .desc = {
  431. .sadb_alg_id = SADB_X_EALG_AESCTR,
  432. .sadb_alg_ivlen = 8,
  433. .sadb_alg_minbits = 160,
  434. .sadb_alg_maxbits = 288
  435. }
  436. },
  437. };
  438. static struct xfrm_algo_desc calg_list[] = {
  439. {
  440. .name = "deflate",
  441. .uinfo = {
  442. .comp = {
  443. .threshold = 90,
  444. }
  445. },
  446. .pfkey_supported = 1,
  447. .desc = { .sadb_alg_id = SADB_X_CALG_DEFLATE }
  448. },
  449. {
  450. .name = "lzs",
  451. .uinfo = {
  452. .comp = {
  453. .threshold = 90,
  454. }
  455. },
  456. .pfkey_supported = 1,
  457. .desc = { .sadb_alg_id = SADB_X_CALG_LZS }
  458. },
  459. {
  460. .name = "lzjh",
  461. .uinfo = {
  462. .comp = {
  463. .threshold = 50,
  464. }
  465. },
  466. .pfkey_supported = 1,
  467. .desc = { .sadb_alg_id = SADB_X_CALG_LZJH }
  468. },
  469. };
  470. static inline int aead_entries(void)
  471. {
  472. return ARRAY_SIZE(aead_list);
  473. }
  474. static inline int aalg_entries(void)
  475. {
  476. return ARRAY_SIZE(aalg_list);
  477. }
  478. static inline int ealg_entries(void)
  479. {
  480. return ARRAY_SIZE(ealg_list);
  481. }
  482. static inline int calg_entries(void)
  483. {
  484. return ARRAY_SIZE(calg_list);
  485. }
  486. struct xfrm_algo_list {
  487. struct xfrm_algo_desc *algs;
  488. int entries;
  489. u32 type;
  490. u32 mask;
  491. };
  492. static const struct xfrm_algo_list xfrm_aead_list = {
  493. .algs = aead_list,
  494. .entries = ARRAY_SIZE(aead_list),
  495. .type = CRYPTO_ALG_TYPE_AEAD,
  496. .mask = CRYPTO_ALG_TYPE_MASK,
  497. };
  498. static const struct xfrm_algo_list xfrm_aalg_list = {
  499. .algs = aalg_list,
  500. .entries = ARRAY_SIZE(aalg_list),
  501. .type = CRYPTO_ALG_TYPE_HASH,
  502. .mask = CRYPTO_ALG_TYPE_HASH_MASK,
  503. };
  504. static const struct xfrm_algo_list xfrm_ealg_list = {
  505. .algs = ealg_list,
  506. .entries = ARRAY_SIZE(ealg_list),
  507. .type = CRYPTO_ALG_TYPE_BLKCIPHER,
  508. .mask = CRYPTO_ALG_TYPE_BLKCIPHER_MASK,
  509. };
  510. static const struct xfrm_algo_list xfrm_calg_list = {
  511. .algs = calg_list,
  512. .entries = ARRAY_SIZE(calg_list),
  513. .type = CRYPTO_ALG_TYPE_COMPRESS,
  514. .mask = CRYPTO_ALG_TYPE_MASK,
  515. };
  516. static struct xfrm_algo_desc *xfrm_find_algo(
  517. const struct xfrm_algo_list *algo_list,
  518. int match(const struct xfrm_algo_desc *entry, const void *data),
  519. const void *data, int probe)
  520. {
  521. struct xfrm_algo_desc *list = algo_list->algs;
  522. int i, status;
  523. for (i = 0; i < algo_list->entries; i++) {
  524. if (!match(list + i, data))
  525. continue;
  526. if (list[i].available)
  527. return &list[i];
  528. if (!probe)
  529. break;
  530. status = crypto_has_alg(list[i].name, algo_list->type,
  531. algo_list->mask);
  532. if (!status)
  533. break;
  534. list[i].available = status;
  535. return &list[i];
  536. }
  537. return NULL;
  538. }
  539. static int xfrm_alg_id_match(const struct xfrm_algo_desc *entry,
  540. const void *data)
  541. {
  542. return entry->desc.sadb_alg_id == (unsigned long)data;
  543. }
  544. struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id)
  545. {
  546. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_id_match,
  547. (void *)(unsigned long)alg_id, 1);
  548. }
  549. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byid);
  550. struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id)
  551. {
  552. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_id_match,
  553. (void *)(unsigned long)alg_id, 1);
  554. }
  555. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byid);
  556. struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id)
  557. {
  558. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_id_match,
  559. (void *)(unsigned long)alg_id, 1);
  560. }
  561. EXPORT_SYMBOL_GPL(xfrm_calg_get_byid);
  562. static int xfrm_alg_name_match(const struct xfrm_algo_desc *entry,
  563. const void *data)
  564. {
  565. const char *name = data;
  566. return name && (!strcmp(name, entry->name) ||
  567. (entry->compat && !strcmp(name, entry->compat)));
  568. }
  569. struct xfrm_algo_desc *xfrm_aalg_get_byname(const char *name, int probe)
  570. {
  571. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_name_match, name,
  572. probe);
  573. }
  574. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname);
  575. struct xfrm_algo_desc *xfrm_ealg_get_byname(const char *name, int probe)
  576. {
  577. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_name_match, name,
  578. probe);
  579. }
  580. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname);
  581. struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe)
  582. {
  583. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_name_match, name,
  584. probe);
  585. }
  586. EXPORT_SYMBOL_GPL(xfrm_calg_get_byname);
  587. struct xfrm_aead_name {
  588. const char *name;
  589. int icvbits;
  590. };
  591. static int xfrm_aead_name_match(const struct xfrm_algo_desc *entry,
  592. const void *data)
  593. {
  594. const struct xfrm_aead_name *aead = data;
  595. const char *name = aead->name;
  596. return aead->icvbits == entry->uinfo.aead.icv_truncbits && name &&
  597. !strcmp(name, entry->name);
  598. }
  599. struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, int probe)
  600. {
  601. struct xfrm_aead_name data = {
  602. .name = name,
  603. .icvbits = icv_len,
  604. };
  605. return xfrm_find_algo(&xfrm_aead_list, xfrm_aead_name_match, &data,
  606. probe);
  607. }
  608. EXPORT_SYMBOL_GPL(xfrm_aead_get_byname);
  609. struct xfrm_algo_desc *xfrm_aalg_get_byidx(unsigned int idx)
  610. {
  611. if (idx >= aalg_entries())
  612. return NULL;
  613. return &aalg_list[idx];
  614. }
  615. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byidx);
  616. struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx)
  617. {
  618. if (idx >= ealg_entries())
  619. return NULL;
  620. return &ealg_list[idx];
  621. }
  622. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byidx);
  623. /*
  624. * Probe for the availability of crypto algorithms, and set the available
  625. * flag for any algorithms found on the system. This is typically called by
  626. * pfkey during userspace SA add, update or register.
  627. */
  628. void xfrm_probe_algs(void)
  629. {
  630. int i, status;
  631. BUG_ON(in_softirq());
  632. for (i = 0; i < aalg_entries(); i++) {
  633. status = crypto_has_hash(aalg_list[i].name, 0,
  634. CRYPTO_ALG_ASYNC);
  635. if (aalg_list[i].available != status)
  636. aalg_list[i].available = status;
  637. }
  638. for (i = 0; i < ealg_entries(); i++) {
  639. status = crypto_has_ablkcipher(ealg_list[i].name, 0, 0);
  640. if (ealg_list[i].available != status)
  641. ealg_list[i].available = status;
  642. }
  643. for (i = 0; i < calg_entries(); i++) {
  644. status = crypto_has_comp(calg_list[i].name, 0,
  645. CRYPTO_ALG_ASYNC);
  646. if (calg_list[i].available != status)
  647. calg_list[i].available = status;
  648. }
  649. }
  650. EXPORT_SYMBOL_GPL(xfrm_probe_algs);
  651. int xfrm_count_pfkey_auth_supported(void)
  652. {
  653. int i, n;
  654. for (i = 0, n = 0; i < aalg_entries(); i++)
  655. if (aalg_list[i].available && aalg_list[i].pfkey_supported)
  656. n++;
  657. return n;
  658. }
  659. EXPORT_SYMBOL_GPL(xfrm_count_pfkey_auth_supported);
  660. int xfrm_count_pfkey_enc_supported(void)
  661. {
  662. int i, n;
  663. for (i = 0, n = 0; i < ealg_entries(); i++)
  664. if (ealg_list[i].available && ealg_list[i].pfkey_supported)
  665. n++;
  666. return n;
  667. }
  668. EXPORT_SYMBOL_GPL(xfrm_count_pfkey_enc_supported);
  669. #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
  670. void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
  671. {
  672. if (tail != skb) {
  673. skb->data_len += len;
  674. skb->len += len;
  675. }
  676. return skb_put(tail, len);
  677. }
  678. EXPORT_SYMBOL_GPL(pskb_put);
  679. #endif
  680. MODULE_LICENSE("GPL");