1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248
|
<html lang="en">
<head>
<title>GNU TLS 1.4.4</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU TLS 1.4.4">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is last updated 21 March 2006 for version
1.4.4 of GNU TLS.
Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.2 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts, and
no Back-Cover Texts. A copy of the license is included in the
section entitled "GNU Free Documentation License".
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<h1 class="settitle">GNU TLS 1.4.4</h1>
<div class="contents">
<h2>Table of Contents</h2>
<ul>
<li><a name="toc_Top" href="#Top">GNU TLS</a>
<li><a name="toc_Preface" href="#Preface">1 Preface</a>
<li><a name="toc_The-Library" href="#The-Library">2 The Library</a>
<ul>
<li><a href="#General-Idea">2.1 General Idea</a>
<li><a href="#Error-handling">2.2 Error handling</a>
<li><a href="#Memory-handling">2.3 Memory handling</a>
<li><a href="#Callback-functions">2.4 Callback functions</a>
</li></ul>
<li><a name="toc_Introduction-to-TLS" href="#Introduction-to-TLS">3 Introduction to <acronym>TLS</acronym></a>
<ul>
<li><a href="#TLS-layers">3.1 TLS layers</a>
<li><a href="#The-transport-layer">3.2 The transport layer</a>
<li><a href="#The-TLS-record-protocol">3.3 The TLS record protocol</a>
<ul>
<li><a href="#Encryption-algorithms-used-in-the-record-layer">3.3.1 Encryption algorithms used in the record layer</a>
<li><a href="#Compression-algorithms-used-in-the-record-layer">3.3.2 Compression algorithms used in the record layer</a>
<li><a href="#Weaknesses-and-countermeasures">3.3.3 Weaknesses and countermeasures</a>
</li></ul>
<li><a href="#The-TLS-Alert-Protocol">3.4 The TLS Alert Protocol</a>
<li><a href="#The-TLS-Handshake-Protocol">3.5 The TLS Handshake Protocol</a>
<ul>
<li><a href="#The-TLS-Handshake-Protocol">3.5.1 TLS cipher suites</a>
<li><a href="#The-TLS-Handshake-Protocol">3.5.2 Client authentication</a>
<li><a href="#The-TLS-Handshake-Protocol">3.5.3 Resuming Sessions</a>
<li><a href="#The-TLS-Handshake-Protocol">3.5.4 Resuming internals</a>
</li></ul>
<li><a href="#TLS-Extensions">3.6 TLS Extensions</a>
<ul>
<li><a href="#TLS-Extensions">3.6.1 Maximum fragment length negotiation</a>
<li><a href="#TLS-Extensions">3.6.2 Server name indication</a>
</li></ul>
<li><a href="#On-SSL-2-and-older-protocols">3.7 On SSL 2 and older protocols</a>
</li></ul>
<li><a name="toc_Authentication-methods" href="#Authentication-methods">4 Authentication methods</a>
<ul>
<li><a href="#Certificate-authentication">4.1 Certificate authentication</a>
<ul>
<li><a href="#Certificate-authentication">4.1.1 Authentication using <acronym>X.509</acronym> certificates</a>
<li><a href="#Certificate-authentication">4.1.2 Authentication using <acronym>OpenPGP</acronym> keys</a>
<li><a href="#Certificate-authentication">4.1.3 Using certificate authentication</a>
</li></ul>
<li><a href="#Anonymous-authentication">4.2 Anonymous authentication</a>
<li><a href="#Authentication-using-SRP">4.3 Authentication using <acronym>SRP</acronym></a>
<li><a href="#Authentication-using-PSK">4.4 Authentication using <acronym>PSK</acronym></a>
<li><a href="#Authentication-and-credentials">4.5 Authentication and credentials</a>
<li><a href="#Parameters-stored-in-credentials">4.6 Parameters stored in credentials</a>
</li></ul>
<li><a name="toc_More-on-certificate-authentication" href="#More-on-certificate-authentication">5 More on certificate authentication</a>
<ul>
<li><a href="#The-X_002e509-trust-model">5.1 The <acronym>X.509</acronym> trust model</a>
<ul>
<li><a href="#X_002e509-certificates">5.1.1 <acronym>X.509</acronym> certificates</a>
<li><a href="#Verifying-X_002e509-certificate-paths">5.1.2 Verifying <acronym>X.509</acronym> certificate paths</a>
<li><a href="#PKCS-_002310-certificate-requests">5.1.3 <acronym>PKCS</acronym> #10 certificate requests</a>
<li><a href="#PKCS-_002312-structures">5.1.4 <acronym>PKCS</acronym> #12 structures</a>
</li></ul>
<li><a href="#The-OpenPGP-trust-model">5.2 The <acronym>OpenPGP</acronym> trust model</a>
<ul>
<li><a href="#The-OpenPGP-trust-model">5.2.1 <acronym>OpenPGP</acronym> keys</a>
<li><a href="#The-OpenPGP-trust-model">5.2.2 Verifying an <acronym>OpenPGP</acronym> key</a>
</li></ul>
<li><a href="#Digital-signatures">5.3 Digital signatures</a>
<ul>
<li><a href="#Digital-signatures">5.3.1 Supported algorithms</a>
<li><a href="#Digital-signatures">5.3.2 Trading security for interoperability</a>
</li></ul>
</li></ul>
<li><a name="toc_How-to-use-TLS-in-application-protocols" href="#How-to-use-TLS-in-application-protocols">6 How to use <acronym>TLS</acronym> in application protocols</a>
<ul>
<li><a href="#Separate-ports">6.1 Separate ports</a>
<li><a href="#Upward-negotiation">6.2 Upward negotiation</a>
</li></ul>
<li><a name="toc_How-to-use-GnuTLS-in-applications" href="#How-to-use-GnuTLS-in-applications">7 How to use <acronym>GnuTLS</acronym> in applications</a>
<ul>
<li><a href="#Preparation">7.1 Preparation</a>
<ul>
<li><a href="#Headers">7.1.1 Headers</a>
<li><a href="#Version-check">7.1.2 Version check</a>
<li><a href="#Building-the-source">7.1.3 Building the source</a>
</li></ul>
<li><a href="#Multi_002dthreaded-applications">7.2 Multi-threaded applications</a>
<li><a href="#Client-examples">7.3 Client examples</a>
<ul>
<li><a href="#Simple-client-example-with-anonymous-authentication">7.3.1 Simple client example with anonymous authentication</a>
<li><a href="#Simple-client-example-with-X_002e509-certificate-support">7.3.2 Simple client example with <acronym>X.509</acronym> certificate support</a>
<li><a href="#Obtaining-session-information">7.3.3 Obtaining session information</a>
<li><a href="#Verifying-peer_0027s-certificate">7.3.4 Verifying peer's certificate</a>
<li><a href="#Using-a-callback-to-select-the-certificate-to-use">7.3.5 Using a callback to select the certificate to use</a>
<li><a href="#Client-with-Resume-capability-example">7.3.6 Client with Resume capability example</a>
<li><a href="#Simple-client-example-with-SRP-authentication">7.3.7 Simple client example with <acronym>SRP</acronym> authentication</a>
</li></ul>
<li><a href="#Server-examples">7.4 Server examples</a>
<ul>
<li><a href="#Echo-Server-with-X_002e509-authentication">7.4.1 Echo Server with <acronym>X.509</acronym> authentication</a>
<li><a href="#Echo-Server-with-X_002e509-authentication-II">7.4.2 Echo Server with <acronym>X.509</acronym> authentication II</a>
<li><a href="#Echo-Server-with-OpenPGP-authentication">7.4.3 Echo Server with <acronym>OpenPGP</acronym> authentication</a>
<li><a href="#Echo-Server-with-SRP-authentication">7.4.4 Echo Server with <acronym>SRP</acronym> authentication</a>
<li><a href="#Echo-Server-with-anonymous-authentication">7.4.5 Echo Server with anonymous authentication</a>
</li></ul>
<li><a href="#Miscellaneous-examples">7.5 Miscellaneous examples</a>
<ul>
<li><a href="#Checking-for-an-alert">7.5.1 Checking for an alert</a>
<li><a href="#X_002e509-certificate-parsing-example">7.5.2 <acronym>X.509</acronym> certificate parsing example</a>
<li><a href="#Certificate-request-generation">7.5.3 Certificate request generation</a>
<li><a href="#PKCS-_002312-structure-generation">7.5.4 <acronym>PKCS</acronym> #12 structure generation</a>
</li></ul>
<li><a href="#Compatibility-with-the-OpenSSL-library">7.6 Compatibility with the OpenSSL library</a>
</li></ul>
<li><a name="toc_Included-programs" href="#Included-programs">8 Included programs</a>
<ul>
<li><a href="#Invoking-srptool">8.1 Invoking srptool</a>
<li><a href="#Invoking-gnutls_002dcli">8.2 Invoking gnutls-cli</a>
<li><a href="#Invoking-gnutls_002dcli_002ddebug">8.3 Invoking gnutls-cli-debug</a>
<li><a href="#Invoking-gnutls_002dserv">8.4 Invoking gnutls-serv</a>
<li><a href="#Invoking-certtool">8.5 Invoking certtool</a>
</li></ul>
<li><a name="toc_Function-reference" href="#Function-reference">9 Function reference</a>
<ul>
<li><a href="#Core-functions">9.1 Core functions</a>
<li><a href="#X_002e509-certificate-functions">9.2 <acronym>X.509</acronym> certificate functions</a>
<li><a href="#GnuTLS_002dextra-functions">9.3 <acronym>GnuTLS-extra</acronym> functions</a>
<li><a href="#OpenPGP-functions">9.4 <acronym>OpenPGP</acronym> functions</a>
<li><a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">9.5 <acronym>TLS</acronym> Inner Application (<acronym>TLS/IA</acronym>) functions</a>
<li><a href="#Error-codes-and-descriptions">9.6 Error codes and descriptions</a>
</li></ul>
<li><a name="toc_Certificate-to-XML-convertion-functions" href="#Certificate-to-XML-convertion-functions">10 Certificate to <acronym>XML</acronym> convertion functions</a>
<ul>
<li><a href="#An-X_002e509-certificate">10.1 An <acronym>X.509</acronym> certificate</a>
<li><a href="#An-OpenPGP-key">10.2 An <acronym>OpenPGP</acronym> key</a>
</li></ul>
<li><a name="toc_All-the-supported-ciphersuites-in-GnuTLS" href="#All-the-supported-ciphersuites-in-GnuTLS">11 All the supported ciphersuites in <acronym>GnuTLS</acronym></a>
<li><a name="toc_Internal-architecture-of-GnuTLS" href="#Internal-architecture-of-GnuTLS">12 Internal architecture of GnuTLS</a>
<ul>
<li><a href="#Internal-architecture-of-GnuTLS">12.1 The TLS protocol</a>
<li><a href="#Internal-architecture-of-GnuTLS">12.2 TLS Handshake protocol</a>
<li><a href="#Internal-architecture-of-GnuTLS">12.3 TLS authentication methods</a>
<li><a href="#Internal-architecture-of-GnuTLS">12.4 TLS Extension handling</a>
<li><a href="#Internal-architecture-of-GnuTLS">12.5 Certificate handling</a>
</li></ul>
<li><a name="toc_Copying-This-Manual" href="#Copying-This-Manual">Appendix A Copying This Manual</a>
<ul>
<li><a href="#GNU-Free-Documentation-License">A.1 GNU Free Documentation License</a>
<ul>
<li><a href="#GNU-Free-Documentation-License">A.1.1 ADDENDUM: How to use this License for your documents</a>
</li></ul>
</li></ul>
<li><a name="toc_Concept-Index" href="#Concept-Index">Concept Index</a>
<li><a name="toc_Function-and-Data-Index" href="#Function-and-Data-Index">Function and Data Index</a>
<li><a name="toc_Bibliography" href="#Bibliography">Bibliography</a>
</li></ul>
</div>
<div class="node">
<p><hr>
<a name="Top"></a>
Next: <a rel="next" accesskey="n" href="#Preface">Preface</a>,
Up: <a rel="up" accesskey="u" href="#dir">(dir)</a>
</div>
<h2 class="unnumbered">GNU TLS</h2>
<p>This manual is last updated 21 March 2006 for version
1.4.4 of GNU TLS.
<p>Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
<blockquote>
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled “GNU
Free Documentation License”.
</blockquote>
<ul class="menu">
<li><a accesskey="1" href="#Preface">Preface</a>
<li><a accesskey="2" href="#The-Library">The Library</a>
<li><a accesskey="3" href="#Introduction-to-TLS">Introduction to TLS</a>
<li><a accesskey="4" href="#Authentication-methods">Authentication methods</a>
<li><a accesskey="5" href="#More-on-certificate-authentication">More on certificate authentication</a>
<li><a accesskey="6" href="#How-to-use-TLS-in-application-protocols">How to use TLS in application protocols</a>
<li><a accesskey="7" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
<li><a accesskey="8" href="#Included-programs">Included programs</a>
<li><a accesskey="9" href="#Function-reference">Function reference</a>
<li><a href="#Certificate-to-XML-convertion-functions">Certificate to XML convertion functions</a>
<li><a href="#All-the-supported-ciphersuites-in-GnuTLS">All the supported ciphersuites in GnuTLS</a>
<li><a href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a>
<li><a href="#Copying-This-Manual">Copying This Manual</a>
<li><a href="#Concept-Index">Concept Index</a>
<li><a href="#Function-and-Data-Index">Function and Data Index</a>
<!-- * @mybibnode{}:: -->
<li><a href="#Bibliography">Bibliography</a>
</ul>
<div class="node">
<p><hr>
<a name="Preface"></a>
Next: <a rel="next" accesskey="n" href="#The-Library">The Library</a>,
Previous: <a rel="previous" accesskey="p" href="#Top">Top</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">1 Preface</h2>
<p>This document tries to demonstrate and explain the <acronym>GnuTLS</acronym>
library API. A brief introduction to the protocols and the technology
involved, is also included so that an application programmer can
better understand the <acronym>GnuTLS</acronym> purpose and actual offerings.
Even if <acronym>GnuTLS</acronym> is a typical library software, it operates
over several security and cryptographic protocols, which require the
programmer to make careful and correct usage of them, otherwise he
risks to offer just a false sense of security. Security and the
network security terms are very general terms even for computer
software thus cannot be easily restricted to a single cryptographic
library. For that reason, do not consider a program secure just
because it uses <acronym>GnuTLS</acronym>; there are several ways to compromise
a program or a communication line and <acronym>GnuTLS</acronym> only helps with
some of them.
<p>Although this document tries to be self contained, basic network
programming and PKI knowlegde is assumed in most of it. A good introduction
to networking can be found in <!-- %**else if -->
[STEVENS] (See <a href="#Bibliography">STEVENS</a>.)
and for
Public Key Infrastructure in <!-- %**else if -->
[GUTPKI] (See <a href="#Bibliography">GUTPKI</a>.)
.
<p><a name="Availability"></a>
<p>Updated versions of the <acronym>GnuTLS</acronym> software and this document
will be available from <a href="http://www.gnutls.org/">http://www.gnutls.org/</a> and
<a href="http://www.gnu.org/software/gnutls/">http://www.gnu.org/software/gnutls/</a>.
<div class="node">
<p><hr>
<a name="The-Library"></a>
Next: <a rel="next" accesskey="n" href="#Introduction-to-TLS">Introduction to TLS</a>,
Previous: <a rel="previous" accesskey="p" href="#Preface">Preface</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">2 The Library</h2>
<p>In brief <acronym>GnuTLS</acronym> can be described as a library which offers an API
to access secure communication protocols. These protocols provide
privacy over insecure lines, and were designed to prevent
eavesdropping, tampering, or message forgery.
<p>Technically <acronym>GnuTLS</acronym> is a portable ANSI C based library which
implements the TLS 1.1 and SSL 3.0 protocols (See <a href="#Introduction-to-TLS">Introduction to TLS</a>, for a more detailed description of the protocols), accompanied
with the required framework for authentication and public key
infrastructure. The library is available under the GNU Lesser GPL
license<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>. Important features of the <acronym>GnuTLS</acronym> library
include:
<ul>
<li>Support for TLS 1.0, TLS 1.1, and SSL 3.0 protocols.
<li>Support for both <acronym>X.509</acronym> and <acronym>OpenPGP</acronym> certificates.
<li>Support for handling and verification of certificates.
<li>Support for <acronym>SRP</acronym> for TLS authentication.
<li>Support for <acronym>PSK</acronym> for TLS authentication.
<li>Support for TLS Extension mechanism.
<li>Support for TLS Compression Methods.
</ul>
<p>Additionally <acronym>GnuTLS</acronym> provides a limited emulation API for the
widely used OpenSSL<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a> library,
to ease integration with existing applications.
<p><acronym>GnuTLS</acronym> consists of three independent parts, namely the “TLS
protocol part”, the “Certificate part”, and the “Crypto backend”
part. The `TLS protocol part' is the actual protocol implementation,
and is entirely implemented within the <acronym>GnuTLS</acronym> library. The
`Certificate part' consists of the certificate parsing, and
verification functions which is partially implemented in the
<acronym>GnuTLS</acronym> library. The
<acronym>Libtasn1</acronym><a rel="footnote" href="#fn-3" name="fnd-3"><sup>3</sup></a>,
a library which offers <acronym>ASN.1</acronym> parsing capabilities, is used
for the <acronym>X.509</acronym> certificate parsing functions, and
<acronym>Opencdk</acronym><a rel="footnote" href="#fn-4" name="fnd-4"><sup>4</sup></a>
is used for the <acronym>OpenPGP</acronym> key support in <acronym>GnuTLS</acronym>.
The “Crypto backend” is provided by the
<acronym>Libgcrypt</acronym><a rel="footnote" href="#fn-5" name="fnd-5"><sup>5</sup></a>
library.
<p>In order to ease integration in embedded systems, parts of the
<acronym>GnuTLS</acronym> library can be disabled at compile time. That way a
small library, with the required features, can be generated.
<ul class="menu">
<li><a accesskey="1" href="#General-Idea">General Idea</a>
<li><a accesskey="2" href="#Error-handling">Error handling</a>
<li><a accesskey="3" href="#Memory-handling">Memory handling</a>
<li><a accesskey="4" href="#Callback-functions">Callback functions</a>
</ul>
<div class="node">
<p><hr>
<a name="General-Idea"></a>
Next: <a rel="next" accesskey="n" href="#Error-handling">Error handling</a>,
Up: <a rel="up" accesskey="u" href="#The-Library">The Library</a>
</div>
<h3 class="section">2.1 General Idea</h3>
<p>A brief description of how <acronym>GnuTLS</acronym> works internally is shown
at the figure below. This section may be easier to understand after
having seen the examples (see <a href="#examples">examples</a>).
<div class="block-image"><img src="internals.png" alt="internals.png"></div>
<p>As shown in the figure, there is a read-only global state that is
initialized once by the global initialization function. This global
structure, among others, contains the memory allocation functions
used, and some structures needed for the <acronym>ASN.1</acronym> parser. This structure
is never modified by any <acronym>GnuTLS</acronym> function, except for the
deinitialization function which frees all memory allocated in the
global structure and is called after the program has permanently
finished using <acronym>GnuTLS</acronym>.
<p>The credentials structure is used by some authentication methods, such
as certificate authentication (see <a href="#Certificate-Authentication">Certificate Authentication</a>). A
credentials structure may contain certificates, private keys,
temporary parameters for diffie hellman or RSA key exchange, and other
stuff that may be shared between several TLS sessions.
<p>This structure should be initialized using the appropriate
initialization functions. For example an application which uses
certificate authentication would probably initialize the credentials,
using the appropriate functions, and put its trusted certificates in
this structure. The next step is to associate the credentials
structure with each <acronym>TLS</acronym> session.
<p>A <acronym>GnuTLS</acronym> session contains all the required stuff for a
session to handle one secure connection. This session calls directly
to the transport layer functions, in order to communicate with the
peer. Every session has a unique session ID shared with the peer.
<p>Since TLS sessions can be resumed, servers would probably need a
database backend to hold the session's parameters. Every
<acronym>GnuTLS</acronym> session after a successful handshake calls the
appropriate backend function (See <a href="#resume">resume</a>, for information on
initialization) to store the newly negotiated session. The session
database is examined by the server just after having received the
client hello<a rel="footnote" href="#fn-6" name="fnd-6"><sup>6</sup></a>,
and if the session ID sent by the client, matches a stored session,
the stored session will be retrieved, and the new session will be a
resumed one, and will share the same session ID with the previous one.
<div class="node">
<p><hr>
<a name="Error-handling"></a>
Next: <a rel="next" accesskey="n" href="#Memory-handling">Memory handling</a>,
Previous: <a rel="previous" accesskey="p" href="#General-Idea">General Idea</a>,
Up: <a rel="up" accesskey="u" href="#The-Library">The Library</a>
</div>
<h3 class="section">2.2 Error handling</h3>
<p>In <acronym>GnuTLS</acronym> most functions return an integer type as a result. In
almost all cases a zero or a positive number means success, and a
negative number indicates failure, or a situation that some action has
to be taken. Thus negative error codes may be fatal or not.
<p>Fatal errors terminate the connection immediately and further sends
and receives will be disallowed. An example of a fatal error code is
<code>GNUTLS_E_DECRYPTION_FAILED</code>. Non-fatal errors may warn about
something, i.e., a warning alert was received, or indicate the some
action has to be taken. This is the case with the error code
<code>GNUTLS_E_REHANDSHAKE</code> returned by <a href="#gnutls_005frecord_005frecv">gnutls_record_recv</a>.
This error code indicates that the server requests a re-handshake. The
client may ignore this request, or may reply with an alert. You can
test if an error code is a fatal one by using the
<a href="#gnutls_005ferror_005fis_005ffatal">gnutls_error_is_fatal</a>.
<p>If any non fatal errors, that require an action, are to be returned by
a function, these error codes will be documented in the function's
reference. See <a href="#Error-Codes">Error Codes</a>, for all the error codes.
<div class="node">
<p><hr>
<a name="Memory-handling"></a>
Next: <a rel="next" accesskey="n" href="#Callback-functions">Callback functions</a>,
Previous: <a rel="previous" accesskey="p" href="#Error-handling">Error handling</a>,
Up: <a rel="up" accesskey="u" href="#The-Library">The Library</a>
</div>
<h3 class="section">2.3 Memory handling</h3>
<p><acronym>GnuTLS</acronym> internally handles heap allocated objects
differently, depending on the sensitivity of the data they
contain. However for performance reasons, the default memory functions
do not overwrite sensitive data from memory, nor protect such objects
from being written to the swap. In order to change the default
behavior the <a href="#gnutls_005fglobal_005fset_005fmem_005ffunctions">gnutls_global_set_mem_functions</a> function is
available which can be used to set other memory handlers than the
defaults.
<p>The <acronym>Libgcrypt</acronym> library on which <acronym>GnuTLS</acronym> depends, has such
secure memory allocation functions available. These should be used in
cases where even the system's swap memory is not considered
secure. See the documentation of <acronym>Libgcrypt</acronym> for more
information.
<div class="node">
<p><hr>
<a name="Callback-functions"></a>
Previous: <a rel="previous" accesskey="p" href="#Memory-handling">Memory handling</a>,
Up: <a rel="up" accesskey="u" href="#The-Library">The Library</a>
</div>
<h3 class="section">2.4 Callback functions</h3>
<p><a name="index-Callback-functions-1"></a>
There are several cases where <acronym>GnuTLS</acronym> may need some out of
band input from your program. This is now implemented using some
callback functions, which your program is expected to register.
<p>An example of this type of functions are the push and pull callbacks
which are used to specify the functions that will retrieve and send
data to the transport layer.
<ul>
<li><a href="#gnutls_005ftransport_005fset_005fpush_005ffunction">gnutls_transport_set_push_function</a>
<li><a href="#gnutls_005ftransport_005fset_005fpull_005ffunction">gnutls_transport_set_pull_function</a>
</ul>
<p>Other callback functions such as the one set by
<a href="#gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction">gnutls_srp_set_server_credentials_function</a>, may require more
complicated input, including data to be allocated. These callbacks
should allocate and free memory using the functions shown below.
<ul>
<li><a href="#gnutls_005fmalloc">gnutls_malloc</a>
<li><a href="#gnutls_005ffree">gnutls_free</a>
</ul>
<div class="node">
<p><hr>
<a name="Introduction-to-TLS"></a>
Next: <a rel="next" accesskey="n" href="#Authentication-methods">Authentication methods</a>,
Previous: <a rel="previous" accesskey="p" href="#The-Library">The Library</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">3 Introduction to <acronym>TLS</acronym></h2>
<p><acronym>TLS</acronym> stands for “Transport Layer Security” and is the
successor of SSL, the Secure Sockets Layer protocol <!-- %**else if -->
[SSL3] (See <a href="#Bibliography">SSL3</a>.)
designed by Netscape. <acronym>TLS</acronym> is an Internet
protocol, defined by <acronym>IETF</acronym><a rel="footnote" href="#fn-7" name="fnd-7"><sup>7</sup></a>, described in
<acronym>RFC</acronym> 2246 and also in <!-- %**else if -->
[RESCOLA] (See <a href="#Bibliography">RESCOLA</a>.)
. The protocol provides
confidentiality, and authentication layers over any reliable transport
layer. The description, below, refers to <acronym>TLS</acronym> 1.0 but also
applies to <acronym>TLS</acronym> 1.1 <!-- %**else if -->
[RFC4346] (See <a href="#Bibliography">RFC4346</a>.)
and <acronym>SSL</acronym> 3.0, since the
differences of these protocols are minor. Older protocols such as
<acronym>SSL</acronym> 2.0 are not discussed nor implemented in
<acronym>GnuTLS</acronym> since they are not considered secure today.
<ul class="menu">
<li><a accesskey="1" href="#TLS-layers">TLS layers</a>
<li><a accesskey="2" href="#The-transport-layer">The transport layer</a>
<li><a accesskey="3" href="#The-TLS-record-protocol">The TLS record protocol</a>
<li><a accesskey="4" href="#The-TLS-Alert-Protocol">The TLS Alert Protocol</a>
<li><a accesskey="5" href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a>
<li><a accesskey="6" href="#TLS-Extensions">TLS Extensions</a>
<li><a accesskey="7" href="#On-SSL-2-and-older-protocols">On SSL 2 and older protocols</a>
</ul>
<div class="node">
<p><hr>
<a name="TLS-layers"></a>
Next: <a rel="next" accesskey="n" href="#The-transport-layer">The transport layer</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.1 TLS layers</h3>
<p><a name="index-TLS-Layers-2"></a>
<acronym>TLS</acronym> is a layered protocol, and consists of the Record
Protocol, the Handshake Protocol and the Alert Protocol. The Record
Protocol is to serve all other protocols and is above the transport
layer. The Record protocol offers symmetric encryption, data
authenticity, and optionally compression.
<p>The Alert protocol offers some signaling to the other protocols. It
can help informing the peer for the cause of failures and other error
conditions. See <a href="#The-Alert-Protocol">The Alert Protocol</a>, for more information. The
alert protocol is above the record protocol.
<p>The Handshake protocol is responsible for the security parameters'
negotiation, the initial key exchange and authentication. See <a href="#The-Handshake-Protocol">The Handshake Protocol</a>, for more information about the handshake
protocol. The protocol layering in TLS is shown in the figure below.
<div class="block-image"><img src="layers.png" alt="layers.png"></div>
<div class="node">
<p><hr>
<a name="The-transport-layer"></a>
Next: <a rel="next" accesskey="n" href="#The-TLS-record-protocol">The TLS record protocol</a>,
Previous: <a rel="previous" accesskey="p" href="#TLS-layers">TLS layers</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.2 The transport layer</h3>
<p><a name="index-Transport-protocol-3"></a>
<acronym>TLS</acronym> is not limited to one transport layer, it can be used
above any transport layer, as long as it is a reliable one. A set of
functions is provided and their purpose is to load to <acronym>GnuTLS</acronym> the
required callbacks to access the transport layer.
<ul>
<li><a href="#gnutls_005ftransport_005fset_005fpush_005ffunction">gnutls_transport_set_push_function</a>
<li><a href="#gnutls_005ftransport_005fset_005fpull_005ffunction">gnutls_transport_set_pull_function</a>
<li><a href="#gnutls_005ftransport_005fset_005fptr">gnutls_transport_set_ptr</a>
<li><a href="#gnutls_005ftransport_005fset_005flowat">gnutls_transport_set_lowat</a>
</ul>
<p>These functions accept a callback function as a parameter. The
callback functions should return the number of bytes written, or -1 on
error and should set <code>errno</code> appropriately.
<p><acronym>GnuTLS</acronym> currently only interprets the EINTR and EAGAIN errno
values and returns the corresponding <acronym>GnuTLS</acronym> error codes
<code>GNUTLS_E_INTERRUPTED</code> and <code>GNUTLS_E_AGAIN</code>. These values
are usually returned by interrupted system calls, or when non blocking
IO is used. All <acronym>GnuTLS</acronym> functions can be resumed (called
again), if any of these error codes is returned. The error codes
above refer to the system call, not the <acronym>GnuTLS</acronym> function,
since signals do not interrupt <acronym>GnuTLS</acronym>' functions.
<p>For non blocking sockets or other custom made pull/push functions
the <a href="#gnutls_005ftransport_005fset_005flowat">gnutls_transport_set_lowat</a> must be called, with a zero
low water mark value.
<p>By default, if the transport functions are not set, <acronym>GnuTLS</acronym>
will use the Berkeley Sockets functions. In this case
<acronym>GnuTLS</acronym> will use some hacks in order for <code>select</code> to
work, thus making it easy to add <acronym>TLS</acronym> support to existing
TCP/IP servers.
<div class="node">
<p><hr>
<a name="The-TLS-record-protocol"></a>
Next: <a rel="next" accesskey="n" href="#The-TLS-Alert-Protocol">The TLS Alert Protocol</a>,
Previous: <a rel="previous" accesskey="p" href="#The-transport-layer">The transport layer</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.3 The TLS record protocol</h3>
<p><a name="index-Record-protocol-4"></a>
The Record protocol is the secure communications provider. Its purpose
is to encrypt, authenticate and —optionally— compress packets.
The following functions are available:
<dl>
<dt><a href="#gnutls_005frecord_005fsend">gnutls_record_send</a>:<dd>To send a record packet (with application data).
<br><dt><a href="#gnutls_005frecord_005frecv">gnutls_record_recv</a>:<dd>To receive a record packet (with application data).
<br><dt><a href="#gnutls_005frecord_005fget_005fdirection">gnutls_record_get_direction</a>:<dd>To get the direction of the last interrupted function call.
</dl>
<p>As you may have already noticed, the functions which access the Record
protocol, are quite limited, given the importance of this protocol in
<acronym>TLS</acronym>. This is because the Record protocol's parameters are
all set by the Handshake protocol.
<p>The Record protocol initially starts with NULL parameters, which means
no encryption, and no MAC is used. Encryption and authentication begin
just after the handshake protocol has finished.
<ul class="menu">
<li><a accesskey="1" href="#Encryption-algorithms-used-in-the-record-layer">Encryption algorithms used in the record layer</a>
<li><a accesskey="2" href="#Compression-algorithms-used-in-the-record-layer">Compression algorithms used in the record layer</a>
<li><a accesskey="3" href="#Weaknesses-and-countermeasures">Weaknesses and countermeasures</a>
</ul>
<div class="node">
<p><hr>
<a name="Encryption-algorithms-used-in-the-record-layer"></a>
Next: <a rel="next" accesskey="n" href="#Compression-algorithms-used-in-the-record-layer">Compression algorithms used in the record layer</a>,
Up: <a rel="up" accesskey="u" href="#The-TLS-record-protocol">The TLS record protocol</a>
</div>
<h4 class="subsection">3.3.1 Encryption algorithms used in the record layer</h4>
<p><a name="index-Symmetric-encryption-algorithms-5"></a>
Confidentiality in the record layer is achieved by using symmetric
block encryption algorithms like <code>3DES</code>, <code>AES</code><a rel="footnote" href="#fn-8" name="fnd-8"><sup>8</sup></a>, or stream algorithms like
<code>ARCFOUR_128</code><a rel="footnote" href="#fn-9" name="fnd-9"><sup>9</sup></a>. Ciphers are encryption algorithms that use a single, secret,
key to encrypt and decrypt data. Block algorithms in TLS also provide
protection against statistical analysis of the data. Thus, if you're
using the <acronym>TLS</acronym> protocol, a random number of blocks will be
appended to data, to prevent eavesdroppers from guessing the actual
data size.
<p>Supported cipher algorithms:
<dl>
<dt><code>3DES_CBC</code><dd><code>3DES_CBC</code> is the DES block cipher algorithm used with triple
encryption (EDE). Has 64 bits block size and is used in CBC mode.
<br><dt><code>ARCFOUR_128</code><dd>ARCFOUR is a fast stream cipher.
<br><dt><code>ARCFOUR_40</code><dd>This is the ARCFOUR cipher that is fed with a 40 bit key,
which is considered weak.
<br><dt><code>AES_CBC</code><dd>AES or RIJNDAEL is the block cipher algorithm that replaces the old
DES algorithm. Has 128 bits block size and is used in CBC mode. This
is not officially supported in TLS.
</dl>
<p>Supported MAC algorithms:
<dl>
<dt><code>MAC_MD5</code><dd>MD5 is a cryptographic hash algorithm designed by Ron Rivest. Outputs
128 bits of data.
<br><dt><code>MAC_SHA</code><dd>SHA is a cryptographic hash algorithm designed by NSA. Outputs 160
bits of data.
</dl>
<div class="node">
<p><hr>
<a name="Compression-algorithms-used-in-the-record-layer"></a>
Next: <a rel="next" accesskey="n" href="#Weaknesses-and-countermeasures">Weaknesses and countermeasures</a>,
Previous: <a rel="previous" accesskey="p" href="#Encryption-algorithms-used-in-the-record-layer">Encryption algorithms used in the record layer</a>,
Up: <a rel="up" accesskey="u" href="#The-TLS-record-protocol">The TLS record protocol</a>
</div>
<h4 class="subsection">3.3.2 Compression algorithms used in the record layer</h4>
<p><a name="index-Compression-algorithms-6"></a>
The TLS record layer also supports compression. The algorithms
implemented in <acronym>GnuTLS</acronym> can be found in the table below.
All the algorithms except for DEFLATE which is
referenced in <!-- %**else if -->
[RFC3749] (See <a href="#Bibliography">RFC3749</a>.)
, should be considered as
<acronym>GnuTLS</acronym>' extensions<a rel="footnote" href="#fn-10" name="fnd-10"><sup>10</sup></a>, and should be advertised only when the peer is known to
have a compliant client, to avoid interoperability problems.
<p>The included algorithms perform really good when text, or other
compressible data are to be transfered, but offer nothing on already
compressed data, such as compressed images, zipped archives etc.
These compression algorithms, may be useful in high bandwidth TLS
tunnels, and in cases where network usage has to be minimized. As a
drawback, compression increases latency.
<p>The record layer compression in <acronym>GnuTLS</acronym> is implemented based
on the proposal <!-- %**else if -->
[RFC3749] (See <a href="#Bibliography">RFC3749</a>.)
.
The supported compression algorithms are:
<dl>
<dt><code>DEFLATE</code><dd>Zlib compression, using the deflate algorithm.
<br><dt><code>LZO</code><dd>LZO is a very fast compression algorithm. This algorithm is only
available if the <acronym>GnuTLS-extra</acronym> library has been initialized
and the private extensions are enabled.
</dl>
<div class="node">
<p><hr>
<a name="Weaknesses-and-countermeasures"></a>
Previous: <a rel="previous" accesskey="p" href="#Compression-algorithms-used-in-the-record-layer">Compression algorithms used in the record layer</a>,
Up: <a rel="up" accesskey="u" href="#The-TLS-record-protocol">The TLS record protocol</a>
</div>
<h4 class="subsection">3.3.3 Weaknesses and countermeasures</h4>
<p>Some weaknesses that may affect the security of the Record layer have
been found in <acronym>TLS</acronym> 1.0 protocol. These weaknesses can be
exploited by active attackers, and exploit the facts that
<ol type=1 start=1>
<li><acronym>TLS</acronym> has separate alerts for “decryption_failed” and
“bad_record_mac”
<li>The decryption failure reason can be detected by timing the response
time.
<li>The IV for CBC encrypted packets is the last block of the previous
encrypted packet.
</ol>
<p>Those weaknesses were solved in <acronym>TLS</acronym> 1.1 <!-- %**else if -->
[RFC4346] (See <a href="#Bibliography">RFC4346</a>.)
which is implemented
in <acronym>GnuTLS</acronym>. For a detailed discussion see the archives of the
TLS Working Group mailing list and the paper <!-- %**else if -->
[CBCATT] (See <a href="#Bibliography">CBCATT</a>.)
.
<div class="node">
<p><hr>
<a name="The-TLS-Alert-Protocol"></a>
Next: <a rel="next" accesskey="n" href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a>,
Previous: <a rel="previous" accesskey="p" href="#The-TLS-record-protocol">The TLS record protocol</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.4 The TLS Alert Protocol</h3>
<p><a name="The-Alert-Protocol"></a>
<a name="index-Alert-protocol-7"></a>
The Alert protocol is there to allow signals to be sent between peers.
These signals are mostly used to inform the peer about the cause of a
protocol failure. Some of these signals are used internally by the
protocol and the application protocol does not have to cope with them
(see <code>GNUTLS_A_CLOSE_NOTIFY</code>), and others refer to the
application protocol solely (see <code>GNUTLS_A_USER_CANCELLED</code>). An
alert signal includes a level indication which may be either fatal or
warning. Fatal alerts always terminate the current connection, and
prevent future renegotiations using the current session ID.
<p>The alert messages are protected by the record protocol, thus the
information that is included does not leak. You must take extreme care
for the alert information not to leak to a possible attacker, via
public log files etc.
<dl>
<dt><a href="#gnutls_005falert_005fsend">gnutls_alert_send</a>:<dd>To send an alert signal.
<br><dt><a href="#gnutls_005ferror_005fto_005falert">gnutls_error_to_alert</a>:<dd>To map a gnutls error number to an alert signal.
<br><dt><a href="#gnutls_005falert_005fget">gnutls_alert_get</a>:<dd>Returns the last received alert.
<br><dt><a href="#gnutls_005falert_005fget_005fname">gnutls_alert_get_name</a>:<dd>Returns the name, in a character array, of the given alert.
</dl>
<div class="node">
<p><hr>
<a name="The-TLS-Handshake-Protocol"></a>
Next: <a rel="next" accesskey="n" href="#TLS-Extensions">TLS Extensions</a>,
Previous: <a rel="previous" accesskey="p" href="#The-TLS-Alert-Protocol">The TLS Alert Protocol</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.5 The TLS Handshake Protocol</h3>
<p><a name="The-Handshake-Protocol"></a>
<a name="index-Handshake-protocol-8"></a>
The Handshake protocol is responsible for the ciphersuite negotiation,
the initial key exchange, and the authentication of the two peers.
This is fully controlled by the application layer, thus your program
has to set up the required parameters. Available functions to control
the handshake protocol include:
<dl>
<dt><a href="#gnutls_005fcipher_005fset_005fpriority">gnutls_cipher_set_priority</a>:<dd>To set the priority of bulk cipher algorithms.
<br><dt><a href="#gnutls_005fmac_005fset_005fpriority">gnutls_mac_set_priority</a>:<dd>To set the priority of MAC algorithms.
<br><dt><a href="#gnutls_005fkx_005fset_005fpriority">gnutls_kx_set_priority</a>:<dd>To set the priority of key exchange algorithms.
<br><dt><a href="#gnutls_005fcompression_005fset_005fpriority">gnutls_compression_set_priority</a>:<dd>To set the priority of compression methods.
<br><dt><a href="#gnutls_005fcertificate_005ftype_005fset_005fpriority">gnutls_certificate_type_set_priority</a>:<dd>To set the priority of certificate types (e.g., <acronym>OpenPGP</acronym>,
<acronym>X.509</acronym>).
<br><dt><a href="#gnutls_005fprotocol_005fset_005fpriority">gnutls_protocol_set_priority</a>:<dd>To set the priority of protocol versions (e.g., <acronym>SSL</acronym> 3.0,
<acronym>TLS</acronym> 1.0).
<br><dt><a href="#gnutls_005fset_005fdefault_005fpriority">gnutls_set_default_priority</a>:<dd>To set some defaults in the current session. That way you don't have
to call each priority function, independently, but you have to live
with the defaults.
<br><dt><a href="#gnutls_005fcredentials_005fset">gnutls_credentials_set</a>:<dd>To set the appropriate credentials structures.
<br><dt><a href="#gnutls_005fcertificate_005fserver_005fset_005frequest">gnutls_certificate_server_set_request</a>:<dd>To set whether client certificate is required or not.
<br><dt><a href="#gnutls_005fhandshake">gnutls_handshake</a>:<dd>To initiate the handshake.
</dl>
<h4 class="subsection">3.5.1 TLS cipher suites</h4>
<p>The Handshake Protocol of <acronym>TLS</acronym> negotiates cipher suites of
the form <code>TLS_DHE_RSA_WITH_3DES_CBC_SHA</code>. The usual cipher
suites contain these parameters:
<ul>
<li>The key exchange algorithm.
<code>DHE_RSA</code> in the example.
<li>The Symmetric encryption algorithm and mode
<code>3DES_CBC</code> in this example.
<li>The MAC<a rel="footnote" href="#fn-11" name="fnd-11"><sup>11</sup></a> algorithm used for authentication.
<code>MAC_SHA</code> is used in the above example.
</ul>
<p>The cipher suite negotiated in the handshake protocol will affect the
Record Protocol, by enabling encryption and data authentication. Note
that you should not over rely on <acronym>TLS</acronym> to negotiate the
strongest available cipher suite. Do not enable ciphers and algorithms
that you consider weak.
<p>The priority functions, dicussed above, allow the application layer to
enable and set priorities on the individual ciphers. It may imply that
all combinations of ciphersuites are allowed, but this is not
true. For several reasons, not discussed here, some combinations were
not defined in the <acronym>TLS</acronym> protocol. The supported ciphersuites
are shown in <a href="#ciphersuites">ciphersuites</a>.
<h4 class="subsection">3.5.2 Client authentication</h4>
<p><a name="index-Client-Certificate-authentication-9"></a>
In the case of ciphersuites that use certificate authentication, the
authentication of the client is optional in <acronym>TLS</acronym>. A server
may request a certificate from the client — using the
<a href="#gnutls_005fcertificate_005fserver_005fset_005frequest">gnutls_certificate_server_set_request</a> function. If a
certificate is to be requested from the client during the handshake,
the server will send a certificate request message that contains a
list of acceptable certificate signers. In <acronym>GnuTLS</acronym> the certificate
signers list is constructed using the trusted Certificate Authorities by the
server. That is the ones set using
<ul>
<li><a href="#gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile">gnutls_certificate_set_x509_trust_file</a>
<li><a href="#gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem">gnutls_certificate_set_x509_trust_mem</a>
</ul>
<p>Sending of the names of the CAs can be controlled using
<a href="#gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence">gnutls_certificate_send_x509_rdn_sequence</a>. The client, then,
may send a certificate, signed by one of the server's acceptable
signers.
<h4 class="subsection">3.5.3 Resuming Sessions</h4>
<p><a name="resume"></a>
<a name="index-Resuming-sessions-10"></a>
The <a href="#gnutls_005fhandshake">gnutls_handshake</a> function, is expensive since a lot of
calculations are performed. In order to support many fast connections
to the same server a client may use session resuming. <strong>Session
resuming</strong> is a feature of the <acronym>TLS</acronym> protocol which allows a
client to connect to a server, after a successful handshake, without
the expensive calculations. This is achieved by using the previously
established keys. <acronym>GnuTLS</acronym> supports this feature, and the
example (see <a href="#ex_003aresume_002dclient">ex:resume-client</a>) illustrates a typical use of it.
<p>Keep in mind that sessions are expired after some time, for security
reasons, thus it may be normal for a server not to resume a session
even if you requested that. Also note that you must enable, using the
priority functions, at least the algorithms used in the last session.
<h4 class="subsection">3.5.4 Resuming internals</h4>
<p>The resuming capability, mostly in the server side, is one of the
problems of a thread-safe TLS implementations. The problem is that all
threads must share information in order to be able to resume
sessions. The gnutls approach is, in case of a client, to leave all
the burden of resuming to the client. I.e., copy and keep the necessary
parameters. See the functions:
<ul>
<li><a href="#gnutls_005fsession_005fget_005fdata">gnutls_session_get_data</a>
<li><a href="#gnutls_005fsession_005fget_005fid">gnutls_session_get_id</a>
<li><a href="#gnutls_005fsession_005fset_005fdata">gnutls_session_set_data</a>
</ul>
<p>The server side is different. A server has to specify some callback
functions which store, retrieve and delete session data. These can be
registered with:
<ul>
<li><a href="#gnutls_005fdb_005fset_005fremove_005ffunction">gnutls_db_set_remove_function</a>
<li><a href="#gnutls_005fdb_005fset_005fstore_005ffunction">gnutls_db_set_store_function</a>
<li><a href="#gnutls_005fdb_005fset_005fretrieve_005ffunction">gnutls_db_set_retrieve_function</a>
<li><a href="#gnutls_005fdb_005fset_005fptr">gnutls_db_set_ptr</a>
</ul>
<p>It might also be useful to be able to check for expired sessions in
order to remove them, and save space. The function
<a href="#gnutls_005fdb_005fcheck_005fentry">gnutls_db_check_entry</a> is provided for that reason.
<div class="node">
<p><hr>
<a name="TLS-Extensions"></a>
Next: <a rel="next" accesskey="n" href="#On-SSL-2-and-older-protocols">On SSL 2 and older protocols</a>,
Previous: <a rel="previous" accesskey="p" href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.6 TLS Extensions</h3>
<p><a name="index-TLS-Extensions-11"></a>
A number of extensions to the <acronym>TLS</acronym> protocol have been
proposed mainly in <!-- %**else if -->
[TLSEXT] (See <a href="#Bibliography">TLSEXT</a>.)
. The extensions supported
in <acronym>GnuTLS</acronym> are:
<ul>
<li>Maximum fragment length negotiation
<li>Server name indication
</ul>
<p>and they will be discussed in the subsections that follow.
<h4 class="subsection">3.6.1 Maximum fragment length negotiation</h4>
<p><a name="index-TLS-Extensions-12"></a><a name="index-Maximum-fragment-length-13"></a>
This extension allows a <acronym>TLS</acronym> implementation to negotiate a
smaller value for record packet maximum length. This extension may be
useful to clients with constrained capabilities. See the
<a href="#gnutls_005frecord_005fset_005fmax_005fsize">gnutls_record_set_max_size</a> and the
<a href="#gnutls_005frecord_005fget_005fmax_005fsize">gnutls_record_get_max_size</a> functions.
<h4 class="subsection">3.6.2 Server name indication</h4>
<p><a name="serverind"></a>
<a name="index-TLS-Extensions-14"></a><a name="index-Server-name-indication-15"></a>
A common problem in <acronym>HTTPS</acronym> servers is the fact that the
<acronym>TLS</acronym> protocol is not aware of the hostname that a client
connects to, when the handshake procedure begins. For that reason the
<acronym>TLS</acronym> server has no way to know which certificate to send.
<p>This extension solves that problem within the <acronym>TLS</acronym> protocol,
and allows a client to send the HTTP hostname before the handshake
begins within the first handshake packet. The functions
<a href="#gnutls_005fserver_005fname_005fset">gnutls_server_name_set</a> and <a href="#gnutls_005fserver_005fname_005fget">gnutls_server_name_get</a> can be
used to enable this extension, or to retrieve the name sent by a
client.
<div class="node">
<p><hr>
<a name="On-SSL-2-and-older-protocols"></a>
Previous: <a rel="previous" accesskey="p" href="#TLS-Extensions">TLS Extensions</a>,
Up: <a rel="up" accesskey="u" href="#Introduction-to-TLS">Introduction to TLS</a>
</div>
<h3 class="section">3.7 On SSL 2 and older protocols</h3>
<p><a name="index-SSL-2-16"></a>
One of the initial decisions in the <acronym>GnuTLS</acronym> development was
to implement the known security protocols for the transport layer.
Initially <acronym>TLS</acronym> 1.0 was implemented since it was the latest at
that time, and was considered to be the most advanced in security
properties. Later the <acronym>SSL</acronym> 3.0 protocol was implemented
since it is still the only protocol supported by several servers and
there are no serious security vulnerabilities known.
<p>One question that may arise is why we didn't implement <acronym>SSL</acronym>
2.0 in the library. There are several reasons, most important being
that it has serious security flaws, unacceptable for a modern security
library. Other than that, this protocol is barely used by anyone
these days since it has been deprecated since 1996.
<p><a name="index-PCT-17"></a>Other protocols such as Microsoft's <acronym>PCT</acronym> 1 and <acronym>PCT</acronym>
2 were not implemented because they were also abandoned and deprecated
by <acronym>SSL</acronym> 3.0 and later <acronym>TLS</acronym> 1.0.
<div class="node">
<p><hr>
<a name="Authentication-methods"></a>
Next: <a rel="next" accesskey="n" href="#More-on-certificate-authentication">More on certificate authentication</a>,
Previous: <a rel="previous" accesskey="p" href="#Introduction-to-TLS">Introduction to TLS</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">4 Authentication methods</h2>
<p>The <acronym>TLS</acronym> protocol provides confidentiality and encryption,
but also offers authentication, which is a prerequisite for a secure
connection. The available authentication methods in <acronym>GnuTLS</acronym>
are:
<ul>
<li>Certificate authentication
<li>Anonymous authentication
<li><acronym>SRP</acronym> authentication
<li><acronym>PSK</acronym> authentication
</ul>
<ul class="menu">
<li><a accesskey="1" href="#Certificate-authentication">Certificate authentication</a>
<li><a accesskey="2" href="#Anonymous-authentication">Anonymous authentication</a>
<li><a accesskey="3" href="#Authentication-using-SRP">Authentication using SRP</a>
<li><a accesskey="4" href="#Authentication-using-PSK">Authentication using PSK</a>
<li><a accesskey="5" href="#Authentication-and-credentials">Authentication and credentials</a>
<li><a accesskey="6" href="#Parameters-stored-in-credentials">Parameters stored in credentials</a>
</ul>
<div class="node">
<p><hr>
<a name="Certificate-authentication"></a>
Next: <a rel="next" accesskey="n" href="#Anonymous-authentication">Anonymous authentication</a>,
Up: <a rel="up" accesskey="u" href="#Authentication-methods">Authentication methods</a>
</div>
<h3 class="section">4.1 Certificate authentication</h3>
<h4 class="subsection">4.1.1 Authentication using <acronym>X.509</acronym> certificates</h4>
<p><a name="index-g_t_0040acronym_007bX_002e509_007d-certificates-18"></a>
<acronym>X.509</acronym> certificates contain the public parameters, of a
public key algorithm, and an authority's signature, which proves the
authenticity of the parameters. See <a href="#The-X_002e509-trust-model">The X.509 trust model</a>, for
more information on <acronym>X.509</acronym> protocols.
<h4 class="subsection">4.1.2 Authentication using <acronym>OpenPGP</acronym> keys</h4>
<p><a name="index-g_t_0040acronym_007bOpenPGP_007d-Keys-19"></a>
<acronym>OpenPGP</acronym> keys also contain public parameters of a public key
algorithm, and signatures from several other parties. Depending on
whether a signer is trusted the key is considered trusted or not.
<acronym>GnuTLS</acronym>'s <acronym>OpenPGP</acronym> authentication implementation is
based on the <!-- %**else if -->
[TLSPGP] (See <a href="#Bibliography">TLSPGP</a>.)
proposal.
<p>See <a href="#The-OpenPGP-trust-model">The OpenPGP trust model</a>, for more information about the
<acronym>OpenPGP</acronym> trust model. For a more detailed introduction to
<acronym>OpenPGP</acronym> and <acronym>GnuPG</acronym> see <!-- %**else if -->
[GPGH] (See <a href="#Bibliography">GPGH</a>.)
.
<h4 class="subsection">4.1.3 Using certificate authentication</h4>
<p>In <acronym>GnuTLS</acronym> both the <acronym>OpenPGP</acronym> and <acronym>X.509</acronym>
certificates are part of the certificate authentication and thus are
handled using a common API.
<p>When using certificates the server is required to have at least one
certificate and private key pair. A client may or may not have such a
pair. The certificate and key pair should be loaded, before any
<acronym>TLS</acronym> session is initialized, in a certificate credentials
structure. This should be done by using
<a href="#gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile">gnutls_certificate_set_x509_key_file</a> or
<a href="#gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile">gnutls_certificate_set_openpgp_key_file</a> depending on the
certificate type. In the <acronym>X.509</acronym> case, the functions will
also accept and use a certificate list that leads to a trusted
authority. The certificate list must be ordered in such way that every
certificate certifies the one before it. The trusted authority's
certificate need not to be included, since the peer should possess it
already.
<p>As an alternative, a callback may be used so the server or the client
specify the certificate and the key at the handshake time. That
callback can be set using the functions:
<ul>
<li><a href="#gnutls_005fcertificate_005fserver_005fset_005fretrieve_005ffunction">gnutls_certificate_server_set_retrieve_function</a>
<li><a href="#gnutls_005fcertificate_005fclient_005fset_005fretrieve_005ffunction">gnutls_certificate_client_set_retrieve_function</a>
</ul>
<p>Certificate verification is possible by loading the trusted
authorities into the credentials structure by using
<a href="#gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile">gnutls_certificate_set_x509_trust_file</a> or
<a href="#gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile">gnutls_certificate_set_openpgp_keyring_file</a> for openpgp
keys. Note however that the peer's certificate is not automatically
verified, you should call <a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a>,
after a successful handshake, to verify the signatures of the
certificate. An alternative way, which reports a more detailed
verification output, is to use <a href="#gnutls_005fcertificate_005fget_005fpeers">gnutls_certificate_get_peers</a> to
obtain the raw certificate of the peer and verify it using the
functions discussed in <a href="#The-X_002e509-trust-model">The X.509 trust model</a>.
<p>In a handshake, the negotiated cipher suite depends on the
certificate's parameters, so not all key exchange methods will be
available with some certificates. <acronym>GnuTLS</acronym> will disable
ciphersuites that are not compatible with the key, or the enabled
authentication methods. For example keys marked as sign-only, will
not be able to access the plain RSA ciphersuites, but only the
<code>DHE_RSA</code> ones. It is recommended not to use RSA keys for both
signing and encryption. If possible use the same key for the
<code>DHE_RSA</code> and <code>RSA_EXPORT</code> ciphersuites, which use signing,
and a different key for the plain RSA ciphersuites, which use
encryption. All the key exchange methods shown below are available in
certificate authentication.
<p>Note that the DHE key exchange methods are generally
slower<a rel="footnote" href="#fn-12" name="fnd-12"><sup>12</sup></a> than plain RSA and require Diffie
Hellman parameters to be generated and associated with a credentials
structure, by the server. The <code>RSA-EXPORT</code> method also requires 512 bit RSA
parameters, that should also be generated and associated with the
credentials structure. See the functions:
<ul>
<li><a href="#gnutls_005fdh_005fparams_005fgenerate2">gnutls_dh_params_generate2</a>
<li><a href="#gnutls_005fcertificate_005fset_005fdh_005fparams">gnutls_certificate_set_dh_params</a>
<li><a href="#gnutls_005frsa_005fparams_005fgenerate2">gnutls_rsa_params_generate2</a>
<li><a href="#gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams">gnutls_certificate_set_rsa_export_params</a>
</ul>
<p>Sometimes in order to avoid bottlenecks in programs it is usefull to store
and read parameters from formats that can be generated by external programs such
as <code>certtool</code>. This is possible with <acronym>GnuTLS</acronym> by using the following
functions:
<ul>
<li><a href="#gnutls_005fdh_005fparams_005fimport_005fpkcs3">gnutls_dh_params_import_pkcs3</a>
<li><a href="#gnutls_005frsa_005fparams_005fimport_005fpkcs1">gnutls_rsa_params_import_pkcs1</a>
<li><a href="#gnutls_005fdh_005fparams_005fexport_005fpkcs3">gnutls_dh_params_export_pkcs3</a>
<li><a href="#gnutls_005frsa_005fparams_005fexport_005fpkcs1">gnutls_rsa_params_export_pkcs1</a>
</ul>
<p>Key exchange algorithms for <acronym>OpenPGP</acronym> and <acronym>X.509</acronym>
certificates:
<dl>
<dt><code>RSA:</code><dd>The RSA algorithm is used to encrypt a key and send it to the peer.
The certificate must allow the key to be used for encryption.
<br><dt><code>RSA_EXPORT:</code><dd>The RSA algorithm is used to encrypt a key and send it to the peer.
In the EXPORT algorithm, the server signs temporary RSA parameters of
512 bits — which are considered weak — and sends them to the client.
<br><dt><code>DHE_RSA:</code><dd>The RSA algorithm is used to sign Ephemeral Diffie Hellman parameters
which are sent to the peer. The key in the certificate must allow the
key to be used for signing. Note that key exchange algorithms which
use Ephemeral Diffie Hellman parameters, offer perfect forward
secrecy. That means that even if the private key used for signing is
compromised, it cannot be used to reveal past session data.
<br><dt><code>DHE_DSS:</code><dd>The DSS algorithm is used to sign Ephemeral Diffie Hellman parameters
which are sent to the peer. The certificate must contain DSA
parameters to use this key exchange algorithm. DSS stands for Digital
Signature Standard.
</dl>
<div class="node">
<p><hr>
<a name="Anonymous-authentication"></a>
Next: <a rel="next" accesskey="n" href="#Authentication-using-SRP">Authentication using SRP</a>,
Previous: <a rel="previous" accesskey="p" href="#Certificate-authentication">Certificate authentication</a>,
Up: <a rel="up" accesskey="u" href="#Authentication-methods">Authentication methods</a>
</div>
<h3 class="section">4.2 Anonymous authentication</h3>
<p><a name="index-Anonymous-authentication-20"></a>
The anonymous key exchange performs encryption but there is no
indication of the identity of the peer. This kind of authentication
is vulnerable to a man in the middle attack, but this protocol can be
used even if there is no prior communication and trusted parties with
the peer, or when full anonymity is required. Unless really required,
do not use anonymous authentication. Available key exchange methods
are shown below.
<p>Note that the key exchange methods for anonymous authentication
require Diffie Hellman parameters to be generated by the server and associated with
an anonymous credentials structure.
<p>Supported anonymous key exchange algorithms:
<dl>
<dt><code>ANON_DH:</code><dd>This algorithm exchanges Diffie Hellman parameters.
</dl>
<div class="node">
<p><hr>
<a name="Authentication-using-SRP"></a>
Next: <a rel="next" accesskey="n" href="#Authentication-using-PSK">Authentication using PSK</a>,
Previous: <a rel="previous" accesskey="p" href="#Anonymous-authentication">Anonymous authentication</a>,
Up: <a rel="up" accesskey="u" href="#Authentication-methods">Authentication methods</a>
</div>
<h3 class="section">4.3 Authentication using <acronym>SRP</acronym></h3>
<p><a name="index-g_t_0040acronym_007bSRP_007d-authentication-21"></a>
Authentication via the Secure Remote Password protocol,
<acronym>SRP</acronym><a rel="footnote" href="#fn-13" name="fnd-13"><sup>13</sup></a>,
is supported. The <acronym>SRP</acronym> key exchange is an extension to the
<acronym>TLS</acronym> protocol, and it is a password based authentication
(unlike <acronym>X.509</acronym> or <acronym>OpenPGP</acronym> that use certificates).
The two peers can be identified using a single password, or there can
be combinations where the client is authenticated using <acronym>SRP</acronym>
and the server using a certificate.
<p>The advantage of <acronym>SRP</acronym> authentication, over other proposed
secure password authentication schemes, is that <acronym>SRP</acronym> does not
require the server to hold the user's password. This kind of
protection is similar to the one used traditionally in the <em>UNIX</em>
<samp><span class="file">/etc/passwd</span></samp> file, where the contents of this file did not cause
harm to the system security if they were revealed. The <acronym>SRP</acronym>
needs instead of the plain password something called a verifier, which
is calculated using the user's password, and if stolen cannot be used
to impersonate the user. Check <!-- %**else if -->
[TOMSRP] (See <a href="#Bibliography">TOMSRP</a>.)
for a detailed description
of the <acronym>SRP</acronym> protocol and the Stanford <acronym>SRP</acronym>
libraries, which includes a PAM module that synchronizes the system's
users passwords with the <acronym>SRP</acronym> password files. That way
<acronym>SRP</acronym> authentication could be used for all the system's users.
<p>The implementation in <acronym>GnuTLS</acronym> is based on paper
<!-- %**else if -->
[TLSSRP] (See <a href="#Bibliography">TLSSRP</a>.)
. The supported <acronym>SRP</acronym> key exchange methods are:
<dl>
<dt><code>SRP:</code><dd>Authentication using the <acronym>SRP</acronym> protocol.
<br><dt><code>SRP_DSS:</code><dd>Client authentication using the <acronym>SRP</acronym> protocol. Server is
authenticated using a certificate with DSA parameters.
<br><dt><code>SRP_RSA:</code><dd>Client authentication using the <acronym>SRP</acronym> protocol. Server is
authenticated using a certificate with RSA parameters.
</dl>
<p>If clients supporting <acronym>SRP</acronym> know the username and password
before the connection, should initialize the client credentials and
call the function <a href="#gnutls_005fsrp_005fset_005fclient_005fcredentials">gnutls_srp_set_client_credentials</a>.
Alternatively they could specify a callback function by using the
function <a href="#gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction">gnutls_srp_set_client_credentials_function</a>. This has
the advantage that allows probing the server for <acronym>SRP</acronym>
support. In that case the callback function will be called twice per
handshake. The first time is before the ciphersuite is negotiated,
and if the callback returns a negative error code, the callback will
be called again if <acronym>SRP</acronym> has been negotiated. This uses a
special <acronym>TLS</acronym>-<acronym>SRP</acronym> handshake idiom in order to avoid,
in interactive applications, to ask the user for <acronym>SRP</acronym>
password and username if the server does not negotiate an
<acronym>SRP</acronym> ciphersuite.
<p>In server side the default behaviour of <acronym>GnuTLS</acronym> is to read
the usernames and <acronym>SRP</acronym> verifiers from password files. These
password files are the ones used by the <em>Stanford srp libraries</em>
and can be specified using the
<a href="#gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile">gnutls_srp_set_server_credentials_file</a>. If a different
password file format is to be used, then the function
<a href="#gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction">gnutls_srp_set_server_credentials_function</a>, should be called,
in order to set an appropriate callback.
<p>Some helper functions such as
<ul>
<li><a href="#gnutls_005fsrp_005fverifier">gnutls_srp_verifier</a>
<li><a href="#gnutls_005fsrp_005fbase64_005fencode">gnutls_srp_base64_encode</a>
<li><a href="#gnutls_005fsrp_005fbase64_005fdecode">gnutls_srp_base64_decode</a>
</ul>
<p>are included in <acronym>GnuTLS</acronym>, and can be used to generate and
maintain <acronym>SRP</acronym> verifiers and password files. A program to
manipulate the required parameters for <acronym>SRP</acronym> authentication is
also included. See <a href="#srptool">srptool</a>, for more information.
<div class="node">
<p><hr>
<a name="Authentication-using-PSK"></a>
Next: <a rel="next" accesskey="n" href="#Authentication-and-credentials">Authentication and credentials</a>,
Previous: <a rel="previous" accesskey="p" href="#Authentication-using-SRP">Authentication using SRP</a>,
Up: <a rel="up" accesskey="u" href="#Authentication-methods">Authentication methods</a>
</div>
<h3 class="section">4.4 Authentication using <acronym>PSK</acronym></h3>
<p><a name="index-g_t_0040acronym_007bPSK_007d-authentication-22"></a>
Authentication using Pre-shared keys is a method to authenticate using
usernames and binary keys. This protocol avoids making use of public key infrastructure
and expensive calculations, thus it is suitable for constraint clients.
<p>The implementation in <acronym>GnuTLS</acronym> is based on paper
<!-- %**else if -->
[TLSPSK] (See <a href="#Bibliography">TLSPSK</a>.)
. The supported <acronym>PSK</acronym> key exchange methods are:
<dl>
<dt><code>PSK:</code><dd>Authentication using the <acronym>PSK</acronym> protocol.
<br><dt><code>DHE-PSK:</code><dd>Authentication using the <acronym>PSK</acronym> protocol and Diffie Hellman key exchange.
This method offers perfect forward secrecy.
</dl>
<p>Clients supporting <acronym>PSK</acronym> should supply the username and key
before the connection to the client credentials by calling
the function <a href="#gnutls_005fpsk_005fset_005fclient_005fcredentials">gnutls_psk_set_client_credentials</a>.
Alternatively they could specify a callback function by using the
function <a href="#gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction">gnutls_psk_set_client_credentials_function</a>.
This has the advantage that the callback will be called only if <acronym>PSK</acronym>
has been negotiated.
<p>In server side the default behaviour of <acronym>GnuTLS</acronym> is to read
the usernames and <acronym>PSK</acronym> keys from a password file. The password file
should contain usernames and keys in hexadecimal format. The name of the password
file can be stored to the credentials structure by calling
<a href="#gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile">gnutls_psk_set_server_credentials_file</a>. If a different
password file format is to be used, then the function
<a href="#gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction">gnutls_psk_set_server_credentials_function</a>, should be used instead.
<p>Some helper functions such as:
<ul>
<li><a href="#gnutls_005fhex_005fencode">gnutls_hex_encode</a>
<li><a href="#gnutls_005fhex_005fdecode">gnutls_hex_decode</a>
</ul>
<p>are included in <acronym>GnuTLS</acronym>, and may be used to generate and
maintain <acronym>PSK</acronym> keys.
<div class="node">
<p><hr>
<a name="Authentication-and-credentials"></a>
Next: <a rel="next" accesskey="n" href="#Parameters-stored-in-credentials">Parameters stored in credentials</a>,
Previous: <a rel="previous" accesskey="p" href="#Authentication-using-PSK">Authentication using PSK</a>,
Up: <a rel="up" accesskey="u" href="#Authentication-methods">Authentication methods</a>
</div>
<h3 class="section">4.5 Authentication and credentials</h3>
<p>In <acronym>GnuTLS</acronym> every key exchange method is associated with a
credentials type. So in order to enable to enable a specific method,
the corresponding credentials type should be initialized and set using
<a href="#gnutls_005fcredentials_005fset">gnutls_credentials_set</a>. A mapping is shown below.
<p>Key exchange algorithms and the corresponding credential types:
<p><table summary="">
<tr align="left"><th valign="top" width="30%">Key exchange </th><th valign="top" width="30%">Client credentials </th><th valign="top" width="30%">Server credentials
<p><br></th></tr><tr align="left"><td valign="top" width="30%"><code>KX_RSA</code>
<br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_DHE_RSA</code>
<br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_DHE_DSS</code>
<br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_RSA_EXPORT</code>
</td><td valign="top" width="30%"><code>CRD_CERTIFICATE</code>
</td><td valign="top" width="30%"><code>CRD_CERTIFICATE</code>
<p><br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_SRP_RSA</code>
</td><td valign="top" width="30%"><code>CRD_SRP</code>
</td><td valign="top" width="30%"><code>CRD_SRP</code>
<br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_SRP_DSS</code>
</td><td valign="top" width="30%">
</td><td valign="top" width="30%"><code>CRD_CERTIFICATE</code>
<p><br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_SRP</code>
</td><td valign="top" width="30%"><code>CRD_SRP</code>
</td><td valign="top" width="30%"><code>CRD_SRP</code>
<p><br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_ANON_DH</code>
</td><td valign="top" width="30%"><code>CRD_ANON</code>
</td><td valign="top" width="30%"><code>CRD_ANON</code>
<p><br></td></tr><tr align="left"><td valign="top" width="30%"><code>KX_PSK</code>
</td><td valign="top" width="30%"><code>CRD_PSK</code>
</td><td valign="top" width="30%"><code>CRD_PSK</code>
<br></td></tr></table>
<div class="node">
<p><hr>
<a name="Parameters-stored-in-credentials"></a>
Previous: <a rel="previous" accesskey="p" href="#Authentication-and-credentials">Authentication and credentials</a>,
Up: <a rel="up" accesskey="u" href="#Authentication-methods">Authentication methods</a>
</div>
<h3 class="section">4.6 Parameters stored in credentials</h3>
<p>Several parameters such as the ones used for Diffie-Hellman
authentication are stored within the credentials structures, so all
sessions can access them. Those parameters are stored in structures
such as <code>gnutls_dh_params_t</code> and <code>gnutls_rsa_params_t</code>, and
functions like <a href="#gnutls_005fcertificate_005fset_005fdh_005fparams">gnutls_certificate_set_dh_params</a> and
<a href="#gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams">gnutls_certificate_set_rsa_export_params</a> can be used to
associate those parameters with the given credentials structure.
<p>Since those parameters need to be renewed from time to time and a
global structure such as the credentials, may not be easy to modify
since it is accessible by all sessions, an alternative interface is
available using a callback function. This can be set using the
<a href="#gnutls_005fcertificate_005fset_005fparams_005ffunction">gnutls_certificate_set_params_function</a>. An example is shown
below.
<pre class="example"> #include <gnutls.h>
gnutls_rsa_params_t rsa_params;
gnutls_dh_params_t dh_params;
/* This function will be called once a session requests DH
* or RSA parameters. The parameters returned (if any) will
* be used for the first handshake only.
*/
static int get_params( gnutls_session_t session,
gnutls_params_type_t type,
gnutls_params_st *st)
{
if (type == GNUTLS_PARAMS_RSA_EXPORT)
st->params.rsa_export = rsa_params;
else if (type == GNUTLS_PARAMS_DH)
st->params.dh = dh_params;
else return -1;
st->type = type;
/* do not deinitialize those parameters.
*/
st->deinit = 0;
return 0;
}
int main()
{
gnutls_certificate_credentials_t cert_cred;
initialize_params();
/* ...
*/
gnutls_certificate_set_params_function( cert_cred, get_params);
}
</pre>
<div class="node">
<p><hr>
<a name="More-on-certificate-authentication"></a>
Next: <a rel="next" accesskey="n" href="#How-to-use-TLS-in-application-protocols">How to use TLS in application protocols</a>,
Previous: <a rel="previous" accesskey="p" href="#Authentication-methods">Authentication methods</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">5 More on certificate authentication</h2>
<p><a name="Certificate-Authentication"></a>
<a name="index-Certificate-authentication-23"></a>
<ul class="menu">
<li><a accesskey="1" href="#The-X_002e509-trust-model">The X.509 trust model</a>
<li><a accesskey="2" href="#The-OpenPGP-trust-model">The OpenPGP trust model</a>
<li><a accesskey="3" href="#Digital-signatures">Digital signatures</a>
</ul>
<div class="node">
<p><hr>
<a name="The-X.509-trust-model"></a>
<a name="The-X_002e509-trust-model"></a>
Next: <a rel="next" accesskey="n" href="#The-OpenPGP-trust-model">The OpenPGP trust model</a>,
Up: <a rel="up" accesskey="u" href="#More-on-certificate-authentication">More on certificate authentication</a>
</div>
<h3 class="section">5.1 The <acronym>X.509</acronym> trust model</h3>
<p><a name="index-g_t_0040acronym_007bX_002e509_007d-certificates-24"></a>
The <acronym>X.509</acronym> protocols rely on a hierarchical trust model. In
this trust model Certification Authorities (CAs) are used to certify
entities. Usually more than one certification authorities exist, and
certification authorities may certify other authorities to issue
certificates as well, following a hierarchical model.
<div class="block-image"><img src="x509-1.png" alt="x509-1.png"></div>
<p>One needs to trust one or more CAs for his secure communications. In
that case only the certificates issued by the trusted authorities are
acceptable. See the figure above for a typical example. The API for
handling <acronym>X.509</acronym> certificates is described at section
<a href="#sec_003ax509api">sec:x509api</a>. Some examples are listed below.
<ul class="menu">
<li><a accesskey="1" href="#X_002e509-certificates">X.509 certificates</a>
<li><a accesskey="2" href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a>
<li><a accesskey="3" href="#PKCS-_002310-certificate-requests">PKCS #10 certificate requests</a>
<li><a accesskey="4" href="#PKCS-_002312-structures">PKCS #12 structures</a>
</ul>
<div class="node">
<p><hr>
<a name="X.509-certificates"></a>
<a name="X_002e509-certificates"></a>
Next: <a rel="next" accesskey="n" href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a>,
Up: <a rel="up" accesskey="u" href="#The-X_002e509-trust-model">The X.509 trust model</a>
</div>
<h4 class="subsection">5.1.1 <acronym>X.509</acronym> certificates</h4>
<p>An <acronym>X.509</acronym> certificate usually contains information about the
certificate holder, the signer, a unique serial number, expiration
dates and some other fields <!-- %**else if -->
[RFC3280] (See <a href="#Bibliography">RFC3280</a>.)
as shown in the table
below.
<dl>
<dt><code>version:</code><dd>The field that indicates the version of the certificate.
<br><dt><code>serialNumber:</code><dd>This field holds a unique serial number per certificate.
<br><dt><code>issuer:</code><dd>Holds the issuer's distinguished name.
<br><dt><code>validity:</code><dd>The activation and expiration dates.
<br><dt><code>subject:</code><dd>The subject's distinguished name of the certificate.
<br><dt><code>extensions:</code><dd>The extensions are fields only present in version 3 certificates.
</dl>
<p>The certificate's <em>subject or issuer name</em> is not just a single
string. It is a Distinguished name and in the <acronym>ASN.1</acronym>
notation is a sequence of several object IDs with their corresponding
values. Some of available OIDs to be used in an <acronym>X.509</acronym>
distinguished name are defined in <samp><span class="file">gnutls/x509.h</span></samp>.
<p>The <em>Version</em> field in a certificate has values either 1 or 3 for
version 3 certificates. Version 1 certificates do not support the
extensions field so it is not possible to distinguish a CA from a
person, thus their usage should be avoided.
<p>The <em>validity</em> dates are there to indicate the date that the
specific certificate was activated and the date the certificate's key
would be considered invalid.
<p>Certificate <em>extensions</em> are there to include information about
the certificate's subject that did not fit in the typical certificate
fields. Those may be e-mail addresses, flags that indicate whether the
belongs to a CA etc. All the supported <acronym>X.509</acronym> version 3
extensions are shown in the table below.
<dl>
<dt><code>subject key id (2.5.29.14):</code><dd>An identifier of the key of the subject.
<br><dt><code>authority key id (2.5.29.35):</code><dd>An identifier of the authority's key used to sign the certificate.
<br><dt><code>subject alternative name (2.5.29.17):</code><dd>Alternative names to subject's distinguished name.
<br><dt><code>key usage (2.5.29.15):</code><dd>Constraints the key's usage of the certificate.
<br><dt><code>extended key usage (2.5.29.37):</code><dd>Constraints the purpose of the certificate.
<br><dt><code>basic constraints (2.5.29.19):</code><dd>Indicates whether this is a CA certificate or not.
<br><dt><code>CRL distribution points (2.5.29.31):</code><dd>This extension is set by the CA, in order to inform about the issued CRLs.
</dl>
<p>In <acronym>GnuTLS</acronym> the <acronym>X.509</acronym> certificate structures are handled using
the <code>gnutls_x509_crt_t</code> type and the corresponding private keys
with the <code>gnutls_x509_privkey_t</code> type. All the available
functions for <acronym>X.509</acronym> certificate handling have their prototypes in
<samp><span class="file">gnutls/x509.h</span></samp>. An example program to demonstrate the <acronym>X.509</acronym>
parsing capabilities can be found at section <a href="#ex_003ax509_002dinfo">ex:x509-info</a>.
<div class="node">
<p><hr>
<a name="Verifying-X.509-certificate-paths"></a>
<a name="Verifying-X_002e509-certificate-paths"></a>
Next: <a rel="next" accesskey="n" href="#PKCS-_002310-certificate-requests">PKCS #10 certificate requests</a>,
Previous: <a rel="previous" accesskey="p" href="#X_002e509-certificates">X.509 certificates</a>,
Up: <a rel="up" accesskey="u" href="#The-X_002e509-trust-model">The X.509 trust model</a>
</div>
<h4 class="subsection">5.1.2 Verifying <acronym>X.509</acronym> certificate paths</h4>
<p><a name="index-Verifying-certificate-paths-25"></a>
Verifying certificate paths is important in <acronym>X.509</acronym> authentication. For
this purpose the function <a href="#gnutls_005fx509_005fcrt_005fverify">gnutls_x509_crt_verify</a> is
provided. The output of this function is the bitwise OR of the
elements of the <code>gnutls_certificate_status_t</code> enumeration. A
detailed description of these elements can be found in figure below.
The function <a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a> is equivalent to
the previous one, and will verify the peer's certificate in a TLS
session.
<dl>
<dt><code>CERT_INVALID:</code><dd>The certificate is not signed by one of the known authorities, or
the signature is invalid.
<br><dt><code>CERT_REVOKED:</code><dd>The certificate has been revoked by its CA.
<br><dt><code>CERT_SIGNER_NOT_FOUND:</code><dd>The certificate's issuer is not known. This is the case when the
issuer is not in the trusted certificates list.
<br><dt><code>GNUTLS_CERT_SIGNER_NOT_CA:</code><dd>The certificate's signer was not a CA. This may happen if
this was a version 1 certificate, which is common with some CAs, or
a version 3 certificate without the basic constrains extension.
<p><a name="GNUTLS_005fCERT_005fINSECURE_005fALGORITHM"></a>
<br><dt><code>GNUTLS_CERT_INSECURE_ALGORITHM:</code><dd>The certificate was signed using an insecure algorithm such as MD2 or
MD5. These algorithms have been broken and should not be trusted.
</dl>
<p>There is also to possibility to pass some input to the verification
functions in the form of flags. For <a href="#gnutls_005fx509_005fcrt_005fverify">gnutls_x509_crt_verify</a> the
flags are passed straightforward, but
<a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a> depends on the flags set by
calling <a href="#gnutls_005fcertificate_005fset_005fverify_005fflags">gnutls_certificate_set_verify_flags</a>. All the available
flags are part of the enumeration
<a href="#gnutls_005fcertificate_005fverify_005fflags">gnutls_certificate_verify_flags</a> and are explained in the table
below.
<p><a name="gnutls_005fcertificate_005fverify_005fflags"></a>
<a name="index-gnutls_005fcertificate_005fverify_005fflags-26"></a>
<dl>
<dt><code>GNUTLS_VERIFY_DISABLE_CA_SIGN:</code><dd>If set a signer does not have to be a certificate authority. This
flag should normaly be disabled, unless you know what this means.
<br><dt><code>GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT:</code><dd>Allow only trusted CA certificates that have version 1. This is
safer than GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT, and should be
used instead. That way only signers in your trusted list will be
allowed to have certificates of version 1.
<br><dt><code>GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT:</code><dd>Allow CA certificates that have version 1 (both root and
intermediate). This is dangerous since those haven't the
basicConstraints extension. Must be used in combination with
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT.
<br><dt><code>GNUTLS_VERIFY_DO_NOT_ALLOW_SAME:</code><dd>If a certificate is not signed by anyone trusted but exists in
the trusted CA list do not treat it as trusted.
<br><dt><code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2:</code><dd>Allow certificates to be signed using the old MD2 algorithm.
<br><dt><code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5:</code><dd>Allow certificates to be signed using the broken MD5 algorithm.
</dl>
<p>Although the verification of a certificate path indicates that the
certificate is signed by trusted authority, does not reveal anything
about the peer's identity. It is required to verify if the
certificate's owner is the one you expect. For more information consult <!-- %**else if -->
[RFC2818] (See <a href="#Bibliography">RFC2818</a>.)
<p>and section <a href="#ex_003averify">ex:verify</a> for an example.
<div class="node">
<p><hr>
<a name="PKCS-%2310-certificate-requests"></a>
<a name="PKCS-_002310-certificate-requests"></a>
Next: <a rel="next" accesskey="n" href="#PKCS-_002312-structures">PKCS #12 structures</a>,
Previous: <a rel="previous" accesskey="p" href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a>,
Up: <a rel="up" accesskey="u" href="#The-X_002e509-trust-model">The X.509 trust model</a>
</div>
<h4 class="subsection">5.1.3 <acronym>PKCS</acronym> #10 certificate requests</h4>
<p><a name="index-Certificate-requests-27"></a><a name="index-g_t_0040acronym_007bPKCS_007d-_002310-28"></a>
A certificate request is a structure, which contain information about
an applicant of a certificate service. It usually contains a private
key, a distinguished name and secondary data such as a challenge
password. <acronym>GnuTLS</acronym> supports the requests defined in
<acronym>PKCS</acronym> #10 <!-- %**else if -->
[RFC2986] (See <a href="#Bibliography">RFC2986</a>.)
. Other certificate request's format
such as PKIX's <!-- %**else if -->
[RFC2511] (See <a href="#Bibliography">RFC2511</a>.)
are not currently supported.
<p>In <acronym>GnuTLS</acronym> the <acronym>PKCS</acronym> #10 structures are handled
using the <code>gnutls_x509_crq_t</code> type. An example of a certificate
request generation can be found at section <a href="#ex_003acrq">ex:crq</a>.
<div class="node">
<p><hr>
<a name="PKCS-%2312-structures"></a>
<a name="PKCS-_002312-structures"></a>
Previous: <a rel="previous" accesskey="p" href="#PKCS-_002310-certificate-requests">PKCS #10 certificate requests</a>,
Up: <a rel="up" accesskey="u" href="#The-X_002e509-trust-model">The X.509 trust model</a>
</div>
<h4 class="subsection">5.1.4 <acronym>PKCS</acronym> #12 structures</h4>
<p><a name="index-g_t_0040acronym_007bPKCS_007d-_002312-29"></a>
A <acronym>PKCS</acronym> #12 structure <!-- %**else if -->
[PKCS12] (See <a href="#Bibliography">PKCS12</a>.)
usually contains a user's
private keys and certificates. It is commonly used in browsers to
export and import the user's identities.
<p>In <acronym>GnuTLS</acronym> the <acronym>PKCS</acronym> #12 structures are handled
using the <code>gnutls_pkcs12_t</code> type. This is an abstract type that
may hold several <code>gnutls_pkcs12_bag_t</code> types. The Bag types are
the holders of the actual data, which may be certificates, private
keys or encrypted data. An Bag of type encrypted should be decrypted
in order for its data to be accessed.
<p>An example of a <acronym>PKCS</acronym> #12 structure generation can be found
at section <a href="#ex_003apkcs12">ex:pkcs12</a>.
<div class="node">
<p><hr>
<a name="The-OpenPGP-trust-model"></a>
Next: <a rel="next" accesskey="n" href="#Digital-signatures">Digital signatures</a>,
Previous: <a rel="previous" accesskey="p" href="#The-X_002e509-trust-model">The X.509 trust model</a>,
Up: <a rel="up" accesskey="u" href="#More-on-certificate-authentication">More on certificate authentication</a>
</div>
<h3 class="section">5.2 The <acronym>OpenPGP</acronym> trust model</h3>
<p><a name="index-g_t_0040acronym_007bOpenPGP_007d-Keys-30"></a>
The <acronym>OpenPGP</acronym> key authentication relies on a distributed trust
model, called the “web of trust”. The “web of trust” uses a
decentralized system of trusted introducers, which are the same as a
CA. <acronym>OpenPGP</acronym> allows anyone to sign anyone's else public
key. When Alice signs Bob's key, she is introducing Bob's key to
anyone who trusts Alice. If someone trusts Alice to introduce keys,
then Alice is a trusted introducer in the mind of that observer.
<div class="block-image"><img src="pgp1.png" alt="pgp1.png"></div>
<p>For example: If David trusts Alice to be an introducer, and Alice
signed Bob's key, Dave also trusts Bob's key to be the real one.
<p>There are some key points that are important in that model. In the
example Alice has to sign Bob's key, only if she is sure that the key
belongs to Bob. Otherwise she may also make Dave falsely believe that
this is Bob's key. Dave has also the responsibility to know who to
trust. This model is similar to real life relations.
<p>Just see how Charlie behaves in the previous example. Although he has
signed Bob's key - because he knows, somehow, that it belongs to Bob -
he does not trust Bob to be an introducer. Charlie decided to trust
only Kevin, for some reason. A reason could be that Bob is lazy
enough, and signs other people's keys without being sure that they
belong to the actual owner.
<h4 class="subsection">5.2.1 <acronym>OpenPGP</acronym> keys</h4>
<p>In <acronym>GnuTLS</acronym> the <acronym>OpenPGP</acronym> key structures
<!-- %**else if -->
[RFC2440] (See <a href="#Bibliography">RFC2440</a>.)
are handled using the <code>gnutls_openpgp_key_t</code> type
and the corresponding private keys with the
<code>gnutls_openpgp_privkey_t</code> type. All the prototypes for the key
handling functions can be found at <samp><span class="file">gnutls/openpgp.h</span></samp>.
<h4 class="subsection">5.2.2 Verifying an <acronym>OpenPGP</acronym> key</h4>
<p>The verification functions of <acronym>OpenPGP</acronym> keys, included in
<acronym>GnuTLS</acronym>, are simple ones, and do not use the features of the
“web of trust”. For that reason, if the verification needs are
complex, the assistance of external tools like <acronym>GnuPG</acronym> and
GPGME (<a href="http://www.gnupg.org/related_software/gpgme/">http://www.gnupg.org/related_software/gpgme/</a>) is
recommended.
<p>There are two verification functions in <acronym>GnuTLS</acronym>, The
<a href="#gnutls_005fopenpgp_005fkey_005fverify_005fring">gnutls_openpgp_key_verify_ring</a> and the
<a href="#gnutls_005fopenpgp_005fkey_005fverify_005ftrustdb">gnutls_openpgp_key_verify_trustdb</a>. The first one checks an
<acronym>OpenPGP</acronym> key against a given set of public keys (keyring) and
returns the key status. The key verification status is the same as in
<acronym>X.509</acronym> certificates, although the meaning and interpretation are
different. For example an <acronym>OpenPGP</acronym> key may be valid, if the
self signature is ok, even if no signers were found. The meaning of
verification status is shown in the figure below. The latter function
checks a <acronym>GnuPG</acronym> trust database for the given key. This
function does not check the key signatures, only checks for disabled
and revoked keys.
<dl>
<dt><code>CERT_INVALID:</code><dd>A signature on the key is invalid. That means that the key was
modified by somebody, or corrupted during transport.
<br><dt><code>CERT_REVOKED:</code><dd>The key has been revoked by its owner.
<br><dt><code>CERT_SIGNER_NOT_FOUND:</code><dd>The key was not signed by a known signer.
<br><dt><code>GNUTLS_CERT_INSECURE_ALGORITHM:</code><dd>The certificate was signed using an insecure algorithm such as MD2 or MD5.
These algorithms have been broken and should not be trusted.
</dl>
<div class="node">
<p><hr>
<a name="Digital-signatures"></a>
Previous: <a rel="previous" accesskey="p" href="#The-OpenPGP-trust-model">The OpenPGP trust model</a>,
Up: <a rel="up" accesskey="u" href="#More-on-certificate-authentication">More on certificate authentication</a>
</div>
<h3 class="section">5.3 Digital signatures</h3>
<p><a name="index-Digital-signatures-31"></a>
<p>In this section we will provide some information about digital
signatures, how they work, and give the rationale for disabling some
of the algorithms used.
<p>Digital signatures work by using somebody's secret key to sign some
arbitrary data. Then anybody else could use the public key of that
person to verify the signature. Since the data may be arbitrary it is
not suitable input to a cryptographic digital signature algorithm. For
this reason and also for performance cryptographic hash algorithms are
used to preprocess the input to the signature algorithm. This works as
long as it is difficult enough to generate two different messages with
the same hash algorithm output. In that case the same signature could
be used as a proof for both messages. Nobody wants to sign an innocent
message of donating 1 € to Greenpeace and find out that he
donated 1.000.000 € to Bad Inc.
<p>For a hash algorithm to be called cryptographic the following three
requirements must hold
<ol type=1 start=1>
<li>Preimage resistance. That means the algorithm must be one way and given
the output of the hash function H(x), it is impossible to
calculate x.
<li>2nd preimage resistance. That means that given a pair x,y with y=H(x) it is impossible
to calculate an x' such that y=H(x').
<li>Collision resistance. That means that it is impossible to calculate random x and x' such
H(x')=H(x).
</ol>
<p>The last two requirements in the list are the most important in
digital signatures. These protect against somebody who would like to
generate two messages with the same hash output. When an algorithm is
considered broken usually it means that the Collision resistance of
the algorithm is less than brute force. Using the birthday paradox the
brute force attack takes
2^((hash size) / 2)
operations. Today colliding certificates using the MD5 hash algorithm
have been generated as shown in <!-- %**else if -->
[WEGER] (See <a href="#Bibliography">WEGER</a>.)
.
<p>There has been cryptographic results for the SHA-1 hash algorithms as
well, although they are not yet critical. Before 2004, MD5 had a
presumed collision strength of 2^64, but it has been showed to
have a collision strength well under 2^50. As of November
2005, it is believed that SHA-1's collision strength is around
2^63. We consider this sufficiently hard so that we still
support SHA-1. We anticipate that SHA-256/386/512 will be used in
publicly-distributed certificates in the future. When 2^63 can
be considered too weak compared to the computer power available
sometime in the future, SHA-1 will be disabled as well. The collision
attacks on SHA-1 may also get better, given the new interest in tools
for creating them.
<h4 class="subsection">5.3.1 Supported algorithms</h4>
<p>The available digital signature algorithms in <acronym>GnuTLS</acronym> are
listed below:
<dl>
<dt><code>RSA</code><dd>RSA is public key cryptosystem designed by Ronald Rivest, Adi Shamir
and Leonard Adleman. It can be used with any hash functions.
<br><dt><code>DSA</code><dd>DSA is the USA's Digital Signature Standard. It uses only the SHA-1
hash algorithm.
</dl>
<p>The supported cryptographic hash algorithms are:
<dl>
<dt><code>MD2</code><dd>MD2 is a cryptographic hash algorithm designed by Ron Rivest. It is
optimized for 8-bit processors. Outputs 128 bits of data. There are no
known weaknesses of this algorithm but since this algorithm is rarely
used and not really studied it should not be used today.
<br><dt><code>MD5</code><dd>MD5 is a cryptographic hash algorithm designed by Ron Rivest. Outputs
128 bits of data. It is considered to be broken.
<br><dt><code>SHA-1</code><dd>SHA is a cryptographic hash algorithm designed by NSA. Outputs 160
bits of data. It is also considered to be broken, though no practical
attacks have been found.
<br><dt><code>RMD160</code><dd>RIPEMD is a cryptographic hash algorithm developed in the framework of
the EU project RIPE. Outputs 160 bits of data.
</dl>
<h4 class="subsection">5.3.2 Trading security for interoperability</h4>
<p>If you connect to a server and use GnuTLS' functions to verify the
certificate chain, and get a <a href="#GNUTLS_005fCERT_005fINSECURE_005fALGORITHM">GNUTLS_CERT_INSECURE_ALGORITHM</a>
validation error (see <a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a>), it means
that somewhere in the certificate chain there is a certificate signed
using <code>RSA-MD2</code> or <code>RSA-MD5</code>. These two digital signature
algorithms are considered broken, so GnuTLS fail when attempting to
verify the certificate. In some situations, it may be useful to be
able to verify the certificate chain anyway, assuming an attacker did
not utilize the fact that these signatures algorithms are broken.
This section will give help on how to achieve that.
<p>First, it is important to know that you do not have to enable any of
the flags discussed here to be able to use trusted root CA
certificates signed using <code>RSA-MD2</code> or <code>RSA-MD5</code>. The only
attack today is that it is possible to generate certificates with
colliding signatures (collision resistance); you cannot generate a
certificate that has the same signature as an already existing
signature (2nd preimage resistance).
<p>If you are using <a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a> to verify the
certificate chain, you can call
<a href="#gnutls_005fcertificate_005fset_005fverify_005fflags">gnutls_certificate_set_verify_flags</a> with the
<code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2</code> or
<code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5</code> flag, as in:
<pre class="example"> gnutls_certificate_set_verify_flags (x509cred,
GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5);
</pre>
<p>This will tell the verifier algorithm to enable <code>RSA-MD5</code> when
verifying the certificates.
<p>If you are using <a href="#gnutls_005fx509_005fcrt_005fverify">gnutls_x509_crt_verify</a> or
<a href="#gnutls_005fx509_005fcrt_005flist_005fverify">gnutls_x509_crt_list_verify</a>, you can pass the
<code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5</code> parameter directly in the
<code>flags</code> parameter.
<p>If you are using these flags, it may also be a good idea to warn the
user when verification failure occur for this reason. The simplest is
to not use the flags by default, and only fall back to using them
after warning the user. If you wish to inspect the certificate chain
yourself, you can use <a href="#gnutls_005fcertificate_005fget_005fpeers">gnutls_certificate_get_peers</a> to extract
the raw server's certificate chain, then use
<a href="#gnutls_005fx509_005fcrt_005fimport">gnutls_x509_crt_import</a> to parse each of the certificates, and
then use <a href="#gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm">gnutls_x509_crt_get_signature_algorithm</a> to find out the
signing algorithm used for each certificate. If any of the
intermediary certificates are using <code>GNUTLS_SIGN_RSA_MD2</code> or
<code>GNUTLS_SIGN_RSA_MD5</code>, you could present a warning.
<div class="node">
<p><hr>
<a name="How-to-use-TLS-in-application-protocols"></a>
Next: <a rel="next" accesskey="n" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>,
Previous: <a rel="previous" accesskey="p" href="#More-on-certificate-authentication">More on certificate authentication</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">6 How to use <acronym>TLS</acronym> in application protocols</h2>
<p>This chapter is intended to provide some hints on how to use the
<acronym>TLS</acronym> over simple custom made application protocols. The
discussion below mainly refers to the <em>TCP/IP</em> transport layer
but may be extended to other ones too.
<ul class="menu">
<li><a accesskey="1" href="#Separate-ports">Separate ports</a>
<li><a accesskey="2" href="#Upward-negotiation">Upward negotiation</a>
</ul>
<div class="node">
<p><hr>
<a name="Separate-ports"></a>
Next: <a rel="next" accesskey="n" href="#Upward-negotiation">Upward negotiation</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-TLS-in-application-protocols">How to use TLS in application protocols</a>
</div>
<h3 class="section">6.1 Separate ports</h3>
<p>Traditionally <acronym>SSL</acronym> was used in application protocols by
assigning a new port number for the secure services. That way two
separate ports were assigned, one for the non secure sessions, and one
for the secured ones. This has the benefit that if a user requests a
secure session then the client will try to connect to the secure port
and fail otherwise. The only possible attack with this method is a
denial of service one. The most famous example of this method is the
famous “HTTP over TLS” or <acronym>HTTPS</acronym> protocol <!-- %**else if -->
[RFC2818] (See <a href="#Bibliography">RFC2818</a>.)
.
<p>Despite its wide use, this method is not as good as it seems. This
approach starts the <acronym>TLS</acronym> Handshake procedure just after the
client connects on the —so called— secure port. That way the
<acronym>TLS</acronym> protocol does not know anything about the client, and
popular methods like the host advertising in HTTP do not
work<a rel="footnote" href="#fn-14" name="fnd-14"><sup>14</sup></a>. There is no way for the client to say “I
connected to YYY server” before the Handshake starts, so the server
cannot possibly know which certificate to use.
<p>Other than that it requires two separate ports to run a single
service, which is unnecessary complication. Due to the fact that there
is a limitation on the available privileged ports, this approach was
soon obsoleted.
<div class="node">
<p><hr>
<a name="Upward-negotiation"></a>
Previous: <a rel="previous" accesskey="p" href="#Separate-ports">Separate ports</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-TLS-in-application-protocols">How to use TLS in application protocols</a>
</div>
<h3 class="section">6.2 Upward negotiation</h3>
<p>Other application protocols<a rel="footnote" href="#fn-15" name="fnd-15"><sup>15</sup></a> use a
different approach to enable the secure layer. They use something
called the “TLS upgrade” method. This method is quite tricky but it
is more flexible. The idea is to extend the application protocol to
have a “STARTTLS” request, whose purpose it to start the TLS
protocols just after the client requests it. This is a really neat
idea and does not require an extra port.
<p>This method is used by almost all modern protocols and there is even
the <!-- %**else if -->
[RFC2817] (See <a href="#Bibliography">RFC2817</a>.)
paper which proposes extensions to HTTP to support
it.
<p>The tricky part, in this method, is that the “STARTTLS” request is
sent in the clear, thus is vulnerable to modifications. A typical
attack is to modify the messages in a way that the client is fooled
and thinks that the server does not have the “STARTTLS” capability.
See a typical conversation of a hypothetical protocol:
<blockquote>
(client connects to the server)
<p>CLIENT: HELLO I'M MR. XXX
<p>SERVER: NICE TO MEET YOU XXX
<p>CLIENT: PLEASE START TLS
<p>SERVER: OK
<p>*** TLS STARTS
<p>CLIENT: HERE ARE SOME CONFIDENTIAL DATA
</blockquote>
<p>And see an example of a conversation where someone is acting
in between:
<blockquote>
(client connects to the server)
<p>CLIENT: HELLO I'M MR. XXX
<p>SERVER: NICE TO MEET YOU XXX
<p>CLIENT: PLEASE START TLS
<p>(here someone inserts this message)
<p>SERVER: SORRY I DON'T HAVE THIS CAPABILITY
<p>CLIENT: HERE ARE SOME CONFIDENTIAL DATA
</blockquote>
<p>As you can see above the client was fooled, and was dummy enough to
send the confidential data in the clear.
<p>How to avoid the above attack? As you may have already thought this
one is easy to avoid. The client has to ask the user before it
connects whether the user requests <acronym>TLS</acronym> or not. If the user
answered that he certainly wants the secure layer the last
conversation should be:
<blockquote>
(client connects to the server)
<p>CLIENT: HELLO I'M MR. XXX
<p>SERVER: NICE TO MEET YOU XXX
<p>CLIENT: PLEASE START TLS
<p>(here someone inserts this message)
<p>SERVER: SORRY I DON'T HAVE THIS CAPABILITY
<p>CLIENT: BYE
<p>(the client notifies the user that the secure connection was not possible)
</blockquote>
<p>This method, if implemented properly, is far better than the
traditional method, and the security properties remain the same, since
only denial of service is possible. The benefit is that the server may
request additional data before the <acronym>TLS</acronym> Handshake protocol
starts, in order to send the correct certificate, use the correct
password file<a rel="footnote" href="#fn-16" name="fnd-16"><sup>16</sup></a>, or anything
else!
<div class="node">
<p><hr>
<a name="How-to-use-GnuTLS-in-applications"></a>
Next: <a rel="next" accesskey="n" href="#Included-programs">Included programs</a>,
Previous: <a rel="previous" accesskey="p" href="#How-to-use-TLS-in-application-protocols">How to use TLS in application protocols</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">7 How to use <acronym>GnuTLS</acronym> in applications</h2>
<p><a name="examples"></a>
<a name="index-Example-programs-32"></a>
<ul class="menu">
<li><a accesskey="1" href="#Preparation">Preparation</a>
<li><a accesskey="2" href="#Multi_002dthreaded-applications">Multi-threaded applications</a>
<li><a accesskey="3" href="#Client-examples">Client examples</a>
<li><a accesskey="4" href="#Server-examples">Server examples</a>
<li><a accesskey="5" href="#Miscellaneous-examples">Miscellaneous examples</a>
<li><a accesskey="6" href="#Compatibility-with-the-OpenSSL-library">Compatibility with the OpenSSL library</a>
</ul>
<div class="node">
<p><hr>
<a name="Preparation"></a>
Next: <a rel="next" accesskey="n" href="#Multi_002dthreaded-applications">Multi-threaded applications</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
</div>
<h3 class="section">7.1 Preparation</h3>
<p>To use <acronym>GnuTLS</acronym>, you have to perform some changes to your
sources and your build system. The necessary changes are explained in
the following subsections.
<ul class="menu">
<li><a accesskey="1" href="#Headers">Headers</a>
<li><a accesskey="2" href="#Version-check">Version check</a>
<li><a accesskey="3" href="#Building-the-source">Building the source</a>
</ul>
<div class="node">
<p><hr>
<a name="Headers"></a>
Next: <a rel="next" accesskey="n" href="#Version-check">Version check</a>,
Up: <a rel="up" accesskey="u" href="#Preparation">Preparation</a>
</div>
<h4 class="subsection">7.1.1 Headers</h4>
<p>All the data types and functions of the <acronym>GnuTLS</acronym> library are
defined in the header file <samp><span class="file">gnutls/gnutls.h</span></samp>. This must be
included in all programs that make use of the <acronym>GnuTLS</acronym>
library.
<p>The extra functionality of the <acronym>GnuTLS-extra</acronym> library is
available by including the header file <samp><span class="file">gnutls/extra.h</span></samp> in your
programs.
<div class="node">
<p><hr>
<a name="Version-check"></a>
Next: <a rel="next" accesskey="n" href="#Building-the-source">Building the source</a>,
Previous: <a rel="previous" accesskey="p" href="#Headers">Headers</a>,
Up: <a rel="up" accesskey="u" href="#Preparation">Preparation</a>
</div>
<h4 class="subsection">7.1.2 Version check</h4>
<p>It is often desirable to check that the version of `gnutls' used is
indeed one which fits all requirements. Even with binary
compatibility new features may have been introduced but due to problem
with the dynamic linker an old version is actually used. So you may
want to check that the version is okay right after program startup.
See the function <a href="#gnutls_005fcheck_005fversion">gnutls_check_version</a>.
<div class="node">
<p><hr>
<a name="Building-the-source"></a>
Previous: <a rel="previous" accesskey="p" href="#Version-check">Version check</a>,
Up: <a rel="up" accesskey="u" href="#Preparation">Preparation</a>
</div>
<h4 class="subsection">7.1.3 Building the source</h4>
<p>If you want to compile a source file including the `gnutls/gnutls.h'
header file, you must make sure that the compiler can find it in the
directory hierarchy. This is accomplished by adding the path to the
directory in which the header file is located to the compilers include
file search path (via the -I option).
<p>However, the path to the include file is determined at the time the
source is configured. To solve this problem, <acronym>GnuTLS</acronym> ships
with two small helper programs <samp><span class="command">libgnutls-config</span></samp> and
<samp><span class="command">libgnutls-extra-config</span></samp> that knows about the path to the
include file and other configuration options. The options that need
to be added to the compiler invocation at compile time are output by
the <code>--cflags</code> option to <samp><span class="command">libgnutls-config</span></samp>. The
following example shows how it can be used at the command line:
<pre class="example"> gcc -c foo.c `libgnutls-config --cflags`
</pre>
<p>Adding the output of <samp><span class="command">libgnutls-config --cflags</span></samp> to the
compilers command line will ensure that the compiler can find the
<acronym>GnuTLS</acronym> header file.
<p>A similar problem occurs when linking the program with the library.
Again, the compiler has to find the library files. For this to work,
the path to the library files has to be added to the library search
path (via the -L option). For this, the option <code>--libs</code> to
<samp><span class="command">libgnutls-config</span></samp> can be used. For convenience, this option
also outputs all other options that are required to link the program
with the <acronym>GnuTLS</acronym> libararies. The example shows how to link
`foo.o' with the <acronym>GnuTLS</acronym> libraries to a program <em>foo</em>.
<pre class="example"> gcc -o foo foo.o `libgnutls-config --libs`
</pre>
<p>Of course you can also combine both examples to a single command by
specifying both options to `libgnutls-config':
<pre class="example"> gcc -o foo foo.c `libgnutls-config --cflags --libs`
</pre>
<div class="node">
<p><hr>
<a name="Multi-threaded-applications"></a>
<a name="Multi_002dthreaded-applications"></a>
Next: <a rel="next" accesskey="n" href="#Client-examples">Client examples</a>,
Previous: <a rel="previous" accesskey="p" href="#Preparation">Preparation</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
</div>
<h3 class="section">7.2 Multi-threaded applications</h3>
<p>Although the <acronym>GnuTLS</acronym> library is thread safe by design, some
parts of the crypto backend, such as the random generator, are
not. Since <em>libgcrypt 1.1.92</em> there was an automatic detection of
the thread library used by the application, so most applications
wouldn't need to do any changes to ensure thread-safety. Due to the
unportability of the automatic thread detection, this was removed from
later releases of <em>libgcrypt</em>, so applications have now to
register callback functions to ensure proper locking in sensitive
parts of <em>libgcrypt</em>.
<p>There are helper macros to help you properly initialize the libraries.
Examples are shown below.
<ul>
<li>POSIX threads
<pre class="example"> #include <gnutls.h>
#include <gcrypt.h>
#include <errno.h>
#include <pthread.h>
GCRY_THREAD_OPTION_PTHREAD_IMPL;
int main()
{
/* The order matters.
*/
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
gnutls_global_init();
}
</pre>
<li>GNU PTH threads
<pre class="example"> #include <gnutls.h>
#include <gcrypt.h>
#include <errno.h>
#include <pth.h>
GCRY_THREAD_OPTION_PTH_IMPL;
int main()
{
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
gnutls_global_init();
}
</pre>
<li>Other thread packages
<pre class="example"> /* The gcry_thread_cbs structure must have been
* initialized.
*/
static struct gcry_thread_cbs gcry_threads_other = { ... };
int main()
{
gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_other);
}
</pre>
</ul>
<div class="node">
<p><hr>
<a name="Client-examples"></a>
Next: <a rel="next" accesskey="n" href="#Server-examples">Server examples</a>,
Previous: <a rel="previous" accesskey="p" href="#Multi_002dthreaded-applications">Multi-threaded applications</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
</div>
<h3 class="section">7.3 Client examples</h3>
<p>This section contains examples of <acronym>TLS</acronym> and <acronym>SSL</acronym>
clients, using <acronym>GnuTLS</acronym>. Note that these examples contain
little or no error checking.
<ul class="menu">
<li><a accesskey="1" href="#Simple-client-example-with-anonymous-authentication">Simple client example with anonymous authentication</a>
<li><a accesskey="2" href="#Simple-client-example-with-X_002e509-certificate-support">Simple client example with X.509 certificate support</a>
<li><a accesskey="3" href="#Obtaining-session-information">Obtaining session information</a>
<li><a accesskey="4" href="#Verifying-peer_0027s-certificate">Verifying peer's certificate</a>
<li><a accesskey="5" href="#Using-a-callback-to-select-the-certificate-to-use">Using a callback to select the certificate to use</a>
<li><a accesskey="6" href="#Client-with-Resume-capability-example">Client with Resume capability example</a>
<li><a accesskey="7" href="#Simple-client-example-with-SRP-authentication">Simple client example with SRP authentication</a>
</ul>
<div class="node">
<p><hr>
<a name="Simple-client-example-with-anonymous-authentication"></a>
Next: <a rel="next" accesskey="n" href="#Simple-client-example-with-X_002e509-certificate-support">Simple client example with X.509 certificate support</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.1 Simple client example with anonymous authentication</h4>
<p>The simplest client using TLS is the one that doesn't do any
authentication. This means no external certificates or passwords are
needed to set up the connection. As could be expected, the connection
is vulnerable to man-in-the-middle (active or redirection) attacks.
However, the data is integrity and privacy protected.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
/* A very basic TLS client, with anonymous authentication.
*/
#define MAX_BUF 1024
#define SA struct sockaddr
#define MSG "GET / HTTP/1.0\r\n\r\n"
extern int tcp_connect (void);
extern void tcp_close (int sd);
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_anon_client_credentials_t anoncred;
/* Need to enable anonymous KX specifically. */
const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
gnutls_global_init ();
gnutls_anon_allocate_client_credentials (&anoncred);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_set_default_priority (session);
gnutls_kx_set_priority (session, kx_prio);
/* put the anonymous credentials to the current session
*/
gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
/* connect to the peer
*/
sd = tcp_connect ();
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* Perform the TLS handshake
*/
ret = gnutls_handshake (session);
if (ret < 0)
{
fprintf (stderr, "*** Handshake failed\n");
gnutls_perror (ret);
goto end;
}
else
{
printf ("- Handshake was completed\n");
}
gnutls_record_send (session, MSG, strlen (MSG));
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("- Peer has closed the TLS connection\n");
goto end;
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
gnutls_bye (session, GNUTLS_SHUT_RDWR);
end:
tcp_close (sd);
gnutls_deinit (session);
gnutls_anon_free_client_credentials (anoncred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Simple-client-example-with-X.509-certificate-support"></a>
<a name="Simple-client-example-with-X_002e509-certificate-support"></a>
Next: <a rel="next" accesskey="n" href="#Obtaining-session-information">Obtaining session information</a>,
Previous: <a rel="previous" accesskey="p" href="#Simple-client-example-with-anonymous-authentication">Simple client example with anonymous authentication</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.2 Simple client example with <acronym>X.509</acronym> certificate support</h4>
<p>Let's assume now that we want to create a TCP client which
communicates with servers that use <acronym>X.509</acronym> or
<acronym>OpenPGP</acronym> certificate authentication. The following client is
a very simple <acronym>TLS</acronym> client, it does not support session
resuming, not even certificate verification. The TCP functions defined
in this example are used in most of the other examples below, without
redefining them.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
/* A very basic TLS client, with X.509 authentication.
*/
#define MAX_BUF 1024
#define CAFILE "ca.pem"
#define MSG "GET / HTTP/1.0\r\n\r\n"
extern int tcp_connect (void);
extern void tcp_close (int sd);
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_certificate_credentials_t xcred;
/* Allow connections to servers that have OpenPGP keys as well.
*/
const int cert_type_priority[3] = { GNUTLS_CRT_X509,
GNUTLS_CRT_OPENPGP, 0
};
gnutls_global_init ();
/* X509 stuff */
gnutls_certificate_allocate_credentials (&xcred);
/* sets the trusted cas file
*/
gnutls_certificate_set_x509_trust_file (xcred, CAFILE, GNUTLS_X509_FMT_PEM);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_set_default_priority (session);
gnutls_certificate_type_set_priority (session, cert_type_priority);
/* put the x509 credentials to the current session
*/
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
/* connect to the peer
*/
sd = tcp_connect ();
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* Perform the TLS handshake
*/
ret = gnutls_handshake (session);
if (ret < 0)
{
fprintf (stderr, "*** Handshake failed\n");
gnutls_perror (ret);
goto end;
}
else
{
printf ("- Handshake was completed\n");
}
gnutls_record_send (session, MSG, strlen (MSG));
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("- Peer has closed the TLS connection\n");
goto end;
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
gnutls_bye (session, GNUTLS_SHUT_RDWR);
end:
tcp_close (sd);
gnutls_deinit (session);
gnutls_certificate_free_credentials (xcred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Obtaining-session-information"></a>
Next: <a rel="next" accesskey="n" href="#Verifying-peer_0027s-certificate">Verifying peer's certificate</a>,
Previous: <a rel="previous" accesskey="p" href="#Simple-client-example-with-X_002e509-certificate-support">Simple client example with X.509 certificate support</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.3 Obtaining session information</h4>
<p>Most of the times it is desirable to know the security properties of
the current established session. This includes the underlying ciphers
and the protocols involved. That is the purpose of the following
function. Note that this function will print meaningful values only
if called after a successful <a href="#gnutls_005fhandshake">gnutls_handshake</a>.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
extern void print_x509_certificate_info (gnutls_session_t);
/* This function will print some details of the
* given session.
*/
int
print_info (gnutls_session_t session)
{
const char *tmp;
gnutls_credentials_type_t cred;
gnutls_kx_algorithm_t kx;
/* print the key exchange's algorithm name
*/
kx = gnutls_kx_get (session);
tmp = gnutls_kx_get_name (kx);
printf ("- Key Exchange: %s\n", tmp);
/* Check the authentication type used and switch
* to the appropriate.
*/
cred = gnutls_auth_get_type (session);
switch (cred)
{
case GNUTLS_CRD_SRP:
printf ("- SRP session with username %s\n",
gnutls_srp_server_get_username (session));
break;
case GNUTLS_CRD_ANON: /* anonymous authentication */
printf ("- Anonymous DH using prime of %d bits\n",
gnutls_dh_get_prime_bits (session));
break;
case GNUTLS_CRD_CERTIFICATE: /* certificate authentication */
/* Check if we have been using ephemeral Diffie Hellman.
*/
if (kx == GNUTLS_KX_DHE_RSA || kx == GNUTLS_KX_DHE_DSS)
{
printf ("\n- Ephemeral DH using prime of %d bits\n",
gnutls_dh_get_prime_bits (session));
}
/* if the certificate list is available, then
* print some information about it.
*/
print_x509_certificate_info (session);
} /* switch */
/* print the protocol's name (ie TLS 1.0)
*/
tmp = gnutls_protocol_get_name (gnutls_protocol_get_version (session));
printf ("- Protocol: %s\n", tmp);
/* print the certificate type of the peer.
* ie X.509
*/
tmp =
gnutls_certificate_type_get_name (gnutls_certificate_type_get (session));
printf ("- Certificate Type: %s\n", tmp);
/* print the compression algorithm (if any)
*/
tmp = gnutls_compression_get_name (gnutls_compression_get (session));
printf ("- Compression: %s\n", tmp);
/* print the name of the cipher used.
* ie 3DES.
*/
tmp = gnutls_cipher_get_name (gnutls_cipher_get (session));
printf ("- Cipher: %s\n", tmp);
/* Print the MAC algorithms name.
* ie SHA1
*/
tmp = gnutls_mac_get_name (gnutls_mac_get (session));
printf ("- MAC: %s\n", tmp);
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Verifying-peer's-certificate"></a>
<a name="Verifying-peer_0027s-certificate"></a>
Next: <a rel="next" accesskey="n" href="#Using-a-callback-to-select-the-certificate-to-use">Using a callback to select the certificate to use</a>,
Previous: <a rel="previous" accesskey="p" href="#Obtaining-session-information">Obtaining session information</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.4 Verifying peer's certificate</h4>
<p><a name="ex_003averify"></a>
<p>A <acronym>TLS</acronym> session is not secure just after the handshake
procedure has finished. It must be considered secure, only after the
peer's certificate and identity have been verified. That is, you have
to verify the signature in peer's certificate, the hostname in the
certificate, and expiration dates. Just after this step you should
treat the connection as being a secure one.
<pre class="verbatim">#include <stdio.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
/* This function will try to verify the peer's certificate, and
* also check if the hostname matches, and the activation, expiration dates.
*/
void
verify_certificate (gnutls_session_t session, const char *hostname)
{
unsigned int status;
const gnutls_datum_t *cert_list;
int cert_list_size, ret;
gnutls_x509_crt_t cert;
/* This verification function uses the trusted CAs in the credentials
* structure. So you must have installed one or more CA certificates.
*/
ret = gnutls_certificate_verify_peers2 (session, &status);
if (ret < 0)
{
printf ("Error\n");
return;
}
if (status & GNUTLS_CERT_INVALID)
printf ("The certificate is not trusted.\n");
if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
printf ("The certificate hasn't got a known issuer.\n");
if (status & GNUTLS_CERT_REVOKED)
printf ("The certificate has been revoked.\n");
/* Up to here the process is the same for X.509 certificates and
* OpenPGP keys. From now on X.509 certificates are assumed. This can
* be easily extended to work with openpgp keys as well.
*/
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509)
return;
if (gnutls_x509_crt_init (&cert) < 0)
{
printf ("error in initialization\n");
return;
}
cert_list = gnutls_certificate_get_peers (session, &cert_list_size);
if (cert_list == NULL)
{
printf ("No certificate was found!\n");
return;
}
/* This is not a real world example, since we only check the first
* certificate in the given chain.
*/
if (gnutls_x509_crt_import (cert, &cert_list[0], GNUTLS_X509_FMT_DER) < 0)
{
printf ("error parsing certificate\n");
return;
}
/* Beware here we do not check for errors.
*/
if (gnutls_x509_crt_get_expiration_time (cert) < time (0))
{
printf ("The certificate has expired\n");
return;
}
if (gnutls_x509_crt_get_activation_time (cert) > time (0))
{
printf ("The certificate is not yet activated\n");
return;
}
if (!gnutls_x509_crt_check_hostname (cert, hostname))
{
printf ("The certificate's owner does not match hostname '%s'\n",
hostname);
return;
}
gnutls_x509_crt_deinit (cert);
return;
}
</pre>
An other example is listed below which provides a more detailed
verification output.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
/* All the available CRLs
*/
gnutls_x509_crl_t *crl_list;
int crl_list_size;
/* All the available trusted CAs
*/
gnutls_x509_crt_t *ca_list;
int ca_list_size;
static void verify_cert2 (gnutls_x509_crt_t crt,
gnutls_x509_crt_t issuer,
gnutls_x509_crl_t * crl_list, int crl_list_size);
static void verify_last_cert (gnutls_x509_crt_t crt,
gnutls_x509_crt_t * ca_list, int ca_list_size,
gnutls_x509_crl_t * crl_list,
int crl_list_size);
/* This function will try to verify the peer's certificate chain, and
* also check if the hostname matches, and the activation, expiration dates.
*/
void
verify_certificate_chain (gnutls_session_t session,
const char *hostname,
const gnutls_datum_t * cert_chain,
int cert_chain_length)
{
int i;
gnutls_x509_crt_t *cert;
cert = malloc (sizeof (*cert) * cert_chain_length);
/* Import all the certificates in the chain to
* native certificate format.
*/
for (i = 0; i < cert_chain_length; i++)
{
gnutls_x509_crt_init (&cert[i]);
gnutls_x509_crt_import (cert[i], &cert_chain[i], GNUTLS_X509_FMT_DER);
}
/* If the last certificate in the chain is self signed ignore it.
* That is because we want to check against our trusted certificate
* list.
*/
if (gnutls_x509_crt_check_issuer (cert[cert_chain_length - 1],
cert[cert_chain_length - 1]) > 0
&& cert_chain_length > 0)
{
cert_chain_length--;
}
/* Now verify the certificates against their issuers
* in the chain.
*/
for (i = 1; i < cert_chain_length; i++)
{
verify_cert2 (cert[i - 1], cert[i], crl_list, crl_list_size);
}
/* Here we must verify the last certificate in the chain against
* our trusted CA list.
*/
verify_last_cert (cert[cert_chain_length - 1],
ca_list, ca_list_size, crl_list, crl_list_size);
/* Check if the name in the first certificate matches our destination!
*/
if (!gnutls_x509_crt_check_hostname (cert[0], hostname))
{
printf ("The certificate's owner does not match hostname '%s'\n",
hostname);
}
for (i = 0; i < cert_chain_length; i++)
gnutls_x509_crt_deinit (cert[i]);
return;
}
/* Verifies a certificate against an other certificate
* which is supposed to be it's issuer. Also checks the
* crl_list if the certificate is revoked.
*/
static void
verify_cert2 (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer,
gnutls_x509_crl_t * crl_list, int crl_list_size)
{
unsigned int output;
int ret;
time_t now = time (0);
size_t name_size;
char name[64];
/* Print information about the certificates to
* be checked.
*/
name_size = sizeof (name);
gnutls_x509_crt_get_dn (crt, name, &name_size);
fprintf (stderr, "\nCertificate: %s\n", name);
name_size = sizeof (name);
gnutls_x509_crt_get_issuer_dn (crt, name, &name_size);
fprintf (stderr, "Issued by: %s\n", name);
/* Get the DN of the issuer cert.
*/
name_size = sizeof (name);
gnutls_x509_crt_get_dn (issuer, name, &name_size);
fprintf (stderr, "Checking against: %s\n", name);
/* Do the actual verification.
*/
gnutls_x509_crt_verify (crt, &issuer, 1, 0, &output);
if (output & GNUTLS_CERT_INVALID)
{
fprintf (stderr, "Not trusted");
if (output & GNUTLS_CERT_SIGNER_NOT_FOUND)
fprintf (stderr, ": no issuer was found");
if (output & GNUTLS_CERT_SIGNER_NOT_CA)
fprintf (stderr, ": issuer is not a CA");
fprintf (stderr, "\n");
}
else
fprintf (stderr, "Trusted\n");
/* Now check the expiration dates.
*/
if (gnutls_x509_crt_get_activation_time (crt) > now)
fprintf (stderr, "Not yet activated\n");
if (gnutls_x509_crt_get_expiration_time (crt) < now)
fprintf (stderr, "Expired\n");
/* Check if the certificate is revoked.
*/
ret = gnutls_x509_crt_check_revocation (crt, crl_list, crl_list_size);
if (ret == 1)
{ /* revoked */
fprintf (stderr, "Revoked\n");
}
}
/* Verifies a certificate against our trusted CA list.
* Also checks the crl_list if the certificate is revoked.
*/
static void
verify_last_cert (gnutls_x509_crt_t crt,
gnutls_x509_crt_t * ca_list, int ca_list_size,
gnutls_x509_crl_t * crl_list, int crl_list_size)
{
unsigned int output;
int ret;
time_t now = time (0);
size_t name_size;
char name[64];
/* Print information about the certificates to
* be checked.
*/
name_size = sizeof (name);
gnutls_x509_crt_get_dn (crt, name, &name_size);
fprintf (stderr, "\nCertificate: %s\n", name);
name_size = sizeof (name);
gnutls_x509_crt_get_issuer_dn (crt, name, &name_size);
fprintf (stderr, "Issued by: %s\n", name);
/* Do the actual verification.
*/
gnutls_x509_crt_verify (crt, ca_list, ca_list_size,
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT, &output);
if (output & GNUTLS_CERT_INVALID)
{
fprintf (stderr, "Not trusted");
if (output & GNUTLS_CERT_SIGNER_NOT_CA)
fprintf (stderr, ": Issuer is not a CA\n");
else
fprintf (stderr, "\n");
}
else
fprintf (stderr, "Trusted\n");
/* Now check the expiration dates.
*/
if (gnutls_x509_crt_get_activation_time (crt) > now)
fprintf (stderr, "Not yet activated\n");
if (gnutls_x509_crt_get_expiration_time (crt) < now)
fprintf (stderr, "Expired\n");
/* Check if the certificate is revoked.
*/
ret = gnutls_x509_crt_check_revocation (crt, crl_list, crl_list_size);
if (ret == 1)
{ /* revoked */
fprintf (stderr, "Revoked\n");
}
}
</pre>
<div class="node">
<p><hr>
<a name="Using-a-callback-to-select-the-certificate-to-use"></a>
Next: <a rel="next" accesskey="n" href="#Client-with-Resume-capability-example">Client with Resume capability example</a>,
Previous: <a rel="previous" accesskey="p" href="#Verifying-peer_0027s-certificate">Verifying peer's certificate</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.5 Using a callback to select the certificate to use</h4>
<p>There are cases where a client holds several certificate and key
pairs, and may not want to load all of them in the credentials
structure. The following example demonstrates the use of the
certificate selection callback.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/stat.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* A TLS client that loads the certificate and key.
*/
#define MAX_BUF 1024
#define MSG "GET / HTTP/1.0\r\n\r\n"
#define CERT_FILE "cert.pem"
#define KEY_FILE "key.pem"
#define CAFILE "ca.pem"
extern int tcp_connect (void);
extern void tcp_close (int sd);
static int cert_callback (gnutls_session_t session,
const gnutls_datum_t * req_ca_rdn, int nreqs,
const gnutls_pk_algorithm_t * sign_algos,
int sign_algos_length, gnutls_retr_st * st);
gnutls_x509_crt_t crt;
gnutls_x509_privkey_t key;
/* Helper functions to load a certificate and key
* files into memory.
*/
static gnutls_datum
load_file (const char *file)
{
FILE *f;
gnutls_datum loaded_file = { NULL, 0 };
long filelen;
void *ptr;
if (!(f = fopen(file, "r"))
|| fseek(f, 0, SEEK_END) != 0
|| (filelen = ftell(f)) < 0
|| fseek(f, 0, SEEK_SET) != 0
|| !(ptr = malloc((size_t)filelen))
|| fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen)
{
return loaded_file;
}
loaded_file.data = ptr;
loaded_file.size = (unsigned int)filelen;
return loaded_file;
}
static void unload_file(gnutls_datum data)
{
free(data.data);
}
/* Load the certificate and the private key.
*/
static void
load_keys (void)
{
int ret;
gnutls_datum_t data;
data = load_file (CERT_FILE);
if (data.data == NULL)
{
fprintf (stderr, "*** Error loading cert file.\n");
exit (1);
}
gnutls_x509_crt_init (&crt);
ret = gnutls_x509_crt_import (crt, &data, GNUTLS_X509_FMT_PEM);
if (ret < 0)
{
fprintf (stderr, "*** Error loading key file: %s\n",
gnutls_strerror (ret));
exit (1);
}
unload_file (data);
data = load_file (KEY_FILE);
if (data.data == NULL)
{
fprintf (stderr, "*** Error loading key file.\n");
exit (1);
}
gnutls_x509_privkey_init (&key);
ret = gnutls_x509_privkey_import (key, &data, GNUTLS_X509_FMT_PEM);
if (ret < 0)
{
fprintf (stderr, "*** Error loading key file: %s\n",
gnutls_strerror (ret));
exit (1);
}
unload_file (data);
}
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_certificate_credentials_t xcred;
/* Allow connections to servers that have OpenPGP keys as well.
*/
gnutls_global_init ();
load_keys ();
/* X509 stuff */
gnutls_certificate_allocate_credentials (&xcred);
/* sets the trusted cas file
*/
gnutls_certificate_set_x509_trust_file (xcred, CAFILE, GNUTLS_X509_FMT_PEM);
gnutls_certificate_client_set_retrieve_function (xcred, cert_callback);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_set_default_priority (session);
/* put the x509 credentials to the current session
*/
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
/* connect to the peer
*/
sd = tcp_connect ();
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* Perform the TLS handshake
*/
ret = gnutls_handshake (session);
if (ret < 0)
{
fprintf (stderr, "*** Handshake failed\n");
gnutls_perror (ret);
goto end;
}
else
{
printf ("- Handshake was completed\n");
}
gnutls_record_send (session, MSG, strlen (MSG));
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("- Peer has closed the TLS connection\n");
goto end;
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
gnutls_bye (session, GNUTLS_SHUT_RDWR);
end:
tcp_close (sd);
gnutls_deinit (session);
gnutls_certificate_free_credentials (xcred);
gnutls_global_deinit ();
return 0;
}
/* This callback should be associated with a session by calling
* gnutls_certificate_client_set_retrieve_function( session, cert_callback),
* before a handshake.
*/
static int
cert_callback (gnutls_session_t session,
const gnutls_datum_t * req_ca_rdn, int nreqs,
const gnutls_pk_algorithm_t * sign_algos,
int sign_algos_length, gnutls_retr_st * st)
{
char issuer_dn[256];
int i, ret;
size_t len;
gnutls_certificate_type_t type;
/* Print the server's trusted CAs
*/
if (nreqs > 0)
printf ("- Server's trusted authorities:\n");
else
printf ("- Server did not send us any trusted authorities names.\n");
/* print the names (if any) */
for (i = 0; i < nreqs; i++)
{
len = sizeof (issuer_dn);
ret = gnutls_x509_rdn_get (&req_ca_rdn[i], issuer_dn, &len);
if (ret >= 0)
{
printf (" [%d]: ", i);
printf ("%s\n", issuer_dn);
}
}
/* Select a certificate and return it.
* The certificate must be of any of the "sign algorithms"
* supported by the server.
*/
type = gnutls_certificate_type_get (session);
if (type == GNUTLS_CRT_X509)
{
st->type = type;
st->ncerts = 1;
st->cert.x509 = &crt;
st->key.x509 = key;
st->deinit_all = 0;
}
else
{
return -1;
}
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Client-with-Resume-capability-example"></a>
Next: <a rel="next" accesskey="n" href="#Simple-client-example-with-SRP-authentication">Simple client example with SRP authentication</a>,
Previous: <a rel="previous" accesskey="p" href="#Using-a-callback-to-select-the-certificate-to-use">Using a callback to select the certificate to use</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.6 Client with Resume capability example</h4>
<p><a name="ex_003aresume_002dclient"></a>
<p>This is a modification of the simple client example. Here we
demonstrate the use of session resumption. The client tries to connect
once using <acronym>TLS</acronym>, close the connection and then try to
establish a new connection using the previously negotiated data.
<pre class="verbatim">#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
/* Those functions are defined in other examples.
*/
extern void check_alert (gnutls_session_t session, int ret);
extern int tcp_connect (void);
extern void tcp_close (int sd);
#define MAX_BUF 1024
#define CRLFILE "crl.pem"
#define CAFILE "ca.pem"
#define MSG "GET / HTTP/1.0\r\n\r\n"
int
main (void)
{
int ret;
int sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_certificate_credentials_t xcred;
/* variables used in session resuming
*/
int t;
char *session_data;
size_t session_data_size;
gnutls_global_init ();
/* X509 stuff */
gnutls_certificate_allocate_credentials (&xcred);
gnutls_certificate_set_x509_trust_file (xcred, CAFILE, GNUTLS_X509_FMT_PEM);
for (t = 0; t < 2; t++)
{ /* connect 2 times to the server */
sd = tcp_connect ();
gnutls_init (&session, GNUTLS_CLIENT);
gnutls_set_default_priority (session);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
if (t > 0)
{
/* if this is not the first time we connect */
gnutls_session_set_data (session, session_data, session_data_size);
free (session_data);
}
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* Perform the TLS handshake
*/
ret = gnutls_handshake (session);
if (ret < 0)
{
fprintf (stderr, "*** Handshake failed\n");
gnutls_perror (ret);
goto end;
}
else
{
printf ("- Handshake was completed\n");
}
if (t == 0)
{ /* the first time we connect */
/* get the session data size */
gnutls_session_get_data (session, NULL, &session_data_size);
session_data = malloc (session_data_size);
/* put session data to the session variable */
gnutls_session_get_data (session, session_data, &session_data_size);
}
else
{ /* the second time we connect */
/* check if we actually resumed the previous session */
if (gnutls_session_is_resumed (session) != 0)
{
printf ("- Previous session was resumed\n");
}
else
{
fprintf (stderr, "*** Previous session was NOT resumed\n");
}
}
/* This function was defined in a previous example
*/
/* print_info(session); */
gnutls_record_send (session, MSG, strlen (MSG));
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("- Peer has closed the TLS connection\n");
goto end;
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
gnutls_bye (session, GNUTLS_SHUT_RDWR);
end:
tcp_close (sd);
gnutls_deinit (session);
} /* for() */
gnutls_certificate_free_credentials (xcred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Simple-client-example-with-SRP-authentication"></a>
Previous: <a rel="previous" accesskey="p" href="#Client-with-Resume-capability-example">Client with Resume capability example</a>,
Up: <a rel="up" accesskey="u" href="#Client-examples">Client examples</a>
</div>
<h4 class="subsection">7.3.7 Simple client example with <acronym>SRP</acronym> authentication</h4>
<p>The following client is a very simple <acronym>SRP</acronym> <acronym>TLS</acronym>
client which connects to a server and authenticates using a
<em>username</em> and a <em>password</em>. The server may authenticate
itself using a certificate, and in that case it has to be verified.
<pre class="verbatim">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
/* Those functions are defined in other examples.
*/
extern void check_alert (gnutls_session_t session, int ret);
extern int tcp_connect (void);
extern void tcp_close (int sd);
#define MAX_BUF 1024
#define USERNAME "user"
#define PASSWORD "pass"
#define CAFILE "ca.pem"
#define SA struct sockaddr
#define MSG "GET / HTTP/1.0\r\n\r\n"
const int kx_priority[] = { GNUTLS_KX_SRP, GNUTLS_KX_SRP_DSS,
GNUTLS_KX_SRP_RSA, 0
};
int
main (void)
{
int ret;
int sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
gnutls_srp_client_credentials_t srp_cred;
gnutls_certificate_credentials_t cert_cred;
gnutls_global_init ();
/* now enable the gnutls-extra library which contains the
* SRP stuff.
*/
gnutls_global_init_extra ();
gnutls_srp_allocate_client_credentials (&srp_cred);
gnutls_certificate_allocate_credentials (&cert_cred);
gnutls_certificate_set_x509_trust_file (cert_cred, CAFILE,
GNUTLS_X509_FMT_PEM);
gnutls_srp_set_client_credentials (srp_cred, USERNAME, PASSWORD);
/* connects to server
*/
sd = tcp_connect ();
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Set the priorities.
*/
gnutls_set_default_priority (session);
gnutls_kx_set_priority (session, kx_priority);
/* put the SRP credentials to the current session
*/
gnutls_credentials_set (session, GNUTLS_CRD_SRP, srp_cred);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cert_cred);
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* Perform the TLS handshake
*/
ret = gnutls_handshake (session);
if (ret < 0)
{
fprintf (stderr, "*** Handshake failed\n");
gnutls_perror (ret);
goto end;
}
else
{
printf ("- Handshake was completed\n");
}
gnutls_record_send (session, MSG, strlen (MSG));
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (gnutls_error_is_fatal (ret) == 1 || ret == 0)
{
if (ret == 0)
{
printf ("- Peer has closed the GNUTLS connection\n");
goto end;
}
else
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
}
else
check_alert (session, ret);
if (ret > 0)
{
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
}
gnutls_bye (session, GNUTLS_SHUT_RDWR);
end:
tcp_close (sd);
gnutls_deinit (session);
gnutls_srp_free_client_credentials (srp_cred);
gnutls_certificate_free_credentials (cert_cred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Server-examples"></a>
Next: <a rel="next" accesskey="n" href="#Miscellaneous-examples">Miscellaneous examples</a>,
Previous: <a rel="previous" accesskey="p" href="#Client-examples">Client examples</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
</div>
<h3 class="section">7.4 Server examples</h3>
<p>This section contains examples of <acronym>TLS</acronym> and <acronym>SSL</acronym>
servers, using <acronym>GnuTLS</acronym>.
<ul class="menu">
<li><a accesskey="1" href="#Echo-Server-with-X_002e509-authentication">Echo Server with X.509 authentication</a>
<li><a accesskey="2" href="#Echo-Server-with-X_002e509-authentication-II">Echo Server with X.509 authentication II</a>
<li><a accesskey="3" href="#Echo-Server-with-OpenPGP-authentication">Echo Server with OpenPGP authentication</a>
<li><a accesskey="4" href="#Echo-Server-with-SRP-authentication">Echo Server with SRP authentication</a>
<li><a accesskey="5" href="#Echo-Server-with-anonymous-authentication">Echo Server with anonymous authentication</a>
</ul>
<div class="node">
<p><hr>
<a name="Echo-Server-with-X.509-authentication"></a>
<a name="Echo-Server-with-X_002e509-authentication"></a>
Next: <a rel="next" accesskey="n" href="#Echo-Server-with-X_002e509-authentication-II">Echo Server with X.509 authentication II</a>,
Up: <a rel="up" accesskey="u" href="#Server-examples">Server examples</a>
</div>
<h4 class="subsection">7.4.1 Echo Server with <acronym>X.509</acronym> authentication</h4>
<p>This example is a very simple echo server which supports
<acronym>X.509</acronym> authentication, using the RSA ciphersuites.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#define KEYFILE "key.pem"
#define CERTFILE "cert.pem"
#define CAFILE "ca.pem"
#define CRLFILE "crl.pem"
/* This is a sample TLS 1.0 echo server, using X.509 authentication.
*/
#define SA struct sockaddr
#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);}
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
#define DH_BITS 1024
/* These are global */
gnutls_certificate_credentials_t x509_cred;
gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
gnutls_init (&session, GNUTLS_SERVER);
/* avoid calling all the priority functions, since the defaults
* are adequate.
*/
gnutls_set_default_priority (session);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
/* request client certificate if any.
*/
gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
gnutls_dh_set_prime_bits (session, DH_BITS);
return session;
}
static gnutls_dh_params_t dh_params;
static int
generate_dh_params (void)
{
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
* security requirements.
*/
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, DH_BITS);
return 0;
}
int
main (void)
{
int err, listen_sd, i;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
int client_len;
char topbuf[512];
gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
/* this must be called once in the program
*/
gnutls_global_init ();
gnutls_certificate_allocate_credentials (&x509_cred);
gnutls_certificate_set_x509_trust_file (x509_cred, CAFILE,
GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_x509_crl_file (x509_cred, CRLFILE,
GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_x509_key_file (x509_cred, CERTFILE, KEYFILE,
GNUTLS_X509_FMT_PEM);
generate_dh_params ();
gnutls_certificate_set_dh_params (x509_cred, dh_params);
/* Socket operations
*/
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
SOCKET_ERR (listen_sd, "socket");
memset (&sa_serv, '\0', sizeof (sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (PORT); /* Server Port number */
setsockopt (listen_sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int));
err = bind (listen_sd, (SA *) & sa_serv, sizeof (sa_serv));
SOCKET_ERR (err, "bind");
err = listen (listen_sd, 1024);
SOCKET_ERR (err, "listen");
printf ("Server ready. Listening to port '%d'.\n\n", PORT);
client_len = sizeof (sa_cli);
for (;;)
{
session = initialize_tls_session ();
sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
printf ("- connection from %s, port %d\n",
inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
sizeof (topbuf)), ntohs (sa_cli.sin_port));
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
ret = gnutls_handshake (session);
if (ret < 0)
{
close (sd);
gnutls_deinit (session);
fprintf (stderr, "*** Handshake has failed (%s)\n\n",
gnutls_strerror (ret));
continue;
}
printf ("- Handshake was completed\n");
/* see the Getting peer's information example */
/* print_info(session); */
i = 0;
for (;;)
{
memset (buffer, 0, MAX_BUF + 1);
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("\n- Peer has closed the GNUTLS connection\n");
break;
}
else if (ret < 0)
{
fprintf (stderr, "\n*** Received corrupted "
"data(%d). Closing the connection.\n\n", ret);
break;
}
else if (ret > 0)
{
/* echo data back to the client
*/
gnutls_record_send (session, buffer, strlen (buffer));
}
}
printf ("\n");
/* do not wait for the peer to close the connection.
*/
gnutls_bye (session, GNUTLS_SHUT_WR);
close (sd);
gnutls_deinit (session);
}
close (listen_sd);
gnutls_certificate_free_credentials (x509_cred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Echo-Server-with-X.509-authentication-II"></a>
<a name="Echo-Server-with-X_002e509-authentication-II"></a>
Next: <a rel="next" accesskey="n" href="#Echo-Server-with-OpenPGP-authentication">Echo Server with OpenPGP authentication</a>,
Previous: <a rel="previous" accesskey="p" href="#Echo-Server-with-X_002e509-authentication">Echo Server with X.509 authentication</a>,
Up: <a rel="up" accesskey="u" href="#Server-examples">Server examples</a>
</div>
<h4 class="subsection">7.4.2 Echo Server with <acronym>X.509</acronym> authentication II</h4>
<p>The following example is a server which supports <acronym>X.509</acronym>
authentication. This server supports the export-grade cipher suites,
the DHE ciphersuites and session resuming.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#define KEYFILE "key.pem"
#define CERTFILE "cert.pem"
#define CAFILE "ca.pem"
#define CRLFILE "crl.pem"
/* This is a sample TLS 1.0 echo server.
* Export-grade ciphersuites and session resuming are supported.
*/
#define SA struct sockaddr
#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);}
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
#define DH_BITS 1024
/* These are global */
gnutls_certificate_credentials_t cert_cred;
static void wrap_db_init (void);
static void wrap_db_deinit (void);
static int wrap_db_store (void *dbf, gnutls_datum_t key, gnutls_datum_t data);
static gnutls_datum_t wrap_db_fetch (void *dbf, gnutls_datum_t key);
static int wrap_db_delete (void *dbf, gnutls_datum_t key);
#define TLS_SESSION_CACHE 50
gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
gnutls_init (&session, GNUTLS_SERVER);
/* Use the default priorities, plus, export cipher suites.
*/
gnutls_set_default_export_priority (session);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cert_cred);
/* request client certificate if any.
*/
gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
gnutls_dh_set_prime_bits (session, DH_BITS);
if (TLS_SESSION_CACHE != 0)
{
gnutls_db_set_retrieve_function (session, wrap_db_fetch);
gnutls_db_set_remove_function (session, wrap_db_delete);
gnutls_db_set_store_function (session, wrap_db_store);
gnutls_db_set_ptr (session, NULL);
}
return session;
}
gnutls_dh_params_t dh_params;
/* Export-grade cipher suites require temporary RSA
* keys.
*/
gnutls_rsa_params_t rsa_params;
int
generate_dh_params (void)
{
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depends on the
* security requirements.
*/
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, DH_BITS);
return 0;
}
static int
generate_rsa_params (void)
{
gnutls_rsa_params_init (&rsa_params);
/* Generate RSA parameters - for use with RSA-export
* cipher suites. These should be discarded and regenerated
* once a day, once every 500 transactions etc. Depends on the
* security requirements.
*/
gnutls_rsa_params_generate2 (rsa_params, 512);
return 0;
}
int
main (void)
{
int err, listen_sd, i;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
int client_len;
char topbuf[512];
gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
char name[256];
strcpy (name, "Echo Server");
/* this must be called once in the program
*/
gnutls_global_init ();
gnutls_certificate_allocate_credentials (&cert_cred);
gnutls_certificate_set_x509_trust_file (cert_cred, CAFILE,
GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_x509_crl_file (cert_cred, CRLFILE,
GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_x509_key_file (cert_cred, CERTFILE, KEYFILE,
GNUTLS_X509_FMT_PEM);
generate_dh_params ();
generate_rsa_params ();
if (TLS_SESSION_CACHE != 0)
{
wrap_db_init ();
}
gnutls_certificate_set_dh_params (cert_cred, dh_params);
gnutls_certificate_set_rsa_export_params (cert_cred, rsa_params);
/* Socket operations
*/
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
SOCKET_ERR (listen_sd, "socket");
memset (&sa_serv, '\0', sizeof (sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (PORT); /* Server Port number */
setsockopt (listen_sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int));
err = bind (listen_sd, (SA *) & sa_serv, sizeof (sa_serv));
SOCKET_ERR (err, "bind");
err = listen (listen_sd, 1024);
SOCKET_ERR (err, "listen");
printf ("%s ready. Listening to port '%d'.\n\n", name, PORT);
client_len = sizeof (sa_cli);
for (;;)
{
session = initialize_tls_session ();
sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
printf ("- connection from %s, port %d\n",
inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
sizeof (topbuf)), ntohs (sa_cli.sin_port));
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
ret = gnutls_handshake (session);
if (ret < 0)
{
close (sd);
gnutls_deinit (session);
fprintf (stderr, "*** Handshake has failed (%s)\n\n",
gnutls_strerror (ret));
continue;
}
printf ("- Handshake was completed\n");
/* print_info(session); */
i = 0;
for (;;)
{
memset (buffer, 0, MAX_BUF + 1);
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("\n- Peer has closed the TLS connection\n");
break;
}
else if (ret < 0)
{
fprintf (stderr, "\n*** Received corrupted "
"data(%d). Closing the connection.\n\n", ret);
break;
}
else if (ret > 0)
{
/* echo data back to the client
*/
gnutls_record_send (session, buffer, strlen (buffer));
}
}
printf ("\n");
/* do not wait for the peer to close the connection.
*/
gnutls_bye (session, GNUTLS_SHUT_WR);
close (sd);
gnutls_deinit (session);
}
close (listen_sd);
gnutls_certificate_free_credentials (cert_cred);
gnutls_global_deinit ();
return 0;
}
/* Functions and other stuff needed for session resuming.
* This is done using a very simple list which holds session ids
* and session data.
*/
#define MAX_SESSION_ID_SIZE 32
#define MAX_SESSION_DATA_SIZE 512
typedef struct
{
char session_id[MAX_SESSION_ID_SIZE];
int session_id_size;
char session_data[MAX_SESSION_DATA_SIZE];
int session_data_size;
} CACHE;
static CACHE *cache_db;
static int cache_db_ptr = 0;
static void
wrap_db_init (void)
{
/* allocate cache_db */
cache_db = calloc (1, TLS_SESSION_CACHE * sizeof (CACHE));
}
static void
wrap_db_deinit (void)
{
return;
}
static int
wrap_db_store (void *dbf, gnutls_datum_t key, gnutls_datum_t data)
{
if (cache_db == NULL)
return -1;
if (key.size > MAX_SESSION_ID_SIZE)
return -1;
if (data.size > MAX_SESSION_DATA_SIZE)
return -1;
memcpy (cache_db[cache_db_ptr].session_id, key.data, key.size);
cache_db[cache_db_ptr].session_id_size = key.size;
memcpy (cache_db[cache_db_ptr].session_data, data.data, data.size);
cache_db[cache_db_ptr].session_data_size = data.size;
cache_db_ptr++;
cache_db_ptr %= TLS_SESSION_CACHE;
return 0;
}
static gnutls_datum_t
wrap_db_fetch (void *dbf, gnutls_datum_t key)
{
gnutls_datum_t res = { NULL, 0 };
int i;
if (cache_db == NULL)
return res;
for (i = 0; i < TLS_SESSION_CACHE; i++)
{
if (key.size == cache_db[i].session_id_size &&
memcmp (key.data, cache_db[i].session_id, key.size) == 0)
{
res.size = cache_db[i].session_data_size;
res.data = gnutls_malloc (res.size);
if (res.data == NULL)
return res;
memcpy (res.data, cache_db[i].session_data, res.size);
return res;
}
}
return res;
}
static int
wrap_db_delete (void *dbf, gnutls_datum_t key)
{
int i;
if (cache_db == NULL)
return -1;
for (i = 0; i < TLS_SESSION_CACHE; i++)
{
if (key.size == cache_db[i].session_id_size &&
memcmp (key.data, cache_db[i].session_id, key.size) == 0)
{
cache_db[i].session_id_size = 0;
cache_db[i].session_data_size = 0;
return 0;
}
}
return -1;
}
</pre>
<div class="node">
<p><hr>
<a name="Echo-Server-with-OpenPGP-authentication"></a>
Next: <a rel="next" accesskey="n" href="#Echo-Server-with-SRP-authentication">Echo Server with SRP authentication</a>,
Previous: <a rel="previous" accesskey="p" href="#Echo-Server-with-X_002e509-authentication-II">Echo Server with X.509 authentication II</a>,
Up: <a rel="up" accesskey="u" href="#Server-examples">Server examples</a>
</div>
<h4 class="subsection">7.4.3 Echo Server with <acronym>OpenPGP</acronym> authentication</h4>
<p><a name="index-g_t_0040acronym_007bOpenPGP_007d-Server-33"></a>
The following example is an echo server which supports
<acronym><acronym>OpenPGP</acronym></acronym> key authentication. You can easily combine
this functionality —that is have a server that supports both
<acronym>X.509</acronym> and <acronym>OpenPGP</acronym> certificates— but we separated
them to keep these examples as simple as possible.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
/* Must be linked against gnutls-extra.
*/
#include <gnutls/extra.h>
#define KEYFILE "secret.asc"
#define CERTFILE "public.asc"
#define RINGFILE "ring.gpg"
/* This is a sample TLS 1.0-OpenPGP echo server.
*/
#define SA struct sockaddr
#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);}
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
#define DH_BITS 1024
/* These are global */
gnutls_certificate_credentials_t cred;
const int cert_type_priority[2] = { GNUTLS_CRT_OPENPGP, 0 };
gnutls_dh_params_t dh_params;
static int
generate_dh_params (void)
{
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
* security requirements.
*/
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, DH_BITS);
return 0;
}
/* These are global */
gnutls_certificate_credentials_t x509_cred;
gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
gnutls_init (&session, GNUTLS_SERVER);
/* avoid calling all the priority functions, since the defaults
* are adequate.
*/
gnutls_set_default_priority (session);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
/* request client certificate if any.
*/
gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
gnutls_dh_set_prime_bits (session, DH_BITS);
return session;
}
int
main (void)
{
int err, listen_sd, i;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
int client_len;
char topbuf[512];
gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
char name[256];
strcpy (name, "Echo Server");
/* this must be called once in the program
*/
gnutls_global_init ();
gnutls_certificate_allocate_credentials (&cred);
gnutls_certificate_set_openpgp_keyring_file (cred, RINGFILE);
gnutls_certificate_set_openpgp_key_file (cred, CERTFILE, KEYFILE);
generate_dh_params ();
gnutls_certificate_set_dh_params (cred, dh_params);
/* Socket operations
*/
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
SOCKET_ERR (listen_sd, "socket");
memset (&sa_serv, '\0', sizeof (sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (PORT); /* Server Port number */
setsockopt (listen_sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int));
err = bind (listen_sd, (SA *) & sa_serv, sizeof (sa_serv));
SOCKET_ERR (err, "bind");
err = listen (listen_sd, 1024);
SOCKET_ERR (err, "listen");
printf ("%s ready. Listening to port '%d'.\n\n", name, PORT);
client_len = sizeof (sa_cli);
for (;;)
{
session = initialize_tls_session ();
gnutls_certificate_type_set_priority (session, cert_type_priority);
sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
printf ("- connection from %s, port %d\n",
inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
sizeof (topbuf)), ntohs (sa_cli.sin_port));
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
ret = gnutls_handshake (session);
if (ret < 0)
{
close (sd);
gnutls_deinit (session);
fprintf (stderr, "*** Handshake has failed (%s)\n\n",
gnutls_strerror (ret));
continue;
}
printf ("- Handshake was completed\n");
/* see the Getting peer's information example */
/* print_info(session); */
i = 0;
for (;;)
{
memset (buffer, 0, MAX_BUF + 1);
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("\n- Peer has closed the GNUTLS connection\n");
break;
}
else if (ret < 0)
{
fprintf (stderr, "\n*** Received corrupted "
"data(%d). Closing the connection.\n\n", ret);
break;
}
else if (ret > 0)
{
/* echo data back to the client
*/
gnutls_record_send (session, buffer, strlen (buffer));
}
}
printf ("\n");
/* do not wait for the peer to close the connection.
*/
gnutls_bye (session, GNUTLS_SHUT_WR);
close (sd);
gnutls_deinit (session);
}
close (listen_sd);
gnutls_certificate_free_credentials (cred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Echo-Server-with-SRP-authentication"></a>
Next: <a rel="next" accesskey="n" href="#Echo-Server-with-anonymous-authentication">Echo Server with anonymous authentication</a>,
Previous: <a rel="previous" accesskey="p" href="#Echo-Server-with-OpenPGP-authentication">Echo Server with OpenPGP authentication</a>,
Up: <a rel="up" accesskey="u" href="#Server-examples">Server examples</a>
</div>
<h4 class="subsection">7.4.4 Echo Server with <acronym>SRP</acronym> authentication</h4>
<p>This is a server which supports <acronym>SRP</acronym> authentication. It is
also possible to combine this functionality with a certificate
server. Here it is separate for simplicity.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/extra.h>
#define SRP_PASSWD "tpasswd"
#define SRP_PASSWD_CONF "tpasswd.conf"
#define KEYFILE "key.pem"
#define CERTFILE "cert.pem"
#define CAFILE "ca.pem"
/* This is a sample TLS-SRP echo server.
*/
#define SA struct sockaddr
#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);}
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
/* These are global */
gnutls_srp_server_credentials_t srp_cred;
gnutls_certificate_credentials_t cert_cred;
gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
const int kx_priority[] = { GNUTLS_KX_SRP, GNUTLS_KX_SRP_DSS,
GNUTLS_KX_SRP_RSA, 0
};
gnutls_init (&session, GNUTLS_SERVER);
gnutls_set_default_priority (session);
gnutls_kx_set_priority (session, kx_priority);
gnutls_credentials_set (session, GNUTLS_CRD_SRP, srp_cred);
/* for the certificate authenticated ciphersuites.
*/
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, cert_cred);
/* request client certificate if any.
*/
gnutls_certificate_server_set_request (session, GNUTLS_CERT_IGNORE);
return session;
}
int
main (void)
{
int err, listen_sd, i;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
int client_len;
char topbuf[512];
gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
char name[256];
strcpy (name, "Echo Server");
/* these must be called once in the program
*/
gnutls_global_init ();
gnutls_global_init_extra (); /* for SRP */
/* SRP_PASSWD a password file (created with the included srptool utility)
*/
gnutls_srp_allocate_server_credentials (&srp_cred);
gnutls_srp_set_server_credentials_file (srp_cred, SRP_PASSWD,
SRP_PASSWD_CONF);
gnutls_certificate_allocate_credentials (&cert_cred);
gnutls_certificate_set_x509_trust_file (cert_cred, CAFILE,
GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_x509_key_file (cert_cred, CERTFILE, KEYFILE,
GNUTLS_X509_FMT_PEM);
/* TCP socket operations
*/
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
SOCKET_ERR (listen_sd, "socket");
memset (&sa_serv, '\0', sizeof (sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (PORT); /* Server Port number */
setsockopt (listen_sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int));
err = bind (listen_sd, (SA *) & sa_serv, sizeof (sa_serv));
SOCKET_ERR (err, "bind");
err = listen (listen_sd, 1024);
SOCKET_ERR (err, "listen");
printf ("%s ready. Listening to port '%d'.\n\n", name, PORT);
client_len = sizeof (sa_cli);
for (;;)
{
session = initialize_tls_session ();
sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
printf ("- connection from %s, port %d\n",
inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
sizeof (topbuf)), ntohs (sa_cli.sin_port));
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
ret = gnutls_handshake (session);
if (ret < 0)
{
close (sd);
gnutls_deinit (session);
fprintf (stderr, "*** Handshake has failed (%s)\n\n",
gnutls_strerror (ret));
continue;
}
printf ("- Handshake was completed\n");
/* print_info(session); */
i = 0;
for (;;)
{
memset (buffer, 0, MAX_BUF + 1);
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("\n- Peer has closed the GNUTLS connection\n");
break;
}
else if (ret < 0)
{
fprintf (stderr, "\n*** Received corrupted "
"data(%d). Closing the connection.\n\n", ret);
break;
}
else if (ret > 0)
{
/* echo data back to the client
*/
gnutls_record_send (session, buffer, strlen (buffer));
}
}
printf ("\n");
/* do not wait for the peer to close the connection. */
gnutls_bye (session, GNUTLS_SHUT_WR);
close (sd);
gnutls_deinit (session);
}
close (listen_sd);
gnutls_srp_free_server_credentials (srp_cred);
gnutls_certificate_free_credentials (cert_cred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Echo-Server-with-anonymous-authentication"></a>
Previous: <a rel="previous" accesskey="p" href="#Echo-Server-with-SRP-authentication">Echo Server with SRP authentication</a>,
Up: <a rel="up" accesskey="u" href="#Server-examples">Server examples</a>
</div>
<h4 class="subsection">7.4.5 Echo Server with anonymous authentication</h4>
<p>This example server support anonymous authentication, and could be
used to serve the example client for anonymous authentication.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
/* This is a sample TLS 1.0 echo server, for anonymous authentication only.
*/
#define SA struct sockaddr
#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);}
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
#define DH_BITS 1024
/* These are global */
gnutls_anon_server_credentials_t anoncred;
gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
gnutls_init (&session, GNUTLS_SERVER);
/* avoid calling all the priority functions, since the defaults
* are adequate.
*/
gnutls_set_default_priority (session);
gnutls_kx_set_priority (session, kx_prio);
gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
gnutls_dh_set_prime_bits (session, DH_BITS);
return session;
}
static gnutls_dh_params_t dh_params;
static int
generate_dh_params (void)
{
/* Generate Diffie Hellman parameters - for use with DHE
* kx algorithms. These should be discarded and regenerated
* once a day, once a week or once a month. Depending on the
* security requirements.
*/
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, DH_BITS);
return 0;
}
int
main (void)
{
int err, listen_sd, i;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
int client_len;
char topbuf[512];
gnutls_session_t session;
char buffer[MAX_BUF + 1];
int optval = 1;
/* this must be called once in the program
*/
gnutls_global_init ();
gnutls_anon_allocate_server_credentials (&anoncred);
generate_dh_params ();
gnutls_anon_set_server_dh_params (anoncred, dh_params);
/* Socket operations
*/
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
SOCKET_ERR (listen_sd, "socket");
memset (&sa_serv, '\0', sizeof (sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (PORT); /* Server Port number */
setsockopt (listen_sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int));
err = bind (listen_sd, (SA *) & sa_serv, sizeof (sa_serv));
SOCKET_ERR (err, "bind");
err = listen (listen_sd, 1024);
SOCKET_ERR (err, "listen");
printf ("Server ready. Listening to port '%d'.\n\n", PORT);
client_len = sizeof (sa_cli);
for (;;)
{
session = initialize_tls_session ();
sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
printf ("- connection from %s, port %d\n",
inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
sizeof (topbuf)), ntohs (sa_cli.sin_port));
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
ret = gnutls_handshake (session);
if (ret < 0)
{
close (sd);
gnutls_deinit (session);
fprintf (stderr, "*** Handshake has failed (%s)\n\n",
gnutls_strerror (ret));
continue;
}
printf ("- Handshake was completed\n");
/* see the Getting peer's information example */
/* print_info(session); */
i = 0;
for (;;)
{
memset (buffer, 0, MAX_BUF + 1);
ret = gnutls_record_recv (session, buffer, MAX_BUF);
if (ret == 0)
{
printf ("\n- Peer has closed the GNUTLS connection\n");
break;
}
else if (ret < 0)
{
fprintf (stderr, "\n*** Received corrupted "
"data(%d). Closing the connection.\n\n", ret);
break;
}
else if (ret > 0)
{
/* echo data back to the client
*/
gnutls_record_send (session, buffer, strlen (buffer));
}
}
printf ("\n");
/* do not wait for the peer to close the connection.
*/
gnutls_bye (session, GNUTLS_SHUT_WR);
close (sd);
gnutls_deinit (session);
}
close (listen_sd);
gnutls_anon_free_server_credentials (anoncred);
gnutls_global_deinit ();
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Miscellaneous-examples"></a>
Next: <a rel="next" accesskey="n" href="#Compatibility-with-the-OpenSSL-library">Compatibility with the OpenSSL library</a>,
Previous: <a rel="previous" accesskey="p" href="#Server-examples">Server examples</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
</div>
<h3 class="section">7.5 Miscellaneous examples</h3>
<ul class="menu">
<li><a accesskey="1" href="#Checking-for-an-alert">Checking for an alert</a>
<li><a accesskey="2" href="#X_002e509-certificate-parsing-example">X.509 certificate parsing example</a>
<li><a accesskey="3" href="#Certificate-request-generation">Certificate request generation</a>
<li><a accesskey="4" href="#PKCS-_002312-structure-generation">PKCS #12 structure generation</a>
</ul>
<div class="node">
<p><hr>
<a name="Checking-for-an-alert"></a>
Next: <a rel="next" accesskey="n" href="#X_002e509-certificate-parsing-example">X.509 certificate parsing example</a>,
Up: <a rel="up" accesskey="u" href="#Miscellaneous-examples">Miscellaneous examples</a>
</div>
<h4 class="subsection">7.5.1 Checking for an alert</h4>
<p>This is a function that checks if an alert has been received in the
current session.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
/* This function will check whether the given return code from
* a gnutls function (recv/send), is an alert, and will print
* that alert.
*/
void
check_alert (gnutls_session_t session, int ret)
{
int last_alert;
if (ret == GNUTLS_E_WARNING_ALERT_RECEIVED
|| ret == GNUTLS_E_FATAL_ALERT_RECEIVED)
{
last_alert = gnutls_alert_get (session);
/* The check for renegotiation is only useful if we are
* a server, and we had requested a rehandshake.
*/
if (last_alert == GNUTLS_A_NO_RENEGOTIATION &&
ret == GNUTLS_E_WARNING_ALERT_RECEIVED)
printf ("* Received NO_RENEGOTIATION alert. "
"Client Does not support renegotiation.\n");
else
printf ("* Received alert '%d': %s.\n", last_alert,
gnutls_alert_get_name (last_alert));
}
}
</pre>
<div class="node">
<p><hr>
<a name="X.509-certificate-parsing-example"></a>
<a name="X_002e509-certificate-parsing-example"></a>
Next: <a rel="next" accesskey="n" href="#Certificate-request-generation">Certificate request generation</a>,
Previous: <a rel="previous" accesskey="p" href="#Checking-for-an-alert">Checking for an alert</a>,
Up: <a rel="up" accesskey="u" href="#Miscellaneous-examples">Miscellaneous examples</a>
</div>
<h4 class="subsection">7.5.2 <acronym>X.509</acronym> certificate parsing example</h4>
<p><a name="ex_003ax509_002dinfo"></a>
<p>To demonstrate the <acronym>X.509</acronym> parsing capabilities an example program is
listed below. That program reads the peer's certificate, and prints
information about it.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
static const char *
bin2hex (const void *bin, size_t bin_size)
{
static char printable[110];
const unsigned char *_bin = bin;
char *print;
size_t i;
if (bin_size > 50)
bin_size = 50;
print = printable;
for (i = 0; i < bin_size; i++)
{
sprintf (print, "%.2x ", _bin[i]);
print += 2;
}
return printable;
}
/* This function will print information about this session's peer
* certificate.
*/
void
print_x509_certificate_info (gnutls_session_t session)
{
char serial[40];
char dn[128];
size_t size;
unsigned int algo, bits;
time_t expiration_time, activation_time;
const gnutls_datum_t *cert_list;
int cert_list_size = 0;
gnutls_x509_crt_t cert;
/* This function only works for X.509 certificates.
*/
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509)
return;
cert_list = gnutls_certificate_get_peers (session, &cert_list_size);
printf ("Peer provided %d certificates.\n", cert_list_size);
if (cert_list_size > 0)
{
/* we only print information about the first certificate.
*/
gnutls_x509_crt_init (&cert);
gnutls_x509_crt_import (cert, &cert_list[0], GNUTLS_X509_FMT_DER);
printf ("Certificate info:\n");
expiration_time = gnutls_x509_crt_get_expiration_time (cert);
activation_time = gnutls_x509_crt_get_activation_time (cert);
printf ("\tCertificate is valid since: %s", ctime (&activation_time));
printf ("\tCertificate expires: %s", ctime (&expiration_time));
/* Print the serial number of the certificate.
*/
size = sizeof (serial);
gnutls_x509_crt_get_serial (cert, serial, &size);
size = sizeof (serial);
printf ("\tCertificate serial number: %s\n", bin2hex (serial, size));
/* Extract some of the public key algorithm's parameters
*/
algo = gnutls_x509_crt_get_pk_algorithm (cert, &bits);
printf ("Certificate public key: %s",
gnutls_pk_algorithm_get_name (algo));
/* Print the version of the X.509
* certificate.
*/
printf ("\tCertificate version: #%d\n",
gnutls_x509_crt_get_version (cert));
size = sizeof (dn);
gnutls_x509_crt_get_dn (cert, dn, &size);
printf ("\tDN: %s\n", dn);
size = sizeof (dn);
gnutls_x509_crt_get_issuer_dn (cert, dn, &size);
printf ("\tIssuer's DN: %s\n", dn);
gnutls_x509_crt_deinit (cert);
}
}
</pre>
<div class="node">
<p><hr>
<a name="Certificate-request-generation"></a>
Next: <a rel="next" accesskey="n" href="#PKCS-_002312-structure-generation">PKCS #12 structure generation</a>,
Previous: <a rel="previous" accesskey="p" href="#X_002e509-certificate-parsing-example">X.509 certificate parsing example</a>,
Up: <a rel="up" accesskey="u" href="#Miscellaneous-examples">Miscellaneous examples</a>
</div>
<h4 class="subsection">7.5.3 Certificate request generation</h4>
<p><a name="ex_003acrq"></a>
<p>The following example is about generating a certificate request, and a
private key. A certificate request can be later be processed by a CA,
which should return a signed certificate.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <time.h>
/* This example will generate a private key and a certificate
* request.
*/
int
main (void)
{
gnutls_x509_crq_t crq;
gnutls_x509_privkey_t key;
unsigned char buffer[10 * 1024];
int buffer_size = sizeof (buffer);
gnutls_global_init ();
/* Initialize an empty certificate request, and
* an empty private key.
*/
gnutls_x509_crq_init (&crq);
gnutls_x509_privkey_init (&key);
/* Generate a 1024 bit RSA private key.
*/
gnutls_x509_privkey_generate (key, GNUTLS_PK_RSA, 1024, 0);
/* Add stuff to the distinguished name
*/
gnutls_x509_crq_set_dn_by_oid (crq, GNUTLS_OID_X520_COUNTRY_NAME,
0, "GR", 2);
gnutls_x509_crq_set_dn_by_oid (crq, GNUTLS_OID_X520_COMMON_NAME,
0, "Nikos", strlen ("Nikos"));
/* Set the request version.
*/
gnutls_x509_crq_set_version (crq, 1);
/* Set a challenge password.
*/
gnutls_x509_crq_set_challenge_password (crq, "something to remember here");
/* Associate the request with the private key
*/
gnutls_x509_crq_set_key (crq, key);
/* Self sign the certificate request.
*/
gnutls_x509_crq_sign (crq, key);
/* Export the PEM encoded certificate request, and
* display it.
*/
gnutls_x509_crq_export (crq, GNUTLS_X509_FMT_PEM, buffer, &buffer_size);
printf ("Certificate Request: \n%s", buffer);
/* Export the PEM encoded private key, and
* display it.
*/
buffer_size = sizeof (buffer);
gnutls_x509_privkey_export (key, GNUTLS_X509_FMT_PEM, buffer, &buffer_size);
printf ("\n\nPrivate key: \n%s", buffer);
gnutls_x509_crq_deinit (crq);
gnutls_x509_privkey_deinit (key);
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="PKCS-%2312-structure-generation"></a>
<a name="PKCS-_002312-structure-generation"></a>
Previous: <a rel="previous" accesskey="p" href="#Certificate-request-generation">Certificate request generation</a>,
Up: <a rel="up" accesskey="u" href="#Miscellaneous-examples">Miscellaneous examples</a>
</div>
<h4 class="subsection">7.5.4 <acronym>PKCS</acronym> #12 structure generation</h4>
<p><a name="ex_003apkcs12"></a>
<p>The following example is about generating a <acronym>PKCS</acronym> #12
structure.
<pre class="verbatim">
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/pkcs12.h>
#define OUTFILE "out.p12"
/* This function will write a pkcs12 structure into a file.
* cert: is a DER encoded certificate
* pkcs8_key: is a PKCS #8 encrypted key (note that this must be
* encrypted using a PKCS #12 cipher, or some browsers will crash)
* password: is the password used to encrypt the PKCS #12 packet.
*/
int
write_pkcs12 (const gnutls_datum_t * cert,
const gnutls_datum_t * pkcs8_key, const char *password)
{
gnutls_pkcs12_t pkcs12;
int ret, bag_index;
gnutls_pkcs12_bag_t bag, key_bag;
char pkcs12_struct[10 * 1024];
int pkcs12_struct_size;
FILE *fd;
/* A good idea might be to use gnutls_x509_privkey_get_key_id()
* to obtain a unique ID.
*/
gnutls_datum_t key_id = { "\x00\x00\x07", 3 };
gnutls_global_init ();
/* Firstly we create two helper bags, which hold the certificate,
* and the (encrypted) key.
*/
gnutls_pkcs12_bag_init (&bag);
gnutls_pkcs12_bag_init (&key_bag);
ret = gnutls_pkcs12_bag_set_data (bag, GNUTLS_BAG_CERTIFICATE, cert);
if (ret < 0)
{
fprintf (stderr, "ret: %s\n", gnutls_strerror (ret));
return 1;
}
/* ret now holds the bag's index.
*/
bag_index = ret;
/* Associate a friendly name with the given certificate. Used
* by browsers.
*/
gnutls_pkcs12_bag_set_friendly_name (bag, bag_index, "My name");
/* Associate the certificate with the key using a unique key
* ID.
*/
gnutls_pkcs12_bag_set_key_id (bag, bag_index, &key_id);
/* use weak encryption for the certificate.
*/
gnutls_pkcs12_bag_encrypt (bag, password, GNUTLS_PKCS_USE_PKCS12_RC2_40);
/* Now the key.
*/
ret = gnutls_pkcs12_bag_set_data (key_bag,
GNUTLS_BAG_PKCS8_ENCRYPTED_KEY,
pkcs8_key);
if (ret < 0)
{
fprintf (stderr, "ret: %s\n", gnutls_strerror (ret));
return 1;
}
/* Note that since the PKCS #8 key is already encrypted we don't
* bother encrypting that bag.
*/
bag_index = ret;
gnutls_pkcs12_bag_set_friendly_name (key_bag, bag_index, "My name");
gnutls_pkcs12_bag_set_key_id (key_bag, bag_index, &key_id);
/* The bags were filled. Now create the PKCS #12 structure.
*/
gnutls_pkcs12_init (&pkcs12);
/* Insert the two bags in the PKCS #12 structure.
*/
gnutls_pkcs12_set_bag (pkcs12, bag);
gnutls_pkcs12_set_bag (pkcs12, key_bag);
/* Generate a message authentication code for the PKCS #12
* structure.
*/
gnutls_pkcs12_generate_mac (pkcs12, password);
pkcs12_struct_size = sizeof (pkcs12_struct);
ret =
gnutls_pkcs12_export (pkcs12, GNUTLS_X509_FMT_DER, pkcs12_struct,
&pkcs12_struct_size);
if (ret < 0)
{
fprintf (stderr, "ret: %s\n", gnutls_strerror (ret));
return 1;
}
fd = fopen (OUTFILE, "w");
if (fd == NULL)
{
fprintf (stderr, "cannot open file\n");
return 1;
}
fwrite (pkcs12_struct, 1, pkcs12_struct_size, fd);
fclose (fd);
gnutls_pkcs12_bag_deinit (bag);
gnutls_pkcs12_bag_deinit (key_bag);
gnutls_pkcs12_deinit (pkcs12);
return 0;
}
</pre>
<div class="node">
<p><hr>
<a name="Compatibility-with-the-OpenSSL-library"></a>
Previous: <a rel="previous" accesskey="p" href="#Miscellaneous-examples">Miscellaneous examples</a>,
Up: <a rel="up" accesskey="u" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>
</div>
<h3 class="section">7.6 Compatibility with the OpenSSL library</h3>
<p><a name="index-OpenSSL-34"></a>
To ease <acronym>GnuTLS</acronym>' integration with existing applications, a
compatibility layer with the widely used OpenSSL library is included
in the <code>gnutls-openssl</code> library. This compatibility layer is not
complete and it is not intended to completely reimplement the OpenSSL
API with <acronym>GnuTLS</acronym>. It only provides source-level
compatibility. There is currently no attempt to make it
binary-compatible with OpenSSL.
<p>The prototypes for the compatibility functions are in the
<samp><span class="file">gnutls/openssl.h</span></samp> header file.
<p>Current limitations imposed by the compatibility layer include:
<ul>
<li>Error handling is not thread safe.
</ul>
<div class="node">
<p><hr>
<a name="Included-programs"></a>
Next: <a rel="next" accesskey="n" href="#Function-reference">Function reference</a>,
Previous: <a rel="previous" accesskey="p" href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">8 Included programs</h2>
<p>Included with <acronym>GnuTLS</acronym> are also a few command line tools that
let you use the library for common tasks without writing an
application. The applications are discussed in this chapter.
<ul class="menu">
<li><a accesskey="1" href="#Invoking-srptool">Invoking srptool</a>
<li><a accesskey="2" href="#Invoking-gnutls_002dcli">Invoking gnutls-cli</a>
<li><a accesskey="3" href="#Invoking-gnutls_002dcli_002ddebug">Invoking gnutls-cli-debug</a>
<li><a accesskey="4" href="#Invoking-gnutls_002dserv">Invoking gnutls-serv</a>
<li><a accesskey="5" href="#Invoking-certtool">Invoking certtool</a>
</ul>
<div class="node">
<p><hr>
<a name="Invoking-srptool"></a>
Next: <a rel="next" accesskey="n" href="#Invoking-gnutls_002dcli">Invoking gnutls-cli</a>,
Up: <a rel="up" accesskey="u" href="#Included-programs">Included programs</a>
</div>
<h3 class="section">8.1 Invoking srptool</h3>
<p><a name="srptool"></a>
<a name="index-srptool-35"></a>
The <samp><span class="file">srptool</span></samp> is a very simple program that emulates the programs
in the <em>Stanford SRP libraries</em>. It is intended for use in
places where you don't expect <acronym>SRP</acronym> authentication to be the
used for system users. Traditionally <em>libsrp</em> used two
files. One called 'tpasswd' which holds usernames and verifiers, and
'tpasswd.conf' which holds generators and primes.
<p>How to use srptool:
<ul>
<li>To create tpasswd.conf which holds the g and n values for
<acronym>SRP</acronym> protocol (generator and a large prime), run:
<pre class="example"> $ srptool --create-conf /etc/tpasswd.conf
</pre>
<li>This command will create /etc/tpasswd and will add user 'test' (you
will also be prompted for a password). Verifiers are stored by default
in the way libsrp expects.
<pre class="example"> $ srptool --passwd /etc/tpasswd \
--passwd-conf /etc/tpasswd.conf -u test
</pre>
<li>This command will check against a password. If the password matches
the one in /etc/tpasswd you will get an ok.
<pre class="example"> $ srptool --passwd /etc/tpasswd \
--passwd-conf /etc/tpasswd.conf --verify -u test
</pre>
</ul>
<div class="node">
<p><hr>
<a name="Invoking-gnutls-cli"></a>
<a name="Invoking-gnutls_002dcli"></a>
Next: <a rel="next" accesskey="n" href="#Invoking-gnutls_002dcli_002ddebug">Invoking gnutls-cli-debug</a>,
Previous: <a rel="previous" accesskey="p" href="#Invoking-srptool">Invoking srptool</a>,
Up: <a rel="up" accesskey="u" href="#Included-programs">Included programs</a>
</div>
<h3 class="section">8.2 Invoking gnutls-cli</h3>
<p><a name="index-gnutls_002dcli-36"></a>
Simple client program to set up a TLS connection to some other
computer. It sets up a TLS connection and forwards data from the
standard input to the secured socket and vice versa.
<pre class="verbatim">
GNU TLS test client
Usage: gnutls-cli [options] hostname
-d, --debug integer Enable debugging
-r, --resume Connect, establish a session. Connect
again and resume this session.
-s, --starttls Connect, establish a plain session and
start TLS when EOF or a SIGALRM is
received.
--crlf Send CR LF instead of LF.
--x509fmtder Use DER format for certificates to read
from.
-f, --fingerprint Send the openpgp fingerprint, instead
of the key.
--disable-extensions Disable all the TLS extensions.
--xml Print the certificate information in
XML format.
--print-cert Print the certificate in PEM format.
-p, --port integer The port to connect to.
--recordsize integer The maximum record size to advertize.
-V, --verbose More verbose output.
--ciphers cipher1 cipher2...
Ciphers to enable.
--protocols protocol1 protocol2...
Protocols to enable.
--comp comp1 comp2... Compression methods to enable.
--macs mac1 mac2... MACs to enable.
--kx kx1 kx2... Key exchange methods to enable.
--ctypes certType1 certType2...
Certificate types to enable.
--x509cafile FILE Certificate file to use.
--x509crlfile FILE CRL file to use.
--pgpkeyfile FILE PGP Key file to use.
--pgpkeyring FILE PGP Key ring file to use.
--pgptrustdb FILE PGP trustdb file to use.
--pgpcertfile FILE PGP Public Key (certificate) file to
use.
--x509keyfile FILE X.509 key file to use.
--x509certfile FILE X.509 Certificate file to use.
--srpusername NAME SRP username to use.
--srppasswd PASSWD SRP password to use.
--insecure Don't abort program if server
certificate can't be validated.
-l, --list Print a list of the supported
algorithms and modes.
-h, --help prints this help
-v, --version prints the program's version number
--copyright prints the program's license
</pre>
<div class="node">
<p><hr>
<a name="Invoking-gnutls-cli-debug"></a>
<a name="Invoking-gnutls_002dcli_002ddebug"></a>
Next: <a rel="next" accesskey="n" href="#Invoking-gnutls_002dserv">Invoking gnutls-serv</a>,
Previous: <a rel="previous" accesskey="p" href="#Invoking-gnutls_002dcli">Invoking gnutls-cli</a>,
Up: <a rel="up" accesskey="u" href="#Included-programs">Included programs</a>
</div>
<h3 class="section">8.3 Invoking gnutls-cli-debug</h3>
<p><a name="index-gnutls_002dcli_002ddebug-37"></a>
This program was created to assist in debugging <acronym>GnuTLS</acronym>, but
it might be useful to extract a <acronym>TLS</acronym> server's capabilities.
It's purpose is to connect onto a <acronym>TLS</acronym> server, perform some
tests and print the server's capabilities. If called with the `-v'
parameter a more checks will be performed. An example output is:
<pre class="smallexample"> crystal:/cvs/gnutls/src$ ./gnutls-cli-debug localhost -p 5556
Resolving 'localhost'...
Connecting to '127.0.0.1:5556'...
Checking for TLS 1.1 support... yes
Checking fallback from TLS 1.1 to... N/A
Checking for TLS 1.0 support... yes
Checking for SSL 3.0 support... yes
Checking for version rollback bug in RSA PMS... no
Checking for version rollback bug in Client Hello... no
Checking whether we need to disable TLS 1.0... N/A
Checking whether the server ignores the RSA PMS version... no
Checking whether the server can accept Hello Extensions... yes
Checking whether the server can accept cipher suites not in SSL 3.0 spec... yes
Checking whether the server can accept a bogus TLS record version in the client hello... yes
Checking for certificate information... N/A
Checking for trusted CAs... N/A
Checking whether the server understands TLS closure alerts... yes
Checking whether the server supports session resumption... yes
Checking for export-grade ciphersuite support... no
Checking RSA-export ciphersuite info... N/A
Checking for anonymous authentication support... no
Checking anonymous Diffie Hellman group info... N/A
Checking for ephemeral Diffie Hellman support... no
Checking ephemeral Diffie Hellman group info... N/A
Checking for AES cipher support (TLS extension)... yes
Checking for 3DES cipher support... yes
Checking for ARCFOUR 128 cipher support... yes
Checking for ARCFOUR 40 cipher support... no
Checking for MD5 MAC support... yes
Checking for SHA1 MAC support... yes
Checking for ZLIB compression support (TLS extension)... yes
Checking for LZO compression support (GnuTLS extension)... yes
Checking for max record size (TLS extension)... yes
Checking for SRP authentication support (TLS extension)... yes
Checking for OpenPGP authentication support (TLS extension)... no
</pre>
<div class="node">
<p><hr>
<a name="Invoking-gnutls-serv"></a>
<a name="Invoking-gnutls_002dserv"></a>
Next: <a rel="next" accesskey="n" href="#Invoking-certtool">Invoking certtool</a>,
Previous: <a rel="previous" accesskey="p" href="#Invoking-gnutls_002dcli_002ddebug">Invoking gnutls-cli-debug</a>,
Up: <a rel="up" accesskey="u" href="#Included-programs">Included programs</a>
</div>
<h3 class="section">8.4 Invoking gnutls-serv</h3>
<p><a name="index-gnutls_002dserv-38"></a>
Simple server program that listens to incoming TLS connections.
<pre class="verbatim">
GNU TLS test server
Usage: gnutls-serv [options]
-d, --debug integer Enable debugging
-g, --generate Generate Diffie Hellman Parameters.
-p, --port integer The port to connect to.
-q, --quiet Suppress some messages.
--nodb Does not use the resume database.
--http Act as an HTTP Server.
--echo Act as an Echo Server.
--dhparams FILE DH params file to use.
--x509fmtder Use DER format for certificates
--x509cafile FILE Certificate file to use.
--x509crlfile FILE CRL file to use.
--pgpkeyring FILE PGP Key ring file to use.
--pgptrustdb FILE PGP trustdb file to use.
--pgpkeyfile FILE PGP Key file to use.
--pgpcertfile FILE PGP Public Key (certificate) file to
use.
--x509keyfile FILE X.509 key file to use.
--x509certfile FILE X.509 Certificate file to use.
--x509dsakeyfile FILE Alternative X.509 key file to use.
--x509dsacertfile FILE Alternative X.509 certificate file to
use.
--srppasswd FILE SRP password file to use.
--srppasswdconf FILE SRP password conf file to use.
--ciphers cipher1 cipher2...
Ciphers to enable.
--protocols protocol1 protocol2...
Protocols to enable.
--comp comp1 comp2... Compression methods to enable.
--macs mac1 mac2... MACs to enable.
--kx kx1 kx2... Key exchange methods to enable.
--ctypes certType1 certType2...
Certificate types to enable.
-l, --list Print a list of the supported
algorithms and modes.
-h, --help prints this help
-v, --version prints the program's version number
--copyright prints the program's license
</pre>
<div class="node">
<p><hr>
<a name="Invoking-certtool"></a>
Previous: <a rel="previous" accesskey="p" href="#Invoking-gnutls_002dserv">Invoking gnutls-serv</a>,
Up: <a rel="up" accesskey="u" href="#Included-programs">Included programs</a>
</div>
<h3 class="section">8.5 Invoking certtool</h3>
<p><a name="index-certtool-39"></a>
This is a program to generate <acronym>X.509</acronym> certificates, certificate
requests, CRLs and private keys. The program can be used interactively
or non interactively by specifying the <code>--template</code> command line
option. See below for an example of a template file.
<p>How to use certtool interactively:
<ul>
<li>To generate parameters for Diffie Hellman key exchange, use the command:
<pre class="example"> $ certtool --generate-dh-params --outfile dh.pem
</pre>
<li>To generate parameters for the RSA-EXPORT key exchange, use the command:
<pre class="example"> $ certtool --generate-privkey --bits 512 --outfile rsa.pem
</pre>
</ul>
<ul>
<li>To create a self signed certificate, use the command:
<pre class="example"> $ certtool --generate-privkey --outfile ca-key.pem
$ certtool --generate-self-signed --load-privkey ca-key.pem \
--outfile ca-cert.pem
</pre>
<p>Note that a self-signed certificate usually belongs to a certificate
authority, that signs other certificates.
<li>To create a private key, run:
<pre class="example"> $ certtool --generate-privkey --outfile key.pem
</pre>
<li>To create a certificate request, run:
<pre class="example"> $ certtool --generate-request --load-privkey key.pem \
--outfile request.pem
</pre>
<li>To generate a certificate using the previous request, use the command:
<pre class="example"> $ certtool --generate-certificate --load-request request.pem \
--outfile cert.pem \
--load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem
</pre>
<li>To view the certificate information, use:
<pre class="example"> $ certtool --certificate-info --infile cert.pem
</pre>
<li>To generate a <acronym>PKCS</acronym> #12 structure using the previous key and
certificate, use the command:
<pre class="example"> $ certtool --load-certificate cert.pem --load-privkey key.pem \
--to-p12 --outder --outfile key.p12
</pre>
</ul>
<p>Certtool's template file format:
<ul>
<li>Firstly create a file named 'cert.cfg' that contains the information
about the certificate. An example file is listed below.
<li>Then execute:
<pre class="example"> $ certtool --generate-certificate cert.pem --load-privkey key.pem \
--template cert.cfg \
--load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem
</pre>
</ul>
<p>An example certtool template file:
<pre class="example"> # X.509 Certificate options
#
# DN options
# The organization of the subject.
organization = "Koko inc."
# The organizational unit of the subject.
unit = "sleeping dept."
# The locality of the subject.
# locality =
# The state of the certificate owner.
state = "Attiki"
# The country of the subject. Two letter code.
country = GR
# The common name of the certificate owner.
cn = "Cindy Lauper"
# A user id of the certificate owner.
#uid = "clauper"
# If the supported DN OIDs are not adequate you can set
# any OID here.
# For example set the X.520 Title and the X.520 Pseudonym
# by using OID and string pairs.
#dn_oid = "2.5.4.12" "Dr." "2.5.4.65" "jackal"
# This is deprecated and should not be used in new
# certificates.
# pkcs9_email = "none@none.org"
# The serial number of the certificate
serial = 007
# In how many days, counting from today, this certificate will expire.
expiration_days = 700
# X.509 v3 extensions
# A dnsname in case of a WWW server.
#dns_name = "www.none.org"
# An IP address in case of a server.
#ip_address = "192.168.1.1"
# An email in case of a person
email = "none@none.org"
# An URL that has CRLs (certificate revocation lists)
# available. Needed in CA certificates.
#crl_dist_points = "http://www.getcrl.crl/getcrl/"
# Whether this is a CA certificate or not
#ca
# Whether this certificate will be used for a TLS client
#tls_www_client
# Whether this certificate will be used for a TLS server
#tls_www_server
# Whether this certificate will be used to sign data (needed
# in TLS DHE ciphersuites).
signing_key
# Whether this certificate will be used to encrypt data (needed
# in TLS RSA ciphersuites). Note that it is prefered to use different
# keys for encryption and signing.
#encryption_key
# Whether this key will be used to sign other certificates.
#cert_signing_key
# Whether this key will be used to sign CRLs.
#crl_signing_key
# Whether this key will be used to sign code.
#code_signing_key
# Whether this key will be used to sign OCSP data.
#ocsp_signing_key
# Whether this key will be used for time stamping.
#time_stamping_key
</pre>
<div class="node">
<p><hr>
<a name="Function-reference"></a>
Next: <a rel="next" accesskey="n" href="#Certificate-to-XML-convertion-functions">Certificate to XML convertion functions</a>,
Previous: <a rel="previous" accesskey="p" href="#Included-programs">Included programs</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">9 Function reference</h2>
<p><a name="index-Function-reference-40"></a>
<ul class="menu">
<li><a accesskey="1" href="#Core-functions">Core functions</a>
<li><a accesskey="2" href="#X_002e509-certificate-functions">X.509 certificate functions</a>
<li><a accesskey="3" href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a>
<li><a accesskey="4" href="#OpenPGP-functions">OpenPGP functions</a>
<li><a accesskey="5" href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a>
<li><a accesskey="6" href="#Error-codes-and-descriptions">Error codes and descriptions</a>
</ul>
<div class="node">
<p><hr>
<a name="Core-functions"></a>
Next: <a rel="next" accesskey="n" href="#X_002e509-certificate-functions">X.509 certificate functions</a>,
Up: <a rel="up" accesskey="u" href="#Function-reference">Function reference</a>
</div>
<h3 class="section">9.1 Core functions</h3>
<p>The prototypes for the following functions lie in
<samp><span class="file">gnutls/gnutls.h</span></samp>.
<h4 class="subheading">gnutls_alert_get_name</h4>
<p><a name="gnutls_005falert_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_alert_get_name</b> (<var>gnutls_alert_description_t alert</var>)<var><a name="index-gnutls_005falert_005fget_005fname-41"></a></var><br>
<blockquote><p><var>alert</var>: is an alert number <code>gnutls_session_t</code> structure.
<p>This function will return a string that describes the given alert
number or NULL. See <code>gnutls_alert_get()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_alert_get</h4>
<p><a name="gnutls_005falert_005fget"></a>
<div class="defun">
— Function: gnutls_alert_description_t <b>gnutls_alert_get</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005falert_005fget-42"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function will return the last alert number received. This
function should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or
GNUTLS_E_FATAL_ALERT_RECEIVED has been returned by a gnutls
function. The peer may send alerts if he thinks some things were
not right. Check gnutls.h for the available alert descriptions.
<p>If no alert has been received the returned value is undefined.
</p></blockquote></div>
<h4 class="subheading">gnutls_alert_send_appropriate</h4>
<p><a name="gnutls_005falert_005fsend_005fappropriate"></a>
<div class="defun">
— Function: int <b>gnutls_alert_send_appropriate</b> (<var>gnutls_session_t session, int err</var>)<var><a name="index-gnutls_005falert_005fsend_005fappropriate-43"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>err</var>: is an integer
<p>Sends an alert to the peer depending on the error code returned by a gnutls
function. This function will call <code>gnutls_error_to_alert()</code> to determine
the appropriate alert to send.
<p>This function may also return GNUTLS_E_AGAIN, or GNUTLS_E_INTERRUPTED.
<p>If the return value is GNUTLS_E_INVALID_REQUEST, then no alert has
been sent to the peer.
<p>Returns zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_alert_send</h4>
<p><a name="gnutls_005falert_005fsend"></a>
<div class="defun">
— Function: int <b>gnutls_alert_send</b> (<var>gnutls_session_t session, gnutls_alert_level_t level, gnutls_alert_description_t desc</var>)<var><a name="index-gnutls_005falert_005fsend-44"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>level</var>: is the level of the alert
<p><var>desc</var>: is the alert description
<p>This function will send an alert to the peer in order to inform
him of something important (eg. his Certificate could not be verified).
If the alert level is Fatal then the peer is expected to close the
connection, otherwise he may ignore the alert and continue.
<p>The error code of the underlying record send function will be returned,
so you may also receive GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN as well.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_allocate_client_credentials</h4>
<p><a name="gnutls_005fanon_005fallocate_005fclient_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_anon_allocate_client_credentials</b> (<var>gnutls_anon_client_credentials_t * sc</var>)<var><a name="index-gnutls_005fanon_005fallocate_005fclient_005fcredentials-45"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_anon_client_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_allocate_server_credentials</h4>
<p><a name="gnutls_005fanon_005fallocate_005fserver_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_anon_allocate_server_credentials</b> (<var>gnutls_anon_server_credentials_t * sc</var>)<var><a name="index-gnutls_005fanon_005fallocate_005fserver_005fcredentials-46"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_anon_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_free_client_credentials</h4>
<p><a name="gnutls_005fanon_005ffree_005fclient_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_anon_free_client_credentials</b> (<var>gnutls_anon_client_credentials_t sc</var>)<var><a name="index-gnutls_005fanon_005ffree_005fclient_005fcredentials-47"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_anon_client_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_free_server_credentials</h4>
<p><a name="gnutls_005fanon_005ffree_005fserver_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_anon_free_server_credentials</b> (<var>gnutls_anon_server_credentials_t sc</var>)<var><a name="index-gnutls_005fanon_005ffree_005fserver_005fcredentials-48"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_anon_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_set_params_function</h4>
<p><a name="gnutls_005fanon_005fset_005fparams_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_anon_set_params_function</b> (<var>gnutls_anon_server_credentials_t res, gnutls_params_function * func</var>)<var><a name="index-gnutls_005fanon_005fset_005fparams_005ffunction-49"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_anon_server_credentials_t structure
<p><var>func</var>: is the function to be called
<p>This function will set a callback in order for the server to get the
diffie hellman or RSA parameters for anonymous authentication. The callback
should return zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_set_server_dh_params</h4>
<p><a name="gnutls_005fanon_005fset_005fserver_005fdh_005fparams"></a>
<div class="defun">
— Function: void <b>gnutls_anon_set_server_dh_params</b> (<var>gnutls_anon_server_credentials_t res, gnutls_dh_params_t dh_params</var>)<var><a name="index-gnutls_005fanon_005fset_005fserver_005fdh_005fparams-50"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_anon_server_credentials_t structure
<p><var>dh_params</var>: is a structure that holds diffie hellman parameters.
<p>This function will set the diffie hellman parameters for an anonymous
server to use. These parameters will be used in Anonymous Diffie Hellman
cipher suites.
</p></blockquote></div>
<h4 class="subheading">gnutls_anon_set_server_params_function</h4>
<p><a name="gnutls_005fanon_005fset_005fserver_005fparams_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_anon_set_server_params_function</b> (<var>gnutls_anon_server_credentials_t res, gnutls_params_function * func</var>)<var><a name="index-gnutls_005fanon_005fset_005fserver_005fparams_005ffunction-51"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials_t structure
<p><var>func</var>: is the function to be called
<p>This function will set a callback in order for the server to get the
diffie hellman parameters for anonymous authentication. The callback should
return zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_auth_client_get_type</h4>
<p><a name="gnutls_005fauth_005fclient_005fget_005ftype"></a>
<div class="defun">
— Function: gnutls_credentials_type_t <b>gnutls_auth_client_get_type</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fauth_005fclient_005fget_005ftype-52"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the type of credentials that were used for client authentication.
The returned information is to be used to distinguish the function used
to access authentication data.
</p></blockquote></div>
<h4 class="subheading">gnutls_auth_get_type</h4>
<p><a name="gnutls_005fauth_005fget_005ftype"></a>
<div class="defun">
— Function: gnutls_credentials_type_t <b>gnutls_auth_get_type</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fauth_005fget_005ftype-53"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns type of credentials for the current authentication schema.
The returned information is to be used to distinguish the function used
to access authentication data.
<p>Eg. for CERTIFICATE ciphersuites (key exchange algorithms: KX_RSA, KX_DHE_RSA),
the same function are to be used to access the authentication data.
</p></blockquote></div>
<h4 class="subheading">gnutls_auth_server_get_type</h4>
<p><a name="gnutls_005fauth_005fserver_005fget_005ftype"></a>
<div class="defun">
— Function: gnutls_credentials_type_t <b>gnutls_auth_server_get_type</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fauth_005fserver_005fget_005ftype-54"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the type of credentials that were used for server authentication.
The returned information is to be used to distinguish the function used
to access authentication data.
</p></blockquote></div>
<h4 class="subheading">gnutls_bye</h4>
<p><a name="gnutls_005fbye"></a>
<div class="defun">
— Function: int <b>gnutls_bye</b> (<var>gnutls_session_t session, gnutls_close_request_t how</var>)<var><a name="index-gnutls_005fbye-55"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>how</var>: is an integer
<p>Terminates the current TLS/SSL connection. The connection should
have been initiated using <code>gnutls_handshake()</code>.
<code>how</code> should be one of GNUTLS_SHUT_RDWR, GNUTLS_SHUT_WR.
<p>In case of GNUTLS_SHUT_RDWR then the TLS connection gets terminated and
further receives and sends will be disallowed. If the return
value is zero you may continue using the connection.
GNUTLS_SHUT_RDWR actually sends an alert containing a close request
and waits for the peer to reply with the same message.
<p>In case of GNUTLS_SHUT_WR then the TLS connection gets terminated and
further sends will be disallowed. In order to reuse the connection
you should wait for an EOF from the peer.
GNUTLS_SHUT_WR sends an alert containing a close request.
<p>Note that not all implementations will properly terminate a TLS connection.
Some of them, usually for performance reasons, will terminate only the
underlying transport layer, thus causing a transmission error to the peer.
This error cannot be distinguished from a malicious party prematurely terminating
the session, thus this behavior is not recommended.
<p>This function may also return GNUTLS_E_AGAIN or GNUTLS_E_INTERRUPTED; cf.
<code>gnutls_record_get_direction()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_activation_time_peers</h4>
<p><a name="gnutls_005fcertificate_005factivation_005ftime_005fpeers"></a>
<div class="defun">
— Function: time_t <b>gnutls_certificate_activation_time_peers</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcertificate_005factivation_005ftime_005fpeers-56"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the peer's certificate activation time.
This is the creation time for openpgp keys.
<p>Returns (time_t) -1 on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_allocate_credentials</h4>
<p><a name="gnutls_005fcertificate_005fallocate_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_allocate_credentials</b> (<var>gnutls_certificate_credentials_t * res</var>)<var><a name="index-gnutls_005fcertificate_005fallocate_005fcredentials-57"></a></var><br>
<blockquote><p><var>res</var>: is a pointer to an <code>gnutls_certificate_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_client_get_request_status</h4>
<p><a name="gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_client_get_request_status</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus-58"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return 0 if the peer (server) did not request client
authentication or 1 otherwise.
Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_client_set_retrieve_function</h4>
<p><a name="gnutls_005fcertificate_005fclient_005fset_005fretrieve_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_client_set_retrieve_function</b> (<var>gnutls_certificate_credentials_t cred, gnutls_certificate_client_retrieve_function * func</var>)<var><a name="index-gnutls_005fcertificate_005fclient_005fset_005fretrieve_005ffunction-59"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
<p><var>func</var>: is the callback function
<p>This function sets a callback to be called in order to retrieve the certificate
to be used in the handshake.
The callback's function prototype is:
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr_st* st);
<p><code>st</code> should contain the certificates and private keys.
<p><code>req_ca_cert</code>, is only used in X.509 certificates.
Contains a list with the CA names that the server considers trusted.
Normally we should send a certificate that is signed
by one of these CAs. These names are DER encoded. To get a more
meaningful value use the function <code>gnutls_x509_rdn_get()</code>.
<p><code>pk_algos</code>, contains a list with server's acceptable signature algorithms.
The certificate returned should support the server's given algorithms.
<p>If the callback function is provided then gnutls will call it, in the
handshake, after the certificate request message has been received.
<p>The callback function should set the certificate list to be sent, and
return 0 on success. If no certificate was selected then the number of certificates
should be set to zero. The value (-1) indicates error and the handshake
will be terminated.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_expiration_time_peers</h4>
<p><a name="gnutls_005fcertificate_005fexpiration_005ftime_005fpeers"></a>
<div class="defun">
— Function: time_t <b>gnutls_certificate_expiration_time_peers</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcertificate_005fexpiration_005ftime_005fpeers-60"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the peer's certificate expiration time.
<p>Returns (time_t) -1 on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_free_ca_names</h4>
<p><a name="gnutls_005fcertificate_005ffree_005fca_005fnames"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_free_ca_names</b> (<var>gnutls_certificate_credentials_t sc</var>)<var><a name="index-gnutls_005fcertificate_005ffree_005fca_005fnames-61"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p>This function will delete all the CA name in the
given credentials. Clients may call this to save some memory
since in client side the CA names are not used.
<p>CA names are used by servers to advertize the CAs they
support to clients.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_free_cas</h4>
<p><a name="gnutls_005fcertificate_005ffree_005fcas"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_free_cas</b> (<var>gnutls_certificate_credentials_t sc</var>)<var><a name="index-gnutls_005fcertificate_005ffree_005fcas-62"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p>This function will delete all the CAs associated
with the given credentials. Servers that do not use
<code>gnutls_certificate_verify_peers2()</code> may call this to
save some memory.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_free_credentials</h4>
<p><a name="gnutls_005fcertificate_005ffree_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_free_credentials</b> (<var>gnutls_certificate_credentials_t sc</var>)<var><a name="index-gnutls_005fcertificate_005ffree_005fcredentials-63"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
<p>This function does not free any temporary parameters associated
with this structure (ie RSA and DH parameters are not freed by
this function).
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_free_crls</h4>
<p><a name="gnutls_005fcertificate_005ffree_005fcrls"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_free_crls</b> (<var>gnutls_certificate_credentials_t sc</var>)<var><a name="index-gnutls_005fcertificate_005ffree_005fcrls-64"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p>This function will delete all the CRLs associated
with the given credentials.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_free_keys</h4>
<p><a name="gnutls_005fcertificate_005ffree_005fkeys"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_free_keys</b> (<var>gnutls_certificate_credentials_t sc</var>)<var><a name="index-gnutls_005fcertificate_005ffree_005fkeys-65"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p>This function will delete all the keys and the certificates associated
with the given credentials. This function must not be called when a
TLS negotiation that uses the credentials is in progress.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_get_ours</h4>
<p><a name="gnutls_005fcertificate_005fget_005fours"></a>
<div class="defun">
— Function: const gnutls_datum_t * <b>gnutls_certificate_get_ours</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcertificate_005fget_005fours-66"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the certificate as sent to the peer,
in the last handshake. These certificates are in raw format.
In X.509 this is a certificate list. In OpenPGP this is a single
certificate.
Returns NULL in case of an error, or if no certificate was used.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_get_peers</h4>
<p><a name="gnutls_005fcertificate_005fget_005fpeers"></a>
<div class="defun">
— Function: const gnutls_datum_t * <b>gnutls_certificate_get_peers</b> (<var>gnutls_session_t session, unsigned int * list_size</var>)<var><a name="index-gnutls_005fcertificate_005fget_005fpeers-67"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p><var>list_size</var>: is the length of the certificate list
<p>This function will return the peer's raw certificate (chain) as
sent by the peer. These certificates are in raw format (DER encoded
for X.509). In case of a X.509 then a certificate list may be present.
The first certificate in the list is the peer's certificate,
following the issuer's certificate, then the issuer's issuer etc.
<p>In case of OpenPGP keys a single key will be returned
in raw format.
<p>Returns NULL in case of an error, or if no certificate was sent.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_send_x509_rdn_sequence</h4>
<p><a name="gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_send_x509_rdn_sequence</b> (<var>gnutls_session_t session, int status</var>)<var><a name="index-gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence-68"></a></var><br>
<blockquote><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
<p><var>status</var>: is 0 or 1
<p>If status is non zero, this function will order gnutls not to send the rdnSequence
in the certificate request message. That is the server will not advertize
it's trusted CAs to the peer. If status is zero then the default behaviour will
take effect, which is to advertize the server's trusted CAs.
<p>This function has no effect in clients, and in authentication methods other than
certificate with X.509 certificates.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_server_set_request</h4>
<p><a name="gnutls_005fcertificate_005fserver_005fset_005frequest"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_server_set_request</b> (<var>gnutls_session_t session, gnutls_certificate_request_t req</var>)<var><a name="index-gnutls_005fcertificate_005fserver_005fset_005frequest-69"></a></var><br>
<blockquote><p><var>session</var>: is an <code>gnutls_session_t</code> structure.
<p><var>req</var>: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
<p>This function specifies if we (in case of a server) are going
to send a certificate request message to the client. If <code>req</code>
is GNUTLS_CERT_REQUIRE then the server will return an error if
the peer does not provide a certificate. If you do not
call this function then the client will not be asked to
send a certificate.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_server_set_retrieve_function</h4>
<p><a name="gnutls_005fcertificate_005fserver_005fset_005fretrieve_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_server_set_retrieve_function</b> (<var>gnutls_certificate_credentials_t cred, gnutls_certificate_server_retrieve_function * func</var>)<var><a name="index-gnutls_005fcertificate_005fserver_005fset_005fretrieve_005ffunction-70"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
<p><var>func</var>: is the callback function
<p>This function sets a callback to be called in order to retrieve the certificate
to be used in the handshake.
The callback's function prototype is:
int (*callback)(gnutls_session_t, gnutls_retr_st* st);
<p><code>st</code> should contain the certificates and private keys.
<p>If the callback function is provided then gnutls will call it, in the
handshake, after the certificate request message has been received.
<p>The callback function should set the certificate list to be sent, and
return 0 on success. The value (-1) indicates error and the handshake
will be terminated.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_dh_params</h4>
<p><a name="gnutls_005fcertificate_005fset_005fdh_005fparams"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_set_dh_params</b> (<var>gnutls_certificate_credentials_t res, gnutls_dh_params_t dh_params</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fdh_005fparams-71"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials_t structure
<p><var>dh_params</var>: is a structure that holds diffie hellman parameters.
<p>This function will set the diffie hellman parameters for a
certificate server to use. These parameters will be used in
Ephemeral Diffie Hellman cipher suites. Note that only a pointer
to the parameters are stored in the certificate handle, so if you
deallocate the parameters before the certificate is deallocated,
you must change the parameters stored in the certificate first.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_params_function</h4>
<p><a name="gnutls_005fcertificate_005fset_005fparams_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_set_params_function</b> (<var>gnutls_certificate_credentials_t res, gnutls_params_function * func</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fparams_005ffunction-72"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials_t structure
<p><var>func</var>: is the function to be called
<p>This function will set a callback in order for the server to get the
diffie hellman or RSA parameters for certificate authentication. The callback
should return zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_rsa_export_params</h4>
<p><a name="gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_set_rsa_export_params</b> (<var>gnutls_certificate_credentials_t res, gnutls_rsa_params_t rsa_params</var>)<var><a name="index-gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams-73"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials_t structure
<p><var>rsa_params</var>: is a structure that holds temporary RSA parameters.
<p>This function will set the temporary RSA parameters for a certificate
server to use. These parameters will be used in RSA-EXPORT
cipher suites.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_verify_flags</h4>
<p><a name="gnutls_005fcertificate_005fset_005fverify_005fflags"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_set_verify_flags</b> (<var>gnutls_certificate_credentials_t res, unsigned int flags</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fverify_005fflags-74"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials_t structure
<p><var>flags</var>: are the flags
<p>This function will set the flags to be used at verification of the
certificates. Flags must be OR of the
<code>gnutls_certificate_verify_flags</code> enumerations.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_verify_limits</h4>
<p><a name="gnutls_005fcertificate_005fset_005fverify_005flimits"></a>
<div class="defun">
— Function: void <b>gnutls_certificate_set_verify_limits</b> (<var>gnutls_certificate_credentials_t res, unsigned int max_bits, unsigned int max_depth</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fverify_005flimits-75"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials structure
<p><var>max_bits</var>: is the number of bits of an acceptable certificate (default 8200)
<p><var>max_depth</var>: is maximum depth of the verification of a certificate chain (default 5)
<p>This function will set some upper limits for the default verification function,
<code>gnutls_certificate_verify_peers2()</code>, to avoid denial of service attacks.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_crl_file</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_crl_file</b> (<var>gnutls_certificate_credentials_t res, const char * crlfile, gnutls_x509_crt_fmt_t type</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile-76"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>crlfile</var>: is a file containing the list of verified CRLs (DER or PEM list)
<p><var>type</var>: is PEM or DER
<p>This function adds the trusted CRLs in order to verify client or server
certificates. In case of a client this is not required
to be called if the certificates are not verified using
<code>gnutls_certificate_verify_peers2()</code>.
This function may be called multiple times.
<p>Returns the number of CRLs processed or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_crl_mem</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_crl_mem</b> (<var>gnutls_certificate_credentials_t res, const gnutls_datum_t * CRL, gnutls_x509_crt_fmt_t type</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem-77"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>CRL</var>: is a list of trusted CRLs. They should have been verified before.
<p><var>type</var>: is DER or PEM
<p>This function adds the trusted CRLs in order to verify client or server
certificates. In case of a client this is not required
to be called if the certificates are not verified using
<code>gnutls_certificate_verify_peers2()</code>.
This function may be called multiple times.
<p>Returns the number of CRLs processed or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_crl</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fcrl"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_crl</b> (<var>gnutls_certificate_credentials_t res, gnutls_x509_crl_t * crl_list, int crl_list_size</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fcrl-78"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>crl_list</var>: is a list of trusted CRLs. They should have been verified before.
<p><var>crl_list_size</var>: holds the size of the crl_list
<p>This function adds the trusted CRLs in order to verify client or server
certificates. In case of a client this is not required
to be called if the certificates are not verified using
<code>gnutls_certificate_verify_peers2()</code>.
This function may be called multiple times.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_key_file</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_key_file</b> (<var>gnutls_certificate_credentials_t res, const char * CERTFILE, const char * KEYFILE, gnutls_x509_crt_fmt_t type</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile-79"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>CERTFILE</var>: is a file that containing the certificate list (path) for
the specified private key, in PKCS7 format, or a list of certificates
<p><var>KEYFILE</var>: is a file that contains the private key
<p><var>type</var>: is PEM or DER
<p>This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be called
more than once (in case multiple keys/certificates exist for the
server).
<p>Currently only PKCS-1 encoded RSA and DSA private keys are accepted by
this function.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_key_mem</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_key_mem</b> (<var>gnutls_certificate_credentials_t res, const gnutls_datum_t * cert, const gnutls_datum_t * key, gnutls_x509_crt_fmt_t type</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem-80"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>cert</var>: contains a certificate list (path) for the specified private key
<p><var>key</var>: is the private key
<p><var>type</var>: is PEM or DER
<p>This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be called
more than once (in case multiple keys/certificates exist for the
server).
<p><strong>Currently are supported:</strong> RSA PKCS-1 encoded private keys,
DSA private keys.
<p>DSA private keys are encoded the OpenSSL way, which is an ASN.1
DER sequence of 6 INTEGERs - version, p, q, g, pub, priv.
<p>Note that the keyUsage (2.5.29.15) PKIX extension in X.509 certificates
is supported. This means that certificates intended for signing cannot
be used for ciphersuites that require encryption.
<p>If the certificate and the private key are given in PEM encoding
then the strings that hold their values must be null terminated.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_key</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fkey"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_key</b> (<var>gnutls_certificate_credentials_t res, gnutls_x509_crt_t * cert_list, int cert_list_size, gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fkey-81"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>cert_list</var>: contains a certificate list (path) for the specified private key
<p><var>cert_list_size</var>: holds the size of the certificate list
<p><var>key</var>: is a gnutls_x509_privkey_t key
<p>This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be called
more than once (in case multiple keys/certificates exist for the
server).
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_simple_pkcs12_file</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_simple_pkcs12_file</b> (<var>gnutls_certificate_credentials_t res, const char * pkcs12file, gnutls_x509_crt_fmt_t type, const char * password</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile-82"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>pkcs12file</var>: filename of file containing PKCS<code>12</code> blob.
<p><var>type</var>: is PEM or DER of the <code>pkcs12file</code>.
<p><var>password</var>: optional password used to decrypt PKCS<code>12</code> file, bags and keys.
<p>This function sets a certificate/private key pair and/or a CRL in
the gnutls_certificate_credentials_t structure. This function may
be called more than once (in case multiple keys/certificates exist
for the server).
<p><strong>MAC:</strong> ed PKCS<code>12</code> files are supported. Encrypted PKCS<code>12</code> bags are
supported. Encrypted PKCS<code>8</code> private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
<p>The private keys may be RSA PKCS<code>1</code> or DSA private keys encoded in
the OpenSSL way.
<p>PKCS<code>12</code> file may contain many keys and/or certificates, and there
is no way to identify which key/certificate pair you want. You
should make sure the PKCS<code>12</code> file only contain one key/certificate
pair and/or one CRL.
<p>It is believed that the limitations of this function is acceptable
for most usage, and that any more flexibility would introduce
complexity that would make it harder to use this functionality at
all.
<p><strong>Return value:</strong> Returns 0 on success, or an error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_trust_file</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_trust_file</b> (<var>gnutls_certificate_credentials_t res, const char * cafile, gnutls_x509_crt_fmt_t type</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile-83"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>cafile</var>: is a file containing the list of trusted CAs (DER or PEM list)
<p><var>type</var>: is PEM or DER
<p>This function adds the trusted CAs in order to verify client
or server certificates. In case of a client this is not required
to be called if the certificates are not verified using
<code>gnutls_certificate_verify_peers2()</code>.
This function may be called multiple times.
<p>In case of a server the names of the CAs set here will be sent to the
client if a certificate request is sent. This can be disabled using
<code>gnutls_certificate_send_x509_rdn_sequence()</code>.
<p>Returns the number of certificates processed or a negative
value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_trust_mem</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_trust_mem</b> (<var>gnutls_certificate_credentials_t res, const gnutls_datum_t * ca, gnutls_x509_crt_fmt_t type</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem-84"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>ca</var>: is a list of trusted CAs or a DER certificate
<p><var>type</var>: is DER or PEM
<p>This function adds the trusted CAs in order to verify client
or server certificates. In case of a client this is not required
to be called if the certificates are not verified using
<code>gnutls_certificate_verify_peers2()</code>.
This function may be called multiple times.
<p>In case of a server the CAs set here will be sent to the client if
a certificate request is sent. This can be disabled using
<code>gnutls_certificate_send_x509_rdn_sequence()</code>.
<p>Returns the number of certificates processed or a negative
value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_x509_trust</h4>
<p><a name="gnutls_005fcertificate_005fset_005fx509_005ftrust"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_x509_trust</b> (<var>gnutls_certificate_credentials_t res, gnutls_x509_crt_t * ca_list, int ca_list_size</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fx509_005ftrust-85"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>ca_list</var>: is a list of trusted CAs
<p><var>ca_list_size</var>: holds the size of the CA list
<p>This function adds the trusted CAs in order to verify client
or server certificates. In case of a client this is not required
to be called if the certificates are not verified using
<code>gnutls_certificate_verify_peers2()</code>.
This function may be called multiple times.
<p>In case of a server the CAs set here will be sent to the client if
a certificate request is sent. This can be disabled using
<code>gnutls_certificate_send_x509_rdn_sequence()</code>.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_type_get_name</h4>
<p><a name="gnutls_005fcertificate_005ftype_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_certificate_type_get_name</b> (<var>gnutls_certificate_type_t type</var>)<var><a name="index-gnutls_005fcertificate_005ftype_005fget_005fname-86"></a></var><br>
<blockquote><p><var>type</var>: is a certificate type
<p>Returns a string (or NULL) that contains the name
of the specified certificate type.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_type_get</h4>
<p><a name="gnutls_005fcertificate_005ftype_005fget"></a>
<div class="defun">
— Function: gnutls_certificate_type_t <b>gnutls_certificate_type_get</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcertificate_005ftype_005fget-87"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the currently used certificate type. The certificate type
is by default X.509, unless it is negotiated as a TLS extension.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_type_set_priority</h4>
<p><a name="gnutls_005fcertificate_005ftype_005fset_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_type_set_priority</b> (<var>gnutls_session_t session, const int * list</var>)<var><a name="index-gnutls_005fcertificate_005ftype_005fset_005fpriority-88"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>list</var>: is a 0 terminated list of gnutls_certificate_type_t elements.
<p>Sets the priority on the certificate types supported by gnutls.
Priority is higher for types specified before others.
After specifying the types you want, you must append a 0.
Note that the certificate type priority is set on the client.
The server does not use the cert type priority except for disabling
types that were not specified.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_verify_peers2</h4>
<p><a name="gnutls_005fcertificate_005fverify_005fpeers2"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_verify_peers2</b> (<var>gnutls_session_t session, unsigned int * status</var>)<var><a name="index-gnutls_005fcertificate_005fverify_005fpeers2-89"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p><var>status</var>: is the output of the verification
<p>This function will try to verify the peer's certificate and return
its status (trusted, invalid etc.). The value of <code>status</code> should
be one or more of the gnutls_certificate_status_t enumerated
elements bitwise or'd. To avoid denial of service attacks some
default upper limits regarding the certificate key size and chain
size are set. To override them use
<code>gnutls_certificate_set_verify_limits()</code>.
<p>Note that you must also check the peer's name in order to check if
the verified certificate belongs to the actual peer.
<p>Returns a negative error code on error and zero on success.
<p>This is the same as <code>gnutls_x509_verify_certificate()</code> and uses the
loaded CAs in the credentials as trusted CAs.
<p>Note that some commonly used X.509 Certificate Authorities are
still using Version 1 certificates. If you want to accept them,
you need to call <code>gnutls_certificate_set_verify_flags()</code> with, e.g.,
<code>GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT</code> parameter.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_verify_peers</h4>
<p><a name="gnutls_005fcertificate_005fverify_005fpeers"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_verify_peers</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcertificate_005fverify_005fpeers-90"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will try to verify the peer's certificate and return
its status (trusted, invalid etc.). However you must also check
the peer's name in order to check if the verified certificate
belongs to the actual peer.
<p>The return value should be one or more of the
gnutls_certificate_status_t enumerated elements bitwise or'd, or a
negative value on error.
<p>This is the same as <code>gnutls_x509_verify_certificate()</code>.
<p><strong>Deprecated:</strong> Use <code>gnutls_certificate_verify_peers2()</code> instead.
</p></blockquote></div>
<h4 class="subheading">gnutls_check_version</h4>
<p><a name="gnutls_005fcheck_005fversion"></a>
<div class="defun">
— Function: const char * <b>gnutls_check_version</b> (<var>const char * req_version</var>)<var><a name="index-gnutls_005fcheck_005fversion-91"></a></var><br>
<blockquote><p><var>req_version</var>: the version to check
<p>Check that the version of the library is at minimum the requested one
and return the version string; return NULL if the condition is not
satisfied. If a NULL is passed to this function, no check is done,
but the version string is simply returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_cipher_get_key_size</h4>
<p><a name="gnutls_005fcipher_005fget_005fkey_005fsize"></a>
<div class="defun">
— Function: size_t <b>gnutls_cipher_get_key_size</b> (<var>gnutls_cipher_algorithm_t algorithm</var>)<var><a name="index-gnutls_005fcipher_005fget_005fkey_005fsize-92"></a></var><br>
<blockquote><p><var>algorithm</var>: is an encryption algorithm
<p>Returns the length (in bytes) of the given cipher's key size.
Returns 0 if the given cipher is invalid.
</p></blockquote></div>
<h4 class="subheading">gnutls_cipher_get_name</h4>
<p><a name="gnutls_005fcipher_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_cipher_get_name</b> (<var>gnutls_cipher_algorithm_t algorithm</var>)<var><a name="index-gnutls_005fcipher_005fget_005fname-93"></a></var><br>
<blockquote><p><var>algorithm</var>: is an encryption algorithm
<p>Returns a pointer to a string that contains the name
of the specified cipher or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_cipher_get</h4>
<p><a name="gnutls_005fcipher_005fget"></a>
<div class="defun">
— Function: gnutls_cipher_algorithm_t <b>gnutls_cipher_get</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcipher_005fget-94"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the currently used cipher.
</p></blockquote></div>
<h4 class="subheading">gnutls_cipher_set_priority</h4>
<p><a name="gnutls_005fcipher_005fset_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_cipher_set_priority</b> (<var>gnutls_session_t session, const int * list</var>)<var><a name="index-gnutls_005fcipher_005fset_005fpriority-95"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>list</var>: is a 0 terminated list of gnutls_cipher_algorithm_t elements.
<p>Sets the priority on the ciphers supported by gnutls.
Priority is higher for ciphers specified before others.
After specifying the ciphers you want, you must append a 0.
Note that the priority is set on the client. The server does
not use the algorithm's priority except for disabling
algorithms that were not specified.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_cipher_suite_get_name</h4>
<p><a name="gnutls_005fcipher_005fsuite_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_cipher_suite_get_name</b> (<var>gnutls_kx_algorithm_t kx_algorithm, gnutls_cipher_algorithm_t cipher_algorithm, gnutls_mac_algorithm_t mac_algorithm</var>)<var><a name="index-gnutls_005fcipher_005fsuite_005fget_005fname-96"></a></var><br>
<blockquote><p><var>kx_algorithm</var>: is a Key exchange algorithm
<p><var>cipher_algorithm</var>: is a cipher algorithm
<p><var>mac_algorithm</var>: is a MAC algorithm
<p>Returns a string that contains the name of a TLS
cipher suite, specified by the given algorithms, or NULL.
<p>Note that the full cipher suite name must be prepended
by TLS or SSL depending of the protocol in use.
</p></blockquote></div>
<h4 class="subheading">gnutls_compression_get_name</h4>
<p><a name="gnutls_005fcompression_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_compression_get_name</b> (<var>gnutls_compression_method_t algorithm</var>)<var><a name="index-gnutls_005fcompression_005fget_005fname-97"></a></var><br>
<blockquote><p><var>algorithm</var>: is a Compression algorithm
<p>Returns a pointer to a string that contains the name
of the specified compression algorithm or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_compression_get</h4>
<p><a name="gnutls_005fcompression_005fget"></a>
<div class="defun">
— Function: gnutls_compression_method_t <b>gnutls_compression_get</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcompression_005fget-98"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the currently used compression method.
</p></blockquote></div>
<h4 class="subheading">gnutls_compression_set_priority</h4>
<p><a name="gnutls_005fcompression_005fset_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_compression_set_priority</b> (<var>gnutls_session_t session, const int * list</var>)<var><a name="index-gnutls_005fcompression_005fset_005fpriority-99"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>list</var>: is a 0 terminated list of gnutls_compression_method_t elements.
<p>Sets the priority on the compression algorithms supported by gnutls.
Priority is higher for algorithms specified before others.
After specifying the algorithms you want, you must append a 0.
Note that the priority is set on the client. The server does
not use the algorithm's priority except for disabling
algorithms that were not specified.
<p>TLS 1.0 does not define any compression algorithms except
NULL. Other compression algorithms are to be considered
as gnutls extensions.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_credentials_clear</h4>
<p><a name="gnutls_005fcredentials_005fclear"></a>
<div class="defun">
— Function: void <b>gnutls_credentials_clear</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fcredentials_005fclear-100"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Clears all the credentials previously set in this session.
</p></blockquote></div>
<h4 class="subheading">gnutls_credentials_set</h4>
<p><a name="gnutls_005fcredentials_005fset"></a>
<div class="defun">
— Function: int <b>gnutls_credentials_set</b> (<var>gnutls_session_t session, gnutls_credentials_type_t type, void * cred</var>)<var><a name="index-gnutls_005fcredentials_005fset-101"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>type</var>: is the type of the credentials
<p><var>cred</var>: is a pointer to a structure.
<p>Sets the needed credentials for the specified type.
Eg username, password - or public and private keys etc.
The (void* cred) parameter is a structure that depends on the
specified type and on the current session (client or server).
[ In order to minimize memory usage, and share credentials between
several threads gnutls keeps a pointer to cred, and not the whole cred
structure. Thus you will have to keep the structure allocated until
you call <code>gnutls_deinit()</code>. ]
<p>For GNUTLS_CRD_ANON cred should be gnutls_anon_client_credentials_t in case of a client.
In case of a server it should be gnutls_anon_server_credentials_t.
<p>For GNUTLS_CRD_SRP cred should be gnutls_srp_client_credentials_t
in case of a client, and gnutls_srp_server_credentials_t, in case
of a server.
<p>For GNUTLS_CRD_CERTIFICATE cred should be gnutls_certificate_credentials_t.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_check_entry</h4>
<p><a name="gnutls_005fdb_005fcheck_005fentry"></a>
<div class="defun">
— Function: int <b>gnutls_db_check_entry</b> (<var>gnutls_session_t session, gnutls_datum_t session_entry</var>)<var><a name="index-gnutls_005fdb_005fcheck_005fentry-102"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>session_entry</var>: is the session data (not key)
<p>This function returns GNUTLS_E_EXPIRED, if the database entry
has expired or 0 otherwise. This function is to be used when
you want to clear unnesessary session which occupy space in your
backend.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_get_ptr</h4>
<p><a name="gnutls_005fdb_005fget_005fptr"></a>
<div class="defun">
— Function: void * <b>gnutls_db_get_ptr</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fdb_005fget_005fptr-103"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the pointer that will be sent to db store, retrieve and delete functions, as
the first argument.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_remove_session</h4>
<p><a name="gnutls_005fdb_005fremove_005fsession"></a>
<div class="defun">
— Function: void <b>gnutls_db_remove_session</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fdb_005fremove_005fsession-104"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function will remove the current session data from the session
database. This will prevent future handshakes reusing these session
data. This function should be called if a session was terminated
abnormally, and before <code>gnutls_deinit()</code> is called.
<p>Normally <code>gnutls_deinit()</code> will remove abnormally terminated sessions.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_set_cache_expiration</h4>
<p><a name="gnutls_005fdb_005fset_005fcache_005fexpiration"></a>
<div class="defun">
— Function: void <b>gnutls_db_set_cache_expiration</b> (<var>gnutls_session_t session, int seconds</var>)<var><a name="index-gnutls_005fdb_005fset_005fcache_005fexpiration-105"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>seconds</var>: is the number of seconds.
<p>Sets the expiration time for resumed sessions. The default is 3600 (one hour)
at the time writing this.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_set_ptr</h4>
<p><a name="gnutls_005fdb_005fset_005fptr"></a>
<div class="defun">
— Function: void <b>gnutls_db_set_ptr</b> (<var>gnutls_session_t session, void * ptr</var>)<var><a name="index-gnutls_005fdb_005fset_005fptr-106"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>ptr</var>: is the pointer
<p>Sets the pointer that will be provided to db store, retrieve and delete functions, as
the first argument.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_set_remove_function</h4>
<p><a name="gnutls_005fdb_005fset_005fremove_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_db_set_remove_function</b> (<var>gnutls_session_t session, gnutls_db_remove_func rem_func</var>)<var><a name="index-gnutls_005fdb_005fset_005fremove_005ffunction-107"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>rem_func</var>: is the function.
<p>Sets the function that will be used to remove data from the resumed
sessions database. This function must return 0 on success.
<p>The first argument to <code>rem_func()</code> will be null unless <code>gnutls_db_set_ptr()</code>
has been called.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_set_retrieve_function</h4>
<p><a name="gnutls_005fdb_005fset_005fretrieve_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_db_set_retrieve_function</b> (<var>gnutls_session_t session, gnutls_db_retr_func retr_func</var>)<var><a name="index-gnutls_005fdb_005fset_005fretrieve_005ffunction-108"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>retr_func</var>: is the function.
<p>Sets the function that will be used to retrieve data from the resumed
sessions database. This function must return a gnutls_datum_t containing the
data on success, or a gnutls_datum_t containing null and 0 on failure.
<p>The datum's data must be allocated using the function
<code>gnutls_malloc()</code>.
<p>The first argument to <code>retr_func()</code> will be null unless <code>gnutls_db_set_ptr()</code>
has been called.
</p></blockquote></div>
<h4 class="subheading">gnutls_db_set_store_function</h4>
<p><a name="gnutls_005fdb_005fset_005fstore_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_db_set_store_function</b> (<var>gnutls_session_t session, gnutls_db_store_func store_func</var>)<var><a name="index-gnutls_005fdb_005fset_005fstore_005ffunction-109"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>store_func</var>: is the function
<p>Sets the function that will be used to store data from the resumed
sessions database. This function must remove 0 on success.
<p>The first argument to <code>store_func()</code> will be null unless <code>gnutls_db_set_ptr()</code>
has been called.
</p></blockquote></div>
<h4 class="subheading">gnutls_deinit</h4>
<p><a name="gnutls_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_deinit</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fdeinit-110"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function clears all buffers associated with the <code>session</code>.
This function will also remove session data from the session database
if the session was terminated abnormally.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_get_group</h4>
<p><a name="gnutls_005fdh_005fget_005fgroup"></a>
<div class="defun">
— Function: int <b>gnutls_dh_get_group</b> (<var>gnutls_session_t session, gnutls_datum_t * raw_gen, gnutls_datum_t * raw_prime</var>)<var><a name="index-gnutls_005fdh_005fget_005fgroup-111"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p><var>raw_gen</var>: will hold the generator.
<p><var>raw_prime</var>: will hold the prime.
<p>This function will return the group parameters used in the last Diffie Hellman
authentication with the peer. These are the prime and the generator used.
This function should be used for both anonymous and ephemeral diffie Hellman.
The output parameters must be freed with <code>gnutls_free()</code>.
<p>Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_get_peers_public_bits</h4>
<p><a name="gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits"></a>
<div class="defun">
— Function: int <b>gnutls_dh_get_peers_public_bits</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits-112"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the bits used in the last Diffie Hellman authentication
with the peer. Should be used for both anonymous and ephemeral diffie Hellman.
Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_get_prime_bits</h4>
<p><a name="gnutls_005fdh_005fget_005fprime_005fbits"></a>
<div class="defun">
— Function: int <b>gnutls_dh_get_prime_bits</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fdh_005fget_005fprime_005fbits-113"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the bits of the prime used in the last Diffie Hellman authentication
with the peer. Should be used for both anonymous and ephemeral diffie Hellman.
Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_get_pubkey</h4>
<p><a name="gnutls_005fdh_005fget_005fpubkey"></a>
<div class="defun">
— Function: int <b>gnutls_dh_get_pubkey</b> (<var>gnutls_session_t session, gnutls_datum_t * raw_key</var>)<var><a name="index-gnutls_005fdh_005fget_005fpubkey-114"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p><var>raw_key</var>: will hold the public key.
<p>This function will return the peer's public key used in the last Diffie Hellman authentication.
This function should be used for both anonymous and ephemeral diffie Hellman.
The output parameters must be freed with <code>gnutls_free()</code>.
<p>Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_get_secret_bits</h4>
<p><a name="gnutls_005fdh_005fget_005fsecret_005fbits"></a>
<div class="defun">
— Function: int <b>gnutls_dh_get_secret_bits</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fdh_005fget_005fsecret_005fbits-115"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the bits used in the last Diffie Hellman authentication
with the peer. Should be used for both anonymous and ephemeral diffie Hellman.
Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_cpy</h4>
<p><a name="gnutls_005fdh_005fparams_005fcpy"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_cpy</b> (<var>gnutls_dh_params_t dst, gnutls_dh_params_t src</var>)<var><a name="index-gnutls_005fdh_005fparams_005fcpy-116"></a></var><br>
<blockquote><p><var>dst</var>: Is the destination structure, which should be initialized.
<p><var>src</var>: Is the source structure
<p>This function will copy the DH parameters structure from source
to destination.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_deinit</h4>
<p><a name="gnutls_005fdh_005fparams_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_dh_params_deinit</b> (<var>gnutls_dh_params_t dh_params</var>)<var><a name="index-gnutls_005fdh_005fparams_005fdeinit-117"></a></var><br>
<blockquote><p><var>dh_params</var>: Is a structure that holds the prime numbers
<p>This function will deinitialize the DH parameters structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_export_pkcs3</h4>
<p><a name="gnutls_005fdh_005fparams_005fexport_005fpkcs3"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_export_pkcs3</b> (<var>gnutls_dh_params_t params, gnutls_x509_crt_fmt_t format, unsigned char * params_data, size_t * params_data_size</var>)<var><a name="index-gnutls_005fdh_005fparams_005fexport_005fpkcs3-118"></a></var><br>
<blockquote><p><var>params</var>: Holds the DH parameters
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>params_data</var>: will contain a PKCS3 DHParams structure PEM or DER encoded
<p><var>params_data_size</var>: holds the size of params_data (and will be replaced by the actual size of parameters)
<p>This function will export the given dh parameters to a PKCS3
DHParams structure. This is the format generated by "openssl dhparam" tool.
If the buffer provided is not long enough to hold the output, then
GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN DH PARAMETERS".
<p>In case of failure a negative value will be returned, and
0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_export_raw</h4>
<p><a name="gnutls_005fdh_005fparams_005fexport_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_export_raw</b> (<var>gnutls_dh_params_t params, gnutls_datum_t * prime, gnutls_datum_t * generator, unsigned int * bits</var>)<var><a name="index-gnutls_005fdh_005fparams_005fexport_005fraw-119"></a></var><br>
<blockquote><p><var>params</var>: Holds the DH parameters
<p><var>prime</var>: will hold the new prime
<p><var>generator</var>: will hold the new generator
<p><var>bits</var>: if non null will hold is the prime's number of bits
<p>This function will export the pair of prime and generator for use in
the Diffie-Hellman key exchange. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_generate2</h4>
<p><a name="gnutls_005fdh_005fparams_005fgenerate2"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_generate2</b> (<var>gnutls_dh_params_t params, unsigned int bits</var>)<var><a name="index-gnutls_005fdh_005fparams_005fgenerate2-120"></a></var><br>
<blockquote><p><var>params</var>: Is the structure that the DH parameters will be stored
<p><var>bits</var>: is the prime's number of bits
<p>This function will generate a new pair of prime and generator for use in
the Diffie-Hellman key exchange. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
This function is normally slow.
<p>Note that the bits value should be one of 768, 1024, 2048, 3072 or 4096.
Also note that the DH parameters are only useful to servers.
Since clients use the parameters sent by the server, it's of
no use to call this in client side.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_import_pkcs3</h4>
<p><a name="gnutls_005fdh_005fparams_005fimport_005fpkcs3"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_import_pkcs3</b> (<var>gnutls_dh_params_t params, const gnutls_datum_t * pkcs3_params, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005fdh_005fparams_005fimport_005fpkcs3-121"></a></var><br>
<blockquote><p><var>params</var>: A structure where the parameters will be copied to
<p><var>pkcs3_params</var>: should contain a PKCS3 DHParams structure PEM or DER encoded
<p><var>format</var>: the format of params. PEM or DER.
<p>This function will extract the DHParams found in a PKCS3 formatted
structure. This is the format generated by "openssl dhparam" tool.
<p>If the structure is PEM encoded, it should have a header
of "BEGIN DH PARAMETERS".
<p>In case of failure a negative value will be returned, and
0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_import_raw</h4>
<p><a name="gnutls_005fdh_005fparams_005fimport_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_import_raw</b> (<var>gnutls_dh_params_t dh_params, const gnutls_datum_t * prime, const gnutls_datum_t * generator</var>)<var><a name="index-gnutls_005fdh_005fparams_005fimport_005fraw-122"></a></var><br>
<blockquote><p><var>dh_params</var>: Is a structure that will hold the prime numbers
<p><var>prime</var>: holds the new prime
<p><var>generator</var>: holds the new generator
<p>This function will replace the pair of prime and generator for use in
the Diffie-Hellman key exchange. The new parameters should be stored in the
appropriate gnutls_datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_params_init</h4>
<p><a name="gnutls_005fdh_005fparams_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_dh_params_init</b> (<var>gnutls_dh_params_t * dh_params</var>)<var><a name="index-gnutls_005fdh_005fparams_005finit-123"></a></var><br>
<blockquote><p><var>dh_params</var>: Is a structure that will hold the prime numbers
<p>This function will initialize the DH parameters structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_dh_set_prime_bits</h4>
<p><a name="gnutls_005fdh_005fset_005fprime_005fbits"></a>
<div class="defun">
— Function: void <b>gnutls_dh_set_prime_bits</b> (<var>gnutls_session_t session, unsigned int bits</var>)<var><a name="index-gnutls_005fdh_005fset_005fprime_005fbits-124"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>bits</var>: is the number of bits
<p>This function sets the number of bits, for use in an
Diffie Hellman key exchange. This is used both in DH ephemeral and
DH anonymous cipher suites. This will set the
minimum size of the prime that will be used for the handshake.
<p>In the client side it sets the minimum accepted number of bits.
If a server sends a prime with less bits than that
GNUTLS_E_DH_PRIME_UNACCEPTABLE will be returned by the
handshake.
</p></blockquote></div>
<h4 class="subheading">gnutls_error_is_fatal</h4>
<p><a name="gnutls_005ferror_005fis_005ffatal"></a>
<div class="defun">
— Function: int <b>gnutls_error_is_fatal</b> (<var>int error</var>)<var><a name="index-gnutls_005ferror_005fis_005ffatal-125"></a></var><br>
<blockquote><p><var>error</var>: is an error returned by a gnutls function. Error should be a negative value.
<p>If a function returns a negative value you may feed that value
to this function to see if it is fatal. Returns 1 for a fatal
error 0 otherwise. However you may want to check the
error code manually, since some non-fatal errors to the protocol
may be fatal for you (your program).
<p>This is only useful if you are dealing with errors from the
record layer or the handshake layer.
</p></blockquote></div>
<h4 class="subheading">gnutls_error_to_alert</h4>
<p><a name="gnutls_005ferror_005fto_005falert"></a>
<div class="defun">
— Function: int <b>gnutls_error_to_alert</b> (<var>int err, int * level</var>)<var><a name="index-gnutls_005ferror_005fto_005falert-126"></a></var><br>
<blockquote><p><var>err</var>: is a negative integer
<p><var>level</var>: the alert level will be stored there
<p>Returns an alert depending on the error code returned by a gnutls
function. All alerts sent by this function should be considered fatal.
The only exception is when err == GNUTLS_E_REHANDSHAKE, where a warning
alert should be sent to the peer indicating that no renegotiation will
be performed.
<p>If the return value is GNUTLS_E_INVALID_REQUEST, then there was no
mapping to an alert.
</p></blockquote></div>
<h4 class="subheading">gnutls_fingerprint</h4>
<p><a name="gnutls_005ffingerprint"></a>
<div class="defun">
— Function: int <b>gnutls_fingerprint</b> (<var>gnutls_digest_algorithm_t algo, const gnutls_datum_t * data, void * result, size_t * result_size</var>)<var><a name="index-gnutls_005ffingerprint-127"></a></var><br>
<blockquote><p><var>algo</var>: is a digest algorithm
<p><var>data</var>: is the data
<p><var>result</var>: is the place where the result will be copied (may be null).
<p><var>result_size</var>: should hold the size of the result. The actual size
of the returned result will also be copied there.
<p>This function will calculate a fingerprint (actually a hash), of the
given data. The result is not printable data. You should convert it
to hex, or to something else printable.
<p>This is the usual way to calculate a fingerprint of an X.509
DER encoded certificate. Note however that the fingerprint
of an OpenPGP is not just a hash and cannot be calculated with
this function.
<p>Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_free</h4>
<p><a name="gnutls_005ffree"></a>
<div class="defun">
— Function: void <b>gnutls_free</b> (<var>void * ptr</var>)<var><a name="index-gnutls_005ffree-128"></a></var><br>
<blockquote><p>This function will free data pointed by ptr.
<p>The deallocation function used is the one set by <code>gnutls_global_set_mem_functions()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_global_deinit</h4>
<p><a name="gnutls_005fglobal_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_global_deinit</b> (<var> void</var>)<var><a name="index-gnutls_005fglobal_005fdeinit-129"></a></var><br>
<blockquote>
<p>This function deinitializes the global data, that were initialized
using <code>gnutls_global_init()</code>.
<p>Note! This function is not thread safe. See the discussion for
<code>gnutls_global_init()</code> for more information.
</p></blockquote></div>
<h4 class="subheading">gnutls_global_init</h4>
<p><a name="gnutls_005fglobal_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_global_init</b> (<var> void</var>)<var><a name="index-gnutls_005fglobal_005finit-130"></a></var><br>
<blockquote>
<p>This function initializes the global data to defaults.
Every gnutls application has a global data which holds common parameters
shared by gnutls session structures.
You must call <code>gnutls_global_deinit()</code> when gnutls usage is no longer needed
Returns zero on success.
<p>Note that this function will also initialize libgcrypt, if it has not
been initialized before. Thus if you want to manually initialize libgcrypt
you must do it before calling this function. This is useful in cases you
want to disable libgcrypt's internal lockings etc.
<p>This function increment a global counter, so that
<code>gnutls_global_deinit()</code> only releases resources when it has been
called as many times as <code>gnutls_global_init()</code>. This is useful when
GnuTLS is used by more than one library in an application. This
function can be called many times, but will only do something the
first time.
<p>Note! This function is not thread safe. If two threads call this
function simultaneously, they can cause a race between checking
the global counter and incrementing it, causing both threads to
execute the library initialization code. That would lead to a
memory leak. To handle this, your application could invoke this
function after aquiring a thread mutex. To ignore the potential
memory leak is also an option.
</p></blockquote></div>
<h4 class="subheading">gnutls_global_set_log_function</h4>
<p><a name="gnutls_005fglobal_005fset_005flog_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_global_set_log_function</b> (<var>gnutls_log_func log_func</var>)<var><a name="index-gnutls_005fglobal_005fset_005flog_005ffunction-131"></a></var><br>
<blockquote><p><var>log_func</var>: it's a log function
<p>This is the function where you set the logging function gnutls
is going to use. This function only accepts a character array.
Normally you may not use this function since it is only used
for debugging purposes.
<p>gnutls_log_func is of the form,
void (*gnutls_log_func)( int level, const char*);
</p></blockquote></div>
<h4 class="subheading">gnutls_global_set_log_level</h4>
<p><a name="gnutls_005fglobal_005fset_005flog_005flevel"></a>
<div class="defun">
— Function: void <b>gnutls_global_set_log_level</b> (<var>int level</var>)<var><a name="index-gnutls_005fglobal_005fset_005flog_005flevel-132"></a></var><br>
<blockquote><p><var>level</var>: it's an integer from 0 to 9.
<p>This is the function that allows you to set the log level.
The level is an integer between 0 and 9. Higher values mean
more verbosity. The default value is 0. Larger values should
only be used with care, since they may reveal sensitive information.
<p>Use a log level over 10 to enable all debugging options.
</p></blockquote></div>
<h4 class="subheading">gnutls_global_set_mem_functions</h4>
<p><a name="gnutls_005fglobal_005fset_005fmem_005ffunctions"></a>
<div class="defun">
— Function: void <b>gnutls_global_set_mem_functions</b> (<var>gnutls_alloc_function alloc_func, gnutls_alloc_function secure_alloc_func, gnutls_is_secure_function is_secure_func, gnutls_realloc_function realloc_func, gnutls_free_function free_func</var>)<var><a name="index-gnutls_005fglobal_005fset_005fmem_005ffunctions-133"></a></var><br>
<blockquote><p><var>alloc_func</var>: it's the default memory allocation function. Like <code>malloc()</code>.
<p><var>secure_alloc_func</var>: This is the memory allocation function that will be used for sensitive data.
<p><var>is_secure_func</var>: a function that returns 0 if the memory given is not secure. May be NULL.
<p><var>realloc_func</var>: A realloc function
<p><var>free_func</var>: The function that frees allocated data. Must accept a NULL pointer.
<p>This is the function were you set the memory allocation functions gnutls
is going to use. By default the libc's allocation functions (<code>malloc()</code>, <code>free()</code>),
are used by gnutls, to allocate both sensitive and not sensitive data.
This function is provided to set the memory allocation functions to
something other than the defaults (ie the gcrypt allocation functions).
<p>This function must be called before <code>gnutls_global_init()</code> is called.
</p></blockquote></div>
<h4 class="subheading">gnutls_handshake_get_last_in</h4>
<p><a name="gnutls_005fhandshake_005fget_005flast_005fin"></a>
<div class="defun">
— Function: gnutls_handshake_description_t <b>gnutls_handshake_get_last_in</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fhandshake_005fget_005flast_005fin-134"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the last handshake message received. This function is only useful
to check where the last performed handshake failed. If the previous handshake
succeed or was not performed at all then no meaningful value will be returned.
<p>Check gnutls.h for the available handshake descriptions.
</p></blockquote></div>
<h4 class="subheading">gnutls_handshake_get_last_out</h4>
<p><a name="gnutls_005fhandshake_005fget_005flast_005fout"></a>
<div class="defun">
— Function: gnutls_handshake_description_t <b>gnutls_handshake_get_last_out</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fhandshake_005fget_005flast_005fout-135"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the last handshake message sent. This function is only useful
to check where the last performed handshake failed. If the previous handshake
succeed or was not performed at all then no meaningful value will be returned.
<p>Check gnutls.h for the available handshake descriptions.
</p></blockquote></div>
<h4 class="subheading">gnutls_handshake_set_max_packet_length</h4>
<p><a name="gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength"></a>
<div class="defun">
— Function: void <b>gnutls_handshake_set_max_packet_length</b> (<var>gnutls_session_t session, size_t max</var>)<var><a name="index-gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength-136"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>max</var>: is the maximum number.
<p>This function will set the maximum size of a handshake message.
Handshake messages over this size are rejected.
The default value is 16kb which is large enough. Set this to 0 if you do not want
to set an upper limit.
</p></blockquote></div>
<h4 class="subheading">gnutls_handshake_set_private_extensions</h4>
<p><a name="gnutls_005fhandshake_005fset_005fprivate_005fextensions"></a>
<div class="defun">
— Function: void <b>gnutls_handshake_set_private_extensions</b> (<var>gnutls_session_t session, int allow</var>)<var><a name="index-gnutls_005fhandshake_005fset_005fprivate_005fextensions-137"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>allow</var>: is an integer (0 or 1)
<p>This function will enable or disable the use of private
cipher suites (the ones that start with 0xFF). By default
or if <code>allow</code> is 0 then these cipher suites will not be
advertized nor used.
<p>Unless this function is called with the option to allow (1), then
no compression algorithms, like LZO. That is because these algorithms
are not yet defined in any RFC or even internet draft.
<p>Enabling the private ciphersuites when talking to other than gnutls
servers and clients may cause interoperability problems.
</p></blockquote></div>
<h4 class="subheading">gnutls_handshake</h4>
<p><a name="gnutls_005fhandshake"></a>
<div class="defun">
— Function: int <b>gnutls_handshake</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fhandshake-138"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function does the handshake of the TLS/SSL protocol,
and initializes the TLS connection.
<p>This function will fail if any problem is encountered,
and will return a negative error code. In case of a client,
if the client has asked to resume a session, but the server couldn't,
then a full handshake will be performed.
<p>The non-fatal errors such as GNUTLS_E_AGAIN and GNUTLS_E_INTERRUPTED
interrupt the handshake procedure, which should be later be resumed.
Call this function again, until it returns 0; cf.
<code>gnutls_record_get_direction()</code> and <code>gnutls_error_is_fatal()</code>.
<p>If this function is called by a server after a rehandshake request then
GNUTLS_E_GOT_APPLICATION_DATA or GNUTLS_E_WARNING_ALERT_RECEIVED
may be returned. Note that these are non fatal errors, only in the
specific case of a rehandshake. Their meaning is that the client
rejected the rehandshake request.
</p></blockquote></div>
<h4 class="subheading">gnutls_hex_decode</h4>
<p><a name="gnutls_005fhex_005fdecode"></a>
<div class="defun">
— Function: int <b>gnutls_hex_decode</b> (<var>const gnutls_datum_t * hex_data, char * result, size_t * result_size</var>)<var><a name="index-gnutls_005fhex_005fdecode-139"></a></var><br>
<blockquote><p><var>hex_data</var>: contain the encoded data
<p><var>result</var>: the place where decoded data will be copied
<p><var>result_size</var>: holds the size of the result
<p>This function will decode the given encoded data, using the hex encoding
used by PSK password files.
<p>Note that hex_data should be null terminated.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not long enough,
or 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_hex_encode</h4>
<p><a name="gnutls_005fhex_005fencode"></a>
<div class="defun">
— Function: int <b>gnutls_hex_encode</b> (<var>const gnutls_datum_t * data, char * result, size_t * result_size</var>)<var><a name="index-gnutls_005fhex_005fencode-140"></a></var><br>
<blockquote><p><var>data</var>: contain the raw data
<p><var>result</var>: the place where hex data will be copied
<p><var>result_size</var>: holds the size of the result
<p>This function will convert the given data to printable data, using the hex
encoding, as used in the PSK password files.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not long enough,
or 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_init</h4>
<p><a name="gnutls_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_init</b> (<var>gnutls_session_t * session, gnutls_connection_end_t con_end</var>)<var><a name="index-gnutls_005finit-141"></a></var><br>
<blockquote><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
<p><var>con_end</var>: is used to indicate if this session is to be used for server or
client. Can be one of GNUTLS_CLIENT and GNUTLS_SERVER.
<p>This function initializes the current session to null. Every session
must be initialized before use, so internal structures can be allocated.
This function allocates structures which can only be free'd
by calling <code>gnutls_deinit()</code>. Returns zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_kx_get_name</h4>
<p><a name="gnutls_005fkx_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_kx_get_name</b> (<var>gnutls_kx_algorithm_t algorithm</var>)<var><a name="index-gnutls_005fkx_005fget_005fname-142"></a></var><br>
<blockquote><p><var>algorithm</var>: is a key exchange algorithm
<p>Returns a pointer to a string that contains the name
of the specified key exchange algorithm or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_kx_get</h4>
<p><a name="gnutls_005fkx_005fget"></a>
<div class="defun">
— Function: gnutls_kx_algorithm_t <b>gnutls_kx_get</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fkx_005fget-143"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the key exchange algorithm used in the last handshake.
</p></blockquote></div>
<h4 class="subheading">gnutls_kx_set_priority</h4>
<p><a name="gnutls_005fkx_005fset_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_kx_set_priority</b> (<var>gnutls_session_t session, const int * list</var>)<var><a name="index-gnutls_005fkx_005fset_005fpriority-144"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>list</var>: is a 0 terminated list of gnutls_kx_algorithm_t elements.
<p>Sets the priority on the key exchange algorithms supported by gnutls.
Priority is higher for algorithms specified before others.
After specifying the algorithms you want, you must append a 0.
Note that the priority is set on the client. The server does
not use the algorithm's priority except for disabling
algorithms that were not specified.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_mac_get_name</h4>
<p><a name="gnutls_005fmac_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_mac_get_name</b> (<var>gnutls_mac_algorithm_t algorithm</var>)<var><a name="index-gnutls_005fmac_005fget_005fname-145"></a></var><br>
<blockquote><p><var>algorithm</var>: is a MAC algorithm
<p>Returns a string that contains the name
of the specified MAC algorithm or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_mac_get</h4>
<p><a name="gnutls_005fmac_005fget"></a>
<div class="defun">
— Function: gnutls_mac_algorithm_t <b>gnutls_mac_get</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fmac_005fget-146"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the currently used mac algorithm.
</p></blockquote></div>
<h4 class="subheading">gnutls_mac_set_priority</h4>
<p><a name="gnutls_005fmac_005fset_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_mac_set_priority</b> (<var>gnutls_session_t session, const int * list</var>)<var><a name="index-gnutls_005fmac_005fset_005fpriority-147"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>list</var>: is a 0 terminated list of gnutls_mac_algorithm_t elements.
<p>Sets the priority on the mac algorithms supported by gnutls.
Priority is higher for algorithms specified before others.
After specifying the algorithms you want, you must append a 0.
Note that the priority is set on the client. The server does
not use the algorithm's priority except for disabling
algorithms that were not specified.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_malloc</h4>
<p><a name="gnutls_005fmalloc"></a>
<div class="defun">
— Function: void * <b>gnutls_malloc</b> (<var>size_t s</var>)<var><a name="index-gnutls_005fmalloc-148"></a></var><br>
<blockquote>
<p>This function will allocate 's' bytes data, and
return a pointer to memory. This function is supposed
to be used by callbacks.
<p>The allocation function used is the one set by <code>gnutls_global_set_mem_functions()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_send_key</h4>
<p><a name="gnutls_005fopenpgp_005fsend_005fkey"></a>
<div class="defun">
— Function: void <b>gnutls_openpgp_send_key</b> (<var>gnutls_session_t session, gnutls_openpgp_key_status_t status</var>)<var><a name="index-gnutls_005fopenpgp_005fsend_005fkey-149"></a></var><br>
<blockquote><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
<p><var>status</var>: is one of OPENPGP_KEY, or OPENPGP_KEY_FINGERPRINT
<p>This function will order gnutls to send the key fingerprint instead
of the key in the initial handshake procedure. This should be used
with care and only when there is indication or knowledge that the
server can obtain the client's key.
</p></blockquote></div>
<h4 class="subheading">gnutls_pem_base64_decode_alloc</h4>
<p><a name="gnutls_005fpem_005fbase64_005fdecode_005falloc"></a>
<div class="defun">
— Function: int <b>gnutls_pem_base64_decode_alloc</b> (<var>const char * header, const gnutls_datum_t * b64_data, gnutls_datum_t * result</var>)<var><a name="index-gnutls_005fpem_005fbase64_005fdecode_005falloc-150"></a></var><br>
<blockquote><p><var>header</var>: The PEM header (eg. CERTIFICATE)
<p><var>b64_data</var>: contains the encoded data
<p><var>result</var>: the place where decoded data lie
<p>This function will decode the given encoded data. The decoded data
will be allocated, and stored into result.
If the header given is non null this function will search for
"——BEGIN header" and decode only this part. Otherwise it will decode the
first PEM packet found.
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p></blockquote></div>
<h4 class="subheading">gnutls_pem_base64_decode</h4>
<p><a name="gnutls_005fpem_005fbase64_005fdecode"></a>
<div class="defun">
— Function: int <b>gnutls_pem_base64_decode</b> (<var>const char * header, const gnutls_datum_t * b64_data, unsigned char * result, size_t * result_size</var>)<var><a name="index-gnutls_005fpem_005fbase64_005fdecode-151"></a></var><br>
<blockquote><p><var>header</var>: A null terminated string with the PEM header (eg. CERTIFICATE)
<p><var>b64_data</var>: contain the encoded data
<p><var>result</var>: the place where decoded data will be copied
<p><var>result_size</var>: holds the size of the result
<p>This function will decode the given encoded data. If the header given
is non null this function will search for "——BEGIN header" and decode
only this part. Otherwise it will decode the first PEM packet found.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not long enough,
or 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pem_base64_encode_alloc</h4>
<p><a name="gnutls_005fpem_005fbase64_005fencode_005falloc"></a>
<div class="defun">
— Function: int <b>gnutls_pem_base64_encode_alloc</b> (<var>const char * msg, const gnutls_datum_t * data, gnutls_datum_t * result</var>)<var><a name="index-gnutls_005fpem_005fbase64_005fencode_005falloc-152"></a></var><br>
<blockquote><p><var>msg</var>: is a message to be put in the encoded header
<p><var>data</var>: contains the raw data
<p><var>result</var>: will hold the newly allocated encoded data
<p>This function will convert the given data to printable data, using the base64
encoding. This is the encoding used in PEM messages. This function will
allocate the required memory to hold the encoded data.
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p></blockquote></div>
<h4 class="subheading">gnutls_pem_base64_encode</h4>
<p><a name="gnutls_005fpem_005fbase64_005fencode"></a>
<div class="defun">
— Function: int <b>gnutls_pem_base64_encode</b> (<var>const char * msg, const gnutls_datum_t * data, char * result, size_t * result_size</var>)<var><a name="index-gnutls_005fpem_005fbase64_005fencode-153"></a></var><br>
<blockquote><p><var>msg</var>: is a message to be put in the header
<p><var>data</var>: contain the raw data
<p><var>result</var>: the place where base64 data will be copied
<p><var>result_size</var>: holds the size of the result
<p>This function will convert the given data to printable data, using the base64
encoding. This is the encoding used in PEM messages. If the provided
buffer is not long enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
<p>The output string will be null terminated, although the size will not include
the terminating null.
</p></blockquote></div>
<h4 class="subheading">gnutls_perror</h4>
<p><a name="gnutls_005fperror"></a>
<div class="defun">
— Function: void <b>gnutls_perror</b> (<var>int error</var>)<var><a name="index-gnutls_005fperror-154"></a></var><br>
<blockquote><p><var>error</var>: is an error returned by a gnutls function. Error is always a negative value.
<p>This function is like <code>perror()</code>. The only difference is that it accepts an
error number returned by a gnutls function.
</p></blockquote></div>
<h4 class="subheading">gnutls_pk_algorithm_get_name</h4>
<p><a name="gnutls_005fpk_005falgorithm_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_pk_algorithm_get_name</b> (<var>gnutls_pk_algorithm_t algorithm</var>)<var><a name="index-gnutls_005fpk_005falgorithm_005fget_005fname-155"></a></var><br>
<blockquote><p><var>algorithm</var>: is a pk algorithm
<p>Returns a string that contains the name
of the specified public key algorithm or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_prf_raw</h4>
<p><a name="gnutls_005fprf_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_prf_raw</b> (<var>gnutls_session_t session, size_t label_size, const char * label, size_t seed_size, const char * seed, size_t outsize, char * out</var>)<var><a name="index-gnutls_005fprf_005fraw-156"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>label_size</var>: length of the <code>label</code> variable.
<p><var>label</var>: label used in PRF computation, typically a short string.
<p><var>seed_size</var>: length of the <code>seed</code> variable.
<p><var>seed</var>: optional extra data to seed the PRF with.
<p><var>outsize</var>: size of pre-allocated output buffer to hold the output.
<p><var>out</var>: pre-allocate buffer to hold the generated data.
<p>Apply the TLS Pseudo-Random-Function (PRF) using the master secret
on some data.
<p>The <code>label</code> variable usually contain a string denoting the purpose
for the generated data. The <code>seed</code> usually contain data such as the
client and server random, perhaps together with some additional
data that is added to guarantee uniqueness of the output for a
particular purpose.
<p>Because the output is not guaranteed to be unique for a particular
session unless <code>seed</code> include the client random and server random
fields (the PRF would output the same data on another connection
resumed from the first one), it is not recommended to use this
function directly. The <code>gnutls_prf()</code> function seed the PRF with the
client and server random fields directly, and is recommended if you
want to generate pseudo random data unique for each session.
<p><strong>Return value:</strong> Return 0 on success, or an error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_prf</h4>
<p><a name="gnutls_005fprf"></a>
<div class="defun">
— Function: int <b>gnutls_prf</b> (<var>gnutls_session_t session, size_t label_size, const char * label, int server_random_first, size_t extra_size, const char * extra, size_t outsize, char * out</var>)<var><a name="index-gnutls_005fprf-157"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>label_size</var>: length of the <code>label</code> variable.
<p><var>label</var>: label used in PRF computation, typically a short string.
<p><var>server_random_first</var>: non-0 if server random field should be first in seed
<p><var>extra_size</var>: length of the <code>extra</code> variable.
<p><var>extra</var>: optional extra data to seed the PRF with.
<p><var>outsize</var>: size of pre-allocated output buffer to hold the output.
<p><var>out</var>: pre-allocate buffer to hold the generated data.
<p>Apply the TLS Pseudo-Random-Function (PRF) using the master secret
on some data, seeded with the client and server random fields.
<p>The <code>label</code> variable usually contain a string denoting the purpose
for the generated data. The <code>server_random_first</code> indicate whether
the client random field or the server random field should be first
in the seed. Non-0 indicate that the server random field is first,
0 that the client random field is first.
<p>The <code>extra</code> variable can be used to add more data to the seed, after
the random variables. It can be used to tie make sure the
generated output is strongly connected to some additional data
(e.g., a string used in user authentication).
<p>The output is placed in *<code>OUT</code>, which must be pre-allocated.
<p><strong>Return value:</strong> Return 0 on success, or an error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_protocol_get_name</h4>
<p><a name="gnutls_005fprotocol_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_protocol_get_name</b> (<var>gnutls_protocol_t version</var>)<var><a name="index-gnutls_005fprotocol_005fget_005fname-158"></a></var><br>
<blockquote><p><var>version</var>: is a (gnutls) version number
<p>Returns a string that contains the name
of the specified TLS version or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_protocol_get_version</h4>
<p><a name="gnutls_005fprotocol_005fget_005fversion"></a>
<div class="defun">
— Function: gnutls_protocol_t <b>gnutls_protocol_get_version</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fprotocol_005fget_005fversion-159"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns the version of the currently used protocol.
</p></blockquote></div>
<h4 class="subheading">gnutls_protocol_set_priority</h4>
<p><a name="gnutls_005fprotocol_005fset_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_protocol_set_priority</b> (<var>gnutls_session_t session, const int * list</var>)<var><a name="index-gnutls_005fprotocol_005fset_005fpriority-160"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>list</var>: is a 0 terminated list of gnutls_protocol_t elements.
<p>Sets the priority on the protocol versions supported by gnutls.
This function actually enables or disables protocols. Newer protocol
versions always have highest priority.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_allocate_client_credentials</h4>
<p><a name="gnutls_005fpsk_005fallocate_005fclient_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_psk_allocate_client_credentials</b> (<var>gnutls_psk_client_credentials_t * sc</var>)<var><a name="index-gnutls_005fpsk_005fallocate_005fclient_005fcredentials-161"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_psk_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_allocate_server_credentials</h4>
<p><a name="gnutls_005fpsk_005fallocate_005fserver_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_psk_allocate_server_credentials</b> (<var>gnutls_psk_server_credentials_t * sc</var>)<var><a name="index-gnutls_005fpsk_005fallocate_005fserver_005fcredentials-162"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_psk_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_free_client_credentials</h4>
<p><a name="gnutls_005fpsk_005ffree_005fclient_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_psk_free_client_credentials</b> (<var>gnutls_psk_client_credentials_t sc</var>)<var><a name="index-gnutls_005fpsk_005ffree_005fclient_005fcredentials-163"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_psk_client_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_free_server_credentials</h4>
<p><a name="gnutls_005fpsk_005ffree_005fserver_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_psk_free_server_credentials</b> (<var>gnutls_psk_server_credentials_t sc</var>)<var><a name="index-gnutls_005fpsk_005ffree_005fserver_005fcredentials-164"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_psk_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_server_get_username</h4>
<p><a name="gnutls_005fpsk_005fserver_005fget_005fusername"></a>
<div class="defun">
— Function: const char * <b>gnutls_psk_server_get_username</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fpsk_005fserver_005fget_005fusername-165"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the username of the peer. This should only be
called in case of PSK authentication and in case of a server.
Returns NULL in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_client_credentials_function</h4>
<p><a name="gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_psk_set_client_credentials_function</b> (<var>gnutls_psk_client_credentials_t cred, gnutls_psk_client_credentials_function * func</var>)<var><a name="index-gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction-166"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
<p><var>func</var>: is the callback function
<p>This function can be used to set a callback to retrieve the username and
password for client PSK authentication.
The callback's function form is:
int (*callback)(gnutls_session_t, char** username,
gnutls_datum* key);
<p>The <code>username</code> and <code>key</code> must be allocated using <code>gnutls_malloc()</code>.
<code>username</code> should be ASCII strings or UTF-8 strings
prepared using the "SASLprep" profile of "stringprep".
<p>The callback function will be called once per handshake.
<p>The callback function should return 0 on success.
-1 indicates an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_client_credentials</h4>
<p><a name="gnutls_005fpsk_005fset_005fclient_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_psk_set_client_credentials</b> (<var>gnutls_psk_client_credentials_t res, const char * username, const gnutls_datum * key, unsigned int flags</var>)<var><a name="index-gnutls_005fpsk_005fset_005fclient_005fcredentials-167"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_psk_client_credentials_t</code> structure.
<p><var>username</var>: is the user's zero-terminated userid
<p><var>key</var>: is the user's key
<p>This function sets the username and password, in a
gnutls_psk_client_credentials_t structure. Those will be used in
PSK authentication. <code>username</code> should be an ASCII
string or UTF-8 strings prepared using the "SASLprep" profile of
"stringprep". The key can be either in raw byte format or in Hex
(not with the '0x' prefix).
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_params_function</h4>
<p><a name="gnutls_005fpsk_005fset_005fparams_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_psk_set_params_function</b> (<var>gnutls_psk_server_credentials_t res, gnutls_params_function * func</var>)<var><a name="index-gnutls_005fpsk_005fset_005fparams_005ffunction-168"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_psk_server_credentials_t structure
<p><var>func</var>: is the function to be called
<p>This function will set a callback in order for the server to get the
diffie hellman or RSA parameters for psk authentication. The callback
should return zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_server_credentials_file</h4>
<p><a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_psk_set_server_credentials_file</b> (<var>gnutls_psk_server_credentials_t res, const char * password_file</var>)<var><a name="index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile-169"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_psk_server_credentials_t</code> structure.
<p><var>password_file</var>: is the PSK password file (passwd.psk)
<p>This function sets the password file, in a gnutls_psk_server_credentials_t structure.
This password file holds usernames and keys and will be used for PSK authentication.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_server_credentials_function</h4>
<p><a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_psk_set_server_credentials_function</b> (<var>gnutls_psk_server_credentials_t cred, gnutls_psk_server_credentials_function * func</var>)<var><a name="index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction-170"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
<p><var>func</var>: is the callback function
<p>This function can be used to set a callback to retrieve the user's PSK credentials.
The callback's function form is:
int (*callback)(gnutls_session_t, const char* username,
gnutls_datum_t* key);
<p><code>username</code> contains the actual username.
The <code>key</code> must be filled in using the <code>gnutls_malloc()</code>.
<p>In case the callback returned a negative number then gnutls will
assume that the username does not exist.
<p>The callback function will only be called once per handshake.
The callback function should return 0 on success, while
-1 indicates an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_server_dh_params</h4>
<p><a name="gnutls_005fpsk_005fset_005fserver_005fdh_005fparams"></a>
<div class="defun">
— Function: void <b>gnutls_psk_set_server_dh_params</b> (<var>gnutls_psk_server_credentials_t res, gnutls_dh_params_t dh_params</var>)<var><a name="index-gnutls_005fpsk_005fset_005fserver_005fdh_005fparams-171"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_psk_server_credentials_t structure
<p><var>dh_params</var>: is a structure that holds diffie hellman parameters.
<p>This function will set the diffie hellman parameters for an anonymous
server to use. These parameters will be used in Diffie Hellman with PSK
cipher suites.
</p></blockquote></div>
<h4 class="subheading">gnutls_psk_set_server_params_function</h4>
<p><a name="gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_psk_set_server_params_function</b> (<var>gnutls_psk_server_credentials_t res, gnutls_params_function * func</var>)<var><a name="index-gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction-172"></a></var><br>
<blockquote><p><var>res</var>: is a gnutls_certificate_credentials_t structure
<p><var>func</var>: is the function to be called
<p>This function will set a callback in order for the server to get the
diffie hellman parameters for PSK authentication. The callback should
return zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_record_check_pending</h4>
<p><a name="gnutls_005frecord_005fcheck_005fpending"></a>
<div class="defun">
— Function: size_t <b>gnutls_record_check_pending</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005frecord_005fcheck_005fpending-173"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function checks if there are any data to receive
in the gnutls buffers. Returns the size of that data or 0.
Notice that you may also use <code>select()</code> to check for data in
a TCP connection, instead of this function.
(gnutls leaves some data in the tcp buffer in order for select
to work).
</p></blockquote></div>
<h4 class="subheading">gnutls_record_get_direction</h4>
<p><a name="gnutls_005frecord_005fget_005fdirection"></a>
<div class="defun">
— Function: int <b>gnutls_record_get_direction</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005frecord_005fget_005fdirection-174"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function provides information about the internals of the record
protocol and is only useful if a prior gnutls function call (e.g.
<code>gnutls_handshake()</code>) was interrupted for some reason, that is, if a function
returned GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN. In such a case, you might
want to call <code>select()</code> or <code>poll()</code> before calling the interrupted gnutls
function again. To tell you whether a file descriptor should be selected
for either reading or writing, <code>gnutls_record_get_direction()</code> returns 0 if
the interrupted function was trying to read data, and 1 if it was trying to
write data.
</p></blockquote></div>
<h4 class="subheading">gnutls_record_get_max_size</h4>
<p><a name="gnutls_005frecord_005fget_005fmax_005fsize"></a>
<div class="defun">
— Function: size_t <b>gnutls_record_get_max_size</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005frecord_005fget_005fmax_005fsize-175"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function returns the maximum record packet size in this connection.
The maximum record size is negotiated by the client after the
first handshake message.
</p></blockquote></div>
<h4 class="subheading">gnutls_record_recv</h4>
<p><a name="gnutls_005frecord_005frecv"></a>
<div class="defun">
— Function: ssize_t <b>gnutls_record_recv</b> (<var>gnutls_session_t session, void * data, size_t sizeofdata</var>)<var><a name="index-gnutls_005frecord_005frecv-176"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>data</var>: the buffer that the data will be read into
<p><var>sizeofdata</var>: the number of requested bytes
<p>This function has the similar semantics with <code>recv()</code>. The only
difference is that is accepts a GNUTLS session, and uses different
error codes.
<p>In the special case that a server requests a renegotiation, the
client may receive an error code of GNUTLS_E_REHANDSHAKE. This
message may be simply ignored, replied with an alert containing
NO_RENEGOTIATION, or replied with a new handshake, depending on
the client's will.
<p>If EINTR is returned by the internal push function (the default is
<code>code</code>{<code>recv()</code>}) then GNUTLS_E_INTERRUPTED will be returned. If
GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN is returned, you must call
this function again, with the same parameters; alternatively you
could provide a NULL pointer for data, and 0 for
size. cf. <code>code</code>{<code>gnutls_record_get_direction()</code>}.
<p>A server may also receive GNUTLS_E_REHANDSHAKE when a client has
initiated a handshake. In that case the server can only initiate a
handshake or terminate the connection.
<p>Returns the number of bytes received and zero on EOF. A negative
error code is returned in case of an error. The number of bytes
received might be less than <code>code</code>{count}.
</p></blockquote></div>
<h4 class="subheading">gnutls_record_send</h4>
<p><a name="gnutls_005frecord_005fsend"></a>
<div class="defun">
— Function: ssize_t <b>gnutls_record_send</b> (<var>gnutls_session_t session, const void * data, size_t sizeofdata</var>)<var><a name="index-gnutls_005frecord_005fsend-177"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>data</var>: contains the data to send
<p><var>sizeofdata</var>: is the length of the data
<p>This function has the similar semantics with <code>send()</code>. The only
difference is that is accepts a GNUTLS session, and uses different
error codes.
<p>Note that if the send buffer is full, <code>send()</code> will block this
function. See the <code>send()</code> documentation for full information. You
can replace the default push function by using
<code>gnutls_transport_set_ptr2()</code> with a call to <code>send()</code> with a
MSG_DONTWAIT flag if blocking is a problem.
<p>If the EINTR is returned by the internal push function (the
default is <code>send()</code>} then <code>GNUTLS_E_INTERRUPTED</code> will be returned. If
<code>GNUTLS_E_INTERRUPTED</code> or <code>GNUTLS_E_AGAIN</code> is returned, you must
call this function again, with the same parameters; alternatively
you could provide a <code>NULL</code> pointer for data, and 0 for
size. cf. <code>gnutls_record_get_direction()</code>.
<p>Returns the number of bytes sent, or a negative error code. The
number of bytes sent might be less than <code>sizeofdata</code>. The maximum
number of bytes this function can send in a single call depends on
the negotiated maximum record size.
</p></blockquote></div>
<h4 class="subheading">gnutls_record_set_max_size</h4>
<p><a name="gnutls_005frecord_005fset_005fmax_005fsize"></a>
<div class="defun">
— Function: ssize_t <b>gnutls_record_set_max_size</b> (<var>gnutls_session_t session, size_t size</var>)<var><a name="index-gnutls_005frecord_005fset_005fmax_005fsize-178"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>size</var>: is the new size
<p>This function sets the maximum record packet size in this connection.
This property can only be set to clients. The server may
choose not to accept the requested size.
<p>Acceptable values are 512(=2^9), 1024(=2^10), 2048(=2^11) and 4096(=2^12).
Returns 0 on success. The requested record size does
get in effect immediately only while sending data. The receive
part will take effect after a successful handshake.
<p>This function uses a TLS extension called 'max record size'.
Not all TLS implementations use or even understand this extension.
</p></blockquote></div>
<h4 class="subheading">gnutls_rehandshake</h4>
<p><a name="gnutls_005frehandshake"></a>
<div class="defun">
— Function: int <b>gnutls_rehandshake</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005frehandshake-179"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function will renegotiate security parameters with the
client. This should only be called in case of a server.
<p>This message informs the peer that we want to renegotiate
parameters (perform a handshake).
<p>If this function succeeds (returns 0), you must call
the <code>gnutls_handshake()</code> function in order to negotiate
the new parameters.
<p>If the client does not wish to renegotiate parameters he
will should with an alert message, thus the return code will be
GNUTLS_E_WARNING_ALERT_RECEIVED and the alert will be
GNUTLS_A_NO_RENEGOTIATION. A client may also choose to ignore
this message.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_export_get_modulus_bits</h4>
<p><a name="gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_export_get_modulus_bits</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits-180"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the bits used in the last RSA-EXPORT key exchange
with the peer.
Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_export_get_pubkey</h4>
<p><a name="gnutls_005frsa_005fexport_005fget_005fpubkey"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_export_get_pubkey</b> (<var>gnutls_session_t session, gnutls_datum_t * exponent, gnutls_datum_t * modulus</var>)<var><a name="index-gnutls_005frsa_005fexport_005fget_005fpubkey-181"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p><var>exponent</var>: will hold the exponent.
<p><var>modulus</var>: will hold the modulus.
<p>This function will return the peer's public key exponent and
modulus used in the last RSA-EXPORT authentication. The output
parameters must be freed with <code>gnutls_free()</code>.
<p>Returns a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_cpy</h4>
<p><a name="gnutls_005frsa_005fparams_005fcpy"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_cpy</b> (<var>gnutls_rsa_params_t dst, gnutls_rsa_params_t src</var>)<var><a name="index-gnutls_005frsa_005fparams_005fcpy-182"></a></var><br>
<blockquote><p><var>dst</var>: Is the destination structure, which should be initialized.
<p><var>src</var>: Is the source structure
<p>This function will copy the RSA parameters structure from source
to destination.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_deinit</h4>
<p><a name="gnutls_005frsa_005fparams_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_rsa_params_deinit</b> (<var>gnutls_rsa_params_t rsa_params</var>)<var><a name="index-gnutls_005frsa_005fparams_005fdeinit-183"></a></var><br>
<blockquote><p><var>rsa_params</var>: Is a structure that holds the parameters
<p>This function will deinitialize the RSA parameters structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_export_pkcs1</h4>
<p><a name="gnutls_005frsa_005fparams_005fexport_005fpkcs1"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_export_pkcs1</b> (<var>gnutls_rsa_params_t params, gnutls_x509_crt_fmt_t format, unsigned char * params_data, size_t * params_data_size</var>)<var><a name="index-gnutls_005frsa_005fparams_005fexport_005fpkcs1-184"></a></var><br>
<blockquote><p><var>params</var>: Holds the RSA parameters
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>params_data</var>: will contain a PKCS1 RSAPublicKey structure PEM or DER encoded
<p><var>params_data_size</var>: holds the size of params_data (and will be replaced by the actual size of parameters)
<p>This function will export the given RSA parameters to a PKCS1
RSAPublicKey structure. If the buffer provided is not long enough to
hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN RSA PRIVATE KEY".
<p>In case of failure a negative value will be returned, and
0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_export_raw</h4>
<p><a name="gnutls_005frsa_005fparams_005fexport_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_export_raw</b> (<var>gnutls_rsa_params_t params, gnutls_datum_t * m, gnutls_datum_t * e, gnutls_datum_t * d, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * u, unsigned int * bits</var>)<var><a name="index-gnutls_005frsa_005fparams_005fexport_005fraw-185"></a></var><br>
<blockquote><p><var>params</var>: a structure that holds the rsa parameters
<p><var>m</var>: will hold the modulus
<p><var>e</var>: will hold the public exponent
<p><var>d</var>: will hold the private exponent
<p><var>p</var>: will hold the first prime (p)
<p><var>q</var>: will hold the second prime (q)
<p><var>u</var>: will hold the coefficient
<p><var>bits</var>: if non null will hold the prime's number of bits
<p>This function will export the RSA parameters found in the given
structure. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_generate2</h4>
<p><a name="gnutls_005frsa_005fparams_005fgenerate2"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_generate2</b> (<var>gnutls_rsa_params_t params, unsigned int bits</var>)<var><a name="index-gnutls_005frsa_005fparams_005fgenerate2-186"></a></var><br>
<blockquote><p><var>params</var>: The structure where the parameters will be stored
<p><var>bits</var>: is the prime's number of bits
<p>This function will generate new temporary RSA parameters for use in
RSA-EXPORT ciphersuites. This function is normally slow.
<p>Note that if the parameters are to be used in export cipher suites the
bits value should be 512 or less.
Also note that the generation of new RSA parameters is only useful
to servers. Clients use the parameters sent by the server, thus it's
no use calling this in client side.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_import_pkcs1</h4>
<p><a name="gnutls_005frsa_005fparams_005fimport_005fpkcs1"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_import_pkcs1</b> (<var>gnutls_rsa_params_t params, const gnutls_datum_t * pkcs1_params, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005frsa_005fparams_005fimport_005fpkcs1-187"></a></var><br>
<blockquote><p><var>params</var>: A structure where the parameters will be copied to
<p><var>pkcs1_params</var>: should contain a PKCS1 RSAPublicKey structure PEM or DER encoded
<p><var>format</var>: the format of params. PEM or DER.
<p>This function will extract the RSAPublicKey found in a PKCS1 formatted
structure.
<p>If the structure is PEM encoded, it should have a header
of "BEGIN RSA PRIVATE KEY".
<p>In case of failure a negative value will be returned, and
0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_import_raw</h4>
<p><a name="gnutls_005frsa_005fparams_005fimport_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_import_raw</b> (<var>gnutls_rsa_params_t rsa_params, const gnutls_datum_t * m, const gnutls_datum_t * e, const gnutls_datum_t * d, const gnutls_datum_t * p, const gnutls_datum_t * q, const gnutls_datum_t * u</var>)<var><a name="index-gnutls_005frsa_005fparams_005fimport_005fraw-188"></a></var><br>
<blockquote><p><var>rsa_params</var>: Is a structure will hold the parameters
<p><var>m</var>: holds the modulus
<p><var>e</var>: holds the public exponent
<p><var>d</var>: holds the private exponent
<p><var>p</var>: holds the first prime (p)
<p><var>q</var>: holds the second prime (q)
<p><var>u</var>: holds the coefficient
<p>This function will replace the parameters in the given structure.
The new parameters should be stored in the appropriate gnutls_datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_rsa_params_init</h4>
<p><a name="gnutls_005frsa_005fparams_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_rsa_params_init</b> (<var>gnutls_rsa_params_t * rsa_params</var>)<var><a name="index-gnutls_005frsa_005fparams_005finit-189"></a></var><br>
<blockquote><p><var>rsa_params</var>: Is a structure that will hold the parameters
<p>This function will initialize the temporary RSA parameters structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_server_name_get</h4>
<p><a name="gnutls_005fserver_005fname_005fget"></a>
<div class="defun">
— Function: int <b>gnutls_server_name_get</b> (<var>gnutls_session_t session, void * data, size_t * data_length, unsigned int * type, unsigned int indx</var>)<var><a name="index-gnutls_005fserver_005fname_005fget-190"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>data</var>: will hold the data
<p><var>data_length</var>: will hold the data length. Must hold the maximum size of data.
<p><var>type</var>: will hold the server name indicator type
<p><var>indx</var>: is the index of the server_name
<p>This function will allow you to get the name indication (if any),
a client has sent. The name indication may be any of the enumeration
gnutls_server_name_type_t.
<p>If <code>type</code> is GNUTLS_NAME_DNS, then this function is to be used by servers
that support virtual hosting, and the data will be a null terminated UTF-8 string.
<p>If <code>data</code> has not enough size to hold the server name GNUTLS_E_SHORT_MEMORY_BUFFER
is returned, and <code>data_length</code> will hold the required size.
<p><code>index</code> is used to retrieve more than one server names (if sent by the client).
The first server name has an index of 0, the second 1 and so on. If no name with the given
index exists GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_server_name_set</h4>
<p><a name="gnutls_005fserver_005fname_005fset"></a>
<div class="defun">
— Function: int <b>gnutls_server_name_set</b> (<var>gnutls_session_t session, gnutls_server_name_type_t type, const void * name, size_t name_length</var>)<var><a name="index-gnutls_005fserver_005fname_005fset-191"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>type</var>: specifies the indicator type
<p><var>name</var>: is a string that contains the server name.
<p><var>name_length</var>: holds the length of name
<p>This function is to be used by clients that want to inform
(via a TLS extension mechanism) the server of the name they
connected to. This should be used by clients that connect
to servers that do virtual hosting.
<p>The value of <code>name</code> depends on the <code>ind</code> type. In case of GNUTLS_NAME_DNS,
an ASCII or UTF-8 null terminated string, without the trailing dot, is expected.
IPv4 or IPv6 addresses are not permitted.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_client_random</h4>
<p><a name="gnutls_005fsession_005fget_005fclient_005frandom"></a>
<div class="defun">
— Function: const void * <b>gnutls_session_get_client_random</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fsession_005fget_005fclient_005frandom-192"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Return a pointer to the 32-byte client random field used in the
session. The pointer must not be modified or deallocated.
<p>If a client random value has not yet been established, the output
will be garbage; in particular, a <code>NULL</code> return value should not be
expected.
<p><strong>Return value:</strong> pointer to client random.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_data2</h4>
<p><a name="gnutls_005fsession_005fget_005fdata2"></a>
<div class="defun">
— Function: int <b>gnutls_session_get_data2</b> (<var>gnutls_session_t session, gnutls_datum * data</var>)<var><a name="index-gnutls_005fsession_005fget_005fdata2-193"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Returns all session parameters, in order to support resuming.
The client should call this, and keep the returned session, if he wants to
resume that current version later by calling <code>gnutls_session_set_data()</code>
This function must be called after a successful handshake. The returned
datum must be freed with <code>gnutls_free()</code>.
<p>Resuming sessions is really useful and speedups connections after a succesful one.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_data</h4>
<p><a name="gnutls_005fsession_005fget_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_session_get_data</b> (<var>gnutls_session_t session, void * session_data, size_t * session_data_size</var>)<var><a name="index-gnutls_005fsession_005fget_005fdata-194"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>session_data</var>: is a pointer to space to hold the session.
<p><var>session_data_size</var>: is the session_data's size, or it will be set by the function.
<p>Returns all session parameters, in order to support resuming.
The client should call this, and keep the returned session, if he wants to
resume that current version later by calling <code>gnutls_session_set_data()</code>
This function must be called after a successful handshake.
<p>Resuming sessions is really useful and speedups connections after a succesful one.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_id</h4>
<p><a name="gnutls_005fsession_005fget_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_session_get_id</b> (<var>gnutls_session_t session, void * session_id, size_t * session_id_size</var>)<var><a name="index-gnutls_005fsession_005fget_005fid-195"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>session_id</var>: is a pointer to space to hold the session id.
<p><var>session_id_size</var>: is the session id's size, or it will be set by the function.
<p>Returns the current session id. This can be used if you want to check if
the next session you tried to resume was actually resumed.
This is because resumed sessions have the same sessionID with the
original session.
<p>Session id is some data set by the server, that identify the current session.
In TLS 1.0 and SSL 3.0 session id is always less than 32 bytes.
<p>Returns zero on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_master_secret</h4>
<p><a name="gnutls_005fsession_005fget_005fmaster_005fsecret"></a>
<div class="defun">
— Function: const void * <b>gnutls_session_get_master_secret</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fsession_005fget_005fmaster_005fsecret-196"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Return a pointer to the 48-byte master secret in the session. The
pointer must not be modified or deallocated.
<p>If a master secret value has not yet been established, the output
will be garbage; in particular, a <code>NULL</code> return value should not be
expected.
<p>Consider using <code>gnutls_prf()</code> rather than extracting the master
secret and use it to derive further data.
<p><strong>Return value:</strong> pointer to master secret.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_ptr</h4>
<p><a name="gnutls_005fsession_005fget_005fptr"></a>
<div class="defun">
— Function: void * <b>gnutls_session_get_ptr</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fsession_005fget_005fptr-197"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function will return the user given pointer from the session structure.
This is the pointer set with <code>gnutls_session_set_ptr()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_get_server_random</h4>
<p><a name="gnutls_005fsession_005fget_005fserver_005frandom"></a>
<div class="defun">
— Function: const void * <b>gnutls_session_get_server_random</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fsession_005fget_005fserver_005frandom-198"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Return a pointer to the 32-byte server random field used in the
session. The pointer must not be modified or deallocated.
<p>If a server random value has not yet been established, the output
will be garbage; in particular, a <code>NULL</code> return value should not be
expected.
<p><strong>Return value:</strong> pointer to server random.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_is_resumed</h4>
<p><a name="gnutls_005fsession_005fis_005fresumed"></a>
<div class="defun">
— Function: int <b>gnutls_session_is_resumed</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fsession_005fis_005fresumed-199"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>This function will return non zero if this session is a resumed one,
or a zero if this is a new session.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_set_data</h4>
<p><a name="gnutls_005fsession_005fset_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_session_set_data</b> (<var>gnutls_session_t session, const void * session_data, size_t session_data_size</var>)<var><a name="index-gnutls_005fsession_005fset_005fdata-200"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>session_data</var>: is a pointer to space to hold the session.
<p><var>session_data_size</var>: is the session's size
<p>Sets all session parameters, in order to resume a previously established
session. The session data given must be the one returned by <code>gnutls_session_get_data()</code>.
This function should be called before <code>gnutls_handshake()</code>.
<p>Keep in mind that session resuming is advisory. The server may
choose not to resume the session, thus a full handshake will be
performed.
<p>Returns a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_session_set_ptr</h4>
<p><a name="gnutls_005fsession_005fset_005fptr"></a>
<div class="defun">
— Function: void <b>gnutls_session_set_ptr</b> (<var>gnutls_session_t session, void * ptr</var>)<var><a name="index-gnutls_005fsession_005fset_005fptr-201"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>ptr</var>: is the user pointer
<p>This function will set (associate) the user given pointer to the
session structure. This is pointer can be accessed with
<code>gnutls_session_get_ptr()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_set_default_export_priority</h4>
<p><a name="gnutls_005fset_005fdefault_005fexport_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_set_default_export_priority</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fset_005fdefault_005fexport_005fpriority-202"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Sets some default priority on the ciphers, key exchange methods, macs
and compression methods. This is to avoid using the gnutls_*<code>_priority()</code> functions, if
these defaults are ok. This function also includes weak algorithms.
The order is TLS1, SSL3 for protocols, RSA, DHE_DSS,
DHE_RSA, RSA_EXPORT for key exchange algorithms.
SHA, MD5, RIPEMD160 for MAC algorithms,
AES_256_CBC, AES_128_CBC,
and 3DES_CBC, ARCFOUR_128, ARCFOUR_40 for ciphers.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_set_default_priority</h4>
<p><a name="gnutls_005fset_005fdefault_005fpriority"></a>
<div class="defun">
— Function: int <b>gnutls_set_default_priority</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fset_005fdefault_005fpriority-203"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Sets some default priority on the ciphers, key exchange methods, macs
and compression methods. This is to avoid using the gnutls_*<code>_priority()</code> functions, if
these defaults are ok. You may override any of the following priorities by calling
the appropriate functions.
<p>The order is TLS1, SSL3 for protocols.
RSA, DHE_DSS, DHE_RSA for key exchange
algorithms. SHA, MD5 and RIPEMD160 for MAC algorithms.
AES_128_CBC, 3DES_CBC,
and ARCFOUR_128 for ciphers.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_sign_algorithm_get_name</h4>
<p><a name="gnutls_005fsign_005falgorithm_005fget_005fname"></a>
<div class="defun">
— Function: const char * <b>gnutls_sign_algorithm_get_name</b> (<var>gnutls_sign_algorithm_t sign</var>)<var><a name="index-gnutls_005fsign_005falgorithm_005fget_005fname-204"></a></var><br>
<blockquote><p>Returns a string that contains the name
of the specified sign algorithm or NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_allocate_client_credentials</h4>
<p><a name="gnutls_005fsrp_005fallocate_005fclient_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_srp_allocate_client_credentials</b> (<var>gnutls_srp_client_credentials_t * sc</var>)<var><a name="index-gnutls_005fsrp_005fallocate_005fclient_005fcredentials-205"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_srp_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_allocate_server_credentials</h4>
<p><a name="gnutls_005fsrp_005fallocate_005fserver_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_srp_allocate_server_credentials</b> (<var>gnutls_srp_server_credentials_t * sc</var>)<var><a name="index-gnutls_005fsrp_005fallocate_005fserver_005fcredentials-206"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_srp_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_base64_decode_alloc</h4>
<p><a name="gnutls_005fsrp_005fbase64_005fdecode_005falloc"></a>
<div class="defun">
— Function: int <b>gnutls_srp_base64_decode_alloc</b> (<var>const gnutls_datum_t * b64_data, gnutls_datum_t * result</var>)<var><a name="index-gnutls_005fsrp_005fbase64_005fdecode_005falloc-207"></a></var><br>
<blockquote><p><var>b64_data</var>: contains the encoded data
<p><var>result</var>: the place where decoded data lie
<p>This function will decode the given encoded data. The decoded data
will be allocated, and stored into result.
It will decode using the base64 algorithm found in libsrp.
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_base64_decode</h4>
<p><a name="gnutls_005fsrp_005fbase64_005fdecode"></a>
<div class="defun">
— Function: int <b>gnutls_srp_base64_decode</b> (<var>const gnutls_datum_t * b64_data, char * result, size_t * result_size</var>)<var><a name="index-gnutls_005fsrp_005fbase64_005fdecode-208"></a></var><br>
<blockquote><p><var>b64_data</var>: contain the encoded data
<p><var>result</var>: the place where decoded data will be copied
<p><var>result_size</var>: holds the size of the result
<p>This function will decode the given encoded data, using the base64 encoding
found in libsrp.
<p>Note that b64_data should be null terminated.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not long enough,
or 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_base64_encode_alloc</h4>
<p><a name="gnutls_005fsrp_005fbase64_005fencode_005falloc"></a>
<div class="defun">
— Function: int <b>gnutls_srp_base64_encode_alloc</b> (<var>const gnutls_datum_t * data, gnutls_datum_t * result</var>)<var><a name="index-gnutls_005fsrp_005fbase64_005fencode_005falloc-209"></a></var><br>
<blockquote><p><var>data</var>: contains the raw data
<p><var>result</var>: will hold the newly allocated encoded data
<p>This function will convert the given data to printable data, using the base64
encoding. This is the encoding used in SRP password files. This function will
allocate the required memory to hold the encoded data.
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_base64_encode</h4>
<p><a name="gnutls_005fsrp_005fbase64_005fencode"></a>
<div class="defun">
— Function: int <b>gnutls_srp_base64_encode</b> (<var>const gnutls_datum_t * data, char * result, size_t * result_size</var>)<var><a name="index-gnutls_005fsrp_005fbase64_005fencode-210"></a></var><br>
<blockquote><p><var>data</var>: contain the raw data
<p><var>result</var>: the place where base64 data will be copied
<p><var>result_size</var>: holds the size of the result
<p>This function will convert the given data to printable data, using the base64
encoding, as used in the libsrp. This is the encoding used in SRP password files.
If the provided buffer is not long enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_free_client_credentials</h4>
<p><a name="gnutls_005fsrp_005ffree_005fclient_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_srp_free_client_credentials</b> (<var>gnutls_srp_client_credentials_t sc</var>)<var><a name="index-gnutls_005fsrp_005ffree_005fclient_005fcredentials-211"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_srp_client_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_free_server_credentials</h4>
<p><a name="gnutls_005fsrp_005ffree_005fserver_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_srp_free_server_credentials</b> (<var>gnutls_srp_server_credentials_t sc</var>)<var><a name="index-gnutls_005fsrp_005ffree_005fserver_005fcredentials-212"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_srp_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_server_get_username</h4>
<p><a name="gnutls_005fsrp_005fserver_005fget_005fusername"></a>
<div class="defun">
— Function: const char * <b>gnutls_srp_server_get_username</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fsrp_005fserver_005fget_005fusername-213"></a></var><br>
<blockquote><p><var>session</var>: is a gnutls session
<p>This function will return the username of the peer. This should only be
called in case of SRP authentication and in case of a server.
Returns NULL in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_set_client_credentials_function</h4>
<p><a name="gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_srp_set_client_credentials_function</b> (<var>gnutls_srp_client_credentials_t cred, gnutls_srp_client_credentials_function * func</var>)<var><a name="index-gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction-214"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
<p><var>func</var>: is the callback function
<p>This function can be used to set a callback to retrieve the username and
password for client SRP authentication.
The callback's function form is:
int (*callback)(gnutls_session_t, unsigned int times, char** username,
char** password);
<p>The <code>username</code> and <code>password</code> must be allocated using <code>gnutls_malloc()</code>.
<code>times</code> will be 0 the first time called, and 1 the second.
<code>username</code> and <code>password</code> should be ASCII strings or UTF-8 strings
prepared using the "SASLprep" profile of "stringprep".
<p>The callback function will be called once or twice per handshake.
The first time called, is before the ciphersuite is negotiated.
At that time if the callback returns a negative error code,
the callback will be called again if SRP has been
negotiated. This uses a special TLS-SRP idiom in order to avoid
asking the user for SRP password and username if the server does
not support SRP.
<p>The callback should not return a negative error code the second
time called, since the handshake procedure will be aborted.
<p>The callback function should return 0 on success.
-1 indicates an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_set_client_credentials</h4>
<p><a name="gnutls_005fsrp_005fset_005fclient_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_srp_set_client_credentials</b> (<var>gnutls_srp_client_credentials_t res, const char * username, const char * password</var>)<var><a name="index-gnutls_005fsrp_005fset_005fclient_005fcredentials-215"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_srp_client_credentials_t</code> structure.
<p><var>username</var>: is the user's userid
<p><var>password</var>: is the user's password
<p>This function sets the username and password, in a gnutls_srp_client_credentials_t structure.
Those will be used in SRP authentication. <code>username</code> and <code>password</code> should be ASCII
strings or UTF-8 strings prepared using the "SASLprep" profile of "stringprep".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_set_server_credentials_file</h4>
<p><a name="gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_srp_set_server_credentials_file</b> (<var>gnutls_srp_server_credentials_t res, const char * password_file, const char * password_conf_file</var>)<var><a name="index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile-216"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_srp_server_credentials_t</code> structure.
<p><var>password_file</var>: is the SRP password file (tpasswd)
<p><var>password_conf_file</var>: is the SRP password conf file (tpasswd.conf)
<p>This function sets the password files, in a gnutls_srp_server_credentials_t structure.
Those password files hold usernames and verifiers and will be used for SRP authentication.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_set_server_credentials_function</h4>
<p><a name="gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_srp_set_server_credentials_function</b> (<var>gnutls_srp_server_credentials_t cred, gnutls_srp_server_credentials_function * func</var>)<var><a name="index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction-217"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
<p><var>func</var>: is the callback function
<p>This function can be used to set a callback to retrieve the user's SRP credentials.
The callback's function form is:
int (*callback)(gnutls_session_t, const char* username,
gnutls_datum_t* salt, gnutls_datum_t *verifier, gnutls_datum_t* g,
gnutls_datum_t* n);
<p><code>username</code> contains the actual username.
The <code>salt</code>, <code>verifier</code>, <code>generator</code> and <code>prime</code> must be filled
in using the <code>gnutls_malloc()</code>. For convenience <code>prime</code> and <code>generator</code>
may also be one of the static parameters defined in extra.h.
<p>In case the callback returned a negative number then gnutls will
assume that the username does not exist.
<p>In order to prevent attackers from guessing valid usernames,
if a user does not exist, g and n values should be filled in
using a random user's parameters. In that case the callback must
return the special value (1).
<p>The callback function will only be called once per handshake.
The callback function should return 0 on success, while
-1 indicates an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_srp_verifier</h4>
<p><a name="gnutls_005fsrp_005fverifier"></a>
<div class="defun">
— Function: int <b>gnutls_srp_verifier</b> (<var>const char * username, const char * password, const gnutls_datum_t * salt, const gnutls_datum_t * generator, const gnutls_datum_t * prime, gnutls_datum_t * res</var>)<var><a name="index-gnutls_005fsrp_005fverifier-218"></a></var><br>
<blockquote><p><var>username</var>: is the user's name
<p><var>password</var>: is the user's password
<p><var>salt</var>: should be some randomly generated bytes
<p><var>generator</var>: is the generator of the group
<p><var>prime</var>: is the group's prime
<p><var>res</var>: where the verifier will be stored.
<p>This function will create an SRP verifier, as specified in RFC2945.
The <code>prime</code> and <code>generator</code> should be one of the static parameters defined
in gnutls/extra.h or may be generated using the GCRYPT functions
<code>gcry_prime_generate()</code> and <code>gcry_prime_group_generator()</code>.
The verifier will be allocated with <code>malloc</code> and will be stored in <code>res</code> using
binary format.
</p></blockquote></div>
<h4 class="subheading">gnutls_strerror</h4>
<p><a name="gnutls_005fstrerror"></a>
<div class="defun">
— Function: const char * <b>gnutls_strerror</b> (<var>int error</var>)<var><a name="index-gnutls_005fstrerror-219"></a></var><br>
<blockquote><p><var>error</var>: is an error returned by a gnutls function. Error is always a negative value.
<p>This function is similar to <code>strerror()</code>. Differences: it accepts an error
number returned by a gnutls function; In case of an unknown error
a descriptive string is sent instead of NULL.
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_get_ptr2</h4>
<p><a name="gnutls_005ftransport_005fget_005fptr2"></a>
<div class="defun">
— Function: void <b>gnutls_transport_get_ptr2</b> (<var>gnutls_session_t session, gnutls_transport_ptr_t * recv_ptr, gnutls_transport_ptr_t * send_ptr</var>)<var><a name="index-gnutls_005ftransport_005fget_005fptr2-220"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>recv_ptr</var>: will hold the value for the pull function
<p><var>send_ptr</var>: will hold the value for the push function
<p>Used to get the arguments of the transport functions (like PUSH and
PULL). These should have been set using <code>gnutls_transport_set_ptr2()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_get_ptr</h4>
<p><a name="gnutls_005ftransport_005fget_005fptr"></a>
<div class="defun">
— Function: gnutls_transport_ptr_t <b>gnutls_transport_get_ptr</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005ftransport_005fget_005fptr-221"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Used to get the first argument of the transport function (like PUSH and
PULL). This must have been set using <code>gnutls_transport_set_ptr()</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_set_lowat</h4>
<p><a name="gnutls_005ftransport_005fset_005flowat"></a>
<div class="defun">
— Function: void <b>gnutls_transport_set_lowat</b> (<var>gnutls_session_t session, int num</var>)<var><a name="index-gnutls_005ftransport_005fset_005flowat-222"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>num</var>: is the low water value.
<p>Used to set the lowat value in order for select to check
if there are pending data to socket buffer. Used only
if you have changed the default low water value (default is 1).
Normally you will not need that function.
This function is only useful if using berkeley style sockets.
Otherwise it must be called and set lowat to zero.
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_set_ptr2</h4>
<p><a name="gnutls_005ftransport_005fset_005fptr2"></a>
<div class="defun">
— Function: void <b>gnutls_transport_set_ptr2</b> (<var>gnutls_session_t session, gnutls_transport_ptr_t recv_ptr, gnutls_transport_ptr_t send_ptr</var>)<var><a name="index-gnutls_005ftransport_005fset_005fptr2-223"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>recv_ptr</var>: is the value for the pull function
<p><var>send_ptr</var>: is the value for the push function
<p>Used to set the first argument of the transport function (like PUSH and
PULL). In berkeley style sockets this function will set the connection
handle. With this function you can use two different pointers for
receiving and sending.
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_set_ptr</h4>
<p><a name="gnutls_005ftransport_005fset_005fptr"></a>
<div class="defun">
— Function: void <b>gnutls_transport_set_ptr</b> (<var>gnutls_session_t session, gnutls_transport_ptr_t ptr</var>)<var><a name="index-gnutls_005ftransport_005fset_005fptr-224"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>ptr</var>: is the value.
<p>Used to set the first argument of the transport function (like PUSH and
PULL). In berkeley style sockets this function will set the connection
handle.
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_set_pull_function</h4>
<p><a name="gnutls_005ftransport_005fset_005fpull_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_transport_set_pull_function</b> (<var>gnutls_session_t session, gnutls_pull_func pull_func</var>)<var><a name="index-gnutls_005ftransport_005fset_005fpull_005ffunction-225"></a></var><br>
<blockquote><p><var>session</var>: gnutls session
<p><var>pull_func</var>: a callback function similar to <code>read()</code>
<p>This is the function where you set a function for gnutls
to receive data. Normally, if you use berkeley style sockets,
do not need to use this function since the default (recv(2)) will
probably be ok.
<p>PULL_FUNC is of the form,
ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
</p></blockquote></div>
<h4 class="subheading">gnutls_transport_set_push_function</h4>
<p><a name="gnutls_005ftransport_005fset_005fpush_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_transport_set_push_function</b> (<var>gnutls_session_t session, gnutls_push_func push_func</var>)<var><a name="index-gnutls_005ftransport_005fset_005fpush_005ffunction-226"></a></var><br>
<blockquote><p><var>session</var>: gnutls session
<p><var>push_func</var>: a callback function similar to <code>write()</code>
<p>This is the function where you set a push function for gnutls
to use in order to send data. If you are going to use berkeley style
sockets, you do not need to use this function since
the default (send(2)) will probably be ok. Otherwise you should
specify this function for gnutls to be able to send data.
<p>PUSH_FUNC is of the form,
ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
</p></blockquote></div>
<div class="node">
<p><hr>
<a name="X.509-certificate-functions"></a>
<a name="X_002e509-certificate-functions"></a>
Next: <a rel="next" accesskey="n" href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a>,
Previous: <a rel="previous" accesskey="p" href="#Core-functions">Core functions</a>,
Up: <a rel="up" accesskey="u" href="#Function-reference">Function reference</a>
</div>
<h3 class="section">9.2 <acronym>X.509</acronym> certificate functions</h3>
<p><a name="sec_003ax509api"></a>
<a name="index-g_t_0040acronym_007bX_002e509_007d-Functions-227"></a>
The following functions are to be used for <acronym>X.509</acronym> certificate handling.
Their prototypes lie in <samp><span class="file">gnutls/x509.h</span></samp>.
<h4 class="subheading">gnutls_pkcs12_bag_decrypt</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fdecrypt"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_decrypt</b> (<var>gnutls_pkcs12_bag_t bag, const char * pass</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fdecrypt-228"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>pass</var>: The password used for encryption. This can only be ASCII.
<p>This function will decrypt the given encrypted bag and return 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_deinit</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_pkcs12_bag_deinit</b> (<var>gnutls_pkcs12_bag_t bag</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fdeinit-229"></a></var><br>
<blockquote><p><var>bag</var>: The structure to be initialized
<p>This function will deinitialize a PKCS12 Bag structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_encrypt</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fencrypt"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_encrypt</b> (<var>gnutls_pkcs12_bag_t bag, const char * pass, unsigned int flags</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fencrypt-230"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>pass</var>: The password used for encryption. This can only be ASCII.
<p><var>flags</var>: should be one of gnutls_pkcs_encrypt_flags_t elements bitwise or'd
<p>This function will encrypt the given bag and return 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_get_count</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fget_005fcount"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_get_count</b> (<var>gnutls_pkcs12_bag_t bag</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fget_005fcount-231"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p>This function will return the number of the elements withing the bag.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_get_data</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fget_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_get_data</b> (<var>gnutls_pkcs12_bag_t bag, int indx, gnutls_datum_t * data</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fget_005fdata-232"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>indx</var>: The element of the bag to get the data from
<p><var>data</var>: where the bag's data will be. Should be treated as constant.
<p>This function will return the bag's data. The data is a constant
that is stored into the bag. Should not be accessed after the bag
is deleted.
<p>Returns 0 on success and a negative error code on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_get_friendly_name</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_get_friendly_name</b> (<var>gnutls_pkcs12_bag_t bag, int indx, char ** name</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname-233"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>indx</var>: The bag's element to add the id
<p><var>name</var>: will hold a pointer to the name (to be treated as const)
<p>This function will return the friendly name, of the specified bag element.
The key ID is usually used to distinguish the local private key and the certificate pair.
<p>Returns 0 on success, or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_get_key_id</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_get_key_id</b> (<var>gnutls_pkcs12_bag_t bag, int indx, gnutls_datum_t * id</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid-234"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>indx</var>: The bag's element to add the id
<p><var>id</var>: where the ID will be copied (to be treated as const)
<p>This function will return the key ID, of the specified bag element.
The key ID is usually used to distinguish the local private key and the certificate pair.
<p>Returns 0 on success, or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_get_type</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fget_005ftype"></a>
<div class="defun">
— Function: gnutls_pkcs12_bag_type_t <b>gnutls_pkcs12_bag_get_type</b> (<var>gnutls_pkcs12_bag_t bag, int indx</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fget_005ftype-235"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>indx</var>: The element of the bag to get the type
<p>This function will return the bag's type. One of the gnutls_pkcs12_bag_type_t
enumerations.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_init</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_init</b> (<var>gnutls_pkcs12_bag_t * bag</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005finit-236"></a></var><br>
<blockquote><p><var>bag</var>: The structure to be initialized
<p>This function will initialize a PKCS12 bag structure. PKCS12 Bags
usually contain private keys, lists of X.509 Certificates and X.509 Certificate
revocation lists.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_set_crl</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fset_005fcrl"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_set_crl</b> (<var>gnutls_pkcs12_bag_t bag, gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fcrl-237"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>crl</var>: the CRL to be copied.
<p>This function will insert the given CRL into the
bag. This is just a wrapper over <code>gnutls_pkcs12_bag_set_data()</code>.
<p>Returns the index of the added bag on success, or a negative
value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_set_crt</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fset_005fcrt"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_set_crt</b> (<var>gnutls_pkcs12_bag_t bag, gnutls_x509_crt_t crt</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fcrt-238"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>crt</var>: the certificate to be copied.
<p>This function will insert the given certificate into the
bag. This is just a wrapper over <code>gnutls_pkcs12_bag_set_data()</code>.
<p>Returns the index of the added bag on success, or a negative
value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_set_data</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fset_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_set_data</b> (<var>gnutls_pkcs12_bag_t bag, gnutls_pkcs12_bag_type_t type, const gnutls_datum_t * data</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fdata-239"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>type</var>: The data's type
<p><var>data</var>: the data to be copied.
<p>This function will insert the given data of the given type into the
bag.
<p>Returns the index of the added bag on success, or a negative
value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_set_friendly_name</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_set_friendly_name</b> (<var>gnutls_pkcs12_bag_t bag, int indx, const char * name</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname-240"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>indx</var>: The bag's element to add the id
<p><var>name</var>: the name
<p>This function will add the given key friendly name, to the specified, by the index, bag
element. The name will be encoded as a 'Friendly name' bag attribute,
which is usually used to set a user name to the local private key and the certificate pair.
<p>Returns 0 on success, or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_bag_set_key_id</h4>
<p><a name="gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_bag_set_key_id</b> (<var>gnutls_pkcs12_bag_t bag, int indx, const gnutls_datum_t * id</var>)<var><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid-241"></a></var><br>
<blockquote><p><var>bag</var>: The bag
<p><var>indx</var>: The bag's element to add the id
<p><var>id</var>: the ID
<p>This function will add the given key ID, to the specified, by the index, bag
element. The key ID will be encoded as a 'Local key identifier' bag attribute,
which is usually used to distinguish the local private key and the certificate pair.
<p>Returns 0 on success, or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_deinit</h4>
<p><a name="gnutls_005fpkcs12_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_pkcs12_deinit</b> (<var>gnutls_pkcs12_t pkcs12</var>)<var><a name="index-gnutls_005fpkcs12_005fdeinit-242"></a></var><br>
<blockquote><p><var>pkcs12</var>: The structure to be initialized
<p>This function will deinitialize a PKCS12 structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_export</h4>
<p><a name="gnutls_005fpkcs12_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_export</b> (<var>gnutls_pkcs12_t pkcs12, gnutls_x509_crt_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fpkcs12_005fexport-243"></a></var><br>
<blockquote><p><var>pkcs12</var>: Holds the pkcs12 structure
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>output_data</var>: will contain a structure PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will export the pkcs12 structure to DER or PEM format.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size will be updated and GNUTLS_E_SHORT_MEMORY_BUFFER
will be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN PKCS12".
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_generate_mac</h4>
<p><a name="gnutls_005fpkcs12_005fgenerate_005fmac"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_generate_mac</b> (<var>gnutls_pkcs12_t pkcs12, const char * pass</var>)<var><a name="index-gnutls_005fpkcs12_005fgenerate_005fmac-244"></a></var><br>
<blockquote><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
<p><var>pass</var>: The password for the MAC
<p>This function will generate a MAC for the PKCS12 structure.
Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_get_bag</h4>
<p><a name="gnutls_005fpkcs12_005fget_005fbag"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_get_bag</b> (<var>gnutls_pkcs12_t pkcs12, int indx, gnutls_pkcs12_bag_t bag</var>)<var><a name="index-gnutls_005fpkcs12_005fget_005fbag-245"></a></var><br>
<blockquote><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
<p><var>indx</var>: contains the index of the bag to extract
<p><var>bag</var>: An initialized bag, where the contents of the bag will be copied
<p>This function will return a Bag from the PKCS12 structure.
Returns 0 on success.
<p>After the last Bag has been read GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_import</h4>
<p><a name="gnutls_005fpkcs12_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_import</b> (<var>gnutls_pkcs12_t pkcs12, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, unsigned int flags</var>)<var><a name="index-gnutls_005fpkcs12_005fimport-246"></a></var><br>
<blockquote><p><var>pkcs12</var>: The structure to store the parsed PKCS12.
<p><var>data</var>: The DER or PEM encoded PKCS12.
<p><var>format</var>: One of DER or PEM
<p><var>flags</var>: an ORed sequence of gnutls_privkey_pkcs8_flags
<p>This function will convert the given DER or PEM encoded PKCS12
to the native gnutls_pkcs12_t format. The output will be stored in 'pkcs12'.
<p>If the PKCS12 is PEM encoded it should have a header of "PKCS12".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_init</h4>
<p><a name="gnutls_005fpkcs12_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_init</b> (<var>gnutls_pkcs12_t * pkcs12</var>)<var><a name="index-gnutls_005fpkcs12_005finit-247"></a></var><br>
<blockquote><p><var>pkcs12</var>: The structure to be initialized
<p>This function will initialize a PKCS12 structure. PKCS12 structures
usually contain lists of X.509 Certificates and X.509 Certificate
revocation lists.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_set_bag</h4>
<p><a name="gnutls_005fpkcs12_005fset_005fbag"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_set_bag</b> (<var>gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag</var>)<var><a name="index-gnutls_005fpkcs12_005fset_005fbag-248"></a></var><br>
<blockquote><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
<p><var>bag</var>: An initialized bag
<p>This function will insert a Bag into the PKCS12 structure.
Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs12_verify_mac</h4>
<p><a name="gnutls_005fpkcs12_005fverify_005fmac"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs12_verify_mac</b> (<var>gnutls_pkcs12_t pkcs12, const char * pass</var>)<var><a name="index-gnutls_005fpkcs12_005fverify_005fmac-249"></a></var><br>
<blockquote><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
<p><var>pass</var>: The password for the MAC
<p>This function will verify the MAC for the PKCS12 structure.
Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_deinit</h4>
<p><a name="gnutls_005fpkcs7_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_pkcs7_deinit</b> (<var>gnutls_pkcs7_t pkcs7</var>)<var><a name="index-gnutls_005fpkcs7_005fdeinit-250"></a></var><br>
<blockquote><p><var>pkcs7</var>: The structure to be initialized
<p>This function will deinitialize a PKCS7 structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_delete_crl</h4>
<p><a name="gnutls_005fpkcs7_005fdelete_005fcrl"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_delete_crl</b> (<var>gnutls_pkcs7_t pkcs7, int indx</var>)<var><a name="index-gnutls_005fpkcs7_005fdelete_005fcrl-251"></a></var><br>
<blockquote><p><var>indx</var>: the index of the crl to delete
<p>This function will delete a crl from a PKCS7 or RFC2630 crl set.
Index starts from 0. Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_delete_crt</h4>
<p><a name="gnutls_005fpkcs7_005fdelete_005fcrt"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_delete_crt</b> (<var>gnutls_pkcs7_t pkcs7, int indx</var>)<var><a name="index-gnutls_005fpkcs7_005fdelete_005fcrt-252"></a></var><br>
<blockquote><p><var>indx</var>: the index of the certificate to delete
<p>This function will delete a certificate from a PKCS7 or RFC2630 certificate set.
Index starts from 0. Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_export</h4>
<p><a name="gnutls_005fpkcs7_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_export</b> (<var>gnutls_pkcs7_t pkcs7, gnutls_x509_crt_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fpkcs7_005fexport-253"></a></var><br>
<blockquote><p><var>pkcs7</var>: Holds the pkcs7 structure
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>output_data</var>: will contain a structure PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will export the pkcs7 structure to DER or PEM format.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN PKCS7".
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_get_crl_count</h4>
<p><a name="gnutls_005fpkcs7_005fget_005fcrl_005fcount"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_get_crl_count</b> (<var>gnutls_pkcs7_t pkcs7</var>)<var><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fcount-254"></a></var><br>
<blockquote><p>This function will return the number of certifcates in the PKCS7 or
RFC2630 crl set.
<p>Returns a negative value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_get_crl_raw</h4>
<p><a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_get_crl_raw</b> (<var>gnutls_pkcs7_t pkcs7, int indx, void * crl, size_t * crl_size</var>)<var><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fraw-255"></a></var><br>
<blockquote><p><var>indx</var>: contains the index of the crl to extract
<p><var>crl</var>: the contents of the crl will be copied there (may be null)
<p><var>crl_size</var>: should hold the size of the crl
<p>This function will return a crl of the PKCS7 or RFC2630 crl set.
Returns 0 on success. If the provided buffer is not long enough,
then <code>crl_size</code> is updated and GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
<p>After the last crl has been read GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_get_crt_count</h4>
<p><a name="gnutls_005fpkcs7_005fget_005fcrt_005fcount"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_get_crt_count</b> (<var>gnutls_pkcs7_t pkcs7</var>)<var><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fcount-256"></a></var><br>
<blockquote><p>This function will return the number of certifcates in the PKCS7 or
RFC2630 certificate set.
<p>Returns a negative value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_get_crt_raw</h4>
<p><a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_get_crt_raw</b> (<var>gnutls_pkcs7_t pkcs7, int indx, void * certificate, size_t * certificate_size</var>)<var><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fraw-257"></a></var><br>
<blockquote><p><var>indx</var>: contains the index of the certificate to extract
<p><var>certificate</var>: the contents of the certificate will be copied there (may be null)
<p><var>certificate_size</var>: should hold the size of the certificate
<p>This function will return a certificate of the PKCS7 or RFC2630 certificate set.
Returns 0 on success. If the provided buffer is not long enough,
then <code>certificate_size</code> is updated and GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
<p>After the last certificate has been read GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_import</h4>
<p><a name="gnutls_005fpkcs7_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_import</b> (<var>gnutls_pkcs7_t pkcs7, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005fpkcs7_005fimport-258"></a></var><br>
<blockquote><p><var>pkcs7</var>: The structure to store the parsed PKCS7.
<p><var>data</var>: The DER or PEM encoded PKCS7.
<p><var>format</var>: One of DER or PEM
<p>This function will convert the given DER or PEM encoded PKCS7
to the native gnutls_pkcs7_t format. The output will be stored in 'pkcs7'.
<p>If the PKCS7 is PEM encoded it should have a header of "PKCS7".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_init</h4>
<p><a name="gnutls_005fpkcs7_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_init</b> (<var>gnutls_pkcs7_t * pkcs7</var>)<var><a name="index-gnutls_005fpkcs7_005finit-259"></a></var><br>
<blockquote><p><var>pkcs7</var>: The structure to be initialized
<p>This function will initialize a PKCS7 structure. PKCS7 structures
usually contain lists of X.509 Certificates and X.509 Certificate
revocation lists.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_set_crl_raw</h4>
<p><a name="gnutls_005fpkcs7_005fset_005fcrl_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_set_crl_raw</b> (<var>gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crl</var>)<var><a name="index-gnutls_005fpkcs7_005fset_005fcrl_005fraw-260"></a></var><br>
<blockquote><p><var>crl</var>: the DER encoded crl to be added
<p>This function will add a crl to the PKCS7 or RFC2630 crl set.
Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_set_crl</h4>
<p><a name="gnutls_005fpkcs7_005fset_005fcrl"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_set_crl</b> (<var>gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fpkcs7_005fset_005fcrl-261"></a></var><br>
<blockquote><p><var>crl</var>: the DER encoded crl to be added
<p>This function will add a parsed crl to the PKCS7 or RFC2630 crl set.
Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_set_crt_raw</h4>
<p><a name="gnutls_005fpkcs7_005fset_005fcrt_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_set_crt_raw</b> (<var>gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crt</var>)<var><a name="index-gnutls_005fpkcs7_005fset_005fcrt_005fraw-262"></a></var><br>
<blockquote><p><var>crt</var>: the DER encoded certificate to be added
<p>This function will add a certificate to the PKCS7 or RFC2630 certificate set.
Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_pkcs7_set_crt</h4>
<p><a name="gnutls_005fpkcs7_005fset_005fcrt"></a>
<div class="defun">
— Function: int <b>gnutls_pkcs7_set_crt</b> (<var>gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt</var>)<var><a name="index-gnutls_005fpkcs7_005fset_005fcrt-263"></a></var><br>
<blockquote><p><var>crt</var>: the certificate to be copied.
<p>This function will add a parsed certificate to the PKCS7 or RFC2630 certificate set.
This is a wrapper function over <code>gnutls_pkcs7_set_crt_raw()</code> .
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_check_issuer</h4>
<p><a name="gnutls_005fx509_005fcrl_005fcheck_005fissuer"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_check_issuer</b> (<var>gnutls_x509_crl_t cert, gnutls_x509_crt_t issuer</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fcheck_005fissuer-264"></a></var><br>
<blockquote><p><var>issuer</var>: is the certificate of a possible issuer
<p>This function will check if the given CRL was issued by the
given issuer certificate. It will return true (1) if the given CRL was issued
by the given issuer, and false (0) if not.
<p>A negative value is returned in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_deinit</h4>
<p><a name="gnutls_005fx509_005fcrl_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_x509_crl_deinit</b> (<var>gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fdeinit-265"></a></var><br>
<blockquote><p><var>crl</var>: The structure to be initialized
<p>This function will deinitialize a CRL structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_export</h4>
<p><a name="gnutls_005fx509_005fcrl_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_export</b> (<var>gnutls_x509_crl_t crl, gnutls_x509_crt_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fexport-266"></a></var><br>
<blockquote><p><var>crl</var>: Holds the revocation list
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>output_data</var>: will contain a private key PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be replaced by the actual size of parameters)
<p>This function will export the revocation list to DER or PEM format.
<p>If the buffer provided is not long enough to hold the output, then
GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN X509 CRL".
<p>Returns 0 on success, and a negative value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_crt_count</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_crt_count</b> (<var>gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount-267"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p>This function will return the number of revoked certificates in the
given CRL.
<p>Returns a negative value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_crt_serial</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_crt_serial</b> (<var>gnutls_x509_crl_t crl, int indx, unsigned char * serial, size_t * serial_size, time_t * t</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial-268"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>indx</var>: the index of the certificate to extract (starting from 0)
<p><var>serial</var>: where the serial number will be copied
<p><var>serial_size</var>: initially holds the size of serial
<p><var>t</var>: if non null, will hold the time this certificate was revoked
<p>This function will return the serial number of the specified, by
the index, revoked certificate.
<p>Returns a negative value on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_dn_oid</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fdn_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_dn_oid</b> (<var>gnutls_x509_crl_t crl, int indx, void * oid, size_t * sizeof_oid</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fdn_005foid-269"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>indx</var>: Specifies which DN OID to send. Use zero to get the first one.
<p><var>oid</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_oid</var>: initially holds the size of 'oid'
<p>This function will extract the requested OID of the name of the CRL issuer, specified
by the given index.
<p>If oid is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and
in that case the sizeof_oid will be updated with the required size.
On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_issuer_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_issuer_dn_by_oid</b> (<var>gnutls_x509_crl_t crl, const char * oid, int indx, unsigned int raw_flag, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid-270"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
<p><var>raw_flag</var>: If non zero returns the raw DER data of the DN part.
<p><var>buf</var>: a pointer to a structure to hold the peer's name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will extract the part of the name of the CRL issuer specified
by the given OID. The output will be encoded as described in RFC2253. The output
string will be ASCII or UTF-8 encoded, depending on the certificate data.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is zero, this function will only return known OIDs as text. Other OIDs
will be DER encoded, as described in RFC2253 – in hex format with a '\#' prefix.
You can check about known OIDs using <code>gnutls_x509_dn_oid_known()</code>.
<p>If buf is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and
in that case the sizeof_buf will be updated with the required size,
and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_issuer_dn</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_issuer_dn</b> (<var>gnutls_x509_crl_t crl, char * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn-271"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>buf</var>: a pointer to a structure to hold the peer's name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will copy the name of the CRL issuer in the provided buffer. The name
will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output
string will be ASCII or UTF-8 encoded, depending on the certificate data.
<p>If buf is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough, and
in that case the sizeof_buf will be updated with the required size, and
0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_next_update</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate"></a>
<div class="defun">
— Function: time_t <b>gnutls_x509_crl_get_next_update</b> (<var>gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate-272"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p>This function will return the time the next CRL will be issued.
This field is optional in a CRL so it might be normal to get
an error instead.
<p>Returns (time_t)-1 on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_signature_algorithm</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_signature_algorithm</b> (<var>gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm-273"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p>This function will return a value of the gnutls_sign_algorithm_t enumeration that
is the signature algorithm.
<p>Returns a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_this_update</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate"></a>
<div class="defun">
— Function: time_t <b>gnutls_x509_crl_get_this_update</b> (<var>gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate-274"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p>This function will return the time this CRL was issued.
<p>Returns (time_t)-1 on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_get_version</h4>
<p><a name="gnutls_005fx509_005fcrl_005fget_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_get_version</b> (<var>gnutls_x509_crl_t crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fget_005fversion-275"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p>This function will return the version of the specified CRL.
<p>Returns a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_import</h4>
<p><a name="gnutls_005fx509_005fcrl_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_import</b> (<var>gnutls_x509_crl_t crl, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fimport-276"></a></var><br>
<blockquote><p><var>crl</var>: The structure to store the parsed CRL.
<p><var>data</var>: The DER or PEM encoded CRL.
<p><var>format</var>: One of DER or PEM
<p>This function will convert the given DER or PEM encoded CRL
to the native gnutls_x509_crl_t format. The output will be stored in 'crl'.
<p>If the CRL is PEM encoded it should have a header of "X509 CRL".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_init</h4>
<p><a name="gnutls_005fx509_005fcrl_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_init</b> (<var>gnutls_x509_crl_t * crl</var>)<var><a name="index-gnutls_005fx509_005fcrl_005finit-277"></a></var><br>
<blockquote><p><var>crl</var>: The structure to be initialized
<p>This function will initialize a CRL structure. CRL stands for
Certificate Revocation List. A revocation list usually contains
lists of certificate serial numbers that have been revoked
by an Authority. The revocation lists are always signed with
the authority's private key.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_set_crt_serial</h4>
<p><a name="gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_set_crt_serial</b> (<var>gnutls_x509_crl_t crl, const void * serial, size_t serial_size, time_t revocation_time</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial-278"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>serial</var>: The revoked certificate's serial number
<p><var>serial_size</var>: Holds the size of the serial field.
<p><var>revocation_time</var>: The time this certificate was revoked
<p>This function will set a revoked certificate's serial number to the CRL.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_set_crt</h4>
<p><a name="gnutls_005fx509_005fcrl_005fset_005fcrt"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_set_crt</b> (<var>gnutls_x509_crl_t crl, gnutls_x509_crt_t crt, time_t revocation_time</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fset_005fcrt-279"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>crt</var>: should contain a gnutls_x509_crt_t structure with the revoked certificate
<p><var>revocation_time</var>: The time this certificate was revoked
<p>This function will set a revoked certificate's serial number to the CRL.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_set_next_update</h4>
<p><a name="gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_set_next_update</b> (<var>gnutls_x509_crl_t crl, time_t exp_time</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate-280"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>exp_time</var>: The actual time
<p>This function will set the time this CRL will be updated.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_set_this_update</h4>
<p><a name="gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_set_this_update</b> (<var>gnutls_x509_crl_t crl, time_t act_time</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate-281"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>act_time</var>: The actual time
<p>This function will set the time this CRL was issued.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_set_version</h4>
<p><a name="gnutls_005fx509_005fcrl_005fset_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_set_version</b> (<var>gnutls_x509_crl_t crl, unsigned int version</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fset_005fversion-282"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>version</var>: holds the version number. For CRLv1 crls must be 1.
<p>This function will set the version of the CRL. This
must be one for CRL version 1, and so on. The CRLs generated
by gnutls should have a version number of 2.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_sign2</h4>
<p><a name="gnutls_005fx509_005fcrl_005fsign2"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_sign2</b> (<var>gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key, gnutls_digest_algorithm_t dig, unsigned int flags</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fsign2-283"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>issuer</var>: is the certificate of the certificate issuer
<p><var>issuer_key</var>: holds the issuer's private key
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
<p><var>flags</var>: must be 0
<p>This function will sign the CRL with the issuer's private key, and
will copy the issuer's information into the CRL.
<p>This must be the last step in a certificate CRL since all
the previously set parameters are now signed.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_sign</h4>
<p><a name="gnutls_005fx509_005fcrl_005fsign"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_sign</b> (<var>gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fsign-284"></a></var><br>
<blockquote><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
<p><var>issuer</var>: is the certificate of the certificate issuer
<p><var>issuer_key</var>: holds the issuer's private key
<p>This function is the same a <code>gnutls_x509_crl_sign2()</code> with no flags, and
SHA1 as the hash algorithm.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crl_verify</h4>
<p><a name="gnutls_005fx509_005fcrl_005fverify"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crl_verify</b> (<var>gnutls_x509_crl_t crl, const gnutls_x509_crt_t * CA_list, int CA_list_length, unsigned int flags, unsigned int * verify</var>)<var><a name="index-gnutls_005fx509_005fcrl_005fverify-285"></a></var><br>
<blockquote><p><var>crl</var>: is the crl to be verified
<p><var>CA_list</var>: is a certificate list that is considered to be trusted one
<p><var>CA_list_length</var>: holds the number of CA certificates in CA_list
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
<p><var>verify</var>: will hold the crl verification output.
<p>This function will try to verify the given crl and return its status.
See <code>gnutls_x509_crt_list_verify()</code> for a detailed description of
return values.
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_deinit</h4>
<p><a name="gnutls_005fx509_005fcrq_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_x509_crq_deinit</b> (<var>gnutls_x509_crq_t crq</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fdeinit-286"></a></var><br>
<blockquote><p><var>crq</var>: The structure to be initialized
<p>This function will deinitialize a CRL structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_export</h4>
<p><a name="gnutls_005fx509_005fcrq_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_export</b> (<var>gnutls_x509_crq_t crq, gnutls_x509_crt_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fexport-287"></a></var><br>
<blockquote><p><var>crq</var>: Holds the request
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>output_data</var>: will contain a certificate request PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will export the certificate request to a PKCS10
<p>If the buffer provided is not long enough to hold the output, then
GNUTLS_E_SHORT_MEMORY_BUFFER will be returned and
*output_data_size will be updated.
<p>If the structure is PEM encoded, it will have a header of "BEGIN
NEW CERTIFICATE REQUEST".
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_attribute_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_attribute_by_oid</b> (<var>gnutls_x509_crq_t crq, const char * oid, int indx, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid-288"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>indx</var>: In case multiple same OIDs exist in the attribute list, this specifies
which to send. Use zero to get the first one.
<p><var>buf</var>: a pointer to a structure to hold the attribute data (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will return the attribute in the certificate request specified
by the given Object ID. The attribute will be DER encoded.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_challenge_password</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_challenge_password</b> (<var>gnutls_x509_crq_t crq, char * pass, size_t * sizeof_pass</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword-289"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>pass</var>: will hold a null terminated password
<p><var>sizeof_pass</var>: Initially holds the size of <code>pass</code>.
<p>This function will return the challenge password in the
request.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_dn_by_oid</b> (<var>gnutls_x509_crq_t crq, const char * oid, int indx, unsigned int raw_flag, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid-290"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies
which to send. Use zero to get the first one.
<p><var>raw_flag</var>: If non zero returns the raw DER data of the DN part.
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will extract the part of the name of the Certificate
request subject, specified by the given OID. The output will be
encoded as described in RFC2253. The output string will be ASCII
or UTF-8 encoded, depending on the certificate data.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is zero, this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC2253 –
in hex format with a '\#' prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code>.
<p>If <code>buf</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_dn_oid</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fdn_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_dn_oid</b> (<var>gnutls_x509_crq_t crq, int indx, void * oid, size_t * sizeof_oid</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fdn_005foid-291"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>indx</var>: Specifies which DN OID to send. Use zero to get the first one.
<p><var>oid</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
<p>This function will extract the requested OID of the name of the
Certificate request subject, specified by the given index.
<p>If oid is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_oid will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_dn</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fdn"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_dn</b> (<var>gnutls_x509_crq_t crq, char * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fdn-292"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will copy the name of the Certificate request
subject in the provided buffer. The name will be in the form
"C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string
will be ASCII or UTF-8 encoded, depending on the certificate data.
<p>If <code>buf</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_pk_algorithm</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_pk_algorithm</b> (<var>gnutls_x509_crq_t crq, unsigned int * bits</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm-293"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>bits</var>: if bits is non null it will hold the size of the parameters' in bits
<p>This function will return the public key algorithm of a PKCS \<code>10</code>
certificate request.
<p>If bits is non null, it should have enough size to hold the parameters
size in bits. For RSA the bits returned is the modulus.
For DSA the bits returned are of the public
exponent.
<p>Returns a member of the gnutls_pk_algorithm_t enumeration on success,
or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_get_version</h4>
<p><a name="gnutls_005fx509_005fcrq_005fget_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_get_version</b> (<var>gnutls_x509_crq_t crq</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fget_005fversion-294"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p>This function will return the version of the specified Certificate request.
<p>Returns a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_import</h4>
<p><a name="gnutls_005fx509_005fcrq_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_import</b> (<var>gnutls_x509_crq_t crq, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fimport-295"></a></var><br>
<blockquote><p><var>crq</var>: The structure to store the parsed certificate request.
<p><var>data</var>: The DER or PEM encoded certificate.
<p><var>format</var>: One of DER or PEM
<p>This function will convert the given DER or PEM encoded Certificate
to the native gnutls_x509_crq_t format. The output will be stored in <code>cert</code>.
<p>If the Certificate is PEM encoded it should have a header of "NEW CERTIFICATE REQUEST".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_init</h4>
<p><a name="gnutls_005fx509_005fcrq_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_init</b> (<var>gnutls_x509_crq_t * crq</var>)<var><a name="index-gnutls_005fx509_005fcrq_005finit-296"></a></var><br>
<blockquote><p><var>crq</var>: The structure to be initialized
<p>This function will initialize a PKCS10 certificate request structure.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_set_attribute_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_set_attribute_by_oid</b> (<var>gnutls_x509_crq_t crq, const char * oid, void * buf, size_t sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid-297"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>buf</var>: a pointer to a structure that holds the attribute data
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
<p>This function will set the attribute in the certificate request specified
by the given Object ID. The attribute must be be DER encoded.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_set_challenge_password</h4>
<p><a name="gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_set_challenge_password</b> (<var>gnutls_x509_crq_t crq, const char * pass</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword-298"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>pass</var>: holds a null terminated password
<p>This function will set a challenge password to be used when revoking the request.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_set_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_set_dn_by_oid</b> (<var>gnutls_x509_crq_t crq, const char * oid, unsigned int raw_flag, const void * data, unsigned int sizeof_data</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid-299"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>oid</var>: holds an Object Identifier in a null terminated string
<p><var>raw_flag</var>: must be 0, or 1 if the data are DER encoded
<p><var>data</var>: a pointer to the input data
<p><var>sizeof_data</var>: holds the size of <code>data</code>
<p>This function will set the part of the name of the Certificate request subject, specified
by the given OID. The input string should be ASCII or UTF-8 encoded.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
With this function you can only set the known OIDs. You can test
for known OIDs using <code>gnutls_x509_dn_oid_known()</code>. For OIDs that are
not known (by gnutls) you should properly DER encode your data, and
call this function with raw_flag set.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_set_key</h4>
<p><a name="gnutls_005fx509_005fcrq_005fset_005fkey"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_set_key</b> (<var>gnutls_x509_crq_t crq, gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fset_005fkey-300"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>key</var>: holds a private key
<p>This function will set the public parameters from the given private key to the
request. Only RSA keys are currently supported.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_set_version</h4>
<p><a name="gnutls_005fx509_005fcrq_005fset_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_set_version</b> (<var>gnutls_x509_crq_t crq, unsigned int version</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fset_005fversion-301"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>version</var>: holds the version number. For v1 Requests must be 1.
<p>This function will set the version of the certificate request. For
version 1 requests this must be one.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_sign2</h4>
<p><a name="gnutls_005fx509_005fcrq_005fsign2"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_sign2</b> (<var>gnutls_x509_crq_t crq, gnutls_x509_privkey_t key, gnutls_digest_algorithm_t dig, unsigned int flags</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fsign2-302"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>key</var>: holds a private key
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
<p><var>flags</var>: must be 0
<p>This function will sign the certificate request with a private key.
This must be the same key as the one used in <code>gnutls_x509_crt_set_key()</code> since a
certificate request is self signed.
<p>This must be the last step in a certificate request generation since all
the previously set parameters are now signed.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crq_sign</h4>
<p><a name="gnutls_005fx509_005fcrq_005fsign"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crq_sign</b> (<var>gnutls_x509_crq_t crq, gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fx509_005fcrq_005fsign-303"></a></var><br>
<blockquote><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
<p><var>key</var>: holds a private key
<p>This function is the same a <code>gnutls_x509_crq_sign2()</code> with no flags, and
SHA1 as the hash algorithm.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_check_hostname</h4>
<p><a name="gnutls_005fx509_005fcrt_005fcheck_005fhostname"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_check_hostname</b> (<var>gnutls_x509_crt_t cert, const char * hostname</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fcheck_005fhostname-304"></a></var><br>
<blockquote><p><var>cert</var>: should contain an gnutls_x509_crt_t structure
<p><var>hostname</var>: A null terminated string that contains a DNS name
<p>This function will check if the given certificate's subject matches
the given hostname. This is a basic implementation of the matching
described in RFC2818 (HTTPS), which takes into account wildcards,
and the subject alternative name PKIX extension.
<p>Returns non zero on success, and zero on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_check_issuer</h4>
<p><a name="gnutls_005fx509_005fcrt_005fcheck_005fissuer"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_check_issuer</b> (<var>gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fcheck_005fissuer-305"></a></var><br>
<blockquote><p><var>cert</var>: is the certificate to be checked
<p><var>issuer</var>: is the certificate of a possible issuer
<p>This function will check if the given certificate was issued by the
given issuer. It will return true (1) if the given certificate is issued
by the given issuer, and false (0) if not.
<p>A negative value is returned in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_check_revocation</h4>
<p><a name="gnutls_005fx509_005fcrt_005fcheck_005frevocation"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_check_revocation</b> (<var>gnutls_x509_crt_t cert, const gnutls_x509_crl_t * crl_list, int crl_list_length</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fcheck_005frevocation-306"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>crl_list</var>: should contain a list of gnutls_x509_crl_t structures
<p><var>crl_list_length</var>: the length of the crl_list
<p>This function will return check if the given certificate is revoked.
It is assumed that the CRLs have been verified before.
<p>Returns 0 if the certificate is NOT revoked, and 1 if it is.
A negative value is returned on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_cpy_crl_dist_points</h4>
<p><a name="gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_cpy_crl_dist_points</b> (<var>gnutls_x509_crt_t dst, gnutls_x509_crt_t src</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints-307"></a></var><br>
<blockquote><p><var>dst</var>: should contain a gnutls_x509_crt_t structure
<p><var>src</var>: the certificate where the dist points will be copied from
<p>This function will copy the CRL distribution points certificate
extension, from the source to the destination certificate.
This may be useful to copy from a CA certificate to issued ones.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_deinit</h4>
<p><a name="gnutls_005fx509_005fcrt_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_x509_crt_deinit</b> (<var>gnutls_x509_crt_t cert</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fdeinit-308"></a></var><br>
<blockquote><p><var>cert</var>: The structure to be initialized
<p>This function will deinitialize a CRL structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_export</h4>
<p><a name="gnutls_005fx509_005fcrt_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_export</b> (<var>gnutls_x509_crt_t cert, gnutls_x509_crt_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fexport-309"></a></var><br>
<blockquote><p><var>cert</var>: Holds the certificate
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>output_data</var>: will contain a certificate PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will export the certificate to DER or PEM format.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_activation_time</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005factivation_005ftime"></a>
<div class="defun">
— Function: time_t <b>gnutls_x509_crt_get_activation_time</b> (<var>gnutls_x509_crt_t cert</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005factivation_005ftime-310"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p>This function will return the time this Certificate was or will be activated.
<p>Returns (time_t)-1 on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_authority_key_id</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_authority_key_id</b> (<var>gnutls_x509_crt_t cert, void * ret, size_t * ret_size, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid-311"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>critical</var>: will be non zero if the extension is marked as critical (may be null)
<p>This function will return the X.509v3 certificate authority's key identifier.
This is obtained by the X.509 Authority Key identifier extension
field (2.5.29.35). Note that this function only returns the keyIdentifier
field of the extension.
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_ca_status</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fca_005fstatus"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_ca_status</b> (<var>gnutls_x509_crt_t cert, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fca_005fstatus-312"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>critical</var>: will be non zero if the extension is marked as critical
<p>This function will return certificates CA status, by reading the
basicConstraints X.509 extension (2.5.29.19). If the certificate is a CA a positive
value will be returned, or zero if the certificate does not have
CA flag set.
<p>A negative value may be returned in case of parsing error.
If the certificate does not contain the basicConstraints extension
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_crl_dist_points</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_crl_dist_points</b> (<var>gnutls_x509_crt_t cert, unsigned int seq, void * ret, size_t * ret_size, unsigned int * reason_flags, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints-313"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>seq</var>: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.)
<p><var>ret</var>: is the place where the distribution point will be copied to
<p><var>ret_size</var>: holds the size of ret.
<p><var>reason_flags</var>: Revocation reasons flags.
<p><var>critical</var>: will be non zero if the extension is marked as critical (may be null)
<p>This function will return the CRL distribution points (2.5.29.31), contained in the
given certificate.
<p><code>reason_flags</code> should be an ORed sequence of GNUTLS_CRL_REASON_UNUSED,
GNUTLS_CRL_REASON_KEY_COMPROMISE, GNUTLS_CRL_REASON_CA_COMPROMISE,
GNUTLS_CRL_REASON_AFFILIATION_CHANGED, GNUTLS_CRL_REASON_SUPERSEEDED,
GNUTLS_CRL_REASON_CESSATION_OF_OPERATION, GNUTLS_CRL_REASON_CERTIFICATE_HOLD,
GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN, GNUTLS_CRL_REASON_AA_COMPROMISE,
or zero for all possible reasons.
<p>This is specified in X509v3 Certificate Extensions. GNUTLS will return the
distribution point type, or a negative error code on error.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER and updates &ret_size if &ret_size is not enough to hold the distribution
point, or the type of the distribution point if everything was ok. The type is
one of the enumerated gnutls_x509_subject_alt_name_t.
<p>If the certificate does not have an Alternative name with the specified
sequence number then returns GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_dn_by_oid</b> (<var>gnutls_x509_crt_t cert, const char * oid, int indx, unsigned int raw_flag, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid-314"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
<p><var>raw_flag</var>: If non zero returns the raw DER data of the DN part.
<p><var>buf</var>: a pointer where the DN part will be copied (may be null).
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will extract the part of the name of the Certificate
subject specified by the given OID. The output, if the raw flag is not
used, will be encoded as described in RFC2253. Thus a string that is
ASCII or UTF-8 encoded, depending on the certificate data.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is zero, this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC2253 –
in hex format with a '\#' prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code>.
<p>If <code>buf</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_dn_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fdn_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_dn_oid</b> (<var>gnutls_x509_crt_t cert, int indx, void * oid, size_t * sizeof_oid</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn_005foid-315"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>indx</var>: This specifies which OID to return. Use zero to get the first one.
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
<p>This function will extract the OIDs of the name of the Certificate
subject specified by the given index.
<p>If oid is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_oid will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_dn</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fdn"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_dn</b> (<var>gnutls_x509_crt_t cert, char * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn-316"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will copy the name of the Certificate in the
provided buffer. The name will be in the form
"C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string
will be ASCII or UTF-8 encoded, depending on the certificate data.
<p>If <code>buf</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_expiration_time</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime"></a>
<div class="defun">
— Function: time_t <b>gnutls_x509_crt_get_expiration_time</b> (<var>gnutls_x509_crt_t cert</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime-317"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p>This function will return the time this Certificate was or will be expired.
<p>Returns (time_t)-1 on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_extension_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_extension_by_oid</b> (<var>gnutls_x509_crt_t cert, const char * oid, int indx, void * buf, size_t * sizeof_buf, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid-318"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>indx</var>: In case multiple same OIDs exist in the extensions, this specifies which to send. Use zero to get the first one.
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p><var>critical</var>: will be non zero if the extension is marked as critical
<p>This function will return the extension specified by the OID in the certificate.
The extensions will be returned as binary data DER encoded, in the provided
buffer.
<p>A negative value may be returned in case of parsing error.
If the certificate does not contain the specified extension
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_extension_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fextension_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_extension_oid</b> (<var>gnutls_x509_crt_t cert, int indx, void * oid, size_t * sizeof_oid</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fextension_005foid-319"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>indx</var>: Specifies which extension OID to send. Use zero to get the first one.
<p><var>oid</var>: a pointer to a structure to hold the OID (may be null)
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
<p>This function will return the requested extension OID in the certificate.
The extension OID will be stored as a string in the provided buffer.
<p>A negative value may be returned in case of parsing error.
If your have reached the last extension available
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_fingerprint</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005ffingerprint"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_fingerprint</b> (<var>gnutls_x509_crt_t cert, gnutls_digest_algorithm_t algo, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005ffingerprint-320"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>algo</var>: is a digest algorithm
<p><var>buf</var>: a pointer to a structure to hold the fingerprint (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will calculate and copy the certificate's fingerprint
in the provided buffer.
<p>If the buffer is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_issuer_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_issuer_dn_by_oid</b> (<var>gnutls_x509_crt_t cert, const char * oid, int indx, unsigned int raw_flag, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid-321"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
<p><var>raw_flag</var>: If non zero returns the raw DER data of the DN part.
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will extract the part of the name of the Certificate
issuer specified by the given OID. The output, if the raw flag is not
used, will be encoded as described in RFC2253. Thus a string that is
ASCII or UTF-8 encoded, depending on the certificate data.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is zero, this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC2253 –
in hex format with a '\#' prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code>.
<p>If <code>buf</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_issuer_dn_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_issuer_dn_oid</b> (<var>gnutls_x509_crt_t cert, int indx, void * oid, size_t * sizeof_oid</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid-322"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>indx</var>: This specifies which OID to return. Use zero to get the first one.
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
<p>This function will extract the OIDs of the name of the Certificate
issuer specified by the given index.
<p>If <code>oid</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_oid will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_issuer_dn</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_issuer_dn</b> (<var>gnutls_x509_crt_t cert, char * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn-323"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
<p>This function will copy the name of the Certificate issuer in the
provided buffer. The name will be in the form
"C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string
will be ASCII or UTF-8 encoded, depending on the certificate data.
<p>If <code>buf</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_buf will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_key_id</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_key_id</b> (<var>gnutls_x509_crt_t crt, unsigned int flags, unsigned char * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fid-324"></a></var><br>
<blockquote><p><var>crt</var>: Holds the certificate
<p><var>flags</var>: should be 0 for now
<p><var>output_data</var>: will contain the key ID
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will return a unique ID the depends on the public key
parameters. This ID can be used in checking whether a certificate
corresponds to the given private key.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_key_purpose_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_key_purpose_oid</b> (<var>gnutls_x509_crt_t cert, int indx, void * oid, size_t * sizeof_oid, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid-325"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>indx</var>: This specifies which OID to return. Use zero to get the first one.
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
<p>This function will extract the key purpose OIDs of the Certificate
specified by the given index. These are stored in the Extended Key
Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for
human readable names.
<p>If <code>oid</code> is null then only the size will be filled.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the *sizeof_oid will be updated with
the required size. On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_key_usage</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fusage"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_key_usage</b> (<var>gnutls_x509_crt_t cert, unsigned int * key_usage, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fusage-326"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>key_usage</var>: where the key usage bits will be stored
<p><var>critical</var>: will be non zero if the extension is marked as critical
<p>This function will return certificate's key usage, by reading the
keyUsage X.509 extension (2.5.29.15). The key usage value will ORed values of the:
GNUTLS_KEY_DIGITAL_SIGNATURE, GNUTLS_KEY_NON_REPUDIATION,
GNUTLS_KEY_KEY_ENCIPHERMENT, GNUTLS_KEY_DATA_ENCIPHERMENT,
GNUTLS_KEY_KEY_AGREEMENT, GNUTLS_KEY_KEY_CERT_SIGN,
GNUTLS_KEY_CRL_SIGN, GNUTLS_KEY_ENCIPHER_ONLY,
GNUTLS_KEY_DECIPHER_ONLY.
<p>A negative value may be returned in case of parsing error.
If the certificate does not contain the keyUsage extension
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_pk_algorithm</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_pk_algorithm</b> (<var>gnutls_x509_crt_t cert, unsigned int * bits</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm-327"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>bits</var>: if bits is non null it will hold the size of the parameters' in bits
<p>This function will return the public key algorithm of an X.509
certificate.
<p>If bits is non null, it should have enough size to hold the parameters
size in bits. For RSA the bits returned is the modulus.
For DSA the bits returned are of the public
exponent.
<p>Returns a member of the gnutls_pk_algorithm_t enumeration on success,
or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_pk_dsa_raw</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_pk_dsa_raw</b> (<var>gnutls_x509_crt_t crt, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * g, gnutls_datum_t * y</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw-328"></a></var><br>
<blockquote><p><var>crt</var>: Holds the certificate
<p><var>p</var>: will hold the p
<p><var>q</var>: will hold the q
<p><var>g</var>: will hold the g
<p><var>y</var>: will hold the y
<p>This function will export the DSA private key's parameters found in the given
certificate. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_pk_rsa_raw</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_pk_rsa_raw</b> (<var>gnutls_x509_crt_t crt, gnutls_datum_t * m, gnutls_datum_t * e</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw-329"></a></var><br>
<blockquote><p><var>crt</var>: Holds the certificate
<p><var>m</var>: will hold the modulus
<p><var>e</var>: will hold the public exponent
<p>This function will export the RSA private key's parameters found in the given
structure. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_serial</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fserial"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_serial</b> (<var>gnutls_x509_crt_t cert, void * result, size_t * result_size</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fserial-330"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>result</var>: The place where the serial number will be copied
<p><var>result_size</var>: Holds the size of the result field.
<p>This function will return the X.509 certificate's serial number.
This is obtained by the X509 Certificate serialNumber
field. Serial is not always a 32 or 64bit number. Some CAs use
large serial numbers, thus it may be wise to handle it as something
opaque.
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_signature_algorithm</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_signature_algorithm</b> (<var>gnutls_x509_crt_t cert</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm-331"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p>This function will return a value of the gnutls_sign_algorithm_t enumeration that
is the signature algorithm.
<p>Returns a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_subject_alt_name</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_subject_alt_name</b> (<var>gnutls_x509_crt_t cert, unsigned int seq, void * ret, size_t * ret_size, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname-332"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
<p><var>ret</var>: is the place where the alternative name will be copied to
<p><var>ret_size</var>: holds the size of ret.
<p><var>critical</var>: will be non zero if the extension is marked as critical (may be null)
<p>This function will return the alternative names, contained in the
given certificate.
<p>This is specified in X509v3 Certificate Extensions.
GNUTLS will return the Alternative name (2.5.29.17), or a negative
error code.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER if &ret_size is not enough to hold the alternative
name. In that case &ret_size will be updated. If everything was ok the type of alternative
name is returned. The type is one of the enumerated gnutls_x509_subject_alt_name_t.
<p>If the certificate does not have an Alternative name with the specified
sequence number then returns GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_subject_key_id</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_subject_key_id</b> (<var>gnutls_x509_crt_t cert, void * ret, size_t * ret_size, unsigned int * critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid-333"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>critical</var>: will be non zero if the extension is marked as critical (may be null)
<p>This function will return the X.509v3 certificate's subject key identifier.
This is obtained by the X.509 Subject Key identifier extension
field (2.5.29.14).
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_get_version</h4>
<p><a name="gnutls_005fx509_005fcrt_005fget_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_get_version</b> (<var>gnutls_x509_crt_t cert</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fget_005fversion-334"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p>This function will return the version of the specified Certificate.
<p>Returns a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_import</h4>
<p><a name="gnutls_005fx509_005fcrt_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_import</b> (<var>gnutls_x509_crt_t cert, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fimport-335"></a></var><br>
<blockquote><p><var>cert</var>: The structure to store the parsed certificate.
<p><var>data</var>: The DER or PEM encoded certificate.
<p><var>format</var>: One of DER or PEM
<p>This function will convert the given DER or PEM encoded Certificate
to the native gnutls_x509_crt_t format. The output will be stored in <code>cert</code>.
<p>If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or
"CERTIFICATE".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_init</h4>
<p><a name="gnutls_005fx509_005fcrt_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_init</b> (<var>gnutls_x509_crt_t * cert</var>)<var><a name="index-gnutls_005fx509_005fcrt_005finit-336"></a></var><br>
<blockquote><p><var>cert</var>: The structure to be initialized
<p>This function will initialize an X.509 certificate structure.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_list_import</h4>
<p><a name="gnutls_005fx509_005fcrt_005flist_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_list_import</b> (<var>gnutls_x509_crt_t * certs, unsigned int * cert_max, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, unsigned int flags</var>)<var><a name="index-gnutls_005fx509_005fcrt_005flist_005fimport-337"></a></var><br>
<blockquote><p><var>certs</var>: The structures to store the parsed certificate. Must not be initialized.
<p><var>cert_max</var>: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
<p><var>data</var>: The PEM encoded certificate.
<p><var>format</var>: One of DER or PEM.
<p><var>flags</var>: must be zero or an OR'd sequence of gnutls_certificate_import_flags.
<p>This function will convert the given PEM encoded certificate list
to the native gnutls_x509_crt_t format. The output will be stored in <code>certs</code>.
They will be automatically initialized.
<p>If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or
"CERTIFICATE".
<p>Returns the number of certificates read or a negative error value.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_list_verify</h4>
<p><a name="gnutls_005fx509_005fcrt_005flist_005fverify"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_list_verify</b> (<var>const gnutls_x509_crt_t * cert_list, int cert_list_length, const gnutls_x509_crt_t * CA_list, int CA_list_length, const gnutls_x509_crl_t * CRL_list, int CRL_list_length, unsigned int flags, unsigned int * verify</var>)<var><a name="index-gnutls_005fx509_005fcrt_005flist_005fverify-338"></a></var><br>
<blockquote><p><var>cert_list</var>: is the certificate list to be verified
<p><var>cert_list_length</var>: holds the number of certificate in cert_list
<p><var>CA_list</var>: is the CA list which will be used in verification
<p><var>CA_list_length</var>: holds the number of CA certificate in CA_list
<p><var>CRL_list</var>: holds a list of CRLs.
<p><var>CRL_list_length</var>: the length of CRL list.
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
<p><var>verify</var>: will hold the certificate verification output.
<p>This function will try to verify the given certificate list and return its status.
Note that expiration and activation dates are not checked
by this function, you should check them using the appropriate functions.
<p>If no flags are specified (0), this function will use the
basicConstraints (2.5.29.19) PKIX extension. This means that only a certificate
authority is allowed to sign a certificate.
<p>You must also check the peer's name in order to check if the verified
certificate belongs to the actual peer.
<p>The certificate verification output will be put in <code>verify</code> and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.
For a more detailed verification status use <code>gnutls_x509_crt_verify()</code> per list
element.
<p><strong>GNUTLS_CERT_INVALID:</strong> the certificate chain is not valid.
<p><strong>GNUTLS_CERT_REVOKED:</strong> a certificate in the chain has been revoked.
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_activation_time</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005factivation_005ftime"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_activation_time</b> (<var>gnutls_x509_crt_t cert, time_t act_time</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005factivation_005ftime-339"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>act_time</var>: The actual time
<p>This function will set the time this Certificate was or will be activated.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_authority_key_id</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_authority_key_id</b> (<var>gnutls_x509_crt_t cert, const void * id, size_t id_size</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid-340"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>id</var>: The key ID
<p><var>id_size</var>: Holds the size of the serial field.
<p>This function will set the X.509 certificate's authority key ID extension.
Only the keyIdentifier field can be set with this function.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_ca_status</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fca_005fstatus"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_ca_status</b> (<var>gnutls_x509_crt_t crt, unsigned int ca</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fca_005fstatus-341"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>ca</var>: true(1) or false(0). Depending on the Certificate authority status.
<p>This function will set the basicConstraints certificate extension.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_crl_dist_points</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_crl_dist_points</b> (<var>gnutls_x509_crt_t crt, gnutls_x509_subject_alt_name_t type, const void * data_string, unsigned int reason_flags</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints-342"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>type</var>: is one of the gnutls_x509_subject_alt_name_t enumerations
<p><var>data_string</var>: The data to be set
<p><var>reason_flags</var>: revocation reasons
<p>This function will set the CRL distribution points certificate extension.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_crq</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fcrq"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_crq</b> (<var>gnutls_x509_crt_t crt, gnutls_x509_crq_t crq</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fcrq-343"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>crq</var>: holds a certificate request
<p>This function will set the name and public parameters from the given certificate request to the
certificate. Only RSA keys are currently supported.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_dn_by_oid</b> (<var>gnutls_x509_crt_t crt, const char * oid, unsigned int raw_flag, const void * name, unsigned int sizeof_name</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid-344"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: holds an Object Identifier in a null terminated string
<p><var>raw_flag</var>: must be 0, or 1 if the data are DER encoded
<p><var>name</var>: a pointer to the name
<p><var>sizeof_name</var>: holds the size of <code>name</code>
<p>This function will set the part of the name of the Certificate subject, specified
by the given OID. The input string should be ASCII or UTF-8 encoded.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
With this function you can only set the known OIDs. You can test
for known OIDs using <code>gnutls_x509_dn_oid_known()</code>. For OIDs that are
not known (by gnutls) you should properly DER encode your data, and
call this function with raw_flag set.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_expiration_time</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_expiration_time</b> (<var>gnutls_x509_crt_t cert, time_t exp_time</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime-345"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>exp_time</var>: The actual time
<p>This function will set the time this Certificate will expire.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_extension_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_extension_by_oid</b> (<var>gnutls_x509_crt_t crt, const char * oid, const void * buf, size_t sizeof_buf, unsigned int critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid-346"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: holds an Object Identified in null terminated string
<p><var>buf</var>: a pointer to a DER encoded data
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
<p><var>critical</var>: should be non zero if the extension is to be marked as critical
<p>This function will set an the extension, by the specified OID, in the certificate.
The extension data should be binary data DER encoded.
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_issuer_dn_by_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_issuer_dn_by_oid</b> (<var>gnutls_x509_crt_t crt, const char * oid, unsigned int raw_flag, const void * name, unsigned int sizeof_name</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid-347"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: holds an Object Identifier in a null terminated string
<p><var>raw_flag</var>: must be 0, or 1 if the data are DER encoded
<p><var>name</var>: a pointer to the name
<p><var>sizeof_name</var>: holds the size of <code>name</code>
<p>This function will set the part of the name of the Certificate issuer, specified
by the given OID. The input string should be ASCII or UTF-8 encoded.
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
With this function you can only set the known OIDs. You can test
for known OIDs using <code>gnutls_x509_dn_oid_known()</code>. For OIDs that are
not known (by gnutls) you should properly DER encode your data, and
call this function with raw_flag set.
<p>Normally you do not need to call this function, since the signing
operation will copy the signer's name as the issuer of the certificate.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_key_purpose_oid</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_key_purpose_oid</b> (<var>gnutls_x509_crt_t cert, const void * oid, unsigned int critical</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid-348"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>oid</var>: a pointer to a null terminated string that holds the OID
<p><var>critical</var>: Whether this extension will be critical or not
<p>This function will set the key purpose OIDs of the Certificate.
These are stored in the Extended Key Usage extension (2.5.29.37)
See the GNUTLS_KP_* definitions for human readable names.
<p>Subsequent calls to this function will append OIDs to the OID list.
<p>On success 0 is returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_key_usage</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fkey_005fusage"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_key_usage</b> (<var>gnutls_x509_crt_t crt, unsigned int usage</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fkey_005fusage-349"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>usage</var>: an ORed sequence of the GNUTLS_KEY_* elements.
<p>This function will set the keyUsage certificate extension.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_key</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fkey"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_key</b> (<var>gnutls_x509_crt_t crt, gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fkey-350"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>key</var>: holds a private key
<p>This function will set the public parameters from the given private key to the
certificate. Only RSA keys are currently supported.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_serial</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fserial"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_serial</b> (<var>gnutls_x509_crt_t cert, const void * serial, size_t serial_size</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fserial-351"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>serial</var>: The serial number
<p><var>serial_size</var>: Holds the size of the serial field.
<p>This function will set the X.509 certificate's serial number.
Serial is not always a 32 or 64bit number. Some CAs use
large serial numbers, thus it may be wise to handle it as something
opaque.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_subject_alternative_name</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_subject_alternative_name</b> (<var>gnutls_x509_crt_t crt, gnutls_x509_subject_alt_name_t type, const char * data_string</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname-352"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>type</var>: is one of the gnutls_x509_subject_alt_name_t enumerations
<p><var>data_string</var>: The data to be set
<p>This function will set the subject alternative name certificate extension.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_subject_key_id</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_subject_key_id</b> (<var>gnutls_x509_crt_t cert, const void * id, size_t id_size</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid-353"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>id</var>: The key ID
<p><var>id_size</var>: Holds the size of the serial field.
<p>This function will set the X.509 certificate's subject key ID extension.
<p>Returns 0 on success, or a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_set_version</h4>
<p><a name="gnutls_005fx509_005fcrt_005fset_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_set_version</b> (<var>gnutls_x509_crt_t crt, unsigned int version</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fset_005fversion-354"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>version</var>: holds the version number. For X.509v1 certificates must be 1.
<p>This function will set the version of the certificate. This
must be one for X.509 version 1, and so on. Plain certificates without
extensions must have version set to one.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_sign2</h4>
<p><a name="gnutls_005fx509_005fcrt_005fsign2"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_sign2</b> (<var>gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key, gnutls_digest_algorithm_t dig, unsigned int flags</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fsign2-355"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>issuer</var>: is the certificate of the certificate issuer
<p><var>issuer_key</var>: holds the issuer's private key
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
<p><var>flags</var>: must be 0
<p>This function will sign the certificate with the issuer's private key, and
will copy the issuer's information into the certificate.
<p>This must be the last step in a certificate generation since all
the previously set parameters are now signed.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_sign</h4>
<p><a name="gnutls_005fx509_005fcrt_005fsign"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_sign</b> (<var>gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer, gnutls_x509_privkey_t issuer_key</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fsign-356"></a></var><br>
<blockquote><p><var>crt</var>: should contain a gnutls_x509_crt_t structure
<p><var>issuer</var>: is the certificate of the certificate issuer
<p><var>issuer_key</var>: holds the issuer's private key
<p>This function is the same a <code>gnutls_x509_crt_sign2()</code> with no flags, and
SHA1 as the hash algorithm.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_to_xml</h4>
<p><a name="gnutls_005fx509_005fcrt_005fto_005fxml"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_to_xml</b> (<var>gnutls_x509_crt_t cert, gnutls_datum_t * res, int detail</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fto_005fxml-357"></a></var><br>
<blockquote><p><var>cert</var>: should contain a gnutls_x509_crt_t structure
<p><var>res</var>: The datum that will hold the result
<p><var>detail</var>: The detail level (must be GNUTLS_XML_SHOW_ALL or GNUTLS_XML_NORMAL)
<p>This function will return the XML structures of the given X.509
certificate. The XML structures are allocated internally (with
malloc) and stored into res.
<p><strong>NOTE:</strong> This function is currently not implemented. See the NEWS
entry for version 1.3.5.
<p>Returns a negative error code in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_verify_data</h4>
<p><a name="gnutls_005fx509_005fcrt_005fverify_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_verify_data</b> (<var>gnutls_x509_crt_t crt, unsigned int flags, const gnutls_datum_t * data, const gnutls_datum_t * signature</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fverify_005fdata-358"></a></var><br>
<blockquote><p><var>crt</var>: Holds the certificate
<p><var>flags</var>: should be 0 for now
<p><var>data</var>: holds the data to be signed
<p><var>signature</var>: contains the signature
<p>This function will verify the given signed data, using the parameters from the
certificate.
<p>In case of a verification failure 0 is returned, and
1 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_crt_verify</h4>
<p><a name="gnutls_005fx509_005fcrt_005fverify"></a>
<div class="defun">
— Function: int <b>gnutls_x509_crt_verify</b> (<var>gnutls_x509_crt_t cert, const gnutls_x509_crt_t * CA_list, int CA_list_length, unsigned int flags, unsigned int * verify</var>)<var><a name="index-gnutls_005fx509_005fcrt_005fverify-359"></a></var><br>
<blockquote><p><var>cert</var>: is the certificate to be verified
<p><var>CA_list</var>: is one certificate that is considered to be trusted one
<p><var>CA_list_length</var>: holds the number of CA certificate in CA_list
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
<p><var>verify</var>: will hold the certificate verification output.
<p>This function will try to verify the given certificate and return its status.
The verification output in this functions cannot be GNUTLS_CERT_NOT_VALID.
<p>Returns 0 on success and a negative value in case of an error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_dn_oid_known</h4>
<p><a name="gnutls_005fx509_005fdn_005foid_005fknown"></a>
<div class="defun">
— Function: int <b>gnutls_x509_dn_oid_known</b> (<var>const char * oid</var>)<var><a name="index-gnutls_005fx509_005fdn_005foid_005fknown-360"></a></var><br>
<blockquote><p><var>oid</var>: holds an Object Identifier in a null terminated string
<p>This function will inform about known DN OIDs. This is useful since functions
like <code>gnutls_x509_crt_set_dn_by_oid()</code> use the information on known
OIDs to properly encode their input. Object Identifiers that are not
known are not encoded by these functions, and their input is stored directly
into the ASN.1 structure. In that case of unknown OIDs, you have
the responsibility of DER encoding your data.
<p>Returns 1 on known OIDs and 0 otherwise.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_cpy</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fcpy"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_cpy</b> (<var>gnutls_x509_privkey_t dst, gnutls_x509_privkey_t src</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fcpy-361"></a></var><br>
<blockquote><p><var>dst</var>: The destination key, which should be initialized.
<p><var>src</var>: The source key
<p>This function will copy a private key from source to destination key.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_deinit</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_x509_privkey_deinit</b> (<var>gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fdeinit-362"></a></var><br>
<blockquote><p><var>key</var>: The structure to be initialized
<p>This function will deinitialize a private key structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_export_dsa_raw</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_export_dsa_raw</b> (<var>gnutls_x509_privkey_t key, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * g, gnutls_datum_t * y, gnutls_datum_t * x</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw-363"></a></var><br>
<blockquote><p><var>p</var>: will hold the p
<p><var>q</var>: will hold the q
<p><var>g</var>: will hold the g
<p><var>y</var>: will hold the y
<p><var>x</var>: will hold the x
<p>This function will export the DSA private key's parameters found in the given
structure. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_export_pkcs8</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fexport_005fpkcs8"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_export_pkcs8</b> (<var>gnutls_x509_privkey_t key, gnutls_x509_crt_fmt_t format, const char * password, unsigned int flags, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fexport_005fpkcs8-364"></a></var><br>
<blockquote><p><var>key</var>: Holds the key
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>password</var>: the password that will be used to encrypt the key.
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
<p><var>output_data</var>: will contain a private key PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will export the private key to a PKCS8 structure.
Currently only RSA keys can be exported since there is no documented
standard for other keys. If the flags do not
specify the encryption cipher, then the default 3DES (PBES2) will
be used.
<p>The <code>password</code> can be either ASCII or UTF-8 in the default PBES2
encryption schemas, or ASCII for the PKCS12 schemas.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN ENCRYPTED PRIVATE KEY" or "BEGIN PRIVATE KEY" if
encryption is not used.
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_export_rsa_raw</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_export_rsa_raw</b> (<var>gnutls_x509_privkey_t key, gnutls_datum_t * m, gnutls_datum_t * e, gnutls_datum_t * d, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * u</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw-365"></a></var><br>
<blockquote><p><var>key</var>: a structure that holds the rsa parameters
<p><var>m</var>: will hold the modulus
<p><var>e</var>: will hold the public exponent
<p><var>d</var>: will hold the private exponent
<p><var>p</var>: will hold the first prime (p)
<p><var>q</var>: will hold the second prime (q)
<p><var>u</var>: will hold the coefficient
<p>This function will export the RSA private key's parameters found in the given
structure. The new parameters will be allocated using
<code>gnutls_malloc()</code> and will be stored in the appropriate datum.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_export</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_export</b> (<var>gnutls_x509_privkey_t key, gnutls_x509_crt_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fexport-366"></a></var><br>
<blockquote><p><var>key</var>: Holds the key
<p><var>format</var>: the format of output params. One of PEM or DER.
<p><var>output_data</var>: will contain a private key PEM or DER encoded
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will export the private key to a PKCS1 structure for
RSA keys, or an integer sequence for DSA keys. The DSA keys are in
the same format with the parameters used by openssl.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
<p>If the structure is PEM encoded, it will have a header
of "BEGIN RSA PRIVATE KEY".
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_fix</h4>
<p><a name="gnutls_005fx509_005fprivkey_005ffix"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_fix</b> (<var>gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005ffix-367"></a></var><br>
<blockquote><p><var>key</var>: Holds the key
<p>This function will recalculate the secondary parameters in a key.
In RSA keys, this can be the coefficient and exponent1,2.
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_generate</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fgenerate"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_generate</b> (<var>gnutls_x509_privkey_t key, gnutls_pk_algorithm_t algo, unsigned int bits, unsigned int flags</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fgenerate-368"></a></var><br>
<blockquote><p><var>key</var>: should contain a gnutls_x509_privkey_t structure
<p><var>algo</var>: is one of RSA or DSA.
<p><var>bits</var>: the size of the modulus
<p><var>flags</var>: unused for now. Must be 0.
<p>This function will generate a random private key. Note that
this function must be called on an empty private key.
<p>Returns 0 on success or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_get_key_id</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fget_005fkey_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_get_key_id</b> (<var>gnutls_x509_privkey_t key, unsigned int flags, unsigned char * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fget_005fkey_005fid-369"></a></var><br>
<blockquote><p><var>key</var>: Holds the key
<p><var>flags</var>: should be 0 for now
<p><var>output_data</var>: will contain the key ID
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
<p>This function will return a unique ID the depends on the public key
parameters. This ID can be used in checking whether a certificate
corresponds to the given key.
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
<p><strong>Return value:</strong> In case of failure a negative value will be
returned, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_get_pk_algorithm</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_get_pk_algorithm</b> (<var>gnutls_x509_privkey_t key</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm-370"></a></var><br>
<blockquote><p><var>key</var>: should contain a gnutls_x509_privkey_t structure
<p>This function will return the public key algorithm of a private
key.
<p>Returns a member of the gnutls_pk_algorithm_t enumeration on success,
or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_import_dsa_raw</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_import_dsa_raw</b> (<var>gnutls_x509_privkey_t key, const gnutls_datum_t * p, const gnutls_datum_t * q, const gnutls_datum_t * g, const gnutls_datum_t * y, const gnutls_datum_t * x</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw-371"></a></var><br>
<blockquote><p><var>key</var>: The structure to store the parsed key
<p><var>p</var>: holds the p
<p><var>q</var>: holds the q
<p><var>g</var>: holds the g
<p><var>y</var>: holds the y
<p><var>x</var>: holds the x
<p>This function will convert the given DSA raw parameters
to the native gnutls_x509_privkey_t format. The output will be stored in <code>key</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_import_pkcs8</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fimport_005fpkcs8"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_import_pkcs8</b> (<var>gnutls_x509_privkey_t key, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, const char * password, unsigned int flags</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fpkcs8-372"></a></var><br>
<blockquote><p><var>key</var>: The structure to store the parsed key
<p><var>data</var>: The DER or PEM encoded key.
<p><var>format</var>: One of DER or PEM
<p><var>password</var>: the password to decrypt the key (if it is encrypted).
<p><var>flags</var>: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted.
<p>This function will convert the given DER or PEM encoded PKCS8 2.0 encrypted key
to the native gnutls_x509_privkey_t format. The output will be stored in <code>key</code>.
Currently only RSA keys can be imported, and flags can only be used to indicate
an unencrypted key.
<p>The <code>password</code> can be either ASCII or UTF-8 in the default PBES2
encryption schemas, or ASCII for the PKCS12 schemas.
<p>If the Certificate is PEM encoded it should have a header of "ENCRYPTED PRIVATE KEY",
or "PRIVATE KEY". You only need to specify the flags if the key is DER encoded, since
in that case the encryption status cannot be auto-detected.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_import_rsa_raw</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_import_rsa_raw</b> (<var>gnutls_x509_privkey_t key, const gnutls_datum_t * m, const gnutls_datum_t * e, const gnutls_datum_t * d, const gnutls_datum_t * p, const gnutls_datum_t * q, const gnutls_datum_t * u</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw-373"></a></var><br>
<blockquote><p><var>key</var>: The structure to store the parsed key
<p><var>m</var>: holds the modulus
<p><var>e</var>: holds the public exponent
<p><var>d</var>: holds the private exponent
<p><var>p</var>: holds the first prime (p)
<p><var>q</var>: holds the second prime (q)
<p><var>u</var>: holds the coefficient
<p>This function will convert the given RSA raw parameters
to the native gnutls_x509_privkey_t format. The output will be stored in <code>key</code>.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_import</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_import</b> (<var>gnutls_x509_privkey_t key, const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fimport-374"></a></var><br>
<blockquote><p><var>key</var>: The structure to store the parsed key
<p><var>data</var>: The DER or PEM encoded certificate.
<p><var>format</var>: One of DER or PEM
<p>This function will convert the given DER or PEM encoded key
to the native gnutls_x509_privkey_t format. The output will be stored in <code>key</code> .
<p>If the key is PEM encoded it should have a header of "RSA PRIVATE KEY", or
"DSA PRIVATE KEY".
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_init</h4>
<p><a name="gnutls_005fx509_005fprivkey_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_init</b> (<var>gnutls_x509_privkey_t * key</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005finit-375"></a></var><br>
<blockquote><p><var>key</var>: The structure to be initialized
<p>This function will initialize an private key structure.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_sign_data</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fsign_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_sign_data</b> (<var>gnutls_x509_privkey_t key, gnutls_digest_algorithm_t digest, unsigned int flags, const gnutls_datum_t * data, void * signature, size_t * signature_size</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fsign_005fdata-376"></a></var><br>
<blockquote><p><var>key</var>: Holds the key
<p><var>digest</var>: should be MD5 or SHA1
<p><var>flags</var>: should be 0 for now
<p><var>data</var>: holds the data to be signed
<p><var>signature</var>: will contain the signature
<p><var>signature_size</var>: holds the size of signature (and will be replaced
by the new size)
<p>This function will sign the given data using a signature algorithm
supported by the private key. Signature algorithms are always used
together with a hash functions. Different hash functions may be
used for the RSA algorithm, but only SHA-1 for the DSA keys.
<p>If the buffer provided is not long enough to hold the output, then
*signature_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
<p>In case of failure a negative value will be returned, and
0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_privkey_verify_data</h4>
<p><a name="gnutls_005fx509_005fprivkey_005fverify_005fdata"></a>
<div class="defun">
— Function: int <b>gnutls_x509_privkey_verify_data</b> (<var>gnutls_x509_privkey_t key, unsigned int flags, const gnutls_datum_t * data, const gnutls_datum_t * signature</var>)<var><a name="index-gnutls_005fx509_005fprivkey_005fverify_005fdata-377"></a></var><br>
<blockquote><p><var>key</var>: Holds the key
<p><var>flags</var>: should be 0 for now
<p><var>data</var>: holds the data to be signed
<p><var>signature</var>: contains the signature
<p>This function will verify the given signed data, using the parameters in the
private key.
<p>In case of a verification failure 0 is returned, and
1 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_rdn_get_by_oid</h4>
<p><a name="gnutls_005fx509_005frdn_005fget_005fby_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_rdn_get_by_oid</b> (<var>const gnutls_datum_t * idn, const char * oid, int indx, unsigned int raw_flag, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005frdn_005fget_005fby_005foid-378"></a></var><br>
<blockquote><p><var>idn</var>: should contain a DER encoded RDN sequence
<p><var>oid</var>: an Object Identifier
<p><var>indx</var>: In case multiple same OIDs exist in the RDN indicates which
to send. Use 0 for the first one.
<p><var>raw_flag</var>: If non zero then the raw DER data are returned.
<p><var>buf</var>: a pointer to a structure to hold the peer's name
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
<p>This function will return the name of the given Object identifier,
of the RDN sequence. The name will be encoded using the rules
from RFC2253.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER and updates *sizeof_buf if
the provided buffer is not long enough, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_rdn_get_oid</h4>
<p><a name="gnutls_005fx509_005frdn_005fget_005foid"></a>
<div class="defun">
— Function: int <b>gnutls_x509_rdn_get_oid</b> (<var>const gnutls_datum_t * idn, int indx, void * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005frdn_005fget_005foid-379"></a></var><br>
<blockquote><p><var>idn</var>: should contain a DER encoded RDN sequence
<p><var>indx</var>: Indicates which OID to return. Use 0 for the first one.
<p>This function will return the specified Object identifier, of the
RDN sequence.
<p>Returns GNUTLS_E_SHORT_MEMORY_BUFFER and updates *sizeof_buf if
the provided buffer is not long enough, and 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_x509_rdn_get</h4>
<p><a name="gnutls_005fx509_005frdn_005fget"></a>
<div class="defun">
— Function: int <b>gnutls_x509_rdn_get</b> (<var>const gnutls_datum_t * idn, char * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fx509_005frdn_005fget-380"></a></var><br>
<blockquote><p><var>idn</var>: should contain a DER encoded RDN sequence
<p><var>buf</var>: a pointer to a structure to hold the peer's name
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
<p>This function will return the name of the given RDN sequence. The
name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in
RFC2253.
<p>If the provided buffer is not long enough, returns
GNUTLS_E_SHORT_MEMORY_BUFFER and *sizeof_buf will be updated. On
success 0 is returned.
</p></blockquote></div>
<div class="node">
<p><hr>
<a name="GnuTLS-extra-functions"></a>
<a name="GnuTLS_002dextra-functions"></a>
Next: <a rel="next" accesskey="n" href="#OpenPGP-functions">OpenPGP functions</a>,
Previous: <a rel="previous" accesskey="p" href="#X_002e509-certificate-functions">X.509 certificate functions</a>,
Up: <a rel="up" accesskey="u" href="#Function-reference">Function reference</a>
</div>
<h3 class="section">9.3 <acronym>GnuTLS-extra</acronym> functions</h3>
<p><a name="index-g_t_0040acronym_007bGnuTLS_002dextra_007d-functions-381"></a>
These functions are only available in the GPL version of the library
called <code>gnutls-extra</code>. The prototypes for this library lie in
<samp><span class="file">gnutls/extra.h</span></samp>.
<h4 class="subheading">gnutls_extra_check_version</h4>
<p><a name="gnutls_005fextra_005fcheck_005fversion"></a>
<div class="defun">
— Function: const char * <b>gnutls_extra_check_version</b> (<var>const char * req_version</var>)<var><a name="index-gnutls_005fextra_005fcheck_005fversion-382"></a></var><br>
<blockquote><p><var>req_version</var>: the version to check
<p>Check that the version of the gnutls-extra library is at minimum
the requested one and return the version string; return NULL if the
condition is not satisfied. If a NULL is passed to this function,
no check is done, but the version string is simply returned.
</p></blockquote></div>
<h4 class="subheading">gnutls_global_init_extra</h4>
<p><a name="gnutls_005fglobal_005finit_005fextra"></a>
<div class="defun">
— Function: int <b>gnutls_global_init_extra</b> (<var> void</var>)<var><a name="index-gnutls_005fglobal_005finit_005fextra-383"></a></var><br>
<blockquote>
<p>This function initializes the global state of gnutls-extra library to defaults.
Returns zero on success.
<p>Note that <code>gnutls_global_init()</code> has to be called before this function.
If this function is not called then the gnutls-extra library will not
be usable.
</p></blockquote></div>
<div class="node">
<p><hr>
<a name="OpenPGP-functions"></a>
Next: <a rel="next" accesskey="n" href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a>,
Previous: <a rel="previous" accesskey="p" href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a>,
Up: <a rel="up" accesskey="u" href="#Function-reference">Function reference</a>
</div>
<h3 class="section">9.4 <acronym>OpenPGP</acronym> functions</h3>
<p><a name="index-g_t_0040acronym_007bOpenPGP_007d-functions-384"></a><a name="sec_003aopenpgpapi"></a>
<p>The following functions are to be used for <acronym>OpenPGP</acronym>
certificate handling. Their prototypes lie in
<samp><span class="file">gnutls/openpgp.h</span></samp>. You need to link with <samp><span class="file">libgnutls-extra</span></samp>
to be able to use these functions (see <a href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a>).
<h4 class="subheading">gnutls_certificate_set_openpgp_key_file</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_key_file</b> (<var>gnutls_certificate_credentials_t res, const char * certfile, const char * keyfile</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile-385"></a></var><br>
<blockquote><p><var>res</var>: the destination context to save the data.
<p><var>certfile</var>: the file that contains the public key.
<p><var>keyfile</var>: the file that contains the secret key.
<p>This funtion is used to load OpenPGP keys into the GnuTLS credentials structure.
It doesn't matter whether the keys are armored or but, but the files
should only contain one key which should not be encrypted.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_openpgp_key_mem</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_key_mem</b> (<var>gnutls_certificate_credentials_t res, const gnutls_datum_t * cert, const gnutls_datum_t * key</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem-386"></a></var><br>
<blockquote><p><var>res</var>: the destination context to save the data.
<p><var>cert</var>: the datum that contains the public key.
<p><var>key</var>: the datum that contains the secret key.
<p>This funtion is used to load OpenPGP keys into the GnuTLS credential structure.
It doesn't matter whether the keys are armored or but, but the files
should only contain one key which should not be encrypted.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_openpgp_keyring_file</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_keyring_file</b> (<var>gnutls_certificate_credentials_t c, const char * file</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile-387"></a></var><br>
<blockquote><p><var>c</var>: A certificate credentials structure
<p><var>file</var>: filename of the keyring.
<p>The function is used to set keyrings that will be used internally
by various OpenPGP functions. For example to find a key when it
is needed for an operations. The keyring will also be used at the
verification functions.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_openpgp_keyring_mem</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_keyring_mem</b> (<var>gnutls_certificate_credentials_t c, const opaque * data, size_t dlen</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem-388"></a></var><br>
<blockquote><p><var>c</var>: A certificate credentials structure
<p><var>data</var>: buffer with keyring data.
<p><var>dlen</var>: length of data buffer.
<p>The function is used to set keyrings that will be used internally
by various OpenPGP functions. For example to find a key when it
is needed for an operations. The keyring will also be used at the
verification functions.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_openpgp_keyserver</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyserver"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_keyserver</b> (<var>gnutls_certificate_credentials_t res, const char * keyserver, int port</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyserver-389"></a></var><br>
<blockquote><p><var>res</var>: the destination context to save the data.
<p><var>keyserver</var>: is the key server address
<p><var>port</var>: is the key server port to connect to
<p>This funtion will set a key server for use with openpgp keys. This
key server will only be used if the peer sends a key fingerprint instead
of a key in the handshake. Using a key server may delay the handshake
process.
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_openpgp_key</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_key</b> (<var>gnutls_certificate_credentials_t res, gnutls_openpgp_key_t key, gnutls_openpgp_privkey_t pkey</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey-390"></a></var><br>
<blockquote><p><var>res</var>: is an <code>gnutls_certificate_credentials_t</code> structure.
<p><var>key</var>: contains an openpgp public key
<p><var>pkey</var>: is an openpgp private key
<p>This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be called
more than once (in case multiple keys/certificates exist for the
server).
</p></blockquote></div>
<h4 class="subheading">gnutls_certificate_set_openpgp_trustdb</h4>
<p><a name="gnutls_005fcertificate_005fset_005fopenpgp_005ftrustdb"></a>
<div class="defun">
— Function: int <b>gnutls_certificate_set_openpgp_trustdb</b> (<var>gnutls_certificate_credentials_t res, const char * trustdb</var>)<var><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005ftrustdb-391"></a></var><br>
<blockquote><p><var>res</var>: the destination context to save the data.
<p><var>trustdb</var>: is the trustdb filename
<p>This funtion will set a GnuPG trustdb which will be used in key
verification functions. Only version 3 trustdb files are supported.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_check_hostname</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fcheck_005fhostname"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_check_hostname</b> (<var>gnutls_openpgp_key_t key, const char * hostname</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fcheck_005fhostname-392"></a></var><br>
<blockquote><p><var>key</var>: should contain an gnutls_openpgp_key_t structure
<p><var>hostname</var>: A null terminated string that contains a DNS name
<p>This function will check if the given key's owner matches
the given hostname. This is a basic implementation of the matching
described in RFC2818 (HTTPS), which takes into account wildcards.
<p>Returns non zero on success, and zero on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_deinit</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_openpgp_key_deinit</b> (<var>gnutls_openpgp_key_t key</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fdeinit-393"></a></var><br>
<blockquote><p><var>key</var>: The structure to be initialized
<p>This function will deinitialize a key structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_export</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fexport"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_export</b> (<var>gnutls_openpgp_key_t key, gnutls_openpgp_key_fmt_t format, void * output_data, size_t * output_data_size</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fexport-394"></a></var><br>
<blockquote><p><var>key</var>: Holds the key.
<p><var>format</var>: One of gnutls_openpgp_key_fmt_t elements.
<p><var>output_data</var>: will contain the key base64 encoded or raw
<p><var>output_data_size</var>: holds the size of output_data (and will be replaced by the actual size of parameters)
<p>This function will convert the given key to RAW or Base64 format.
If the buffer provided is not long enough to hold the output, then
GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_creation_time</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fcreation_005ftime"></a>
<div class="defun">
— Function: time_t <b>gnutls_openpgp_key_get_creation_time</b> (<var>gnutls_openpgp_key_t key</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fcreation_005ftime-395"></a></var><br>
<blockquote><p><var>key</var>: the structure that contains the OpenPGP public key.
<p>Returns the timestamp when the OpenPGP key was created.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_expiration_time</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fexpiration_005ftime"></a>
<div class="defun">
— Function: time_t <b>gnutls_openpgp_key_get_expiration_time</b> (<var>gnutls_openpgp_key_t key</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fexpiration_005ftime-396"></a></var><br>
<blockquote><p><var>key</var>: the structure that contains the OpenPGP public key.
<p>Returns the time when the OpenPGP key expires. A value of '0' means
that the key doesn't expire at all.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_fingerprint</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005ffingerprint"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_get_fingerprint</b> (<var>gnutls_openpgp_key_t key, void * fpr, size_t * fprlen</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005ffingerprint-397"></a></var><br>
<blockquote><p><var>key</var>: the raw data that contains the OpenPGP public key.
<p><var>fpr</var>: the buffer to save the fingerprint.
<p><var>fprlen</var>: the integer to save the length of the fingerprint.
<p>Returns the fingerprint of the OpenPGP key. Depends on the algorithm,
the fingerprint can be 16 or 20 bytes.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_id</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_get_id</b> (<var>gnutls_openpgp_key_t key, unsigned char keyid[8]</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fid-398"></a></var><br>
<blockquote><p><var>key</var>: the structure that contains the OpenPGP public key.
<p>Returns the 64-bit keyID of the OpenPGP key.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_key_usage</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fkey_005fusage"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_get_key_usage</b> (<var>gnutls_openpgp_key_t key, unsigned int * key_usage</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fkey_005fusage-399"></a></var><br>
<blockquote><p><var>key</var>: should contain a gnutls_openpgp_key_t structure
<p><var>key_usage</var>: where the key usage bits will be stored
<p>This function will return certificate's key usage, by checking the
key algorithm. The key usage value will ORed values of the:
GNUTLS_KEY_DIGITAL_SIGNATURE, GNUTLS_KEY_KEY_ENCIPHERMENT.
<p>A negative value may be returned in case of parsing error.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_name</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fname"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_get_name</b> (<var>gnutls_openpgp_key_t key, int idx, char * buf, size_t * sizeof_buf</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fname-400"></a></var><br>
<blockquote><p><var>key</var>: the structure that contains the OpenPGP public key.
<p><var>idx</var>: the index of the ID to extract
<p><var>buf</var>: a pointer to a structure to hold the name
<p><var>sizeof_buf</var>: holds the size of 'buf'
<p>Extracts the userID from the parsed OpenPGP key.
<p>Returns 0 on success, and GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
if the index of the ID does not exist.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_pk_algorithm</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fpk_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_get_pk_algorithm</b> (<var>gnutls_openpgp_key_t key, unsigned int * bits</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fpk_005falgorithm-401"></a></var><br>
<blockquote><p><var>key</var>: is an OpenPGP key
<p><var>bits</var>: if bits is non null it will hold the size of the parameters' in bits
<p>This function will return the public key algorithm of an OpenPGP
certificate.
<p>If bits is non null, it should have enough size to hold the parameters
size in bits. For RSA the bits returned is the modulus.
For DSA the bits returned are of the public exponent.
<p>Returns a member of the GNUTLS_PKAlgorithm enumeration on success,
or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_get_version</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fget_005fversion"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_get_version</b> (<var>gnutls_openpgp_key_t key</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fget_005fversion-402"></a></var><br>
<blockquote><p><var>key</var>: the structure that contains the OpenPGP public key.
<p>Extract the version of the OpenPGP key.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_import</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_import</b> (<var>gnutls_openpgp_key_t key, const gnutls_datum_t * data, gnutls_openpgp_key_fmt_t format</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fimport-403"></a></var><br>
<blockquote><p><var>key</var>: The structure to store the parsed key.
<p><var>data</var>: The RAW or BASE64 encoded key.
<p><var>format</var>: One of gnutls_openpgp_key_fmt_t elements.
<p>This function will convert the given RAW or Base64 encoded key
to the native gnutls_openpgp_key_t format. The output will be stored in 'key'.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_init</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_init</b> (<var>gnutls_openpgp_key_t * key</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005finit-404"></a></var><br>
<blockquote><p><var>key</var>: The structure to be initialized
<p>This function will initialize an OpenPGP key structure.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_to_xml</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fto_005fxml"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_to_xml</b> (<var>gnutls_openpgp_key_t key, gnutls_datum_t * xmlkey, int ext</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fto_005fxml-405"></a></var><br>
<blockquote><p><var>xmlkey</var>: he datum struct to store the XML result.
<p><var>ext</var>: extension mode (1/0), 1 means include key signatures and key data.
<p>This function will return the all OpenPGP key information encapsulated as
a XML string.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_verify_ring</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fverify_005fring"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_verify_ring</b> (<var>gnutls_openpgp_key_t key, gnutls_openpgp_keyring_t keyring, unsigned int flags, unsigned int * verify</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fverify_005fring-406"></a></var><br>
<blockquote><p><var>key</var>: the structure that holds the key.
<p><var>keyring</var>: holds the keyring to check against
<p><var>flags</var>: unused (should be 0)
<p><var>verify</var>: will hold the certificate verification output.
<p>Verify all signatures in the key, using the given set of keys (keyring).
<p>The key verification output will be put in <code>verify</code> and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.
<p><strong>GNUTLS_CERT_INVALID:</strong> A signature on the key is invalid.
<p><strong>GNUTLS_CERT_REVOKED:</strong> The key has been revoked.
<p>Note that this function does not verify using any "web of
trust". You may use GnuPG for that purpose, or any other external
PGP application.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_verify_self</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fverify_005fself"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_verify_self</b> (<var>gnutls_openpgp_key_t key, unsigned int flags, unsigned int * verify</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fverify_005fself-407"></a></var><br>
<blockquote><p><var>key</var>: the structure that holds the key.
<p><var>flags</var>: unused (should be 0)
<p><var>verify</var>: will hold the key verification output.
<p>Verifies the self signature in the key.
The key verification output will be put in <code>verify</code> and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.
<p><strong>GNUTLS_CERT_INVALID:</strong> The self signature on the key is invalid.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_key_verify_trustdb</h4>
<p><a name="gnutls_005fopenpgp_005fkey_005fverify_005ftrustdb"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_key_verify_trustdb</b> (<var>gnutls_openpgp_key_t key, gnutls_openpgp_trustdb_t trustdb, unsigned int flags, unsigned int * verify</var>)<var><a name="index-gnutls_005fopenpgp_005fkey_005fverify_005ftrustdb-408"></a></var><br>
<blockquote><p><var>key</var>: the structure that holds the key.
<p><var>trustdb</var>: holds the trustdb to check against
<p><var>flags</var>: unused (should be 0)
<p><var>verify</var>: will hold the certificate verification output.
<p>Checks if the key is revoked or disabled, in the trustdb.
The verification output will be put in <code>verify</code> and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.
<p><strong>GNUTLS_CERT_INVALID:</strong> A signature on the key is invalid.
<p><strong>GNUTLS_CERT_REVOKED:</strong> The key has been revoked.
<p>Note that this function does not verify using any "web of
trust". You may use GnuPG for that purpose, or any other external
PGP application.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_keyring_check_id</h4>
<p><a name="gnutls_005fopenpgp_005fkeyring_005fcheck_005fid"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_keyring_check_id</b> (<var>gnutls_openpgp_keyring_t ring, const unsigned char keyid[8], unsigned int flags</var>)<var><a name="index-gnutls_005fopenpgp_005fkeyring_005fcheck_005fid-409"></a></var><br>
<blockquote><p><var>ring</var>: holds the keyring to check against
<p><var>flags</var>: unused (should be 0)
<p>Check if a given key ID exists in the keyring.
<p>Returns 0 on success (if keyid exists) and a negative error code
on failure.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_keyring_deinit</h4>
<p><a name="gnutls_005fopenpgp_005fkeyring_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_openpgp_keyring_deinit</b> (<var>gnutls_openpgp_keyring_t keyring</var>)<var><a name="index-gnutls_005fopenpgp_005fkeyring_005fdeinit-410"></a></var><br>
<blockquote><p><var>keyring</var>: The structure to be initialized
<p>This function will deinitialize a CRL structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_keyring_import</h4>
<p><a name="gnutls_005fopenpgp_005fkeyring_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_keyring_import</b> (<var>gnutls_openpgp_keyring_t keyring, const gnutls_datum_t * data, gnutls_openpgp_key_fmt_t format</var>)<var><a name="index-gnutls_005fopenpgp_005fkeyring_005fimport-411"></a></var><br>
<blockquote><p><var>keyring</var>: The structure to store the parsed key.
<p><var>data</var>: The RAW or BASE64 encoded keyring.
<p><var>format</var>: One of gnutls_openpgp_keyring_fmt elements.
<p>This function will convert the given RAW or Base64 encoded keyring
to the native gnutls_openpgp_keyring_t format. The output will be stored in 'keyring'.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_keyring_init</h4>
<p><a name="gnutls_005fopenpgp_005fkeyring_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_keyring_init</b> (<var>gnutls_openpgp_keyring_t * keyring</var>)<var><a name="index-gnutls_005fopenpgp_005fkeyring_005finit-412"></a></var><br>
<blockquote><p><var>keyring</var>: The structure to be initialized
<p>This function will initialize an OpenPGP keyring structure.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_privkey_deinit</h4>
<p><a name="gnutls_005fopenpgp_005fprivkey_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_openpgp_privkey_deinit</b> (<var>gnutls_openpgp_privkey_t key</var>)<var><a name="index-gnutls_005fopenpgp_005fprivkey_005fdeinit-413"></a></var><br>
<blockquote><p><var>key</var>: The structure to be initialized
<p>This function will deinitialize a key structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_privkey_get_pk_algorithm</h4>
<p><a name="gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_privkey_get_pk_algorithm</b> (<var>gnutls_openpgp_privkey_t key, unsigned int * bits</var>)<var><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm-414"></a></var><br>
<blockquote><p><var>key</var>: is an OpenPGP key
<p><var>bits</var>: if bits is non null it will hold the size of the parameters' in bits
<p>This function will return the public key algorithm of an OpenPGP
certificate.
<p>If bits is non null, it should have enough size to hold the parameters
size in bits. For RSA the bits returned is the modulus.
For DSA the bits returned are of the public exponent.
<p>Returns a member of the GNUTLS_PKAlgorithm enumeration on success,
or a negative value on error.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_privkey_import</h4>
<p><a name="gnutls_005fopenpgp_005fprivkey_005fimport"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_privkey_import</b> (<var>gnutls_openpgp_privkey_t key, const gnutls_datum_t * data, gnutls_openpgp_key_fmt_t format, const char * pass, unsigned int flags</var>)<var><a name="index-gnutls_005fopenpgp_005fprivkey_005fimport-415"></a></var><br>
<blockquote><p><var>key</var>: The structure to store the parsed key.
<p><var>data</var>: The RAW or BASE64 encoded key.
<p><var>format</var>: One of gnutls_openpgp_key_fmt_t elements.
<p><var>pass</var>: Unused for now
<p><var>flags</var>: should be zero
<p>This function will convert the given RAW or Base64 encoded key
to the native gnutls_openpgp_privkey_t format. The output will be stored in 'key'.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_privkey_init</h4>
<p><a name="gnutls_005fopenpgp_005fprivkey_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_privkey_init</b> (<var>gnutls_openpgp_privkey_t * key</var>)<var><a name="index-gnutls_005fopenpgp_005fprivkey_005finit-416"></a></var><br>
<blockquote><p><var>key</var>: The structure to be initialized
<p>This function will initialize an OpenPGP key structure.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_set_recv_key_function</h4>
<p><a name="gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_openpgp_set_recv_key_function</b> (<var>gnutls_session_t session, gnutls_openpgp_recv_key_func func</var>)<var><a name="index-gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction-417"></a></var><br>
<blockquote><p><var>session</var>: a TLS session
<p><var>func</var>: the callback
<p>This funtion will set a key retrieval function for OpenPGP keys. This
callback is only useful in server side, and will be used if the peer
sent a key fingerprint instead of a full key.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_trustdb_deinit</h4>
<p><a name="gnutls_005fopenpgp_005ftrustdb_005fdeinit"></a>
<div class="defun">
— Function: void <b>gnutls_openpgp_trustdb_deinit</b> (<var>gnutls_openpgp_trustdb_t trustdb</var>)<var><a name="index-gnutls_005fopenpgp_005ftrustdb_005fdeinit-418"></a></var><br>
<blockquote><p><var>trustdb</var>: The structure to be initialized
<p>This function will deinitialize a CRL structure.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_trustdb_import_file</h4>
<p><a name="gnutls_005fopenpgp_005ftrustdb_005fimport_005ffile"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_trustdb_import_file</b> (<var>gnutls_openpgp_trustdb_t trustdb, const char * file</var>)<var><a name="index-gnutls_005fopenpgp_005ftrustdb_005fimport_005ffile-419"></a></var><br>
<blockquote><p><var>trustdb</var>: The structure to store the parsed key.
<p><var>file</var>: The file that holds the trustdb.
<p>This function will convert the given RAW or Base64 encoded trustdb
to the native gnutls_openpgp_trustdb_t format. The output will be stored in 'trustdb'.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_openpgp_trustdb_init</h4>
<p><a name="gnutls_005fopenpgp_005ftrustdb_005finit"></a>
<div class="defun">
— Function: int <b>gnutls_openpgp_trustdb_init</b> (<var>gnutls_openpgp_trustdb_t * trustdb</var>)<var><a name="index-gnutls_005fopenpgp_005ftrustdb_005finit-420"></a></var><br>
<blockquote><p><var>trustdb</var>: The structure to be initialized
<p>This function will initialize an OpenPGP trustdb structure.
<p>Returns 0 on success.
</p></blockquote></div>
<div class="node">
<p><hr>
<a name="TLS-Inner-Application-(TLS%2fIA)-functions"></a>
<a name="TLS-Inner-Application-_0028TLS_002fIA_0029-functions"></a>
Next: <a rel="next" accesskey="n" href="#Error-codes-and-descriptions">Error codes and descriptions</a>,
Previous: <a rel="previous" accesskey="p" href="#OpenPGP-functions">OpenPGP functions</a>,
Up: <a rel="up" accesskey="u" href="#Function-reference">Function reference</a>
</div>
<h3 class="section">9.5 <acronym>TLS</acronym> Inner Application (<acronym>TLS/IA</acronym>) functions</h3>
<p><a name="index-g_t_0040acronym_007bTLS_007d-Inner-Application-_0028_0040acronym_007bTLS_002fIA_007d_0029-functions-421"></a><a name="index-Inner-Application-_0028_0040acronym_007bTLS_002fIA_007d_0029-functions-422"></a>
The following functions are used for <acronym>TLS</acronym> Inner Application
(<acronym>TLS/IA</acronym>). Their prototypes lie in <samp><span class="file">gnutls/extra.h</span></samp>.
You need to link with <samp><span class="file">libgnutls-extra</span></samp> to be able to use these
functions (see <a href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a>).
<p>The typical control flow in an TLS/IA client (that would not require
an Application Phase for resumed sessions) would be similar to the
following:
<pre class="example"> int client_avp (gnuls_session_t *session, void *ptr,
const char *last, size_t lastlen,
char **new, size_t *newlen)
{
...
}
...
int main ()
{
gnutls_ia_client_credentials_t iacred;
...
gnutls_init (&session, GNUTLS_CLIENT);
...
/* Enable TLS/IA. */
gnutls_ia_allocate_client_credentials(&iacred);
gnutls_ia_set_client_avp_function(iacred, client_avp);
gnutls_credentials_set (session, GNUTLS_CRD_IA, iacred);
...
ret = gnutls_handshake (session);
// Error handling...
...
if (gnutls_ia_handshake_p (session))
{
ret = gnutls_ia_handshake (session);
// Error handling...
...
</pre>
<p>See below for detailed descriptions of all the functions used above.
<p>The function <code>client_avp</code> would have to be implemented by your
application. The function is responsible for handling the AVP data.
See <code>gnutls_ia_set_client_avp_function</code> below for more
information on how that function should be implemented.
<p>The control flow in a typical server is similar to the above, use
<code>gnutls_ia_server_credentials_t</code> instead of
<code>gnutls_ia_client_credentials_t</code>, and replace the call to the
client functions with the corresponding server functions.
<h4 class="subheading">gnutls_ia_allocate_client_credentials</h4>
<p><a name="gnutls_005fia_005fallocate_005fclient_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_ia_allocate_client_credentials</b> (<var>gnutls_ia_client_credentials_t * sc</var>)<var><a name="index-gnutls_005fia_005fallocate_005fclient_005fcredentials-423"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_ia_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
<p>Adding this credential to a session will enable TLS/IA, and will
require an Application Phase after the TLS handshake (if the server
support TLS/IA). Use <code>gnutls_ia_require_inner_phase()</code> to toggle the
TLS/IA mode.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_allocate_server_credentials</h4>
<p><a name="gnutls_005fia_005fallocate_005fserver_005fcredentials"></a>
<div class="defun">
— Function: int <b>gnutls_ia_allocate_server_credentials</b> (<var>gnutls_ia_server_credentials_t * sc</var>)<var><a name="index-gnutls_005fia_005fallocate_005fserver_005fcredentials-424"></a></var><br>
<blockquote><p><var>sc</var>: is a pointer to an <code>gnutls_ia_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
<p>Adding this credential to a session will enable TLS/IA, and will
require an Application Phase after the TLS handshake (if the client
support TLS/IA). Use <code>gnutls_ia_require_inner_phase()</code> to toggle the
TLS/IA mode.
<p>Returns 0 on success.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_enable</h4>
<p><a name="gnutls_005fia_005fenable"></a>
<div class="defun">
— Function: void <b>gnutls_ia_enable</b> (<var>gnutls_session_t session, int allow_skip_on_resume</var>)<var><a name="index-gnutls_005fia_005fenable-425"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>allow_skip_on_resume</var>: non-zero if local party allows to skip the
TLS/IA application phases for a resumed session.
<p>Specify whether we must advertise support for the TLS/IA extension
during the handshake.
<p>At the client side, we always advertise TLS/IA if gnutls_ia_enable
was called before the handshake; at the server side, we also
require that the client has advertised that it wants to run TLS/IA
before including the advertisement, as required by the protocol.
<p>Similarly, at the client side we always advertise that we allow
TLS/IA to be skipped for resumed sessions if <code>allow_skip_on_resume</code>
is non-zero; at the server side, we also require that the session
is indeed resumable and that the client has also advertised that it
allows TLS/IA to be skipped for resumed sessions.
<p>After the TLS handshake, call <code>gnutls_ia_handshake_p()</code> to find out
whether both parties agreed to do a TLS/IA handshake, before
calling <code>gnutls_ia_handshake()</code> or one of the lower level gnutls_ia_*
functions.
Specify whether we must advertise support for the TLS/IA extension
during the handshake.
<p>At the client side, we always advertise TLS/IA if gnutls_ia_enable
was called before the handshake; at the server side, we also
require that the client has advertised that it wants to run TLS/IA
before including the advertisement, as required by the protocol.
<p>Similarly, at the client side we always advertise that we allow
TLS/IA to be skipped for resumed sessions if <code>allow_skip_on_resume</code>
is non-zero; at the server side, we also require that the session
is indeed resumable and that the client has also advertised that it
allows TLS/IA to be skipped for resumed sessions.
<p>After the TLS handshake, call <code>gnutls_ia_handshake_p()</code> to find out
whether both parties agreed to do a TLS/IA handshake, before
calling <code>gnutls_ia_handshake()</code> or one of the lower level gnutls_ia_*
functions.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_endphase_send</h4>
<p><a name="gnutls_005fia_005fendphase_005fsend"></a>
<div class="defun">
— Function: int <b>gnutls_ia_endphase_send</b> (<var>gnutls_session_t session, int final_p</var>)<var><a name="index-gnutls_005fia_005fendphase_005fsend-426"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>final_p</var>: Set iff this should signal the final phase.
<p>Send a TLS/IA end phase message.
<p>In the client, this should only be used to acknowledge an end phase
message sent by the server.
<p>In the server, this can be called instead of <code>gnutls_ia_send()</code> if
the server wishes to end an application phase.
<p><strong>Return value:</strong> Return 0 on success, or an error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_extract_inner_secret</h4>
<p><a name="gnutls_005fia_005fextract_005finner_005fsecret"></a>
<div class="defun">
— Function: void <b>gnutls_ia_extract_inner_secret</b> (<var>gnutls_session_t session, char * buffer</var>)<var><a name="index-gnutls_005fia_005fextract_005finner_005fsecret-427"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>buffer</var>: pre-allocated buffer to hold 48 bytes of inner secret.
<p>Copy the 48 bytes large inner secret into the specified buffer
<p>This function is typically used after the TLS/IA handshake has
concluded. The TLS/IA inner secret can be used as input to a PRF
to derive session keys. Do not use the inner secret directly as a
session key, because for a resumed session that does not include an
application phase, the inner secret will be identical to the inner
secret in the original session. It is important to include, for
example, the client and server randomness when deriving a sesssion
key from the inner secret.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_free_client_credentials</h4>
<p><a name="gnutls_005fia_005ffree_005fclient_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_ia_free_client_credentials</b> (<var>gnutls_ia_client_credentials_t sc</var>)<var><a name="index-gnutls_005fia_005ffree_005fclient_005fcredentials-428"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_ia_client_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_free_server_credentials</h4>
<p><a name="gnutls_005fia_005ffree_005fserver_005fcredentials"></a>
<div class="defun">
— Function: void <b>gnutls_ia_free_server_credentials</b> (<var>gnutls_ia_server_credentials_t sc</var>)<var><a name="index-gnutls_005fia_005ffree_005fserver_005fcredentials-429"></a></var><br>
<blockquote><p><var>sc</var>: is an <code>gnutls_ia_server_credentials_t</code> structure.
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_generate_challenge</h4>
<p><a name="gnutls_005fia_005fgenerate_005fchallenge"></a>
<div class="defun">
— Function: int <b>gnutls_ia_generate_challenge</b> (<var>gnutls_session_t session, size_t buffer_size, char * buffer</var>)<var><a name="index-gnutls_005fia_005fgenerate_005fchallenge-430"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>buffer_size</var>: size of output buffer.
<p><var>buffer</var>: pre-allocated buffer to contain <code>buffer_size</code> bytes of output.
<p>Generate an application challenge that the client cannot control or
predict, based on the TLS/IA inner secret.
<p><strong>Return value:</strong> Returns 0 on success, or an negative error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_get_client_avp_ptr</h4>
<p><a name="gnutls_005fia_005fget_005fclient_005favp_005fptr"></a>
<div class="defun">
— Function: void * <b>gnutls_ia_get_client_avp_ptr</b> (<var>gnutls_ia_client_credentials_t cred</var>)<var><a name="index-gnutls_005fia_005fget_005fclient_005favp_005fptr-431"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_ia_client_credentials_t</code> structure.
<p>Returns the pointer that will be provided to the TLS/IA callback
function as the first argument.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_get_server_avp_ptr</h4>
<p><a name="gnutls_005fia_005fget_005fserver_005favp_005fptr"></a>
<div class="defun">
— Function: void * <b>gnutls_ia_get_server_avp_ptr</b> (<var>gnutls_ia_server_credentials_t cred</var>)<var><a name="index-gnutls_005fia_005fget_005fserver_005favp_005fptr-432"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_ia_client_credentials_t</code> structure.
<p>Returns the pointer that will be provided to the TLS/IA callback
function as the first argument.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_handshake_p</h4>
<p><a name="gnutls_005fia_005fhandshake_005fp"></a>
<div class="defun">
— Function: int <b>gnutls_ia_handshake_p</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fia_005fhandshake_005fp-433"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Predicate to be used after <code>gnutls_handshake()</code> to decide whether to
invoke <code>gnutls_ia_handshake()</code>. Usable by both clients and servers.
<p><strong>Return value:</strong> non-zero if TLS/IA handshake is expected, zero
otherwise.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_handshake</h4>
<p><a name="gnutls_005fia_005fhandshake"></a>
<div class="defun">
— Function: int <b>gnutls_ia_handshake</b> (<var>gnutls_session_t session</var>)<var><a name="index-gnutls_005fia_005fhandshake-434"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p>Perform a TLS/IA handshake. This should be called after
<code>gnutls_handshake()</code> iff <code>gnutls_ia_handshake_p()</code>.
<p>Return 0 on success, or an error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_permute_inner_secret</h4>
<p><a name="gnutls_005fia_005fpermute_005finner_005fsecret"></a>
<div class="defun">
— Function: int <b>gnutls_ia_permute_inner_secret</b> (<var>gnutls_session_t session, size_t session_keys_size, const char * session_keys</var>)<var><a name="index-gnutls_005fia_005fpermute_005finner_005fsecret-435"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>session_keys_size</var>: Size of generated session keys (0 if none).
<p><var>session_keys</var>: Generated session keys, used to permute inner secret
(NULL if none).
<p>Permute the inner secret using the generated session keys.
<p>This can be called in the TLS/IA AVP callback to mix any generated
session keys with the TLS/IA inner secret.
<p><strong>Return value:</strong> Return zero on success, or a negative error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_recv</h4>
<p><a name="gnutls_005fia_005frecv"></a>
<div class="defun">
— Function: ssize_t <b>gnutls_ia_recv</b> (<var>gnutls_session_t session, char * data, size_t sizeofdata</var>)<var><a name="index-gnutls_005fia_005frecv-436"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>data</var>: the buffer that the data will be read into, must hold >= 12 bytes.
<p><var>sizeofdata</var>: the number of requested bytes, must be >= 12.
<p>Receive TLS/IA data. This function has the similar semantics with
<code>recv()</code>. The only difference is that is accepts a GNUTLS session,
and uses different error codes.
<p>If the server attempt to finish an application phase, this function
will return <code>GNUTLS_E_WARNING_IA_IPHF_RECEIVED</code> or
<code>GNUTLS_E_WARNING_IA_FPHF_RECEIVED</code>. The caller should then invoke
<code>gnutls_ia_verify_endphase()</code>, and if it runs the client side, also
send an endphase message of its own using gnutls_ia_endphase_send.
<p>If EINTR is returned by the internal push function (the default is
<code>code</code>{<code>recv()</code>}) then GNUTLS_E_INTERRUPTED will be returned. If
GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN is returned, you must call
this function again, with the same parameters; alternatively you
could provide a NULL pointer for data, and 0 for size.
<p>Returns the number of bytes received. A negative error code is
returned in case of an error. The
<code>GNUTLS_E_WARNING_IA_IPHF_RECEIVED</code> and
<code>GNUTLS_E_WARNING_IA_FPHF_RECEIVED</code> errors are returned when an
application phase finished message has been sent by the server.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_send</h4>
<p><a name="gnutls_005fia_005fsend"></a>
<div class="defun">
— Function: ssize_t <b>gnutls_ia_send</b> (<var>gnutls_session_t session, const char * data, size_t sizeofdata</var>)<var><a name="index-gnutls_005fia_005fsend-437"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>data</var>: contains the data to send
<p><var>sizeofdata</var>: is the length of the data
<p>Send TLS/IA application payload data. This function has the
similar semantics with <code>send()</code>. The only difference is that is
accepts a GNUTLS session, and uses different error codes.
<p>The TLS/IA protocol is synchronous, so you cannot send more than
one packet at a time. The client always send the first packet.
<p>To finish an application phase in the server, use
<code>gnutls_ia_endphase_send()</code>. The client cannot end an application
phase unilaterally; rather, a client is required to respond with an
endphase of its own if gnutls_ia_recv indicates that the server has
sent one.
<p>If the EINTR is returned by the internal push function (the default
is <code>send()</code>} then <code>GNUTLS_E_INTERRUPTED</code> will be returned. If
<code>GNUTLS_E_INTERRUPTED</code> or <code>GNUTLS_E_AGAIN</code> is returned, you must call
this function again, with the same parameters; alternatively you
could provide a <code>NULL</code> pointer for data, and 0 for size.
<p>Returns the number of bytes sent, or a negative error code.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_set_client_avp_function</h4>
<p><a name="gnutls_005fia_005fset_005fclient_005favp_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_ia_set_client_avp_function</b> (<var>gnutls_ia_client_credentials_t cred, gnutls_ia_avp_func avp_func</var>)<var><a name="index-gnutls_005fia_005fset_005fclient_005favp_005ffunction-438"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_ia_client_credentials_t</code> structure.
<p><var>avp_func</var>: is the callback function
<p>Set the TLS/IA AVP callback handler used for the session.
<p>The AVP callback is called to process AVPs received from the
server, and to get a new AVP to send to the server.
<p>The callback's function form is:
int (*avp_func) (gnutls_session_t session, void *ptr,
const char *last, size_t lastlen,
char **next, size_t *nextlen);
<p>The <code>session</code> parameter is the <code>gnutls_session_t</code> structure
corresponding to the current session. The <code>ptr</code> parameter is the
application hook pointer, set through
<code>gnutls_ia_set_client_avp_ptr()</code>. The AVP received from the server
is present in <code>last</code> of <code>lastlen</code> size, which will be <code>NULL</code> on the
first invocation. The newly allocated output AVP to send to the
server should be placed in *<code>next</code> of *<code>nextlen</code> size.
<p>The callback may invoke <code>gnutls_ia_permute_inner_secret()</code> to mix any
generated session keys with the TLS/IA inner secret.
<p>Return 0 (<code>GNUTLS_IA_APPLICATION_PAYLOAD</code>) on success, or a negative
error code to abort the TLS/IA handshake.
<p>Note that the callback must use allocate the <code>next</code> parameter using
<code>gnutls_malloc()</code>, because it is released via <code>gnutls_free()</code> by the
TLS/IA handshake function.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_set_client_avp_ptr</h4>
<p><a name="gnutls_005fia_005fset_005fclient_005favp_005fptr"></a>
<div class="defun">
— Function: void <b>gnutls_ia_set_client_avp_ptr</b> (<var>gnutls_ia_client_credentials_t cred, void * ptr</var>)<var><a name="index-gnutls_005fia_005fset_005fclient_005favp_005fptr-439"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_ia_client_credentials_t</code> structure.
<p><var>ptr</var>: is the pointer
<p>Sets the pointer that will be provided to the TLS/IA callback
function as the first argument.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_set_server_avp_function</h4>
<p><a name="gnutls_005fia_005fset_005fserver_005favp_005ffunction"></a>
<div class="defun">
— Function: void <b>gnutls_ia_set_server_avp_function</b> (<var>gnutls_ia_server_credentials_t cred, gnutls_ia_avp_func avp_func</var>)<var><a name="index-gnutls_005fia_005fset_005fserver_005favp_005ffunction-440"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_ia_server_credentials_t</code> structure.
<p>Set the TLS/IA AVP callback handler used for the session.
<p>The callback's function form is:
int (*avp_func) (gnutls_session_t session, void *ptr,
const char *last, size_t lastlen,
char **next, size_t *nextlen);
<p>The <code>session</code> parameter is the <code>gnutls_session_t</code> structure
corresponding to the current session. The <code>ptr</code> parameter is the
application hook pointer, set through
<code>gnutls_ia_set_server_avp_ptr()</code>. The AVP received from the client
is present in <code>last</code> of <code>lastlen</code> size. The newly allocated output
AVP to send to the client should be placed in *<code>next</code> of *<code>nextlen</code>
size.
<p>The AVP callback is called to process incoming AVPs from the
client, and to get a new AVP to send to the client. It can also be
used to instruct the TLS/IA handshake to do go into the
Intermediate or Final phases. It return a negative error code, or
an <code>gnutls_ia_apptype_t</code> message type.
<p>The callback may invoke <code>gnutls_ia_permute_inner_secret()</code> to mix any
generated session keys with the TLS/IA inner secret.
<p>Specifically, return <code>GNUTLS_IA_APPLICATION_PAYLOAD</code> (0) to send
another AVP to the client, return
<code>GNUTLS_IA_INTERMEDIATE_PHASE_FINISHED</code> (1) to indicate that an
IntermediatePhaseFinished message should be sent, and return
<code>GNUTLS_IA_FINAL_PHASE_FINISHED</code> (2) to indicate that an
FinalPhaseFinished message should be sent. In the last two cases,
the contents of the <code>next</code> and <code>nextlen</code> parameter is not used.
<p>Note that the callback must use allocate the <code>next</code> parameter using
<code>gnutls_malloc()</code>, because it is released via <code>gnutls_free()</code> by the
TLS/IA handshake function.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_set_server_avp_ptr</h4>
<p><a name="gnutls_005fia_005fset_005fserver_005favp_005fptr"></a>
<div class="defun">
— Function: void <b>gnutls_ia_set_server_avp_ptr</b> (<var>gnutls_ia_server_credentials_t cred, void * ptr</var>)<var><a name="index-gnutls_005fia_005fset_005fserver_005favp_005fptr-441"></a></var><br>
<blockquote><p><var>cred</var>: is a <code>gnutls_ia_client_credentials_t</code> structure.
<p><var>ptr</var>: is the pointer
<p>Sets the pointer that will be provided to the TLS/IA callback
function as the first argument.
</p></blockquote></div>
<h4 class="subheading">gnutls_ia_verify_endphase</h4>
<p><a name="gnutls_005fia_005fverify_005fendphase"></a>
<div class="defun">
— Function: int <b>gnutls_ia_verify_endphase</b> (<var>gnutls_session_t session, const char * checksum</var>)<var><a name="index-gnutls_005fia_005fverify_005fendphase-442"></a></var><br>
<blockquote><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
<p><var>checksum</var>: 12-byte checksum data, received from <code>gnutls_ia_recv()</code>.
<p>Verify TLS/IA end phase checksum data. If verification fails, the
<code>GNUTLS_A_INNER_APPLICATION_VERIFICATION</code> alert is sent to the other
sie.
<p>This function is called when <code>gnutls_ia_recv()</code> return
<code>GNUTLS_E_WARNING_IA_IPHF_RECEIVED</code> or
<code>GNUTLS_E_WARNING_IA_FPHF_RECEIVED</code>.
<p><strong>Return value:</strong> Return 0 on successful verification, or an error
code. If the checksum verification of the end phase message fails,
<code>GNUTLS_E_IA_VERIFY_FAILED</code> is returned.
</p></blockquote></div>
<div class="node">
<p><hr>
<a name="Error-codes-and-descriptions"></a>
Previous: <a rel="previous" accesskey="p" href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a>,
Up: <a rel="up" accesskey="u" href="#Function-reference">Function reference</a>
</div>
<h3 class="section">9.6 Error codes and descriptions</h3>
<p><a name="Error-Codes"></a>
<a name="index-Error-codes-443"></a>
The error codes used throughout the library are described below. The
return code <code>GNUTLS_E_SUCCESS</code> indicate successful operation, and
is guaranteed to have the value 0, so you can use it in logical
expressions.
<dl>
<dt><code>GNUTLS_E_AGAIN:</code><dd>Function was interrupted.
<br><dt><code>GNUTLS_E_ASN1_DER_ERROR:</code><dd>ASN1 parser: Error in DER parsing.
<br><dt><code>GNUTLS_E_ASN1_DER_OVERFLOW:</code><dd>ASN1 parser: Overflow in DER parsing.
<br><dt><code>GNUTLS_E_ASN1_ELEMENT_NOT_FOUND:</code><dd>ASN1 parser: Element was not found.
<br><dt><code>GNUTLS_E_ASN1_GENERIC_ERROR:</code><dd>ASN1 parser: Generic parsing error.
<br><dt><code>GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND:</code><dd>ASN1 parser: Identifier was not found
<br><dt><code>GNUTLS_E_ASN1_SYNTAX_ERROR:</code><dd>ASN1 parser: Syntax error.
<br><dt><code>GNUTLS_E_ASN1_TAG_ERROR:</code><dd>ASN1 parser: Error in TAG.
<br><dt><code>GNUTLS_E_ASN1_TAG_IMPLICIT:</code><dd>ASN1 parser: error in implicit tag
<br><dt><code>GNUTLS_E_ASN1_TYPE_ANY_ERROR:</code><dd>ASN1 parser: Error in type 'ANY'.
<br><dt><code>GNUTLS_E_ASN1_VALUE_NOT_FOUND:</code><dd>ASN1 parser: Value was not found.
<br><dt><code>GNUTLS_E_ASN1_VALUE_NOT_VALID:</code><dd>ASN1 parser: Value is not valid.
<br><dt><code>GNUTLS_E_BASE64_DECODING_ERROR:</code><dd>Base64 decoding error.
<br><dt><code>GNUTLS_E_BASE64_ENCODING_ERROR:</code><dd>Base64 encoding error.
<br><dt><code>GNUTLS_E_CERTIFICATE_ERROR:</code><dd>Error in the certificate.
<br><dt><code>GNUTLS_E_CERTIFICATE_KEY_MISMATCH:</code><dd>The certificate and the given key do not match.
<br><dt><code>GNUTLS_E_COMPRESSION_FAILED:</code><dd>Compression of the TLS record packet has failed.
<br><dt><code>GNUTLS_E_CONSTRAINT_ERROR:</code><dd>Some constraint limits were reached.
<br><dt><code>GNUTLS_E_DB_ERROR:</code><dd>Error in Database backend.
<br><dt><code>GNUTLS_E_DECOMPRESSION_FAILED:</code><dd>Decompression of the TLS record packet has failed.
<br><dt><code>GNUTLS_E_DECRYPTION_FAILED:</code><dd>Decryption has failed.
<br><dt><code>GNUTLS_E_DH_PRIME_UNACCEPTABLE:</code><dd>The Diffie Hellman prime sent by the server is not acceptable (not long enough).
<br><dt><code>GNUTLS_E_ENCRYPTION_FAILED:</code><dd>Encryption has failed.
<br><dt><code>GNUTLS_E_ERROR_IN_FINISHED_PACKET:</code><dd>An error was encountered at the TLS Finished packet calculation.
<br><dt><code>GNUTLS_E_EXPIRED:</code><dd>The requested session has expired.
<br><dt><code>GNUTLS_E_FATAL_ALERT_RECEIVED:</code><dd>A TLS fatal alert has been received.
<br><dt><code>GNUTLS_E_FILE_ERROR:</code><dd>Error while reading file.
<br><dt><code>GNUTLS_E_GOT_APPLICATION_DATA:</code><dd>TLS Application data were received, while expecting handshake data.
<br><dt><code>GNUTLS_E_HASH_FAILED:</code><dd>Hashing has failed.
<br><dt><code>GNUTLS_E_IA_VERIFY_FAILED:</code><dd>Verifying TLS/IA phase checksum failed
<br><dt><code>GNUTLS_E_ILLEGAL_SRP_USERNAME:</code><dd>The SRP username supplied is illegal.
<br><dt><code>GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY:</code><dd>The gcrypt library version is too old.
<br><dt><code>GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY:</code><dd>The tasn1 library version is too old.
<br><dt><code>GNUTLS_E_INIT_LIBEXTRA:</code><dd>The initialization of GnuTLS-extra has failed.
<br><dt><code>GNUTLS_E_INSUFFICIENT_CREDENTIALS:</code><dd>Insufficient credentials for that request.
<br><dt><code>GNUTLS_E_INTERNAL_ERROR:</code><dd>GnuTLS internal error.
<br><dt><code>GNUTLS_E_INTERRUPTED:</code><dd>Function was interrupted.
<br><dt><code>GNUTLS_E_INVALID_PASSWORD:</code><dd>The given password contains invalid characters.
<br><dt><code>GNUTLS_E_INVALID_REQUEST:</code><dd>The request is invalid.
<br><dt><code>GNUTLS_E_INVALID_SESSION:</code><dd>The specified session has been invalidated for some reason.
<br><dt><code>GNUTLS_E_KEY_USAGE_VIOLATION:</code><dd>Key usage violation in certificate has been detected.
<br><dt><code>GNUTLS_E_LARGE_PACKET:</code><dd>A large TLS record packet was received.
<br><dt><code>GNUTLS_E_LIBRARY_VERSION_MISMATCH:</code><dd>The GnuTLS library version does not match the GnuTLS-extra library version.
<br><dt><code>GNUTLS_E_LZO_INIT_FAILED:</code><dd>The initialization of LZO has failed.
<br><dt><code>GNUTLS_E_MAC_VERIFY_FAILED:</code><dd>The Message Authentication Code verification failed.
<br><dt><code>GNUTLS_E_MEMORY_ERROR:</code><dd>Internal error in memory allocation.
<br><dt><code>GNUTLS_E_MPI_PRINT_FAILED:</code><dd>Could not export a large integer.
<br><dt><code>GNUTLS_E_MPI_SCAN_FAILED:</code><dd>The scanning of a large integer has failed.
<br><dt><code>GNUTLS_E_NO_CERTIFICATE_FOUND:</code><dd>The peer did not send any certificate.
<br><dt><code>GNUTLS_E_NO_CIPHER_SUITES:</code><dd>No supported cipher suites have been found.
<br><dt><code>GNUTLS_E_NO_COMPRESSION_ALGORITHMS:</code><dd>No supported compression algorithms have been found.
<br><dt><code>GNUTLS_E_NO_TEMPORARY_DH_PARAMS:</code><dd>No temporary DH parameters were found.
<br><dt><code>GNUTLS_E_NO_TEMPORARY_RSA_PARAMS:</code><dd>No temporary RSA parameters were found.
<br><dt><code>GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED:</code><dd>The OpenPGP fingerprint is not supported.
<br><dt><code>GNUTLS_E_OPENPGP_GETKEY_FAILED:</code><dd>Could not get OpenPGP key.
<br><dt><code>GNUTLS_E_OPENPGP_KEYRING_ERROR:</code><dd>Error loading the keyring.
<br><dt><code>GNUTLS_E_OPENPGP_TRUSTDB_VERSION_UNSUPPORTED:</code><dd>The specified GnuPG TrustDB version is not supported. TrustDB v4 is supported.
<br><dt><code>GNUTLS_E_PKCS1_WRONG_PAD:</code><dd>Wrong padding in PKCS1 packet.
<br><dt><code>GNUTLS_E_PK_DECRYPTION_FAILED:</code><dd>Public key decryption has failed.
<br><dt><code>GNUTLS_E_PK_ENCRYPTION_FAILED:</code><dd>Public key encryption has failed.
<br><dt><code>GNUTLS_E_PK_SIGN_FAILED:</code><dd>Public key signing has failed.
<br><dt><code>GNUTLS_E_PK_SIG_VERIFY_FAILED:</code><dd>Public key signature verification has failed.
<br><dt><code>GNUTLS_E_PULL_ERROR:</code><dd>Error in the pull function.
<br><dt><code>GNUTLS_E_PUSH_ERROR:</code><dd>Error in the push function.
<br><dt><code>GNUTLS_E_RANDOM_FAILED:</code><dd>Failed to acquire random data.
<br><dt><code>GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION:</code><dd>An illegal TLS extension was received.
<br><dt><code>GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER:</code><dd>An illegal parameter has been received.
<br><dt><code>GNUTLS_E_RECORD_LIMIT_REACHED:</code><dd>The upper limit of record packet sequence numbers has been reached. Wow!
<br><dt><code>GNUTLS_E_REHANDSHAKE:</code><dd>Rehandshake was requested by the peer.
<br><dt><code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE:</code><dd>The requested data were not available.
<br><dt><code>GNUTLS_E_SHORT_MEMORY_BUFFER:</code><dd>The given memory buffer is too short to hold parameters.
<br><dt><code>GNUTLS_E_SRP_PWD_ERROR:</code><dd>Error in password file.
<br><dt><code>GNUTLS_E_SRP_PWD_PARSING_ERROR:</code><dd>Parsing error in password file.
<br><dt><code>GNUTLS_E_SUCCESS:</code><dd>Success.
<br><dt><code>GNUTLS_E_TOO_MANY_EMPTY_PACKETS:</code><dd>Too many empty record packets have been received.
<br><dt><code>GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET:</code><dd>An unexpected TLS handshake packet was received.
<br><dt><code>GNUTLS_E_UNEXPECTED_PACKET:</code><dd>An unexpected TLS packet was received.
<br><dt><code>GNUTLS_E_UNEXPECTED_PACKET_LENGTH:</code><dd>A TLS packet with unexpected length was received.
<br><dt><code>GNUTLS_E_UNKNOWN_CIPHER_SUITE:</code><dd>Could not negotiate a supported cipher suite.
<br><dt><code>GNUTLS_E_UNKNOWN_CIPHER_TYPE:</code><dd>The cipher type is unsupported.
<br><dt><code>GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM:</code><dd>Could not negotiate a supported compression method.
<br><dt><code>GNUTLS_E_UNKNOWN_HASH_ALGORITHM:</code><dd>The hash algorithm is unknown.
<br><dt><code>GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE:</code><dd>The PKCS structure's bag type is unknown.
<br><dt><code>GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE:</code><dd>The PKCS structure's content type is unknown.
<br><dt><code>GNUTLS_E_UNKNOWN_PK_ALGORITHM:</code><dd>An unknown public key algorithm was encountered.
<br><dt><code>GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE:</code><dd>The certificate type is not supported.
<br><dt><code>GNUTLS_E_UNSUPPORTED_VERSION_PACKET:</code><dd>A record packet with illegal version was received.
<br><dt><code>GNUTLS_E_UNWANTED_ALGORITHM:</code><dd>An algorithm that is not enabled was negotiated.
<br><dt><code>GNUTLS_E_WARNING_ALERT_RECEIVED:</code><dd>A TLS warning alert has been received.
<br><dt><code>GNUTLS_E_WARNING_IA_FPHF_RECEIVED:</code><dd>Received a TLS/IA Final Phase Finished message
<br><dt><code>GNUTLS_E_WARNING_IA_IPHF_RECEIVED:</code><dd>Received a TLS/IA Intermediate Phase Finished message
<br><dt><code>GNUTLS_E_X509_UNKNOWN_SAN:</code><dd>Unknown Subject Alternative name in X.509 certificate.
<br><dt><code>GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE:</code><dd>The certificate has unsupported attributes.
<br><dt><code>GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION:</code><dd>Unsupported critical extension in X.509 certificate.
<br><dt><code>GNUTLS_E_X509_UNSUPPORTED_OID:</code><dd>The OID is not supported.
</dl>
<div class="node">
<p><hr>
<a name="Certificate-to-XML-convertion-functions"></a>
Next: <a rel="next" accesskey="n" href="#All-the-supported-ciphersuites-in-GnuTLS">All the supported ciphersuites in GnuTLS</a>,
Previous: <a rel="previous" accesskey="p" href="#Function-reference">Function reference</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">10 Certificate to <acronym>XML</acronym> convertion functions</h2>
<p><a name="index-Certificate-to-XML-convertion-444"></a>
This appendix contains some example output of the XML convertion
functions:
<ul>
<li><a href="#gnutls_005fx509_005fcrt_005fto_005fxml">gnutls_x509_crt_to_xml</a>
<li><a href="#gnutls_005fopenpgp_005fkey_005fto_005fxml">gnutls_openpgp_key_to_xml</a>
</ul>
<ul class="menu">
<li><a accesskey="1" href="#An-X_002e509-certificate">An X.509 certificate</a>
<li><a accesskey="2" href="#An-OpenPGP-key">An OpenPGP key</a>
</ul>
<div class="node">
<p><hr>
<a name="An-X.509-certificate"></a>
<a name="An-X_002e509-certificate"></a>
Next: <a rel="next" accesskey="n" href="#An-OpenPGP-key">An OpenPGP key</a>,
Up: <a rel="up" accesskey="u" href="#Certificate-to-XML-convertion-functions">Certificate to XML convertion functions</a>
</div>
<h3 class="section">10.1 An <acronym>X.509</acronym> certificate</h3>
<pre class="smallexample"> <?xml version="1.0" encoding="UTF-8"?>
<gnutls:x509:certificate version="1.1">
<certificate type="SEQUENCE">
<tbsCertificate type="SEQUENCE">
<version type="INTEGER" encoding="HEX">02</version>
<serialNumber type="INTEGER" encoding="HEX">01</serialNumber>
<signature type="SEQUENCE">
<algorithm type="OBJECT ID">1.2.840.113549.1.1.4</algorithm>
<parameters type="ANY">
<md5WithRSAEncryption encoding="HEX">0500</md5WithRSAEncryption>
</parameters>
</signature>
<issuer type="CHOICE">
<rdnSequence type="SEQUENCE OF">
<unnamed1 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.6</type>
<value type="ANY">
<X520countryName>GR</X520countryName>
</value>
</unnamed1>
</unnamed1>
<unnamed2 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.8</type>
<value type="ANY">
<X520StateOrProvinceName>Attiki</X520StateOrProvinceName>
</value>
</unnamed1>
</unnamed2>
<unnamed3 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.7</type>
<value type="ANY">
<X520LocalityName>Athina</X520LocalityName>
</value>
</unnamed1>
</unnamed3>
<unnamed4 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.10</type>
<value type="ANY">
<X520OrganizationName>GNUTLS</X520OrganizationName>
</value>
</unnamed1>
</unnamed4>
<unnamed5 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.11</type>
<value type="ANY">
<X520OrganizationalUnitName>GNUTLS dev.</X520OrganizationalUnitName>
</value>
</unnamed1>
</unnamed5>
<unnamed6 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.3</type>
<value type="ANY">
<X520CommonName>GNUTLS TEST CA</X520CommonName>
</value>
</unnamed1>
</unnamed6>
<unnamed7 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">1.2.840.113549.1.9.1</type>
<value type="ANY">
<Pkcs9email>gnutls-dev@gnupg.org</Pkcs9email>
</value>
</unnamed1>
</unnamed7>
</rdnSequence>
</issuer>
<validity type="SEQUENCE">
<notBefore type="CHOICE">
<utcTime type="TIME">010707101845Z</utcTime>
</notBefore>
<notAfter type="CHOICE">
<utcTime type="TIME">020707101845Z</utcTime>
</notAfter>
</validity>
<subject type="CHOICE">
<rdnSequence type="SEQUENCE OF">
<unnamed1 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.6</type>
<value type="ANY">
<X520countryName>GR</X520countryName>
</value>
</unnamed1>
</unnamed1>
<unnamed2 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.8</type>
<value type="ANY">
<X520StateOrProvinceName>Attiki</X520StateOrProvinceName>
</value>
</unnamed1>
</unnamed2>
<unnamed3 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.7</type>
<value type="ANY">
<X520LocalityName>Athina</X520LocalityName>
</value>
</unnamed1>
</unnamed3>
<unnamed4 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.10</type>
<value type="ANY">
<X520OrganizationName>GNUTLS</X520OrganizationName>
</value>
</unnamed1>
</unnamed4>
<unnamed5 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.11</type>
<value type="ANY">
<X520OrganizationalUnitName>GNUTLS dev.</X520OrganizationalUnitName>
</value>
</unnamed1>
</unnamed5>
<unnamed6 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">2.5.4.3</type>
<value type="ANY">
<X520CommonName>localhost</X520CommonName>
</value>
</unnamed1>
</unnamed6>
<unnamed7 type="SET OF">
<unnamed1 type="SEQUENCE">
<type type="OBJECT ID">1.2.840.113549.1.9.1</type>
<value type="ANY">
<Pkcs9email>root@localhost</Pkcs9email>
</value>
</unnamed1>
</unnamed7>
</rdnSequence>
</subject>
<subjectPublicKeyInfo type="SEQUENCE">
<algorithm type="SEQUENCE">
<algorithm type="OBJECT ID">1.2.840.113549.1.1.1</algorithm>
<parameters type="ANY">
<rsaEncryption encoding="HEX">0500</rsaEncryption>
</parameters>
</algorithm>
<subjectPublicKey type="BIT STRING" encoding="HEX" length="1120">
30818902818100D00B49EBB226D951F5CC57072199DDF287683D2DA1A0E
FCC96BFF73164777C78C3991E92EDA66584E7B97BAB4BE68D595D225557
E01E7E57B5C35C04B491948C5C427AD588D8C6989764996D6D44E17B65C
CFC86F3B4842DE559B730C1DE3AEF1CE1A328AFF8A357EBA911E1F7E8FC
1598E21E4BF721748C587F50CF46157D950203010001</subjectPublicKey>
</subjectPublicKeyInfo>
<extensions type="SEQUENCE OF">
<unnamed1 type="SEQUENCE">
<extnID type="OBJECT ID">2.5.29.35</extnID>
<critical type="BOOLEAN">FALSE</critical>
<extnValue type="SEQUENCE">
<keyIdentifier type="OCTET STRING" encoding="HEX">
EFEE94ABC8CA577F5313DB76DC1A950093BAF3C9</keyIdentifier>
</extnValue>
</unnamed1>
<unnamed2 type="SEQUENCE">
<extnID type="OBJECT ID">2.5.29.37</extnID>
<critical type="BOOLEAN">FALSE</critical>
<extnValue type="SEQUENCE OF">
<unnamed1 type="OBJECT ID">1.3.6.1.5.5.7.3.1</unnamed1>
<unnamed2 type="OBJECT ID">1.3.6.1.5.5.7.3.2</unnamed2>
<unnamed3 type="OBJECT ID">1.3.6.1.4.1.311.10.3.3</unnamed3>
<unnamed4 type="OBJECT ID">2.16.840.1.113730.4.1</unnamed4>
</extnValue>
</unnamed2>
<unnamed3 type="SEQUENCE">
<extnID type="OBJECT ID">2.5.29.19</extnID>
<critical type="BOOLEAN">TRUE</critical>
<extnValue type="SEQUENCE">
<cA type="BOOLEAN">FALSE</cA>
</extnValue>
</unnamed3>
</extensions>
</tbsCertificate>
<signatureAlgorithm type="SEQUENCE">
<algorithm type="OBJECT ID">1.2.840.113549.1.1.4</algorithm>
<parameters type="ANY">
<md5WithRSAEncryption encoding="HEX">0500</md5WithRSAEncryption>
</parameters>
</signatureAlgorithm>
<signature type="BIT STRING" encoding="HEX" length="1024">
B73945273AF2A395EC54BF5DC669D953885A9D811A3B92909D24792D36A44EC
27E1C463AF8738BEFD29B311CCE8C6D9661BEC30911DAABB39B8813382B32D2
E259581EBCD26C495C083984763966FF35D1DEFE432891E610C85072578DA74
23244A8F5997B41A1F44E61F4F22C94375775055A5E72F25D5E4557467A91BD
4251</signature>
</certificate>
</gnutls:x509:certificate>
</pre>
<div class="node">
<p><hr>
<a name="An-OpenPGP-key"></a>
Previous: <a rel="previous" accesskey="p" href="#An-X_002e509-certificate">An X.509 certificate</a>,
Up: <a rel="up" accesskey="u" href="#Certificate-to-XML-convertion-functions">Certificate to XML convertion functions</a>
</div>
<h3 class="section">10.2 An <acronym>OpenPGP</acronym> key</h3>
<pre class="smallexample"> <?xml version="1.0"?>
<gnutls:openpgp:key version="1.0">
<OPENPGPKEY>
<MAINKEY>
<KEYID>BD572CDCCCC07C3</KEYID>
<FINGERPRINT>BE615E88D6CFF27225B8A2E7BD572CDCCCC07C35</FINGERPRINT>
<PKALGO>DSA</PKALGO>
<KEYLEN>1024</KEYLEN>
<CREATED>1011533164</CREATED>
<REVOKED>0</REVOKED>
<KEY ENCODING="HEX"/>
<DSA-P>0400E72E76B62EEFA9A3BD594093292418050C02D7029D6CA2066E
FC34C86038627C643EB1A652A7AF1D37CF46FC505AC1E0C699B37895B4BCB
3E53541FFDA4766D6168C2B8AAFD6AB22466D06D18034D5DAC698E6993BA5
B350FF822E1CD8702A75114E8B73A6B09CB3B93CE44DBB516C9BB5F95BB66
6188602A0A1447236C0658F</DSA-P>
<DSA-Q>00A08F5B5E78D85F792CC2072F9474645726FB4D9373</DSA-Q>
<DSA-G>03FE3578D689D6606E9118E9F9A7042B963CF23F3D8F1377A273C0
F0974DBF44B3CABCBE14DD64412555863E39A9C627662D77AC36662AE4497
92C3262D3F12E9832A7565309D67BA0AE4DF25F5EDA0937056AD5BE89F406
9EBD7EC76CE432441DF5D52FFFD06D39E5F61E36947B698A77CB62AB81E4A
4122BF9050671D9946C865E</DSA-G>
<DSA-Y>0400D061437A964DDE318818C2B24DE008E60096B60DB8A684B85A
838D119FC930311889AD57A3B927F448F84EB253C623EDA73B42FF78BCE63
A6A531D75A64CE8540513808E9F5B10CE075D3417B801164918B131D3544C
8765A8ECB9971F61A09FC73D509806106B5977D211CB0E1D04D0ED96BCE89
BAE8F73D800B052139CBF8D</DSA-Y>
</MAINKEY>
<USERID>
<NAME>OpenCDK test key (Only intended for test purposes!)</NAME>
<EMAIL>opencdk@foo-bar.org</EMAIL>
<PRIMARY>0</PRIMARY>
<REVOKED>0</REVOKED>
</USERID>
<SIGNATURE>
<VERSION>4</VERSION>
<SIGCLASS>19</SIGCLASS>
<EXPIRED>0</EXPIRED>
<PKALGO>DSA</PKALGO>
<MDALGO>SHA1</MDALGO>
<CREATED>1011533164</CREATED>
<KEYID>BD572CDCCCC07C3</KEYID>
</SIGNATURE>
<SUBKEY>
<KEYID>FCB0CF3A5261E06</KEYID>
<FINGERPRINT>297B48ACC09C0FF683CA1ED1FCB0CF3A5261E067</FINGERPRINT>
<PKALGO>ELG</PKALGO>
<KEYLEN>1024</KEYLEN>
<CREATED>1011533167</CREATED>
<REVOKED>0</REVOKED>
<KEY ENCODING="HEX"/>
<ELG-P>0400E20156526069D067D24F4D71E6D38658E08BE3BF246C1ADCE0
8DB69CD8D459C1ED335738410798755AFDB79F1797CF022E70C7960F12CA6
896D27CFD24A11CD316DDE1FBCC1EA615C5C31FEC656E467078C875FC509B
1ECB99C8B56C2D875C50E2018B5B0FA378606EB6425A2533830F55FD21D64
9015615D49A1D09E9510F5F</ELG-P>
<ELG-G>000305</ELG-G>
<ELG-Y>0400D0BDADE40432758675C87D0730C360981467BAE1BEB6CC105A
3C1F366BFDBEA12E378456513238B8AD414E52A2A9661D1DF1DB6BB5F33F6
906166107556C813224330B30932DB7C8CC8225672D7AE24AF2469750E539
B661EA6475D2E03CD8D3838DC4A8AC4AFD213536FE3E96EC9D0AEA65164B5
76E01B37A8DCA89F2B257D0</ELG-Y>
</SUBKEY>
<SIGNATURE>
<VERSION>4</VERSION>
<SIGCLASS>24</SIGCLASS>
<EXPIRED>0</EXPIRED>
<PKALGO>DSA</PKALGO>
<MDALGO>SHA1</MDALGO>
<CREATED>1011533167</CREATED>
<KEYID>BD572CDCCCC07C3</KEYID>
</SIGNATURE>
</OPENPGPKEY>
</gnutls:openpgp:key>
</pre>
<div class="node">
<p><hr>
<a name="All-the-supported-ciphersuites-in-GnuTLS"></a>
Next: <a rel="next" accesskey="n" href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a>,
Previous: <a rel="previous" accesskey="p" href="#Certificate-to-XML-convertion-functions">Certificate to XML convertion functions</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">11 All the supported ciphersuites in <acronym>GnuTLS</acronym></h2>
<p><a name="ciphersuites"></a>
<a name="index-Ciphersuites-445"></a>
<p><table summary="">
<tr align="left"><td valign="top" width="45%"><code>TLS_RSA_NULL_MD5</code>
</td><td valign="top" width="20%">0x00 0x01
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_ANON_DH_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x1B
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_ANON_DH_ARCFOUR_MD5</code>
</td><td valign="top" width="20%">0x00 0x18
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_ANON_DH_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x34
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_ANON_DH_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x3A
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_RSA_ARCFOUR_SHA</code>
</td><td valign="top" width="20%">0x00 0x05
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_RSA_ARCFOUR_MD5</code>
</td><td valign="top" width="20%">0x00 0x04
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_RSA_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x0A
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_RSA_EXPORT_ARCFOUR_40_MD5</code>
</td><td valign="top" width="20%">0x00 0x03
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_DSS_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x13
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_RSA_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x16
</td><td valign="top" width="35%">RFC 2246
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_RSA_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x2F
</td><td valign="top" width="35%">RFC 3268
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_RSA_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x35
</td><td valign="top" width="35%">RFC 3268
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_DSS_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x38
</td><td valign="top" width="35%">RFC 3268
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_DSS_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x32
</td><td valign="top" width="35%">RFC 3268
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_RSA_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x39
</td><td valign="top" width="35%">RFC 3268
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_RSA_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x33
</td><td valign="top" width="35%">RFC 3268
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x50
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x53
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x56
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_RSA_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x51
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_DSS_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x52
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_RSA_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x54
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_DSS_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x55
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_RSA_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x57
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_SRP_SHA_DSS_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x58
</td><td valign="top" width="35%">draft-ietf-tls-srp
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_DHE_DSS_ARCFOUR_SHA</code>
</td><td valign="top" width="20%">0x00 0x66
</td><td valign="top" width="35%">draft-ietf-tls-56-bit-ciphersuites
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_PSK_ARCFOUR_SHA</code>
</td><td valign="top" width="20%">0x00 0x8A
</td><td valign="top" width="35%">draft-ietf-tls-psk
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_PSK_3DES_EDE_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x8B
</td><td valign="top" width="35%">draft-ietf-tls-psk
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_PSK_AES_128_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x8C
</td><td valign="top" width="35%">draft-ietf-tls-psk
<p><br></td></tr><tr align="left"><td valign="top" width="45%"><code>TLS_PSK_AES_256_CBC_SHA</code>
</td><td valign="top" width="20%">0x00 0x8D
</td><td valign="top" width="35%">draft-ietf-tls-psk
<br></td></tr></table>
<div class="node">
<p><hr>
<a name="Internal-architecture-of-GnuTLS"></a>
Next: <a rel="next" accesskey="n" href="#Copying-This-Manual">Copying This Manual</a>,
Previous: <a rel="previous" accesskey="p" href="#All-the-supported-ciphersuites-in-GnuTLS">All the supported ciphersuites in GnuTLS</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="chapter">12 Internal architecture of GnuTLS</h2>
<p><a name="index-Internal-architecture-446"></a>
<p>This chapter is to give a brief description of the
way <acronym>GnuTLS</acronym> works. The focus is to give an idea
to potential developers and those who want to know what
happens inside the black box.
<h3 class="section">12.1 The TLS protocol</h3>
<p>The main needs for the TLS protocol to be used are
shown in the image below.
<div class="block-image"><img src="arch/client-server-use-case.png" alt="arch/client-server-use-case.png"></div>
<p>This is being accomplished by the following object diagram.
Note that since <acronym>GnuTLS</acronym> is being developed in C
object are just structures with attributes. The operations listed
are functions that require the first parameter to be that object.
<img src="arch/objects.png" alt="arch/objects.png">
<h3 class="section">12.2 TLS Handshake protocol</h3>
<p>The <acronym>GnuTLS</acronym> handshake protocol is implemented as a state
machine that waits for input or returns immediately when the non-blocking
transport layer functions are used. The main idea is shown in the following
figure.
<div class="block-image"><img src="arch/handshake-state.png" alt="arch/handshake-state.png"></div>
<p>Also the way the input is processed varies per ciphersuite. Several
implementations of the internal handlers are available and
<a href="#gnutls_005fhandshake">gnutls_handshake</a> only multiplexes the input to the appropriate
handler. For example a <acronym>PSK</acronym> ciphersuite has a different
implementation of the <code>process_client_key_exchange</code> than a
certificate ciphersuite.
<div class="block-image"><img src="arch/handshake-sequence.png" alt="arch/handshake-sequence.png"></div>
<h3 class="section">12.3 TLS authentication methods</h3>
<p>In <acronym>GnuTLS</acronym> authentication methods can be implemented quite easily.
Since the required changes to add a new authentication method affect only the
handshake protocol, a simple interface is used. An authentication method needs
only to implement the functions as seen in the figure below.
<div class="block-image"><img src="arch/mod_auth_st.png" alt="arch/mod_auth_st.png"></div>
<p>The functions that need to be implemented are the ones responsible for interpreting
the handshake protocol messages. It is common for such functions to read data from
one or more <code>credentials_t</code> structures<a rel="footnote" href="#fn-17" name="fnd-17"><sup>17</sup></a> and write data, such as certificates, usernames etc. to <code>auth_info_t</code> structures.
<p>Simple examples of existing authentication methods can be seen in <code>auth_psk.c</code>
for PSK ciphersuites and <code>auth_srp.c</code> for SRP ciphersuites. After implementing these functions
the structure holding its pointers has to be registered in <code>gnutls_algorithms.c</code>
in the <code>_gnutls_kx_algorithms</code> structure.
<h3 class="section">12.4 TLS Extension handling</h3>
<p>As with authentication methods, the TLS extensions handlers can be implemented
using the following interface.
<div class="block-image"><img src="arch/extensions_st.png" alt="arch/extensions_st.png"></div>
<p>Here there are two functions, one for receiving the extension data
and one for sending. These functions have to check internally whether
they operate in client or server side.
<p>A simple example of an extension handler can be seen in <code>ext_srp.c</code>
After implementing these functions, together with the extension number they
handle, they have to be registered in <code>gnutls_extensions.c</code> in the
<code>_gnutls_extensions</code> structure.
<h3 class="section">12.5 Certificate handling</h3>
<p>What is provided by the certificate handling functions
is summarized in the following diagram.
<div class="block-image"><img src="arch/certificate-user-use-case.png" alt="arch/certificate-user-use-case.png"></div>
<div class="node">
<p><hr>
<a name="Copying-This-Manual"></a>
Next: <a rel="next" accesskey="n" href="#Concept-Index">Concept Index</a>,
Previous: <a rel="previous" accesskey="p" href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="appendix">Appendix A Copying This Manual</h2>
<ul class="menu">
<li><a accesskey="1" href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>: License for copying this manual.
</ul>
<div class="node">
<p><hr>
<a name="GNU-Free-Documentation-License"></a>
Up: <a rel="up" accesskey="u" href="#Copying-This-Manual">Copying This Manual</a>
</div>
<h3 class="appendixsec">A.1 GNU Free Documentation License</h3>
<p><a name="index-FDL_002c-GNU-Free-Documentation-License-447"></a><div align="center">Version 1.2, November 2002</div>
<pre class="display"> Copyright © 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
</pre>
<ol type=1 start=0>
<li>PREAMBLE
<p>The purpose of this License is to make a manual, textbook, or other
functional and useful document <dfn>free</dfn> in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
<p>This License is a kind of “copyleft”, which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
<p>We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
<li>APPLICABILITY AND DEFINITIONS
<p>This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The “Document”, below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as “you”. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
<p>A “Modified Version” of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
<p>A “Secondary Section” is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
<p>The “Invariant Sections” are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
<p>The “Cover Texts” are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
<p>A “Transparent” copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not “Transparent” is called “Opaque”.
<p>Examples of suitable formats for Transparent copies include plain
<span class="sc">ascii</span> without markup, Texinfo input format, LaTeX input
format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly available
<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
PostScript or <acronym>PDF</acronym> designed for human modification. Examples
of transparent image formats include <acronym>PNG</acronym>, <acronym>XCF</acronym> and
<acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, <acronym>SGML</acronym> or
<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing tools are
not generally available, and the machine-generated <acronym>HTML</acronym>,
PostScript or <acronym>PDF</acronym> produced by some word processors for
output purposes only.
<p>The “Title Page” means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, “Title Page” means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
<p>A section “Entitled XYZ” means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as “Acknowledgements”,
“Dedications”, “Endorsements”, or “History”.) To “Preserve the Title”
of such a section when you modify the Document means that it remains a
section “Entitled XYZ” according to this definition.
<p>The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
<li>VERBATIM COPYING
<p>You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
<p>You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
<li>COPYING IN QUANTITY
<p>If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
<p>If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
<p>If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
<p>It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
<li>MODIFICATIONS
<p>You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
<ol type=A start=1>
<li>Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
<li>List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
<li>State on the Title page the name of the publisher of the
Modified Version, as the publisher.
<li>Preserve all the copyright notices of the Document.
<li>Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
<li>Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
<li>Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
<li>Include an unaltered copy of this License.
<li>Preserve the section Entitled “History”, Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled “History” in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
<li>Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the “History” section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
<li>For any section Entitled “Acknowledgements” or “Dedications”, Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
<li>Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
<li>Delete any section Entitled “Endorsements”. Such a section
may not be included in the Modified Version.
<li>Do not retitle any existing section to be Entitled “Endorsements” or
to conflict in title with any Invariant Section.
<li>Preserve any Warranty Disclaimers.
</ol>
<p>If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
<p>You may add a section Entitled “Endorsements”, provided it contains
nothing but endorsements of your Modified Version by various
parties—for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
<p>You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
<p>The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
<li>COMBINING DOCUMENTS
<p>You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
<p>The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
<p>In the combination, you must combine any sections Entitled “History”
in the various original documents, forming one section Entitled
“History”; likewise combine any sections Entitled “Acknowledgements”,
and any sections Entitled “Dedications”. You must delete all
sections Entitled “Endorsements.”
<li>COLLECTIONS OF DOCUMENTS
<p>You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
<p>You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
<li>AGGREGATION WITH INDEPENDENT WORKS
<p>A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an “aggregate” if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
<p>If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
<li>TRANSLATION
<p>Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
<p>If a section in the Document is Entitled “Acknowledgements”,
“Dedications”, or “History”, the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
<li>TERMINATION
<p>You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
<li>FUTURE REVISIONS OF THIS LICENSE
<p>The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
<p>Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License “or any later version” applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
</ol>
<h4 class="appendixsubsec">A.1.1 ADDENDUM: How to use this License for your documents</h4>
<p>To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
<pre class="smallexample"> Copyright (C) <var>year</var> <var>your name</var>.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
</pre>
<p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the “with...Texts.” line with this:
<pre class="smallexample"> with the Invariant Sections being <var>list their titles</var>, with
the Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts
being <var>list</var>.
</pre>
<p>If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
<p>If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
<!-- Local Variables: -->
<!-- ispell-local-pdict: "ispell-dict" -->
<!-- End: -->
<div class="node">
<p><hr>
<a name="Concept-Index"></a>
Next: <a rel="next" accesskey="n" href="#Function-and-Data-Index">Function and Data Index</a>,
Previous: <a rel="previous" accesskey="p" href="#Copying-This-Manual">Copying This Manual</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="unnumbered">Concept Index</h2>
<ul class="index-cp" compact>
<li><a href="#index-Alert-protocol-7">Alert protocol</a>: <a href="#The-TLS-Alert-Protocol">The TLS Alert Protocol</a></li>
<li><a href="#index-Anonymous-authentication-20">Anonymous authentication</a>: <a href="#Anonymous-authentication">Anonymous authentication</a></li>
<li><a href="#index-Callback-functions-1">Callback functions</a>: <a href="#Callback-functions">Callback functions</a></li>
<li><a href="#index-Certificate-authentication-23">Certificate authentication</a>: <a href="#More-on-certificate-authentication">More on certificate authentication</a></li>
<li><a href="#index-Certificate-requests-27">Certificate requests</a>: <a href="#PKCS-_002310-certificate-requests">PKCS #10 certificate requests</a></li>
<li><a href="#index-Certificate-to-XML-convertion-444">Certificate to XML convertion</a>: <a href="#Certificate-to-XML-convertion-functions">Certificate to XML convertion functions</a></li>
<li><a href="#index-certtool-39">certtool</a>: <a href="#Invoking-certtool">Invoking certtool</a></li>
<li><a href="#index-Ciphersuites-445">Ciphersuites</a>: <a href="#All-the-supported-ciphersuites-in-GnuTLS">All the supported ciphersuites in GnuTLS</a></li>
<li><a href="#index-Client-Certificate-authentication-9">Client Certificate authentication</a>: <a href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a></li>
<li><a href="#index-Compression-algorithms-6">Compression algorithms</a>: <a href="#Compression-algorithms-used-in-the-record-layer">Compression algorithms used in the record layer</a></li>
<li><a href="#index-Digital-signatures-31">Digital signatures</a>: <a href="#Digital-signatures">Digital signatures</a></li>
<li><a href="#index-Error-codes-443">Error codes</a>: <a href="#Error-codes-and-descriptions">Error codes and descriptions</a></li>
<li><a href="#index-Example-programs-32">Example programs</a>: <a href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a></li>
<li><a href="#index-FDL_002c-GNU-Free-Documentation-License-447">FDL, GNU Free Documentation License</a>: <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></li>
<li><a href="#index-Function-reference-40">Function reference</a>: <a href="#Function-reference">Function reference</a></li>
<li><a href="#index-gnutls_002dcli-36">gnutls-cli</a>: <a href="#Invoking-gnutls_002dcli">Invoking gnutls-cli</a></li>
<li><a href="#index-gnutls_002dcli_002ddebug-37">gnutls-cli-debug</a>: <a href="#Invoking-gnutls_002dcli_002ddebug">Invoking gnutls-cli-debug</a></li>
<li><a href="#index-g_t_0040acronym_007bGnuTLS_002dextra_007d-functions-381"><acronym>GnuTLS-extra</acronym> functions</a>: <a href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a></li>
<li><a href="#index-gnutls_002dserv-38">gnutls-serv</a>: <a href="#Invoking-gnutls_002dserv">Invoking gnutls-serv</a></li>
<li><a href="#index-Handshake-protocol-8">Handshake protocol</a>: <a href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a></li>
<li><a href="#index-Inner-Application-_0028_0040acronym_007bTLS_002fIA_007d_0029-functions-422">Inner Application (<acronym>TLS/IA</acronym>) functions</a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-Internal-architecture-446">Internal architecture</a>: <a href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a></li>
<li><a href="#index-Maximum-fragment-length-13">Maximum fragment length</a>: <a href="#TLS-Extensions">TLS Extensions</a></li>
<li><a href="#index-g_t_0040acronym_007bOpenPGP_007d-functions-384"><acronym>OpenPGP</acronym> functions</a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-g_t_0040acronym_007bOpenPGP_007d-Keys-30"><acronym>OpenPGP</acronym> Keys</a>: <a href="#The-OpenPGP-trust-model">The OpenPGP trust model</a></li>
<li><a href="#index-g_t_0040acronym_007bOpenPGP_007d-Keys-19"><acronym>OpenPGP</acronym> Keys</a>: <a href="#Certificate-authentication">Certificate authentication</a></li>
<li><a href="#index-g_t_0040acronym_007bOpenPGP_007d-Server-33"><acronym>OpenPGP</acronym> Server</a>: <a href="#Echo-Server-with-OpenPGP-authentication">Echo Server with OpenPGP authentication</a></li>
<li><a href="#index-OpenSSL-34">OpenSSL</a>: <a href="#Compatibility-with-the-OpenSSL-library">Compatibility with the OpenSSL library</a></li>
<li><a href="#index-PCT-17">PCT</a>: <a href="#On-SSL-2-and-older-protocols">On SSL 2 and older protocols</a></li>
<li><a href="#index-g_t_0040acronym_007bPKCS_007d-_002310-28"><acronym>PKCS</acronym> #10</a>: <a href="#PKCS-_002310-certificate-requests">PKCS #10 certificate requests</a></li>
<li><a href="#index-g_t_0040acronym_007bPKCS_007d-_002312-29"><acronym>PKCS</acronym> #12</a>: <a href="#PKCS-_002312-structures">PKCS #12 structures</a></li>
<li><a href="#index-g_t_0040acronym_007bPSK_007d-authentication-22"><acronym>PSK</acronym> authentication</a>: <a href="#Authentication-using-PSK">Authentication using PSK</a></li>
<li><a href="#index-Record-protocol-4">Record protocol</a>: <a href="#The-TLS-record-protocol">The TLS record protocol</a></li>
<li><a href="#index-Resuming-sessions-10">Resuming sessions</a>: <a href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a></li>
<li><a href="#index-Server-name-indication-15">Server name indication</a>: <a href="#TLS-Extensions">TLS Extensions</a></li>
<li><a href="#index-g_t_0040acronym_007bSRP_007d-authentication-21"><acronym>SRP</acronym> authentication</a>: <a href="#Authentication-using-SRP">Authentication using SRP</a></li>
<li><a href="#index-srptool-35">srptool</a>: <a href="#Invoking-srptool">Invoking srptool</a></li>
<li><a href="#index-SSL-2-16">SSL 2</a>: <a href="#On-SSL-2-and-older-protocols">On SSL 2 and older protocols</a></li>
<li><a href="#index-Symmetric-encryption-algorithms-5">Symmetric encryption algorithms</a>: <a href="#Encryption-algorithms-used-in-the-record-layer">Encryption algorithms used in the record layer</a></li>
<li><a href="#index-TLS-Extensions-11">TLS Extensions</a>: <a href="#TLS-Extensions">TLS Extensions</a></li>
<li><a href="#index-g_t_0040acronym_007bTLS_007d-Inner-Application-_0028_0040acronym_007bTLS_002fIA_007d_0029-functions-421"><acronym>TLS</acronym> Inner Application (<acronym>TLS/IA</acronym>) functions</a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-TLS-Layers-2">TLS Layers</a>: <a href="#TLS-layers">TLS layers</a></li>
<li><a href="#index-Transport-protocol-3">Transport protocol</a>: <a href="#The-transport-layer">The transport layer</a></li>
<li><a href="#index-Verifying-certificate-paths-25">Verifying certificate paths</a>: <a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></li>
<li><a href="#index-g_t_0040acronym_007bX_002e509_007d-certificates-24"><acronym>X.509</acronym> certificates</a>: <a href="#The-X_002e509-trust-model">The X.509 trust model</a></li>
<li><a href="#index-g_t_0040acronym_007bX_002e509_007d-certificates-18"><acronym>X.509</acronym> certificates</a>: <a href="#Certificate-authentication">Certificate authentication</a></li>
<li><a href="#index-g_t_0040acronym_007bX_002e509_007d-Functions-227"><acronym>X.509</acronym> Functions</a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
</ul><div class="node">
<p><hr>
<a name="Function-and-Data-Index"></a>
Next: <a rel="next" accesskey="n" href="#Bibliography">Bibliography</a>,
Previous: <a rel="previous" accesskey="p" href="#Concept-Index">Concept Index</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="unnumbered">Function and Data Index</h2>
<ul class="index-fn" compact>
<li><a href="#index-gnutls_005falert_005fget-42"><code>gnutls_alert_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005falert_005fget_005fname-41"><code>gnutls_alert_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005falert_005fsend-44"><code>gnutls_alert_send</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005falert_005fsend_005fappropriate-43"><code>gnutls_alert_send_appropriate</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005fallocate_005fclient_005fcredentials-45"><code>gnutls_anon_allocate_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005fallocate_005fserver_005fcredentials-46"><code>gnutls_anon_allocate_server_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005ffree_005fclient_005fcredentials-47"><code>gnutls_anon_free_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005ffree_005fserver_005fcredentials-48"><code>gnutls_anon_free_server_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005fset_005fparams_005ffunction-49"><code>gnutls_anon_set_params_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005fset_005fserver_005fdh_005fparams-50"><code>gnutls_anon_set_server_dh_params</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fanon_005fset_005fserver_005fparams_005ffunction-51"><code>gnutls_anon_set_server_params_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fauth_005fclient_005fget_005ftype-52"><code>gnutls_auth_client_get_type</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fauth_005fget_005ftype-53"><code>gnutls_auth_get_type</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fauth_005fserver_005fget_005ftype-54"><code>gnutls_auth_server_get_type</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fbye-55"><code>gnutls_bye</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005factivation_005ftime_005fpeers-56"><code>gnutls_certificate_activation_time_peers</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fallocate_005fcredentials-57"><code>gnutls_certificate_allocate_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus-58"><code>gnutls_certificate_client_get_request_status</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fclient_005fset_005fretrieve_005ffunction-59"><code>gnutls_certificate_client_set_retrieve_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fexpiration_005ftime_005fpeers-60"><code>gnutls_certificate_expiration_time_peers</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ffree_005fca_005fnames-61"><code>gnutls_certificate_free_ca_names</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ffree_005fcas-62"><code>gnutls_certificate_free_cas</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ffree_005fcredentials-63"><code>gnutls_certificate_free_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ffree_005fcrls-64"><code>gnutls_certificate_free_crls</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ffree_005fkeys-65"><code>gnutls_certificate_free_keys</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fget_005fours-66"><code>gnutls_certificate_get_ours</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fget_005fpeers-67"><code>gnutls_certificate_get_peers</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence-68"><code>gnutls_certificate_send_x509_rdn_sequence</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fserver_005fset_005frequest-69"><code>gnutls_certificate_server_set_request</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fserver_005fset_005fretrieve_005ffunction-70"><code>gnutls_certificate_server_set_retrieve_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fdh_005fparams-71"><code>gnutls_certificate_set_dh_params</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey-390"><code>gnutls_certificate_set_openpgp_key</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile-385"><code>gnutls_certificate_set_openpgp_key_file</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem-386"><code>gnutls_certificate_set_openpgp_key_mem</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile-387"><code>gnutls_certificate_set_openpgp_keyring_file</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem-388"><code>gnutls_certificate_set_openpgp_keyring_mem</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyserver-389"><code>gnutls_certificate_set_openpgp_keyserver</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005ftrustdb-391"><code>gnutls_certificate_set_openpgp_trustdb</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fparams_005ffunction-72"><code>gnutls_certificate_set_params_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams-73"><code>gnutls_certificate_set_rsa_export_params</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fverify_005fflags-74"><code>gnutls_certificate_set_verify_flags</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fverify_005flimits-75"><code>gnutls_certificate_set_verify_limits</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fcrl-78"><code>gnutls_certificate_set_x509_crl</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile-76"><code>gnutls_certificate_set_x509_crl_file</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem-77"><code>gnutls_certificate_set_x509_crl_mem</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fkey-81"><code>gnutls_certificate_set_x509_key</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile-79"><code>gnutls_certificate_set_x509_key_file</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem-80"><code>gnutls_certificate_set_x509_key_mem</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile-82"><code>gnutls_certificate_set_x509_simple_pkcs12_file</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005ftrust-85"><code>gnutls_certificate_set_x509_trust</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile-83"><code>gnutls_certificate_set_x509_trust_file</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem-84"><code>gnutls_certificate_set_x509_trust_mem</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ftype_005fget-87"><code>gnutls_certificate_type_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ftype_005fget_005fname-86"><code>gnutls_certificate_type_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005ftype_005fset_005fpriority-88"><code>gnutls_certificate_type_set_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fverify_005fflags-26"><code>gnutls_certificate_verify_flags</code></a>: <a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></li>
<li><a href="#index-gnutls_005fcertificate_005fverify_005fpeers-90"><code>gnutls_certificate_verify_peers</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcertificate_005fverify_005fpeers2-89"><code>gnutls_certificate_verify_peers2</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcheck_005fversion-91"><code>gnutls_check_version</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcipher_005fget-94"><code>gnutls_cipher_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcipher_005fget_005fkey_005fsize-92"><code>gnutls_cipher_get_key_size</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcipher_005fget_005fname-93"><code>gnutls_cipher_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcipher_005fset_005fpriority-95"><code>gnutls_cipher_set_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcipher_005fsuite_005fget_005fname-96"><code>gnutls_cipher_suite_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcompression_005fget-98"><code>gnutls_compression_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcompression_005fget_005fname-97"><code>gnutls_compression_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcompression_005fset_005fpriority-99"><code>gnutls_compression_set_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcredentials_005fclear-100"><code>gnutls_credentials_clear</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fcredentials_005fset-101"><code>gnutls_credentials_set</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fcheck_005fentry-102"><code>gnutls_db_check_entry</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fget_005fptr-103"><code>gnutls_db_get_ptr</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fremove_005fsession-104"><code>gnutls_db_remove_session</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fset_005fcache_005fexpiration-105"><code>gnutls_db_set_cache_expiration</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fset_005fptr-106"><code>gnutls_db_set_ptr</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fset_005fremove_005ffunction-107"><code>gnutls_db_set_remove_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fset_005fretrieve_005ffunction-108"><code>gnutls_db_set_retrieve_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdb_005fset_005fstore_005ffunction-109"><code>gnutls_db_set_store_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdeinit-110"><code>gnutls_deinit</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fget_005fgroup-111"><code>gnutls_dh_get_group</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits-112"><code>gnutls_dh_get_peers_public_bits</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fget_005fprime_005fbits-113"><code>gnutls_dh_get_prime_bits</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fget_005fpubkey-114"><code>gnutls_dh_get_pubkey</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fget_005fsecret_005fbits-115"><code>gnutls_dh_get_secret_bits</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fcpy-116"><code>gnutls_dh_params_cpy</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fdeinit-117"><code>gnutls_dh_params_deinit</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fexport_005fpkcs3-118"><code>gnutls_dh_params_export_pkcs3</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fexport_005fraw-119"><code>gnutls_dh_params_export_raw</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fgenerate2-120"><code>gnutls_dh_params_generate2</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fimport_005fpkcs3-121"><code>gnutls_dh_params_import_pkcs3</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005fimport_005fraw-122"><code>gnutls_dh_params_import_raw</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fparams_005finit-123"><code>gnutls_dh_params_init</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fdh_005fset_005fprime_005fbits-124"><code>gnutls_dh_set_prime_bits</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ferror_005fis_005ffatal-125"><code>gnutls_error_is_fatal</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ferror_005fto_005falert-126"><code>gnutls_error_to_alert</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fextra_005fcheck_005fversion-382"><code>gnutls_extra_check_version</code></a>: <a href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a></li>
<li><a href="#index-gnutls_005ffingerprint-127"><code>gnutls_fingerprint</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ffree-128"><code>gnutls_free</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fglobal_005fdeinit-129"><code>gnutls_global_deinit</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fglobal_005finit-130"><code>gnutls_global_init</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fglobal_005finit_005fextra-383"><code>gnutls_global_init_extra</code></a>: <a href="#GnuTLS_002dextra-functions">GnuTLS-extra functions</a></li>
<li><a href="#index-gnutls_005fglobal_005fset_005flog_005ffunction-131"><code>gnutls_global_set_log_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fglobal_005fset_005flog_005flevel-132"><code>gnutls_global_set_log_level</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fglobal_005fset_005fmem_005ffunctions-133"><code>gnutls_global_set_mem_functions</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhandshake-138"><code>gnutls_handshake</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhandshake_005fget_005flast_005fin-134"><code>gnutls_handshake_get_last_in</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhandshake_005fget_005flast_005fout-135"><code>gnutls_handshake_get_last_out</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength-136"><code>gnutls_handshake_set_max_packet_length</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhandshake_005fset_005fprivate_005fextensions-137"><code>gnutls_handshake_set_private_extensions</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhex_005fdecode-139"><code>gnutls_hex_decode</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fhex_005fencode-140"><code>gnutls_hex_encode</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fia_005fallocate_005fclient_005fcredentials-423"><code>gnutls_ia_allocate_client_credentials</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fallocate_005fserver_005fcredentials-424"><code>gnutls_ia_allocate_server_credentials</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fenable-425"><code>gnutls_ia_enable</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fendphase_005fsend-426"><code>gnutls_ia_endphase_send</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fextract_005finner_005fsecret-427"><code>gnutls_ia_extract_inner_secret</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005ffree_005fclient_005fcredentials-428"><code>gnutls_ia_free_client_credentials</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005ffree_005fserver_005fcredentials-429"><code>gnutls_ia_free_server_credentials</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fgenerate_005fchallenge-430"><code>gnutls_ia_generate_challenge</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fget_005fclient_005favp_005fptr-431"><code>gnutls_ia_get_client_avp_ptr</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fget_005fserver_005favp_005fptr-432"><code>gnutls_ia_get_server_avp_ptr</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fhandshake-434"><code>gnutls_ia_handshake</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fhandshake_005fp-433"><code>gnutls_ia_handshake_p</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fpermute_005finner_005fsecret-435"><code>gnutls_ia_permute_inner_secret</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005frecv-436"><code>gnutls_ia_recv</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fsend-437"><code>gnutls_ia_send</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fset_005fclient_005favp_005ffunction-438"><code>gnutls_ia_set_client_avp_function</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fset_005fclient_005favp_005fptr-439"><code>gnutls_ia_set_client_avp_ptr</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fset_005fserver_005favp_005ffunction-440"><code>gnutls_ia_set_server_avp_function</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fset_005fserver_005favp_005fptr-441"><code>gnutls_ia_set_server_avp_ptr</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005fia_005fverify_005fendphase-442"><code>gnutls_ia_verify_endphase</code></a>: <a href="#TLS-Inner-Application-_0028TLS_002fIA_0029-functions">TLS Inner Application (TLS/IA) functions</a></li>
<li><a href="#index-gnutls_005finit-141"><code>gnutls_init</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fkx_005fget-143"><code>gnutls_kx_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fkx_005fget_005fname-142"><code>gnutls_kx_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fkx_005fset_005fpriority-144"><code>gnutls_kx_set_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fmac_005fget-146"><code>gnutls_mac_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fmac_005fget_005fname-145"><code>gnutls_mac_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fmac_005fset_005fpriority-147"><code>gnutls_mac_set_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fmalloc-148"><code>gnutls_malloc</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fcheck_005fhostname-392"><code>gnutls_openpgp_key_check_hostname</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fdeinit-393"><code>gnutls_openpgp_key_deinit</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fexport-394"><code>gnutls_openpgp_key_export</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fcreation_005ftime-395"><code>gnutls_openpgp_key_get_creation_time</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fexpiration_005ftime-396"><code>gnutls_openpgp_key_get_expiration_time</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005ffingerprint-397"><code>gnutls_openpgp_key_get_fingerprint</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fid-398"><code>gnutls_openpgp_key_get_id</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fkey_005fusage-399"><code>gnutls_openpgp_key_get_key_usage</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fname-400"><code>gnutls_openpgp_key_get_name</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fpk_005falgorithm-401"><code>gnutls_openpgp_key_get_pk_algorithm</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fget_005fversion-402"><code>gnutls_openpgp_key_get_version</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fimport-403"><code>gnutls_openpgp_key_import</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005finit-404"><code>gnutls_openpgp_key_init</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fto_005fxml-405"><code>gnutls_openpgp_key_to_xml</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fverify_005fring-406"><code>gnutls_openpgp_key_verify_ring</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fverify_005fself-407"><code>gnutls_openpgp_key_verify_self</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkey_005fverify_005ftrustdb-408"><code>gnutls_openpgp_key_verify_trustdb</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkeyring_005fcheck_005fid-409"><code>gnutls_openpgp_keyring_check_id</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkeyring_005fdeinit-410"><code>gnutls_openpgp_keyring_deinit</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkeyring_005fimport-411"><code>gnutls_openpgp_keyring_import</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fkeyring_005finit-412"><code>gnutls_openpgp_keyring_init</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fprivkey_005fdeinit-413"><code>gnutls_openpgp_privkey_deinit</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm-414"><code>gnutls_openpgp_privkey_get_pk_algorithm</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fprivkey_005fimport-415"><code>gnutls_openpgp_privkey_import</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fprivkey_005finit-416"><code>gnutls_openpgp_privkey_init</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fsend_005fkey-149"><code>gnutls_openpgp_send_key</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction-417"><code>gnutls_openpgp_set_recv_key_function</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005ftrustdb_005fdeinit-418"><code>gnutls_openpgp_trustdb_deinit</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005ftrustdb_005fimport_005ffile-419"><code>gnutls_openpgp_trustdb_import_file</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fopenpgp_005ftrustdb_005finit-420"><code>gnutls_openpgp_trustdb_init</code></a>: <a href="#OpenPGP-functions">OpenPGP functions</a></li>
<li><a href="#index-gnutls_005fpem_005fbase64_005fdecode-151"><code>gnutls_pem_base64_decode</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpem_005fbase64_005fdecode_005falloc-150"><code>gnutls_pem_base64_decode_alloc</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpem_005fbase64_005fencode-153"><code>gnutls_pem_base64_encode</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpem_005fbase64_005fencode_005falloc-152"><code>gnutls_pem_base64_encode_alloc</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fperror-154"><code>gnutls_perror</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpk_005falgorithm_005fget_005fname-155"><code>gnutls_pk_algorithm_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fdecrypt-228"><code>gnutls_pkcs12_bag_decrypt</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fdeinit-229"><code>gnutls_pkcs12_bag_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fencrypt-230"><code>gnutls_pkcs12_bag_encrypt</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005fcount-231"><code>gnutls_pkcs12_bag_get_count</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005fdata-232"><code>gnutls_pkcs12_bag_get_data</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname-233"><code>gnutls_pkcs12_bag_get_friendly_name</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid-234"><code>gnutls_pkcs12_bag_get_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005ftype-235"><code>gnutls_pkcs12_bag_get_type</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005finit-236"><code>gnutls_pkcs12_bag_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fcrl-237"><code>gnutls_pkcs12_bag_set_crl</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fcrt-238"><code>gnutls_pkcs12_bag_set_crt</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fdata-239"><code>gnutls_pkcs12_bag_set_data</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname-240"><code>gnutls_pkcs12_bag_set_friendly_name</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid-241"><code>gnutls_pkcs12_bag_set_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fdeinit-242"><code>gnutls_pkcs12_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fexport-243"><code>gnutls_pkcs12_export</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fgenerate_005fmac-244"><code>gnutls_pkcs12_generate_mac</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fget_005fbag-245"><code>gnutls_pkcs12_get_bag</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fimport-246"><code>gnutls_pkcs12_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005finit-247"><code>gnutls_pkcs12_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fset_005fbag-248"><code>gnutls_pkcs12_set_bag</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs12_005fverify_005fmac-249"><code>gnutls_pkcs12_verify_mac</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fdeinit-250"><code>gnutls_pkcs7_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fdelete_005fcrl-251"><code>gnutls_pkcs7_delete_crl</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fdelete_005fcrt-252"><code>gnutls_pkcs7_delete_crt</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fexport-253"><code>gnutls_pkcs7_export</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fget_005fcrl_005fcount-254"><code>gnutls_pkcs7_get_crl_count</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fget_005fcrl_005fraw-255"><code>gnutls_pkcs7_get_crl_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fget_005fcrt_005fcount-256"><code>gnutls_pkcs7_get_crt_count</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fget_005fcrt_005fraw-257"><code>gnutls_pkcs7_get_crt_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fimport-258"><code>gnutls_pkcs7_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005finit-259"><code>gnutls_pkcs7_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fset_005fcrl-261"><code>gnutls_pkcs7_set_crl</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fset_005fcrl_005fraw-260"><code>gnutls_pkcs7_set_crl_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fset_005fcrt-263"><code>gnutls_pkcs7_set_crt</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fpkcs7_005fset_005fcrt_005fraw-262"><code>gnutls_pkcs7_set_crt_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fprf-157"><code>gnutls_prf</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fprf_005fraw-156"><code>gnutls_prf_raw</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fprotocol_005fget_005fname-158"><code>gnutls_protocol_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fprotocol_005fget_005fversion-159"><code>gnutls_protocol_get_version</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fprotocol_005fset_005fpriority-160"><code>gnutls_protocol_set_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fallocate_005fclient_005fcredentials-161"><code>gnutls_psk_allocate_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fallocate_005fserver_005fcredentials-162"><code>gnutls_psk_allocate_server_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005ffree_005fclient_005fcredentials-163"><code>gnutls_psk_free_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005ffree_005fserver_005fcredentials-164"><code>gnutls_psk_free_server_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fserver_005fget_005fusername-165"><code>gnutls_psk_server_get_username</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fclient_005fcredentials-167"><code>gnutls_psk_set_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction-166"><code>gnutls_psk_set_client_credentials_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fparams_005ffunction-168"><code>gnutls_psk_set_params_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile-169"><code>gnutls_psk_set_server_credentials_file</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction-170"><code>gnutls_psk_set_server_credentials_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fserver_005fdh_005fparams-171"><code>gnutls_psk_set_server_dh_params</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction-172"><code>gnutls_psk_set_server_params_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frecord_005fcheck_005fpending-173"><code>gnutls_record_check_pending</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frecord_005fget_005fdirection-174"><code>gnutls_record_get_direction</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frecord_005fget_005fmax_005fsize-175"><code>gnutls_record_get_max_size</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frecord_005frecv-176"><code>gnutls_record_recv</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frecord_005fsend-177"><code>gnutls_record_send</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frecord_005fset_005fmax_005fsize-178"><code>gnutls_record_set_max_size</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frehandshake-179"><code>gnutls_rehandshake</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits-180"><code>gnutls_rsa_export_get_modulus_bits</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fexport_005fget_005fpubkey-181"><code>gnutls_rsa_export_get_pubkey</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fcpy-182"><code>gnutls_rsa_params_cpy</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fdeinit-183"><code>gnutls_rsa_params_deinit</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fexport_005fpkcs1-184"><code>gnutls_rsa_params_export_pkcs1</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fexport_005fraw-185"><code>gnutls_rsa_params_export_raw</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fgenerate2-186"><code>gnutls_rsa_params_generate2</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fimport_005fpkcs1-187"><code>gnutls_rsa_params_import_pkcs1</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005fimport_005fraw-188"><code>gnutls_rsa_params_import_raw</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005frsa_005fparams_005finit-189"><code>gnutls_rsa_params_init</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fserver_005fname_005fget-190"><code>gnutls_server_name_get</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fserver_005fname_005fset-191"><code>gnutls_server_name_set</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fclient_005frandom-192"><code>gnutls_session_get_client_random</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fdata-194"><code>gnutls_session_get_data</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fdata2-193"><code>gnutls_session_get_data2</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fid-195"><code>gnutls_session_get_id</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fmaster_005fsecret-196"><code>gnutls_session_get_master_secret</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fptr-197"><code>gnutls_session_get_ptr</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fget_005fserver_005frandom-198"><code>gnutls_session_get_server_random</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fis_005fresumed-199"><code>gnutls_session_is_resumed</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fset_005fdata-200"><code>gnutls_session_set_data</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsession_005fset_005fptr-201"><code>gnutls_session_set_ptr</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fset_005fdefault_005fexport_005fpriority-202"><code>gnutls_set_default_export_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fset_005fdefault_005fpriority-203"><code>gnutls_set_default_priority</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsign_005falgorithm_005fget_005fname-204"><code>gnutls_sign_algorithm_get_name</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fallocate_005fclient_005fcredentials-205"><code>gnutls_srp_allocate_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fallocate_005fserver_005fcredentials-206"><code>gnutls_srp_allocate_server_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fbase64_005fdecode-208"><code>gnutls_srp_base64_decode</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fbase64_005fdecode_005falloc-207"><code>gnutls_srp_base64_decode_alloc</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fbase64_005fencode-210"><code>gnutls_srp_base64_encode</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fbase64_005fencode_005falloc-209"><code>gnutls_srp_base64_encode_alloc</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005ffree_005fclient_005fcredentials-211"><code>gnutls_srp_free_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005ffree_005fserver_005fcredentials-212"><code>gnutls_srp_free_server_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fserver_005fget_005fusername-213"><code>gnutls_srp_server_get_username</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fset_005fclient_005fcredentials-215"><code>gnutls_srp_set_client_credentials</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction-214"><code>gnutls_srp_set_client_credentials_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile-216"><code>gnutls_srp_set_server_credentials_file</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction-217"><code>gnutls_srp_set_server_credentials_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fsrp_005fverifier-218"><code>gnutls_srp_verifier</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fstrerror-219"><code>gnutls_strerror</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fget_005fptr-221"><code>gnutls_transport_get_ptr</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fget_005fptr2-220"><code>gnutls_transport_get_ptr2</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fset_005flowat-222"><code>gnutls_transport_set_lowat</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fset_005fptr-224"><code>gnutls_transport_set_ptr</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fset_005fptr2-223"><code>gnutls_transport_set_ptr2</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fset_005fpull_005ffunction-225"><code>gnutls_transport_set_pull_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005ftransport_005fset_005fpush_005ffunction-226"><code>gnutls_transport_set_push_function</code></a>: <a href="#Core-functions">Core functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fcheck_005fissuer-264"><code>gnutls_x509_crl_check_issuer</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fdeinit-265"><code>gnutls_x509_crl_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fexport-266"><code>gnutls_x509_crl_export</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount-267"><code>gnutls_x509_crl_get_crt_count</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial-268"><code>gnutls_x509_crl_get_crt_serial</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fdn_005foid-269"><code>gnutls_x509_crl_get_dn_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn-271"><code>gnutls_x509_crl_get_issuer_dn</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid-270"><code>gnutls_x509_crl_get_issuer_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate-272"><code>gnutls_x509_crl_get_next_update</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm-273"><code>gnutls_x509_crl_get_signature_algorithm</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate-274"><code>gnutls_x509_crl_get_this_update</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fget_005fversion-275"><code>gnutls_x509_crl_get_version</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fimport-276"><code>gnutls_x509_crl_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005finit-277"><code>gnutls_x509_crl_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fset_005fcrt-279"><code>gnutls_x509_crl_set_crt</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial-278"><code>gnutls_x509_crl_set_crt_serial</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate-280"><code>gnutls_x509_crl_set_next_update</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate-281"><code>gnutls_x509_crl_set_this_update</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fset_005fversion-282"><code>gnutls_x509_crl_set_version</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fsign-284"><code>gnutls_x509_crl_sign</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fsign2-283"><code>gnutls_x509_crl_sign2</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrl_005fverify-285"><code>gnutls_x509_crl_verify</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fdeinit-286"><code>gnutls_x509_crq_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fexport-287"><code>gnutls_x509_crq_export</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid-288"><code>gnutls_x509_crq_get_attribute_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword-289"><code>gnutls_x509_crq_get_challenge_password</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fdn-292"><code>gnutls_x509_crq_get_dn</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid-290"><code>gnutls_x509_crq_get_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fdn_005foid-291"><code>gnutls_x509_crq_get_dn_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm-293"><code>gnutls_x509_crq_get_pk_algorithm</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fget_005fversion-294"><code>gnutls_x509_crq_get_version</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fimport-295"><code>gnutls_x509_crq_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005finit-296"><code>gnutls_x509_crq_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid-297"><code>gnutls_x509_crq_set_attribute_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword-298"><code>gnutls_x509_crq_set_challenge_password</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid-299"><code>gnutls_x509_crq_set_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fset_005fkey-300"><code>gnutls_x509_crq_set_key</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fset_005fversion-301"><code>gnutls_x509_crq_set_version</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fsign-303"><code>gnutls_x509_crq_sign</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrq_005fsign2-302"><code>gnutls_x509_crq_sign2</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fcheck_005fhostname-304"><code>gnutls_x509_crt_check_hostname</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fcheck_005fissuer-305"><code>gnutls_x509_crt_check_issuer</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fcheck_005frevocation-306"><code>gnutls_x509_crt_check_revocation</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints-307"><code>gnutls_x509_crt_cpy_crl_dist_points</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fdeinit-308"><code>gnutls_x509_crt_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fexport-309"><code>gnutls_x509_crt_export</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005factivation_005ftime-310"><code>gnutls_x509_crt_get_activation_time</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid-311"><code>gnutls_x509_crt_get_authority_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fca_005fstatus-312"><code>gnutls_x509_crt_get_ca_status</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints-313"><code>gnutls_x509_crt_get_crl_dist_points</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn-316"><code>gnutls_x509_crt_get_dn</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid-314"><code>gnutls_x509_crt_get_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn_005foid-315"><code>gnutls_x509_crt_get_dn_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime-317"><code>gnutls_x509_crt_get_expiration_time</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid-318"><code>gnutls_x509_crt_get_extension_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fextension_005foid-319"><code>gnutls_x509_crt_get_extension_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005ffingerprint-320"><code>gnutls_x509_crt_get_fingerprint</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn-323"><code>gnutls_x509_crt_get_issuer_dn</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid-321"><code>gnutls_x509_crt_get_issuer_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid-322"><code>gnutls_x509_crt_get_issuer_dn_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fid-324"><code>gnutls_x509_crt_get_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid-325"><code>gnutls_x509_crt_get_key_purpose_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fusage-326"><code>gnutls_x509_crt_get_key_usage</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm-327"><code>gnutls_x509_crt_get_pk_algorithm</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw-328"><code>gnutls_x509_crt_get_pk_dsa_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw-329"><code>gnutls_x509_crt_get_pk_rsa_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fserial-330"><code>gnutls_x509_crt_get_serial</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm-331"><code>gnutls_x509_crt_get_signature_algorithm</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname-332"><code>gnutls_x509_crt_get_subject_alt_name</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid-333"><code>gnutls_x509_crt_get_subject_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fget_005fversion-334"><code>gnutls_x509_crt_get_version</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fimport-335"><code>gnutls_x509_crt_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005finit-336"><code>gnutls_x509_crt_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005flist_005fimport-337"><code>gnutls_x509_crt_list_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005flist_005fverify-338"><code>gnutls_x509_crt_list_verify</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005factivation_005ftime-339"><code>gnutls_x509_crt_set_activation_time</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid-340"><code>gnutls_x509_crt_set_authority_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fca_005fstatus-341"><code>gnutls_x509_crt_set_ca_status</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints-342"><code>gnutls_x509_crt_set_crl_dist_points</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fcrq-343"><code>gnutls_x509_crt_set_crq</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid-344"><code>gnutls_x509_crt_set_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime-345"><code>gnutls_x509_crt_set_expiration_time</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid-346"><code>gnutls_x509_crt_set_extension_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid-347"><code>gnutls_x509_crt_set_issuer_dn_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fkey-350"><code>gnutls_x509_crt_set_key</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid-348"><code>gnutls_x509_crt_set_key_purpose_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fkey_005fusage-349"><code>gnutls_x509_crt_set_key_usage</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fserial-351"><code>gnutls_x509_crt_set_serial</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname-352"><code>gnutls_x509_crt_set_subject_alternative_name</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid-353"><code>gnutls_x509_crt_set_subject_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fset_005fversion-354"><code>gnutls_x509_crt_set_version</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fsign-356"><code>gnutls_x509_crt_sign</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fsign2-355"><code>gnutls_x509_crt_sign2</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fto_005fxml-357"><code>gnutls_x509_crt_to_xml</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fverify-359"><code>gnutls_x509_crt_verify</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fcrt_005fverify_005fdata-358"><code>gnutls_x509_crt_verify_data</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fdn_005foid_005fknown-360"><code>gnutls_x509_dn_oid_known</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fcpy-361"><code>gnutls_x509_privkey_cpy</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fdeinit-362"><code>gnutls_x509_privkey_deinit</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fexport-366"><code>gnutls_x509_privkey_export</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw-363"><code>gnutls_x509_privkey_export_dsa_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005fpkcs8-364"><code>gnutls_x509_privkey_export_pkcs8</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw-365"><code>gnutls_x509_privkey_export_rsa_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005ffix-367"><code>gnutls_x509_privkey_fix</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fgenerate-368"><code>gnutls_x509_privkey_generate</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fget_005fkey_005fid-369"><code>gnutls_x509_privkey_get_key_id</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm-370"><code>gnutls_x509_privkey_get_pk_algorithm</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fimport-374"><code>gnutls_x509_privkey_import</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw-371"><code>gnutls_x509_privkey_import_dsa_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fpkcs8-372"><code>gnutls_x509_privkey_import_pkcs8</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw-373"><code>gnutls_x509_privkey_import_rsa_raw</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005finit-375"><code>gnutls_x509_privkey_init</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fsign_005fdata-376"><code>gnutls_x509_privkey_sign_data</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005fprivkey_005fverify_005fdata-377"><code>gnutls_x509_privkey_verify_data</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005frdn_005fget-380"><code>gnutls_x509_rdn_get</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005frdn_005fget_005fby_005foid-378"><code>gnutls_x509_rdn_get_by_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
<li><a href="#index-gnutls_005fx509_005frdn_005fget_005foid-379"><code>gnutls_x509_rdn_get_oid</code></a>: <a href="#X_002e509-certificate-functions">X.509 certificate functions</a></li>
</ul><!-- texi2dvi has problem if unnumbered is put there. However makeinfo works great. -->
<!-- STUPID texinfo. -->
<!-- @node @mybibnode{} -->
<!-- @unnumbered @mybibnode{} -->
<div class="node">
<p><hr>
<a name="Bibliography"></a>
Previous: <a rel="previous" accesskey="p" href="#Function-and-Data-Index">Function and Data Index</a>,
Up: <a rel="up" accesskey="u" href="#Top">Top</a>
</div>
<h2 class="unnumbered">Bibliography</h2>
<dl>
<!-- %**else if -->
<dt><a name="CBCATT"></a>[CBCATT]<dd>
Bodo Moeller, "Security of CBC Ciphersuites in SSL/TLS: Problems and Countermeasures",
2002, Available from <a href="http://www.openssl.org/~bodo/tls-cbc.txt">http://www.openssl.org/~bodo/tls-cbc.txt</a>.
<!-- %**else if -->
<br><dt><a name="GPGH"></a>[GPGH]<dd>
Mike Ashley, "The GNU Privacy Handbook", 2002,
Available from <a href="http://www.gnupg.org/gph/en/manual.pdf">http://www.gnupg.org/gph/en/manual.pdf</a>.
<!-- %**else if -->
<br><dt><a name="GUTPKI"></a>[GUTPKI]<dd>
Peter Gutmann, "Everything you never wanted to know about PKI but were forced to find out",
Available from <a href="http://www.cs.auckland.ac.nz/~pgut001/">http://www.cs.auckland.ac.nz/~pgut001/</a>.
<!-- %**else if -->
<br><dt><a name="RFC2246"></a>[RFC2246]<dd>
Tim Dierks and Christopher Allen, "The TLS Protocol Version 1.0",
January 1999, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2246.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2246.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC4346"></a>[RFC4346]<dd>
Tim Dierks and Eric Rescorla, "The TLS Protocol Version 1.1",
Match 2006, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc4346.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc4346.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC2440"></a>[RFC2440]<dd>
Jon Callas, Lutz Donnerhacke, Hal Finney and Rodney Thayer,
"OpenPGP Message Format", November 1998, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2440.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2440.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC2511"></a>[RFC2511]<dd>
Michael Myers, Carlisle Adams, Dave Solo and David Kemp,
"Internet X.509 Certificate Request Message Format", March 1999, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2511.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2511.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC2817"></a>[RFC2817]<dd>
Rohit Khare and Scott Lawrence, "Upgrading to TLS Within HTTP/1.1",
May 2000, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2817.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2817.txt</a>
<!-- %**else if -->
<br><dt><a name="RFC2818"></a>[RFC2818]<dd>
Eric Rescola, "HTTP Over TLS", May 2000,
Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2818.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2818.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC2945"></a>[RFC2945]<dd>
Tom Wu, "The SRP Authentication and Key Exchange System",
September 2000, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2945.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2945.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC2986"></a>[RFC2986]<dd>
Magnus Nystrom and Burt Kaliski, "PKCS 10 v1.7: Certification Request Syntax Specification",
November 2000, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2986.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc2986.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC3280"></a>[RFC3280]<dd>
Russell Housley, Tim Polk, Warwick Ford and David Solo,
"Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile",
April 2002, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc3280.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc3280.txt</a>.
<!-- %**else if -->
<br><dt><a name="RFC3749"></a>[RFC3749]<dd>
Scott Hollenbeck, "Transport Layer Security Protocol Compression Methods",
May 2004, Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc3749.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc3749.txt</a>.
<!-- %**else if -->
<br><dt><a name="PKCS12"></a>[PKCS12]<dd>
RSA Laboratories, "PKCS 12 v1.0: Personal Information Exchange Syntax",
June 1999, Available from <a href="http://www.rsa.com">http://www.rsa.com</a>.
<!-- %**else if -->
<br><dt><a name="RESCOLA"></a>[RESCOLA]<dd>
Eric Rescola, "SSL and TLS: Designing and Building Secure Systems", 2001
<!-- %**else if -->
<br><dt><a name="SSL3"></a>[SSL3]<dd>
Alan Freier, Philip Karlton and Paul Kocher, "The SSL Protocol Version 3.0",
November 1996, Available from <a href="http://wp.netscape.com/eng/ssl3/draft302.txt">http://wp.netscape.com/eng/ssl3/draft302.txt</a>.
<!-- %**else if -->
<br><dt><a name="STEVENS"></a>[STEVENS]<dd>
Richard Stevens, "UNIX Network Programming, Volume 1", Prentice Hall PTR,
January 1998
<!-- %**else if -->
<br><dt><a name="TLSEXT"></a>[TLSEXT]<dd>
Simon Blake-Wilson, Magnus Nystrom, David Hopwood, Jan Mikkelsen and Tim Wright,
"Transport Layer Security (TLS) Extensions", June 2003,
Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc3546.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc3546.txt</a>.
<!-- %**else if -->
<br><dt><a name="TLSPGP"></a>[TLSPGP]<dd>
Nikos Mavrogiannopoulos, "Using OpenPGP keys for TLS authentication",
April 2004, Internet draft, work in progress. Available from <a href="http://www.normos.org/ietf/draft/draft-ietf-tls-openpgp-keys-05.txt">http://www.normos.org/ietf/draft/draft-ietf-tls-openpgp-keys-05.txt</a>.
<!-- %**else if -->
<br><dt><a name="TLSSRP"></a>[TLSSRP]<dd>
David Taylor, Trevor Perrin, Tom Wu and Nikos Mavrogiannopoulos,
"Using SRP for TLS Authentication", August 2005,
Internet draft, work in progress. Available from <a href="http://www.normos.org/ietf/draft/draft-ietf-tls-srp-08.txt">http://www.normos.org/ietf/draft/draft-ietf-tls-srp-08.txt</a>.
<!-- %**else if -->
<br><dt><a name="TLSPSK"></a>[TLSPSK]<dd>
Pasi Eronen and Hannes Tschofenig,
"Pre-shared key Ciphersuites for TLS", December 2005,
Available from <a href="http://kaizi.viagenie.qc.ca/ietf/rfc/rfc4279.txt">http://kaizi.viagenie.qc.ca/ietf/rfc/rfc4279.txt</a>.
<!-- %**else if -->
<br><dt><a name="TOMSRP"></a>[TOMSRP]<dd>
Tom Wu, "The Stanford SRP Authentication Project",
Available at <a href="http://srp.stanford.edu/">http://srp.stanford.edu/</a>.
<!-- %**else if -->
<br><dt><a name="WEGER"></a>[WEGER]<dd>
Arjen Lenstra and Xiaoyun Wang and Benne de Weger, "Colliding X.509 Certificates",
Cryptology ePrint Archive, Report 2005/067,
Available at <a href="http://eprint.iacr.org/">http://eprint.iacr.org/</a>.
</dl>
<div class="footnote">
<hr>
<a name="texinfo-footnotes-in-document"></a><h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> A copy of the license is included in the
distribution</p>
<p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> <a href="http://www.openssl.org/">http://www.openssl.org/</a></p>
<p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small> <a href="ftp://ftp.gnupg.org/gcrypt/alpha/gnutls/libtasn1/">ftp://ftp.gnupg.org/gcrypt/alpha/gnutls/libtasn1/</a></p>
<p class="footnote"><small>[<a name="fn-4" href="#fnd-4">4</a>]</small> <a href="ftp://ftp.gnupg.org/gcrypt/alpha/gnutls/opencdk/">ftp://ftp.gnupg.org/gcrypt/alpha/gnutls/opencdk/</a></p>
<p class="footnote"><small>[<a name="fn-5" href="#fnd-5">5</a>]</small> <a href="ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/">ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/</a></p>
<p class="footnote"><small>[<a name="fn-6" href="#fnd-6">6</a>]</small> The first message in a <acronym>TLS</acronym> handshake</p>
<p class="footnote"><small>[<a name="fn-7" href="#fnd-7">7</a>]</small> IETF, or Internet
Engineering Task Force, is a large open international community of
network designers, operators, vendors, and researchers concerned with
the evolution of the Internet architecture and the smooth operation of
the Internet. It is open to any interested individual.</p>
<p class="footnote"><small>[<a name="fn-8" href="#fnd-8">8</a>]</small> AES,
or Advanced Encryption Standard, is actually the RIJNDAEL algorithm.
This is the algorithm that replaced DES.</p>
<p class="footnote"><small>[<a name="fn-9" href="#fnd-9">9</a>]</small> <code>ARCFOUR_128</code> is a compatible
algorithm with RSA's RC4 algorithm, which is considered to be a trade
secret.</p>
<p class="footnote"><small>[<a name="fn-10" href="#fnd-10">10</a>]</small> You should use
<a href="#gnutls_005fhandshake_005fset_005fprivate_005fextensions">gnutls_handshake_set_private_extensions</a> to enable private
extensions.</p>
<p class="footnote"><small>[<a name="fn-11" href="#fnd-11">11</a>]</small> MAC stands for Message Authentication Code. It can be described as a keyed hash algorithm. See RFC2104.</p>
<p class="footnote"><small>[<a name="fn-12" href="#fnd-12">12</a>]</small> It really depends on the group used. Primes with
lesser bits are always faster, but also easier to break. Values less
than 768 should not be used today</p>
<p class="footnote"><small>[<a name="fn-13" href="#fnd-13">13</a>]</small> <acronym>SRP</acronym> is described in <!-- %**else if -->
[RFC2945] (See <a href="#Bibliography">RFC2945</a>.)
</p>
<p class="footnote"><small>[<a name="fn-14" href="#fnd-14">14</a>]</small> See also the Server Name Indication extension on
<a href="#serverind">serverind</a>.</p>
<p class="footnote"><small>[<a name="fn-15" href="#fnd-15">15</a>]</small> See LDAP, IMAP etc.</p>
<p class="footnote"><small>[<a name="fn-16" href="#fnd-16">16</a>]</small> in <acronym>SRP</acronym> authentication</p>
<p class="footnote"><small>[<a name="fn-17" href="#fnd-17">17</a>]</small> such as the <code>gnutls_certificate_credentials_t</code> structures</p>
<p><hr></div>
</body></html>
|