xfrm_algo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  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 aalg_entries(void)
  482. {
  483. return ARRAY_SIZE(aalg_list);
  484. }
  485. static inline int ealg_entries(void)
  486. {
  487. return ARRAY_SIZE(ealg_list);
  488. }
  489. static inline int calg_entries(void)
  490. {
  491. return ARRAY_SIZE(calg_list);
  492. }
  493. struct xfrm_algo_list {
  494. struct xfrm_algo_desc *algs;
  495. int entries;
  496. u32 type;
  497. u32 mask;
  498. };
  499. static const struct xfrm_algo_list xfrm_aead_list = {
  500. .algs = aead_list,
  501. .entries = ARRAY_SIZE(aead_list),
  502. .type = CRYPTO_ALG_TYPE_AEAD,
  503. .mask = CRYPTO_ALG_TYPE_MASK,
  504. };
  505. static const struct xfrm_algo_list xfrm_aalg_list = {
  506. .algs = aalg_list,
  507. .entries = ARRAY_SIZE(aalg_list),
  508. .type = CRYPTO_ALG_TYPE_HASH,
  509. .mask = CRYPTO_ALG_TYPE_HASH_MASK,
  510. };
  511. static const struct xfrm_algo_list xfrm_ealg_list = {
  512. .algs = ealg_list,
  513. .entries = ARRAY_SIZE(ealg_list),
  514. .type = CRYPTO_ALG_TYPE_BLKCIPHER,
  515. .mask = CRYPTO_ALG_TYPE_BLKCIPHER_MASK,
  516. };
  517. static const struct xfrm_algo_list xfrm_calg_list = {
  518. .algs = calg_list,
  519. .entries = ARRAY_SIZE(calg_list),
  520. .type = CRYPTO_ALG_TYPE_COMPRESS,
  521. .mask = CRYPTO_ALG_TYPE_MASK,
  522. };
  523. static struct xfrm_algo_desc *xfrm_find_algo(
  524. const struct xfrm_algo_list *algo_list,
  525. int match(const struct xfrm_algo_desc *entry, const void *data),
  526. const void *data, int probe)
  527. {
  528. struct xfrm_algo_desc *list = algo_list->algs;
  529. int i, status;
  530. for (i = 0; i < algo_list->entries; i++) {
  531. if (!match(list + i, data))
  532. continue;
  533. if (list[i].available)
  534. return &list[i];
  535. if (!probe)
  536. break;
  537. status = crypto_has_alg(list[i].name, algo_list->type,
  538. algo_list->mask);
  539. if (!status)
  540. break;
  541. list[i].available = status;
  542. return &list[i];
  543. }
  544. return NULL;
  545. }
  546. static int xfrm_alg_id_match(const struct xfrm_algo_desc *entry,
  547. const void *data)
  548. {
  549. return entry->desc.sadb_alg_id == (unsigned long)data;
  550. }
  551. struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id)
  552. {
  553. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_id_match,
  554. (void *)(unsigned long)alg_id, 1);
  555. }
  556. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byid);
  557. struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id)
  558. {
  559. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_id_match,
  560. (void *)(unsigned long)alg_id, 1);
  561. }
  562. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byid);
  563. struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id)
  564. {
  565. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_id_match,
  566. (void *)(unsigned long)alg_id, 1);
  567. }
  568. EXPORT_SYMBOL_GPL(xfrm_calg_get_byid);
  569. static int xfrm_alg_name_match(const struct xfrm_algo_desc *entry,
  570. const void *data)
  571. {
  572. const char *name = data;
  573. return name && (!strcmp(name, entry->name) ||
  574. (entry->compat && !strcmp(name, entry->compat)));
  575. }
  576. struct xfrm_algo_desc *xfrm_aalg_get_byname(const char *name, int probe)
  577. {
  578. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_name_match, name,
  579. probe);
  580. }
  581. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname);
  582. struct xfrm_algo_desc *xfrm_ealg_get_byname(const char *name, int probe)
  583. {
  584. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_name_match, name,
  585. probe);
  586. }
  587. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname);
  588. struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe)
  589. {
  590. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_name_match, name,
  591. probe);
  592. }
  593. EXPORT_SYMBOL_GPL(xfrm_calg_get_byname);
  594. struct xfrm_aead_name {
  595. const char *name;
  596. int icvbits;
  597. };
  598. static int xfrm_aead_name_match(const struct xfrm_algo_desc *entry,
  599. const void *data)
  600. {
  601. const struct xfrm_aead_name *aead = data;
  602. const char *name = aead->name;
  603. return aead->icvbits == entry->uinfo.aead.icv_truncbits && name &&
  604. !strcmp(name, entry->name);
  605. }
  606. struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, int probe)
  607. {
  608. struct xfrm_aead_name data = {
  609. .name = name,
  610. .icvbits = icv_len,
  611. };
  612. return xfrm_find_algo(&xfrm_aead_list, xfrm_aead_name_match, &data,
  613. probe);
  614. }
  615. EXPORT_SYMBOL_GPL(xfrm_aead_get_byname);
  616. struct xfrm_algo_desc *xfrm_aalg_get_byidx(unsigned int idx)
  617. {
  618. if (idx >= aalg_entries())
  619. return NULL;
  620. return &aalg_list[idx];
  621. }
  622. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byidx);
  623. struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx)
  624. {
  625. if (idx >= ealg_entries())
  626. return NULL;
  627. return &ealg_list[idx];
  628. }
  629. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byidx);
  630. /*
  631. * Probe for the availability of crypto algorithms, and set the available
  632. * flag for any algorithms found on the system. This is typically called by
  633. * pfkey during userspace SA add, update or register.
  634. */
  635. void xfrm_probe_algs(void)
  636. {
  637. int i, status;
  638. BUG_ON(in_softirq());
  639. for (i = 0; i < aalg_entries(); i++) {
  640. status = crypto_has_hash(aalg_list[i].name, 0,
  641. CRYPTO_ALG_ASYNC);
  642. if (aalg_list[i].available != status)
  643. aalg_list[i].available = status;
  644. }
  645. for (i = 0; i < ealg_entries(); i++) {
  646. status = crypto_has_ablkcipher(ealg_list[i].name, 0, 0);
  647. if (ealg_list[i].available != status)
  648. ealg_list[i].available = status;
  649. }
  650. for (i = 0; i < calg_entries(); i++) {
  651. status = crypto_has_comp(calg_list[i].name, 0,
  652. CRYPTO_ALG_ASYNC);
  653. if (calg_list[i].available != status)
  654. calg_list[i].available = status;
  655. }
  656. }
  657. EXPORT_SYMBOL_GPL(xfrm_probe_algs);
  658. int xfrm_count_pfkey_auth_supported(void)
  659. {
  660. int i, n;
  661. for (i = 0, n = 0; i < aalg_entries(); i++)
  662. if (aalg_list[i].available && aalg_list[i].pfkey_supported)
  663. n++;
  664. return n;
  665. }
  666. EXPORT_SYMBOL_GPL(xfrm_count_pfkey_auth_supported);
  667. int xfrm_count_pfkey_enc_supported(void)
  668. {
  669. int i, n;
  670. for (i = 0, n = 0; i < ealg_entries(); i++)
  671. if (ealg_list[i].available && ealg_list[i].pfkey_supported)
  672. n++;
  673. return n;
  674. }
  675. EXPORT_SYMBOL_GPL(xfrm_count_pfkey_enc_supported);
  676. MODULE_LICENSE("GPL");