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
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is last updated 29 January 2013 for version
3.1.7 of GnuTLS.
Copyright (C) 2001-2013 Free Software Foundation, Inc.\\
Copyright (C) 2001-2013 Nikos Mavrogiannopoulos
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 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". -->
<!-- Created by GNU Texinfo 4.13.90, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GnuTLS 3.1.7</title>
<meta name="description" content="GnuTLS 3.1.7">
<meta name="keywords" content="GnuTLS 3.1.7">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#Top" rel="start" title="Top">
<link href="#Function-and-Data-Index" rel="index" title="Function and Data Index">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<link href="dir.html#Top" rel="up" title="(dir)">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {
margin: 2%;
padding: 0 5%;
background: #ffffff;
}
h1,h2,h3,h4,h5 {
font-weight: bold;
padding: 5px 5px 5px 5px;
background-color: #c2e0ff;
color: #336699;
}
h1 {
padding: 2em 2em 2em 5%;
color: white;
background: #336699;
text-align: center;
letter-spacing: 3px;
}
h2 { text-decoration: underline; }
pre {
margin: 0 5%;
padding: 0.5em;
}
pre.example,pre.verbatim {
padding-bottom: 1em;
border: solid #c2e0ff;
background: #f0faff;
border-width: 1px 1px 1px 5px;
margin: 1em auto;
width: 90%;
}
div.node {
margin: 0 -5% 0 -2%;
padding: 0.5em 0.5em;
margin-top: 0.5em;
margin-bottom: 0.5em;
font-weight: bold;
}
dd, li {
padding-top: 0.1em;
padding-bottom: 0.1em;
}
div.float {
margin-bottom: 0.5em;
text-align: center;
}
table {
text-align: left;
margin-left:auto;
margin-right:auto;
width: 50%;
}
th {
padding: 0;
color: #336699;
background-color: #c2e0ff;
border: solid #000000;
border-width: 0px;
margin: 1em auto;
text-align: center;
margin-left:auto;
margin-right:auto;
}
td {
padding: 0;
border: solid #000000;
background-color: #f0faff;
border-width: 0px;
margin: 1em auto;
text-align: left;
margin-left:auto;
margin-right:auto;
padding-left: 1em;
}
dl {
text-align: left;
margin-left:auto;
margin-right:auto;
width: 50%;
padding-left: 1em;
border: solid #c2e0ff;
background: #f0faff;
border-width: 5px 1px 1px 1px;
margin: 1em auto;
}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1 class="settitle" align="center">GnuTLS 3.1.7</h1>
<a name="SEC_Contents"></a>
<h2 class="contents-heading">Table of Contents</h2>
<div class="contents">
<ul class="no-bullet">
<li><a name="toc-Preface-1" href="#Preface">1 Preface</a></li>
<li><a name="toc-Introduction-to-GnuTLS-1" href="#Introduction-to-GnuTLS">2 Introduction to GnuTLS</a>
<ul class="no-bullet">
<li><a name="toc-Downloading-and-installing-1" href="#Downloading-and-installing">2.1 Downloading and installing</a></li>
<li><a name="toc-Overview" href="#Document-overview">2.2 Overview</a></li>
</ul></li>
<li><a name="toc-Introduction-to-TLS-and-DTLS" href="#Introduction-to-TLS">3 Introduction to <acronym>TLS</acronym> and <acronym>DTLS</acronym></a>
<ul class="no-bullet">
<li><a name="toc-TLS-layers-1" href="#TLS-layers">3.1 TLS layers</a></li>
<li><a name="toc-The-transport-layer-1" href="#The-transport-layer">3.2 The transport layer</a></li>
<li><a name="toc-The-TLS-record-protocol-1" href="#The-TLS-record-protocol">3.3 The TLS record protocol</a>
<ul class="no-bullet">
<li><a name="toc-Encryption-algorithms-used-in-the-record-layer-1" href="#Encryption-algorithms-used-in-the-record-layer">3.3.1 Encryption algorithms used in the record layer</a></li>
<li><a name="toc-Compression-algorithms-used-in-the-record-layer-1" href="#Compression-algorithms-used-in-the-record-layer">3.3.2 Compression algorithms used in the record layer</a></li>
<li><a name="toc-Weaknesses-and-countermeasures-1" href="#Weaknesses-and-countermeasures">3.3.3 Weaknesses and countermeasures</a></li>
<li><a name="toc-On-record-padding" href="#On-Record-Padding">3.3.4 On record padding</a></li>
</ul></li>
<li><a name="toc-The-TLS-alert-protocol" href="#The-TLS-Alert-Protocol">3.4 The TLS alert protocol</a></li>
<li><a name="toc-The-TLS-handshake-protocol" href="#The-TLS-Handshake-Protocol">3.5 The TLS handshake protocol</a>
<ul class="no-bullet">
<li><a name="toc-TLS-ciphersuites" href="#TLS-Cipher-Suites">3.5.1 TLS ciphersuites</a></li>
<li><a name="toc-Authentication-1" href="#Authentication">3.5.2 Authentication</a></li>
<li><a name="toc-Client-authentication" href="#Client-Authentication">3.5.3 Client authentication</a></li>
<li><a name="toc-Resuming-sessions" href="#Resuming-Sessions">3.5.4 Resuming sessions</a></li>
</ul></li>
<li><a name="toc-TLS-extensions" href="#TLS-Extensions">3.6 TLS extensions</a>
<ul class="no-bullet">
<li><a name="toc-Maximum-fragment-length-negotiation-1" href="#Maximum-fragment-length-negotiation">3.6.1 Maximum fragment length negotiation</a></li>
<li><a name="toc-Server-name-indication-1" href="#Server-name-indication">3.6.2 Server name indication</a></li>
<li><a name="toc-Session-tickets-1" href="#Session-tickets">3.6.3 Session tickets</a></li>
<li><a name="toc-HeartBeat-1" href="#HeartBeat">3.6.4 HeartBeat</a></li>
<li><a name="toc-Safe-renegotiation-1" href="#Safe-renegotiation">3.6.5 Safe renegotiation</a></li>
<li><a name="toc-OCSP-status-request-1" href="#OCSP-status-request">3.6.6 OCSP status request</a></li>
<li><a name="toc-SRTP-1" href="#SRTP">3.6.7 SRTP</a></li>
</ul></li>
<li><a name="toc-How-to-use-TLS-in-application-protocols-1" href="#How-to-use-TLS-in-application-protocols">3.7 How to use <acronym>TLS</acronym> in application protocols</a>
<ul class="no-bullet">
<li><a name="toc-Separate-ports-1" href="#Separate-ports">3.7.1 Separate ports</a></li>
<li><a name="toc-Upward-negotiation-1" href="#Upward-negotiation">3.7.2 Upward negotiation</a></li>
</ul></li>
<li><a name="toc-On-SSL-2-and-older-protocols-1" href="#On-SSL-2-and-older-protocols">3.8 On SSL 2 and older protocols</a></li>
</ul></li>
<li><a name="toc-Authentication-methods-1" href="#Authentication-methods">4 Authentication methods</a>
<ul class="no-bullet">
<li><a name="toc-Certificate-authentication-1" href="#Certificate-authentication">4.1 Certificate authentication</a>
<ul class="no-bullet">
<li><a name="toc-X_002e509-certificates-1" href="#X_002e509-certificates">4.1.1 <acronym>X.509</acronym> certificates</a>
<ul class="no-bullet">
<li><a name="toc-X_002e509-certificate-structure-1" href="#X_002e509-certificate-structure">4.1.1.1 <acronym>X.509</acronym> certificate structure</a></li>
<li><a name="toc-Importing-an-X_002e509-certificate-1" href="#Importing-an-X_002e509-certificate">4.1.1.2 Importing an X.509 certificate</a></li>
<li><a name="toc-X_002e509-distinguished-names-1" href="#X_002e509-distinguished-names">4.1.1.3 X.509 distinguished names</a></li>
<li><a name="toc-Accessing-public-and-private-keys" href="#X_002e509-public-and-private-keys">4.1.1.4 Accessing public and private keys</a></li>
<li><a name="toc-Verifying-X_002e509-certificate-paths-1" href="#Verifying-X_002e509-certificate-paths">4.1.1.5 Verifying <acronym>X.509</acronym> certificate paths</a></li>
<li><a name="toc-Verifying-a-certificate-in-the-context-of-TLS-session-1" href="#Verifying-a-certificate-in-the-context-of-TLS-session">4.1.1.6 Verifying a certificate in the context of TLS session</a></li>
</ul></li>
<li><a name="toc-OpenPGP-certificates-1" href="#OpenPGP-certificates">4.1.2 <acronym>OpenPGP</acronym> certificates</a>
<ul class="no-bullet">
<li><a name="toc-OpenPGP-certificate-structure" href="#OpenPGP-certificate-structure">4.1.2.1 <acronym>OpenPGP</acronym> certificate structure</a></li>
<li><a name="toc-Verifying-an-OpenPGP-certificate" href="#Verifying-an-OpenPGP-certificate">4.1.2.2 Verifying an <acronym>OpenPGP</acronym> certificate</a></li>
<li><a name="toc-Verifying-a-certificate-in-the-context-of-a-TLS-session" href="#Verifying-a-certificate-in-the-context-of-a-TLS-session">4.1.2.3 Verifying a certificate in the context of a TLS session</a></li>
</ul></li>
<li><a name="toc-Advanced-certificate-verification-1" href="#Advanced-certificate-verification">4.1.3 Advanced certificate verification</a>
<ul class="no-bullet">
<li><a name="toc-Verifying-a-certificate-using-trust-on-first-use-authentication-1" href="#Verifying-a-certificate-using-trust-on-first-use-authentication">4.1.3.1 Verifying a certificate using trust on first use authentication</a></li>
<li><a name="toc-Verifying-a-certificate-using-DANE-_0028DNSSEC_0029" href="#Verifying-a-certificate-using-DANE">4.1.3.2 Verifying a certificate using DANE (DNSSEC)</a></li>
</ul></li>
<li><a name="toc-Digital-signatures-1" href="#Digital-signatures">4.1.4 Digital signatures</a>
<ul class="no-bullet">
<li><a name="toc-Trading-security-for-interoperability" href="#Trading-security-for-interoperability">4.1.4.1 Trading security for interoperability</a></li>
</ul></li>
</ul></li>
<li><a name="toc-More-on-certificate-authentication-1" href="#More-on-certificate-authentication">4.2 More on certificate authentication</a>
<ul class="no-bullet">
<li><a name="toc-PKCS-_002310-certificate-requests" href="#PKCS-10-certificate-requests">4.2.1 <acronym>PKCS</acronym> #10 certificate requests</a></li>
<li><a name="toc-PKIX-certificate-revocation-lists-1" href="#PKIX-certificate-revocation-lists">4.2.2 PKIX certificate revocation lists</a></li>
<li><a name="toc-OCSP-certificate-status-checking-1" href="#OCSP-certificate-status-checking">4.2.3 <acronym>OCSP</acronym> certificate status checking</a></li>
<li><a name="toc-Managing-encrypted-keys-1" href="#Managing-encrypted-keys">4.2.4 Managing encrypted keys</a></li>
<li><a name="toc-Invoking-certtool" href="#certtool-Invocation">4.2.5 Invoking certtool</a></li>
<li><a name="toc-Invoking-ocsptool" href="#ocsptool-Invocation">4.2.6 Invoking ocsptool</a></li>
<li><a name="toc-Invoking-danetool" href="#danetool-Invocation">4.2.7 Invoking danetool</a></li>
</ul></li>
<li><a name="toc-Shared_002dkey-and-anonymous-authentication-1" href="#Shared_002dkey-and-anonymous-authentication">4.3 Shared-key and anonymous authentication</a>
<ul class="no-bullet">
<li><a name="toc-SRP-authentication-1" href="#SRP-authentication">4.3.1 SRP authentication</a>
<ul class="no-bullet">
<li><a name="toc-Authentication-using-SRP-1" href="#Authentication-using-SRP">4.3.1.1 Authentication using <acronym>SRP</acronym></a></li>
<li><a name="toc-Invoking-srptool" href="#srptool-Invocation">4.3.1.2 Invoking srptool</a></li>
</ul></li>
<li><a name="toc-PSK-authentication-1" href="#PSK-authentication">4.3.2 PSK authentication</a>
<ul class="no-bullet">
<li><a name="toc-Authentication-using-PSK-1" href="#Authentication-using-PSK">4.3.2.1 Authentication using <acronym>PSK</acronym></a></li>
<li><a name="toc-Invoking-psktool" href="#psktool-Invocation">4.3.2.2 Invoking psktool</a></li>
</ul></li>
<li><a name="toc-Anonymous-authentication-1" href="#Anonymous-authentication">4.3.3 Anonymous authentication</a></li>
</ul></li>
<li><a name="toc-Selecting-an-appropriate-authentication-method-1" href="#Selecting-an-appropriate-authentication-method">4.4 Selecting an appropriate authentication method</a>
<ul class="no-bullet">
<li><a name="toc-Two-peers-with-an-out_002dof_002dband-channel" href="#Two-peers-with-an-out_002dof_002dband-channel">4.4.1 Two peers with an out-of-band channel</a></li>
<li><a name="toc-Two-peers-without-an-out_002dof_002dband-channel" href="#Two-peers-without-an-out_002dof_002dband-channel">4.4.2 Two peers without an out-of-band channel</a></li>
<li><a name="toc-Two-peers-and-a-trusted-third-party" href="#Two-peers-and-a-trusted-third-party">4.4.3 Two peers and a trusted third party</a></li>
</ul></li>
</ul></li>
<li><a name="toc-Hardware-security-modules-and-abstract-key-types-1" href="#Hardware-security-modules-and-abstract-key-types">5 Hardware security modules and abstract key types</a>
<ul class="no-bullet">
<li><a name="toc-Abstract-key-types-1" href="#Abstract-key-types">5.1 Abstract key types</a>
<ul class="no-bullet">
<li><a name="toc-Public-keys" href="#Abstract-public-keys">5.1.1 Public keys</a></li>
<li><a name="toc-Private-keys" href="#Abstract-private-keys">5.1.2 Private keys</a></li>
<li><a name="toc-Operations-1" href="#Operations">5.1.3 Operations</a></li>
</ul></li>
<li><a name="toc-Smart-cards-and-HSMs-1" href="#Smart-cards-and-HSMs">5.2 Smart cards and HSMs</a>
<ul class="no-bullet">
<li><a name="toc-Initialization-1" href="#PKCS11-Initialization">5.2.1 Initialization</a></li>
<li><a name="toc-Accessing-objects-that-require-a-PIN-1" href="#Accessing-objects-that-require-a-PIN">5.2.2 Accessing objects that require a PIN</a></li>
<li><a name="toc-Reading-objects-1" href="#Reading-objects">5.2.3 Reading objects</a></li>
<li><a name="toc-Writing-objects-1" href="#Writing-objects">5.2.4 Writing objects</a></li>
<li><a name="toc-Using-a-PKCS-_002311-token-with-TLS" href="#Using-a-PKCS11-token-with-TLS">5.2.5 Using a <acronym>PKCS</acronym> #11 token with TLS</a></li>
<li><a name="toc-Invoking-p11tool" href="#p11tool-Invocation">5.2.6 Invoking p11tool</a></li>
</ul></li>
<li><a name="toc-Trusted-Platform-Module-_0028TPM_0029" href="#Trusted-Platform-Module">5.3 Trusted Platform Module (TPM)</a>
<ul class="no-bullet">
<li><a name="toc-Keys-in-TPM-1" href="#Keys-in-TPM">5.3.1 Keys in TPM</a></li>
<li><a name="toc-Key-generation-1" href="#Key-generation">5.3.2 Key generation</a></li>
<li><a name="toc-Using-keys-1" href="#Using-keys">5.3.3 Using keys</a></li>
<li><a name="toc-Invoking-tpmtool" href="#tpmtool-Invocation">5.3.4 Invoking tpmtool</a></li>
</ul></li>
</ul></li>
<li><a name="toc-How-to-use-GnuTLS-in-applications-1" href="#How-to-use-GnuTLS-in-applications">6 How to use <acronym>GnuTLS</acronym> in applications</a>
<ul class="no-bullet">
<li><a name="toc-Introduction" href="#Introduction-to-the-library">6.1 Introduction</a>
<ul class="no-bullet">
<li><a name="toc-General-idea-1" href="#General-idea">6.1.1 General idea</a></li>
<li><a name="toc-Error-handling-1" href="#Error-handling">6.1.2 Error handling</a></li>
<li><a name="toc-Common-types-1" href="#Common-types">6.1.3 Common types</a></li>
<li><a name="toc-Debugging-and-auditing-1" href="#Debugging-and-auditing">6.1.4 Debugging and auditing</a></li>
<li><a name="toc-Thread-safety-1" href="#Thread-safety">6.1.5 Thread safety</a></li>
<li><a name="toc-Callback-functions-1" href="#Callback-functions">6.1.6 Callback functions</a></li>
</ul></li>
<li><a name="toc-Preparation-1" href="#Preparation">6.2 Preparation</a>
<ul class="no-bullet">
<li><a name="toc-Headers-1" href="#Headers">6.2.1 Headers</a></li>
<li><a name="toc-Initialization-2" href="#Initialization">6.2.2 Initialization</a></li>
<li><a name="toc-Version-check-1" href="#Version-check">6.2.3 Version check</a></li>
<li><a name="toc-Building-the-source-1" href="#Building-the-source">6.2.4 Building the source</a></li>
</ul></li>
<li><a name="toc-Session-initialization-1" href="#Session-initialization">6.3 Session initialization</a></li>
<li><a name="toc-Associating-the-credentials-1" href="#Associating-the-credentials">6.4 Associating the credentials</a>
<ul class="no-bullet">
<li><a name="toc-Certificates" href="#Certificate-credentials">6.4.1 Certificates</a></li>
<li><a name="toc-SRP" href="#SRP-credentials">6.4.2 SRP</a></li>
<li><a name="toc-PSK" href="#PSK-credentials">6.4.3 PSK</a></li>
<li><a name="toc-Anonymous" href="#Anonymous-credentials">6.4.4 Anonymous</a></li>
</ul></li>
<li><a name="toc-Setting-up-the-transport-layer-1" href="#Setting-up-the-transport-layer">6.5 Setting up the transport layer</a>
<ul class="no-bullet">
<li><a name="toc-Asynchronous-operation-1" href="#Asynchronous-operation">6.5.1 Asynchronous operation</a></li>
<li><a name="toc-DTLS-sessions-1" href="#DTLS-sessions">6.5.2 DTLS sessions</a></li>
</ul></li>
<li><a name="toc-TLS-handshake-1" href="#TLS-handshake">6.6 TLS handshake</a></li>
<li><a name="toc-Data-transfer-and-termination-1" href="#Data-transfer-and-termination">6.7 Data transfer and termination</a></li>
<li><a name="toc-Buffered-data-transfer-1" href="#Buffered-data-transfer">6.8 Buffered data transfer</a></li>
<li><a name="toc-Handling-alerts-1" href="#Handling-alerts">6.9 Handling alerts</a></li>
<li><a name="toc-Priority-strings" href="#Priority-Strings">6.10 Priority strings</a></li>
<li><a name="toc-Selecting-cryptographic-key-sizes-1" href="#Selecting-cryptographic-key-sizes">6.11 Selecting cryptographic key sizes</a></li>
<li><a name="toc-Advanced-topics-1" href="#Advanced-topics">6.12 Advanced topics</a>
<ul class="no-bullet">
<li><a name="toc-Session-resumption-1" href="#Session-resumption">6.12.1 Session resumption</a></li>
<li><a name="toc-Certificate-verification-1" href="#Certificate-verification">6.12.2 Certificate verification</a>
<ul class="no-bullet">
<li><a name="toc-Trust-on-first-use" href="#Trust-on-first-use">6.12.2.1 Trust on first use</a></li>
<li><a name="toc-DANE-verification" href="#DANE-verification">6.12.2.2 DANE verification</a></li>
</ul></li>
<li><a name="toc-Parameter-generation-1" href="#Parameter-generation">6.12.3 Parameter generation</a></li>
<li><a name="toc-Keying-material-exporters" href="#Keying-Material-Exporters">6.12.4 Keying material exporters</a></li>
<li><a name="toc-Channel-bindings" href="#Channel-Bindings">6.12.5 Channel bindings</a></li>
<li><a name="toc-Interoperability-1" href="#Interoperability">6.12.6 Interoperability</a></li>
<li><a name="toc-Compatibility-with-the-OpenSSL-library-1" href="#Compatibility-with-the-OpenSSL-library">6.12.7 Compatibility with the OpenSSL library</a></li>
</ul></li>
</ul></li>
<li><a name="toc-GnuTLS-application-examples-1" href="#GnuTLS-application-examples">7 GnuTLS application examples</a>
<ul class="no-bullet">
<li><a name="toc-Client-examples-1" href="#Client-examples">7.1 Client examples</a>
<ul class="no-bullet">
<li><a name="toc-Simple-client-example-with-X_002e509-certificate-support-1" href="#Simple-client-example-with-X_002e509-certificate-support">7.1.1 Simple client example with <acronym>X.509</acronym> certificate support</a></li>
<li><a name="toc-Simple-client-example-with-SSH_002dstyle-certificate-verification-1" href="#Simple-client-example-with-SSH_002dstyle-certificate-verification">7.1.2 Simple client example with SSH-style certificate verification</a></li>
<li><a name="toc-Simple-client-example-with-anonymous-authentication-1" href="#Simple-client-example-with-anonymous-authentication">7.1.3 Simple client example with anonymous authentication</a></li>
<li><a name="toc-Simple-datagram-TLS-client-example" href="#Simple-Datagram-TLS-client-example">7.1.4 Simple datagram <acronym>TLS</acronym> client example</a></li>
<li><a name="toc-Obtaining-session-information-1" href="#Obtaining-session-information">7.1.5 Obtaining session information</a></li>
<li><a name="toc-Using-a-callback-to-select-the-certificate-to-use-1" href="#Using-a-callback-to-select-the-certificate-to-use">7.1.6 Using a callback to select the certificate to use</a></li>
<li><a name="toc-Verifying-a-certificate-1" href="#Verifying-a-certificate">7.1.7 Verifying a certificate</a></li>
<li><a name="toc-Using-a-smart-card-with-TLS" href="#Client-using-a-smart-card-with-TLS">7.1.8 Using a smart card with TLS</a></li>
<li><a name="toc-Client-with-resume-capability-example" href="#Client-with-Resume-capability-example">7.1.9 Client with resume capability example</a></li>
<li><a name="toc-Simple-client-example-with-SRP-authentication-1" href="#Simple-client-example-with-SRP-authentication">7.1.10 Simple client example with <acronym>SRP</acronym> authentication</a></li>
<li><a name="toc-Simple-client-example-using-the-C_002b_002b-API" href="#Simple-client-example-in-C_002b_002b">7.1.11 Simple client example using the C++ API</a></li>
<li><a name="toc-Helper-functions-for-TCP-connections-1" href="#Helper-functions-for-TCP-connections">7.1.12 Helper functions for TCP connections</a></li>
<li><a name="toc-Helper-functions-for-UDP-connections-1" href="#Helper-functions-for-UDP-connections">7.1.13 Helper functions for UDP connections</a></li>
</ul></li>
<li><a name="toc-Server-examples-1" href="#Server-examples">7.2 Server examples</a>
<ul class="no-bullet">
<li><a name="toc-Echo-server-with-X_002e509-authentication-1" href="#Echo-server-with-X_002e509-authentication">7.2.1 Echo server with <acronym>X.509</acronym> authentication</a></li>
<li><a name="toc-Echo-server-with-OpenPGP-authentication-1" href="#Echo-server-with-OpenPGP-authentication">7.2.2 Echo server with <acronym>OpenPGP</acronym> authentication</a></li>
<li><a name="toc-Echo-server-with-SRP-authentication-1" href="#Echo-server-with-SRP-authentication">7.2.3 Echo server with <acronym>SRP</acronym> authentication</a></li>
<li><a name="toc-Echo-server-with-anonymous-authentication-1" href="#Echo-server-with-anonymous-authentication">7.2.4 Echo server with anonymous authentication</a></li>
<li><a name="toc-DTLS-echo-server-with-X_002e509-authentication-1" href="#DTLS-echo-server-with-X_002e509-authentication">7.2.5 DTLS echo server with <acronym>X.509</acronym> authentication</a></li>
</ul></li>
<li><a name="toc-OCSP-example-1" href="#OCSP-example">7.3 OCSP example</a></li>
<li><a name="toc-Miscellaneous-examples-1" href="#Miscellaneous-examples">7.4 Miscellaneous examples</a>
<ul class="no-bullet">
<li><a name="toc-Checking-for-an-alert-1" href="#Checking-for-an-alert">7.4.1 Checking for an alert</a></li>
<li><a name="toc-X_002e509-certificate-parsing-example-1" href="#X_002e509-certificate-parsing-example">7.4.2 <acronym>X.509</acronym> certificate parsing example</a></li>
<li><a name="toc-Listing-the-ciphersuites-in-a-priority-string-1" href="#Listing-the-ciphersuites-in-a-priority-string">7.4.3 Listing the ciphersuites in a priority string</a></li>
</ul></li>
<li><a name="toc-XSSL-examples-1" href="#XSSL-examples">7.5 XSSL examples</a>
<ul class="no-bullet">
<li><a name="toc-Example-client-with-X_002e509-certificate-authentication-1" href="#Example-client-with-X_002e509-certificate-authentication">7.5.1 Example client with X.509 certificate authentication</a></li>
<li><a name="toc-Example-client-with-X_002e509-certificate-authentication-and-TOFU-1" href="#Example-client-with-X_002e509-certificate-authentication-and-TOFU">7.5.2 Example client with X.509 certificate authentication and TOFU</a></li>
</ul></li>
</ul></li>
<li><a name="toc-Using-GnuTLS-as-a-cryptographic-library-1" href="#Using-GnuTLS-as-a-cryptographic-library">8 Using GnuTLS as a cryptographic library</a>
<ul class="no-bullet">
<li><a name="toc-Encryption-algorithms-1" href="#Encryption-algorithms">8.1 Encryption algorithms</a></li>
<li><a name="toc-Hash-and-HMAC-functions-1" href="#Hash-and-HMAC-functions">8.2 Hash and HMAC functions</a></li>
<li><a name="toc-Random-number-generation-1" href="#Random-number-generation">8.3 Random number generation</a></li>
</ul></li>
<li><a name="toc-Other-included-programs-1" href="#Other-included-programs">9 Other included programs</a>
<ul class="no-bullet">
<li><a name="toc-Invoking-gnutls_002dcli" href="#gnutls_002dcli-Invocation">9.1 Invoking gnutls-cli</a></li>
<li><a name="toc-Invoking-gnutls_002dserv" href="#gnutls_002dserv-Invocation">9.2 Invoking gnutls-serv</a></li>
<li><a name="toc-Invoking-gnutls_002dcli_002ddebug" href="#gnutls_002dcli_002ddebug-Invocation">9.3 Invoking gnutls-cli-debug</a></li>
</ul></li>
<li><a name="toc-Internal-Architecture-of-GnuTLS" href="#Internal-architecture-of-GnuTLS">10 Internal Architecture of GnuTLS</a>
<ul class="no-bullet">
<li><a name="toc-The-TLS-Protocol-1" href="#The-TLS-Protocol">10.1 The TLS Protocol</a></li>
<li><a name="toc-TLS-Handshake-Protocol-1" href="#TLS-Handshake-Protocol">10.2 TLS Handshake Protocol</a></li>
<li><a name="toc-TLS-Authentication-Methods-1" href="#TLS-Authentication-Methods">10.3 TLS Authentication Methods</a></li>
<li><a name="toc-TLS-Extension-Handling-1" href="#TLS-Extension-Handling">10.4 TLS Extension Handling</a></li>
<li><a name="toc-Cryptographic-Backend-1" href="#Cryptographic-Backend">10.5 Cryptographic Backend</a></li>
</ul></li>
<li><a name="toc-Upgrading-from-previous-versions-1" href="#Upgrading-from-previous-versions">Appendix A Upgrading from previous versions</a></li>
<li><a name="toc-Support-1" href="#Support">Appendix B Support</a>
<ul class="no-bullet">
<li><a name="toc-Getting-Help" href="#Getting-help">B.1 Getting Help</a></li>
<li><a name="toc-Commercial-Support-1" href="#Commercial-Support">B.2 Commercial Support</a></li>
<li><a name="toc-Bug-Reports-1" href="#Bug-Reports">B.3 Bug Reports</a></li>
<li><a name="toc-Contributing-1" href="#Contributing">B.4 Contributing</a></li>
</ul></li>
<li><a name="toc-Error-Codes-and-Descriptions" href="#Error-codes">Appendix C Error Codes and Descriptions</a></li>
<li><a name="toc-Supported-Ciphersuites" href="#Supported-ciphersuites">Appendix D Supported Ciphersuites</a></li>
<li><a name="toc-API-reference-1" href="#API-reference">Appendix E API reference</a>
<ul class="no-bullet">
<li><a name="toc-Core-TLS-API-1" href="#Core-TLS-API">E.1 Core TLS API</a></li>
<li><a name="toc-High-level-TLS-API-1" href="#High-level-TLS-API">E.2 High level TLS API</a></li>
<li><a name="toc-Datagram-TLS-API-1" href="#Datagram-TLS-API">E.3 Datagram TLS API</a></li>
<li><a name="toc-X_002e509-certificate-API" href="#X509-certificate-API">E.4 <acronym>X.509</acronym> certificate API</a></li>
<li><a name="toc-OCSP-API-1" href="#OCSP-API">E.5 <acronym>OCSP</acronym> API</a></li>
<li><a name="toc-OpenPGP-API-1" href="#OpenPGP-API">E.6 <acronym>OpenPGP</acronym> API</a></li>
<li><a name="toc-PKCS-12-API-1" href="#PKCS-12-API">E.7 PKCS 12 API</a></li>
<li><a name="toc-Hardware-token-via-PKCS-11-API" href="#PKCS-11-API">E.8 Hardware token via PKCS 11 API</a></li>
<li><a name="toc-TPM-API-1" href="#TPM-API">E.9 TPM API</a></li>
<li><a name="toc-Abstract-key-API-1" href="#Abstract-key-API">E.10 Abstract key API</a></li>
<li><a name="toc-DANE-API-1" href="#DANE-API">E.11 DANE API</a></li>
<li><a name="toc-Cryptographic-API-1" href="#Cryptographic-API">E.12 Cryptographic API</a></li>
<li><a name="toc-Compatibility-API-1" href="#Compatibility-API">E.13 Compatibility API</a></li>
</ul></li>
<li><a name="toc-Copying-Information-1" href="#Copying-Information">Appendix F Copying Information</a></li>
<li><a name="toc-Bibliography-1" href="#Bibliography">Bibliography</a></li>
<li><a name="toc-Function-and-Data-Index-1" href="#Function-and-Data-Index">Function and Data Index</a></li>
<li><a name="toc-Concept-Index-1" href="#Concept-Index">Concept Index</a></li>
</ul>
</div>
<a name="Top"></a>
<div class="header">
<p>
Next: <a href="#Preface" accesskey="n" rel="next">Preface</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="GnuTLS"></a>
<h1 class="top">GnuTLS</h1>
<p>This manual is last updated 29 January 2013 for version
3.1.7 of GnuTLS.
</p>
<p>Copyright © 2001-2013 Free Software Foundation, Inc.\\
Copyright © 2001-2013 Nikos Mavrogiannopoulos
</p>
<blockquote>
<p>Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 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”.
</p></blockquote>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Preface" accesskey="1">Preface</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Introduction-to-GnuTLS" accesskey="2">Introduction to GnuTLS</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Introduction-to-TLS" accesskey="3">Introduction to TLS</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Authentication-methods" accesskey="4">Authentication methods</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Hardware-security-modules-and-abstract-key-types" accesskey="5">Hardware security modules and abstract key types</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#How-to-use-GnuTLS-in-applications" accesskey="6">How to use GnuTLS in applications</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#GnuTLS-application-examples" accesskey="7">GnuTLS application examples</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Using-GnuTLS-as-a-cryptographic-library" accesskey="8">Using GnuTLS as a cryptographic library</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Other-included-programs" accesskey="9">Other included programs</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Upgrading-from-previous-versions">Upgrading from previous versions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Support">Support</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Error-codes">Error codes</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Supported-ciphersuites">Supported ciphersuites</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#API-reference">API reference</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Copying-Information">Copying Information</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Bibliography">Bibliography</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Function-and-Data-Index">Function and Data Index</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Concept-Index">Concept Index</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Preface"></a>
<div class="header">
<p>
Next: <a href="#Introduction-to-GnuTLS" accesskey="n" rel="next">Introduction to GnuTLS</a>, Previous: <a href="#Top" accesskey="p" rel="previous">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Preface-1"></a>
<h2 class="chapter">1 Preface</h2>
<p>This document demonstrates and explains 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 it
is likely to only obtain a false sense of security.
The term of security is very broad even if restricted to computer
software, and cannot be confined to a single cryptographic
library. For that reason, do not consider any 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>
<p>Although this document tries to be self contained, basic network
programming and public key infrastructure (PKI) knowledge is assumed
in most of it. A good introduction to networking can be found
in [<em>STEVENS</em>], to public key infrastructure in [<em>GUTPKI</em>]
and to security engineering in [<em>ANDERSON</em>].
</p>
<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>.
</p>
<hr>
<a name="Introduction-to-GnuTLS"></a>
<div class="header">
<p>
Next: <a href="#Introduction-to-TLS" accesskey="n" rel="next">Introduction to TLS</a>, Previous: <a href="#Preface" accesskey="p" rel="previous">Preface</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Introduction-to-GnuTLS-1"></a>
<h2 class="chapter">2 Introduction to GnuTLS</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>
<p>Technically <acronym>GnuTLS</acronym> is a portable ANSI C based library which
implements the protocols ranging from SSL 3.0 to TLS 1.2 (see <a href="#Introduction-to-TLS">Introduction to TLS</a>,
for a detailed description of the protocols), accompanied
with the required framework for authentication and public key
infrastructure. Important features of the <acronym>GnuTLS</acronym> library
include:
</p>
<ul>
<li> Support for TLS 1.2, TLS 1.1, TLS 1.0 and SSL 3.0 protocols.
</li><li> Support for Datagram TLS 1.0.
</li><li> Support for handling and verification of <acronym>X.509</acronym> and <acronym>OpenPGP</acronym> certificates.
</li><li> Support for password authentication using <acronym>TLS-SRP</acronym>.
</li><li> Support for keyed authentication using <acronym>TLS-PSK</acronym>.
</li><li> Support for TPM, <acronym>PKCS</acronym> #11 tokens and smart-cards.
</li></ul>
<p>The <acronym>GnuTLS</acronym> library consists of three independent parts, namely the “TLS
protocol part”, the “Certificate part”, and the “Cryptographic
back-end” 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 and it uses
functionality from the
libtasn1<a name="DOCF1" href="#FOOT1"><sup>1</sup></a> library.
The “Cryptographic back-end” is provided by the nettle<a name="DOCF2" href="#FOOT2"><sup>2</sup></a>
library.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Downloading-and-installing" accesskey="1">Downloading and installing</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Document-overview" accesskey="2">Document overview</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Downloading-and-installing"></a>
<div class="header">
<p>
Next: <a href="#Document-overview" accesskey="n" rel="next">Document overview</a>, Up: <a href="#Introduction-to-GnuTLS" accesskey="u" rel="up">Introduction to GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Downloading-and-installing-1"></a>
<h3 class="section">2.1 Downloading and installing</h3>
<a name="index-installation"></a>
<a name="index-download"></a>
<p>GnuTLS is available for download at:
<a href="http://www.gnutls.org/download.html">http://www.gnutls.org/download.html</a>
</p>
<p>GnuTLS uses a development cycle where even minor version numbers
indicate a stable release and a odd minor version number indicate a
development release. For example, GnuTLS 1.6.3 denote a stable
release since 6 is even, and GnuTLS 1.7.11 denote a development
release since 7 is odd.
</p>
<p>GnuTLS depends on Libnettle, and you will need to install it
before installing GnuTLS. Libnettle is available from
<a href="http://www.lysator.liu.se/~nisse/nettle/">http://www.lysator.liu.se/~nisse/nettle/</a>.
Don’t forget to verify the cryptographic signature after downloading
source code packages.
</p>
<p>The package is then extracted, configured and built like many other
packages that use Autoconf. For detailed information on configuring
and building it, refer to the <samp>INSTALL</samp> file that is part of the
distribution archive. Typically you invoke <code>./configure</code> and
then <code>make check install</code>. There are a number of compile-time
parameters, as discussed below.
</p>
<p>The compression library, libz, as well as p11-kit are a optional dependencies.
You can get libz from <a href="http://www.zlib.net/">http://www.zlib.net/</a> and p11-kit from <a href="http://p11-glue.freedesktop.org/">http://p11-glue.freedesktop.org/</a>.
</p>
<p>The X.509 part of GnuTLS needs ASN.1 functionality, from a library
called libtasn1. A copy of libtasn1 is included in GnuTLS. If you
want to install it separately (e.g., to make it possibly to use
libtasn1 in other programs), you can get it from
<a href="http://www.gnu.org/software/gnutls/download.html">http://www.gnu.org/software/gnutls/download.html</a>.
</p>
<p>A few <code>configure</code> options may be relevant, summarized below.
They disable or enable particular features,
to create a smaller library with only the required features.
Note however, that although a smaller library is generated, the
included programs are not guarranteed to compile if some of these
options are given.
</p>
<pre class="verbatim">--disable-srp-authentication
--disable-psk-authentication
--disable-anon-authentication
--disable-extra-pki
--disable-openpgp-authentication
--disable-openssl-compatibility
--disable-libdane
--without-p11-kit
--with-tpm
--disable-dtls-srtp-support
</pre>
<p>For the complete list, refer to the output from <code>configure --help</code>.
</p>
<hr>
<a name="Document-overview"></a>
<div class="header">
<p>
Previous: <a href="#Downloading-and-installing" accesskey="p" rel="previous">Downloading and installing</a>, Up: <a href="#Introduction-to-GnuTLS" accesskey="u" rel="up">Introduction to GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Overview"></a>
<h3 class="section">2.2 Overview</h3>
<p>In this document we present an overview of the supported security protocols in <a href="#Introduction-to-TLS">Introduction to TLS</a>, and
continue by providing more information on the certificate authentication in <a href="#Certificate-authentication">Certificate authentication</a>,
and shared-key as well anonymous authentication in <a href="#Shared_002dkey-and-anonymous-authentication">Shared-key and anonymous authentication</a>. We
elaborate on certificate authentication by demonstrating advanced usage of the API in <a href="#More-on-certificate-authentication">More on certificate authentication</a>.
The core of the TLS library is presented in <a href="#How-to-use-GnuTLS-in-applications">How to use GnuTLS in applications</a> and example
applications are listed in <a href="#GnuTLS-application-examples">GnuTLS application examples</a>.
In <a href="#Other-included-programs">Other included programs</a> the usage of few included programs that
may assist debugging is presented. The last chapter is <a href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a> that
provides a short introduction to GnuTLS’ internal architecture.
</p>
<hr>
<a name="Introduction-to-TLS"></a>
<div class="header">
<p>
Next: <a href="#Authentication-methods" accesskey="n" rel="next">Authentication methods</a>, Previous: <a href="#Introduction-to-GnuTLS" accesskey="p" rel="previous">Introduction to GnuTLS</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Introduction-to-TLS-and-DTLS"></a>
<h2 class="chapter">3 Introduction to <acronym>TLS</acronym> and <acronym>DTLS</acronym></h2>
<p><acronym>TLS</acronym> stands for “Transport Layer Security” and is the
successor of SSL, the Secure Sockets Layer protocol [<em>SSL3</em>]
designed by Netscape. <acronym>TLS</acronym> is an Internet protocol, defined
by <acronym>IETF</acronym><a name="DOCF3" href="#FOOT3"><sup>3</sup></a>, described in [<em>RFC5246</em>].
The protocol provides
confidentiality, and authentication layers over any reliable transport
layer. The description, above, refers to <acronym>TLS</acronym> 1.0 but applies
to all other TLS versions as the differences between the protocols are not major.
</p>
<p>The <acronym>DTLS</acronym> protocol, or “Datagram <acronym>TLS</acronym>” [<em>RFC4347</em>] is a
protocol with identical goals as <acronym>TLS</acronym>, but can operate
under unreliable transport layers such as <acronym>UDP</acronym>. The
discussions below apply to this protocol as well, except when
noted otherwise.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#TLS-layers" accesskey="1">TLS layers</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#The-transport-layer" accesskey="2">The transport layer</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#The-TLS-record-protocol" accesskey="3">The TLS record protocol</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#The-TLS-Alert-Protocol" accesskey="4">The TLS Alert Protocol</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#The-TLS-Handshake-Protocol" accesskey="5">The TLS Handshake Protocol</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#TLS-Extensions" accesskey="6">TLS Extensions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#How-to-use-TLS-in-application-protocols" accesskey="7">How to use TLS in application protocols</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#On-SSL-2-and-older-protocols" accesskey="8">On SSL 2 and older protocols</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="TLS-layers"></a>
<div class="header">
<p>
Next: <a href="#The-transport-layer" accesskey="n" rel="next">The transport layer</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-layers-1"></a>
<h3 class="section">3.1 TLS layers</h3>
<a name="index-TLS-layers"></a>
<p><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.
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>
<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 <a href="#fig_003atls_002dlayers">Figure 3.1</a>.
</p>
<div class="float"><a name="fig_003atls_002dlayers"></a>
<img src="gnutls-layers.png" alt="gnutls-layers">
<div class="float-caption"><p><strong>Figure 3.1: </strong>The TLS protocol layers.</p></div></div>
<hr>
<a name="The-transport-layer"></a>
<div class="header">
<p>
Next: <a href="#The-TLS-record-protocol" accesskey="n" rel="next">The TLS record protocol</a>, Previous: <a href="#TLS-layers" accesskey="p" rel="previous">TLS layers</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="The-transport-layer-1"></a>
<h3 class="section">3.2 The transport layer</h3>
<a name="index-transport-protocol"></a>
<a name="index-transport-layer"></a>
<p><acronym>TLS</acronym> is not limited to any transport layer and can be used
above any transport layer, as long as it is a reliable one. <acronym>DTLS</acronym>
can be used over reliable and unreliable transport layers.
<acronym>GnuTLS</acronym> supports TCP and UDP layers transparently using
the Berkeley sockets API. However, any transport layer can be used
by providing callbacks for <acronym>GnuTLS</acronym> to access the transport layer
(for details see <a href="#Setting-up-the-transport-layer">Setting up the transport layer</a>).
</p>
<hr>
<a name="The-TLS-record-protocol"></a>
<div class="header">
<p>
Next: <a href="#The-TLS-Alert-Protocol" accesskey="n" rel="next">The TLS Alert Protocol</a>, Previous: <a href="#The-transport-layer" accesskey="p" rel="previous">The transport layer</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="The-TLS-record-protocol-1"></a>
<h3 class="section">3.3 The TLS record protocol</h3>
<a name="index-record-protocol"></a>
<p>The record protocol is the secure communications provider. Its purpose
is to encrypt, authenticate and —optionally— compress packets.
The record layer functions can be called at any time after
the handshake process is finished, when there is need to receive
or send data. In <acronym>DTLS</acronym> however, due to re-transmission
timers used in the handshake out-of-order handshake data might
be received for some time (maximum 60 seconds) after the handshake
process is finished.
</p>
<p>The functions to access the record protocol are limited to send
and receive functions, which might, given
the importance of this protocol in <acronym>TLS</acronym>, seem awkward. This is because
the record protocol’s parameters are all set by the handshake protocol.
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.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Encryption-algorithms-used-in-the-record-layer" accesskey="1">Encryption algorithms used in the record layer</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Compression-algorithms-used-in-the-record-layer" accesskey="2">Compression algorithms used in the record layer</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Weaknesses-and-countermeasures" accesskey="3">Weaknesses and countermeasures</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#On-Record-Padding" accesskey="4">On Record Padding</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Encryption-algorithms-used-in-the-record-layer"></a>
<div class="header">
<p>
Next: <a href="#Compression-algorithms-used-in-the-record-layer" accesskey="n" rel="next">Compression algorithms used in the record layer</a>, Up: <a href="#The-TLS-record-protocol" accesskey="u" rel="up">The TLS record protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Encryption-algorithms-used-in-the-record-layer-1"></a>
<h4 class="subsection">3.3.1 Encryption algorithms used in the record layer</h4>
<a name="index-symmetric-encryption-algorithms"></a>
<p>Confidentiality in the record layer is achieved by using symmetric
block encryption algorithms like <code>3DES</code>, <code>AES</code>
or stream algorithms like <code>ARCFOUR_128</code>.
Ciphers are encryption algorithms that use a single, secret,
key to encrypt and decrypt data. Block algorithms in CBC mode 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>
<p>The supported in <acronym>GnuTLS</acronym> ciphers and MAC algorithms are shown in <a href="#tab_003aciphers">Table 3.1</a> and
<a href="#tab_003amacs">Table 3.2</a>.
</p>
<div class="float"><a name="tab_003aciphers"></a>
<table>
<thead><tr><th width="20%">Algorithm</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">3DES_CBC</td><td width="70%">This is the DES block cipher algorithm used with triple
encryption (EDE). Has 64 bits block size and is used in CBC mode.</td></tr>
<tr><td width="20%">ARCFOUR_128</td><td width="70%">ARCFOUR_128 is a compatible algorithm with RSA’s RC4 algorithm, which is considered to be a trade
secret. It is a fast cipher but considered weak today.</td></tr>
<tr><td width="20%">ARCFOUR_40</td><td width="70%">This is the ARCFOUR cipher fed with a 40 bit key,
which is considered weak.</td></tr>
<tr><td width="20%">AES_CBC</td><td width="70%">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.</td></tr>
<tr><td width="20%">AES_GCM</td><td width="70%">This is the AES algorithm in the authenticated encryption GCM mode.
This mode combines message authentication and encryption and can
be extremely fast on CPUs that support hardware acceleration.</td></tr>
<tr><td width="20%">CAMELLIA_CBC</td><td width="70%">This is an 128-bit block cipher developed by Mitsubishi and NTT. It
is one of the approved ciphers of the European NESSIE and Japanese
CRYPTREC projects.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 3.1: </strong>Supported ciphers.</p></div></div>
<div class="float"><a name="tab_003amacs"></a>
<table>
<thead><tr><th width="20%">Algorithm</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">MAC_MD5</td><td width="70%">This is an HMAC based on MD5 a cryptographic hash algorithm designed
by Ron Rivest. Outputs 128 bits of data.</td></tr>
<tr><td width="20%">MAC_SHA1</td><td width="70%">An HMAC based on the SHA1 cryptographic hash algorithm
designed by NSA. Outputs 160 bits of data.</td></tr>
<tr><td width="20%">MAC_SHA256</td><td width="70%">An HMAC based on SHA256. Outputs 256 bits of data.</td></tr>
<tr><td width="20%">MAC_AEAD</td><td width="70%">This indicates that an authenticated encryption algorithm, such as
GCM, is in use.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 3.2: </strong>Supported MAC algorithms.</p></div></div>
<hr>
<a name="Compression-algorithms-used-in-the-record-layer"></a>
<div class="header">
<p>
Next: <a href="#Weaknesses-and-countermeasures" accesskey="n" rel="next">Weaknesses and countermeasures</a>, Previous: <a href="#Encryption-algorithms-used-in-the-record-layer" accesskey="p" rel="previous">Encryption algorithms used in the record layer</a>, Up: <a href="#The-TLS-record-protocol" accesskey="u" rel="up">The TLS record protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Compression-algorithms-used-in-the-record-layer-1"></a>
<h4 class="subsection">3.3.2 Compression algorithms used in the record layer</h4>
<a name="index-compression-algorithms"></a>
<p>The TLS record layer also supports compression. The algorithms
implemented in <acronym>GnuTLS</acronym> can be found in the table below.
The included algorithms perform really good when text, or other
compressible data are to be transferred, 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. It
should be noted however that compression increases latency.
</p>
<p>The record layer compression in <acronym>GnuTLS</acronym> is implemented based
on [<em>RFC3749</em>]. The supported algorithms are shown below.
</p>
<div class="float"><a name="gnutls_005fcompression_005fmethod_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_COMP_UNKNOWN</code></dt>
<dd><p>Unknown compression method.
</p></dd>
<dt><code>GNUTLS_COMP_NULL</code></dt>
<dd><p>The NULL compression method (no compression).
</p></dd>
<dt><code>GNUTLS_COMP_DEFLATE</code></dt>
<dd><p>The DEFLATE compression method from zlib.
</p></dd>
<dt><code>GNUTLS_COMP_ZLIB</code></dt>
<dd><p>Same as <code>GNUTLS_COMP_DEFLATE</code> .
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 3.2: </strong>Supported compression algorithms</p></div></div>
<p>Note that compression enables attacks such as traffic analysis, or even
plaintext recovery under certain circumstances. To avoid some of these
attacks GnuTLS allows each record to be compressed independently (i.e.,
stateless compression), by using the "%STATELESS_COMPRESSION" priority string,
in order to be used in cases where the attacker controlled data are
pt in separate records.
</p>
<hr>
<a name="Weaknesses-and-countermeasures"></a>
<div class="header">
<p>
Next: <a href="#On-Record-Padding" accesskey="n" rel="next">On Record Padding</a>, Previous: <a href="#Compression-algorithms-used-in-the-record-layer" accesskey="p" rel="previous">Compression algorithms used in the record layer</a>, Up: <a href="#The-TLS-record-protocol" accesskey="u" rel="up">The TLS record protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Weaknesses-and-countermeasures-1"></a>
<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
</p>
<ol>
<li> <acronym>TLS</acronym> has separate alerts for “decryption_failed” and
“bad_record_mac”
</li><li> The decryption failure reason can be detected by timing the response
time.
</li><li> The IV for CBC encrypted packets is the last block of the previous
encrypted packet.
</li></ol>
<p>Those weaknesses were solved in <acronym>TLS</acronym> 1.1 [<em>RFC4346</em>]
which is implemented in <acronym>GnuTLS</acronym>. For this reason we suggest
to always negotiate the highest supported TLS version with the
peer<a name="DOCF4" href="#FOOT4"><sup>4</sup></a>.
For a detailed discussion of the issues see the archives of the TLS
Working Group mailing list and [<em>CBCATT</em>].
</p>
<hr>
<a name="On-Record-Padding"></a>
<div class="header">
<p>
Previous: <a href="#Weaknesses-and-countermeasures" accesskey="p" rel="previous">Weaknesses and countermeasures</a>, Up: <a href="#The-TLS-record-protocol" accesskey="u" rel="up">The TLS record protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="On-record-padding"></a>
<h4 class="subsection">3.3.4 On record padding</h4>
<a name="index-record-padding"></a>
<a name="index-bad_005frecord_005fmac"></a>
<p>The TLS protocol allows for extra padding of records in CBC ciphers, to prevent
statistical analysis based on the length of exchanged messages (see [<em>RFC5246</em>] section 6.2.3.2).
GnuTLS appears to be one of few implementations that take advantage of this feature:
the user can provide some plaintext data with a range of lengths she wishes to hide,
and GnuTLS adds extra padding to make sure the attacker cannot tell the real plaintext
length is in a range smaller than the user-provided one.
Use <a href="#gnutls_005frecord_005fsend_005frange">gnutls_record_send_range</a> to send length-hidden messages and
<a href="#gnutls_005frecord_005fcan_005fuse_005flength_005fhiding">gnutls_record_can_use_length_hiding</a> to check whether the current
session supports length hiding. Using the standard <a href="#gnutls_005frecord_005fsend">gnutls_record_send</a>
will only add minimal padding.
</p>
<p>The TLS implementation in the Symbian operating system, frequently
used by Nokia and Sony-Ericsson mobile phones, cannot handle
non-minimal record padding. What happens when one of these clients
handshake with a GnuTLS server is that the client will fail to compute
the correct MAC for the record. The client sends a TLS alert
(<code>bad_record_mac</code>) and disconnects. Typically this will result
in error messages such as ’A TLS fatal alert has been received’, ’Bad
record MAC’, or both, on the GnuTLS server side.
</p>
<p>If compatibility with such devices is a concern, not sending length-hidden messages
solves the problem by using minimal padding.
</p>
<p>If you implement an application that have a configuration file, we
recommend that you make it possible for users or administrators to
specify a GnuTLS protocol priority string, which is used by your
application via <a href="#gnutls_005fpriority_005fset">gnutls_priority_set</a>. To allow the best
flexibility, make it possible to have a different priority string for
different incoming IP addresses.
</p>
<hr>
<a name="The-TLS-Alert-Protocol"></a>
<div class="header">
<p>
Next: <a href="#The-TLS-Handshake-Protocol" accesskey="n" rel="next">The TLS Handshake Protocol</a>, Previous: <a href="#The-TLS-record-protocol" accesskey="p" rel="previous">The TLS record protocol</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="The-TLS-alert-protocol"></a>
<h3 class="section">3.4 The TLS alert protocol</h3>
<a name="The-Alert-Protocol"></a><a name="index-alert-protocol"></a>
<p>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
(e.g. <code>GNUTLS_A_CLOSE_NOTIFY</code>), and others refer to the
application protocol solely (e.g. <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 re-negotiations using the current session ID. All alert
messages are summarized in the table below.
</p>
<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.
</p>
<table>
<tr><td><a name="tab_003aalerts"></a></td></tr>
<thead><tr><th width="55%">Alert</th><th width="10%">ID</th><th width="30%">Description</th></tr></thead>
<tr><td width="55%">GNUTLS_A_CLOSE_NOTIFY</td><td width="10%">0</td><td width="30%">Close notify</td></tr>
<tr><td width="55%">GNUTLS_A_UNEXPECTED_MESSAGE</td><td width="10%">10</td><td width="30%">Unexpected message</td></tr>
<tr><td width="55%">GNUTLS_A_BAD_RECORD_MAC</td><td width="10%">20</td><td width="30%">Bad record MAC</td></tr>
<tr><td width="55%">GNUTLS_A_DECRYPTION_FAILED</td><td width="10%">21</td><td width="30%">Decryption failed</td></tr>
<tr><td width="55%">GNUTLS_A_RECORD_OVERFLOW</td><td width="10%">22</td><td width="30%">Record overflow</td></tr>
<tr><td width="55%">GNUTLS_A_DECOMPRESSION_FAILURE</td><td width="10%">30</td><td width="30%">Decompression failed</td></tr>
<tr><td width="55%">GNUTLS_A_HANDSHAKE_FAILURE</td><td width="10%">40</td><td width="30%">Handshake failed</td></tr>
<tr><td width="55%">GNUTLS_A_SSL3_NO_CERTIFICATE</td><td width="10%">41</td><td width="30%">No certificate (SSL 3.0)</td></tr>
<tr><td width="55%">GNUTLS_A_BAD_CERTIFICATE</td><td width="10%">42</td><td width="30%">Certificate is bad</td></tr>
<tr><td width="55%">GNUTLS_A_UNSUPPORTED_CERTIFICATE</td><td width="10%">43</td><td width="30%">Certificate is not supported</td></tr>
<tr><td width="55%">GNUTLS_A_CERTIFICATE_REVOKED</td><td width="10%">44</td><td width="30%">Certificate was revoked</td></tr>
<tr><td width="55%">GNUTLS_A_CERTIFICATE_EXPIRED</td><td width="10%">45</td><td width="30%">Certificate is expired</td></tr>
<tr><td width="55%">GNUTLS_A_CERTIFICATE_UNKNOWN</td><td width="10%">46</td><td width="30%">Unknown certificate</td></tr>
<tr><td width="55%">GNUTLS_A_ILLEGAL_PARAMETER</td><td width="10%">47</td><td width="30%">Illegal parameter</td></tr>
<tr><td width="55%">GNUTLS_A_UNKNOWN_CA</td><td width="10%">48</td><td width="30%">CA is unknown</td></tr>
<tr><td width="55%">GNUTLS_A_ACCESS_DENIED</td><td width="10%">49</td><td width="30%">Access was denied</td></tr>
<tr><td width="55%">GNUTLS_A_DECODE_ERROR</td><td width="10%">50</td><td width="30%">Decode error</td></tr>
<tr><td width="55%">GNUTLS_A_DECRYPT_ERROR</td><td width="10%">51</td><td width="30%">Decrypt error</td></tr>
<tr><td width="55%">GNUTLS_A_EXPORT_RESTRICTION</td><td width="10%">60</td><td width="30%">Export restriction</td></tr>
<tr><td width="55%">GNUTLS_A_PROTOCOL_VERSION</td><td width="10%">70</td><td width="30%">Error in protocol version</td></tr>
<tr><td width="55%">GNUTLS_A_INSUFFICIENT_SECURITY</td><td width="10%">71</td><td width="30%">Insufficient security</td></tr>
<tr><td width="55%">GNUTLS_A_INTERNAL_ERROR</td><td width="10%">80</td><td width="30%">Internal error</td></tr>
<tr><td width="55%">GNUTLS_A_USER_CANCELED</td><td width="10%">90</td><td width="30%">User canceled</td></tr>
<tr><td width="55%">GNUTLS_A_NO_RENEGOTIATION</td><td width="10%">100</td><td width="30%">No renegotiation is allowed</td></tr>
<tr><td width="55%">GNUTLS_A_UNSUPPORTED_EXTENSION</td><td width="10%">110</td><td width="30%">An unsupported extension was sent</td></tr>
<tr><td width="55%">GNUTLS_A_CERTIFICATE_UNOBTAINABLE</td><td width="10%">111</td><td width="30%">Could not retrieve the specified certificate</td></tr>
<tr><td width="55%">GNUTLS_A_UNRECOGNIZED_NAME</td><td width="10%">112</td><td width="30%">The server name sent was not recognized</td></tr>
<tr><td width="55%">GNUTLS_A_UNKNOWN_PSK_IDENTITY</td><td width="10%">115</td><td width="30%">The SRP/PSK username is missing or not known</td></tr>
</table>
<hr>
<a name="The-TLS-Handshake-Protocol"></a>
<div class="header">
<p>
Next: <a href="#TLS-Extensions" accesskey="n" rel="next">TLS Extensions</a>, Previous: <a href="#The-TLS-Alert-Protocol" accesskey="p" rel="previous">The TLS Alert Protocol</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="The-TLS-handshake-protocol"></a>
<h3 class="section">3.5 The TLS handshake protocol</h3>
<a name="The-Handshake-Protocol"></a><a name="index-handshake-protocol"></a>
<p>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. The main handshake function
is <a href="#gnutls_005fhandshake">gnutls_handshake</a>. In the next paragraphs we elaborate on
the handshake protocol, i.e., the ciphersuite negotiation.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#TLS-Cipher-Suites" accesskey="1">TLS Cipher Suites</a>:</td><td> </td><td align="left" valign="top">TLS session parameters.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Authentication" accesskey="2">Authentication</a>:</td><td> </td><td align="left" valign="top">TLS authentication.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Client-Authentication" accesskey="3">Client Authentication</a>:</td><td> </td><td align="left" valign="top">Requesting a certificate from the client.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Resuming-Sessions" accesskey="4">Resuming Sessions</a>:</td><td> </td><td align="left" valign="top">Reusing previously established keys.
</td></tr>
</table>
<hr>
<a name="TLS-Cipher-Suites"></a>
<div class="header">
<p>
Next: <a href="#Authentication" accesskey="n" rel="next">Authentication</a>, Up: <a href="#The-TLS-Handshake-Protocol" accesskey="u" rel="up">The TLS Handshake Protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-ciphersuites"></a>
<h4 class="subsection">3.5.1 TLS ciphersuites</h4>
<p>The handshake protocol of <acronym>TLS</acronym> negotiates cipher suites of
a special form illustrated by the <code>TLS_DHE_RSA_WITH_3DES_CBC_SHA</code> cipher suite name. A typical cipher
suite contains these parameters:
</p>
<ul>
<li> The key exchange algorithm.
<code>DHE_RSA</code> in the example.
</li><li> The Symmetric encryption algorithm and mode
<code>3DES_CBC</code> in this example.
</li><li> The MAC<a name="DOCF5" href="#FOOT5"><sup>5</sup></a> algorithm used for authentication.
<code>MAC_SHA</code> is used in the above example.
</li></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>
<p>All the supported ciphersuites are listed in <a href="#ciphersuites">ciphersuites</a>.
</p>
<hr>
<a name="Authentication"></a>
<div class="header">
<p>
Next: <a href="#Client-Authentication" accesskey="n" rel="next">Client Authentication</a>, Previous: <a href="#TLS-Cipher-Suites" accesskey="p" rel="previous">TLS Cipher Suites</a>, Up: <a href="#The-TLS-Handshake-Protocol" accesskey="u" rel="up">The TLS Handshake Protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Authentication-1"></a>
<h4 class="subsection">3.5.2 Authentication</h4>
<p>The key exchange algorithms of the <acronym>TLS</acronym> protocol offer
authentication, which is a prerequisite for a secure connection.
The available authentication methods in <acronym>GnuTLS</acronym> follow.
</p>
<ul>
<li> Certificate authentication: Authenticated key exchange using public key infrastructure and certificates (X.509 or OpenPGP).
</li><li> <acronym>SRP</acronym> authentication: Authenticated key exchange using a password.
</li><li> <acronym>PSK</acronym> authentication: Authenticated key exchange using a pre-shared key.
</li><li> Anonymous authentication: Key exchange without peer authentication.
</li></ul>
<hr>
<a name="Client-Authentication"></a>
<div class="header">
<p>
Next: <a href="#Resuming-Sessions" accesskey="n" rel="next">Resuming Sessions</a>, Previous: <a href="#Authentication" accesskey="p" rel="previous">Authentication</a>, Up: <a href="#The-TLS-Handshake-Protocol" accesskey="u" rel="up">The TLS Handshake Protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Client-authentication"></a>
<h4 class="subsection">3.5.3 Client authentication</h4>
<a name="index-client-certificate-authentication"></a>
<p>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. We elaborate
in <a href="#Certificate-credentials">Certificate credentials</a>.
</p>
<hr>
<a name="Resuming-Sessions"></a>
<div class="header">
<p>
Previous: <a href="#Client-Authentication" accesskey="p" rel="previous">Client Authentication</a>, Up: <a href="#The-TLS-Handshake-Protocol" accesskey="u" rel="up">The TLS Handshake Protocol</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Resuming-sessions"></a>
<h4 class="subsection">3.5.4 Resuming sessions</h4>
<a name="resume"></a><a name="index-resuming-sessions"></a>
<a name="index-session-resumption"></a>
<p>The TLS handshake process performs expensive calculations
and a busy server might easily be put under load. To
reduce the load, session resumption may be used. This
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 re-using the previously
established keys, meaning the server needs to store the state of established
connections (unless session tickets are used – <a href="#Session-tickets">Session tickets</a>).
</p>
<p>Session resumption is an integral part of <acronym>GnuTLS</acronym>, and
<a href="#Session-resumption">Session resumption</a>, <a href="#ex_003aresume_002dclient">ex:resume-client</a> illustrate typical
uses of it.
</p>
<hr>
<a name="TLS-Extensions"></a>
<div class="header">
<p>
Next: <a href="#How-to-use-TLS-in-application-protocols" accesskey="n" rel="next">How to use TLS in application protocols</a>, Previous: <a href="#The-TLS-Handshake-Protocol" accesskey="p" rel="previous">The TLS Handshake Protocol</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-extensions"></a>
<h3 class="section">3.6 TLS extensions</h3>
<a name="index-TLS-extensions"></a>
<p>A number of extensions to the <acronym>TLS</acronym> protocol have been
proposed mainly in [<em>TLSEXT</em>]. The extensions supported
in <acronym>GnuTLS</acronym> are:
</p>
<ul>
<li> Maximum fragment length negotiation
</li><li> Server name indication
</li><li> Session tickets
</li><li> HeartBeat
</li><li> Safe Renegotiation
</li></ul>
<p>and they will be discussed in the subsections that follow.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Maximum-fragment-length-negotiation" accesskey="1">Maximum fragment length negotiation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Server-name-indication" accesskey="2">Server name indication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Session-tickets" accesskey="3">Session tickets</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#HeartBeat" accesskey="4">HeartBeat</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Safe-renegotiation" accesskey="5">Safe renegotiation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#OCSP-status-request" accesskey="6">OCSP status request</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#SRTP" accesskey="7">SRTP</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Maximum-fragment-length-negotiation"></a>
<div class="header">
<p>
Next: <a href="#Server-name-indication" accesskey="n" rel="next">Server name indication</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Maximum-fragment-length-negotiation-1"></a>
<h4 class="subsection">3.6.1 Maximum fragment length negotiation</h4>
<a name="index-TLS-extensions-1"></a>
<a name="index-maximum-fragment-length"></a>
<p>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. The functions shown
below can be used to control this extension.
</p>
<dl compact="compact">
<dt><code><var>size_t</var> <a href="#gnutls_005frecord_005fget_005fmax_005fsize">gnutls_record_get_max_size</a> (gnutls_session_t <var>session</var>)</code></dt>
<dt><code><var>ssize_t</var> <a href="#gnutls_005frecord_005fset_005fmax_005fsize">gnutls_record_set_max_size</a> (gnutls_session_t <var>session</var>, size_t <var>size</var>)</code></dt>
</dl>
<hr>
<a name="Server-name-indication"></a>
<div class="header">
<p>
Next: <a href="#Session-tickets" accesskey="n" rel="next">Session tickets</a>, Previous: <a href="#Maximum-fragment-length-negotiation" accesskey="p" rel="previous">Maximum fragment length negotiation</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Server-name-indication-1"></a>
<h4 class="subsection">3.6.2 Server name indication</h4>
<a name="serverind"></a><a name="index-TLS-extensions-2"></a>
<a name="index-server-name-indication"></a>
<p>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>
<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.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fserver_005fname_005fset">gnutls_server_name_set</a> (gnutls_session_t <var>session</var>, gnutls_server_name_type_t <var>type</var>, const void * <var>name</var>, size_t <var>name_length</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fserver_005fname_005fget">gnutls_server_name_get</a> (gnutls_session_t <var>session</var>, void * <var>data</var>, size_t * <var>data_length</var>, unsigned int * <var>type</var>, unsigned int <var>indx</var>)</code></dt>
</dl>
<hr>
<a name="Session-tickets"></a>
<div class="header">
<p>
Next: <a href="#HeartBeat" accesskey="n" rel="next">HeartBeat</a>, Previous: <a href="#Server-name-indication" accesskey="p" rel="previous">Server name indication</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Session-tickets-1"></a>
<h4 class="subsection">3.6.3 Session tickets</h4>
<a name="index-TLS-extensions-3"></a>
<a name="index-session-tickets"></a>
<a name="index-tickets"></a>
<p>To resume a TLS session the server normally store session parameters. This
complicates deployment, and could be avoiding by delegating the storage
to the client. Because session parameters are sensitive they are encrypted
and authenticated with a key only known to the server and then sent to the
client. The Session Tickets extension is described in RFC 5077 [<em>TLSTKT</em>].
</p>
<p>Since version 3.1.3 GnuTLS clients transparently support session tickets.
</p>
<hr>
<a name="HeartBeat"></a>
<div class="header">
<p>
Next: <a href="#Safe-renegotiation" accesskey="n" rel="next">Safe renegotiation</a>, Previous: <a href="#Session-tickets" accesskey="p" rel="previous">Session tickets</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="HeartBeat-1"></a>
<h4 class="subsection">3.6.4 HeartBeat</h4>
<a name="index-TLS-extensions-4"></a>
<a name="index-heartbeat"></a>
<p>This TLS extension allows to ping and receive confirmation from the peer,
is described in [<em>RFC6520</em>]. The extension is disabled by default and
<a href="#gnutls_005fheartbeat_005fenable">gnutls_heartbeat_enable</a> can be used to enable it. A policy
may be negotiated to only allow sending heartbeat messages or sending and receiving.
The current session policy can be checked with <a href="#gnutls_005fheartbeat_005fallowed">gnutls_heartbeat_allowed</a>.
The requests coming from the peer result to <code>GNUTLS_E_HERTBEAT_PING_RECEIVED</code>
being returned from the receive function. Ping requests to peer can be send via
<a href="#gnutls_005fheartbeat_005fping">gnutls_heartbeat_ping</a>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fheartbeat_005fallowed">gnutls_heartbeat_allowed</a> (gnutls_session_t <var>session</var>, unsigned int <var>type</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fheartbeat_005fenable">gnutls_heartbeat_enable</a> (gnutls_session_t <var>session</var>, unsigned int <var>type</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fheartbeat_005fping">gnutls_heartbeat_ping</a> (gnutls_session_t <var>session</var>, size_t <var>data_size</var>, unsigned int <var>max_tries</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fheartbeat_005fpong">gnutls_heartbeat_pong</a> (gnutls_session_t <var>session</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fheartbeat_005fset_005ftimeouts">gnutls_heartbeat_set_timeouts</a> (gnutls_session_t <var>session</var>, unsigned int <var>retrans_timeout</var>, unsigned int <var>total_timeout</var>)</code></dt>
<dt><code><var>unsigned int</var> <a href="#gnutls_005fheartbeat_005fget_005ftimeout">gnutls_heartbeat_get_timeout</a> (gnutls_session_t <var>session</var>)</code></dt>
</dl>
<hr>
<a name="Safe-renegotiation"></a>
<div class="header">
<p>
Next: <a href="#OCSP-status-request" accesskey="n" rel="next">OCSP status request</a>, Previous: <a href="#HeartBeat" accesskey="p" rel="previous">HeartBeat</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Safe-renegotiation-1"></a>
<h4 class="subsection">3.6.5 Safe renegotiation</h4>
<a name="index-renegotiation"></a>
<a name="index-safe-renegotiation"></a>
<p>TLS gives the option to two communicating parties to renegotiate
and update their security parameters. One useful example of this feature
was for a client to initially connect using anonymous negotiation to a
server, and the renegotiate using some authenticated ciphersuite. This occurred
to avoid having the client sending its credentials in the clear.
</p>
<p>However this renegotiation, as initially designed would not ensure that
the party one is renegotiating is the same as the one in the initial negotiation.
For example one server could forward all renegotiation traffic to an other
server who will see this traffic as an initial negotiation attempt.
</p>
<p>This might be seen as a valid design decision, but it seems it was
not widely known or understood, thus today some application protocols the TLS
renegotiation feature in a manner that enables a malicious server to insert
content of his choice in the beginning of a TLS session.
</p>
<p>The most prominent vulnerability was with HTTPS. There servers request
a renegotiation to enforce an anonymous user to use a certificate in order
to access certain parts of a web site. The
attack works by having the attacker simulate a client and connect to a
server, with server-only authentication, and send some data intended
to cause harm. The server will then require renegotiation from him
in order to perform the request.
When the proper client attempts to contact the server,
the attacker hijacks that connection and forwards traffic to
the initial server that requested renegotiation. The
attacker will not be able to read the data exchanged between the
client and the server. However, the server will (incorrectly) assume
that the initial request sent by the attacker was sent by the now authenticated
client. The result is a prefix plain-text injection attack.
</p>
<p>The above is just one example. Other vulnerabilities exists that do
not rely on the TLS renegotiation to change the client’s authenticated
status (either TLS or application layer).
</p>
<p>While fixing these application protocols and implementations would be
one natural reaction, an extension to TLS has been designed that
cryptographically binds together any renegotiated handshakes with the
initial negotiation. When the extension is used, the attack is
detected and the session can be terminated. The extension is
specified in [<em>RFC5746</em>].
</p>
<p>GnuTLS supports the safe renegotiation extension. The default
behavior is as follows. Clients will attempt to negotiate the safe
renegotiation extension when talking to servers. Servers will accept
the extension when presented by clients. Clients and servers will
permit an initial handshake to complete even when the other side does
not support the safe renegotiation extension. Clients and servers
will refuse renegotiation attempts when the extension has not been
negotiated.
</p>
<p>Note that permitting clients to connect to servers when the safe
renegotiation extension is not enabled, is open up for attacks.
Changing this default behavior would prevent interoperability against
the majority of deployed servers out there. We will reconsider this
default behavior in the future when more servers have been upgraded.
Note that it is easy to configure clients to always require the safe
renegotiation extension from servers.
</p>
<p>To modify the default behavior, we have introduced some new priority
strings (see <a href="#Priority-Strings">Priority Strings</a>).
The <code>%UNSAFE_RENEGOTIATION</code> priority string permits
(re-)handshakes even when the safe renegotiation extension was not
negotiated. The default behavior is <code>%PARTIAL_RENEGOTIATION</code> that will
prevent renegotiation with clients and servers not supporting the
extension. This is secure for servers but leaves clients vulnerable
to some attacks, but this is a trade-off between security and compatibility
with old servers. The <code>%SAFE_RENEGOTIATION</code> priority string makes
clients and servers require the extension for every handshake. The latter
is the most secure option for clients, at the cost of not being able
to connect to legacy servers. Servers will also deny clients that
do not support the extension from connecting.
</p>
<p>It is possible to disable use of the extension completely, in both
clients and servers, by using the <code>%DISABLE_SAFE_RENEGOTIATION</code>
priority string however we strongly recommend you to only do this for
debugging and test purposes.
</p>
<p>The default values if the flags above are not specified are:
</p><dl compact="compact">
<dt><code>Server:</code></dt>
<dd><p>%PARTIAL_RENEGOTIATION
</p>
</dd>
<dt><code>Client:</code></dt>
<dd><p>%PARTIAL_RENEGOTIATION
</p>
</dd>
</dl>
<p>For applications we have introduced a new API related to safe
renegotiation. The <a href="#gnutls_005fsafe_005frenegotiation_005fstatus">gnutls_safe_renegotiation_status</a> function is
used to check if the extension has been negotiated on a session, and
can be used both by clients and servers.
</p>
<hr>
<a name="OCSP-status-request"></a>
<div class="header">
<p>
Next: <a href="#SRTP" accesskey="n" rel="next">SRTP</a>, Previous: <a href="#Safe-renegotiation" accesskey="p" rel="previous">Safe renegotiation</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="OCSP-status-request-1"></a>
<h4 class="subsection">3.6.6 OCSP status request</h4>
<a name="index-OCSP-status-request"></a>
<a name="index-Certificate-status-request"></a>
<p>The Online Certificate Status Protocol (OCSP) is a protocol that allows the
client to verify the server certificate for revocation without messing with
certificate revocation lists. Its drawback is that it requires the client
to connect to the server’s CA OCSP server and request the status of the
certificate. This extension however, enables a TLS server to include
its CA OCSP server response in the handshake. That is an HTTPS server
may periodically run <code>ocsptool</code> (see <a href="#ocsptool-Invocation">ocsptool Invocation</a>) to obtain
its certificate revocation status and serve it to the clients. That
way a client avoids an additional connection to the OCSP server.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffunction">gnutls_certificate_set_ocsp_status_request_function</a> (gnutls_certificate_credentials_t <var>sc</var>, gnutls_status_request_ocsp_func <var>ocsp_func</var>, void * <var>ptr</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffile">gnutls_certificate_set_ocsp_status_request_file</a> (gnutls_certificate_credentials_t <var>sc</var>, const char* <var>response_file</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fstatus_005frequest_005fenable_005fclient">gnutls_ocsp_status_request_enable_client</a> (gnutls_session_t <var>session</var>, gnutls_datum_t * <var>responder_id</var>, size_t <var>responder_id_size</var>, gnutls_datum_t * <var>extensions</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fstatus_005frequest_005fis_005fchecked">gnutls_ocsp_status_request_is_checked</a> (gnutls_session_t <var>session</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<p>A server is required to provide the OCSP server’s response using the <a href="#gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffile">gnutls_certificate_set_ocsp_status_request_file</a>.
The response may be obtained periodically using the following command.
</p>
<div class="example">
<pre class="example">ocsptool --ask --load-cert server_cert.pem --load-issuer the_issuer.pem
--load-signer the_issuer.pem --outfile ocsp.response
</pre></div>
<p>Since version 3.1.3 GnuTLS clients transparently support the certificate status
request.
</p>
<hr>
<a name="SRTP"></a>
<div class="header">
<p>
Previous: <a href="#OCSP-status-request" accesskey="p" rel="previous">OCSP status request</a>, Up: <a href="#TLS-Extensions" accesskey="u" rel="up">TLS Extensions</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="SRTP-1"></a>
<h4 class="subsection">3.6.7 SRTP</h4>
<a name="index-SRTP"></a>
<a name="index-Secure-RTP"></a>
<p>The TLS protocol was extended in [<em>RFC5764</em>] to provide keying material to the
Secure RTP (SRTP) protocol. The SRTP protocol provides an encapsulation of encrypted
data that is optimized for voice data. With the SRTP TLS extension two peers can
negotiate keys using TLS or DTLS and obtain keying material for use with SRTP. The
available SRTP profiles are listed below.
</p>
<div class="float"><a name="gnutls_005fsrtp_005fprofile_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80</code></dt>
<dd><p>128 bit AES with a 80 bit HMAC-SHA1
</p></dd>
<dt><code>GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32</code></dt>
<dd><p>128 bit AES with a 32 bit HMAC-SHA1
</p></dd>
<dt><code>GNUTLS_SRTP_NULL_HMAC_SHA1_80</code></dt>
<dd><p>NULL cipher with a 80 bit HMAC-SHA1
</p></dd>
<dt><code>GNUTLS_SRTP_NULL_HMAC_SHA1_32</code></dt>
<dd><p>NULL cipher with a 32 bit HMAC-SHA1
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 3.3: </strong>Supported SRTP profiles</p></div></div>
<p>To enable use the following functions.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fsrtp_005fset_005fprofile">gnutls_srtp_set_profile</a> (gnutls_session_t <var>session</var>, gnutls_srtp_profile_t <var>profile</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsrtp_005fset_005fprofile_005fdirect">gnutls_srtp_set_profile_direct</a> (gnutls_session_t <var>session</var>, const char * <var>profiles</var>, const char ** <var>err_pos</var>)</code></dt>
</dl>
<p>To obtain the negotiated keys use the function below.
</p>
<dl>
<dt><a name="index-gnutls_005fsrtp_005fget_005fkeys"></a>Function: <em>int</em> <strong>gnutls_srtp_get_keys</strong> <em>(gnutls_session_t <var>session</var>, void * <var>key_material</var>, unsigned int <var>key_material_size</var>, gnutls_datum_t * <var>client_key</var>, gnutls_datum_t * <var>client_salt</var>, gnutls_datum_t * <var>server_key</var>, gnutls_datum_t * <var>server_salt</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>key_material</var>: Space to hold the generated key material
</p>
<p><var>key_material_size</var>: The maximum size of the key material
</p>
<p><var>client_key</var>: The master client write key, pointing inside the key material
</p>
<p><var>client_salt</var>: The master client write salt, pointing inside the key material
</p>
<p><var>server_key</var>: The master server write key, pointing inside the key material
</p>
<p><var>server_salt</var>: The master server write salt, pointing inside the key material
</p>
<p>This is a helper function to generate the keying material for SRTP.
It requires the space of the key material to be pre-allocated (should be at least
2x the maximum key size and salt size). The <code>client_key</code> , <code>client_salt</code> , <code>server_key</code> and <code>server_salt</code> are convenience datums that point inside the key material. They may
be <code>NULL</code> .
</p>
<p><strong>Returns:</strong> On success the size of the key material is returned,
otherwise, <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the buffer given is not
sufficient, or a negative error code.
</p>
<p>Since 3.1.4
</p></dd></dl>
<p>Other helper functions are listed below.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fsrtp_005fget_005fselected_005fprofile">gnutls_srtp_get_selected_profile</a> (gnutls_session_t <var>session</var>, gnutls_srtp_profile_t * <var>profile</var>)</code></dt>
<dt><code><var>const char *</var> <a href="#gnutls_005fsrtp_005fget_005fprofile_005fname">gnutls_srtp_get_profile_name</a> (gnutls_srtp_profile_t <var>profile</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsrtp_005fget_005fprofile_005fid">gnutls_srtp_get_profile_id</a> (const char * <var>name</var>, gnutls_srtp_profile_t * <var>profile</var>)</code></dt>
</dl>
<hr>
<a name="How-to-use-TLS-in-application-protocols"></a>
<div class="header">
<p>
Next: <a href="#On-SSL-2-and-older-protocols" accesskey="n" rel="next">On SSL 2 and older protocols</a>, Previous: <a href="#TLS-Extensions" accesskey="p" rel="previous">TLS Extensions</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="How-to-use-TLS-in-application-protocols-1"></a>
<h3 class="section">3.7 How to use <acronym>TLS</acronym> in application protocols</h3>
<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 <acronym>TCP/IP</acronym> transport layer
but may be extended to other ones too.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Separate-ports" accesskey="1">Separate ports</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Upward-negotiation" accesskey="2">Upward negotiation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Separate-ports"></a>
<div class="header">
<p>
Next: <a href="#Upward-negotiation" accesskey="n" rel="next">Upward negotiation</a>, Up: <a href="#How-to-use-TLS-in-application-protocols" accesskey="u" rel="up">How to use TLS in application protocols</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Separate-ports-1"></a>
<h4 class="subsection">3.7.1 Separate ports</h4>
<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 [<em>RFC2818</em>].
</p>
<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 name="DOCF6" href="#FOOT6"><sup>6</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>
<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.
</p>
<hr>
<a name="Upward-negotiation"></a>
<div class="header">
<p>
Previous: <a href="#Separate-ports" accesskey="p" rel="previous">Separate ports</a>, Up: <a href="#How-to-use-TLS-in-application-protocols" accesskey="u" rel="up">How to use TLS in application protocols</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Upward-negotiation-1"></a>
<h4 class="subsection">3.7.2 Upward negotiation</h4>
<p>Other application protocols<a name="DOCF7" href="#FOOT7"><sup>7</sup></a> use a
different approach to enable the secure layer. They use something
often called as 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 approach
does not require any extra port to be reserved.
There is even an extension to HTTP protocol to support
that method [<em>RFC2817</em>].
</p>
<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:
</p>
<blockquote>
<p>(client connects to the server)
</p>
<p>CLIENT: HELLO I’M MR. XXX
</p>
<p>SERVER: NICE TO MEET YOU XXX
</p>
<p>CLIENT: PLEASE START TLS
</p>
<p>SERVER: OK
</p>
<p>*** TLS STARTS
</p>
<p>CLIENT: HERE ARE SOME CONFIDENTIAL DATA
</p></blockquote>
<p>And see an example of a conversation where someone is acting
in between:
</p>
<blockquote>
<p>(client connects to the server)
</p>
<p>CLIENT: HELLO I’M MR. XXX
</p>
<p>SERVER: NICE TO MEET YOU XXX
</p>
<p>CLIENT: PLEASE START TLS
</p>
<p>(here someone inserts this message)
</p>
<p>SERVER: SORRY I DON’T HAVE THIS CAPABILITY
</p>
<p>CLIENT: HERE ARE SOME CONFIDENTIAL DATA
</p></blockquote>
<p>As you can see above the client was fooled, and was dummy enough to
send the confidential data in the clear.
</p>
<p>How to avoid the above attack? As you may have already noticed 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:
</p>
<blockquote>
<p>(client connects to the server)
</p>
<p>CLIENT: HELLO I’M MR. XXX
</p>
<p>SERVER: NICE TO MEET YOU XXX
</p>
<p>CLIENT: PLEASE START TLS
</p>
<p>(here someone inserts this message)
</p>
<p>SERVER: SORRY I DON’T HAVE THIS CAPABILITY
</p>
<p>CLIENT: BYE
</p>
<p>(the client notifies the user that the secure connection was not possible)
</p></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, or anything else!
</p>
<hr>
<a name="On-SSL-2-and-older-protocols"></a>
<div class="header">
<p>
Previous: <a href="#How-to-use-TLS-in-application-protocols" accesskey="p" rel="previous">How to use TLS in application protocols</a>, Up: <a href="#Introduction-to-TLS" accesskey="u" rel="up">Introduction to TLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="On-SSL-2-and-older-protocols-1"></a>
<h3 class="section">3.8 On SSL 2 and older protocols</h3>
<a name="index-SSL-2"></a>
<p>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>
<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. The security
problems in <acronym>SSL</acronym> 2.0 include:
</p>
<ul>
<li> Message integrity compromised.
The <acronym>SSLv2</acronym> message authentication uses the MD5 function, and
is insecure.
</li><li> Man-in-the-middle attack.
There is no protection of the handshake in <acronym>SSLv2</acronym>, which
permits a man-in-the-middle attack.
</li><li> Truncation attack.
<acronym>SSLv2</acronym> relies on TCP FIN to close the session, so the
attacker can forge a TCP FIN, and the peer cannot tell if it was a
legitimate end of data or not.
</li><li> Weak message integrity for export ciphers.
The cryptographic keys in <acronym>SSLv2</acronym> are used for both message
authentication and encryption, so if weak encryption schemes are
negotiated (say 40-bit keys) the message authentication code uses the
same weak key, which isn’t necessary.
</li></ul>
<a name="index-PCT"></a>
<p>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.
</p>
<hr>
<a name="Authentication-methods"></a>
<div class="header">
<p>
Next: <a href="#Hardware-security-modules-and-abstract-key-types" accesskey="n" rel="next">Hardware security modules and abstract key types</a>, Previous: <a href="#Introduction-to-TLS" accesskey="p" rel="previous">Introduction to TLS</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Authentication-methods-1"></a>
<h2 class="chapter">4 Authentication methods</h2>
<a name="index-authentication-methods"></a>
<p>The initial key exchange of the TLS protocol performs authentication
of the peers. In typical scenarios the server is authenticated to
the client, and optionally the client to the server.
</p>
<p>While many associate TLS with X.509 certificates and public key
authentication, the protocol supports various authentication methods,
including pre-shared keys, and passwords. In this chapter a description
of the existing authentication methods is provided, as well as some
guidance on which use-cases each method can be used at.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Certificate-authentication" accesskey="1">Certificate authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#More-on-certificate-authentication" accesskey="2">More on certificate authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shared_002dkey-and-anonymous-authentication" accesskey="3">Shared-key and anonymous authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Selecting-an-appropriate-authentication-method" accesskey="4">Selecting an appropriate authentication method</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Certificate-authentication"></a>
<div class="header">
<p>
Next: <a href="#More-on-certificate-authentication" accesskey="n" rel="next">More on certificate authentication</a>, Up: <a href="#Authentication-methods" accesskey="u" rel="up">Authentication methods</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Certificate-authentication-1"></a>
<h3 class="section">4.1 Certificate authentication</h3>
<a name="index-certificate-authentication"></a>
<p>The most known authentication method of <acronym>TLS</acronym> are certificates.
The PKIX [<em>PKIX</em>] public key infrastructure is daily used by anyone
using a browser today. <acronym>GnuTLS</acronym> supports both
<acronym>X.509</acronym> certificates [<em>PKIX</em>] and <acronym>OpenPGP</acronym>
certificates using a common API.
</p>
<p>The key exchange algorithms supported by certificate authentication are
shown in <a href="#tab_003akey_002dexchange">Table 4.1</a>.
</p>
<div class="float"><a name="tab_003akey_002dexchange"></a>
<table>
<thead><tr><th width="20%">Key exchange</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">RSA</td><td width="70%">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.</td></tr>
<tr><td width="20%">RSA_EXPORT</td><td width="70%">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.</td></tr>
<tr><td width="20%">DHE_RSA</td><td width="70%">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.</td></tr>
<tr><td width="20%">ECDHE_RSA</td><td width="70%">The RSA algorithm is used to sign ephemeral elliptic curve Diffie-Hellman
parameters which are sent to the peer. The key in the certificate must allow
the key to be used for signing. It also offers 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.</td></tr>
<tr><td width="20%">DHE_DSS</td><td width="70%">The DSA 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. DSA is the algorithm
of the Digital Signature Standard (DSS).</td></tr>
<tr><td width="20%">ECDHE_ECDSA</td><td width="70%">The Elliptic curve DSA algorithm is used to sign ephemeral elliptic
curve Diffie-Hellman parameters which are sent to the peer. The
certificate must contain ECDSA parameters (i.e., EC and marked for signing)
to use this key exchange algorithm.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.1: </strong>Supported key exchange algorithms.</p></div></div>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#X_002e509-certificates" accesskey="1">X.509 certificates</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#OpenPGP-certificates" accesskey="2">OpenPGP certificates</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Advanced-certificate-verification" accesskey="3">Advanced certificate verification</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Digital-signatures" accesskey="4">Digital signatures</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="X_002e509-certificates"></a>
<div class="header">
<p>
Next: <a href="#OpenPGP-certificates" accesskey="n" rel="next">OpenPGP certificates</a>, Up: <a href="#Certificate-authentication" accesskey="u" rel="up">Certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="X_002e509-certificates-1"></a>
<h4 class="subsection">4.1.1 <acronym>X.509</acronym> certificates</h4>
<a name="index-X_002e509-certificates"></a>
<p>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.
</p>
<div class="float"><a name="fig_003ax509"></a>
<img src="gnutls-x509.png" alt="gnutls-x509">
<div class="float-caption"><p><strong>Figure 4.1: </strong>An example of the X.509 hierarchical trust model.</p></div></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. The framework is illustrated on <a href="#fig_003ax509">Figure 4.1</a>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#X_002e509-certificate-structure" accesskey="1">X.509 certificate structure</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Importing-an-X_002e509-certificate" accesskey="2">Importing an X.509 certificate</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#X_002e509-distinguished-names" accesskey="3">X.509 distinguished names</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#X_002e509-public-and-private-keys" accesskey="4">X.509 public and private keys</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Verifying-X_002e509-certificate-paths" accesskey="5">Verifying X.509 certificate paths</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Verifying-a-certificate-in-the-context-of-TLS-session" accesskey="6">Verifying a certificate in the context of TLS session</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="X_002e509-certificate-structure"></a>
<div class="header">
<p>
Next: <a href="#Importing-an-X_002e509-certificate" accesskey="n" rel="next">Importing an X.509 certificate</a>, Up: <a href="#X_002e509-certificates" accesskey="u" rel="up">X.509 certificates</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="X_002e509-certificate-structure-1"></a>
<h4 class="subsubsection">4.1.1.1 <acronym>X.509</acronym> certificate structure</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 [<em>PKIX</em>] as shown in <a href="#tab_003ax509">Table 4.2</a>.
</p>
<div class="float"><a name="tab_003ax509"></a>
<table>
<thead><tr><th width="20%">Field</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">version</td><td width="70%">The field that indicates the version of the certificate.</td></tr>
<tr><td width="20%">serialNumber</td><td width="70%">This field holds a unique serial number per certificate.</td></tr>
<tr><td width="20%">signature</td><td width="70%">The issuing authority’s signature.</td></tr>
<tr><td width="20%">issuer</td><td width="70%">Holds the issuer’s distinguished name.</td></tr>
<tr><td width="20%">validity</td><td width="70%">The activation and expiration dates.</td></tr>
<tr><td width="20%">subject</td><td width="70%">The subject’s distinguished name of the certificate.</td></tr>
<tr><td width="20%">extensions</td><td width="70%">The extensions are fields only present in version 3 certificates.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.2: </strong>X.509 certificate fields.</p></div></div>
<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 identifiers with their corresponding
values. Some of available OIDs to be used in an <acronym>X.509</acronym>
distinguished name are defined in <samp>gnutls/x509.h</samp>.
</p>
<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>
<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>
<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 <a href="#tab_003ax509_002dext">Table 4.3</a>.
</p>
<div class="float"><a name="tab_003ax509_002dext"></a>
<table>
<thead><tr><th width="30%">Extension</th><th width="20%">OID</th><th width="40%">Description</th></tr></thead>
<tr><td width="30%">Subject key id</td><td width="20%">2.5.29.14</td><td width="40%">An identifier of the key of the subject.</td></tr>
<tr><td width="30%">Authority key id</td><td width="20%">2.5.29.35</td><td width="40%">An identifier of the authority’s key used to sign the certificate.</td></tr>
<tr><td width="30%">Subject alternative name</td><td width="20%">2.5.29.17</td><td width="40%">Alternative names to subject’s distinguished name.</td></tr>
<tr><td width="30%">Key usage</td><td width="20%">2.5.29.15</td><td width="40%">Constraints the key’s usage of the certificate.</td></tr>
<tr><td width="30%">Extended key usage</td><td width="20%">2.5.29.37</td><td width="40%">Constraints the purpose of the certificate.</td></tr>
<tr><td width="30%">Basic constraints</td><td width="20%">2.5.29.19</td><td width="40%">Indicates whether this is a CA certificate or not, and specify the
maximum path lengths of certificate chains.</td></tr>
<tr><td width="30%">CRL distribution points</td><td width="20%">2.5.29.31</td><td width="40%">This extension is set by the CA, in order to inform about the issued
CRLs.</td></tr>
<tr><td width="30%">Certificate policy</td><td width="20%">2.5.29.32</td><td width="40%">This extension is set to indicate the certificate policy as object
identifier and may contain a descriptive string or URL.</td></tr>
<tr><td width="30%">Proxy Certification Information</td><td width="20%">1.3.6.1.5.5.7.1.14</td><td width="40%">Proxy Certificates includes this extension that contains the OID of
the proxy policy language used, and can specify limits on the maximum
lengths of proxy chains. Proxy Certificates are specified in
[<em>RFC3820</em>].</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.3: </strong>X.509 certificate extensions.</p></div></div>
<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>gnutls/x509.h</samp>. An example program to
demonstrate the <acronym>X.509</acronym> parsing capabilities can be found in
<a href="#ex_003ax509_002dinfo">ex:x509-info</a>.
</p>
<hr>
<a name="Importing-an-X_002e509-certificate"></a>
<div class="header">
<p>
Next: <a href="#X_002e509-distinguished-names" accesskey="n" rel="next">X.509 distinguished names</a>, Previous: <a href="#X_002e509-certificate-structure" accesskey="p" rel="previous">X.509 certificate structure</a>, Up: <a href="#X_002e509-certificates" accesskey="u" rel="up">X.509 certificates</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Importing-an-X_002e509-certificate-1"></a>
<h4 class="subsubsection">4.1.1.2 Importing an X.509 certificate</h4>
<p>The certificate structure should be initialized using <a href="#gnutls_005fx509_005fcrt_005finit">gnutls_x509_crt_init</a>, and
a certificate structure can be imported using <a href="#gnutls_005fx509_005fcrt_005fimport">gnutls_x509_crt_import</a>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005finit">gnutls_x509_crt_init</a> (gnutls_x509_crt_t * <var>cert</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fimport">gnutls_x509_crt_import</a> (gnutls_x509_crt_t <var>cert</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fx509_005fcrt_005fdeinit">gnutls_x509_crt_deinit</a> (gnutls_x509_crt_t <var>cert</var>)</code></dt>
</dl>
<p>In several functions an array of certificates is required. To assist in initialization
and import the following two functions are provided.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005flist_005fimport">gnutls_x509_crt_list_import</a> (gnutls_x509_crt_t * <var>certs</var>, unsigned int * <var>cert_max</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005flist_005fimport2">gnutls_x509_crt_list_import2</a> (gnutls_x509_crt_t ** <var>certs</var>, unsigned int * <var>size</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<p>In all cases after use a certificate must be deinitialized using <a href="#gnutls_005fx509_005fcrt_005fdeinit">gnutls_x509_crt_deinit</a>.
Note that although the functions above apply to <code>gnutls_x509_crt_t</code> structure, similar functions
exist for the CRL structure <code>gnutls_x509_crl_t</code>.
</p>
<hr>
<a name="X_002e509-distinguished-names"></a>
<div class="header">
<p>
Next: <a href="#X_002e509-public-and-private-keys" accesskey="n" rel="next">X.509 public and private keys</a>, Previous: <a href="#Importing-an-X_002e509-certificate" accesskey="p" rel="previous">Importing an X.509 certificate</a>, Up: <a href="#X_002e509-certificates" accesskey="u" rel="up">X.509 certificates</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="X_002e509-distinguished-names-1"></a>
<h4 class="subsubsection">4.1.1.3 X.509 distinguished names</h4>
<a name="index-X_002e509-distinguished-name"></a>
<p>The “subject” of an X.509 certificate is not described by
a single name, but rather with a distinguished name. This in
X.509 terminology is a list of strings each associated an object
identifier. To make things simple GnuTLS provides <a href="#gnutls_005fx509_005fcrt_005fget_005fdn">gnutls_x509_crt_get_dn</a>
which follows the rules in [<em>RFC4514</em>] and returns a single
string. Access to each string by individual object identifiers
can be accessed using <a href="#gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid">gnutls_x509_crt_get_dn_by_oid</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_dn</strong> <em>(gnutls_x509_crt_t <var>cert</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. The output string will be ASCII or UTF-8
encoded, depending on the certificate data.
</p>
<p>If <code>buf</code> is null then only the size will be filled.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated
with the required size. On success 0 is returned.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_dn_by_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identified in null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
</p>
<p><var>raw_flag</var>: If non-zero returns the raw DER data of the DN part.
</p>
<p><var>buf</var>: a pointer where the DN part will be copied (may be null).
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. Thus a string
that is ASCII or UTF-8 encoded, depending on the certificate data.
</p>
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is (0), this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC4514 –
in hex format with a ’#’ prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code> .
</p>
<p>If <code>buf</code> is null then only the size will be filled. If the <code>raw_flag</code> is not specified the output is always null terminated, although the
<code>buf_size</code> will not include the null character.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if there
are no data in the current index. On success 0 is returned.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_dn_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: This specifies which OID to return. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
</p>
<p><var>oid_size</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will extract the OIDs of the name of the Certificate
subject specified by the given index.
</p>
<p>If <code>oid</code> is null then only the size will be filled. The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if there
are no data in the current index. On success 0 is returned.
</p></dd></dl>
<p>Similar functions exist to access the distinguished name
of the issuer of the certificate.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn">gnutls_x509_crt_get_issuer_dn</a> (gnutls_x509_crt_t <var>cert</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid">gnutls_x509_crt_get_issuer_dn_by_oid</a> (gnutls_x509_crt_t <var>cert</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid">gnutls_x509_crt_get_issuer_dn_oid</a> (gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fissuer">gnutls_x509_crt_get_issuer</a> (gnutls_x509_crt_t <var>cert</var>, gnutls_x509_dn_t * <var>dn</var>)</code></dt>
</dl>
<p>The more powerful <a href="#gnutls_005fx509_005fcrt_005fget_005fsubject">gnutls_x509_crt_get_subject</a> and
<a href="#gnutls_005fx509_005fdn_005fget_005frdn_005fava">gnutls_x509_dn_get_rdn_ava</a> provide efficient but low-level access
to the contents of the distinguished name structure.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fsubject">gnutls_x509_crt_get_subject</a> (gnutls_x509_crt_t <var>cert</var>, gnutls_x509_dn_t * <var>dn</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fissuer">gnutls_x509_crt_get_issuer</a> (gnutls_x509_crt_t <var>cert</var>, gnutls_x509_dn_t * <var>dn</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fx509_005fdn_005fget_005frdn_005fava"></a>Function: <em>int</em> <strong>gnutls_x509_dn_get_rdn_ava</strong> <em>(gnutls_x509_dn_t <var>dn</var>, int <var>irdn</var>, int <var>iava</var>, gnutls_x509_ava_st * <var>ava</var>)</em></dt>
<dd><p><var>dn</var>: a pointer to DN
</p>
<p><var>irdn</var>: index of RDN
</p>
<p><var>iava</var>: index of AVA.
</p>
<p><var>ava</var>: Pointer to structure which will hold output information.
</p>
<p>Get pointers to data within the DN. The format of the <code>ava</code> structure
is shown below.
</p>
<p>struct gnutls_x509_ava_st {
gnutls_datum_t oid;
gnutls_datum_t value;
unsigned long value_tag;
};
</p>
<p>The X.509 distinguished name is a sequence of sequences of strings
and this is what the <code>irdn</code> and <code>iava</code> indexes model.
</p>
<p>Note that <code>ava</code> will contain pointers into the <code>dn</code> structure which
in turns points to the original certificate. Thus you should not
modify any data or deallocate any of those.
</p>
<p>This is a low-level function that requires the caller to do the
value conversions when necessary (e.g. from UCS-2).
</p>
<p><strong>Returns:</strong> Returns 0 on success, or an error code.
</p></dd></dl>
<hr>
<a name="X_002e509-public-and-private-keys"></a>
<div class="header">
<p>
Next: <a href="#Verifying-X_002e509-certificate-paths" accesskey="n" rel="next">Verifying X.509 certificate paths</a>, Previous: <a href="#X_002e509-distinguished-names" accesskey="p" rel="previous">X.509 distinguished names</a>, Up: <a href="#X_002e509-certificates" accesskey="u" rel="up">X.509 certificates</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Accessing-public-and-private-keys"></a>
<h4 class="subsubsection">4.1.1.4 Accessing public and private keys</h4>
<p>Each X.509 certificate contains a public key that corresponds to a private key. To
get a unique identifier of the public key the <a href="#gnutls_005fx509_005fcrt_005fget_005fkey_005fid">gnutls_x509_crt_get_key_id</a>
function is provided. To export the public key or its parameters you may need
to convert the X.509 structure to a <code>gnutls_pubkey_t</code>. See
<a href="#Abstract-public-keys">Abstract public keys</a> for more information.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_key_id</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>output_data</var>: will contain the key ID
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will return a unique ID that depends on the public
key parameters. This ID can be used in checking whether a
certificate corresponds to the given private key.
</p>
<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>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<p>The private key parameters may be directly accessed by using one of the following functions.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm2">gnutls_x509_privkey_get_pk_algorithm2</a> (gnutls_x509_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw2">gnutls_x509_privkey_export_rsa_raw2</a> (gnutls_x509_privkey_t <var>key</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>, gnutls_datum_t * <var>d</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>u</var>, gnutls_datum_t * <var>e1</var>, gnutls_datum_t * <var>e2</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fexport_005fecc_005fraw">gnutls_x509_privkey_export_ecc_raw</a> (gnutls_x509_privkey_t <var>key</var>, gnutls_ecc_curve_t * <var>curve</var>, gnutls_datum_t * <var>x</var>, gnutls_datum_t * <var>y</var>, gnutls_datum_t* <var>k</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw">gnutls_x509_privkey_export_dsa_raw</a> (gnutls_x509_privkey_t <var>key</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>, gnutls_datum_t * <var>x</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fget_005fkey_005fid">gnutls_x509_privkey_get_key_id</a> (gnutls_x509_privkey_t <var>key</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</code></dt>
</dl>
<hr>
<a name="Verifying-X_002e509-certificate-paths"></a>
<div class="header">
<p>
Next: <a href="#Verifying-a-certificate-in-the-context-of-TLS-session" accesskey="n" rel="next">Verifying a certificate in the context of TLS session</a>, Previous: <a href="#X_002e509-public-and-private-keys" accesskey="p" rel="previous">X.509 public and private keys</a>, Up: <a href="#X_002e509-certificates" accesskey="u" rel="up">X.509 certificates</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Verifying-X_002e509-certificate-paths-1"></a>
<h4 class="subsubsection">4.1.1.5 Verifying <acronym>X.509</acronym> certificate paths</h4>
<a name="index-verifying-certificate-paths"></a>
<p>Verifying certificate paths is important in <acronym>X.509</acronym>
authentication. For this purpose the following functions are
provided.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcas"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_cas</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const gnutls_x509_crt_t * <var>clist</var>, int <var>clist_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>clist</var>: A list of CAs
</p>
<p><var>clist_size</var>: The length of the CA list
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will add the given certificate authorities
to the trusted list. The list of CAs must not be deinitialized
during this structure’s lifetime.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_named_crt</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t <var>cert</var>, const void * <var>name</var>, size_t <var>name_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert</var>: A certificate
</p>
<p><var>name</var>: An identifier for the certificate
</p>
<p><var>name_size</var>: The size of the identifier
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will add the given certificate to the trusted
list and associate it with a name. The certificate will not be
be used for verification with <code>gnutls_x509_trust_list_verify_crt()</code>
but only with <code>gnutls_x509_trust_list_verify_named_crt()</code> .
</p>
<p>In principle this function can be used to set individual "server"
certificates that are trusted by the user for that specific server
but for no other purposes.
</p>
<p>The certificate must not be deinitialized during the lifetime
of the trusted list.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcrls"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_crls</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const gnutls_x509_crl_t * <var>crl_list</var>, int <var>crl_size</var>, unsigned int <var>flags</var>, unsigned int <var>verification_flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>crl_list</var>: A list of CRLs
</p>
<p><var>crl_size</var>: The length of the CRL list
</p>
<p><var>flags</var>: if GNUTLS_TL_VERIFY_CRL is given the CRLs will be verified before being added.
</p>
<p><var>verification_flags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function will add the given certificate revocation lists
to the trusted list. The list of CRLs must not be deinitialized
during this structure’s lifetime.
</p>
<p>This function must be called after <code>gnutls_x509_trust_list_add_cas()</code>
to allow verifying the CRLs for validity.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_verify_crt</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t * <var>cert_list</var>, unsigned int <var>cert_list_size</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>, gnutls_verify_output_function <var>func</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert_list</var>: is the certificate list to be verified
</p>
<p><var>cert_list_size</var>: is the certificate list size
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p><var>func</var>: If non-null will be called on each chain element verification with the output.
</p>
<p>This function will try to verify the given certificate and return
its status. The <code>verify</code> parameter will hold an OR’ed sequence of
<code>gnutls_certificate_status_t</code> flags.
</p>
<p><strong>Limitation:</strong> Pathlen constraints or key usage flags are not consulted.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_verify_named_crt</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t <var>cert</var>, const void * <var>name</var>, size_t <var>name_size</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>, gnutls_verify_output_function <var>func</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert</var>: is the certificate to be verified
</p>
<p><var>name</var>: is the certificate’s name
</p>
<p><var>name_size</var>: is the certificate’s name size
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p><var>func</var>: If non-null will be called on each chain element verification with the output.
</p>
<p>This function will try to find a certificate that is associated with the provided
name –see <code>gnutls_x509_trust_list_add_named_crt()</code> . If a match is found the certificate is considered valid. In addition to that
this function will also check CRLs. The <code>verify</code> parameter will hold an OR’ed sequence of
<code>gnutls_certificate_status_t</code> flags.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005ffile"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_trust_file</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const char* <var>ca_file</var>, const char* <var>crl_file</var>, gnutls_x509_crt_fmt_t <var>type</var>, unsigned int <var>tl_flags</var>, unsigned int <var>tl_vflags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>ca_file</var>: A file containing a list of CAs (optional)
</p>
<p><var>crl_file</var>: A file containing a list of CRLs (optional)
</p>
<p><var>type</var>: The format of the certificates
</p>
<p><var>tl_flags</var>: GNUTLS_TL_*
</p>
<p><var>tl_vflags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function will add the given certificate authorities
to the trusted list. pkcs11 URLs are also accepted, instead
of files, by this function.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005fmem"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_trust_mem</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const gnutls_datum_t * <var>cas</var>, const gnutls_datum_t * <var>crls</var>, gnutls_x509_crt_fmt_t <var>type</var>, unsigned int <var>tl_flags</var>, unsigned int <var>tl_vflags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cas</var>: A buffer containing a list of CAs (optional)
</p>
<p><var>crls</var>: A buffer containing a list of CRLs (optional)
</p>
<p><var>type</var>: The format of the certificates
</p>
<p><var>tl_flags</var>: GNUTLS_TL_*
</p>
<p><var>tl_vflags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function will add the given certificate authorities
to the trusted list.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fsystem_005ftrust"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_system_trust</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, unsigned int <var>tl_flags</var>, unsigned int <var>tl_vflags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>tl_flags</var>: GNUTLS_TL_*
</p>
<p><var>tl_vflags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function adds the system’s default trusted certificate
authorities to the trusted list. Note that on unsupported system
this function returns <code>GNUTLS_E_UNIMPLEMENTED_FEATURE</code> .
</p>
<p><strong>Returns:</strong> The number of added elements or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<p>The verification function will verify a given certificate chain against a list of certificate
authorities and certificate revocation lists, and output
a bit-wise OR of elements of the <code>gnutls_certificate_status_t</code>
enumeration shown in <a href="#gnutls_005fcertificate_005fstatus_005ft">Figure 4.2</a>. The <code>GNUTLS_CERT_INVALID</code> flag
is always set on a verification error and more detailed flags will also be set when appropriate.
</p>
<div class="float"><a name="gnutls_005fcertificate_005fstatus_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_CERT_INVALID</code></dt>
<dd><p>The certificate is not signed by one of the
known authorities or the signature is invalid (deprecated by the flags
<code>GNUTLS_CERT_SIGNATURE_FAILURE</code> and <code>GNUTLS_CERT_SIGNER_NOT_FOUND</code> ).
</p></dd>
<dt><code>GNUTLS_CERT_REVOKED</code></dt>
<dd><p>Certificate is revoked by its authority. In X.509 this will be
set only if CRLs are checked.
</p></dd>
<dt><code>GNUTLS_CERT_SIGNER_NOT_FOUND</code></dt>
<dd><p>The certificate’s issuer is not known.
This is the case if the issuer is not included in the trusted certificate list.
</p></dd>
<dt><code>GNUTLS_CERT_SIGNER_NOT_CA</code></dt>
<dd><p>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></dd>
<dt><code>GNUTLS_CERT_INSECURE_ALGORITHM</code></dt>
<dd><p>The certificate was signed using an insecure
algorithm such as MD2 or MD5. These algorithms have been broken and
should not be trusted.
</p></dd>
<dt><code>GNUTLS_CERT_NOT_ACTIVATED</code></dt>
<dd><p>The certificate is not yet activated.
</p></dd>
<dt><code>GNUTLS_CERT_EXPIRED</code></dt>
<dd><p>The certificate has expired.
</p></dd>
<dt><code>GNUTLS_CERT_SIGNATURE_FAILURE</code></dt>
<dd><p>The signature verification failed.
</p></dd>
<dt><code>GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED</code></dt>
<dd><p>The revocation data are old and have been superseded.
</p></dd>
<dt><code>GNUTLS_CERT_UNEXPECTED_OWNER</code></dt>
<dd><p>The owner is not the expected one.
</p></dd>
<dt><code>GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE</code></dt>
<dd><p>The revocation data have a future issue date.
</p></dd>
<dt><code>GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE</code></dt>
<dd><p>The certificate’s signer constraints were
violated.
</p></dd>
<dt><code>GNUTLS_CERT_MISMATCH</code></dt>
<dd><p>The certificate presented isn’t the expected one (TOFU)
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 4.2: </strong>The <code>gnutls_certificate_status_t</code> enumeration.</p></div></div>
<p>An example of certificate verification is shown in <a href="#ex_003averify2">ex:verify2</a>.
It is also possible to have a set of certificates that
are trusted for a particular server but not to authorize other certificates.
This purpose is served by the functions <a href="#gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt">gnutls_x509_trust_list_add_named_crt</a> and <a href="#gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt">gnutls_x509_trust_list_verify_named_crt</a>.
</p>
<hr>
<a name="Verifying-a-certificate-in-the-context-of-TLS-session"></a>
<div class="header">
<p>
Previous: <a href="#Verifying-X_002e509-certificate-paths" accesskey="p" rel="previous">Verifying X.509 certificate paths</a>, Up: <a href="#X_002e509-certificates" accesskey="u" rel="up">X.509 certificates</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Verifying-a-certificate-in-the-context-of-TLS-session-1"></a>
<h4 class="subsubsection">4.1.1.6 Verifying a certificate in the context of TLS session</h4>
<a name="index-verifying-certificate-paths-1"></a>
<a name="index-gnutls_005fcertificate_005fverify_005fflags"></a>
<p>When operating in the context of a TLS session, the trusted certificate
authority list may also be set using:
</p><dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile">gnutls_certificate_set_x509_trust_file</a> (gnutls_certificate_credentials_t <var>cred</var>, const char * <var>cafile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile">gnutls_certificate_set_x509_crl_file</a> (gnutls_certificate_credentials_t <var>res</var>, const char * <var>crlfile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust">gnutls_certificate_set_x509_system_trust</a> (gnutls_certificate_credentials_t <var>cred</var>)</code></dt>
</dl>
<p>Then it is not required to setup a trusted list as above.
The function <a href="#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</a>
may then be used to verify the peer’s certificate chain and identity. The flags
are set similarly to the verification functions in the previous section.
</p>
<p>There is also the possibility to pass some input to the verification
functions in the form of flags. For <a href="#gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt">gnutls_x509_trust_list_verify_crt</a> the
flags are passed straightforward, but
<a href="#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</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
<code>gnutls_certificate_verify_flags</code> shown in <a href="#gnutls_005fcertificate_005fverify_005fflags">Figure 4.3</a>.
</p>
<div class="float"><a name="gnutls_005fcertificate_005fverify_005fflags"></a>
<dl compact="compact">
<dt><code>GNUTLS_VERIFY_DISABLE_CA_SIGN</code></dt>
<dd><p>If set a signer does not have to be
a certificate authority. This flag should normaly be disabled,
unless you know what this means.
</p></dd>
<dt><code>GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT</code></dt>
<dd><p>Allow trusted CA certificates
with version 1. This is safer than <code>GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT</code> ,
and should be used instead. That way only signers in your trusted list
will be allowed to have certificates of version 1. This is the default.
</p></dd>
<dt><code>GNUTLS_VERIFY_DO_NOT_ALLOW_SAME</code></dt>
<dd><p>If a certificate is not signed by
anyone trusted but exists in the trusted CA list do not treat it
as trusted.
</p></dd>
<dt><code>GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT</code></dt>
<dd><p>Allow CA certificates that
have version 1 (both root and intermediate). This might be
dangerous since those haven’t the basicConstraints
extension. Must be used in combination with
<code>GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT</code> .
</p></dd>
<dt><code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2</code></dt>
<dd><p>Allow certificates to be signed
using the broken MD2 algorithm.
</p></dd>
<dt><code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5</code></dt>
<dd><p>Allow certificates to be signed
using the broken MD5 algorithm.
</p></dd>
<dt><code>GNUTLS_VERIFY_DISABLE_TIME_CHECKS</code></dt>
<dd><p>Disable checking of activation
and expiration validity periods of certificate chains. Don’t set
this unless you understand the security implications.
</p></dd>
<dt><code>GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS</code></dt>
<dd><p>If set a signer in the trusted
list is never checked for expiration or activation.
</p></dd>
<dt><code>GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT</code></dt>
<dd><p>Do not allow trusted CA
certificates that have version 1. This option is to be used
to deprecate all certificates of version 1.
</p></dd>
<dt><code>GNUTLS_VERIFY_DISABLE_CRL_CHECKS</code></dt>
<dd><p>Disable checking for validity
using certificate revocation lists or the available OCSP data.
</p></dd>
<dt><code>GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN</code></dt>
<dd><p>A certificate chain is tolerated
if unsorted (the case with many TLS servers out there). This is the
default since GnuTLS 3.1.4.
</p></dd>
<dt><code>GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN</code></dt>
<dd><p>Do not tolerate an unsorted
certificate chain.
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 4.3: </strong>The <code>gnutls_certificate_verify_flags</code> enumeration.</p></div></div>
<hr>
<a name="OpenPGP-certificates"></a>
<div class="header">
<p>
Next: <a href="#Advanced-certificate-verification" accesskey="n" rel="next">Advanced certificate verification</a>, Previous: <a href="#X_002e509-certificates" accesskey="p" rel="previous">X.509 certificates</a>, Up: <a href="#Certificate-authentication" accesskey="u" rel="up">Certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="OpenPGP-certificates-1"></a>
<h4 class="subsection">4.1.2 <acronym>OpenPGP</acronym> certificates</h4>
<a name="index-OpenPGP-certificates"></a>
<p>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 else’s 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.
For example in <a href="#fig_003aopenpgp">Figure 4.4</a>, David trusts Alice to be an introducer and Alice
signed Bob’s key thus Dave trusts Bob’s key to be the real one.
</p>
<div class="float"><a name="fig_003aopenpgp"></a>
<img src="gnutls-pgp.png" alt="gnutls-pgp">
<div class="float-caption"><p><strong>Figure 4.4: </strong>An example of the OpenPGP trust model.</p></div></div>
<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>
<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.
</p>
<div class="float"><a name="tab_003aopenpgp_002dcertificate"></a>
<table>
<thead><tr><th width="20%">Field</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">version</td><td width="70%">The field that indicates the version of the OpenPGP structure.</td></tr>
<tr><td width="20%">user ID</td><td width="70%">An RFC 2822 string that identifies the owner of the key. There may be
multiple user identifiers in a key.</td></tr>
<tr><td width="20%">public key</td><td width="70%">The main public key of the certificate.</td></tr>
<tr><td width="20%">expiration</td><td width="70%">The expiration time of the main public key.</td></tr>
<tr><td width="20%">public subkey</td><td width="70%">An additional public key of the certificate. There may be multiple subkeys
in a certificate.</td></tr>
<tr><td width="20%">public subkey expiration</td><td width="70%">The expiration time of the subkey.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.4: </strong>OpenPGP certificate fields.</p></div></div>
<a name="OpenPGP-certificate-structure"></a>
<h4 class="subsubsection">4.1.2.1 <acronym>OpenPGP</acronym> certificate structure</h4>
<p>In <acronym>GnuTLS</acronym> the <acronym>OpenPGP</acronym> certificate structures
[<em>RFC2440</em>] are handled using the <code>gnutls_openpgp_crt_t</code> type.
A typical certificate contains the user ID, which is an RFC 2822
mail and name address, a public key, possibly a number of additional
public keys (called subkeys), and a number of signatures. The various
fields are shown in <a href="#tab_003aopenpgp_002dcertificate">Table 4.4</a>.
</p>
<p>The additional subkeys may provide key for various different purposes,
e.g. one key to encrypt mail, and another to sign a TLS key exchange.
Each subkey is identified by a unique key ID.
The keys that are to be used in a TLS key exchange that requires
signatures are called authentication keys in the OpenPGP jargon.
The mapping of TLS key exchange methods to public keys is shown in
<a href="#tab_003aopenpgp_002dkey_002dexchange">Table 4.5</a>.
</p>
<div class="float"><a name="tab_003aopenpgp_002dkey_002dexchange"></a>
<table>
<thead><tr><th width="20%">Key exchange</th><th width="70%">Public key requirements</th></tr></thead>
<tr><td width="20%">RSA</td><td width="70%">An RSA public key that allows encryption.</td></tr>
<tr><td width="20%">DHE_RSA</td><td width="70%">An RSA public key that is marked for authentication.</td></tr>
<tr><td width="20%">ECDHE_RSA</td><td width="70%">An RSA public key that is marked for authentication.</td></tr>
<tr><td width="20%">DHE_DSS</td><td width="70%">A DSA public key that is marked for authentication.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.5: </strong>The types of (sub)keys required for the various TLS key exchange methods.</p></div></div>
<p>The corresponding private keys are stored in the
<code>gnutls_openpgp_privkey_t</code> type. All the prototypes for the key
handling functions can be found in <samp>gnutls/openpgp.h</samp>.
</p>
<a name="Verifying-an-OpenPGP-certificate"></a>
<h4 class="subsubsection">4.1.2.2 Verifying an <acronym>OpenPGP</acronym> certificate</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 name="DOCF8" href="#FOOT8"><sup>8</sup></a> is
recommended.
</p>
<p>In GnuTLS there is a verification function for OpenPGP certificates,
the <a href="#gnutls_005fopenpgp_005fcrt_005fverify_005fring">gnutls_openpgp_crt_verify_ring</a>. This 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 flags is the same as in the <acronym>X.509</acronym> certificates
(see <a href="#gnutls_005fcertificate_005fverify_005fflags">Figure 4.3</a>).
</p>
<dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fverify_005fring"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_verify_ring</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_keyring_t <var>keyring</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>key</var>: the structure that holds the key.
</p>
<p><var>keyring</var>: holds the keyring to check against
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p>Verify all signatures in the key, using the given set of keys
(keyring).
</p>
<p>The key verification output will be put in <code>verify</code> and will be one
or more of the <code>gnutls_certificate_status_t</code> enumerated elements
bitwise or’d.
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fverify_005fself"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_verify_self</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>key</var>: the structure that holds the key.
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p><var>verify</var>: will hold the key verification output.
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="Verifying-a-certificate-in-the-context-of-a-TLS-session"></a>
<h4 class="subsubsection">4.1.2.3 Verifying a certificate in the context of a TLS session</h4>
<p>Similarly with X.509 certificates, one needs to specify
the OpenPGP keyring file in the credentials structure. The certificates
in this file will be used by <a href="#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</a>
to verify the signatures in the certificate sent by the peer.
</p>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_keyring_file</strong> <em>(gnutls_certificate_credentials_t <var>c</var>, const char * <var>file</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>c</var>: A certificate credentials structure
</p>
<p><var>file</var>: filename of the keyring.
</p>
<p><var>format</var>: format of keyring.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<hr>
<a name="Advanced-certificate-verification"></a>
<div class="header">
<p>
Next: <a href="#Digital-signatures" accesskey="n" rel="next">Digital signatures</a>, Previous: <a href="#OpenPGP-certificates" accesskey="p" rel="previous">OpenPGP certificates</a>, Up: <a href="#Certificate-authentication" accesskey="u" rel="up">Certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Advanced-certificate-verification-1"></a>
<h4 class="subsection">4.1.3 Advanced certificate verification</h4>
<a name="index-Certificate-verification"></a>
<p>The verification of X.509 certificates in the HTTPS and other Internet protocols is typically
done by loading a trusted list of commercial Certificate Authorities
(see <a href="#gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust">gnutls_certificate_set_x509_system_trust</a>), and using them as trusted anchors.
However, there are several examples (eg. the Diginotar incident) where one of these
authorities was compromised. This risk can be mitigated by using in addition to CA certificate verification,
other verification methods. In this section we list the available in GnuTLS methods.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Verifying-a-certificate-using-trust-on-first-use-authentication" accesskey="1">Verifying a certificate using trust on first use authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Verifying-a-certificate-using-DANE" accesskey="2">Verifying a certificate using DANE</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Verifying-a-certificate-using-trust-on-first-use-authentication"></a>
<div class="header">
<p>
Next: <a href="#Verifying-a-certificate-using-DANE" accesskey="n" rel="next">Verifying a certificate using DANE</a>, Up: <a href="#Advanced-certificate-verification" accesskey="u" rel="up">Advanced certificate verification</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Verifying-a-certificate-using-trust-on-first-use-authentication-1"></a>
<h4 class="subsubsection">4.1.3.1 Verifying a certificate using trust on first use authentication</h4>
<a name="index-verifying-certificate-paths-2"></a>
<a name="index-SSH_002dstyle-authentication"></a>
<a name="index-Trust-on-first-use"></a>
<a name="index-Key-pinning"></a>
<p>It is possible to use a trust on first use (TOFU) authentication
method in GnuTLS. That is the concept used by the SSH programs, where the
public key of the peer is not verified, or verified in an out-of-bound way,
but subsequent connections to the same peer require the public key to
remain the same. Such a system in combination with the typical CA
verification of a certificate, and OCSP revocation checks,
can help to provide multiple factor verification, where a single point of
failure is not enough to compromise the system. For example a server compromise
may be detected using OCSP, and a CA compromise can be detected using
the trust on first use method.
Such a hybrid system with X.509 and trust on first use authentication is
shown in <a href="#Simple-client-example-with-SSH_002dstyle-certificate-verification">Simple client example with SSH-style certificate verification</a>.
</p>
<p>See <a href="#Certificate-verification">Certificate verification</a> on how to use the available functionality.
</p>
<hr>
<a name="Verifying-a-certificate-using-DANE"></a>
<div class="header">
<p>
Previous: <a href="#Verifying-a-certificate-using-trust-on-first-use-authentication" accesskey="p" rel="previous">Verifying a certificate using trust on first use authentication</a>, Up: <a href="#Advanced-certificate-verification" accesskey="u" rel="up">Advanced certificate verification</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Verifying-a-certificate-using-DANE-_0028DNSSEC_0029"></a>
<h4 class="subsubsection">4.1.3.2 Verifying a certificate using DANE (DNSSEC)</h4>
<a name="index-verifying-certificate-paths-3"></a>
<a name="index-DANE"></a>
<a name="index-DNSSEC"></a>
<p>The DANE protocol is a protocol that can be used to verify TLS certificates
using the DNS (or better DNSSEC) protocols. The DNS security extensions (DNSSEC)
provide an alternative public key infrastructure to the commercial CAs that
are typically used to sign TLS certificates. The DANE protocol takes advantage
of the DNSSEC infrastructure to verify TLS certificates. This can be
in addition to the verification by CA infrastructure or
may even replace it where DNSSEC is fully deployed. Note however, that DNSSEC deployment is
fairly new and it would be better to use it as an additional verification
method rather than the only one.
</p>
<p>The DANE functionality is provided by the <code>libgnutls-dane</code> library that is shipped
with GnuTLS and the function prototypes are in <code>gnutls/dane.h</code>.
See <a href="#Certificate-verification">Certificate verification</a> for information on how to use the library.
</p>
<hr>
<a name="Digital-signatures"></a>
<div class="header">
<p>
Previous: <a href="#Advanced-certificate-verification" accesskey="p" rel="previous">Advanced certificate verification</a>, Up: <a href="#Certificate-authentication" accesskey="u" rel="up">Certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Digital-signatures-1"></a>
<h4 class="subsection">4.1.4 Digital signatures</h4>
<a name="index-digital-signatures"></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>
<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 euro to Greenpeace and find out that he
donated 1.000.000 euros to Bad Inc.
</p>
<p>For a hash algorithm to be called cryptographic the following three
requirements must hold:
</p>
<ol>
<li> Preimage resistance.
That means the algorithm must be one way and given the output of the
hash function <em>H(x)</em>, it is impossible to calculate <em>x</em>.
</li><li> 2nd preimage resistance.
That means that given a pair <em>x,y</em> with <em>y=H(x)</em> it is
impossible to calculate an <em>x'</em> such that <em>y=H(x')</em>.
</li><li> Collision resistance.
That means that it is impossible to calculate random <em>x</em> and
<em>x'</em> such <em>H(x')=H(x)</em>.
</li></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
<em>2^{((hash size) / 2)}</em>
operations. Today colliding certificates using the MD5 hash algorithm
have been generated as shown in [<em>WEGER</em>].
</p>
<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 <em>2^{64}</em>, but it has been showed
to have a collision strength well under <em>2^{50}</em>. As of November
2005, it is believed that SHA-1’s collision strength is around
<em>2^{63}</em>. 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 <em>2^{63}</em>
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.
</p>
<a name="Trading-security-for-interoperability"></a>
<h4 class="subsubsection">4.1.4.1 Trading security for interoperability</h4>
<p>If you connect to a server and use GnuTLS’ functions to verify the
certificate chain, and get a <code>GNUTLS_CERT_INSECURE_ALGORITHM</code>
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 fails verifying
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>
<p>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 self-signed using <code>RSA-MD2</code> or <code>RSA-MD5</code>. The
certificates in the trusted list are considered trusted irrespective
of the signature.
</p>
<p>If you are using <a href="#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</a> to verify the
certificate chain, you can call
<a href="#gnutls_005fcertificate_005fset_005fverify_005fflags">gnutls_certificate_set_verify_flags</a> with the flags:
</p><ul>
<li> <code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2</code>
</li><li> <code>GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5</code>
</li></ul>
<p>as in the following example:
</p>
<div class="example">
<pre class="example"> gnutls_certificate_set_verify_flags (x509cred,
GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5);
</pre></div>
<p>This will signal the verifier algorithm to enable <code>RSA-MD5</code> when
verifying the certificates.
</p>
<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>
<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, <a href="#gnutls_005fx509_005fcrt_005flist_005fimport">gnutls_x509_crt_list_import</a> to parse each of the certificates, and
then <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.
</p>
<hr>
<a name="More-on-certificate-authentication"></a>
<div class="header">
<p>
Next: <a href="#Shared_002dkey-and-anonymous-authentication" accesskey="n" rel="next">Shared-key and anonymous authentication</a>, Previous: <a href="#Certificate-authentication" accesskey="p" rel="previous">Certificate authentication</a>, Up: <a href="#Authentication-methods" accesskey="u" rel="up">Authentication methods</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="More-on-certificate-authentication-1"></a>
<h3 class="section">4.2 More on certificate authentication</h3>
<a name="index-certificate-authentication-1"></a>
<p>Certificates are not the only structures involved in a public key
infrastructure. Several other structures that are used for certificate
requests, encrypted private keys, revocation lists, GnuTLS abstract key
structures, etc., are discussed in this chapter.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#PKCS-10-certificate-requests" accesskey="1">PKCS 10 certificate requests</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#PKIX-certificate-revocation-lists" accesskey="2">PKIX certificate revocation lists</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#OCSP-certificate-status-checking" accesskey="3">OCSP certificate status checking</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Managing-encrypted-keys" accesskey="4">Managing encrypted keys</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#certtool-Invocation" accesskey="5">certtool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking certtool
</td></tr>
<tr><td align="left" valign="top">• <a href="#ocsptool-Invocation" accesskey="6">ocsptool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking ocsptool
</td></tr>
<tr><td align="left" valign="top">• <a href="#danetool-Invocation" accesskey="7">danetool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking danetool
</td></tr>
</table>
<hr>
<a name="PKCS-10-certificate-requests"></a>
<div class="header">
<p>
Next: <a href="#PKIX-certificate-revocation-lists" accesskey="n" rel="next">PKIX certificate revocation lists</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PKCS-_002310-certificate-requests"></a>
<h4 class="subsection">4.2.1 <acronym>PKCS</acronym> #10 certificate requests</h4>
<a name="index-certificate-requests"></a>
<a name="index-PKCS-_002310"></a>
<p>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 [<em>RFC2986</em>]. Other formats of certificate requests
are not currently supported.
</p>
<p>A certificate request can be generated by
associating it with a private key, setting the
subject’s information and finally self signing it.
The last step ensures that the requester is in
possession of the private key.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fset_005fversion">gnutls_x509_crq_set_version</a> (gnutls_x509_crq_t <var>crq</var>, unsigned int <var>version</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fset_005fdn">gnutls_x509_crq_set_dn</a> (gnutls_x509_crq_t <var>crq</var>, const char * <var>dn</var>, const char** <var>err</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid">gnutls_x509_crq_set_dn_by_oid</a> (gnutls_x509_crq_t <var>crq</var>, const char * <var>oid</var>, unsigned int <var>raw_flag</var>, const void * <var>data</var>, unsigned int <var>sizeof_data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fset_005fkey_005fusage">gnutls_x509_crq_set_key_usage</a> (gnutls_x509_crq_t <var>crq</var>, unsigned int <var>usage</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fset_005fkey_005fpurpose_005foid">gnutls_x509_crq_set_key_purpose_oid</a> (gnutls_x509_crq_t <var>crq</var>, const void * <var>oid</var>, unsigned int <var>critical</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fset_005fbasic_005fconstraints">gnutls_x509_crq_set_basic_constraints</a> (gnutls_x509_crq_t <var>crq</var>, unsigned int <var>ca</var>, int <var>pathLenConstraint</var>)</code></dt>
</dl>
<p>The <a href="#gnutls_005fx509_005fcrq_005fset_005fkey">gnutls_x509_crq_set_key</a> and <a href="#gnutls_005fx509_005fcrq_005fsign2">gnutls_x509_crq_sign2</a>
functions associate the request with a private key and sign it. If a
request is to be signed with a key residing in a PKCS #11 token it is recommended to use
the signing functions shown in <a href="#Abstract-key-types">Abstract key types</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fkey"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_key</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a private key
</p>
<p>This function will set the public parameters from the given private
key to the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fsign2"></a>Function: <em>int</em> <strong>gnutls_x509_crq_sign2</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_privkey_t <var>key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a private key
</p>
<p><var>dig</var>: The message digest to use, i.e., <code>GNUTLS_DIG_SHA1</code>
</p>
<p><var>flags</var>: must be 0
</p>
<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>
<p>This must be the last step in a certificate request generation
since all the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
<code>GNUTLS_E_ASN1_VALUE_NOT_FOUND</code> is returned if you didn’t set all
information in the certificate request (e.g., the version using
<code>gnutls_x509_crq_set_version()</code> ).
</p></dd></dl>
<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.
</p>
<a name="ex_003acrq"></a><pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.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];
size_t buffer_size = sizeof (buffer);
unsigned int bits;
gnutls_global_init ();
/* Initialize an empty certificate request, and
* an empty private key.
*/
gnutls_x509_crq_init (&crq);
gnutls_x509_privkey_init (&key);
/* Generate an RSA key of moderate security.
*/
bits = gnutls_sec_param_to_pk_bits (GNUTLS_PK_RSA, GNUTLS_SEC_PARAM_NORMAL);
gnutls_x509_privkey_generate (key, GNUTLS_PK_RSA, bits, 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_sign2 (crq, key, GNUTLS_DIG_SHA1, 0);
/* 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>
<hr>
<a name="PKIX-certificate-revocation-lists"></a>
<div class="header">
<p>
Next: <a href="#OCSP-certificate-status-checking" accesskey="n" rel="next">OCSP certificate status checking</a>, Previous: <a href="#PKCS-10-certificate-requests" accesskey="p" rel="previous">PKCS 10 certificate requests</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PKIX-certificate-revocation-lists-1"></a>
<h4 class="subsection">4.2.2 PKIX certificate revocation lists</h4>
<a name="index-certificate-revocation-lists"></a>
<a name="index-CRL"></a>
<p>A certificate revocation list (CRL) is a structure issued by an authority
periodically containing a list of revoked certificates serial numbers.
The CRL structure is signed with the issuing authorities’ keys. A typical
CRL contains the fields as shown in <a href="#tab_003acrl">Table 4.6</a>.
Certificate revocation lists are used to complement the expiration date of a certificate,
in order to account for other reasons of revocation, such as compromised keys, etc.
</p>
<p>Each CRL is valid for limited amount of
time and is required to provide, except for the current issuing time, also
the issuing time of the next update.
</p>
<div class="float"><a name="tab_003acrl"></a>
<table>
<thead><tr><th width="20%">Field</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">version</td><td width="70%">The field that indicates the version of the CRL structure.</td></tr>
<tr><td width="20%">signature</td><td width="70%">A signature by the issuing authority.</td></tr>
<tr><td width="20%">issuer</td><td width="70%">Holds the issuer’s distinguished name.</td></tr>
<tr><td width="20%">thisUpdate</td><td width="70%">The issuing time of the revocation list.</td></tr>
<tr><td width="20%">nextUpdate</td><td width="70%">The issuing time of the revocation list that will update that one.</td></tr>
<tr><td width="20%">revokedCertificates</td><td width="70%">List of revoked certificates serial numbers.</td></tr>
<tr><td width="20%">extensions</td><td width="70%">Optional CRL structure extensions.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.6: </strong>Certificate revocation list fields.</p></div></div>
<p>The basic CRL structure functions follow.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005finit">gnutls_x509_crl_init</a> (gnutls_x509_crl_t * <var>crl</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fimport">gnutls_x509_crl_import</a> (gnutls_x509_crl_t <var>crl</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fexport">gnutls_x509_crl_export</a> (gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fexport">gnutls_x509_crl_export</a> (gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</code></dt>
</dl>
<a name="Reading-a-CRL"></a>
<h4 class="subsubheading">Reading a CRL</h4>
<p>The most important function that extracts the certificate revocation
information from a CRL is <a href="#gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial">gnutls_x509_crl_get_crt_serial</a>. Other
functions that return other fields of the CRL structure are also provided.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_crt_serial</strong> <em>(gnutls_x509_crl_t <var>crl</var>, int <var>indx</var>, unsigned char * <var>serial</var>, size_t * <var>serial_size</var>, time_t * <var>t</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>indx</var>: the index of the certificate to extract (starting from 0)
</p>
<p><var>serial</var>: where the serial number will be copied
</p>
<p><var>serial_size</var>: initially holds the size of serial
</p>
<p><var>t</var>: if non null, will hold the time this certificate was revoked
</p>
<p>This function will retrieve the serial number of the specified, by
the index, revoked certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. and a negative error code on error.
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fget_005fversion">gnutls_x509_crl_get_version</a> (gnutls_x509_crl_t <var>crl</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn">gnutls_x509_crl_get_issuer_dn</a> (const gnutls_x509_crl_t <var>crl</var>, char * <var>buf</var>, size_t * <var>sizeof_buf</var>)</code></dt>
<dt><code><var>time_t</var> <a href="#gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate">gnutls_x509_crl_get_this_update</a> (gnutls_x509_crl_t <var>crl</var>)</code></dt>
<dt><code><var>time_t</var> <a href="#gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate">gnutls_x509_crl_get_next_update</a> (gnutls_x509_crl_t <var>crl</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount">gnutls_x509_crl_get_crt_count</a> (gnutls_x509_crl_t <var>crl</var>)</code></dt>
</dl>
<a name="Generation-of-a-CRL"></a>
<h4 class="subsubheading">Generation of a CRL</h4>
<p>The following functions can be used to generate a CRL.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fversion">gnutls_x509_crl_set_version</a> (gnutls_x509_crl_t <var>crl</var>, unsigned int <var>version</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial">gnutls_x509_crl_set_crt_serial</a> (gnutls_x509_crl_t <var>crl</var>, const void * <var>serial</var>, size_t <var>serial_size</var>, time_t <var>revocation_time</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fcrt">gnutls_x509_crl_set_crt</a> (gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>crt</var>, time_t <var>revocation_time</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate">gnutls_x509_crl_set_next_update</a> (gnutls_x509_crl_t <var>crl</var>, time_t <var>exp_time</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate">gnutls_x509_crl_set_this_update</a> (gnutls_x509_crl_t <var>crl</var>, time_t <var>act_time</var>)</code></dt>
</dl>
<p>The <a href="#gnutls_005fx509_005fcrl_005fsign2">gnutls_x509_crl_sign2</a> and <a href="#gnutls_005fx509_005fcrl_005fprivkey_005fsign">gnutls_x509_crl_privkey_sign</a>
functions sign the revocation list with a private key. The latter function
can be used to sign with a key residing in a PKCS #11 token.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fsign2"></a>Function: <em>int</em> <strong>gnutls_x509_crl_sign2</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
</p>
<p><var>flags</var>: must be 0
</p>
<p>This function will sign the CRL with the issuer’s private key, and
will copy the issuer’s information into the CRL.
</p>
<p>This must be the last step in a certificate CRL since all
the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fprivkey_005fsign"></a>Function: <em>int</em> <strong>gnutls_x509_crl_privkey_sign</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
</p>
<p><var>flags</var>: must be 0
</p>
<p>This function will sign the CRL with the issuer’s private key, and
will copy the issuer’s information into the CRL.
</p>
<p>This must be the last step in a certificate CRL since all
the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p>Since 2.12.0
</p></dd></dl>
<p>Few extensions on the CRL structure are supported, including the
CRL number extension and the authority key identifier.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fnumber">gnutls_x509_crl_set_number</a> (gnutls_x509_crl_t <var>crl</var>, const void * <var>nr</var>, size_t <var>nr_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fset_005fauthority_005fkey_005fid">gnutls_x509_crl_set_authority_key_id</a> (gnutls_x509_crl_t <var>crl</var>, const void * <var>id</var>, size_t <var>id_size</var>)</code></dt>
</dl>
<hr>
<a name="OCSP-certificate-status-checking"></a>
<div class="header">
<p>
Next: <a href="#Managing-encrypted-keys" accesskey="n" rel="next">Managing encrypted keys</a>, Previous: <a href="#PKIX-certificate-revocation-lists" accesskey="p" rel="previous">PKIX certificate revocation lists</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="OCSP-certificate-status-checking-1"></a>
<h4 class="subsection">4.2.3 <acronym>OCSP</acronym> certificate status checking</h4>
<a name="index-certificate-status"></a>
<a name="index-Online-Certificate-Status-Protocol"></a>
<a name="index-OCSP"></a>
<p>Certificates may be revoked before their expiration time has been
reached. There are several reasons for revoking certificates, but a
typical situation is when the private key associated with a
certificate has been compromised. Traditionally, Certificate
Revocation Lists (CRLs) have been used by application to implement
revocation checking, however, several problems with CRLs have been
identified [<em>RIVESTCRL</em>].
</p>
<p>The Online Certificate Status Protocol, or <acronym>OCSP</acronym> [<em>RFC2560</em>],
is a widely implemented protocol to perform certificate revocation status
checking. An application that wish to verify the
identity of a peer will verify the certificate against a set of
trusted certificates and then check whether the certificate is listed
in a CRL and/or perform an OCSP check for the certificate.
</p>
<p>Note that in the context of a TLS session the server may provide an
OCSP response that will used during the TLS certificate verification
(see <a href="#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</a>).
You may obtain this response using <a href="#gnutls_005focsp_005fstatus_005frequest_005fget">gnutls_ocsp_status_request_get</a>.
</p>
<p>Before performing the OCSP query, the application will need to figure
out the address of the OCSP server. The OCSP server address can be
provided by the local user in manual configuration or may be stored
in the certificate that is being checked. When stored in a certificate
the OCSP server is in the extension field called the Authority Information
Access (AIA). The following function
extracts this information from a certificate.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fget_005fauthority_005finfo_005faccess">gnutls_x509_crt_get_authority_info_access</a> (gnutls_x509_crt_t <var>crt</var>, unsigned int <var>seq</var>, int <var>what</var>, gnutls_datum_t * <var>data</var>, unsigned int * <var>critical</var>)</code></dt>
</dl>
<p>There are several functions in GnuTLS for creating and manipulating
OCSP requests and responses. The general idea is that a client
application create an OCSP request object, store some information
about the certificate to check in the request, and then export the
request in DER format. The request will then need to be sent to the
OCSP responder, which needs to be done by the application (GnuTLS does
not send and receive OCSP packets). Normally an OCSP response is
received that the application will need to import into an OCSP
response object. The digital signature in the OCSP response needs to
be verified against a set of trust anchors before the information in
the response can be trusted.
</p>
<p>The ASN.1 structure of OCSP requests are briefly as follows. It is
useful to review the structures to get an understanding of which
fields are modified by GnuTLS functions.
</p>
<div class="example">
<pre class="example">OCSPRequest ::= SEQUENCE {
tbsRequest TBSRequest,
optionalSignature [0] EXPLICIT Signature OPTIONAL }
TBSRequest ::= SEQUENCE {
version [0] EXPLICIT Version DEFAULT v1,
requestorName [1] EXPLICIT GeneralName OPTIONAL,
requestList SEQUENCE OF Request,
requestExtensions [2] EXPLICIT Extensions OPTIONAL }
Request ::= SEQUENCE {
reqCert CertID,
singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL }
CertID ::= SEQUENCE {
hashAlgorithm AlgorithmIdentifier,
issuerNameHash OCTET STRING, -- Hash of Issuer's DN
issuerKeyHash OCTET STRING, -- Hash of Issuers public key
serialNumber CertificateSerialNumber }
</pre></div>
<p>The basic functions to initialize, import, export and deallocate OCSP
requests are the following.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005finit">gnutls_ocsp_req_init</a> (gnutls_ocsp_req_t * <var>req</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005focsp_005freq_005fdeinit">gnutls_ocsp_req_deinit</a> (gnutls_ocsp_req_t <var>req</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fimport">gnutls_ocsp_req_import</a> (gnutls_ocsp_req_t <var>req</var>, const gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fexport">gnutls_ocsp_req_export</a> (gnutls_ocsp_req_t <var>req</var>, gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fprint">gnutls_ocsp_req_print</a> (gnutls_ocsp_req_t <var>req</var>, gnutls_ocsp_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</code></dt>
</dl>
<p>To generate an OCSP request the issuer name hash, issuer key hash, and
the checked certificate’s serial number are required. There are two
interfaces available for setting those in an OCSP request.
The is a low-level function when you have the
issuer name hash, issuer key hash, and certificate serial number in
binary form. The second is more useful if you have the
certificate (and its issuer) in a <code>gnutls_x509_crt_t</code> type.
There is also a function to extract this information from existing an OCSP
request.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fadd_005fcert_005fid">gnutls_ocsp_req_add_cert_id</a> (gnutls_ocsp_req_t <var>req</var>, gnutls_digest_algorithm_t <var>digest</var>, const gnutls_datum_t * <var>issuer_name_hash</var>, const gnutls_datum_t * <var>issuer_key_hash</var>, const gnutls_datum_t * <var>serial_number</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fadd_005fcert">gnutls_ocsp_req_add_cert</a> (gnutls_ocsp_req_t <var>req</var>, gnutls_digest_algorithm_t <var>digest</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_crt_t <var>cert</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fget_005fcert_005fid">gnutls_ocsp_req_get_cert_id</a> (gnutls_ocsp_req_t <var>req</var>, unsigned <var>indx</var>, gnutls_digest_algorithm_t * <var>digest</var>, gnutls_datum_t * <var>issuer_name_hash</var>, gnutls_datum_t * <var>issuer_key_hash</var>, gnutls_datum_t * <var>serial_number</var>)</code></dt>
</dl>
<p>Each OCSP request may contain a number of extensions. Extensions are
identified by an Object Identifier (OID) and an opaque data buffer
whose syntax and semantics is implied by the OID. You can extract or
set those extensions using the following functions.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fget_005fextension">gnutls_ocsp_req_get_extension</a> (gnutls_ocsp_req_t <var>req</var>, unsigned <var>indx</var>, gnutls_datum_t * <var>oid</var>, unsigned int * <var>critical</var>, gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fset_005fextension">gnutls_ocsp_req_set_extension</a> (gnutls_ocsp_req_t <var>req</var>, const char * <var>oid</var>, unsigned int <var>critical</var>, const gnutls_datum_t * <var>data</var>)</code></dt>
</dl>
<p>A common OCSP Request extension is the nonce extension (OID
1.3.6.1.5.5.7.48.1.2), which is used to avoid replay attacks of
earlier recorded OCSP responses. The nonce extension carries a value
that is intended to be sufficiently random and unique so that an
attacker will not be able to give a stale response for the same nonce.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fget_005fnonce">gnutls_ocsp_req_get_nonce</a> (gnutls_ocsp_req_t <var>req</var>, unsigned int * <var>critical</var>, gnutls_datum_t * <var>nonce</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005fset_005fnonce">gnutls_ocsp_req_set_nonce</a> (gnutls_ocsp_req_t <var>req</var>, unsigned int <var>critical</var>, const gnutls_datum_t * <var>nonce</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005freq_005frandomize_005fnonce">gnutls_ocsp_req_randomize_nonce</a> (gnutls_ocsp_req_t <var>req</var>)</code></dt>
</dl>
<p>The OCSP response structures is a complex structure. A simplified overview
of it is in <a href="#tab_003aocsp_002dresponse">Table 4.7</a>. Note that a response may contain
information on multiple certificates.
</p>
<div class="float"><a name="tab_003aocsp_002dresponse"></a>
<table>
<thead><tr><th width="20%">Field</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">version</td><td width="70%">The OCSP response version number (typically 1).</td></tr>
<tr><td width="20%">responder ID</td><td width="70%">An identifier of the responder (DN name or a hash of its key).</td></tr>
<tr><td width="20%">issue time</td><td width="70%">The time the response was generated.</td></tr>
<tr><td width="20%">thisUpdate</td><td width="70%">The issuing time of the revocation information.</td></tr>
<tr><td width="20%">nextUpdate</td><td width="70%">The issuing time of the revocation information that will update that one.</td></tr>
<tr><td width="20%"></td><td width="70%">Revoked certificates</td></tr>
<tr><td width="20%">certificate status</td><td width="70%">The status of the certificate.</td></tr>
<tr><td width="20%">certificate serial</td><td width="70%">The certificate’s serial number.</td></tr>
<tr><td width="20%">revocationTime</td><td width="70%">The time the certificate was revoked.</td></tr>
<tr><td width="20%">revocationReason</td><td width="70%">The reason the certificate was revoked.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 4.7: </strong>The most important OCSP response fields.</p></div></div>
<p>We provide basic functions for initialization, importing, exporting
and deallocating OCSP responses.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005finit">gnutls_ocsp_resp_init</a> (gnutls_ocsp_resp_t * <var>resp</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005focsp_005fresp_005fdeinit">gnutls_ocsp_resp_deinit</a> (gnutls_ocsp_resp_t <var>resp</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005fimport">gnutls_ocsp_resp_import</a> (gnutls_ocsp_resp_t <var>resp</var>, const gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005fexport">gnutls_ocsp_resp_export</a> (gnutls_ocsp_resp_t <var>resp</var>, gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005fprint">gnutls_ocsp_resp_print</a> (gnutls_ocsp_resp_t <var>resp</var>, gnutls_ocsp_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</code></dt>
</dl>
<p>The utility function that extracts the revocation as well as other information
from a response is shown below.
</p>
<dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fsingle"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_single</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, unsigned <var>indx</var>, gnutls_digest_algorithm_t * <var>digest</var>, gnutls_datum_t * <var>issuer_name_hash</var>, gnutls_datum_t * <var>issuer_key_hash</var>, gnutls_datum_t * <var>serial_number</var>, unsigned int * <var>cert_status</var>, time_t * <var>this_update</var>, time_t * <var>next_update</var>, time_t * <var>revocation_time</var>, unsigned int * <var>revocation_reason</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>indx</var>: Specifies response number to get. Use (0) to get the first one.
</p>
<p><var>digest</var>: output variable with <code>gnutls_digest_algorithm_t</code> hash algorithm
</p>
<p><var>issuer_name_hash</var>: output buffer with hash of issuer’s DN
</p>
<p><var>issuer_key_hash</var>: output buffer with hash of issuer’s public key
</p>
<p><var>serial_number</var>: output buffer with serial number of certificate to check
</p>
<p><var>cert_status</var>: a certificate status, a <code>gnutls_ocsp_cert_status_t</code> enum.
</p>
<p><var>this_update</var>: time at which the status is known to be correct.
</p>
<p><var>next_update</var>: when newer information will be available, or (time_t)-1 if unspecified
</p>
<p><var>revocation_time</var>: when <code>cert_status</code> is <code>GNUTLS_OCSP_CERT_REVOKED</code> , holds time of revocation.
</p>
<p><var>revocation_reason</var>: revocation reason, a <code>gnutls_x509_crl_reason_t</code> enum.
</p>
<p>This function will return the certificate information of the
<code>indx</code> ’ed response in the Basic OCSP Response <code>resp</code> . The
information returned corresponds to the OCSP SingleResponse structure
except the final singleExtensions.
</p>
<p>Each of the pointers to output variables may be NULL to indicate
that the caller is not interested in that value.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned. If you have reached the last
CertID available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be
returned.
</p></dd></dl>
<p>The possible revocation reasons available in an OCSP response are shown
below.
</p>
<div class="float"><a name="gnutls_005fx509_005fcrl_005freason_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_X509_CRLREASON_UNSPECIFIED</code></dt>
<dd><p>Unspecified reason.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_KEYCOMPROMISE</code></dt>
<dd><p>Private key compromised.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_CACOMPROMISE</code></dt>
<dd><p>CA compromised.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_AFFILIATIONCHANGED</code></dt>
<dd><p>Affiliation has changed.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_SUPERSEDED</code></dt>
<dd><p>Certificate superseded.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_CESSATIONOFOPERATION</code></dt>
<dd><p>Operation has ceased.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_CERTIFICATEHOLD</code></dt>
<dd><p>Certificate is on hold.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_REMOVEFROMCRL</code></dt>
<dd><p>Will be removed from delta CRL.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_PRIVILEGEWITHDRAWN</code></dt>
<dd><p>Privilege withdrawn.
</p></dd>
<dt><code>GNUTLS_X509_CRLREASON_AACOMPROMISE</code></dt>
<dd><p>AA compromised.
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 4.5: </strong>The revocation reasons</p></div></div>
<p>Note, that the OCSP response needs to be verified against some set of trust
anchors before it can be relied upon. It is also important to check
whether the received OCSP response corresponds to the certificate being checked.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005fverify">gnutls_ocsp_resp_verify</a> (gnutls_ocsp_resp_t <var>resp</var>, gnutls_x509_trust_list_t <var>trustlist</var>, unsigned int * <var>verify</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005fverify_005fdirect">gnutls_ocsp_resp_verify_direct</a> (gnutls_ocsp_resp_t <var>resp</var>, gnutls_x509_crt_t <var>issuer</var>, unsigned int * <var>verify</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005focsp_005fresp_005fcheck_005fcrt">gnutls_ocsp_resp_check_crt</a> (gnutls_ocsp_resp_t <var>resp</var>, unsigned int <var>indx</var>, gnutls_x509_crt_t <var>crt</var>)</code></dt>
</dl>
<hr>
<a name="Managing-encrypted-keys"></a>
<div class="header">
<p>
Next: <a href="#certtool-Invocation" accesskey="n" rel="next">certtool Invocation</a>, Previous: <a href="#OCSP-certificate-status-checking" accesskey="p" rel="previous">OCSP certificate status checking</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Managing-encrypted-keys-1"></a>
<h4 class="subsection">4.2.4 Managing encrypted keys</h4>
<a name="index-Encrypted-keys"></a>
<p>Transferring or storing private keys in plain may not be a
good idea, since any compromise is irreparable.
Storing the keys in hardware security modules (see <a href="#Smart-cards-and-HSMs">Smart cards and HSMs</a>)
could solve the storage problem but it is not always practical
or efficient enough. This section describes ways to store and
transfer encrypted private keys.
</p>
<p>There are methods for key encryption, namely the
PKCS #8, PKCS #12 and OpenSSL’s custom encrypted private key formats.
The PKCS #8 and the OpenSSL’s method allow encryption of the private key,
while the PKCS #12 method allows, in addition, the bundling of accompanying
data into the structure. That is typically the corresponding certificate, as
well as a trusted CA certificate.
</p>
<a name="High-level-functionality"></a>
<h4 class="subsubheading">High level functionality</h4>
<p>Generic and higher level private key import functions are available, that
import plain or encrypted keys and will auto-detect the encrypted key format.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport2"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import2</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char* <var>password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>data</var>: The DER or PEM encoded key.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p><var>password</var>: A password (optional)
</p>
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
</p>
<p>This function will import the given DER or PEM encoded key, to
the native <code>gnutls_x509_privkey_t</code> format, irrespective of the
input format. The input format is auto-detected.
</p>
<p>The supported formats are basic unencrypted key, PKCS <code>8</code> , PKCS <code>12</code> ,
and the openssl format.
</p>
<p>If the provided key is encrypted but no password was given, then
<code>GNUTLS_E_DECRYPTION_FAILED</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fx509_005fraw"></a>Function: <em>int</em> <strong>gnutls_privkey_import_x509_raw</strong> <em>(gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char* <var>password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>data</var>: The private key data to be imported
</p>
<p><var>format</var>: The format of the private key
</p>
<p><var>password</var>: A password (optional)
</p>
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>The supported formats are basic unencrypted key, PKCS <code>8</code> , PKCS <code>12</code> ,
and the openssl format.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="PKCS-_00238-structures"></a>
<h4 class="subsubheading"><acronym>PKCS</acronym> #8 structures</h4>
<a name="index-PKCS-_00238"></a>
<p>PKCS #8 keys can be imported and exported as normal private keys using
the functions below. An addition to the normal import functions, are
a password and a flags argument. The flags can be any element of the <code>gnutls_pkcs_encrypt_flags_t</code>
enumeration. Note however, that GnuTLS only supports the PKCS #5 PBES2
encryption scheme. Keys encrypted with the obsolete PBES1 scheme cannot
be decrypted.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fimport_005fpkcs8">gnutls_x509_privkey_import_pkcs8</a> (gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fexport_005fpkcs8">gnutls_x509_privkey_export_pkcs8</a> (gnutls_x509_privkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fprivkey_005fexport2_005fpkcs8">gnutls_x509_privkey_export2_pkcs8</a> (gnutls_x509_privkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>, gnutls_datum_t * <var>out</var>)</code></dt>
</dl>
<div class="float"><a name="gnutls_005fpkcs_005fencrypt_005fflags_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_PKCS_PLAIN</code></dt>
<dd><p>Unencrypted private key.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PKCS12_3DES</code></dt>
<dd><p>PKCS-12 3DES.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PKCS12_ARCFOUR</code></dt>
<dd><p>PKCS-12 ARCFOUR.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PKCS12_RC2_40</code></dt>
<dd><p>PKCS-12 RC2-40.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PBES2_3DES</code></dt>
<dd><p>PBES2 3DES.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PBES2_AES_128</code></dt>
<dd><p>PBES2 AES-128.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PBES2_AES_192</code></dt>
<dd><p>PBES2 AES-192.
</p></dd>
<dt><code>GNUTLS_PKCS_USE_PBES2_AES_256</code></dt>
<dd><p>PBES2 AES-256.
</p></dd>
<dt><code>GNUTLS_PKCS_NULL_PASSWORD</code></dt>
<dd><p>Some schemas distinguish between an empty and a NULL password.
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 4.6: </strong>Encryption flags</p></div></div>
<a name="PKCS-_002312-structures"></a>
<h4 class="subsubheading"><acronym>PKCS</acronym> #12 structures</h4>
<a name="index-PKCS-_002312"></a>
<p>A <acronym>PKCS</acronym> #12 structure [<em>PKCS12</em>] usually contains a user’s
private keys and certificates. It is commonly used in browsers to
export and import the user’s identities.
</p>
<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. A bag of type encrypted should be decrypted
in order for its data to be accessed.
</p>
<p>To reduce the complexity in parsing the structures the simple
helper function <a href="#gnutls_005fpkcs12_005fsimple_005fparse">gnutls_pkcs12_simple_parse</a> is provided. For more
advanced uses, manual parsing of the structure is required using the
functions below.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fget_005fbag">gnutls_pkcs12_get_bag</a> (gnutls_pkcs12_t <var>pkcs12</var>, int <var>indx</var>, gnutls_pkcs12_bag_t <var>bag</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fverify_005fmac">gnutls_pkcs12_verify_mac</a> (gnutls_pkcs12_t <var>pkcs12</var>, const char * <var>pass</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fdecrypt">gnutls_pkcs12_bag_decrypt</a> (gnutls_pkcs12_bag_t <var>bag</var>, const char * <var>pass</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fget_005fcount">gnutls_pkcs12_bag_get_count</a> (gnutls_pkcs12_bag_t <var>bag</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fpkcs12_005fsimple_005fparse"></a>Function: <em>int</em> <strong>gnutls_pkcs12_simple_parse</strong> <em>(gnutls_pkcs12_t <var>p12</var>, const char * <var>password</var>, gnutls_x509_privkey_t * <var>key</var>, gnutls_x509_crt_t ** <var>chain</var>, unsigned int * <var>chain_len</var>, gnutls_x509_crt_t ** <var>extra_certs</var>, unsigned int * <var>extra_certs_len</var>, gnutls_x509_crl_t * <var>crl</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>p12</var>: the PKCS<code>12</code> blob.
</p>
<p><var>password</var>: optional password used to decrypt PKCS<code>12</code> blob, bags and keys.
</p>
<p><var>key</var>: a structure to store the parsed private key.
</p>
<p><var>chain</var>: the corresponding to key certificate chain (may be <code>NULL</code> )
</p>
<p><var>chain_len</var>: will be updated with the number of additional (may be <code>NULL</code> )
</p>
<p><var>extra_certs</var>: optional pointer to receive an array of additional
certificates found in the PKCS<code>12</code> blob (may be <code>NULL</code> ).
</p>
<p><var>extra_certs_len</var>: will be updated with the number of additional
certs (may be <code>NULL</code> ).
</p>
<p><var>crl</var>: an optional structure to store the parsed CRL (may be <code>NULL</code> ).
</p>
<p><var>flags</var>: should be zero or one of GNUTLS_PKCS12_SP_*
</p>
<p>This function parses a PKCS<code>12</code> blob in <code>p12blob</code> and extracts the
private key, the corresponding certificate chain, and any additional
certificates and a CRL.
</p>
<p>The <code>extra_certs_ret</code> and <code>extra_certs_len</code> parameters are optional
and both may be set to <code>NULL</code> . If either is non-<code>NULL</code> , then both must
be set.
</p>
<p>Encrypted PKCS<code>12</code> bags and PKCS<code>8</code> private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
</p>
<p>A 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>
<p>It is believed that the limitations of this function are acceptable
for common usage, and that any more flexibility would introduce
complexity that would make it harder to use this functionality at
all.
</p>
<p>If the provided structure has encrypted fields but no password
is provided then this function returns <code>GNUTLS_E_DECRYPTION_FAILED</code> .
</p>
<p>Note that normally the chain constructed does not include self signed
certificates, to comply with TLS’ requirements. If, however, the flag
<code>GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED</code> is specified then
self signed certificates will be included in the chain.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fget_005fdata">gnutls_pkcs12_bag_get_data</a> (gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid">gnutls_pkcs12_bag_get_key_id</a> (gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, gnutls_datum_t * <var>id</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname">gnutls_pkcs12_bag_get_friendly_name</a> (gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, char ** <var>name</var>)</code></dt>
</dl>
<p>The functions below are used to generate a PKCS #12 structure. An example
of their usage is also shown.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fset_005fbag">gnutls_pkcs12_set_bag</a> (gnutls_pkcs12_t <var>pkcs12</var>, gnutls_pkcs12_bag_t <var>bag</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fencrypt">gnutls_pkcs12_bag_encrypt</a> (gnutls_pkcs12_bag_t <var>bag</var>, const char * <var>pass</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fgenerate_005fmac">gnutls_pkcs12_generate_mac</a> (gnutls_pkcs12_t <var>pkcs12</var>, const char * <var>pass</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fset_005fdata">gnutls_pkcs12_bag_set_data</a> (gnutls_pkcs12_bag_t <var>bag</var>, gnutls_pkcs12_bag_type_t <var>type</var>, const gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fset_005fcrl">gnutls_pkcs12_bag_set_crl</a> (gnutls_pkcs12_bag_t <var>bag</var>, gnutls_x509_crl_t <var>crl</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fset_005fcrt">gnutls_pkcs12_bag_set_crt</a> (gnutls_pkcs12_bag_t <var>bag</var>, gnutls_x509_crt_t <var>crt</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid">gnutls_pkcs12_bag_set_key_id</a> (gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, const gnutls_datum_t * <var>id</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname">gnutls_pkcs12_bag_set_friendly_name</a> (gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, const char * <var>name</var>)</code></dt>
</dl>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/pkcs12.h>
#include "examples.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];
size_t 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 = { (void *) "\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>
<a name="OpenSSL-encrypted-keys"></a>
<h4 class="subsubheading">OpenSSL encrypted keys</h4>
<a name="index-OpenSSL-encrypted-keys"></a>
<p>Unfortunately the structures discussed in the previous sections are
not the only structures that may hold an encrypted private key. For example
the OpenSSL library offers a custom key encryption method. Those structures
are also supported in GnuTLS with <a href="#gnutls_005fx509_005fprivkey_005fimport_005fopenssl">gnutls_x509_privkey_import_openssl</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fopenssl"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_openssl</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, const char* <var>password</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>data</var>: The DER or PEM encoded key.
</p>
<p><var>password</var>: the password to decrypt the key (if it is encrypted).
</p>
<p>This function will convert the given PEM encrypted to
the native gnutls_x509_privkey_t format. The
output will be stored in <code>key</code> .
</p>
<p>The <code>password</code> should be in ASCII. If the password is not provided
or wrong then <code>GNUTLS_E_DECRYPTION_FAILED</code> will be returned.
</p>
<p>If the Certificate is PEM encoded it should have a header of
"PRIVATE KEY" and the "DEK-Info" header.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<hr>
<a name="certtool-Invocation"></a>
<div class="header">
<p>
Next: <a href="#ocsptool-Invocation" accesskey="n" rel="next">ocsptool Invocation</a>, Previous: <a href="#Managing-encrypted-keys" accesskey="p" rel="previous">Managing encrypted keys</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-certtool"></a>
<h4 class="subsection">4.2.5 Invoking certtool</h4>
<a name="index-certtool"></a>
<p>Tool to parse and generate X.509 certificates, requests and private keys.
It can be used interactively or non interactively by
specifying the template command line option.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>certtool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="certtool-usage"></a><a name="certtool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">certtool help/usage (-h)</h4>
<a name="index-certtool-help"></a>
<p>This is the automatically generated usage text for certtool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">certtool - GnuTLS certificate tool - Ver. 3.1.7
USAGE: certtool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-V, --verbose More verbose output
- may appear multiple times
--infile=file Input file
- file must pre-exist
--outfile=str Output file
-s, --generate-self-signed Generate a self-signed certificate
-c, --generate-certificate Generate a signed certificate
--generate-proxy Generates a proxy certificate
--generate-crl Generate a CRL
-u, --update-certificate Update a signed certificate
-p, --generate-privkey Generate a private key
-q, --generate-request Generate a PKCS #10 certificate request
- prohibits these options:
infile
-e, --verify-chain Verify a PEM encoded certificate chain.
--verify Verify a PEM encoded certificate chain using a trusted list.
- requires these options:
load-ca-certificate
--verify-crl Verify a CRL using a trusted list.
- requires these options:
load-ca-certificate
--generate-dh-params Generate PKCS #3 encoded Diffie-Hellman parameters.
--get-dh-params Get the included PKCS #3 encoded Diffie-Hellman parameters.
--dh-info Print information PKCS #3 encoded Diffie-Hellman parameters
--load-privkey=str Loads a private key file
--load-pubkey=str Loads a public key file
--load-request=file Loads a certificate request file
- file must pre-exist
--load-certificate=str Loads a certificate file
--load-ca-privkey=str Loads the certificate authority's private key file
--load-ca-certificate=str Loads the certificate authority's certificate file
--password=str Password to use
--hex-numbers Print big number in an easier format to parse
--cprint In certain operations it prints the information is C-friendly format
--null-password Enforce a NULL password
-i, --certificate-info Print information on the given certificate
--certificate-pubkey Print certificate's public key
--pgp-certificate-info Print information on the given OpenPGP certificate
--pgp-ring-info Print information on the given OpenPGP keyring structure
-l, --crl-info Print information on the given CRL structure
--crq-info Print information on the given certificate request
--no-crq-extensions Do not use extensions in certificate requests
--p12-info Print information on a PKCS #12 structure
--p7-info Print information on a PKCS #7 structure
--smime-to-p7 Convert S/MIME to PKCS #7 structure
-k, --key-info Print information on a private key
--pgp-key-info Print information on an OpenPGP private key
--pubkey-info Print information on a public key
--v1 Generate an X.509 version 1 certificate (with no extensions)
--to-p12 Generate a PKCS #12 structure
- requires these options:
load-certificate
--to-p8 Generate a PKCS #8 structure
-8, --pkcs8 Use PKCS #8 format for private keys
--rsa Generate RSA key
--dsa Generate DSA key
--ecc Generate ECC (ECDSA) key
--ecdsa This is an alias for 'ecc'
--hash=str Hash algorithm to use for signing.
--inder Use DER format for input certificates and private keys.
- disabled as --no-inder
--inraw This is an alias for 'inder'
--outder Use DER format for output certificates and private keys
- disabled as --no-outder
--outraw This is an alias for 'outder'
--bits=num Specify the number of bits for key generate
--sec-param=str Specify the security level [low, legacy, normal, high, ultra].
--disable-quick-random No effect
--template=file Template file to use for non-interactive operation
- file must pre-exist
--pkcs-cipher=str Cipher to use for PKCS #8 and #12 operations
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Tool to parse and generate X.509 certificates, requests and private keys.
It can be used interactively or non interactively by specifying the
template command line option.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="certtool-debug"></a><a name="debug-option-_0028_002dd_0029"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="certtool-generate_002drequest"></a></p><a name="generate_002drequest-option-_0028_002dq_0029"></a>
<h4 class="subsubheading">generate-request option (-q)</h4>
<p>This is the “generate a pkcs #10 certificate request” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must not appear in combination with any of the following options:
infile.
</li></ul>
<p>Will generate a PKCS #10 certificate request. To specify a private key use –load-privkey.
<a name="certtool-verify_002dchain"></a></p><a name="verify_002dchain-option-_0028_002de_0029"></a>
<h4 class="subsubheading">verify-chain option (-e)</h4>
<p>This is the “verify a pem encoded certificate chain.” option.
The last certificate in the chain must be a self signed one.
<a name="certtool-verify"></a></p><a name="verify-option"></a>
<h4 class="subsubheading">verify option</h4>
<p>This is the “verify a pem encoded certificate chain using a trusted list.” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
load-ca-certificate.
</li></ul>
<p>The trusted certificate list must be loaded with –load-ca-certificate.
<a name="certtool-verify_002dcrl"></a></p><a name="verify_002dcrl-option"></a>
<h4 class="subsubheading">verify-crl option</h4>
<p>This is the “verify a crl using a trusted list.” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
load-ca-certificate.
</li></ul>
<p>The trusted certificate list must be loaded with –load-ca-certificate.
<a name="certtool-get_002ddh_002dparams"></a></p><a name="get_002ddh_002dparams-option"></a>
<h4 class="subsubheading">get-dh-params option</h4>
<p>This is the “get the included pkcs #3 encoded diffie-hellman parameters.” option.
Returns stored DH parameters in GnuTLS. Those parameters are used in the SRP protocol. The parameters returned by fresh generation
are more efficient since GnuTLS 3.0.9.
<a name="certtool-load_002dprivkey"></a></p><a name="load_002dprivkey-option"></a>
<h4 class="subsubheading">load-privkey option</h4>
<p>This is the “loads a private key file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="certtool-load_002dpubkey"></a></p><a name="load_002dpubkey-option"></a>
<h4 class="subsubheading">load-pubkey option</h4>
<p>This is the “loads a public key file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="certtool-load_002dcertificate"></a></p><a name="load_002dcertificate-option"></a>
<h4 class="subsubheading">load-certificate option</h4>
<p>This is the “loads a certificate file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="certtool-load_002dca_002dprivkey"></a></p><a name="load_002dca_002dprivkey-option"></a>
<h4 class="subsubheading">load-ca-privkey option</h4>
<p>This is the “loads the certificate authority’s private key file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="certtool-load_002dca_002dcertificate"></a></p><a name="load_002dca_002dcertificate-option"></a>
<h4 class="subsubheading">load-ca-certificate option</h4>
<p>This is the “loads the certificate authority’s certificate file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="certtool-cprint"></a></p><a name="cprint-option"></a>
<h4 class="subsubheading">cprint option</h4>
<p>This is the “in certain operations it prints the information is c-friendly format” option.
In certain operations it prints the information is C-friendly format, suitable for including into C programs.
<a name="certtool-null_002dpassword"></a></p><a name="null_002dpassword-option"></a>
<h4 class="subsubheading">null-password option</h4>
<p>This is the “enforce a null password” option.
This option enforces a NULL password. This may be different than the empty password in some schemas.
<a name="certtool-pubkey_002dinfo"></a></p><a name="pubkey_002dinfo-option"></a>
<h4 class="subsubheading">pubkey-info option</h4>
<p>This is the “print information on a public key” option.
The option combined with –load-request, –load-pubkey, –load-privkey and –load-certificate will extract the public key of the object in question.
<a name="certtool-to_002dp12"></a></p><a name="to_002dp12-option"></a>
<h4 class="subsubheading">to-p12 option</h4>
<p>This is the “generate a pkcs #12 structure” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
load-certificate.
</li></ul>
<p>It requires a certificate, a private key and possibly a CA certificate to be specified.
<a name="certtool-rsa"></a></p><a name="rsa-option"></a>
<h4 class="subsubheading">rsa option</h4>
<p>This is the “generate rsa key” option.
When combined with –generate-privkey generates an RSA private key.
<a name="certtool-dsa"></a></p><a name="dsa-option"></a>
<h4 class="subsubheading">dsa option</h4>
<p>This is the “generate dsa key” option.
When combined with –generate-privkey generates a DSA private key.
<a name="certtool-ecc"></a></p><a name="ecc-option"></a>
<h4 class="subsubheading">ecc option</h4>
<p>This is the “generate ecc (ecdsa) key” option.
When combined with –generate-privkey generates an elliptic curve private key to be used with ECDSA.
<a name="certtool-ecdsa"></a></p><a name="ecdsa-option"></a>
<h4 class="subsubheading">ecdsa option</h4>
<p>This is an alias for the ecc option,
see <a href="#certtool-ecc">the ecc option documentation</a>.
</p>
<a name="certtool-hash"></a><a name="hash-option"></a>
<h4 class="subsubheading">hash option</h4>
<p>This is the “hash algorithm to use for signing.” option.
This option takes an argument string.
Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512.
<a name="certtool-inder"></a></p><a name="inder-option"></a>
<h4 class="subsubheading">inder option</h4>
<p>This is the “use der format for input certificates and private keys.” option.
The input files will be assumed to be in DER or RAW format.
Unlike options that in PEM input would allow multiple input data (e.g. multiple
certificates), when reading in DER format a single data structure is read.
<a name="certtool-inraw"></a></p><a name="inraw-option"></a>
<h4 class="subsubheading">inraw option</h4>
<p>This is an alias for the inder option,
see <a href="#certtool-inder">the inder option documentation</a>.
</p>
<a name="certtool-outder"></a><a name="outder-option"></a>
<h4 class="subsubheading">outder option</h4>
<p>This is the “use der format for output certificates and private keys” option.
The output will be in DER or RAW format.
<a name="certtool-outraw"></a></p><a name="outraw-option"></a>
<h4 class="subsubheading">outraw option</h4>
<p>This is an alias for the outder option,
see <a href="#certtool-outder">the outder option documentation</a>.
</p>
<a name="certtool-sec_002dparam"></a><a name="sec_002dparam-option"></a>
<h4 class="subsubheading">sec-param option</h4>
<p>This is the “specify the security level [low, legacy, normal, high, ultra].” option.
This option takes an argument string <samp>Security parameter</samp>.
This is alternative to the bits option.
<a name="certtool-pkcs_002dcipher"></a></p><a name="pkcs_002dcipher-option"></a>
<h4 class="subsubheading">pkcs-cipher option</h4>
<p>This is the “cipher to use for pkcs #8 and #12 operations” option.
This option takes an argument string <samp>Cipher</samp>.
Cipher may be one of 3des, 3des-pkcs12, aes-128, aes-192, aes-256, rc2-40, arcfour.
<a name="certtool-exit-status"></a></p><a name="certtool-exit-status-1"></a>
<h4 class="subsubheading">certtool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="certtool-See-Also"></a><a name="certtool-See-Also-1"></a>
<h4 class="subsubheading">certtool See Also</h4>
<p>p11tool (1)
</p>
<a name="certtool-Examples"></a><a name="certtool-Examples-1"></a>
<h4 class="subsubheading">certtool Examples</h4>
<a name="Generating-private-keys"></a>
<h4 class="subsubheading">Generating private keys</h4>
<p>To create an RSA private key, run:
</p><div class="example">
<pre class="example">$ certtool --generate-privkey --outfile key.pem --rsa
</pre></div>
<p>To create a DSA or elliptic curves (ECDSA) private key use the
above command combined with ’dsa’ or ’ecc’ options.
</p>
<a name="Generating-certificate-requests"></a>
<h4 class="subsubheading">Generating certificate requests</h4>
<p>To create a certificate request (needed when the certificate is issued by
another party), run:
</p><div class="example">
<pre class="example">certtool --generate-request --load-privkey key.pem \
--outfile request.pem
</pre></div>
<p>If the private key is stored in a smart card you can generate
a request by specifying the private key object URL.
</p><div class="example">
<pre class="example">$ ./certtool --generate-request --load-privkey "pkcs11:..." \
--load-pubkey "pkcs11:..." --outfile request.pem
</pre></div>
<a name="Generating-a-self_002dsigned-certificate"></a>
<h4 class="subsubheading">Generating a self-signed certificate</h4>
<p>To create a self signed certificate, use the command:
</p><div class="example">
<pre class="example">$ certtool --generate-privkey --outfile ca-key.pem
$ certtool --generate-self-signed --load-privkey ca-key.pem \
--outfile ca-cert.pem
</pre></div>
<p>Note that a self-signed certificate usually belongs to a certificate
authority, that signs other certificates.
</p>
<a name="Generating-a-certificate"></a>
<h4 class="subsubheading">Generating a certificate</h4>
<p>To generate a certificate using the previous request, use the command:
</p><div class="example">
<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></div>
<p>To generate a certificate using the private key only, use the command:
</p><div class="example">
<pre class="example">$ certtool --generate-certificate --load-privkey key.pem \
--outfile cert.pem --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem
</pre></div>
<a name="Certificate-information"></a>
<h4 class="subsubheading">Certificate information</h4>
<p>To view the certificate information, use:
</p><div class="example">
<pre class="example">$ certtool --certificate-info --infile cert.pem
</pre></div>
<a name="PKCS-_002312-structure-generation"></a>
<h4 class="subsubheading">PKCS #12 structure generation</h4>
<p>To generate a PKCS #12 structure using the previous key and certificate,
use the command:
</p><div class="example">
<pre class="example">$ certtool --load-certificate cert.pem --load-privkey key.pem \
--to-p12 --outder --outfile key.p12
</pre></div>
<p>Some tools (reportedly web browsers) have problems with that file
because it does not contain the CA certificate for the certificate.
To work around that problem in the tool, you can use the
–load-ca-certificate parameter as follows:
</p>
<div class="example">
<pre class="example">$ certtool --load-ca-certificate ca.pem \
--load-certificate cert.pem --load-privkey key.pem \
--to-p12 --outder --outfile key.p12
</pre></div>
<a name="Diffie_002dHellman-parameter-generation"></a>
<h4 class="subsubheading">Diffie-Hellman parameter generation</h4>
<p>To generate parameters for Diffie-Hellman key exchange, use the command:
</p><div class="example">
<pre class="example">$ certtool --generate-dh-params --outfile dh.pem --sec-param normal
</pre></div>
<a name="Proxy-certificate-generation"></a>
<h4 class="subsubheading">Proxy certificate generation</h4>
<p>Proxy certificate can be used to delegate your credential to a
temporary, typically short-lived, certificate. To create one from the
previously created certificate, first create a temporary key and then
generate a proxy certificate for it, using the commands:
</p>
<div class="example">
<pre class="example">$ certtool --generate-privkey > proxy-key.pem
$ certtool --generate-proxy --load-ca-privkey key.pem \
--load-privkey proxy-key.pem --load-certificate cert.pem \
--outfile proxy-cert.pem
</pre></div>
<a name="Certificate-revocation-list-generation"></a>
<h4 class="subsubheading">Certificate revocation list generation</h4>
<p>To create an empty Certificate Revocation List (CRL) do:
</p>
<div class="example">
<pre class="example">$ certtool --generate-crl --load-ca-privkey x509-ca-key.pem \
--load-ca-certificate x509-ca.pem
</pre></div>
<p>To create a CRL that contains some revoked certificates, place the
certificates in a file and use <code>--load-certificate</code> as follows:
</p>
<div class="example">
<pre class="example">$ certtool --generate-crl --load-ca-privkey x509-ca-key.pem \
--load-ca-certificate x509-ca.pem --load-certificate revoked-certs.pem
</pre></div>
<p>To verify a Certificate Revocation List (CRL) do:
</p>
<div class="example">
<pre class="example">$ certtool --verify-crl --load-ca-certificate x509-ca.pem < crl.pem
</pre></div>
<a name="certtool-Files"></a><a name="certtool-Files-1"></a>
<h4 class="subsubheading">certtool Files</h4>
<a name="Certtool_0027s-template-file-format"></a>
<h4 class="subsubheading">Certtool’s template file format</h4>
<p>A template file can be used to avoid the interactive questions of
certtool. Initially create a file named ’cert.cfg’ that contains the information
about the certificate. The template can be used as below:
</p>
<div class="example">
<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></div>
<p>An example certtool template file that can be used to generate a certificate
request or a self signed certificate follows.
</p>
<div class="example">
<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"
# Set domain components
#dc = "name"
#dc = "domain"
# 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.
#dn_oid = 2.5.4.65 jackal
# This is deprecated and should not be used in new
# certificates.
# pkcs9_email = "none@none.org"
# An alternative way to set the certificate's distinguished name directly
# is with the "dn" option. The attribute names allowed are:
# C (country), street, O (organization), OU (unit), title, CN (common name),
# L (locality), ST (state), placeOfBirth, gender, countryOfCitizenship,
# countryOfResidence, serialNumber, telephoneNumber, surName, initials,
# generationQualifier, givenName, pseudonym, dnQualifier, postalCode, name,
# businessCategory, DC, UID, jurisdictionOfIncorporationLocalityName,
# jurisdictionOfIncorporationStateOrProvinceName,
# jurisdictionOfIncorporationCountryName, XmppAddr, and numeric OIDs.
#dn = "cn=Nik,st=Attiki,C=GR,surName=Mavrogiannopoulos,2.5.4.9=Arkadias"
# 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"
#dns_name = "www.morethanone.org"
# A subject alternative name URI
#uri = "http://www.example.com"
# 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"
# Challenge password used in certificate requests
challenge_password = 123456
# Password when encrypting a private key
#password = secret
# 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
# for microsoft smart card logon
# key_purpose_oid = 1.3.6.1.4.1.311.20.2.2
### Other predefined key purpose OIDs
# 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 preferred 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
# Whether this key will be used for IPsec IKE operations.
#ipsec_ike_key
### end of key purpose OIDs
# When generating a certificate from a certificate
# request, then honor the extensions stored in the request
# and store them in the real certificate.
#honor_crq_extensions
# Path length contraint. Sets the maximum number of
# certificates that can be used to certify this certificate.
# (i.e. the certificate chain length)
#path_len = -1
#path_len = 2
# OCSP URI
# ocsp_uri = http://my.ocsp.server/ocsp
# CA issuers URI
# ca_issuers_uri = http://my.ca.issuer
# Certificate policies
# policy1 = 1.3.6.1.4.1.5484.1.10.99.1.0
# policy1_txt = "This is a long policy to summarize"
# policy1_url = http://www.example.com/a-policy-to-read
# policy2 = 1.3.6.1.4.1.5484.1.10.99.1.1
# policy2_txt = "This is a short policy"
# policy2_url = http://www.example.com/another-policy-to-read
# Options for proxy certificates
# proxy_policy_language = 1.3.6.1.5.5.7.21.1
# Options for generating a CRL
# next CRL update will be in 43 days (wow)
#crl_next_update = 43
# this is the 5th CRL by this CA
#crl_number = 5
</pre></div>
<hr>
<a name="ocsptool-Invocation"></a>
<div class="header">
<p>
Next: <a href="#danetool-Invocation" accesskey="n" rel="next">danetool Invocation</a>, Previous: <a href="#certtool-Invocation" accesskey="p" rel="previous">certtool Invocation</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-ocsptool"></a>
<h4 class="subsection">4.2.6 Invoking ocsptool</h4>
<a name="index-ocsptool"></a>
<p>Ocsptool is a program that can parse and print information about
OCSP requests/responses, generate requests and verify responses.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>ocsptool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="ocsptool-usage"></a><a name="ocsptool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">ocsptool help/usage (-h)</h4>
<a name="index-ocsptool-help"></a>
<p>This is the automatically generated usage text for ocsptool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">ocsptool - GnuTLS OCSP tool - Ver. 3.1.7
USAGE: ocsptool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-V, --verbose More verbose output
- may appear multiple times
--infile=file Input file
- file must pre-exist
--outfile=str Output file
--ask[=arg] Ask an OCSP/HTTP server on a certificate validity
- requires these options:
load-cert
load-issuer
-e, --verify-response Verify response
-i, --request-info Print information on a OCSP request
-j, --response-info Print information on a OCSP response
-q, --generate-request Generate an OCSP request
--nonce Don't add nonce to OCSP request
- disabled as --no-nonce
--load-issuer=file Read issuer certificate from file
- file must pre-exist
--load-cert=file Read certificate to check from file
- file must pre-exist
--load-trust=file Read OCSP trust anchors from file
- prohibits these options:
load-signer
- file must pre-exist
--load-signer=file Read OCSP response signer from file
- prohibits these options:
load-trust
- file must pre-exist
--inder Use DER format for input certificates and private keys
- disabled as --no-inder
-Q, --load-request=file Read DER encoded OCSP request from file
- file must pre-exist
-S, --load-response=file Read DER encoded OCSP response from file
- file must pre-exist
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Ocsptool is a program that can parse and print information about OCSP
requests/responses, generate requests and verify responses.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="ocsptool-debug"></a><a name="debug-option-_0028_002dd_0029-1"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="ocsptool-ask"></a></p><a name="ask-option"></a>
<h4 class="subsubheading">ask option</h4>
<p>This is the “ask an ocsp/http server on a certificate validity” option.
This option takes an optional argument string <samp>server name|url</samp>.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
load-cert, load-issuer.
</li></ul>
<p>Connects to the specified HTTP OCSP server and queries on the validity of the loaded certificate.
<a name="ocsptool-exit-status"></a></p><a name="ocsptool-exit-status-1"></a>
<h4 class="subsubheading">ocsptool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="ocsptool-See-Also"></a><a name="ocsptool-See-Also-1"></a>
<h4 class="subsubheading">ocsptool See Also</h4>
<p>certtool (1)
</p>
<a name="ocsptool-Examples"></a><a name="ocsptool-Examples-1"></a>
<h4 class="subsubheading">ocsptool Examples</h4>
<a name="Print-information-about-an-OCSP-request"></a>
<h4 class="subsubheading">Print information about an OCSP request</h4>
<p>To parse an OCSP request and print information about the content, the
<code>-i</code> or <code>--request-info</code> parameter may be used as follows.
The <code>-Q</code> parameter specify the name of the file containing the
OCSP request, and it should contain the OCSP request in binary DER
format.
</p>
<div class="example">
<pre class="example">$ ocsptool -i -Q ocsp-request.der
</pre></div>
<p>The input file may also be sent to standard input like this:
</p>
<div class="example">
<pre class="example">$ cat ocsp-request.der | ocsptool --request-info
</pre></div>
<a name="Print-information-about-an-OCSP-response"></a>
<h4 class="subsubheading">Print information about an OCSP response</h4>
<p>Similar to parsing OCSP requests, OCSP responses can be parsed using
the <code>-j</code> or <code>--response-info</code> as follows.
</p>
<div class="example">
<pre class="example">$ ocsptool -j -Q ocsp-response.der
$ cat ocsp-response.der | ocsptool --response-info
</pre></div>
<a name="Generate-an-OCSP-request"></a>
<h4 class="subsubheading">Generate an OCSP request</h4>
<p>The <code>-q</code> or <code>--generate-request</code> parameters are used to
generate an OCSP request. By default the OCSP request is written to
standard output in binary DER format, but can be stored in a file
using <code>--outfile</code>. To generate an OCSP request the issuer of the
certificate to check needs to be specified with <code>--load-issuer</code>
and the certificate to check with <code>--load-cert</code>. By default PEM
format is used for these files, although <code>--inder</code> can be used to
specify that the input files are in DER format.
</p>
<div class="example">
<pre class="example">$ ocsptool -q --load-issuer issuer.pem --load-cert client.pem \
--outfile ocsp-request.der
</pre></div>
<p>When generating OCSP requests, the tool will add an OCSP extension
containing a nonce. This behaviour can be disabled by specifying
<code>--no-nonce</code>.
</p>
<a name="Verify-signature-in-OCSP-response"></a>
<h4 class="subsubheading">Verify signature in OCSP response</h4>
<p>To verify the signature in an OCSP response the <code>-e</code> or
<code>--verify-response</code> parameter is used. The tool will read an
OCSP response in DER format from standard input, or from the file
specified by <code>--load-response</code>. The OCSP response is verified
against a set of trust anchors, which are specified using
<code>--load-trust</code>. The trust anchors are concatenated certificates
in PEM format. The certificate that signed the OCSP response needs to
be in the set of trust anchors, or the issuer of the signer
certificate needs to be in the set of trust anchors and the OCSP
Extended Key Usage bit has to be asserted in the signer certificate.
</p>
<div class="example">
<pre class="example">$ ocsptool -e --load-trust issuer.pem \
--load-response ocsp-response.der
</pre></div>
<p>The tool will print status of verification.
</p>
<a name="Verify-signature-in-OCSP-response-against-given-certificate"></a>
<h4 class="subsubheading">Verify signature in OCSP response against given certificate</h4>
<p>It is possible to override the normal trust logic if you know that a
certain certificate is supposed to have signed the OCSP response, and
you want to use it to check the signature. This is achieved using
<code>--load-signer</code> instead of <code>--load-trust</code>. This will load
one certificate and it will be used to verify the signature in the
OCSP response. It will not check the Extended Key Usage bit.
</p>
<div class="example">
<pre class="example">$ ocsptool -e --load-signer ocsp-signer.pem \
--load-response ocsp-response.der
</pre></div>
<p>This approach is normally only relevant in two situations. The first
is when the OCSP response does not contain a copy of the signer
certificate, so the <code>--load-trust</code> code would fail. The second
is if you want to avoid the indirect mode where the OCSP response
signer certificate is signed by a trust anchor.
</p>
<a name="Real_002dworld-example"></a>
<h4 class="subsubheading">Real-world example</h4>
<p>Here is an example of how to generate an OCSP request for a
certificate and to verify the response. For illustration we’ll use
the <code>blog.josefsson.org</code> host, which (as of writing) uses a
certificate from CACert. First we’ll use <code>gnutls-cli</code> to get a
copy of the server certificate chain. The server is not required to
send this information, but this particular one is configured to do so.
</p>
<div class="example">
<pre class="example">$ echo | gnutls-cli -p 443 blog.josefsson.org --print-cert > chain.pem
</pre></div>
<p>Use a text editor on <code>chain.pem</code> to create three files for each
separate certificates, called <code>cert.pem</code> for the first
certificate for the domain itself, secondly <code>issuer.pem</code> for the
intermediate certificate and <code>root.pem</code> for the final root
certificate.
</p>
<p>The domain certificate normally contains a pointer to where the OCSP
responder is located, in the Authority Information Access Information
extension. For example, from <code>certtool -i < cert.pem</code> there is
this information:
</p>
<div class="example">
<pre class="example">Authority Information Access Information (not critical):
Access Method: 1.3.6.1.5.5.7.48.1 (id-ad-ocsp)
Access Location URI: http://ocsp.CAcert.org/
</pre></div>
<p>This means the CA support OCSP queries over HTTP. We are now ready to
create a OCSP request for the certificate.
</p>
<div class="example">
<pre class="example">$ ocsptool --ask ocsp.CAcert.org --load-issuer issuer.pem \
--load-cert cert.pem --outfile ocsp-response.der
</pre></div>
<p>The request is sent via HTTP to the OCSP server address specified. If the
address is ommited ocsptool will use the address stored in the certificate.
</p>
<hr>
<a name="danetool-Invocation"></a>
<div class="header">
<p>
Previous: <a href="#ocsptool-Invocation" accesskey="p" rel="previous">ocsptool Invocation</a>, Up: <a href="#More-on-certificate-authentication" accesskey="u" rel="up">More on certificate authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-danetool"></a>
<h4 class="subsection">4.2.7 Invoking danetool</h4>
<a name="index-danetool"></a>
<p>Tool to generate and check DNS resource records for the DANE protocol.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>danetool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="danetool-usage"></a><a name="danetool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">danetool help/usage (-h)</h4>
<a name="index-danetool-help"></a>
<p>This is the automatically generated usage text for danetool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">danetool - GnuTLS DANE tool - Ver. 3.1.7
USAGE: danetool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-V, --verbose More verbose output
- may appear multiple times
--infile=file Input file
- file must pre-exist
--outfile=str Output file
--load-pubkey=str Loads a public key file
--load-certificate=str Loads a certificate file
--dlv=str Sets a DLV file
--hash=str Hash algorithm to use for signing.
--check=str Check a host's DANE TLSA entry.
--insecure Do not verify any DNSSEC signature.
--local-dns Use the local DNS server for DNSSEC resolving.
- disabled as --no-local-dns
--inder Use DER format for input certificates and private keys.
- disabled as --no-inder
--inraw This is an alias for 'inder'
--tlsa-rr Print the DANE RR data on a certificate or public key
- requires these options:
host
--host=str Specify the hostname to be used in the DANE RR
--proto=str The protocol set for DANE data (tcp, udp etc.)
--port=num Specify the port number for the DANE data.
--ca Whether the provided certificate or public key is a Certificate
Authority.
--x509 Use the hash of the X.509 certificate, rather than the public key.
--local The provided certificate or public key is a local entity.
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Tool to generate and check DNS resource records for the DANE protocol.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="danetool-debug"></a><a name="debug-option-_0028_002dd_0029-2"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="danetool-load_002dpubkey"></a></p><a name="load_002dpubkey-option-1"></a>
<h4 class="subsubheading">load-pubkey option</h4>
<p>This is the “loads a public key file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="danetool-load_002dcertificate"></a></p><a name="load_002dcertificate-option-1"></a>
<h4 class="subsubheading">load-certificate option</h4>
<p>This is the “loads a certificate file” option.
This option takes an argument string.
This can be either a file or a PKCS #11 URL
<a name="danetool-dlv"></a></p><a name="dlv-option"></a>
<h4 class="subsubheading">dlv option</h4>
<p>This is the “sets a dlv file” option.
This option takes an argument string.
This sets a DLV file to be used for DNSSEC verification.
<a name="danetool-hash"></a></p><a name="hash-option-1"></a>
<h4 class="subsubheading">hash option</h4>
<p>This is the “hash algorithm to use for signing.” option.
This option takes an argument string.
Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512.
<a name="danetool-check"></a></p><a name="check-option"></a>
<h4 class="subsubheading">check option</h4>
<p>This is the “check a host’s dane tlsa entry.” option.
This option takes an argument string.
Obtains the DANE TLSA entry from the given hostname and prints information.
<a name="danetool-insecure"></a></p><a name="insecure-option"></a>
<h4 class="subsubheading">insecure option</h4>
<p>This is the “do not verify any dnssec signature.” option.
Ignores any DNSSEC signature verification results.
<a name="danetool-local_002ddns"></a></p><a name="local_002ddns-option"></a>
<h4 class="subsubheading">local-dns option</h4>
<p>This is the “use the local dns server for dnssec resolving.” option.
This option will use the local DNS server for DNSSEC.
This is disabled by default due to many servers not allowing DNSSEC.
<a name="danetool-inder"></a></p><a name="inder-option-1"></a>
<h4 class="subsubheading">inder option</h4>
<p>This is the “use der format for input certificates and private keys.” option.
The input files will be assumed to be in DER or RAW format.
Unlike options that in PEM input would allow multiple input data (e.g. multiple
certificates), when reading in DER format a single data structure is read.
<a name="danetool-inraw"></a></p><a name="inraw-option-1"></a>
<h4 class="subsubheading">inraw option</h4>
<p>This is an alias for the inder option,
see <a href="#danetool-inder">the inder option documentation</a>.
</p>
<a name="danetool-tlsa_002drr"></a><a name="tlsa_002drr-option"></a>
<h4 class="subsubheading">tlsa-rr option</h4>
<p>This is the “print the dane rr data on a certificate or public key” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
host.
</li></ul>
<p>This command prints the DANE RR data needed to enable DANE on a DNS server.
<a name="danetool-host"></a></p><a name="host-option"></a>
<h4 class="subsubheading">host option</h4>
<p>This is the “specify the hostname to be used in the dane rr” option.
This option takes an argument string <samp>Hostname</samp>.
This command sets the hostname for the DANE RR.
<a name="danetool-proto"></a></p><a name="proto-option"></a>
<h4 class="subsubheading">proto option</h4>
<p>This is the “the protocol set for dane data (tcp, udp etc.)” option.
This option takes an argument string <samp>Protocol</samp>.
This command specifies the protocol for the service set in the DANE data.
<a name="danetool-ca"></a></p><a name="ca-option"></a>
<h4 class="subsubheading">ca option</h4>
<p>This is the “whether the provided certificate or public key is a certificate authority.” option.
Marks the DANE RR as a CA certificate if specified.
<a name="danetool-x509"></a></p><a name="x509-option"></a>
<h4 class="subsubheading">x509 option</h4>
<p>This is the “use the hash of the x.509 certificate, rather than the public key.” option.
This option forces the generated record to contain the hash of the full X.509 certificate. By default only the hash of the public key is used.
<a name="danetool-local"></a></p><a name="local-option"></a>
<h4 class="subsubheading">local option</h4>
<p>This is the “the provided certificate or public key is a local entity.” option.
DANE distinguishes certificates and public keys offered via the DNSSEC to trusted and local entities. Use this flag if this is a local (and possibly unsigned) entity.
<a name="danetool-exit-status"></a></p><a name="danetool-exit-status-1"></a>
<h4 class="subsubheading">danetool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="danetool-See-Also"></a><a name="danetool-See-Also-1"></a>
<h4 class="subsubheading">danetool See Also</h4>
<p>certtool (1)
</p>
<a name="danetool-Examples"></a><a name="danetool-Examples-1"></a>
<h4 class="subsubheading">danetool Examples</h4>
<a name="DANE-TLSA-RR-generation"></a>
<h4 class="subsubheading">DANE TLSA RR generation</h4>
<p>To create a DANE TLSA resource record for a CA signed certificate use the following commands.
</p>
<div class="example">
<pre class="example">$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem
</pre></div>
<p>For a self signed certificate use:
</p><div class="example">
<pre class="example">$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem \
--local
</pre></div>
<p>The latter is useful to add in your DNS entry even if your certificate is signed
by a CA. That way even users who do not trust your CA will be able to verify your
certificate using DANE.
</p>
<p>In order to create a record for the signer of your certificate use:
</p><div class="example">
<pre class="example">$ danetool --tlsa-rr --host www.example.com --load-certificate cert.pem \
--ca
</pre></div>
<p>To read a server’s DANE TLSA entry, use:
</p><div class="example">
<pre class="example">$ danetool --check www.example.com --proto tcp --port 443
</pre></div>
<p>To verify a server’s DANE TLSA entry, use:
</p><div class="example">
<pre class="example">$ danetool --check www.example.com --proto tcp --port 443 --load-certificate chain.pem
</pre></div>
<hr>
<a name="Shared_002dkey-and-anonymous-authentication"></a>
<div class="header">
<p>
Next: <a href="#Selecting-an-appropriate-authentication-method" accesskey="n" rel="next">Selecting an appropriate authentication method</a>, Previous: <a href="#More-on-certificate-authentication" accesskey="p" rel="previous">More on certificate authentication</a>, Up: <a href="#Authentication-methods" accesskey="u" rel="up">Authentication methods</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Shared_002dkey-and-anonymous-authentication-1"></a>
<h3 class="section">4.3 Shared-key and anonymous authentication</h3>
<p>In addition to certificate authentication, the TLS protocol may be
used with password, shared-key and anonymous authentication methods.
The rest of this chapter discusses details of these methods.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#SRP-authentication" accesskey="1">SRP authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#PSK-authentication" accesskey="2">PSK authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Anonymous-authentication" accesskey="3">Anonymous authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="SRP-authentication"></a>
<div class="header">
<p>
Next: <a href="#PSK-authentication" accesskey="n" rel="next">PSK authentication</a>, Up: <a href="#Shared_002dkey-and-anonymous-authentication" accesskey="u" rel="up">Shared-key and anonymous authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="SRP-authentication-1"></a>
<h4 class="subsection">4.3.1 SRP authentication</h4>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Authentication-using-SRP" accesskey="1">Authentication using SRP</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#srptool-Invocation" accesskey="2">srptool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking srptool
</td></tr>
</table>
<hr>
<a name="Authentication-using-SRP"></a>
<div class="header">
<p>
Next: <a href="#srptool-Invocation" accesskey="n" rel="next">srptool Invocation</a>, Up: <a href="#SRP-authentication" accesskey="u" rel="up">SRP authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Authentication-using-SRP-1"></a>
<h4 class="subsubsection">4.3.1.1 Authentication using <acronym>SRP</acronym></h4>
<a name="index-SRP-authentication"></a>
<p><acronym>GnuTLS</acronym> supports authentication via the Secure Remote Password
or <acronym>SRP</acronym> protocol (see [<em>RFC2945,TOMSRP</em>] for a description).
The <acronym>SRP</acronym> key exchange is an extension to the
<acronym>TLS</acronym> protocol, and it provides an authenticated with a
password key exchange. The 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>
<p>The advantage of <acronym>SRP</acronym> authentication, over other proposed
secure password authentication schemes, is that <acronym>SRP</acronym> is not
susceptible to off-line dictionary attacks.
Moreover, SRP does not require the server to hold the user’s password.
This kind of protection is similar to the one used traditionally in the <acronym>UNIX</acronym>
<samp>/etc/passwd</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.
</p>
<p>Typical conventions in SRP are a password file, called <samp>tpasswd</samp> that
holds the SRP verifiers (encoded passwords) and another file, <samp>tpasswd.conf</samp>,
which holds the allowed SRP parameters. The included in GnuTLS helper
follow those conventions. The srptool program, discussed in the next section
is a tool to manipulate the SRP parameters.
</p>
<p>The implementation in <acronym>GnuTLS</acronym> is based on [<em>TLSSRP</em>]. The
supported key exchange methods are shown below.
</p>
<dl compact="compact">
<dt><code>SRP:</code></dt>
<dd><p>Authentication using the <acronym>SRP</acronym> protocol.
</p>
</dd>
<dt><code>SRP_DSS:</code></dt>
<dd><p>Client authentication using the <acronym>SRP</acronym> protocol. Server is
authenticated using a certificate with DSA parameters.
</p>
</dd>
<dt><code>SRP_RSA:</code></dt>
<dd><p>Client authentication using the <acronym>SRP</acronym> protocol. Server is
authenticated using a certificate with RSA parameters.
</p>
</dd>
</dl>
<dl>
<dt><a name="index-gnutls_005fsrp_005fverifier"></a>Function: <em>int</em> <strong>gnutls_srp_verifier</strong> <em>(const char * <var>username</var>, const char * <var>password</var>, const gnutls_datum_t * <var>salt</var>, const gnutls_datum_t * <var>generator</var>, const gnutls_datum_t * <var>prime</var>, gnutls_datum_t * <var>res</var>)</em></dt>
<dd><p><var>username</var>: is the user’s name
</p>
<p><var>password</var>: is the user’s password
</p>
<p><var>salt</var>: should be some randomly generated bytes
</p>
<p><var>generator</var>: is the generator of the group
</p>
<p><var>prime</var>: is the group’s prime
</p>
<p><var>res</var>: where the verifier will be stored.
</p>
<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/gnutls.h or may be generated.
</p>
<p>The verifier will be allocated with <code>gnutls_malloc</code> () and will be stored in
<code>res</code> using binary format.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fsrp_005fbase64_005fencode_005falloc">gnutls_srp_base64_encode_alloc</a> (const gnutls_datum_t * <var>data</var>, gnutls_datum_t * <var>result</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsrp_005fbase64_005fdecode_005falloc">gnutls_srp_base64_decode_alloc</a> (const gnutls_datum_t * <var>b64_data</var>, gnutls_datum_t * <var>result</var>)</code></dt>
</dl>
<hr>
<a name="srptool-Invocation"></a>
<div class="header">
<p>
Previous: <a href="#Authentication-using-SRP" accesskey="p" rel="previous">Authentication using SRP</a>, Up: <a href="#SRP-authentication" accesskey="u" rel="up">SRP authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-srptool"></a>
<h4 class="subsubsection">4.3.1.2 Invoking srptool</h4>
<a name="index-srptool"></a>
<p>Simple program that emulates the programs in the Stanford SRP (Secure
Remote Password) libraries using GnuTLS. It is intended for use in places
where you don’t expect SRP authentication to be the used for system users.
</p>
<p>In brief, to use SRP you need to create two files. These are the password
file that holds the users and the verifiers associated with them and the
configuration file to hold the group parameters (called tpasswd.conf).
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>srptool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="srptool-usage"></a><a name="srptool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">srptool help/usage (-h)</h4>
<a name="index-srptool-help"></a>
<p>This is the automatically generated usage text for srptool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">srptool - GnuTLS SRP tool - Ver. 3.1.7
USAGE: srptool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-i, --index specify the index of the group parameters in tpasswd.conf to use.
-u, --username=str specify a username
-p, --passwd=str specify a password file.
-s, --salt=num specify salt size.
--verify just verify the password.
-v, --passwd-conf=str specify a password conf file.
--create-conf=str Generate a password configuration file.
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Simple program that emulates the programs in the Stanford SRP (Secure
Remote Password) libraries using GnuTLS. It is intended for use in places
where you don't expect SRP authentication to be the used for system users.
In brief, to use SRP you need to create two files. These are the password
file that holds the users and the verifiers associated with them and the
configuration file to hold the group parameters (called tpasswd.conf).
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="srptool-debug"></a><a name="debug-option-_0028_002dd_0029-3"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="srptool-verify"></a></p><a name="verify-option-1"></a>
<h4 class="subsubheading">verify option</h4>
<p>This is the “just verify the password.” option.
Verifies the password provided against the password file.
<a name="srptool-passwd_002dconf"></a></p><a name="passwd_002dconf-option-_0028_002dv_0029"></a>
<h4 class="subsubheading">passwd-conf option (-v)</h4>
<p>This is the “specify a password conf file.” option.
This option takes an argument string.
Specify a filename or a PKCS #11 URL to read the CAs from.
<a name="srptool-create_002dconf"></a></p><a name="create_002dconf-option"></a>
<h4 class="subsubheading">create-conf option</h4>
<p>This is the “generate a password configuration file.” option.
This option takes an argument string.
This generates a password configuration file (tpasswd.conf)
containing the required for TLS parameters.
<a name="srptool-exit-status"></a></p><a name="srptool-exit-status-1"></a>
<h4 class="subsubheading">srptool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="srptool-See-Also"></a><a name="srptool-See-Also-1"></a>
<h4 class="subsubheading">srptool See Also</h4>
<p>gnutls-cli-debug (1), gnutls-serv (1), srptool (1), psktool (1), certtool (1)
</p>
<a name="srptool-Examples"></a><a name="srptool-Examples-1"></a>
<h4 class="subsubheading">srptool Examples</h4>
<p>To create <samp>tpasswd.conf</samp> which holds the g and n values for SRP protocol
(generator and a large prime), run:
</p><div class="example">
<pre class="example">$ srptool --create-conf /etc/tpasswd.conf
</pre></div>
<p>This command will create <samp>/etc/tpasswd</samp> and will add user ’test’ (you
will also be prompted for a password). Verifiers are stored by default
in the way libsrp expects.
</p><div class="example">
<pre class="example">$ srptool --passwd /etc/tpasswd --passwd-conf /etc/tpasswd.conf -u test
</pre></div>
<p>This command will check against a password. If the password matches
the one in <samp>/etc/tpasswd</samp> you will get an ok.
</p><div class="example">
<pre class="example">$ srptool --passwd /etc/tpasswd --passwd\-conf /etc/tpasswd.conf --verify -u test
</pre></div>
<hr>
<a name="PSK-authentication"></a>
<div class="header">
<p>
Next: <a href="#Anonymous-authentication" accesskey="n" rel="next">Anonymous authentication</a>, Previous: <a href="#SRP-authentication" accesskey="p" rel="previous">SRP authentication</a>, Up: <a href="#Shared_002dkey-and-anonymous-authentication" accesskey="u" rel="up">Shared-key and anonymous authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PSK-authentication-1"></a>
<h4 class="subsection">4.3.2 PSK authentication</h4>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Authentication-using-PSK" accesskey="1">Authentication using PSK</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#psktool-Invocation" accesskey="2">psktool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking psktool
</td></tr>
</table>
<hr>
<a name="Authentication-using-PSK"></a>
<div class="header">
<p>
Next: <a href="#psktool-Invocation" accesskey="n" rel="next">psktool Invocation</a>, Up: <a href="#PSK-authentication" accesskey="u" rel="up">PSK authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Authentication-using-PSK-1"></a>
<h4 class="subsubsection">4.3.2.1 Authentication using <acronym>PSK</acronym></h4>
<a name="index-PSK-authentication"></a>
<p>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>
<p>The implementation in <acronym>GnuTLS</acronym> is based on [<em>TLSPSK</em>].
The supported <acronym>PSK</acronym> key exchange methods are:
</p>
<dl compact="compact">
<dt><code>PSK:</code></dt>
<dd><p>Authentication using the <acronym>PSK</acronym> protocol.
</p>
</dd>
<dt><code>DHE-PSK:</code></dt>
<dd><p>Authentication using the <acronym>PSK</acronym> protocol and Diffie-Hellman key
exchange. This method offers perfect forward secrecy.
</p>
</dd>
<dt><code>ECDHE-PSK:</code></dt>
<dd><p>Authentication using the <acronym>PSK</acronym> protocol and Elliptic curve Diffie-Hellman key
exchange. This method offers perfect forward secrecy.
</p>
</dd>
</dl>
<p>Helper functions to generate and maintain <acronym>PSK</acronym> keys are also included
in <acronym>GnuTLS</acronym>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fkey_005fgenerate">gnutls_key_generate</a> (gnutls_datum_t * <var>key</var>, unsigned int <var>key_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhex_005fencode">gnutls_hex_encode</a> (const gnutls_datum_t * <var>data</var>, char * <var>result</var>, size_t * <var>result_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhex_005fdecode">gnutls_hex_decode</a> (const gnutls_datum_t * <var>hex_data</var>, void * <var>result</var>, size_t * <var>result_size</var>)</code></dt>
</dl>
<hr>
<a name="psktool-Invocation"></a>
<div class="header">
<p>
Previous: <a href="#Authentication-using-PSK" accesskey="p" rel="previous">Authentication using PSK</a>, Up: <a href="#PSK-authentication" accesskey="u" rel="up">PSK authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-psktool"></a>
<h4 class="subsubsection">4.3.2.2 Invoking psktool</h4>
<a name="index-psktool"></a>
<p>Program that generates random keys for use with TLS-PSK. The
keys are stored in hexadecimal format in a key file.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>psktool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="psktool-usage"></a><a name="psktool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">psktool help/usage (-h)</h4>
<a name="index-psktool-help"></a>
<p>This is the automatically generated usage text for psktool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">psktool - GnuTLS PSK tool - Ver. 3.1.7
USAGE: psktool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-s, --keysize=num specify the key size in bytes
- It must be in the range:
0 to 512
-u, --username=str specify a username
-p, --passwd=str specify a password file.
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Program that generates random keys for use with TLS-PSK. The keys are
stored in hexadecimal format in a key file.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="psktool-debug"></a><a name="debug-option-_0028_002dd_0029-4"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="psktool-exit-status"></a></p><a name="psktool-exit-status-1"></a>
<h4 class="subsubheading">psktool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="psktool-See-Also"></a><a name="psktool-See-Also-1"></a>
<h4 class="subsubheading">psktool See Also</h4>
<p>gnutls-cli-debug (1), gnutls-serv (1), srptool (1), certtool (1)
</p>
<a name="psktool-Examples"></a><a name="psktool-Examples-1"></a>
<h4 class="subsubheading">psktool Examples</h4>
<p>To add a user ’psk_identity’ in <samp>passwd.psk</samp> for use with GnuTLS run:
</p><div class="example">
<pre class="example">$ ./psktool -u psk_identity -p passwd.psk
Generating a random key for user 'psk_identity'
Key stored to passwd.psk
$ cat psks.txt
psk_identity:88f3824b3e5659f52d00e959bacab954b6540344
$
</pre></div>
<p>This command will create <samp>passwd.psk</samp> if it does not exist
and will add user ’psk_identity’ (you will also be prompted for a password).
</p>
<hr>
<a name="Anonymous-authentication"></a>
<div class="header">
<p>
Previous: <a href="#PSK-authentication" accesskey="p" rel="previous">PSK authentication</a>, Up: <a href="#Shared_002dkey-and-anonymous-authentication" accesskey="u" rel="up">Shared-key and anonymous authentication</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Anonymous-authentication-1"></a>
<h4 class="subsection">4.3.3 Anonymous authentication</h4>
<a name="index-anonymous-authentication"></a>
<p>The anonymous key exchange offers encryption without any
indication of the peer’s identity. This kind of authentication
is vulnerable to a man in the middle attack, but can be
used even if there is no prior communication or shared trusted parties
with the peer. Moreover it is useful when complete anonymity is required.
Unless in one of the above cases, do not use anonymous authentication.
</p>
<p>The available key exchange algorithms for anonymous authentication are
shown below, but note that few public servers support them. They typically
have to be explicitly enabled.
</p>
<dl compact="compact">
<dt><code>ANON_DH:</code></dt>
<dd><p>This algorithm exchanges Diffie-Hellman parameters.
</p>
</dd>
<dt><code>ANON_ECDH:</code></dt>
<dd><p>This algorithm exchanges elliptic curve Diffie-Hellman parameters. It is more
efficient than ANON_DH on equivalent security levels.
</p>
</dd>
</dl>
<hr>
<a name="Selecting-an-appropriate-authentication-method"></a>
<div class="header">
<p>
Previous: <a href="#Shared_002dkey-and-anonymous-authentication" accesskey="p" rel="previous">Shared-key and anonymous authentication</a>, Up: <a href="#Authentication-methods" accesskey="u" rel="up">Authentication methods</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Selecting-an-appropriate-authentication-method-1"></a>
<h3 class="section">4.4 Selecting an appropriate authentication method</h3>
<p>This section provides some guidance on how to use the available authentication
methods in <acronym>GnuTLS</acronym> in various scenarios.
</p>
<a name="Two-peers-with-an-out_002dof_002dband-channel"></a>
<h4 class="subsection">4.4.1 Two peers with an out-of-band channel</h4>
<p>Let’s consider two peers need to communicate over an untrusted channel
(the Internet), but have an out-of-band channel available. The latter
channel is considered safe from eavesdropping and message modification and thus
can be used for an initial bootstrapping of the protocol. The options
available are:
</p><ul>
<li> Pre-shared keys (see <a href="#PSK-authentication">PSK authentication</a>). The server and a
client communicate a shared randomly generated key over the trusted
channel and use it to negotiate further sessions over the untrusted channel.
</li><li> Passwords (see <a href="#SRP-authentication">SRP authentication</a>). The client communicates
to the server his username and password of choice and uses it to
negotiate further sessions over the untrusted channel.
</li><li> Public keys (see <a href="#Certificate-authentication">Certificate authentication</a>). The client
and the server exchange their public keys (or fingerprints of them)
over the trusted channel.
On future sessions over the untrusted channel they verify the key
being the same (similar to <a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a>).
</li></ul>
<p>Provided that the out-of-band channel is trusted all of the above provide
a similar level of protection. An out-of-band channel may be the initial
bootstrapping of a user’s PC in a corporate environment, in-person
communication, communication over an alternative network (e.g. the phone
network), etc.
</p>
<a name="Two-peers-without-an-out_002dof_002dband-channel"></a>
<h4 class="subsection">4.4.2 Two peers without an out-of-band channel</h4>
<p>When an out-of-band channel is not available a peer cannot be reliably
authenticated. What can be done, however, is to allow some form of
registration of users connecting for the first time and ensure that their
keys remain the same after that initial connection. This is termed
key continuity or trust on first use (TOFU).
</p>
<p>The available option is to use public key authentication (see <a href="#Certificate-authentication">Certificate authentication</a>).
The client and the server store each other’s public keys (or fingerprints of them)
and associate them with their identity.
On future sessions over the untrusted channel they verify the keys
being the same (see <a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a>).
</p>
<p>To mitigate the uncertainty of the information exchanged in the first
connection other channels over the Internet may be used, e.g., <acronym>DNSSEC</acronym>
(see <a href="#Verifying-a-certificate-using-DANE">Verifying a certificate using DANE</a>).
</p>
<a name="Two-peers-and-a-trusted-third-party"></a>
<h4 class="subsection">4.4.3 Two peers and a trusted third party</h4>
<p>When a trusted third party is available the most suitable option is to use
certificate authentication (see <a href="#Certificate-authentication">Certificate authentication</a>).
The client and the server obtain certificates that associate their identity
and public keys in a reliable way and use them to on the subsequent
communications with each other. Each party verifies the peer’s certificate
using the trusted third party’s certificate.
</p>
<p>While the above is the typical authentication method for servers in the
Internet by using the commercial CAs, the users that act as clients in the
protocol rarely possess such certificates. In that case a hybrid method
can be used where the server is authenticated by the client using the
commercial CAs and the client is authenticated based on some information
the client provided over the initial server-authenticated channel. The
available options are:
</p><ul>
<li> Passwords (see <a href="#SRP-authentication">SRP authentication</a>). The client communicates
to the server his username and password of choice on the initial
server-authenticated connection and uses it to negotiate further sessions.
This is possible because the SRP protocol allows for the server to be
authenticated using a certificate and the client using the
password.
</li><li> Public keys (see <a href="#Certificate-authentication">Certificate authentication</a>). The client
sends its public key to the server (or a fingerprint of it) over the
initial server-authenticated connection.
On future sessions the client verifies the server using the third party
certificate and the server verifies that the client’s public key remained
the same (see <a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a>).
</li></ul>
<hr>
<a name="Hardware-security-modules-and-abstract-key-types"></a>
<div class="header">
<p>
Next: <a href="#How-to-use-GnuTLS-in-applications" accesskey="n" rel="next">How to use GnuTLS in applications</a>, Previous: <a href="#Authentication-methods" accesskey="p" rel="previous">Authentication methods</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Hardware-security-modules-and-abstract-key-types-1"></a>
<h2 class="chapter">5 Hardware security modules and abstract key types</h2>
<p>In several cases storing the long term cryptographic keys in a hard disk or
even in memory poses a significant risk. Once the system they are stored
is compromised the keys must be replaced as the secrecy of future sessions
is no longer guarranteed. Moreover, past sessions that were not protected by a
perfect forward secrecy offering ciphersuite are also to be assumed compromised.
</p>
<p>If such threats need to be addressed, then it may be wise storing the keys in a security
module such as a smart card, an HSM or the TPM chip. Those modules ensure the
protection of the cryptographic keys by only allowing operations on them and
preventing their extraction.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Abstract-key-types" accesskey="1">Abstract key types</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Smart-cards-and-HSMs" accesskey="2">Smart cards and HSMs</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Trusted-Platform-Module" accesskey="3">Trusted Platform Module</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Abstract-key-types"></a>
<div class="header">
<p>
Next: <a href="#Smart-cards-and-HSMs" accesskey="n" rel="next">Smart cards and HSMs</a>, Up: <a href="#Hardware-security-modules-and-abstract-key-types" accesskey="u" rel="up">Hardware security modules and abstract key types</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Abstract-key-types-1"></a>
<h3 class="section">5.1 Abstract key types</h3>
<a name="index-abstract-types"></a>
<p>Since there are many forms of a public or private keys supported by <acronym>GnuTLS</acronym> such as
<acronym>X.509</acronym>, <acronym>OpenPGP</acronym>, <acronym>PKCS</acronym> #11 or TPM it is desirable to allow common operations
on them. For these reasons the abstract <code>gnutls_privkey_t</code> and <code>gnutls_pubkey_t</code> were
introduced in <code>gnutls/abstract.h</code> header. Those types are initialized using a specific type of
key and then can be used to perform operations in an abstract way. For example in order
to sign an X.509 certificate with a key that resides in a token the following steps must be
used.
</p>
<div class="example">
<pre class="example">#inlude <gnutls/abstract.h>
void sign_cert( gnutls_x509_crt_t to_be_signed)
{
gnutls_x509_crt_t ca_cert;
gnutls_privkey_t abs_key;
/* initialize the abstract key */
gnutls_privkey_init(&abs_key);
/* keys stored in tokens are identified by URLs */
gnutls_privkey_import_url(abs_key, key_url);
gnutls_x509_crt_init(&ca_cert);
gnutls_x509_crt_import_pkcs11_url(&ca_cert, cert_url);
/* sign the certificate to be signed */
gnutls_x509_crt_privkey_sign(to_be_signed, ca_cert, abs_key,
GNUTLS_DIG_SHA256, 0);
}
</pre></div>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Abstract-public-keys" accesskey="1">Abstract public keys</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Abstract-private-keys" accesskey="2">Abstract private keys</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Operations" accesskey="3">Operations</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Abstract-public-keys"></a>
<div class="header">
<p>
Next: <a href="#Abstract-private-keys" accesskey="n" rel="next">Abstract private keys</a>, Up: <a href="#Abstract-key-types" accesskey="u" rel="up">Abstract key types</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Public-keys"></a>
<h4 class="subsection">5.1.1 Public keys</h4>
<p>An abstract <code>gnutls_pubkey_t</code> can be initialized
using the functions below. It can be imported through
an existing structure like <code>gnutls_x509_crt_t</code>,
or through an ASN.1 encoding of the X.509 <code>SubjectPublicKeyInfo</code>
sequence.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005fx509">gnutls_pubkey_import_x509</a> (gnutls_pubkey_t <var>key</var>, gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005fopenpgp">gnutls_pubkey_import_openpgp</a> (gnutls_pubkey_t <var>key</var>, gnutls_openpgp_crt_t <var>crt</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005fpkcs11">gnutls_pubkey_import_pkcs11</a> (gnutls_pubkey_t <var>key</var>, gnutls_pkcs11_obj_t <var>obj</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005furl">gnutls_pubkey_import_url</a> (gnutls_pubkey_t <var>key</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005fprivkey">gnutls_pubkey_import_privkey</a> (gnutls_pubkey_t <var>key</var>, gnutls_privkey_t <var>pkey</var>, unsigned int <var>usage</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport">gnutls_pubkey_import</a> (gnutls_pubkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fexport">gnutls_pubkey_export</a> (gnutls_pubkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fpubkey_005fexport2"></a>Function: <em>int</em> <strong>gnutls_pubkey_export2</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>key</var>: Holds the certificate
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a certificate PEM or DER encoded
</p>
<p>This function will export the public key to DER or PEM format.
The contents of the exported data is the SubjectPublicKeyInfo
X.509 structure.
</p>
<p>The output buffer will be allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<p>Other helper functions that allow directly importing from raw X.509 or
OpenPGP structures are shown below.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005fx509_005fraw">gnutls_pubkey_import_x509_raw</a> (gnutls_pubkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005fopenpgp_005fraw">gnutls_pubkey_import_openpgp_raw</a> (gnutls_pubkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const gnutls_openpgp_keyid_t <var>keyid</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<p>An important function is <a href="#gnutls_005fpubkey_005fimport_005furl">gnutls_pubkey_import_url</a> which will import
public keys from URLs that identify objects stored in tokens (see <a href="#Smart-cards-and-HSMs">Smart cards and HSMs</a> and <a href="#Trusted-Platform-Module">Trusted Platform Module</a>).
A function to check for a supported by GnuTLS URL is <a href="#gnutls_005furl_005fis_005fsupported">gnutls_url_is_supported</a>.
</p>
<dl>
<dt><a name="index-gnutls_005furl_005fis_005fsupported"></a>Function: <em>int</em> <strong>gnutls_url_is_supported</strong> <em>(const char* <var>url</var>)</em></dt>
<dd><p><var>url</var>: A PKCS 11 url
</p>
<p>Check whether url is supported. Depending on the system libraries
GnuTLS may support pkcs11 or tpmkey URLs.
</p>
<p><strong>Returns:</strong> return non-zero if the given URL is supported, and zero if
it is not known.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<p>Additional functions are available that will return
information over a public key, as well as a function that given a public
key fingerprint would provide a memorable sketch.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fpk_005falgorithm">gnutls_pubkey_get_pk_algorithm</a> (gnutls_pubkey_t <var>key</var>, unsigned int * <var>bits</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fpreferred_005fhash_005falgorithm">gnutls_pubkey_get_preferred_hash_algorithm</a> (gnutls_pubkey_t <var>key</var>, gnutls_digest_algorithm_t * <var>hash</var>, unsigned int * <var>mand</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fkey_005fid">gnutls_pubkey_get_key_id</a> (gnutls_pubkey_t <var>key</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005frandom_005fart">gnutls_random_art</a> (gnutls_random_art_t <var>type</var>, const char* <var>key_type</var>, unsigned int <var>key_size</var>, void * <var>fpr</var>, size_t <var>fpr_size</var>, gnutls_datum_t* <var>art</var>)</code></dt>
</dl>
<p>To export the key-specific parameters, or obtain a unique key ID the following functions are provided.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fpk_005frsa_005fraw">gnutls_pubkey_get_pk_rsa_raw</a> (gnutls_pubkey_t <var>key</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fpk_005fdsa_005fraw">gnutls_pubkey_get_pk_dsa_raw</a> (gnutls_pubkey_t <var>key</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fpk_005fecc_005fraw">gnutls_pubkey_get_pk_ecc_raw</a> (gnutls_pubkey_t <var>key</var>, gnutls_ecc_curve_t * <var>curve</var>, gnutls_datum_t * <var>x</var>, gnutls_datum_t * <var>y</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fget_005fpk_005fecc_005fx962">gnutls_pubkey_get_pk_ecc_x962</a> (gnutls_pubkey_t <var>key</var>, gnutls_datum_t* <var>parameters</var>, gnutls_datum_t * <var>ecpoint</var>)</code></dt>
</dl>
<hr>
<a name="Abstract-private-keys"></a>
<div class="header">
<p>
Next: <a href="#Operations" accesskey="n" rel="next">Operations</a>, Previous: <a href="#Abstract-public-keys" accesskey="p" rel="previous">Abstract public keys</a>, Up: <a href="#Abstract-key-types" accesskey="u" rel="up">Abstract key types</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Private-keys"></a>
<h4 class="subsection">5.1.2 Private keys</h4>
<p>An abstract <code>gnutls_privkey_t</code> can be initialized
using the functions below. It can be imported through
an existing structure like <code>gnutls_x509_privkey_t</code>,
but unlike public keys it cannot be exported. That is
to allow abstraction over keys stored in hardware that
makes available only operations.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fimport_005fx509">gnutls_privkey_import_x509</a> (gnutls_privkey_t <var>pkey</var>, gnutls_x509_privkey_t <var>key</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fimport_005fopenpgp">gnutls_privkey_import_openpgp</a> (gnutls_privkey_t <var>pkey</var>, gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fimport_005fpkcs11">gnutls_privkey_import_pkcs11</a> (gnutls_privkey_t <var>pkey</var>, gnutls_pkcs11_privkey_t <var>key</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<p>Other helper functions that allow directly importing from raw X.509 or
OpenPGP structures are shown below. Again, as with public keys, private keys
can be imported from a hardware module using URLs.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fimport_005fx509_005fraw">gnutls_privkey_import_x509_raw</a> (gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char* <var>password</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fimport_005fopenpgp_005fraw">gnutls_privkey_import_openpgp_raw</a> (gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const gnutls_openpgp_keyid_t <var>keyid</var>, const char* <var>password</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_privkey_import_url</strong> <em>(gnutls_privkey_t <var>key</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_privkey_t</code>
</p>
<p><var>url</var>: A PKCS 11 url
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import a PKCS11 or TPM URL as a
private key. The supported URL types can be checked
using <code>gnutls_url_is_supported()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fget_005fpk_005falgorithm">gnutls_privkey_get_pk_algorithm</a> (gnutls_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</code></dt>
<dt><code><var>gnutls_privkey_type_t</var> <a href="#gnutls_005fprivkey_005fget_005ftype">gnutls_privkey_get_type</a> (gnutls_privkey_t <var>key</var>)</code></dt>
</dl>
<p>In order to support cryptographic operations using
an external API, the following function is provided.
This allows for a simple extensibility API without
resorting to <acronym>PKCS</acronym> #11.
</p>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fext2"></a>Function: <em>int</em> <strong>gnutls_privkey_import_ext2</strong> <em>(gnutls_privkey_t <var>pkey</var>, gnutls_pk_algorithm_t <var>pk</var>, void* <var>userdata</var>, gnutls_privkey_sign_func <var>sign_func</var>, gnutls_privkey_decrypt_func <var>decrypt_func</var>, gnutls_privkey_deinit_func <var>deinit_func</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>pk</var>: The public key algorithm
</p>
<p><var>userdata</var>: private data to be provided to the callbacks
</p>
<p><var>sign_func</var>: callback for signature operations
</p>
<p><var>decrypt_func</var>: callback for decryption operations
</p>
<p><var>deinit_func</var>: a deinitialization function
</p>
<p><var>flags</var>: Flags for the import
</p>
<p>This function will associate the given callbacks with the
<code>gnutls_privkey_t</code> structure. At least one of the two callbacks
must be non-null. If a deinitialization function is provided
then flags is assumed to contain <code>GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<hr>
<a name="Operations"></a>
<div class="header">
<p>
Previous: <a href="#Abstract-private-keys" accesskey="p" rel="previous">Abstract private keys</a>, Up: <a href="#Abstract-key-types" accesskey="u" rel="up">Abstract key types</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Operations-1"></a>
<h4 class="subsection">5.1.3 Operations</h4>
<p>The abstract key types can be used to access signing and
signature verification operations with the underlying keys.
</p>
<dl>
<dt><a name="index-gnutls_005fpubkey_005fverify_005fdata2"></a>Function: <em>int</em> <strong>gnutls_pubkey_verify_data2</strong> <em>(gnutls_pubkey_t <var>pubkey</var>, gnutls_sign_algorithm_t <var>algo</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>pubkey</var>: Holds the public key
</p>
<p><var>algo</var>: The signature algorithm used
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the signed data
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed data, using the
parameters from the certificate.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fpubkey_005fverify_005fhash2"></a>Function: <em>int</em> <strong>gnutls_pubkey_verify_hash2</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_sign_algorithm_t <var>algo</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>hash</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>algo</var>: The signature algorithm used
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>hash</var>: holds the hash digest to be verified
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed digest, using the
parameters from the public key.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fpubkey_005fencrypt_005fdata"></a>Function: <em>int</em> <strong>gnutls_pubkey_encrypt_data</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>plaintext</var>, gnutls_datum_t * <var>ciphertext</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>plaintext</var>: The data to be encrypted
</p>
<p><var>ciphertext</var>: contains the encrypted data
</p>
<p>This function will encrypt the given data, using the public
key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fsign_005fdata"></a>Function: <em>int</em> <strong>gnutls_privkey_sign_data</strong> <em>(gnutls_privkey_t <var>signer</var>, gnutls_digest_algorithm_t <var>hash</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>signer</var>: Holds the key
</p>
<p><var>hash</var>: should be a digest algorithm
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain the signature allocate with <code>gnutls_malloc()</code>
</p>
<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 the SHA family for the DSA keys.
</p>
<p>You may use <code>gnutls_pubkey_get_preferred_hash_algorithm()</code> to determine
the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fsign_005fhash"></a>Function: <em>int</em> <strong>gnutls_privkey_sign_hash</strong> <em>(gnutls_privkey_t <var>signer</var>, gnutls_digest_algorithm_t <var>hash_algo</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>hash_data</var>, gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>signer</var>: Holds the signer’s key
</p>
<p><var>hash_algo</var>: The hash algorithm used
</p>
<p><var>flags</var>: zero for now
</p>
<p><var>hash_data</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain newly allocated signature
</p>
<p>This function will sign the given hashed 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-XXX for the DSA keys.
</p>
<p>You may use <code>gnutls_pubkey_get_preferred_hash_algorithm()</code> to determine
the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fdecrypt_005fdata"></a>Function: <em>int</em> <strong>gnutls_privkey_decrypt_data</strong> <em>(gnutls_privkey_t <var>key</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>ciphertext</var>, gnutls_datum_t * <var>plaintext</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>flags</var>: zero for now
</p>
<p><var>ciphertext</var>: holds the data to be decrypted
</p>
<p><var>plaintext</var>: will contain the decrypted data, allocated with <code>gnutls_malloc()</code>
</p>
<p>This function will decrypt the given data using the algorithm
supported by the private key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<p>Signing existing structures, such as certificates, CRLs,
or certificate requests, as well as associating public
keys with structures is also possible using the
key abstractions.
</p>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_pubkey</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_pubkey_t <var>key</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a public key
</p>
<p>This function will set the public parameters from the given public
key to the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_pubkey</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_pubkey_t <var>key</var>)</em></dt>
<dd><p><var>crt</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>key</var>: holds a public key
</p>
<p>This function will set the public parameters from the given public
key to the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fprivkey_005fsign">gnutls_x509_crt_privkey_sign</a> (gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrl_005fprivkey_005fsign">gnutls_x509_crl_privkey_sign</a> (gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrq_005fprivkey_005fsign">gnutls_x509_crq_privkey_sign</a> (gnutls_x509_crq_t <var>crq</var>, gnutls_privkey_t <var>key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<hr>
<a name="Smart-cards-and-HSMs"></a>
<div class="header">
<p>
Next: <a href="#Trusted-Platform-Module" accesskey="n" rel="next">Trusted Platform Module</a>, Previous: <a href="#Abstract-key-types" accesskey="p" rel="previous">Abstract key types</a>, Up: <a href="#Hardware-security-modules-and-abstract-key-types" accesskey="u" rel="up">Hardware security modules and abstract key types</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Smart-cards-and-HSMs-1"></a>
<h3 class="section">5.2 Smart cards and HSMs</h3>
<a name="index-PKCS-_002311-tokens"></a>
<a name="index-hardware-tokens"></a>
<a name="index-hardware-security-modules"></a>
<a name="index-smart-cards"></a>
<p>In this section we present the smart-card and hardware security module (HSM) support
in <acronym>GnuTLS</acronym> using <acronym>PKCS</acronym> #11 [<em>PKCS11</em>]. Hardware security
modules and smart cards provide a way to store private keys and perform
operations on them without exposing them. This decouples cryptographic
keys from the applications that use them and provide an additional
security layer against cryptographic key extraction.
Since this can also be achieved in software components such as in Gnome keyring,
we will use the term security module to describe any cryptographic key
separation subsystem.
</p>
<p><acronym>PKCS</acronym> #11 is plugin API allowing applications to access cryptographic
operations on a security module, as well as to objects residing on it. PKCS
#11 modules exist for hardware tokens such as smart cards<a name="DOCF9" href="#FOOT9"><sup>9</sup></a>,
cryptographic tokens, as well as for software modules like <acronym>Gnome Keyring</acronym>.
The objects residing on a security module may be certificates, public keys,
private keys or secret keys. Of those certificates and public/private key
pairs can be used with <acronym>GnuTLS</acronym>. PKCS #11’s main advantage is that
it allows operations on private key objects such as decryption
and signing without exposing the key. In GnuTLS the PKCS #11 functionality is
available in <code>gnutls/pkcs11.h</code>.
</p>
<p>Moreover <acronym>PKCS</acronym> #11 can be (ab)used to allow all applications in the same operating system to access
shared cryptographic keys and certificates in a uniform way, as in <a href="#fig_003apkcs11_002dvision">Figure 5.1</a>.
That way applications could load their trusted certificate list, as well as user
certificates from a common PKCS #11 module. Such a provider exists in the <acronym>Gnome</acronym>
system, being the <acronym>Gnome Keyring</acronym>.
</p>
<div class="float"><a name="fig_003apkcs11_002dvision"></a>
<img src="pkcs11-vision.png" alt="pkcs11-vision">
<div class="float-caption"><p><strong>Figure 5.1: </strong>PKCS #11 module usage.</p></div></div>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#PKCS11-Initialization" accesskey="1">PKCS11 Initialization</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Accessing-objects-that-require-a-PIN" accesskey="2">Accessing objects that require a PIN</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Reading-objects" accesskey="3">Reading objects</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Writing-objects" accesskey="4">Writing objects</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Using-a-PKCS11-token-with-TLS" accesskey="5">Using a PKCS11 token with TLS</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#p11tool-Invocation" accesskey="6">p11tool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking p11tool
</td></tr>
</table>
<hr>
<a name="PKCS11-Initialization"></a>
<div class="header">
<p>
Next: <a href="#Accessing-objects-that-require-a-PIN" accesskey="n" rel="next">Accessing objects that require a PIN</a>, Up: <a href="#Smart-cards-and-HSMs" accesskey="u" rel="up">Smart cards and HSMs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Initialization-1"></a>
<h4 class="subsection">5.2.1 Initialization</h4>
<p>To allow all the <acronym>GnuTLS</acronym> applications to access <acronym>PKCS</acronym> #11 tokens
you can use a configuration per module, stored in <code>/etc/pkcs11/modules/</code>.
These are the configuration files of <acronym>p11-kit</acronym><a name="DOCF10" href="#FOOT10"><sup>10</sup></a>.
For example a file that will load the <acronym>OpenSC</acronym> module, could be named
<code>/etc/pkcs11/modules/opensc</code> and contain the following:
</p>
<div class="example">
<pre class="example">module: /usr/lib/opensc-pkcs11.so
</pre></div>
<p>If you use this file, then there is no need for other initialization in
<acronym>GnuTLS</acronym>, except for the PIN and token functions (see next section).
However, you may manually initialize the PKCS #11 subsystem if the default
settings are not desirable.
</p>
<dl>
<dt><a name="index-gnutls_005fpkcs11_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_init</strong> <em>(unsigned int <var>flags</var>, const char * <var>deprecated_config_file</var>)</em></dt>
<dd><p><var>flags</var>: <code>GNUTLS_PKCS11_FLAG_MANUAL</code> or <code>GNUTLS_PKCS11_FLAG_AUTO</code>
</p>
<p><var>deprecated_config_file</var>: either NULL or the location of a deprecated
configuration file
</p>
<p>This function will initialize the PKCS 11 subsystem in gnutls. It will
read configuration files if <code>GNUTLS_PKCS11_FLAG_AUTO</code> is used or allow
you to independently load PKCS 11 modules using <code>gnutls_pkcs11_add_provider()</code>
if <code>GNUTLS_PKCS11_FLAG_MANUAL</code> is specified.
</p>
<p>Normally you don’t need to call this function since it is being called
by <code>gnutls_global_init()</code> using the <code>GNUTLS_PKCS11_FLAG_AUTO</code> . If other option
is required then it must be called before it.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<p>Note that PKCS #11 modules must be reinitialized on the child processes
after a <code>fork</code>. <acronym>GnuTLS</acronym> provides <a href="#gnutls_005fpkcs11_005freinit">gnutls_pkcs11_reinit</a>
to be called for this purpose.
</p>
<dl>
<dt><a name="index-gnutls_005fpkcs11_005freinit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_reinit</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function will reinitialize the PKCS 11 subsystem in gnutls.
This is required by PKCS 11 when an application uses <code>fork()</code> . The
reinitialization function must be called on the child.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<hr>
<a name="Accessing-objects-that-require-a-PIN"></a>
<div class="header">
<p>
Next: <a href="#Reading-objects" accesskey="n" rel="next">Reading objects</a>, Previous: <a href="#PKCS11-Initialization" accesskey="p" rel="previous">PKCS11 Initialization</a>, Up: <a href="#Smart-cards-and-HSMs" accesskey="u" rel="up">Smart cards and HSMs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Accessing-objects-that-require-a-PIN-1"></a>
<h4 class="subsection">5.2.2 Accessing objects that require a PIN</h4>
<p>Objects stored in token such as a private keys are typically protected
from access by a PIN or password. This PIN may be required to either read
the object (if allowed) or to perform operations with it. To allow obtaining
the PIN when accessing a protected object, as well as probe
the user to insert the token the following functions allow to set a callback.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fpkcs11_005fset_005ftoken_005ffunction">gnutls_pkcs11_set_token_function</a> (gnutls_pkcs11_token_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fpkcs11_005fset_005fpin_005ffunction">gnutls_pkcs11_set_pin_function</a> (gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005fadd_005fprovider">gnutls_pkcs11_add_provider</a> (const char * <var>name</var>, const char * <var>params</var>)</code></dt>
<dt><code><var>gnutls_pin_callback_t</var> <a href="#gnutls_005fpkcs11_005fget_005fpin_005ffunction">gnutls_pkcs11_get_pin_function</a> (void ** <var>userdata</var>)</code></dt>
</dl>
<p>The callback is of type <code>gnutls_pin_callback_t</code> and will have as
input the provided userdata, the PIN attempt number, a URL describing the
token, a label describing the object and flags. The PIN must be at most
of <code>pin_max</code> size and must be copied to pin variable. The function must
return 0 on success or a negative error code otherwise.
</p>
<pre class="verbatim">typedef int (*gnutls_pin_callback_t) (void *userdata, int attempt,
const char *token_url,
const char *token_label,
unsigned int flags,
char *pin, size_t pin_max);
</pre>
<p>The flags are of <code>gnutls_pin_flag_t</code> type and are explained below.
</p>
<div class="float"><a name="gnutls_005fpin_005fflag_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_PIN_USER</code></dt>
<dd><p>The PIN for the user.
</p></dd>
<dt><code>GNUTLS_PIN_SO</code></dt>
<dd><p>The PIN for the security officer (admin).
</p></dd>
<dt><code>GNUTLS_PIN_FINAL_TRY</code></dt>
<dd><p>This is the final try before blocking.
</p></dd>
<dt><code>GNUTLS_PIN_COUNT_LOW</code></dt>
<dd><p>Few tries remain before token blocks.
</p></dd>
<dt><code>GNUTLS_PIN_CONTEXT_SPECIFIC</code></dt>
<dd><p>The PIN is for a specific action and key like signing.
</p></dd>
<dt><code>GNUTLS_PIN_WRONG</code></dt>
<dd><p>Last given PIN was not correct.
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 5.2: </strong>The <code>gnutls_pin_flag_t</code> enumeration.</p></div></div>
<p>Note that due to limitations of <acronym>PKCS</acronym> #11 there are issues when multiple libraries
are sharing a module. To avoid this problem GnuTLS uses <acronym>p11-kit</acronym>
that provides a middleware to control access to resources over the
multiple users.
</p>
<p>To avoid conflicts with multiple registered callbacks for PIN functions,
<a href="#gnutls_005fpkcs11_005fget_005fpin_005ffunction">gnutls_pkcs11_get_pin_function</a> may be used to check for any previously
set functions. In addition context specific PIN functions are allowed, e.g., by
using functions below.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005fset_005fpin_005ffunction">gnutls_certificate_set_pin_function</a> (gnutls_certificate_credentials_t <var>cred</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fpubkey_005fset_005fpin_005ffunction">gnutls_pubkey_set_pin_function</a> (gnutls_pubkey_t <var>key</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fprivkey_005fset_005fpin_005ffunction">gnutls_privkey_set_pin_function</a> (gnutls_privkey_t <var>key</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction">gnutls_pkcs11_obj_set_pin_function</a> (gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fx509_005fcrt_005fset_005fpin_005ffunction">gnutls_x509_crt_set_pin_function</a> (gnutls_x509_crt_t <var>crt</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</code></dt>
</dl>
<hr>
<a name="Reading-objects"></a>
<div class="header">
<p>
Next: <a href="#Writing-objects" accesskey="n" rel="next">Writing objects</a>, Previous: <a href="#Accessing-objects-that-require-a-PIN" accesskey="p" rel="previous">Accessing objects that require a PIN</a>, Up: <a href="#Smart-cards-and-HSMs" accesskey="u" rel="up">Smart cards and HSMs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Reading-objects-1"></a>
<h4 class="subsection">5.2.3 Reading objects</h4>
<p>All <acronym>PKCS</acronym> #11 objects are referenced by <acronym>GnuTLS</acronym> functions by
URLs as described in [<em>PKCS11URI</em>].
This allows for a consistent naming of objects across systems and applications
in the same system. For example a public
key on a smart card may be referenced as:
</p>
<div class="example">
<pre class="example">pkcs11:token=Nikos;serial=307521161601031;model=PKCS%2315; \
manufacturer=EnterSafe;object=test1;objecttype=public;\
id=32f153f3e37990b08624141077ca5dec2d15faed
</pre></div>
<p>while the smart card itself can be referenced as:
</p><div class="example">
<pre class="example">pkcs11:token=Nikos;serial=307521161601031;model=PKCS%2315;manufacturer=EnterSafe
</pre></div>
<p>Objects stored in a <acronym>PKCS</acronym> #11 token can be extracted
if they are not marked as sensitive. Usually only private keys are marked as
sensitive and cannot be extracted, while certificates and other data can
be retrieved. The functions that can be used to access objects
are shown below.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005fobj_005fimport_005furl">gnutls_pkcs11_obj_import_url</a> (gnutls_pkcs11_obj_t <var>obj</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005fobj_005fexport_005furl">gnutls_pkcs11_obj_export_url</a> (gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_get_info</strong> <em>(gnutls_pkcs11_obj_t <var>crt</var>, gnutls_pkcs11_obj_info_t <var>itype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>crt</var>: should contain a <code>gnutls_pkcs11_obj_t</code> structure
</p>
<p><var>itype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS11 certificate
such as the label, id as well as token information where the key is
stored. When output is text it returns null terminated string
although <code>output_size</code> contains the size of the actual data only.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fimport_005fpkcs11">gnutls_x509_crt_import_pkcs11</a> (gnutls_x509_crt_t <var>crt</var>, gnutls_pkcs11_obj_t <var>pkcs11_crt</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005fimport_005fpkcs11_005furl">gnutls_x509_crt_import_pkcs11_url</a> (gnutls_x509_crt_t <var>crt</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11">gnutls_x509_crt_list_import_pkcs11</a> (gnutls_x509_crt_t * <var>certs</var>, unsigned int <var>cert_max</var>, gnutls_pkcs11_obj_t * const <var>objs</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<p>Properties of the physical token can also be accessed and altered with <acronym>GnuTLS</acronym>.
For example data in a token can be erased (initialized), PIN can be altered, etc.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005ftoken_005finit">gnutls_pkcs11_token_init</a> (const char * <var>token_url</var>, const char * <var>so_pin</var>, const char * <var>label</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005ftoken_005fget_005furl">gnutls_pkcs11_token_get_url</a> (unsigned int <var>seq</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005ftoken_005fget_005finfo">gnutls_pkcs11_token_get_info</a> (const char * <var>url</var>, gnutls_pkcs11_token_info_t <var>ttype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005ftoken_005fget_005fflags">gnutls_pkcs11_token_get_flags</a> (const char * <var>url</var>, unsigned int * <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpkcs11_005ftoken_005fset_005fpin">gnutls_pkcs11_token_set_pin</a> (const char * <var>token_url</var>, const char * <var>oldpin</var>, const char * <var>newpin</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<p>The following examples demonstrate the usage of the API. The first example
will list all available PKCS #11 tokens in a system and the latter will
list all certificates in a token that have a corresponding private key.
</p>
<div class="example">
<pre class="example">int i;
char* url;
gnutls_global_init();
for (i=0;;i++)
{
ret = gnutls_pkcs11_token_get_url(i, &url);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
if (ret < 0)
exit(1);
fprintf(stdout, "Token[%d]: URL: %s\n", i, url);
gnutls_free(url);
}
gnutls_global_deinit();
</pre></div>
<pre class="verbatim">/* This example code is placed in the public domain. */
#include <config.h>
#include <gnutls/gnutls.h>
#include <gnutls/pkcs11.h>
#include <stdio.h>
#include <stdlib.h>
#define URL "pkcs11:URL"
int
main (int argc, char** argv)
{
gnutls_pkcs11_obj_t *obj_list;
gnutls_x509_crt_t xcrt;
unsigned int obj_list_size = 0;
gnutls_datum_t cinfo;
int ret;
unsigned int i;
obj_list_size = 0;
ret = gnutls_pkcs11_obj_list_import_url (NULL, &obj_list_size, URL,
GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY,
0);
if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
return -1;
/* no error checking from now on */
obj_list = malloc (sizeof (*obj_list) * obj_list_size);
gnutls_pkcs11_obj_list_import_url (obj_list, &obj_list_size, URL,
GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY,
0);
/* now all certificates are in obj_list */
for (i = 0; i < obj_list_size; i++)
{
gnutls_x509_crt_init (&xcrt);
gnutls_x509_crt_import_pkcs11 (xcrt, obj_list[i]);
gnutls_x509_crt_print (xcrt, GNUTLS_CRT_PRINT_FULL, &cinfo);
fprintf (stdout, "cert[%d]:\n %s\n\n", i, cinfo.data);
gnutls_free (cinfo.data);
gnutls_x509_crt_deinit (xcrt);
}
return 0;
}
</pre>
<hr>
<a name="Writing-objects"></a>
<div class="header">
<p>
Next: <a href="#Using-a-PKCS11-token-with-TLS" accesskey="n" rel="next">Using a PKCS11 token with TLS</a>, Previous: <a href="#Reading-objects" accesskey="p" rel="previous">Reading objects</a>, Up: <a href="#Smart-cards-and-HSMs" accesskey="u" rel="up">Smart cards and HSMs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Writing-objects-1"></a>
<h4 class="subsection">5.2.4 Writing objects</h4>
<p>With <acronym>GnuTLS</acronym> you can copy existing private keys and certificates
to a token. Note that when copying private keys it is recommended to mark
them as sensitive using the <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code>
to prevent its extraction. An object can be marked as private using the flag
<code>GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE</code>, to require PIN to be
entered before accessing the object (for operations or otherwise).
</p>
<dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_privkey</strong> <em>(const char * <var>token_url</var>, gnutls_x509_privkey_t <var>key</var>, const char * <var>label</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>key</var>: A private key
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will copy a private key into a PKCS <code>11</code> token specified by
a URL. It is highly recommended flags to contain <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code>
unless there is a strong reason not to.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_crt</strong> <em>(const char * <var>token_url</var>, gnutls_x509_crt_t <var>crt</var>, const char * <var>label</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>crt</var>: A certificate
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a certificate into a PKCS <code>11</code> token specified by
a URL. The certificate can be marked as trusted or not.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fpkcs11_005fdelete_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_delete_url</strong> <em>(const char * <var>object_url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>object_url</var>: The URL of the object to delete.
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will delete objects matching the given URL.
Note that not all tokens support the delete operation.
</p>
<p><strong>Returns:</strong> On success, the number of objects deleted is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<hr>
<a name="Using-a-PKCS11-token-with-TLS"></a>
<div class="header">
<p>
Next: <a href="#p11tool-Invocation" accesskey="n" rel="next">p11tool Invocation</a>, Previous: <a href="#Writing-objects" accesskey="p" rel="previous">Writing objects</a>, Up: <a href="#Smart-cards-and-HSMs" accesskey="u" rel="up">Smart cards and HSMs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Using-a-PKCS-_002311-token-with-TLS"></a>
<h4 class="subsection">5.2.5 Using a <acronym>PKCS</acronym> #11 token with TLS</h4>
<p>It is possible to use a <acronym>PKCS</acronym> #11 token to a TLS
session, as shown in <a href="#ex_003apkcs11_002dclient">ex:pkcs11-client</a>. In addition
the following functions can be used to load PKCS #11 key and
certificates by specifying a PKCS #11 URL instead of a filename.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile">gnutls_certificate_set_x509_trust_file</a> (gnutls_certificate_credentials_t <var>cred</var>, const char * <var>cafile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile">gnutls_certificate_set_x509_key_file</a> (gnutls_certificate_credentials_t <var>res</var>, const char * <var>certfile</var>, const char * <var>keyfile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_system_trust</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p>This function adds the system’s default trusted CAs in order to
verify client or server certificates.
</p>
<p>In the case the system is currently unsupported <code>GNUTLS_E_UNIMPLEMENTED_FEATURE</code>
is returned.
</p>
<p><strong>Returns:</strong> the number of certificates processed or a negative error code
on error.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<hr>
<a name="p11tool-Invocation"></a>
<div class="header">
<p>
Previous: <a href="#Using-a-PKCS11-token-with-TLS" accesskey="p" rel="previous">Using a PKCS11 token with TLS</a>, Up: <a href="#Smart-cards-and-HSMs" accesskey="u" rel="up">Smart cards and HSMs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-p11tool"></a>
<h4 class="subsection">5.2.6 Invoking p11tool</h4>
<a name="index-p11tool"></a>
<p>Program that allows handling data from PKCS #11 smart cards
and security modules.
</p>
<p>To use PKCS #11 tokens with gnutls the configuration file
/etc/gnutls/pkcs11.conf has to exist and contain a number of lines of the form ’load=/usr/lib/opensc-pkcs11.so’.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>p11tool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="p11tool-usage"></a><a name="p11tool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">p11tool help/usage (-h)</h4>
<a name="index-p11tool-help"></a>
<p>This is the automatically generated usage text for p11tool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">p11tool - GnuTLS PKCS #11 tool - Ver. 3.1.7
USAGE: p11tool [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [url]
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
--outfile=str Output file
--list-tokens List all available tokens
--export Export the object specified by the URL
--list-mechanisms List all available mechanisms in a token
--list-all List all available objects in a token
--list-all-certs List all available certificates in a token
--list-certs List all certificates that have an associated private key
--list-all-privkeys List all available private keys in a token
--list-all-trusted List all available certificates marked as trusted
--initialize Initializes a PKCS #11 token
--write Writes the loaded objects to a PKCS #11 token
--delete Deletes the objects matching the PKCS #11 URL
--generate-rsa Generate an RSA private-public key pair
--generate-dsa Generate an RSA private-public key pair
--generate-ecc Generate an RSA private-public key pair
--label=str Sets a label for the write operation
--trusted Marks the object to be written as trusted
- disabled as --no-trusted
--private Marks the object to be written as private
- disabled as --no-private
- enabled by default
--login Force login to token
- disabled as --no-login
--detailed-url Print detailed URLs
- disabled as --no-detailed-url
--secret-key=str Provide a hex encoded secret key
--load-privkey=file Private key file to use
- file must pre-exist
--load-pubkey=file Public key file to use
- file must pre-exist
--load-certificate=file Certificate file to use
- file must pre-exist
-8, --pkcs8 Use PKCS #8 format for private keys
--bits=num Specify the number of bits for key generate
--sec-param=str Specify the security level
--inder Use DER/RAW format for input
- disabled as --no-inder
--inraw This is an alias for 'inder'
--provider=file Specify the PKCS #11 provider library
- file must pre-exist
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Operands and options may be intermixed. They will be reordered.
Program that allows handling data from PKCS #11 smart cards and security
modules.
To use PKCS #11 tokens with gnutls the configuration file
/etc/gnutls/pkcs11.conf has to exist and contain a number of lines of the
form 'load=/usr/lib/opensc-pkcs11.so'.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="p11tool-debug"></a><a name="debug-option-_0028_002dd_0029-5"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="p11tool-write"></a></p><a name="write-option"></a>
<h4 class="subsubheading">write option</h4>
<p>This is the “writes the loaded objects to a pkcs #11 token” option.
It can be used to write private keys, certificates or secret keys to a token.
<a name="p11tool-generate_002drsa"></a></p><a name="generate_002drsa-option"></a>
<h4 class="subsubheading">generate-rsa option</h4>
<p>This is the “generate an rsa private-public key pair” option.
Generates an RSA private-public key pair on the specified token.
<a name="p11tool-generate_002ddsa"></a></p><a name="generate_002ddsa-option"></a>
<h4 class="subsubheading">generate-dsa option</h4>
<p>This is the “generate an rsa private-public key pair” option.
Generates an RSA private-public key pair on the specified token.
<a name="p11tool-generate_002decc"></a></p><a name="generate_002decc-option"></a>
<h4 class="subsubheading">generate-ecc option</h4>
<p>This is the “generate an rsa private-public key pair” option.
Generates an RSA private-public key pair on the specified token.
<a name="p11tool-private"></a></p><a name="private-option"></a>
<h4 class="subsubheading">private option</h4>
<p>This is the “marks the object to be written as private” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> is enabled by default.
</li></ul>
<p>The written object will require a PIN to be used.
<a name="p11tool-sec_002dparam"></a></p><a name="sec_002dparam-option-1"></a>
<h4 class="subsubheading">sec-param option</h4>
<p>This is the “specify the security level” option.
This option takes an argument string <samp>Security parameter</samp>.
This is alternative to the bits option. Available options are [low, legacy, normal, high, ultra].
<a name="p11tool-inder"></a></p><a name="inder-option-2"></a>
<h4 class="subsubheading">inder option</h4>
<p>This is the “use der/raw format for input” option.
Use DER/RAW format for input certificates and private keys.
<a name="p11tool-inraw"></a></p><a name="inraw-option-2"></a>
<h4 class="subsubheading">inraw option</h4>
<p>This is an alias for the inder option,
see <a href="#p11tool-inder">the inder option documentation</a>.
</p>
<a name="p11tool-provider"></a><a name="provider-option"></a>
<h4 class="subsubheading">provider option</h4>
<p>This is the “specify the pkcs #11 provider library” option.
This option takes an argument file.
This will override the default options in /etc/gnutls/pkcs11.conf
<a name="p11tool-exit-status"></a></p><a name="p11tool-exit-status-1"></a>
<h4 class="subsubheading">p11tool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="p11tool-See-Also"></a><a name="p11tool-See-Also-1"></a>
<h4 class="subsubheading">p11tool See Also</h4>
<p>certtool (1)
</p>
<a name="p11tool-Examples"></a><a name="p11tool-Examples-1"></a>
<h4 class="subsubheading">p11tool Examples</h4>
<p>To view all tokens in your system use:
</p><div class="example">
<pre class="example">$ p11tool --list-tokens
</pre></div>
<p>To view all objects in a token use:
</p><div class="example">
<pre class="example">$ p11tool --login --list-all "pkcs11:TOKEN-URL"
</pre></div>
<p>To store a private key and a certificate in a token run:
</p><div class="example">
<pre class="example">$ p11tool --login --write "pkcs11:URL" --load-privkey key.pem \
--label "Mykey"
$ p11tool --login --write "pkcs11:URL" --load-certificate cert.pem \
--label "Mykey"
</pre></div>
<p>Note that some tokens require the same label to be used for the certificate
and its corresponding private key.
</p>
<p>To generate an RSA private key inside the token use:
</p><div class="example">
<pre class="example">$ p11tool --login --generate-rsa --bits 1024 --label "MyNewKey" \
--outfile MyNewKey.pub "pkcs11:TOKEN-URL"
</pre></div>
<p>The bits parameter in the above example is explicitly set because some
tokens only support a limited number of bits. The output file is the
corresponding public key. This key can be used to general a certificate
request with certtool.
</p><div class="example">
<pre class="example">certtool --generate-request --load-privkey "pkcs11:KEY-URL" \
--load-pubkey MyNewKey.pub --outfile request.pem
</pre></div>
<hr>
<a name="Trusted-Platform-Module"></a>
<div class="header">
<p>
Previous: <a href="#Smart-cards-and-HSMs" accesskey="p" rel="previous">Smart cards and HSMs</a>, Up: <a href="#Hardware-security-modules-and-abstract-key-types" accesskey="u" rel="up">Hardware security modules and abstract key types</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Trusted-Platform-Module-_0028TPM_0029"></a>
<h3 class="section">5.3 Trusted Platform Module (TPM)</h3>
<a name="index-trusted-platform-module"></a>
<a name="index-TPM"></a>
<p>In this section we present the Trusted Platform Module (TPM) support
in <acronym>GnuTLS</acronym>. Note that this functionality is disabled by default
because the <code>trousers</code> libraries GnuTLS depends on for that functionality
are under the Common Public License which is not compatible with the GPL license.
</p>
<p>There was a big hype when the TPM chip was introduced into
computers. Briefly it is a co-processor in your PC that allows it to perform
calculations independently of the main processor. This has good and bad
side-effects. In this section we focus on the good ones, which are the fact that
you can use it to perform cryptographic operations the similarly to a
<acronym>PKCS</acronym> #11 smart card.
It allows for storing and using RSA keys but with slight differences
from a <acronym>PKCS</acronym> #11 module that require different handling.
The basic operations supported, and used by GnuTLS, are key generation and signing.
</p>
<p>In GnuTLS the TPM functionality is available in <code>gnutls/tpm.h</code>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Keys-in-TPM" accesskey="1">Keys in TPM</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Key-generation" accesskey="2">Key generation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Using-keys" accesskey="3">Using keys</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#tpmtool-Invocation" accesskey="4">tpmtool Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking tpmtool
</td></tr>
</table>
<hr>
<a name="Keys-in-TPM"></a>
<div class="header">
<p>
Next: <a href="#Key-generation" accesskey="n" rel="next">Key generation</a>, Up: <a href="#Trusted-Platform-Module" accesskey="u" rel="up">Trusted Platform Module</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Keys-in-TPM-1"></a>
<h4 class="subsection">5.3.1 Keys in TPM</h4>
<p>The RSA keys in the TPM module may either be stored in a flash memory
within TPM or stored in a file in disk. In the former case the key can
provide operations as with <acronym>PKCS</acronym> #11 and is identified by
a URL. The URL is of the following form.
</p><pre class="verbatim">tpmkey:uuid=42309df8-d101-11e1-a89a-97bb33c23ad1;storage=user
</pre>
<p>It consists from a unique identifier of the key as well as the part of the
flash memory the key is stored at. The two options for the storage field are
‘user’ and ‘system’. The user keys are typically only available to the generating
user and the system keys to all users. The stored in TPM keys are called
registered keys.
</p>
<p>The keys that are stored in the disk are exported from the TPM but in an
encrypted form. To access them two passwords are required. The first is the TPM
Storage Root Key (SRK), and the other is a key-specific password. Also those keys are
identified by a URL of the form:
</p><pre class="verbatim">tpmkey:file=/path/to/file
</pre>
<p>When objects require a PIN to be accessed the same callbacks as with PKCS #11
objects are expected (see <a href="#Accessing-objects-that-require-a-PIN">Accessing objects that require a PIN</a>).
</p>
<hr>
<a name="Key-generation"></a>
<div class="header">
<p>
Next: <a href="#Using-keys" accesskey="n" rel="next">Using keys</a>, Previous: <a href="#Keys-in-TPM" accesskey="p" rel="previous">Keys in TPM</a>, Up: <a href="#Trusted-Platform-Module" accesskey="u" rel="up">Trusted Platform Module</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Key-generation-1"></a>
<h4 class="subsection">5.3.2 Key generation</h4>
<p>All keys used by the TPM must be generated by the TPM. This can be
done using <a href="#gnutls_005ftpm_005fprivkey_005fgenerate">gnutls_tpm_privkey_generate</a>.
</p>
<dl>
<dt><a name="index-gnutls_005ftpm_005fprivkey_005fgenerate"></a>Function: <em>int</em> <strong>gnutls_tpm_privkey_generate</strong> <em>(gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char* <var>srk_password</var>, const char* <var>key_password</var>, gnutls_tpmkey_fmt_t <var>format</var>, gnutls_x509_crt_fmt_t <var>pub_format</var>, gnutls_datum_t* <var>privkey</var>, gnutls_datum_t* <var>pubkey</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>srk_password</var>: a password to protect the exported key (optional)
</p>
<p><var>key_password</var>: the password for the TPM (optional)
</p>
<p><var>format</var>: the format of the private key
</p>
<p><var>pub_format</var>: the format of the public key
</p>
<p><var>privkey</var>: the generated key
</p>
<p><var>pubkey</var>: the corresponding public key (may be null)
</p>
<p><var>flags</var>: should be a list of GNUTLS_TPM_* flags
</p>
<p>This function will generate a private key in the TPM
chip. The private key will be generated within the chip
and will be exported in a wrapped with TPM’s master key
form. Furthermore the wrapped key can be protected with
the provided <code>password</code> .
</p>
<p>Note that bits in TPM is quantized value. If the input value
is not one of the allowed values, then it will be quantized to
one of 512, 1024, 2048, 4096, 8192 and 16384.
</p>
<p>Allowed flags are:
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005ftpm_005fget_005fregistered">gnutls_tpm_get_registered</a> (gnutls_tpm_key_list_t * <var>list</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftpm_005fkey_005flist_005fdeinit">gnutls_tpm_key_list_deinit</a> (gnutls_tpm_key_list_t <var>list</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005ftpm_005fkey_005flist_005fget_005furl">gnutls_tpm_key_list_get_url</a> (gnutls_tpm_key_list_t <var>list</var>, unsigned int <var>idx</var>, char** <var>url</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005ftpm_005fprivkey_005fdelete"></a>Function: <em>int</em> <strong>gnutls_tpm_privkey_delete</strong> <em>(const char* <var>url</var>, const char* <var>srk_password</var>)</em></dt>
<dd><p><var>url</var>: the URL describing the key
</p>
<p><var>srk_password</var>: a password for the SRK key
</p>
<p>This function will unregister the private key from the TPM
chip.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<hr>
<a name="Using-keys"></a>
<div class="header">
<p>
Next: <a href="#tpmtool-Invocation" accesskey="n" rel="next">tpmtool Invocation</a>, Previous: <a href="#Key-generation" accesskey="p" rel="previous">Key generation</a>, Up: <a href="#Trusted-Platform-Module" accesskey="u" rel="up">Trusted Platform Module</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Using-keys-1"></a>
<h4 class="subsection">5.3.3 Using keys</h4>
<a name="Importing-keys"></a>
<h4 class="subsubheading">Importing keys</h4>
<p>The TPM keys can be used directly by the abstract key types and do not require
any special structures. Moreover functions like <a href="#gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile">gnutls_certificate_set_x509_key_file</a>
can access TPM URLs.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fprivkey_005fimport_005ftpm_005fraw">gnutls_privkey_import_tpm_raw</a> (gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>fdata</var>, gnutls_tpmkey_fmt_t <var>format</var>, const char * <var>srk_password</var>, const char * <var>key_password</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpubkey_005fimport_005ftpm_005fraw">gnutls_pubkey_import_tpm_raw</a> (gnutls_pubkey_t <var>pkey</var>, const gnutls_datum_t * <var>fdata</var>, gnutls_tpmkey_fmt_t <var>format</var>, const char * <var>srk_password</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005ftpm_005furl"></a>Function: <em>int</em> <strong>gnutls_privkey_import_tpm_url</strong> <em>(gnutls_privkey_t <var>pkey</var>, const char* <var>url</var>, const char * <var>srk_password</var>, const char * <var>key_password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>url</var>: The URL of the TPM key to be imported
</p>
<p><var>srk_password</var>: The password for the SRK key (optional)
</p>
<p><var>key_password</var>: A password for the key (optional)
</p>
<p><var>flags</var>: One of the GNUTLS_PRIVKEY_* flags
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>Note that unless <code>GNUTLS_PRIVKEY_DISABLE_CALLBACKS</code>
is specified, if incorrect (or NULL) passwords are given
the PKCS11 callback functions will be used to obtain the
correct passwords. Otherwise if the SRK password is wrong
<code>GNUTLS_E_TPM_SRK_PASSWORD_ERROR</code> is returned and if the key password
is wrong or not provided then <code>GNUTLS_E_TPM_KEY_PASSWORD_ERROR</code>
is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005ftpm_005furl"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_tpm_url</strong> <em>(gnutls_pubkey_t <var>pkey</var>, const char* <var>url</var>, const char * <var>srk_password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The public key
</p>
<p><var>url</var>: The URL of the TPM key to be imported
</p>
<p><var>srk_password</var>: The password for the SRK key (optional)
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>Note that unless <code>GNUTLS_PUBKEY_DISABLE_CALLBACKS</code>
is specified, if incorrect (or NULL) passwords are given
the PKCS11 callback functions will be used to obtain the
correct passwords. Otherwise if the SRK password is wrong
<code>GNUTLS_E_TPM_SRK_PASSWORD_ERROR</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="Listing-and-deleting-keys"></a>
<h4 class="subsubheading">Listing and deleting keys</h4>
<p>The registered keys (that are stored in the TPM) can be listed using one of
the following functions. Those keys are unfortunately only identified by
their UUID and have no label or other human friendly identifier.
Keys can be deleted from permament storage using <a href="#gnutls_005ftpm_005fprivkey_005fdelete">gnutls_tpm_privkey_delete</a>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005ftpm_005fget_005fregistered">gnutls_tpm_get_registered</a> (gnutls_tpm_key_list_t * <var>list</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftpm_005fkey_005flist_005fdeinit">gnutls_tpm_key_list_deinit</a> (gnutls_tpm_key_list_t <var>list</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005ftpm_005fkey_005flist_005fget_005furl">gnutls_tpm_key_list_get_url</a> (gnutls_tpm_key_list_t <var>list</var>, unsigned int <var>idx</var>, char** <var>url</var>, unsigned int <var>flags</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005ftpm_005fprivkey_005fdelete-1"></a>Function: <em>int</em> <strong>gnutls_tpm_privkey_delete</strong> <em>(const char* <var>url</var>, const char* <var>srk_password</var>)</em></dt>
<dd><p><var>url</var>: the URL describing the key
</p>
<p><var>srk_password</var>: a password for the SRK key
</p>
<p>This function will unregister the private key from the TPM
chip.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<hr>
<a name="tpmtool-Invocation"></a>
<div class="header">
<p>
Previous: <a href="#Using-keys" accesskey="p" rel="previous">Using keys</a>, Up: <a href="#Trusted-Platform-Module" accesskey="u" rel="up">Trusted Platform Module</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-tpmtool"></a>
<h4 class="subsection">5.3.4 Invoking tpmtool</h4>
<a name="index-tpmtool"></a>
<p>Program that allows handling cryptographic data from the TPM chip.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>tpmtool</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="tpmtool-usage"></a><a name="tpmtool-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subsubheading">tpmtool help/usage (-h)</h4>
<a name="index-tpmtool-help"></a>
<p>This is the automatically generated usage text for tpmtool.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">tpmtool - GnuTLS TPM tool - Ver. 3.1.7
USAGE: tpmtool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
--infile=file Input file
- file must pre-exist
--outfile=str Output file
--generate-rsa Generate an RSA private-public key pair
--register Any generated key will be registered in the TPM
- requires these options:
generate-rsa
--signing Any generated key will be a signing key
- requires these options:
generate-rsa
-- and prohibits these options:
legacy
--legacy Any generated key will be a legacy key
- requires these options:
generate-rsa
-- and prohibits these options:
signing
--user Any registered key will be a user key
- requires these options:
register
-- and prohibits these options:
system
--system Any registred key will be a system key
- requires these options:
register
-- and prohibits these options:
user
--pubkey=str Prints the public key of the provided key
--list Lists all stored keys in the TPM
--delete=str Delete the key identified by the given URL (UUID).
--sec-param=str Specify the security level [low, legacy, normal, high, ultra].
--bits=num Specify the number of bits for key generate
--inder Use the DER format for keys.
- disabled as --no-inder
--outder Use DER format for output keys
- disabled as --no-outder
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Program that allows handling cryptographic data from the TPM chip.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="tpmtool-debug"></a><a name="debug-option-_0028_002dd_0029-6"></a>
<h4 class="subsubheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="tpmtool-generate_002drsa"></a></p><a name="generate_002drsa-option-1"></a>
<h4 class="subsubheading">generate-rsa option</h4>
<p>This is the “generate an rsa private-public key pair” option.
Generates an RSA private-public key pair in the TPM chip.
The key may be stored in filesystem and protected by a PIN, or stored (registered)
in the TPM chip flash.
<a name="tpmtool-user"></a></p><a name="user-option"></a>
<h4 class="subsubheading">user option</h4>
<p>This is the “any registered key will be a user key” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
register.
</li><li> must not appear in combination with any of the following options:
system.
</li></ul>
<p>The generated key will be stored in a user specific persistent storage.
<a name="tpmtool-system"></a></p><a name="system-option"></a>
<h4 class="subsubheading">system option</h4>
<p>This is the “any registred key will be a system key” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> must appear in combination with the following options:
register.
</li><li> must not appear in combination with any of the following options:
user.
</li></ul>
<p>The generated key will be stored in system persistent storage.
<a name="tpmtool-sec_002dparam"></a></p><a name="sec_002dparam-option-2"></a>
<h4 class="subsubheading">sec-param option</h4>
<p>This is the “specify the security level [low, legacy, normal, high, ultra].” option.
This option takes an argument string <samp>Security parameter</samp>.
This is alternative to the bits option. Note however that the
values allowed by the TPM chip are quantized and given values may be rounded up.
<a name="tpmtool-inder"></a></p><a name="inder-option-3"></a>
<h4 class="subsubheading">inder option</h4>
<p>This is the “use the der format for keys.” option.
The input files will be assumed to be in the portable
DER format of TPM. The default format is a custom format used by various
TPM tools
<a name="tpmtool-outder"></a></p><a name="outder-option-1"></a>
<h4 class="subsubheading">outder option</h4>
<p>This is the “use der format for output keys” option.
The output will be in the TPM portable DER format.
<a name="tpmtool-exit-status"></a></p><a name="tpmtool-exit-status-1"></a>
<h4 class="subsubheading">tpmtool exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="tpmtool-See-Also"></a><a name="tpmtool-See-Also-1"></a>
<h4 class="subsubheading">tpmtool See Also</h4>
<p>p11tool (1), certtool (1)
</p>
<a name="tpmtool-Examples"></a><a name="tpmtool-Examples-1"></a>
<h4 class="subsubheading">tpmtool Examples</h4>
<p>To generate a key that is to be stored in filesystem use:
</p><div class="example">
<pre class="example">$ tpmtool --generate-rsa --bits 2048 --outfile tpmkey.pem
</pre></div>
<p>To generate a key that is to be stored in TPM’s flash use:
</p><div class="example">
<pre class="example">$ tpmtool --generate-rsa --bits 2048 --register --user
</pre></div>
<p>To get the public key of a TPM key use:
</p><div class="example">
<pre class="example">$ tpmtool --pubkey tpmkey:uuid=58ad734b-bde6-45c7-89d8-756a55ad1891;storage=user \
--outfile pubkey.pem
</pre></div>
<p>or if the key is stored in the filesystem:
</p><div class="example">
<pre class="example">$ tpmtool --pubkey tpmkey:file=tmpkey.pem --outfile pubkey.pem
</pre></div>
<p>To list all keys stored in TPM use:
</p><div class="example">
<pre class="example">$ tpmtool --list
</pre></div>
<hr>
<a name="How-to-use-GnuTLS-in-applications"></a>
<div class="header">
<p>
Next: <a href="#GnuTLS-application-examples" accesskey="n" rel="next">GnuTLS application examples</a>, Previous: <a href="#Hardware-security-modules-and-abstract-key-types" accesskey="p" rel="previous">Hardware security modules and abstract key types</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="How-to-use-GnuTLS-in-applications-1"></a>
<h2 class="chapter">6 How to use <acronym>GnuTLS</acronym> in applications</h2>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Introduction-to-the-library" accesskey="1">Introduction to the library</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Preparation" accesskey="2">Preparation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Session-initialization" accesskey="3">Session initialization</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Associating-the-credentials" accesskey="4">Associating the credentials</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Setting-up-the-transport-layer" accesskey="5">Setting up the transport layer</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#TLS-handshake" accesskey="6">TLS handshake</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Data-transfer-and-termination" accesskey="7">Data transfer and termination</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Buffered-data-transfer" accesskey="8">Buffered data transfer</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Handling-alerts" accesskey="9">Handling alerts</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Priority-Strings">Priority Strings</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Selecting-cryptographic-key-sizes">Selecting cryptographic key sizes</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Advanced-topics">Advanced topics</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Introduction-to-the-library"></a>
<div class="header">
<p>
Next: <a href="#Preparation" accesskey="n" rel="next">Preparation</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Introduction"></a>
<h3 class="section">6.1 Introduction</h3>
<p>This chapter tries to explain the basic functionality of the current GnuTLS
library. Note that there may be additional functionality not discussed here
but included in the library. Checking the header files in <samp>/usr/include/gnutls/</samp>
and the manpages is recommended.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#General-idea" accesskey="1">General idea</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Error-handling" accesskey="2">Error handling</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Common-types" accesskey="3">Common types</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Debugging-and-auditing" accesskey="4">Debugging and auditing</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Thread-safety" accesskey="5">Thread safety</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Callback-functions" accesskey="6">Callback functions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="General-idea"></a>
<div class="header">
<p>
Next: <a href="#Error-handling" accesskey="n" rel="next">Error handling</a>, Up: <a href="#Introduction-to-the-library" accesskey="u" rel="up">Introduction to the library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="General-idea-1"></a>
<h4 class="subsection">6.1.1 General idea</h4>
<p>A brief description of how <acronym>GnuTLS</acronym> sessions operate is shown
at <a href="#fig_003agnutls_002ddesign">Figure 6.1</a>. This section will become more clear when it
is completely read.
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, structures needed for the <acronym>ASN.1</acronym> parser and depending
on the system’s CPU, pointers to hardware accelerated encryption functions. This
structure is never modified by any <acronym>GnuTLS</acronym> function, except
for the deinitialization function which frees all allocated memory
and must be called after the program has permanently
finished using <acronym>GnuTLS</acronym>.
</p>
<div class="float"><a name="fig_003agnutls_002ddesign"></a>
<img src="gnutls-internals.png" alt="gnutls-internals">
<div class="float-caption"><p><strong>Figure 6.1: </strong>High level design of GnuTLS.</p></div></div>
<p>The credentials structures are used by the authentication methods, such
as certificate authentication. They store certificates, privates keys,
and other information that is needed to prove the identity to the peer,
and/or verify the indentity of the peer. The information stored in
the credentials structures is initialized once and then can be
shared by many <acronym>TLS</acronym> sessions.
</p>
<p>A <acronym>GnuTLS</acronym> session contains all the required information
to handle one secure connection. The session communicates with the
peers using the provided functions of the transport layer.
Every session has a unique session ID shared with the peer.
</p>
<p>Since TLS sessions can be resumed, servers need a
database back-end to hold the session’s parameters. Every
<acronym>GnuTLS</acronym> session after a successful handshake calls the
appropriate back-end function (see <a href="#resume">resume</a>)
to store the newly negotiated session. The session
database is examined by the server just after having received the
client hello<a name="DOCF11" href="#FOOT11"><sup>11</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.
</p>
<hr>
<a name="Error-handling"></a>
<div class="header">
<p>
Next: <a href="#Common-types" accesskey="n" rel="next">Common types</a>, Previous: <a href="#General-idea" accesskey="p" rel="previous">General idea</a>, Up: <a href="#Introduction-to-the-library" accesskey="u" rel="up">Introduction to the library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Error-handling-1"></a>
<h4 class="subsection">6.1.2 Error handling</h4>
<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>
<p>Fatal errors terminate the connection immediately and further sends
and receives will be disallowed. Such an example 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>.
All errors can be converted to a descriptive string using <a href="#gnutls_005fstrerror">gnutls_strerror</a>.
</p>
<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. For example the error codes <code>GNUTLS_E_WARNING_ALERT_RECEIVED</code> and <code>GNUTLS_E_FATAL_ALERT_RECEIVED</code>
that may returned when receiving data, should be handled by notifying the
user of the alert (as explained in <a href="#Handling-alerts">Handling alerts</a>).
See <a href="#Error-codes">Error codes</a>, for a description of the available error codes.
</p>
<hr>
<a name="Common-types"></a>
<div class="header">
<p>
Next: <a href="#Debugging-and-auditing" accesskey="n" rel="next">Debugging and auditing</a>, Previous: <a href="#Error-handling" accesskey="p" rel="previous">Error handling</a>, Up: <a href="#Introduction-to-the-library" accesskey="u" rel="up">Introduction to the library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Common-types-1"></a>
<h4 class="subsection">6.1.3 Common types</h4>
<p>All strings that are to provided as input to <acronym>GnuTLS</acronym> functions
should be in UTF-8 unless otherwise specified. Output strings are also
in UTF-8 format unless otherwise specified.
</p>
<p>When data of a fixed size are provided to <acronym>GnuTLS</acronym> functions then
the helper structure <code>gnutls_datum_t</code> is often used. Its definition is
shown below.
</p><pre class="verbatim"> typedef struct
{
unsigned char *data;
unsigned int size;
} gnutls_datum_t;
</pre>
<p>Other functions that require data for scattered read use a structure similar
to <code>struct iovec</code> typically used by <code>readv</code>. It is shown
below.
</p><pre class="verbatim"> typedef struct
{
void *iov_base; /* Starting address */
size_t iov_len; /* Number of bytes to transfer */
} giovec_t;
</pre>
<hr>
<a name="Debugging-and-auditing"></a>
<div class="header">
<p>
Next: <a href="#Thread-safety" accesskey="n" rel="next">Thread safety</a>, Previous: <a href="#Common-types" accesskey="p" rel="previous">Common types</a>, Up: <a href="#Introduction-to-the-library" accesskey="u" rel="up">Introduction to the library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Debugging-and-auditing-1"></a>
<h4 class="subsection">6.1.4 Debugging and auditing</h4>
<p>In many cases things may not go as expected and further information,
to assist debugging, from <acronym>GnuTLS</acronym> is desired.
Those are the cases where the <a href="#gnutls_005fglobal_005fset_005flog_005flevel">gnutls_global_set_log_level</a> and
<a href="#gnutls_005fglobal_005fset_005flog_005ffunction">gnutls_global_set_log_function</a> are to be used. Those will print
verbose information on the <acronym>GnuTLS</acronym> functions internal flow.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fglobal_005fset_005flog_005flevel">gnutls_global_set_log_level</a> (int <var>level</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fglobal_005fset_005flog_005ffunction">gnutls_global_set_log_function</a> (gnutls_log_func <var>log_func</var>)</code></dt>
</dl>
<p>When debugging is not required, important issues, such as detected
attacks on the protocol still need to be logged. This is provided
by the logging function set by
<a href="#gnutls_005fglobal_005fset_005faudit_005flog_005ffunction">gnutls_global_set_audit_log_function</a>. The provided function
will receive an message and the corresponding
TLS session. The session information might be used to derive IP addresses
or other information about the peer involved.
</p>
<dl>
<dt><a name="index-gnutls_005fglobal_005fset_005faudit_005flog_005ffunction"></a>Function: <em>void</em> <strong>gnutls_global_set_audit_log_function</strong> <em>(gnutls_audit_log_func <var>log_func</var>)</em></dt>
<dd><p><var>log_func</var>: it is the audit log function
</p>
<p>This is the function where you set the logging function gnutls is
going to use. This is different from <code>gnutls_global_set_log_function()</code>
because it will report the session of the event if any. Note that
that session might be null if there is no corresponding TLS session.
</p>
<p><code>gnutls_audit_log_func</code> is of the form,
void (*gnutls_audit_log_func)( gnutls_session_t, const char*);
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<hr>
<a name="Thread-safety"></a>
<div class="header">
<p>
Next: <a href="#Callback-functions" accesskey="n" rel="next">Callback functions</a>, Previous: <a href="#Debugging-and-auditing" accesskey="p" rel="previous">Debugging and auditing</a>, Up: <a href="#Introduction-to-the-library" accesskey="u" rel="up">Introduction to the library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Thread-safety-1"></a>
<h4 class="subsection">6.1.5 Thread safety</h4>
<a name="index-thread-safety"></a>
<p>The <acronym>GnuTLS</acronym> library is thread safe by design, meaning that
objects of the library such as TLS sessions, can be safely divided across
threads as long as a single thread accesses a single object. This is
sufficient to support a server which handles several sessions per thread.
If, however, an object needs to be shared across threads then access must be
protected with a mutex. Read-only access to objects, for example the
credentials holding structures, is also thread-safe.
</p>
<p>The random generator of the cryptographic back-end, is not thread safe and requires
mutex locks which are setup by <acronym>GnuTLS</acronym>.
Applications can either call <a href="#gnutls_005fglobal_005finit">gnutls_global_init</a> which will initialize the default
operating system provided locks (i.e. <code>pthreads</code> on GNU/Linux and
<code>CriticalSection</code> on Windows), or manually specify the locking system using
the function <a href="#gnutls_005fglobal_005fset_005fmutex">gnutls_global_set_mutex</a> before calling <a href="#gnutls_005fglobal_005finit">gnutls_global_init</a>.
Setting mutexes manually is recommended
only for applications that have full control of the underlying libraries. If this
is not the case, the use of the operating system defaults is recommended. An example of
non-native thread usage is shown below.
</p>
<div class="example">
<pre class="example">#include <gnutls/gnutls.h>
int main()
{
/* When the system mutexes are not to be used
* gnutls_global_set_mutex() must be called explicitly
*/
gnutls_global_set_mutex (mutex_init, mutex_deinit,
mutex_lock, mutex_unlock);
gnutls_global_init();
}
</pre></div>
<dl>
<dt><a name="index-gnutls_005fglobal_005fset_005fmutex"></a>Function: <em>void</em> <strong>gnutls_global_set_mutex</strong> <em>(mutex_init_func <var>init</var>, mutex_deinit_func <var>deinit</var>, mutex_lock_func <var>lock</var>, mutex_unlock_func <var>unlock</var>)</em></dt>
<dd><p><var>init</var>: mutex initialization function
</p>
<p><var>deinit</var>: mutex deinitialization function
</p>
<p><var>lock</var>: mutex locking function
</p>
<p><var>unlock</var>: mutex unlocking function
</p>
<p>With this function you are allowed to override the default mutex
locks used in some parts of gnutls and dependent libraries. This function
should be used if you have complete control of your program and libraries.
Do not call this function from a library. Instead only initialize gnutls and
the default OS mutex locks will be used.
</p>
<p>This function must be called before <code>gnutls_global_init()</code> .
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<hr>
<a name="Callback-functions"></a>
<div class="header">
<p>
Previous: <a href="#Thread-safety" accesskey="p" rel="previous">Thread safety</a>, Up: <a href="#Introduction-to-the-library" accesskey="u" rel="up">Introduction to the library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Callback-functions-1"></a>
<h4 class="subsection">6.1.6 Callback functions</h4>
<a name="index-callback-functions"></a>
<p>There are several cases where <acronym>GnuTLS</acronym> may need out of
band input from your program. This is now implemented using some
callback functions, which your program is expected to register.
</p>
<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.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005ftransport_005fset_005fpush_005ffunction">gnutls_transport_set_push_function</a> (gnutls_session_t <var>session</var>, gnutls_push_func <var>push_func</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftransport_005fset_005fpull_005ffunction">gnutls_transport_set_pull_function</a> (gnutls_session_t <var>session</var>, gnutls_pull_func <var>pull_func</var>)</code></dt>
</dl>
<p>Other callback functions may require more complicated input and data
to be allocated. Such an example is
<a href="#gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction">gnutls_srp_set_server_credentials_function</a>.
All callbacks should allocate and free memory using
<code>gnutls_malloc</code> and <code>gnutls_free</code>.
</p>
<hr>
<a name="Preparation"></a>
<div class="header">
<p>
Next: <a href="#Session-initialization" accesskey="n" rel="next">Session initialization</a>, Previous: <a href="#Introduction-to-the-library" accesskey="p" rel="previous">Introduction to the library</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Preparation-1"></a>
<h3 class="section">6.2 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.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Headers" accesskey="1">Headers</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Initialization" accesskey="2">Initialization</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Version-check" accesskey="3">Version check</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Building-the-source" accesskey="4">Building the source</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Headers"></a>
<div class="header">
<p>
Next: <a href="#Initialization" accesskey="n" rel="next">Initialization</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Headers-1"></a>
<h4 class="subsection">6.2.1 Headers</h4>
<p>All the data types and functions of the <acronym>GnuTLS</acronym> library are
defined in the header file <samp>gnutls/gnutls.h</samp>. This must be
included in all programs that make use of the <acronym>GnuTLS</acronym>
library.
</p>
<hr>
<a name="Initialization"></a>
<div class="header">
<p>
Next: <a href="#Version-check" accesskey="n" rel="next">Version check</a>, Previous: <a href="#Headers" accesskey="p" rel="previous">Headers</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Initialization-2"></a>
<h4 class="subsection">6.2.2 Initialization</h4>
<p>GnuTLS must be initialized before it can be used. The library is
initialized by calling <a href="#gnutls_005fglobal_005finit">gnutls_global_init</a>. The resources
allocated by the initialization process can be released if the
application no longer has a need to call GnuTLS functions, this is
done by calling <a href="#gnutls_005fglobal_005fdeinit">gnutls_global_deinit</a>.
</p>
<p>In order to take advantage of the internationalization features in
GnuTLS, such as translated error messages, the application must set
the current locale using <code>setlocale</code> before initializing GnuTLS.
</p>
<hr>
<a name="Version-check"></a>
<div class="header">
<p>
Next: <a href="#Building-the-source" accesskey="n" rel="next">Building the source</a>, Previous: <a href="#Initialization" accesskey="p" rel="previous">Initialization</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Version-check-1"></a>
<h4 class="subsection">6.2.3 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 start-up.
See the function <a href="#gnutls_005fcheck_005fversion">gnutls_check_version</a>.
</p>
<hr>
<a name="Building-the-source"></a>
<div class="header">
<p>
Previous: <a href="#Version-check" accesskey="p" rel="previous">Version check</a>, Up: <a href="#Preparation" accesskey="u" rel="up">Preparation</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Building-the-source-1"></a>
<h4 class="subsection">6.2.4 Building the source</h4>
<p>If you want to compile a source file including the
<samp>gnutls/gnutls.h</samp> 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 <samp>-I</samp>
option).
</p>
<p>However, the path to the include file is determined at the time the
source is configured. To solve this problem, the library uses the
external package <code>pkg-config</code> that knows 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 <samp>--cflags</samp> option to <code>pkg-config gnutls</code>. The
following example shows how it can be used at the command line:
</p>
<div class="example">
<pre class="example">gcc -c foo.c `pkg-config gnutls --cflags`
</pre></div>
<p>Adding the output of ‘<samp>pkg-config gnutls --cflags</samp>’ to the
compilers command line will ensure that the compiler can find the
<samp>gnutls/gnutls.h</samp> header file.
</p>
<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 <samp>-L</samp> option). For this, the option
<samp>--libs</samp> to <code>pkg-config gnutls</code> can be used. For
convenience, this option also outputs all other options that are
required to link the program with the library (for instance, the
‘<samp>-ltasn1</samp>’ option). The example shows how to link <samp>foo.o</samp>
with the library to a program <code>foo</code>.
</p>
<div class="example">
<pre class="example">gcc -o foo foo.o `pkg-config gnutls --libs`
</pre></div>
<p>Of course you can also combine both examples to a single command by
specifying both options to <code>pkg-config</code>:
</p>
<div class="example">
<pre class="example">gcc -o foo foo.c `pkg-config gnutls --cflags --libs`
</pre></div>
<p>When a program uses the GNU autoconf system, then the following
line or similar can be used to detect the presence of GnuTLS.
</p>
<div class="example">
<pre class="example">PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 3.0.0])
AC_SUBST([LIBGNUTLS_CFLAGS])
AC_SUBST([LIBGNUTLS_LIBS])
</pre></div>
<hr>
<a name="Session-initialization"></a>
<div class="header">
<p>
Next: <a href="#Associating-the-credentials" accesskey="n" rel="next">Associating the credentials</a>, Previous: <a href="#Preparation" accesskey="p" rel="previous">Preparation</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Session-initialization-1"></a>
<h3 class="section">6.3 Session initialization</h3>
<p>In the previous sections we have discussed the global initialization
required for GnuTLS as well as the initialization required for each
authentication method’s credentials (see <a href="#Authentication">Authentication</a>).
In this section we elaborate on the TLS or DTLS session initiation.
Each session is initialized using <a href="#gnutls_005finit">gnutls_init</a> which among
others is used to specify the type of the connection (server or client),
and the underlying protocol type, i.e., datagram (UDP) or reliable (TCP).
</p>
<dl>
<dt><a name="index-gnutls_005finit"></a>Function: <em>int</em> <strong>gnutls_init</strong> <em>(gnutls_session_t * <var>session</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
</p>
<p><var>flags</var>: indicate if this session is to be used for server or client.
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p>
<p><code>flags</code> can be one of <code>GNUTLS_CLIENT</code> and <code>GNUTLS_SERVER</code> . For a DTLS
entity, the flags <code>GNUTLS_DATAGRAM</code> and <code>GNUTLS_NONBLOCK</code> are
also available. The latter flag will enable a non-blocking
operation of the DTLS timers.
</p>
<p>Note that since version 3.1.2 this function enables some common
TLS extensions such as session tickets and OCSP certificate status
request in client side by default. To prevent that use the <code>GNUTLS_NO_EXTENSIONS</code>
flag.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<p>After the session initialization details on the allowed ciphersuites
and protocol versions should be set using the priority functions
such as <a href="#gnutls_005fpriority_005fset_005fdirect">gnutls_priority_set_direct</a>. We elaborate on them
in <a href="#Priority-Strings">Priority Strings</a>.
The credentials used for the key exchange method, such as certificates
or usernames and passwords should also be associated with the session
current session using <a href="#gnutls_005fcredentials_005fset">gnutls_credentials_set</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fcredentials_005fset"></a>Function: <em>int</em> <strong>gnutls_credentials_set</strong> <em>(gnutls_session_t <var>session</var>, gnutls_credentials_type_t <var>type</var>, void * <var>cred</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>type</var>: is the type of the credentials
</p>
<p><var>cred</var>: is a pointer to a structure.
</p>
<p>Sets the needed credentials for the specified type. Eg username,
password - or public and private keys etc. The <code>cred</code> parameter is
a structure that depends on the specified type and on the current
session (client or server).
</p>
<p>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>
<p>For <code>GNUTLS_CRD_ANON</code> , <code>cred</code> should be
<code>gnutls_anon_client_credentials_t</code> in case of a client. In case of
a server it should be <code>gnutls_anon_server_credentials_t</code> .
</p>
<p>For <code>GNUTLS_CRD_SRP</code> , <code>cred</code> should be <code>gnutls_srp_client_credentials_t</code>
in case of a client, and <code>gnutls_srp_server_credentials_t</code> , in case
of a server.
</p>
<p>For <code>GNUTLS_CRD_CERTIFICATE</code> , <code>cred</code> should be
<code>gnutls_certificate_credentials_t</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<hr>
<a name="Associating-the-credentials"></a>
<div class="header">
<p>
Next: <a href="#Setting-up-the-transport-layer" accesskey="n" rel="next">Setting up the transport layer</a>, Previous: <a href="#Session-initialization" accesskey="p" rel="previous">Session initialization</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Associating-the-credentials-1"></a>
<h3 class="section">6.4 Associating the credentials</h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Certificate-credentials" accesskey="1">Certificate credentials</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#SRP-credentials" accesskey="2">SRP credentials</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#PSK-credentials" accesskey="3">PSK credentials</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Anonymous-credentials" accesskey="4">Anonymous credentials</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<p>Each authentication method is associated with a key exchange method, and a credentials type.
The contents of the credentials is method-dependent, e.g. certificates
for certificate authentication and should be initialized and associated
with a session (see <a href="#gnutls_005fcredentials_005fset">gnutls_credentials_set</a>). A mapping of the key exchange methods
with the credential types is shown in <a href="#tab_003akey_002dexchange_002dcred">Table 6.1</a>.
</p>
<div class="float"><a name="tab_003akey_002dexchange_002dcred"></a>
<table>
<thead><tr><th width="25%">Authentication method</th><th width="25%">Key exchange</th><th width="20%">Client credentials</th><th width="20%">Server credentials</th></tr></thead>
<tr><td width="25%">Certificate</td><td width="25%"><code>KX_RSA</code>,
<code>KX_DHE_RSA</code>,
<code>KX_DHE_DSS</code>,
<code>KX_ECDHE_RSA</code>,
<code>KX_ECDHE_ECDSA</code>,
<code>KX_RSA_EXPORT</code></td><td width="20%"><code>CRD_CERTIFICATE</code></td><td width="20%"><code>CRD_CERTIFICATE</code></td></tr>
<tr><td width="25%">Password and certificate</td><td width="25%"><code>KX_SRP_RSA</code>, <code>KX_SRP_DSS</code></td><td width="20%"><code>CRD_SRP</code></td><td width="20%"><code>CRD_CERTIFICATE</code>, <code>CRD_SRP</code></td></tr>
<tr><td width="25%">Password</td><td width="25%"><code>KX_SRP</code></td><td width="20%"><code>CRD_SRP</code></td><td width="20%"><code>CRD_SRP</code></td></tr>
<tr><td width="25%">Anonymous</td><td width="25%"><code>KX_ANON_DH</code>,
<code>KX_ANON_ECDH</code></td><td width="20%"><code>CRD_ANON</code></td><td width="20%"><code>CRD_ANON</code></td></tr>
<tr><td width="25%">Pre-shared key</td><td width="25%"><code>KX_PSK</code>,
<code>KX_DHE_PSK</code>, <code>KX_ECDHE_PSK</code></td><td width="20%"><code>CRD_PSK</code></td><td width="20%"><code>CRD_PSK</code></td></tr>
</table>
<div class="float-caption"><p><strong>Table 6.1: </strong>Key exchange algorithms and the corresponding credential types.</p></div></div>
<hr>
<a name="Certificate-credentials"></a>
<div class="header">
<p>
Next: <a href="#SRP-credentials" accesskey="n" rel="next">SRP credentials</a>, Up: <a href="#Associating-the-credentials" accesskey="u" rel="up">Associating the credentials</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Certificates"></a>
<h4 class="subsection">6.4.1 Certificates</h4>
<a name="Server-certificate-authentication"></a>
<h4 class="subsubheading">Server certificate authentication</h4>
<p>When using certificates the server is required to have at least one
certificate and private key pair. Clients may not hold such
a pair, but a server could require it. In this section we discuss
general issues applying to both client and server certificates. The next
section will elaborate on issues arising from client authentication only.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fallocate_005fcredentials">gnutls_certificate_allocate_credentials</a> (gnutls_certificate_credentials_t * <var>res</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005ffree_005fcredentials">gnutls_certificate_free_credentials</a> (gnutls_certificate_credentials_t <var>sc</var>)</code></dt>
</dl>
<p>After the credentials structures are initialized, the certificate
and key pair must be loaded. This occurs before any <acronym>TLS</acronym>
session is initialized, and the same structures are reused for multiple sessions.
Depending on the certificate type different loading functions
are available, as shown below.
For <acronym>X.509</acronym> certificates, the functions will
accept and use a certificate chain that leads to a trusted
authority. The certificate chain 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>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem">gnutls_certificate_set_x509_key_mem</a> (gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>cert</var>, const gnutls_datum_t * <var>key</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fkey">gnutls_certificate_set_x509_key</a> (gnutls_certificate_credentials_t <var>res</var>, gnutls_x509_crt_t * <var>cert_list</var>, int <var>cert_list_size</var>, gnutls_x509_privkey_t <var>key</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile">gnutls_certificate_set_x509_key_file</a> (gnutls_certificate_credentials_t <var>res</var>, const char * <var>certfile</var>, const char * <var>keyfile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem">gnutls_certificate_set_openpgp_key_mem</a> (gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>cert</var>, const gnutls_datum_t * <var>key</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fopenpgp_005fkey">gnutls_certificate_set_openpgp_key</a> (gnutls_certificate_credentials_t <var>res</var>, gnutls_openpgp_crt_t <var>crt</var>, gnutls_openpgp_privkey_t <var>pkey</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile">gnutls_certificate_set_openpgp_key_file</a> (gnutls_certificate_credentials_t <var>res</var>, const char * <var>certfile</var>, const char * <var>keyfile</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</code></dt>
</dl>
<p>Note however, that since functions like <a href="#gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile">gnutls_certificate_set_x509_key_file</a>
may accept URLs that specify objects stored in token, another important
function is <a href="#gnutls_005fcertificate_005fset_005fpin_005ffunction">gnutls_certificate_set_pin_function</a>. That
allows setting a callback function to retrieve a PIN if the input keys are
protected by PIN by the token.
</p>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_certificate_set_pin_function</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>fn</var>: A PIN callback
</p>
<p><var>userdata</var>: Data to be passed in the callback
</p>
<p>This function will set a callback function to be used when
required to access a protected object. This function overrides any other
global PIN functions.
</p>
<p>Note that this function must be called right after initialization
to have effect.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<p>If the imported keys and certificates need to be accessed before any TLS session
is established, it is convenient to use <a href="#gnutls_005fcertificate_005fset_005fkey">gnutls_certificate_set_key</a>
in combination with <a href="#gnutls_005fpcert_005fimport_005fx509_005fraw">gnutls_pcert_import_x509_raw</a> and <a href="#gnutls_005fprivkey_005fimport_005fx509_005fraw">gnutls_privkey_import_x509_raw</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fkey"></a>Function: <em>int</em> <strong>gnutls_certificate_set_key</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char** <var>names</var>, int <var>names_size</var>, gnutls_pcert_st * <var>pcert_list</var>, int <var>pcert_list_size</var>, gnutls_privkey_t <var>key</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>names</var>: is an array of DNS name of the certificate (NULL if none)
</p>
<p><var>names_size</var>: holds the size of the names list
</p>
<p><var>pcert_list</var>: contains a certificate list (path) for the specified private key
</p>
<p><var>pcert_list_size</var>: holds the size of the certificate list
</p>
<p><var>key</var>: is a <code>gnutls_privkey_t</code> key
</p>
<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. For clients that wants to send more than its own end
entity certificate (e.g., also an intermediate CA cert) then put
the certificate chain in <code>pcert_list</code> . The <code>pcert_list</code> and <code>key</code> will
become part of the credentials structure and must not
be deallocated. They will be automatically deallocated when <code>res</code> is deinitialized.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<p>If multiple certificates are used with the functions above each
client’s request will be served with the certificate that matches the
requested name (see <a href="#Server-name-indication">Server name indication</a>).
</p>
<p>As an alternative to loading from files or buffers, a callback may be used for the
server or the client to specify the certificate and the key at the handshake time.
In that case a certificate should be selected according the peer’s signature
algorithm preferences. To get those preferences use
<a href="#gnutls_005fsign_005falgorithm_005fget_005frequested">gnutls_sign_algorithm_get_requested</a>. Both functions are shown below.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005fset_005fretrieve_005ffunction">gnutls_certificate_set_retrieve_function</a> (gnutls_certificate_credentials_t <var>cred</var>, gnutls_certificate_retrieve_function * <var>func</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005fset_005fretrieve_005ffunction2">gnutls_certificate_set_retrieve_function2</a> (gnutls_certificate_credentials_t <var>cred</var>, gnutls_certificate_retrieve_function2 * <var>func</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsign_005falgorithm_005fget_005frequested">gnutls_sign_algorithm_get_requested</a> (gnutls_session_t <var>session</var>, size_t <var>indx</var>, gnutls_sign_algorithm_t * <var>algo</var>)</code></dt>
</dl>
<p>The functions above do not handle the requested server name automatically.
A server would need to check the name requested by the client
using <a href="#gnutls_005fserver_005fname_005fget">gnutls_server_name_get</a>, and serve the appropriate
certificate. Note that some of these functions require the <code>gnutls_pcert_st</code> structure to be
filled in. Helper functions to make the required structures are listed below.
</p>
<pre class="verbatim">typedef struct gnutls_pcert_st
{
gnutls_pubkey_t pubkey;
gnutls_datum_t cert;
gnutls_certificate_type_t type;
} gnutls_pcert_st;
</pre>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpcert_005fimport_005fx509">gnutls_pcert_import_x509</a> (gnutls_pcert_st* <var>pcert</var>, gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpcert_005fimport_005fopenpgp">gnutls_pcert_import_openpgp</a> (gnutls_pcert_st* <var>pcert</var>, gnutls_openpgp_crt_t <var>crt</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpcert_005fimport_005fx509_005fraw">gnutls_pcert_import_x509_raw</a> (gnutls_pcert_st * <var>pcert</var>, const gnutls_datum_t* <var>cert</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpcert_005fimport_005fopenpgp_005fraw">gnutls_pcert_import_openpgp_raw</a> (gnutls_pcert_st * <var>pcert</var>, const gnutls_datum_t* <var>cert</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, gnutls_openpgp_keyid_t <var>keyid</var>, unsigned int <var>flags</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fpcert_005fdeinit">gnutls_pcert_deinit</a> (gnutls_pcert_st * <var>pcert</var>)</code></dt>
</dl>
<p>In a handshake, the negotiated cipher suite depends on the
certificate’s parameters, so some key exchange methods might not be
available with all 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, that require
decryption. It is not recommended to use RSA keys for both
signing and encryption. If possible use a different key for the
<code>DHE-RSA</code> which uses signing and <code>RSA</code> that requires decryption.
All the key exchange methods shown in <a href="#tab_003akey_002dexchange">Table 4.1</a> are
available in certificate authentication.
</p>
<a name="Client-certificate-authentication"></a>
<h4 class="subsubheading">Client certificate authentication</h4>
<p>If a certificate is to be requested from the client during the handshake, the server
will send a certificate request message. This behavior is controlled <a href="#gnutls_005fcertificate_005fserver_005fset_005frequest">gnutls_certificate_server_set_request</a>.
The request contains a list of the acceptable by the server certificate signers. This list
is constructed using the trusted certificate authorities of the server.
In cases where the server supports a large number of certificate authorities
it makes sense not to advertise all of the names to save bandwidth. That can
be controlled using the function <a href="#gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence">gnutls_certificate_send_x509_rdn_sequence</a>.
This however will have the side-effect of not restricting the client to certificates
signed by server’s acceptable signers.
</p>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fserver_005fset_005frequest"></a>Function: <em>void</em> <strong>gnutls_certificate_server_set_request</strong> <em>(gnutls_session_t <var>session</var>, gnutls_certificate_request_t <var>req</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>req</var>: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
</p>
<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></dd></dl>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence"></a>Function: <em>void</em> <strong>gnutls_certificate_send_x509_rdn_sequence</strong> <em>(gnutls_session_t <var>session</var>, int <var>status</var>)</em></dt>
<dd><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
</p>
<p><var>status</var>: is 0 or 1
</p>
<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 advertise its trusted CAs to the peer. If status
is zero then the default behaviour will take effect, which is to
advertise the server’s trusted CAs.
</p>
<p>This function has no effect in clients, and in authentication
methods other than certificate with X.509 certificates.
</p></dd></dl>
<a name="Client-or-server-certificate-verification"></a>
<h4 class="subsubheading">Client or server certificate verification</h4>
<p>Certificate verification is possible by loading the trusted
authorities into the credentials structure by using
the following functions, applicable to X.509 and OpenPGP certificates.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust">gnutls_certificate_set_x509_system_trust</a> (gnutls_certificate_credentials_t <var>cred</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile">gnutls_certificate_set_x509_trust_file</a> (gnutls_certificate_credentials_t <var>cred</var>, const char * <var>cafile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile">gnutls_certificate_set_openpgp_keyring_file</a> (gnutls_certificate_credentials_t <var>c</var>, const char * <var>file</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</code></dt>
</dl>
<p>The peer’s certificate is not automatically verified and one
must call <a href="#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</a>
after a successful handshake to verify the certificate’s signature and the owner
of the certificate. The verification status returned can be printed using
<a href="#gnutls_005fcertificate_005fverification_005fstatus_005fprint">gnutls_certificate_verification_status_print</a>.
</p>
<p>Alternatively the verification can occur during the handshake
by using <a href="#gnutls_005fcertificate_005fset_005fverify_005ffunction">gnutls_certificate_set_verify_function</a>.
</p>
<p>The functions above provide a brief verification output. If a
detailed output is required one should call <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="#X_002e509-certificates">X.509 certificates</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fverify_005fpeers3"></a>Function: <em>int</em> <strong>gnutls_certificate_verify_peers3</strong> <em>(gnutls_session_t <var>session</var>, const char* <var>hostname</var>, unsigned int * <var>status</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>hostname</var>: is the expected name of the peer; may be <code>NULL</code>
</p>
<p><var>status</var>: is the output of the verification
</p>
<p>This function will verify the peer’s certificate and store the
status in the <code>status</code> variable as a bitwise or’d gnutls_certificate_status_t
values or zero if the certificate is trusted. Note that value in <code>status</code> is set only when the return value of this function is success (i.e, failure
to trust a certificate does not imply a negative return value).
</p>
<p>If the <code>hostname</code> provided is non-NULL then this function will compare
the hostname in the certificate against the given. If they do not match
the <code>GNUTLS_CERT_UNEXPECTED_OWNER</code> status flag will be set.
</p>
<p>If available the OCSP Certificate Status extension will be
utilized by this function.
</p>
<p>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>
<p><strong>Returns:</strong> a negative error code on error and <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p>
<p><strong>Since:</strong> 3.1.4
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fverify_005ffunction"></a>Function: <em>void</em> <strong>gnutls_certificate_set_verify_function</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, gnutls_certificate_verify_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<p>This function sets a callback to be called when peer’s certificate
has been received in order to verify it on receipt rather than
doing after the handshake is completed.
</p>
<p>The callback’s function prototype is:
int (*callback)(gnutls_session_t);
</p>
<p>If the callback function is provided then gnutls will call it, in the
handshake, just after the certificate message has been received.
To verify or obtain the certificate the <code>gnutls_certificate_verify_peers2()</code> ,
<code>gnutls_certificate_type_get()</code> , <code>gnutls_certificate_get_peers()</code> functions
can be used.
</p>
<p>The callback function should return 0 for the handshake to continue
or non-zero to terminate.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<hr>
<a name="SRP-credentials"></a>
<div class="header">
<p>
Next: <a href="#PSK-credentials" accesskey="n" rel="next">PSK credentials</a>, Previous: <a href="#Certificate-credentials" accesskey="p" rel="previous">Certificate credentials</a>, Up: <a href="#Associating-the-credentials" accesskey="u" rel="up">Associating the credentials</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="SRP"></a>
<h4 class="subsection">6.4.2 SRP</h4>
<p>The initialization functions in SRP credentials differ between
client and server.
Clients supporting <acronym>SRP</acronym> should set the username and password
prior to connection, to the credentials structure.
Alternatively <a href="#gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction">gnutls_srp_set_client_credentials_function</a>
may be used instead, to specify a callback function that should return the
SRP username and password.
The callback is called once during the <acronym>TLS</acronym> handshake.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fsrp_005fallocate_005fserver_005fcredentials">gnutls_srp_allocate_server_credentials</a> (gnutls_srp_server_credentials_t * <var>sc</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsrp_005fallocate_005fclient_005fcredentials">gnutls_srp_allocate_client_credentials</a> (gnutls_srp_client_credentials_t * <var>sc</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fsrp_005ffree_005fserver_005fcredentials">gnutls_srp_free_server_credentials</a> (gnutls_srp_server_credentials_t <var>sc</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fsrp_005ffree_005fclient_005fcredentials">gnutls_srp_free_client_credentials</a> (gnutls_srp_client_credentials_t <var>sc</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsrp_005fset_005fclient_005fcredentials">gnutls_srp_set_client_credentials</a> (gnutls_srp_client_credentials_t <var>res</var>, const char * <var>username</var>, const char * <var>password</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction"></a>Function: <em>void</em> <strong>gnutls_srp_set_client_credentials_function</strong> <em>(gnutls_srp_client_credentials_t <var>cred</var>, gnutls_srp_client_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<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:
</p>
<p>int (*callback)(gnutls_session_t, char** username, char**password);
</p>
<p>The <code>username</code> and <code>password</code> must be allocated using
<code>gnutls_malloc()</code> . <code>username</code> and <code>password</code> should be ASCII strings
or UTF-8 strings prepared using the "SASLprep" profile of
"stringprep".
</p>
<p>The callback function will be called once per handshake before the
initial hello message is sent.
</p>
<p>The callback should not return a negative error code the second
time called, since the handshake procedure will be aborted.
</p>
<p>The callback function should return 0 on success.
-1 indicates an error.
</p></dd></dl>
<p>In server side the default behavior of <acronym>GnuTLS</acronym> is to read
the usernames and <acronym>SRP</acronym> verifiers from password files. These
password file format is compatible the with the <em>Stanford srp libraries</em>
format. If a different password file format is to be used, then
<a href="#gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction">gnutls_srp_set_server_credentials_function</a> should be called,
to set an appropriate callback.
</p>
<dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile"></a>Function: <em>int</em> <strong>gnutls_srp_set_server_credentials_file</strong> <em>(gnutls_srp_server_credentials_t <var>res</var>, const char * <var>password_file</var>, const char * <var>password_conf_file</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p><var>password_file</var>: is the SRP password file (tpasswd)
</p>
<p><var>password_conf_file</var>: is the SRP password conf file (tpasswd.conf)
</p>
<p>This function sets the password files, in a
<code>gnutls_srp_server_credentials_t</code> structure. Those password files
hold usernames and verifiers and will be used for SRP
authentication.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction"></a>Function: <em>void</em> <strong>gnutls_srp_set_server_credentials_function</strong> <em>(gnutls_srp_server_credentials_t <var>cred</var>, gnutls_srp_server_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<p>This function can be used to set a callback to retrieve the user’s
SRP credentials. The callback’s function form is:
</p>
<p>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>
<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 gnutls.h.
</p>
<p>In case the callback returned a negative number then gnutls will
assume that the username does not exist.
</p>
<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>
<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></dd></dl>
<hr>
<a name="PSK-credentials"></a>
<div class="header">
<p>
Next: <a href="#Anonymous-credentials" accesskey="n" rel="next">Anonymous credentials</a>, Previous: <a href="#SRP-credentials" accesskey="p" rel="previous">SRP credentials</a>, Up: <a href="#Associating-the-credentials" accesskey="u" rel="up">Associating the credentials</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PSK"></a>
<h4 class="subsection">6.4.3 PSK</h4>
<p>The initialization functions in PSK credentials differ between
client and server.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpsk_005fallocate_005fserver_005fcredentials">gnutls_psk_allocate_server_credentials</a> (gnutls_psk_server_credentials_t * <var>sc</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpsk_005fallocate_005fclient_005fcredentials">gnutls_psk_allocate_client_credentials</a> (gnutls_psk_client_credentials_t * <var>sc</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fpsk_005ffree_005fserver_005fcredentials">gnutls_psk_free_server_credentials</a> (gnutls_psk_server_credentials_t <var>sc</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fpsk_005ffree_005fclient_005fcredentials">gnutls_psk_free_client_credentials</a> (gnutls_psk_client_credentials_t <var>sc</var>)</code></dt>
</dl>
<p>Clients supporting <acronym>PSK</acronym> should supply the username and key
before a TLS session is established. Alternatively
<a href="#gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction">gnutls_psk_set_client_credentials_function</a> can be used to
specify a callback function. This has the
advantage that the callback will be called only if <acronym>PSK</acronym> has
been negotiated.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpsk_005fset_005fclient_005fcredentials">gnutls_psk_set_client_credentials</a> (gnutls_psk_client_credentials_t <var>res</var>, const char * <var>username</var>, const gnutls_datum_t * <var>key</var>, gnutls_psk_key_flags <var>flags</var>)</code></dt>
</dl>
<dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction"></a>Function: <em>void</em> <strong>gnutls_psk_set_client_credentials_function</strong> <em>(gnutls_psk_client_credentials_t <var>cred</var>, gnutls_psk_client_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<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_t* key);
</p>
<p>The <code>username</code> and <code>key</code> ->data 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>
<p>The callback function will be called once per handshake.
</p>
<p>The callback function should return 0 on success.
-1 indicates an error.
</p></dd></dl>
<p>In server side the default behavior 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
a callback should be set instead by <a href="#gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction">gnutls_psk_set_server_credentials_function</a>.
</p>
<p>The server can help the client chose a suitable username and password,
by sending a hint. Note that there is no common profile for the PSK hint and applications
are discouraged to use it.
A server, may specify the hint by calling
<a href="#gnutls_005fpsk_005fset_005fserver_005fcredentials_005fhint">gnutls_psk_set_server_credentials_hint</a>. The client can retrieve
the hint, for example in the callback function, using
<a href="#gnutls_005fpsk_005fclient_005fget_005fhint">gnutls_psk_client_get_hint</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile"></a>Function: <em>int</em> <strong>gnutls_psk_set_server_credentials_file</strong> <em>(gnutls_psk_server_credentials_t <var>res</var>, const char * <var>password_file</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p><var>password_file</var>: is the PSK password file (passwd.psk)
</p>
<p>This function sets the password file, in a
<code>gnutls_psk_server_credentials_t</code> structure. This password file
holds usernames and keys and will be used for PSK authentication.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction">gnutls_psk_set_server_credentials_function</a> (gnutls_psk_server_credentials_t <var>cred</var>, gnutls_psk_server_credentials_function * <var>func</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpsk_005fset_005fserver_005fcredentials_005fhint">gnutls_psk_set_server_credentials_hint</a> (gnutls_psk_server_credentials_t <var>res</var>, const char * <var>hint</var>)</code></dt>
<dt><code><var>const char *</var> <a href="#gnutls_005fpsk_005fclient_005fget_005fhint">gnutls_psk_client_get_hint</a> (gnutls_session_t <var>session</var>)</code></dt>
</dl>
<hr>
<a name="Anonymous-credentials"></a>
<div class="header">
<p>
Previous: <a href="#PSK-credentials" accesskey="p" rel="previous">PSK credentials</a>, Up: <a href="#Associating-the-credentials" accesskey="u" rel="up">Associating the credentials</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Anonymous"></a>
<h4 class="subsection">6.4.4 Anonymous</h4>
<p>The key exchange methods for anonymous authentication
might require Diffie-Hellman parameters to be generated by the server and
associated with an anonymous credentials structure. Check
<a href="#Parameter-generation">Parameter generation</a> for more information.
The initialization functions for the credentials are shown below.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fanon_005fallocate_005fserver_005fcredentials">gnutls_anon_allocate_server_credentials</a> (gnutls_anon_server_credentials_t * <var>sc</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fanon_005fallocate_005fclient_005fcredentials">gnutls_anon_allocate_client_credentials</a> (gnutls_anon_client_credentials_t * <var>sc</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fanon_005ffree_005fserver_005fcredentials">gnutls_anon_free_server_credentials</a> (gnutls_anon_server_credentials_t <var>sc</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fanon_005ffree_005fclient_005fcredentials">gnutls_anon_free_client_credentials</a> (gnutls_anon_client_credentials_t <var>sc</var>)</code></dt>
</dl>
<hr>
<a name="Setting-up-the-transport-layer"></a>
<div class="header">
<p>
Next: <a href="#TLS-handshake" accesskey="n" rel="next">TLS handshake</a>, Previous: <a href="#Associating-the-credentials" accesskey="p" rel="previous">Associating the credentials</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Setting-up-the-transport-layer-1"></a>
<h3 class="section">6.5 Setting up the transport layer</h3>
<p>The next step is to setup the underlying transport layer details. The
Berkeley sockets are implicitly used by GnuTLS, thus a
call to <a href="#gnutls_005ftransport_005fset_005fptr2">gnutls_transport_set_ptr2</a> would be sufficient to
specify the socket descriptor.
</p>
<dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fptr2"></a>Function: <em>void</em> <strong>gnutls_transport_set_ptr2</strong> <em>(gnutls_session_t <var>session</var>, gnutls_transport_ptr_t <var>recv_ptr</var>, gnutls_transport_ptr_t <var>send_ptr</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>recv_ptr</var>: is the value for the pull function
</p>
<p><var>send_ptr</var>: is the value for the push function
</p>
<p>Used to set the first argument of the transport function (for push
and pull callbacks). In berkeley style sockets this function will set the
connection descriptor. With this function you can use two different
pointers for receiving and sending.
</p></dd></dl>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005ftransport_005fset_005fptr">gnutls_transport_set_ptr</a> (gnutls_session_t <var>session</var>, gnutls_transport_ptr_t <var>ptr</var>)</code></dt>
</dl>
<p>If however another transport layer than TCP is selected, then
the following functions have to be specified.
</p>
<dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fpush_005ffunction"></a>Function: <em>void</em> <strong>gnutls_transport_set_push_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_push_func <var>push_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>push_func</var>: a callback function similar to <code>write()</code>
</p>
<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.
The callback should return a positive number indicating the
bytes sent, and -1 on error.
</p>
<p><code>push_func</code> is of the form,
ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fvec_005fpush_005ffunction"></a>Function: <em>void</em> <strong>gnutls_transport_set_vec_push_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_vec_push_func <var>vec_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>vec_func</var>: a callback function similar to <code>writev()</code>
</p>
<p>Using this function you can override the default writev(2)
function for gnutls to send data. Setting this callback
instead of <code>gnutls_transport_set_push_function()</code> is recommended
since it introduces less overhead in the TLS handshake process.
</p>
<p><code>vec_func</code> is of the form,
ssize_t (*gnutls_vec_push_func) (gnutls_transport_ptr_t, const giovec_t * iov, int iovcnt);
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fpull_005ffunction"></a>Function: <em>void</em> <strong>gnutls_transport_set_pull_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_pull_func <var>pull_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>pull_func</var>: a callback function similar to <code>read()</code>
</p>
<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.
The callback should return 0 on connection termination, a positive
number indicating the number of bytes received, and -1 on error.
</p>
<p><code>gnutls_pull_func</code> is of the form,
ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
</p></dd></dl>
<p>The functions above accept a callback function which
should return the number of bytes written, or -1 on
error and should set <code>errno</code> appropriately.
In some environments, setting <code>errno</code> is unreliable. For example
Windows have several errno variables in different CRTs, or in other
systems it may be a non thread-local variable. If this is a concern to
you, call <a href="#gnutls_005ftransport_005fset_005ferrno">gnutls_transport_set_errno</a> with the intended errno
value instead of setting <code>errno</code> directly.
</p>
<dl>
<dt><a name="index-gnutls_005ftransport_005fset_005ferrno"></a>Function: <em>void</em> <strong>gnutls_transport_set_errno</strong> <em>(gnutls_session_t <var>session</var>, int <var>err</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>err</var>: error value to store in session-specific errno variable.
</p>
<p>Store <code>err</code> in the session-specific errno variable. Useful values
for <code>err</code> is EAGAIN and EINTR, other values are treated will be
treated as real errors in the push/pull function.
</p>
<p>This function is useful in replacement push and pull functions set by
<code>gnutls_transport_set_push_function()</code> and
<code>gnutls_transport_set_pull_function()</code> under Windows, where the
replacements may not have access to the same <code>errno</code> variable that is used by GnuTLS (e.g., the application is linked to
msvcr71.dll and gnutls is linked to msvcrt.dll).
</p></dd></dl>
<p><acronym>GnuTLS</acronym> currently only interprets the EINTR, EAGAIN and EMSGSIZE errno
values and returns the corresponding <acronym>GnuTLS</acronym> error codes:
</p><ul>
<li> <code>GNUTLS_E_INTERRUPTED</code>
</li><li> <code>GNUTLS_E_AGAIN</code>
</li><li> <code>GNUTLS_E_LARGE_PACKET</code>
</li></ul>
<p>The EINTR and EAGAIN values are 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 the above error codes is returned. The
EMSGSIZE value is returned when attempting to send a large datagram.
</p>
<p>In the case of DTLS it is also desirable to override the generic
transport functions with functions that emulate the operation
of <code>recvfrom</code> and <code>sendto</code>. In addition
<acronym>DTLS</acronym> requires timers during the receive of a handshake
message, set using the <a href="#gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction">gnutls_transport_set_pull_timeout_function</a>
function. To check the retransmission timers the function
<a href="#gnutls_005fdtls_005fget_005ftimeout">gnutls_dtls_get_timeout</a> is provided, which returns the time
remaining until the next retransmission, or better the time until
<a href="#gnutls_005fhandshake">gnutls_handshake</a> should be called again.
</p>
<dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction"></a>Function: <em>void</em> <strong>gnutls_transport_set_pull_timeout_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_pull_timeout_func <var>func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>func</var>: a callback function
</p>
<p>This is the function where you set a function for gnutls to know
whether data are ready to be received. It should wait for data a
given time frame in milliseconds. The callback should return 0 on
timeout, a positive number if data can be received, and -1 on error.
You’ll need to override this function if <code>select()</code> is not suitable
for the provided transport calls.
The callback function is used in DTLS only.
</p>
<p><code>gnutls_pull_timeout_func</code> is of the form,
int (*gnutls_pull_timeout_func)(gnutls_transport_ptr_t, unsigned int ms);
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fdtls_005fget_005ftimeout"></a>Function: <em>unsigned int</em> <strong>gnutls_dtls_get_timeout</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the milliseconds remaining
for a retransmission of the previously sent handshake
message. This function is useful when DTLS is used in
non-blocking mode, to estimate when to call <code>gnutls_handshake()</code>
if no packets have been received.
</p>
<p><strong>Returns:</strong> the remaining time in milliseconds.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Asynchronous-operation" accesskey="1">Asynchronous operation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#DTLS-sessions" accesskey="2">DTLS sessions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Asynchronous-operation"></a>
<div class="header">
<p>
Next: <a href="#DTLS-sessions" accesskey="n" rel="next">DTLS sessions</a>, Up: <a href="#Setting-up-the-transport-layer" accesskey="u" rel="up">Setting up the transport layer</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Asynchronous-operation-1"></a>
<h4 class="subsection">6.5.1 Asynchronous operation</h4>
<p><acronym>GnuTLS</acronym> can be used with asynchronous socket or event-driven programming.
The approach is similar to using Berkeley sockets under such an environment.
The blocking, due to network interaction, calls such as
<a href="#gnutls_005fhandshake">gnutls_handshake</a>, <a href="#gnutls_005frecord_005frecv">gnutls_record_recv</a>,
can be set to non-blocking by setting the underlying sockets to non-blocking.
If other push and pull functions are setup, then they should behave the same
way as <code>recv</code> and <code>send</code> when used in a non-blocking
way, i.e., set errno to <code>EAGAIN</code>. Since, during a TLS protocol session
<acronym>GnuTLS</acronym> does not block except for network interaction, the non blocking
<code>EAGAIN</code> errno will be propagated and <acronym>GnuTLS</acronym> functions
will return the <code>GNUTLS_E_AGAIN</code> error code. Such calls can be resumed the
same way as a system call would.
The only exception is <a href="#gnutls_005frecord_005fsend">gnutls_record_send</a>,
which if interrupted subsequent calls need not to include the data to be
sent (can be called with NULL argument).
</p>
<p>The <code>select</code> system call can also be used in combination with the
<acronym>GnuTLS</acronym> functions. <code>select</code> allows monitoring of sockets
and notifies on them being ready for reading or writing data. Note however
that this system call cannot notify on data present in <acronym>GnuTLS</acronym>
read buffers, it is only applicable to the kernel sockets API. Thus if
you are using it for reading from a <acronym>GnuTLS</acronym> session, make sure
that any cached data are read completely. That can be achieved by checking there
are no data waiting to be read (using <a href="#gnutls_005frecord_005fcheck_005fpending">gnutls_record_check_pending</a>),
either before the <code>select</code> system call, or after a call to
<a href="#gnutls_005frecord_005frecv">gnutls_record_recv</a>. <acronym>GnuTLS</acronym> does not keep a write buffer,
thus when writing no additional actions are required.
</p>
<p>Although in the TLS protocol implementation each call to receive or send
function implies to restoring the same function that was interrupted, in
the DTLS protocol this requirement isn’t true.
There are cases where a retransmission is required, which are indicated by
a received message and thus <a href="#gnutls_005frecord_005fget_005fdirection">gnutls_record_get_direction</a> must be called
to decide which direction to check prior to restoring a function call.
</p>
<dl>
<dt><a name="index-gnutls_005frecord_005fget_005fdirection"></a>Function: <em>int</em> <strong>gnutls_record_get_direction</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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 <code>GNUTLS_E_INTERRUPTED</code> or
<code>GNUTLS_E_AGAIN</code> . 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>
<p><strong>Returns:</strong> 0 if trying to read data, 1 if trying to write data.
</p></dd></dl>
<p>Moreover, to prevent blocking from DTLS’ retransmission timers to block a
handshake, the <a href="#gnutls_005finit">gnutls_init</a> function should be called with the
<code>GNUTLS_NONBLOCK</code> flag set (see <a href="#Session-initialization">Session initialization</a>).
</p>
<hr>
<a name="DTLS-sessions"></a>
<div class="header">
<p>
Previous: <a href="#Asynchronous-operation" accesskey="p" rel="previous">Asynchronous operation</a>, Up: <a href="#Setting-up-the-transport-layer" accesskey="u" rel="up">Setting up the transport layer</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="DTLS-sessions-1"></a>
<h4 class="subsection">6.5.2 DTLS sessions</h4>
<p>Because datagram TLS can operate over connections where the peer
of a server cannot be reliably verified, functionality is available to prevent
denial of service attacks. <acronym>GnuTLS</acronym> requires a server
to generate a secret key that is used to sign a cookie<a name="DOCF12" href="#FOOT12"><sup>12</sup></a>.
That cookie is sent to the client using <a href="#gnutls_005fdtls_005fcookie_005fsend">gnutls_dtls_cookie_send</a>, and
the client must reply using the correct cookie. The server side
should verify the initial message sent by client using <a href="#gnutls_005fdtls_005fcookie_005fverify">gnutls_dtls_cookie_verify</a>.
If successful the session should be initialized and associated with
the cookie using <a href="#gnutls_005fdtls_005fprestate_005fset">gnutls_dtls_prestate_set</a>, before proceeding to
the handshake.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fkey_005fgenerate">gnutls_key_generate</a> (gnutls_datum_t * <var>key</var>, unsigned int <var>key_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fdtls_005fcookie_005fsend">gnutls_dtls_cookie_send</a> (gnutls_datum_t* <var>key</var>, void* <var>client_data</var>, size_t <var>client_data_size</var>, gnutls_dtls_prestate_st* <var>prestate</var>, gnutls_transport_ptr_t <var>ptr</var>, gnutls_push_func <var>push_func</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fdtls_005fcookie_005fverify">gnutls_dtls_cookie_verify</a> (gnutls_datum_t* <var>key</var>, void* <var>client_data</var>, size_t <var>client_data_size</var>, void* <var>_msg</var>, size_t <var>msg_size</var>, gnutls_dtls_prestate_st* <var>prestate</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fdtls_005fprestate_005fset">gnutls_dtls_prestate_set</a> (gnutls_session_t <var>session</var>, gnutls_dtls_prestate_st* <var>prestate</var>)</code></dt>
</dl>
<p>Note that the above apply to server side only and they are not mandatory to be
used. Not using them, however, allows denial of service attacks.
The client side cookie handling is part of <a href="#gnutls_005fhandshake">gnutls_handshake</a>.
</p>
<p>Datagrams are typically restricted by a maximum transfer unit (MTU). For that
both client and server side should set the correct maximum transfer unit for
the layer underneath <acronym>GnuTLS</acronym>. This will allow proper fragmentation
of DTLS messages and prevent messages from being silently discarded by the
transport layer. The “correct” maximum transfer unit can be obtained through
a path MTU discovery mechanism [<em>RFC4821</em>].
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fdtls_005fset_005fmtu">gnutls_dtls_set_mtu</a> (gnutls_session_t <var>session</var>, unsigned int <var>mtu</var>)</code></dt>
<dt><code><var>unsigned int</var> <a href="#gnutls_005fdtls_005fget_005fmtu">gnutls_dtls_get_mtu</a> (gnutls_session_t <var>session</var>)</code></dt>
<dt><code><var>unsigned int</var> <a href="#gnutls_005fdtls_005fget_005fdata_005fmtu">gnutls_dtls_get_data_mtu</a> (gnutls_session_t <var>session</var>)</code></dt>
</dl>
<hr>
<a name="TLS-handshake"></a>
<div class="header">
<p>
Next: <a href="#Data-transfer-and-termination" accesskey="n" rel="next">Data transfer and termination</a>, Previous: <a href="#Setting-up-the-transport-layer" accesskey="p" rel="previous">Setting up the transport layer</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-handshake-1"></a>
<h3 class="section">6.6 TLS handshake</h3>
<p>Once a session has been initialized and a network
connection has been set up, TLS and DTLS protocols
perform a handshake. The handshake is the actual key
exchange.
</p>
<dl>
<dt><a name="index-gnutls_005fhandshake"></a>Function: <em>int</em> <strong>gnutls_handshake</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function does the handshake of the TLS/SSL protocol, and
initializes the TLS connection.
</p>
<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>
<p>The non-fatal errors such as <code>GNUTLS_E_AGAIN</code> and
<code>GNUTLS_E_INTERRUPTED</code> interrupt the handshake procedure, which
should be resumed later. Call this function again, until it
returns 0; cf. <code>gnutls_record_get_direction()</code> and
<code>gnutls_error_is_fatal()</code> .
</p>
<p>If this function is called by a server after a rehandshake request
then <code>GNUTLS_E_GOT_APPLICATION_DATA</code> or
<code>GNUTLS_E_WARNING_ALERT_RECEIVED</code> 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 or
in the case of <code>GNUTLS_E_GOT_APPLICATION_DATA</code> it might also mean that
some data were pending.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fhandshake_005fset_005ftimeout"></a>Function: <em>void</em> <strong>gnutls_handshake_set_timeout</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>ms</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>ms</var>: is a timeout value in milliseconds
</p>
<p>This function sets the timeout for the handshake process
to the provided value. Use an <code>ms</code> value of zero to disable
timeout.
</p>
<p>Note that in order for the timeout to be enforced
<code>gnutls_transport_set_pull_timeout_function()</code> must be set
(it is set by default in most systems).
</p></dd></dl>
<p>The handshake process doesn’t ensure the verification
of the peer’s identity. When certificates are in use,
this can be done, either after the handshake is complete, or during
the handshake if <a href="#gnutls_005fcertificate_005fset_005fverify_005ffunction">gnutls_certificate_set_verify_function</a>
has been used. In both cases the <a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a> function can be
used to verify the peer’s certificate (see <a href="#Certificate-authentication">Certificate authentication</a>
for more information).
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a> (gnutls_session_t <var>session</var>, unsigned int * <var>status</var>)</code></dt>
</dl>
<hr>
<a name="Data-transfer-and-termination"></a>
<div class="header">
<p>
Next: <a href="#Buffered-data-transfer" accesskey="n" rel="next">Buffered data transfer</a>, Previous: <a href="#TLS-handshake" accesskey="p" rel="previous">TLS handshake</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Data-transfer-and-termination-1"></a>
<h3 class="section">6.7 Data transfer and termination</h3>
<p>Once the handshake is complete and peer’s identity
has been verified data can be exchanged. The available
functions resemble the POSIX <code>recv</code> and <code>send</code>
functions. It is suggested to use <a href="#gnutls_005ferror_005fis_005ffatal">gnutls_error_is_fatal</a>
to check whether the error codes returned by these functions are
fatal for the protocol or can be ignored.
</p>
<dl>
<dt><a name="index-gnutls_005frecord_005fsend"></a>Function: <em>ssize_t</em> <strong>gnutls_record_send</strong> <em>(gnutls_session_t <var>session</var>, const void * <var>data</var>, size_t <var>data_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: contains the data to send
</p>
<p><var>data_size</var>: is the length of the data
</p>
<p>This function has the similar semantics with <code>send()</code> . The only
difference is that it accepts a GnuTLS session, and uses different
error codes.
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.
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> . The errno value EMSGSIZE
maps to <code>GNUTLS_E_LARGE_PACKET</code> .
</p>
<p><strong>Returns:</strong> The number of bytes sent, or a negative error code. The
number of bytes sent might be less than <code>data_size</code> . The maximum
number of bytes this function can send in a single call depends
on the negotiated maximum record size.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005frecord_005frecv"></a>Function: <em>ssize_t</em> <strong>gnutls_record_recv</strong> <em>(gnutls_session_t <var>session</var>, void * <var>data</var>, size_t <var>data_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: the buffer that the data will be read into
</p>
<p><var>data_size</var>: the number of requested bytes
</p>
<p>This function has the similar semantics with <code>recv()</code> . The only
difference is that it accepts a GnuTLS session, and uses different
error codes.
In the special case that a server requests a renegotiation, the
client may receive an error code of <code>GNUTLS_E_REHANDSHAKE</code> . This
message may be simply ignored, replied with an alert
<code>GNUTLS_A_NO_RENEGOTIATION</code> , or replied with a new handshake,
depending on the client’s will.
If <code>EINTR</code> is returned by the internal push function (the default
is <code>recv()</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 to get the data. See also
<code>gnutls_record_get_direction()</code> .
A server may also receive <code>GNUTLS_E_REHANDSHAKE</code> when a client has
initiated a handshake. In that case the server can only initiate a
handshake or terminate the connection.
</p>
<p><strong>Returns:</strong> The number of bytes received and zero on EOF (for stream
connections). A negative error code is returned in case of an error.
The number of bytes received might be less than the requested <code>data_size</code> .
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005ferror_005fis_005ffatal"></a>Function: <em>int</em> <strong>gnutls_error_is_fatal</strong> <em>(int <var>error</var>)</em></dt>
<dd><p><var>error</var>: is a GnuTLS error code, a negative error code
</p>
<p>If a GnuTLS function returns a negative error code you may feed that
value to this function to see if the error condition is fatal.
Note that you may also want to check the error code manually, since some
non-fatal errors to the protocol (such as a warning alert or
a rehandshake request) may be fatal for your program.
</p>
<p>This function is only useful if you are dealing with errors from
the record layer or the handshake layer.
</p>
<p><strong>Returns:</strong> 1 if the error code is fatal, for positive <code>error</code> values,
0 is returned. For unknown <code>error</code> values, -1 is returned.
</p></dd></dl>
<p>Although, in the TLS protocol the receive function can be called
at any time, when DTLS is used the GnuTLS receive functions must be
called once a message is available for reading, even if no data are
expected. This is because in DTLS various (internal) actions
may be required due to retransmission timers. Moreover,
an extended receive function is shown below, which allows the extraction
of the message’s sequence number. Due to the unreliable nature of the
protocol, this field allows distinguishing out-of-order messages.
</p>
<dl>
<dt><a name="index-gnutls_005frecord_005frecv_005fseq"></a>Function: <em>ssize_t</em> <strong>gnutls_record_recv_seq</strong> <em>(gnutls_session_t <var>session</var>, void * <var>data</var>, size_t <var>data_size</var>, unsigned char * <var>seq</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: the buffer that the data will be read into
</p>
<p><var>data_size</var>: the number of requested bytes
</p>
<p><var>seq</var>: is the packet’s 64-bit sequence number. Should have space for 8 bytes.
</p>
<p>This function is the same as <code>gnutls_record_recv()</code> , except that
it returns in addition to data, the sequence number of the data.
This is useful in DTLS where record packets might be received
out-of-order. The returned 8-byte sequence number is an
integer in big-endian format and should be
treated as a unique message identification.
</p>
<p><strong>Returns:</strong> 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>data_size</code> .
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<p>The <a href="#gnutls_005frecord_005fcheck_005fpending">gnutls_record_check_pending</a> helper function is available to
allow checking whether data are available to be read in a <acronym>GnuTLS</acronym> session
buffers. Note that this function complements but does not replace <code>select</code>,
i.e., <a href="#gnutls_005frecord_005fcheck_005fpending">gnutls_record_check_pending</a> reports no data to be read, <code>select</code>
should be called to check for data in the network buffers.
</p>
<dl>
<dt><a name="index-gnutls_005frecord_005fcheck_005fpending"></a>Function: <em>size_t</em> <strong>gnutls_record_check_pending</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function checks if there are unread data
in the gnutls buffers. If the return value is
non-zero the next call to <code>gnutls_record_recv()</code>
is guarranteed not to block.
</p>
<p><strong>Returns:</strong> Returns the size of the data or zero.
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005frecord_005fget_005fdirection">gnutls_record_get_direction</a> (gnutls_session_t <var>session</var>)</code></dt>
</dl>
<p>Once a TLS or DTLS session is no longer needed, it is
recommended to use <a href="#gnutls_005fbye">gnutls_bye</a> to terminate the
session. That way the peer is notified securely about the
intention of termination, which allows distinguishing it
from a malicious connection termination.
A session can be deinitialized with the <a href="#gnutls_005fdeinit">gnutls_deinit</a> function.
</p>
<dl>
<dt><a name="index-gnutls_005fbye"></a>Function: <em>int</em> <strong>gnutls_bye</strong> <em>(gnutls_session_t <var>session</var>, gnutls_close_request_t <var>how</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>how</var>: is an integer
</p>
<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 <code>GNUTLS_SHUT_RDWR</code> , <code>GNUTLS_SHUT_WR</code> .
</p>
<p>In case of <code>GNUTLS_SHUT_RDWR</code> the TLS session gets
terminated and further receives and sends will be disallowed. If
the return value is zero you may continue using the underlying
transport layer. <code>GNUTLS_SHUT_RDWR</code> sends an alert containing a close
request and waits for the peer to reply with the same message.
</p>
<p>In case of <code>GNUTLS_SHUT_WR</code> the TLS session gets terminated
and further sends will be disallowed. In order to reuse the
connection you should wait for an EOF from the peer.
<code>GNUTLS_SHUT_WR</code> sends an alert containing a close request.
</p>
<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, and thus not
distinguishing between a malicious party prematurely terminating
the connection and normal termination.
</p>
<p>This function may also return <code>GNUTLS_E_AGAIN</code> or
<code>GNUTLS_E_INTERRUPTED</code> ; cf. <code>gnutls_record_get_direction()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code, see
function documentation for entire semantics.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_deinit</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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></dd></dl>
<hr>
<a name="Buffered-data-transfer"></a>
<div class="header">
<p>
Next: <a href="#Handling-alerts" accesskey="n" rel="next">Handling alerts</a>, Previous: <a href="#Data-transfer-and-termination" accesskey="p" rel="previous">Data transfer and termination</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Buffered-data-transfer-1"></a>
<h3 class="section">6.8 Buffered data transfer</h3>
<p>Although <a href="#gnutls_005frecord_005fsend">gnutls_record_send</a> is sufficient to transmit data
to the peer, when many small chunks of data are to be transmitted
it is inefficient and wastes bandwidth due to the TLS record
overhead. In that case it is preferrable to combine the small chunks
before transmission. The following functions provide that functionality.
</p>
<dl>
<dt><a name="index-gnutls_005frecord_005fcork"></a>Function: <em>void</em> <strong>gnutls_record_cork</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>If called <code>gnutls_record_send()</code> will no longer send partial records.
All queued records will be sent when <code>gnutls_uncork()</code> is called, or
when the maximum record size is reached.
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005frecord_005funcork"></a>Function: <em>int</em> <strong>gnutls_record_uncork</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>flags</var>: Could be zero or <code>GNUTLS_RECORD_WAIT</code>
</p>
<p>This resets the effect of <code>gnutls_cork()</code> , and flushes any pending
data. If the <code>GNUTLS_RECORD_WAIT</code> flag is specified then this
function will block until the data is sent or a fatal error
occurs (i.e., the function will retry on <code>GNUTLS_E_AGAIN</code> and
<code>GNUTLS_E_INTERRUPTED</code> ).
</p>
<p><strong>Returns:</strong> On success the number of transmitted data is returned, or
otherwise a negative error code.
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>
<hr>
<a name="Handling-alerts"></a>
<div class="header">
<p>
Next: <a href="#Priority-Strings" accesskey="n" rel="next">Priority Strings</a>, Previous: <a href="#Buffered-data-transfer" accesskey="p" rel="previous">Buffered data transfer</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Handling-alerts-1"></a>
<h3 class="section">6.9 Handling alerts</h3>
<p>During a TLS connection alert messages may be exchanged by the
two peers. Those messages may be fatal, meaning the connection
must be terminated afterwards, or warning when something needs
to be reported to the peer, but without interrupting the session.
The error codes <code>GNUTLS_E_WARNING_ALERT_RECEIVED</code>
or <code>GNUTLS_E_FATAL_ALERT_RECEIVED</code> signal those alerts
when received, and may be returned by all GnuTLS functions that receive
data from the peer, being <a href="#gnutls_005fhandshake">gnutls_handshake</a> and <a href="#gnutls_005frecord_005frecv">gnutls_record_recv</a>.
</p>
<p>If those error codes are received the alert and its level should be logged
or reported to the peer using the functions below.
</p>
<dl>
<dt><a name="index-gnutls_005falert_005fget"></a>Function: <em>gnutls_alert_description_t</em> <strong>gnutls_alert_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the last alert number received. This
function should be called when <code>GNUTLS_E_WARNING_ALERT_RECEIVED</code> or
<code>GNUTLS_E_FATAL_ALERT_RECEIVED</code> errors are returned by a gnutls
function. The peer may send alerts if he encounters an error.
If no alert has been received the returned value is undefined.
</p>
<p><strong>Returns:</strong> the last alert received, a
<code>gnutls_alert_description_t</code> value.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005falert_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_alert_get_name</strong> <em>(gnutls_alert_description_t <var>alert</var>)</em></dt>
<dd><p><var>alert</var>: is an alert number.
</p>
<p>This function will return a string that describes the given alert
number, or <code>NULL</code> . See <code>gnutls_alert_get()</code> .
</p>
<p><strong>Returns:</strong> string corresponding to <code>gnutls_alert_description_t</code> value.
</p></dd></dl>
<p>The peer may also be warned or notified of a fatal issue
by using one of the functions below. All the available alerts
are listed in <a href="#The-Alert-Protocol">The Alert Protocol</a>.
</p>
<dl>
<dt><a name="index-gnutls_005falert_005fsend"></a>Function: <em>int</em> <strong>gnutls_alert_send</strong> <em>(gnutls_session_t <var>session</var>, gnutls_alert_level_t <var>level</var>, gnutls_alert_description_t <var>desc</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>level</var>: is the level of the alert
</p>
<p><var>desc</var>: is the alert description
</p>
<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>
<p>The error code of the underlying record send function will be
returned, so you may also receive <code>GNUTLS_E_INTERRUPTED</code> or
<code>GNUTLS_E_AGAIN</code> as well.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005ferror_005fto_005falert"></a>Function: <em>int</em> <strong>gnutls_error_to_alert</strong> <em>(int <var>err</var>, int * <var>level</var>)</em></dt>
<dd><p><var>err</var>: is a negative integer
</p>
<p><var>level</var>: the alert level will be stored there
</p>
<p>Get 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 <code>err</code> is <code>GNUTLS_E_REHANDSHAKE</code> ,
where a warning alert should be sent to the peer indicating that no
renegotiation will be performed.
</p>
<p>If there is no mapping to a valid alert the alert to indicate
internal error is returned.
</p>
<p><strong>Returns:</strong> the alert code to use for a particular error code.
</p></dd></dl>
<hr>
<a name="Priority-Strings"></a>
<div class="header">
<p>
Next: <a href="#Selecting-cryptographic-key-sizes" accesskey="n" rel="next">Selecting cryptographic key sizes</a>, Previous: <a href="#Handling-alerts" accesskey="p" rel="previous">Handling alerts</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Priority-strings"></a>
<h3 class="section">6.10 Priority strings</h3>
<a name="index-Priority-strings"></a>
<p>In order to specify cipher suite preferences on a TLS session
there are priority functions that accept a string
specifying the enabled for the handshake algorithms.
That string may contain a single initial keyword such as
in <a href="#tab_003aprio_002dkeywords">Table 6.2</a> and may be followed by
additional algorithm or special keywords.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fpriority_005fset_005fdirect">gnutls_priority_set_direct</a> (gnutls_session_t <var>session</var>, const char * <var>priorities</var>, const char ** <var>err_pos</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fpriority_005fset">gnutls_priority_set</a> (gnutls_session_t <var>session</var>, gnutls_priority_t <var>priority</var>)</code></dt>
</dl>
<div class="float"><a name="tab_003aprio_002dkeywords"></a>
<table>
<thead><tr><th width="20%">Keyword</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">PERFORMANCE</td><td width="70%">All the known to be secure ciphersuites are enabled,
limited to 128 bit ciphers and sorted by terms of speed
performance. The message authenticity security level is of 64 bits or more.</td></tr>
<tr><td width="20%">NORMAL</td><td width="70%">Means all the known to be secure ciphersuites. The ciphers are sorted by security
margin, although the 256-bit ciphers are included as a fallback only.
The message authenticity security level is of 64 bits or more.</td></tr>
<tr><td width="20%">SECURE128</td><td width="70%">Means all known to be secure ciphersuites that offer a
security level 128-bit or more and a message authenticity
security level of 80 bits or more.</td></tr>
<tr><td width="20%">SECURE192</td><td width="70%">Means all the known to be secure ciphersuites that offer a
security level 192-bit or more and a message authenticity
security level of 128 bits or more.</td></tr>
<tr><td width="20%">SECURE256</td><td width="70%">Currently alias for SECURE192.</td></tr>
<tr><td width="20%">SUITEB128</td><td width="70%">Means all the NSA Suite B cryptography (RFC5430) ciphersuites
with an 128 bit security level.</td></tr>
<tr><td width="20%">SUITEB192</td><td width="70%">Means all the NSA Suite B cryptography (RFC5430) ciphersuites
with an 192 bit security level.</td></tr>
<tr><td width="20%">EXPORT</td><td width="70%">Means all ciphersuites are enabled, including the
low-security 40 bit ciphers.</td></tr>
<tr><td width="20%">NONE</td><td width="70%">Means nothing is enabled. This disables even protocols and
compression methods. It should be followed by the
algorithms to be enabled.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 6.2: </strong>Supported initial keywords.</p></div></div>
<p>Unless the initial keyword is "NONE" the defaults (in preference
order) are for TLS protocols TLS 1.2, TLS1.1, TLS1.0, SSL3.0; for
compression NULL; for certificate types X.509.
In key exchange algorithms when in NORMAL or SECURE levels the
perfect forward secrecy algorithms take precedence of the other
protocols. In all cases all the supported key exchange algorithms
are enabled<a name="DOCF13" href="#FOOT13"><sup>13</sup></a>.
</p>
<p>Note that the SECURE levels distinguish between overall security level and
message authenticity security level. That is because the message
authenticity security level requires the adversary to break
the algorithms at real-time during the protocol run, whilst
the overall security level refers to off-line adversaries
(e.g. adversaries breaking the ciphertext years after it was captured).
</p>
<p>The NONE keyword, if used, must followed by keywords specifying
the algorithms and protocols to be enabled. The other initial keywords
do not require, but may be followed by such keywords. All level keywords
can be combined, and for example a level of "SECURE256:+SECURE128" is
allowed.
</p>
<p>The order with which every algorithm or protocol
is specified is significant. Algorithms specified before others
will take precedence. The supported algorithms and protocols
are shown in <a href="#tab_003aprio_002dalgorithms">Table 6.3</a>.
To avoid collisions in order to specify a compression algorithm in
the priority string you have to prefix it with "COMP-", protocol versions
with "VERS-", signature algorithms with "SIGN-" and certificate types with "CTYPE-".
All other algorithms don’t need a prefix. Each specified keyword can
be prefixed with any of the following characters.
</p>
<dl compact="compact">
<dt>’!’ or ’-’</dt>
<dd><p>appended with an algorithm will remove this algorithm.
</p></dd>
<dt>"+"</dt>
<dd><p>appended with an algorithm will add this algorithm.
</p></dd>
</dl>
<div class="float"><a name="tab_003aprio_002dalgorithms"></a>
<table>
<thead><tr><th width="20%">Type</th><th width="70%">Keywords</th></tr></thead>
<tr><td width="20%">Ciphers</td><td width="70%">AES-128-CBC, AES-256-CBC, AES-128-GCM, CAMELLIA-128-CBC,
CAMELLIA-256-CBC, ARCFOUR-128, 3DES-CBC ARCFOUR-40. Catch all
name is CIPHER-ALL which will add all the algorithms from NORMAL
priority.</td></tr>
<tr><td width="20%">Key exchange</td><td width="70%">RSA, DHE-RSA, DHE-DSS, SRP, SRP-RSA, SRP-DSS,
PSK, DHE-PSK, ECDHE-RSA, ANON-ECDH, ANON-DH, RSA-EXPORT. The
Catch all name is KX-ALL which will add all the algorithms from NORMAL
priority.</td></tr>
<tr><td width="20%">MAC</td><td width="70%">MD5, SHA1, SHA256, AEAD (used with
GCM ciphers only). All algorithms from NORMAL priority can be accessed with MAC-ALL.</td></tr>
<tr><td width="20%">Compression algorithms</td><td width="70%">COMP-NULL, COMP-DEFLATE. Catch all is COMP-ALL.</td></tr>
<tr><td width="20%">TLS versions</td><td width="70%">VERS-SSL3.0, VERS-TLS1.0, VERS-TLS1.1,
VERS-TLS1.2, VERS-DTLS1.0. Catch all is VERS-TLS-ALL.</td></tr>
<tr><td width="20%">Signature algorithms</td><td width="70%">SIGN-RSA-SHA1, SIGN-RSA-SHA224,
SIGN-RSA-SHA256, SIGN-RSA-SHA384, SIGN-RSA-SHA512, SIGN-DSA-SHA1,
SIGN-DSA-SHA224, SIGN-DSA-SHA256, SIGN-RSA-MD5. Catch all
is SIGN-ALL. This is only valid for TLS 1.2 and later.</td></tr>
<tr><td width="20%">Elliptic curves</td><td width="70%">CURVE-SECP192R1, CURVE-SECP224R1, CURVE-SECP256R1, CURVE-SECP384R1, CURVE-SECP521R1. Catch all is CURVE-ALL.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 6.3: </strong>The supported algorithm keywords in priority strings.</p></div></div>
<p>Note that the DHE key exchange methods are generally
slower<a name="DOCF14" href="#FOOT14"><sup>14</sup></a> than their elliptic curves counterpart
(ECDHE). Moreover the plain Diffie-Hellman key exchange
requires parameters to be generated and associated with a credentials
structure by the server (see <a href="#Parameter-generation">Parameter generation</a>).
</p>
<p>The available special keywords are shown in <a href="#tab_003aprio_002dspecial1">Table 6.4</a>
and <a href="#tab_003aprio_002dspecial2">Table 6.5</a>.
</p>
<div class="float"><a name="tab_003aprio_002dspecial1"></a>
<table>
<thead><tr><th width="45%">Keyword</th><th width="45%">Description</th></tr></thead>
<tr><td width="45%">%COMPAT</td><td width="45%">will enable compatibility mode. It might mean that violations
of the protocols are allowed as long as maximum compatibility with
problematic clients and servers is achieved. More specifically this
string would disable TLS record random padding and tolerate packets
over the maximum allowed TLS record.</td></tr>
<tr><td width="45%">%NO_EXTENSIONS</td><td width="45%">will prevent the sending of any TLS extensions in client side. Note
that TLS 1.2 requires extensions to be used, as well as safe
renegotiation thus this option must be used with care.</td></tr>
<tr><td width="45%">%SERVER_PRECEDENCE</td><td width="45%">The ciphersuite will be selected according to server priorities
and not the client’s.</td></tr>
<tr><td width="45%">%SSL3_RECORD_VERSION</td><td width="45%">will use SSL3.0 record version in client hello.
This is the default.</td></tr>
<tr><td width="45%">%LATEST_RECORD_VERSION</td><td width="45%">will use the latest TLS version record version in client hello.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 6.4: </strong>Special priority string keywords.</p></div></div>
<div class="float"><a name="tab_003aprio_002dspecial2"></a>
<table>
<thead><tr><th width="45%">Keyword</th><th width="45%">Description</th></tr></thead>
<tr><td width="45%">%STATELESS_COMPRESSION</td><td width="45%">will disable keeping state across records when compressing. This may
help to mitigate attacks when compression is used but an attacker
is in control of input data. This has to be used only when the
data that are possibly controlled by an attacker are placed in
separate records.</td></tr>
<tr><td width="45%">%DISABLE_SAFE_RENEGOTIATION</td><td width="45%">will completely disable safe renegotiation
completely. Do not use unless you know what you are doing.</td></tr>
<tr><td width="45%">%UNSAFE_RENEGOTIATION</td><td width="45%">will allow handshakes and re-handshakes
without the safe renegotiation extension. Note that for clients
this mode is insecure (you may be under attack), and for servers it
will allow insecure clients to connect (which could be fooled by an
attacker). Do not use unless you know what you are doing and want
maximum compatibility.</td></tr>
<tr><td width="45%">%PARTIAL_RENEGOTIATION</td><td width="45%">will allow initial handshakes to proceed,
but not re-handshakes. This leaves the client vulnerable to attack,
and servers will be compatible with non-upgraded clients for
initial handshakes. This is currently the default for clients and
servers, for compatibility reasons.</td></tr>
<tr><td width="45%">%SAFE_RENEGOTIATION</td><td width="45%">will enforce safe renegotiation. Clients and
servers will refuse to talk to an insecure peer. Currently this
causes interoperability problems, but is required for full protection.</td></tr>
<tr><td width="45%">%VERIFY_ALLOW_SIGN_RSA_MD5</td><td width="45%">will allow RSA-MD5 signatures in certificate chains.</td></tr>
<tr><td width="45%">%VERIFY_DISABLE_CRL_CHECKS</td><td width="45%">will disable CRL or OCSP checks in the verification of the certificate chain.</td></tr>
<tr><td width="45%">%VERIFY_ALLOW_X509_V1_CA_CRT</td><td width="45%">will allow V1 CAs in chains.</td></tr>
</table>
<div class="float-caption"><p><strong>Table 6.5: </strong>More priority string keywords.</p></div></div>
<p>Finally the ciphersuites enabled by any priority string can be
listed using the <code>gnutls-cli</code> application (see <a href="#gnutls_002dcli-Invocation">gnutls-cli Invocation</a>),
or by using the priority functions as in <a href="#Listing-the-ciphersuites-in-a-priority-string">Listing the ciphersuites in a priority string</a>.
</p>
<p>Example priority strings are:
</p><div class="example">
<pre class="example">The default priority without the HMAC-MD5:
"NORMAL:-MD5"
Specifying RSA with AES-128-CBC:
"NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+AES-128-CBC:+SIGN-ALL:+COMP-NULL"
Specifying the defaults except ARCFOUR-128:
"NORMAL:-ARCFOUR-128"
Enabling the 128-bit secure ciphers, while disabling SSL 3.0 and enabling compression:
"SECURE128:-VERS-SSL3.0:+COMP-DEFLATE"
Enabling the 128-bit and 192-bit secure ciphers, while disabling all TLS versions
except TLS 1.2:
"SECURE128:+SECURE192:-VERS-TLS-ALL:+VERS-TLS1.2"
</pre></div>
<hr>
<a name="Selecting-cryptographic-key-sizes"></a>
<div class="header">
<p>
Next: <a href="#Advanced-topics" accesskey="n" rel="next">Advanced topics</a>, Previous: <a href="#Priority-Strings" accesskey="p" rel="previous">Priority Strings</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Selecting-cryptographic-key-sizes-1"></a>
<h3 class="section">6.11 Selecting cryptographic key sizes</h3>
<a name="index-key-sizes"></a>
<p>Because many algorithms are involved in TLS, it is not easy to set
a consistent security level. For this reason in <a href="#tab_003akey_002dsizes">Table 6.6</a> we
present some correspondence between key sizes of symmetric algorithms
and public key algorithms based on [<em>ECRYPT</em>].
Those can be used to generate certificates with
appropriate key sizes as well as select parameters for Diffie-Hellman and SRP
authentication.
</p>
<div class="float"><a name="tab_003akey_002dsizes"></a>
<table>
<thead><tr><th width="10%">Security bits</th><th width="12%">RSA, DH and SRP parameter size</th><th width="10%">ECC key size</th><th width="20%">Security parameter</th><th width="32%">Description</th></tr></thead>
<tr><td width="10%"><72</td><td width="12%"><1008</td><td width="10%"><160</td><td width="20%"><code>INSECURE</code></td><td width="32%">Considered to be insecure</td></tr>
<tr><td width="10%">72</td><td width="12%">1008</td><td width="10%">160</td><td width="20%"><code>WEAK</code></td><td width="32%">Short term protection against small organizations</td></tr>
<tr><td width="10%">80</td><td width="12%">1248</td><td width="10%">160</td><td width="20%"><code>LOW</code></td><td width="32%">Very short term protection against agencies</td></tr>
<tr><td width="10%">96</td><td width="12%">1776</td><td width="10%">192</td><td width="20%"><code>LEGACY</code></td><td width="32%">Legacy standard level</td></tr>
<tr><td width="10%">112</td><td width="12%">2432</td><td width="10%">224</td><td width="20%"><code>NORMAL</code></td><td width="32%">Medium-term protection</td></tr>
<tr><td width="10%">128</td><td width="12%">3248</td><td width="10%">256</td><td width="20%"><code>HIGH</code></td><td width="32%">Long term protection</td></tr>
<tr><td width="10%">256</td><td width="12%">15424</td><td width="10%">512</td><td width="20%"><code>ULTRA</code></td><td width="32%">Foreseeable future</td></tr>
</table>
<div class="float-caption"><p><strong>Table 6.6: </strong>Key sizes and security parameters.</p></div></div>
<p>The first column provides a security parameter in a number of bits. This
gives an indication of the number of combinations to be tried by an adversary
to brute force a key. For example to test all possible keys in a 112 bit security parameter
<em>2^{112}</em> combinations have to be tried. For today’s technology this is infeasible.
The next two columns correlate the security
parameter with actual bit sizes of parameters for DH, RSA, SRP and ECC algorithms.
A mapping to <code>gnutls_sec_param_t</code> value is given for each security parameter, on
the next column, and finally a brief description of the level.
</p>
<p>Note, however, that the values suggested here are nothing more than an
educated guess that is valid today. There are no guarantees that an
algorithm will remain unbreakable or that these values will remain
constant in time. There could be scientific breakthroughs that cannot
be predicted or total failure of the current public key systems by
quantum computers. On the other hand though the cryptosystems used in
TLS are selected in a conservative way and such catastrophic
breakthroughs or failures are believed to be unlikely.
The NIST publication SP 800-57 [<em>NISTSP80057</em>] contains a similar
table.
</p>
<p>When using <acronym>GnuTLS</acronym> and a decision on bit sizes for a public
key algorithm is required, use of the following functions is
recommended:
</p>
<dl>
<dt><a name="index-gnutls_005fsec_005fparam_005fto_005fpk_005fbits"></a>Function: <em>unsigned int</em> <strong>gnutls_sec_param_to_pk_bits</strong> <em>(gnutls_pk_algorithm_t <var>algo</var>, gnutls_sec_param_t <var>param</var>)</em></dt>
<dd><p><var>algo</var>: is a public key algorithm
</p>
<p><var>param</var>: is a security parameter
</p>
<p>When generating private and public key pairs a difficult question
is which size of "bits" the modulus will be in RSA and the group size
in DSA. The easy answer is 1024, which is also wrong. This function
will convert a human understandable security parameter to an
appropriate size for the specific algorithm.
</p>
<p><strong>Returns:</strong> The number of bits, or (0).
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fpk_005fbits_005fto_005fsec_005fparam"></a>Function: <em>gnutls_sec_param_t</em> <strong>gnutls_pk_bits_to_sec_param</strong> <em>(gnutls_pk_algorithm_t <var>algo</var>, unsigned int <var>bits</var>)</em></dt>
<dd><p><var>algo</var>: is a public key algorithm
</p>
<p><var>bits</var>: is the number of bits
</p>
<p>This is the inverse of <code>gnutls_sec_param_to_pk_bits()</code> . Given an algorithm
and the number of bits, it will return the security parameter. This is
a rough indication.
</p>
<p><strong>Returns:</strong> The security parameter.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<p>Those functions will convert a human understandable security parameter
of <code>gnutls_sec_param_t</code> type, to a number of bits suitable for a public
key algorithm.
</p>
<dl compact="compact">
<dt><code><var>const char *</var> <a href="#gnutls_005fsec_005fparam_005fget_005fname">gnutls_sec_param_get_name</a> (gnutls_sec_param_t <var>param</var>)</code></dt>
</dl>
<p>The following functions will set the minimum acceptable group size for Diffie-Hellman
and SRP authentication.
</p><dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fdh_005fset_005fprime_005fbits">gnutls_dh_set_prime_bits</a> (gnutls_session_t <var>session</var>, unsigned int <var>bits</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fsrp_005fset_005fprime_005fbits">gnutls_srp_set_prime_bits</a> (gnutls_session_t <var>session</var>, unsigned int <var>bits</var>)</code></dt>
</dl>
<hr>
<a name="Advanced-topics"></a>
<div class="header">
<p>
Previous: <a href="#Selecting-cryptographic-key-sizes" accesskey="p" rel="previous">Selecting cryptographic key sizes</a>, Up: <a href="#How-to-use-GnuTLS-in-applications" accesskey="u" rel="up">How to use GnuTLS in applications</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Advanced-topics-1"></a>
<h3 class="section">6.12 Advanced topics</h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Session-resumption" accesskey="1">Session resumption</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Certificate-verification" accesskey="2">Certificate verification</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Parameter-generation" accesskey="3">Parameter generation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Keying-Material-Exporters" accesskey="4">Keying Material Exporters</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Channel-Bindings" accesskey="5">Channel Bindings</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Interoperability" accesskey="6">Interoperability</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Compatibility-with-the-OpenSSL-library" accesskey="7">Compatibility with the OpenSSL library</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Session-resumption"></a>
<div class="header">
<p>
Next: <a href="#Certificate-verification" accesskey="n" rel="next">Certificate verification</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Session-resumption-1"></a>
<h4 class="subsection">6.12.1 Session resumption</h4>
<a name="index-resuming-sessions-1"></a>
<a name="index-session-resumption-1"></a>
<a name="Client-side"></a>
<h4 class="subsubheading">Client side</h4>
<p>To reduce time and roundtrips spent in a handshake the client can
request session resumption from a server that previously shared
a session with. For that the client has to retrieve and store
the session parameters. Before establishing a new session to the same
server the parameters must be re-associated with the GnuTLS session
using <a href="#gnutls_005fsession_005fset_005fdata">gnutls_session_set_data</a>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fsession_005fget_005fdata2">gnutls_session_get_data2</a> (gnutls_session_t <var>session</var>, gnutls_datum_t * <var>data</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsession_005fget_005fid2">gnutls_session_get_id2</a> (gnutls_session_t <var>session</var>, gnutls_datum_t * <var>session_id</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fsession_005fset_005fdata">gnutls_session_set_data</a> (gnutls_session_t <var>session</var>, const void * <var>session_data</var>, size_t <var>session_data_size</var>)</code></dt>
</dl>
<p>Keep in mind that sessions will be expired after some time, depending
on the server, and a server may choose not to resume a session
even when requested to. The expiration is to prevent temporal session keys
from becoming long-term keys. Also note that as a client you must enable,
using the priority functions, at least the algorithms used in the last session.
</p>
<dl>
<dt><a name="index-gnutls_005fsession_005fis_005fresumed"></a>Function: <em>int</em> <strong>gnutls_session_is_resumed</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Check whether session is resumed or not.
</p>
<p><strong>Returns:</strong> non zero if this session is resumed, or a zero if this is
a new session.
</p></dd></dl>
<a name="Server-side"></a>
<h4 class="subsubheading">Server side</h4>
<p>In order to support resumption a server can store
the session security parameters in a local database or by using session
tickets (see <a href="#Session-tickets">Session tickets</a>) to delegate storage to the client. Because
session tickets might not be supported by all clients, servers
could combine the two methods.
</p>
<p>A storing server needs to specify callback functions to store, retrieve and delete session data. These can be
registered with the functions below. The stored sessions in the database can be checked using <a href="#gnutls_005fdb_005fcheck_005fentry">gnutls_db_check_entry</a>
for expiration.
</p>
<dl compact="compact">
<dt><code><var>void</var> <a href="#gnutls_005fdb_005fset_005fretrieve_005ffunction">gnutls_db_set_retrieve_function</a> (gnutls_session_t <var>session</var>, gnutls_db_retr_func <var>retr_func</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fdb_005fset_005fstore_005ffunction">gnutls_db_set_store_function</a> (gnutls_session_t <var>session</var>, gnutls_db_store_func <var>store_func</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fdb_005fset_005fptr">gnutls_db_set_ptr</a> (gnutls_session_t <var>session</var>, void * <var>ptr</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fdb_005fset_005fremove_005ffunction">gnutls_db_set_remove_function</a> (gnutls_session_t <var>session</var>, gnutls_db_remove_func <var>rem_func</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fdb_005fcheck_005fentry">gnutls_db_check_entry</a> (gnutls_session_t <var>session</var>, gnutls_datum_t <var>session_entry</var>)</code></dt>
</dl>
<p>A server utilizing tickets should generate ticket encryption
and authentication keys using <a href="#gnutls_005fsession_005fticket_005fkey_005fgenerate">gnutls_session_ticket_key_generate</a>.
Those keys should be associated with the GnuTLS session using
<a href="#gnutls_005fsession_005fticket_005fenable_005fserver">gnutls_session_ticket_enable_server</a>.
</p>
<dl>
<dt><a name="index-gnutls_005fsession_005fticket_005fenable_005fserver"></a>Function: <em>int</em> <strong>gnutls_session_ticket_enable_server</strong> <em>(gnutls_session_t <var>session</var>, const gnutls_datum_t * <var>key</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>key</var>: key to encrypt session parameters.
</p>
<p>Request that the server should attempt session resumption using
SessionTicket. <code>key</code> must be initialized with
<code>gnutls_session_ticket_key_generate()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fsession_005fticket_005fkey_005fgenerate"></a>Function: <em>int</em> <strong>gnutls_session_ticket_key_generate</strong> <em>(gnutls_datum_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: is a pointer to a <code>gnutls_datum_t</code> which will contain a newly
created key.
</p>
<p>Generate a random key to encrypt security parameters within
SessionTicket.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fsession_005fresumption_005frequested"></a>Function: <em>int</em> <strong>gnutls_session_resumption_requested</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Check whether the client has asked for session resumption.
This function is valid only on server side.
</p>
<p><strong>Returns:</strong> non zero if session resumption was asked, or a zero if not.
</p></dd></dl>
<p>A server enabling both session tickets and a storage for session data
would use session tickets when clients support it and the storage otherwise.
</p>
<hr>
<a name="Certificate-verification"></a>
<div class="header">
<p>
Next: <a href="#Parameter-generation" accesskey="n" rel="next">Parameter generation</a>, Previous: <a href="#Session-resumption" accesskey="p" rel="previous">Session resumption</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Certificate-verification-1"></a>
<h4 class="subsection">6.12.2 Certificate verification</h4>
<a name="index-DANE-1"></a>
<a name="index-DNSSEC-1"></a>
<a name="index-SSH_002dstyle-authentication-1"></a>
<a name="index-Trust-on-first-use-1"></a>
<a name="index-Key-pinning-1"></a>
<a name="index-gnutls_005fcertificate_005fverify_005fflags-1"></a>
<p>In this section the functionality for additional certificate verification methods is listed.
These methods are intended to be used in addition to normal PKI verification, in order to reduce
the risk of a compromised CA being undetected.
</p>
<a name="Trust-on-first-use"></a>
<h4 class="subsubsection">6.12.2.1 Trust on first use</h4>
<p>The GnuTLS library includes functionlity to use an SSH-like trust on first use authentication.
The available functions to store and verify public keys are listed below.
</p>
<dl>
<dt><a name="index-gnutls_005fverify_005fstored_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_verify_stored_pubkey</strong> <em>(const char* <var>db_name</var>, gnutls_tdb_t <var>tdb</var>, const char* <var>host</var>, const char* <var>service</var>, gnutls_certificate_type_t <var>cert_type</var>, const gnutls_datum_t * <var>cert</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>db_name</var>: A file specifying the stored keys (use NULL for the default)
</p>
<p><var>tdb</var>: A storage structure or NULL to use the default
</p>
<p><var>host</var>: The peer’s name
</p>
<p><var>service</var>: non-NULL if this key is specific to a service (e.g. http)
</p>
<p><var>cert_type</var>: The type of the certificate
</p>
<p><var>cert</var>: The raw (der) data of the certificate
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will try to verify the provided certificate using
a list of stored public keys. The <code>service</code> field if non-NULL should
be a port number.
</p>
<p>The <code>retrieve</code> variable if non-null specifies a custom backend for
the retrieval of entries. If it is NULL then the
default file backend will be used. In POSIX-like systems the
file backend uses the $HOME/.gnutls/known_hosts file.
</p>
<p>Note that if the custom storage backend is provided the
retrieval function should return <code>GNUTLS_E_CERTIFICATE_KEY_MISMATCH</code>
if the host/service pair is found but key doesn’t match,
<code>GNUTLS_E_NO_CERTIFICATE_FOUND</code> if no such host/service with
the given key is found, and 0 if it was found. The storage
function should return 0 on success.
</p>
<p><strong>Returns:</strong> If no associated public key is found
then <code>GNUTLS_E_NO_CERTIFICATE_FOUND</code> will be returned. If a key
is found but does not match <code>GNUTLS_E_CERTIFICATE_KEY_MISMATCH</code>
is returned. On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
or a negative error value on other errors.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<dl>
<dt><a name="index-gnutls_005fstore_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_store_pubkey</strong> <em>(const char* <var>db_name</var>, gnutls_tdb_t <var>tdb</var>, const char* <var>host</var>, const char* <var>service</var>, gnutls_certificate_type_t <var>cert_type</var>, const gnutls_datum_t * <var>cert</var>, time_t <var>expiration</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>db_name</var>: A file specifying the stored keys (use NULL for the default)
</p>
<p><var>tdb</var>: A storage structure or NULL to use the default
</p>
<p><var>host</var>: The peer’s name
</p>
<p><var>service</var>: non-NULL if this key is specific to a service (e.g. http)
</p>
<p><var>cert_type</var>: The type of the certificate
</p>
<p><var>cert</var>: The data of the certificate
</p>
<p><var>expiration</var>: The expiration time (use 0 to disable expiration)
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will store the provided certificate to
the list of stored public keys. The key will be considered valid until
the provided expiration time.
</p>
<p>The <code>store</code> variable if non-null specifies a custom backend for
the storage of entries. If it is NULL then the
default file backend will be used.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<p>In addition to the above the <a href="#gnutls_005fstore_005fcommitment">gnutls_store_commitment</a> can be
used to implement a key-pinning architecture as in [<em>KEYPIN</em>].
This provides a way for web server to commit on a public key that is
not yet active.
</p>
<dl>
<dt><a name="index-gnutls_005fstore_005fcommitment"></a>Function: <em>int</em> <strong>gnutls_store_commitment</strong> <em>(const char* <var>db_name</var>, gnutls_tdb_t <var>tdb</var>, const char* <var>host</var>, const char* <var>service</var>, gnutls_digest_algorithm_t <var>hash_algo</var>, const gnutls_datum_t* <var>hash</var>, time_t <var>expiration</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>db_name</var>: A file specifying the stored keys (use NULL for the default)
</p>
<p><var>tdb</var>: A storage structure or NULL to use the default
</p>
<p><var>host</var>: The peer’s name
</p>
<p><var>service</var>: non-NULL if this key is specific to a service (e.g. http)
</p>
<p><var>hash_algo</var>: The hash algorithm type
</p>
<p><var>hash</var>: The raw hash
</p>
<p><var>expiration</var>: The expiration time (use 0 to disable expiration)
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will store the provided hash commitment to
the list of stored public keys. The key with the given
hash will be considered valid until the provided expiration time.
</p>
<p>The <code>store</code> variable if non-null specifies a custom backend for
the storage of entries. If it is NULL then the
default file backend will be used.
</p>
<p>Note that this function is not thread safe with the default backend.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<p>The storage and verification functions may be used with the default
text file based back-end, or another back-end may be specified. That
should contain storage and retrieval functions and specified as below.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005ftdb_005finit">gnutls_tdb_init</a> (gnutls_tdb_t* <var>tdb</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftdb_005fdeinit">gnutls_tdb_deinit</a> (gnutls_tdb_t <var>tdb</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftdb_005fset_005fverify_005ffunc">gnutls_tdb_set_verify_func</a> (gnutls_tdb_t <var>tdb</var>, gnutls_tdb_verify_func <var>verify</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftdb_005fset_005fstore_005ffunc">gnutls_tdb_set_store_func</a> (gnutls_tdb_t <var>tdb</var>, gnutls_tdb_store_func <var>store</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005ftdb_005fset_005fstore_005fcommitment_005ffunc">gnutls_tdb_set_store_commitment_func</a> (gnutls_tdb_t <var>tdb</var>, gnutls_tdb_store_commitment_func <var>cstore</var>)</code></dt>
</dl>
<a name="DANE-verification"></a>
<h4 class="subsubsection">6.12.2.2 DANE verification</h4>
<p>Since the DANE library is not included in GnuTLS it requires programs
to be linked against it. This can be achieved with the following commands.
</p>
<div class="example">
<pre class="example">gcc -o foo foo.c `pkg-config gnutls-dane --cflags --libs`
</pre></div>
<p>When a program uses the GNU autoconf system, then the following
line or similar can be used to detect the presence of the library.
</p>
<div class="example">
<pre class="example">PKG_CHECK_MODULES([LIBDANE], [gnutls-dane >= 3.0.0])
AC_SUBST([LIBDANE_CFLAGS])
AC_SUBST([LIBDANE_LIBS])
</pre></div>
<p>The high level functionality provided by the DANE library is shown below.
</p>
<dl>
<dt><a name="index-dane_005fverify_005fcrt"></a>Function: <em>int</em> <strong>dane_verify_crt</strong> <em>(dane_state_t <var>s</var>, const gnutls_datum_t * <var>chain</var>, unsigned <var>chain_size</var>, gnutls_certificate_type_t <var>chain_type</var>, const char * <var>hostname</var>, const char* <var>proto</var>, unsigned int <var>port</var>, unsigned int <var>sflags</var>, unsigned int <var>vflags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>s</var>: A DANE state structure (may be NULL)
</p>
<p><var>chain</var>: A certificate chain
</p>
<p><var>chain_size</var>: The size of the chain
</p>
<p><var>chain_type</var>: The type of the certificate chain
</p>
<p><var>hostname</var>: The hostname associated with the chain
</p>
<p><var>proto</var>: The protocol of the service connecting (e.g. tcp)
</p>
<p><var>port</var>: The port of the service connecting (e.g. 443)
</p>
<p><var>sflags</var>: Flags for the the initialization of <code>s</code> (if NULL)
</p>
<p><var>vflags</var>: Verification flags; should be zero
</p>
<p><var>verify</var>: An OR’ed list of <code>dane_verify_status_t</code> .
</p>
<p>This function will verify the given certificate chain against the
CA constrains and/or the certificate available via DANE.
If no information via DANE can be obtained the flag <code>DANE_VERIFY_NO_DANE_INFO</code>
is set. If a DNSSEC signature is not available for the DANE
record then the verify flag <code>DANE_VERIFY_NO_DNSSEC_DATA</code> is set.
</p>
<p>Due to the many possible options of DANE, there is no single threat
model countered. When notifying the user about DANE verification results
it may be better to mention: DANE verification did not reject the certificate,
rather than mentioning a successful DANE verication.
</p>
<p>If the <code>q</code> parameter is provided it will be used for caching entries.
</p>
<p><strong>Returns:</strong> On success, <code>DANE_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#dane_005fverify_005fsession_005fcrt">dane_verify_session_crt</a> (dane_state_t <var>s</var>, gnutls_session_t <var>session</var>, const char * <var>hostname</var>, const char* <var>proto</var>, unsigned int <var>port</var>, unsigned int <var>sflags</var>, unsigned int <var>vflags</var>, unsigned int * <var>verify</var>)</code></dt>
<dt><code><var>const char *</var> <a href="#dane_005fstrerror">dane_strerror</a> (int <var>error</var>)</code></dt>
</dl>
<p>Note that the <code>dane_state_t</code> structure that is accepted by both
verification functions is optional. It is required when many queries
are performed to facilitate caching.
The following flags are returned by the verify functions to
indicate the status of the verification.
</p>
<div class="float"><a name="dane_005fverify_005fstatus_005ft"></a>
<dl compact="compact">
<dt><code>DANE_VERIFY_CA_CONSTRAINS_VIOLATED</code></dt>
<dd><p>The CA constrains was violated.
</p></dd>
<dt><code>DANE_VERIFY_CERT_DIFFERS</code></dt>
<dd><p>The certificate obtained via DNS differs.
</p></dd>
<dt><code>DANE_VERIFY_NO_DANE_INFO</code></dt>
<dd><p>No DANE data were found in the DNS record.
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 6.2: </strong>The DANE verification status flags.</p></div></div>
<p>In order to generate a DANE TLSA entry to use in a DNS server
you may use danetool (see <a href="#danetool-Invocation">danetool Invocation</a>).
</p>
<hr>
<a name="Parameter-generation"></a>
<div class="header">
<p>
Next: <a href="#Keying-Material-Exporters" accesskey="n" rel="next">Keying Material Exporters</a>, Previous: <a href="#Certificate-verification" accesskey="p" rel="previous">Certificate verification</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Parameter-generation-1"></a>
<h4 class="subsection">6.12.3 Parameter generation</h4>
<a name="index-parameter-generation"></a>
<a name="index-generating-parameters"></a>
<p>Several TLS ciphersuites require additional parameters that
need to be generated or provided by the application. The
Diffie-Hellman based ciphersuites (ANON-DH or DHE), require
the group parameters to be provided. Those can either be
be generated on the fly using <a href="#gnutls_005fdh_005fparams_005fgenerate2">gnutls_dh_params_generate2</a>
or imported from pregenerated data using <a href="#gnutls_005fdh_005fparams_005fimport_005fpkcs3">gnutls_dh_params_import_pkcs3</a>.
The parameters can be used in a <acronym>TLS</acronym> session by calling
<a href="#gnutls_005fcertificate_005fset_005fdh_005fparams">gnutls_certificate_set_dh_params</a> or
<a href="#gnutls_005fanon_005fset_005fserver_005fdh_005fparams">gnutls_anon_set_server_dh_params</a> for anonymous sessions.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fdh_005fparams_005fgenerate2">gnutls_dh_params_generate2</a> (gnutls_dh_params_t <var>params</var>, unsigned int <var>bits</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fdh_005fparams_005fimport_005fpkcs3">gnutls_dh_params_import_pkcs3</a> (gnutls_dh_params_t <var>params</var>, const gnutls_datum_t * <var>pkcs3_params</var>, gnutls_x509_crt_fmt_t <var>format</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005fset_005fdh_005fparams">gnutls_certificate_set_dh_params</a> (gnutls_certificate_credentials_t <var>res</var>, gnutls_dh_params_t <var>dh_params</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fanon_005fset_005fserver_005fdh_005fparams">gnutls_anon_set_server_dh_params</a> (gnutls_anon_server_credentials_t <var>res</var>, gnutls_dh_params_t <var>dh_params</var>)</code></dt>
</dl>
<p>Due to the time-consuming calculations required for the generation
of Diffie-Hellman parameters we suggest against performing generation
of them within an application. The <code>certtool</code> tool can be used to
generate or export known safe values that can be stored in code
or in a configuration file to provide the ability to replace. We also
recommend the usage of <a href="#gnutls_005fsec_005fparam_005fto_005fpk_005fbits">gnutls_sec_param_to_pk_bits</a>
(see <a href="#Selecting-cryptographic-key-sizes">Selecting cryptographic key sizes</a>) to determine
the bit size of the generated parameters.
</p>
<p>Note that the information stored in the generated PKCS #3 structure
changed with GnuTLS 3.0.9. Since that version the <code>privateValueLength</code>
member of the structure is set, allowing the server utilizing the
parameters to use keys of the size of the security parameter. This
provides better performance in key exchange.
</p>
<p>The ciphersuites that involve the RSA-EXPORT key exchange require
additional parameters. Those ciphersuites are rarely used today
because they are by design insecure, thus if you have no requirement
for them, the rest of this section can be skipped. The RSA-EXPORT key exchange
requires 512-bit RSA keys to be generated. It is recommended those
parameters to be refreshed (regenerated) in short intervals. The
following functions can be used for these parameters.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005frsa_005fparams_005fgenerate2">gnutls_rsa_params_generate2</a> (gnutls_rsa_params_t <var>params</var>, unsigned int <var>bits</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams">gnutls_certificate_set_rsa_export_params</a> (gnutls_certificate_credentials_t <var>res</var>, gnutls_rsa_params_t <var>rsa_params</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005frsa_005fparams_005fimport_005fpkcs1">gnutls_rsa_params_import_pkcs1</a> (gnutls_rsa_params_t <var>params</var>, const gnutls_datum_t * <var>pkcs1_params</var>, gnutls_x509_crt_fmt_t <var>format</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005frsa_005fparams_005fexport_005fpkcs1">gnutls_rsa_params_export_pkcs1</a> (gnutls_rsa_params_t <var>params</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned char * <var>params_data</var>, size_t * <var>params_data_size</var>)</code></dt>
</dl>
<p>To allow renewal of the parameters within an application without
accessing the credentials, which are a shared structure,
an alternative interface is available using a callback function.
</p>
<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fparams_005ffunction"></a>Function: <em>void</em> <strong>gnutls_certificate_set_params_function</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_params_function * <var>func</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials_t structure
</p>
<p><var>func</var>: is the function to be called
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<hr>
<a name="Keying-Material-Exporters"></a>
<div class="header">
<p>
Next: <a href="#Channel-Bindings" accesskey="n" rel="next">Channel Bindings</a>, Previous: <a href="#Parameter-generation" accesskey="p" rel="previous">Parameter generation</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Keying-material-exporters"></a>
<h4 class="subsection">6.12.4 Keying material exporters</h4>
<a name="index-keying-material-exporters"></a>
<a name="index-exporting-keying-material"></a>
<p>The TLS PRF can be used by other protocols to derive keys based on
the TLS master secret. The API to use is <a href="#gnutls_005fprf">gnutls_prf</a>. The
function needs to be provided with the label in the parameter
<code>label</code>, and the extra data to mix in the
<code>extra</code> parameter. Depending on whether you want to mix in the
client or server random data first, you can set the
<code>server_random_first</code> parameter.
</p>
<p>For example, after establishing a TLS session using
<a href="#gnutls_005fhandshake">gnutls_handshake</a>, you can invoke the TLS PRF with this call:
</p>
<div class="example">
<pre class="example">#define MYLABEL "EXPORTER-FOO"
#define MYCONTEXT "some context data"
char out[32];
rc = gnutls_prf (session, strlen (MYLABEL), MYLABEL, 0,
strlen (MYCONTEXT), MYCONTEXT, 32, out);
</pre></div>
<p>If you don’t want to mix in the client/server random, there is a
low-level TLS PRF interface called <a href="#gnutls_005fprf_005fraw">gnutls_prf_raw</a>.
</p>
<hr>
<a name="Channel-Bindings"></a>
<div class="header">
<p>
Next: <a href="#Interoperability" accesskey="n" rel="next">Interoperability</a>, Previous: <a href="#Keying-Material-Exporters" accesskey="p" rel="previous">Keying Material Exporters</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Channel-bindings"></a>
<h4 class="subsection">6.12.5 Channel bindings</h4>
<a name="index-channel-bindings"></a>
<p>In user authentication protocols (e.g., EAP or SASL mechanisms) it is
useful to have a unique string that identifies the secure channel that
is used, to bind together the user authentication with the secure
channel. This can protect against man-in-the-middle attacks in some
situations. That unique string is called a “channel binding”. For
background and discussion see [<em>RFC5056</em>].
</p>
<p>In <acronym>GnuTLS</acronym> you can extract a channel binding using the
<a href="#gnutls_005fsession_005fchannel_005fbinding">gnutls_session_channel_binding</a> function. Currently only the
type <code>GNUTLS_CB_TLS_UNIQUE</code> is supported, which corresponds to
the <code>tls-unique</code> channel binding for TLS defined in
[<em>RFC5929</em>].
</p>
<p>The following example describes how to print the channel binding data.
Note that it must be run after a successful TLS handshake.
</p>
<div class="example">
<pre class="example">{
gnutls_datum_t cb;
int rc;
rc = gnutls_session_channel_binding (session,
GNUTLS_CB_TLS_UNIQUE,
&cb);
if (rc)
fprintf (stderr, "Channel binding error: %s\n",
gnutls_strerror (rc));
else
{
size_t i;
printf ("- Channel binding 'tls-unique': ");
for (i = 0; i < cb.size; i++)
printf ("%02x", cb.data[i]);
printf ("\n");
}
}
</pre></div>
<hr>
<a name="Interoperability"></a>
<div class="header">
<p>
Next: <a href="#Compatibility-with-the-OpenSSL-library" accesskey="n" rel="next">Compatibility with the OpenSSL library</a>, Previous: <a href="#Channel-Bindings" accesskey="p" rel="previous">Channel Bindings</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Interoperability-1"></a>
<h4 class="subsection">6.12.6 Interoperability</h4>
<p>The <acronym>TLS</acronym> protocols support many ciphersuites, extensions and version
numbers. As a result, few implementations are
not able to properly interoperate once faced with extensions or version protocols
they do not support and understand. The <acronym>TLS</acronym> protocol allows for a
graceful downgrade to the commonly supported options, but practice shows
it is not always implemented correctly.
</p>
<p>Because there is no way to achieve maximum interoperability with broken peers
without sacrificing security, <acronym>GnuTLS</acronym> ignores such peers by default.
This might not be acceptable in cases where maximum compatibility
is required. Thus we allow enabling compatibility with broken peers using
priority strings (see <a href="#Priority-Strings">Priority Strings</a>). A conservative priority
string that would disable certain <acronym>TLS</acronym> protocol
options that are known to cause compatibility problems, is shown below.
</p><pre class="verbatim">NORMAL:%COMPAT
</pre>
<p>For broken peers that do not tolerate TLS version numbers over TLS 1.0
another priority string is:
</p><pre class="verbatim">NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:+VERS-SSL3.0:%COMPAT
</pre><p>This priority string will in addition to above, only enable SSL 3.0 and
TLS 1.0 as protocols. Note however that
there are known attacks against those protocol versions, especially over
the CBC-mode ciphersuites. To mitigate them another priority string
that only allows the stream cipher ARCFOUR is below.
</p><pre class="verbatim">NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:+VERS-SSL3.0:-CIPHER-ALL:+ARCFOUR-128:%COMPAT
</pre>
<hr>
<a name="Compatibility-with-the-OpenSSL-library"></a>
<div class="header">
<p>
Previous: <a href="#Interoperability" accesskey="p" rel="previous">Interoperability</a>, Up: <a href="#Advanced-topics" accesskey="u" rel="up">Advanced topics</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Compatibility-with-the-OpenSSL-library-1"></a>
<h4 class="subsection">6.12.7 Compatibility with the OpenSSL library</h4>
<a name="index-OpenSSL"></a>
<p>To ease <acronym>GnuTLS</acronym>’ integration with existing applications, a
compatibility layer with the OpenSSL library is included
in the <code>gnutls-openssl</code> library. This compatibility layer is not
complete and it is not intended to completely re-implement the OpenSSL
API with <acronym>GnuTLS</acronym>. It only provides limited source-level
compatibility.
</p>
<p>The prototypes for the compatibility functions are in the
<samp>gnutls/openssl.h</samp> header file. The limitations
imposed by the compatibility layer include:
</p>
<ul>
<li> Error handling is not thread safe.
</li></ul>
<hr>
<a name="GnuTLS-application-examples"></a>
<div class="header">
<p>
Next: <a href="#Using-GnuTLS-as-a-cryptographic-library" accesskey="n" rel="next">Using GnuTLS as a cryptographic library</a>, Previous: <a href="#How-to-use-GnuTLS-in-applications" accesskey="p" rel="previous">How to use GnuTLS in applications</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="GnuTLS-application-examples-1"></a>
<h2 class="chapter">7 GnuTLS application examples</h2>
<a name="examples"></a><a name="index-example-programs"></a>
<a name="index-examples"></a>
<p>In this chapter several examples of real-world use cases are listed.
The examples are simplified to promote readability and contain little or
no error checking.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Client-examples" accesskey="1">Client examples</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Server-examples" accesskey="2">Server examples</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#OCSP-example" accesskey="3">OCSP example</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Miscellaneous-examples" accesskey="4">Miscellaneous examples</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#XSSL-examples" accesskey="5">XSSL examples</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Client-examples"></a>
<div class="header">
<p>
Next: <a href="#Server-examples" accesskey="n" rel="next">Server examples</a>, Up: <a href="#GnuTLS-application-examples" accesskey="u" rel="up">GnuTLS application examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Client-examples-1"></a>
<h3 class="section">7.1 Client examples</h3>
<p>This section contains examples of <acronym>TLS</acronym> and <acronym>SSL</acronym>
clients, using <acronym>GnuTLS</acronym>. Note that some of the examples require functions
implemented by another example.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Simple-client-example-with-X_002e509-certificate-support" accesskey="1">Simple client example with X.509 certificate support</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simple-client-example-with-SSH_002dstyle-certificate-verification" accesskey="2">Simple client example with SSH-style certificate verification</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simple-client-example-with-anonymous-authentication" accesskey="3">Simple client example with anonymous authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simple-Datagram-TLS-client-example" accesskey="4">Simple Datagram TLS client example</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Obtaining-session-information" accesskey="5">Obtaining session information</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Using-a-callback-to-select-the-certificate-to-use" accesskey="6">Using a callback to select the certificate to use</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Verifying-a-certificate" accesskey="7">Verifying a certificate</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Client-using-a-smart-card-with-TLS" accesskey="8">Client using a smart card with TLS</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Client-with-Resume-capability-example" accesskey="9">Client with Resume capability example</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simple-client-example-with-SRP-authentication">Simple client example with SRP authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Simple-client-example-in-C_002b_002b">Simple client example in C++</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Helper-functions-for-TCP-connections">Helper functions for TCP connections</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Helper-functions-for-UDP-connections">Helper functions for UDP connections</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Simple-client-example-with-X_002e509-certificate-support"></a>
<div class="header">
<p>
Next: <a href="#Simple-client-example-with-SSH_002dstyle-certificate-verification" accesskey="n" rel="next">Simple client example with SSH-style certificate verification</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-client-example-with-X_002e509-certificate-support-1"></a>
<h4 class="subsection">7.1.1 Simple client example with <acronym>X.509</acronym> certificate support</h4>
<a name="ex_003averify"></a>
<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, which uses the high level verification
functions for certificates, but does not support session
resumption.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "examples.h"
/* A very basic TLS client, with X.509 authentication and server certificate
* verification. Note that error checking for missing files etc. is omitted
* for simplicity.
*/
#define MAX_BUF 1024
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
#define MSG "GET / HTTP/1.0\r\n\r\n"
extern int tcp_connect (void);
extern void tcp_close (int sd);
static int _verify_certificate_callback (gnutls_session_t session);
int main (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
const char *err;
gnutls_certificate_credentials_t xcred;
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);
gnutls_certificate_set_verify_function (xcred, _verify_certificate_callback);
/* If client holds a certificate it can be set using the following:
*
gnutls_certificate_set_x509_key_file (xcred,
"cert.pem", "key.pem",
GNUTLS_X509_FMT_PEM);
*/
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
gnutls_session_set_ptr (session, (void *) "my_host_name");
gnutls_server_name_set (session, GNUTLS_NAME_DNS, "my_host_name",
strlen("my_host_name"));
/* Use default priorities */
ret = gnutls_priority_set_direct (session, "NORMAL", &err);
if (ret < 0)
{
if (ret == GNUTLS_E_INVALID_REQUEST)
{
fprintf (stderr, "Syntax error at: %s\n", err);
}
exit (1);
}
/* 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);
gnutls_handshake_set_timeout (session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
/* Perform the TLS handshake
*/
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
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_certificate_free_credentials (xcred);
gnutls_global_deinit ();
return 0;
}
/* This function will verify the peer's certificate, and check
* if the hostname matches, as well as the activation, expiration dates.
*/
static int
_verify_certificate_callback (gnutls_session_t session)
{
unsigned int status;
int ret, type;
const char *hostname;
gnutls_datum_t out;
/* read hostname */
hostname = gnutls_session_get_ptr (session);
/* 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_peers3 (session, hostname, &status);
if (ret < 0)
{
printf ("Error\n");
return GNUTLS_E_CERTIFICATE_ERROR;
}
type = gnutls_certificate_type_get (session);
ret = gnutls_certificate_verification_status_print( status, type, &out, 0);
if (ret < 0)
{
printf ("Error\n");
return GNUTLS_E_CERTIFICATE_ERROR;
}
printf ("%s", out.data);
gnutls_free(out.data);
if (status != 0) /* Certificate is not trusted */
return GNUTLS_E_CERTIFICATE_ERROR;
/* notify gnutls to continue handshake normally */
return 0;
}
</pre>
<hr>
<a name="Simple-client-example-with-SSH_002dstyle-certificate-verification"></a>
<div class="header">
<p>
Next: <a href="#Simple-client-example-with-anonymous-authentication" accesskey="n" rel="next">Simple client example with anonymous authentication</a>, Previous: <a href="#Simple-client-example-with-X_002e509-certificate-support" accesskey="p" rel="previous">Simple client example with X.509 certificate support</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-client-example-with-SSH_002dstyle-certificate-verification-1"></a>
<h4 class="subsection">7.1.2 Simple client example with SSH-style certificate verification</h4>
<p>This is an alternative verification function that will use the
X.509 certificate authorities for verification, but also assume an
trust on first use (SSH-like) authentication system. That is the user is
prompted on unknown public keys and known public keys are considered
trusted.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "examples.h"
/* This function will verify the peer's certificate, check
* if the hostname matches. In addition it will perform an
* SSH-style authentication, where ultimately trusted keys
* are only the keys that have been seen before.
*/
int
_ssh_verify_certificate_callback (gnutls_session_t session)
{
unsigned int status;
const gnutls_datum_t *cert_list;
unsigned int cert_list_size;
int ret, type;
gnutls_datum_t out;
const char *hostname;
/* read hostname */
hostname = gnutls_session_get_ptr (session);
/* 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_peers3 (session, hostname, &status);
if (ret < 0)
{
printf ("Error\n");
return GNUTLS_E_CERTIFICATE_ERROR;
}
type = gnutls_certificate_type_get (session);
ret = gnutls_certificate_verification_status_print( status, type, &out, 0);
if (ret < 0)
{
printf ("Error\n");
return GNUTLS_E_CERTIFICATE_ERROR;
}
printf ("%s", out.data);
gnutls_free(out.data);
if (status != 0) /* Certificate is not trusted */
return GNUTLS_E_CERTIFICATE_ERROR;
/* Do SSH verification */
cert_list = gnutls_certificate_get_peers (session, &cert_list_size);
if (cert_list == NULL)
{
printf ("No certificate was found!\n");
return GNUTLS_E_CERTIFICATE_ERROR;
}
/* service may be obtained alternatively using getservbyport() */
ret = gnutls_verify_stored_pubkey(NULL, NULL, hostname, "https",
type, &cert_list[0], 0);
if (ret == GNUTLS_E_NO_CERTIFICATE_FOUND)
{
printf("Host %s is not known.", hostname);
if (status == 0)
printf("Its certificate is valid for %s.\n", hostname);
/* the certificate must be printed and user must be asked on
* whether it is trustworthy. --see gnutls_x509_crt_print() */
/* if not trusted */
return GNUTLS_E_CERTIFICATE_ERROR;
}
else if (ret == GNUTLS_E_CERTIFICATE_KEY_MISMATCH)
{
printf("Warning: host %s is known but has another key associated.", hostname);
printf("It might be that the server has multiple keys, or you are under attack\n");
if (status == 0)
printf("Its certificate is valid for %s.\n", hostname);
/* the certificate must be printed and user must be asked on
* whether it is trustworthy. --see gnutls_x509_crt_print() */
/* if not trusted */
return GNUTLS_E_CERTIFICATE_ERROR;
}
else if (ret < 0)
{
printf("gnutls_verify_stored_pubkey: %s\n", gnutls_strerror(ret));
return ret;
}
/* user trusts the key -> store it */
if (ret != 0)
{
ret = gnutls_store_pubkey(NULL, NULL, hostname, "https",
type, &cert_list[0], 0, 0);
if (ret < 0)
printf("gnutls_store_pubkey: %s\n", gnutls_strerror(ret));
}
/* notify gnutls to continue handshake normally */
return 0;
}
</pre>
<hr>
<a name="Simple-client-example-with-anonymous-authentication"></a>
<div class="header">
<p>
Next: <a href="#Simple-Datagram-TLS-client-example" accesskey="n" rel="next">Simple Datagram TLS client example</a>, Previous: <a href="#Simple-client-example-with-SSH_002dstyle-certificate-verification" accesskey="p" rel="previous">Simple client example with SSH-style certificate verification</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-client-example-with-anonymous-authentication-1"></a>
<h4 class="subsection">7.1.3 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 are integrity protected and encrypted from
passive eavesdroppers.
</p>
<p>Note that due to the vulnerable nature of this method very few public
servers support it.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.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 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. */
gnutls_global_init ();
gnutls_anon_allocate_client_credentials (&anoncred);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_priority_set_direct (session, "PERFORMANCE:+ANON-ECDH:+ANON-DH",
NULL);
/* 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);
gnutls_handshake_set_timeout (session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
/* Perform the TLS handshake
*/
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
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_anon_free_client_credentials (anoncred);
gnutls_global_deinit ();
return 0;
}
</pre>
<hr>
<a name="Simple-Datagram-TLS-client-example"></a>
<div class="header">
<p>
Next: <a href="#Obtaining-session-information" accesskey="n" rel="next">Obtaining session information</a>, Previous: <a href="#Simple-client-example-with-anonymous-authentication" accesskey="p" rel="previous">Simple client example with anonymous authentication</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-datagram-TLS-client-example"></a>
<h4 class="subsection">7.1.4 Simple datagram <acronym>TLS</acronym> client example</h4>
<p>This is a client that uses <acronym>UDP</acronym> to connect to a
server. This is the <acronym>DTLS</acronym> equivalent to the TLS example
with X.509 certificates.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/dtls.h>
/* A very basic Datagram TLS client, over UDP with X.509 authentication.
*/
#define MAX_BUF 1024
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
#define MSG "GET / HTTP/1.0\r\n\r\n"
extern int udp_connect (void);
extern void udp_close (int sd);
extern int verify_certificate_callback (gnutls_session_t session);
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
char buffer[MAX_BUF + 1];
const char *err;
gnutls_certificate_credentials_t xcred;
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);
gnutls_certificate_set_verify_function (xcred, verify_certificate_callback);
/* Initialize TLS session */
gnutls_init (&session, GNUTLS_CLIENT | GNUTLS_DATAGRAM);
/* Use default priorities */
ret = gnutls_priority_set_direct (session, "NORMAL", &err);
if (ret < 0)
{
if (ret == GNUTLS_E_INVALID_REQUEST)
{
fprintf (stderr, "Syntax error at: %s\n", err);
}
exit (1);
}
/* put the x509 credentials to the current session */
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, xcred);
gnutls_server_name_set (session, GNUTLS_NAME_DNS, "my_host_name",
strlen("my_host_name"));
/* connect to the peer */
sd = udp_connect ();
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
/* set the connection MTU */
gnutls_dtls_set_mtu (session, 1000);
gnutls_handshake_set_timeout (session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
/* Perform the TLS handshake */
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
if (ret > 0)
{
printf ("- Received %d bytes: ", ret);
for (ii = 0; ii < ret; ii++)
{
fputc (buffer[ii], stdout);
}
fputs ("\n", stdout);
}
/* It is suggested not to use GNUTLS_SHUT_RDWR in DTLS
* connections because the peer's closure message might
* be lost */
gnutls_bye (session, GNUTLS_SHUT_WR);
end:
udp_close (sd);
gnutls_deinit (session);
gnutls_certificate_free_credentials (xcred);
gnutls_global_deinit ();
return 0;
}
</pre>
<hr>
<a name="Obtaining-session-information"></a>
<div class="header">
<p>
Next: <a href="#Using-a-callback-to-select-the-certificate-to-use" accesskey="n" rel="next">Using a callback to select the certificate to use</a>, Previous: <a href="#Simple-Datagram-TLS-client-example" accesskey="p" rel="previous">Simple Datagram TLS client example</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Obtaining-session-information-1"></a>
<h4 class="subsection">7.1.5 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>.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "examples.h"
/* 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;
int dhe, ecdh;
dhe = ecdh = 0;
/* 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_IA:
printf ("- TLS/IA session\n");
break;
#ifdef ENABLE_SRP
case GNUTLS_CRD_SRP:
printf ("- SRP session with username %s\n",
gnutls_srp_server_get_username (session));
break;
#endif
case GNUTLS_CRD_PSK:
/* This returns NULL in server side.
*/
if (gnutls_psk_client_get_hint (session) != NULL)
printf ("- PSK authentication. PSK hint '%s'\n",
gnutls_psk_client_get_hint (session));
/* This returns NULL in client side.
*/
if (gnutls_psk_server_get_username (session) != NULL)
printf ("- PSK authentication. Connected as '%s'\n",
gnutls_psk_server_get_username (session));
if (kx == GNUTLS_KX_ECDHE_PSK)
ecdh = 1;
else if (kx == GNUTLS_KX_DHE_PSK)
dhe = 1;
break;
case GNUTLS_CRD_ANON: /* anonymous authentication */
printf ("- Anonymous authentication.\n");
if (kx == GNUTLS_KX_ANON_ECDH)
ecdh = 1;
else if (kx == GNUTLS_KX_ANON_DH)
dhe = 1;
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)
dhe = 1;
else if (kx == GNUTLS_KX_ECDHE_RSA || kx == GNUTLS_KX_ECDHE_ECDSA)
ecdh = 1;
/* if the certificate list is available, then
* print some information about it.
*/
print_x509_certificate_info (session);
} /* switch */
if (ecdh != 0)
printf ("- Ephemeral ECDH using curve %s\n",
gnutls_ecc_curve_get_name (gnutls_ecc_curve_get (session)));
else if (dhe != 0)
printf ("- Ephemeral DH using prime of %d bits\n",
gnutls_dh_get_prime_bits (session));
/* 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>
<hr>
<a name="Using-a-callback-to-select-the-certificate-to-use"></a>
<div class="header">
<p>
Next: <a href="#Verifying-a-certificate" accesskey="n" rel="next">Verifying a certificate</a>, Previous: <a href="#Obtaining-session-information" accesskey="p" rel="previous">Obtaining session information</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Using-a-callback-to-select-the-certificate-to-use-1"></a>
<h4 class="subsection">7.1.6 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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.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 "/etc/ssl/certs/ca-certificates.crt"
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_pcert_st ** pcert,
unsigned int *pcert_length, gnutls_privkey_t * pkey);
gnutls_pcert_st pcrt;
gnutls_privkey_t key;
/* Load the certificate and the private key.
*/
static void
load_keys (void)
{
int ret;
gnutls_datum_t data;
ret = gnutls_load_file (CERT_FILE, &data);
if (ret < 0)
{
fprintf (stderr, "*** Error loading certificate file.\n");
exit (1);
}
ret = gnutls_pcert_import_x509_raw (&pcrt, &data, GNUTLS_X509_FMT_PEM, 0);
if (ret < 0)
{
fprintf (stderr, "*** Error loading certificate file: %s\n",
gnutls_strerror (ret));
exit (1);
}
gnutls_free(data.data);
ret = gnutls_load_file (KEY_FILE, &data);
if (ret < 0)
{
fprintf (stderr, "*** Error loading key file.\n");
exit (1);
}
gnutls_privkey_init (&key);
ret = gnutls_privkey_import_x509_raw (key, &data, GNUTLS_X509_FMT_PEM, NULL, 0);
if (ret < 0)
{
fprintf (stderr, "*** Error loading key file: %s\n",
gnutls_strerror (ret));
exit (1);
}
gnutls_free(data.data);
}
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
gnutls_priority_t priorities_cache;
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);
/* priorities */
gnutls_priority_init (&priorities_cache, "NORMAL", NULL);
/* sets the trusted cas file
*/
gnutls_certificate_set_x509_trust_file (xcred, CAFILE, GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_retrieve_function2 (xcred, cert_callback);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_priority_set (session, priorities_cache);
/* 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_priority_deinit (priorities_cache);
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_pcert_st ** pcert,
unsigned int *pcert_length, gnutls_privkey_t * pkey)
{
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)
{
*pcert_length = 1;
*pcert = &pcrt;
*pkey = key;
}
else
{
return -1;
}
return 0;
}
</pre>
<hr>
<a name="Verifying-a-certificate"></a>
<div class="header">
<p>
Next: <a href="#Client-using-a-smart-card-with-TLS" accesskey="n" rel="next">Client using a smart card with TLS</a>, Previous: <a href="#Using-a-callback-to-select-the-certificate-to-use" accesskey="p" rel="previous">Using a callback to select the certificate to use</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Verifying-a-certificate-1"></a>
<h4 class="subsection">7.1.7 Verifying a certificate</h4>
<a name="ex_003averify2"></a>
<p>An example is listed below which uses the high level verification
functions to verify a given certificate list.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "examples.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 int print_details_func (gnutls_x509_crt_t cert,
gnutls_x509_crt_t issuer,
gnutls_x509_crl_t crl,
unsigned int verification_output);
/* This function will try to verify the peer's certificate chain, and
* also check if the hostname matches.
*/
void
verify_certificate_chain (const char *hostname,
const gnutls_datum_t * cert_chain,
int cert_chain_length)
{
int i;
gnutls_x509_trust_list_t tlist;
gnutls_x509_crt_t *cert;
unsigned int output;
/* Initialize the trusted certificate list. This should be done
* once on initialization. gnutls_x509_crt_list_import2() and
* gnutls_x509_crl_list_import2() can be used to load them.
*/
gnutls_x509_trust_list_init (&tlist, 0);
gnutls_x509_trust_list_add_cas (tlist, ca_list, ca_list_size, 0);
gnutls_x509_trust_list_add_crls (tlist, crl_list, crl_list_size,
GNUTLS_TL_VERIFY_CRL, 0);
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);
}
gnutls_x509_trust_list_verify_named_crt (tlist, cert[0], hostname,
strlen (hostname),
GNUTLS_VERIFY_DISABLE_CRL_CHECKS,
&output, print_details_func);
/* if this certificate is not explicitly trusted verify against CAs
*/
if (output != 0)
{
gnutls_x509_trust_list_verify_crt (tlist, cert, cert_chain_length, 0,
&output, print_details_func);
}
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");
if (output & GNUTLS_CERT_NOT_ACTIVATED)
fprintf (stderr, ": not yet activated\n");
if (output & GNUTLS_CERT_EXPIRED)
fprintf (stderr, ": expired\n");
fprintf (stderr, "\n");
}
else
fprintf (stderr, "Trusted\n");
/* 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);
}
gnutls_x509_trust_list_deinit (tlist, 1);
return;
}
static int
print_details_func (gnutls_x509_crt_t cert,
gnutls_x509_crt_t issuer, gnutls_x509_crl_t crl,
unsigned int verification_output)
{
char name[512];
char issuer_name[512];
size_t name_size;
size_t issuer_name_size;
issuer_name_size = sizeof (issuer_name);
gnutls_x509_crt_get_issuer_dn (cert, issuer_name, &issuer_name_size);
name_size = sizeof (name);
gnutls_x509_crt_get_dn (cert, name, &name_size);
fprintf (stdout, "\tSubject: %s\n", name);
fprintf (stdout, "\tIssuer: %s\n", issuer_name);
if (issuer != NULL)
{
issuer_name_size = sizeof (issuer_name);
gnutls_x509_crt_get_dn (issuer, issuer_name, &issuer_name_size);
fprintf (stdout, "\tVerified against: %s\n", issuer_name);
}
if (crl != NULL)
{
issuer_name_size = sizeof (issuer_name);
gnutls_x509_crl_get_issuer_dn (crl, issuer_name, &issuer_name_size);
fprintf (stdout, "\tVerified against CRL of: %s\n", issuer_name);
}
fprintf (stdout, "\tVerification output: %x\n\n", verification_output);
return 0;
}
</pre>
<hr>
<a name="Client-using-a-smart-card-with-TLS"></a>
<div class="header">
<p>
Next: <a href="#Client-with-Resume-capability-example" accesskey="n" rel="next">Client with Resume capability example</a>, Previous: <a href="#Verifying-a-certificate" accesskey="p" rel="previous">Verifying a certificate</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Using-a-smart-card-with-TLS"></a>
<h4 class="subsection">7.1.8 Using a smart card with TLS</h4>
<a name="ex_003apkcs11_002dclient"></a><a name="index-Smart-card-example"></a>
<p>This example will demonstrate how to load keys and certificates
from a smart-card or any other <acronym>PKCS</acronym> #11 token, and
use it in a TLS connection.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/pkcs11.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <getpass.h> /* for getpass() */
/* A TLS client that loads the certificate and key.
*/
#define MAX_BUF 1024
#define MSG "GET / HTTP/1.0\r\n\r\n"
#define MIN(x,y) (((x)<(y))?(x):(y))
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
/* The URLs of the objects can be obtained
* using p11tool --list-all --login
*/
#define KEY_URL "pkcs11:manufacturer=SomeManufacturer;object=Private%20Key" \
";objecttype=private;id=%db%5b%3e%b5%72%33"
#define CERT_URL "pkcs11:manufacturer=SomeManufacturer;object=Certificate;" \
"objecttype=cert;id=db%5b%3e%b5%72%33"
extern int tcp_connect (void);
extern void tcp_close (int sd);
static int
pin_callback (void *user, int attempt, const char *token_url,
const char *token_label, unsigned int flags, char *pin,
size_t pin_max)
{
const char *password;
int len;
printf ("PIN required for token '%s' with URL '%s'\n", token_label,
token_url);
if (flags & GNUTLS_PIN_FINAL_TRY)
printf ("*** This is the final try before locking!\n");
if (flags & GNUTLS_PIN_COUNT_LOW)
printf ("*** Only few tries left before locking!\n");
if (flags & GNUTLS_PIN_WRONG)
printf ("*** Wrong PIN\n");
password = getpass ("Enter pin: ");
if (password == NULL || password[0] == 0)
{
fprintf (stderr, "No password given\n");
exit (1);
}
len = MIN (pin_max, strlen (password));
memcpy (pin, password, len);
pin[len] = 0;
return 0;
}
int
main (void)
{
int ret, sd, ii;
gnutls_session_t session;
gnutls_priority_t priorities_cache;
char buffer[MAX_BUF + 1];
gnutls_certificate_credentials_t xcred;
/* Allow connections to servers that have OpenPGP keys as well.
*/
gnutls_global_init ();
/* PKCS11 private key operations might require PIN.
* Register a callback.
*/
gnutls_pkcs11_set_pin_function (pin_callback, NULL);
/* X509 stuff */
gnutls_certificate_allocate_credentials (&xcred);
/* priorities */
gnutls_priority_init (&priorities_cache, "NORMAL", NULL);
/* sets the trusted cas file
*/
gnutls_certificate_set_x509_trust_file (xcred, CAFILE, GNUTLS_X509_FMT_PEM);
gnutls_certificate_set_x509_key_file (xcred, CERT_URL, KEY_URL, GNUTLS_X509_FMT_DER);
/* Initialize TLS session
*/
gnutls_init (&session, GNUTLS_CLIENT);
/* Use default priorities */
gnutls_priority_set (session, priorities_cache);
/* 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_priority_deinit (priorities_cache);
gnutls_global_deinit ();
return 0;
}
</pre>
<hr>
<a name="Client-with-Resume-capability-example"></a>
<div class="header">
<p>
Next: <a href="#Simple-client-example-with-SRP-authentication" accesskey="n" rel="next">Simple client example with SRP authentication</a>, Previous: <a href="#Client-using-a-smart-card-with-TLS" accesskey="p" rel="previous">Client using a smart card with TLS</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Client-with-resume-capability-example"></a>
<h4 class="subsection">7.1.9 Client with resume capability example</h4>
<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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#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 CAFILE "/etc/ssl/certs/ca-certificates.crt"
#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 = NULL;
size_t session_data_size = 0;
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_priority_set_direct (session, "PERFORMANCE:!ARCFOUR-128", NULL);
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);
gnutls_handshake_set_timeout (session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
/* Perform the TLS handshake
*/
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
else if (ret < 0)
{
fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
goto end;
}
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);
} /* for() */
gnutls_certificate_free_credentials (xcred);
gnutls_global_deinit ();
return 0;
}
</pre>
<hr>
<a name="Simple-client-example-with-SRP-authentication"></a>
<div class="header">
<p>
Next: <a href="#Simple-client-example-in-C_002b_002b" accesskey="n" rel="next">Simple client example in C++</a>, Previous: <a href="#Client-with-Resume-capability-example" accesskey="p" rel="previous">Client with Resume capability example</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-client-example-with-SRP-authentication-1"></a>
<h4 class="subsection">7.1.10 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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.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 USERNAME "user"
#define PASSWORD "pass"
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
#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_srp_client_credentials_t srp_cred;
gnutls_certificate_credentials_t cert_cred;
gnutls_global_init ();
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_priority_set_direct (session, "NORMAL:+SRP:+SRP-RSA:+SRP-DSS", NULL);
/* 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);
gnutls_handshake_set_timeout (session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
/* Perform the TLS handshake
*/
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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) != 0 || 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>
<hr>
<a name="Simple-client-example-in-C_002b_002b"></a>
<div class="header">
<p>
Next: <a href="#Helper-functions-for-TCP-connections" accesskey="n" rel="next">Helper functions for TCP connections</a>, Previous: <a href="#Simple-client-example-with-SRP-authentication" accesskey="p" rel="previous">Simple client example with SRP authentication</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-client-example-using-the-C_002b_002b-API"></a>
<h4 class="subsection">7.1.11 Simple client example using the C++ API</h4>
<p>The following client is a simple example of a client client utilizing
the GnuTLS C++ API.
</p>
<pre class="verbatim">#include <config.h>
#include <iostream>
#include <stdexcept>
#include <gnutls/gnutls.h>
#include <gnutls/gnutlsxx.h>
#include <cstring> /* for strlen */
/* A very basic TLS client, with anonymous authentication.
* written by Eduardo Villanueva Che.
*/
#define MAX_BUF 1024
#define SA struct sockaddr
#define CAFILE "ca.pem"
#define MSG "GET / HTTP/1.0\r\n\r\n"
extern "C"
{
int tcp_connect(void);
void tcp_close(int sd);
}
int main(void)
{
int sd = -1;
gnutls_global_init();
try
{
/* Allow connections to servers that have OpenPGP keys as well.
*/
gnutls::client_session session;
/* X509 stuff */
gnutls::certificate_credentials credentials;
/* sets the trusted cas file
*/
credentials.set_x509_trust_file(CAFILE, GNUTLS_X509_FMT_PEM);
/* put the x509 credentials to the current session
*/
session.set_credentials(credentials);
/* Use default priorities */
session.set_priority ("NORMAL", NULL);
/* connect to the peer
*/
sd = tcp_connect();
session.set_transport_ptr((gnutls_transport_ptr_t) (ptrdiff_t)sd);
/* Perform the TLS handshake
*/
int ret = session.handshake();
if (ret < 0)
{
throw std::runtime_error("Handshake failed");
}
else
{
std::cout << "- Handshake was completed" << std::endl;
}
session.send(MSG, strlen(MSG));
char buffer[MAX_BUF + 1];
ret = session.recv(buffer, MAX_BUF);
if (ret == 0)
{
throw std::runtime_error("Peer has closed the TLS connection");
}
else if (ret < 0)
{
throw std::runtime_error(gnutls_strerror(ret));
}
std::cout << "- Received " << ret << " bytes:" << std::endl;
std::cout.write(buffer, ret);
std::cout << std::endl;
session.bye(GNUTLS_SHUT_RDWR);
}
catch (std::exception &ex)
{
std::cerr << "Exception caught: " << ex.what() << std::endl;
}
if (sd != -1)
tcp_close(sd);
gnutls_global_deinit();
return 0;
}
</pre>
<hr>
<a name="Helper-functions-for-TCP-connections"></a>
<div class="header">
<p>
Next: <a href="#Helper-functions-for-UDP-connections" accesskey="n" rel="next">Helper functions for UDP connections</a>, Previous: <a href="#Simple-client-example-in-C_002b_002b" accesskey="p" rel="previous">Simple client example in C++</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Helper-functions-for-TCP-connections-1"></a>
<h4 class="subsection">7.1.12 Helper functions for TCP connections</h4>
<p>Those helper function abstract away TCP connection handling from the
other examples. It is required to build some examples.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
/* tcp.c */
int tcp_connect (void);
void tcp_close (int sd);
/* Connects to the peer and returns a socket
* descriptor.
*/
extern int
tcp_connect (void)
{
const char *PORT = "5556";
const char *SERVER = "127.0.0.1";
int err, sd;
struct sockaddr_in sa;
/* connects to server
*/
sd = socket (AF_INET, SOCK_STREAM, 0);
memset (&sa, '\0', sizeof (sa));
sa.sin_family = AF_INET;
sa.sin_port = htons (atoi (PORT));
inet_pton (AF_INET, SERVER, &sa.sin_addr);
err = connect (sd, (struct sockaddr *) & sa, sizeof (sa));
if (err < 0)
{
fprintf (stderr, "Connect error\n");
exit (1);
}
return sd;
}
/* closes the given socket descriptor.
*/
extern void
tcp_close (int sd)
{
shutdown (sd, SHUT_RDWR); /* no more receptions */
close (sd);
}
</pre>
<hr>
<a name="Helper-functions-for-UDP-connections"></a>
<div class="header">
<p>
Previous: <a href="#Helper-functions-for-TCP-connections" accesskey="p" rel="previous">Helper functions for TCP connections</a>, Up: <a href="#Client-examples" accesskey="u" rel="up">Client examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Helper-functions-for-UDP-connections-1"></a>
<h4 class="subsection">7.1.13 Helper functions for UDP connections</h4>
<p>The UDP helper functions abstract away UDP connection handling from the
other examples. It is required to build the examples using UDP.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
/* udp.c */
int udp_connect (void);
void udp_close (int sd);
/* Connects to the peer and returns a socket
* descriptor.
*/
extern int
udp_connect (void)
{
const char *PORT = "5557";
const char *SERVER = "127.0.0.1";
int err, sd, optval;
struct sockaddr_in sa;
/* connects to server
*/
sd = socket (AF_INET, SOCK_DGRAM, 0);
memset (&sa, '\0', sizeof (sa));
sa.sin_family = AF_INET;
sa.sin_port = htons (atoi (PORT));
inet_pton (AF_INET, SERVER, &sa.sin_addr);
#if defined(IP_DONTFRAG)
optval = 1;
setsockopt (sd, IPPROTO_IP, IP_DONTFRAG,
(const void *) &optval, sizeof (optval));
#elif defined(IP_MTU_DISCOVER)
optval = IP_PMTUDISC_DO;
setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER,
(const void*) &optval, sizeof (optval));
#endif
err = connect (sd, (struct sockaddr *) & sa, sizeof (sa));
if (err < 0)
{
fprintf (stderr, "Connect error\n");
exit (1);
}
return sd;
}
/* closes the given socket descriptor.
*/
extern void
udp_close (int sd)
{
close (sd);
}
</pre>
<hr>
<a name="Server-examples"></a>
<div class="header">
<p>
Next: <a href="#OCSP-example" accesskey="n" rel="next">OCSP example</a>, Previous: <a href="#Client-examples" accesskey="p" rel="previous">Client examples</a>, Up: <a href="#GnuTLS-application-examples" accesskey="u" rel="up">GnuTLS application examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Server-examples-1"></a>
<h3 class="section">7.2 Server examples</h3>
<p>This section contains examples of <acronym>TLS</acronym> and <acronym>SSL</acronym>
servers, using <acronym>GnuTLS</acronym>.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Echo-server-with-X_002e509-authentication" accesskey="1">Echo server with X.509 authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Echo-server-with-OpenPGP-authentication" accesskey="2">Echo server with OpenPGP authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Echo-server-with-SRP-authentication" accesskey="3">Echo server with SRP authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Echo-server-with-anonymous-authentication" accesskey="4">Echo server with anonymous authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#DTLS-echo-server-with-X_002e509-authentication" accesskey="5">DTLS echo server with X.509 authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Echo-server-with-X_002e509-authentication"></a>
<div class="header">
<p>
Next: <a href="#Echo-server-with-OpenPGP-authentication" accesskey="n" rel="next">Echo server with OpenPGP authentication</a>, Up: <a href="#Server-examples" accesskey="u" rel="up">Server examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Echo-server-with-X_002e509-authentication-1"></a>
<h4 class="subsection">7.2.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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#define KEYFILE "key.pem"
#define CERTFILE "cert.pem"
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
#define CRLFILE "crl.pem"
/* This is a sample TLS 1.0 echo server, using X.509 authentication.
*/
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
/* These are global */
static gnutls_dh_params_t dh_params;
static int
generate_dh_params (void)
{
unsigned int bits =
gnutls_sec_param_to_pk_bits (GNUTLS_PK_DH, GNUTLS_SEC_PARAM_LEGACY);
/* Generate Diffie-Hellman parameters - for use with DHE
* kx algorithms. When short bit length is used, it might
* be wise to regenerate parameters often.
*/
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, bits);
return 0;
}
int
main (void)
{
int listen_sd;
int sd, ret;
gnutls_certificate_credentials_t x509_cred;
gnutls_priority_t priority_cache;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
socklen_t 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_system_trust(xcred); */
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);
ret = gnutls_certificate_set_x509_key_file (x509_cred, CERTFILE, KEYFILE,
GNUTLS_X509_FMT_PEM);
if (ret < 0)
{
printf("No certificate or key were found\n");
exit(1);
}
generate_dh_params ();
gnutls_priority_init (&priority_cache, "PERFORMANCE:%SERVER_PRECEDENCE", NULL);
gnutls_certificate_set_dh_params (x509_cred, dh_params);
/* Socket operations
*/
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
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, (void *) &optval,
sizeof (int));
bind (listen_sd, (struct sockaddr *) & sa_serv, sizeof (sa_serv));
listen (listen_sd, 1024);
printf ("Server ready. Listening to port '%d'.\n\n", PORT);
client_len = sizeof (sa_cli);
for (;;)
{
gnutls_init (&session, GNUTLS_SERVER);
gnutls_priority_set (session, priority_cache);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
/* We don't request any certificate from the client.
* If we did we would need to verify it.
*/
gnutls_certificate_server_set_request (session, GNUTLS_CERT_IGNORE);
sd = accept (listen_sd, (struct sockaddr *) & 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);
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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); */
for (;;)
{
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
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, ret);
}
}
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_priority_deinit (priority_cache);
gnutls_global_deinit ();
return 0;
}
</pre>
<hr>
<a name="Echo-server-with-OpenPGP-authentication"></a>
<div class="header">
<p>
Next: <a href="#Echo-server-with-SRP-authentication" accesskey="n" rel="next">Echo server with SRP authentication</a>, Previous: <a href="#Echo-server-with-X_002e509-authentication" accesskey="p" rel="previous">Echo server with X.509 authentication</a>, Up: <a href="#Server-examples" accesskey="u" rel="up">Server examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Echo-server-with-OpenPGP-authentication-1"></a>
<h4 class="subsection">7.2.2 Echo server with <acronym>OpenPGP</acronym> authentication</h4>
<a name="index-OpenPGP-server"></a>
<p>The following example is an echo server which supports
<acronym>OpenPGP</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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/openpgp.h>
#define KEYFILE "secret.asc"
#define CERTFILE "public.asc"
#define RINGFILE "ring.gpg"
/* This is a sample TLS 1.0-OpenPGP echo server.
*/
#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_dh_params_t dh_params;
static int
generate_dh_params (void)
{
unsigned int bits =
gnutls_sec_param_to_pk_bits (GNUTLS_PK_DH, GNUTLS_SEC_PARAM_LEGACY);
/* 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, bits);
return 0;
}
int
main (void)
{
int err, listen_sd;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
socklen_t client_len;
char topbuf[512];
gnutls_session_t session;
gnutls_certificate_credentials_t cred;
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_OPENPGP_FMT_BASE64);
gnutls_certificate_set_openpgp_key_file (cred, CERTFILE, KEYFILE,
GNUTLS_OPENPGP_FMT_BASE64);
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, (void *) &optval,
sizeof (int));
err = bind (listen_sd, (struct sockaddr *) & 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 (;;)
{
gnutls_init (&session, GNUTLS_SERVER);
gnutls_priority_set_direct (session, "NORMAL:+CTYPE-OPENPGP", NULL);
/* request client certificate if any.
*/
gnutls_certificate_server_set_request (session, GNUTLS_CERT_REQUEST);
sd = accept (listen_sd, (struct sockaddr *) & 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); */
for (;;)
{
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
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, ret);
}
}
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>
<hr>
<a name="Echo-server-with-SRP-authentication"></a>
<div class="header">
<p>
Next: <a href="#Echo-server-with-anonymous-authentication" accesskey="n" rel="next">Echo server with anonymous authentication</a>, Previous: <a href="#Echo-server-with-OpenPGP-authentication" accesskey="p" rel="previous">Echo server with OpenPGP authentication</a>, Up: <a href="#Server-examples" accesskey="u" rel="up">Server examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Echo-server-with-SRP-authentication-1"></a>
<h4 class="subsection">7.2.3 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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#define SRP_PASSWD "tpasswd"
#define SRP_PASSWD_CONF "tpasswd.conf"
#define KEYFILE "key.pem"
#define CERTFILE "cert.pem"
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
/* This is a sample TLS-SRP echo server.
*/
#define SOCKET_ERR(err,s) if(err==-1) {perror(s);return(1);}
#define MAX_BUF 1024
#define PORT 5556 /* listen to 5556 port */
int
main (void)
{
int err, listen_sd;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
socklen_t client_len;
char topbuf[512];
gnutls_session_t session;
gnutls_srp_server_credentials_t srp_cred;
gnutls_certificate_credentials_t cert_cred;
char buffer[MAX_BUF + 1];
int optval = 1;
char name[256];
strcpy (name, "Echo Server");
gnutls_global_init ();
/* 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, (void *) &optval,
sizeof (int));
err = bind (listen_sd, (struct sockaddr *) & 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 (;;)
{
gnutls_init (&session, GNUTLS_SERVER);
gnutls_priority_set_direct (session,
"NORMAL:-KX-ALL:+SRP:+SRP-DSS:+SRP-RSA", NULL);
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);
sd = accept (listen_sd, (struct sockaddr *) & 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);
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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");
printf ("- User %s was connected\n", gnutls_srp_server_get_username(session));
/* print_info(session); */
for (;;)
{
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
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, ret);
}
}
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>
<hr>
<a name="Echo-server-with-anonymous-authentication"></a>
<div class="header">
<p>
Next: <a href="#DTLS-echo-server-with-X_002e509-authentication" accesskey="n" rel="next">DTLS echo server with X.509 authentication</a>, Previous: <a href="#Echo-server-with-SRP-authentication" accesskey="p" rel="previous">Echo server with SRP authentication</a>, Up: <a href="#Server-examples" accesskey="u" rel="up">Server examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Echo-server-with-anonymous-authentication-1"></a>
<h4 class="subsection">7.2.4 Echo server with anonymous authentication</h4>
<p>This example server supports anonymous authentication, and could be
used to serve the example client for anonymous authentication.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.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 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 */
static gnutls_dh_params_t dh_params;
static int
generate_dh_params (void)
{
unsigned int bits =
gnutls_sec_param_to_pk_bits (GNUTLS_PK_DH, GNUTLS_SEC_PARAM_LEGACY);
/* 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, bits);
return 0;
}
int
main (void)
{
int err, listen_sd;
int sd, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
socklen_t client_len;
char topbuf[512];
gnutls_session_t session;
gnutls_anon_server_credentials_t anoncred;
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, (void *) &optval,
sizeof (int));
err = bind (listen_sd, (struct sockaddr *) & 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 (;;)
{
gnutls_init (&session, GNUTLS_SERVER);
gnutls_priority_set_direct (session, "NORMAL:+ANON-ECDH:+ANON-DH", NULL);
gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
sd = accept (listen_sd, (struct sockaddr *) & 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) ((ptrdiff_t) sd));
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
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); */
for (;;)
{
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 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
}
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, ret);
}
}
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>
<hr>
<a name="DTLS-echo-server-with-X_002e509-authentication"></a>
<div class="header">
<p>
Previous: <a href="#Echo-server-with-anonymous-authentication" accesskey="p" rel="previous">Echo server with anonymous authentication</a>, Up: <a href="#Server-examples" accesskey="u" rel="up">Server examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="DTLS-echo-server-with-X_002e509-authentication-1"></a>
<h4 class="subsection">7.2.5 DTLS echo server with <acronym>X.509</acronym> authentication</h4>
<p>This example is a very simple echo server using Datagram TLS and
<acronym>X.509</acronym> authentication.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/select.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <gnutls/gnutls.h>
#include <gnutls/dtls.h>
#define KEYFILE "key.pem"
#define CERTFILE "cert.pem"
#define CAFILE "/etc/ssl/certs/ca-certificates.crt"
#define CRLFILE "crl.pem"
/* This is a sample DTLS echo server, using X.509 authentication.
* Note that error checking is minimal to simplify the example.
*/
#define MAX_BUFFER 1024
#define PORT 5556
typedef struct
{
gnutls_session_t session;
int fd;
struct sockaddr *cli_addr;
socklen_t cli_addr_size;
} priv_data_st;
static int pull_timeout_func (gnutls_transport_ptr_t ptr, unsigned int ms);
static ssize_t push_func (gnutls_transport_ptr_t p, const void *data,
size_t size);
static ssize_t pull_func (gnutls_transport_ptr_t p, void *data, size_t size);
static const char *human_addr (const struct sockaddr *sa, socklen_t salen,
char *buf, size_t buflen);
static int wait_for_connection (int fd);
static int generate_dh_params (void);
/* Use global credentials and parameters to simplify
* the example. */
static gnutls_certificate_credentials_t x509_cred;
static gnutls_priority_t priority_cache;
static gnutls_dh_params_t dh_params;
int
main (void)
{
int listen_sd;
int sock, ret;
struct sockaddr_in sa_serv;
struct sockaddr_in cli_addr;
socklen_t cli_addr_size;
gnutls_session_t session;
char buffer[MAX_BUFFER];
priv_data_st priv;
gnutls_datum_t cookie_key;
gnutls_dtls_prestate_st prestate;
int mtu = 1400;
unsigned char sequence[8];
/* 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);
ret = gnutls_certificate_set_x509_key_file (x509_cred, CERTFILE, KEYFILE,
GNUTLS_X509_FMT_PEM);
if (ret < 0)
{
printf("No certificate or key were found\n");
exit(1);
}
generate_dh_params ();
gnutls_certificate_set_dh_params (x509_cred, dh_params);
gnutls_priority_init (&priority_cache,
"PERFORMANCE:-VERS-TLS-ALL:+VERS-DTLS1.0:%SERVER_PRECEDENCE",
NULL);
gnutls_key_generate (&cookie_key, GNUTLS_COOKIE_KEY_SIZE);
/* Socket operations
*/
listen_sd = socket (AF_INET, SOCK_DGRAM, 0);
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);
{ /* DTLS requires the IP don't fragment (DF) bit to be set */
#if defined(IP_DONTFRAG)
int optval = 1;
setsockopt (listen_sd, IPPROTO_IP, IP_DONTFRAG,
(const void *) &optval, sizeof (optval));
#elif defined(IP_MTU_DISCOVER)
int optval = IP_PMTUDISC_DO;
setsockopt(listen_sd, IPPROTO_IP, IP_MTU_DISCOVER,
(const void*) &optval, sizeof (optval));
#endif
}
bind (listen_sd, (struct sockaddr *) &sa_serv, sizeof (sa_serv));
printf ("UDP server ready. Listening to port '%d'.\n\n", PORT);
for (;;)
{
printf ("Waiting for connection...\n");
sock = wait_for_connection (listen_sd);
if (sock < 0)
continue;
cli_addr_size = sizeof (cli_addr);
ret = recvfrom (sock, buffer, sizeof (buffer), MSG_PEEK,
(struct sockaddr *) &cli_addr, &cli_addr_size);
if (ret > 0)
{
memset (&prestate, 0, sizeof (prestate));
ret = gnutls_dtls_cookie_verify (&cookie_key, &cli_addr,
sizeof (cli_addr), buffer, ret,
&prestate);
if (ret < 0) /* cookie not valid */
{
priv_data_st s;
memset (&s, 0, sizeof (s));
s.fd = sock;
s.cli_addr = (void *) &cli_addr;
s.cli_addr_size = sizeof (cli_addr);
printf ("Sending hello verify request to %s\n",
human_addr ((struct sockaddr *) &cli_addr,
sizeof (cli_addr), buffer,
sizeof (buffer)));
gnutls_dtls_cookie_send (&cookie_key, &cli_addr,
sizeof (cli_addr), &prestate,
(gnutls_transport_ptr_t) & s,
push_func);
/* discard peeked data */
recvfrom (sock, buffer, sizeof (buffer), 0,
(struct sockaddr *) &cli_addr, &cli_addr_size);
usleep (100);
continue;
}
printf ("Accepted connection from %s\n",
human_addr ((struct sockaddr *)
&cli_addr, sizeof (cli_addr), buffer,
sizeof (buffer)));
}
else
continue;
gnutls_init (&session, GNUTLS_SERVER | GNUTLS_DATAGRAM);
gnutls_priority_set (session, priority_cache);
gnutls_credentials_set (session, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_dtls_prestate_set (session, &prestate);
gnutls_dtls_set_mtu (session, mtu);
priv.session = session;
priv.fd = sock;
priv.cli_addr = (struct sockaddr *) &cli_addr;
priv.cli_addr_size = sizeof (cli_addr);
gnutls_transport_set_ptr (session, &priv);
gnutls_transport_set_push_function (session, push_func);
gnutls_transport_set_pull_function (session, pull_func);
gnutls_transport_set_pull_timeout_function (session, pull_timeout_func);
do
{
ret = gnutls_handshake (session);
}
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
if (ret < 0)
{
fprintf (stderr, "Error in handshake(): %s\n",
gnutls_strerror (ret));
gnutls_deinit (session);
continue;
}
printf ("- Handshake was completed\n");
for (;;)
{
do
{
ret = gnutls_record_recv_seq (session, buffer, MAX_BUFFER,
sequence);
}
while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
{
fprintf (stderr, "*** Warning: %s\n", gnutls_strerror (ret));
continue;
}
else if (ret < 0)
{
fprintf (stderr, "Error in recv(): %s\n",
gnutls_strerror (ret));
break;
}
if (ret == 0)
{
printf ("EOF\n\n");
break;
}
buffer[ret] = 0;
printf ("received[%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x]: %s\n",
sequence[0], sequence[1], sequence[2], sequence[3],
sequence[4], sequence[5], sequence[6], sequence[7], buffer);
/* reply back */
ret = gnutls_record_send (session, buffer, ret);
if (ret < 0)
{
fprintf (stderr, "Error in send(): %s\n",
gnutls_strerror (ret));
break;
}
}
gnutls_bye (session, GNUTLS_SHUT_WR);
gnutls_deinit (session);
}
close (listen_sd);
gnutls_certificate_free_credentials (x509_cred);
gnutls_priority_deinit (priority_cache);
gnutls_global_deinit ();
return 0;
}
static int
wait_for_connection (int fd)
{
fd_set rd, wr;
int n;
FD_ZERO (&rd);
FD_ZERO (&wr);
FD_SET (fd, &rd);
/* waiting part */
n = select (fd + 1, &rd, &wr, NULL, NULL);
if (n == -1 && errno == EINTR)
return -1;
if (n < 0)
{
perror ("select()");
exit (1);
}
return fd;
}
/* Wait for data to be received within a timeout period in milliseconds
*/
static int
pull_timeout_func (gnutls_transport_ptr_t ptr, unsigned int ms)
{
fd_set rfds;
struct timeval tv;
priv_data_st *priv = ptr;
struct sockaddr_in cli_addr;
socklen_t cli_addr_size;
int ret;
char c;
FD_ZERO (&rfds);
FD_SET (priv->fd, &rfds);
tv.tv_sec = 0;
tv.tv_usec = ms * 1000;
while(tv.tv_usec >= 1000000)
{
tv.tv_usec -= 1000000;
tv.tv_sec++;
}
ret = select (priv->fd + 1, &rfds, NULL, NULL, &tv);
if (ret <= 0)
return ret;
/* only report ok if the next message is from the peer we expect
* from
*/
cli_addr_size = sizeof (cli_addr);
ret =
recvfrom (priv->fd, &c, 1, MSG_PEEK, (struct sockaddr *) &cli_addr,
&cli_addr_size);
if (ret > 0)
{
if (cli_addr_size == priv->cli_addr_size
&& memcmp (&cli_addr, priv->cli_addr, sizeof (cli_addr)) == 0)
return 1;
}
return 0;
}
static ssize_t
push_func (gnutls_transport_ptr_t p, const void *data, size_t size)
{
priv_data_st *priv = p;
return sendto (priv->fd, data, size, 0, priv->cli_addr,
priv->cli_addr_size);
}
static ssize_t
pull_func (gnutls_transport_ptr_t p, void *data, size_t size)
{
priv_data_st *priv = p;
struct sockaddr_in cli_addr;
socklen_t cli_addr_size;
char buffer[64];
int ret;
cli_addr_size = sizeof (cli_addr);
ret =
recvfrom (priv->fd, data, size, 0, (struct sockaddr *) &cli_addr,
&cli_addr_size);
if (ret == -1)
return ret;
if (cli_addr_size == priv->cli_addr_size
&& memcmp (&cli_addr, priv->cli_addr, sizeof (cli_addr)) == 0)
return ret;
printf ("Denied connection from %s\n",
human_addr ((struct sockaddr *)
&cli_addr, sizeof (cli_addr), buffer, sizeof (buffer)));
gnutls_transport_set_errno (priv->session, EAGAIN);
return -1;
}
static const char *
human_addr (const struct sockaddr *sa, socklen_t salen,
char *buf, size_t buflen)
{
const char *save_buf = buf;
size_t l;
if (!buf || !buflen)
return NULL;
*buf = '\0';
switch (sa->sa_family)
{
#if HAVE_IPV6
case AF_INET6:
snprintf (buf, buflen, "IPv6 ");
break;
#endif
case AF_INET:
snprintf (buf, buflen, "IPv4 ");
break;
}
l = strlen (buf);
buf += l;
buflen -= l;
if (getnameinfo (sa, salen, buf, buflen, NULL, 0, NI_NUMERICHOST) != 0)
return NULL;
l = strlen (buf);
buf += l;
buflen -= l;
strncat (buf, " port ", buflen);
l = strlen (buf);
buf += l;
buflen -= l;
if (getnameinfo (sa, salen, NULL, 0, buf, buflen, NI_NUMERICSERV) != 0)
return NULL;
return save_buf;
}
static int
generate_dh_params (void)
{
int bits =
gnutls_sec_param_to_pk_bits (GNUTLS_PK_DH, GNUTLS_SEC_PARAM_LEGACY);
/* Generate Diffie-Hellman parameters - for use with DHE
* kx algorithms. When short bit length is used, it might
* be wise to regenerate parameters often.
*/
gnutls_dh_params_init (&dh_params);
gnutls_dh_params_generate2 (dh_params, bits);
return 0;
}
</pre>
<hr>
<a name="OCSP-example"></a>
<div class="header">
<p>
Next: <a href="#Miscellaneous-examples" accesskey="n" rel="next">Miscellaneous examples</a>, Previous: <a href="#Server-examples" accesskey="p" rel="previous">Server examples</a>, Up: <a href="#GnuTLS-application-examples" accesskey="u" rel="up">GnuTLS application examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="OCSP-example-1"></a>
<h3 class="section">7.3 OCSP example</h3>
<a name="Generate-OCSP-request"></a><a name="Generate-OCSP-request-1"></a>
<h4 class="subheading">Generate <acronym>OCSP</acronym> request</h4>
<p>A small tool to generate OCSP requests.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#include <gnutls/ocsp.h>
#ifndef NO_LIBCURL
#include <curl/curl.h>
#endif
#include "read-file.h"
size_t get_data (void *buffer, size_t size, size_t nmemb,
void *userp);
static gnutls_x509_crt_t load_cert (const char *cert_file);
static void _response_info (const gnutls_datum_t * data);
static void
_generate_request (gnutls_datum_t * rdata, gnutls_x509_crt_t cert,
gnutls_x509_crt_t issuer);
static int
_verify_response (gnutls_datum_t * data, gnutls_x509_crt_t cert,
gnutls_x509_crt_t signer);
/* This program queries an OCSP server.
It expects three files. argv[1] containing the certificate to
be checked, argv[2] holding the issuer for this certificate,
and argv[3] holding a trusted certificate to verify OCSP's response.
argv[4] is optional and should hold the server host name.
For simplicity the libcurl library is used.
*/
int
main (int argc, char *argv[])
{
gnutls_datum_t ud, tmp;
int ret;
gnutls_datum_t req;
gnutls_x509_crt_t cert, issuer, signer;
#ifndef NO_LIBCURL
CURL *handle;
struct curl_slist *headers = NULL;
#endif
int v, seq;
const char *cert_file = argv[1];
const char *issuer_file = argv[2];
const char *signer_file = argv[3];
char *hostname = NULL;
gnutls_global_init ();
if (argc > 4)
hostname = argv[4];
cert = load_cert (cert_file);
issuer = load_cert (issuer_file);
signer = load_cert (signer_file);
if (hostname == NULL)
{
for (seq = 0;; seq++)
{
ret = gnutls_x509_crt_get_authority_info_access (cert, seq,
GNUTLS_IA_OCSP_URI,
&tmp,
NULL);
if (ret == GNUTLS_E_UNKNOWN_ALGORITHM)
continue;
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
{
fprintf (stderr,
"No URI was found in the certificate.\n");
exit (1);
}
if (ret < 0)
{
fprintf (stderr, "error: %s\n",
gnutls_strerror (ret));
exit (1);
}
printf ("CA issuers URI: %.*s\n", tmp.size, tmp.data);
hostname = malloc (tmp.size + 1);
memcpy (hostname, tmp.data, tmp.size);
hostname[tmp.size] = 0;
gnutls_free (tmp.data);
break;
}
}
/* Note that the OCSP servers hostname might be available
* using gnutls_x509_crt_get_authority_info_access() in the issuer's
* certificate */
memset (&ud, 0, sizeof (ud));
fprintf (stderr, "Connecting to %s\n", hostname);
_generate_request (&req, cert, issuer);
#ifndef NO_LIBCURL
curl_global_init (CURL_GLOBAL_ALL);
handle = curl_easy_init ();
if (handle == NULL)
exit (1);
headers =
curl_slist_append (headers,
"Content-Type: application/ocsp-request");
curl_easy_setopt (handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt (handle, CURLOPT_POSTFIELDS, (void *) req.data);
curl_easy_setopt (handle, CURLOPT_POSTFIELDSIZE, req.size);
curl_easy_setopt (handle, CURLOPT_URL, hostname);
curl_easy_setopt (handle, CURLOPT_WRITEFUNCTION, get_data);
curl_easy_setopt (handle, CURLOPT_WRITEDATA, &ud);
ret = curl_easy_perform (handle);
if (ret != 0)
{
fprintf (stderr, "curl[%d] error %d\n", __LINE__, ret);
exit (1);
}
curl_easy_cleanup (handle);
#endif
_response_info (&ud);
v = _verify_response (&ud, cert, signer);
gnutls_x509_crt_deinit (cert);
gnutls_x509_crt_deinit (issuer);
gnutls_x509_crt_deinit (signer);
gnutls_global_deinit ();
return v;
}
static void
_response_info (const gnutls_datum_t * data)
{
gnutls_ocsp_resp_t resp;
int ret;
gnutls_datum buf;
ret = gnutls_ocsp_resp_init (&resp);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_resp_import (resp, data);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_resp_print (resp, GNUTLS_OCSP_PRINT_FULL, &buf);
if (ret != 0)
exit (1);
printf ("%.*s", buf.size, buf.data);
gnutls_free (buf.data);
gnutls_ocsp_resp_deinit (resp);
}
static gnutls_x509_crt_t
load_cert (const char *cert_file)
{
gnutls_x509_crt_t crt;
int ret;
gnutls_datum_t data;
size_t size;
ret = gnutls_x509_crt_init (&crt);
if (ret < 0)
exit (1);
data.data = (void *) read_binary_file (cert_file, &size);
data.size = size;
if (!data.data)
{
fprintf (stderr, "Cannot open file: %s\n", cert_file);
exit (1);
}
ret = gnutls_x509_crt_import (crt, &data, GNUTLS_X509_FMT_PEM);
free (data.data);
if (ret < 0)
{
fprintf (stderr, "Cannot import certificate in %s: %s\n",
cert_file, gnutls_strerror (ret));
exit (1);
}
return crt;
}
static void
_generate_request (gnutls_datum_t * rdata, gnutls_x509_crt_t cert,
gnutls_x509_crt_t issuer)
{
gnutls_ocsp_req_t req;
int ret;
unsigned char noncebuf[23];
gnutls_datum_t nonce = { noncebuf, sizeof (noncebuf) };
ret = gnutls_ocsp_req_init (&req);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_req_add_cert (req, GNUTLS_DIG_SHA1, issuer, cert);
if (ret < 0)
exit (1);
ret = gnutls_rnd (GNUTLS_RND_RANDOM, nonce.data, nonce.size);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_req_set_nonce (req, 0, &nonce);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_req_export (req, rdata);
if (ret != 0)
exit (1);
gnutls_ocsp_req_deinit (req);
return;
}
static int
_verify_response (gnutls_datum_t * data, gnutls_x509_crt_t cert,
gnutls_x509_crt_t signer)
{
gnutls_ocsp_resp_t resp;
int ret;
unsigned verify;
ret = gnutls_ocsp_resp_init (&resp);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_resp_import (resp, data);
if (ret < 0)
exit (1);
ret = gnutls_ocsp_resp_check_crt (resp, 0, cert);
if (ret < 0)
exit(1);
ret = gnutls_ocsp_resp_verify_direct (resp, signer, &verify, 0);
if (ret < 0)
exit (1);
printf ("Verifying OCSP Response: ");
if (verify == 0)
printf ("Verification success!\n");
else
printf ("Verification error!\n");
if (verify & GNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND)
printf ("Signer cert not found\n");
if (verify & GNUTLS_OCSP_VERIFY_SIGNER_KEYUSAGE_ERROR)
printf ("Signer cert keyusage error\n");
if (verify & GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER)
printf ("Signer cert is not trusted\n");
if (verify & GNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM)
printf ("Insecure algorithm\n");
if (verify & GNUTLS_OCSP_VERIFY_SIGNATURE_FAILURE)
printf ("Signature failure\n");
if (verify & GNUTLS_OCSP_VERIFY_CERT_NOT_ACTIVATED)
printf ("Signer cert not yet activated\n");
if (verify & GNUTLS_OCSP_VERIFY_CERT_EXPIRED)
printf ("Signer cert expired\n");
gnutls_ocsp_resp_deinit (resp);
return verify;
}
size_t
get_data (void *buffer, size_t size, size_t nmemb, void *userp)
{
gnutls_datum_t *ud = userp;
size *= nmemb;
ud->data = realloc (ud->data, size + ud->size);
if (ud->data == NULL)
{
fprintf (stderr, "Not enough memory for the request\n");
exit (1);
}
memcpy (&ud->data[ud->size], buffer, size);
ud->size += size;
return size;
}
</pre>
<hr>
<a name="Miscellaneous-examples"></a>
<div class="header">
<p>
Next: <a href="#XSSL-examples" accesskey="n" rel="next">XSSL examples</a>, Previous: <a href="#OCSP-example" accesskey="p" rel="previous">OCSP example</a>, Up: <a href="#GnuTLS-application-examples" accesskey="u" rel="up">GnuTLS application examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Miscellaneous-examples-1"></a>
<h3 class="section">7.4 Miscellaneous examples</h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Checking-for-an-alert" accesskey="1">Checking for an alert</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#X_002e509-certificate-parsing-example" accesskey="2">X.509 certificate parsing example</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Listing-the-ciphersuites-in-a-priority-string" accesskey="3">Listing the ciphersuites in a priority string</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Checking-for-an-alert"></a>
<div class="header">
<p>
Next: <a href="#X_002e509-certificate-parsing-example" accesskey="n" rel="next">X.509 certificate parsing example</a>, Up: <a href="#Miscellaneous-examples" accesskey="u" rel="up">Miscellaneous examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Checking-for-an-alert-1"></a>
<h4 class="subsection">7.4.1 Checking for an alert</h4>
<p>This is a function that checks if an alert has been received in the
current session.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include "examples.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>
<hr>
<a name="X_002e509-certificate-parsing-example"></a>
<div class="header">
<p>
Next: <a href="#Listing-the-ciphersuites-in-a-priority-string" accesskey="n" rel="next">Listing the ciphersuites in a priority string</a>, Previous: <a href="#Checking-for-an-alert" accesskey="p" rel="previous">Checking for an alert</a>, Up: <a href="#Miscellaneous-examples" accesskey="u" rel="up">Miscellaneous examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="X_002e509-certificate-parsing-example-1"></a>
<h4 class="subsection">7.4.2 <acronym>X.509</acronym> certificate parsing example</h4>
<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.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "examples.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[256];
size_t size;
unsigned int algo, bits;
time_t expiration_time, activation_time;
const gnutls_datum_t *cert_list;
unsigned int cert_list_size = 0;
gnutls_x509_crt_t cert;
gnutls_datum_t cinfo;
/* 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)
{
int ret;
/* 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");
/* This is the preferred way of printing short information about
a certificate. */
ret = gnutls_x509_crt_print (cert, GNUTLS_CRT_PRINT_ONELINE, &cinfo);
if (ret == 0)
{
printf ("\t%s\n", cinfo.data);
gnutls_free (cinfo.data);
}
/* If you want to extract fields manually for some other reason,
below are popular example calls. */
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);
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>
<hr>
<a name="Listing-the-ciphersuites-in-a-priority-string"></a>
<div class="header">
<p>
Previous: <a href="#X_002e509-certificate-parsing-example" accesskey="p" rel="previous">X.509 certificate parsing example</a>, Up: <a href="#Miscellaneous-examples" accesskey="u" rel="up">Miscellaneous examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Listing-the-ciphersuites-in-a-priority-string-1"></a>
<h4 class="subsection">7.4.3 Listing the ciphersuites in a priority string</h4>
<p>This is a small program to list the enabled ciphersuites by a
priority string.
</p>
<pre class="verbatim">/* This example code is placed in the public domain. */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
static void
print_cipher_suite_list (const char* priorities)
{
size_t i;
int ret;
unsigned int idx;
const char *name;
const char *err;
unsigned char id[2];
gnutls_protocol_t version;
gnutls_priority_t pcache;
if (priorities != NULL)
{
printf ("Cipher suites for %s\n", priorities);
ret = gnutls_priority_init(&pcache, priorities, &err);
if (ret < 0)
{
fprintf (stderr, "Syntax error at: %s\n", err);
exit(1);
}
for (i=0;;i++)
{
ret = gnutls_priority_get_cipher_suite_index(pcache, i, &idx);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) break;
if (ret == GNUTLS_E_UNKNOWN_CIPHER_SUITE) continue;
name = gnutls_cipher_suite_info(idx, id, NULL, NULL, NULL, &version);
if (name != NULL)
printf ("%-50s\t0x%02x, 0x%02x\t%s\n",
name, (unsigned char) id[0], (unsigned char) id[1],
gnutls_protocol_get_name (version));
}
return;
}
}
int main(int argc, char** argv)
{
if (argc > 1)
print_cipher_suite_list (argv[1]);
}
</pre>
<hr>
<a name="XSSL-examples"></a>
<div class="header">
<p>
Previous: <a href="#Miscellaneous-examples" accesskey="p" rel="previous">Miscellaneous examples</a>, Up: <a href="#GnuTLS-application-examples" accesskey="u" rel="up">GnuTLS application examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="XSSL-examples-1"></a>
<h3 class="section">7.5 XSSL examples</h3>
<p>XSSL is an experimental API available in the <code>gnutls-xssl</code> library
and in <code>gnutls/xssl.h</code> header. It is intended to be a very simple
to use API avoid the GnuTLS API. The API however has the following limitations
</p><ul>
<li> It is applicable to blocking sockets only.
</li><li> The server verification is based on its DNS name.
</li></ul>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Example-client-with-X_002e509-certificate-authentication" accesskey="1">Example client with X.509 certificate authentication</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Example-client-with-X_002e509-certificate-authentication-and-TOFU" accesskey="2">Example client with X.509 certificate authentication and TOFU</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Example-client-with-X_002e509-certificate-authentication"></a>
<div class="header">
<p>
Next: <a href="#Example-client-with-X_002e509-certificate-authentication-and-TOFU" accesskey="n" rel="next">Example client with X.509 certificate authentication and TOFU</a>, Up: <a href="#XSSL-examples" accesskey="u" rel="up">XSSL examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-client-with-X_002e509-certificate-authentication-1"></a>
<h4 class="subsection">7.5.1 Example client with X.509 certificate authentication</h4>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/xssl.h>
#include "examples.h"
/* A simple TLS client, with X.509 authentication. Certificate verification
* is explicit.
*/
extern int tcp_connect (void);
extern void tcp_close (int sd);
int main (void)
{
int ret;
char *line = NULL;
size_t line_len;
xssl_cred_t cred;
xssl_t sb;
unsigned int status;
int fd;
gnutls_global_init ();
fd = tcp_connect ();
ret = xssl_cred_init(&cred, GNUTLS_VMETHOD_SYSTEM_CAS, NULL, 0);
if (ret < 0)
exit(1);
/* Initialize TLS session
*/
ret = xssl_client_init(&sb, "www.example.com", NULL,
(gnutls_transport_ptr_t)fd,
NULL, cred, &status, 0);
if (ret < 0)
{
if (ret == GNUTLS_E_AUTH_ERROR)
{
gnutls_datum_t txt;
gnutls_certificate_verification_status_print(status, GNUTLS_CRT_X509,
&txt, 0);
fprintf(stderr, "Verification error (%x): %s\n", status, txt.data);
gnutls_free(txt.data);
}
exit(1);
}
#define REQ "GET / HTTP/1.0\r\n"
ret = xssl_write(sb, REQ, sizeof(REQ)-1);
if (ret < 0)
exit(1);
do
{
ret = xssl_getline(sb, &line, &line_len);
if (ret < 0)
exit(1);
fprintf(stderr, "received: %s\n", line);
}
while (ret >= 0);
gnutls_free(line);
xssl_deinit(sb);
tcp_close (fd);
xssl_cred_deinit (cred);
gnutls_global_deinit ();
}
</pre>
<hr>
<a name="Example-client-with-X_002e509-certificate-authentication-and-TOFU"></a>
<div class="header">
<p>
Previous: <a href="#Example-client-with-X_002e509-certificate-authentication" accesskey="p" rel="previous">Example client with X.509 certificate authentication</a>, Up: <a href="#XSSL-examples" accesskey="u" rel="up">XSSL examples</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Example-client-with-X_002e509-certificate-authentication-and-TOFU-1"></a>
<h4 class="subsection">7.5.2 Example client with X.509 certificate authentication and TOFU</h4>
<pre class="verbatim">/* This example code is placed in the public domain. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/xssl.h>
#include "examples.h"
/* A simple TLS client, with X.509 authentication. Certificate verification
* with a fixed CA, and trust on first use.
*/
extern int tcp_connect (void);
extern void tcp_close (int sd);
int main (void)
{
int ret;
char *line = NULL;
size_t line_len;
xssl_cred_t cred;
xssl_t sb;
gnutls_cinput_st aux[2];
unsigned aux_size = 0;
unsigned int status;
int fd;
gnutls_global_init ();
fd = tcp_connect ();
aux[aux_size].type = GNUTLS_CINPUT_TYPE_FILE;
aux[aux_size].contents = GNUTLS_CINPUT_CAS;
aux[aux_size].fmt = GNUTLS_X509_FMT_PEM;
aux[aux_size].i1.file = "/path/to/ca/file";
aux_size++;
/* This may be skipped to use the default DB file */
aux[aux_size].type = GNUTLS_CINPUT_TYPE_FILE;
aux[aux_size].contents = GNUTLS_CINPUT_TOFU_DB;
aux[aux_size].i1.file = "/path/to/trust/db/file";
aux_size++;
ret = xssl_cred_init(&cred, GNUTLS_VMETHOD_GIVEN_CAS|GNUTLS_VMETHOD_TOFU,
aux, aux_size);
if (ret < 0)
exit(1);
/* Initialize TLS session
*/
ret = xssl_client_init(&sb, "www.example.com", NULL,
(gnutls_transport_ptr_t)fd,
NULL, cred, &status, 0);
if (ret < 0)
{
if (ret == GNUTLS_E_AUTH_ERROR)
{
gnutls_datum_t txt;
gnutls_certificate_verification_status_print(status, GNUTLS_CRT_X509,
&txt, 0);
fprintf(stderr, "Verification error (%x): %s\n", status, txt.data);
gnutls_free(txt.data);
}
exit(1);
}
#define REQ "GET / HTTP/1.0\r\n"
ret = xssl_write(sb, REQ, sizeof(REQ)-1);
if (ret < 0)
exit(1);
do
{
ret = xssl_getline(sb, &line, &line_len);
if (ret < 0)
exit(1);
fprintf(stderr, "received: %s\n", line);
}
while (ret >= 0);
gnutls_free(line);
xssl_deinit(sb);
tcp_close (fd);
xssl_cred_deinit (cred);
gnutls_global_deinit ();
}
</pre>
<hr>
<a name="Using-GnuTLS-as-a-cryptographic-library"></a>
<div class="header">
<p>
Next: <a href="#Other-included-programs" accesskey="n" rel="next">Other included programs</a>, Previous: <a href="#GnuTLS-application-examples" accesskey="p" rel="previous">GnuTLS application examples</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Using-GnuTLS-as-a-cryptographic-library-1"></a>
<h2 class="chapter">8 Using GnuTLS as a cryptographic library</h2>
<p><acronym>GnuTLS</acronym> is not a low-level cryptographic library, i.e.,
it does not provide access to basic cryptographic primitives. However
it abstracts the internal cryptographic back-end (see <a href="#Cryptographic-Backend">Cryptographic Backend</a>),
providing symmetric crypto, hash and HMAC algorithms, as well access
to the random number generation.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Encryption-algorithms" accesskey="1">Encryption algorithms</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Hash-and-HMAC-functions" accesskey="2">Hash and HMAC functions</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Random-number-generation" accesskey="3">Random number generation</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Encryption-algorithms"></a>
<div class="header">
<p>
Next: <a href="#Hash-and-HMAC-functions" accesskey="n" rel="next">Hash and HMAC functions</a>, Up: <a href="#Using-GnuTLS-as-a-cryptographic-library" accesskey="u" rel="up">Using GnuTLS as a cryptographic library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Encryption-algorithms-1"></a>
<h3 class="section">8.1 Encryption algorithms</h3>
<a name="index-encryption-algorithms"></a>
<a name="index-symmetric-cryptography"></a>
<p>The available functions to access symmetric crypto algorithms operations
are shown below. The supported algorithms are the algorithms required by the TLS protocol.
They are listed in <a href="#tab_003aciphers">Table 3.1</a>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcipher_005finit">gnutls_cipher_init</a> (gnutls_cipher_hd_t * <var>handle</var>, gnutls_cipher_algorithm_t <var>cipher</var>, const gnutls_datum_t * <var>key</var>, const gnutls_datum_t * <var>iv</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcipher_005fencrypt2">gnutls_cipher_encrypt2</a> (gnutls_cipher_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcipher_005fdecrypt2">gnutls_cipher_decrypt2</a> (gnutls_cipher_hd_t <var>handle</var>, const void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>, void * <var>text</var>, size_t <var>textlen</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fcipher_005fset_005fiv">gnutls_cipher_set_iv</a> (gnutls_cipher_hd_t <var>handle</var>, void * <var>iv</var>, size_t <var>ivlen</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fcipher_005fdeinit">gnutls_cipher_deinit</a> (gnutls_cipher_hd_t <var>handle</var>)</code></dt>
</dl>
<p>In order to support authenticated encryption with associated data (AEAD) algorithms the following
functions are provided to set the associated data and retrieve the authentication tag.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fcipher_005fadd_005fauth">gnutls_cipher_add_auth</a> (gnutls_cipher_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>text_size</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fcipher_005ftag">gnutls_cipher_tag</a> (gnutls_cipher_hd_t <var>handle</var>, void * <var>tag</var>, size_t <var>tag_size</var>)</code></dt>
</dl>
<hr>
<a name="Hash-and-HMAC-functions"></a>
<div class="header">
<p>
Next: <a href="#Random-number-generation" accesskey="n" rel="next">Random number generation</a>, Previous: <a href="#Encryption-algorithms" accesskey="p" rel="previous">Encryption algorithms</a>, Up: <a href="#Using-GnuTLS-as-a-cryptographic-library" accesskey="u" rel="up">Using GnuTLS as a cryptographic library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Hash-and-HMAC-functions-1"></a>
<h3 class="section">8.2 Hash and HMAC functions</h3>
<a name="index-hash-functions"></a>
<a name="index-HMAC-functions"></a>
<p>The available operations to access hash functions and hash-MAC (HMAC) algorithms
are shown below. HMAC algorithms provided keyed hash functionality. They supported HMAC algorithms are listed in <a href="#tab_003amacs">Table 3.2</a>.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fhmac_005finit">gnutls_hmac_init</a> (gnutls_hmac_hd_t * <var>dig</var>, gnutls_mac_algorithm_t <var>algorithm</var>, const void * <var>key</var>, size_t <var>keylen</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhmac">gnutls_hmac</a> (gnutls_hmac_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fhmac_005foutput">gnutls_hmac_output</a> (gnutls_hmac_hd_t <var>handle</var>, void * <var>digest</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fhmac_005fdeinit">gnutls_hmac_deinit</a> (gnutls_hmac_hd_t <var>handle</var>, void * <var>digest</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhmac_005fget_005flen">gnutls_hmac_get_len</a> (gnutls_mac_algorithm_t <var>algorithm</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhmac_005ffast">gnutls_hmac_fast</a> (gnutls_mac_algorithm_t <var>algorithm</var>, const void * <var>key</var>, size_t <var>keylen</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>digest</var>)</code></dt>
</dl>
<p>The available functions to access hash functions are shown below. The supported hash functions
are the same as the HMAC algorithms.
</p>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005fhash_005finit">gnutls_hash_init</a> (gnutls_hash_hd_t * <var>dig</var>, gnutls_digest_algorithm_t <var>algorithm</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhash">gnutls_hash</a> (gnutls_hash_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fhash_005foutput">gnutls_hash_output</a> (gnutls_hash_hd_t <var>handle</var>, void * <var>digest</var>)</code></dt>
<dt><code><var>void</var> <a href="#gnutls_005fhash_005fdeinit">gnutls_hash_deinit</a> (gnutls_hash_hd_t <var>handle</var>, void * <var>digest</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhash_005fget_005flen">gnutls_hash_get_len</a> (gnutls_digest_algorithm_t <var>algorithm</var>)</code></dt>
<dt><code><var>int</var> <a href="#gnutls_005fhash_005ffast">gnutls_hash_fast</a> (gnutls_digest_algorithm_t <var>algorithm</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>digest</var>)</code></dt>
</dl>
<dl compact="compact">
<dt><code><var>int</var> <a href="#gnutls_005ffingerprint">gnutls_fingerprint</a> (gnutls_digest_algorithm_t <var>algo</var>, const gnutls_datum_t * <var>data</var>, void * <var>result</var>, size_t * <var>result_size</var>)</code></dt>
</dl>
<hr>
<a name="Random-number-generation"></a>
<div class="header">
<p>
Previous: <a href="#Hash-and-HMAC-functions" accesskey="p" rel="previous">Hash and HMAC functions</a>, Up: <a href="#Using-GnuTLS-as-a-cryptographic-library" accesskey="u" rel="up">Using GnuTLS as a cryptographic library</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Random-number-generation-1"></a>
<h3 class="section">8.3 Random number generation</h3>
<a name="index-random-numbers"></a>
<p>Access to the random number generator is provided using the <a href="#gnutls_005frnd">gnutls_rnd</a>
function. It allows obtaining random data of various levels.
</p>
<div class="float"><a name="gnutls_005frnd_005flevel_005ft"></a>
<dl compact="compact">
<dt><code>GNUTLS_RND_NONCE</code></dt>
<dd><p>Non-predictable random number. Fatal in parts
of session if broken, i.e., vulnerable to statistical analysis.
</p></dd>
<dt><code>GNUTLS_RND_RANDOM</code></dt>
<dd><p>Pseudo-random cryptographic random number.
Fatal in session if broken.
</p></dd>
<dt><code>GNUTLS_RND_KEY</code></dt>
<dd><p>Fatal in many sessions if broken.
</p></dd>
</dl>
<div class="float-caption"><p><strong>Figure 8.1: </strong>The random number levels.</p></div></div>
<dl>
<dt><a name="index-gnutls_005frnd"></a>Function: <em>int</em> <strong>gnutls_rnd</strong> <em>(gnutls_rnd_level_t <var>level</var>, void * <var>data</var>, size_t <var>len</var>)</em></dt>
<dd><p><var>level</var>: a security level
</p>
<p><var>data</var>: place to store random bytes
</p>
<p><var>len</var>: The requested size
</p>
<p>This function will generate random data and store it to output
buffer.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<hr>
<a name="Other-included-programs"></a>
<div class="header">
<p>
Next: <a href="#Internal-architecture-of-GnuTLS" accesskey="n" rel="next">Internal architecture of GnuTLS</a>, Previous: <a href="#Using-GnuTLS-as-a-cryptographic-library" accesskey="p" rel="previous">Using GnuTLS as a cryptographic library</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Other-included-programs-1"></a>
<h2 class="chapter">9 Other 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.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#gnutls_002dcli-Invocation" accesskey="1">gnutls-cli Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking gnutls-cli
</td></tr>
<tr><td align="left" valign="top">• <a href="#gnutls_002dserv-Invocation" accesskey="2">gnutls-serv Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking gnutls-serv
</td></tr>
<tr><td align="left" valign="top">• <a href="#gnutls_002dcli_002ddebug-Invocation" accesskey="3">gnutls-cli-debug Invocation</a>:</td><td> </td><td align="left" valign="top">Invoking gnutls-cli-debug
</td></tr>
</table>
<hr>
<a name="gnutls_002dcli-Invocation"></a>
<div class="header">
<p>
Next: <a href="#gnutls_002dserv-Invocation" accesskey="n" rel="next">gnutls-serv Invocation</a>, Up: <a href="#Other-included-programs" accesskey="u" rel="up">Other included programs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-gnutls_002dcli"></a>
<h3 class="section">9.1 Invoking gnutls-cli</h3>
<a name="index-gnutls_002dcli"></a>
<p>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.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>gnutls-cli</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="gnutls_002dcli-usage"></a><a name="gnutls_002dcli-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subheading">gnutls-cli help/usage (-h)</h4>
<a name="index-gnutls_002dcli-help"></a>
<p>This is the automatically generated usage text for gnutls-cli.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">gnutls-cli - GnuTLS client - Ver. 3.1.7
USAGE: gnutls-cli [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostname]
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-V, --verbose More verbose output
- may appear multiple times
--tofu Enable trust on first use authentication
- disabled as --no-tofu
--dane Enable DANE certificate verification (DNSSEC)
- disabled as --no-dane
--local-dns Use the local DNS server for DNSSEC resolving.
- disabled as --no-local-dns
--ca-verification Disable CA certificate verification
- disabled as --no-ca-verification
- enabled by default
--ocsp Enable OCSP certificate verification
- disabled as --no-ocsp
-r, --resume Establish a session and resume
-b, --heartbeat Activate heartbeat support
-e, --rehandshake Establish a session and rehandshake
--noticket Don't accept session tickets
-s, --starttls Connect, establish a plain session and start TLS.
-u, --udp Use DTLS (datagram TLS) over UDP
--mtu=num Set MTU for datagram TLS
- It must be in the range:
0 to 17000
--srtp-profiles=str Offer SRTP profiles
--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
--print-cert Print peer's certificate in PEM format
--recordsize=num The maximum record size to advertize
- It must be in the range:
0 to 4096
--dh-bits=num The minimum number of bits allowed for DH
--priority=str Priorities string
--x509cafile=str Certificate file or PKCS #11 URL to use
--x509crlfile=file CRL file to use
- file must pre-exist
--pgpkeyfile=file PGP Key file to use
- file must pre-exist
--pgpkeyring=file PGP Key ring file to use
- file must pre-exist
--pgpcertfile=file PGP Public Key (certificate) file to use
- file must pre-exist
--x509keyfile=str X.509 key file or PKCS #11 URL to use
--x509certfile=str X.509 Certificate file or PKCS #11 URL to use
--pgpsubkey=str PGP subkey to use (hex or auto)
--srpusername=str SRP username to use
--srppasswd=str SRP password to use
--pskusername=str PSK username to use
--pskkey=str PSK key (in hex) to use
-p, --port=str The port or service to connect to
--insecure Don't abort program if server certificate can't be validated
--ranges Use length-hiding padding to prevent traffic analysis
--benchmark-ciphers Benchmark individual ciphers
--benchmark-soft-ciphers Benchmark individual software ciphers (no hw acceleration)
--benchmark-tls-kx Benchmark TLS key exchange methods
--benchmark-tls-ciphers Benchmark TLS ciphers
-l, --list Print a list of the supported algorithms and modes
--disable-sni Do not send a Server Name Indication (SNI)
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Operands and options may be intermixed. They will be reordered.
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.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="gnutls_002dcli-debug"></a><a name="debug-option-_0028_002dd_0029-7"></a>
<h4 class="subheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="gnutls_002dcli-tofu"></a></p><a name="tofu-option"></a>
<h4 class="subheading">tofu option</h4>
<p>This is the “enable trust on first use authentication” option.
This option will, in addition to certificate authentication, perform authentication based on previously seen public keys, a model similar to SSH authentication.
<a name="gnutls_002dcli-dane"></a></p><a name="dane-option"></a>
<h4 class="subheading">dane option</h4>
<p>This is the “enable dane certificate verification (dnssec)” option.
This option will, in addition to certificate authentication using
the trusted CAs, verify the server certificates using on the DANE information
available via DNSSEC.
<a name="gnutls_002dcli-local_002ddns"></a></p><a name="local_002ddns-option-1"></a>
<h4 class="subheading">local-dns option</h4>
<p>This is the “use the local dns server for dnssec resolving.” option.
This option will use the local DNS server for DNSSEC.
This is disabled by default due to many servers not allowing DNSSEC.
<a name="gnutls_002dcli-ca_002dverification"></a></p><a name="ca_002dverification-option"></a>
<h4 class="subheading">ca-verification option</h4>
<p>This is the “disable ca certificate verification” option.
</p>
<p>This option has some usage constraints. It:
</p><ul>
<li> is enabled by default.
</li></ul>
<p>This option will disable CA certificate verification. It is to be used with the –dane or –tofu options.
<a name="gnutls_002dcli-ocsp"></a></p><a name="ocsp-option"></a>
<h4 class="subheading">ocsp option</h4>
<p>This is the “enable ocsp certificate verification” option.
This option will enable verification of the peer’s certificate using ocsp
<a name="gnutls_002dcli-resume"></a></p><a name="resume-option-_0028_002dr_0029"></a>
<h4 class="subheading">resume option (-r)</h4>
<p>This is the “establish a session and resume” option.
Connect, establish a session, reconnect and resume.
<a name="gnutls_002dcli-rehandshake"></a></p><a name="rehandshake-option-_0028_002de_0029"></a>
<h4 class="subheading">rehandshake option (-e)</h4>
<p>This is the “establish a session and rehandshake” option.
Connect, establish a session and rehandshake immediately.
<a name="gnutls_002dcli-starttls"></a></p><a name="starttls-option-_0028_002ds_0029"></a>
<h4 class="subheading">starttls option (-s)</h4>
<p>This is the “connect, establish a plain session and start tls.” option.
The TLS session will be initiated when EOF or a SIGALRM is received.
<a name="gnutls_002dcli-disable_002dextensions"></a></p><a name="disable_002dextensions-option"></a>
<h4 class="subheading">disable-extensions option</h4>
<p>This is the “disable all the tls extensions” option.
This option disables all TLS extensions. Deprecated option. Use the priority string.
<a name="gnutls_002dcli-dh_002dbits"></a></p><a name="dh_002dbits-option"></a>
<h4 class="subheading">dh-bits option</h4>
<p>This is the “the minimum number of bits allowed for dh” option.
This option takes an argument number.
This option sets the minimum number of bits allowed for a Diffie-Hellman key exchange. You may want to lower the default value if the peer sends a weak prime and you get an connection error with unacceptable prime.
<a name="gnutls_002dcli-priority"></a></p><a name="priority-option"></a>
<h4 class="subheading">priority option</h4>
<p>This is the “priorities string” option.
This option takes an argument string.
TLS algorithms and protocols to enable. You can
use predefined sets of ciphersuites such as PERFORMANCE,
NORMAL, SECURE128, SECURE256.
</p>
<p>Check the GnuTLS manual on section “Priority strings” for more
information on allowed keywords
<a name="gnutls_002dcli-ranges"></a></p><a name="ranges-option"></a>
<h4 class="subheading">ranges option</h4>
<p>This is the “use length-hiding padding to prevent traffic analysis” option.
When possible (e.g., when %NEW_PADDING is specified), use length-hiding padding to prevent traffic analysis.
<a name="gnutls_002dcli-list"></a></p><a name="list-option-_0028_002dl_0029"></a>
<h4 class="subheading">list option (-l)</h4>
<p>This is the “print a list of the supported algorithms and modes” option.
Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.
<a name="gnutls_002dcli-exit-status"></a></p><a name="gnutls_002dcli-exit-status-1"></a>
<h4 class="subheading">gnutls-cli exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="gnutls_002dcli-See-Also"></a><a name="gnutls_002dcli-See-Also-1"></a>
<h4 class="subheading">gnutls-cli See Also</h4>
<p>gnutls-cli-debug(1), gnutls-serv(1)
</p>
<a name="gnutls_002dcli-Examples"></a><a name="gnutls_002dcli-Examples-1"></a>
<h4 class="subheading">gnutls-cli Examples</h4>
<a name="Connecting-using-PSK-authentication"></a>
<h4 class="subheading">Connecting using PSK authentication</h4>
<p>To connect to a server using PSK authentication, you need to enable the choice of PSK by using a cipher priority parameter such as in the example below.
</p><div class="example">
<pre class="example">$ ./gnutls-cli -p 5556 localhost --pskusername psk_identity \
--pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \
--priority NORMAL:-KX-ALL:+ECDHE-PSK:+DHE-PSK:+PSK
Resolving 'localhost'...
Connecting to '127.0.0.1:5556'...
- PSK authentication.
- Version: TLS1.1
- Key Exchange: PSK
- Cipher: AES-128-CBC
- MAC: SHA1
- Compression: NULL
- Handshake was completed
- Simple Client Mode:
</pre></div>
<p>By keeping the –pskusername parameter and removing the –pskkey parameter, it will query only for the password during the handshake.
</p>
<a name="Listing-ciphersuites-in-a-priority-string"></a>
<h4 class="subheading">Listing ciphersuites in a priority string</h4>
<p>To list the ciphersuites in a priority string:
</p><div class="example">
<pre class="example">$ ./gnutls-cli --priority SECURE192 -l
Cipher suites for SECURE192
TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2
TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2
TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2
TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2
TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2
TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2
Certificate types: CTYPE-X.509
Protocols: VERS-TLS1.2, VERS-TLS1.1, VERS-TLS1.0, VERS-SSL3.0, VERS-DTLS1.0
Compression: COMP-NULL
Elliptic curves: CURVE-SECP384R1, CURVE-SECP521R1
PK-signatures: SIGN-RSA-SHA384, SIGN-ECDSA-SHA384, SIGN-RSA-SHA512, SIGN-ECDSA-SHA512
</pre></div>
<hr>
<a name="gnutls_002dserv-Invocation"></a>
<div class="header">
<p>
Next: <a href="#gnutls_002dcli_002ddebug-Invocation" accesskey="n" rel="next">gnutls-cli-debug Invocation</a>, Previous: <a href="#gnutls_002dcli-Invocation" accesskey="p" rel="previous">gnutls-cli Invocation</a>, Up: <a href="#Other-included-programs" accesskey="u" rel="up">Other included programs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-gnutls_002dserv"></a>
<h3 class="section">9.2 Invoking gnutls-serv</h3>
<a name="index-gnutls_002dserv"></a>
<p>Server program that listens to incoming TLS connections.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>gnutls-serv</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="gnutls_002dserv-usage"></a><a name="gnutls_002dserv-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subheading">gnutls-serv help/usage (-h)</h4>
<a name="index-gnutls_002dserv-help"></a>
<p>This is the automatically generated usage text for gnutls-serv.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">gnutls-serv - GnuTLS server - Ver. 3.1.7
USAGE: gnutls-serv [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
--noticket Don't accept session tickets
-g, --generate Generate Diffie-Hellman and RSA-export parameters
-q, --quiet Suppress some messages
--nodb Do not use a resumption database
--http Act as an HTTP server
--echo Act as an Echo server
-u, --udp Use DTLS (datagram TLS) over UDP
--mtu=num Set MTU for datagram TLS
- It must be in the range:
0 to 17000
--srtp-profiles=str Offer SRTP profiles
-a, --disable-client-cert Do not request a client certificate
-r, --require-client-cert Require a client certificate
-b, --heartbeat Activate heartbeat support
--x509fmtder Use DER format for certificates to read from
--priority=str Priorities string
--dhparams=file DH params file to use
- file must pre-exist
--x509cafile=str Certificate file or PKCS #11 URL to use
--x509crlfile=file CRL file to use
- file must pre-exist
--pgpkeyfile=file PGP Key file to use
- file must pre-exist
--pgpkeyring=file PGP Key ring file to use
- file must pre-exist
--pgpcertfile=file PGP Public Key (certificate) file to use
- file must pre-exist
--x509keyfile=str X.509 key file or PKCS #11 URL to use
--x509certfile=str X.509 Certificate file or PKCS #11 URL to use
--x509dsakeyfile=str Alternative X.509 key file or PKCS #11 URL to use
--x509dsacertfile=str Alternative X.509 Certificate file or PKCS #11 URL to use
--x509ecckeyfile=str Alternative X.509 key file or PKCS #11 URL to use
--x509ecccertfile=str Alternative X.509 Certificate file or PKCS #11 URL to use
--pgpsubkey=str PGP subkey to use (hex or auto)
--srppasswd=file SRP password file to use
- file must pre-exist
--srppasswdconf=file SRP password configuration file to use
- file must pre-exist
--pskpasswd=file PSK password file to use
- file must pre-exist
--pskhint=str PSK identity hint to use
--ocsp-response=file The OCSP response to send to client
- file must pre-exist
-p, --port=num The port to connect to
-l, --list Print a list of the supported algorithms and modes
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Server program that listens to incoming TLS connections.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="gnutls_002dserv-debug"></a><a name="debug-option-_0028_002dd_0029-8"></a>
<h4 class="subheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="gnutls_002dserv-heartbeat"></a></p><a name="heartbeat-option-_0028_002db_0029"></a>
<h4 class="subheading">heartbeat option (-b)</h4>
<p>This is the “activate heartbeat support” option.
Regularly ping client via heartbeat extension messages
<a name="gnutls_002dserv-priority"></a></p><a name="priority-option-1"></a>
<h4 class="subheading">priority option</h4>
<p>This is the “priorities string” option.
This option takes an argument string.
TLS algorithms and protocols to enable. You can
use predefined sets of ciphersuites such as PERFORMANCE,
NORMAL, SECURE128, SECURE256.
</p>
<p>Check the GnuTLS manual on section “Priority strings” for more
information on allowed keywords
<a name="gnutls_002dserv-ocsp_002dresponse"></a></p><a name="ocsp_002dresponse-option"></a>
<h4 class="subheading">ocsp-response option</h4>
<p>This is the “the ocsp response to send to client” option.
This option takes an argument file.
If the client requested an OCSP response, return data from this file to the client.
<a name="gnutls_002dserv-list"></a></p><a name="list-option-_0028_002dl_0029-1"></a>
<h4 class="subheading">list option (-l)</h4>
<p>This is the “print a list of the supported algorithms and modes” option.
Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.
<a name="gnutls_002dserv-exit-status"></a></p><a name="gnutls_002dserv-exit-status-1"></a>
<h4 class="subheading">gnutls-serv exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="gnutls_002dserv-See-Also"></a><a name="gnutls_002dserv-See-Also-1"></a>
<h4 class="subheading">gnutls-serv See Also</h4>
<p>gnutls-cli-debug(1), gnutls-cli(1)
</p>
<a name="gnutls_002dserv-Examples"></a><a name="gnutls_002dserv-Examples-1"></a>
<h4 class="subheading">gnutls-serv Examples</h4>
<p>Running your own TLS server based on GnuTLS can be useful when
debugging clients and/or GnuTLS itself. This section describes how to
use <code>gnutls-serv</code> as a simple HTTPS server.
</p>
<p>The most basic server can be started as:
</p>
<div class="example">
<pre class="example">gnutls-serv --http
</pre></div>
<p>It will only support anonymous ciphersuites, which many TLS clients
refuse to use.
</p>
<p>The next step is to add support for X.509. First we generate a CA:
</p>
<div class="example">
<pre class="example">$ certtool --generate-privkey > x509-ca-key.pem
$ echo 'cn = GnuTLS test CA' > ca.tmpl
$ echo 'ca' >> ca.tmpl
$ echo 'cert_signing_key' >> ca.tmpl
$ certtool --generate-self-signed --load-privkey x509-ca-key.pem \
--template ca.tmpl --outfile x509-ca.pem
...
</pre></div>
<p>Then generate a server certificate. Remember to change the dns_name
value to the name of your server host, or skip that command to avoid
the field.
</p>
<div class="example">
<pre class="example">$ certtool --generate-privkey > x509-server-key.pem
$ echo 'organization = GnuTLS test server' > server.tmpl
$ echo 'cn = test.gnutls.org' >> server.tmpl
$ echo 'tls_www_server' >> server.tmpl
$ echo 'encryption_key' >> server.tmpl
$ echo 'signing_key' >> server.tmpl
$ echo 'dns_name = test.gnutls.org' >> server.tmpl
$ certtool --generate-certificate --load-privkey x509-server-key.pem \
--load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
--template server.tmpl --outfile x509-server.pem
...
</pre></div>
<p>For use in the client, you may want to generate a client certificate
as well.
</p>
<div class="example">
<pre class="example">$ certtool --generate-privkey > x509-client-key.pem
$ echo 'cn = GnuTLS test client' > client.tmpl
$ echo 'tls_www_client' >> client.tmpl
$ echo 'encryption_key' >> client.tmpl
$ echo 'signing_key' >> client.tmpl
$ certtool --generate-certificate --load-privkey x509-client-key.pem \
--load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
--template client.tmpl --outfile x509-client.pem
...
</pre></div>
<p>To be able to import the client key/certificate into some
applications, you will need to convert them into a PKCS#12 structure.
This also encrypts the security sensitive key with a password.
</p>
<div class="example">
<pre class="example">$ certtool --to-p12 --load-ca-certificate x509-ca.pem \
--load-privkey x509-client-key.pem --load-certificate x509-client.pem \
--outder --outfile x509-client.p12
</pre></div>
<p>For icing, we’ll create a proxy certificate for the client too.
</p>
<div class="example">
<pre class="example">$ certtool --generate-privkey > x509-proxy-key.pem
$ echo 'cn = GnuTLS test client proxy' > proxy.tmpl
$ certtool --generate-proxy --load-privkey x509-proxy-key.pem \
--load-ca-certificate x509-client.pem --load-ca-privkey x509-client-key.pem \
--load-certificate x509-client.pem --template proxy.tmpl \
--outfile x509-proxy.pem
...
</pre></div>
<p>Then start the server again:
</p>
<div class="example">
<pre class="example">$ gnutls-serv --http \
--x509cafile x509-ca.pem \
--x509keyfile x509-server-key.pem \
--x509certfile x509-server.pem
</pre></div>
<p>Try connecting to the server using your web browser. Note that the
server listens to port 5556 by default.
</p>
<p>While you are at it, to allow connections using DSA, you can also
create a DSA key and certificate for the server. These credentials
will be used in the final example below.
</p>
<div class="example">
<pre class="example">$ certtool --generate-privkey --dsa > x509-server-key-dsa.pem
$ certtool --generate-certificate --load-privkey x509-server-key-dsa.pem \
--load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
--template server.tmpl --outfile x509-server-dsa.pem
...
</pre></div>
<p>The next step is to create OpenPGP credentials for the server.
</p>
<div class="example">
<pre class="example">gpg --gen-key
...enter whatever details you want, use 'test.gnutls.org' as name...
</pre></div>
<p>Make a note of the OpenPGP key identifier of the newly generated key,
here it was <code>5D1D14D8</code>. You will need to export the key for
GnuTLS to be able to use it.
</p>
<div class="example">
<pre class="example">gpg -a --export 5D1D14D8 > openpgp-server.txt
gpg --export 5D1D14D8 > openpgp-server.bin
gpg --export-secret-keys 5D1D14D8 > openpgp-server-key.bin
gpg -a --export-secret-keys 5D1D14D8 > openpgp-server-key.txt
</pre></div>
<p>Let’s start the server with support for OpenPGP credentials:
</p>
<div class="example">
<pre class="example">gnutls-serv --http \
--pgpkeyfile openpgp-server-key.txt \
--pgpcertfile openpgp-server.txt
</pre></div>
<p>The next step is to add support for SRP authentication. This requires
an SRP password file created with <code>srptool</code>.
To start the server with SRP support:
</p>
<div class="example">
<pre class="example">gnutls-serv --http \
--srppasswdconf srp-tpasswd.conf \
--srppasswd srp-passwd.txt
</pre></div>
<p>Let’s also start a server with support for PSK. This would require
a password file created with <code>psktool</code>.
</p>
<div class="example">
<pre class="example">gnutls-serv --http \
--pskpasswd psk-passwd.txt
</pre></div>
<p>Finally, we start the server with all the earlier parameters and you
get this command:
</p>
<div class="example">
<pre class="example">gnutls-serv --http \
--x509cafile x509-ca.pem \
--x509keyfile x509-server-key.pem \
--x509certfile x509-server.pem \
--x509dsakeyfile x509-server-key-dsa.pem \
--x509dsacertfile x509-server-dsa.pem \
--pgpkeyfile openpgp-server-key.txt \
--pgpcertfile openpgp-server.txt \
--srppasswdconf srp-tpasswd.conf \
--srppasswd srp-passwd.txt \
--pskpasswd psk-passwd.txt
</pre></div>
<hr>
<a name="gnutls_002dcli_002ddebug-Invocation"></a>
<div class="header">
<p>
Previous: <a href="#gnutls_002dserv-Invocation" accesskey="p" rel="previous">gnutls-serv Invocation</a>, Up: <a href="#Other-included-programs" accesskey="u" rel="up">Other included programs</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Invoking-gnutls_002dcli_002ddebug"></a>
<h3 class="section">9.3 Invoking gnutls-cli-debug</h3>
<a name="index-gnutls_002dcli_002ddebug"></a>
<p>TLS debug client. It sets up multiple TLS connections to
a server and queries its capabilities. It was created to assist in debugging
GnuTLS, but it might be useful to extract a TLS server’s capabilities.
It connects to a TLS server, performs tests and print the server’s
capabilities. If called with the ‘-v’ parameter more checks will be performed.
Can be used to check for servers with special needs or bugs.
</p>
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>gnutls-cli-debug</code> program.
This software is released under the GNU General Public License, version 3 or later.
</p>
<a name="gnutls_002dcli_002ddebug-usage"></a><a name="gnutls_002dcli_002ddebug-help_002fusage-_0028_002dh_0029"></a>
<h4 class="subheading">gnutls-cli-debug help/usage (-h)</h4>
<a name="index-gnutls_002dcli_002ddebug-help"></a>
<p>This is the automatically generated usage text for gnutls-cli-debug.
The text printed is the same whether for the <code>help</code> option (-h) or the <code>more-help</code> option (-!). <code>more-help</code> will print
the usage text by passing it through a pager program.
<code>more-help</code> is disabled on platforms without a working
<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">gnutls-cli-debug - GnuTLS debug client - Ver. 3.1.7
USAGE: gnutls-cli-debug [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-d, --debug=num Enable debugging.
- It must be in the range:
0 to 9999
-V, --verbose More verbose output
- may appear multiple times
-p, --port=num The port to connect to
- It must be in the range:
0 to 65536
-v, --version[=arg] Output version information and exit
-h, --help Display extended usage information and exit
-!, --more-help Extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Operands and options may be intermixed. They will be reordered.
TLS debug client. It sets up multiple TLS connections to a server and
queries its capabilities. It was created to assist in debugging GnuTLS,
but it might be useful to extract a TLS server's capabilities. It connects
to a TLS server, performs tests and print the server's capabilities. If
called with the `-v' parameter more checks will be performed. Can be used
to check for servers with special needs or bugs.
please send bug reports to: bug-gnutls@gnu.org
</pre></div>
<a name="gnutls_002dcli_002ddebug-debug"></a><a name="debug-option-_0028_002dd_0029-9"></a>
<h4 class="subheading">debug option (-d)</h4>
<p>This is the “enable debugging.” option.
This option takes an argument number.
Specifies the debug level.
<a name="gnutls_002dcli_002ddebug-exit-status"></a></p><a name="gnutls_002dcli_002ddebug-exit-status-1"></a>
<h4 class="subheading">gnutls-cli-debug exit status</h4>
<p>One of the following exit values will be returned:
</p><dl compact="compact">
<dt>‘<samp>0 (EXIT_SUCCESS)</samp>’</dt>
<dd><p>Successful program execution.
</p></dd>
<dt>‘<samp>1 (EXIT_FAILURE)</samp>’</dt>
<dd><p>The operation failed or the command syntax was not valid.
</p></dd>
</dl>
<a name="gnutls_002dcli_002ddebug-See-Also"></a><a name="gnutls_002dcli_002ddebug-See-Also-1"></a>
<h4 class="subheading">gnutls-cli-debug See Also</h4>
<p>gnutls-cli(1), gnutls-serv(1)
</p>
<a name="gnutls_002dcli_002ddebug-Examples"></a><a name="gnutls_002dcli_002ddebug-Examples-1"></a>
<h4 class="subheading">gnutls-cli-debug Examples</h4>
<div class="example">
<pre class="example">$ ../src/gnutls-cli-debug localhost
Resolving 'localhost'...
Connecting to '127.0.0.1:443'...
Checking for SSL 3.0 support... yes
Checking whether %COMPAT is required... no
Checking for TLS 1.0 support... yes
Checking for TLS 1.1 support... no
Checking fallback from TLS 1.1 to... TLS 1.0
Checking for TLS 1.2 support... no
Checking whether we need to disable TLS 1.0... N/A
Checking for Safe renegotiation support... yes
Checking for Safe renegotiation support (SCSV)... yes
Checking for HTTPS server name... not checked
Checking for version rollback bug in RSA PMS... no
Checking for version rollback bug in Client Hello... no
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 small records (512 bytes)... 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... partially
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 ephemeral EC Diffie-Hellman support... yes
Checking ephemeral EC Diffie-Hellman group info...
Curve SECP256R1
Checking for AES-GCM cipher support... no
Checking for AES-CBC cipher support... yes
Checking for CAMELLIA cipher support... no
Checking for 3DES-CBC 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 SHA256 MAC support... no
Checking for ZLIB compression support... no
Checking for max record size... no
Checking for OpenPGP authentication support... no
</pre></div>
<hr>
<a name="Internal-architecture-of-GnuTLS"></a>
<div class="header">
<p>
Next: <a href="#Upgrading-from-previous-versions" accesskey="n" rel="next">Upgrading from previous versions</a>, Previous: <a href="#Other-included-programs" accesskey="p" rel="previous">Other included programs</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Internal-Architecture-of-GnuTLS"></a>
<h2 class="chapter">10 Internal Architecture of GnuTLS</h2>
<a name="index-internal-architecture"></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.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#The-TLS-Protocol" accesskey="1">The TLS Protocol</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#TLS-Handshake-Protocol" accesskey="2">TLS Handshake Protocol</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#TLS-Authentication-Methods" accesskey="3">TLS Authentication Methods</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#TLS-Extension-Handling" accesskey="4">TLS Extension Handling</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Cryptographic-Backend" accesskey="5">Cryptographic Backend</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="The-TLS-Protocol"></a>
<div class="header">
<p>
Next: <a href="#TLS-Handshake-Protocol" accesskey="n" rel="next">TLS Handshake Protocol</a>, Up: <a href="#Internal-architecture-of-GnuTLS" accesskey="u" rel="up">Internal architecture of GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="The-TLS-Protocol-1"></a>
<h3 class="section">10.1 The TLS Protocol</h3>
<p>The main use case for the TLS protocol is shown in <a href="#fig_003aclient_002dserver">Figure 10.1</a>.
A user of a library implementing the protocol expects no less than this functionality,
i.e., to be able to set parameters such as the accepted security level, perform a
negotiation with the peer and be able to exchange data.
</p>
<div class="float"><a name="fig_003aclient_002dserver"></a>
<img src="gnutls-client-server-use-case.png" alt="gnutls-client-server-use-case">
<div class="float-caption"><p><strong>Figure 10.1: </strong>TLS protocol use case.</p></div></div>
<hr>
<a name="TLS-Handshake-Protocol"></a>
<div class="header">
<p>
Next: <a href="#TLS-Authentication-Methods" accesskey="n" rel="next">TLS Authentication Methods</a>, Previous: <a href="#The-TLS-Protocol" accesskey="p" rel="previous">The TLS Protocol</a>, Up: <a href="#Internal-architecture-of-GnuTLS" accesskey="u" rel="up">Internal architecture of GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-Handshake-Protocol-1"></a>
<h3 class="section">10.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 <a href="#fig_003agnutls_002dhandshake">Figure 10.2</a>.
</p>
<div class="float"><a name="fig_003agnutls_002dhandshake"></a>
<img src="gnutls-handshake-state.png" alt="gnutls-handshake-state">
<div class="float-caption"><p><strong>Figure 10.2: </strong>GnuTLS handshake state machine.</p></div></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. We illustrate the idea in <a href="#fig_003agnutls_002dhandshake_002dsequence">Figure 10.3</a>.
</p>
<div class="float"><a name="fig_003agnutls_002dhandshake_002dsequence"></a>
<img src="gnutls-handshake-sequence.png" alt="gnutls-handshake-sequence">
<div class="float-caption"><p><strong>Figure 10.3: </strong>GnuTLS handshake process sequence.</p></div></div>
<hr>
<a name="TLS-Authentication-Methods"></a>
<div class="header">
<p>
Next: <a href="#TLS-Extension-Handling" accesskey="n" rel="next">TLS Extension Handling</a>, Previous: <a href="#TLS-Handshake-Protocol" accesskey="p" rel="previous">TLS Handshake Protocol</a>, Up: <a href="#Internal-architecture-of-GnuTLS" accesskey="u" rel="up">Internal architecture of GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-Authentication-Methods-1"></a>
<h3 class="section">10.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 to implement the functions shown below.
</p>
<pre class="verbatim">typedef struct
{
const char *name;
int (*gnutls_generate_server_certificate) (gnutls_session_t, gnutls_buffer_st*);
int (*gnutls_generate_client_certificate) (gnutls_session_t, gnutls_buffer_st*);
int (*gnutls_generate_server_kx) (gnutls_session_t, gnutls_buffer_st*);
int (*gnutls_generate_client_kx) (gnutls_session_t, gnutls_buffer_st*);
int (*gnutls_generate_client_cert_vrfy) (gnutls_session_t, gnutls_buffer_st *);
int (*gnutls_generate_server_certificate_request) (gnutls_session_t,
gnutls_buffer_st *);
int (*gnutls_process_server_certificate) (gnutls_session_t, opaque *,
size_t);
int (*gnutls_process_client_certificate) (gnutls_session_t, opaque *,
size_t);
int (*gnutls_process_server_kx) (gnutls_session_t, opaque *, size_t);
int (*gnutls_process_client_kx) (gnutls_session_t, opaque *, size_t);
int (*gnutls_process_client_cert_vrfy) (gnutls_session_t, opaque *, size_t);
int (*gnutls_process_server_certificate_request) (gnutls_session_t,
opaque *, size_t);
} mod_auth_st;
</pre>
<p>Those functions are responsible for the
interpretation of the handshake protocol messages. It is common for such
functions to read data from one or more <code>credentials_t</code>
structures<a name="DOCF15" href="#FOOT15"><sup>15</sup></a> and write data,
such as certificates, usernames etc. to <code>auth_info_t</code> structures.
</p>
<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.
</p>
<hr>
<a name="TLS-Extension-Handling"></a>
<div class="header">
<p>
Next: <a href="#Cryptographic-Backend" accesskey="n" rel="next">Cryptographic Backend</a>, Previous: <a href="#TLS-Authentication-Methods" accesskey="p" rel="previous">TLS Authentication Methods</a>, Up: <a href="#Internal-architecture-of-GnuTLS" accesskey="u" rel="up">Internal architecture of GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TLS-Extension-Handling-1"></a>
<h3 class="section">10.4 TLS Extension Handling</h3>
<p>As with authentication methods, the TLS extensions handlers can be
implemented using the interface shown below.
</p>
<pre class="verbatim">typedef int (*gnutls_ext_recv_func) (gnutls_session_t session,
const unsigned char *data, size_t len);
typedef int (*gnutls_ext_send_func) (gnutls_session_t session,
gnutls_buffer_st *extdata);
</pre>
<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>
<p>A simple example of an extension handler can be seen in
<code>ext/srp.c</code> in GnuTLS’ source code. After implementing these functions,
together with the extension number they handle, they have to be registered
using <code>_gnutls_ext_register</code> in
<code>gnutls_extensions.c</code> typically within <code>_gnutls_ext_init</code>.
</p>
<a name="Adding-a-new-TLS-extension"></a>
<h4 class="subheading">Adding a new TLS extension</h4>
<p>Adding support for a new TLS extension is done from time to time, and
the process to do so is not difficult. Here are the steps you need to
follow if you wish to do this yourself. For sake of discussion, let’s
consider adding support for the hypothetical TLS extension
<code>foobar</code>.
</p>
<a name="Add-configure-option-like-_002d_002denable_002dfoobar-or-_002d_002ddisable_002dfoobar_002e"></a>
<h4 class="subsubheading">Add <code>configure</code> option like <code>--enable-foobar</code> or <code>--disable-foobar</code>.</h4>
<p>This step is useful when the extension code is large and it might be desirable
to disable the extension under some circumstances. Otherwise it can be safely
skipped.
</p>
<p>Whether to chose enable or disable depends on whether you intend to make the extension be
enabled by default. Look at existing checks (i.e., SRP, authz) for
how to model the code. For example:
</p>
<div class="example">
<pre class="example">AC_MSG_CHECKING([whether to disable foobar support])
AC_ARG_ENABLE(foobar,
AS_HELP_STRING([--disable-foobar],
[disable foobar support]),
ac_enable_foobar=no)
if test x$ac_enable_foobar != xno; then
AC_MSG_RESULT(no)
AC_DEFINE(ENABLE_FOOBAR, 1, [enable foobar])
else
ac_full=0
AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL(ENABLE_FOOBAR, test "$ac_enable_foobar" != "no")
</pre></div>
<p>These lines should go in <code>lib/m4/hooks.m4</code>.
</p>
<a name="Add-IANA-extension-value-to-extensions_005ft-in-gnutls_005fint_002eh_002e"></a>
<h4 class="subsubheading">Add IANA extension value to <code>extensions_t</code> in <code>gnutls_int.h</code>.</h4>
<p>A good name for the value would be GNUTLS_EXTENSION_FOOBAR. Check
with <a href="http://www.iana.org/assignments/tls-extensiontype-values">http://www.iana.org/assignments/tls-extensiontype-values</a>
for allocated values. For experiments, you could pick a number but
remember that some consider it a bad idea to deploy such modified
version since it will lead to interoperability problems in the future
when the IANA allocates that number to someone else, or when the
foobar protocol is allocated another number.
</p>
<a name="Add-an-entry-to-_005fgnutls_005fextensions-in-gnutls_005fextensions_002ec_002e"></a>
<h4 class="subsubheading">Add an entry to <code>_gnutls_extensions</code> in <code>gnutls_extensions.c</code>.</h4>
<p>A typical entry would be:
</p>
<div class="example">
<pre class="example"> int ret;
#if ENABLE_FOOBAR
ret = _gnutls_ext_register (&foobar_ext);
if (ret != GNUTLS_E_SUCCESS)
return ret;
#endif
</pre></div>
<p>Most likely you’ll need to add an <code>#include "ext/foobar.h"</code>, that
will contain something like
like:
</p><div class="example">
<pre class="example"> extension_entry_st foobar_ext = {
.name = "FOOBAR",
.type = GNUTLS_EXTENSION_FOOBAR,
.parse_type = GNUTLS_EXT_TLS,
.recv_func = _foobar_recv_params,
.send_func = _foobar_send_params,
.pack_func = _foobar_pack,
.unpack_func = _foobar_unpack,
.deinit_func = NULL
}
</pre></div>
<p>The GNUTLS_EXTENSION_FOOBAR is the integer value you added to
<code>gnutls_int.h</code> earlier. In this structure you specify the
functions to read the extension from the hello message, the function
to send the reply to, and two more functions to pack and unpack from
stored session data (e.g. when resumming a session). The <code>deinit</code> function
will be called to deinitialize the extension’s private parameters, if any.
</p>
<p>Note that the conditional <code>ENABLE_FOOBAR</code> definition should only be
used if step 1 with the <code>configure</code> options has taken place.
</p>
<a name="Add-new-files-that-implement-the-extension_002e"></a>
<h4 class="subsubheading">Add new files that implement the extension.</h4>
<p>The functions you are responsible to add are those mentioned in the
previous step. They should be added in a file such as <code>ext/foobar.c</code>
and headers should be placed in <code>ext/foobar.h</code>.
As a starter, you could add this:
</p>
<div class="example">
<pre class="example">int
_foobar_recv_params (gnutls_session_t session, const opaque * data,
size_t data_size)
{
return 0;
}
int
_foobar_send_params (gnutls_session_t session, gnutls_buffer_st* data)
{
return 0;
}
int
_foobar_pack (extension_priv_data_t epriv, gnutls_buffer_st * ps)
{
/* Append the extension's internal state to buffer */
return 0;
}
int
_foobar_unpack (gnutls_buffer_st * ps, extension_priv_data_t * epriv)
{
/* Read the internal state from buffer */
return 0;
}
</pre></div>
<p>The <code>_foobar_recv_params</code> function is responsible for
parsing incoming extension data (both in the client and server).
</p>
<p>The <code>_foobar_send_params</code> function is responsible for
sending extension data (both in the client and server).
</p>
<p>If you receive length fields that don’t match, return
<code>GNUTLS_E_UNEXPECTED_PACKET_LENGTH</code>. If you receive invalid
data, return <code>GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER</code>. You can use
other error codes from the list in <a href="#Error-codes">Error codes</a>. Return 0 on success.
</p>
<p>An extension typically stores private information in the <code>session</code>
data for later usage. That can be done using the functions
<code>_gnutls_ext_set_session_data</code> and
<code>_gnutls_ext_get_session_data</code>. You can check simple examples
at <code>ext/max_record.c</code> and <code>ext/server_name.c</code> extensions.
That private information can be saved and restored across session
resumption if the following functions are set:
</p>
<p>The <code>_foobar_pack</code> function is responsible for packing
internal extension data to save them in the session resumption storage.
</p>
<p>The <code>_foobar_unpack</code> function is responsible for
restoring session data from the session resumption storage.
</p>
<p>Recall that both the client and server, send and receive
parameters, and your code most likely will need to do different things
depending on which mode it is in. It may be useful to make this
distinction explicit in the code. Thus, for example, a better
template than above would be:
</p>
<div class="example">
<pre class="example">int
_gnutls_foobar_recv_params (gnutls_session_t session,
const opaque * data,
size_t data_size)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
return foobar_recv_client (session, data, data_size);
else
return foobar_recv_server (session, data, data_size);
}
int
_gnutls_foobar_send_params (gnutls_session_t session,
gnutls_buffer_st * data)
{
if (session->security_parameters.entity == GNUTLS_CLIENT)
return foobar_send_client (session, data);
else
return foobar_send_server (session, data);
}
</pre></div>
<p>The functions used would be declared as <code>static</code> functions, of
the appropriate prototype, in the same file.
When adding the files, you’ll need to add them to <code>ext/Makefile.am</code>
as well, for example:
</p>
<div class="example">
<pre class="example">if ENABLE_FOOBAR
libgnutls_ext_la_SOURCES += ext/foobar.c ext/foobar.h
endif
</pre></div>
<a name="Add-API-functions-to-enable_002fdisable-the-extension_002e"></a>
<h4 class="subsubheading">Add API functions to enable/disable the extension.</h4>
<p>It might be desirable to allow users of the extension to
request use of the extension, or set extension specific data.
This can be implemented by adding extension specific function calls
that can be added to <code>includes/gnutls/gnutls.h</code>,
as long as the LGPLv3+ applies.
The implementation of the function should lie in the <code>ext/foobar.c</code> file.
</p>
<p>To make the API available in the shared library you need to add the
symbol in <code>lib/libgnutls.map</code>, so that the symbol
is exported properly.
</p>
<p>When writing GTK-DOC style documentation for your new APIs, don’t
forget to add <code>Since:</code> tags to indicate the GnuTLS version the
API was introduced in.
</p>
<a name="Adding-a-new-Supplemental-Data-Handshake-Message"></a>
<h4 class="subheading">Adding a new Supplemental Data Handshake Message</h4>
<p>TLS handshake extensions allow to send so called supplemental data
handshake messages [<em>RFC4680</em>]. This short section explains how to
implement a supplemental data handshake message for a given TLS extension.
</p>
<p>First of all, modify your extension <code>foobar</code> in the way, the that
flags
<code>session->security_parameters.do_send_supplemental</code>
and
<code>session->security_parameters.do_recv_supplemental</code>
are set:
</p>
<div class="example">
<pre class="example">int
_gnutls_foobar_recv_params (gnutls_session_t session, const opaque * data,
size_t _data_size)
{
...
session->security_parameters.do_recv_supplemental=1;
...
}
int
_gnutls_foobar_send_params (gnutls_session_t session, gnutls_buffer_st *extdata)
{
...
session->security_parameters.do_send_supplemental=1;
...
}
</pre></div>
<p>Furthermore add the functions <code>_foobar_supp_recv_params</code>
and <code>_foobar_supp_send_params</code> to <code>_foobar.h</code> and
<code>_foobar.c</code>. The following example code shows how to send a
“Hello World” string in the supplemental data handshake message:
</p>
<div class="example">
<pre class="example">int
_foobar_supp_recv_params(gnutls_session_t session, const opaque *data, size_t _data_size)
{
uint8_t len = _data_size;
unsigned char *msg;
msg = gnutls_malloc(len);
if (msg == NULL) return GNUTLS_E_MEMORY_ERROR;
memcpy(msg, data, len);
msg[len]='\0';
/* do something with msg */
gnutls_free(msg);
return len;
}
int
_foobar_supp_send_params(gnutls_session_t session, gnutls_buffer_st *buf)
{
unsigned char *msg = "hello world";
int len = strlen(msg);
_gnutls_buffer_append_data_prefix(buf, 8, msg, len);
return len;
}
</pre></div>
<p>Afterwards, add the new supplemental data handshake message to
<code>lib/gnutls_supplemental.c</code> by adding a new entry to the
<code>_gnutls_supplemental[]</code> structure:
</p>
<div class="example">
<pre class="example">gnutls_supplemental_entry _gnutls_supplemental[] =
{
{"foobar",
GNUTLS_SUPPLEMENTAL_FOOBAR_DATA,
_foobar_supp_recv_params,
_foobar_supp_send_params},
{0, 0, 0, 0}
};
</pre></div>
<p>You have to include your <code>foobar.h</code> header file as well:
</p>
<div class="example">
<pre class="example">#include "foobar.h"
</pre></div>
<p>Lastly, add the new supplemental data type to
<code>lib/includes/gnutls/gnutls.h</code>:
</p>
<div class="example">
<pre class="example">typedef enum
{
GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0,
GNUTLS_SUPPLEMENTAL_FOOBAR_DATA = 1
} gnutls_supplemental_data_format_type_t;
</pre></div>
<a name="Heartbeat-extension_002e"></a>
<h4 class="subsubheading">Heartbeat extension.</h4>
<p>One such extension is HeartBeat protocol (RFC6520:
<a href="https://tools.ietf.org/html/rfc6520">https://tools.ietf.org/html/rfc6520</a>) implementation. To enable
it use option –heartbeat with example client and server supplied with
gnutls:
</p>
<div class="example">
<pre class="example">./doc/credentials/gnutls-http-serv --priority "NORMAL:-CIPHER-ALL:+NULL" -d 100 --heartbeat --echo
./src/gnutls-cli --priority "NORMAL:-CIPHER-ALL:+NULL" -d 100 localhost -p 5556 --insecure --heartbeat
</pre></div>
<p>After that pasting
</p><div class="example">
<pre class="example">**HEARTBEAT**
</pre></div>
<p>command into gnutls-cli will trigger corresponding command on the server and it will send HeartBeat Request with random length to client.
</p>
<p>Another way is to run capabilities check with:
</p>
<div class="example">
<pre class="example">./doc/credentials/gnutls-http-serv -d 100 --heartbeat
./src/gnutls-cli-debug localhost -p 5556
</pre></div>
<hr>
<a name="Cryptographic-Backend"></a>
<div class="header">
<p>
Previous: <a href="#TLS-Extension-Handling" accesskey="p" rel="previous">TLS Extension Handling</a>, Up: <a href="#Internal-architecture-of-GnuTLS" accesskey="u" rel="up">Internal architecture of GnuTLS</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Cryptographic-Backend-1"></a>
<h3 class="section">10.5 Cryptographic Backend</h3>
<p>Today most new processors, either for embedded or desktop systems
include either instructions intended to speed up cryptographic operations,
or a co-processor with cryptographic capabilities. Taking advantage of
those is a challenging task for every cryptographic application or
library. Unfortunately the cryptographic library that GnuTLS is based
on takes no advantage of these capabilities. For this reason GnuTLS handles
this internally by following a layered approach to accessing
cryptographic operations as in <a href="#fig_003acrypto_002dlayers">Figure 10.4</a>.
</p>
<div class="float"><a name="fig_003acrypto_002dlayers"></a>
<img src="gnutls-crypto-layers.png" alt="gnutls-crypto-layers">
<div class="float-caption"><p><strong>Figure 10.4: </strong>GnuTLS cryptographic back-end design.</p></div></div>
<p>The TLS layer uses a cryptographic provider layer, that will in turn either
use the default crypto provider – a software crypto library, or use an external
crypto provider, if available in the local system. The reason of handling
the external cryptographic provider in GnuTLS and not delegating it to
the cryptographic libraries, is that none of the supported cryptographic
libraries support <code>/dev/crypto</code> or CPU-optimized cryptography in
an efficient way.
</p>
<a name="Cryptographic-library-layer"></a>
<h4 class="subheading">Cryptographic library layer</h4>
<p>The Cryptographic library layer, currently supports only
libnettle. Older versions of GnuTLS used to support libgcrypt,
but it was switched with nettle mainly for performance reasons<a name="DOCF16" href="#FOOT16"><sup>16</sup></a>
and secondary because it is a simpler library to use.
In the future other cryptographic libraries might be supported as well.
</p>
<a name="External-cryptography-provider"></a>
<h4 class="subheading">External cryptography provider</h4>
<p>Systems that include a cryptographic co-processor, typically come with
kernel drivers to utilize the operations from software. For this reason
GnuTLS provides a layer where each individual algorithm used can be replaced
by another implementation, i.e., the one provided by the driver. The
FreeBSD, OpenBSD and Linux kernels<a name="DOCF17" href="#FOOT17"><sup>17</sup></a> include already
a number of hardware assisted implementations, and also provide an interface
to access them, called <code>/dev/crypto</code>.
GnuTLS will take advantage of this interface if compiled with special
options. That is because in most systems where hardware-assisted
cryptographic operations are not available, using this interface might
actually harm performance.
</p>
<p>In systems that include cryptographic instructions with the CPU’s
instructions set, using the kernel interface will introduce an
unneeded layer. For this reason GnuTLS includes such optimizations
found in popular processors such as the AES-NI or VIA PADLOCK instruction sets.
This is achieved using a mechanism that detects CPU capabilities and
overrides parts of crypto back-end at runtime.
The next section discusses the registration of a detected algorithm
optimization. For more information please consult the <acronym>GnuTLS</acronym>
source code in <code>lib/accelerated/</code>.
</p>
<a name="Overriding-specific-algorithms"></a>
<h4 class="subsubheading">Overriding specific algorithms</h4>
<p>When an optimized implementation of a single algorithm is available,
say a hardware assisted version of <acronym>AES-CBC</acronym> then the
following (internal) functions, from <code>crypto-backend.h</code>, can
be used to register those algorithms.
</p>
<ul>
<li> <code>gnutls_crypto_single_cipher_register</code>:
To register a cipher algorithm.
</li><li> <code>gnutls_crypto_single_digest_register</code>:
To register a hash (digest) or MAC algorithm.
</li></ul>
<p>Those registration functions will only replace the specified algorithm
and leave the rest of subsystem intact.
</p>
<a name="Overriding-the-cryptographic-library"></a>
<h4 class="subsubheading">Overriding the cryptographic library</h4>
<p>In some systems, that might contain a broad acceleration engine, it
might be desirable to override big parts of the cryptographic back-end,
or even all of them. The following functions are provided for this reason.
</p>
<ul>
<li> <code>gnutls_crypto_cipher_register</code>:
To override the cryptographic algorithms back-end.
</li><li> <code>gnutls_crypto_digest_register</code>:
To override the digest algorithms back-end.
</li><li> <code>gnutls_crypto_rnd_register</code>:
To override the random number generator back-end.
</li><li> <code>gnutls_crypto_bigint_register</code>:
To override the big number number operations back-end.
</li><li> <code>gnutls_crypto_pk_register</code>:
To override the public key encryption back-end. This is tied to the
big number operations so either none or both of them should be overriden.
</li></ul>
<hr>
<a name="Upgrading-from-previous-versions"></a>
<div class="header">
<p>
Next: <a href="#Support" accesskey="n" rel="next">Support</a>, Previous: <a href="#Internal-architecture-of-GnuTLS" accesskey="p" rel="previous">Internal architecture of GnuTLS</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Upgrading-from-previous-versions-1"></a>
<h2 class="appendix">Appendix A Upgrading from previous versions</h2>
<a name="index-upgrading"></a>
<p>The GnuTLS library typically maintains binary and source code compatibility
across versions. The releases that have the major version increased
break binary compatibility but source compatibility is provided.
This section lists exceptional cases where changes to existing code are
required due to library changes.
</p>
<a name="Upgrading-to-2_002e12_002ex-from-previous-versions"></a>
<h3 class="heading">Upgrading to 2.12.x from previous versions</h3>
<p>GnuTLS 2.12.x is binary compatible with previous versions but changes the
semantics of <code>gnutls_transport_set_lowat</code>, which might cause breakage
in applications that relied on its default value be 1. Two fixes
are proposed:
</p><ul>
<li> Quick fix. Explicitly call <code>gnutls_transport_set_lowat (session, 1);</code>
after <a href="#gnutls_005finit">gnutls_init</a>.
</li><li> Long term fix. Because later versions of gnutls abolish the functionality
of using the system call <code>select</code> to check for gnutls pending data, the
function <a href="#gnutls_005frecord_005fcheck_005fpending">gnutls_record_check_pending</a> has to be used to achieve the same
functionality as described in <a href="#Asynchronous-operation">Asynchronous operation</a>.
</li></ul>
<a name="Upgrading-to-3_002e0_002ex-from-2_002e12_002ex"></a>
<h3 class="heading">Upgrading to 3.0.x from 2.12.x</h3>
<p>GnuTLS 3.0.x is source compatible with previous versions except for the functions
listed below.
</p>
<table>
<thead><tr><th width="30%">Old function</th><th width="60%">Replacement</th></tr></thead>
<tr><td width="30%"><code>gnutls_transport_set_lowat</code></td><td width="60%">To replace its functionality the function <a href="#gnutls_005frecord_005fcheck_005fpending">gnutls_record_check_pending</a> has to be used,
as described in <a href="#Asynchronous-operation">Asynchronous operation</a></td></tr>
<tr><td width="30%"><code>gnutls_session_get_server_random</code>,
<code>gnutls_session_get_client_random</code></td><td width="60%">They are replaced by the safer function <a href="#gnutls_005fsession_005fget_005frandom">gnutls_session_get_random</a></td></tr>
<tr><td width="30%"><code>gnutls_session_get_master_secret</code></td><td width="60%">Replaced by the keying material exporters discussed in <a href="#Keying-Material-Exporters">Keying Material Exporters</a></td></tr>
<tr><td width="30%"><code>gnutls_transport_set_global_errno</code></td><td width="60%">Replaced by using the system’s errno fascility or <a href="#gnutls_005ftransport_005fset_005ferrno">gnutls_transport_set_errno</a>.</td></tr>
<tr><td width="30%"><code>gnutls_x509_privkey_verify_data</code></td><td width="60%">Replaced by <a href="#gnutls_005fpubkey_005fverify_005fdata">gnutls_pubkey_verify_data</a>.</td></tr>
<tr><td width="30%"><code>gnutls_certificate_verify_peers</code></td><td width="60%">Replaced by <a href="#gnutls_005fcertificate_005fverify_005fpeers2">gnutls_certificate_verify_peers2</a>.</td></tr>
<tr><td width="30%"><code>gnutls_psk_netconf_derive_key</code></td><td width="60%">Removed. The key derivation function was never standardized.</td></tr>
<tr><td width="30%"><code>gnutls_session_set_finished_function</code></td><td width="60%">Removed.</td></tr>
<tr><td width="30%"><code>gnutls_ext_register</code></td><td width="60%">Removed. Extension registration API is now internal to allow easier changes in the API.</td></tr>
<tr><td width="30%"><code>gnutls_certificate_get_x509_crls</code>, <code>gnutls_certificate_get_x509_cas</code></td><td width="60%">Removed to allow updating the internal structures. Replaced by <a href="#gnutls_005fcertificate_005fget_005fissuer">gnutls_certificate_get_issuer</a>.</td></tr>
<tr><td width="30%"><code>gnutls_certificate_get_openpgp_keyring</code></td><td width="60%">Removed.</td></tr>
<tr><td width="30%"><code>gnutls_ia_*</code></td><td width="60%">Removed. The inner application extensions were completely removed (they failed to be standardized).</td></tr>
</table>
<a name="Upgrading-to-3_002e1_002ex-from-3_002e0_002ex"></a>
<h3 class="heading">Upgrading to 3.1.x from 3.0.x</h3>
<p>GnuTLS 3.1.x is source and binary compatible with GnuTLS 3.0.x releases. Few
functions have been deprecated and are listed below.
</p>
<table>
<thead><tr><th width="30%">Old function</th><th width="60%">Replacement</th></tr></thead>
<tr><td width="30%"><code>gnutls_pubkey_verify_hash</code></td><td width="60%">The function <a href="#gnutls_005fpubkey_005fverify_005fhash2">gnutls_pubkey_verify_hash2</a> is provided and
is functionally equivalent and safer to use.</td></tr>
<tr><td width="30%"><code>gnutls_pubkey_verify_data</code></td><td width="60%">The function <a href="#gnutls_005fpubkey_005fverify_005fdata2">gnutls_pubkey_verify_data2</a> is provided and
is functionally equivalent and safer to use.</td></tr>
</table>
<hr>
<a name="Support"></a>
<div class="header">
<p>
Next: <a href="#Error-codes" accesskey="n" rel="next">Error codes</a>, Previous: <a href="#Upgrading-from-previous-versions" accesskey="p" rel="previous">Upgrading from previous versions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Support-1"></a>
<h2 class="appendix">Appendix B Support</h2>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Getting-help" accesskey="1">Getting help</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Commercial-Support" accesskey="2">Commercial Support</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Bug-Reports" accesskey="3">Bug Reports</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Contributing" accesskey="4">Contributing</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Getting-help"></a>
<div class="header">
<p>
Next: <a href="#Commercial-Support" accesskey="n" rel="next">Commercial Support</a>, Up: <a href="#Support" accesskey="u" rel="up">Support</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Getting-Help"></a>
<h3 class="section">B.1 Getting Help</h3>
<p>A mailing list where users may help each other exists, and you can
reach it by sending e-mail to <a href="mailto:help-gnutls@gnu.org">help-gnutls@gnu.org</a>. Archives
of the mailing list discussions, and an interface to manage
subscriptions, is available through the World Wide Web at
<a href="http://lists.gnu.org/mailman/listinfo/help-gnutls">http://lists.gnu.org/mailman/listinfo/help-gnutls</a>.
</p>
<p>A mailing list for developers are also available, see
<a href="http://www.gnu.org/software/gnutls/lists.html">http://www.gnu.org/software/gnutls/lists.html</a>.
Bug reports should be sent to <a href="mailto:bug-gnutls@gnu.org">bug-gnutls@gnu.org</a>, see
<a href="#Bug-Reports">Bug Reports</a>.
</p>
<hr>
<a name="Commercial-Support"></a>
<div class="header">
<p>
Next: <a href="#Bug-Reports" accesskey="n" rel="next">Bug Reports</a>, Previous: <a href="#Getting-help" accesskey="p" rel="previous">Getting help</a>, Up: <a href="#Support" accesskey="u" rel="up">Support</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Commercial-Support-1"></a>
<h3 class="section">B.2 Commercial Support</h3>
<p>Commercial support is available for users of GnuTLS. The kind of
support that can be purchased may include:
</p>
<ul>
<li> Implement new features.
Such as a new TLS extension.
</li><li> Port GnuTLS to new platforms.
This could include porting to an embedded platforms that may need
memory or size optimization.
</li><li> Integrating TLS as a security environment in your existing project.
</li><li> System design of components related to TLS.
</li></ul>
<p>If you are interested, please write to:
</p>
<pre class="verbatim">Simon Josefsson Datakonsult
Hagagatan 24
113 47 Stockholm
Sweden
E-mail: simon@josefsson.org
</pre>
<p>If your company provides support related to GnuTLS and would like to
be mentioned here, contact the authors.
</p>
<hr>
<a name="Bug-Reports"></a>
<div class="header">
<p>
Next: <a href="#Contributing" accesskey="n" rel="next">Contributing</a>, Previous: <a href="#Commercial-Support" accesskey="p" rel="previous">Commercial Support</a>, Up: <a href="#Support" accesskey="u" rel="up">Support</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Bug-Reports-1"></a>
<h3 class="section">B.3 Bug Reports</h3>
<a name="index-reporting-bugs"></a>
<p>If you think you have found a bug in GnuTLS, please investigate it and
report it.
</p>
<ul>
<li> Please make sure that the bug is really in GnuTLS, and
preferably also check that it hasn’t already been fixed in the latest
version.
</li><li> You have to send us a test case that makes it possible for us to
reproduce the bug.
</li><li> You also have to explain what is wrong; if you get a crash, or
if the results printed are not good and in that case, in what way.
Make sure that the bug report includes all information you would need
to fix this kind of bug for someone else.
</li></ul>
<p>Please make an effort to produce a self-contained report, with
something definite that can be tested or debugged. Vague queries or
piecemeal messages are difficult to act on and don’t help the
development effort.
</p>
<p>If your bug report is good, we will do our best to help you to get a
corrected version of the software; if the bug report is poor, we won’t
do anything about it (apart from asking you to send better bug
reports).
</p>
<p>If you think something in this manual is unclear, or downright
incorrect, or if the language needs to be improved, please also send a
note.
</p>
<p>Send your bug report to:
</p>
<div align="center">‘<samp>bug-gnutls@gnu.org</samp>’
</div>
<hr>
<a name="Contributing"></a>
<div class="header">
<p>
Previous: <a href="#Bug-Reports" accesskey="p" rel="previous">Bug Reports</a>, Up: <a href="#Support" accesskey="u" rel="up">Support</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Contributing-1"></a>
<h3 class="section">B.4 Contributing</h3>
<a name="index-contributing"></a>
<a name="index-hacking"></a>
<p>If you want to submit a patch for inclusion – from solving a typo you
discovered, up to adding support for a new feature – you should
submit it as a bug report, using the process in <a href="#Bug-Reports">Bug Reports</a>. There are some
things that you can do to increase the chances for it to be included
in the official package.
</p>
<p>Unless your patch is very small (say, under 10 lines) we require that
you assign the copyright of your work to the Free Software Foundation.
This is to protect the freedom of the project. If you have not
already signed papers, we will send you the necessary information when
you submit your contribution.
</p>
<p>For contributions that doesn’t consist of actual programming code, the
only guidelines are common sense.
For code contributions, a number of style guides will help you:
</p>
<ul>
<li> Coding Style.
Follow the GNU Standards document.
<p>If you normally code using another coding standard, there is no
problem, but you should use ‘<samp>indent</samp>’ to reformat the code
before submitting your work.
</p>
</li><li> Use the unified diff format ‘<samp>diff -u</samp>’.
</li><li> Return errors.
No reason whatsoever should abort the execution of the library. Even
memory allocation errors, e.g. when malloc return NULL, should work
although result in an error code.
</li><li> Design with thread safety in mind.
Don’t use global variables. Don’t even write to per-handle global
variables unless the documented behaviour of the function you write is
to write to the per-handle global variable.
</li><li> Avoid using the C math library.
It causes problems for embedded implementations, and in most
situations it is very easy to avoid using it.
</li><li> Document your functions.
Use comments before each function headers, that, if properly
formatted, are extracted into Texinfo manuals and GTK-DOC web pages.
</li><li> Supply a ChangeLog and NEWS entries, where appropriate.
</li></ul>
<hr>
<a name="Error-codes"></a>
<div class="header">
<p>
Next: <a href="#Supported-ciphersuites" accesskey="n" rel="next">Supported ciphersuites</a>, Previous: <a href="#Support" accesskey="p" rel="previous">Support</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Error-Codes-and-Descriptions"></a>
<h2 class="appendix">Appendix C Error Codes and Descriptions</h2>
<a name="index-error-codes"></a>
<p>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.
</p>
<table>
<tr><td width="15%">0</td><td width="40%">GNUTLS_E_SUCCESS</td><td width="37%">Success.</td></tr>
<tr><td width="15%">-3</td><td width="40%">GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM</td><td width="37%">Could not negotiate a supported compression method.</td></tr>
<tr><td width="15%">-6</td><td width="40%">GNUTLS_E_UNKNOWN_CIPHER_TYPE</td><td width="37%">The cipher type is unsupported.</td></tr>
<tr><td width="15%">-7</td><td width="40%">GNUTLS_E_LARGE_PACKET</td><td width="37%">The transmitted packet is too large (EMSGSIZE).</td></tr>
<tr><td width="15%">-8</td><td width="40%">GNUTLS_E_UNSUPPORTED_VERSION_PACKET</td><td width="37%">A record packet with illegal version was received.</td></tr>
<tr><td width="15%">-9</td><td width="40%">GNUTLS_E_UNEXPECTED_PACKET_LENGTH</td><td width="37%">A TLS packet with unexpected length was received.</td></tr>
<tr><td width="15%">-10</td><td width="40%">GNUTLS_E_INVALID_SESSION</td><td width="37%">The specified session has been invalidated for some reason.</td></tr>
<tr><td width="15%">-12</td><td width="40%">GNUTLS_E_FATAL_ALERT_RECEIVED</td><td width="37%">A TLS fatal alert has been received.</td></tr>
<tr><td width="15%">-15</td><td width="40%">GNUTLS_E_UNEXPECTED_PACKET</td><td width="37%">An unexpected TLS packet was received.</td></tr>
<tr><td width="15%">-16</td><td width="40%">GNUTLS_E_WARNING_ALERT_RECEIVED</td><td width="37%">A TLS warning alert has been received.</td></tr>
<tr><td width="15%">-18</td><td width="40%">GNUTLS_E_ERROR_IN_FINISHED_PACKET</td><td width="37%">An error was encountered at the TLS Finished packet calculation.</td></tr>
<tr><td width="15%">-19</td><td width="40%">GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET</td><td width="37%">An unexpected TLS handshake packet was received.</td></tr>
<tr><td width="15%">-21</td><td width="40%">GNUTLS_E_UNKNOWN_CIPHER_SUITE</td><td width="37%">Could not negotiate a supported cipher suite.</td></tr>
<tr><td width="15%">-22</td><td width="40%">GNUTLS_E_UNWANTED_ALGORITHM</td><td width="37%">An algorithm that is not enabled was negotiated.</td></tr>
<tr><td width="15%">-23</td><td width="40%">GNUTLS_E_MPI_SCAN_FAILED</td><td width="37%">The scanning of a large integer has failed.</td></tr>
<tr><td width="15%">-24</td><td width="40%">GNUTLS_E_DECRYPTION_FAILED</td><td width="37%">Decryption has failed.</td></tr>
<tr><td width="15%">-25</td><td width="40%">GNUTLS_E_MEMORY_ERROR</td><td width="37%">Internal error in memory allocation.</td></tr>
<tr><td width="15%">-26</td><td width="40%">GNUTLS_E_DECOMPRESSION_FAILED</td><td width="37%">Decompression of the TLS record packet has failed.</td></tr>
<tr><td width="15%">-27</td><td width="40%">GNUTLS_E_COMPRESSION_FAILED</td><td width="37%">Compression of the TLS record packet has failed.</td></tr>
<tr><td width="15%">-28</td><td width="40%">GNUTLS_E_AGAIN</td><td width="37%">Resource temporarily unavailable, try again.</td></tr>
<tr><td width="15%">-29</td><td width="40%">GNUTLS_E_EXPIRED</td><td width="37%">The requested session has expired.</td></tr>
<tr><td width="15%">-30</td><td width="40%">GNUTLS_E_DB_ERROR</td><td width="37%">Error in Database backend.</td></tr>
<tr><td width="15%">-31</td><td width="40%">GNUTLS_E_SRP_PWD_ERROR</td><td width="37%">Error in password file.</td></tr>
<tr><td width="15%">-32</td><td width="40%">GNUTLS_E_INSUFFICIENT_CREDENTIALS</td><td width="37%">Insufficient credentials for that request.</td></tr>
<tr><td width="15%">-33</td><td width="40%">GNUTLS_E_HASH_FAILED</td><td width="37%">Hashing has failed.</td></tr>
<tr><td width="15%">-34</td><td width="40%">GNUTLS_E_BASE64_DECODING_ERROR</td><td width="37%">Base64 decoding error.</td></tr>
<tr><td width="15%">-35</td><td width="40%">GNUTLS_E_MPI_PRINT_FAILED</td><td width="37%">Could not export a large integer.</td></tr>
<tr><td width="15%">-37</td><td width="40%">GNUTLS_E_REHANDSHAKE</td><td width="37%">Rehandshake was requested by the peer.</td></tr>
<tr><td width="15%">-38</td><td width="40%">GNUTLS_E_GOT_APPLICATION_DATA</td><td width="37%">TLS Application data were received, while expecting handshake data.</td></tr>
<tr><td width="15%">-39</td><td width="40%">GNUTLS_E_RECORD_LIMIT_REACHED</td><td width="37%">The upper limit of record packet sequence numbers has been reached. Wow!</td></tr>
<tr><td width="15%">-40</td><td width="40%">GNUTLS_E_ENCRYPTION_FAILED</td><td width="37%">Encryption has failed.</td></tr>
<tr><td width="15%">-43</td><td width="40%">GNUTLS_E_CERTIFICATE_ERROR</td><td width="37%">Error in the certificate.</td></tr>
<tr><td width="15%">-44</td><td width="40%">GNUTLS_E_PK_ENCRYPTION_FAILED</td><td width="37%">Public key encryption has failed.</td></tr>
<tr><td width="15%">-45</td><td width="40%">GNUTLS_E_PK_DECRYPTION_FAILED</td><td width="37%">Public key decryption has failed.</td></tr>
<tr><td width="15%">-46</td><td width="40%">GNUTLS_E_PK_SIGN_FAILED</td><td width="37%">Public key signing has failed.</td></tr>
<tr><td width="15%">-47</td><td width="40%">GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION</td><td width="37%">Unsupported critical extension in X.509 certificate.</td></tr>
<tr><td width="15%">-48</td><td width="40%">GNUTLS_E_KEY_USAGE_VIOLATION</td><td width="37%">Key usage violation in certificate has been detected.</td></tr>
<tr><td width="15%">-49</td><td width="40%">GNUTLS_E_NO_CERTIFICATE_FOUND</td><td width="37%">No certificate was found.</td></tr>
<tr><td width="15%">-50</td><td width="40%">GNUTLS_E_INVALID_REQUEST</td><td width="37%">The request is invalid.</td></tr>
<tr><td width="15%">-51</td><td width="40%">GNUTLS_E_SHORT_MEMORY_BUFFER</td><td width="37%">The given memory buffer is too short to hold parameters.</td></tr>
<tr><td width="15%">-52</td><td width="40%">GNUTLS_E_INTERRUPTED</td><td width="37%">Function was interrupted.</td></tr>
<tr><td width="15%">-53</td><td width="40%">GNUTLS_E_PUSH_ERROR</td><td width="37%">Error in the push function.</td></tr>
<tr><td width="15%">-54</td><td width="40%">GNUTLS_E_PULL_ERROR</td><td width="37%">Error in the pull function.</td></tr>
<tr><td width="15%">-55</td><td width="40%">GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER</td><td width="37%">An illegal parameter has been received.</td></tr>
<tr><td width="15%">-56</td><td width="40%">GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</td><td width="37%">The requested data were not available.</td></tr>
<tr><td width="15%">-57</td><td width="40%">GNUTLS_E_PKCS1_WRONG_PAD</td><td width="37%">Wrong padding in PKCS1 packet.</td></tr>
<tr><td width="15%">-58</td><td width="40%">GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION</td><td width="37%">An illegal TLS extension was received.</td></tr>
<tr><td width="15%">-59</td><td width="40%">GNUTLS_E_INTERNAL_ERROR</td><td width="37%">GnuTLS internal error.</td></tr>
<tr><td width="15%">-60</td><td width="40%">GNUTLS_E_CERTIFICATE_KEY_MISMATCH</td><td width="37%">The certificate and the given key do not match.</td></tr>
<tr><td width="15%">-61</td><td width="40%">GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE</td><td width="37%">The certificate type is not supported.</td></tr>
<tr><td width="15%">-62</td><td width="40%">GNUTLS_E_X509_UNKNOWN_SAN</td><td width="37%">Unknown Subject Alternative name in X.509 certificate.</td></tr>
<tr><td width="15%">-63</td><td width="40%">GNUTLS_E_DH_PRIME_UNACCEPTABLE</td><td width="37%">The Diffie-Hellman prime sent by the server is not acceptable (not long enough).</td></tr>
<tr><td width="15%">-64</td><td width="40%">GNUTLS_E_FILE_ERROR</td><td width="37%">Error while reading file.</td></tr>
<tr><td width="15%">-67</td><td width="40%">GNUTLS_E_ASN1_ELEMENT_NOT_FOUND</td><td width="37%">ASN1 parser: Element was not found.</td></tr>
<tr><td width="15%">-68</td><td width="40%">GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND</td><td width="37%">ASN1 parser: Identifier was not found</td></tr>
<tr><td width="15%">-69</td><td width="40%">GNUTLS_E_ASN1_DER_ERROR</td><td width="37%">ASN1 parser: Error in DER parsing.</td></tr>
<tr><td width="15%">-70</td><td width="40%">GNUTLS_E_ASN1_VALUE_NOT_FOUND</td><td width="37%">ASN1 parser: Value was not found.</td></tr>
<tr><td width="15%">-71</td><td width="40%">GNUTLS_E_ASN1_GENERIC_ERROR</td><td width="37%">ASN1 parser: Generic parsing error.</td></tr>
<tr><td width="15%">-72</td><td width="40%">GNUTLS_E_ASN1_VALUE_NOT_VALID</td><td width="37%">ASN1 parser: Value is not valid.</td></tr>
<tr><td width="15%">-73</td><td width="40%">GNUTLS_E_ASN1_TAG_ERROR</td><td width="37%">ASN1 parser: Error in TAG.</td></tr>
<tr><td width="15%">-74</td><td width="40%">GNUTLS_E_ASN1_TAG_IMPLICIT</td><td width="37%">ASN1 parser: error in implicit tag</td></tr>
<tr><td width="15%">-75</td><td width="40%">GNUTLS_E_ASN1_TYPE_ANY_ERROR</td><td width="37%">ASN1 parser: Error in type ’ANY’.</td></tr>
<tr><td width="15%">-76</td><td width="40%">GNUTLS_E_ASN1_SYNTAX_ERROR</td><td width="37%">ASN1 parser: Syntax error.</td></tr>
<tr><td width="15%">-77</td><td width="40%">GNUTLS_E_ASN1_DER_OVERFLOW</td><td width="37%">ASN1 parser: Overflow in DER parsing.</td></tr>
<tr><td width="15%">-78</td><td width="40%">GNUTLS_E_TOO_MANY_EMPTY_PACKETS</td><td width="37%">Too many empty record packets have been received.</td></tr>
<tr><td width="15%">-79</td><td width="40%">GNUTLS_E_OPENPGP_UID_REVOKED</td><td width="37%">The OpenPGP User ID is revoked.</td></tr>
<tr><td width="15%">-80</td><td width="40%">GNUTLS_E_UNKNOWN_PK_ALGORITHM</td><td width="37%">An unknown public key algorithm was encountered.</td></tr>
<tr><td width="15%">-81</td><td width="40%">GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS</td><td width="37%">Too many handshake packets have been received.</td></tr>
<tr><td width="15%">-84</td><td width="40%">GNUTLS_E_NO_TEMPORARY_RSA_PARAMS</td><td width="37%">No temporary RSA parameters were found.</td></tr>
<tr><td width="15%">-86</td><td width="40%">GNUTLS_E_NO_COMPRESSION_ALGORITHMS</td><td width="37%">No supported compression algorithms have been found.</td></tr>
<tr><td width="15%">-87</td><td width="40%">GNUTLS_E_NO_CIPHER_SUITES</td><td width="37%">No supported cipher suites have been found.</td></tr>
<tr><td width="15%">-88</td><td width="40%">GNUTLS_E_OPENPGP_GETKEY_FAILED</td><td width="37%">Could not get OpenPGP key.</td></tr>
<tr><td width="15%">-89</td><td width="40%">GNUTLS_E_PK_SIG_VERIFY_FAILED</td><td width="37%">Public key signature verification has failed.</td></tr>
<tr><td width="15%">-90</td><td width="40%">GNUTLS_E_ILLEGAL_SRP_USERNAME</td><td width="37%">The SRP username supplied is illegal.</td></tr>
<tr><td width="15%">-91</td><td width="40%">GNUTLS_E_SRP_PWD_PARSING_ERROR</td><td width="37%">Parsing error in password file.</td></tr>
<tr><td width="15%">-93</td><td width="40%">GNUTLS_E_NO_TEMPORARY_DH_PARAMS</td><td width="37%">No temporary DH parameters were found.</td></tr>
<tr><td width="15%">-94</td><td width="40%">GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED</td><td width="37%">The OpenPGP fingerprint is not supported.</td></tr>
<tr><td width="15%">-95</td><td width="40%">GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE</td><td width="37%">The certificate has unsupported attributes.</td></tr>
<tr><td width="15%">-96</td><td width="40%">GNUTLS_E_UNKNOWN_HASH_ALGORITHM</td><td width="37%">The hash algorithm is unknown.</td></tr>
<tr><td width="15%">-97</td><td width="40%">GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE</td><td width="37%">The PKCS structure’s content type is unknown.</td></tr>
<tr><td width="15%">-98</td><td width="40%">GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE</td><td width="37%">The PKCS structure’s bag type is unknown.</td></tr>
<tr><td width="15%">-99</td><td width="40%">GNUTLS_E_INVALID_PASSWORD</td><td width="37%">The given password contains invalid characters.</td></tr>
<tr><td width="15%">-100</td><td width="40%">GNUTLS_E_MAC_VERIFY_FAILED</td><td width="37%">The Message Authentication Code verification failed.</td></tr>
<tr><td width="15%">-101</td><td width="40%">GNUTLS_E_CONSTRAINT_ERROR</td><td width="37%">Some constraint limits were reached.</td></tr>
<tr><td width="15%">-102</td><td width="40%">GNUTLS_E_WARNING_IA_IPHF_RECEIVED</td><td width="37%">Received a TLS/IA Intermediate Phase Finished message</td></tr>
<tr><td width="15%">-103</td><td width="40%">GNUTLS_E_WARNING_IA_FPHF_RECEIVED</td><td width="37%">Received a TLS/IA Final Phase Finished message</td></tr>
<tr><td width="15%">-104</td><td width="40%">GNUTLS_E_IA_VERIFY_FAILED</td><td width="37%">Verifying TLS/IA phase checksum failed</td></tr>
<tr><td width="15%">-105</td><td width="40%">GNUTLS_E_UNKNOWN_ALGORITHM</td><td width="37%">The specified algorithm or protocol is unknown.</td></tr>
<tr><td width="15%">-106</td><td width="40%">GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM</td><td width="37%">The signature algorithm is not supported.</td></tr>
<tr><td width="15%">-107</td><td width="40%">GNUTLS_E_SAFE_RENEGOTIATION_FAILED</td><td width="37%">Safe renegotiation failed.</td></tr>
<tr><td width="15%">-108</td><td width="40%">GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED</td><td width="37%">Unsafe renegotiation denied.</td></tr>
<tr><td width="15%">-109</td><td width="40%">GNUTLS_E_UNKNOWN_SRP_USERNAME</td><td width="37%">The SRP username supplied is unknown.</td></tr>
<tr><td width="15%">-110</td><td width="40%">GNUTLS_E_PREMATURE_TERMINATION</td><td width="37%">The TLS connection was non-properly terminated.</td></tr>
<tr><td width="15%">-201</td><td width="40%">GNUTLS_E_BASE64_ENCODING_ERROR</td><td width="37%">Base64 encoding error.</td></tr>
<tr><td width="15%">-202</td><td width="40%">GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY</td><td width="37%">The crypto library version is too old.</td></tr>
<tr><td width="15%">-203</td><td width="40%">GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY</td><td width="37%">The tasn1 library version is too old.</td></tr>
<tr><td width="15%">-204</td><td width="40%">GNUTLS_E_OPENPGP_KEYRING_ERROR</td><td width="37%">Error loading the keyring.</td></tr>
<tr><td width="15%">-205</td><td width="40%">GNUTLS_E_X509_UNSUPPORTED_OID</td><td width="37%">The OID is not supported.</td></tr>
<tr><td width="15%">-206</td><td width="40%">GNUTLS_E_RANDOM_FAILED</td><td width="37%">Failed to acquire random data.</td></tr>
<tr><td width="15%">-207</td><td width="40%">GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR</td><td width="37%">Base64 unexpected header error.</td></tr>
<tr><td width="15%">-208</td><td width="40%">GNUTLS_E_OPENPGP_SUBKEY_ERROR</td><td width="37%">Could not find OpenPGP subkey.</td></tr>
<tr><td width="15%">-209</td><td width="40%">GNUTLS_E_CRYPTO_ALREADY_REGISTERED</td><td width="37%">There is already a crypto algorithm with lower priority.</td></tr>
<tr><td width="15%">-210</td><td width="40%">GNUTLS_E_HANDSHAKE_TOO_LARGE</td><td width="37%">The handshake data size is too large.</td></tr>
<tr><td width="15%">-211</td><td width="40%">GNUTLS_E_CRYPTODEV_IOCTL_ERROR</td><td width="37%">Error interfacing with /dev/crypto</td></tr>
<tr><td width="15%">-212</td><td width="40%">GNUTLS_E_CRYPTODEV_DEVICE_ERROR</td><td width="37%">Error opening /dev/crypto</td></tr>
<tr><td width="15%">-213</td><td width="40%">GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE</td><td width="37%">Channel binding data not available</td></tr>
<tr><td width="15%">-214</td><td width="40%">GNUTLS_E_BAD_COOKIE</td><td width="37%">The cookie was bad.</td></tr>
<tr><td width="15%">-215</td><td width="40%">GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR</td><td width="37%">The OpenPGP key has not a preferred key set.</td></tr>
<tr><td width="15%">-216</td><td width="40%">GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL</td><td width="37%">The given DSA key is incompatible with the selected TLS protocol.</td></tr>
<tr><td width="15%">-292</td><td width="40%">GNUTLS_E_HEARTBEAT_PONG_RECEIVED</td><td width="37%">A heartbeat pong message was received.</td></tr>
<tr><td width="15%">-293</td><td width="40%">GNUTLS_E_HEARTBEAT_PING_RECEIVED</td><td width="37%">A heartbeat ping message was received.</td></tr>
<tr><td width="15%">-300</td><td width="40%">GNUTLS_E_PKCS11_ERROR</td><td width="37%">PKCS #11 error.</td></tr>
<tr><td width="15%">-301</td><td width="40%">GNUTLS_E_PKCS11_LOAD_ERROR</td><td width="37%">PKCS #11 initialization error.</td></tr>
<tr><td width="15%">-302</td><td width="40%">GNUTLS_E_PARSING_ERROR</td><td width="37%">Error in parsing.</td></tr>
<tr><td width="15%">-303</td><td width="40%">GNUTLS_E_PKCS11_PIN_ERROR</td><td width="37%">Error in provided PIN.</td></tr>
<tr><td width="15%">-305</td><td width="40%">GNUTLS_E_PKCS11_SLOT_ERROR</td><td width="37%">PKCS #11 error in slot</td></tr>
<tr><td width="15%">-306</td><td width="40%">GNUTLS_E_LOCKING_ERROR</td><td width="37%">Thread locking error</td></tr>
<tr><td width="15%">-307</td><td width="40%">GNUTLS_E_PKCS11_ATTRIBUTE_ERROR</td><td width="37%">PKCS #11 error in attribute</td></tr>
<tr><td width="15%">-308</td><td width="40%">GNUTLS_E_PKCS11_DEVICE_ERROR</td><td width="37%">PKCS #11 error in device</td></tr>
<tr><td width="15%">-309</td><td width="40%">GNUTLS_E_PKCS11_DATA_ERROR</td><td width="37%">PKCS #11 error in data</td></tr>
<tr><td width="15%">-310</td><td width="40%">GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR</td><td width="37%">PKCS #11 unsupported feature</td></tr>
<tr><td width="15%">-311</td><td width="40%">GNUTLS_E_PKCS11_KEY_ERROR</td><td width="37%">PKCS #11 error in key</td></tr>
<tr><td width="15%">-312</td><td width="40%">GNUTLS_E_PKCS11_PIN_EXPIRED</td><td width="37%">PKCS #11 PIN expired</td></tr>
<tr><td width="15%">-313</td><td width="40%">GNUTLS_E_PKCS11_PIN_LOCKED</td><td width="37%">PKCS #11 PIN locked</td></tr>
<tr><td width="15%">-314</td><td width="40%">GNUTLS_E_PKCS11_SESSION_ERROR</td><td width="37%">PKCS #11 error in session</td></tr>
<tr><td width="15%">-315</td><td width="40%">GNUTLS_E_PKCS11_SIGNATURE_ERROR</td><td width="37%">PKCS #11 error in signature</td></tr>
<tr><td width="15%">-316</td><td width="40%">GNUTLS_E_PKCS11_TOKEN_ERROR</td><td width="37%">PKCS #11 error in token</td></tr>
<tr><td width="15%">-317</td><td width="40%">GNUTLS_E_PKCS11_USER_ERROR</td><td width="37%">PKCS #11 user error</td></tr>
<tr><td width="15%">-318</td><td width="40%">GNUTLS_E_CRYPTO_INIT_FAILED</td><td width="37%">The initialization of crypto backend has failed.</td></tr>
<tr><td width="15%">-319</td><td width="40%">GNUTLS_E_TIMEDOUT</td><td width="37%">The operation timed out</td></tr>
<tr><td width="15%">-320</td><td width="40%">GNUTLS_E_USER_ERROR</td><td width="37%">The operation was cancelled due to user error</td></tr>
<tr><td width="15%">-321</td><td width="40%">GNUTLS_E_ECC_NO_SUPPORTED_CURVES</td><td width="37%">No supported ECC curves were found</td></tr>
<tr><td width="15%">-322</td><td width="40%">GNUTLS_E_ECC_UNSUPPORTED_CURVE</td><td width="37%">The curve is unsupported</td></tr>
<tr><td width="15%">-323</td><td width="40%">GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE</td><td width="37%">The requested PKCS #11 object is not available</td></tr>
<tr><td width="15%">-324</td><td width="40%">GNUTLS_E_CERTIFICATE_LIST_UNSORTED</td><td width="37%">The provided X.509 certificate list is not sorted (in subject to issuer order)</td></tr>
<tr><td width="15%">-325</td><td width="40%">GNUTLS_E_ILLEGAL_PARAMETER</td><td width="37%">An illegal parameter was found.</td></tr>
<tr><td width="15%">-326</td><td width="40%">GNUTLS_E_NO_PRIORITIES_WERE_SET</td><td width="37%">No or insufficient priorities were set.</td></tr>
<tr><td width="15%">-327</td><td width="40%">GNUTLS_E_X509_UNSUPPORTED_EXTENSION</td><td width="37%">Unsupported extension in X.509 certificate.</td></tr>
<tr><td width="15%">-328</td><td width="40%">GNUTLS_E_SESSION_EOF</td><td width="37%">Peer has terminated the connection</td></tr>
<tr><td width="15%">-329</td><td width="40%">GNUTLS_E_TPM_ERROR</td><td width="37%">TPM error.</td></tr>
<tr><td width="15%">-330</td><td width="40%">GNUTLS_E_TPM_KEY_PASSWORD_ERROR</td><td width="37%">Error in provided password for key to be loaded in TPM.</td></tr>
<tr><td width="15%">-331</td><td width="40%">GNUTLS_E_TPM_SRK_PASSWORD_ERROR</td><td width="37%">Error in provided SRK password for TPM.</td></tr>
<tr><td width="15%">-332</td><td width="40%">GNUTLS_E_TPM_SESSION_ERROR</td><td width="37%">Cannot initialize a session with the TPM.</td></tr>
<tr><td width="15%">-333</td><td width="40%">GNUTLS_E_TPM_KEY_NOT_FOUND</td><td width="37%">TPM key was not found in persistent storage.</td></tr>
<tr><td width="15%">-334</td><td width="40%">GNUTLS_E_TPM_UNINITIALIZED</td><td width="37%">TPM is not initialized.</td></tr>
<tr><td width="15%">-340</td><td width="40%">GNUTLS_E_NO_CERTIFICATE_STATUS</td><td width="37%">There is no certificate status (OCSP).</td></tr>
<tr><td width="15%">-341</td><td width="40%">GNUTLS_E_OCSP_RESPONSE_ERROR</td><td width="37%">The OCSP response is invalid</td></tr>
<tr><td width="15%">-342</td><td width="40%">GNUTLS_E_RANDOM_DEVICE_ERROR</td><td width="37%">Error in the system’s randomness device.</td></tr>
<tr><td width="15%">-343</td><td width="40%">GNUTLS_E_AUTH_ERROR</td><td width="37%">Could not authenticate peer.</td></tr>
</table>
<hr>
<a name="Supported-ciphersuites"></a>
<div class="header">
<p>
Next: <a href="#API-reference" accesskey="n" rel="next">API reference</a>, Previous: <a href="#Error-codes" accesskey="p" rel="previous">Error codes</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Supported-Ciphersuites"></a>
<h2 class="appendix">Appendix D Supported Ciphersuites</h2>
<a name="ciphersuites"></a><a name="index-ciphersuites"></a>
<a name="Ciphersuites"></a>
<h3 class="heading">Ciphersuites</h3>
<table>
<thead><tr><th width="60%">Ciphersuite name</th><th width="20%">TLS ID</th><th width="20%">Since</th></tr></thead>
<tr><td width="60%">TLS_DH_ANON_ARCFOUR_MD5</td><td width="20%">0x00 0x18</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DH_ANON_3DES_EDE_CBC_SHA1</td><td width="20%">0x00 0x1B</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DH_ANON_AES_128_CBC_SHA1</td><td width="20%">0x00 0x34</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DH_ANON_AES_256_CBC_SHA1</td><td width="20%">0x00 0x3A</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DH_ANON_CAMELLIA_128_CBC_SHA1</td><td width="20%">0x00 0x46</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DH_ANON_CAMELLIA_256_CBC_SHA1</td><td width="20%">0x00 0x89</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DH_ANON_AES_128_CBC_SHA256</td><td width="20%">0x00 0x6C</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DH_ANON_AES_256_CBC_SHA256</td><td width="20%">0x00 0x6D</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_PSK_SHA_ARCFOUR_SHA1</td><td width="20%">0x00 0x8A</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_PSK_SHA_3DES_EDE_CBC_SHA1</td><td width="20%">0x00 0x8B</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_PSK_SHA_AES_128_CBC_SHA1</td><td width="20%">0x00 0x8C</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_PSK_SHA_AES_256_CBC_SHA1</td><td width="20%">0x00 0x8D</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_PSK_AES_128_CBC_SHA256</td><td width="20%">0x00 0xAE</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_PSK_AES_128_GCM_SHA256</td><td width="20%">0x00 0xA8</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_PSK_NULL_SHA256</td><td width="20%">0x00 0xB0</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_PSK_SHA_ARCFOUR_SHA1</td><td width="20%">0x00 0x8E</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_PSK_SHA_3DES_EDE_CBC_SHA1</td><td width="20%">0x00 0x8F</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_PSK_SHA_AES_128_CBC_SHA1</td><td width="20%">0x00 0x90</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_PSK_SHA_AES_256_CBC_SHA1</td><td width="20%">0x00 0x91</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_PSK_AES_128_CBC_SHA256</td><td width="20%">0x00 0xB2</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_PSK_AES_128_GCM_SHA256</td><td width="20%">0x00 0xAA</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_PSK_NULL_SHA256</td><td width="20%">0x00 0xB4</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x1A</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x1D</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x20</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_DSS_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x1C</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_RSA_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x1B</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_DSS_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x1F</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_RSA_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x1E</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_DSS_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x22</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_SRP_SHA_RSA_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x21</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_ARCFOUR_SHA1</td><td width="20%">0x00 0x66</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_3DES_EDE_CBC_SHA1</td><td width="20%">0x00 0x13</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_AES_128_CBC_SHA1</td><td width="20%">0x00 0x32</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_AES_256_CBC_SHA1</td><td width="20%">0x00 0x38</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_CAMELLIA_128_CBC_SHA1</td><td width="20%">0x00 0x44</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_CAMELLIA_256_CBC_SHA1</td><td width="20%">0x00 0x87</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_DSS_AES_128_CBC_SHA256</td><td width="20%">0x00 0x40</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_DSS_AES_256_CBC_SHA256</td><td width="20%">0x00 0x6A</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_RSA_3DES_EDE_CBC_SHA1</td><td width="20%">0x00 0x16</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DHE_RSA_AES_128_CBC_SHA1</td><td width="20%">0x00 0x33</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DHE_RSA_AES_256_CBC_SHA1</td><td width="20%">0x00 0x39</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_DHE_RSA_CAMELLIA_128_CBC_SHA1</td><td width="20%">0x00 0x45</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_RSA_CAMELLIA_256_CBC_SHA1</td><td width="20%">0x00 0x88</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_DHE_RSA_AES_128_CBC_SHA256</td><td width="20%">0x00 0x67</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_RSA_AES_256_CBC_SHA256</td><td width="20%">0x00 0x6B</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_RSA_NULL_MD5</td><td width="20%">0x00 0x01</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_NULL_SHA1</td><td width="20%">0x00 0x02</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_NULL_SHA256</td><td width="20%">0x00 0x3B</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_RSA_EXPORT_ARCFOUR_40_MD5</td><td width="20%">0x00 0x03</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_ARCFOUR_SHA1</td><td width="20%">0x00 0x05</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_ARCFOUR_MD5</td><td width="20%">0x00 0x04</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_3DES_EDE_CBC_SHA1</td><td width="20%">0x00 0x0A</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_AES_128_CBC_SHA1</td><td width="20%">0x00 0x2F</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_AES_256_CBC_SHA1</td><td width="20%">0x00 0x35</td><td width="20%">SSL3.0</td></tr>
<tr><td width="60%">TLS_RSA_CAMELLIA_128_CBC_SHA1</td><td width="20%">0x00 0x41</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_RSA_CAMELLIA_256_CBC_SHA1</td><td width="20%">0x00 0x84</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_RSA_AES_128_CBC_SHA256</td><td width="20%">0x00 0x3C</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_RSA_AES_256_CBC_SHA256</td><td width="20%">0x00 0x3D</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_RSA_AES_128_GCM_SHA256</td><td width="20%">0x00 0x9C</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_RSA_AES_128_GCM_SHA256</td><td width="20%">0x00 0x9E</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_DSS_AES_128_GCM_SHA256</td><td width="20%">0x00 0xA2</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DH_ANON_AES_128_GCM_SHA256</td><td width="20%">0x00 0xA6</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDH_ANON_NULL_SHA1</td><td width="20%">0xC0 0x15</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDH_ANON_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x17</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDH_ANON_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x18</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDH_ANON_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x19</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_NULL_SHA1</td><td width="20%">0xC0 0x10</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x12</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x13</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x14</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_NULL_SHA1</td><td width="20%">0xC0 0x06</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x08</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x09</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x0A</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_AES_128_CBC_SHA256</td><td width="20%">0xC0 0x23</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_AES_128_CBC_SHA256</td><td width="20%">0xC0 0x27</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_AES_128_GCM_SHA256</td><td width="20%">0xC0 0x2B</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_AES_128_GCM_SHA256</td><td width="20%">0xC0 0x2F</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_3DES_EDE_CBC_SHA1</td><td width="20%">0xC0 0x34</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_AES_128_CBC_SHA1</td><td width="20%">0xC0 0x35</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_AES_256_CBC_SHA1</td><td width="20%">0xC0 0x36</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_AES_128_CBC_SHA256</td><td width="20%">0xC0 0x37</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_AES_256_CBC_SHA384</td><td width="20%">0xC0 0x38</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_NULL_SHA256</td><td width="20%">0xC0 0x3A</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_PSK_NULL_SHA384</td><td width="20%">0xC0 0x3B</td><td width="20%">TLS1.0</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_AES_256_GCM_SHA384</td><td width="20%">0xC0 0x2C</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDHE_RSA_AES_256_GCM_SHA384</td><td width="20%">0xC0 0x30</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_ECDHE_ECDSA_AES_256_CBC_SHA384</td><td width="20%">0xC0 0x24</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_PSK_WITH_AES_256_GCM_SHA384</td><td width="20%">0x00 0xA9</td><td width="20%">TLS1.2</td></tr>
<tr><td width="60%">TLS_DHE_PSK_WITH_AES_256_GCM_SHA384</td><td width="20%">0x00 0xAB</td><td width="20%">TLS1.2</td></tr>
</table>
<a name="Certificate-types"></a>
<h3 class="heading">Certificate types</h3>
<dl compact="compact">
<dt><code>X.509</code></dt>
<dt><code>OPENPGP</code></dt>
</dl>
<a name="Protocols"></a>
<h3 class="heading">Protocols</h3>
<dl compact="compact">
<dt><code>SSL3.0</code></dt>
<dt><code>TLS1.0</code></dt>
<dt><code>TLS1.1</code></dt>
<dt><code>TLS1.2</code></dt>
<dt><code>DTLS0.9</code></dt>
<dt><code>DTLS1.0</code></dt>
</dl>
<a name="Ciphers"></a>
<h3 class="heading">Ciphers</h3>
<dl compact="compact">
<dt><code>AES-256-CBC</code></dt>
<dt><code>AES-192-CBC</code></dt>
<dt><code>AES-128-CBC</code></dt>
<dt><code>AES-128-GCM</code></dt>
<dt><code>AES-256-GCM</code></dt>
<dt><code>ARCFOUR-128</code></dt>
<dt><code>CAMELLIA-256-CBC</code></dt>
<dt><code>CAMELLIA-192-CBC</code></dt>
<dt><code>CAMELLIA-128-CBC</code></dt>
<dt><code>3DES-CBC</code></dt>
<dt><code>DES-CBC</code></dt>
<dt><code>ARCFOUR-40</code></dt>
<dt><code>RC2-40</code></dt>
</dl>
<a name="MAC-algorithms"></a>
<h3 class="heading">MAC algorithms</h3>
<dl compact="compact">
<dt><code>SHA1</code></dt>
<dt><code>MD5</code></dt>
<dt><code>SHA256</code></dt>
<dt><code>SHA384</code></dt>
<dt><code>SHA512</code></dt>
<dt><code>SHA224</code></dt>
<dt><code>AEAD</code></dt>
</dl>
<a name="Key-exchange-methods"></a>
<h3 class="heading">Key exchange methods</h3>
<dl compact="compact">
<dt><code>ANON-DH</code></dt>
<dt><code>ANON-ECDH</code></dt>
<dt><code>RSA</code></dt>
<dt><code>RSA-EXPORT</code></dt>
<dt><code>DHE-RSA</code></dt>
<dt><code>ECDHE-RSA</code></dt>
<dt><code>ECDHE-ECDSA</code></dt>
<dt><code>DHE-DSS</code></dt>
<dt><code>SRP-DSS</code></dt>
<dt><code>SRP-RSA</code></dt>
<dt><code>SRP</code></dt>
<dt><code>PSK</code></dt>
<dt><code>DHE-PSK</code></dt>
<dt><code>ECDHE-PSK</code></dt>
</dl>
<a name="Public-key-algorithms"></a>
<h3 class="heading">Public key algorithms</h3>
<dl compact="compact">
<dt><code>RSA</code></dt>
<dt><code>DSA</code></dt>
<dt><code>EC</code></dt>
</dl>
<a name="Public-key-signature-algorithms"></a>
<h3 class="heading">Public key signature algorithms</h3>
<dl compact="compact">
<dt><code>RSA-SHA1</code></dt>
<dt><code>RSA-SHA224</code></dt>
<dt><code>RSA-SHA256</code></dt>
<dt><code>RSA-SHA384</code></dt>
<dt><code>RSA-SHA512</code></dt>
<dt><code>RSA-RMD160</code></dt>
<dt><code>DSA-SHA1</code></dt>
<dt><code>DSA-SHA224</code></dt>
<dt><code>DSA-SHA256</code></dt>
<dt><code>RSA-MD5</code></dt>
<dt><code>RSA-MD2</code></dt>
<dt><code>ECDSA-SHA1</code></dt>
<dt><code>ECDSA-SHA224</code></dt>
<dt><code>ECDSA-SHA256</code></dt>
<dt><code>ECDSA-SHA384</code></dt>
<dt><code>ECDSA-SHA512</code></dt>
</dl>
<a name="Elliptic-curves"></a>
<h3 class="heading">Elliptic curves</h3>
<dl compact="compact">
<dt><code>SECP192R1</code></dt>
<dt><code>SECP224R1</code></dt>
<dt><code>SECP256R1</code></dt>
<dt><code>SECP384R1</code></dt>
<dt><code>SECP521R1</code></dt>
</dl>
<a name="Compression-methods"></a>
<h3 class="heading">Compression methods</h3>
<dl compact="compact">
<dt><code>DEFLATE</code></dt>
<dt><code>NULL</code></dt>
</dl>
<hr>
<a name="API-reference"></a>
<div class="header">
<p>
Next: <a href="#Copying-Information" accesskey="n" rel="next">Copying Information</a>, Previous: <a href="#Supported-ciphersuites" accesskey="p" rel="previous">Supported ciphersuites</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="API-reference-1"></a>
<h2 class="appendix">Appendix E API reference</h2>
<a name="index-API-reference"></a>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Core-TLS-API" accesskey="1">Core TLS API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#High-level-TLS-API" accesskey="2">High level TLS API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Datagram-TLS-API" accesskey="3">Datagram TLS API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#X509-certificate-API" accesskey="4">X509 certificate API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#OCSP-API" accesskey="5">OCSP API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#OpenPGP-API" accesskey="6">OpenPGP API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#PKCS-12-API" accesskey="7">PKCS 12 API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#PKCS-11-API" accesskey="8">PKCS 11 API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#TPM-API" accesskey="9">TPM API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Abstract-key-API">Abstract key API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#DANE-API">DANE API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Cryptographic-API">Cryptographic API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#Compatibility-API">Compatibility API</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="Core-TLS-API"></a>
<div class="header">
<p>
Next: <a href="#High-level-TLS-API" accesskey="n" rel="next">High level TLS API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Core-TLS-API-1"></a>
<h3 class="section">E.1 Core TLS API</h3>
<p>The prototypes for the following functions lie in
<samp>gnutls/gnutls.h</samp>.
</p>
<a name="gnutls_005falert_005fget-1"></a>
<h4 class="subheading">gnutls_alert_get</h4>
<a name="gnutls_005falert_005fget"></a><dl>
<dt><a name="index-gnutls_005falert_005fget-1"></a>Function: <em>gnutls_alert_description_t</em> <strong>gnutls_alert_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the last alert number received. This
function should be called when <code>GNUTLS_E_WARNING_ALERT_RECEIVED</code> or
<code>GNUTLS_E_FATAL_ALERT_RECEIVED</code> errors are returned by a gnutls
function. The peer may send alerts if he encounters an error.
If no alert has been received the returned value is undefined.
</p>
<p><strong>Returns:</strong> the last alert received, a
<code>gnutls_alert_description_t</code> value.
</p></dd></dl>
<a name="gnutls_005falert_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_alert_get_name</h4>
<a name="gnutls_005falert_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005falert_005fget_005fname-1"></a>Function: <em>const char *</em> <strong>gnutls_alert_get_name</strong> <em>(gnutls_alert_description_t <var>alert</var>)</em></dt>
<dd><p><var>alert</var>: is an alert number.
</p>
<p>This function will return a string that describes the given alert
number, or <code>NULL</code> . See <code>gnutls_alert_get()</code> .
</p>
<p><strong>Returns:</strong> string corresponding to <code>gnutls_alert_description_t</code> value.
</p></dd></dl>
<a name="gnutls_005falert_005fget_005fstrname-1"></a>
<h4 class="subheading">gnutls_alert_get_strname</h4>
<a name="gnutls_005falert_005fget_005fstrname"></a><dl>
<dt><a name="index-gnutls_005falert_005fget_005fstrname"></a>Function: <em>const char *</em> <strong>gnutls_alert_get_strname</strong> <em>(gnutls_alert_description_t <var>alert</var>)</em></dt>
<dd><p><var>alert</var>: is an alert number.
</p>
<p>This function will return a string of the name of the alert.
</p>
<p><strong>Returns:</strong> string corresponding to <code>gnutls_alert_description_t</code> value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005falert_005fsend-1"></a>
<h4 class="subheading">gnutls_alert_send</h4>
<a name="gnutls_005falert_005fsend"></a><dl>
<dt><a name="index-gnutls_005falert_005fsend-1"></a>Function: <em>int</em> <strong>gnutls_alert_send</strong> <em>(gnutls_session_t <var>session</var>, gnutls_alert_level_t <var>level</var>, gnutls_alert_description_t <var>desc</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>level</var>: is the level of the alert
</p>
<p><var>desc</var>: is the alert description
</p>
<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>
<p>The error code of the underlying record send function will be
returned, so you may also receive <code>GNUTLS_E_INTERRUPTED</code> or
<code>GNUTLS_E_AGAIN</code> as well.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005falert_005fsend_005fappropriate-1"></a>
<h4 class="subheading">gnutls_alert_send_appropriate</h4>
<a name="gnutls_005falert_005fsend_005fappropriate"></a><dl>
<dt><a name="index-gnutls_005falert_005fsend_005fappropriate"></a>Function: <em>int</em> <strong>gnutls_alert_send_appropriate</strong> <em>(gnutls_session_t <var>session</var>, int <var>err</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>err</var>: is an integer
</p>
<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>
<p>This function may also return <code>GNUTLS_E_AGAIN</code> , or
<code>GNUTLS_E_INTERRUPTED</code> .
</p>
<p>If the return value is <code>GNUTLS_E_INVALID_REQUEST</code> , then no alert has
been sent to the peer.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fanon_005fallocate_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_anon_allocate_client_credentials</h4>
<a name="gnutls_005fanon_005fallocate_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fanon_005fallocate_005fclient_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_anon_allocate_client_credentials</strong> <em>(gnutls_anon_client_credentials_t * <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a pointer to a <code>gnutls_anon_client_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fanon_005fallocate_005fserver_005fcredentials-1"></a>
<h4 class="subheading">gnutls_anon_allocate_server_credentials</h4>
<a name="gnutls_005fanon_005fallocate_005fserver_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fanon_005fallocate_005fserver_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_anon_allocate_server_credentials</strong> <em>(gnutls_anon_server_credentials_t * <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a pointer to a <code>gnutls_anon_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fanon_005ffree_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_anon_free_client_credentials</h4>
<a name="gnutls_005fanon_005ffree_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fanon_005ffree_005fclient_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_anon_free_client_credentials</strong> <em>(gnutls_anon_client_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_anon_client_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p></dd></dl>
<a name="gnutls_005fanon_005ffree_005fserver_005fcredentials-1"></a>
<h4 class="subheading">gnutls_anon_free_server_credentials</h4>
<a name="gnutls_005fanon_005ffree_005fserver_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fanon_005ffree_005fserver_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_anon_free_server_credentials</strong> <em>(gnutls_anon_server_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_anon_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p></dd></dl>
<a name="gnutls_005fanon_005fset_005fparams_005ffunction-1"></a>
<h4 class="subheading">gnutls_anon_set_params_function</h4>
<a name="gnutls_005fanon_005fset_005fparams_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fanon_005fset_005fparams_005ffunction"></a>Function: <em>void</em> <strong>gnutls_anon_set_params_function</strong> <em>(gnutls_anon_server_credentials_t <var>res</var>, gnutls_params_function * <var>func</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_anon_server_credentials_t structure
</p>
<p><var>func</var>: is the function to be called
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<a name="gnutls_005fanon_005fset_005fserver_005fdh_005fparams-1"></a>
<h4 class="subheading">gnutls_anon_set_server_dh_params</h4>
<a name="gnutls_005fanon_005fset_005fserver_005fdh_005fparams"></a><dl>
<dt><a name="index-gnutls_005fanon_005fset_005fserver_005fdh_005fparams"></a>Function: <em>void</em> <strong>gnutls_anon_set_server_dh_params</strong> <em>(gnutls_anon_server_credentials_t <var>res</var>, gnutls_dh_params_t <var>dh_params</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_anon_server_credentials_t structure
</p>
<p><var>dh_params</var>: is a structure that holds Diffie-Hellman parameters.
</p>
<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></dd></dl>
<a name="gnutls_005fanon_005fset_005fserver_005fparams_005ffunction-1"></a>
<h4 class="subheading">gnutls_anon_set_server_params_function</h4>
<a name="gnutls_005fanon_005fset_005fserver_005fparams_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fanon_005fset_005fserver_005fparams_005ffunction"></a>Function: <em>void</em> <strong>gnutls_anon_set_server_params_function</strong> <em>(gnutls_anon_server_credentials_t <var>res</var>, gnutls_params_function * <var>func</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials_t structure
</p>
<p><var>func</var>: is the function to be called
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<a name="gnutls_005fauth_005fclient_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_auth_client_get_type</h4>
<a name="gnutls_005fauth_005fclient_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fauth_005fclient_005fget_005ftype"></a>Function: <em>gnutls_credentials_type_t</em> <strong>gnutls_auth_client_get_type</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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>
<p><strong>Returns:</strong> The type of credentials for the client authentication
schema, a <code>gnutls_credentials_type_t</code> type.
</p></dd></dl>
<a name="gnutls_005fauth_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_auth_get_type</h4>
<a name="gnutls_005fauth_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fauth_005fget_005ftype"></a>Function: <em>gnutls_credentials_type_t</em> <strong>gnutls_auth_get_type</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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>
<p>Eg. for CERTIFICATE ciphersuites (key exchange algorithms:
<code>GNUTLS_KX_RSA</code> , <code>GNUTLS_KX_DHE_RSA</code> ), the same function are to be
used to access the authentication data.
</p>
<p><strong>Returns:</strong> The type of credentials for the current authentication
schema, a <code>gnutls_credentials_type_t</code> type.
</p></dd></dl>
<a name="gnutls_005fauth_005fserver_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_auth_server_get_type</h4>
<a name="gnutls_005fauth_005fserver_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fauth_005fserver_005fget_005ftype"></a>Function: <em>gnutls_credentials_type_t</em> <strong>gnutls_auth_server_get_type</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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>
<p><strong>Returns:</strong> The type of credentials for the server authentication
schema, a <code>gnutls_credentials_type_t</code> type.
</p></dd></dl>
<a name="gnutls_005fbye-1"></a>
<h4 class="subheading">gnutls_bye</h4>
<a name="gnutls_005fbye"></a><dl>
<dt><a name="index-gnutls_005fbye-1"></a>Function: <em>int</em> <strong>gnutls_bye</strong> <em>(gnutls_session_t <var>session</var>, gnutls_close_request_t <var>how</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>how</var>: is an integer
</p>
<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 <code>GNUTLS_SHUT_RDWR</code> , <code>GNUTLS_SHUT_WR</code> .
</p>
<p>In case of <code>GNUTLS_SHUT_RDWR</code> the TLS session gets
terminated and further receives and sends will be disallowed. If
the return value is zero you may continue using the underlying
transport layer. <code>GNUTLS_SHUT_RDWR</code> sends an alert containing a close
request and waits for the peer to reply with the same message.
</p>
<p>In case of <code>GNUTLS_SHUT_WR</code> the TLS session gets terminated
and further sends will be disallowed. In order to reuse the
connection you should wait for an EOF from the peer.
<code>GNUTLS_SHUT_WR</code> sends an alert containing a close request.
</p>
<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, and thus not
distinguishing between a malicious party prematurely terminating
the connection and normal termination.
</p>
<p>This function may also return <code>GNUTLS_E_AGAIN</code> or
<code>GNUTLS_E_INTERRUPTED</code> ; cf. <code>gnutls_record_get_direction()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code, see
function documentation for entire semantics.
</p></dd></dl>
<a name="gnutls_005fcertificate_005factivation_005ftime_005fpeers-1"></a>
<h4 class="subheading">gnutls_certificate_activation_time_peers</h4>
<a name="gnutls_005fcertificate_005factivation_005ftime_005fpeers"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005factivation_005ftime_005fpeers"></a>Function: <em>time_t</em> <strong>gnutls_certificate_activation_time_peers</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>This function will return the peer’s certificate activation time.
This is the creation time for openpgp keys.
</p>
<p><strong>Returns:</strong> (time_t)-1 on error.
</p>
<p><strong>Deprecated:</strong> <code>gnutls_certificate_verify_peers2()</code> now verifies activation times.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fallocate_005fcredentials-1"></a>
<h4 class="subheading">gnutls_certificate_allocate_credentials</h4>
<a name="gnutls_005fcertificate_005fallocate_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fallocate_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_certificate_allocate_credentials</strong> <em>(gnutls_certificate_credentials_t * <var>res</var>)</em></dt>
<dd><p><var>res</var>: is a pointer to a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus-1"></a>
<h4 class="subheading">gnutls_certificate_client_get_request_status</h4>
<a name="gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus"></a>Function: <em>int</em> <strong>gnutls_certificate_client_get_request_status</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>Get whether client certificate is requested or not.
</p>
<p><strong>Returns:</strong> 0 if the peer (server) did not request client
authentication or 1 otherwise, or a negative error code in case of
error.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fexpiration_005ftime_005fpeers-1"></a>
<h4 class="subheading">gnutls_certificate_expiration_time_peers</h4>
<a name="gnutls_005fcertificate_005fexpiration_005ftime_005fpeers"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fexpiration_005ftime_005fpeers"></a>Function: <em>time_t</em> <strong>gnutls_certificate_expiration_time_peers</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>This function will return the peer’s certificate expiration time.
</p>
<p><strong>Returns:</strong> (time_t)-1 on error.
</p>
<p><strong>Deprecated:</strong> <code>gnutls_certificate_verify_peers2()</code> now verifies expiration times.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ffree_005fca_005fnames-1"></a>
<h4 class="subheading">gnutls_certificate_free_ca_names</h4>
<a name="gnutls_005fcertificate_005ffree_005fca_005fnames"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ffree_005fca_005fnames"></a>Function: <em>void</em> <strong>gnutls_certificate_free_ca_names</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<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. Servers might want to use
this function if a large list of trusted CAs is present and
sending the names of it would just consume bandwidth without providing
information to client.
</p>
<p>CA names are used by servers to advertise the CAs they support to
clients.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ffree_005fcas-1"></a>
<h4 class="subheading">gnutls_certificate_free_cas</h4>
<a name="gnutls_005fcertificate_005ffree_005fcas"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ffree_005fcas"></a>Function: <em>void</em> <strong>gnutls_certificate_free_cas</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<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></dd></dl>
<a name="gnutls_005fcertificate_005ffree_005fcredentials-1"></a>
<h4 class="subheading">gnutls_certificate_free_credentials</h4>
<a name="gnutls_005fcertificate_005ffree_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ffree_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_certificate_free_credentials</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p>
<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></dd></dl>
<a name="gnutls_005fcertificate_005ffree_005fcrls-1"></a>
<h4 class="subheading">gnutls_certificate_free_crls</h4>
<a name="gnutls_005fcertificate_005ffree_005fcrls"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ffree_005fcrls"></a>Function: <em>void</em> <strong>gnutls_certificate_free_crls</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p>This function will delete all the CRLs associated
with the given credentials.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ffree_005fkeys-1"></a>
<h4 class="subheading">gnutls_certificate_free_keys</h4>
<a name="gnutls_005fcertificate_005ffree_005fkeys"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ffree_005fkeys"></a>Function: <em>void</em> <strong>gnutls_certificate_free_keys</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<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></dd></dl>
<a name="gnutls_005fcertificate_005fget_005fissuer-1"></a>
<h4 class="subheading">gnutls_certificate_get_issuer</h4>
<a name="gnutls_005fcertificate_005fget_005fissuer"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fget_005fissuer"></a>Function: <em>int</em> <strong>gnutls_certificate_get_issuer</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>, gnutls_x509_crt_t <var>cert</var>, gnutls_x509_crt_t* <var>issuer</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>cert</var>: is the certificate to find issuer for
</p>
<p><var>issuer</var>: Will hold the issuer if any. Should be treated as constant.
</p>
<p><var>flags</var>: Use zero.
</p>
<p>This function will return the issuer of a given certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fget_005fours-1"></a>
<h4 class="subheading">gnutls_certificate_get_ours</h4>
<a name="gnutls_005fcertificate_005fget_005fours"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fget_005fours"></a>Function: <em>const gnutls_datum_t *</em> <strong>gnutls_certificate_get_ours</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>Gets the certificate as sent to the peer in the last handshake.
The certificate is in raw (DER) format. No certificate
list is being returned. Only the first certificate.
</p>
<p><strong>Returns:</strong> a pointer to a <code>gnutls_datum_t</code> containing our
certificate, or <code>NULL</code> in case of an error or if no certificate
was used.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fget_005fpeers-1"></a>
<h4 class="subheading">gnutls_certificate_get_peers</h4>
<a name="gnutls_005fcertificate_005fget_005fpeers"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fget_005fpeers"></a>Function: <em>const gnutls_datum_t *</em> <strong>gnutls_certificate_get_peers</strong> <em>(gnutls_session_t <var>session</var>, unsigned int * <var>list_size</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>list_size</var>: is the length of the certificate list
</p>
<p>Get 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>
<p>In case of OpenPGP keys a single key will be returned in raw
format.
</p>
<p><strong>Returns:</strong> a pointer to a <code>gnutls_datum_t</code> containing our
certificates, or <code>NULL</code> in case of an error or if no certificate
was used.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fget_005fpeers_005fsubkey_005fid-1"></a>
<h4 class="subheading">gnutls_certificate_get_peers_subkey_id</h4>
<a name="gnutls_005fcertificate_005fget_005fpeers_005fsubkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fget_005fpeers_005fsubkey_005fid"></a>Function: <em>int</em> <strong>gnutls_certificate_get_peers_subkey_id</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>id</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>id</var>: will contain the ID
</p>
<p>Get the peer’s subkey ID when OpenPGP certificates are
used. The returned <code>id</code> should be treated as constant.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence-1"></a>
<h4 class="subheading">gnutls_certificate_send_x509_rdn_sequence</h4>
<a name="gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence-1"></a>Function: <em>void</em> <strong>gnutls_certificate_send_x509_rdn_sequence</strong> <em>(gnutls_session_t <var>session</var>, int <var>status</var>)</em></dt>
<dd><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
</p>
<p><var>status</var>: is 0 or 1
</p>
<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 advertise its trusted CAs to the peer. If status
is zero then the default behaviour will take effect, which is to
advertise the server’s trusted CAs.
</p>
<p>This function has no effect in clients, and in authentication
methods other than certificate with X.509 certificates.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fserver_005fset_005frequest-1"></a>
<h4 class="subheading">gnutls_certificate_server_set_request</h4>
<a name="gnutls_005fcertificate_005fserver_005fset_005frequest"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fserver_005fset_005frequest-1"></a>Function: <em>void</em> <strong>gnutls_certificate_server_set_request</strong> <em>(gnutls_session_t <var>session</var>, gnutls_certificate_request_t <var>req</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>req</var>: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
</p>
<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></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fdh_005fparams-1"></a>
<h4 class="subheading">gnutls_certificate_set_dh_params</h4>
<a name="gnutls_005fcertificate_005fset_005fdh_005fparams"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fdh_005fparams"></a>Function: <em>void</em> <strong>gnutls_certificate_set_dh_params</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_dh_params_t <var>dh_params</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials_t structure
</p>
<p><var>dh_params</var>: is a structure that holds Diffie-Hellman parameters.
</p>
<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></dd></dl>
<a name="gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_ocsp_status_request_file</h4>
<a name="gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_ocsp_status_request_file</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>, const char* <var>response_file</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>sc</var>: – undescribed –
</p>
<p><var>response_file</var>: a filename of the OCSP response
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function sets the filename of an OCSP response, that will be
sent to the client if requests an OCSP certificate status. This is
a convenience function which is inefficient on busy servers since
the file is opened on every access. Use
<code>gnutls_certificate_set_ocsp_status_request_function()</code> to fine-tune
file accesses.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffunction-1"></a>
<h4 class="subheading">gnutls_certificate_set_ocsp_status_request_function</h4>
<a name="gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffunction"></a>Function: <em>void</em> <strong>gnutls_certificate_set_ocsp_status_request_function</strong> <em>(gnutls_certificate_credentials_t <var>sc</var>, gnutls_status_request_ocsp_func <var>ocsp_func</var>, void * <var>ptr</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>ocsp_func</var>: function pointer to OCSP status request callback.
</p>
<p><var>ptr</var>: opaque pointer passed to callback function
</p>
<p>This function is to be used by server to register a callback to
handle OCSP status requests from the client. The callback will be
invoked if the client supplied a status-request OCSP extension.
The callback function prototype is:
</p>
<p>typedef int (*gnutls_status_request_ocsp_func)
(gnutls_session_t session, void *ptr, gnutls_datum_t *ocsp_response);
</p>
<p>The callback will be invoked if the client requests an OCSP certificate
status. The callback may return <code>GNUTLS_E_NO_CERTIFICATE_STATUS</code> , if
there is no recent OCSP response. If the callback returns <code>GNUTLS_E_SUCCESS</code> ,
the server will provide the client with the ocsp_response.
</p>
<p>The response must be a value allocated using <code>gnutls_malloc()</code> , and will be
deinitialized when needed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fparams_005ffunction-1"></a>
<h4 class="subheading">gnutls_certificate_set_params_function</h4>
<a name="gnutls_005fcertificate_005fset_005fparams_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fparams_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_certificate_set_params_function</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_params_function * <var>func</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials_t structure
</p>
<p><var>func</var>: is the function to be called
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_certificate_set_pin_function</h4>
<a name="gnutls_005fcertificate_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fpin_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_certificate_set_pin_function</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>fn</var>: A PIN callback
</p>
<p><var>userdata</var>: Data to be passed in the callback
</p>
<p>This function will set a callback function to be used when
required to access a protected object. This function overrides any other
global PIN functions.
</p>
<p>Note that this function must be called right after initialization
to have effect.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fretrieve_005ffunction-1"></a>
<h4 class="subheading">gnutls_certificate_set_retrieve_function</h4>
<a name="gnutls_005fcertificate_005fset_005fretrieve_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fretrieve_005ffunction"></a>Function: <em>void</em> <strong>gnutls_certificate_set_retrieve_function</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, gnutls_certificate_retrieve_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<p>This function sets a callback to be called in order to retrieve the
certificate to be used in the handshake. You are advised
to use <code>gnutls_certificate_set_retrieve_function2()</code> because it
is much more efficient in the processing it requires from gnutls.
</p>
<p>The callback’s function prototype is:
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr2_st* st);
</p>
<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>
<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>
<p><code>st</code> should contain the certificates and private keys.
</p>
<p>If the callback function is provided then gnutls will call it, in the
handshake, after the certificate request message has been received.
</p>
<p>In server side pk_algos and req_ca_dn are NULL.
</p>
<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>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fverify_005fflags-1"></a>
<h4 class="subheading">gnutls_certificate_set_verify_flags</h4>
<a name="gnutls_005fcertificate_005fset_005fverify_005fflags"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fverify_005fflags"></a>Function: <em>void</em> <strong>gnutls_certificate_set_verify_flags</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials_t structure
</p>
<p><var>flags</var>: are the flags
</p>
<p>This function will set the flags to be used for verification
of certificates and override any defaults. The provided flags must be an OR of the
<code>gnutls_certificate_verify_flags</code> enumerations.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fverify_005ffunction-1"></a>
<h4 class="subheading">gnutls_certificate_set_verify_function</h4>
<a name="gnutls_005fcertificate_005fset_005fverify_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fverify_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_certificate_set_verify_function</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, gnutls_certificate_verify_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<p>This function sets a callback to be called when peer’s certificate
has been received in order to verify it on receipt rather than
doing after the handshake is completed.
</p>
<p>The callback’s function prototype is:
int (*callback)(gnutls_session_t);
</p>
<p>If the callback function is provided then gnutls will call it, in the
handshake, just after the certificate message has been received.
To verify or obtain the certificate the <code>gnutls_certificate_verify_peers2()</code> ,
<code>gnutls_certificate_type_get()</code> , <code>gnutls_certificate_get_peers()</code> functions
can be used.
</p>
<p>The callback function should return 0 for the handshake to continue
or non-zero to terminate.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fverify_005flimits-1"></a>
<h4 class="subheading">gnutls_certificate_set_verify_limits</h4>
<a name="gnutls_005fcertificate_005fset_005fverify_005flimits"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fverify_005flimits"></a>Function: <em>void</em> <strong>gnutls_certificate_set_verify_limits</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, unsigned int <var>max_bits</var>, unsigned int <var>max_depth</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials structure
</p>
<p><var>max_bits</var>: is the number of bits of an acceptable certificate (default 8200)
</p>
<p><var>max_depth</var>: is maximum depth of the verification of a certificate chain (default 5)
</p>
<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. You can set them to zero to disable
limits.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fcrl-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_crl</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fcrl"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fcrl"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_crl</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_x509_crl_t * <var>crl_list</var>, int <var>crl_list_size</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>crl_list</var>: is a list of trusted CRLs. They should have been verified before.
</p>
<p><var>crl_list_size</var>: holds the size of the crl_list
</p>
<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>
<p><strong>Returns:</strong> number of CRLs processed, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_crl_file</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_crl_file</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char * <var>crlfile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>crlfile</var>: is a file containing the list of verified CRLs (DER or PEM list)
</p>
<p><var>type</var>: is PEM or DER
</p>
<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>
<p><strong>Returns:</strong> number of CRLs processed or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_crl_mem</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_crl_mem</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>CRL</var>, gnutls_x509_crt_fmt_t <var>type</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>CRL</var>: is a list of trusted CRLs. They should have been verified before.
</p>
<p><var>type</var>: is DER or PEM
</p>
<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>
<p><strong>Returns:</strong> number of CRLs processed, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fkey-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_key</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fkey"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fkey"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_key</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_x509_crt_t * <var>cert_list</var>, int <var>cert_list_size</var>, gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>cert_list</var>: contains a certificate list (path) for the specified private key
</p>
<p><var>cert_list_size</var>: holds the size of the certificate list
</p>
<p><var>key</var>: is a <code>gnutls_x509_privkey_t</code> key
</p>
<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. For clients that wants to send more than their own end
entity certificate (e.g., also an intermediate CA cert) then put
the certificate chain in <code>cert_list</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_key_file</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_key_file</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char * <var>certfile</var>, const char * <var>keyfile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<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>
<p><var>keyfile</var>: is a file that contains the private key
</p>
<p><var>type</var>: is PEM or DER
</p>
<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. For clients that need to send more than its own end
entity certificate, e.g., also an intermediate CA cert, then the
<code>certfile</code> must contain the ordered certificate chain.
</p>
<p>This function can also accept URLs at <code>keyfile</code> and <code>certfile</code> . In that case it
will import the private key and certificate indicated by the URLs. Note
that the supported URLs are the ones indicated by <code>gnutls_url_is_supported()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_key_mem</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_key_mem</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>cert</var>, const gnutls_datum_t * <var>key</var>, gnutls_x509_crt_fmt_t <var>type</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>cert</var>: contains a certificate list (path) for the specified private key
</p>
<p><var>key</var>: is the private key, or <code>NULL</code>
</p>
<p><var>type</var>: is PEM or DER
</p>
<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>
<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>
<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>
<p>The <code>key</code> may be <code>NULL</code> if you are using a sign callback, see
<code>gnutls_sign_callback_set()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_simple_pkcs12_file</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_simple_pkcs12_file</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char * <var>pkcs12file</var>, gnutls_x509_crt_fmt_t <var>type</var>, const char * <var>password</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>pkcs12file</var>: filename of file containing PKCS<code>12</code> blob.
</p>
<p><var>type</var>: is PEM or DER of the <code>pkcs12file</code> .
</p>
<p><var>password</var>: optional password used to decrypt PKCS<code>12</code> file, bags and keys.
</p>
<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>
<p>PKCS<code>12</code> files with a MAC, encrypted bags and PKCS <code>8</code>
private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
</p>
<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>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005fmem-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_simple_pkcs12_mem</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005fmem"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005fmem"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_simple_pkcs12_mem</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>p12blob</var>, gnutls_x509_crt_fmt_t <var>type</var>, const char * <var>password</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>p12blob</var>: the PKCS<code>12</code> blob.
</p>
<p><var>type</var>: is PEM or DER of the <code>pkcs12file</code> .
</p>
<p><var>password</var>: optional password used to decrypt PKCS<code>12</code> file, bags and keys.
</p>
<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>
<p>Encrypted PKCS<code>12</code> bags and PKCS<code>8</code> private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
</p>
<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>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_system_trust</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust-1"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_system_trust</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p>This function adds the system’s default trusted CAs in order to
verify client or server certificates.
</p>
<p>In the case the system is currently unsupported <code>GNUTLS_E_UNIMPLEMENTED_FEATURE</code>
is returned.
</p>
<p><strong>Returns:</strong> the number of certificates processed or a negative error code
on error.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005ftrust-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_trust</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005ftrust"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005ftrust"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_trust</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_x509_crt_t * <var>ca_list</var>, int <var>ca_list_size</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>ca_list</var>: is a list of trusted CAs
</p>
<p><var>ca_list_size</var>: holds the size of the CA list
</p>
<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>
<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>
<p><strong>Returns:</strong> the number of certificates processed or a negative error code
on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_trust_file</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_trust_file</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, const char * <var>cafile</var>, gnutls_x509_crt_fmt_t <var>type</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>cafile</var>: is a file containing the list of trusted CAs (DER or PEM list)
</p>
<p><var>type</var>: is PEM or DER
</p>
<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>
<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>
<p>This function can also accept URLs. In that case it
will import all certificates that are marked as trusted. Note
that the supported URLs are the ones indicated by <code>gnutls_url_is_supported()</code> .
</p>
<p><strong>Returns:</strong> number of certificates processed, or a negative error code on
error.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem-1"></a>
<h4 class="subheading">gnutls_certificate_set_x509_trust_mem</h4>
<a name="gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem"></a>Function: <em>int</em> <strong>gnutls_certificate_set_x509_trust_mem</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>ca</var>, gnutls_x509_crt_fmt_t <var>type</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>ca</var>: is a list of trusted CAs or a DER certificate
</p>
<p><var>type</var>: is DER or PEM
</p>
<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>
<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>
<p><strong>Returns:</strong> the number of certificates processed or a negative error code
on error.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ftype_005fget-1"></a>
<h4 class="subheading">gnutls_certificate_type_get</h4>
<a name="gnutls_005fcertificate_005ftype_005fget"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ftype_005fget"></a>Function: <em>gnutls_certificate_type_t</em> <strong>gnutls_certificate_type_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>The certificate type is by default X.509, unless it is negotiated
as a TLS extension.
</p>
<p><strong>Returns:</strong> the currently used <code>gnutls_certificate_type_t</code> certificate
type.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ftype_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_certificate_type_get_id</h4>
<a name="gnutls_005fcertificate_005ftype_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ftype_005fget_005fid"></a>Function: <em>gnutls_certificate_type_t</em> <strong>gnutls_certificate_type_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a certificate type name
</p>
<p>The names are compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> a <code>gnutls_certificate_type_t</code> for the specified in a
string certificate type, or <code>GNUTLS_CRT_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ftype_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_certificate_type_get_name</h4>
<a name="gnutls_005fcertificate_005ftype_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ftype_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_certificate_type_get_name</strong> <em>(gnutls_certificate_type_t <var>type</var>)</em></dt>
<dd><p><var>type</var>: is a certificate type
</p>
<p>Convert a <code>gnutls_certificate_type_t</code> type to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified
certificate type, or <code>NULL</code> in case of unknown types.
</p></dd></dl>
<a name="gnutls_005fcertificate_005ftype_005flist-1"></a>
<h4 class="subheading">gnutls_certificate_type_list</h4>
<a name="gnutls_005fcertificate_005ftype_005flist"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ftype_005flist"></a>Function: <em>const gnutls_certificate_type_t *</em> <strong>gnutls_certificate_type_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of certificate types.
</p>
<p><strong>Returns:</strong> a (0)-terminated list of <code>gnutls_certificate_type_t</code>
integers indicating the available certificate types.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fverification_005fstatus_005fprint-1"></a>
<h4 class="subheading">gnutls_certificate_verification_status_print</h4>
<a name="gnutls_005fcertificate_005fverification_005fstatus_005fprint"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fverification_005fstatus_005fprint"></a>Function: <em>int</em> <strong>gnutls_certificate_verification_status_print</strong> <em>(unsigned int <var>status</var>, gnutls_certificate_type_t <var>type</var>, gnutls_datum_t * <var>out</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>status</var>: The status flags to be printed
</p>
<p><var>type</var>: The certificate type
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will pretty print the status of a verification
process – eg. the one obtained by <code>gnutls_certificate_verify_peers3()</code> .
</p>
<p>The output <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.4
</p></dd></dl>
<a name="gnutls_005fcertificate_005fverify_005fpeers2-1"></a>
<h4 class="subheading">gnutls_certificate_verify_peers2</h4>
<a name="gnutls_005fcertificate_005fverify_005fpeers2"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fverify_005fpeers2"></a>Function: <em>int</em> <strong>gnutls_certificate_verify_peers2</strong> <em>(gnutls_session_t <var>session</var>, unsigned int * <var>status</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>status</var>: is the output of the verification
</p>
<p>This function will verify the peer’s certificate and store
the status in the <code>status</code> variable as a bitwise or’d gnutls_certificate_status_t
values or zero if the certificate is trusted. Note that value in <code>status</code> is set only when the return value of this function is success (i.e, failure
to trust a certificate does not imply a negative return value).
</p>
<p>If available the OCSP Certificate Status extension will be
utilized by this function.
</p>
<p>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>
<p>Note that you must also check the peer’s name in order to check if
the verified certificate belongs to the actual peer, see <code>gnutls_x509_crt_check_hostname()</code> ,
or use <code>gnutls_certificate_verify_peers3()</code> .
</p>
<p><strong>Returns:</strong> a negative error code on error and <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fverify_005fpeers3-1"></a>
<h4 class="subheading">gnutls_certificate_verify_peers3</h4>
<a name="gnutls_005fcertificate_005fverify_005fpeers3"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fverify_005fpeers3-1"></a>Function: <em>int</em> <strong>gnutls_certificate_verify_peers3</strong> <em>(gnutls_session_t <var>session</var>, const char* <var>hostname</var>, unsigned int * <var>status</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>hostname</var>: is the expected name of the peer; may be <code>NULL</code>
</p>
<p><var>status</var>: is the output of the verification
</p>
<p>This function will verify the peer’s certificate and store the
status in the <code>status</code> variable as a bitwise or’d gnutls_certificate_status_t
values or zero if the certificate is trusted. Note that value in <code>status</code> is set only when the return value of this function is success (i.e, failure
to trust a certificate does not imply a negative return value).
</p>
<p>If the <code>hostname</code> provided is non-NULL then this function will compare
the hostname in the certificate against the given. If they do not match
the <code>GNUTLS_CERT_UNEXPECTED_OWNER</code> status flag will be set.
</p>
<p>If available the OCSP Certificate Status extension will be
utilized by this function.
</p>
<p>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>
<p><strong>Returns:</strong> a negative error code on error and <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p>
<p><strong>Since:</strong> 3.1.4
</p></dd></dl>
<a name="gnutls_005fcheck_005fversion-1"></a>
<h4 class="subheading">gnutls_check_version</h4>
<a name="gnutls_005fcheck_005fversion"></a><dl>
<dt><a name="index-gnutls_005fcheck_005fversion"></a>Function: <em>const char *</em> <strong>gnutls_check_version</strong> <em>(const char * <var>req_version</var>)</em></dt>
<dd><p><var>req_version</var>: version string to compare with, or <code>NULL</code> .
</p>
<p>Check GnuTLS Library version.
</p>
<p>See <code>GNUTLS_VERSION</code> for a suitable <code>req_version</code> string.
</p>
<p><strong>Returns:</strong> Check that the version of the library is at
minimum the one given as a string in <code>req_version</code> and return the
actual version string of the library; return <code>NULL</code> if the
condition is not met. If <code>NULL</code> is passed to this function no
check is done and only the version string is returned.
</p></dd></dl>
<a name="gnutls_005fcipher_005fget-1"></a>
<h4 class="subheading">gnutls_cipher_get</h4>
<a name="gnutls_005fcipher_005fget"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget"></a>Function: <em>gnutls_cipher_algorithm_t</em> <strong>gnutls_cipher_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get currently used cipher.
</p>
<p><strong>Returns:</strong> the currently used cipher, a <code>gnutls_cipher_algorithm_t</code>
type.
</p></dd></dl>
<a name="gnutls_005fcipher_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_cipher_get_id</h4>
<a name="gnutls_005fcipher_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005fid"></a>Function: <em>gnutls_cipher_algorithm_t</em> <strong>gnutls_cipher_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a cipher algorithm name
</p>
<p>The names are compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> return a <code>gnutls_cipher_algorithm_t</code> value corresponding to
the specified cipher, or <code>GNUTLS_CIPHER_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fcipher_005fget_005fkey_005fsize-1"></a>
<h4 class="subheading">gnutls_cipher_get_key_size</h4>
<a name="gnutls_005fcipher_005fget_005fkey_005fsize"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005fkey_005fsize"></a>Function: <em>size_t</em> <strong>gnutls_cipher_get_key_size</strong> <em>(gnutls_cipher_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>
<p>Get key size for cipher.
</p>
<p><strong>Returns:</strong> length (in bytes) of the given cipher’s key size, or 0 if
the given cipher is invalid.
</p></dd></dl>
<a name="gnutls_005fcipher_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_cipher_get_name</h4>
<a name="gnutls_005fcipher_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_cipher_get_name</strong> <em>(gnutls_cipher_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>
<p>Convert a <code>gnutls_cipher_algorithm_t</code> type to a string.
</p>
<p><strong>Returns:</strong> a pointer to a string that contains the name of the
specified cipher, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fcipher_005flist-1"></a>
<h4 class="subheading">gnutls_cipher_list</h4>
<a name="gnutls_005fcipher_005flist"></a><dl>
<dt><a name="index-gnutls_005fcipher_005flist"></a>Function: <em>const gnutls_cipher_algorithm_t *</em> <strong>gnutls_cipher_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of supported cipher algorithms. Note that not
necessarily all ciphers are supported as TLS cipher suites. For
example, DES is not supported as a cipher suite, but is supported
for other purposes (e.g., PKCS<code>8</code> or similar).
</p>
<p>This function is not thread safe.
</p>
<p><strong>Returns:</strong> a (0)-terminated list of <code>gnutls_cipher_algorithm_t</code>
integers indicating the available ciphers.
</p></dd></dl>
<a name="gnutls_005fcipher_005fsuite_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_cipher_suite_get_name</h4>
<a name="gnutls_005fcipher_005fsuite_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fsuite_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_cipher_suite_get_name</strong> <em>(gnutls_kx_algorithm_t <var>kx_algorithm</var>, gnutls_cipher_algorithm_t <var>cipher_algorithm</var>, gnutls_mac_algorithm_t <var>mac_algorithm</var>)</em></dt>
<dd><p><var>kx_algorithm</var>: is a Key exchange algorithm
</p>
<p><var>cipher_algorithm</var>: is a cipher algorithm
</p>
<p><var>mac_algorithm</var>: is a MAC algorithm
</p>
<p>Note that the full cipher suite name must be prepended by TLS or
SSL depending of the protocol in use.
</p>
<p><strong>Returns:</strong> a string that contains the name of a TLS cipher suite,
specified by the given algorithms, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fcipher_005fsuite_005finfo-1"></a>
<h4 class="subheading">gnutls_cipher_suite_info</h4>
<a name="gnutls_005fcipher_005fsuite_005finfo"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fsuite_005finfo"></a>Function: <em>const char *</em> <strong>gnutls_cipher_suite_info</strong> <em>(size_t <var>idx</var>, unsigned char * <var>cs_id</var>, gnutls_kx_algorithm_t * <var>kx</var>, gnutls_cipher_algorithm_t * <var>cipher</var>, gnutls_mac_algorithm_t * <var>mac</var>, gnutls_protocol_t * <var>min_version</var>)</em></dt>
<dd><p><var>idx</var>: index of cipher suite to get information about, starts on 0.
</p>
<p><var>cs_id</var>: output buffer with room for 2 bytes, indicating cipher suite value
</p>
<p><var>kx</var>: output variable indicating key exchange algorithm, or <code>NULL</code> .
</p>
<p><var>cipher</var>: output variable indicating cipher, or <code>NULL</code> .
</p>
<p><var>mac</var>: output variable indicating MAC algorithm, or <code>NULL</code> .
</p>
<p><var>min_version</var>: output variable indicating TLS protocol version, or <code>NULL</code> .
</p>
<p>Get information about supported cipher suites. Use the function
iteratively to get information about all supported cipher suites.
Call with idx=0 to get information about first cipher suite, then
idx=1 and so on until the function returns NULL.
</p>
<p><strong>Returns:</strong> the name of <code>idx</code> cipher suite, and set the information
about the cipher suite in the output variables. If <code>idx</code> is out of
bounds, <code>NULL</code> is returned.
</p></dd></dl>
<a name="gnutls_005fcompression_005fget-1"></a>
<h4 class="subheading">gnutls_compression_get</h4>
<a name="gnutls_005fcompression_005fget"></a><dl>
<dt><a name="index-gnutls_005fcompression_005fget"></a>Function: <em>gnutls_compression_method_t</em> <strong>gnutls_compression_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get currently used compression algorithm.
</p>
<p><strong>Returns:</strong> the currently used compression method, a
<code>gnutls_compression_method_t</code> value.
</p></dd></dl>
<a name="gnutls_005fcompression_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_compression_get_id</h4>
<a name="gnutls_005fcompression_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fcompression_005fget_005fid"></a>Function: <em>gnutls_compression_method_t</em> <strong>gnutls_compression_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a compression method name
</p>
<p>The names are compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> an id of the specified in a string compression method, or
<code>GNUTLS_COMP_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fcompression_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_compression_get_name</h4>
<a name="gnutls_005fcompression_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fcompression_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_compression_get_name</strong> <em>(gnutls_compression_method_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a Compression algorithm
</p>
<p>Convert a <code>gnutls_compression_method_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a pointer to a string that contains the name of the
specified compression algorithm, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fcompression_005flist-1"></a>
<h4 class="subheading">gnutls_compression_list</h4>
<a name="gnutls_005fcompression_005flist"></a><dl>
<dt><a name="index-gnutls_005fcompression_005flist"></a>Function: <em>const gnutls_compression_method_t *</em> <strong>gnutls_compression_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of compression methods.
</p>
<p><strong>Returns:</strong> a zero-terminated list of <code>gnutls_compression_method_t</code>
integers indicating the available compression methods.
</p></dd></dl>
<a name="gnutls_005fcredentials_005fclear-1"></a>
<h4 class="subheading">gnutls_credentials_clear</h4>
<a name="gnutls_005fcredentials_005fclear"></a><dl>
<dt><a name="index-gnutls_005fcredentials_005fclear"></a>Function: <em>void</em> <strong>gnutls_credentials_clear</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Clears all the credentials previously set in this session.
</p></dd></dl>
<a name="gnutls_005fcredentials_005fset-1"></a>
<h4 class="subheading">gnutls_credentials_set</h4>
<a name="gnutls_005fcredentials_005fset"></a><dl>
<dt><a name="index-gnutls_005fcredentials_005fset-1"></a>Function: <em>int</em> <strong>gnutls_credentials_set</strong> <em>(gnutls_session_t <var>session</var>, gnutls_credentials_type_t <var>type</var>, void * <var>cred</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>type</var>: is the type of the credentials
</p>
<p><var>cred</var>: is a pointer to a structure.
</p>
<p>Sets the needed credentials for the specified type. Eg username,
password - or public and private keys etc. The <code>cred</code> parameter is
a structure that depends on the specified type and on the current
session (client or server).
</p>
<p>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>
<p>For <code>GNUTLS_CRD_ANON</code> , <code>cred</code> should be
<code>gnutls_anon_client_credentials_t</code> in case of a client. In case of
a server it should be <code>gnutls_anon_server_credentials_t</code> .
</p>
<p>For <code>GNUTLS_CRD_SRP</code> , <code>cred</code> should be <code>gnutls_srp_client_credentials_t</code>
in case of a client, and <code>gnutls_srp_server_credentials_t</code> , in case
of a server.
</p>
<p>For <code>GNUTLS_CRD_CERTIFICATE</code> , <code>cred</code> should be
<code>gnutls_certificate_credentials_t</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdb_005fcheck_005fentry-1"></a>
<h4 class="subheading">gnutls_db_check_entry</h4>
<a name="gnutls_005fdb_005fcheck_005fentry"></a><dl>
<dt><a name="index-gnutls_005fdb_005fcheck_005fentry"></a>Function: <em>int</em> <strong>gnutls_db_check_entry</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t <var>session_entry</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>session_entry</var>: is the session data (not key)
</p>
<p>This function has no effect.
</p>
<p><strong>Returns:</strong> Returns <code>GNUTLS_E_EXPIRED</code> , if the database entry has
expired or 0 otherwise.
</p></dd></dl>
<a name="gnutls_005fdb_005fcheck_005fentry_005ftime-1"></a>
<h4 class="subheading">gnutls_db_check_entry_time</h4>
<a name="gnutls_005fdb_005fcheck_005fentry_005ftime"></a><dl>
<dt><a name="index-gnutls_005fdb_005fcheck_005fentry_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_db_check_entry_time</strong> <em>(gnutls_datum_t * <var>entry</var>)</em></dt>
<dd><p><var>entry</var>: is a pointer to a <code>gnutls_datum_t</code> structure.
</p>
<p>This function returns the time that this entry was active.
It can be used for database entry expiration.
</p></dd></dl>
<a name="gnutls_005fdb_005fget_005fptr-1"></a>
<h4 class="subheading">gnutls_db_get_ptr</h4>
<a name="gnutls_005fdb_005fget_005fptr"></a><dl>
<dt><a name="index-gnutls_005fdb_005fget_005fptr"></a>Function: <em>void *</em> <strong>gnutls_db_get_ptr</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get db function pointer.
</p>
<p><strong>Returns:</strong> the pointer that will be sent to db store, retrieve and
delete functions, as the first argument.
</p></dd></dl>
<a name="gnutls_005fdb_005fremove_005fsession-1"></a>
<h4 class="subheading">gnutls_db_remove_session</h4>
<a name="gnutls_005fdb_005fremove_005fsession"></a><dl>
<dt><a name="index-gnutls_005fdb_005fremove_005fsession"></a>Function: <em>void</em> <strong>gnutls_db_remove_session</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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>
<p>Normally <code>gnutls_deinit()</code> will remove abnormally terminated
sessions.
</p></dd></dl>
<a name="gnutls_005fdb_005fset_005fcache_005fexpiration-1"></a>
<h4 class="subheading">gnutls_db_set_cache_expiration</h4>
<a name="gnutls_005fdb_005fset_005fcache_005fexpiration"></a><dl>
<dt><a name="index-gnutls_005fdb_005fset_005fcache_005fexpiration"></a>Function: <em>void</em> <strong>gnutls_db_set_cache_expiration</strong> <em>(gnutls_session_t <var>session</var>, int <var>seconds</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>seconds</var>: is the number of seconds.
</p>
<p>Set the expiration time for resumed sessions. The default is 3600
(one hour) at the time of this writing.
</p></dd></dl>
<a name="gnutls_005fdb_005fset_005fptr-1"></a>
<h4 class="subheading">gnutls_db_set_ptr</h4>
<a name="gnutls_005fdb_005fset_005fptr"></a><dl>
<dt><a name="index-gnutls_005fdb_005fset_005fptr"></a>Function: <em>void</em> <strong>gnutls_db_set_ptr</strong> <em>(gnutls_session_t <var>session</var>, void * <var>ptr</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>ptr</var>: is the pointer
</p>
<p>Sets the pointer that will be provided to db store, retrieve and
delete functions, as the first argument.
</p></dd></dl>
<a name="gnutls_005fdb_005fset_005fremove_005ffunction-1"></a>
<h4 class="subheading">gnutls_db_set_remove_function</h4>
<a name="gnutls_005fdb_005fset_005fremove_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fdb_005fset_005fremove_005ffunction"></a>Function: <em>void</em> <strong>gnutls_db_set_remove_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_db_remove_func <var>rem_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>rem_func</var>: is the function.
</p>
<p>Sets the function that will be used to remove data from the
resumed sessions database. This function must return 0 on success.
</p>
<p>The first argument to <code>rem_func</code> will be null unless
<code>gnutls_db_set_ptr()</code> has been called.
</p></dd></dl>
<a name="gnutls_005fdb_005fset_005fretrieve_005ffunction-1"></a>
<h4 class="subheading">gnutls_db_set_retrieve_function</h4>
<a name="gnutls_005fdb_005fset_005fretrieve_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fdb_005fset_005fretrieve_005ffunction"></a>Function: <em>void</em> <strong>gnutls_db_set_retrieve_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_db_retr_func <var>retr_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>retr_func</var>: is the function.
</p>
<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>
<p>The datum’s data must be allocated using the function
<code>gnutls_malloc()</code> .
</p>
<p>The first argument to <code>retr_func</code> will be null unless
<code>gnutls_db_set_ptr()</code> has been called.
</p></dd></dl>
<a name="gnutls_005fdb_005fset_005fstore_005ffunction-1"></a>
<h4 class="subheading">gnutls_db_set_store_function</h4>
<a name="gnutls_005fdb_005fset_005fstore_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fdb_005fset_005fstore_005ffunction"></a>Function: <em>void</em> <strong>gnutls_db_set_store_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_db_store_func <var>store_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>store_func</var>: is the function
</p>
<p>Sets the function that will be used to store data in the resumed
sessions database. This function must return 0 on success.
</p>
<p>The first argument to <code>store_func</code> will be null unless
<code>gnutls_db_set_ptr()</code> has been called.
</p></dd></dl>
<a name="gnutls_005fdeinit-1"></a>
<h4 class="subheading">gnutls_deinit</h4>
<a name="gnutls_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fdeinit-1"></a>Function: <em>void</em> <strong>gnutls_deinit</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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></dd></dl>
<a name="gnutls_005fdh_005fget_005fgroup-1"></a>
<h4 class="subheading">gnutls_dh_get_group</h4>
<a name="gnutls_005fdh_005fget_005fgroup"></a><dl>
<dt><a name="index-gnutls_005fdh_005fget_005fgroup"></a>Function: <em>int</em> <strong>gnutls_dh_get_group</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>raw_gen</var>, gnutls_datum_t * <var>raw_prime</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>raw_gen</var>: will hold the generator.
</p>
<p><var>raw_prime</var>: will hold the prime.
</p>
<p>This function will return the group parameters used in the last
Diffie-Hellman key exchange 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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits-1"></a>
<h4 class="subheading">gnutls_dh_get_peers_public_bits</h4>
<a name="gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits"></a><dl>
<dt><a name="index-gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits"></a>Function: <em>int</em> <strong>gnutls_dh_get_peers_public_bits</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>Get the Diffie-Hellman public key bit size. Can be used for both
anonymous and ephemeral Diffie-Hellman.
</p>
<p><strong>Returns:</strong> The public key bit size used in the last Diffie-Hellman
key exchange with the peer, or a negative error code in case of error.
</p></dd></dl>
<a name="gnutls_005fdh_005fget_005fprime_005fbits-1"></a>
<h4 class="subheading">gnutls_dh_get_prime_bits</h4>
<a name="gnutls_005fdh_005fget_005fprime_005fbits"></a><dl>
<dt><a name="index-gnutls_005fdh_005fget_005fprime_005fbits"></a>Function: <em>int</em> <strong>gnutls_dh_get_prime_bits</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>This function will return the bits of the prime used in the last
Diffie-Hellman key exchange with the peer. Should be used for both
anonymous and ephemeral Diffie-Hellman. Note that some ciphers,
like RSA and DSA without DHE, do not use a Diffie-Hellman key
exchange, and then this function will return 0.
</p>
<p><strong>Returns:</strong> The Diffie-Hellman bit strength is returned, or 0 if no
Diffie-Hellman key exchange was done, or a negative error code on
failure.
</p></dd></dl>
<a name="gnutls_005fdh_005fget_005fpubkey-1"></a>
<h4 class="subheading">gnutls_dh_get_pubkey</h4>
<a name="gnutls_005fdh_005fget_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fdh_005fget_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_dh_get_pubkey</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>raw_key</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>raw_key</var>: will hold the public key.
</p>
<p>This function will return the peer’s public key used in the last
Diffie-Hellman key exchange. This function should be used for both
anonymous and ephemeral Diffie-Hellman. The output parameters must
be freed with <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fget_005fsecret_005fbits-1"></a>
<h4 class="subheading">gnutls_dh_get_secret_bits</h4>
<a name="gnutls_005fdh_005fget_005fsecret_005fbits"></a><dl>
<dt><a name="index-gnutls_005fdh_005fget_005fsecret_005fbits"></a>Function: <em>int</em> <strong>gnutls_dh_get_secret_bits</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>This function will return the bits used in the last Diffie-Hellman
key exchange with the peer. Should be used for both anonymous and
ephemeral Diffie-Hellman.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fcpy-1"></a>
<h4 class="subheading">gnutls_dh_params_cpy</h4>
<a name="gnutls_005fdh_005fparams_005fcpy"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fcpy"></a>Function: <em>int</em> <strong>gnutls_dh_params_cpy</strong> <em>(gnutls_dh_params_t <var>dst</var>, gnutls_dh_params_t <var>src</var>)</em></dt>
<dd><p><var>dst</var>: Is the destination structure, which should be initialized.
</p>
<p><var>src</var>: Is the source structure
</p>
<p>This function will copy the DH parameters structure from source
to destination.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fdeinit-1"></a>
<h4 class="subheading">gnutls_dh_params_deinit</h4>
<a name="gnutls_005fdh_005fparams_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_dh_params_deinit</strong> <em>(gnutls_dh_params_t <var>dh_params</var>)</em></dt>
<dd><p><var>dh_params</var>: Is a structure that holds the prime numbers
</p>
<p>This function will deinitialize the DH parameters structure.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fexport2_005fpkcs3-1"></a>
<h4 class="subheading">gnutls_dh_params_export2_pkcs3</h4>
<a name="gnutls_005fdh_005fparams_005fexport2_005fpkcs3"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fexport2_005fpkcs3"></a>Function: <em>int</em> <strong>gnutls_dh_params_export2_pkcs3</strong> <em>(gnutls_dh_params_t <var>params</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>params</var>: Holds the DH parameters
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a PKCS3 DHParams structure PEM or DER encoded
</p>
<p>This function will export the given dh parameters to a PKCS3
DHParams structure. This is the format generated by "openssl dhparam" tool.
The data in <code>out</code> will be allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN DH PARAMETERS".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fexport_005fpkcs3-1"></a>
<h4 class="subheading">gnutls_dh_params_export_pkcs3</h4>
<a name="gnutls_005fdh_005fparams_005fexport_005fpkcs3"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fexport_005fpkcs3"></a>Function: <em>int</em> <strong>gnutls_dh_params_export_pkcs3</strong> <em>(gnutls_dh_params_t <var>params</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned char * <var>params_data</var>, size_t * <var>params_data_size</var>)</em></dt>
<dd><p><var>params</var>: Holds the DH parameters
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>params_data</var>: will contain a PKCS3 DHParams structure PEM or DER encoded
</p>
<p><var>params_data_size</var>: holds the size of params_data (and will be replaced by the actual size of parameters)
</p>
<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>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN DH PARAMETERS".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fexport_005fraw-1"></a>
<h4 class="subheading">gnutls_dh_params_export_raw</h4>
<a name="gnutls_005fdh_005fparams_005fexport_005fraw"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fexport_005fraw"></a>Function: <em>int</em> <strong>gnutls_dh_params_export_raw</strong> <em>(gnutls_dh_params_t <var>params</var>, gnutls_datum_t * <var>prime</var>, gnutls_datum_t * <var>generator</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>params</var>: Holds the DH parameters
</p>
<p><var>prime</var>: will hold the new prime
</p>
<p><var>generator</var>: will hold the new generator
</p>
<p><var>bits</var>: if non null will hold the secret key’s number of bits
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fgenerate2-1"></a>
<h4 class="subheading">gnutls_dh_params_generate2</h4>
<a name="gnutls_005fdh_005fparams_005fgenerate2"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fgenerate2"></a>Function: <em>int</em> <strong>gnutls_dh_params_generate2</strong> <em>(gnutls_dh_params_t <var>params</var>, unsigned int <var>bits</var>)</em></dt>
<dd><p><var>params</var>: Is the structure that the DH parameters will be stored
</p>
<p><var>bits</var>: is the prime’s number of bits
</p>
<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>
<p>Do not set the number of bits directly, use <code>gnutls_sec_param_to_pk_bits()</code> to
get bits for <code>GNUTLS_PK_DSA</code> .
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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fimport_005fpkcs3-1"></a>
<h4 class="subheading">gnutls_dh_params_import_pkcs3</h4>
<a name="gnutls_005fdh_005fparams_005fimport_005fpkcs3"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fimport_005fpkcs3"></a>Function: <em>int</em> <strong>gnutls_dh_params_import_pkcs3</strong> <em>(gnutls_dh_params_t <var>params</var>, const gnutls_datum_t * <var>pkcs3_params</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>params</var>: A structure where the parameters will be copied to
</p>
<p><var>pkcs3_params</var>: should contain a PKCS3 DHParams structure PEM or DER encoded
</p>
<p><var>format</var>: the format of params. PEM or DER.
</p>
<p>This function will extract the DHParams found in a PKCS3 formatted
structure. This is the format generated by "openssl dhparam" tool.
</p>
<p>If the structure is PEM encoded, it should have a header
of "BEGIN DH PARAMETERS".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005fimport_005fraw-1"></a>
<h4 class="subheading">gnutls_dh_params_import_raw</h4>
<a name="gnutls_005fdh_005fparams_005fimport_005fraw"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005fimport_005fraw"></a>Function: <em>int</em> <strong>gnutls_dh_params_import_raw</strong> <em>(gnutls_dh_params_t <var>dh_params</var>, const gnutls_datum_t * <var>prime</var>, const gnutls_datum_t * <var>generator</var>)</em></dt>
<dd><p><var>dh_params</var>: Is a structure that will hold the prime numbers
</p>
<p><var>prime</var>: holds the new prime
</p>
<p><var>generator</var>: holds the new generator
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fparams_005finit-1"></a>
<h4 class="subheading">gnutls_dh_params_init</h4>
<a name="gnutls_005fdh_005fparams_005finit"></a><dl>
<dt><a name="index-gnutls_005fdh_005fparams_005finit"></a>Function: <em>int</em> <strong>gnutls_dh_params_init</strong> <em>(gnutls_dh_params_t * <var>dh_params</var>)</em></dt>
<dd><p><var>dh_params</var>: Is a structure that will hold the prime numbers
</p>
<p>This function will initialize the DH parameters structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fdh_005fset_005fprime_005fbits-1"></a>
<h4 class="subheading">gnutls_dh_set_prime_bits</h4>
<a name="gnutls_005fdh_005fset_005fprime_005fbits"></a><dl>
<dt><a name="index-gnutls_005fdh_005fset_005fprime_005fbits"></a>Function: <em>void</em> <strong>gnutls_dh_set_prime_bits</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>bits</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>bits</var>: is the number of bits
</p>
<p>This function sets the number of bits, for use in a 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>
<p>In the client side it sets the minimum accepted number of bits. If
a server sends a prime with less bits than that
<code>GNUTLS_E_DH_PRIME_UNACCEPTABLE</code> will be returned by the handshake.
</p>
<p>Note that values lower than 512 bits may allow decryption of the
exchanged data.
</p>
<p>The function has no effect in server side.
</p>
<p>Note that since 3.1.7 this function is deprecated. The minimum
number of bits is set by the priority string level.
Also this function must be called after <code>gnutls_priority_set_direct()</code>
or the set value may be overriden by the selected priority options.
</p></dd></dl>
<a name="gnutls_005fecc_005fcurve_005fget-1"></a>
<h4 class="subheading">gnutls_ecc_curve_get</h4>
<a name="gnutls_005fecc_005fcurve_005fget"></a><dl>
<dt><a name="index-gnutls_005fecc_005fcurve_005fget"></a>Function: <em>gnutls_ecc_curve_t</em> <strong>gnutls_ecc_curve_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Returns the currently used elliptic curve. Only valid
when using an elliptic curve ciphersuite.
</p>
<p><strong>Returns:</strong> the currently used curve, a <code>gnutls_ecc_curve_t</code>
type.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fecc_005fcurve_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_ecc_curve_get_name</h4>
<a name="gnutls_005fecc_005fcurve_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fecc_005fcurve_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_ecc_curve_get_name</strong> <em>(gnutls_ecc_curve_t <var>curve</var>)</em></dt>
<dd><p><var>curve</var>: is an ECC curve
</p>
<p>Convert a <code>gnutls_ecc_curve_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified
curve or <code>NULL</code> .
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fecc_005fcurve_005fget_005fsize-1"></a>
<h4 class="subheading">gnutls_ecc_curve_get_size</h4>
<a name="gnutls_005fecc_005fcurve_005fget_005fsize"></a><dl>
<dt><a name="index-gnutls_005fecc_005fcurve_005fget_005fsize"></a>Function: <em>int</em> <strong>gnutls_ecc_curve_get_size</strong> <em>(gnutls_ecc_curve_t <var>curve</var>)</em></dt>
<dd><p><var>curve</var>: is an ECC curve
</p>
<p>Returns the size in bytes of the curve.
</p>
<p><strong>Returns:</strong> a the size or (0).
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fecc_005fcurve_005flist-1"></a>
<h4 class="subheading">gnutls_ecc_curve_list</h4>
<a name="gnutls_005fecc_005fcurve_005flist"></a><dl>
<dt><a name="index-gnutls_005fecc_005fcurve_005flist"></a>Function: <em>const gnutls_ecc_curve_t *</em> <strong>gnutls_ecc_curve_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get the list of supported elliptic curves.
</p>
<p>This function is not thread safe.
</p>
<p><strong>Returns:</strong> Return a (0)-terminated list of <code>gnutls_ecc_curve_t</code>
integers indicating the available curves.
</p></dd></dl>
<a name="gnutls_005ferror_005fis_005ffatal-1"></a>
<h4 class="subheading">gnutls_error_is_fatal</h4>
<a name="gnutls_005ferror_005fis_005ffatal"></a><dl>
<dt><a name="index-gnutls_005ferror_005fis_005ffatal-1"></a>Function: <em>int</em> <strong>gnutls_error_is_fatal</strong> <em>(int <var>error</var>)</em></dt>
<dd><p><var>error</var>: is a GnuTLS error code, a negative error code
</p>
<p>If a GnuTLS function returns a negative error code you may feed that
value to this function to see if the error condition is fatal.
Note that you may also want to check the error code manually, since some
non-fatal errors to the protocol (such as a warning alert or
a rehandshake request) may be fatal for your program.
</p>
<p>This function is only useful if you are dealing with errors from
the record layer or the handshake layer.
</p>
<p><strong>Returns:</strong> 1 if the error code is fatal, for positive <code>error</code> values,
0 is returned. For unknown <code>error</code> values, -1 is returned.
</p></dd></dl>
<a name="gnutls_005ferror_005fto_005falert-1"></a>
<h4 class="subheading">gnutls_error_to_alert</h4>
<a name="gnutls_005ferror_005fto_005falert"></a><dl>
<dt><a name="index-gnutls_005ferror_005fto_005falert-1"></a>Function: <em>int</em> <strong>gnutls_error_to_alert</strong> <em>(int <var>err</var>, int * <var>level</var>)</em></dt>
<dd><p><var>err</var>: is a negative integer
</p>
<p><var>level</var>: the alert level will be stored there
</p>
<p>Get 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 <code>err</code> is <code>GNUTLS_E_REHANDSHAKE</code> ,
where a warning alert should be sent to the peer indicating that no
renegotiation will be performed.
</p>
<p>If there is no mapping to a valid alert the alert to indicate
internal error is returned.
</p>
<p><strong>Returns:</strong> the alert code to use for a particular error code.
</p></dd></dl>
<a name="gnutls_005ffingerprint-1"></a>
<h4 class="subheading">gnutls_fingerprint</h4>
<a name="gnutls_005ffingerprint"></a><dl>
<dt><a name="index-gnutls_005ffingerprint"></a>Function: <em>int</em> <strong>gnutls_fingerprint</strong> <em>(gnutls_digest_algorithm_t <var>algo</var>, const gnutls_datum_t * <var>data</var>, void * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>algo</var>: is a digest algorithm
</p>
<p><var>data</var>: is the data
</p>
<p><var>result</var>: is the place where the result will be copied (may be null).
</p>
<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>
<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>
<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 certificate is not just a hash and cannot be calculated with this
function.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fglobal_005fdeinit-1"></a>
<h4 class="subheading">gnutls_global_deinit</h4>
<a name="gnutls_005fglobal_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_global_deinit</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function deinitializes the global data, that were initialized
using <code>gnutls_global_init()</code> .
</p>
<p>Note! This function is not thread safe. See the discussion for
<code>gnutls_global_init()</code> for more information.
</p></dd></dl>
<a name="gnutls_005fglobal_005finit-1"></a>
<h4 class="subheading">gnutls_global_init</h4>
<a name="gnutls_005fglobal_005finit"></a><dl>
<dt><a name="index-gnutls_005fglobal_005finit"></a>Function: <em>int</em> <strong>gnutls_global_init</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function initializes the global data to defaults.
In order to free resources you may call <code>gnutls_global_deinit()</code>
when gnutls usage is no longer needed.
</p>
<p>Note that this function will also initialize the underlying crypto
backend, if it has not been initialized before.
</p>
<p>This function increments 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>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fglobal_005fset_005faudit_005flog_005ffunction-1"></a>
<h4 class="subheading">gnutls_global_set_audit_log_function</h4>
<a name="gnutls_005fglobal_005fset_005faudit_005flog_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fset_005faudit_005flog_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_global_set_audit_log_function</strong> <em>(gnutls_audit_log_func <var>log_func</var>)</em></dt>
<dd><p><var>log_func</var>: it is the audit log function
</p>
<p>This is the function where you set the logging function gnutls is
going to use. This is different from <code>gnutls_global_set_log_function()</code>
because it will report the session of the event if any. Note that
that session might be null if there is no corresponding TLS session.
</p>
<p><code>gnutls_audit_log_func</code> is of the form,
void (*gnutls_audit_log_func)( gnutls_session_t, const char*);
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fglobal_005fset_005flog_005ffunction-1"></a>
<h4 class="subheading">gnutls_global_set_log_function</h4>
<a name="gnutls_005fglobal_005fset_005flog_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fset_005flog_005ffunction"></a>Function: <em>void</em> <strong>gnutls_global_set_log_function</strong> <em>(gnutls_log_func <var>log_func</var>)</em></dt>
<dd><p><var>log_func</var>: it’s a log function
</p>
<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>
<p><code>gnutls_log_func</code> is of the form,
void (*gnutls_log_func)( int level, const char*);
</p></dd></dl>
<a name="gnutls_005fglobal_005fset_005flog_005flevel-1"></a>
<h4 class="subheading">gnutls_global_set_log_level</h4>
<a name="gnutls_005fglobal_005fset_005flog_005flevel"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fset_005flog_005flevel"></a>Function: <em>void</em> <strong>gnutls_global_set_log_level</strong> <em>(int <var>level</var>)</em></dt>
<dd><p><var>level</var>: it’s an integer from 0 to 9.
</p>
<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>
<p>Use a log level over 10 to enable all debugging options.
</p></dd></dl>
<a name="gnutls_005fglobal_005fset_005fmem_005ffunctions-1"></a>
<h4 class="subheading">gnutls_global_set_mem_functions</h4>
<a name="gnutls_005fglobal_005fset_005fmem_005ffunctions"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fset_005fmem_005ffunctions"></a>Function: <em>void</em> <strong>gnutls_global_set_mem_functions</strong> <em>(gnutls_alloc_function <var>alloc_func</var>, gnutls_alloc_function <var>secure_alloc_func</var>, gnutls_is_secure_function <var>is_secure_func</var>, gnutls_realloc_function <var>realloc_func</var>, gnutls_free_function <var>free_func</var>)</em></dt>
<dd><p><var>alloc_func</var>: it’s the default memory allocation function. Like <code>malloc()</code> .
</p>
<p><var>secure_alloc_func</var>: This is the memory allocation function that will be used for sensitive data.
</p>
<p><var>is_secure_func</var>: a function that returns 0 if the memory given is not secure. May be NULL.
</p>
<p><var>realloc_func</var>: A realloc function
</p>
<p><var>free_func</var>: The function that frees allocated data. Must accept a NULL pointer.
</p>
<p>This is the function where 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
</p>
<p>This function must be called before <code>gnutls_global_init()</code> is called.
This function is not thread safe.
</p></dd></dl>
<a name="gnutls_005fglobal_005fset_005fmutex-1"></a>
<h4 class="subheading">gnutls_global_set_mutex</h4>
<a name="gnutls_005fglobal_005fset_005fmutex"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fset_005fmutex-1"></a>Function: <em>void</em> <strong>gnutls_global_set_mutex</strong> <em>(mutex_init_func <var>init</var>, mutex_deinit_func <var>deinit</var>, mutex_lock_func <var>lock</var>, mutex_unlock_func <var>unlock</var>)</em></dt>
<dd><p><var>init</var>: mutex initialization function
</p>
<p><var>deinit</var>: mutex deinitialization function
</p>
<p><var>lock</var>: mutex locking function
</p>
<p><var>unlock</var>: mutex unlocking function
</p>
<p>With this function you are allowed to override the default mutex
locks used in some parts of gnutls and dependent libraries. This function
should be used if you have complete control of your program and libraries.
Do not call this function from a library. Instead only initialize gnutls and
the default OS mutex locks will be used.
</p>
<p>This function must be called before <code>gnutls_global_init()</code> .
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fglobal_005fset_005ftime_005ffunction-1"></a>
<h4 class="subheading">gnutls_global_set_time_function</h4>
<a name="gnutls_005fglobal_005fset_005ftime_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fglobal_005fset_005ftime_005ffunction"></a>Function: <em>void</em> <strong>gnutls_global_set_time_function</strong> <em>(gnutls_time_func <var>time_func</var>)</em></dt>
<dd><p><var>time_func</var>: it’s the system time function, a <code>gnutls_time_func()</code> callback.
</p>
<p>This is the function where you can override the default system time
function. The application provided function should behave the same
as the standard function.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fhandshake-1"></a>
<h4 class="subheading">gnutls_handshake</h4>
<a name="gnutls_005fhandshake"></a><dl>
<dt><a name="index-gnutls_005fhandshake-1"></a>Function: <em>int</em> <strong>gnutls_handshake</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function does the handshake of the TLS/SSL protocol, and
initializes the TLS connection.
</p>
<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>
<p>The non-fatal errors such as <code>GNUTLS_E_AGAIN</code> and
<code>GNUTLS_E_INTERRUPTED</code> interrupt the handshake procedure, which
should be resumed later. Call this function again, until it
returns 0; cf. <code>gnutls_record_get_direction()</code> and
<code>gnutls_error_is_fatal()</code> .
</p>
<p>If this function is called by a server after a rehandshake request
then <code>GNUTLS_E_GOT_APPLICATION_DATA</code> or
<code>GNUTLS_E_WARNING_ALERT_RECEIVED</code> 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 or
in the case of <code>GNUTLS_E_GOT_APPLICATION_DATA</code> it might also mean that
some data were pending.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p></dd></dl>
<a name="gnutls_005fhandshake_005fget_005flast_005fin-1"></a>
<h4 class="subheading">gnutls_handshake_get_last_in</h4>
<a name="gnutls_005fhandshake_005fget_005flast_005fin"></a><dl>
<dt><a name="index-gnutls_005fhandshake_005fget_005flast_005fin"></a>Function: <em>gnutls_handshake_description_t</em> <strong>gnutls_handshake_get_last_in</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>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>
<p>Check <code>gnutls_handshake_description_t</code> in gnutls.h for the
available handshake descriptions.
</p>
<p><strong>Returns:</strong> the last handshake message type received, a
<code>gnutls_handshake_description_t</code> .
</p></dd></dl>
<a name="gnutls_005fhandshake_005fget_005flast_005fout-1"></a>
<h4 class="subheading">gnutls_handshake_get_last_out</h4>
<a name="gnutls_005fhandshake_005fget_005flast_005fout"></a><dl>
<dt><a name="index-gnutls_005fhandshake_005fget_005flast_005fout"></a>Function: <em>gnutls_handshake_description_t</em> <strong>gnutls_handshake_get_last_out</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>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>
<p>Check <code>gnutls_handshake_description_t</code> in gnutls.h for the
available handshake descriptions.
</p>
<p><strong>Returns:</strong> the last handshake message type sent, a
<code>gnutls_handshake_description_t</code> .
</p></dd></dl>
<a name="gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength-1"></a>
<h4 class="subheading">gnutls_handshake_set_max_packet_length</h4>
<a name="gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength"></a><dl>
<dt><a name="index-gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength"></a>Function: <em>void</em> <strong>gnutls_handshake_set_max_packet_length</strong> <em>(gnutls_session_t <var>session</var>, size_t <var>max</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>max</var>: is the maximum number.
</p>
<p>This function will set the maximum size of all handshake messages.
Handshakes over this size are rejected with
<code>GNUTLS_E_HANDSHAKE_TOO_LARGE</code> error code. The default value is
48kb which is typically large enough. Set this to 0 if you do not
want to set an upper limit.
</p>
<p>The reason for restricting the handshake message sizes are to
limit Denial of Service attacks.
</p></dd></dl>
<a name="gnutls_005fhandshake_005fset_005fpost_005fclient_005fhello_005ffunction-1"></a>
<h4 class="subheading">gnutls_handshake_set_post_client_hello_function</h4>
<a name="gnutls_005fhandshake_005fset_005fpost_005fclient_005fhello_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fhandshake_005fset_005fpost_005fclient_005fhello_005ffunction"></a>Function: <em>void</em> <strong>gnutls_handshake_set_post_client_hello_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_handshake_post_client_hello_func <var>func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>func</var>: is the function to be called
</p>
<p>This function will set a callback to be called after the client
hello has been received (callback valid in server side only). This
allows the server to adjust settings based on received extensions.
</p>
<p>Those settings could be ciphersuites, requesting certificate, or
anything else except for version negotiation (this is done before
the hello message is parsed).
</p>
<p>This callback must return 0 on success or a gnutls error code to
terminate the handshake.
</p>
<p><strong>Warning:</strong> You should not use this function to terminate the
handshake based on client input unless you know what you are
doing. Before the handshake is finished there is no way to know if
there is a man-in-the-middle attack being performed.
</p></dd></dl>
<a name="gnutls_005fhandshake_005fset_005fprivate_005fextensions-1"></a>
<h4 class="subheading">gnutls_handshake_set_private_extensions</h4>
<a name="gnutls_005fhandshake_005fset_005fprivate_005fextensions"></a><dl>
<dt><a name="index-gnutls_005fhandshake_005fset_005fprivate_005fextensions"></a>Function: <em>void</em> <strong>gnutls_handshake_set_private_extensions</strong> <em>(gnutls_session_t <var>session</var>, int <var>allow</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>allow</var>: is an integer (0 or 1)
</p>
<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>
<p>Currently GnuTLS does not include such cipher-suites or
compression algorithms.
</p>
<p>Enabling the private ciphersuites when talking to other than
gnutls servers and clients may cause interoperability problems.
</p></dd></dl>
<a name="gnutls_005fhandshake_005fset_005ftimeout-1"></a>
<h4 class="subheading">gnutls_handshake_set_timeout</h4>
<a name="gnutls_005fhandshake_005fset_005ftimeout"></a><dl>
<dt><a name="index-gnutls_005fhandshake_005fset_005ftimeout-1"></a>Function: <em>void</em> <strong>gnutls_handshake_set_timeout</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>ms</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>ms</var>: is a timeout value in milliseconds
</p>
<p>This function sets the timeout for the handshake process
to the provided value. Use an <code>ms</code> value of zero to disable
timeout.
</p>
<p>Note that in order for the timeout to be enforced
<code>gnutls_transport_set_pull_timeout_function()</code> must be set
(it is set by default in most systems).
</p></dd></dl>
<a name="gnutls_005fheartbeat_005fallowed-1"></a>
<h4 class="subheading">gnutls_heartbeat_allowed</h4>
<a name="gnutls_005fheartbeat_005fallowed"></a><dl>
<dt><a name="index-gnutls_005fheartbeat_005fallowed"></a>Function: <em>int</em> <strong>gnutls_heartbeat_allowed</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>type</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>type</var>: one of <code>GNUTLS_HB_LOCAL_ALLOWED_TO_SEND</code> and <code>GNUTLS_HB_PEER_ALLOWED_TO_SEND</code>
</p>
<p>This function will check whether heartbeats are allowed
to be sent or received in this session.
</p>
<p><strong>Returns:</strong> Non zero if heartbeats are allowed.
</p>
<p><strong>Since:</strong> 3.1.2
</p></dd></dl>
<a name="gnutls_005fheartbeat_005fenable-1"></a>
<h4 class="subheading">gnutls_heartbeat_enable</h4>
<a name="gnutls_005fheartbeat_005fenable"></a><dl>
<dt><a name="index-gnutls_005fheartbeat_005fenable"></a>Function: <em>void</em> <strong>gnutls_heartbeat_enable</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>type</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>type</var>: one of the GNUTLS_HB_* flags
</p>
<p>This function will allow heartbeat messages to be
received.
</p>
<p><strong>Since:</strong> 3.1.2
</p></dd></dl>
<a name="gnutls_005fheartbeat_005fget_005ftimeout-1"></a>
<h4 class="subheading">gnutls_heartbeat_get_timeout</h4>
<a name="gnutls_005fheartbeat_005fget_005ftimeout"></a><dl>
<dt><a name="index-gnutls_005fheartbeat_005fget_005ftimeout"></a>Function: <em>unsigned int</em> <strong>gnutls_heartbeat_get_timeout</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the milliseconds remaining
for a retransmission of the previously sent ping
message. This function is useful when ping is used in
non-blocking mode, to estimate when to call <code>gnutls_heartbeat_ping()</code>
if no packets have been received.
</p>
<p><strong>Returns:</strong> the remaining time in milliseconds.
</p>
<p><strong>Since:</strong> 3.1.2
</p></dd></dl>
<a name="gnutls_005fheartbeat_005fping-1"></a>
<h4 class="subheading">gnutls_heartbeat_ping</h4>
<a name="gnutls_005fheartbeat_005fping"></a><dl>
<dt><a name="index-gnutls_005fheartbeat_005fping"></a>Function: <em>int</em> <strong>gnutls_heartbeat_ping</strong> <em>(gnutls_session_t <var>session</var>, size_t <var>data_size</var>, unsigned int <var>max_tries</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data_size</var>: is the length of the ping payload.
</p>
<p><var>max_tries</var>: if flags is <code>GNUTLS_HEARTBEAT_WAIT</code> then this sets the number of retransmissions. Use zero for indefinite (until timeout).
</p>
<p><var>flags</var>: if <code>GNUTLS_HEARTBEAT_WAIT</code> then wait for pong or timeout instead of returning immediately.
</p>
<p>This function sends a ping to the peer. If the <code>flags</code> is set
to <code>GNUTLS_HEARTBEAT_WAIT</code> then it waits for a reply from the peer.
</p>
<p>Note that it is highly recommended to use this function with the
flag <code>GNUTLS_HEARTBEAT_WAIT</code> , or you need to handle retransmissions
and timeouts manually.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 3.1.2
</p></dd></dl>
<a name="gnutls_005fheartbeat_005fpong-1"></a>
<h4 class="subheading">gnutls_heartbeat_pong</h4>
<a name="gnutls_005fheartbeat_005fpong"></a><dl>
<dt><a name="index-gnutls_005fheartbeat_005fpong"></a>Function: <em>int</em> <strong>gnutls_heartbeat_pong</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function replies to a ping by sending a pong to the peer.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 3.1.2
</p></dd></dl>
<a name="gnutls_005fheartbeat_005fset_005ftimeouts-1"></a>
<h4 class="subheading">gnutls_heartbeat_set_timeouts</h4>
<a name="gnutls_005fheartbeat_005fset_005ftimeouts"></a><dl>
<dt><a name="index-gnutls_005fheartbeat_005fset_005ftimeouts"></a>Function: <em>void</em> <strong>gnutls_heartbeat_set_timeouts</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>retrans_timeout</var>, unsigned int <var>total_timeout</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>retrans_timeout</var>: The time at which a retransmission will occur in milliseconds
</p>
<p><var>total_timeout</var>: The time at which the connection will be aborted, in milliseconds.
</p>
<p>This function will set the timeouts required for the DTLS handshake
protocol. The retransmission timeout is the time after which a
message from the peer is not received, the previous messages will
be retransmitted. The total timeout is the time after which the
handshake will be aborted with <code>GNUTLS_E_TIMEDOUT</code> .
</p>
<p>The DTLS protocol recommends the values of 1 sec and 60 seconds
respectively.
</p>
<p>If the retransmission timeout is zero then the handshake will operate
in a non-blocking way, i.e., return <code>GNUTLS_E_AGAIN</code> .
</p>
<p><strong>Since:</strong> 3.1.2
</p></dd></dl>
<a name="gnutls_005fhex2bin-1"></a>
<h4 class="subheading">gnutls_hex2bin</h4>
<a name="gnutls_005fhex2bin"></a><dl>
<dt><a name="index-gnutls_005fhex2bin"></a>Function: <em>int</em> <strong>gnutls_hex2bin</strong> <em>(const char * <var>hex_data</var>, size_t <var>hex_size</var>, void * <var>bin_data</var>, size_t * <var>bin_size</var>)</em></dt>
<dd><p><var>hex_data</var>: string with data in hex format
</p>
<p><var>hex_size</var>: size of hex data
</p>
<p><var>bin_data</var>: output array with binary data
</p>
<p><var>bin_size</var>: when calling should hold maximum size of <code>bin_data</code> ,
on return will hold actual length of <code>bin_data</code> .
</p>
<p>Convert a buffer with hex data to binary data.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fhex_005fdecode-1"></a>
<h4 class="subheading">gnutls_hex_decode</h4>
<a name="gnutls_005fhex_005fdecode"></a><dl>
<dt><a name="index-gnutls_005fhex_005fdecode"></a>Function: <em>int</em> <strong>gnutls_hex_decode</strong> <em>(const gnutls_datum_t * <var>hex_data</var>, void * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>hex_data</var>: contain the encoded data
</p>
<p><var>result</var>: the place where decoded data will be copied
</p>
<p><var>result_size</var>: holds the size of the result
</p>
<p>This function will decode the given encoded data, using the hex
encoding used by PSK password files.
</p>
<p>Note that hex_data should be null terminated.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the buffer given is not
long enough, or 0 on success.
</p></dd></dl>
<a name="gnutls_005fhex_005fencode-1"></a>
<h4 class="subheading">gnutls_hex_encode</h4>
<a name="gnutls_005fhex_005fencode"></a><dl>
<dt><a name="index-gnutls_005fhex_005fencode"></a>Function: <em>int</em> <strong>gnutls_hex_encode</strong> <em>(const gnutls_datum_t * <var>data</var>, char * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>data</var>: contain the raw data
</p>
<p><var>result</var>: the place where hex data will be copied
</p>
<p><var>result_size</var>: holds the size of the result
</p>
<p>This function will convert the given data to printable data, using
the hex encoding, as used in the PSK password files.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the buffer given is not
long enough, or 0 on success.
</p></dd></dl>
<a name="gnutls_005finit-1"></a>
<h4 class="subheading">gnutls_init</h4>
<a name="gnutls_005finit"></a><dl>
<dt><a name="index-gnutls_005finit-1"></a>Function: <em>int</em> <strong>gnutls_init</strong> <em>(gnutls_session_t * <var>session</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
</p>
<p><var>flags</var>: indicate if this session is to be used for server or client.
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p>
<p><code>flags</code> can be one of <code>GNUTLS_CLIENT</code> and <code>GNUTLS_SERVER</code> . For a DTLS
entity, the flags <code>GNUTLS_DATAGRAM</code> and <code>GNUTLS_NONBLOCK</code> are
also available. The latter flag will enable a non-blocking
operation of the DTLS timers.
</p>
<p>Note that since version 3.1.2 this function enables some common
TLS extensions such as session tickets and OCSP certificate status
request in client side by default. To prevent that use the <code>GNUTLS_NO_EXTENSIONS</code>
flag.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fkey_005fgenerate-1"></a>
<h4 class="subheading">gnutls_key_generate</h4>
<a name="gnutls_005fkey_005fgenerate"></a><dl>
<dt><a name="index-gnutls_005fkey_005fgenerate"></a>Function: <em>int</em> <strong>gnutls_key_generate</strong> <em>(gnutls_datum_t * <var>key</var>, unsigned int <var>key_size</var>)</em></dt>
<dd><p><var>key</var>: is a pointer to a <code>gnutls_datum_t</code> which will contain a newly
created key.
</p>
<p><var>key_size</var>: The number of bytes of the key.
</p>
<p>Generates a random key of <code>key_size</code> bytes.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fkx_005fget-1"></a>
<h4 class="subheading">gnutls_kx_get</h4>
<a name="gnutls_005fkx_005fget"></a><dl>
<dt><a name="index-gnutls_005fkx_005fget"></a>Function: <em>gnutls_kx_algorithm_t</em> <strong>gnutls_kx_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get currently used key exchange algorithm.
</p>
<p><strong>Returns:</strong> the key exchange algorithm used in the last handshake, a
<code>gnutls_kx_algorithm_t</code> value.
</p></dd></dl>
<a name="gnutls_005fkx_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_kx_get_id</h4>
<a name="gnutls_005fkx_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fkx_005fget_005fid"></a>Function: <em>gnutls_kx_algorithm_t</em> <strong>gnutls_kx_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a KX name
</p>
<p>Convert a string to a <code>gnutls_kx_algorithm_t</code> value. The names are
compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> an id of the specified KX algorithm, or <code>GNUTLS_KX_UNKNOWN</code>
on error.
</p></dd></dl>
<a name="gnutls_005fkx_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_kx_get_name</h4>
<a name="gnutls_005fkx_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fkx_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_kx_get_name</strong> <em>(gnutls_kx_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a key exchange algorithm
</p>
<p>Convert a <code>gnutls_kx_algorithm_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a pointer to a string that contains the name of the
specified key exchange algorithm, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fkx_005flist-1"></a>
<h4 class="subheading">gnutls_kx_list</h4>
<a name="gnutls_005fkx_005flist"></a><dl>
<dt><a name="index-gnutls_005fkx_005flist"></a>Function: <em>const gnutls_kx_algorithm_t *</em> <strong>gnutls_kx_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of supported key exchange algorithms.
</p>
<p>This function is not thread safe.
</p>
<p><strong>Returns:</strong> a (0)-terminated list of <code>gnutls_kx_algorithm_t</code> integers
indicating the available key exchange algorithms.
</p></dd></dl>
<a name="gnutls_005fload_005ffile-1"></a>
<h4 class="subheading">gnutls_load_file</h4>
<a name="gnutls_005fload_005ffile"></a><dl>
<dt><a name="index-gnutls_005fload_005ffile"></a>Function: <em>int</em> <strong>gnutls_load_file</strong> <em>(const char* <var>filename</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>filename</var>: the name of the file to load
</p>
<p><var>data</var>: Where the file will be stored
</p>
<p>This function will load a file into a datum. The data are
zero terminated but the terminating null is not included in length.
The returned data are allocated using <code>gnutls_malloc()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p>
<p>Since 3.1.0
</p></dd></dl>
<a name="gnutls_005fmac_005fget-1"></a>
<h4 class="subheading">gnutls_mac_get</h4>
<a name="gnutls_005fmac_005fget"></a><dl>
<dt><a name="index-gnutls_005fmac_005fget"></a>Function: <em>gnutls_mac_algorithm_t</em> <strong>gnutls_mac_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get currently used MAC algorithm.
</p>
<p><strong>Returns:</strong> the currently used mac algorithm, a
<code>gnutls_mac_algorithm_t</code> value.
</p></dd></dl>
<a name="gnutls_005fmac_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_mac_get_id</h4>
<a name="gnutls_005fmac_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fmac_005fget_005fid"></a>Function: <em>gnutls_mac_algorithm_t</em> <strong>gnutls_mac_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a MAC algorithm name
</p>
<p>Convert a string to a <code>gnutls_mac_algorithm_t</code> value. The names are
compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> a <code>gnutls_mac_algorithm_t</code> id of the specified MAC
algorithm string, or <code>GNUTLS_MAC_UNKNOWN</code> on failures.
</p></dd></dl>
<a name="gnutls_005fmac_005fget_005fkey_005fsize-1"></a>
<h4 class="subheading">gnutls_mac_get_key_size</h4>
<a name="gnutls_005fmac_005fget_005fkey_005fsize"></a><dl>
<dt><a name="index-gnutls_005fmac_005fget_005fkey_005fsize"></a>Function: <em>size_t</em> <strong>gnutls_mac_get_key_size</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>
<p>Get size of MAC key.
</p>
<p><strong>Returns:</strong> length (in bytes) of the given MAC key size, or 0 if the
given MAC algorithm is invalid.
</p></dd></dl>
<a name="gnutls_005fmac_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_mac_get_name</h4>
<a name="gnutls_005fmac_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fmac_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_mac_get_name</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a MAC algorithm
</p>
<p>Convert a <code>gnutls_mac_algorithm_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified MAC
algorithm, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fmac_005flist-1"></a>
<h4 class="subheading">gnutls_mac_list</h4>
<a name="gnutls_005fmac_005flist"></a><dl>
<dt><a name="index-gnutls_005fmac_005flist"></a>Function: <em>const gnutls_mac_algorithm_t *</em> <strong>gnutls_mac_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of hash algorithms for use as MACs. Note that not
necessarily all MACs are supported in TLS cipher suites. For
example, MD2 is not supported as a cipher suite, but is supported
for other purposes (e.g., X.509 signature verification or similar).
</p>
<p>This function is not thread safe.
</p>
<p><strong>Returns:</strong> Return a (0)-terminated list of <code>gnutls_mac_algorithm_t</code>
integers indicating the available MACs.
</p></dd></dl>
<a name="gnutls_005focsp_005fstatus_005frequest_005fenable_005fclient-1"></a>
<h4 class="subheading">gnutls_ocsp_status_request_enable_client</h4>
<a name="gnutls_005focsp_005fstatus_005frequest_005fenable_005fclient"></a><dl>
<dt><a name="index-gnutls_005focsp_005fstatus_005frequest_005fenable_005fclient"></a>Function: <em>int</em> <strong>gnutls_ocsp_status_request_enable_client</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>responder_id</var>, size_t <var>responder_id_size</var>, gnutls_datum_t * <var>extensions</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>responder_id</var>: array with <code>gnutls_datum_t</code> with DER data of responder id
</p>
<p><var>responder_id_size</var>: number of members in <code>responder_id</code> array
</p>
<p><var>extensions</var>: a <code>gnutls_datum_t</code> with DER encoded OCSP extensions
</p>
<p>This function is to be used by clients to request OCSP response
from the server, using the "status_request" TLS extension. Only
OCSP status type is supported. A typical server has a single
OCSP response cached, so <code>responder_id</code> and <code>extensions</code> should be null.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005focsp_005fstatus_005frequest_005fget-1"></a>
<h4 class="subheading">gnutls_ocsp_status_request_get</h4>
<a name="gnutls_005focsp_005fstatus_005frequest_005fget"></a><dl>
<dt><a name="index-gnutls_005focsp_005fstatus_005frequest_005fget"></a>Function: <em>int</em> <strong>gnutls_ocsp_status_request_get</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>response</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>response</var>: a <code>gnutls_datum_t</code> with DER encoded OCSP response
</p>
<p>This function returns the OCSP status response received
from the TLS server. The <code>response</code> should be treated as
constant. If no OCSP response is available then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005focsp_005fstatus_005frequest_005fis_005fchecked-1"></a>
<h4 class="subheading">gnutls_ocsp_status_request_is_checked</h4>
<a name="gnutls_005focsp_005fstatus_005frequest_005fis_005fchecked"></a><dl>
<dt><a name="index-gnutls_005focsp_005fstatus_005frequest_005fis_005fchecked"></a>Function: <em>int</em> <strong>gnutls_ocsp_status_request_is_checked</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>flags</var>: should be zero
</p>
<p>Check whether an OCSP status response was included in the handshake
and whether it was checked and valid (not too old or superseded).
This is a helper function when needing to decide whether to perform an
OCSP validity check on the peer’s certificate. Must be called after
<code>gnutls_certificate_verify_peers3()</code> is called.
</p>
<p><strong>Returns:</strong> non zero it was valid, or a zero if it wasn’t sent,
or sent and was invalid.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fsend_005fcert-1"></a>
<h4 class="subheading">gnutls_openpgp_send_cert</h4>
<a name="gnutls_005fopenpgp_005fsend_005fcert"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fsend_005fcert"></a>Function: <em>void</em> <strong>gnutls_openpgp_send_cert</strong> <em>(gnutls_session_t <var>session</var>, gnutls_openpgp_crt_status_t <var>status</var>)</em></dt>
<dd><p><var>session</var>: is a pointer to a <code>gnutls_session_t</code> structure.
</p>
<p><var>status</var>: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT
</p>
<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></dd></dl>
<a name="gnutls_005fpem_005fbase64_005fdecode-1"></a>
<h4 class="subheading">gnutls_pem_base64_decode</h4>
<a name="gnutls_005fpem_005fbase64_005fdecode"></a><dl>
<dt><a name="index-gnutls_005fpem_005fbase64_005fdecode"></a>Function: <em>int</em> <strong>gnutls_pem_base64_decode</strong> <em>(const char * <var>header</var>, const gnutls_datum_t * <var>b64_data</var>, unsigned char * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>header</var>: A null terminated string with the PEM header (eg. CERTIFICATE)
</p>
<p><var>b64_data</var>: contain the encoded data
</p>
<p><var>result</var>: the place where decoded data will be copied
</p>
<p><var>result_size</var>: holds the size of the result
</p>
<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>
<p><strong>Returns:</strong> On success <code>GNUTLS_E_SUCCESS</code> (0) is returned,
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is returned if the buffer given is
not long enough, or 0 on success.
</p></dd></dl>
<a name="gnutls_005fpem_005fbase64_005fdecode_005falloc-1"></a>
<h4 class="subheading">gnutls_pem_base64_decode_alloc</h4>
<a name="gnutls_005fpem_005fbase64_005fdecode_005falloc"></a><dl>
<dt><a name="index-gnutls_005fpem_005fbase64_005fdecode_005falloc"></a>Function: <em>int</em> <strong>gnutls_pem_base64_decode_alloc</strong> <em>(const char * <var>header</var>, const gnutls_datum_t * <var>b64_data</var>, gnutls_datum_t * <var>result</var>)</em></dt>
<dd><p><var>header</var>: The PEM header (eg. CERTIFICATE)
</p>
<p><var>b64_data</var>: contains the encoded data
</p>
<p><var>result</var>: the place where decoded data lie
</p>
<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>
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fpem_005fbase64_005fencode-1"></a>
<h4 class="subheading">gnutls_pem_base64_encode</h4>
<a name="gnutls_005fpem_005fbase64_005fencode"></a><dl>
<dt><a name="index-gnutls_005fpem_005fbase64_005fencode"></a>Function: <em>int</em> <strong>gnutls_pem_base64_encode</strong> <em>(const char * <var>msg</var>, const gnutls_datum_t * <var>data</var>, char * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>msg</var>: is a message to be put in the header
</p>
<p><var>data</var>: contain the raw data
</p>
<p><var>result</var>: the place where base64 data will be copied
</p>
<p><var>result_size</var>: holds the size of the result
</p>
<p>This function will convert the given data to printable data, using
the base64 encoding. This is the encoding used in PEM messages.
</p>
<p>The output string will be null terminated, although the size will
not include the terminating null.
</p>
<p><strong>Returns:</strong> On success <code>GNUTLS_E_SUCCESS</code> (0) is returned,
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is returned if the buffer given is
not long enough, or 0 on success.
</p></dd></dl>
<a name="gnutls_005fpem_005fbase64_005fencode_005falloc-1"></a>
<h4 class="subheading">gnutls_pem_base64_encode_alloc</h4>
<a name="gnutls_005fpem_005fbase64_005fencode_005falloc"></a><dl>
<dt><a name="index-gnutls_005fpem_005fbase64_005fencode_005falloc"></a>Function: <em>int</em> <strong>gnutls_pem_base64_encode_alloc</strong> <em>(const char * <var>msg</var>, const gnutls_datum_t * <var>data</var>, gnutls_datum_t * <var>result</var>)</em></dt>
<dd><p><var>msg</var>: is a message to be put in the encoded header
</p>
<p><var>data</var>: contains the raw data
</p>
<p><var>result</var>: will hold the newly allocated encoded data
</p>
<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>
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fperror-1"></a>
<h4 class="subheading">gnutls_perror</h4>
<a name="gnutls_005fperror"></a><dl>
<dt><a name="index-gnutls_005fperror"></a>Function: <em>void</em> <strong>gnutls_perror</strong> <em>(int <var>error</var>)</em></dt>
<dd><p><var>error</var>: is a GnuTLS error code, a negative error code
</p>
<p>This function is like <code>perror()</code> . The only difference is that it
accepts an error number returned by a gnutls function.
</p></dd></dl>
<a name="gnutls_005fpk_005falgorithm_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_pk_algorithm_get_name</h4>
<a name="gnutls_005fpk_005falgorithm_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fpk_005falgorithm_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_pk_algorithm_get_name</strong> <em>(gnutls_pk_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a pk algorithm
</p>
<p>Convert a <code>gnutls_pk_algorithm_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified public
key algorithm, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fpk_005fbits_005fto_005fsec_005fparam-1"></a>
<h4 class="subheading">gnutls_pk_bits_to_sec_param</h4>
<a name="gnutls_005fpk_005fbits_005fto_005fsec_005fparam"></a><dl>
<dt><a name="index-gnutls_005fpk_005fbits_005fto_005fsec_005fparam-1"></a>Function: <em>gnutls_sec_param_t</em> <strong>gnutls_pk_bits_to_sec_param</strong> <em>(gnutls_pk_algorithm_t <var>algo</var>, unsigned int <var>bits</var>)</em></dt>
<dd><p><var>algo</var>: is a public key algorithm
</p>
<p><var>bits</var>: is the number of bits
</p>
<p>This is the inverse of <code>gnutls_sec_param_to_pk_bits()</code> . Given an algorithm
and the number of bits, it will return the security parameter. This is
a rough indication.
</p>
<p><strong>Returns:</strong> The security parameter.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpk_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_pk_get_id</h4>
<a name="gnutls_005fpk_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fpk_005fget_005fid"></a>Function: <em>gnutls_pk_algorithm_t</em> <strong>gnutls_pk_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a string containing a public key algorithm name.
</p>
<p>Convert a string to a <code>gnutls_pk_algorithm_t</code> value. The names are
compared in a case insensitive way. For example,
gnutls_pk_get_id("RSA") will return <code>GNUTLS_PK_RSA</code> .
</p>
<p><strong>Returns:</strong> a <code>gnutls_pk_algorithm_t</code> id of the specified public key
algorithm string, or <code>GNUTLS_PK_UNKNOWN</code> on failures.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fpk_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_pk_get_name</h4>
<a name="gnutls_005fpk_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fpk_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_pk_get_name</strong> <em>(gnutls_pk_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a public key algorithm
</p>
<p>Convert a <code>gnutls_pk_algorithm_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a pointer to a string that contains the name of the
specified public key algorithm, or <code>NULL</code> .
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fpk_005flist-1"></a>
<h4 class="subheading">gnutls_pk_list</h4>
<a name="gnutls_005fpk_005flist"></a><dl>
<dt><a name="index-gnutls_005fpk_005flist"></a>Function: <em>const gnutls_pk_algorithm_t *</em> <strong>gnutls_pk_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of supported public key algorithms.
</p>
<p>This function is not thread safe.
</p>
<p><strong>Returns:</strong> a (0)-terminated list of <code>gnutls_pk_algorithm_t</code> integers
indicating the available ciphers.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fpk_005fto_005fsign-1"></a>
<h4 class="subheading">gnutls_pk_to_sign</h4>
<a name="gnutls_005fpk_005fto_005fsign"></a><dl>
<dt><a name="index-gnutls_005fpk_005fto_005fsign"></a>Function: <em>gnutls_sign_algorithm_t</em> <strong>gnutls_pk_to_sign</strong> <em>(gnutls_pk_algorithm_t <var>pk</var>, gnutls_digest_algorithm_t <var>hash</var>)</em></dt>
<dd><p><var>pk</var>: is a public key algorithm
</p>
<p><var>hash</var>: a hash algorithm
</p>
<p>This function maps public key and hash algorithms combinations
to signature algorithms.
</p>
<p><strong>Returns:</strong> return a <code>gnutls_sign_algorithm_t</code> value, or <code>GNUTLS_SIGN_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fprf-1"></a>
<h4 class="subheading">gnutls_prf</h4>
<a name="gnutls_005fprf"></a><dl>
<dt><a name="index-gnutls_005fprf"></a>Function: <em>int</em> <strong>gnutls_prf</strong> <em>(gnutls_session_t <var>session</var>, size_t <var>label_size</var>, const char * <var>label</var>, int <var>server_random_first</var>, size_t <var>extra_size</var>, const char * <var>extra</var>, size_t <var>outsize</var>, char * <var>out</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>label_size</var>: length of the <code>label</code> variable.
</p>
<p><var>label</var>: label used in PRF computation, typically a short string.
</p>
<p><var>server_random_first</var>: non-0 if server random field should be first in seed
</p>
<p><var>extra_size</var>: length of the <code>extra</code> variable.
</p>
<p><var>extra</var>: optional extra data to seed the PRF with.
</p>
<p><var>outsize</var>: size of pre-allocated output buffer to hold the output.
</p>
<p><var>out</var>: pre-allocated buffer to hold the generated data.
</p>
<p>Apply the TLS Pseudo-Random-Function (PRF) on the master secret
and the provided data, seeded with the client and server random fields.
</p>
<p>The <code>label</code> variable usually contains a string denoting the purpose
for the generated data. The <code>server_random_first</code> indicates whether
the client random field or the server random field should be first
in the seed. Non-0 indicates that the server random field is first,
0 that the client random field is first.
</p>
<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 make sure the
generated output is strongly connected to some additional data
(e.g., a string used in user authentication).
</p>
<p>The output is placed in <code>out</code> , which must be pre-allocated.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fprf_005fraw-1"></a>
<h4 class="subheading">gnutls_prf_raw</h4>
<a name="gnutls_005fprf_005fraw"></a><dl>
<dt><a name="index-gnutls_005fprf_005fraw"></a>Function: <em>int</em> <strong>gnutls_prf_raw</strong> <em>(gnutls_session_t <var>session</var>, size_t <var>label_size</var>, const char * <var>label</var>, size_t <var>seed_size</var>, const char * <var>seed</var>, size_t <var>outsize</var>, char * <var>out</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>label_size</var>: length of the <code>label</code> variable.
</p>
<p><var>label</var>: label used in PRF computation, typically a short string.
</p>
<p><var>seed_size</var>: length of the <code>seed</code> variable.
</p>
<p><var>seed</var>: optional extra data to seed the PRF with.
</p>
<p><var>outsize</var>: size of pre-allocated output buffer to hold the output.
</p>
<p><var>out</var>: pre-allocated buffer to hold the generated data.
</p>
<p>Apply the TLS Pseudo-Random-Function (PRF) on the master secret
and the provided data.
</p>
<p>The <code>label</code> variable usually contains a string denoting the purpose
for the generated data. The <code>seed</code> usually contains 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>
<p>Because the output is not guaranteed to be unique for a particular
session unless <code>seed</code> includes 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 seeds 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fpriority_005fcertificate_005ftype_005flist-1"></a>
<h4 class="subheading">gnutls_priority_certificate_type_list</h4>
<a name="gnutls_005fpriority_005fcertificate_005ftype_005flist"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fcertificate_005ftype_005flist"></a>Function: <em>int</em> <strong>gnutls_priority_certificate_type_list</strong> <em>(gnutls_priority_t <var>pcache</var>, const unsigned int** <var>list</var>)</em></dt>
<dd><p><var>pcache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>list</var>: will point to an integer list
</p>
<p>Get a list of available certificate types in the priority
structure.
</p>
<p><strong>Returns:</strong> the number of certificate types, or an error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpriority_005fcompression_005flist-1"></a>
<h4 class="subheading">gnutls_priority_compression_list</h4>
<a name="gnutls_005fpriority_005fcompression_005flist"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fcompression_005flist"></a>Function: <em>int</em> <strong>gnutls_priority_compression_list</strong> <em>(gnutls_priority_t <var>pcache</var>, const unsigned int** <var>list</var>)</em></dt>
<dd><p><var>pcache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>list</var>: will point to an integer list
</p>
<p>Get a list of available compression method in the priority
structure.
</p>
<p><strong>Returns:</strong> the number of methods, or an error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpriority_005fdeinit-1"></a>
<h4 class="subheading">gnutls_priority_deinit</h4>
<a name="gnutls_005fpriority_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_priority_deinit</strong> <em>(gnutls_priority_t <var>priority_cache</var>)</em></dt>
<dd><p><var>priority_cache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p>Deinitializes the priority cache.
</p></dd></dl>
<a name="gnutls_005fpriority_005fecc_005fcurve_005flist-1"></a>
<h4 class="subheading">gnutls_priority_ecc_curve_list</h4>
<a name="gnutls_005fpriority_005fecc_005fcurve_005flist"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fecc_005fcurve_005flist"></a>Function: <em>int</em> <strong>gnutls_priority_ecc_curve_list</strong> <em>(gnutls_priority_t <var>pcache</var>, const unsigned int** <var>list</var>)</em></dt>
<dd><p><var>pcache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>list</var>: will point to an integer list
</p>
<p>Get a list of available elliptic curves in the priority
structure.
</p>
<p><strong>Returns:</strong> the number of curves, or an error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpriority_005fget_005fcipher_005fsuite_005findex-1"></a>
<h4 class="subheading">gnutls_priority_get_cipher_suite_index</h4>
<a name="gnutls_005fpriority_005fget_005fcipher_005fsuite_005findex"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fget_005fcipher_005fsuite_005findex"></a>Function: <em>int</em> <strong>gnutls_priority_get_cipher_suite_index</strong> <em>(gnutls_priority_t <var>pcache</var>, unsigned int <var>idx</var>, unsigned int * <var>sidx</var>)</em></dt>
<dd><p><var>pcache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>idx</var>: is an index number.
</p>
<p><var>sidx</var>: internal index of cipher suite to get information about.
</p>
<p>Provides the internal ciphersuite index to be used with
<code>gnutls_cipher_suite_info()</code> . The index <code>idx</code> provided is an
index kept at the priorities structure. It might be that a valid
priorities index does not correspond to a ciphersuite and in
that case <code>GNUTLS_E_UNKNOWN_CIPHER_SUITE</code> will be returned.
Once the last available index is crossed then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p>
<p><strong>Returns:</strong> On success it returns <code>GNUTLS_E_SUCCESS</code> (0), or a negative error value otherwise.
</p></dd></dl>
<a name="gnutls_005fpriority_005finit-1"></a>
<h4 class="subheading">gnutls_priority_init</h4>
<a name="gnutls_005fpriority_005finit"></a><dl>
<dt><a name="index-gnutls_005fpriority_005finit"></a>Function: <em>int</em> <strong>gnutls_priority_init</strong> <em>(gnutls_priority_t * <var>priority_cache</var>, const char * <var>priorities</var>, const char ** <var>err_pos</var>)</em></dt>
<dd><p><var>priority_cache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>priorities</var>: is a string describing priorities
</p>
<p><var>err_pos</var>: In case of an error this will have the position in the string the error occured
</p>
<p>Sets priorities for the ciphers, key exchange methods, macs and
compression methods.
</p>
<p>The <code>priorities</code> option allows you to specify a colon
separated list of the cipher priorities to enable.
Some keywords are defined to provide quick access
to common preferences.
</p>
<p>"PERFORMANCE" means all the "secure" ciphersuites are enabled,
limited to 128 bit ciphers and sorted by terms of speed
performance.
</p>
<p>"NORMAL" means all "secure" ciphersuites. The 256-bit ciphers are
included as a fallback only. The ciphers are sorted by security
margin.
</p>
<p>"SECURE128" means all "secure" ciphersuites of security level 128-bit
or more.
</p>
<p>"SECURE192" means all "secure" ciphersuites of security level 192-bit
or more.
</p>
<p>"SUITEB128" means all the NSA SuiteB ciphersuites with security level
of 128.
</p>
<p>"SUITEB192" means all the NSA SuiteB ciphersuites with security level
of 192.
</p>
<p>"EXPORT" means all ciphersuites are enabled, including the
low-security 40 bit ciphers.
</p>
<p>"NONE" means nothing is enabled. This disables even protocols and
compression methods.
</p>
<p>Special keywords are "!", "-" and "+".
"!" or "-" appended with an algorithm will remove this algorithm.
"+" appended with an algorithm will add this algorithm.
</p>
<p>Check the GnuTLS manual section "Priority strings" for detailed
information.
</p>
<p><strong>Examples:</strong>
"NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+AES-128-CBC:+SIGN-ALL:+COMP-NULL"
</p>
<p>"NORMAL:-ARCFOUR-128" means normal ciphers except for ARCFOUR-128.
</p>
<p>"SECURE:-VERS-SSL3.0:+COMP-DEFLATE" means that only secure ciphers are
enabled, SSL3.0 is disabled, and libz compression enabled.
</p>
<p>"NONE:+VERS-TLS-ALL:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1",
</p>
<p>"NONE:+VERS-TLS-ALL:+AES-128-CBC:+ECDHE-RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1:+CURVE-SECP256R1",
</p>
<p>"SECURE256:+SECURE128",
</p>
<p>Note that "NORMAL:<code>COMPAT</code> " is the most compatible mode.
</p>
<p><strong>Returns:</strong> On syntax error <code>GNUTLS_E_INVALID_REQUEST</code> is returned,
<code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fpriority_005fprotocol_005flist-1"></a>
<h4 class="subheading">gnutls_priority_protocol_list</h4>
<a name="gnutls_005fpriority_005fprotocol_005flist"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fprotocol_005flist"></a>Function: <em>int</em> <strong>gnutls_priority_protocol_list</strong> <em>(gnutls_priority_t <var>pcache</var>, const unsigned int** <var>list</var>)</em></dt>
<dd><p><var>pcache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>list</var>: will point to an integer list
</p>
<p>Get a list of available TLS version numbers in the priority
structure.
</p>
<p><strong>Returns:</strong> the number of protocols, or an error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpriority_005fset-1"></a>
<h4 class="subheading">gnutls_priority_set</h4>
<a name="gnutls_005fpriority_005fset"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fset"></a>Function: <em>int</em> <strong>gnutls_priority_set</strong> <em>(gnutls_session_t <var>session</var>, gnutls_priority_t <var>priority</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>priority</var>: is a <code>gnutls_priority_t</code> structure.
</p>
<p>Sets the priorities to use on the ciphers, key exchange methods,
macs and compression methods.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fpriority_005fset_005fdirect-1"></a>
<h4 class="subheading">gnutls_priority_set_direct</h4>
<a name="gnutls_005fpriority_005fset_005fdirect"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fset_005fdirect"></a>Function: <em>int</em> <strong>gnutls_priority_set_direct</strong> <em>(gnutls_session_t <var>session</var>, const char * <var>priorities</var>, const char ** <var>err_pos</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>priorities</var>: is a string describing priorities
</p>
<p><var>err_pos</var>: In case of an error this will have the position in the string the error occured
</p>
<p>Sets the priorities to use on the ciphers, key exchange methods,
macs and compression methods. This function avoids keeping a
priority cache and is used to directly set string priorities to a
TLS session. For documentation check the <code>gnutls_priority_init()</code> .
</p>
<p><strong>Returns:</strong> On syntax error <code>GNUTLS_E_INVALID_REQUEST</code> is returned,
<code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fpriority_005fsign_005flist-1"></a>
<h4 class="subheading">gnutls_priority_sign_list</h4>
<a name="gnutls_005fpriority_005fsign_005flist"></a><dl>
<dt><a name="index-gnutls_005fpriority_005fsign_005flist"></a>Function: <em>int</em> <strong>gnutls_priority_sign_list</strong> <em>(gnutls_priority_t <var>pcache</var>, const unsigned int** <var>list</var>)</em></dt>
<dd><p><var>pcache</var>: is a <code>gnutls_prioritity_t</code> structure.
</p>
<p><var>list</var>: will point to an integer list
</p>
<p>Get a list of available signature algorithms in the priority
structure.
</p>
<p><strong>Returns:</strong> the number of algorithms, or an error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fprotocol_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_protocol_get_id</h4>
<a name="gnutls_005fprotocol_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fprotocol_005fget_005fid"></a>Function: <em>gnutls_protocol_t</em> <strong>gnutls_protocol_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a protocol name
</p>
<p>The names are compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> an id of the specified protocol, or
<code>GNUTLS_VERSION_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fprotocol_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_protocol_get_name</h4>
<a name="gnutls_005fprotocol_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fprotocol_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_protocol_get_name</strong> <em>(gnutls_protocol_t <var>version</var>)</em></dt>
<dd><p><var>version</var>: is a (gnutls) version number
</p>
<p>Convert a <code>gnutls_protocol_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified TLS
version (e.g., "TLS1.0"), or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fprotocol_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_protocol_get_version</h4>
<a name="gnutls_005fprotocol_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005fprotocol_005fget_005fversion"></a>Function: <em>gnutls_protocol_t</em> <strong>gnutls_protocol_get_version</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get TLS version, a <code>gnutls_protocol_t</code> value.
</p>
<p><strong>Returns:</strong> The version of the currently used protocol.
</p></dd></dl>
<a name="gnutls_005fprotocol_005flist-1"></a>
<h4 class="subheading">gnutls_protocol_list</h4>
<a name="gnutls_005fprotocol_005flist"></a><dl>
<dt><a name="index-gnutls_005fprotocol_005flist"></a>Function: <em>const gnutls_protocol_t *</em> <strong>gnutls_protocol_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc.
</p>
<p>This function is not thread safe.
</p>
<p><strong>Returns:</strong> a (0)-terminated list of <code>gnutls_protocol_t</code> integers
indicating the available protocols.
</p></dd></dl>
<a name="gnutls_005fpsk_005fallocate_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_psk_allocate_client_credentials</h4>
<a name="gnutls_005fpsk_005fallocate_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fallocate_005fclient_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_psk_allocate_client_credentials</strong> <em>(gnutls_psk_client_credentials_t * <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a pointer to a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fpsk_005fallocate_005fserver_005fcredentials-1"></a>
<h4 class="subheading">gnutls_psk_allocate_server_credentials</h4>
<a name="gnutls_005fpsk_005fallocate_005fserver_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fallocate_005fserver_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_psk_allocate_server_credentials</strong> <em>(gnutls_psk_server_credentials_t * <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a pointer to a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fpsk_005fclient_005fget_005fhint-1"></a>
<h4 class="subheading">gnutls_psk_client_get_hint</h4>
<a name="gnutls_005fpsk_005fclient_005fget_005fhint"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fclient_005fget_005fhint"></a>Function: <em>const char *</em> <strong>gnutls_psk_client_get_hint</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>The PSK identity hint may give the client help in deciding which
username to use. This should only be called in case of PSK
authentication and in case of a client.
</p>
<p><strong>Returns:</strong> the identity hint of the peer, or <code>NULL</code> in case of an error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fpsk_005ffree_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_psk_free_client_credentials</h4>
<a name="gnutls_005fpsk_005ffree_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fpsk_005ffree_005fclient_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_psk_free_client_credentials</strong> <em>(gnutls_psk_client_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_psk_client_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p></dd></dl>
<a name="gnutls_005fpsk_005ffree_005fserver_005fcredentials-1"></a>
<h4 class="subheading">gnutls_psk_free_server_credentials</h4>
<a name="gnutls_005fpsk_005ffree_005fserver_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fpsk_005ffree_005fserver_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_psk_free_server_credentials</strong> <em>(gnutls_psk_server_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
</p></dd></dl>
<a name="gnutls_005fpsk_005fserver_005fget_005fusername-1"></a>
<h4 class="subheading">gnutls_psk_server_get_username</h4>
<a name="gnutls_005fpsk_005fserver_005fget_005fusername"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fserver_005fget_005fusername"></a>Function: <em>const char *</em> <strong>gnutls_psk_server_get_username</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>This should only be called in case of PSK authentication and in
case of a server.
</p>
<p><strong>Returns:</strong> the username of the peer, or <code>NULL</code> in case of an error.
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_psk_set_client_credentials</h4>
<a name="gnutls_005fpsk_005fset_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fclient_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_psk_set_client_credentials</strong> <em>(gnutls_psk_client_credentials_t <var>res</var>, const char * <var>username</var>, const gnutls_datum_t * <var>key</var>, gnutls_psk_key_flags <var>flags</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_psk_client_credentials_t</code> structure.
</p>
<p><var>username</var>: is the user’s zero-terminated userid
</p>
<p><var>key</var>: is the user’s key
</p>
<p><var>flags</var>: indicate the format of the key, either
<code>GNUTLS_PSK_KEY_RAW</code> or <code>GNUTLS_PSK_KEY_HEX</code> .
</p>
<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 format (without the
0x prefix).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction-1"></a>
<h4 class="subheading">gnutls_psk_set_client_credentials_function</h4>
<a name="gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_psk_set_client_credentials_function</strong> <em>(gnutls_psk_client_credentials_t <var>cred</var>, gnutls_psk_client_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<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_t* key);
</p>
<p>The <code>username</code> and <code>key</code> ->data 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>
<p>The callback function will be called once per handshake.
</p>
<p>The callback function should return 0 on success.
-1 indicates an error.
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fparams_005ffunction-1"></a>
<h4 class="subheading">gnutls_psk_set_params_function</h4>
<a name="gnutls_005fpsk_005fset_005fparams_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fparams_005ffunction"></a>Function: <em>void</em> <strong>gnutls_psk_set_params_function</strong> <em>(gnutls_psk_server_credentials_t <var>res</var>, gnutls_params_function * <var>func</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_psk_server_credentials_t structure
</p>
<p><var>func</var>: is the function to be called
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile-1"></a>
<h4 class="subheading">gnutls_psk_set_server_credentials_file</h4>
<a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile-1"></a>Function: <em>int</em> <strong>gnutls_psk_set_server_credentials_file</strong> <em>(gnutls_psk_server_credentials_t <var>res</var>, const char * <var>password_file</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p><var>password_file</var>: is the PSK password file (passwd.psk)
</p>
<p>This function sets the password file, in a
<code>gnutls_psk_server_credentials_t</code> structure. This password file
holds usernames and keys and will be used for PSK authentication.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction-1"></a>
<h4 class="subheading">gnutls_psk_set_server_credentials_function</h4>
<a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction"></a>Function: <em>void</em> <strong>gnutls_psk_set_server_credentials_function</strong> <em>(gnutls_psk_server_credentials_t <var>cred</var>, gnutls_psk_server_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<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>
<p><code>username</code> contains the actual username.
The <code>key</code> must be filled in using the <code>gnutls_malloc()</code> .
</p>
<p>In case the callback returned a negative number then gnutls will
assume that the username does not exist.
</p>
<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></dd></dl>
<a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005fhint-1"></a>
<h4 class="subheading">gnutls_psk_set_server_credentials_hint</h4>
<a name="gnutls_005fpsk_005fset_005fserver_005fcredentials_005fhint"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005fhint"></a>Function: <em>int</em> <strong>gnutls_psk_set_server_credentials_hint</strong> <em>(gnutls_psk_server_credentials_t <var>res</var>, const char * <var>hint</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_psk_server_credentials_t</code> structure.
</p>
<p><var>hint</var>: is the PSK identity hint string
</p>
<p>This function sets the identity hint, in a
<code>gnutls_psk_server_credentials_t</code> structure. This hint is sent to
the client to help it chose a good PSK credential (i.e., username
and password).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fserver_005fdh_005fparams-1"></a>
<h4 class="subheading">gnutls_psk_set_server_dh_params</h4>
<a name="gnutls_005fpsk_005fset_005fserver_005fdh_005fparams"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fserver_005fdh_005fparams"></a>Function: <em>void</em> <strong>gnutls_psk_set_server_dh_params</strong> <em>(gnutls_psk_server_credentials_t <var>res</var>, gnutls_dh_params_t <var>dh_params</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_psk_server_credentials_t structure
</p>
<p><var>dh_params</var>: is a structure that holds Diffie-Hellman parameters.
</p>
<p>This function will set the Diffie-Hellman parameters for an
anonymous server to use. These parameters will be used in
Diffie-Hellman exchange with PSK cipher suites.
</p></dd></dl>
<a name="gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction-1"></a>
<h4 class="subheading">gnutls_psk_set_server_params_function</h4>
<a name="gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction"></a>Function: <em>void</em> <strong>gnutls_psk_set_server_params_function</strong> <em>(gnutls_psk_server_credentials_t <var>res</var>, gnutls_params_function * <var>func</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure
</p>
<p><var>func</var>: is the function to be called
</p>
<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 <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p></dd></dl>
<a name="gnutls_005frandom_005fart-1"></a>
<h4 class="subheading">gnutls_random_art</h4>
<a name="gnutls_005frandom_005fart"></a><dl>
<dt><a name="index-gnutls_005frandom_005fart"></a>Function: <em>int</em> <strong>gnutls_random_art</strong> <em>(gnutls_random_art_t <var>type</var>, const char* <var>key_type</var>, unsigned int <var>key_size</var>, void * <var>fpr</var>, size_t <var>fpr_size</var>, gnutls_datum_t* <var>art</var>)</em></dt>
<dd><p><var>type</var>: The type of the random art
</p>
<p><var>key_type</var>: The type of the key (RSA, DSA etc.)
</p>
<p><var>key_size</var>: The size of the key in bits
</p>
<p><var>fpr</var>: The fingerprint of the key
</p>
<p><var>fpr_size</var>: The size of the fingerprint
</p>
<p><var>art</var>: The returned random art
</p>
<p>This function will convert a given fingerprint to an "artistic"
image. The returned image is allocated using <code>gnutls_malloc()</code>
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005frange_005fsplit-1"></a>
<h4 class="subheading">gnutls_range_split</h4>
<a name="gnutls_005frange_005fsplit"></a><dl>
<dt><a name="index-gnutls_005frange_005fsplit"></a>Function: <em>int</em> <strong>gnutls_range_split</strong> <em>(gnutls_session_t <var>session</var>, const gnutls_range_st * <var>orig</var>, gnutls_range_st * <var>next</var>, gnutls_range_st * <var>remainder</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure
</p>
<p><var>orig</var>: is the original range provided by the user
</p>
<p><var>next</var>: is the returned range that can be conveyed in a TLS record
</p>
<p><var>remainder</var>: is the returned remaining range
</p>
<p>This function should be used when it is required to hide the length
of very long data that cannot be directly provided to <code>gnutls_record_send_range()</code> .
In that case this function should be called with the desired length
hiding range in <code>orig</code> . The returned <code>next</code> value should then be used in
the next call to <code>gnutls_record_send_range()</code> with the partial data.
That process should be repeated until <code>remainder</code> is (0,0).
</p>
<p><strong>Returns:</strong> 0 in case splitting succeeds, non zero in case of error.
Note that <code>orig</code> is not changed, while the values of <code>next</code> and <code>remainder</code> are modified to store the resulting values.
</p></dd></dl>
<a name="gnutls_005frecord_005fcan_005fuse_005flength_005fhiding-1"></a>
<h4 class="subheading">gnutls_record_can_use_length_hiding</h4>
<a name="gnutls_005frecord_005fcan_005fuse_005flength_005fhiding"></a><dl>
<dt><a name="index-gnutls_005frecord_005fcan_005fuse_005flength_005fhiding"></a>Function: <em>int</em> <strong>gnutls_record_can_use_length_hiding</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Returns true (1) if the current session supports length-hiding
padding, false (0) if the current session does not. Returns
a negative value in case of error.
If the session supports length-hiding padding, you can
invoke <code>gnutls_range_send_message()</code> to send a message whose
length is hidden in the given range. If the session does not
support length hiding padding, you can use the standard
<code>gnutls_record_send()</code> function, or <code>gnutls_range_send_message()</code>
making sure that the range is the same as the length of the
message you are trying to send.
</p></dd></dl>
<a name="gnutls_005frecord_005fcheck_005fpending-1"></a>
<h4 class="subheading">gnutls_record_check_pending</h4>
<a name="gnutls_005frecord_005fcheck_005fpending"></a><dl>
<dt><a name="index-gnutls_005frecord_005fcheck_005fpending-1"></a>Function: <em>size_t</em> <strong>gnutls_record_check_pending</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function checks if there are unread data
in the gnutls buffers. If the return value is
non-zero the next call to <code>gnutls_record_recv()</code>
is guarranteed not to block.
</p>
<p><strong>Returns:</strong> Returns the size of the data or zero.
</p></dd></dl>
<a name="gnutls_005frecord_005fcork-1"></a>
<h4 class="subheading">gnutls_record_cork</h4>
<a name="gnutls_005frecord_005fcork"></a><dl>
<dt><a name="index-gnutls_005frecord_005fcork-1"></a>Function: <em>void</em> <strong>gnutls_record_cork</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>If called <code>gnutls_record_send()</code> will no longer send partial records.
All queued records will be sent when <code>gnutls_uncork()</code> is called, or
when the maximum record size is reached.
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>
<a name="gnutls_005frecord_005fdisable_005fpadding-1"></a>
<h4 class="subheading">gnutls_record_disable_padding</h4>
<a name="gnutls_005frecord_005fdisable_005fpadding"></a><dl>
<dt><a name="index-gnutls_005frecord_005fdisable_005fpadding"></a>Function: <em>void</em> <strong>gnutls_record_disable_padding</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Used to disabled padding in TLS 1.0 and above. Normally you do not
need to use this function, but there are buggy clients that
complain if a server pads the encrypted data. This of course will
disable protection against statistical attacks on the data.
</p>
<p>This functions is defunt since 3.1.7. Random padding is disabled
by default unless requested using <code>gnutls_range_send_message()</code> .
</p></dd></dl>
<a name="gnutls_005frecord_005fget_005fdirection-1"></a>
<h4 class="subheading">gnutls_record_get_direction</h4>
<a name="gnutls_005frecord_005fget_005fdirection"></a><dl>
<dt><a name="index-gnutls_005frecord_005fget_005fdirection-1"></a>Function: <em>int</em> <strong>gnutls_record_get_direction</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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 <code>GNUTLS_E_INTERRUPTED</code> or
<code>GNUTLS_E_AGAIN</code> . 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>
<p><strong>Returns:</strong> 0 if trying to read data, 1 if trying to write data.
</p></dd></dl>
<a name="gnutls_005frecord_005fget_005fmax_005fsize-1"></a>
<h4 class="subheading">gnutls_record_get_max_size</h4>
<a name="gnutls_005frecord_005fget_005fmax_005fsize"></a><dl>
<dt><a name="index-gnutls_005frecord_005fget_005fmax_005fsize"></a>Function: <em>size_t</em> <strong>gnutls_record_get_max_size</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get the record size. The maximum record size is negotiated by the
client after the first handshake message.
</p>
<p><strong>Returns:</strong> The maximum record packet size in this connection.
</p></dd></dl>
<a name="gnutls_005frecord_005frecv-1"></a>
<h4 class="subheading">gnutls_record_recv</h4>
<a name="gnutls_005frecord_005frecv"></a><dl>
<dt><a name="index-gnutls_005frecord_005frecv-1"></a>Function: <em>ssize_t</em> <strong>gnutls_record_recv</strong> <em>(gnutls_session_t <var>session</var>, void * <var>data</var>, size_t <var>data_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: the buffer that the data will be read into
</p>
<p><var>data_size</var>: the number of requested bytes
</p>
<p>This function has the similar semantics with <code>recv()</code> . The only
difference is that it accepts a GnuTLS session, and uses different
error codes.
In the special case that a server requests a renegotiation, the
client may receive an error code of <code>GNUTLS_E_REHANDSHAKE</code> . This
message may be simply ignored, replied with an alert
<code>GNUTLS_A_NO_RENEGOTIATION</code> , or replied with a new handshake,
depending on the client’s will.
If <code>EINTR</code> is returned by the internal push function (the default
is <code>recv()</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 to get the data. See also
<code>gnutls_record_get_direction()</code> .
A server may also receive <code>GNUTLS_E_REHANDSHAKE</code> when a client has
initiated a handshake. In that case the server can only initiate a
handshake or terminate the connection.
</p>
<p><strong>Returns:</strong> The number of bytes received and zero on EOF (for stream
connections). A negative error code is returned in case of an error.
The number of bytes received might be less than the requested <code>data_size</code> .
</p></dd></dl>
<a name="gnutls_005frecord_005frecv_005fseq-1"></a>
<h4 class="subheading">gnutls_record_recv_seq</h4>
<a name="gnutls_005frecord_005frecv_005fseq"></a><dl>
<dt><a name="index-gnutls_005frecord_005frecv_005fseq-1"></a>Function: <em>ssize_t</em> <strong>gnutls_record_recv_seq</strong> <em>(gnutls_session_t <var>session</var>, void * <var>data</var>, size_t <var>data_size</var>, unsigned char * <var>seq</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: the buffer that the data will be read into
</p>
<p><var>data_size</var>: the number of requested bytes
</p>
<p><var>seq</var>: is the packet’s 64-bit sequence number. Should have space for 8 bytes.
</p>
<p>This function is the same as <code>gnutls_record_recv()</code> , except that
it returns in addition to data, the sequence number of the data.
This is useful in DTLS where record packets might be received
out-of-order. The returned 8-byte sequence number is an
integer in big-endian format and should be
treated as a unique message identification.
</p>
<p><strong>Returns:</strong> 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>data_size</code> .
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005frecord_005fsend-1"></a>
<h4 class="subheading">gnutls_record_send</h4>
<a name="gnutls_005frecord_005fsend"></a><dl>
<dt><a name="index-gnutls_005frecord_005fsend-1"></a>Function: <em>ssize_t</em> <strong>gnutls_record_send</strong> <em>(gnutls_session_t <var>session</var>, const void * <var>data</var>, size_t <var>data_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: contains the data to send
</p>
<p><var>data_size</var>: is the length of the data
</p>
<p>This function has the similar semantics with <code>send()</code> . The only
difference is that it accepts a GnuTLS session, and uses different
error codes.
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.
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> . The errno value EMSGSIZE
maps to <code>GNUTLS_E_LARGE_PACKET</code> .
</p>
<p><strong>Returns:</strong> The number of bytes sent, or a negative error code. The
number of bytes sent might be less than <code>data_size</code> . The maximum
number of bytes this function can send in a single call depends
on the negotiated maximum record size.
</p></dd></dl>
<a name="gnutls_005frecord_005fsend_005frange-1"></a>
<h4 class="subheading">gnutls_record_send_range</h4>
<a name="gnutls_005frecord_005fsend_005frange"></a><dl>
<dt><a name="index-gnutls_005frecord_005fsend_005frange"></a>Function: <em>ssize_t</em> <strong>gnutls_record_send_range</strong> <em>(gnutls_session_t <var>session</var>, const void * <var>data</var>, size_t <var>data_size</var>, const gnutls_range_st * <var>range</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: contains the data to send.
</p>
<p><var>data_size</var>: is the length of the data.
</p>
<p><var>range</var>: is the range of lengths in which the real data length must be hidden.
</p>
<p>This function operates like <code>gnutls_record_send()</code> but, while
<code>gnutls_record_send()</code> adds minimal padding to each TLS record,
this function uses the TLS extra-padding feature to conceal the real
data size within the range of lengths provided.
Some TLS sessions do not support extra padding (e.g. stream ciphers in standard
TLS or SSL3 sessions). To know whether the current session supports extra
padding, and hence length hiding, use the <code>gnutls_record_can_use_length_hiding()</code>
function.
</p>
<p><strong>Note:</strong> This function currently is only limited to blocking sockets.
</p>
<p><strong>Returns:</strong> The number of bytes sent (that is data_size in a successful invocation),
or a negative error code.
</p></dd></dl>
<a name="gnutls_005frecord_005fset_005fmax_005fempty_005frecords-1"></a>
<h4 class="subheading">gnutls_record_set_max_empty_records</h4>
<a name="gnutls_005frecord_005fset_005fmax_005fempty_005frecords"></a><dl>
<dt><a name="index-gnutls_005frecord_005fset_005fmax_005fempty_005frecords"></a>Function: <em>void</em> <strong>gnutls_record_set_max_empty_records</strong> <em>(gnutls_session_t <var>session</var>, const unsigned int <var>i</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>i</var>: is the desired value of maximum empty records that can be accepted in a row.
</p>
<p>Used to set the maximum number of empty fragments that can be accepted
in a row. Accepting many empty fragments is useful for receiving length-hidden
content, where empty fragments filled with pad are sent to hide the real
length of a message. However, a malicious peer could send empty fragments to
mount a DoS attack, so as a safety measure, a maximum number of empty fragments
is accepted by default. If you know your application must accept a given number
of empty fragments in a row, you can use this function to set the desired value.
</p></dd></dl>
<a name="gnutls_005frecord_005fset_005fmax_005fsize-1"></a>
<h4 class="subheading">gnutls_record_set_max_size</h4>
<a name="gnutls_005frecord_005fset_005fmax_005fsize"></a><dl>
<dt><a name="index-gnutls_005frecord_005fset_005fmax_005fsize"></a>Function: <em>ssize_t</em> <strong>gnutls_record_set_max_size</strong> <em>(gnutls_session_t <var>session</var>, size_t <var>size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>size</var>: is the new size
</p>
<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>
<p>Acceptable values are 512(=2^9), 1024(=2^10), 2048(=2^11) and
4096(=2^12). The requested record size does get in effect
immediately only while sending data. The receive part will take
effect after a successful handshake.
</p>
<p>This function uses a TLS extension called ’max record size’. Not
all TLS implementations use or even understand this extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005frecord_005fset_005ftimeout-1"></a>
<h4 class="subheading">gnutls_record_set_timeout</h4>
<a name="gnutls_005frecord_005fset_005ftimeout"></a><dl>
<dt><a name="index-gnutls_005frecord_005fset_005ftimeout"></a>Function: <em>void</em> <strong>gnutls_record_set_timeout</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>ms</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>ms</var>: is a timeout value in milliseconds
</p>
<p>This function sets the receive timeout for the record layer
to the provided value. Use an <code>ms</code> value of zero to disable
timeout (the default).
</p>
<p>Note that in order for the timeout to be enforced
<code>gnutls_transport_set_pull_timeout_function()</code> must be set
(it is set by default in most systems).
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>
<a name="gnutls_005frecord_005funcork-1"></a>
<h4 class="subheading">gnutls_record_uncork</h4>
<a name="gnutls_005frecord_005funcork"></a><dl>
<dt><a name="index-gnutls_005frecord_005funcork-1"></a>Function: <em>int</em> <strong>gnutls_record_uncork</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>flags</var>: Could be zero or <code>GNUTLS_RECORD_WAIT</code>
</p>
<p>This resets the effect of <code>gnutls_cork()</code> , and flushes any pending
data. If the <code>GNUTLS_RECORD_WAIT</code> flag is specified then this
function will block until the data is sent or a fatal error
occurs (i.e., the function will retry on <code>GNUTLS_E_AGAIN</code> and
<code>GNUTLS_E_INTERRUPTED</code> ).
</p>
<p><strong>Returns:</strong> On success the number of transmitted data is returned, or
otherwise a negative error code.
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>
<a name="gnutls_005frehandshake-1"></a>
<h4 class="subheading">gnutls_rehandshake</h4>
<a name="gnutls_005frehandshake"></a><dl>
<dt><a name="index-gnutls_005frehandshake"></a>Function: <em>int</em> <strong>gnutls_rehandshake</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will renegotiate security parameters with the
client. This should only be called in case of a server.
</p>
<p>This message informs the peer that we want to renegotiate
parameters (perform a handshake).
</p>
<p>If this function succeeds (returns 0), you must call the
<code>gnutls_handshake()</code> function in order to negotiate the new
parameters.
</p>
<p>Since TLS is full duplex some application data might have been
sent during peer’s processing of this message. In that case
one should call <code>gnutls_record_recv()</code> until GNUTLS_E_REHANDSHAKE
is returned to clear any pending data. Care must be taken if
rehandshake is mandatory to terminate if it does not start after
some threshold.
</p>
<p>If the client does not wish to renegotiate parameters he will
should with an alert message, thus the return code will be
<code>GNUTLS_E_WARNING_ALERT_RECEIVED</code> and the alert will be
<code>GNUTLS_A_NO_RENEGOTIATION</code> . A client may also choose to ignore
this message.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p></dd></dl>
<a name="gnutls_005fsafe_005frenegotiation_005fstatus-1"></a>
<h4 class="subheading">gnutls_safe_renegotiation_status</h4>
<a name="gnutls_005fsafe_005frenegotiation_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fsafe_005frenegotiation_005fstatus"></a>Function: <em>int</em> <strong>gnutls_safe_renegotiation_status</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Can be used to check whether safe renegotiation is being used
in the current session.
</p>
<p><strong>Returns:</strong> 0 when safe renegotiation is not used and non (0) when
safe renegotiation is used.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fsec_005fparam_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_sec_param_get_name</h4>
<a name="gnutls_005fsec_005fparam_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fsec_005fparam_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_sec_param_get_name</strong> <em>(gnutls_sec_param_t <var>param</var>)</em></dt>
<dd><p><var>param</var>: is a security parameter
</p>
<p>Convert a <code>gnutls_sec_param_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a pointer to a string that contains the name of the
specified security level, or <code>NULL</code> .
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fsec_005fparam_005fto_005fpk_005fbits-1"></a>
<h4 class="subheading">gnutls_sec_param_to_pk_bits</h4>
<a name="gnutls_005fsec_005fparam_005fto_005fpk_005fbits"></a><dl>
<dt><a name="index-gnutls_005fsec_005fparam_005fto_005fpk_005fbits-1"></a>Function: <em>unsigned int</em> <strong>gnutls_sec_param_to_pk_bits</strong> <em>(gnutls_pk_algorithm_t <var>algo</var>, gnutls_sec_param_t <var>param</var>)</em></dt>
<dd><p><var>algo</var>: is a public key algorithm
</p>
<p><var>param</var>: is a security parameter
</p>
<p>When generating private and public key pairs a difficult question
is which size of "bits" the modulus will be in RSA and the group size
in DSA. The easy answer is 1024, which is also wrong. This function
will convert a human understandable security parameter to an
appropriate size for the specific algorithm.
</p>
<p><strong>Returns:</strong> The number of bits, or (0).
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fserver_005fname_005fget-1"></a>
<h4 class="subheading">gnutls_server_name_get</h4>
<a name="gnutls_005fserver_005fname_005fget"></a><dl>
<dt><a name="index-gnutls_005fserver_005fname_005fget"></a>Function: <em>int</em> <strong>gnutls_server_name_get</strong> <em>(gnutls_session_t <var>session</var>, void * <var>data</var>, size_t * <var>data_length</var>, unsigned int * <var>type</var>, unsigned int <var>indx</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: will hold the data
</p>
<p><var>data_length</var>: will hold the data length. Must hold the maximum size of data.
</p>
<p><var>type</var>: will hold the server name indicator type
</p>
<p><var>indx</var>: is the index of the server_name
</p>
<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>
<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>
<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>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fserver_005fname_005fset-1"></a>
<h4 class="subheading">gnutls_server_name_set</h4>
<a name="gnutls_005fserver_005fname_005fset"></a><dl>
<dt><a name="index-gnutls_005fserver_005fname_005fset"></a>Function: <em>int</em> <strong>gnutls_server_name_set</strong> <em>(gnutls_session_t <var>session</var>, gnutls_server_name_type_t <var>type</var>, const void * <var>name</var>, size_t <var>name_length</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>type</var>: specifies the indicator type
</p>
<p><var>name</var>: is a string that contains the server name.
</p>
<p><var>name_length</var>: holds the length of name
</p>
<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>
<p>The value of <code>name</code> depends on the <code>type</code> type. In case of
<code>GNUTLS_NAME_DNS</code> , an ASCII (0)-terminated domain name string,
without the trailing dot, is expected. IPv4 or IPv6 addresses are
not permitted.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fsession_005fchannel_005fbinding-1"></a>
<h4 class="subheading">gnutls_session_channel_binding</h4>
<a name="gnutls_005fsession_005fchannel_005fbinding"></a><dl>
<dt><a name="index-gnutls_005fsession_005fchannel_005fbinding"></a>Function: <em>int</em> <strong>gnutls_session_channel_binding</strong> <em>(gnutls_session_t <var>session</var>, gnutls_channel_binding_t <var>cbtype</var>, gnutls_datum_t * <var>cb</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>cbtype</var>: an <code>gnutls_channel_binding_t</code> enumeration type
</p>
<p><var>cb</var>: output buffer array with data
</p>
<p>Extract given channel binding data of the <code>cbtype</code> (e.g.,
<code>GNUTLS_CB_TLS_UNIQUE</code> ) type.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success,
<code>GNUTLS_E_UNIMPLEMENTED_FEATURE</code> if the <code>cbtype</code> is unsupported,
<code>GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE</code> if the data is not
currently available, or an error code.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fsession_005fenable_005fcompatibility_005fmode-1"></a>
<h4 class="subheading">gnutls_session_enable_compatibility_mode</h4>
<a name="gnutls_005fsession_005fenable_005fcompatibility_005fmode"></a><dl>
<dt><a name="index-gnutls_005fsession_005fenable_005fcompatibility_005fmode"></a>Function: <em>void</em> <strong>gnutls_session_enable_compatibility_mode</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function can be used to disable certain (security) features in
TLS in order to maintain maximum compatibility with buggy
clients. Because several trade-offs with security are enabled,
if required they will be reported through the audit subsystem.
</p>
<p>Normally only servers that require maximum compatibility with
everything out there, need to call this function.
</p></dd></dl>
<a name="gnutls_005fsession_005fforce_005fvalid-1"></a>
<h4 class="subheading">gnutls_session_force_valid</h4>
<a name="gnutls_005fsession_005fforce_005fvalid"></a><dl>
<dt><a name="index-gnutls_005fsession_005fforce_005fvalid"></a>Function: <em>void</em> <strong>gnutls_session_force_valid</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Clears the invalid flag in a session. That means
that sessions were corrupt or invalid data were received
can be re-used. Use only when debugging or experimenting
with the TLS protocol. Should not be used in typical
applications.
</p></dd></dl>
<a name="gnutls_005fsession_005fget_005fdata-1"></a>
<h4 class="subheading">gnutls_session_get_data</h4>
<a name="gnutls_005fsession_005fget_005fdata"></a><dl>
<dt><a name="index-gnutls_005fsession_005fget_005fdata"></a>Function: <em>int</em> <strong>gnutls_session_get_data</strong> <em>(gnutls_session_t <var>session</var>, void * <var>session_data</var>, size_t * <var>session_data_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>session_data</var>: is a pointer to space to hold the session.
</p>
<p><var>session_data_size</var>: is the session_data’s size, or it will be set by the function.
</p>
<p>Returns all session parameters needed to be stored to support resumption.
The client should call this, and store the returned session data. A session
may be resumed later by calling <code>gnutls_session_set_data()</code> .
This function must be called after a successful handshake.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fsession_005fget_005fdata2-1"></a>
<h4 class="subheading">gnutls_session_get_data2</h4>
<a name="gnutls_005fsession_005fget_005fdata2"></a><dl>
<dt><a name="index-gnutls_005fsession_005fget_005fdata2"></a>Function: <em>int</em> <strong>gnutls_session_get_data2</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>data</var>: is a pointer to a datum that will hold the session.
</p>
<p>Returns all session parameters needed to be stored to support resumption.
The client should call this, and store the returned session data. A session
may be resumed later by calling <code>gnutls_session_set_data()</code> .
This function must be called after a successful handshake.
The returned <code>data</code> are allocated and must be released using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fsession_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_session_get_id</h4>
<a name="gnutls_005fsession_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fsession_005fget_005fid"></a>Function: <em>int</em> <strong>gnutls_session_get_id</strong> <em>(gnutls_session_t <var>session</var>, void * <var>session_id</var>, size_t * <var>session_id_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>session_id</var>: is a pointer to space to hold the session id.
</p>
<p><var>session_id_size</var>: initially should contain the maximum <code>session_id</code> size and will be updated.
</p>
<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. That is because resumed sessions share the same session ID
with the original session.
</p>
<p>The session ID is selected 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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fsession_005fget_005fid2-1"></a>
<h4 class="subheading">gnutls_session_get_id2</h4>
<a name="gnutls_005fsession_005fget_005fid2"></a><dl>
<dt><a name="index-gnutls_005fsession_005fget_005fid2"></a>Function: <em>int</em> <strong>gnutls_session_get_id2</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>session_id</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>session_id</var>: will point to the session ID.
</p>
<p>Returns the current session ID. The returned data should be
treated as constant.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p>
<p><strong>Since:</strong> 3.1.4
</p></dd></dl>
<a name="gnutls_005fsession_005fget_005fptr-1"></a>
<h4 class="subheading">gnutls_session_get_ptr</h4>
<a name="gnutls_005fsession_005fget_005fptr"></a><dl>
<dt><a name="index-gnutls_005fsession_005fget_005fptr"></a>Function: <em>void *</em> <strong>gnutls_session_get_ptr</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Get user pointer for session. Useful in callbacks. This is the
pointer set with <code>gnutls_session_set_ptr()</code> .
</p>
<p><strong>Returns:</strong> the user given pointer from the session structure, or
<code>NULL</code> if it was never set.
</p></dd></dl>
<a name="gnutls_005fsession_005fget_005frandom-1"></a>
<h4 class="subheading">gnutls_session_get_random</h4>
<a name="gnutls_005fsession_005fget_005frandom"></a><dl>
<dt><a name="index-gnutls_005fsession_005fget_005frandom"></a>Function: <em>void</em> <strong>gnutls_session_get_random</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t* <var>client</var>, gnutls_datum_t* <var>server</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>client</var>: the client part of the random
</p>
<p><var>server</var>: the server part of the random
</p>
<p>This function returns pointers to the client and server
random fields used in the TLS handshake. The pointers are
not to be modified or deallocated.
</p>
<p>If a client random value has not yet been established, the output
will be garbage.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fsession_005fis_005fresumed-1"></a>
<h4 class="subheading">gnutls_session_is_resumed</h4>
<a name="gnutls_005fsession_005fis_005fresumed"></a><dl>
<dt><a name="index-gnutls_005fsession_005fis_005fresumed-1"></a>Function: <em>int</em> <strong>gnutls_session_is_resumed</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Check whether session is resumed or not.
</p>
<p><strong>Returns:</strong> non zero if this session is resumed, or a zero if this is
a new session.
</p></dd></dl>
<a name="gnutls_005fsession_005fresumption_005frequested-1"></a>
<h4 class="subheading">gnutls_session_resumption_requested</h4>
<a name="gnutls_005fsession_005fresumption_005frequested"></a><dl>
<dt><a name="index-gnutls_005fsession_005fresumption_005frequested-1"></a>Function: <em>int</em> <strong>gnutls_session_resumption_requested</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Check whether the client has asked for session resumption.
This function is valid only on server side.
</p>
<p><strong>Returns:</strong> non zero if session resumption was asked, or a zero if not.
</p></dd></dl>
<a name="gnutls_005fsession_005fset_005fdata-1"></a>
<h4 class="subheading">gnutls_session_set_data</h4>
<a name="gnutls_005fsession_005fset_005fdata"></a><dl>
<dt><a name="index-gnutls_005fsession_005fset_005fdata"></a>Function: <em>int</em> <strong>gnutls_session_set_data</strong> <em>(gnutls_session_t <var>session</var>, const void * <var>session_data</var>, size_t <var>session_data_size</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>session_data</var>: is a pointer to space to hold the session.
</p>
<p><var>session_data_size</var>: is the session’s size
</p>
<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>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fsession_005fset_005fpremaster-1"></a>
<h4 class="subheading">gnutls_session_set_premaster</h4>
<a name="gnutls_005fsession_005fset_005fpremaster"></a><dl>
<dt><a name="index-gnutls_005fsession_005fset_005fpremaster"></a>Function: <em>int</em> <strong>gnutls_session_set_premaster</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>entity</var>, gnutls_protocol_t <var>version</var>, gnutls_kx_algorithm_t <var>kx</var>, gnutls_cipher_algorithm_t <var>cipher</var>, gnutls_mac_algorithm_t <var>mac</var>, gnutls_compression_method_t <var>comp</var>, const gnutls_datum_t* <var>master</var>, const gnutls_datum_t * <var>session_id</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>entity</var>: GNUTLS_SERVER or GNUTLS_CLIENT
</p>
<p><var>version</var>: the TLS protocol version
</p>
<p><var>kx</var>: the key exchange method
</p>
<p><var>cipher</var>: the cipher
</p>
<p><var>mac</var>: the MAC algorithm
</p>
<p><var>comp</var>: the compression method
</p>
<p><var>master</var>: the master key to use
</p>
<p><var>session_id</var>: the session identifier
</p>
<p>This function sets the premaster secret in a session. This is
a function intended for exceptional uses. Do not use this
function unless you are implementing a legacy protocol.
Use <code>gnutls_session_set_data()</code> instead.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005fsession_005fset_005fptr-1"></a>
<h4 class="subheading">gnutls_session_set_ptr</h4>
<a name="gnutls_005fsession_005fset_005fptr"></a><dl>
<dt><a name="index-gnutls_005fsession_005fset_005fptr"></a>Function: <em>void</em> <strong>gnutls_session_set_ptr</strong> <em>(gnutls_session_t <var>session</var>, void * <var>ptr</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>ptr</var>: is the user pointer
</p>
<p>This function will set (associate) the user given pointer <code>ptr</code> to
the session structure. This pointer can be accessed with
<code>gnutls_session_get_ptr()</code> .
</p></dd></dl>
<a name="gnutls_005fsession_005fticket_005fenable_005fclient-1"></a>
<h4 class="subheading">gnutls_session_ticket_enable_client</h4>
<a name="gnutls_005fsession_005fticket_005fenable_005fclient"></a><dl>
<dt><a name="index-gnutls_005fsession_005fticket_005fenable_005fclient"></a>Function: <em>int</em> <strong>gnutls_session_ticket_enable_client</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Request that the client should attempt session resumption using
SessionTicket.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fsession_005fticket_005fenable_005fserver-1"></a>
<h4 class="subheading">gnutls_session_ticket_enable_server</h4>
<a name="gnutls_005fsession_005fticket_005fenable_005fserver"></a><dl>
<dt><a name="index-gnutls_005fsession_005fticket_005fenable_005fserver-1"></a>Function: <em>int</em> <strong>gnutls_session_ticket_enable_server</strong> <em>(gnutls_session_t <var>session</var>, const gnutls_datum_t * <var>key</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>key</var>: key to encrypt session parameters.
</p>
<p>Request that the server should attempt session resumption using
SessionTicket. <code>key</code> must be initialized with
<code>gnutls_session_ticket_key_generate()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fsession_005fticket_005fkey_005fgenerate-1"></a>
<h4 class="subheading">gnutls_session_ticket_key_generate</h4>
<a name="gnutls_005fsession_005fticket_005fkey_005fgenerate"></a><dl>
<dt><a name="index-gnutls_005fsession_005fticket_005fkey_005fgenerate-1"></a>Function: <em>int</em> <strong>gnutls_session_ticket_key_generate</strong> <em>(gnutls_datum_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: is a pointer to a <code>gnutls_datum_t</code> which will contain a newly
created key.
</p>
<p>Generate a random key to encrypt security parameters within
SessionTicket.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fset_005fdefault_005fpriority-1"></a>
<h4 class="subheading">gnutls_set_default_priority</h4>
<a name="gnutls_005fset_005fdefault_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fset_005fdefault_005fpriority"></a>Function: <em>int</em> <strong>gnutls_set_default_priority</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Sets some default priority on the ciphers, key exchange methods,
macs and compression methods.
</p>
<p>This is the same as calling:
</p>
<p>gnutls_priority_set_direct (session, "NORMAL", NULL);
</p>
<p>This function is kept around for backwards compatibility, but
because of its wide use it is still fully supported. If you wish
to allow users to provide a string that specify which ciphers to
use (which is recommended), you should use
<code>gnutls_priority_set_direct()</code> or <code>gnutls_priority_set()</code> instead.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fsign_005falgorithm_005fget-1"></a>
<h4 class="subheading">gnutls_sign_algorithm_get</h4>
<a name="gnutls_005fsign_005falgorithm_005fget"></a><dl>
<dt><a name="index-gnutls_005fsign_005falgorithm_005fget"></a>Function: <em>int</em> <strong>gnutls_sign_algorithm_get</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Returns the signature algorithm that is (or will be) used in this
session to sign data.
</p>
<p><strong>Returns:</strong> The sign algorithm or <code>GNUTLS_SIGN_UNKNOWN</code> .
</p>
<p><strong>Since:</strong> 3.1.1
</p></dd></dl>
<a name="gnutls_005fsign_005falgorithm_005fget_005frequested-1"></a>
<h4 class="subheading">gnutls_sign_algorithm_get_requested</h4>
<a name="gnutls_005fsign_005falgorithm_005fget_005frequested"></a><dl>
<dt><a name="index-gnutls_005fsign_005falgorithm_005fget_005frequested"></a>Function: <em>int</em> <strong>gnutls_sign_algorithm_get_requested</strong> <em>(gnutls_session_t <var>session</var>, size_t <var>indx</var>, gnutls_sign_algorithm_t * <var>algo</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>indx</var>: is an index of the signature algorithm to return
</p>
<p><var>algo</var>: the returned certificate type will be stored there
</p>
<p>Returns the signature algorithm specified by index that was
requested by the peer. If the specified index has no data available
this function returns <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> . If
the negotiated TLS version does not support signature algorithms
then <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned even
for the first index. The first index is 0.
</p>
<p>This function is useful in the certificate callback functions
to assist in selecting the correct certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fsign_005fget_005fhash_005falgorithm-1"></a>
<h4 class="subheading">gnutls_sign_get_hash_algorithm</h4>
<a name="gnutls_005fsign_005fget_005fhash_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fsign_005fget_005fhash_005falgorithm"></a>Function: <em>gnutls_digest_algorithm_t</em> <strong>gnutls_sign_get_hash_algorithm</strong> <em>(gnutls_sign_algorithm_t <var>sign</var>)</em></dt>
<dd><p><var>sign</var>: is a signature algorithm
</p>
<p>This function returns the digest algorithm corresponding to
the given signature algorithms.
</p>
<p><strong>Since:</strong> 3.1.1
</p>
<p><strong>Returns:</strong> return a <code>gnutls_digest_algorithm_t</code> value, or <code>GNUTLS_DIG_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fsign_005fget_005fid-1"></a>
<h4 class="subheading">gnutls_sign_get_id</h4>
<a name="gnutls_005fsign_005fget_005fid"></a><dl>
<dt><a name="index-gnutls_005fsign_005fget_005fid"></a>Function: <em>gnutls_sign_algorithm_t</em> <strong>gnutls_sign_get_id</strong> <em>(const char * <var>name</var>)</em></dt>
<dd><p><var>name</var>: is a sign algorithm name
</p>
<p>The names are compared in a case insensitive way.
</p>
<p><strong>Returns:</strong> return a <code>gnutls_sign_algorithm_t</code> value corresponding to
the specified algorithm, or <code>GNUTLS_SIGN_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fsign_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_sign_get_name</h4>
<a name="gnutls_005fsign_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fsign_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_sign_get_name</strong> <em>(gnutls_sign_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a sign algorithm
</p>
<p>Convert a <code>gnutls_sign_algorithm_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified sign
algorithm, or <code>NULL</code> .
</p></dd></dl>
<a name="gnutls_005fsign_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_sign_get_pk_algorithm</h4>
<a name="gnutls_005fsign_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fsign_005fget_005fpk_005falgorithm"></a>Function: <em>gnutls_pk_algorithm_t</em> <strong>gnutls_sign_get_pk_algorithm</strong> <em>(gnutls_sign_algorithm_t <var>sign</var>)</em></dt>
<dd><p><var>sign</var>: is a signature algorithm
</p>
<p>This function returns the public key algorithm corresponding to
the given signature algorithms.
</p>
<p><strong>Since:</strong> 3.1.1
</p>
<p><strong>Returns:</strong> return a <code>gnutls_pk_algorithm_t</code> value, or <code>GNUTLS_PK_UNKNOWN</code> on error.
</p></dd></dl>
<a name="gnutls_005fsign_005fis_005fsecure-1"></a>
<h4 class="subheading">gnutls_sign_is_secure</h4>
<a name="gnutls_005fsign_005fis_005fsecure"></a><dl>
<dt><a name="index-gnutls_005fsign_005fis_005fsecure"></a>Function: <em>int</em> <strong>gnutls_sign_is_secure</strong> <em>(gnutls_sign_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is a sign algorithm
</p>
<p><strong>Returns:</strong> Non-zero if the provided signature algorithm is considered to be secure.
</p></dd></dl>
<a name="gnutls_005fsign_005flist-1"></a>
<h4 class="subheading">gnutls_sign_list</h4>
<a name="gnutls_005fsign_005flist"></a><dl>
<dt><a name="index-gnutls_005fsign_005flist"></a>Function: <em>const gnutls_sign_algorithm_t *</em> <strong>gnutls_sign_list</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>Get a list of supported public key signature algorithms.
</p>
<p><strong>Returns:</strong> a (0)-terminated list of <code>gnutls_sign_algorithm_t</code>
integers indicating the available ciphers.
</p></dd></dl>
<a name="gnutls_005fsrp_005fallocate_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_srp_allocate_client_credentials</h4>
<a name="gnutls_005fsrp_005fallocate_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fallocate_005fclient_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_srp_allocate_client_credentials</strong> <em>(gnutls_srp_client_credentials_t * <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a pointer to a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<a name="gnutls_005fsrp_005fallocate_005fserver_005fcredentials-1"></a>
<h4 class="subheading">gnutls_srp_allocate_server_credentials</h4>
<a name="gnutls_005fsrp_005fallocate_005fserver_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fallocate_005fserver_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_srp_allocate_server_credentials</strong> <em>(gnutls_srp_server_credentials_t * <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a pointer to a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<a name="gnutls_005fsrp_005fbase64_005fdecode-1"></a>
<h4 class="subheading">gnutls_srp_base64_decode</h4>
<a name="gnutls_005fsrp_005fbase64_005fdecode"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fbase64_005fdecode"></a>Function: <em>int</em> <strong>gnutls_srp_base64_decode</strong> <em>(const gnutls_datum_t * <var>b64_data</var>, char * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>b64_data</var>: contain the encoded data
</p>
<p><var>result</var>: the place where decoded data will be copied
</p>
<p><var>result_size</var>: holds the size of the result
</p>
<p>This function will decode the given encoded data, using the base64
encoding found in libsrp.
</p>
<p>Note that <code>b64_data</code> should be null terminated.
</p>
<p>Warning! This base64 encoding is not the "standard" encoding, so
do not use it for non-SRP purposes.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the buffer given is not
long enough, or 0 on success.
</p></dd></dl>
<a name="gnutls_005fsrp_005fbase64_005fdecode_005falloc-1"></a>
<h4 class="subheading">gnutls_srp_base64_decode_alloc</h4>
<a name="gnutls_005fsrp_005fbase64_005fdecode_005falloc"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fbase64_005fdecode_005falloc"></a>Function: <em>int</em> <strong>gnutls_srp_base64_decode_alloc</strong> <em>(const gnutls_datum_t * <var>b64_data</var>, gnutls_datum_t * <var>result</var>)</em></dt>
<dd><p><var>b64_data</var>: contains the encoded data
</p>
<p><var>result</var>: the place where decoded data lie
</p>
<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 as used in libsrp.
</p>
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p>
<p>Warning! This base64 encoding is not the "standard" encoding, so
do not use it for non-SRP purposes.
</p>
<p><strong>Returns:</strong> 0 on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fsrp_005fbase64_005fencode-1"></a>
<h4 class="subheading">gnutls_srp_base64_encode</h4>
<a name="gnutls_005fsrp_005fbase64_005fencode"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fbase64_005fencode"></a>Function: <em>int</em> <strong>gnutls_srp_base64_encode</strong> <em>(const gnutls_datum_t * <var>data</var>, char * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>data</var>: contain the raw data
</p>
<p><var>result</var>: the place where base64 data will be copied
</p>
<p><var>result_size</var>: holds the size of the result
</p>
<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>
<p>Warning! This base64 encoding is not the "standard" encoding, so
do not use it for non-SRP purposes.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the buffer given is not
long enough, or 0 on success.
</p></dd></dl>
<a name="gnutls_005fsrp_005fbase64_005fencode_005falloc-1"></a>
<h4 class="subheading">gnutls_srp_base64_encode_alloc</h4>
<a name="gnutls_005fsrp_005fbase64_005fencode_005falloc"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fbase64_005fencode_005falloc"></a>Function: <em>int</em> <strong>gnutls_srp_base64_encode_alloc</strong> <em>(const gnutls_datum_t * <var>data</var>, gnutls_datum_t * <var>result</var>)</em></dt>
<dd><p><var>data</var>: contains the raw data
</p>
<p><var>result</var>: will hold the newly allocated encoded data
</p>
<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>
<p>You should use <code>gnutls_free()</code> to free the returned data.
</p>
<p>Warning! This base64 encoding is not the "standard" encoding, so
do not use it for non-SRP purposes.
</p>
<p><strong>Returns:</strong> 0 on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fsrp_005ffree_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_srp_free_client_credentials</h4>
<a name="gnutls_005fsrp_005ffree_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fsrp_005ffree_005fclient_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_srp_free_client_credentials</strong> <em>(gnutls_srp_client_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_srp_client_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></dd></dl>
<a name="gnutls_005fsrp_005ffree_005fserver_005fcredentials-1"></a>
<h4 class="subheading">gnutls_srp_free_server_credentials</h4>
<a name="gnutls_005fsrp_005ffree_005fserver_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fsrp_005ffree_005fserver_005fcredentials"></a>Function: <em>void</em> <strong>gnutls_srp_free_server_credentials</strong> <em>(gnutls_srp_server_credentials_t <var>sc</var>)</em></dt>
<dd><p><var>sc</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p>This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
</p></dd></dl>
<a name="gnutls_005fsrp_005fserver_005fget_005fusername-1"></a>
<h4 class="subheading">gnutls_srp_server_get_username</h4>
<a name="gnutls_005fsrp_005fserver_005fget_005fusername"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fserver_005fget_005fusername"></a>Function: <em>const char *</em> <strong>gnutls_srp_server_get_username</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<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>
<p><strong>Returns:</strong> SRP username of the peer, or NULL in case of error.
</p></dd></dl>
<a name="gnutls_005fsrp_005fset_005fclient_005fcredentials-1"></a>
<h4 class="subheading">gnutls_srp_set_client_credentials</h4>
<a name="gnutls_005fsrp_005fset_005fclient_005fcredentials"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fclient_005fcredentials"></a>Function: <em>int</em> <strong>gnutls_srp_set_client_credentials</strong> <em>(gnutls_srp_client_credentials_t <var>res</var>, const char * <var>username</var>, const char * <var>password</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_srp_client_credentials_t</code> structure.
</p>
<p><var>username</var>: is the user’s userid
</p>
<p><var>password</var>: is the user’s password
</p>
<p>This function sets the username and password, in a
<code>gnutls_srp_client_credentials_t</code> 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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<a name="gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction-1"></a>
<h4 class="subheading">gnutls_srp_set_client_credentials_function</h4>
<a name="gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_srp_set_client_credentials_function</strong> <em>(gnutls_srp_client_credentials_t <var>cred</var>, gnutls_srp_client_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<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:
</p>
<p>int (*callback)(gnutls_session_t, char** username, char**password);
</p>
<p>The <code>username</code> and <code>password</code> must be allocated using
<code>gnutls_malloc()</code> . <code>username</code> and <code>password</code> should be ASCII strings
or UTF-8 strings prepared using the "SASLprep" profile of
"stringprep".
</p>
<p>The callback function will be called once per handshake before the
initial hello message is sent.
</p>
<p>The callback should not return a negative error code the second
time called, since the handshake procedure will be aborted.
</p>
<p>The callback function should return 0 on success.
-1 indicates an error.
</p></dd></dl>
<a name="gnutls_005fsrp_005fset_005fprime_005fbits-1"></a>
<h4 class="subheading">gnutls_srp_set_prime_bits</h4>
<a name="gnutls_005fsrp_005fset_005fprime_005fbits"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fprime_005fbits"></a>Function: <em>void</em> <strong>gnutls_srp_set_prime_bits</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>bits</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>bits</var>: is the number of bits
</p>
<p>This function sets the minimum accepted number of bits, for use in
an SRP key exchange. If zero, the default 2048 bits will be used.
</p>
<p>In the client side it sets the minimum accepted number of bits. If
a server sends a prime with less bits than that
<code>GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER</code> will be returned by the
handshake.
</p>
<p>This function has no effect in server side.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile-1"></a>
<h4 class="subheading">gnutls_srp_set_server_credentials_file</h4>
<a name="gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile-1"></a>Function: <em>int</em> <strong>gnutls_srp_set_server_credentials_file</strong> <em>(gnutls_srp_server_credentials_t <var>res</var>, const char * <var>password_file</var>, const char * <var>password_conf_file</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p><var>password_file</var>: is the SRP password file (tpasswd)
</p>
<p><var>password_conf_file</var>: is the SRP password conf file (tpasswd.conf)
</p>
<p>This function sets the password files, in a
<code>gnutls_srp_server_credentials_t</code> structure. Those password files
hold usernames and verifiers and will be used for SRP
authentication.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<a name="gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction-1"></a>
<h4 class="subheading">gnutls_srp_set_server_credentials_function</h4>
<a name="gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_srp_set_server_credentials_function</strong> <em>(gnutls_srp_server_credentials_t <var>cred</var>, gnutls_srp_server_credentials_function * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_srp_server_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<p>This function can be used to set a callback to retrieve the user’s
SRP credentials. The callback’s function form is:
</p>
<p>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>
<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 gnutls.h.
</p>
<p>In case the callback returned a negative number then gnutls will
assume that the username does not exist.
</p>
<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>
<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></dd></dl>
<a name="gnutls_005fsrp_005fverifier-1"></a>
<h4 class="subheading">gnutls_srp_verifier</h4>
<a name="gnutls_005fsrp_005fverifier"></a><dl>
<dt><a name="index-gnutls_005fsrp_005fverifier-1"></a>Function: <em>int</em> <strong>gnutls_srp_verifier</strong> <em>(const char * <var>username</var>, const char * <var>password</var>, const gnutls_datum_t * <var>salt</var>, const gnutls_datum_t * <var>generator</var>, const gnutls_datum_t * <var>prime</var>, gnutls_datum_t * <var>res</var>)</em></dt>
<dd><p><var>username</var>: is the user’s name
</p>
<p><var>password</var>: is the user’s password
</p>
<p><var>salt</var>: should be some randomly generated bytes
</p>
<p><var>generator</var>: is the generator of the group
</p>
<p><var>prime</var>: is the group’s prime
</p>
<p><var>res</var>: where the verifier will be stored.
</p>
<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/gnutls.h or may be generated.
</p>
<p>The verifier will be allocated with <code>gnutls_malloc</code> () and will be stored in
<code>res</code> using binary format.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or an
error code.
</p></dd></dl>
<a name="gnutls_005fsrtp_005fget_005fkeys-1"></a>
<h4 class="subheading">gnutls_srtp_get_keys</h4>
<a name="gnutls_005fsrtp_005fget_005fkeys"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fget_005fkeys-1"></a>Function: <em>int</em> <strong>gnutls_srtp_get_keys</strong> <em>(gnutls_session_t <var>session</var>, void * <var>key_material</var>, unsigned int <var>key_material_size</var>, gnutls_datum_t * <var>client_key</var>, gnutls_datum_t * <var>client_salt</var>, gnutls_datum_t * <var>server_key</var>, gnutls_datum_t * <var>server_salt</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>key_material</var>: Space to hold the generated key material
</p>
<p><var>key_material_size</var>: The maximum size of the key material
</p>
<p><var>client_key</var>: The master client write key, pointing inside the key material
</p>
<p><var>client_salt</var>: The master client write salt, pointing inside the key material
</p>
<p><var>server_key</var>: The master server write key, pointing inside the key material
</p>
<p><var>server_salt</var>: The master server write salt, pointing inside the key material
</p>
<p>This is a helper function to generate the keying material for SRTP.
It requires the space of the key material to be pre-allocated (should be at least
2x the maximum key size and salt size). The <code>client_key</code> , <code>client_salt</code> , <code>server_key</code> and <code>server_salt</code> are convenience datums that point inside the key material. They may
be <code>NULL</code> .
</p>
<p><strong>Returns:</strong> On success the size of the key material is returned,
otherwise, <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the buffer given is not
sufficient, or a negative error code.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fget_005fmki-1"></a>
<h4 class="subheading">gnutls_srtp_get_mki</h4>
<a name="gnutls_005fsrtp_005fget_005fmki"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fget_005fmki"></a>Function: <em>int</em> <strong>gnutls_srtp_get_mki</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>mki</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>mki</var>: will hold the MKI
</p>
<p>This function exports the negotiated Master Key Identifier,
received by the peer if any. The returned value in <code>mki</code> should be
treated as constant and valid only during the session’s lifetime.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fget_005fprofile_005fid-1"></a>
<h4 class="subheading">gnutls_srtp_get_profile_id</h4>
<a name="gnutls_005fsrtp_005fget_005fprofile_005fid"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fget_005fprofile_005fid"></a>Function: <em>int</em> <strong>gnutls_srtp_get_profile_id</strong> <em>(const char * <var>name</var>, gnutls_srtp_profile_t * <var>profile</var>)</em></dt>
<dd><p><var>name</var>: The name of the profile to look up
</p>
<p><var>profile</var>: Will hold the profile id
</p>
<p>This function allows you to look up a profile based on a string.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fget_005fprofile_005fname-1"></a>
<h4 class="subheading">gnutls_srtp_get_profile_name</h4>
<a name="gnutls_005fsrtp_005fget_005fprofile_005fname"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fget_005fprofile_005fname"></a>Function: <em>const char *</em> <strong>gnutls_srtp_get_profile_name</strong> <em>(gnutls_srtp_profile_t <var>profile</var>)</em></dt>
<dd><p><var>profile</var>: The profile to look up a string for
</p>
<p>This function allows you to get the corresponding name for a
SRTP protection profile.
</p>
<p><strong>Returns:</strong> On success, the name of a SRTP profile as a string,
otherwise NULL.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fget_005fselected_005fprofile-1"></a>
<h4 class="subheading">gnutls_srtp_get_selected_profile</h4>
<a name="gnutls_005fsrtp_005fget_005fselected_005fprofile"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fget_005fselected_005fprofile"></a>Function: <em>int</em> <strong>gnutls_srtp_get_selected_profile</strong> <em>(gnutls_session_t <var>session</var>, gnutls_srtp_profile_t * <var>profile</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>profile</var>: will hold the profile
</p>
<p>This function allows you to get the negotiated SRTP profile.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fset_005fmki-1"></a>
<h4 class="subheading">gnutls_srtp_set_mki</h4>
<a name="gnutls_005fsrtp_005fset_005fmki"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fset_005fmki"></a>Function: <em>int</em> <strong>gnutls_srtp_set_mki</strong> <em>(gnutls_session_t <var>session</var>, const gnutls_datum_t * <var>mki</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>mki</var>: holds the MKI
</p>
<p>This function sets the Master Key Identifier, to be
used by this session (if any).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fset_005fprofile-1"></a>
<h4 class="subheading">gnutls_srtp_set_profile</h4>
<a name="gnutls_005fsrtp_005fset_005fprofile"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fset_005fprofile"></a>Function: <em>int</em> <strong>gnutls_srtp_set_profile</strong> <em>(gnutls_session_t <var>session</var>, gnutls_srtp_profile_t <var>profile</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>profile</var>: is the profile id to add.
</p>
<p>This function is to be used by both clients and servers, to declare
what SRTP profiles they support, to negotiate with the peer.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fsrtp_005fset_005fprofile_005fdirect-1"></a>
<h4 class="subheading">gnutls_srtp_set_profile_direct</h4>
<a name="gnutls_005fsrtp_005fset_005fprofile_005fdirect"></a><dl>
<dt><a name="index-gnutls_005fsrtp_005fset_005fprofile_005fdirect"></a>Function: <em>int</em> <strong>gnutls_srtp_set_profile_direct</strong> <em>(gnutls_session_t <var>session</var>, const char * <var>profiles</var>, const char ** <var>err_pos</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>profiles</var>: is a string that contains the supported SRTP profiles,
separated by colons.
</p>
<p><var>err_pos</var>: In case of an error this will have the position in the string the error occured, may be NULL.
</p>
<p>This function is to be used by both clients and servers, to declare
what SRTP profiles they support, to negotiate with the peer.
</p>
<p><strong>Returns:</strong> On syntax error <code>GNUTLS_E_INVALID_REQUEST</code> is returned,
<code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p>
<p>Since 3.1.4
</p></dd></dl>
<a name="gnutls_005fstore_005fcommitment-1"></a>
<h4 class="subheading">gnutls_store_commitment</h4>
<a name="gnutls_005fstore_005fcommitment"></a><dl>
<dt><a name="index-gnutls_005fstore_005fcommitment-1"></a>Function: <em>int</em> <strong>gnutls_store_commitment</strong> <em>(const char* <var>db_name</var>, gnutls_tdb_t <var>tdb</var>, const char* <var>host</var>, const char* <var>service</var>, gnutls_digest_algorithm_t <var>hash_algo</var>, const gnutls_datum_t* <var>hash</var>, time_t <var>expiration</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>db_name</var>: A file specifying the stored keys (use NULL for the default)
</p>
<p><var>tdb</var>: A storage structure or NULL to use the default
</p>
<p><var>host</var>: The peer’s name
</p>
<p><var>service</var>: non-NULL if this key is specific to a service (e.g. http)
</p>
<p><var>hash_algo</var>: The hash algorithm type
</p>
<p><var>hash</var>: The raw hash
</p>
<p><var>expiration</var>: The expiration time (use 0 to disable expiration)
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will store the provided hash commitment to
the list of stored public keys. The key with the given
hash will be considered valid until the provided expiration time.
</p>
<p>The <code>store</code> variable if non-null specifies a custom backend for
the storage of entries. If it is NULL then the
default file backend will be used.
</p>
<p>Note that this function is not thread safe with the default backend.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fstore_005fpubkey-1"></a>
<h4 class="subheading">gnutls_store_pubkey</h4>
<a name="gnutls_005fstore_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fstore_005fpubkey-1"></a>Function: <em>int</em> <strong>gnutls_store_pubkey</strong> <em>(const char* <var>db_name</var>, gnutls_tdb_t <var>tdb</var>, const char* <var>host</var>, const char* <var>service</var>, gnutls_certificate_type_t <var>cert_type</var>, const gnutls_datum_t * <var>cert</var>, time_t <var>expiration</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>db_name</var>: A file specifying the stored keys (use NULL for the default)
</p>
<p><var>tdb</var>: A storage structure or NULL to use the default
</p>
<p><var>host</var>: The peer’s name
</p>
<p><var>service</var>: non-NULL if this key is specific to a service (e.g. http)
</p>
<p><var>cert_type</var>: The type of the certificate
</p>
<p><var>cert</var>: The data of the certificate
</p>
<p><var>expiration</var>: The expiration time (use 0 to disable expiration)
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will store the provided certificate to
the list of stored public keys. The key will be considered valid until
the provided expiration time.
</p>
<p>The <code>store</code> variable if non-null specifies a custom backend for
the storage of entries. If it is NULL then the
default file backend will be used.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fstrerror-1"></a>
<h4 class="subheading">gnutls_strerror</h4>
<a name="gnutls_005fstrerror"></a><dl>
<dt><a name="index-gnutls_005fstrerror"></a>Function: <em>const char *</em> <strong>gnutls_strerror</strong> <em>(int <var>error</var>)</em></dt>
<dd><p><var>error</var>: is a GnuTLS error code, a negative error code
</p>
<p>This function is similar to strerror. The difference is that it
accepts an error number returned by a gnutls function; In case of
an unknown error a descriptive string is sent instead of <code>NULL</code> .
</p>
<p>Error codes are always a negative error code.
</p>
<p><strong>Returns:</strong> A string explaining the GnuTLS error message.
</p></dd></dl>
<a name="gnutls_005fstrerror_005fname-1"></a>
<h4 class="subheading">gnutls_strerror_name</h4>
<a name="gnutls_005fstrerror_005fname"></a><dl>
<dt><a name="index-gnutls_005fstrerror_005fname"></a>Function: <em>const char *</em> <strong>gnutls_strerror_name</strong> <em>(int <var>error</var>)</em></dt>
<dd><p><var>error</var>: is an error returned by a gnutls function.
</p>
<p>Return the GnuTLS error code define as a string. For example,
gnutls_strerror_name (GNUTLS_E_DH_PRIME_UNACCEPTABLE) will return
the string "GNUTLS_E_DH_PRIME_UNACCEPTABLE".
</p>
<p><strong>Returns:</strong> A string corresponding to the symbol name of the error
code.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fsupplemental_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_supplemental_get_name</h4>
<a name="gnutls_005fsupplemental_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fsupplemental_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_supplemental_get_name</strong> <em>(gnutls_supplemental_data_format_type_t <var>type</var>)</em></dt>
<dd><p><var>type</var>: is a supplemental data format type
</p>
<p>Convert a <code>gnutls_supplemental_data_format_type_t</code> value to a
string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified
supplemental data format type, or <code>NULL</code> for unknown types.
</p></dd></dl>
<a name="gnutls_005ftdb_005fdeinit-1"></a>
<h4 class="subheading">gnutls_tdb_deinit</h4>
<a name="gnutls_005ftdb_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005ftdb_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_tdb_deinit</strong> <em>(gnutls_tdb_t <var>tdb</var>)</em></dt>
<dd><p><var>tdb</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a public key trust storage structure.
</p></dd></dl>
<a name="gnutls_005ftdb_005finit-1"></a>
<h4 class="subheading">gnutls_tdb_init</h4>
<a name="gnutls_005ftdb_005finit"></a><dl>
<dt><a name="index-gnutls_005ftdb_005finit"></a>Function: <em>int</em> <strong>gnutls_tdb_init</strong> <em>(gnutls_tdb_t* <var>tdb</var>)</em></dt>
<dd><p><var>tdb</var>: The structure to be initialized
</p>
<p>This function will initialize a public key trust storage structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005ftdb_005fset_005fstore_005fcommitment_005ffunc-1"></a>
<h4 class="subheading">gnutls_tdb_set_store_commitment_func</h4>
<a name="gnutls_005ftdb_005fset_005fstore_005fcommitment_005ffunc"></a><dl>
<dt><a name="index-gnutls_005ftdb_005fset_005fstore_005fcommitment_005ffunc"></a>Function: <em>void</em> <strong>gnutls_tdb_set_store_commitment_func</strong> <em>(gnutls_tdb_t <var>tdb</var>, gnutls_tdb_store_commitment_func <var>cstore</var>)</em></dt>
<dd><p><var>tdb</var>: The trust storage
</p>
<p><var>cstore</var>: The commitment storage function
</p>
<p>This function will associate a commitment (hash) storage function with the
trust storage structure. The function is of the following form.
</p>
<p>gnutls_tdb_store_commitment_func(const char* db_name, const char* host,
const char* service, time_t expiration,
gnutls_digest_algorithm_t, const gnutls_datum_t* hash);
</p></dd></dl>
<a name="gnutls_005ftdb_005fset_005fstore_005ffunc-1"></a>
<h4 class="subheading">gnutls_tdb_set_store_func</h4>
<a name="gnutls_005ftdb_005fset_005fstore_005ffunc"></a><dl>
<dt><a name="index-gnutls_005ftdb_005fset_005fstore_005ffunc"></a>Function: <em>void</em> <strong>gnutls_tdb_set_store_func</strong> <em>(gnutls_tdb_t <var>tdb</var>, gnutls_tdb_store_func <var>store</var>)</em></dt>
<dd><p><var>tdb</var>: The trust storage
</p>
<p><var>store</var>: The storage function
</p>
<p>This function will associate a storage function with the
trust storage structure. The function is of the following form.
</p>
<p>gnutls_tdb_store_func(const char* db_name, const char* host,
const char* service, time_t expiration,
const gnutls_datum_t* pubkey);
</p></dd></dl>
<a name="gnutls_005ftdb_005fset_005fverify_005ffunc-1"></a>
<h4 class="subheading">gnutls_tdb_set_verify_func</h4>
<a name="gnutls_005ftdb_005fset_005fverify_005ffunc"></a><dl>
<dt><a name="index-gnutls_005ftdb_005fset_005fverify_005ffunc"></a>Function: <em>void</em> <strong>gnutls_tdb_set_verify_func</strong> <em>(gnutls_tdb_t <var>tdb</var>, gnutls_tdb_verify_func <var>verify</var>)</em></dt>
<dd><p><var>tdb</var>: The trust storage
</p>
<p><var>verify</var>: The verification function
</p>
<p>This function will associate a retrieval function with the
trust storage structure. The function is of the following form.
</p>
<p>gnutls_tdb_verify_func(const char* db_name, const char* host,
const char* service, const gnutls_datum_t* pubkey);
</p></dd></dl>
<a name="gnutls_005ftransport_005fget_005fptr-1"></a>
<h4 class="subheading">gnutls_transport_get_ptr</h4>
<a name="gnutls_005ftransport_005fget_005fptr"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fget_005fptr"></a>Function: <em>gnutls_transport_ptr_t</em> <strong>gnutls_transport_get_ptr</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<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>
<p><strong>Returns:</strong> The first argument of the transport function.
</p></dd></dl>
<a name="gnutls_005ftransport_005fget_005fptr2-1"></a>
<h4 class="subheading">gnutls_transport_get_ptr2</h4>
<a name="gnutls_005ftransport_005fget_005fptr2"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fget_005fptr2"></a>Function: <em>void</em> <strong>gnutls_transport_get_ptr2</strong> <em>(gnutls_session_t <var>session</var>, gnutls_transport_ptr_t * <var>recv_ptr</var>, gnutls_transport_ptr_t * <var>send_ptr</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>recv_ptr</var>: will hold the value for the pull function
</p>
<p><var>send_ptr</var>: will hold the value for the push function
</p>
<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></dd></dl>
<a name="gnutls_005ftransport_005fset_005ferrno-1"></a>
<h4 class="subheading">gnutls_transport_set_errno</h4>
<a name="gnutls_005ftransport_005fset_005ferrno"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005ferrno-1"></a>Function: <em>void</em> <strong>gnutls_transport_set_errno</strong> <em>(gnutls_session_t <var>session</var>, int <var>err</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>err</var>: error value to store in session-specific errno variable.
</p>
<p>Store <code>err</code> in the session-specific errno variable. Useful values
for <code>err</code> is EAGAIN and EINTR, other values are treated will be
treated as real errors in the push/pull function.
</p>
<p>This function is useful in replacement push and pull functions set by
<code>gnutls_transport_set_push_function()</code> and
<code>gnutls_transport_set_pull_function()</code> under Windows, where the
replacements may not have access to the same <code>errno</code> variable that is used by GnuTLS (e.g., the application is linked to
msvcr71.dll and gnutls is linked to msvcrt.dll).
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005ferrno_005ffunction-1"></a>
<h4 class="subheading">gnutls_transport_set_errno_function</h4>
<a name="gnutls_005ftransport_005fset_005ferrno_005ffunction"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005ferrno_005ffunction"></a>Function: <em>void</em> <strong>gnutls_transport_set_errno_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_errno_func <var>errno_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>errno_func</var>: a callback function similar to <code>write()</code>
</p>
<p>This is the function where you set a function to retrieve errno
after a failed push or pull operation.
</p>
<p><code>errno_func</code> is of the form,
int (*gnutls_errno_func)(gnutls_transport_ptr_t);
and should return the errno.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005fptr-1"></a>
<h4 class="subheading">gnutls_transport_set_ptr</h4>
<a name="gnutls_005ftransport_005fset_005fptr"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fptr"></a>Function: <em>void</em> <strong>gnutls_transport_set_ptr</strong> <em>(gnutls_session_t <var>session</var>, gnutls_transport_ptr_t <var>ptr</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>ptr</var>: is the value.
</p>
<p>Used to set the first argument of the transport function (for push
and pull callbacks). In berkeley style sockets this function will set the
connection descriptor.
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005fptr2-1"></a>
<h4 class="subheading">gnutls_transport_set_ptr2</h4>
<a name="gnutls_005ftransport_005fset_005fptr2"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fptr2-1"></a>Function: <em>void</em> <strong>gnutls_transport_set_ptr2</strong> <em>(gnutls_session_t <var>session</var>, gnutls_transport_ptr_t <var>recv_ptr</var>, gnutls_transport_ptr_t <var>send_ptr</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>recv_ptr</var>: is the value for the pull function
</p>
<p><var>send_ptr</var>: is the value for the push function
</p>
<p>Used to set the first argument of the transport function (for push
and pull callbacks). In berkeley style sockets this function will set the
connection descriptor. With this function you can use two different
pointers for receiving and sending.
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005fpull_005ffunction-1"></a>
<h4 class="subheading">gnutls_transport_set_pull_function</h4>
<a name="gnutls_005ftransport_005fset_005fpull_005ffunction"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fpull_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_transport_set_pull_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_pull_func <var>pull_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>pull_func</var>: a callback function similar to <code>read()</code>
</p>
<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.
The callback should return 0 on connection termination, a positive
number indicating the number of bytes received, and -1 on error.
</p>
<p><code>gnutls_pull_func</code> is of the form,
ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction-1"></a>
<h4 class="subheading">gnutls_transport_set_pull_timeout_function</h4>
<a name="gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_transport_set_pull_timeout_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_pull_timeout_func <var>func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>func</var>: a callback function
</p>
<p>This is the function where you set a function for gnutls to know
whether data are ready to be received. It should wait for data a
given time frame in milliseconds. The callback should return 0 on
timeout, a positive number if data can be received, and -1 on error.
You’ll need to override this function if <code>select()</code> is not suitable
for the provided transport calls.
The callback function is used in DTLS only.
</p>
<p><code>gnutls_pull_timeout_func</code> is of the form,
int (*gnutls_pull_timeout_func)(gnutls_transport_ptr_t, unsigned int ms);
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005fpush_005ffunction-1"></a>
<h4 class="subheading">gnutls_transport_set_push_function</h4>
<a name="gnutls_005ftransport_005fset_005fpush_005ffunction"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fpush_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_transport_set_push_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_push_func <var>push_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>push_func</var>: a callback function similar to <code>write()</code>
</p>
<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.
The callback should return a positive number indicating the
bytes sent, and -1 on error.
</p>
<p><code>push_func</code> is of the form,
ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
</p></dd></dl>
<a name="gnutls_005ftransport_005fset_005fvec_005fpush_005ffunction-1"></a>
<h4 class="subheading">gnutls_transport_set_vec_push_function</h4>
<a name="gnutls_005ftransport_005fset_005fvec_005fpush_005ffunction"></a><dl>
<dt><a name="index-gnutls_005ftransport_005fset_005fvec_005fpush_005ffunction-1"></a>Function: <em>void</em> <strong>gnutls_transport_set_vec_push_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_vec_push_func <var>vec_func</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>vec_func</var>: a callback function similar to <code>writev()</code>
</p>
<p>Using this function you can override the default writev(2)
function for gnutls to send data. Setting this callback
instead of <code>gnutls_transport_set_push_function()</code> is recommended
since it introduces less overhead in the TLS handshake process.
</p>
<p><code>vec_func</code> is of the form,
ssize_t (*gnutls_vec_push_func) (gnutls_transport_ptr_t, const giovec_t * iov, int iovcnt);
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005furl_005fis_005fsupported-1"></a>
<h4 class="subheading">gnutls_url_is_supported</h4>
<a name="gnutls_005furl_005fis_005fsupported"></a><dl>
<dt><a name="index-gnutls_005furl_005fis_005fsupported-1"></a>Function: <em>int</em> <strong>gnutls_url_is_supported</strong> <em>(const char* <var>url</var>)</em></dt>
<dd><p><var>url</var>: A PKCS 11 url
</p>
<p>Check whether url is supported. Depending on the system libraries
GnuTLS may support pkcs11 or tpmkey URLs.
</p>
<p><strong>Returns:</strong> return non-zero if the given URL is supported, and zero if
it is not known.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fverify_005fstored_005fpubkey-1"></a>
<h4 class="subheading">gnutls_verify_stored_pubkey</h4>
<a name="gnutls_005fverify_005fstored_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fverify_005fstored_005fpubkey-1"></a>Function: <em>int</em> <strong>gnutls_verify_stored_pubkey</strong> <em>(const char* <var>db_name</var>, gnutls_tdb_t <var>tdb</var>, const char* <var>host</var>, const char* <var>service</var>, gnutls_certificate_type_t <var>cert_type</var>, const gnutls_datum_t * <var>cert</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>db_name</var>: A file specifying the stored keys (use NULL for the default)
</p>
<p><var>tdb</var>: A storage structure or NULL to use the default
</p>
<p><var>host</var>: The peer’s name
</p>
<p><var>service</var>: non-NULL if this key is specific to a service (e.g. http)
</p>
<p><var>cert_type</var>: The type of the certificate
</p>
<p><var>cert</var>: The raw (der) data of the certificate
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will try to verify the provided certificate using
a list of stored public keys. The <code>service</code> field if non-NULL should
be a port number.
</p>
<p>The <code>retrieve</code> variable if non-null specifies a custom backend for
the retrieval of entries. If it is NULL then the
default file backend will be used. In POSIX-like systems the
file backend uses the $HOME/.gnutls/known_hosts file.
</p>
<p>Note that if the custom storage backend is provided the
retrieval function should return <code>GNUTLS_E_CERTIFICATE_KEY_MISMATCH</code>
if the host/service pair is found but key doesn’t match,
<code>GNUTLS_E_NO_CERTIFICATE_FOUND</code> if no such host/service with
the given key is found, and 0 if it was found. The storage
function should return 0 on success.
</p>
<p><strong>Returns:</strong> If no associated public key is found
then <code>GNUTLS_E_NO_CERTIFICATE_FOUND</code> will be returned. If a key
is found but does not match <code>GNUTLS_E_CERTIFICATE_KEY_MISMATCH</code>
is returned. On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
or a negative error value on other errors.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<hr>
<a name="High-level-TLS-API"></a>
<div class="header">
<p>
Next: <a href="#Datagram-TLS-API" accesskey="n" rel="next">Datagram TLS API</a>, Previous: <a href="#Core-TLS-API" accesskey="p" rel="previous">Core TLS API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="High-level-TLS-API-1"></a>
<h3 class="section">E.2 High level TLS API</h3>
<p>The prototypes for the following functions lie in
<samp>gnutls/xssl.h</samp>.
</p>
<hr>
<a name="Datagram-TLS-API"></a>
<div class="header">
<p>
Next: <a href="#X509-certificate-API" accesskey="n" rel="next">X509 certificate API</a>, Previous: <a href="#High-level-TLS-API" accesskey="p" rel="previous">High level TLS API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Datagram-TLS-API-1"></a>
<h3 class="section">E.3 Datagram TLS API</h3>
<p>The prototypes for the following functions lie in
<samp>gnutls/dtls.h</samp>.
</p>
<a name="gnutls_005fdtls_005fcookie_005fsend-1"></a>
<h4 class="subheading">gnutls_dtls_cookie_send</h4>
<a name="gnutls_005fdtls_005fcookie_005fsend"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fcookie_005fsend"></a>Function: <em>int</em> <strong>gnutls_dtls_cookie_send</strong> <em>(gnutls_datum_t* <var>key</var>, void* <var>client_data</var>, size_t <var>client_data_size</var>, gnutls_dtls_prestate_st* <var>prestate</var>, gnutls_transport_ptr_t <var>ptr</var>, gnutls_push_func <var>push_func</var>)</em></dt>
<dd><p><var>key</var>: is a random key to be used at cookie generation
</p>
<p><var>client_data</var>: contains data identifying the client (i.e. address)
</p>
<p><var>client_data_size</var>: The size of client’s data
</p>
<p><var>prestate</var>: The previous cookie returned by <code>gnutls_dtls_cookie_verify()</code>
</p>
<p><var>ptr</var>: A transport pointer to be used by <code>push_func</code>
</p>
<p><var>push_func</var>: A function that will be used to reply
</p>
<p>This function can be used to prevent denial of service
attacks to a DTLS server by requiring the client to
reply using a cookie sent by this function. That way
it can be ensured that a client we allocated resources
for (i.e. <code>gnutls_session_t</code> ) is the one that the
original incoming packet was originated from.
</p>
<p><strong>Returns:</strong> the number of bytes sent, or a negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fcookie_005fverify-1"></a>
<h4 class="subheading">gnutls_dtls_cookie_verify</h4>
<a name="gnutls_005fdtls_005fcookie_005fverify"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fcookie_005fverify"></a>Function: <em>int</em> <strong>gnutls_dtls_cookie_verify</strong> <em>(gnutls_datum_t* <var>key</var>, void* <var>client_data</var>, size_t <var>client_data_size</var>, void* <var>_msg</var>, size_t <var>msg_size</var>, gnutls_dtls_prestate_st* <var>prestate</var>)</em></dt>
<dd><p><var>key</var>: is a random key to be used at cookie generation
</p>
<p><var>client_data</var>: contains data identifying the client (i.e. address)
</p>
<p><var>client_data_size</var>: The size of client’s data
</p>
<p><var>_msg</var>: An incoming message that initiates a connection.
</p>
<p><var>msg_size</var>: The size of the message.
</p>
<p><var>prestate</var>: The cookie of this client.
</p>
<p>This function will verify an incoming message for
a valid cookie. If a valid cookie is returned then
it should be associated with the session using
<code>gnutls_dtls_prestate_set()</code> ;
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fget_005fdata_005fmtu-1"></a>
<h4 class="subheading">gnutls_dtls_get_data_mtu</h4>
<a name="gnutls_005fdtls_005fget_005fdata_005fmtu"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fget_005fdata_005fmtu"></a>Function: <em>unsigned int</em> <strong>gnutls_dtls_get_data_mtu</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the actual maximum transfer unit for
application data. I.e. DTLS headers are subtracted from the
actual MTU.
</p>
<p><strong>Returns:</strong> the maximum allowed transfer unit.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fget_005fmtu-1"></a>
<h4 class="subheading">gnutls_dtls_get_mtu</h4>
<a name="gnutls_005fdtls_005fget_005fmtu"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fget_005fmtu"></a>Function: <em>unsigned int</em> <strong>gnutls_dtls_get_mtu</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the MTU size as set with
<code>gnutls_dtls_set_mtu()</code> . This is not the actual MTU
of data you can transmit. Use <code>gnutls_dtls_get_data_mtu()</code>
for that reason.
</p>
<p><strong>Returns:</strong> the set maximum transfer unit.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fget_005ftimeout-1"></a>
<h4 class="subheading">gnutls_dtls_get_timeout</h4>
<a name="gnutls_005fdtls_005fget_005ftimeout"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fget_005ftimeout-1"></a>Function: <em>unsigned int</em> <strong>gnutls_dtls_get_timeout</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>This function will return the milliseconds remaining
for a retransmission of the previously sent handshake
message. This function is useful when DTLS is used in
non-blocking mode, to estimate when to call <code>gnutls_handshake()</code>
if no packets have been received.
</p>
<p><strong>Returns:</strong> the remaining time in milliseconds.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fprestate_005fset-1"></a>
<h4 class="subheading">gnutls_dtls_prestate_set</h4>
<a name="gnutls_005fdtls_005fprestate_005fset"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fprestate_005fset"></a>Function: <em>void</em> <strong>gnutls_dtls_prestate_set</strong> <em>(gnutls_session_t <var>session</var>, gnutls_dtls_prestate_st* <var>prestate</var>)</em></dt>
<dd><p><var>session</var>: a new session
</p>
<p><var>prestate</var>: contains the client’s prestate
</p>
<p>This function will associate the prestate acquired by
the cookie authentication with the client, with the newly
established session.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fset_005fdata_005fmtu-1"></a>
<h4 class="subheading">gnutls_dtls_set_data_mtu</h4>
<a name="gnutls_005fdtls_005fset_005fdata_005fmtu"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fset_005fdata_005fmtu"></a>Function: <em>int</em> <strong>gnutls_dtls_set_data_mtu</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>mtu</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>mtu</var>: The maximum unencrypted transfer unit of the session
</p>
<p>This function will set the maximum size of the *unencrypted* records
which will be sent over a DTLS session. It is equivalent to calculating
the DTLS packet overhead with the current encryption parameters, and
calling <code>gnutls_dtls_set_mtu()</code> with that value. In particular, this means
that you may need to call this function again after any negotiation or
renegotiation, in order to ensure that the MTU is still sufficient to
account for the new protocol overhead.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<a name="gnutls_005fdtls_005fset_005fmtu-1"></a>
<h4 class="subheading">gnutls_dtls_set_mtu</h4>
<a name="gnutls_005fdtls_005fset_005fmtu"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fset_005fmtu"></a>Function: <em>void</em> <strong>gnutls_dtls_set_mtu</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>mtu</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>mtu</var>: The maximum transfer unit of the transport
</p>
<p>This function will set the maximum transfer unit of the transport
that DTLS packets are sent over. Note that this should exclude
the IP (or IPv6) and UDP headers. So for DTLS over IPv6 on an
Ethenet device with MTU 1500, the DTLS MTU set with this function
would be 1500 - 40 (IPV6 header) - 8 (UDP header) = 1452.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fdtls_005fset_005ftimeouts-1"></a>
<h4 class="subheading">gnutls_dtls_set_timeouts</h4>
<a name="gnutls_005fdtls_005fset_005ftimeouts"></a><dl>
<dt><a name="index-gnutls_005fdtls_005fset_005ftimeouts"></a>Function: <em>void</em> <strong>gnutls_dtls_set_timeouts</strong> <em>(gnutls_session_t <var>session</var>, unsigned int <var>retrans_timeout</var>, unsigned int <var>total_timeout</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>retrans_timeout</var>: The time at which a retransmission will occur in milliseconds
</p>
<p><var>total_timeout</var>: The time at which the connection will be aborted, in milliseconds.
</p>
<p>This function will set the timeouts required for the DTLS handshake
protocol. The retransmission timeout is the time after which a
message from the peer is not received, the previous messages will
be retransmitted. The total timeout is the time after which the
handshake will be aborted with <code>GNUTLS_E_TIMEDOUT</code> .
</p>
<p>The DTLS protocol recommends the values of 1 sec and 60 seconds
respectively.
</p>
<p>If the retransmission timeout is zero then the handshake will operate
in a non-blocking way, i.e., return <code>GNUTLS_E_AGAIN</code> .
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005frecord_005fget_005fdiscarded-1"></a>
<h4 class="subheading">gnutls_record_get_discarded</h4>
<a name="gnutls_005frecord_005fget_005fdiscarded"></a><dl>
<dt><a name="index-gnutls_005frecord_005fget_005fdiscarded"></a>Function: <em>unsigned int</em> <strong>gnutls_record_get_discarded</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Returns the number of discarded packets in a
DTLS connection.
</p>
<p><strong>Returns:</strong> The number of discarded packets.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<hr>
<a name="X509-certificate-API"></a>
<div class="header">
<p>
Next: <a href="#OCSP-API" accesskey="n" rel="next">OCSP API</a>, Previous: <a href="#Datagram-TLS-API" accesskey="p" rel="previous">Datagram TLS API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="X_002e509-certificate-API"></a>
<h3 class="section">E.4 <acronym>X.509</acronym> certificate API</h3>
<a name="index-X_002e509-Functions"></a>
<p>The following functions are to be used for <acronym>X.509</acronym> certificate handling.
Their prototypes lie in <samp>gnutls/x509.h</samp>.
</p>
<a name="gnutls_005fpkcs7_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs7_deinit</h4>
<a name="gnutls_005fpkcs7_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs7_deinit</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: The structure to be initialized
</p>
<p>This function will deinitialize a PKCS7 structure.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fdelete_005fcrl-1"></a>
<h4 class="subheading">gnutls_pkcs7_delete_crl</h4>
<a name="gnutls_005fpkcs7_005fdelete_005fcrl"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fdelete_005fcrl"></a>Function: <em>int</em> <strong>gnutls_pkcs7_delete_crl</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, int <var>indx</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p><var>indx</var>: the index of the crl to delete
</p>
<p>This function will delete a crl from a PKCS7 or RFC2630 crl set.
Index starts from 0. Returns 0 on success.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fdelete_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs7_delete_crt</h4>
<a name="gnutls_005fpkcs7_005fdelete_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fdelete_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs7_delete_crt</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, int <var>indx</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a gnutls_pkcs7_t structure
</p>
<p><var>indx</var>: the index of the certificate to delete
</p>
<p>This function will delete a certificate from a PKCS7 or RFC2630
certificate set. Index starts from 0. Returns 0 on success.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fexport-1"></a>
<h4 class="subheading">gnutls_pkcs7_export</h4>
<a name="gnutls_005fpkcs7_005fexport"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fexport"></a>Function: <em>int</em> <strong>gnutls_pkcs7_export</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>pkcs7</var>: Holds the pkcs7 structure
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a structure PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the pkcs7 structure to DER or PEM format.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>output_data_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code>
will be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN PKCS7".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fexport2-1"></a>
<h4 class="subheading">gnutls_pkcs7_export2</h4>
<a name="gnutls_005fpkcs7_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fexport2"></a>Function: <em>int</em> <strong>gnutls_pkcs7_export2</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>pkcs7</var>: Holds the pkcs7 structure
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a structure PEM or DER encoded
</p>
<p>This function will export the pkcs7 structure to DER or PEM format.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN PKCS7".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fcount-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crl_count</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fcount"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fcount"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crl_count</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a gnutls_pkcs7_t structure
</p>
<p>This function will return the number of certifcates in the PKCS7
or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crl_raw</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrl_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrl_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crl_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, int <var>indx</var>, void * <var>crl</var>, size_t * <var>crl_size</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p><var>indx</var>: contains the index of the crl to extract
</p>
<p><var>crl</var>: the contents of the crl will be copied there (may be null)
</p>
<p><var>crl_size</var>: should hold the size of the crl
</p>
<p>This function will return a crl of the PKCS7 or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. If the provided buffer is not long enough,
then <code>crl_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is
returned. After the last crl has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fcount-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crt_count</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fcount"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fcount"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crt_count</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p>This function will return the number of certifcates in the PKCS7
or RFC2630 certificate set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_get_crt_raw</h4>
<a name="gnutls_005fpkcs7_005fget_005fcrt_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fget_005fcrt_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_get_crt_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, int <var>indx</var>, void * <var>certificate</var>, size_t * <var>certificate_size</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a gnutls_pkcs7_t structure
</p>
<p><var>indx</var>: contains the index of the certificate to extract
</p>
<p><var>certificate</var>: the contents of the certificate will be copied
there (may be null)
</p>
<p><var>certificate_size</var>: should hold the size of the certificate
</p>
<p>This function will return a certificate of the PKCS7 or RFC2630
certificate set.
</p>
<p>After the last certificate has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. If the provided buffer is not long enough,
then <code>certificate_size</code> is updated and
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is returned.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fimport-1"></a>
<h4 class="subheading">gnutls_pkcs7_import</h4>
<a name="gnutls_005fpkcs7_005fimport"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fimport"></a>Function: <em>int</em> <strong>gnutls_pkcs7_import</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>pkcs7</var>: The structure to store the parsed PKCS7.
</p>
<p><var>data</var>: The DER or PEM encoded PKCS7.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p>This function will convert the given DER or PEM encoded PKCS7 to
the native <code>gnutls_pkcs7_t</code> format. The output will be stored in
<code>pkcs7</code> .
</p>
<p>If the PKCS7 is PEM encoded it should have a header of "PKCS7".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs7_init</h4>
<a name="gnutls_005fpkcs7_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs7_init</strong> <em>(gnutls_pkcs7_t * <var>pkcs7</var>)</em></dt>
<dd><p><var>pkcs7</var>: The structure to be initialized
</p>
<p>This function will initialize a PKCS7 structure. PKCS7 structures
usually contain lists of X.509 Certificates and X.509 Certificate
revocation lists.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fset_005fcrl-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crl</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrl"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrl"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crl</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p><var>crl</var>: the DER encoded crl to be added
</p>
<p>This function will add a parsed CRL to the PKCS7 or RFC2630 crl
set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fset_005fcrl_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crl_raw</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrl_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrl_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crl_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, const gnutls_datum_t * <var>crl</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p><var>crl</var>: the DER encoded crl to be added
</p>
<p>This function will add a crl to the PKCS7 or RFC2630 crl set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fset_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crt</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crt</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, gnutls_x509_crt_t <var>crt</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p><var>crt</var>: the certificate to be copied.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs7_005fset_005fcrt_005fraw-1"></a>
<h4 class="subheading">gnutls_pkcs7_set_crt_raw</h4>
<a name="gnutls_005fpkcs7_005fset_005fcrt_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpkcs7_005fset_005fcrt_005fraw"></a>Function: <em>int</em> <strong>gnutls_pkcs7_set_crt_raw</strong> <em>(gnutls_pkcs7_t <var>pkcs7</var>, const gnutls_datum_t * <var>crt</var>)</em></dt>
<dd><p><var>pkcs7</var>: should contain a <code>gnutls_pkcs7_t</code> structure
</p>
<p><var>crt</var>: the DER encoded certificate to be added
</p>
<p>This function will add a certificate to the PKCS7 or RFC2630
certificate set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fcheck_005fissuer-1"></a>
<h4 class="subheading">gnutls_x509_crl_check_issuer</h4>
<a name="gnutls_005fx509_005fcrl_005fcheck_005fissuer"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fcheck_005fissuer"></a>Function: <em>int</em> <strong>gnutls_x509_crl_check_issuer</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>)</em></dt>
<dd><p><var>crl</var>: is the CRL to be checked
</p>
<p><var>issuer</var>: is the certificate of a possible issuer
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fdeinit-1"></a>
<h4 class="subheading">gnutls_x509_crl_deinit</h4>
<a name="gnutls_005fx509_005fcrl_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_x509_crl_deinit</strong> <em>(gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: The structure to be initialized
</p>
<p>This function will deinitialize a CRL structure.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fexport-1"></a>
<h4 class="subheading">gnutls_x509_crl_export</h4>
<a name="gnutls_005fx509_005fcrl_005fexport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fexport"></a>Function: <em>int</em> <strong>gnutls_x509_crl_export</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>crl</var>: Holds the revocation list
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a private key PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will
be replaced by the actual size of parameters)
</p>
<p>This function will export the revocation list to DER or PEM format.
</p>
<p>If the buffer provided is not long enough to hold the output, then
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN X509 CRL".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. and a negative error code on failure.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fexport2-1"></a>
<h4 class="subheading">gnutls_x509_crl_export2</h4>
<a name="gnutls_005fx509_005fcrl_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fexport2"></a>Function: <em>int</em> <strong>gnutls_x509_crl_export2</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>crl</var>: Holds the revocation list
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a private key PEM or DER encoded
</p>
<p>This function will export the revocation list to DER or PEM format.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN X509 CRL".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. and a negative error code on failure.
</p>
<p>Since 3.1.3
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fgn_005fserial-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_authority_key_gn_serial</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fgn_005fserial"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fgn_005fserial"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_authority_key_gn_serial</strong> <em>(gnutls_x509_crl_t <var>crl</var>, unsigned int <var>seq</var>, void * <var>alt</var>, size_t * <var>alt_size</var>, unsigned int * <var>alt_type</var>, void* <var>serial</var>, size_t * <var>serial_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>alt</var>: is the place where the alternative name will be copied to
</p>
<p><var>alt_size</var>: holds the size of alt.
</p>
<p><var>alt_type</var>: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
</p>
<p><var>serial</var>: buffer to store the serial number (may be null)
</p>
<p><var>serial_size</var>: Holds the size of the serial field (may be null)
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function will return the X.509 authority key
identifier when stored as a general name (authorityCertIssuer)
and serial number.
</p>
<p>Because more than one general names might be stored
<code>seq</code> can be used as a counter to request them all until
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Returns:</strong> Returns 0 on success, or an error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_authority_key_id</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_authority_key_id</strong> <em>(gnutls_x509_crl_t <var>crl</var>, void * <var>id</var>, size_t * <var>id_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>id</var>: The place where the identifier will be copied
</p>
<p><var>id_size</var>: Holds the size of the result field.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
(may be null)
</p>
<p>This function will return the CRL 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 and
<code>GNUTLS_E_X509_UNSUPPORTED_EXTENSION</code> , if the extension contains
the name and serial number of the certificate. In that case
<code>gnutls_x509_crl_get_authority_key_gn_serial()</code> may be used.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_crt_count</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_crt_count</strong> <em>(gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p>This function will return the number of revoked certificates in the
given CRL.
</p>
<p><strong>Returns:</strong> number of certificates, a negative error code on failure.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_crt_serial</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial-1"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_crt_serial</strong> <em>(gnutls_x509_crl_t <var>crl</var>, int <var>indx</var>, unsigned char * <var>serial</var>, size_t * <var>serial_size</var>, time_t * <var>t</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>indx</var>: the index of the certificate to extract (starting from 0)
</p>
<p><var>serial</var>: where the serial number will be copied
</p>
<p><var>serial_size</var>: initially holds the size of serial
</p>
<p><var>t</var>: if non null, will hold the time this certificate was revoked
</p>
<p>This function will retrieve the serial number of the specified, by
the index, revoked certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. and a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fdn_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_dn_oid</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fdn_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fdn_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_dn_oid</strong> <em>(gnutls_x509_crl_t <var>crl</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>indx</var>: Specifies which DN OID to send. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>sizeof_oid</var>: initially holds the size of ’oid’
</p>
<p>This function will extract the requested OID of the name of the CRL
issuer, specified by the given index.
</p>
<p>If oid is null then only the size will be filled.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> 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></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fextension_005fdata-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_extension_data</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fextension_005fdata"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fextension_005fdata"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_extension_data</strong> <em>(gnutls_x509_crl_t <var>crl</var>, int <var>indx</var>, void * <var>data</var>, size_t * <var>sizeof_data</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to send. Use (0) to get the first one.
</p>
<p><var>data</var>: a pointer to a structure to hold the data (may be null)
</p>
<p><var>sizeof_data</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will return the requested extension data in the CRL.
The extension data will be stored as a string in the provided
buffer.
</p>
<p>Use <code>gnutls_x509_crl_get_extension_info()</code> to extract the OID and
critical flag. Use <code>gnutls_x509_crl_get_extension_info()</code> instead,
if you want to get data indexed by the extension OID rather than
sequence.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fextension_005finfo-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_extension_info</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fextension_005finfo"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fextension_005finfo"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_extension_info</strong> <em>(gnutls_x509_crl_t <var>crl</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to send, use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the OID
</p>
<p><var>sizeof_oid</var>: initially holds the maximum size of <code>oid</code> , on return
holds actual size of <code>oid</code> .
</p>
<p><var>critical</var>: output variable with critical flag, may be NULL.
</p>
<p>This function will return the requested extension OID in the CRL,
and the critical flag for it. The extension OID will be stored as
a string in the provided buffer. Use
<code>gnutls_x509_crl_get_extension_data()</code> to extract the data.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>sizeof_oid</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be
returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fextension_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_extension_oid</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fextension_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fextension_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_extension_oid</strong> <em>(gnutls_x509_crl_t <var>crl</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to send, use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the OID (may be null)
</p>
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will return the requested extension OID in the CRL.
The extension OID will be stored as a string in the provided
buffer.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_issuer_dn</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_issuer_dn</strong> <em>(const gnutls_x509_crl_t <var>crl</var>, char * <var>buf</var>, size_t * <var>sizeof_buf</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>buf</var>: a pointer to a structure to hold the peer’s name (may be null)
</p>
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. The output string will be ASCII or UTF-8
encoded, depending on the certificate data.
</p>
<p>If buf is <code>NULL</code> then only the size will be filled.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> 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></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_issuer_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_issuer_dn_by_oid</strong> <em>(gnutls_x509_crl_t <var>crl</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>sizeof_buf</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>oid</var>: holds an Object Identified in null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
</p>
<p><var>raw_flag</var>: If non-zero returns the raw DER data of the DN part.
</p>
<p><var>buf</var>: a pointer to a structure to hold the peer’s name (may be null)
</p>
<p><var>sizeof_buf</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. The output string will be ASCII or UTF-8 encoded,
depending on the certificate data.
</p>
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is (0), this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC4514 – in
hex format with a ’#’ prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code> .
</p>
<p>If buf is null then only the size will be filled.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> 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></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_next_update</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate"></a>Function: <em>time_t</em> <strong>gnutls_x509_crl_get_next_update</strong> <em>(gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<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>
<p><strong>Returns:</strong> when the next CRL will be issued, or (time_t)-1 on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fnumber-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_number</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fnumber"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fnumber"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_number</strong> <em>(gnutls_x509_crl_t <var>crl</var>, void * <var>ret</var>, size_t * <var>ret_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p><var>ret</var>: The place where the number will be copied
</p>
<p><var>ret_size</var>: Holds the size of the result field.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
(may be null)
</p>
<p>This function will return the CRL number extension. This is
obtained by the CRL Number extension field (2.5.29.20).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fraw_005fissuer_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_raw_issuer_dn</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fraw_005fissuer_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fraw_005fissuer_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_raw_issuer_dn</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_datum_t * <var>dn</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>dn</var>: will hold the starting point of the DN
</p>
<p>This function will return a pointer to the DER encoded DN structure
and the length.
</p>
<p><strong>Returns:</strong> a negative error code on error, and (0) on success.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fsignature-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_signature</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fsignature"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fsignature"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_signature</strong> <em>(gnutls_x509_crl_t <var>crl</var>, char * <var>sig</var>, size_t * <var>sizeof_sig</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>sig</var>: a pointer where the signature part will be copied (may be null).
</p>
<p><var>sizeof_sig</var>: initially holds the size of <code>sig</code>
</p>
<p>This function will extract the signature field of a CRL.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. and a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_signature_algorithm</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_signature_algorithm</strong> <em>(gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p>This function will return a value of the <code>gnutls_sign_algorithm_t</code>
enumeration that is the signature algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_this_update</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate"></a>Function: <em>time_t</em> <strong>gnutls_x509_crl_get_this_update</strong> <em>(gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p>This function will return the time this CRL was issued.
</p>
<p><strong>Returns:</strong> when the CRL was issued, or (time_t)-1 on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_x509_crl_get_version</h4>
<a name="gnutls_005fx509_005fcrl_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fget_005fversion"></a>Function: <em>int</em> <strong>gnutls_x509_crl_get_version</strong> <em>(gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: should contain a <code>gnutls_x509_crl_t</code> structure
</p>
<p>This function will return the version of the specified CRL.
</p>
<p><strong>Returns:</strong> The version number, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_crl_import</h4>
<a name="gnutls_005fx509_005fcrl_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_crl_import</strong> <em>(gnutls_x509_crl_t <var>crl</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>crl</var>: The structure to store the parsed CRL.
</p>
<p><var>data</var>: The DER or PEM encoded CRL.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p>This function will convert the given DER or PEM encoded CRL
to the native <code>gnutls_x509_crl_t</code> format. The output will be stored in ’crl’.
</p>
<p>If the CRL is PEM encoded it should have a header of "X509 CRL".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005finit-1"></a>
<h4 class="subheading">gnutls_x509_crl_init</h4>
<a name="gnutls_005fx509_005fcrl_005finit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005finit"></a>Function: <em>int</em> <strong>gnutls_x509_crl_init</strong> <em>(gnutls_x509_crl_t * <var>crl</var>)</em></dt>
<dd><p><var>crl</var>: The structure to be initialized
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005flist_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_crl_list_import</h4>
<a name="gnutls_005fx509_005fcrl_005flist_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005flist_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_crl_list_import</strong> <em>(gnutls_x509_crl_t * <var>crls</var>, unsigned int * <var>crl_max</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crls</var>: The structures to store the parsed CRLs. Must not be initialized.
</p>
<p><var>crl_max</var>: Initially must hold the maximum number of crls. It will be updated with the number of crls available.
</p>
<p><var>data</var>: The PEM encoded CRLs
</p>
<p><var>format</var>: One of DER or PEM.
</p>
<p><var>flags</var>: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
</p>
<p>This function will convert the given PEM encoded CRL list
to the native gnutls_x509_crl_t format. The output will be stored
in <code>crls</code> . They will be automatically initialized.
</p>
<p>If the Certificate is PEM encoded it should have a header of "X509 CRL".
</p>
<p><strong>Returns:</strong> the number of certificates read or a negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005flist_005fimport2-1"></a>
<h4 class="subheading">gnutls_x509_crl_list_import2</h4>
<a name="gnutls_005fx509_005fcrl_005flist_005fimport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005flist_005fimport2"></a>Function: <em>int</em> <strong>gnutls_x509_crl_list_import2</strong> <em>(gnutls_x509_crl_t ** <var>crls</var>, unsigned int * <var>size</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crls</var>: The structures to store the parsed crl list. Must not be initialized.
</p>
<p><var>size</var>: It will contain the size of the list.
</p>
<p><var>data</var>: The PEM encoded CRL.
</p>
<p><var>format</var>: One of DER or PEM.
</p>
<p><var>flags</var>: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
</p>
<p>This function will convert the given PEM encoded CRL list
to the native gnutls_x509_crl_t format. The output will be stored
in <code>crls</code> . They will be automatically initialized.
</p>
<p>If the Certificate is PEM encoded it should have a header of "X509
CRL".
</p>
<p><strong>Returns:</strong> the number of certificates read or a negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fprint-1"></a>
<h4 class="subheading">gnutls_x509_crl_print</h4>
<a name="gnutls_005fx509_005fcrl_005fprint"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fprint"></a>Function: <em>int</em> <strong>gnutls_x509_crl_print</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_certificate_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>crl</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print a X.509 certificate revocation
list, suitable for display to a human.
</p>
<p>The output <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fauthority_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_authority_key_id</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fauthority_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fauthority_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_authority_key_id</strong> <em>(gnutls_x509_crl_t <var>crl</var>, const void * <var>id</var>, size_t <var>id_size</var>)</em></dt>
<dd><p><var>crl</var>: a CRL of type <code>gnutls_x509_crl_t</code>
</p>
<p><var>id</var>: The key ID
</p>
<p><var>id_size</var>: Holds the size of the serial field.
</p>
<p>This function will set the CRL’s authority key ID extension. Only
the keyIdentifier field can be set with this function. This may
be used by an authority that holds multiple private keys, to distinguish
the used key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fcrt-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_crt</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fcrt"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_crt</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>crt</var>, time_t <var>revocation_time</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code> with the revoked certificate
</p>
<p><var>revocation_time</var>: The time this certificate was revoked
</p>
<p>This function will set a revoked certificate’s serial number to the CRL.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_crt_serial</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_crt_serial</strong> <em>(gnutls_x509_crl_t <var>crl</var>, const void * <var>serial</var>, size_t <var>serial_size</var>, time_t <var>revocation_time</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>serial</var>: The revoked certificate’s serial number
</p>
<p><var>serial_size</var>: Holds the size of the serial field.
</p>
<p><var>revocation_time</var>: The time this certificate was revoked
</p>
<p>This function will set a revoked certificate’s serial number to the CRL.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_next_update</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_next_update</strong> <em>(gnutls_x509_crl_t <var>crl</var>, time_t <var>exp_time</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>exp_time</var>: The actual time
</p>
<p>This function will set the time this CRL will be updated.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fnumber-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_number</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fnumber"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fnumber"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_number</strong> <em>(gnutls_x509_crl_t <var>crl</var>, const void * <var>nr</var>, size_t <var>nr_size</var>)</em></dt>
<dd><p><var>crl</var>: a CRL of type <code>gnutls_x509_crl_t</code>
</p>
<p><var>nr</var>: The CRL number
</p>
<p><var>nr_size</var>: Holds the size of the nr field.
</p>
<p>This function will set the CRL’s number extension. This
is to be used as a unique and monotonic number assigned to
the CRL by the authority.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_this_update</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_this_update</strong> <em>(gnutls_x509_crl_t <var>crl</var>, time_t <var>act_time</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>act_time</var>: The actual time
</p>
<p>This function will set the time this CRL was issued.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fset_005fversion-1"></a>
<h4 class="subheading">gnutls_x509_crl_set_version</h4>
<a name="gnutls_005fx509_005fcrl_005fset_005fversion"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fset_005fversion"></a>Function: <em>int</em> <strong>gnutls_x509_crl_set_version</strong> <em>(gnutls_x509_crl_t <var>crl</var>, unsigned int <var>version</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>version</var>: holds the version number. For CRLv1 crls must be 1.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fsign2-1"></a>
<h4 class="subheading">gnutls_x509_crl_sign2</h4>
<a name="gnutls_005fx509_005fcrl_005fsign2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fsign2-1"></a>Function: <em>int</em> <strong>gnutls_x509_crl_sign2</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
</p>
<p><var>flags</var>: must be 0
</p>
<p>This function will sign the CRL with the issuer’s private key, and
will copy the issuer’s information into the CRL.
</p>
<p>This must be the last step in a certificate CRL since all
the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fverify-1"></a>
<h4 class="subheading">gnutls_x509_crl_verify</h4>
<a name="gnutls_005fx509_005fcrl_005fverify"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fverify"></a>Function: <em>int</em> <strong>gnutls_x509_crl_verify</strong> <em>(gnutls_x509_crl_t <var>crl</var>, const gnutls_x509_crt_t * <var>CA_list</var>, int <var>CA_list_length</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>crl</var>: is the crl to be verified
</p>
<p><var>CA_list</var>: is a certificate list that is considered to be trusted one
</p>
<p><var>CA_list_length</var>: holds the number of CA certificates in CA_list
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the crl verification output.
</p>
<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. Note that since GnuTLS 3.1.4 this function includes
the time checks.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fdeinit-1"></a>
<h4 class="subheading">gnutls_x509_crq_deinit</h4>
<a name="gnutls_005fx509_005fcrq_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_x509_crq_deinit</strong> <em>(gnutls_x509_crq_t <var>crq</var>)</em></dt>
<dd><p><var>crq</var>: The structure to be initialized
</p>
<p>This function will deinitialize a PKCS<code>10</code> certificate request
structure.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fexport-1"></a>
<h4 class="subheading">gnutls_x509_crq_export</h4>
<a name="gnutls_005fx509_005fcrq_005fexport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fexport"></a>Function: <em>int</em> <strong>gnutls_x509_crq_export</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a certificate request PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the certificate request to a PEM or DER
encoded PKCS10 structure.
</p>
<p>If the buffer provided is not long enough to hold the output, then
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be returned and
* <code>output_data_size</code> will be updated.
</p>
<p>If the structure is PEM encoded, it will have a header of "BEGIN
NEW CERTIFICATE REQUEST".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fexport2-1"></a>
<h4 class="subheading">gnutls_x509_crq_export2</h4>
<a name="gnutls_005fx509_005fcrq_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fexport2"></a>Function: <em>int</em> <strong>gnutls_x509_crq_export2</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a certificate request PEM or DER encoded
</p>
<p>This function will export the certificate request to a PEM or DER
encoded PKCS10 structure.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header of "BEGIN
NEW CERTIFICATE REQUEST".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p>Since 3.1.3
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_attribute_by_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_attribute_by_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>oid</var>, int <var>indx</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identifier in null-terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the attribute list, this
specifies which to get, use (0) to get the first one
</p>
<p><var>buf</var>: a pointer to a structure to hold the attribute data (may be <code>NULL</code> )
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<p>This function will return the attribute in the certificate request
specified by the given Object ID. The attribute will be DER
encoded.
</p>
<p>Attributes in a certificate request is an optional set of data
appended to the request. Their interpretation depends on the CA policy.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005fdata-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_attribute_data</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005fdata"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fattribute_005fdata"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_attribute_data</strong> <em>(gnutls_x509_crq_t <var>crq</var>, int <var>indx</var>, void * <var>data</var>, size_t * <var>sizeof_data</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>indx</var>: Specifies which attribute number to get. Use (0) to get the first one.
</p>
<p><var>data</var>: a pointer to a structure to hold the data (may be null)
</p>
<p><var>sizeof_data</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will return the requested attribute data in the
certificate request. The attribute data will be stored as a string in the
provided buffer.
</p>
<p>Use <code>gnutls_x509_crq_get_attribute_info()</code> to extract the OID.
Use <code>gnutls_x509_crq_get_attribute_by_oid()</code> instead,
if you want to get data indexed by the attribute OID rather than
sequence.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005finfo-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_attribute_info</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fattribute_005finfo"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fattribute_005finfo"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_attribute_info</strong> <em>(gnutls_x509_crq_t <var>crq</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>indx</var>: Specifies which attribute number to get. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the OID
</p>
<p><var>sizeof_oid</var>: initially holds the maximum size of <code>oid</code> , on return
holds actual size of <code>oid</code> .
</p>
<p>This function will return the requested attribute OID in the
certificate, and the critical flag for it. The attribute OID will
be stored as a string in the provided buffer. Use
<code>gnutls_x509_crq_get_attribute_data()</code> to extract the data.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>sizeof_oid</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be
returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fbasic_005fconstraints-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_basic_constraints</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fbasic_005fconstraints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fbasic_005fconstraints"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_basic_constraints</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int * <var>critical</var>, unsigned int * <var>ca</var>, int * <var>pathlen</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<p><var>ca</var>: pointer to output integer indicating CA status, may be NULL,
value is 1 if the certificate CA flag is set, 0 otherwise.
</p>
<p><var>pathlen</var>: pointer to output integer indicating path length (may be
NULL), non-negative error codes indicate a present pathLenConstraint
field and the actual value, -1 indicate that the field is absent.
</p>
<p>This function will read the certificate’s basic constraints, and
return the certificates CA status. It reads the basicConstraints
X.509 extension (2.5.29.19).
</p>
<p><strong>Returns:</strong> If the certificate is a CA a positive value will be
returned, or (0) if the certificate does not have CA flag set.
A negative error code may be returned in case of errors. If the
certificate does not contain the basicConstraints extension
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_challenge_password</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_challenge_password</strong> <em>(gnutls_x509_crq_t <var>crq</var>, char * <var>pass</var>, size_t * <var>pass_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>pass</var>: will hold a (0)-terminated password string
</p>
<p><var>pass_size</var>: Initially holds the size of <code>pass</code> .
</p>
<p>This function will return the challenge password in the request.
The challenge password is intended to be used for requesting a
revocation of the certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_dn</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_dn</strong> <em>(gnutls_x509_crq_t <var>crq</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be <code>NULL</code> )
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<p>This function will copy the name of the Certificate request subject
to the provided buffer. The name will be in the form
"C=xxxx,O=yyyy,CN=zzzz" as described in RFC 2253. The output string
<code>buf</code> will be ASCII or UTF-8 encoded, depending on the certificate
data.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the * <code>buf_size</code> will be updated with
the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_dn_by_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
</p>
<p><var>oid</var>: holds an Object Identifier in a null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies
which to get. Use (0) to get the first one.
</p>
<p><var>raw_flag</var>: If non-zero returns the raw DER data of the DN part.
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be <code>NULL</code> )
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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>
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is (0), 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is
not long enough, and in that case the * <code>buf_size</code> will be
updated with the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fdn_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_dn_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fdn_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fdn_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_dn_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>)</em></dt>
<dd><p><var>crq</var>: should contain a gnutls_x509_crq_t structure
</p>
<p><var>indx</var>: Specifies which DN OID to get. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the name (may be <code>NULL</code> )
</p>
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will extract the requested OID of the name of the
certificate request subject, specified by the given index.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is
not long enough, and in that case the * <code>sizeof_oid</code> will be
updated with the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fextension_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_extension_by_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fextension_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fextension_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_extension_by_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>oid</var>, int <var>indx</var>, void * <var>buf</var>, size_t * <var>buf_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identifier in a null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the extensions, this
specifies which to get. Use (0) to get the first one.
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If the certificate does not
contain the specified extension
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fextension_005fdata-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_extension_data</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fextension_005fdata"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fextension_005fdata"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_extension_data</strong> <em>(gnutls_x509_crq_t <var>crq</var>, int <var>indx</var>, void * <var>data</var>, size_t * <var>sizeof_data</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension number to get. Use (0) to get the first one.
</p>
<p><var>data</var>: a pointer to a structure to hold the data (may be null)
</p>
<p><var>sizeof_data</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will return the requested extension data in the
certificate. The extension data will be stored as a string in the
provided buffer.
</p>
<p>Use <code>gnutls_x509_crq_get_extension_info()</code> to extract the OID and
critical flag. Use <code>gnutls_x509_crq_get_extension_by_oid()</code> instead,
if you want to get data indexed by the extension OID rather than
sequence.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fextension_005finfo-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_extension_info</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fextension_005finfo"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fextension_005finfo"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_extension_info</strong> <em>(gnutls_x509_crq_t <var>crq</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension number to get. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the OID
</p>
<p><var>sizeof_oid</var>: initially holds the maximum size of <code>oid</code> , on return
holds actual size of <code>oid</code> .
</p>
<p><var>critical</var>: output variable with critical flag, may be NULL.
</p>
<p>This function will return the requested extension OID in the
certificate, and the critical flag for it. The extension OID will
be stored as a string in the provided buffer. Use
<code>gnutls_x509_crq_get_extension_data()</code> to extract the data.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>sizeof_oid</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be
returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code in case of an error. If your have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_key_id</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_key_id</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>crq</var>: a certificate of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>output_data</var>: will contain the key ID
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will return a unique ID that depends on the public key
parameters. This ID can be used in checking whether a certificate
corresponds to the given private key.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>output_data_size</code> 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>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005fpurpose_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_key_purpose_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005fpurpose_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fkey_005fpurpose_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_key_purpose_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>sizeof_oid</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>indx</var>: This specifies which OID to return, use (0) to get the first one
</p>
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be <code>NULL</code> )
</p>
<p><var>sizeof_oid</var>: initially holds the size of <code>oid</code>
</p>
<p><var>critical</var>: output variable with critical flag, may be <code>NULL</code> .
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is
not long enough, and in that case the * <code>sizeof_oid</code> will be
updated with the required size. On success 0 is returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_key_rsa_raw</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fkey_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_key_rsa_raw</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>crq</var>: Holds the certificate
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p>This function will export the RSA public 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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_key_usage</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_key_usage</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int * <var>key_usage</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key_usage</var>: where the key usage bits will be stored
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<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: <code>GNUTLS_KEY_DIGITAL_SIGNATURE</code> ,
<code>GNUTLS_KEY_NON_REPUDIATION</code> , <code>GNUTLS_KEY_KEY_ENCIPHERMENT</code> ,
<code>GNUTLS_KEY_DATA_ENCIPHERMENT</code> , <code>GNUTLS_KEY_KEY_AGREEMENT</code> ,
<code>GNUTLS_KEY_KEY_CERT_SIGN</code> , <code>GNUTLS_KEY_CRL_SIGN</code> ,
<code>GNUTLS_KEY_ENCIPHER_ONLY</code> , <code>GNUTLS_KEY_DECIPHER_ONLY</code> .
</p>
<p><strong>Returns:</strong> the certificate key usage, or a negative error code in case of
parsing error. If the certificate does not contain the keyUsage
extension <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be
returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_pk_algorithm</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_pk_algorithm</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>bits</var>: if bits is non-<code>NULL</code> it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of a PKCS<code>10</code>
certificate request.
</p>
<p>If bits is non-<code>NULL</code> , 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>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fprivate_005fkey_005fusage_005fperiod-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_private_key_usage_period</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fprivate_005fkey_005fusage_005fperiod"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fprivate_005fkey_005fusage_005fperiod"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_private_key_usage_period</strong> <em>(gnutls_x509_crq_t <var>crq</var>, time_t* <var>activation</var>, time_t* <var>expiration</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: – undescribed –
</p>
<p><var>activation</var>: The activation time
</p>
<p><var>expiration</var>: The expiration time
</p>
<p><var>critical</var>: the extension status
</p>
<p>This function will return the expiration and activation
times of the private key of the certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
if the extension is not present, otherwise a negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fname-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_subject_alt_name</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fname"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_subject_alt_name</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>seq</var>, void * <var>ret</var>, size_t * <var>ret_size</var>, unsigned int * <var>ret_type</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name, 0 for the
first one, 1 for the second etc.
</p>
<p><var>ret</var>: is the place where the alternative name will be copied to
</p>
<p><var>ret_size</var>: holds the size of ret.
</p>
<p><var>ret_type</var>: holds the <code>gnutls_x509_subject_alt_name_t</code> name type
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
(may be null)
</p>
<p>This function will return the alternative names, contained in the
given certificate. It is the same as
<code>gnutls_x509_crq_get_subject_alt_name()</code> except for the fact that it
will return the type of the alternative name in <code>ret_type</code> even if
the function fails for some reason (i.e. the buffer provided is
not enough).
</p>
<p><strong>Returns:</strong> the alternative subject name type on success, one of the
enumerated <code>gnutls_x509_subject_alt_name_t</code> . It will return
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if <code>ret_size</code> is not large enough to
hold the value. In that case <code>ret_size</code> will be updated with the
required size. If the certificate request does not have an
Alternative name with the specified sequence number then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fothername_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_subject_alt_othername_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fothername_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fothername_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_subject_alt_othername_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>seq</var>, void * <var>ret</var>, size_t * <var>ret_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>ret</var>: is the place where the otherName OID will be copied to
</p>
<p><var>ret_size</var>: holds the size of ret.
</p>
<p>This function will extract the type OID of an otherName Subject
Alternative Name, contained in the given certificate, and return
the type as an enumerated element.
</p>
<p>This function is only useful if
<code>gnutls_x509_crq_get_subject_alt_name()</code> returned
<code>GNUTLS_SAN_OTHERNAME</code> .
</p>
<p><strong>Returns:</strong> the alternative subject name type on success, one of the
enumerated gnutls_x509_subject_alt_name_t. For supported OIDs,
it will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types,
e.g. <code>GNUTLS_SAN_OTHERNAME_XMPP</code> , and <code>GNUTLS_SAN_OTHERNAME</code> for
unknown OIDs. It will return <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if
<code>ret_size</code> is not large enough to hold the value. In that case
<code>ret_size</code> will be updated with the required size. If the
certificate does not have an Alternative name with the specified
sequence number and with the otherName type then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_x509_crq_get_version</h4>
<a name="gnutls_005fx509_005fcrq_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fget_005fversion"></a>Function: <em>int</em> <strong>gnutls_x509_crq_get_version</strong> <em>(gnutls_x509_crq_t <var>crq</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p>This function will return the version of the specified Certificate
request.
</p>
<p><strong>Returns:</strong> version of certificate request, or a negative error code on
error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_crq_import</h4>
<a name="gnutls_005fx509_005fcrq_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_crq_import</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>crq</var>: The structure to store the parsed certificate request.
</p>
<p><var>data</var>: The DER or PEM encoded certificate.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p>This function will convert the given DER or PEM encoded certificate
request to a <code>gnutls_x509_crq_t</code> structure. The output will be
stored in <code>crq</code> .
</p>
<p>If the Certificate is PEM encoded it should have a header of "NEW
CERTIFICATE REQUEST".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005finit-1"></a>
<h4 class="subheading">gnutls_x509_crq_init</h4>
<a name="gnutls_005fx509_005fcrq_005finit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005finit"></a>Function: <em>int</em> <strong>gnutls_x509_crq_init</strong> <em>(gnutls_x509_crq_t * <var>crq</var>)</em></dt>
<dd><p><var>crq</var>: The structure to be initialized
</p>
<p>This function will initialize a PKCS<code>10</code> certificate request
structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fprint-1"></a>
<h4 class="subheading">gnutls_x509_crq_print</h4>
<a name="gnutls_005fx509_005fcrq_005fprint"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fprint"></a>Function: <em>int</em> <strong>gnutls_x509_crq_print</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_certificate_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>crq</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print a certificate request, suitable for
display to a human.
</p>
<p>The output <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_attribute_by_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_attribute_by_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>oid</var>, void * <var>buf</var>, size_t <var>buf_size</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identifier in a null-terminated string
</p>
<p><var>buf</var>: a pointer to a structure that holds the attribute data
</p>
<p><var>buf_size</var>: holds the size of <code>buf</code>
</p>
<p>This function will set the attribute in the certificate request
specified by the given Object ID. The provided attribute must be be DER
encoded.
</p>
<p>Attributes in a certificate request is an optional set of data
appended to the request. Their interpretation depends on the CA policy.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fbasic_005fconstraints-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_basic_constraints</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fbasic_005fconstraints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fbasic_005fconstraints"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_basic_constraints</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>ca</var>, int <var>pathLenConstraint</var>)</em></dt>
<dd><p><var>crq</var>: a certificate request of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>ca</var>: true(1) or false(0) depending on the Certificate authority status.
</p>
<p><var>pathLenConstraint</var>: non-negative error codes indicate maximum length of path,
and negative error codes indicate that the pathLenConstraints field should
not be present.
</p>
<p>This function will set the basicConstraints certificate extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_challenge_password</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_challenge_password</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>pass</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>pass</var>: holds a (0)-terminated password
</p>
<p>This function will set a challenge password to be used when
revoking the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_dn</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_dn</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>dn</var>, const char** <var>err</var>)</em></dt>
<dd><p><var>crq</var>: a certificate of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>dn</var>: a comma separated DN string (RFC4514)
</p>
<p><var>err</var>: indicates the error position (if any)
</p>
<p>This function will set the DN on the provided certificate.
The input string should be plain ASCII or UTF-8 encoded.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_dn_by_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const char * <var>oid</var>, unsigned int <var>raw_flag</var>, const void * <var>data</var>, unsigned int <var>sizeof_data</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identifier in a (0)-terminated string
</p>
<p><var>raw_flag</var>: must be 0, or 1 if the data are DER encoded
</p>
<p><var>data</var>: a pointer to the input data
</p>
<p><var>sizeof_data</var>: holds the size of <code>data</code>
</p>
<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>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_key</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fkey-1"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_key</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a private key
</p>
<p>This function will set the public parameters from the given private
key to the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey_005fpurpose_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_key_purpose_oid</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey_005fpurpose_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fkey_005fpurpose_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_key_purpose_oid</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const void * <var>oid</var>, unsigned int <var>critical</var>)</em></dt>
<dd><p><var>crq</var>: a certificate of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>oid</var>: a pointer to a (0)-terminated string that holds the OID
</p>
<p><var>critical</var>: Whether this extension will be critical or not
</p>
<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>
<p>Subsequent calls to this function will append OIDs to the OID list.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_key_rsa_raw</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fkey_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_key_rsa_raw</strong> <em>(gnutls_x509_crq_t <var>crq</var>, const gnutls_datum_t * <var>m</var>, const gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>m</var>: holds the modulus
</p>
<p><var>e</var>: holds the public exponent
</p>
<p>This function will set the public parameters from the given private
key to the request. Only RSA keys are currently supported.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_key_usage</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_key_usage</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>usage</var>)</em></dt>
<dd><p><var>crq</var>: a certificate request of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>usage</var>: an ORed sequence of the GNUTLS_KEY_* elements.
</p>
<p>This function will set the keyUsage certificate extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fprivate_005fkey_005fusage_005fperiod-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_private_key_usage_period</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fprivate_005fkey_005fusage_005fperiod"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fprivate_005fkey_005fusage_005fperiod"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_private_key_usage_period</strong> <em>(gnutls_x509_crq_t <var>crq</var>, time_t <var>activation</var>, time_t <var>expiration</var>)</em></dt>
<dd><p><var>crq</var>: a certificate of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>activation</var>: The activation time
</p>
<p><var>expiration</var>: The expiration time
</p>
<p>This function will set the private key usage period extension (2.5.29.16).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fsubject_005falt_005fname-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_subject_alt_name</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fsubject_005falt_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fsubject_005falt_005fname"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_subject_alt_name</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_subject_alt_name_t <var>nt</var>, const void * <var>data</var>, unsigned int <var>data_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crq</var>: a certificate request of type <code>gnutls_x509_crq_t</code>
</p>
<p><var>nt</var>: is one of the <code>gnutls_x509_subject_alt_name_t</code> enumerations
</p>
<p><var>data</var>: The data to be set
</p>
<p><var>data_size</var>: The size of data to be set
</p>
<p><var>flags</var>: <code>GNUTLS_FSAN_SET</code> to clear previous data or
<code>GNUTLS_FSAN_APPEND</code> to append.
</p>
<p>This function will set the subject alternative name certificate
extension. It can set the following types:
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fversion-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_version</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fversion"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fversion"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_version</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>version</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>version</var>: holds the version number, for v1 Requests must be 1
</p>
<p>This function will set the version of the certificate request. For
version 1 requests this must be one.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fsign2-1"></a>
<h4 class="subheading">gnutls_x509_crq_sign2</h4>
<a name="gnutls_005fx509_005fcrq_005fsign2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fsign2-1"></a>Function: <em>int</em> <strong>gnutls_x509_crq_sign2</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_privkey_t <var>key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a private key
</p>
<p><var>dig</var>: The message digest to use, i.e., <code>GNUTLS_DIG_SHA1</code>
</p>
<p><var>flags</var>: must be 0
</p>
<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>
<p>This must be the last step in a certificate request generation
since all the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
<code>GNUTLS_E_ASN1_VALUE_NOT_FOUND</code> is returned if you didn’t set all
information in the certificate request (e.g., the version using
<code>gnutls_x509_crq_set_version()</code> ).
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fverify-1"></a>
<h4 class="subheading">gnutls_x509_crq_verify</h4>
<a name="gnutls_005fx509_005fcrq_005fverify"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fverify"></a>Function: <em>int</em> <strong>gnutls_x509_crq_verify</strong> <em>(gnutls_x509_crq_t <var>crq</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crq</var>: is the crq to be verified
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p>This function will verify self signature in the certificate
request and return its status.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p>Since 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fcheck_005fhostname-1"></a>
<h4 class="subheading">gnutls_x509_crt_check_hostname</h4>
<a name="gnutls_005fx509_005fcrt_005fcheck_005fhostname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fcheck_005fhostname"></a>Function: <em>int</em> <strong>gnutls_x509_crt_check_hostname</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const char * <var>hostname</var>)</em></dt>
<dd><p><var>cert</var>: should contain an gnutls_x509_crt_t structure
</p>
<p><var>hostname</var>: A null terminated string that contains a DNS name
</p>
<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 DNSName/IPAddress subject alternative name PKIX extension.
</p>
<p><strong>Returns:</strong> non-zero for a successful match, and zero on failure.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fcheck_005fissuer-1"></a>
<h4 class="subheading">gnutls_x509_crt_check_issuer</h4>
<a name="gnutls_005fx509_005fcrt_005fcheck_005fissuer"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fcheck_005fissuer"></a>Function: <em>int</em> <strong>gnutls_x509_crt_check_issuer</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_x509_crt_t <var>issuer</var>)</em></dt>
<dd><p><var>cert</var>: is the certificate to be checked
</p>
<p><var>issuer</var>: is the certificate of a possible issuer
</p>
<p>This function will check if the given certificate was issued by the
given issuer. It checks the DN fields and the authority
key identifier and subject key identifier fields match.
</p>
<p><strong>Returns:</strong> It will return true (1) if the given certificate is issued
by the given issuer, and false (0) if not. A negative error code is
returned in case of an error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fcheck_005frevocation-1"></a>
<h4 class="subheading">gnutls_x509_crt_check_revocation</h4>
<a name="gnutls_005fx509_005fcrt_005fcheck_005frevocation"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fcheck_005frevocation"></a>Function: <em>int</em> <strong>gnutls_x509_crt_check_revocation</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const gnutls_x509_crl_t * <var>crl_list</var>, int <var>crl_list_length</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>crl_list</var>: should contain a list of gnutls_x509_crl_t structures
</p>
<p><var>crl_list_length</var>: the length of the crl_list
</p>
<p>This function will return check if the given certificate is
revoked. It is assumed that the CRLs have been verified before.
</p>
<p><strong>Returns:</strong> 0 if the certificate is NOT revoked, and 1 if it is. A
negative error code is returned on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints-1"></a>
<h4 class="subheading">gnutls_x509_crt_cpy_crl_dist_points</h4>
<a name="gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints"></a>Function: <em>int</em> <strong>gnutls_x509_crt_cpy_crl_dist_points</strong> <em>(gnutls_x509_crt_t <var>dst</var>, gnutls_x509_crt_t <var>src</var>)</em></dt>
<dd><p><var>dst</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>src</var>: the certificate where the dist points will be copied from
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fdeinit-1"></a>
<h4 class="subheading">gnutls_x509_crt_deinit</h4>
<a name="gnutls_005fx509_005fcrt_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_x509_crt_deinit</strong> <em>(gnutls_x509_crt_t <var>cert</var>)</em></dt>
<dd><p><var>cert</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a certificate structure.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fexport-1"></a>
<h4 class="subheading">gnutls_x509_crt_export</h4>
<a name="gnutls_005fx509_005fcrt_005fexport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fexport"></a>Function: <em>int</em> <strong>gnutls_x509_crt_export</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>cert</var>: Holds the certificate
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a certificate PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the certificate to DER or PEM format.
</p>
<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>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fexport2-1"></a>
<h4 class="subheading">gnutls_x509_crt_export2</h4>
<a name="gnutls_005fx509_005fcrt_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fexport2"></a>Function: <em>int</em> <strong>gnutls_x509_crt_export2</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>cert</var>: Holds the certificate
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a certificate PEM or DER encoded
</p>
<p>This function will export the certificate to DER or PEM format.
The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005factivation_005ftime-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_activation_time</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005factivation_005ftime"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005factivation_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_x509_crt_get_activation_time</strong> <em>(gnutls_x509_crt_t <var>cert</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p>This function will return the time this Certificate was or will be
activated.
</p>
<p><strong>Returns:</strong> activation time, or (time_t)-1 on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005finfo_005faccess-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_authority_info_access</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005finfo_005faccess"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fauthority_005finfo_005faccess"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_authority_info_access</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>seq</var>, int <var>what</var>, gnutls_datum_t * <var>data</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>seq</var>: specifies the sequence number of the access descriptor (0 for the first one, 1 for the second etc.)
</p>
<p><var>what</var>: what data to get, a <code>gnutls_info_access_what_t</code> type.
</p>
<p><var>data</var>: output data to be freed with <code>gnutls_free()</code> .
</p>
<p><var>critical</var>: pointer to output integer that is set to non-0 if the extension is marked as critical (may be <code>NULL</code> )
</p>
<p>This function extracts the Authority Information Access (AIA)
extension, see RFC 5280 section 4.2.2.1 for more information. The
AIA extension holds a sequence of AccessDescription (AD) data:
</p>
<p><informalexample><programlisting>
AuthorityInfoAccessSyntax ::=
SEQUENCE SIZE (1..MAX) OF AccessDescription
</p>
<p>AccessDescription ::= SEQUENCE {
accessMethod OBJECT IDENTIFIER,
accessLocation GeneralName }
</programlisting></informalexample>
</p>
<p>The <code>seq</code> input parameter is used to indicate which member of the
sequence the caller is interested in. The first member is 0, the
second member 1 and so on. When the <code>seq</code> value is out of bounds,
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p>The type of data returned in <code>data</code> is specified via <code>what</code> which
should be <code>gnutls_info_access_what_t</code> values.
</p>
<p>If <code>what</code> is <code>GNUTLS_IA_ACCESSMETHOD_OID</code> then <code>data</code> will hold the
accessMethod OID (e.g., "1.3.6.1.5.5.7.48.1").
</p>
<p>If <code>what</code> is <code>GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE</code> , <code>data</code> will
hold the accessLocation GeneralName type (e.g.,
"uniformResourceIdentifier").
</p>
<p>If <code>what</code> is <code>GNUTLS_IA_URI</code> , <code>data</code> will hold the accessLocation URI
data. Requesting this <code>what</code> value leads to an error if the
accessLocation is not of the "uniformResourceIdentifier" type.
</p>
<p>If <code>what</code> is <code>GNUTLS_IA_OCSP_URI</code> , <code>data</code> will hold the OCSP URI.
Requesting this <code>what</code> value leads to an error if the accessMethod
is not 1.3.6.1.5.5.7.48.1 aka OSCP, or if accessLocation is not of
the "uniformResourceIdentifier" type.
</p>
<p>If <code>what</code> is <code>GNUTLS_IA_CAISSUERS_URI</code> , <code>data</code> will hold the caIssuers
URI. Requesting this <code>what</code> value leads to an error if the
accessMethod is not 1.3.6.1.5.5.7.48.2 aka caIssuers, or if
accessLocation is not of the "uniformResourceIdentifier" type.
</p>
<p>More <code>what</code> values may be allocated in the future as needed.
</p>
<p>If <code>data</code> is NULL, the function does the same without storing the
output data, that is, it will set <code>critical</code> and do error checking
as usual.
</p>
<p>The value of the critical flag is returned in * <code>critical</code> . Supply a
NULL <code>critical</code> if you want the function to make sure the extension
is non-critical, as required by RFC 5280.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, <code>GNUTLS_E_INVALID_REQUEST</code> on
invalid <code>crt</code> , <code>GNUTLS_E_CONSTRAINT_ERROR</code> if the extension is
incorrectly marked as critical (use a non-NULL <code>critical</code> to
override), <code>GNUTLS_E_UNKNOWN_ALGORITHM</code> if the requested OID does
not match (e.g., when using <code>GNUTLS_IA_OCSP_URI</code> ), otherwise a
negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fgn_005fserial-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_authority_key_gn_serial</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fgn_005fserial"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fgn_005fserial"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_authority_key_gn_serial</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>alt</var>, size_t * <var>alt_size</var>, unsigned int * <var>alt_type</var>, void* <var>serial</var>, size_t * <var>serial_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>alt</var>: is the place where the alternative name will be copied to
</p>
<p><var>alt_size</var>: holds the size of alt.
</p>
<p><var>alt_type</var>: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
</p>
<p><var>serial</var>: buffer to store the serial number (may be null)
</p>
<p><var>serial_size</var>: Holds the size of the serial field (may be null)
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function will return the X.509 authority key
identifier when stored as a general name (authorityCertIssuer)
and serial number.
</p>
<p>Because more than one general names might be stored
<code>seq</code> can be used as a counter to request them all until
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
if the extension is not present, otherwise a negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_authority_key_id</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_authority_key_id</strong> <em>(gnutls_x509_crt_t <var>cert</var>, void * <var>id</var>, size_t * <var>id_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>id</var>: The place where the identifier will be copied
</p>
<p><var>id_size</var>: Holds the size of the id field.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<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 and
<code>GNUTLS_E_X509_UNSUPPORTED_EXTENSION</code> , if the extension contains
the name and serial number of the certificate. In that case
<code>gnutls_x509_crt_get_authority_key_gn_serial()</code> may be used.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
if the extension is not present, otherwise a negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fbasic_005fconstraints-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_basic_constraints</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fbasic_005fconstraints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fbasic_005fconstraints"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_basic_constraints</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int * <var>critical</var>, unsigned int * <var>ca</var>, int * <var>pathlen</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<p><var>ca</var>: pointer to output integer indicating CA status, may be NULL,
value is 1 if the certificate CA flag is set, 0 otherwise.
</p>
<p><var>pathlen</var>: pointer to output integer indicating path length (may be
NULL), non-negative error codes indicate a present pathLenConstraint
field and the actual value, -1 indicate that the field is absent.
</p>
<p>This function will read the certificate’s basic constraints, and
return the certificates CA status. It reads the basicConstraints
X.509 extension (2.5.29.19).
</p>
<p><strong>Returns:</strong> If the certificate is a CA a positive value will be
returned, or (0) if the certificate does not have CA flag set. A
negative error code may be returned in case of errors. If the
certificate does not contain the basicConstraints extension
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fca_005fstatus-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_ca_status</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fca_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fca_005fstatus"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_ca_status</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<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 (0) if the certificate
does not have CA flag set.
</p>
<p>Use <code>gnutls_x509_crt_get_basic_constraints()</code> if you want to read the
pathLenConstraint field too.
</p>
<p><strong>Returns:</strong> A negative error code may be returned in case of parsing error.
If the certificate does not contain the basicConstraints extension
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_crl_dist_points</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_crl_dist_points</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>ret</var>, size_t * <var>ret_size</var>, unsigned int * <var>reason_flags</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.)
</p>
<p><var>ret</var>: is the place where the distribution point will be copied to
</p>
<p><var>ret_size</var>: holds the size of ret.
</p>
<p><var>reason_flags</var>: Revocation reasons. An ORed sequence of flags from <code>gnutls_x509_crl_reason_flags_t</code> .
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function retrieves the CRL distribution points (2.5.29.31),
contained in the given certificate in the X509v3 Certificate
Extensions.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> and updates <code>ret_size</code> if
<code>ret_size</code> 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 <code>gnutls_x509_subject_alt_name_t</code> . If the
certificate does not have an Alternative name with the specified
sequence number then <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is
returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn-1"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_dn</strong> <em>(gnutls_x509_crt_t <var>cert</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. The output string will be ASCII or UTF-8
encoded, depending on the certificate data.
</p>
<p>If <code>buf</code> is null then only the size will be filled.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated
with the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid-1"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_dn_by_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identified in null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
</p>
<p><var>raw_flag</var>: If non-zero returns the raw DER data of the DN part.
</p>
<p><var>buf</var>: a pointer where the DN part will be copied (may be null).
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. Thus a string
that is ASCII or UTF-8 encoded, depending on the certificate data.
</p>
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is (0), this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC4514 –
in hex format with a ’#’ prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code> .
</p>
<p>If <code>buf</code> is null then only the size will be filled. If the <code>raw_flag</code> is not specified the output is always null terminated, although the
<code>buf_size</code> will not include the null character.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if there
are no data in the current index. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fdn_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_dn_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fdn_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fdn_005foid-1"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_dn_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: This specifies which OID to return. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
</p>
<p><var>oid_size</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will extract the OIDs of the name of the Certificate
subject specified by the given index.
</p>
<p>If <code>oid</code> is null then only the size will be filled. The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if there
are no data in the current index. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_expiration_time</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_x509_crt_get_expiration_time</strong> <em>(gnutls_x509_crt_t <var>cert</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p>This function will return the time this Certificate was or will be
expired.
</p>
<p><strong>Returns:</strong> expiration time, or (time_t)-1 on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_extension_by_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_extension_by_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const char * <var>oid</var>, int <var>indx</var>, void * <var>buf</var>, size_t * <var>buf_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identified in null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the extensions, this specifies which to send. Use (0) to get the first one.
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned. If the certificate does not
contain the specified extension
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005fdata-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_extension_data</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005fdata"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fextension_005fdata"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_extension_data</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>data</var>, size_t * <var>sizeof_data</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to send. Use (0) to get the first one.
</p>
<p><var>data</var>: a pointer to a structure to hold the data (may be null)
</p>
<p><var>sizeof_data</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will return the requested extension data in the
certificate. The extension data will be stored as a string in the
provided buffer.
</p>
<p>Use <code>gnutls_x509_crt_get_extension_info()</code> to extract the OID and
critical flag. Use <code>gnutls_x509_crt_get_extension_by_oid()</code> instead,
if you want to get data indexed by the extension OID rather than
sequence.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned. If you have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005finfo-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_extension_info</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005finfo"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fextension_005finfo"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_extension_info</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to send. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the OID
</p>
<p><var>oid_size</var>: initially holds the maximum size of <code>oid</code> , on return
holds actual size of <code>oid</code> .
</p>
<p><var>critical</var>: output variable with critical flag, may be NULL.
</p>
<p>This function will return the requested extension OID in the
certificate, and the critical flag for it. The extension OID will
be stored as a string in the provided buffer. Use
<code>gnutls_x509_crt_get_extension_data()</code> to extract the data.
</p>
<p>If the buffer provided is not long enough to hold the output, then
<code>oid_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be
returned. The <code>oid</code> returned will be null terminated, although
<code>oid_size</code> will not account for the trailing null.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned. If you have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_extension_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fextension_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fextension_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_extension_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to send. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a structure to hold the OID (may be null)
</p>
<p><var>oid_size</var>: initially holds the size of <code>oid</code>
</p>
<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>
<p>The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned. If you have reached the
last extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
will be returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005ffingerprint-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_fingerprint</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005ffingerprint"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005ffingerprint"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_fingerprint</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_digest_algorithm_t <var>algo</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>algo</var>: is a digest algorithm
</p>
<p><var>buf</var>: a pointer to a structure to hold the fingerprint (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<p>This function will calculate and copy the certificate’s fingerprint
in the provided buffer.
</p>
<p>If the buffer is null then only the size will be filled.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is
not long enough, and in that case the *buf_size will be updated
with the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_x509_dn_t * <var>dn</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>dn</var>: output variable with pointer to uint8_t DN
</p>
<p>Return the Certificate’s Issuer DN as a <code>gnutls_x509_dn_t</code> data type,
that can be decoded using <code>gnutls_x509_dn_get_rdn_ava()</code> .
</p>
<p>Note that <code>dn</code> should be treated as constant. Because it points
into the <code>cert</code> object, you should not use <code>dn</code> after <code>cert</code> is
deallocated.
</p>
<p><strong>Returns:</strong> Returns 0 on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_alt_name</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_alt_name</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>ian</var>, size_t * <var>ian_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>ian</var>: is the place where the alternative name will be copied to
</p>
<p><var>ian_size</var>: holds the size of ian.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function retrieves the Issuer Alternative Name (2.5.29.18),
contained in the given certificate in the X509v3 Certificate
Extensions.
</p>
<p>When the SAN type is otherName, it will extract the data in the
otherName’s value field, and <code>GNUTLS_SAN_OTHERNAME</code> is returned.
You may use <code>gnutls_x509_crt_get_subject_alt_othername_oid()</code> to get
the corresponding OID and the "virtual" SAN types (e.g.,
<code>GNUTLS_SAN_OTHERNAME_XMPP</code> ).
</p>
<p>If an otherName OID is known, the data will be decoded. Otherwise
the returned data will be DER encoded, and you will have to decode
it yourself. Currently, only the RFC 3920 id-on-xmppAddr Issuer
AltName is recognized.
</p>
<p><strong>Returns:</strong> the alternative issuer name type on success, one of the
enumerated <code>gnutls_x509_subject_alt_name_t</code> . It will return
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if <code>ian_size</code> is not large enough
to hold the value. In that case <code>ian_size</code> will be updated with
the required size. If the certificate does not have an
Alternative name with the specified sequence number then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname2-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_alt_name2</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname2"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_alt_name2</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>ian</var>, size_t * <var>ian_size</var>, unsigned int * <var>ian_type</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>ian</var>: is the place where the alternative name will be copied to
</p>
<p><var>ian_size</var>: holds the size of ret.
</p>
<p><var>ian_type</var>: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function will return the alternative names, contained in the
given certificate. It is the same as
<code>gnutls_x509_crt_get_issuer_alt_name()</code> except for the fact that it
will return the type of the alternative name in <code>ian_type</code> even if
the function fails for some reason (i.e. the buffer provided is
not enough).
</p>
<p><strong>Returns:</strong> the alternative issuer name type on success, one of the
enumerated <code>gnutls_x509_subject_alt_name_t</code> . It will return
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if <code>ian_size</code> is not large enough
to hold the value. In that case <code>ian_size</code> will be updated with
the required size. If the certificate does not have an
Alternative name with the specified sequence number then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fothername_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_alt_othername_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fothername_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fothername_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_alt_othername_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>ret</var>, size_t * <var>ret_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>ret</var>: is the place where the otherName OID will be copied to
</p>
<p><var>ret_size</var>: holds the size of ret.
</p>
<p>This function will extract the type OID of an otherName Subject
Alternative Name, contained in the given certificate, and return
the type as an enumerated element.
</p>
<p>If <code>oid</code> is null then only the size will be filled. The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p>This function is only useful if
<code>gnutls_x509_crt_get_issuer_alt_name()</code> returned
<code>GNUTLS_SAN_OTHERNAME</code> .
</p>
<p><strong>Returns:</strong> the alternative issuer name type on success, one of the
enumerated gnutls_x509_subject_alt_name_t. For supported OIDs, it
will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types,
e.g. <code>GNUTLS_SAN_OTHERNAME_XMPP</code> , and <code>GNUTLS_SAN_OTHERNAME</code> for
unknown OIDs. It will return <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if
<code>ret_size</code> is not large enough to hold the value. In that case
<code>ret_size</code> will be updated with the required size. If the
certificate does not have an Alternative name with the specified
sequence number and with the otherName type then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_dn</strong> <em>(gnutls_x509_crt_t <var>cert</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. The output string
will be ASCII or UTF-8 encoded, depending on the certificate data.
</p>
<p>If <code>buf</code> is null then only the size will be filled.
</p>
<p><strong>Returns:</strong> GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_dn_by_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>oid</var>: holds an Object Identified in null terminated string
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the RDN, this specifies which to send. Use (0) to get the first one.
</p>
<p><var>raw_flag</var>: If non-zero returns the raw DER data of the DN part.
</p>
<p><var>buf</var>: a pointer to a structure to hold the name (may be null)
</p>
<p><var>buf_size</var>: initially holds the size of <code>buf</code>
</p>
<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 RFC4514. Thus a string that is
ASCII or UTF-8 encoded, depending on the certificate data.
</p>
<p>Some helper macros with popular OIDs can be found in gnutls/x509.h
If raw flag is (0), this function will only return known OIDs as
text. Other OIDs will be DER encoded, as described in RFC4514 –
in hex format with a ’#’ prefix. You can check about known OIDs
using <code>gnutls_x509_dn_oid_known()</code> .
</p>
<p>If <code>buf</code> is null then only the size will be filled. If the <code>raw_flag</code> is not specified the output is always null terminated, although the
<code>buf_size</code> will not include the null character.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if there
are no data in the current index. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_dn_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_dn_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: This specifies which OID to return. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
</p>
<p><var>oid_size</var>: initially holds the size of <code>oid</code>
</p>
<p>This function will extract the OIDs of the name of the Certificate
issuer specified by the given index.
</p>
<p>If <code>oid</code> is null then only the size will be filled. The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is not
long enough, and in that case the <code>buf_size</code> will be updated with
the required size. <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if there
are no data in the current index. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005funique_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_issuer_unique_id</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fissuer_005funique_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fissuer_005funique_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_issuer_unique_id</strong> <em>(gnutls_x509_crt_t <var>crt</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>buf</var>: user allocated memory buffer, will hold the unique id
</p>
<p><var>buf_size</var>: size of user allocated memory buffer (on input), will hold
actual size of the unique ID on return.
</p>
<p>This function will extract the issuerUniqueID value (if present) for
the given certificate.
</p>
<p>If the user allocated memory buffer is not large enough to hold the
full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be
returned, and buf_size will be set to the actual length.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_key_id</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fid-1"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_key_id</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>output_data</var>: will contain the key ID
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will return a unique ID that depends on the public
key parameters. This ID can be used in checking whether a
certificate corresponds to the given private key.
</p>
<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>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_key_purpose_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_key_purpose_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, int <var>indx</var>, void * <var>oid</var>, size_t * <var>oid_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>indx</var>: This specifies which OID to return. Use (0) to get the first one.
</p>
<p><var>oid</var>: a pointer to a buffer to hold the OID (may be null)
</p>
<p><var>oid_size</var>: initially holds the size of <code>oid</code>
</p>
<p><var>critical</var>: output flag to indicate criticality of extension
</p>
<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>
<p>If <code>oid</code> is null then only the size will be filled. The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if the provided buffer is
not long enough, and in that case the *oid_size will be updated
with the required size. On success 0 is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_key_usage</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_key_usage</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int * <var>key_usage</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>key_usage</var>: where the key usage bits will be stored
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<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: <code>GNUTLS_KEY_DIGITAL_SIGNATURE</code> ,
<code>GNUTLS_KEY_NON_REPUDIATION</code> , <code>GNUTLS_KEY_KEY_ENCIPHERMENT</code> ,
<code>GNUTLS_KEY_DATA_ENCIPHERMENT</code> , <code>GNUTLS_KEY_KEY_AGREEMENT</code> ,
<code>GNUTLS_KEY_KEY_CERT_SIGN</code> , <code>GNUTLS_KEY_CRL_SIGN</code> ,
<code>GNUTLS_KEY_ENCIPHER_ONLY</code> , <code>GNUTLS_KEY_DECIPHER_ONLY</code> .
</p>
<p><strong>Returns:</strong> the certificate key usage, or a negative error code in case of
parsing error. If the certificate does not contain the keyUsage
extension <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be
returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_pk_algorithm</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_pk_algorithm</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of an X.509
certificate.
</p>
<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>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_pk_dsa_raw</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_pk_dsa_raw</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p>This function will export the DSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_pk_rsa_raw</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_pk_rsa_raw</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p>This function will export the RSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fpolicy-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_policy</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fpolicy"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fpolicy"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_policy</strong> <em>(gnutls_x509_crt_t <var>crt</var>, int <var>indx</var>, struct gnutls_x509_policy_st* <var>policy</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>crt</var>: – undescribed –
</p>
<p><var>indx</var>: This specifies which policy to return. Use (0) to get the first one.
</p>
<p><var>policy</var>: A pointer to a policy structure.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<p>This function will extract the certificate policy (extension 2.5.29.32)
specified by the given index.
</p>
<p>The policy returned by this function must be deinitialized by using
<code>gnutls_x509_policy_release()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
if the extension is not present, otherwise a negative error value.
</p>
<p><strong>Since:</strong> 3.1.5
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fprivate_005fkey_005fusage_005fperiod-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_private_key_usage_period</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fprivate_005fkey_005fusage_005fperiod"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fprivate_005fkey_005fusage_005fperiod"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_private_key_usage_period</strong> <em>(gnutls_x509_crt_t <var>cert</var>, time_t* <var>activation</var>, time_t* <var>expiration</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>activation</var>: The activation time
</p>
<p><var>expiration</var>: The expiration time
</p>
<p><var>critical</var>: the extension status
</p>
<p>This function will return the expiration and activation
times of the private key of the certificate. It relies on
the PKIX extension 2.5.29.16 being present.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
if the extension is not present, otherwise a negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fproxy-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_proxy</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fproxy"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fproxy"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_proxy</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int * <var>critical</var>, int * <var>pathlen</var>, char ** <var>policyLanguage</var>, char ** <var>policy</var>, size_t * <var>sizeof_policy</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical
</p>
<p><var>pathlen</var>: pointer to output integer indicating path length (may be
NULL), non-negative error codes indicate a present pCPathLenConstraint
field and the actual value, -1 indicate that the field is absent.
</p>
<p><var>policyLanguage</var>: output variable with OID of policy language
</p>
<p><var>policy</var>: output variable with policy data
</p>
<p><var>sizeof_policy</var>: output variable size of policy data
</p>
<p>This function will get information from a proxy certificate. It
reads the ProxyCertInfo X.509 extension (1.3.6.1.5.5.7.1.14).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fraw_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_raw_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fraw_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fraw_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_raw_dn</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_datum_t * <var>start</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>start</var>: will hold the starting point of the DN
</p>
<p>This function will return a pointer to the DER encoded DN structure and
the length. This points to allocated data that must be free’d using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fraw_005fissuer_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_raw_issuer_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fraw_005fissuer_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fraw_005fissuer_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_raw_issuer_dn</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_datum_t * <var>start</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>start</var>: will hold the starting point of the DN
</p>
<p>This function will return a pointer to the DER encoded DN structure
and the length. This points to allocated data that must be free’d using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fserial-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_serial</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fserial"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fserial"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_serial</strong> <em>(gnutls_x509_crt_t <var>cert</var>, void * <var>result</var>, size_t * <var>result_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>result</var>: The place where the serial number will be copied
</p>
<p><var>result_size</var>: Holds the size of the result field.
</p>
<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 uint8_t.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsignature-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_signature</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsignature"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsignature"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_signature</strong> <em>(gnutls_x509_crt_t <var>cert</var>, char * <var>sig</var>, size_t * <var>sizeof_sig</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>sig</var>: a pointer where the signature part will be copied (may be null).
</p>
<p><var>sizeof_sig</var>: initially holds the size of <code>sig</code>
</p>
<p>This function will extract the signature field of a certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. and a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_signature_algorithm</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_signature_algorithm</strong> <em>(gnutls_x509_crt_t <var>cert</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p>This function will return a value of the <code>gnutls_sign_algorithm_t</code>
enumeration that is the signature algorithm that has been used to
sign this certificate.
</p>
<p><strong>Returns:</strong> a <code>gnutls_sign_algorithm_t</code> value, or a negative error code on
error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_subject</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_subject</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_x509_dn_t * <var>dn</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>dn</var>: output variable with pointer to uint8_t DN.
</p>
<p>Return the Certificate’s Subject DN as a <code>gnutls_x509_dn_t</code> data type,
that can be decoded using <code>gnutls_x509_dn_get_rdn_ava()</code> .
</p>
<p>Note that <code>dn</code> should be treated as constant. Because it points
into the <code>cert</code> object, you should not use <code>dn</code> after <code>cert</code> is
deallocated.
</p>
<p><strong>Returns:</strong> Returns 0 on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_subject_alt_name</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_subject_alt_name</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>san</var>, size_t * <var>san_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>san</var>: is the place where the alternative name will be copied to
</p>
<p><var>san_size</var>: holds the size of san.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function retrieves the Alternative Name (2.5.29.17), contained
in the given certificate in the X509v3 Certificate Extensions.
</p>
<p>When the SAN type is otherName, it will extract the data in the
otherName’s value field, and <code>GNUTLS_SAN_OTHERNAME</code> is returned.
You may use <code>gnutls_x509_crt_get_subject_alt_othername_oid()</code> to get
the corresponding OID and the "virtual" SAN types (e.g.,
<code>GNUTLS_SAN_OTHERNAME_XMPP</code> ).
</p>
<p>If an otherName OID is known, the data will be decoded. Otherwise
the returned data will be DER encoded, and you will have to decode
it yourself. Currently, only the RFC 3920 id-on-xmppAddr SAN is
recognized.
</p>
<p><strong>Returns:</strong> the alternative subject name type on success, one of the
enumerated <code>gnutls_x509_subject_alt_name_t</code> . It will return
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if <code>san_size</code> is not large enough to
hold the value. In that case <code>san_size</code> will be updated with the
required size. If the certificate does not have an Alternative
name with the specified sequence number then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname2-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_subject_alt_name2</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname2"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_subject_alt_name2</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>san</var>, size_t * <var>san_size</var>, unsigned int * <var>san_type</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>san</var>: is the place where the alternative name will be copied to
</p>
<p><var>san_size</var>: holds the size of ret.
</p>
<p><var>san_type</var>: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<p>This function will return the alternative names, contained in the
given certificate. It is the same as
<code>gnutls_x509_crt_get_subject_alt_name()</code> except for the fact that it
will return the type of the alternative name in <code>san_type</code> even if
the function fails for some reason (i.e. the buffer provided is
not enough).
</p>
<p><strong>Returns:</strong> the alternative subject name type on success, one of the
enumerated <code>gnutls_x509_subject_alt_name_t</code> . It will return
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if <code>san_size</code> is not large enough
to hold the value. In that case <code>san_size</code> will be updated with
the required size. If the certificate does not have an
Alternative name with the specified sequence number then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fothername_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_subject_alt_othername_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fothername_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fothername_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_subject_alt_othername_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, unsigned int <var>seq</var>, void * <var>oid</var>, size_t * <var>oid_size</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>seq</var>: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
</p>
<p><var>oid</var>: is the place where the otherName OID will be copied to
</p>
<p><var>oid_size</var>: holds the size of ret.
</p>
<p>This function will extract the type OID of an otherName Subject
Alternative Name, contained in the given certificate, and return
the type as an enumerated element.
</p>
<p>This function is only useful if
<code>gnutls_x509_crt_get_subject_alt_name()</code> returned
<code>GNUTLS_SAN_OTHERNAME</code> .
</p>
<p>If <code>oid</code> is null then only the size will be filled. The <code>oid</code> returned will be null terminated, although <code>oid_size</code> will not
account for the trailing null.
</p>
<p><strong>Returns:</strong> the alternative subject name type on success, one of the
enumerated gnutls_x509_subject_alt_name_t. For supported OIDs, it
will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types,
e.g. <code>GNUTLS_SAN_OTHERNAME_XMPP</code> , and <code>GNUTLS_SAN_OTHERNAME</code> for
unknown OIDs. It will return <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> if
<code>ian_size</code> is not large enough to hold the value. In that case
<code>ian_size</code> will be updated with the required size. If the
certificate does not have an Alternative name with the specified
sequence number and with the otherName type then
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_subject_key_id</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_subject_key_id</strong> <em>(gnutls_x509_crt_t <var>cert</var>, void * <var>ret</var>, size_t * <var>ret_size</var>, unsigned int * <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>ret</var>: The place where the identifier will be copied
</p>
<p><var>ret_size</var>: Holds the size of the result field.
</p>
<p><var>critical</var>: will be non-zero if the extension is marked as critical (may be null)
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
if the extension is not present, otherwise a negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005funique_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_subject_unique_id</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fsubject_005funique_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fsubject_005funique_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_subject_unique_id</strong> <em>(gnutls_x509_crt_t <var>crt</var>, char * <var>buf</var>, size_t * <var>buf_size</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>buf</var>: user allocated memory buffer, will hold the unique id
</p>
<p><var>buf_size</var>: size of user allocated memory buffer (on input), will hold
actual size of the unique ID on return.
</p>
<p>This function will extract the subjectUniqueID value (if present) for
the given certificate.
</p>
<p>If the user allocated memory buffer is not large enough to hold the
full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be
returned, and buf_size will be set to the actual length.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_version</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fversion"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_version</strong> <em>(gnutls_x509_crt_t <var>cert</var>)</em></dt>
<dd><p><var>cert</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p>This function will return the version of the specified Certificate.
</p>
<p><strong>Returns:</strong> version of certificate, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_crt_import</h4>
<a name="gnutls_005fx509_005fcrt_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_crt_import</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>cert</var>: The structure to store the parsed certificate.
</p>
<p><var>data</var>: The DER or PEM encoded certificate.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<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>
<p>If the Certificate is PEM encoded it should have a header of "X509
CERTIFICATE", or "CERTIFICATE".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005finit-1"></a>
<h4 class="subheading">gnutls_x509_crt_init</h4>
<a name="gnutls_005fx509_005fcrt_005finit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005finit"></a>Function: <em>int</em> <strong>gnutls_x509_crt_init</strong> <em>(gnutls_x509_crt_t * <var>cert</var>)</em></dt>
<dd><p><var>cert</var>: The structure to be initialized
</p>
<p>This function will initialize an X.509 certificate structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_crt_list_import</h4>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005flist_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_crt_list_import</strong> <em>(gnutls_x509_crt_t * <var>certs</var>, unsigned int * <var>cert_max</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>certs</var>: The structures to store the parsed certificate. Must not be initialized.
</p>
<p><var>cert_max</var>: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
</p>
<p><var>data</var>: The PEM encoded certificate.
</p>
<p><var>format</var>: One of DER or PEM.
</p>
<p><var>flags</var>: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
</p>
<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>
<p>The flag <code>GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED</code> will cause
import to fail if the certificates in the provided buffer are more
than the available structures. The <code>GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED</code>
flag will cause the function to fail if the provided list is not
sorted from subject to issuer.
</p>
<p>If the Certificate is PEM encoded it should have a header of "X509
CERTIFICATE", or "CERTIFICATE".
</p>
<p><strong>Returns:</strong> the number of certificates read or a negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport2-1"></a>
<h4 class="subheading">gnutls_x509_crt_list_import2</h4>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005flist_005fimport2"></a>Function: <em>int</em> <strong>gnutls_x509_crt_list_import2</strong> <em>(gnutls_x509_crt_t ** <var>certs</var>, unsigned int * <var>size</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>certs</var>: The structures to store the parsed certificate. Must not be initialized.
</p>
<p><var>size</var>: It will contain the size of the list.
</p>
<p><var>data</var>: The PEM encoded certificate.
</p>
<p><var>format</var>: One of DER or PEM.
</p>
<p><var>flags</var>: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
</p>
<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> which will be initialized.
</p>
<p>If the Certificate is PEM encoded it should have a header of "X509
CERTIFICATE", or "CERTIFICATE".
</p>
<p><strong>Returns:</strong> the number of certificates read or a negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005flist_005fverify-1"></a>
<h4 class="subheading">gnutls_x509_crt_list_verify</h4>
<a name="gnutls_005fx509_005fcrt_005flist_005fverify"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005flist_005fverify"></a>Function: <em>int</em> <strong>gnutls_x509_crt_list_verify</strong> <em>(const gnutls_x509_crt_t * <var>cert_list</var>, int <var>cert_list_length</var>, const gnutls_x509_crt_t * <var>CA_list</var>, int <var>CA_list_length</var>, const gnutls_x509_crl_t * <var>CRL_list</var>, int <var>CRL_list_length</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>cert_list</var>: is the certificate list to be verified
</p>
<p><var>cert_list_length</var>: holds the number of certificate in cert_list
</p>
<p><var>CA_list</var>: is the CA list which will be used in verification
</p>
<p><var>CA_list_length</var>: holds the number of CA certificate in CA_list
</p>
<p><var>CRL_list</var>: holds a list of CRLs.
</p>
<p><var>CRL_list_length</var>: the length of CRL list.
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p>This function will try to verify the given certificate list and
return its status. 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>
<p>You must also check the peer’s name in order to check if the verified
certificate belongs to the actual peer.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fprint-1"></a>
<h4 class="subheading">gnutls_x509_crt_print</h4>
<a name="gnutls_005fx509_005fcrt_005fprint"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fprint"></a>Function: <em>int</em> <strong>gnutls_x509_crt_print</strong> <em>(gnutls_x509_crt_t <var>cert</var>, gnutls_certificate_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>cert</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print a X.509 certificate, suitable for
display to a human.
</p>
<p>If the format is <code>GNUTLS_CRT_PRINT_FULL</code> then all fields of the
certificate will be output, on multiple lines. The
<code>GNUTLS_CRT_PRINT_ONELINE</code> format will generate one line with some
selected fields, which is useful for logging purposes.
</p>
<p>The output <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005factivation_005ftime-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_activation_time</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005factivation_005ftime"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005factivation_005ftime"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_activation_time</strong> <em>(gnutls_x509_crt_t <var>cert</var>, time_t <var>act_time</var>)</em></dt>
<dd><p><var>cert</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>act_time</var>: The actual time
</p>
<p>This function will set the time this Certificate was or will be
activated.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fauthority_005finfo_005faccess-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_authority_info_access</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fauthority_005finfo_005faccess"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fauthority_005finfo_005faccess"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_authority_info_access</strong> <em>(gnutls_x509_crt_t <var>crt</var>, int <var>what</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>what</var>: what data to get, a <code>gnutls_info_access_what_t</code> type.
</p>
<p><var>data</var>: output data to be freed with <code>gnutls_free()</code> .
</p>
<p>This function sets the Authority Information Access (AIA)
extension, see RFC 5280 section 4.2.2.1 for more information.
</p>
<p>The type of data stored in <code>data</code> is specified via <code>what</code> which
should be <code>gnutls_info_access_what_t</code> values.
</p>
<p>If <code>what</code> is <code>GNUTLS_IA_OCSP_URI</code> , <code>data</code> will hold the OCSP URI.
If <code>what</code> is <code>GNUTLS_IA_CAISSUERS_URI</code> , <code>data</code> will hold the caIssuers
URI.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_authority_key_id</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_authority_key_id</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const void * <var>id</var>, size_t <var>id_size</var>)</em></dt>
<dd><p><var>cert</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>id</var>: The key ID
</p>
<p><var>id_size</var>: Holds the size of the serial field.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fbasic_005fconstraints-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_basic_constraints</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fbasic_005fconstraints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fbasic_005fconstraints"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_basic_constraints</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>ca</var>, int <var>pathLenConstraint</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>ca</var>: true(1) or false(0). Depending on the Certificate authority status.
</p>
<p><var>pathLenConstraint</var>: non-negative error codes indicate maximum length of path,
and negative error codes indicate that the pathLenConstraints field should
not be present.
</p>
<p>This function will set the basicConstraints certificate extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fca_005fstatus-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_ca_status</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fca_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fca_005fstatus"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_ca_status</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>ca</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>ca</var>: true(1) or false(0). Depending on the Certificate authority status.
</p>
<p>This function will set the basicConstraints certificate extension.
Use <code>gnutls_x509_crt_set_basic_constraints()</code> if you want to control
the pathLenConstraint field too.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_crl_dist_points</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_crl_dist_points</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_subject_alt_name_t <var>type</var>, const void * <var>data_string</var>, unsigned int <var>reason_flags</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>type</var>: is one of the gnutls_x509_subject_alt_name_t enumerations
</p>
<p><var>data_string</var>: The data to be set
</p>
<p><var>reason_flags</var>: revocation reasons
</p>
<p>This function will set the CRL distribution points certificate extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints2-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_crl_dist_points2</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints2"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_crl_dist_points2</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_subject_alt_name_t <var>type</var>, const void * <var>data</var>, unsigned int <var>data_size</var>, unsigned int <var>reason_flags</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>type</var>: is one of the gnutls_x509_subject_alt_name_t enumerations
</p>
<p><var>data</var>: The data to be set
</p>
<p><var>data_size</var>: The data size
</p>
<p><var>reason_flags</var>: revocation reasons
</p>
<p>This function will set the CRL distribution points certificate extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrq-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_crq</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrq"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fcrq"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_crq</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crq_t <var>crq</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>crq</var>: holds a certificate request
</p>
<p>This function will set the name and public parameters as well as
the extensions from the given certificate request to the certificate.
Only RSA keys are currently supported.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrq_005fextensions-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_crq_extensions</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fcrq_005fextensions"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fcrq_005fextensions"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_crq_extensions</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crq_t <var>crq</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>crq</var>: holds a certificate request
</p>
<p>This function will set extensions from the given request to the
certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_dn</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const char * <var>dn</var>, const char** <var>err</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>dn</var>: a comma separated DN string (RFC4514)
</p>
<p><var>err</var>: indicates the error position (if any)
</p>
<p>This function will set the DN on the provided certificate.
The input string should be plain ASCII or UTF-8 encoded.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_dn_by_oid</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const char * <var>oid</var>, unsigned int <var>raw_flag</var>, const void * <var>name</var>, unsigned int <var>sizeof_name</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>oid</var>: holds an Object Identifier in a null terminated string
</p>
<p><var>raw_flag</var>: must be 0, or 1 if the data are DER encoded
</p>
<p><var>name</var>: a pointer to the name
</p>
<p><var>sizeof_name</var>: holds the size of <code>name</code>
</p>
<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>
<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 <code>raw_flag</code> set.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_expiration_time</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_expiration_time</strong> <em>(gnutls_x509_crt_t <var>cert</var>, time_t <var>exp_time</var>)</em></dt>
<dd><p><var>cert</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>exp_time</var>: The actual time
</p>
<p>This function will set the time this Certificate will expire.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_extension_by_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_extension_by_oid</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const char * <var>oid</var>, const void * <var>buf</var>, size_t <var>sizeof_buf</var>, unsigned int <var>critical</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>oid</var>: holds an Object Identified in null terminated string
</p>
<p><var>buf</var>: a pointer to a DER encoded data
</p>
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
</p>
<p><var>critical</var>: should be non-zero if the extension is to be marked as critical
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_issuer_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_issuer_dn</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const char * <var>dn</var>, const char** <var>err</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>dn</var>: a comma separated DN string (RFC4514)
</p>
<p><var>err</var>: indicates the error position (if any)
</p>
<p>This function will set the DN on the provided certificate.
The input string should be plain ASCII or UTF-8 encoded.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_issuer_dn_by_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_issuer_dn_by_oid</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const char * <var>oid</var>, unsigned int <var>raw_flag</var>, const void * <var>name</var>, unsigned int <var>sizeof_name</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>oid</var>: holds an Object Identifier in a null terminated string
</p>
<p><var>raw_flag</var>: must be 0, or 1 if the data are DER encoded
</p>
<p><var>name</var>: a pointer to the name
</p>
<p><var>sizeof_name</var>: holds the size of <code>name</code>
</p>
<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>
<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 <code>raw_flag</code> set.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fkey-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_key</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fkey"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fkey"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_key</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>key</var>: holds a private key
</p>
<p>This function will set the public parameters from the given
private key to the certificate. Only RSA keys are currently
supported.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_key_purpose_oid</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_key_purpose_oid</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const void * <var>oid</var>, unsigned int <var>critical</var>)</em></dt>
<dd><p><var>cert</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>oid</var>: a pointer to a null terminated string that holds the OID
</p>
<p><var>critical</var>: Whether this extension will be critical or not
</p>
<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>
<p>Subsequent calls to this function will append OIDs to the OID list.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_key_usage</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_key_usage</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>usage</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>usage</var>: an ORed sequence of the GNUTLS_KEY_* elements.
</p>
<p>This function will set the keyUsage certificate extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_pin_function</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_x509_crt_set_pin_function</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>crt</var>: The certificate structure
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
it is required to access a protected object. This function overrides
the global function set using <code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p>Note that this callback is currently used only during the import
of a PKCS <code>11</code> certificate with <code>gnutls_x509_crt_import_pkcs11_url()</code> .
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fpolicy-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_policy</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fpolicy"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fpolicy"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_policy</strong> <em>(gnutls_x509_crt_t <var>crt</var>, struct gnutls_x509_policy_st* <var>policy</var>, unsigned int <var>critical</var>)</em></dt>
<dd><p><var>crt</var>: – undescribed –
</p>
<p><var>policy</var>: A pointer to a policy structure.
</p>
<p><var>critical</var>: use non-zero if the extension is marked as critical
</p>
<p>This function will set the certificate policy extension (2.5.29.32).
Multiple calls to this function append a new policy.
</p>
<p>Note the maximum text size for the qualifier <code>GNUTLS_X509_QUALIFIER_NOTICE</code>
is 200 characters. This function will fail with <code>GNUTLS_E_INVALID_REQUEST</code>
if this is exceeded.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.5
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fprivate_005fkey_005fusage_005fperiod-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_private_key_usage_period</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fprivate_005fkey_005fusage_005fperiod"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fprivate_005fkey_005fusage_005fperiod"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_private_key_usage_period</strong> <em>(gnutls_x509_crt_t <var>crt</var>, time_t <var>activation</var>, time_t <var>expiration</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>activation</var>: The activation time
</p>
<p><var>expiration</var>: The expiration time
</p>
<p>This function will set the private key usage period extension (2.5.29.16).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fproxy-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_proxy</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fproxy"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fproxy"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_proxy</strong> <em>(gnutls_x509_crt_t <var>crt</var>, int <var>pathLenConstraint</var>, const char * <var>policyLanguage</var>, const char * <var>policy</var>, size_t <var>sizeof_policy</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>pathLenConstraint</var>: non-negative error codes indicate maximum length of path,
and negative error codes indicate that the pathLenConstraints field should
not be present.
</p>
<p><var>policyLanguage</var>: OID describing the language of <code>policy</code> .
</p>
<p><var>policy</var>: uint8_t byte array with policy language, can be <code>NULL</code>
</p>
<p><var>sizeof_policy</var>: size of <code>policy</code> .
</p>
<p>This function will set the proxyCertInfo extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fproxy_005fdn-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_proxy_dn</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fproxy_005fdn"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fproxy_005fdn"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_proxy_dn</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crt_t <var>eecrt</var>, unsigned int <var>raw_flag</var>, const void * <var>name</var>, unsigned int <var>sizeof_name</var>)</em></dt>
<dd><p><var>crt</var>: a gnutls_x509_crt_t structure with the new proxy cert
</p>
<p><var>eecrt</var>: the end entity certificate that will be issuing the proxy
</p>
<p><var>raw_flag</var>: must be 0, or 1 if the CN is DER encoded
</p>
<p><var>name</var>: a pointer to the CN name, may be NULL (but MUST then be added later)
</p>
<p><var>sizeof_name</var>: holds the size of <code>name</code>
</p>
<p>This function will set the subject in <code>crt</code> to the end entity’s
<code>eecrt</code> subject name, and add a single Common Name component <code>name</code> of size <code>sizeof_name</code> . This corresponds to the required proxy
certificate naming style. Note that if <code>name</code> is <code>NULL</code> , you MUST
set it later by using <code>gnutls_x509_crt_set_dn_by_oid()</code> or similar.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fserial-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_serial</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fserial"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fserial"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_serial</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const void * <var>serial</var>, size_t <var>serial_size</var>)</em></dt>
<dd><p><var>cert</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>serial</var>: The serial number
</p>
<p><var>serial_size</var>: Holds the size of the serial field.
</p>
<p>This function will set the X.509 certificate’s serial number.
While the serial number is an integer, it is often handled
as an opaque field by several CAs. For this reason this function
accepts any kind of data as a serial number. To be consistent
with the X.509/PKIX specifications the provided <code>serial</code> should be
a big-endian positive number (i.e. it’s leftmost bit should be zero).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005falt_005fname-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_subject_alt_name</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005falt_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fsubject_005falt_005fname"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_subject_alt_name</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_subject_alt_name_t <var>type</var>, const void * <var>data</var>, unsigned int <var>data_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>type</var>: is one of the gnutls_x509_subject_alt_name_t enumerations
</p>
<p><var>data</var>: The data to be set
</p>
<p><var>data_size</var>: The size of data to be set
</p>
<p><var>flags</var>: GNUTLS_FSAN_SET to clear previous data or GNUTLS_FSAN_APPEND to append.
</p>
<p>This function will set the subject alternative name certificate
extension. It can set the following types:
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.6.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_subject_alternative_name</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_subject_alternative_name</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_subject_alt_name_t <var>type</var>, const char * <var>data_string</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>type</var>: is one of the gnutls_x509_subject_alt_name_t enumerations
</p>
<p><var>data_string</var>: The data to be set, a (0) terminated string
</p>
<p>This function will set the subject alternative name certificate
extension. This function assumes that data can be expressed as a null
terminated string.
</p>
<p>The name of the function is unfortunate since it is incosistent with
<code>gnutls_x509_crt_get_subject_alt_name()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_subject_key_id</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_subject_key_id</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const void * <var>id</var>, size_t <var>id_size</var>)</em></dt>
<dd><p><var>cert</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>id</var>: The key ID
</p>
<p><var>id_size</var>: Holds the size of the serial field.
</p>
<p>This function will set the X.509 certificate’s subject key ID
extension.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fversion-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_version</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fversion"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fversion"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_version</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>version</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>version</var>: holds the version number. For X.509v1 certificates must be 1.
</p>
<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>
<p>To create well-formed certificates, you must specify version 3 if
you use any certificate extensions. Extensions are created by
functions such as <code>gnutls_x509_crt_set_subject_alt_name()</code>
or <code>gnutls_x509_crt_set_key_usage()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fsign-1"></a>
<h4 class="subheading">gnutls_x509_crt_sign</h4>
<a name="gnutls_005fx509_005fcrt_005fsign"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fsign"></a>Function: <em>int</em> <strong>gnutls_x509_crt_sign</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_privkey_t <var>issuer_key</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p>This function is the same a <code>gnutls_x509_crt_sign2()</code> with no flags,
and SHA1 as the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fsign2-1"></a>
<h4 class="subheading">gnutls_x509_crt_sign2</h4>
<a name="gnutls_005fx509_005fcrt_005fsign2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fsign2"></a>Function: <em>int</em> <strong>gnutls_x509_crt_sign2</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p><var>dig</var>: The message digest to use, <code>GNUTLS_DIG_SHA1</code> is a safe choice
</p>
<p><var>flags</var>: must be 0
</p>
<p>This function will sign the certificate with the issuer’s private key, and
will copy the issuer’s information into the certificate.
</p>
<p>This must be the last step in a certificate generation since all
the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fverify-1"></a>
<h4 class="subheading">gnutls_x509_crt_verify</h4>
<a name="gnutls_005fx509_005fcrt_005fverify"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fverify"></a>Function: <em>int</em> <strong>gnutls_x509_crt_verify</strong> <em>(gnutls_x509_crt_t <var>cert</var>, const gnutls_x509_crt_t * <var>CA_list</var>, int <var>CA_list_length</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>cert</var>: is the certificate to be verified
</p>
<p><var>CA_list</var>: is one certificate that is considered to be trusted one
</p>
<p><var>CA_list_length</var>: holds the number of CA certificate in CA_list
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p>This function will try to verify the given certificate and return
its status.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005fdeinit-1"></a>
<h4 class="subheading">gnutls_x509_dn_deinit</h4>
<a name="gnutls_005fx509_005fdn_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_x509_dn_deinit</strong> <em>(gnutls_x509_dn_t <var>dn</var>)</em></dt>
<dd><p><var>dn</var>: a DN uint8_t object pointer.
</p>
<p>This function deallocates the DN object as returned by
<code>gnutls_x509_dn_import()</code> .
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005fexport-1"></a>
<h4 class="subheading">gnutls_x509_dn_export</h4>
<a name="gnutls_005fx509_005fdn_005fexport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005fexport"></a>Function: <em>int</em> <strong>gnutls_x509_dn_export</strong> <em>(gnutls_x509_dn_t <var>dn</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>dn</var>: Holds the uint8_t DN object
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a DN PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the DN to DER or PEM format.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>output_data_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code>
will be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN NAME".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005fexport2-1"></a>
<h4 class="subheading">gnutls_x509_dn_export2</h4>
<a name="gnutls_005fx509_005fdn_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005fexport2"></a>Function: <em>int</em> <strong>gnutls_x509_dn_export2</strong> <em>(gnutls_x509_dn_t <var>dn</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>dn</var>: Holds the uint8_t DN object
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a DN PEM or DER encoded
</p>
<p>This function will export the DN to DER or PEM format.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN NAME".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005fget_005frdn_005fava-1"></a>
<h4 class="subheading">gnutls_x509_dn_get_rdn_ava</h4>
<a name="gnutls_005fx509_005fdn_005fget_005frdn_005fava"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005fget_005frdn_005fava-1"></a>Function: <em>int</em> <strong>gnutls_x509_dn_get_rdn_ava</strong> <em>(gnutls_x509_dn_t <var>dn</var>, int <var>irdn</var>, int <var>iava</var>, gnutls_x509_ava_st * <var>ava</var>)</em></dt>
<dd><p><var>dn</var>: a pointer to DN
</p>
<p><var>irdn</var>: index of RDN
</p>
<p><var>iava</var>: index of AVA.
</p>
<p><var>ava</var>: Pointer to structure which will hold output information.
</p>
<p>Get pointers to data within the DN. The format of the <code>ava</code> structure
is shown below.
</p>
<p>struct gnutls_x509_ava_st {
gnutls_datum_t oid;
gnutls_datum_t value;
unsigned long value_tag;
};
</p>
<p>The X.509 distinguished name is a sequence of sequences of strings
and this is what the <code>irdn</code> and <code>iava</code> indexes model.
</p>
<p>Note that <code>ava</code> will contain pointers into the <code>dn</code> structure which
in turns points to the original certificate. Thus you should not
modify any data or deallocate any of those.
</p>
<p>This is a low-level function that requires the caller to do the
value conversions when necessary (e.g. from UCS-2).
</p>
<p><strong>Returns:</strong> Returns 0 on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_dn_import</h4>
<a name="gnutls_005fx509_005fdn_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_dn_import</strong> <em>(gnutls_x509_dn_t <var>dn</var>, const gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>dn</var>: the structure that will hold the imported DN
</p>
<p><var>data</var>: should contain a DER encoded RDN sequence
</p>
<p>This function parses an RDN sequence and stores the result to a
<code>gnutls_x509_dn_t</code> structure. The structure must have been initialized
with <code>gnutls_x509_dn_init()</code> . You may use <code>gnutls_x509_dn_get_rdn_ava()</code> to
decode the DN.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005finit-1"></a>
<h4 class="subheading">gnutls_x509_dn_init</h4>
<a name="gnutls_005fx509_005fdn_005finit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005finit"></a>Function: <em>int</em> <strong>gnutls_x509_dn_init</strong> <em>(gnutls_x509_dn_t * <var>dn</var>)</em></dt>
<dd><p><var>dn</var>: the object to be initialized
</p>
<p>This function initializes a <code>gnutls_x509_dn_t</code> structure.
</p>
<p>The object returned must be deallocated using
<code>gnutls_x509_dn_deinit()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005foid_005fknown-1"></a>
<h4 class="subheading">gnutls_x509_dn_oid_known</h4>
<a name="gnutls_005fx509_005fdn_005foid_005fknown"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005foid_005fknown"></a>Function: <em>int</em> <strong>gnutls_x509_dn_oid_known</strong> <em>(const char * <var>oid</var>)</em></dt>
<dd><p><var>oid</var>: holds an Object Identifier in a null terminated string
</p>
<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>
<p><strong>Returns:</strong> 1 on known OIDs and 0 otherwise.
</p></dd></dl>
<a name="gnutls_005fx509_005fdn_005foid_005fname-1"></a>
<h4 class="subheading">gnutls_x509_dn_oid_name</h4>
<a name="gnutls_005fx509_005fdn_005foid_005fname"></a><dl>
<dt><a name="index-gnutls_005fx509_005fdn_005foid_005fname"></a>Function: <em>const char*</em> <strong>gnutls_x509_dn_oid_name</strong> <em>(const char * <var>oid</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>oid</var>: holds an Object Identifier in a null terminated string
</p>
<p><var>flags</var>: 0 or GNUTLS_X509_DN_OID_*
</p>
<p>This function will return the name of a known DN OID. If
<code>GNUTLS_X509_DN_OID_RETURN_OID</code> is specified this function
will return the given OID if no descriptive name has been
found.
</p>
<p><strong>Returns:</strong> A null terminated string or NULL otherwise.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fpolicy_005frelease-1"></a>
<h4 class="subheading">gnutls_x509_policy_release</h4>
<a name="gnutls_005fx509_005fpolicy_005frelease"></a><dl>
<dt><a name="index-gnutls_005fx509_005fpolicy_005frelease"></a>Function: <em>void</em> <strong>gnutls_x509_policy_release</strong> <em>(struct gnutls_x509_policy_st* <var>policy</var>)</em></dt>
<dd><p><var>policy</var>: a certificate policy
</p>
<p>This function will deinitialize all memory associated with the provided
<code>policy</code> . The policy is allocated using <code>gnutls_x509_crt_get_policy()</code> .
</p>
<p><strong>Since:</strong> 3.1.5
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fcpy-1"></a>
<h4 class="subheading">gnutls_x509_privkey_cpy</h4>
<a name="gnutls_005fx509_005fprivkey_005fcpy"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fcpy"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_cpy</strong> <em>(gnutls_x509_privkey_t <var>dst</var>, gnutls_x509_privkey_t <var>src</var>)</em></dt>
<dd><p><var>dst</var>: The destination key, which should be initialized.
</p>
<p><var>src</var>: The source key
</p>
<p>This function will copy a private key from source to destination
key. Destination has to be initialized.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fdeinit-1"></a>
<h4 class="subheading">gnutls_x509_privkey_deinit</h4>
<a name="gnutls_005fx509_005fprivkey_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_x509_privkey_deinit</strong> <em>(gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a private key structure.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a private key PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<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>
<p>If the buffer provided is not long enough to hold the output, then
* <code>output_data_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code>
will be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN RSA PRIVATE KEY".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport2-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export2</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport2"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export2</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a private key PEM or DER encoded
</p>
<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>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN RSA PRIVATE KEY".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p>Since 3.1.3
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport2_005fpkcs8-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export2_pkcs8</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport2_005fpkcs8"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport2_005fpkcs8"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export2_pkcs8</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>password</var>: the password that will be used to encrypt the key.
</p>
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
</p>
<p><var>out</var>: will contain a private key PEM or DER encoded
</p>
<p>This function will export the private key to a PKCS8 structure.
Both RSA and DSA keys can be exported. For DSA keys we use
PKCS <code>11</code> definitions. If the flags do not specify the encryption
cipher, then the default 3DES (PBES2) will be used.
</p>
<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>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<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>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p>Since 3.1.3
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export_dsa_raw</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export_dsa_raw</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>, gnutls_datum_t * <var>x</var>)</em></dt>
<dd><p><var>key</var>: a structure that holds the DSA parameters
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p><var>x</var>: will hold the x
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport_005fecc_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export_ecc_raw</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport_005fecc_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport_005fecc_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export_ecc_raw</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_ecc_curve_t * <var>curve</var>, gnutls_datum_t * <var>x</var>, gnutls_datum_t * <var>y</var>, gnutls_datum_t* <var>k</var>)</em></dt>
<dd><p><var>key</var>: a structure that holds the rsa parameters
</p>
<p><var>curve</var>: will hold the curve
</p>
<p><var>x</var>: will hold the x coordinate
</p>
<p><var>y</var>: will hold the y coordinate
</p>
<p><var>k</var>: will hold the private key
</p>
<p>This function will export the ECC 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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport_005fpkcs8-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export_pkcs8</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport_005fpkcs8"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport_005fpkcs8"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export_pkcs8</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>password</var>: the password that will be used to encrypt the key.
</p>
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
</p>
<p><var>output_data</var>: will contain a private key PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the private key to a PKCS8 structure.
Both RSA and DSA keys can be exported. For DSA keys we use
PKCS <code>11</code> definitions. If the flags do not specify the encryption
cipher, then the default 3DES (PBES2) will be used.
</p>
<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>
<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>
<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>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export_rsa_raw</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export_rsa_raw</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>, gnutls_datum_t * <var>d</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>u</var>)</em></dt>
<dd><p><var>key</var>: a structure that holds the rsa parameters
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p><var>d</var>: will hold the private exponent
</p>
<p><var>p</var>: will hold the first prime (p)
</p>
<p><var>q</var>: will hold the second prime (q)
</p>
<p><var>u</var>: will hold the coefficient
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw2-1"></a>
<h4 class="subheading">gnutls_x509_privkey_export_rsa_raw2</h4>
<a name="gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw2"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_export_rsa_raw2</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>, gnutls_datum_t * <var>d</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>u</var>, gnutls_datum_t * <var>e1</var>, gnutls_datum_t * <var>e2</var>)</em></dt>
<dd><p><var>key</var>: a structure that holds the rsa parameters
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p><var>d</var>: will hold the private exponent
</p>
<p><var>p</var>: will hold the first prime (p)
</p>
<p><var>q</var>: will hold the second prime (q)
</p>
<p><var>u</var>: will hold the coefficient
</p>
<p><var>e1</var>: will hold e1 = d mod (p-1)
</p>
<p><var>e2</var>: will hold e2 = d mod (q-1)
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005ffix-1"></a>
<h4 class="subheading">gnutls_x509_privkey_fix</h4>
<a name="gnutls_005fx509_005fprivkey_005ffix"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005ffix"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_fix</strong> <em>(gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p>This function will recalculate the secondary parameters in a key.
In RSA keys, this can be the coefficient and exponent1,2.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fgenerate-1"></a>
<h4 class="subheading">gnutls_x509_privkey_generate</h4>
<a name="gnutls_005fx509_005fprivkey_005fgenerate"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fgenerate"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_generate</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_pk_algorithm_t <var>algo</var>, unsigned int <var>bits</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_x509_privkey_t</code> structure
</p>
<p><var>algo</var>: is one of the algorithms in <code>gnutls_pk_algorithm_t</code> .
</p>
<p><var>bits</var>: the size of the modulus
</p>
<p><var>flags</var>: unused for now. Must be 0.
</p>
<p>This function will generate a random private key. Note that this
function must be called on an empty private key.
</p>
<p>Do not set the number of bits directly, use <code>gnutls_sec_param_to_pk_bits()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_x509_privkey_get_key_id</h4>
<a name="gnutls_005fx509_005fprivkey_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_get_key_id</strong> <em>(gnutls_x509_privkey_t <var>key</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>output_data</var>: will contain the key ID
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will return a unique ID that depends on the public key
parameters. This ID can be used in checking whether a certificate
corresponds to the given key.
</p>
<p>If the buffer provided is not long enough to hold the output, then
* <code>output_data_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_privkey_get_pk_algorithm</h4>
<a name="gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_get_pk_algorithm</strong> <em>(gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_x509_privkey_t</code> structure
</p>
<p>This function will return the public key algorithm of a private
key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm2-1"></a>
<h4 class="subheading">gnutls_x509_privkey_get_pk_algorithm2</h4>
<a name="gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm2"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_get_pk_algorithm2</strong> <em>(gnutls_x509_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_x509_privkey_t</code> structure
</p>
<p><var>bits</var>: The number of bits in the public key algorithm
</p>
<p>This function will return the public key algorithm of a private
key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>data</var>: The DER or PEM encoded certificate.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p>This function will convert the given DER or PEM encoded key to the
native <code>gnutls_x509_privkey_t</code> format. The output will be stored in
<code>key</code> .
</p>
<p>If the key is PEM encoded it should have a header that contains "PRIVATE
KEY". Note that this function falls back to PKCS <code>8</code> decoding without
password, if the default format fails to import.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport2-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import2</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport2-1"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import2</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char* <var>password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>data</var>: The DER or PEM encoded key.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p><var>password</var>: A password (optional)
</p>
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
</p>
<p>This function will import the given DER or PEM encoded key, to
the native <code>gnutls_x509_privkey_t</code> format, irrespective of the
input format. The input format is auto-detected.
</p>
<p>The supported formats are basic unencrypted key, PKCS <code>8</code> , PKCS <code>12</code> ,
and the openssl format.
</p>
<p>If the provided key is encrypted but no password was given, then
<code>GNUTLS_E_DECRYPTION_FAILED</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import_dsa_raw</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_dsa_raw</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>p</var>, const gnutls_datum_t * <var>q</var>, const gnutls_datum_t * <var>g</var>, const gnutls_datum_t * <var>y</var>, const gnutls_datum_t * <var>x</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>p</var>: holds the p
</p>
<p><var>q</var>: holds the q
</p>
<p><var>g</var>: holds the g
</p>
<p><var>y</var>: holds the y
</p>
<p><var>x</var>: holds the x
</p>
<p>This function will convert the given DSA raw parameters to the
native <code>gnutls_x509_privkey_t</code> format. The output will be stored
in <code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fecc_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import_ecc_raw</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fecc_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fecc_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_ecc_raw</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_ecc_curve_t <var>curve</var>, const gnutls_datum_t * <var>x</var>, const gnutls_datum_t * <var>y</var>, const gnutls_datum_t * <var>k</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>curve</var>: holds the curve
</p>
<p><var>x</var>: holds the x
</p>
<p><var>y</var>: holds the y
</p>
<p><var>k</var>: holds the k
</p>
<p>This function will convert the given elliptic curve parameters to the
native <code>gnutls_x509_privkey_t</code> format. The output will be stored
in <code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fopenssl-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import_openssl</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fopenssl"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fopenssl-1"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_openssl</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, const char* <var>password</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>data</var>: The DER or PEM encoded key.
</p>
<p><var>password</var>: the password to decrypt the key (if it is encrypted).
</p>
<p>This function will convert the given PEM encrypted to
the native gnutls_x509_privkey_t format. The
output will be stored in <code>key</code> .
</p>
<p>The <code>password</code> should be in ASCII. If the password is not provided
or wrong then <code>GNUTLS_E_DECRYPTION_FAILED</code> will be returned.
</p>
<p>If the Certificate is PEM encoded it should have a header of
"PRIVATE KEY" and the "DEK-Info" header.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fpkcs8-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import_pkcs8</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport_005fpkcs8"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005fpkcs8"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_pkcs8</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>data</var>: The DER or PEM encoded key.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p><var>password</var>: the password to decrypt the key (if it is encrypted).
</p>
<p><var>flags</var>: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted.
</p>
<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> . Both RSA and DSA keys can be
imported, and flags can only be used to indicate an unencrypted
key.
</p>
<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>
<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>
<p>If the <code>GNUTLS_PKCS_PLAIN</code> flag is specified and the supplied data
are encrypted then <code>GNUTLS_E_DECRYPTION_FAILED</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import_rsa_raw</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_rsa_raw</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>m</var>, const gnutls_datum_t * <var>e</var>, const gnutls_datum_t * <var>d</var>, const gnutls_datum_t * <var>p</var>, const gnutls_datum_t * <var>q</var>, const gnutls_datum_t * <var>u</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>m</var>: holds the modulus
</p>
<p><var>e</var>: holds the public exponent
</p>
<p><var>d</var>: holds the private exponent
</p>
<p><var>p</var>: holds the first prime (p)
</p>
<p><var>q</var>: holds the second prime (q)
</p>
<p><var>u</var>: holds the coefficient
</p>
<p>This function will convert the given RSA raw parameters to the
native <code>gnutls_x509_privkey_t</code> format. The output will be stored in
<code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw2-1"></a>
<h4 class="subheading">gnutls_x509_privkey_import_rsa_raw2</h4>
<a name="gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw2"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw2"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_import_rsa_raw2</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>m</var>, const gnutls_datum_t * <var>e</var>, const gnutls_datum_t * <var>d</var>, const gnutls_datum_t * <var>p</var>, const gnutls_datum_t * <var>q</var>, const gnutls_datum_t * <var>u</var>, const gnutls_datum_t * <var>e1</var>, const gnutls_datum_t * <var>e2</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>m</var>: holds the modulus
</p>
<p><var>e</var>: holds the public exponent
</p>
<p><var>d</var>: holds the private exponent
</p>
<p><var>p</var>: holds the first prime (p)
</p>
<p><var>q</var>: holds the second prime (q)
</p>
<p><var>u</var>: holds the coefficient
</p>
<p><var>e1</var>: holds e1 = d mod (p-1)
</p>
<p><var>e2</var>: holds e2 = d mod (q-1)
</p>
<p>This function will convert the given RSA raw parameters to the
native <code>gnutls_x509_privkey_t</code> format. The output will be stored in
<code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005finit-1"></a>
<h4 class="subheading">gnutls_x509_privkey_init</h4>
<a name="gnutls_005fx509_005fprivkey_005finit"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005finit"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_init</strong> <em>(gnutls_x509_privkey_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will initialize an private key structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fsec_005fparam-1"></a>
<h4 class="subheading">gnutls_x509_privkey_sec_param</h4>
<a name="gnutls_005fx509_005fprivkey_005fsec_005fparam"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fsec_005fparam"></a>Function: <em>gnutls_sec_param_t</em> <strong>gnutls_x509_privkey_sec_param</strong> <em>(gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: a key structure
</p>
<p>This function will return the security parameter appropriate with
this private key.
</p>
<p><strong>Returns:</strong> On success, a valid security parameter is returned otherwise
<code>GNUTLS_SEC_PARAM_UNKNOWN</code> is returned.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fverify_005fparams-1"></a>
<h4 class="subheading">gnutls_x509_privkey_verify_params</h4>
<a name="gnutls_005fx509_005fprivkey_005fverify_005fparams"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fverify_005fparams"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_verify_params</strong> <em>(gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_x509_privkey_t</code> structure
</p>
<p>This function will verify the private key parameters.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005frdn_005fget-1"></a>
<h4 class="subheading">gnutls_x509_rdn_get</h4>
<a name="gnutls_005fx509_005frdn_005fget"></a><dl>
<dt><a name="index-gnutls_005fx509_005frdn_005fget"></a>Function: <em>int</em> <strong>gnutls_x509_rdn_get</strong> <em>(const gnutls_datum_t * <var>idn</var>, char * <var>buf</var>, size_t * <var>sizeof_buf</var>)</em></dt>
<dd><p><var>idn</var>: should contain a DER encoded RDN sequence
</p>
<p><var>buf</var>: a pointer to a structure to hold the peer’s name
</p>
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
</p>
<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
RFC4514.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is returned and * <code>sizeof_buf</code> is
updated if the provided buffer is not long enough, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005frdn_005fget_005fby_005foid-1"></a>
<h4 class="subheading">gnutls_x509_rdn_get_by_oid</h4>
<a name="gnutls_005fx509_005frdn_005fget_005fby_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005frdn_005fget_005fby_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_rdn_get_by_oid</strong> <em>(const gnutls_datum_t * <var>idn</var>, const char * <var>oid</var>, int <var>indx</var>, unsigned int <var>raw_flag</var>, void * <var>buf</var>, size_t * <var>sizeof_buf</var>)</em></dt>
<dd><p><var>idn</var>: should contain a DER encoded RDN sequence
</p>
<p><var>oid</var>: an Object Identifier
</p>
<p><var>indx</var>: In case multiple same OIDs exist in the RDN indicates which
to send. Use 0 for the first one.
</p>
<p><var>raw_flag</var>: If non-zero then the raw DER data are returned.
</p>
<p><var>buf</var>: a pointer to a structure to hold the peer’s name
</p>
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
</p>
<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 RFC4514.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is returned and * <code>sizeof_buf</code> is
updated if the provided buffer is not long enough, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005frdn_005fget_005foid-1"></a>
<h4 class="subheading">gnutls_x509_rdn_get_oid</h4>
<a name="gnutls_005fx509_005frdn_005fget_005foid"></a><dl>
<dt><a name="index-gnutls_005fx509_005frdn_005fget_005foid"></a>Function: <em>int</em> <strong>gnutls_x509_rdn_get_oid</strong> <em>(const gnutls_datum_t * <var>idn</var>, int <var>indx</var>, void * <var>buf</var>, size_t * <var>sizeof_buf</var>)</em></dt>
<dd><p><var>idn</var>: should contain a DER encoded RDN sequence
</p>
<p><var>indx</var>: Indicates which OID to return. Use 0 for the first one.
</p>
<p><var>buf</var>: a pointer to a structure to hold the peer’s name OID
</p>
<p><var>sizeof_buf</var>: holds the size of <code>buf</code>
</p>
<p>This function will return the specified Object identifier, of the
RDN sequence.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, or
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> is returned and * <code>sizeof_buf</code> is
updated if the provided buffer is not long enough, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fcas-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_add_cas</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fcas"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcas-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_cas</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const gnutls_x509_crt_t * <var>clist</var>, int <var>clist_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>clist</var>: A list of CAs
</p>
<p><var>clist_size</var>: The length of the CA list
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will add the given certificate authorities
to the trusted list. The list of CAs must not be deinitialized
during this structure’s lifetime.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fcrls-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_add_crls</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fcrls"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcrls-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_crls</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const gnutls_x509_crl_t * <var>crl_list</var>, int <var>crl_size</var>, unsigned int <var>flags</var>, unsigned int <var>verification_flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>crl_list</var>: A list of CRLs
</p>
<p><var>crl_size</var>: The length of the CRL list
</p>
<p><var>flags</var>: if GNUTLS_TL_VERIFY_CRL is given the CRLs will be verified before being added.
</p>
<p><var>verification_flags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function will add the given certificate revocation lists
to the trusted list. The list of CRLs must not be deinitialized
during this structure’s lifetime.
</p>
<p>This function must be called after <code>gnutls_x509_trust_list_add_cas()</code>
to allow verifying the CRLs for validity.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_add_named_crt</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_named_crt</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t <var>cert</var>, const void * <var>name</var>, size_t <var>name_size</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert</var>: A certificate
</p>
<p><var>name</var>: An identifier for the certificate
</p>
<p><var>name_size</var>: The size of the identifier
</p>
<p><var>flags</var>: should be 0.
</p>
<p>This function will add the given certificate to the trusted
list and associate it with a name. The certificate will not be
be used for verification with <code>gnutls_x509_trust_list_verify_crt()</code>
but only with <code>gnutls_x509_trust_list_verify_named_crt()</code> .
</p>
<p>In principle this function can be used to set individual "server"
certificates that are trusted by the user for that specific server
but for no other purposes.
</p>
<p>The certificate must not be deinitialized during the lifetime
of the trusted list.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fsystem_005ftrust-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_add_system_trust</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005fsystem_005ftrust"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005fsystem_005ftrust-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_system_trust</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, unsigned int <var>tl_flags</var>, unsigned int <var>tl_vflags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>tl_flags</var>: GNUTLS_TL_*
</p>
<p><var>tl_vflags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function adds the system’s default trusted certificate
authorities to the trusted list. Note that on unsupported system
this function returns <code>GNUTLS_E_UNIMPLEMENTED_FEATURE</code> .
</p>
<p><strong>Returns:</strong> The number of added elements or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005ffile-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_add_trust_file</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005ffile"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005ffile-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_trust_file</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const char* <var>ca_file</var>, const char* <var>crl_file</var>, gnutls_x509_crt_fmt_t <var>type</var>, unsigned int <var>tl_flags</var>, unsigned int <var>tl_vflags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>ca_file</var>: A file containing a list of CAs (optional)
</p>
<p><var>crl_file</var>: A file containing a list of CRLs (optional)
</p>
<p><var>type</var>: The format of the certificates
</p>
<p><var>tl_flags</var>: GNUTLS_TL_*
</p>
<p><var>tl_vflags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function will add the given certificate authorities
to the trusted list. pkcs11 URLs are also accepted, instead
of files, by this function.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005fmem-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_add_trust_mem</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005fmem"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005fmem-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_add_trust_mem</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, const gnutls_datum_t * <var>cas</var>, const gnutls_datum_t * <var>crls</var>, gnutls_x509_crt_fmt_t <var>type</var>, unsigned int <var>tl_flags</var>, unsigned int <var>tl_vflags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cas</var>: A buffer containing a list of CAs (optional)
</p>
<p><var>crls</var>: A buffer containing a list of CRLs (optional)
</p>
<p><var>type</var>: The format of the certificates
</p>
<p><var>tl_flags</var>: GNUTLS_TL_*
</p>
<p><var>tl_vflags</var>: gnutls_certificate_verify_flags if flags specifies GNUTLS_TL_VERIFY_CRL
</p>
<p>This function will add the given certificate authorities
to the trusted list.
</p>
<p><strong>Returns:</strong> The number of added elements is returned.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fdeinit-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_deinit</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_x509_trust_list_deinit</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, unsigned int <var>all</var>)</em></dt>
<dd><p><var>list</var>: The structure to be deinitialized
</p>
<p><var>all</var>: if non-(0) it will deinitialize all the certificates and CRLs contained in the structure.
</p>
<p>This function will deinitialize a trust list.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fget_005fissuer-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_get_issuer</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fget_005fissuer"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fget_005fissuer"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_get_issuer</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t <var>cert</var>, gnutls_x509_crt_t * <var>issuer</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert</var>: is the certificate to find issuer for
</p>
<p><var>issuer</var>: Will hold the issuer if any. Should be treated as constant.
</p>
<p><var>flags</var>: Use (0).
</p>
<p>This function will attempt to find the issuer of the
given certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005finit-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_init</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005finit"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005finit"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_init</strong> <em>(gnutls_x509_trust_list_t * <var>list</var>, unsigned int <var>size</var>)</em></dt>
<dd><p><var>list</var>: The structure to be initialized
</p>
<p><var>size</var>: The size of the internal hash table. Use (0) for default size.
</p>
<p>This function will initialize an X.509 trust list structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_verify_crt</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_verify_crt</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t * <var>cert_list</var>, unsigned int <var>cert_list_size</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>, gnutls_verify_output_function <var>func</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert_list</var>: is the certificate list to be verified
</p>
<p><var>cert_list_size</var>: is the certificate list size
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p><var>func</var>: If non-null will be called on each chain element verification with the output.
</p>
<p>This function will try to verify the given certificate and return
its status. The <code>verify</code> parameter will hold an OR’ed sequence of
<code>gnutls_certificate_status_t</code> flags.
</p>
<p><strong>Limitation:</strong> Pathlen constraints or key usage flags are not consulted.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt-1"></a>
<h4 class="subheading">gnutls_x509_trust_list_verify_named_crt</h4>
<a name="gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt-1"></a>Function: <em>int</em> <strong>gnutls_x509_trust_list_verify_named_crt</strong> <em>(gnutls_x509_trust_list_t <var>list</var>, gnutls_x509_crt_t <var>cert</var>, const void * <var>name</var>, size_t <var>name_size</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>, gnutls_verify_output_function <var>func</var>)</em></dt>
<dd><p><var>list</var>: The structure of the list
</p>
<p><var>cert</var>: is the certificate to be verified
</p>
<p><var>name</var>: is the certificate’s name
</p>
<p><var>name_size</var>: is the certificate’s name size
</p>
<p><var>flags</var>: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p><var>func</var>: If non-null will be called on each chain element verification with the output.
</p>
<p>This function will try to find a certificate that is associated with the provided
name –see <code>gnutls_x509_trust_list_add_named_crt()</code> . If a match is found the certificate is considered valid. In addition to that
this function will also check CRLs. The <code>verify</code> parameter will hold an OR’ed sequence of
<code>gnutls_certificate_status_t</code> flags.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<hr>
<a name="OCSP-API"></a>
<div class="header">
<p>
Next: <a href="#OpenPGP-API" accesskey="n" rel="next">OpenPGP API</a>, Previous: <a href="#X509-certificate-API" accesskey="p" rel="previous">X509 certificate API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="OCSP-API-1"></a>
<h3 class="section">E.5 <acronym>OCSP</acronym> API</h3>
<a name="index-OCSP-Functions"></a>
<p>The following functions are for <acronym>OCSP</acronym> certificate status
checking. Their prototypes lie in <samp>gnutls/ocsp.h</samp>.
</p>
<a name="gnutls_005focsp_005freq_005fadd_005fcert-1"></a>
<h4 class="subheading">gnutls_ocsp_req_add_cert</h4>
<a name="gnutls_005focsp_005freq_005fadd_005fcert"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fadd_005fcert"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_add_cert</strong> <em>(gnutls_ocsp_req_t <var>req</var>, gnutls_digest_algorithm_t <var>digest</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_crt_t <var>cert</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>digest</var>: hash algorithm, a <code>gnutls_digest_algorithm_t</code> value
</p>
<p><var>issuer</var>: issuer of <code>subject</code> certificate
</p>
<p><var>cert</var>: certificate to request status for
</p>
<p>This function will add another request to the OCSP request for a
particular certificate. The issuer name hash, issuer key hash, and
serial number fields is populated as follows. The issuer name and
the serial number is taken from <code>cert</code> . The issuer key is taken
from <code>issuer</code> . The hashed values will be hashed using the <code>digest</code> algorithm, normally <code>GNUTLS_DIG_SHA1</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fadd_005fcert_005fid-1"></a>
<h4 class="subheading">gnutls_ocsp_req_add_cert_id</h4>
<a name="gnutls_005focsp_005freq_005fadd_005fcert_005fid"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fadd_005fcert_005fid"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_add_cert_id</strong> <em>(gnutls_ocsp_req_t <var>req</var>, gnutls_digest_algorithm_t <var>digest</var>, const gnutls_datum_t * <var>issuer_name_hash</var>, const gnutls_datum_t * <var>issuer_key_hash</var>, const gnutls_datum_t * <var>serial_number</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>digest</var>: hash algorithm, a <code>gnutls_digest_algorithm_t</code> value
</p>
<p><var>issuer_name_hash</var>: hash of issuer’s DN
</p>
<p><var>issuer_key_hash</var>: hash of issuer’s public key
</p>
<p><var>serial_number</var>: serial number of certificate to check
</p>
<p>This function will add another request to the OCSP request for a
particular certificate having the issuer name hash of
<code>issuer_name_hash</code> and issuer key hash of <code>issuer_key_hash</code> (both
hashed using <code>digest</code> ) and serial number <code>serial_number</code> .
</p>
<p>The information needed corresponds to the CertID structure:
</p>
<p><informalexample><programlisting>
CertID ::= SEQUENCE {
hashAlgorithm AlgorithmIdentifier,
issuerNameHash OCTET STRING, – Hash of Issuer’s DN
issuerKeyHash OCTET STRING, – Hash of Issuers public key
serialNumber CertificateSerialNumber }
</programlisting></informalexample>
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fdeinit-1"></a>
<h4 class="subheading">gnutls_ocsp_req_deinit</h4>
<a name="gnutls_005focsp_005freq_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_ocsp_req_deinit</strong> <em>(gnutls_ocsp_req_t <var>req</var>)</em></dt>
<dd><p><var>req</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a OCSP request structure.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fexport-1"></a>
<h4 class="subheading">gnutls_ocsp_req_export</h4>
<a name="gnutls_005focsp_005freq_005fexport"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fexport"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_export</strong> <em>(gnutls_ocsp_req_t <var>req</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>req</var>: Holds the OCSP request
</p>
<p><var>data</var>: newly allocate buffer holding DER encoded OCSP request
</p>
<p>This function will export the OCSP request to DER format.
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fget_005fcert_005fid-1"></a>
<h4 class="subheading">gnutls_ocsp_req_get_cert_id</h4>
<a name="gnutls_005focsp_005freq_005fget_005fcert_005fid"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fget_005fcert_005fid"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_get_cert_id</strong> <em>(gnutls_ocsp_req_t <var>req</var>, unsigned <var>indx</var>, gnutls_digest_algorithm_t * <var>digest</var>, gnutls_datum_t * <var>issuer_name_hash</var>, gnutls_datum_t * <var>issuer_key_hash</var>, gnutls_datum_t * <var>serial_number</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to get. Use (0) to get the first one.
</p>
<p><var>digest</var>: output variable with <code>gnutls_digest_algorithm_t</code> hash algorithm
</p>
<p><var>issuer_name_hash</var>: output buffer with hash of issuer’s DN
</p>
<p><var>issuer_key_hash</var>: output buffer with hash of issuer’s public key
</p>
<p><var>serial_number</var>: output buffer with serial number of certificate to check
</p>
<p>This function will return the certificate information of the
<code>indx</code> ’ed request in the OCSP request. The information returned
corresponds to the CertID structure:
</p>
<p><informalexample><programlisting>
CertID ::= SEQUENCE {
hashAlgorithm AlgorithmIdentifier,
issuerNameHash OCTET STRING, – Hash of Issuer’s DN
issuerKeyHash OCTET STRING, – Hash of Issuers public key
serialNumber CertificateSerialNumber }
</programlisting></informalexample>
</p>
<p>Each of the pointers to output variables may be NULL to indicate
that the caller is not interested in that value.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned. If you have reached the last
CertID available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be
returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fget_005fextension-1"></a>
<h4 class="subheading">gnutls_ocsp_req_get_extension</h4>
<a name="gnutls_005focsp_005freq_005fget_005fextension"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fget_005fextension"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_get_extension</strong> <em>(gnutls_ocsp_req_t <var>req</var>, unsigned <var>indx</var>, gnutls_datum_t * <var>oid</var>, unsigned int * <var>critical</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to get. Use (0) to get the first one.
</p>
<p><var>oid</var>: will hold newly allocated buffer with OID of extension, may be NULL
</p>
<p><var>critical</var>: output variable with critical flag, may be NULL.
</p>
<p><var>data</var>: will hold newly allocated buffer with extension data, may be NULL
</p>
<p>This function will return all information about the requested
extension in the OCSP request. The information returned is the
OID, the critical flag, and the data itself. The extension OID
will be stored as a string. Any of <code>oid</code> , <code>critical</code> , and <code>data</code> may
be NULL which means that the caller is not interested in getting
that information back.
</p>
<p>The caller needs to deallocate memory by calling <code>gnutls_free()</code> on
<code>oid</code> ->data and <code>data</code> ->data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned. If you have reached the last
extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will
be returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fget_005fnonce-1"></a>
<h4 class="subheading">gnutls_ocsp_req_get_nonce</h4>
<a name="gnutls_005focsp_005freq_005fget_005fnonce"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fget_005fnonce"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_get_nonce</strong> <em>(gnutls_ocsp_req_t <var>req</var>, unsigned int * <var>critical</var>, gnutls_datum_t * <var>nonce</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>critical</var>: whether nonce extension is marked critical, or NULL
</p>
<p><var>nonce</var>: will hold newly allocated buffer with nonce data
</p>
<p>This function will return the OCSP request nonce extension data.
</p>
<p>The caller needs to deallocate memory by calling <code>gnutls_free()</code> on
<code>nonce</code> ->data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_ocsp_req_get_version</h4>
<a name="gnutls_005focsp_005freq_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fget_005fversion"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_get_version</strong> <em>(gnutls_ocsp_req_t <var>req</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p>This function will return the version of the OCSP request.
Typically this is always 1 indicating version 1.
</p>
<p><strong>Returns:</strong> version of OCSP request, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fimport-1"></a>
<h4 class="subheading">gnutls_ocsp_req_import</h4>
<a name="gnutls_005focsp_005freq_005fimport"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fimport"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_import</strong> <em>(gnutls_ocsp_req_t <var>req</var>, const gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>req</var>: The structure to store the parsed request.
</p>
<p><var>data</var>: DER encoded OCSP request.
</p>
<p>This function will convert the given DER encoded OCSP request to
the native <code>gnutls_ocsp_req_t</code> format. The output will be stored in
<code>req</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005finit-1"></a>
<h4 class="subheading">gnutls_ocsp_req_init</h4>
<a name="gnutls_005focsp_005freq_005finit"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005finit"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_init</strong> <em>(gnutls_ocsp_req_t * <var>req</var>)</em></dt>
<dd><p><var>req</var>: The structure to be initialized
</p>
<p>This function will initialize an OCSP request structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fprint-1"></a>
<h4 class="subheading">gnutls_ocsp_req_print</h4>
<a name="gnutls_005focsp_005freq_005fprint"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fprint"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_print</strong> <em>(gnutls_ocsp_req_t <var>req</var>, gnutls_ocsp_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>req</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print a OCSP request, suitable for
display to a human.
</p>
<p>If the format is <code>GNUTLS_OCSP_PRINT_FULL</code> then all fields of the
request will be output, on multiple lines.
</p>
<p>The output <code>out</code> ->data needs to be deallocate using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005frandomize_005fnonce-1"></a>
<h4 class="subheading">gnutls_ocsp_req_randomize_nonce</h4>
<a name="gnutls_005focsp_005freq_005frandomize_005fnonce"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005frandomize_005fnonce"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_randomize_nonce</strong> <em>(gnutls_ocsp_req_t <var>req</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p>This function will add or update an nonce extension to the OCSP
request with a newly generated random value.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fset_005fextension-1"></a>
<h4 class="subheading">gnutls_ocsp_req_set_extension</h4>
<a name="gnutls_005focsp_005freq_005fset_005fextension"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fset_005fextension"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_set_extension</strong> <em>(gnutls_ocsp_req_t <var>req</var>, const char * <var>oid</var>, unsigned int <var>critical</var>, const gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>oid</var>: buffer with OID of extension as a string.
</p>
<p><var>critical</var>: critical flag, normally false.
</p>
<p><var>data</var>: the extension data
</p>
<p>This function will add an extension to the OCSP request. Calling
this function multiple times for the same OID will overwrite values
from earlier calls.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005freq_005fset_005fnonce-1"></a>
<h4 class="subheading">gnutls_ocsp_req_set_nonce</h4>
<a name="gnutls_005focsp_005freq_005fset_005fnonce"></a><dl>
<dt><a name="index-gnutls_005focsp_005freq_005fset_005fnonce"></a>Function: <em>int</em> <strong>gnutls_ocsp_req_set_nonce</strong> <em>(gnutls_ocsp_req_t <var>req</var>, unsigned int <var>critical</var>, const gnutls_datum_t * <var>nonce</var>)</em></dt>
<dd><p><var>req</var>: should contain a <code>gnutls_ocsp_req_t</code> structure
</p>
<p><var>critical</var>: critical flag, normally false.
</p>
<p><var>nonce</var>: the nonce data
</p>
<p>This function will add an nonce extension to the OCSP request.
Calling this function multiple times will overwrite values from
earlier calls.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fcheck_005fcrt-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_check_crt</h4>
<a name="gnutls_005focsp_005fresp_005fcheck_005fcrt"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fcheck_005fcrt"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_check_crt</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, unsigned int <var>indx</var>, gnutls_x509_crt_t <var>crt</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>indx</var>: Specifies response number to get. Use (0) to get the first one.
</p>
<p><var>crt</var>: The certificate to check
</p>
<p>This function will check whether the OCSP response
is about the provided certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fdeinit-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_deinit</h4>
<a name="gnutls_005focsp_005fresp_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_ocsp_resp_deinit</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>)</em></dt>
<dd><p><var>resp</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a OCSP response structure.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fexport-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_export</h4>
<a name="gnutls_005focsp_005fresp_005fexport"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fexport"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_export</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>resp</var>: Holds the OCSP response
</p>
<p><var>data</var>: newly allocate buffer holding DER encoded OCSP response
</p>
<p>This function will export the OCSP response to DER format.
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fcerts-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_certs</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fcerts"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fcerts"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_certs</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_x509_crt_t ** <var>certs</var>, size_t * <var>ncerts</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>certs</var>: newly allocated array with <code>gnutls_x509_crt_t</code> certificates
</p>
<p><var>ncerts</var>: output variable with number of allocated certs.
</p>
<p>This function will extract the X.509 certificates found in the
Basic OCSP Response. The <code>certs</code> output variable will hold a newly
allocated zero-terminated array with X.509 certificates.
</p>
<p>Every certificate in the array needs to be de-allocated with
<code>gnutls_x509_crt_deinit()</code> and the array itself must be freed using
<code>gnutls_free()</code> .
</p>
<p>Both the <code>certs</code> and <code>ncerts</code> variables may be NULL. Then the
function will work as normal but will not return the NULL:d
information. This can be used to get the number of certificates
only, or to just get the certificate array without its size.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fextension-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_extension</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fextension"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fextension"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_extension</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, unsigned <var>indx</var>, gnutls_datum_t * <var>oid</var>, unsigned int * <var>critical</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>indx</var>: Specifies which extension OID to get. Use (0) to get the first one.
</p>
<p><var>oid</var>: will hold newly allocated buffer with OID of extension, may be NULL
</p>
<p><var>critical</var>: output variable with critical flag, may be NULL.
</p>
<p><var>data</var>: will hold newly allocated buffer with extension data, may be NULL
</p>
<p>This function will return all information about the requested
extension in the OCSP response. The information returned is the
OID, the critical flag, and the data itself. The extension OID
will be stored as a string. Any of <code>oid</code> , <code>critical</code> , and <code>data</code> may
be NULL which means that the caller is not interested in getting
that information back.
</p>
<p>The caller needs to deallocate memory by calling <code>gnutls_free()</code> on
<code>oid</code> ->data and <code>data</code> ->data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned. If you have reached the last
extension available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will
be returned.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fnonce-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_nonce</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fnonce"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fnonce"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_nonce</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, unsigned int * <var>critical</var>, gnutls_datum_t * <var>nonce</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>critical</var>: whether nonce extension is marked critical
</p>
<p><var>nonce</var>: will hold newly allocated buffer with nonce data
</p>
<p>This function will return the Basic OCSP Response nonce extension
data.
</p>
<p>The caller needs to deallocate memory by calling <code>gnutls_free()</code> on
<code>nonce</code> ->data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fproduced-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_produced</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fproduced"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fproduced"></a>Function: <em>time_t</em> <strong>gnutls_ocsp_resp_get_produced</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p>This function will return the time when the OCSP response was
signed.
</p>
<p><strong>Returns:</strong> signing time, or (time_t)-1 on error.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fresponder-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_responder</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fresponder"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fresponder"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_responder</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_datum_t * <var>dn</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>dn</var>: newly allocated buffer with name
</p>
<p>This function will extract the name of the Basic OCSP Response 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>
<p>The caller needs to deallocate memory by calling <code>gnutls_free()</code> on
<code>dn</code> ->data.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fresponse-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_response</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fresponse"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fresponse"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_response</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_datum_t * <var>response_type_oid</var>, gnutls_datum_t * <var>response</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>response_type_oid</var>: newly allocated output buffer with response type OID
</p>
<p><var>response</var>: newly allocated output buffer with DER encoded response
</p>
<p>This function will extract the response type OID in and the
response data from an OCSP response. Normally the
<code>response_type_oid</code> is always "1.3.6.1.5.5.7.48.1.1" which means the
<code>response</code> should be decoded as a Basic OCSP Response, but
technically other response types could be used.
</p>
<p>This function is typically only useful when you want to extract the
response type OID of an response for diagnostic purposes.
Otherwise <code>gnutls_ocsp_resp_import()</code> will decode the basic OCSP
response part and the caller need not worry about that aspect.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fsignature-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_signature</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fsignature"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fsignature"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_signature</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_datum_t * <var>sig</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>sig</var>: newly allocated output buffer with signature data
</p>
<p>This function will extract the signature field of a OCSP response.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fsignature_005falgorithm-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_signature_algorithm</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fsignature_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fsignature_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_signature_algorithm</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p>This function will return a value of the <code>gnutls_sign_algorithm_t</code>
enumeration that is the signature algorithm that has been used to
sign the OCSP response.
</p>
<p><strong>Returns:</strong> a <code>gnutls_sign_algorithm_t</code> value, or a negative error code
on error.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fsingle-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_single</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fsingle"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fsingle-1"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_single</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, unsigned <var>indx</var>, gnutls_digest_algorithm_t * <var>digest</var>, gnutls_datum_t * <var>issuer_name_hash</var>, gnutls_datum_t * <var>issuer_key_hash</var>, gnutls_datum_t * <var>serial_number</var>, unsigned int * <var>cert_status</var>, time_t * <var>this_update</var>, time_t * <var>next_update</var>, time_t * <var>revocation_time</var>, unsigned int * <var>revocation_reason</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>indx</var>: Specifies response number to get. Use (0) to get the first one.
</p>
<p><var>digest</var>: output variable with <code>gnutls_digest_algorithm_t</code> hash algorithm
</p>
<p><var>issuer_name_hash</var>: output buffer with hash of issuer’s DN
</p>
<p><var>issuer_key_hash</var>: output buffer with hash of issuer’s public key
</p>
<p><var>serial_number</var>: output buffer with serial number of certificate to check
</p>
<p><var>cert_status</var>: a certificate status, a <code>gnutls_ocsp_cert_status_t</code> enum.
</p>
<p><var>this_update</var>: time at which the status is known to be correct.
</p>
<p><var>next_update</var>: when newer information will be available, or (time_t)-1 if unspecified
</p>
<p><var>revocation_time</var>: when <code>cert_status</code> is <code>GNUTLS_OCSP_CERT_REVOKED</code> , holds time of revocation.
</p>
<p><var>revocation_reason</var>: revocation reason, a <code>gnutls_x509_crl_reason_t</code> enum.
</p>
<p>This function will return the certificate information of the
<code>indx</code> ’ed response in the Basic OCSP Response <code>resp</code> . The
information returned corresponds to the OCSP SingleResponse structure
except the final singleExtensions.
</p>
<p>Each of the pointers to output variables may be NULL to indicate
that the caller is not interested in that value.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error code is returned. If you have reached the last
CertID available <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be
returned.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fstatus-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_status</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fstatus"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fstatus"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_status</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p>This function will return the status of a OCSP response, an
<code>gnutls_ocsp_resp_status_t</code> enumeration.
</p>
<p><strong>Returns:</strong> status of OCSP request as a <code>gnutls_ocsp_resp_status_t</code> , or
a negative error code on error.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_get_version</h4>
<a name="gnutls_005focsp_005fresp_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fget_005fversion"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_get_version</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p>This function will return the version of the Basic OCSP Response.
Typically this is always 1 indicating version 1.
</p>
<p><strong>Returns:</strong> version of Basic OCSP response, or a negative error code
on error.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fimport-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_import</h4>
<a name="gnutls_005focsp_005fresp_005fimport"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fimport"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_import</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, const gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>resp</var>: The structure to store the parsed response.
</p>
<p><var>data</var>: DER encoded OCSP response.
</p>
<p>This function will convert the given DER encoded OCSP response to
the native <code>gnutls_ocsp_resp_t</code> format. It also decodes the Basic
OCSP Response part, if any. The output will be stored in <code>resp</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005finit-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_init</h4>
<a name="gnutls_005focsp_005fresp_005finit"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005finit"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_init</strong> <em>(gnutls_ocsp_resp_t * <var>resp</var>)</em></dt>
<dd><p><var>resp</var>: The structure to be initialized
</p>
<p>This function will initialize an OCSP response structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fprint-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_print</h4>
<a name="gnutls_005focsp_005fresp_005fprint"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fprint"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_print</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_ocsp_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>resp</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print a OCSP response, suitable for
display to a human.
</p>
<p>If the format is <code>GNUTLS_OCSP_PRINT_FULL</code> then all fields of the
response will be output, on multiple lines.
</p>
<p>The output <code>out</code> ->data needs to be deallocate using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fverify-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_verify</h4>
<a name="gnutls_005focsp_005fresp_005fverify"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fverify"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_verify</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_x509_trust_list_t <var>trustlist</var>, unsigned int * <var>verify</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>trustlist</var>: trust anchors as a <code>gnutls_x509_trust_list_t</code> structure
</p>
<p><var>verify</var>: output variable with verification status, an <code>gnutls_ocsp_cert_status_t</code>
</p>
<p><var>flags</var>: verification flags, 0 for now.
</p>
<p>Verify signature of the Basic OCSP Response against the public key
in the certificate of a trusted signer. The <code>trustlist</code> should be
populated with trust anchors. The function will extract the signer
certificate from the Basic OCSP Response and will verify it against
the <code>trustlist</code> . A trusted signer is a certificate that is either
in <code>trustlist</code> , or it is signed directly by a certificate in
<code>trustlist</code> and has the id-ad-ocspSigning Extended Key Usage bit
set.
</p>
<p>The output <code>verify</code> variable will hold verification status codes
(e.g., <code>GNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND</code> ,
<code>GNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM</code> ) which are only valid if the
function returned <code>GNUTLS_E_SUCCESS</code> .
</p>
<p>Note that the function returns <code>GNUTLS_E_SUCCESS</code> even when
verification failed. The caller must always inspect the <code>verify</code> variable to find out the verification status.
</p>
<p>The <code>flags</code> variable should be 0 for now.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005focsp_005fresp_005fverify_005fdirect-1"></a>
<h4 class="subheading">gnutls_ocsp_resp_verify_direct</h4>
<a name="gnutls_005focsp_005fresp_005fverify_005fdirect"></a><dl>
<dt><a name="index-gnutls_005focsp_005fresp_005fverify_005fdirect"></a>Function: <em>int</em> <strong>gnutls_ocsp_resp_verify_direct</strong> <em>(gnutls_ocsp_resp_t <var>resp</var>, gnutls_x509_crt_t <var>issuer</var>, unsigned int * <var>verify</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>resp</var>: should contain a <code>gnutls_ocsp_resp_t</code> structure
</p>
<p><var>issuer</var>: certificate believed to have signed the response
</p>
<p><var>verify</var>: output variable with verification status, an <code>gnutls_ocsp_cert_status_t</code>
</p>
<p><var>flags</var>: verification flags, 0 for now.
</p>
<p>Verify signature of the Basic OCSP Response against the public key
in the <code>issuer</code> certificate.
</p>
<p>The output <code>verify</code> variable will hold verification status codes
(e.g., <code>GNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND</code> ,
<code>GNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM</code> ) which are only valid if the
function returned <code>GNUTLS_E_SUCCESS</code> .
</p>
<p>Note that the function returns <code>GNUTLS_E_SUCCESS</code> even when
verification failed. The caller must always inspect the <code>verify</code> variable to find out the verification status.
</p>
<p>The <code>flags</code> variable should be 0 for now.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<hr>
<a name="OpenPGP-API"></a>
<div class="header">
<p>
Next: <a href="#PKCS-12-API" accesskey="n" rel="next">PKCS 12 API</a>, Previous: <a href="#OCSP-API" accesskey="p" rel="previous">OCSP API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="OpenPGP-API-1"></a>
<h3 class="section">E.6 <acronym>OpenPGP</acronym> API</h3>
<a name="index-OpenPGP-API"></a>
<p>The following functions are to be used for <acronym>OpenPGP</acronym>
certificate handling. Their prototypes lie in
<samp>gnutls/openpgp.h</samp>.
</p>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_key</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_key</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_openpgp_crt_t <var>crt</var>, gnutls_openpgp_privkey_t <var>pkey</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>crt</var>: contains an openpgp public key
</p>
<p><var>pkey</var>: is an openpgp private key
</p>
<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>
<p>Note that this function requires that the preferred key ids have
been set and be used. See <code>gnutls_openpgp_crt_set_preferred_key_id()</code> .
Otherwise the master key will be used.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_key_file</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_key_file</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char * <var>certfile</var>, const char * <var>keyfile</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>res</var>: the destination context to save the data.
</p>
<p><var>certfile</var>: the file that contains the public key.
</p>
<p><var>keyfile</var>: the file that contains the secret key.
</p>
<p><var>format</var>: the format of the keys
</p>
<p>This funtion is used to load OpenPGP keys into the GnuTLS
credentials structure. The file should contain at least one valid non encrypted subkey.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile2-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_key_file2</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile2"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile2"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_key_file2</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char * <var>certfile</var>, const char * <var>keyfile</var>, const char * <var>subkey_id</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>res</var>: the destination context to save the data.
</p>
<p><var>certfile</var>: the file that contains the public key.
</p>
<p><var>keyfile</var>: the file that contains the secret key.
</p>
<p><var>subkey_id</var>: a hex encoded subkey id
</p>
<p><var>format</var>: the format of the keys
</p>
<p>This funtion is used to load OpenPGP keys into the GnuTLS credential
structure. The file should contain at least one valid non encrypted subkey.
</p>
<p>The special keyword "auto" is also accepted as <code>subkey_id</code> . In that
case the <code>gnutls_openpgp_crt_get_auth_subkey()</code> will be used to
retrieve the subkey.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_key_mem</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_key_mem</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>cert</var>, const gnutls_datum_t * <var>key</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>res</var>: the destination context to save the data.
</p>
<p><var>cert</var>: the datum that contains the public key.
</p>
<p><var>key</var>: the datum that contains the secret key.
</p>
<p><var>format</var>: the format of the keys
</p>
<p>This funtion is used to load OpenPGP keys into the GnuTLS credential
structure. The datum should contain at least one valid non encrypted subkey.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem2-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_key_mem2</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem2"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem2"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_key_mem2</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const gnutls_datum_t * <var>cert</var>, const gnutls_datum_t * <var>key</var>, const char * <var>subkey_id</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>res</var>: the destination context to save the data.
</p>
<p><var>cert</var>: the datum that contains the public key.
</p>
<p><var>key</var>: the datum that contains the secret key.
</p>
<p><var>subkey_id</var>: a hex encoded subkey id
</p>
<p><var>format</var>: the format of the keys
</p>
<p>This funtion is used to load OpenPGP keys into the GnuTLS
credentials structure. The datum should contain at least one valid non encrypted subkey.
</p>
<p>The special keyword "auto" is also accepted as <code>subkey_id</code> . In that
case the <code>gnutls_openpgp_crt_get_auth_subkey()</code> will be used to
retrieve the subkey.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_keyring_file</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile-1"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_keyring_file</strong> <em>(gnutls_certificate_credentials_t <var>c</var>, const char * <var>file</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>c</var>: A certificate credentials structure
</p>
<p><var>file</var>: filename of the keyring.
</p>
<p><var>format</var>: format of keyring.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem-1"></a>
<h4 class="subheading">gnutls_certificate_set_openpgp_keyring_mem</h4>
<a name="gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_keyring_mem</strong> <em>(gnutls_certificate_credentials_t <var>c</var>, const uint8_t * <var>data</var>, size_t <var>dlen</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>c</var>: A certificate credentials structure
</p>
<p><var>data</var>: buffer with keyring data.
</p>
<p><var>dlen</var>: length of data buffer.
</p>
<p><var>format</var>: the format of the keyring
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fcheck_005fhostname-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_check_hostname</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fcheck_005fhostname"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fcheck_005fhostname"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_check_hostname</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, const char * <var>hostname</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_openpgp_crt_t</code> structure
</p>
<p><var>hostname</var>: A null terminated string that contains a DNS name
</p>
<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>
<p><strong>Returns:</strong> non-zero for a successful match, and zero on failure.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fdeinit-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_deinit</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_openpgp_crt_deinit</strong> <em>(gnutls_openpgp_crt_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will deinitialize a key structure.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fexport-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_export</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fexport"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fexport"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_export</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the key.
</p>
<p><var>format</var>: One of gnutls_openpgp_crt_fmt_t elements.
</p>
<p><var>output_data</var>: will contain the raw or base64 encoded key
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will
be replaced by the actual size of parameters)
</p>
<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
<code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will be returned.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fexport2-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_export2</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fexport2"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_export2</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>key</var>: Holds the key.
</p>
<p><var>format</var>: One of gnutls_openpgp_crt_fmt_t elements.
</p>
<p><var>out</var>: will contain the raw or base64 encoded key
</p>
<p>This function will convert the given key to RAW or Base64 format.
The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fauth_005fsubkey-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_auth_subkey</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fauth_005fsubkey"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fauth_005fsubkey"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_auth_subkey</strong> <em>(gnutls_openpgp_crt_t <var>crt</var>, gnutls_openpgp_keyid_t <var>keyid</var>, unsigned int <var>flag</var>)</em></dt>
<dd><p><var>crt</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the struct to save the keyid.
</p>
<p><var>flag</var>: Non-zero indicates that a valid subkey is always returned.
</p>
<p>Returns the 64-bit keyID of the first valid OpenPGP subkey marked
for authentication. If flag is non-zero and no authentication
subkey exists, then a valid subkey will be returned even if it is
not marked for authentication.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fcreation_005ftime-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_creation_time</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fcreation_005ftime"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fcreation_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_openpgp_crt_get_creation_time</strong> <em>(gnutls_openpgp_crt_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p>Get key creation time.
</p>
<p><strong>Returns:</strong> the timestamp when the OpenPGP key was created.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fexpiration_005ftime-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_expiration_time</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fexpiration_005ftime"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fexpiration_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_openpgp_crt_get_expiration_time</strong> <em>(gnutls_openpgp_crt_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p>Get key expiration time. A value of ’0’ means that the key doesn’t
expire at all.
</p>
<p><strong>Returns:</strong> the time when the OpenPGP key expires.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005ffingerprint-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_fingerprint</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005ffingerprint"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005ffingerprint"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_fingerprint</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, void * <var>fpr</var>, size_t * <var>fprlen</var>)</em></dt>
<dd><p><var>key</var>: the raw data that contains the OpenPGP public key.
</p>
<p><var>fpr</var>: the buffer to save the fingerprint, must hold at least 20 bytes.
</p>
<p><var>fprlen</var>: the integer to save the length of the fingerprint.
</p>
<p>Get key fingerprint. Depending on the algorithm, the fingerprint
can be 16 or 20 bytes.
</p>
<p><strong>Returns:</strong> On success, 0 is returned. Otherwise, an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_key_id</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_key_id</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the buffer to save the keyid.
</p>
<p>Get key id string.
</p>
<p><strong>Returns:</strong> the 64-bit keyID of the OpenPGP key.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_key_usage</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_key_usage</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int * <var>key_usage</var>)</em></dt>
<dd><p><var>key</var>: should contain a gnutls_openpgp_crt_t structure
</p>
<p><var>key_usage</var>: where the key usage bits will be stored
</p>
<p>This function will return certificate’s key usage, by checking the
key algorithm. The key usage value will ORed values of the:
<code>GNUTLS_KEY_DIGITAL_SIGNATURE</code> , <code>GNUTLS_KEY_KEY_ENCIPHERMENT</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_name</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fname"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_name</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, int <var>idx</var>, char * <var>buf</var>, size_t * <var>sizeof_buf</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>idx</var>: the index of the ID to extract
</p>
<p><var>buf</var>: a pointer to a structure to hold the name, may be <code>NULL</code>
to only get the <code>sizeof_buf</code> .
</p>
<p><var>sizeof_buf</var>: holds the maximum size of <code>buf</code> , on return hold the
actual/required size of <code>buf</code> .
</p>
<p>Extracts the userID from the parsed OpenPGP key.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, and if the index of the ID
does not exist <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> , or an
error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_pk_algorithm</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fpk_005falgorithm"></a>Function: <em>gnutls_pk_algorithm_t</em> <strong>gnutls_openpgp_crt_get_pk_algorithm</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: is an OpenPGP key
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of an OpenPGP
certificate.
</p>
<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>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or GNUTLS_PK_UNKNOWN on error.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpk_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_pk_dsa_raw</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpk_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fpk_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_pk_dsa_raw</strong> <em>(gnutls_openpgp_crt_t <var>crt</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p>This function will export the DSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpk_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_pk_rsa_raw</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpk_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fpk_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_pk_rsa_raw</strong> <em>(gnutls_openpgp_crt_t <var>crt</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p>This function will export the RSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpreferred_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_preferred_key_id</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fpreferred_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fpreferred_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_preferred_key_id</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the struct to save the keyid.
</p>
<p>Get preferred key id. If it hasn’t been set it returns
<code>GNUTLS_E_INVALID_REQUEST</code> .
</p>
<p><strong>Returns:</strong> the 64-bit preferred keyID of the OpenPGP key.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005frevoked_005fstatus-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_revoked_status</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005frevoked_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005frevoked_005fstatus"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_revoked_status</strong> <em>(gnutls_openpgp_crt_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p>Get revocation status of key.
</p>
<p><strong>Returns:</strong> true (1) if the key has been revoked, or false (0) if it
has not.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcount-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_count</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcount"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcount"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_count</strong> <em>(gnutls_openpgp_crt_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: is an OpenPGP key
</p>
<p>This function will return the number of subkeys present in the
given OpenPGP certificate.
</p>
<p><strong>Returns:</strong> the number of subkeys, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcreation_005ftime-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_creation_time</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcreation_005ftime"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcreation_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_openpgp_crt_get_subkey_creation_time</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p>Get subkey creation time.
</p>
<p><strong>Returns:</strong> the timestamp when the OpenPGP sub-key was created.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fexpiration_005ftime-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_expiration_time</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fexpiration_005ftime"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fexpiration_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_openpgp_crt_get_subkey_expiration_time</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p>Get subkey expiration time. A value of ’0’ means that the key
doesn’t expire at all.
</p>
<p><strong>Returns:</strong> the time when the OpenPGP key expires.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005ffingerprint-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_fingerprint</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005ffingerprint"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005ffingerprint"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_fingerprint</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>, void * <var>fpr</var>, size_t * <var>fprlen</var>)</em></dt>
<dd><p><var>key</var>: the raw data that contains the OpenPGP public key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p><var>fpr</var>: the buffer to save the fingerprint, must hold at least 20 bytes.
</p>
<p><var>fprlen</var>: the integer to save the length of the fingerprint.
</p>
<p>Get key fingerprint of a subkey. Depending on the algorithm, the
fingerprint can be 16 or 20 bytes.
</p>
<p><strong>Returns:</strong> On success, 0 is returned. Otherwise, an error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_id</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_id</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>, gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p><var>keyid</var>: the buffer to save the keyid.
</p>
<p>Get the subkey’s key-id.
</p>
<p><strong>Returns:</strong> the 64-bit keyID of the OpenPGP key.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fidx-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_idx</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fidx"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fidx"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_idx</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, const gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the keyid.
</p>
<p>Get subkey’s index.
</p>
<p><strong>Returns:</strong> the index of the subkey or a negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_pk_algorithm</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005falgorithm"></a>Function: <em>gnutls_pk_algorithm_t</em> <strong>gnutls_openpgp_crt_get_subkey_pk_algorithm</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: is an OpenPGP key
</p>
<p><var>idx</var>: is the subkey index
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of a subkey of an OpenPGP
certificate.
</p>
<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>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or GNUTLS_PK_UNKNOWN on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_pk_dsa_raw</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_pk_dsa_raw</strong> <em>(gnutls_openpgp_crt_t <var>crt</var>, unsigned int <var>idx</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>idx</var>: Is the subkey index
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p>This function will export the DSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_pk_rsa_raw</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_pk_rsa_raw</strong> <em>(gnutls_openpgp_crt_t <var>crt</var>, unsigned int <var>idx</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>idx</var>: Is the subkey index
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p>This function will export the RSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005frevoked_005fstatus-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_revoked_status</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005frevoked_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005frevoked_005fstatus"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_revoked_status</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>idx</var>: is the subkey index
</p>
<p>Get subkey revocation status. A negative error code indicates an error.
</p>
<p><strong>Returns:</strong> true (1) if the key has been revoked, or false (0) if it
has not.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fusage-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_subkey_usage</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_subkey_usage</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>idx</var>, unsigned int * <var>key_usage</var>)</em></dt>
<dd><p><var>key</var>: should contain a gnutls_openpgp_crt_t structure
</p>
<p><var>idx</var>: the subkey index
</p>
<p><var>key_usage</var>: where the key usage bits will be stored
</p>
<p>This function will return certificate’s key usage, by checking the
key algorithm. The key usage value will ORed values of
<code>GNUTLS_KEY_DIGITAL_SIGNATURE</code> or <code>GNUTLS_KEY_KEY_ENCIPHERMENT</code> .
</p>
<p>A negative error code may be returned in case of parsing error.
</p>
<p><strong>Returns:</strong> key usage value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fversion-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_get_version</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fget_005fversion"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fget_005fversion"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_get_version</strong> <em>(gnutls_openpgp_crt_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p>Extract the version of the OpenPGP key.
</p>
<p><strong>Returns:</strong> the version number is returned, or a negative error code on errors.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fimport-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_import</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fimport"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fimport"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_import</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key.
</p>
<p><var>data</var>: The RAW or BASE64 encoded key.
</p>
<p><var>format</var>: One of gnutls_openpgp_crt_fmt_t elements.
</p>
<p>This function will convert the given RAW or Base64 encoded key to
the native <code>gnutls_openpgp_crt_t</code> format. The output will be stored
in ’key’.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005finit-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_init</h4>
<a name="gnutls_005fopenpgp_005fcrt_005finit"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005finit"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_init</strong> <em>(gnutls_openpgp_crt_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will initialize an OpenPGP key structure.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fprint-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_print</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fprint"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fprint"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_print</strong> <em>(gnutls_openpgp_crt_t <var>cert</var>, gnutls_certificate_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>cert</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print an OpenPGP certificate, suitable
for display to a human.
</p>
<p>The format should be (0) for future compatibility.
</p>
<p>The output <code>out</code> needs to be deallocate using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fset_005fpreferred_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_set_preferred_key_id</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fset_005fpreferred_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fset_005fpreferred_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_set_preferred_key_id</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, const gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the selected keyid
</p>
<p>This allows setting a preferred key id for the given certificate.
This key will be used by functions that involve key handling.
</p>
<p>If the provided <code>keyid</code> is <code>NULL</code> then the master key is
set as preferred.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fverify_005fring-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_verify_ring</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fverify_005fring"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fverify_005fring-1"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_verify_ring</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_keyring_t <var>keyring</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>key</var>: the structure that holds the key.
</p>
<p><var>keyring</var>: holds the keyring to check against
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p>Verify all signatures in the key, using the given set of keys
(keyring).
</p>
<p>The key verification output will be put in <code>verify</code> and will be one
or more of the <code>gnutls_certificate_status_t</code> enumerated elements
bitwise or’d.
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fcrt_005fverify_005fself-1"></a>
<h4 class="subheading">gnutls_openpgp_crt_verify_self</h4>
<a name="gnutls_005fopenpgp_005fcrt_005fverify_005fself"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fverify_005fself-1"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_verify_self</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>key</var>: the structure that holds the key.
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p><var>verify</var>: will hold the key verification output.
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fkeyring_005fcheck_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_keyring_check_id</h4>
<a name="gnutls_005fopenpgp_005fkeyring_005fcheck_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fkeyring_005fcheck_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_keyring_check_id</strong> <em>(gnutls_openpgp_keyring_t <var>ring</var>, const gnutls_openpgp_keyid_t <var>keyid</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>ring</var>: holds the keyring to check against
</p>
<p><var>keyid</var>: will hold the keyid to check for.
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p>Check if a given key ID exists in the keyring.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success (if keyid exists) and a
negative error code on failure.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fkeyring_005fdeinit-1"></a>
<h4 class="subheading">gnutls_openpgp_keyring_deinit</h4>
<a name="gnutls_005fopenpgp_005fkeyring_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fkeyring_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_openpgp_keyring_deinit</strong> <em>(gnutls_openpgp_keyring_t <var>keyring</var>)</em></dt>
<dd><p><var>keyring</var>: The structure to be initialized
</p>
<p>This function will deinitialize a keyring structure.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fkeyring_005fget_005fcrt-1"></a>
<h4 class="subheading">gnutls_openpgp_keyring_get_crt</h4>
<a name="gnutls_005fopenpgp_005fkeyring_005fget_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fkeyring_005fget_005fcrt"></a>Function: <em>int</em> <strong>gnutls_openpgp_keyring_get_crt</strong> <em>(gnutls_openpgp_keyring_t <var>ring</var>, unsigned int <var>idx</var>, gnutls_openpgp_crt_t * <var>cert</var>)</em></dt>
<dd><p><var>ring</var>: Holds the keyring.
</p>
<p><var>idx</var>: the index of the certificate to export
</p>
<p><var>cert</var>: An uninitialized <code>gnutls_openpgp_crt_t</code> structure
</p>
<p>This function will extract an OpenPGP certificate from the given
keyring. If the index given is out of range
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned. The
returned structure needs to be deinited.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fkeyring_005fget_005fcrt_005fcount-1"></a>
<h4 class="subheading">gnutls_openpgp_keyring_get_crt_count</h4>
<a name="gnutls_005fopenpgp_005fkeyring_005fget_005fcrt_005fcount"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fkeyring_005fget_005fcrt_005fcount"></a>Function: <em>int</em> <strong>gnutls_openpgp_keyring_get_crt_count</strong> <em>(gnutls_openpgp_keyring_t <var>ring</var>)</em></dt>
<dd><p><var>ring</var>: is an OpenPGP key ring
</p>
<p>This function will return the number of OpenPGP certificates
present in the given keyring.
</p>
<p><strong>Returns:</strong> the number of subkeys, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fkeyring_005fimport-1"></a>
<h4 class="subheading">gnutls_openpgp_keyring_import</h4>
<a name="gnutls_005fopenpgp_005fkeyring_005fimport"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fkeyring_005fimport"></a>Function: <em>int</em> <strong>gnutls_openpgp_keyring_import</strong> <em>(gnutls_openpgp_keyring_t <var>keyring</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>keyring</var>: The structure to store the parsed key.
</p>
<p><var>data</var>: The RAW or BASE64 encoded keyring.
</p>
<p><var>format</var>: One of <code>gnutls_openpgp_keyring_fmt</code> elements.
</p>
<p>This function will convert the given RAW or Base64 encoded keyring
to the native <code>gnutls_openpgp_keyring_t</code> format. The output will be
stored in ’keyring’.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fkeyring_005finit-1"></a>
<h4 class="subheading">gnutls_openpgp_keyring_init</h4>
<a name="gnutls_005fopenpgp_005fkeyring_005finit"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fkeyring_005finit"></a>Function: <em>int</em> <strong>gnutls_openpgp_keyring_init</strong> <em>(gnutls_openpgp_keyring_t * <var>keyring</var>)</em></dt>
<dd><p><var>keyring</var>: The structure to be initialized
</p>
<p>This function will initialize an keyring structure.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fdeinit-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_deinit</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_openpgp_privkey_deinit</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will deinitialize a key structure.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_export</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fexport"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_export</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the key.
</p>
<p><var>format</var>: One of gnutls_openpgp_crt_fmt_t elements.
</p>
<p><var>password</var>: the password that will be used to encrypt the key. (unused for now)
</p>
<p><var>flags</var>: (0) for future compatibility
</p>
<p><var>output_data</var>: will contain the key base64 encoded or raw
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport2-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_export2</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fexport2"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_export2</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>key</var>: Holds the key.
</p>
<p><var>format</var>: One of gnutls_openpgp_crt_fmt_t elements.
</p>
<p><var>password</var>: the password that will be used to encrypt the key. (unused for now)
</p>
<p><var>flags</var>: (0) for future compatibility
</p>
<p><var>out</var>: will contain the raw or based64 encoded key
</p>
<p>This function will convert the given key to RAW or Base64 format.
The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_export_dsa_raw</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fexport_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_export_dsa_raw</strong> <em>(gnutls_openpgp_privkey_t <var>pkey</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>, gnutls_datum_t * <var>x</var>)</em></dt>
<dd><p><var>pkey</var>: Holds the certificate
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p><var>x</var>: will hold the x
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_export_rsa_raw</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fexport_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_export_rsa_raw</strong> <em>(gnutls_openpgp_privkey_t <var>pkey</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>, gnutls_datum_t * <var>d</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>u</var>)</em></dt>
<dd><p><var>pkey</var>: Holds the certificate
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p><var>d</var>: will hold the private exponent
</p>
<p><var>p</var>: will hold the first prime (p)
</p>
<p><var>q</var>: will hold the second prime (q)
</p>
<p><var>u</var>: will hold the coefficient
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_export_subkey_dsa_raw</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_export_subkey_dsa_raw</strong> <em>(gnutls_openpgp_privkey_t <var>pkey</var>, unsigned int <var>idx</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>, gnutls_datum_t * <var>x</var>)</em></dt>
<dd><p><var>pkey</var>: Holds the certificate
</p>
<p><var>idx</var>: Is the subkey index
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p><var>x</var>: will hold the x
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_export_subkey_rsa_raw</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_export_subkey_rsa_raw</strong> <em>(gnutls_openpgp_privkey_t <var>pkey</var>, unsigned int <var>idx</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>, gnutls_datum_t * <var>d</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>u</var>)</em></dt>
<dd><p><var>pkey</var>: Holds the certificate
</p>
<p><var>idx</var>: Is the subkey index
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p><var>d</var>: will hold the private exponent
</p>
<p><var>p</var>: will hold the first prime (p)
</p>
<p><var>q</var>: will hold the second prime (q)
</p>
<p><var>u</var>: will hold the coefficient
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005ffingerprint-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_fingerprint</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005ffingerprint"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005ffingerprint"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_fingerprint</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, void * <var>fpr</var>, size_t * <var>fprlen</var>)</em></dt>
<dd><p><var>key</var>: the raw data that contains the OpenPGP secret key.
</p>
<p><var>fpr</var>: the buffer to save the fingerprint, must hold at least 20 bytes.
</p>
<p><var>fprlen</var>: the integer to save the length of the fingerprint.
</p>
<p>Get the fingerprint of the OpenPGP key. Depends on the
algorithm, the fingerprint can be 16 or 20 bytes.
</p>
<p><strong>Returns:</strong> On success, 0 is returned, or an error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_key_id</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_key_id</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP secret key.
</p>
<p><var>keyid</var>: the buffer to save the keyid.
</p>
<p>Get key-id.
</p>
<p><strong>Returns:</strong> the 64-bit keyID of the OpenPGP key.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_pk_algorithm</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm"></a>Function: <em>gnutls_pk_algorithm_t</em> <strong>gnutls_openpgp_privkey_get_pk_algorithm</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: is an OpenPGP key
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of an OpenPGP
certificate.
</p>
<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>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fpreferred_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_preferred_key_id</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fpreferred_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fpreferred_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_preferred_key_id</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the struct to save the keyid.
</p>
<p>Get the preferred key-id for the key.
</p>
<p><strong>Returns:</strong> the 64-bit preferred keyID of the OpenPGP key, or if it
hasn’t been set it returns <code>GNUTLS_E_INVALID_REQUEST</code> .
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005frevoked_005fstatus-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_revoked_status</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005frevoked_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005frevoked_005fstatus"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_revoked_status</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP private key.
</p>
<p>Get revocation status of key.
</p>
<p><strong>Returns:</strong> true (1) if the key has been revoked, or false (0) if it
has not, or a negative error code indicates an error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcount-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_count</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcount"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcount"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_subkey_count</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: is an OpenPGP key
</p>
<p>This function will return the number of subkeys present in the
given OpenPGP certificate.
</p>
<p><strong>Returns:</strong> the number of subkeys, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcreation_005ftime-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_creation_time</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcreation_005ftime"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcreation_005ftime"></a>Function: <em>time_t</em> <strong>gnutls_openpgp_privkey_get_subkey_creation_time</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>idx</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP private key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p>Get subkey creation time.
</p>
<p><strong>Returns:</strong> the timestamp when the OpenPGP key was created.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005ffingerprint-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_fingerprint</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005ffingerprint"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005ffingerprint"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_subkey_fingerprint</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>idx</var>, void * <var>fpr</var>, size_t * <var>fprlen</var>)</em></dt>
<dd><p><var>key</var>: the raw data that contains the OpenPGP secret key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p><var>fpr</var>: the buffer to save the fingerprint, must hold at least 20 bytes.
</p>
<p><var>fprlen</var>: the integer to save the length of the fingerprint.
</p>
<p>Get the fingerprint of an OpenPGP subkey. Depends on the
algorithm, the fingerprint can be 16 or 20 bytes.
</p>
<p><strong>Returns:</strong> On success, 0 is returned, or an error code.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_id</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_subkey_id</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>idx</var>, gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP secret key.
</p>
<p><var>idx</var>: the subkey index
</p>
<p><var>keyid</var>: the buffer to save the keyid.
</p>
<p>Get the key-id for the subkey.
</p>
<p><strong>Returns:</strong> the 64-bit keyID of the OpenPGP key.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fidx-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_idx</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fidx"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fidx"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_subkey_idx</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, const gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP private key.
</p>
<p><var>keyid</var>: the keyid.
</p>
<p>Get index of subkey.
</p>
<p><strong>Returns:</strong> the index of the subkey or a negative error value.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_pk_algorithm</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fpk_005falgorithm"></a>Function: <em>gnutls_pk_algorithm_t</em> <strong>gnutls_openpgp_privkey_get_subkey_pk_algorithm</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>idx</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: is an OpenPGP key
</p>
<p><var>idx</var>: is the subkey index
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of a subkey of an OpenPGP
certificate.
</p>
<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>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005frevoked_005fstatus-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_get_subkey_revoked_status</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005frevoked_005fstatus"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005frevoked_005fstatus"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_get_subkey_revoked_status</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>idx</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP private key.
</p>
<p><var>idx</var>: is the subkey index
</p>
<p>Get revocation status of key.
</p>
<p><strong>Returns:</strong> true (1) if the key has been revoked, or false (0) if it
has not, or a negative error code indicates an error.
</p>
<p><strong>Since:</strong> 2.4.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fimport-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_import</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fimport"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fimport"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_import</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const char * <var>password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key.
</p>
<p><var>data</var>: The RAW or BASE64 encoded key.
</p>
<p><var>format</var>: One of <code>gnutls_openpgp_crt_fmt_t</code> elements.
</p>
<p><var>password</var>: not used for now
</p>
<p><var>flags</var>: should be (0)
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005finit-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_init</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005finit"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005finit"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_init</strong> <em>(gnutls_openpgp_privkey_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will initialize an OpenPGP key structure.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fsec_005fparam-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_sec_param</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fsec_005fparam"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fsec_005fparam"></a>Function: <em>gnutls_sec_param_t</em> <strong>gnutls_openpgp_privkey_sec_param</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: a key structure
</p>
<p>This function will return the security parameter appropriate with
this private key.
</p>
<p><strong>Returns:</strong> On success, a valid security parameter is returned otherwise
<code>GNUTLS_SEC_PARAM_UNKNOWN</code> is returned.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fset_005fpreferred_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_set_preferred_key_id</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fset_005fpreferred_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fset_005fpreferred_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_set_preferred_key_id</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, const gnutls_openpgp_keyid_t <var>keyid</var>)</em></dt>
<dd><p><var>key</var>: the structure that contains the OpenPGP public key.
</p>
<p><var>keyid</var>: the selected keyid
</p>
<p>This allows setting a preferred key id for the given certificate.
This key will be used by functions that involve key handling.
</p>
<p>If the provided <code>keyid</code> is <code>NULL</code> then the master key is
set as preferred.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction-1"></a>
<h4 class="subheading">gnutls_openpgp_set_recv_key_function</h4>
<a name="gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction"></a>Function: <em>void</em> <strong>gnutls_openpgp_set_recv_key_function</strong> <em>(gnutls_session_t <var>session</var>, gnutls_openpgp_recv_key_func <var>func</var>)</em></dt>
<dd><p><var>session</var>: a TLS session
</p>
<p><var>func</var>: the callback
</p>
<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></dd></dl>
<hr>
<a name="PKCS-12-API"></a>
<div class="header">
<p>
Next: <a href="#PKCS-11-API" accesskey="n" rel="next">PKCS 11 API</a>, Previous: <a href="#OpenPGP-API" accesskey="p" rel="previous">OpenPGP API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="PKCS-12-API-1"></a>
<h3 class="section">E.7 PKCS 12 API</h3>
<p>The following functions are to be used for PKCS 12 handling.
Their prototypes lie in <samp>gnutls/pkcs12.h</samp>.
</p>
<a name="gnutls_005fpkcs12_005fbag_005fdecrypt-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_decrypt</h4>
<a name="gnutls_005fpkcs12_005fbag_005fdecrypt"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fdecrypt"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_decrypt</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, const char * <var>pass</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>pass</var>: The password used for encryption, must be ASCII.
</p>
<p>This function will decrypt the given encrypted bag and return 0 on
success.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_deinit</h4>
<a name="gnutls_005fpkcs12_005fbag_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs12_bag_deinit</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>)</em></dt>
<dd><p><var>bag</var>: The structure to be initialized
</p>
<p>This function will deinitialize a PKCS12 Bag structure.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fencrypt-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_encrypt</h4>
<a name="gnutls_005fpkcs12_005fbag_005fencrypt"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fencrypt"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_encrypt</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, const char * <var>pass</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>pass</var>: The password used for encryption, must be ASCII
</p>
<p><var>flags</var>: should be one of <code>gnutls_pkcs_encrypt_flags_t</code> elements bitwise or’d
</p>
<p>This function will encrypt the given bag.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
otherwise a negative error code is returned.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fget_005fcount-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_get_count</h4>
<a name="gnutls_005fpkcs12_005fbag_005fget_005fcount"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fget_005fcount"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_get_count</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p>This function will return the number of the elements withing the bag.
</p>
<p><strong>Returns:</strong> Number of elements in bag, or an negative error code on
error.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fget_005fdata-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_get_data</h4>
<a name="gnutls_005fpkcs12_005fbag_005fget_005fdata"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fget_005fdata"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_get_data</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>indx</var>: The element of the bag to get the data from
</p>
<p><var>data</var>: where the bag’s data will be. Should be treated as constant.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_get_friendly_name</h4>
<a name="gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_get_friendly_name</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, char ** <var>name</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>indx</var>: The bag’s element to add the id
</p>
<p><var>name</var>: will hold a pointer to the name (to be treated as const)
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_get_key_id</h4>
<a name="gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_get_key_id</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, gnutls_datum_t * <var>id</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>indx</var>: The bag’s element to add the id
</p>
<p><var>id</var>: where the ID will be copied (to be treated as const)
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_get_type</h4>
<a name="gnutls_005fpkcs12_005fbag_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fget_005ftype"></a>Function: <em>gnutls_pkcs12_bag_type_t</em> <strong>gnutls_pkcs12_bag_get_type</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>indx</var>: The element of the bag to get the type
</p>
<p>This function will return the bag’s type.
</p>
<p><strong>Returns:</strong> One of the <code>gnutls_pkcs12_bag_type_t</code> enumerations.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_init</h4>
<a name="gnutls_005fpkcs12_005fbag_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_init</strong> <em>(gnutls_pkcs12_bag_t * <var>bag</var>)</em></dt>
<dd><p><var>bag</var>: The structure to be initialized
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fcrl-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_set_crl</h4>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fcrl"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fcrl"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_set_crl</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, gnutls_x509_crl_t <var>crl</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>crl</var>: the CRL to be copied.
</p>
<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>
<p><strong>Returns:</strong> the index of the added bag on success, or a negative error code
on failure.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_set_crt</h4>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fcrt"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_set_crt</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, gnutls_x509_crt_t <var>crt</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>crt</var>: the certificate to be copied.
</p>
<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>
<p><strong>Returns:</strong> the index of the added bag on success, or a negative
value on failure.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fdata-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_set_data</h4>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fdata"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fdata"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_set_data</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, gnutls_pkcs12_bag_type_t <var>type</var>, const gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>type</var>: The data’s type
</p>
<p><var>data</var>: the data to be copied.
</p>
<p>This function will insert the given data of the given type into
the bag.
</p>
<p><strong>Returns:</strong> the index of the added bag on success, or a negative
value on error.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_set_friendly_name</h4>
<a name="gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_set_friendly_name</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, const char * <var>name</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>indx</var>: The bag’s element to add the id
</p>
<p><var>name</var>: the name
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_pkcs12_bag_set_key_id</h4>
<a name="gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_pkcs12_bag_set_key_id</strong> <em>(gnutls_pkcs12_bag_t <var>bag</var>, int <var>indx</var>, const gnutls_datum_t * <var>id</var>)</em></dt>
<dd><p><var>bag</var>: The bag
</p>
<p><var>indx</var>: The bag’s element to add the id
</p>
<p><var>id</var>: the ID
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value. or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs12_deinit</h4>
<a name="gnutls_005fpkcs12_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs12_deinit</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>)</em></dt>
<dd><p><var>pkcs12</var>: The structure to be initialized
</p>
<p>This function will deinitialize a PKCS12 structure.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fexport-1"></a>
<h4 class="subheading">gnutls_pkcs12_export</h4>
<a name="gnutls_005fpkcs12_005fexport"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fexport"></a>Function: <em>int</em> <strong>gnutls_pkcs12_export</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>pkcs12</var>: Holds the pkcs12 structure
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a structure PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the pkcs12 structure to DER or PEM format.
</p>
<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>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN PKCS12".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fexport2-1"></a>
<h4 class="subheading">gnutls_pkcs12_export2</h4>
<a name="gnutls_005fpkcs12_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fexport2"></a>Function: <em>int</em> <strong>gnutls_pkcs12_export2</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>pkcs12</var>: Holds the pkcs12 structure
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a structure PEM or DER encoded
</p>
<p>This function will export the pkcs12 structure to DER or PEM format.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN PKCS12".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fgenerate_005fmac-1"></a>
<h4 class="subheading">gnutls_pkcs12_generate_mac</h4>
<a name="gnutls_005fpkcs12_005fgenerate_005fmac"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fgenerate_005fmac"></a>Function: <em>int</em> <strong>gnutls_pkcs12_generate_mac</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, const char * <var>pass</var>)</em></dt>
<dd><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
</p>
<p><var>pass</var>: The password for the MAC
</p>
<p>This function will generate a MAC for the PKCS12 structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fget_005fbag-1"></a>
<h4 class="subheading">gnutls_pkcs12_get_bag</h4>
<a name="gnutls_005fpkcs12_005fget_005fbag"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fget_005fbag"></a>Function: <em>int</em> <strong>gnutls_pkcs12_get_bag</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, int <var>indx</var>, gnutls_pkcs12_bag_t <var>bag</var>)</em></dt>
<dd><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
</p>
<p><var>indx</var>: contains the index of the bag to extract
</p>
<p><var>bag</var>: An initialized bag, where the contents of the bag will be copied
</p>
<p>This function will return a Bag from the PKCS12 structure.
</p>
<p>After the last Bag has been read
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> will be returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fimport-1"></a>
<h4 class="subheading">gnutls_pkcs12_import</h4>
<a name="gnutls_005fpkcs12_005fimport"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fimport"></a>Function: <em>int</em> <strong>gnutls_pkcs12_import</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkcs12</var>: The structure to store the parsed PKCS12.
</p>
<p><var>data</var>: The DER or PEM encoded PKCS12.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p><var>flags</var>: an ORed sequence of gnutls_privkey_pkcs8_flags
</p>
<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>
<p>If the PKCS12 is PEM encoded it should have a header of "PKCS12".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs12_init</h4>
<a name="gnutls_005fpkcs12_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs12_init</strong> <em>(gnutls_pkcs12_t * <var>pkcs12</var>)</em></dt>
<dd><p><var>pkcs12</var>: The structure to be initialized
</p>
<p>This function will initialize a PKCS12 structure. PKCS12 structures
usually contain lists of X.509 Certificates and X.509 Certificate
revocation lists.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fset_005fbag-1"></a>
<h4 class="subheading">gnutls_pkcs12_set_bag</h4>
<a name="gnutls_005fpkcs12_005fset_005fbag"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fset_005fbag"></a>Function: <em>int</em> <strong>gnutls_pkcs12_set_bag</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, gnutls_pkcs12_bag_t <var>bag</var>)</em></dt>
<dd><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
</p>
<p><var>bag</var>: An initialized bag
</p>
<p>This function will insert a Bag into the PKCS12 structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fsimple_005fparse-1"></a>
<h4 class="subheading">gnutls_pkcs12_simple_parse</h4>
<a name="gnutls_005fpkcs12_005fsimple_005fparse"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fsimple_005fparse-1"></a>Function: <em>int</em> <strong>gnutls_pkcs12_simple_parse</strong> <em>(gnutls_pkcs12_t <var>p12</var>, const char * <var>password</var>, gnutls_x509_privkey_t * <var>key</var>, gnutls_x509_crt_t ** <var>chain</var>, unsigned int * <var>chain_len</var>, gnutls_x509_crt_t ** <var>extra_certs</var>, unsigned int * <var>extra_certs_len</var>, gnutls_x509_crl_t * <var>crl</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>p12</var>: the PKCS<code>12</code> blob.
</p>
<p><var>password</var>: optional password used to decrypt PKCS<code>12</code> blob, bags and keys.
</p>
<p><var>key</var>: a structure to store the parsed private key.
</p>
<p><var>chain</var>: the corresponding to key certificate chain (may be <code>NULL</code> )
</p>
<p><var>chain_len</var>: will be updated with the number of additional (may be <code>NULL</code> )
</p>
<p><var>extra_certs</var>: optional pointer to receive an array of additional
certificates found in the PKCS<code>12</code> blob (may be <code>NULL</code> ).
</p>
<p><var>extra_certs_len</var>: will be updated with the number of additional
certs (may be <code>NULL</code> ).
</p>
<p><var>crl</var>: an optional structure to store the parsed CRL (may be <code>NULL</code> ).
</p>
<p><var>flags</var>: should be zero or one of GNUTLS_PKCS12_SP_*
</p>
<p>This function parses a PKCS<code>12</code> blob in <code>p12blob</code> and extracts the
private key, the corresponding certificate chain, and any additional
certificates and a CRL.
</p>
<p>The <code>extra_certs_ret</code> and <code>extra_certs_len</code> parameters are optional
and both may be set to <code>NULL</code> . If either is non-<code>NULL</code> , then both must
be set.
</p>
<p>Encrypted PKCS<code>12</code> bags and PKCS<code>8</code> private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
</p>
<p>A 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>
<p>It is believed that the limitations of this function are acceptable
for common usage, and that any more flexibility would introduce
complexity that would make it harder to use this functionality at
all.
</p>
<p>If the provided structure has encrypted fields but no password
is provided then this function returns <code>GNUTLS_E_DECRYPTION_FAILED</code> .
</p>
<p>Note that normally the chain constructed does not include self signed
certificates, to comply with TLS’ requirements. If, however, the flag
<code>GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED</code> is specified then
self signed certificates will be included in the chain.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<a name="gnutls_005fpkcs12_005fverify_005fmac-1"></a>
<h4 class="subheading">gnutls_pkcs12_verify_mac</h4>
<a name="gnutls_005fpkcs12_005fverify_005fmac"></a><dl>
<dt><a name="index-gnutls_005fpkcs12_005fverify_005fmac"></a>Function: <em>int</em> <strong>gnutls_pkcs12_verify_mac</strong> <em>(gnutls_pkcs12_t <var>pkcs12</var>, const char * <var>pass</var>)</em></dt>
<dd><p><var>pkcs12</var>: should contain a gnutls_pkcs12_t structure
</p>
<p><var>pass</var>: The password for the MAC
</p>
<p>This function will verify the MAC for the PKCS12 structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<hr>
<a name="PKCS-11-API"></a>
<div class="header">
<p>
Next: <a href="#TPM-API" accesskey="n" rel="next">TPM API</a>, Previous: <a href="#PKCS-12-API" accesskey="p" rel="previous">PKCS 12 API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Hardware-token-via-PKCS-11-API"></a>
<h3 class="section">E.8 Hardware token via PKCS 11 API</h3>
<p>The following functions are to be used for PKCS 11 handling.
Their prototypes lie in <samp>gnutls/pkcs11.h</samp>.
</p>
<a name="gnutls_005fpkcs11_005fadd_005fprovider-1"></a>
<h4 class="subheading">gnutls_pkcs11_add_provider</h4>
<a name="gnutls_005fpkcs11_005fadd_005fprovider"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fadd_005fprovider"></a>Function: <em>int</em> <strong>gnutls_pkcs11_add_provider</strong> <em>(const char * <var>name</var>, const char * <var>params</var>)</em></dt>
<dd><p><var>name</var>: The filename of the module
</p>
<p><var>params</var>: should be NULL
</p>
<p>This function will load and add a PKCS 11 module to the module
list used in gnutls. After this function is called the module will
be used for PKCS 11 operations.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fcopy_005fsecret_005fkey-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_secret_key</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fsecret_005fkey"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fsecret_005fkey"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_secret_key</strong> <em>(const char * <var>token_url</var>, gnutls_datum_t * <var>key</var>, const char * <var>label</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>key</var>: The raw key
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a raw secret (symmetric) key into a PKCS <code>11</code>
token specified by a URL. The key can be marked as sensitive or not.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fcrt-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_x509_crt</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fcrt"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fcrt-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_crt</strong> <em>(const char * <var>token_url</var>, gnutls_x509_crt_t <var>crt</var>, const char * <var>label</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>crt</var>: A certificate
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_FLAG_*
</p>
<p>This function will copy a certificate into a PKCS <code>11</code> token specified by
a URL. The certificate can be marked as trusted or not.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey-1"></a>
<h4 class="subheading">gnutls_pkcs11_copy_x509_privkey</h4>
<a name="gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_copy_x509_privkey</strong> <em>(const char * <var>token_url</var>, gnutls_x509_privkey_t <var>key</var>, const char * <var>label</var>, unsigned int <var>key_usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>key</var>: A private key
</p>
<p><var>label</var>: A name to be used for the stored data
</p>
<p><var>key_usage</var>: One of GNUTLS_KEY_*
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will copy a private key into a PKCS <code>11</code> token specified by
a URL. It is highly recommended flags to contain <code>GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE</code>
unless there is a strong reason not to.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_deinit</h4>
<a name="gnutls_005fpkcs11_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs11_deinit</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function will deinitialize the PKCS 11 subsystem in gnutls.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fdelete_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_delete_url</h4>
<a name="gnutls_005fpkcs11_005fdelete_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fdelete_005furl-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_delete_url</strong> <em>(const char * <var>object_url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>object_url</var>: The URL of the object to delete.
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will delete objects matching the given URL.
Note that not all tokens support the delete operation.
</p>
<p><strong>Returns:</strong> On success, the number of objects deleted is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fget_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_get_pin_function</h4>
<a name="gnutls_005fpkcs11_005fget_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fget_005fpin_005ffunction"></a>Function: <em>gnutls_pin_callback_t</em> <strong>gnutls_pkcs11_get_pin_function</strong> <em>(void ** <var>userdata</var>)</em></dt>
<dd><p><var>userdata</var>: data to be supplied to callback
</p>
<p>This function will return the callback function set using
<code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p><strong>Returns:</strong> The function set or NULL otherwise.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_init</h4>
<a name="gnutls_005fpkcs11_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005finit-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_init</strong> <em>(unsigned int <var>flags</var>, const char * <var>deprecated_config_file</var>)</em></dt>
<dd><p><var>flags</var>: <code>GNUTLS_PKCS11_FLAG_MANUAL</code> or <code>GNUTLS_PKCS11_FLAG_AUTO</code>
</p>
<p><var>deprecated_config_file</var>: either NULL or the location of a deprecated
configuration file
</p>
<p>This function will initialize the PKCS 11 subsystem in gnutls. It will
read configuration files if <code>GNUTLS_PKCS11_FLAG_AUTO</code> is used or allow
you to independently load PKCS 11 modules using <code>gnutls_pkcs11_add_provider()</code>
if <code>GNUTLS_PKCS11_FLAG_MANUAL</code> is specified.
</p>
<p>Normally you don’t need to call this function since it is being called
by <code>gnutls_global_init()</code> using the <code>GNUTLS_PKCS11_FLAG_AUTO</code> . If other option
is required then it must be called before it.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_deinit</h4>
<a name="gnutls_005fpkcs11_005fobj_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs11_obj_deinit</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>)</em></dt>
<dd><p><var>obj</var>: The structure to be initialized
</p>
<p>This function will deinitialize a certificate structure.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fexport-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>obj</var>: Holds the object
</p>
<p><var>output_data</var>: will contain a certificate PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the PKCS11 object data. It is normal for
data to be inaccesible and in that case <code>GNUTLS_E_INVALID_REQUEST</code>
will be returned.
</p>
<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>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fexport2-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export2</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport2"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export2</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>obj</var>: Holds the object
</p>
<p><var>out</var>: will contain a certificate PEM or DER encoded
</p>
<p>This function will export the PKCS11 object data. It is normal for
data to be inaccesible and in that case <code>GNUTLS_E_INVALID_REQUEST</code>
will be returned.
</p>
<p>The output buffer is allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and <code>GNUTLS_E_SUCCESS</code> (0) on success.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fexport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_export_url</h4>
<a name="gnutls_005fpkcs11_005fobj_005fexport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fexport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_export_url</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</em></dt>
<dd><p><var>obj</var>: Holds the PKCS 11 certificate
</p>
<p><var>detailed</var>: non zero if a detailed URL is required
</p>
<p><var>url</var>: will contain an allocated url
</p>
<p>This function will export a URL identifying the given certificate.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fget_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_get_info</h4>
<a name="gnutls_005fpkcs11_005fobj_005fget_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005finfo-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_get_info</strong> <em>(gnutls_pkcs11_obj_t <var>crt</var>, gnutls_pkcs11_obj_info_t <var>itype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>crt</var>: should contain a <code>gnutls_pkcs11_obj_t</code> structure
</p>
<p><var>itype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS11 certificate
such as the label, id as well as token information where the key is
stored. When output is text it returns null terminated string
although <code>output_size</code> contains the size of the actual data only.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_get_type</h4>
<a name="gnutls_005fpkcs11_005fobj_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fget_005ftype"></a>Function: <em>gnutls_pkcs11_obj_type_t</em> <strong>gnutls_pkcs11_obj_get_type</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>)</em></dt>
<dd><p><var>obj</var>: Holds the PKCS 11 object
</p>
<p>This function will return the type of the certificate being
stored in the structure.
</p>
<p><strong>Returns:</strong> The type of the certificate.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_import_url</h4>
<a name="gnutls_005fpkcs11_005fobj_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_import_url</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>obj</var>: The structure to store the object
</p>
<p><var>url</var>: a PKCS 11 url identifying the key
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will "import" a PKCS 11 URL identifying an object (e.g. certificate)
to the <code>gnutls_pkcs11_obj_t</code> structure. This does not involve any
parsing (such as X.509 or OpenPGP) since the <code>gnutls_pkcs11_obj_t</code> is
format agnostic. Only data are transferred.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_init</h4>
<a name="gnutls_005fpkcs11_005fobj_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_init</strong> <em>(gnutls_pkcs11_obj_t * <var>obj</var>)</em></dt>
<dd><p><var>obj</var>: The structure to be initialized
</p>
<p>This function will initialize a pkcs11 certificate structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_list_import_url</h4>
<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_list_import_url</strong> <em>(gnutls_pkcs11_obj_t * <var>p_list</var>, unsigned int * <var>n_list</var>, const char * <var>url</var>, gnutls_pkcs11_obj_attr_t <var>attrs</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>p_list</var>: An uninitialized object list (may be NULL)
</p>
<p><var>n_list</var>: initially should hold the maximum size of the list. Will contain the actual size.
</p>
<p><var>url</var>: A PKCS 11 url identifying a set of objects
</p>
<p><var>attrs</var>: Attributes of type <code>gnutls_pkcs11_obj_attr_t</code> that can be used to limit output
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will initialize and set values to an object list
by using all objects identified by a PKCS 11 URL.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl2-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_list_import_url2</h4>
<a name="gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl2"></a>Function: <em>int</em> <strong>gnutls_pkcs11_obj_list_import_url2</strong> <em>(gnutls_pkcs11_obj_t ** <var>p_list</var>, unsigned int * <var>n_list</var>, const char * <var>url</var>, gnutls_pkcs11_obj_attr_t <var>attrs</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>p_list</var>: An uninitialized object list (may be NULL)
</p>
<p><var>n_list</var>: It will contain the size of the list.
</p>
<p><var>url</var>: A PKCS 11 url identifying a set of objects
</p>
<p><var>attrs</var>: Attributes of type <code>gnutls_pkcs11_obj_attr_t</code> that can be used to limit output
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will initialize and set values to an object list
by using all objects identified by the PKCS 11 URL. The output
is stored in <code>p_list</code> , which will be initialized.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_obj_set_pin_function</h4>
<a name="gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_obj_set_pin_function</strong> <em>(gnutls_pkcs11_obj_t <var>obj</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>obj</var>: The object structure
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
required to access the object. This function overrides the global
set using <code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_deinit</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pkcs11_privkey_deinit</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will deinitialize a private key structure.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fexport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_export_url</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fexport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fexport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_export_url</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</em></dt>
<dd><p><var>key</var>: Holds the PKCS 11 key
</p>
<p><var>detailed</var>: non zero if a detailed URL is required
</p>
<p><var>url</var>: will contain an allocated url
</p>
<p>This function will export a URL identifying the given key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_generate</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fgenerate"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_generate</strong> <em>(const char* <var>url</var>, gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char* <var>label</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: a token URL
</p>
<p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>label</var>: a label
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will generate a private key in the specified
by the <code>url</code> token. The private key will be generate within
the token and will not be exportable.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate2-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_generate2</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fgenerate2"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fgenerate2"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_generate2</strong> <em>(const char* <var>url</var>, gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char* <var>label</var>, gnutls_x509_crt_fmt_t <var>fmt</var>, gnutls_datum_t * <var>pubkey</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>url</var>: a token URL
</p>
<p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>label</var>: a label
</p>
<p><var>fmt</var>: the format of output params. PEM or DER.
</p>
<p><var>pubkey</var>: will hold the public key (may be <code>NULL</code> )
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will generate a private key in the specified
by the <code>url</code> token. The private key will be generate within
the token and will not be exportable. This function will
store the DER-encoded public key in the SubjectPublicKeyInfo format
in <code>pubkey</code> . The <code>pubkey</code> should be deinitialized using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.5
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fget_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_get_info</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fget_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fget_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_get_info</strong> <em>(gnutls_pkcs11_privkey_t <var>pkey</var>, gnutls_pkcs11_obj_info_t <var>itype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>pkey</var>: should contain a <code>gnutls_pkcs11_privkey_t</code> structure
</p>
<p><var>itype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS 11 private key such
as the label, id as well as token information where the key is stored. When
output is text it returns null terminated string although <code>output_size</code> contains
the size of the actual data only.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_get_pk_algorithm</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_get_pk_algorithm</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_pkcs11_privkey_t</code> structure
</p>
<p><var>bits</var>: if bits is non null it will hold the size of the parameters’ in bits
</p>
<p>This function will return the public key algorithm of a private
key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_import_url</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_import_url</strong> <em>(gnutls_pkcs11_privkey_t <var>pkey</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The structure to store the parsed key
</p>
<p><var>url</var>: a PKCS 11 url identifying the key
</p>
<p><var>flags</var>: sequence of GNUTLS_PKCS_PRIVKEY_*
</p>
<p>This function will "import" a PKCS 11 URL identifying a private
key to the <code>gnutls_pkcs11_privkey_t</code> structure. In reality since
in most cases keys cannot be exported, the private key structure
is being associated with the available operations on the token.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_init</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_privkey_init</strong> <em>(gnutls_pkcs11_privkey_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will initialize an private key structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_privkey_set_pin_function</h4>
<a name="gnutls_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_privkey_set_pin_function</strong> <em>(gnutls_pkcs11_privkey_t <var>key</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>key</var>: The private key
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
required to access the object. This function overrides the global
set using <code>gnutls_pkcs11_set_pin_function()</code> .
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005freinit-1"></a>
<h4 class="subheading">gnutls_pkcs11_reinit</h4>
<a name="gnutls_005fpkcs11_005freinit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005freinit-1"></a>Function: <em>int</em> <strong>gnutls_pkcs11_reinit</strong> <em>( <var>void</var>)</em></dt>
<dd>
<p>This function will reinitialize the PKCS 11 subsystem in gnutls.
This is required by PKCS 11 when an application uses <code>fork()</code> . The
reinitialization function must be called on the child.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_set_pin_function</h4>
<a name="gnutls_005fpkcs11_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_set_pin_function</strong> <em>(gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>fn</var>: The PIN callback, a <code>gnutls_pin_callback_t()</code> function.
</p>
<p><var>userdata</var>: data to be supplied to callback
</p>
<p>This function will set a callback function to be used when a PIN is
required for PKCS 11 operations. See
<code>gnutls_pin_callback_t()</code> on how the callback should behave.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005fset_005ftoken_005ffunction-1"></a>
<h4 class="subheading">gnutls_pkcs11_set_token_function</h4>
<a name="gnutls_005fpkcs11_005fset_005ftoken_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005fset_005ftoken_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pkcs11_set_token_function</strong> <em>(gnutls_pkcs11_token_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>fn</var>: The token callback
</p>
<p><var>userdata</var>: data to be supplied to callback
</p>
<p>This function will set a callback function to be used when a token
needs to be inserted to continue PKCS 11 operations.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005fflags-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_flags</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005fflags"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005fflags"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_flags</strong> <em>(const char * <var>url</var>, unsigned int * <var>flags</var>)</em></dt>
<dd><p><var>url</var>: should contain a PKCS 11 URL
</p>
<p><var>flags</var>: The output flags (GNUTLS_PKCS11_TOKEN_*)
</p>
<p>This function will return information about the PKCS 11 token flags.
The flags from the <code>gnutls_pkcs11_token_info_t</code> enumeration.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005finfo-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_info</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005finfo"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005finfo"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_info</strong> <em>(const char * <var>url</var>, gnutls_pkcs11_token_info_t <var>ttype</var>, void * <var>output</var>, size_t * <var>output_size</var>)</em></dt>
<dd><p><var>url</var>: should contain a PKCS 11 URL
</p>
<p><var>ttype</var>: Denotes the type of information requested
</p>
<p><var>output</var>: where output will be stored
</p>
<p><var>output_size</var>: contains the maximum size of the output and will be overwritten with actual
</p>
<p>This function will return information about the PKCS 11 token such
as the label, id, etc.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success or a negative error code
on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005fmechanism-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_mechanism</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005fmechanism"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005fmechanism"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_mechanism</strong> <em>(const char * <var>url</var>, unsigned int <var>idx</var>, unsigned long * <var>mechanism</var>)</em></dt>
<dd><p><var>url</var>: should contain a PKCS 11 URL
</p>
<p><var>idx</var>: The index of the mechanism
</p>
<p><var>mechanism</var>: The PKCS <code>11</code> mechanism ID
</p>
<p>This function will return the names of the supported mechanisms
by the token. It should be called with an increasing index until
it return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005furl-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_get_url</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fget_005furl"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fget_005furl"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_get_url</strong> <em>(unsigned int <var>seq</var>, gnutls_pkcs11_url_type_t <var>detailed</var>, char ** <var>url</var>)</em></dt>
<dd><p><var>seq</var>: sequence number starting from 0
</p>
<p><var>detailed</var>: non zero if a detailed URL is required
</p>
<p><var>url</var>: will contain an allocated url
</p>
<p>This function will return the URL for each token available
in system. The url has to be released using <code>gnutls_free()</code>
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned,
<code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code> if the sequence number
exceeds the available tokens, otherwise a negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftoken_005finit-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_init</h4>
<a name="gnutls_005fpkcs11_005ftoken_005finit"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005finit"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_init</strong> <em>(const char * <var>token_url</var>, const char * <var>so_pin</var>, const char * <var>label</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>so_pin</var>: Security Officer’s PIN
</p>
<p><var>label</var>: A name to be used for the token
</p>
<p>This function will initialize (format) a token. If the token is
at a factory defaults state the security officer’s PIN given will be
set to be the default. Otherwise it should match the officer’s PIN.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftoken_005fset_005fpin-1"></a>
<h4 class="subheading">gnutls_pkcs11_token_set_pin</h4>
<a name="gnutls_005fpkcs11_005ftoken_005fset_005fpin"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftoken_005fset_005fpin"></a>Function: <em>int</em> <strong>gnutls_pkcs11_token_set_pin</strong> <em>(const char * <var>token_url</var>, const char * <var>oldpin</var>, const char * <var>newpin</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>token_url</var>: A PKCS <code>11</code> URL specifying a token
</p>
<p><var>oldpin</var>: old user’s PIN
</p>
<p><var>newpin</var>: new user’s PIN
</p>
<p><var>flags</var>: one of <code>gnutls_pin_flag_t</code> .
</p>
<p>This function will modify or set a user’s PIN for the given token.
If it is called to set a user pin for first time the oldpin must
be NULL.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fpkcs11_005ftype_005fget_005fname-1"></a>
<h4 class="subheading">gnutls_pkcs11_type_get_name</h4>
<a name="gnutls_005fpkcs11_005ftype_005fget_005fname"></a><dl>
<dt><a name="index-gnutls_005fpkcs11_005ftype_005fget_005fname"></a>Function: <em>const char *</em> <strong>gnutls_pkcs11_type_get_name</strong> <em>(gnutls_pkcs11_obj_type_t <var>type</var>)</em></dt>
<dd><p><var>type</var>: Holds the PKCS 11 object type, a <code>gnutls_pkcs11_obj_type_t</code> .
</p>
<p>This function will return a human readable description of the
PKCS11 object type <code>obj</code> . It will return "Unknown" for unknown
types.
</p>
<p><strong>Returns:</strong> human readable string labeling the PKCS11 object type
<code>type</code> .
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fimport_005fpkcs11-1"></a>
<h4 class="subheading">gnutls_x509_crt_import_pkcs11</h4>
<a name="gnutls_005fx509_005fcrt_005fimport_005fpkcs11"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fimport_005fpkcs11"></a>Function: <em>int</em> <strong>gnutls_x509_crt_import_pkcs11</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_pkcs11_obj_t <var>pkcs11_crt</var>)</em></dt>
<dd><p><var>crt</var>: A certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>pkcs11_crt</var>: A PKCS 11 object that contains a certificate
</p>
<p>This function will import a PKCS 11 certificate to a <code>gnutls_x509_crt_t</code>
structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fimport_005fpkcs11_005furl-1"></a>
<h4 class="subheading">gnutls_x509_crt_import_pkcs11_url</h4>
<a name="gnutls_005fx509_005fcrt_005fimport_005fpkcs11_005furl"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fimport_005fpkcs11_005furl"></a>Function: <em>int</em> <strong>gnutls_x509_crt_import_pkcs11_url</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crt</var>: A certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>url</var>: A PKCS 11 url
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will import a PKCS 11 certificate directly from a token
without involving the <code>gnutls_pkcs11_obj_t</code> structure. This function will
fail if the certificate stored is not of X.509 type.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11-1"></a>
<h4 class="subheading">gnutls_x509_crt_list_import_pkcs11</h4>
<a name="gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11"></a>Function: <em>int</em> <strong>gnutls_x509_crt_list_import_pkcs11</strong> <em>(gnutls_x509_crt_t * <var>certs</var>, unsigned int <var>cert_max</var>, gnutls_pkcs11_obj_t * const <var>objs</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>certs</var>: A list of certificates of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>cert_max</var>: The maximum size of the list
</p>
<p><var>objs</var>: A list of PKCS 11 objects
</p>
<p><var>flags</var>: 0 for now
</p>
<p>This function will import a PKCS 11 certificate list to a list of
<code>gnutls_x509_crt_t</code> structure. These must not be initialized.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<hr>
<a name="TPM-API"></a>
<div class="header">
<p>
Next: <a href="#Abstract-key-API" accesskey="n" rel="next">Abstract key API</a>, Previous: <a href="#PKCS-11-API" accesskey="p" rel="previous">PKCS 11 API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="TPM-API-1"></a>
<h3 class="section">E.9 TPM API</h3>
<p>The following functions are to be used for TPM handling.
Their prototypes lie in <samp>gnutls/tpm.h</samp>.
</p>
<a name="gnutls_005ftpm_005fget_005fregistered-1"></a>
<h4 class="subheading">gnutls_tpm_get_registered</h4>
<a name="gnutls_005ftpm_005fget_005fregistered"></a><dl>
<dt><a name="index-gnutls_005ftpm_005fget_005fregistered"></a>Function: <em>int</em> <strong>gnutls_tpm_get_registered</strong> <em>(gnutls_tpm_key_list_t * <var>list</var>)</em></dt>
<dd><p><var>list</var>: a list to store the keys
</p>
<p>This function will get a list of stored keys in the TPM. The uuid
of those keys
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005ftpm_005fkey_005flist_005fdeinit-1"></a>
<h4 class="subheading">gnutls_tpm_key_list_deinit</h4>
<a name="gnutls_005ftpm_005fkey_005flist_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005ftpm_005fkey_005flist_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_tpm_key_list_deinit</strong> <em>(gnutls_tpm_key_list_t <var>list</var>)</em></dt>
<dd><p><var>list</var>: a list of the keys
</p>
<p>This function will deinitialize the list of stored keys in the TPM.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005ftpm_005fkey_005flist_005fget_005furl-1"></a>
<h4 class="subheading">gnutls_tpm_key_list_get_url</h4>
<a name="gnutls_005ftpm_005fkey_005flist_005fget_005furl"></a><dl>
<dt><a name="index-gnutls_005ftpm_005fkey_005flist_005fget_005furl"></a>Function: <em>int</em> <strong>gnutls_tpm_key_list_get_url</strong> <em>(gnutls_tpm_key_list_t <var>list</var>, unsigned int <var>idx</var>, char** <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>list</var>: a list of the keys
</p>
<p><var>idx</var>: The index of the key (starting from zero)
</p>
<p><var>url</var>: The URL to be returned
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will return for each given index a URL of
the corresponding key.
If the provided index is out of bounds then <code>GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE</code>
is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005ftpm_005fprivkey_005fdelete-1"></a>
<h4 class="subheading">gnutls_tpm_privkey_delete</h4>
<a name="gnutls_005ftpm_005fprivkey_005fdelete"></a><dl>
<dt><a name="index-gnutls_005ftpm_005fprivkey_005fdelete-2"></a>Function: <em>int</em> <strong>gnutls_tpm_privkey_delete</strong> <em>(const char* <var>url</var>, const char* <var>srk_password</var>)</em></dt>
<dd><p><var>url</var>: the URL describing the key
</p>
<p><var>srk_password</var>: a password for the SRK key
</p>
<p>This function will unregister the private key from the TPM
chip.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005ftpm_005fprivkey_005fgenerate-1"></a>
<h4 class="subheading">gnutls_tpm_privkey_generate</h4>
<a name="gnutls_005ftpm_005fprivkey_005fgenerate"></a><dl>
<dt><a name="index-gnutls_005ftpm_005fprivkey_005fgenerate-1"></a>Function: <em>int</em> <strong>gnutls_tpm_privkey_generate</strong> <em>(gnutls_pk_algorithm_t <var>pk</var>, unsigned int <var>bits</var>, const char* <var>srk_password</var>, const char* <var>key_password</var>, gnutls_tpmkey_fmt_t <var>format</var>, gnutls_x509_crt_fmt_t <var>pub_format</var>, gnutls_datum_t* <var>privkey</var>, gnutls_datum_t* <var>pubkey</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pk</var>: the public key algorithm
</p>
<p><var>bits</var>: the security bits
</p>
<p><var>srk_password</var>: a password to protect the exported key (optional)
</p>
<p><var>key_password</var>: the password for the TPM (optional)
</p>
<p><var>format</var>: the format of the private key
</p>
<p><var>pub_format</var>: the format of the public key
</p>
<p><var>privkey</var>: the generated key
</p>
<p><var>pubkey</var>: the corresponding public key (may be null)
</p>
<p><var>flags</var>: should be a list of GNUTLS_TPM_* flags
</p>
<p>This function will generate a private key in the TPM
chip. The private key will be generated within the chip
and will be exported in a wrapped with TPM’s master key
form. Furthermore the wrapped key can be protected with
the provided <code>password</code> .
</p>
<p>Note that bits in TPM is quantized value. If the input value
is not one of the allowed values, then it will be quantized to
one of 512, 1024, 2048, 4096, 8192 and 16384.
</p>
<p>Allowed flags are:
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<hr>
<a name="Abstract-key-API"></a>
<div class="header">
<p>
Next: <a href="#DANE-API" accesskey="n" rel="next">DANE API</a>, Previous: <a href="#TPM-API" accesskey="p" rel="previous">TPM API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Abstract-key-API-1"></a>
<h3 class="section">E.10 Abstract key API</h3>
<p>The following functions are to be used for abstract key handling.
Their prototypes lie in <samp>gnutls/abstract.h</samp>.
</p>
<a name="gnutls_005fcertificate_005fset_005fkey-1"></a>
<h4 class="subheading">gnutls_certificate_set_key</h4>
<a name="gnutls_005fcertificate_005fset_005fkey"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fkey-1"></a>Function: <em>int</em> <strong>gnutls_certificate_set_key</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, const char** <var>names</var>, int <var>names_size</var>, gnutls_pcert_st * <var>pcert_list</var>, int <var>pcert_list_size</var>, gnutls_privkey_t <var>key</var>)</em></dt>
<dd><p><var>res</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>names</var>: is an array of DNS name of the certificate (NULL if none)
</p>
<p><var>names_size</var>: holds the size of the names list
</p>
<p><var>pcert_list</var>: contains a certificate list (path) for the specified private key
</p>
<p><var>pcert_list_size</var>: holds the size of the certificate list
</p>
<p><var>key</var>: is a <code>gnutls_privkey_t</code> key
</p>
<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. For clients that wants to send more than its own end
entity certificate (e.g., also an intermediate CA cert) then put
the certificate chain in <code>pcert_list</code> . The <code>pcert_list</code> and <code>key</code> will
become part of the credentials structure and must not
be deallocated. They will be automatically deallocated when <code>res</code> is deinitialized.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fcertificate_005fset_005fretrieve_005ffunction2-1"></a>
<h4 class="subheading">gnutls_certificate_set_retrieve_function2</h4>
<a name="gnutls_005fcertificate_005fset_005fretrieve_005ffunction2"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fretrieve_005ffunction2"></a>Function: <em>void</em> <strong>gnutls_certificate_set_retrieve_function2</strong> <em>(gnutls_certificate_credentials_t <var>cred</var>, gnutls_certificate_retrieve_function2 * <var>func</var>)</em></dt>
<dd><p><var>cred</var>: is a <code>gnutls_certificate_credentials_t</code> structure.
</p>
<p><var>func</var>: is the callback function
</p>
<p>This function sets a callback to be called in order to retrieve the
certificate to be used in the handshake.
</p>
<p>The callback’s function prototype is:
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_pcert_st** pcert,
unsigned int *pcert_length, gnutls_privkey_t * pkey);
</p>
<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>
<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>
<p><code>pcert</code> should contain a single certificate and public or a list of them.
</p>
<p><code>pcert_length</code> is the size of the previous list.
</p>
<p><code>pkey</code> is the private key.
</p>
<p>If the callback function is provided then gnutls will call it, in the
handshake, after the certificate request message has been received.
</p>
<p>In server side pk_algos and req_ca_dn are NULL.
</p>
<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>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpcert_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pcert_deinit</h4>
<a name="gnutls_005fpcert_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpcert_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pcert_deinit</strong> <em>(gnutls_pcert_st * <var>pcert</var>)</em></dt>
<dd><p><var>pcert</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a pcert structure.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpcert_005fimport_005fopenpgp-1"></a>
<h4 class="subheading">gnutls_pcert_import_openpgp</h4>
<a name="gnutls_005fpcert_005fimport_005fopenpgp"></a><dl>
<dt><a name="index-gnutls_005fpcert_005fimport_005fopenpgp"></a>Function: <em>int</em> <strong>gnutls_pcert_import_openpgp</strong> <em>(gnutls_pcert_st* <var>pcert</var>, gnutls_openpgp_crt_t <var>crt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pcert</var>: The pcert structure
</p>
<p><var>crt</var>: The raw certificate to be imported
</p>
<p><var>flags</var>: zero for now
</p>
<p>This convenience function will import the given certificate to a
<code>gnutls_pcert_st</code> structure. The structure must be deinitialized
afterwards using <code>gnutls_pcert_deinit()</code> ;
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpcert_005fimport_005fopenpgp_005fraw-1"></a>
<h4 class="subheading">gnutls_pcert_import_openpgp_raw</h4>
<a name="gnutls_005fpcert_005fimport_005fopenpgp_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpcert_005fimport_005fopenpgp_005fraw"></a>Function: <em>int</em> <strong>gnutls_pcert_import_openpgp_raw</strong> <em>(gnutls_pcert_st * <var>pcert</var>, const gnutls_datum_t* <var>cert</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, gnutls_openpgp_keyid_t <var>keyid</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pcert</var>: The pcert structure
</p>
<p><var>cert</var>: The raw certificate to be imported
</p>
<p><var>format</var>: The format of the certificate
</p>
<p><var>keyid</var>: The key ID to use (NULL for the master key)
</p>
<p><var>flags</var>: zero for now
</p>
<p>This convenience function will import the given certificate to a
<code>gnutls_pcert_st</code> structure. The structure must be deinitialized
afterwards using <code>gnutls_pcert_deinit()</code> ;
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpcert_005fimport_005fx509-1"></a>
<h4 class="subheading">gnutls_pcert_import_x509</h4>
<a name="gnutls_005fpcert_005fimport_005fx509"></a><dl>
<dt><a name="index-gnutls_005fpcert_005fimport_005fx509"></a>Function: <em>int</em> <strong>gnutls_pcert_import_x509</strong> <em>(gnutls_pcert_st* <var>pcert</var>, gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pcert</var>: The pcert structure
</p>
<p><var>crt</var>: The raw certificate to be imported
</p>
<p><var>flags</var>: zero for now
</p>
<p>This convenience function will import the given certificate to a
<code>gnutls_pcert_st</code> structure. The structure must be deinitialized
afterwards using <code>gnutls_pcert_deinit()</code> ;
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpcert_005fimport_005fx509_005fraw-1"></a>
<h4 class="subheading">gnutls_pcert_import_x509_raw</h4>
<a name="gnutls_005fpcert_005fimport_005fx509_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpcert_005fimport_005fx509_005fraw"></a>Function: <em>int</em> <strong>gnutls_pcert_import_x509_raw</strong> <em>(gnutls_pcert_st * <var>pcert</var>, const gnutls_datum_t* <var>cert</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pcert</var>: The pcert structure
</p>
<p><var>cert</var>: The raw certificate to be imported
</p>
<p><var>format</var>: The format of the certificate
</p>
<p><var>flags</var>: zero for now
</p>
<p>This convenience function will import the given certificate to a
<code>gnutls_pcert_st</code> structure. The structure must be deinitialized
afterwards using <code>gnutls_pcert_deinit()</code> ;
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpcert_005flist_005fimport_005fx509_005fraw-1"></a>
<h4 class="subheading">gnutls_pcert_list_import_x509_raw</h4>
<a name="gnutls_005fpcert_005flist_005fimport_005fx509_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpcert_005flist_005fimport_005fx509_005fraw"></a>Function: <em>int</em> <strong>gnutls_pcert_list_import_x509_raw</strong> <em>(gnutls_pcert_st * <var>pcerts</var>, unsigned int * <var>pcert_max</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pcerts</var>: The structures to store the parsed certificate. Must not be initialized.
</p>
<p><var>pcert_max</var>: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
</p>
<p><var>data</var>: The certificates.
</p>
<p><var>format</var>: One of DER or PEM.
</p>
<p><var>flags</var>: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
</p>
<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>
<p>If the Certificate is PEM encoded it should have a header of "X509
CERTIFICATE", or "CERTIFICATE".
</p>
<p><strong>Returns:</strong> the number of certificates read or a negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fdecrypt_005fdata-1"></a>
<h4 class="subheading">gnutls_privkey_decrypt_data</h4>
<a name="gnutls_005fprivkey_005fdecrypt_005fdata"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fdecrypt_005fdata-1"></a>Function: <em>int</em> <strong>gnutls_privkey_decrypt_data</strong> <em>(gnutls_privkey_t <var>key</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>ciphertext</var>, gnutls_datum_t * <var>plaintext</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>flags</var>: zero for now
</p>
<p><var>ciphertext</var>: holds the data to be decrypted
</p>
<p><var>plaintext</var>: will contain the decrypted data, allocated with <code>gnutls_malloc()</code>
</p>
<p>This function will decrypt the given data using the algorithm
supported by the private key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fdeinit-1"></a>
<h4 class="subheading">gnutls_privkey_deinit</h4>
<a name="gnutls_005fprivkey_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_privkey_deinit</strong> <em>(gnutls_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a private key structure.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_privkey_get_pk_algorithm</h4>
<a name="gnutls_005fprivkey_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_privkey_get_pk_algorithm</strong> <em>(gnutls_privkey_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_privkey_t</code> structure
</p>
<p><var>bits</var>: If set will return the number of bits of the parameters (may be NULL)
</p>
<p>This function will return the public key algorithm of a private
key and if possible will return a number of bits that indicates
the security parameter of the key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fget_005ftype-1"></a>
<h4 class="subheading">gnutls_privkey_get_type</h4>
<a name="gnutls_005fprivkey_005fget_005ftype"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fget_005ftype"></a>Function: <em>gnutls_privkey_type_t</em> <strong>gnutls_privkey_get_type</strong> <em>(gnutls_privkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_privkey_t</code> structure
</p>
<p>This function will return the type of the private key. This is
actually the type of the subsystem used to set this private key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_privkey_type_t</code> enumeration on
success, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fext-1"></a>
<h4 class="subheading">gnutls_privkey_import_ext</h4>
<a name="gnutls_005fprivkey_005fimport_005fext"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fext"></a>Function: <em>int</em> <strong>gnutls_privkey_import_ext</strong> <em>(gnutls_privkey_t <var>pkey</var>, gnutls_pk_algorithm_t <var>pk</var>, void* <var>userdata</var>, gnutls_privkey_sign_func <var>sign_func</var>, gnutls_privkey_decrypt_func <var>decrypt_func</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>pk</var>: The public key algorithm
</p>
<p><var>userdata</var>: private data to be provided to the callbacks
</p>
<p><var>sign_func</var>: callback for signature operations
</p>
<p><var>decrypt_func</var>: callback for decryption operations
</p>
<p><var>flags</var>: Flags for the import
</p>
<p>This function will associate the given callbacks with the
<code>gnutls_privkey_t</code> structure. At least one of the two callbacks
must be non-null.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fext2-1"></a>
<h4 class="subheading">gnutls_privkey_import_ext2</h4>
<a name="gnutls_005fprivkey_005fimport_005fext2"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fext2-1"></a>Function: <em>int</em> <strong>gnutls_privkey_import_ext2</strong> <em>(gnutls_privkey_t <var>pkey</var>, gnutls_pk_algorithm_t <var>pk</var>, void* <var>userdata</var>, gnutls_privkey_sign_func <var>sign_func</var>, gnutls_privkey_decrypt_func <var>decrypt_func</var>, gnutls_privkey_deinit_func <var>deinit_func</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>pk</var>: The public key algorithm
</p>
<p><var>userdata</var>: private data to be provided to the callbacks
</p>
<p><var>sign_func</var>: callback for signature operations
</p>
<p><var>decrypt_func</var>: callback for decryption operations
</p>
<p><var>deinit_func</var>: a deinitialization function
</p>
<p><var>flags</var>: Flags for the import
</p>
<p>This function will associate the given callbacks with the
<code>gnutls_privkey_t</code> structure. At least one of the two callbacks
must be non-null. If a deinitialization function is provided
then flags is assumed to contain <code>GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fopenpgp-1"></a>
<h4 class="subheading">gnutls_privkey_import_openpgp</h4>
<a name="gnutls_005fprivkey_005fimport_005fopenpgp"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fopenpgp"></a>Function: <em>int</em> <strong>gnutls_privkey_import_openpgp</strong> <em>(gnutls_privkey_t <var>pkey</var>, gnutls_openpgp_privkey_t <var>key</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>key</var>: The private key to be imported
</p>
<p><var>flags</var>: Flags for the import
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>The <code>gnutls_openpgp_privkey_t</code> object must not be deallocated
during the lifetime of this structure. The subkey set as
preferred will be used, or the master key otherwise.
</p>
<p><code>flags</code> might be zero or one of <code>GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE</code>
and <code>GNUTLS_PRIVKEY_IMPORT_COPY</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fopenpgp_005fraw-1"></a>
<h4 class="subheading">gnutls_privkey_import_openpgp_raw</h4>
<a name="gnutls_005fprivkey_005fimport_005fopenpgp_005fraw"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fopenpgp_005fraw"></a>Function: <em>int</em> <strong>gnutls_privkey_import_openpgp_raw</strong> <em>(gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const gnutls_openpgp_keyid_t <var>keyid</var>, const char* <var>password</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>data</var>: The private key data to be imported
</p>
<p><var>format</var>: The format of the private key
</p>
<p><var>keyid</var>: The key id to use (optional)
</p>
<p><var>password</var>: A password (optional)
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fpkcs11-1"></a>
<h4 class="subheading">gnutls_privkey_import_pkcs11</h4>
<a name="gnutls_005fprivkey_005fimport_005fpkcs11"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fpkcs11"></a>Function: <em>int</em> <strong>gnutls_privkey_import_pkcs11</strong> <em>(gnutls_privkey_t <var>pkey</var>, gnutls_pkcs11_privkey_t <var>key</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>key</var>: The private key to be imported
</p>
<p><var>flags</var>: Flags for the import
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>The <code>gnutls_pkcs11_privkey_t</code> object must not be deallocated
during the lifetime of this structure.
</p>
<p><code>flags</code> might be zero or one of <code>GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE</code>
and <code>GNUTLS_PRIVKEY_IMPORT_COPY</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fpkcs11_005furl-1"></a>
<h4 class="subheading">gnutls_privkey_import_pkcs11_url</h4>
<a name="gnutls_005fprivkey_005fimport_005fpkcs11_005furl"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fpkcs11_005furl"></a>Function: <em>int</em> <strong>gnutls_privkey_import_pkcs11_url</strong> <em>(gnutls_privkey_t <var>key</var>, const char * <var>url</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_pubkey_t</code>
</p>
<p><var>url</var>: A PKCS 11 url
</p>
<p>This function will import a PKCS 11 private key to a <code>gnutls_private_key_t</code>
structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005ftpm_005fraw-1"></a>
<h4 class="subheading">gnutls_privkey_import_tpm_raw</h4>
<a name="gnutls_005fprivkey_005fimport_005ftpm_005fraw"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005ftpm_005fraw"></a>Function: <em>int</em> <strong>gnutls_privkey_import_tpm_raw</strong> <em>(gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>fdata</var>, gnutls_tpmkey_fmt_t <var>format</var>, const char * <var>srk_password</var>, const char * <var>key_password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>fdata</var>: The TPM key to be imported
</p>
<p><var>format</var>: The format of the private key
</p>
<p><var>srk_password</var>: The password for the SRK key (optional)
</p>
<p><var>key_password</var>: A password for the key (optional)
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>With respect to passwords the same as in <code>gnutls_privkey_import_tpm_url()</code> apply.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005ftpm_005furl-1"></a>
<h4 class="subheading">gnutls_privkey_import_tpm_url</h4>
<a name="gnutls_005fprivkey_005fimport_005ftpm_005furl"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005ftpm_005furl-1"></a>Function: <em>int</em> <strong>gnutls_privkey_import_tpm_url</strong> <em>(gnutls_privkey_t <var>pkey</var>, const char* <var>url</var>, const char * <var>srk_password</var>, const char * <var>key_password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>url</var>: The URL of the TPM key to be imported
</p>
<p><var>srk_password</var>: The password for the SRK key (optional)
</p>
<p><var>key_password</var>: A password for the key (optional)
</p>
<p><var>flags</var>: One of the GNUTLS_PRIVKEY_* flags
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>Note that unless <code>GNUTLS_PRIVKEY_DISABLE_CALLBACKS</code>
is specified, if incorrect (or NULL) passwords are given
the PKCS11 callback functions will be used to obtain the
correct passwords. Otherwise if the SRK password is wrong
<code>GNUTLS_E_TPM_SRK_PASSWORD_ERROR</code> is returned and if the key password
is wrong or not provided then <code>GNUTLS_E_TPM_KEY_PASSWORD_ERROR</code>
is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_privkey_import_url</h4>
<a name="gnutls_005fprivkey_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005furl-1"></a>Function: <em>int</em> <strong>gnutls_privkey_import_url</strong> <em>(gnutls_privkey_t <var>key</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_privkey_t</code>
</p>
<p><var>url</var>: A PKCS 11 url
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import a PKCS11 or TPM URL as a
private key. The supported URL types can be checked
using <code>gnutls_url_is_supported()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fx509-1"></a>
<h4 class="subheading">gnutls_privkey_import_x509</h4>
<a name="gnutls_005fprivkey_005fimport_005fx509"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fx509"></a>Function: <em>int</em> <strong>gnutls_privkey_import_x509</strong> <em>(gnutls_privkey_t <var>pkey</var>, gnutls_x509_privkey_t <var>key</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>key</var>: The private key to be imported
</p>
<p><var>flags</var>: Flags for the import
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>The <code>gnutls_x509_privkey_t</code> object must not be deallocated
during the lifetime of this structure.
</p>
<p><code>flags</code> might be zero or one of <code>GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE</code>
and <code>GNUTLS_PRIVKEY_IMPORT_COPY</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fimport_005fx509_005fraw-1"></a>
<h4 class="subheading">gnutls_privkey_import_x509_raw</h4>
<a name="gnutls_005fprivkey_005fimport_005fx509_005fraw"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fimport_005fx509_005fraw-1"></a>Function: <em>int</em> <strong>gnutls_privkey_import_x509_raw</strong> <em>(gnutls_privkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, const char* <var>password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The private key
</p>
<p><var>data</var>: The private key data to be imported
</p>
<p><var>format</var>: The format of the private key
</p>
<p><var>password</var>: A password (optional)
</p>
<p><var>flags</var>: an ORed sequence of gnutls_pkcs_encrypt_flags_t
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>The supported formats are basic unencrypted key, PKCS <code>8</code> , PKCS <code>12</code> ,
and the openssl format.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005finit-1"></a>
<h4 class="subheading">gnutls_privkey_init</h4>
<a name="gnutls_005fprivkey_005finit"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005finit"></a>Function: <em>int</em> <strong>gnutls_privkey_init</strong> <em>(gnutls_privkey_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will initialize an private key structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_privkey_set_pin_function</h4>
<a name="gnutls_005fprivkey_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_privkey_set_pin_function</strong> <em>(gnutls_privkey_t <var>key</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_privkey_t</code>
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
required to access the object. This function overrides any other
global PIN functions.
</p>
<p>Note that this function must be called right after initialization
to have effect.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fsign_005fdata-1"></a>
<h4 class="subheading">gnutls_privkey_sign_data</h4>
<a name="gnutls_005fprivkey_005fsign_005fdata"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fsign_005fdata-1"></a>Function: <em>int</em> <strong>gnutls_privkey_sign_data</strong> <em>(gnutls_privkey_t <var>signer</var>, gnutls_digest_algorithm_t <var>hash</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>signer</var>: Holds the key
</p>
<p><var>hash</var>: should be a digest algorithm
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain the signature allocate with <code>gnutls_malloc()</code>
</p>
<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 the SHA family for the DSA keys.
</p>
<p>You may use <code>gnutls_pubkey_get_preferred_hash_algorithm()</code> to determine
the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fprivkey_005fsign_005fhash-1"></a>
<h4 class="subheading">gnutls_privkey_sign_hash</h4>
<a name="gnutls_005fprivkey_005fsign_005fhash"></a><dl>
<dt><a name="index-gnutls_005fprivkey_005fsign_005fhash-1"></a>Function: <em>int</em> <strong>gnutls_privkey_sign_hash</strong> <em>(gnutls_privkey_t <var>signer</var>, gnutls_digest_algorithm_t <var>hash_algo</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>hash_data</var>, gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>signer</var>: Holds the signer’s key
</p>
<p><var>hash_algo</var>: The hash algorithm used
</p>
<p><var>flags</var>: zero for now
</p>
<p><var>hash_data</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain newly allocated signature
</p>
<p>This function will sign the given hashed 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-XXX for the DSA keys.
</p>
<p>You may use <code>gnutls_pubkey_get_preferred_hash_algorithm()</code> to determine
the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fdeinit-1"></a>
<h4 class="subheading">gnutls_pubkey_deinit</h4>
<a name="gnutls_005fpubkey_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_pubkey_deinit</strong> <em>(gnutls_pubkey_t <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a public key structure.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fencrypt_005fdata-1"></a>
<h4 class="subheading">gnutls_pubkey_encrypt_data</h4>
<a name="gnutls_005fpubkey_005fencrypt_005fdata"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fencrypt_005fdata-1"></a>Function: <em>int</em> <strong>gnutls_pubkey_encrypt_data</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>plaintext</var>, gnutls_datum_t * <var>ciphertext</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>plaintext</var>: The data to be encrypted
</p>
<p><var>ciphertext</var>: contains the encrypted data
</p>
<p>This function will encrypt the given data, using the public
key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fexport-1"></a>
<h4 class="subheading">gnutls_pubkey_export</h4>
<a name="gnutls_005fpubkey_005fexport"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fexport"></a>Function: <em>int</em> <strong>gnutls_pubkey_export</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, void * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the certificate
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>output_data</var>: will contain a certificate PEM or DER encoded
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will export the public key to DER or PEM format.
The contents of the exported data is the SubjectPublicKeyInfo
X.509 structure.
</p>
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will
be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fexport2-1"></a>
<h4 class="subheading">gnutls_pubkey_export2</h4>
<a name="gnutls_005fpubkey_005fexport2"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fexport2-1"></a>Function: <em>int</em> <strong>gnutls_pubkey_export2</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_x509_crt_fmt_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>key</var>: Holds the certificate
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>out</var>: will contain a certificate PEM or DER encoded
</p>
<p>This function will export the public key to DER or PEM format.
The contents of the exported data is the SubjectPublicKeyInfo
X.509 structure.
</p>
<p>The output buffer will be allocated using <code>gnutls_malloc()</code> .
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN CERTIFICATE".
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_pubkey_get_key_id</h4>
<a name="gnutls_005fpubkey_005fget_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_key_id</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>output_data</var>: will contain the key ID
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p>This function will return a unique ID that depends on the public
key parameters. This ID can be used in checking whether a
certificate corresponds to the given public key.
</p>
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_pubkey_get_key_usage</h4>
<a name="gnutls_005fpubkey_005fget_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_key_usage</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int * <var>usage</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_pubkey_t</code> structure
</p>
<p><var>usage</var>: If set will return the number of bits of the parameters (may be NULL)
</p>
<p>This function will return the key usage of the public key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fopenpgp_005fkey_005fid-1"></a>
<h4 class="subheading">gnutls_pubkey_get_openpgp_key_id</h4>
<a name="gnutls_005fpubkey_005fget_005fopenpgp_005fkey_005fid"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fopenpgp_005fkey_005fid"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_openpgp_key_id</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int <var>flags</var>, unsigned char * <var>output_data</var>, size_t * <var>output_data_size</var>, unsigned int * <var>subkey</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>output_data</var>: will contain the key ID
</p>
<p><var>output_data_size</var>: holds the size of output_data (and will be
replaced by the actual size of parameters)
</p>
<p><var>subkey</var>: Will be non zero if the key ID corresponds to a subkey
</p>
<p>This function returned the OpenPGP key ID of the corresponding key.
The key is a unique ID that depends on the public
key parameters.
</p>
<p>If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will
be returned. The output is <code>GNUTLS_OPENPGP_KEYID_SIZE</code> bytes long.
</p>
<p><strong>Returns:</strong> In case of failure a negative error code will be
returned, and 0 on success.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fpk_005falgorithm-1"></a>
<h4 class="subheading">gnutls_pubkey_get_pk_algorithm</h4>
<a name="gnutls_005fpubkey_005fget_005fpk_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fpk_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_pk_algorithm</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>key</var>: should contain a <code>gnutls_pubkey_t</code> structure
</p>
<p><var>bits</var>: If set will return the number of bits of the parameters (may be NULL)
</p>
<p>This function will return the public key algorithm of a public
key and if possible will return a number of bits that indicates
the security parameter of the key.
</p>
<p><strong>Returns:</strong> a member of the <code>gnutls_pk_algorithm_t</code> enumeration on
success, or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fpk_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_get_pk_dsa_raw</h4>
<a name="gnutls_005fpubkey_005fget_005fpk_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fpk_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_pk_dsa_raw</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>g</var>, gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>p</var>: will hold the p
</p>
<p><var>q</var>: will hold the q
</p>
<p><var>g</var>: will hold the g
</p>
<p><var>y</var>: will hold the y
</p>
<p>This function will export the DSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fpk_005fecc_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_get_pk_ecc_raw</h4>
<a name="gnutls_005fpubkey_005fget_005fpk_005fecc_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fpk_005fecc_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_pk_ecc_raw</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_ecc_curve_t * <var>curve</var>, gnutls_datum_t * <var>x</var>, gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>curve</var>: will hold the curve
</p>
<p><var>x</var>: will hold x
</p>
<p><var>y</var>: will hold y
</p>
<p>This function will export the ECC public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fpk_005fecc_005fx962-1"></a>
<h4 class="subheading">gnutls_pubkey_get_pk_ecc_x962</h4>
<a name="gnutls_005fpubkey_005fget_005fpk_005fecc_005fx962"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fpk_005fecc_005fx962"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_pk_ecc_x962</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_datum_t* <var>parameters</var>, gnutls_datum_t * <var>ecpoint</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>parameters</var>: DER encoding of an ANSI X9.62 parameters
</p>
<p><var>ecpoint</var>: DER encoding of ANSI X9.62 ECPoint
</p>
<p>This function will export the ECC public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fpk_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_get_pk_rsa_raw</h4>
<a name="gnutls_005fpubkey_005fget_005fpk_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fpk_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_pk_rsa_raw</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>key</var>: Holds the certificate
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p>This function will export the RSA public 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fpreferred_005fhash_005falgorithm-1"></a>
<h4 class="subheading">gnutls_pubkey_get_preferred_hash_algorithm</h4>
<a name="gnutls_005fpubkey_005fget_005fpreferred_005fhash_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fpreferred_005fhash_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_preferred_hash_algorithm</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_digest_algorithm_t * <var>hash</var>, unsigned int * <var>mand</var>)</em></dt>
<dd><p><var>key</var>: Holds the certificate
</p>
<p><var>hash</var>: The result of the call with the hash algorithm used for signature
</p>
<p><var>mand</var>: If non zero it means that the algorithm MUST use this hash. May be NULL.
</p>
<p>This function will read the certifcate and return the appropriate digest
algorithm to use for signing with this certificate. Some certificates (i.e.
DSA might not be able to sign without the preferred algorithm).
</p>
<p><strong>Returns:</strong> the 0 if the hash algorithm is found. A negative error code is
returned on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fget_005fverify_005falgorithm-1"></a>
<h4 class="subheading">gnutls_pubkey_get_verify_algorithm</h4>
<a name="gnutls_005fpubkey_005fget_005fverify_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fget_005fverify_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_pubkey_get_verify_algorithm</strong> <em>(gnutls_pubkey_t <var>key</var>, const gnutls_datum_t * <var>signature</var>, gnutls_digest_algorithm_t * <var>hash</var>)</em></dt>
<dd><p><var>key</var>: Holds the certificate
</p>
<p><var>signature</var>: contains the signature
</p>
<p><var>hash</var>: The result of the call with the hash algorithm used for signature
</p>
<p>This function will read the certifcate and the signed data to
determine the hash algorithm used to generate the signature.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport-1"></a>
<h4 class="subheading">gnutls_pubkey_import</h4>
<a name="gnutls_005fpubkey_005fimport"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport"></a>Function: <em>int</em> <strong>gnutls_pubkey_import</strong> <em>(gnutls_pubkey_t <var>key</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed public key.
</p>
<p><var>data</var>: The DER or PEM encoded certificate.
</p>
<p><var>format</var>: One of DER or PEM
</p>
<p>This function will import the provided public key in
a SubjectPublicKeyInfo X.509 structure to a native
<code>gnutls_pubkey_t</code> structure. The output will be stored
in <code>key</code> . If the public key is PEM encoded it should have a header
of "PUBLIC KEY".
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fdsa_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_import_dsa_raw</h4>
<a name="gnutls_005fpubkey_005fimport_005fdsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fdsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_dsa_raw</strong> <em>(gnutls_pubkey_t <var>key</var>, const gnutls_datum_t * <var>p</var>, const gnutls_datum_t * <var>q</var>, const gnutls_datum_t * <var>g</var>, const gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>p</var>: holds the p
</p>
<p><var>q</var>: holds the q
</p>
<p><var>g</var>: holds the g
</p>
<p><var>y</var>: holds the y
</p>
<p>This function will convert the given DSA raw parameters to the
native <code>gnutls_pubkey_t</code> format. The output will be stored
in <code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fecc_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_import_ecc_raw</h4>
<a name="gnutls_005fpubkey_005fimport_005fecc_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fecc_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_ecc_raw</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_ecc_curve_t <var>curve</var>, const gnutls_datum_t * <var>x</var>, const gnutls_datum_t * <var>y</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>curve</var>: holds the curve
</p>
<p><var>x</var>: holds the x
</p>
<p><var>y</var>: holds the y
</p>
<p>This function will convert the given elliptic curve parameters to a
<code>gnutls_pubkey_t</code> . The output will be stored in <code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fecc_005fx962-1"></a>
<h4 class="subheading">gnutls_pubkey_import_ecc_x962</h4>
<a name="gnutls_005fpubkey_005fimport_005fecc_005fx962"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fecc_005fx962"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_ecc_x962</strong> <em>(gnutls_pubkey_t <var>key</var>, const gnutls_datum_t * <var>parameters</var>, const gnutls_datum_t * <var>ecpoint</var>)</em></dt>
<dd><p><var>key</var>: The structure to store the parsed key
</p>
<p><var>parameters</var>: DER encoding of an ANSI X9.62 parameters
</p>
<p><var>ecpoint</var>: DER encoding of ANSI X9.62 ECPoint
</p>
<p>This function will convert the given elliptic curve parameters to a
<code>gnutls_pubkey_t</code> . The output will be stored in <code>key</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fopenpgp-1"></a>
<h4 class="subheading">gnutls_pubkey_import_openpgp</h4>
<a name="gnutls_005fpubkey_005fimport_005fopenpgp"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fopenpgp"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_openpgp</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_openpgp_crt_t <var>crt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The public key
</p>
<p><var>crt</var>: The certificate to be imported
</p>
<p><var>flags</var>: should be zero
</p>
<p>Imports a public key from an openpgp key. This function will import
the given public key to the abstract <code>gnutls_pubkey_t</code>
structure. The subkey set as preferred will be imported or the
master key otherwise.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fopenpgp_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_import_openpgp_raw</h4>
<a name="gnutls_005fpubkey_005fimport_005fopenpgp_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fopenpgp_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_openpgp_raw</strong> <em>(gnutls_pubkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_openpgp_crt_fmt_t <var>format</var>, const gnutls_openpgp_keyid_t <var>keyid</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The public key
</p>
<p><var>data</var>: The public key data to be imported
</p>
<p><var>format</var>: The format of the public key
</p>
<p><var>keyid</var>: The key id to use (optional)
</p>
<p><var>flags</var>: Should be zero
</p>
<p>This function will import the given public key to the abstract
<code>gnutls_pubkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fpkcs11-1"></a>
<h4 class="subheading">gnutls_pubkey_import_pkcs11</h4>
<a name="gnutls_005fpubkey_005fimport_005fpkcs11"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fpkcs11"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_pkcs11</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_pkcs11_obj_t <var>obj</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The public key
</p>
<p><var>obj</var>: The parameters to be imported
</p>
<p><var>flags</var>: should be zero
</p>
<p>Imports a public key from a pkcs11 key. This function will import
the given public key to the abstract <code>gnutls_pubkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fpkcs11_005furl-1"></a>
<h4 class="subheading">gnutls_pubkey_import_pkcs11_url</h4>
<a name="gnutls_005fpubkey_005fimport_005fpkcs11_005furl"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fpkcs11_005furl"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_pkcs11_url</strong> <em>(gnutls_pubkey_t <var>key</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_pubkey_t</code>
</p>
<p><var>url</var>: A PKCS 11 url
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will import a PKCS 11 certificate to a <code>gnutls_pubkey_t</code>
structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fprivkey-1"></a>
<h4 class="subheading">gnutls_pubkey_import_privkey</h4>
<a name="gnutls_005fpubkey_005fimport_005fprivkey"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fprivkey"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_privkey</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_privkey_t <var>pkey</var>, unsigned int <var>usage</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The public key
</p>
<p><var>pkey</var>: The private key
</p>
<p><var>usage</var>: GNUTLS_KEY_* key usage flags.
</p>
<p><var>flags</var>: should be zero
</p>
<p>Imports the public key from a private. This function will import
the given public key to the abstract <code>gnutls_pubkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005frsa_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_import_rsa_raw</h4>
<a name="gnutls_005fpubkey_005fimport_005frsa_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005frsa_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_rsa_raw</strong> <em>(gnutls_pubkey_t <var>key</var>, const gnutls_datum_t * <var>m</var>, const gnutls_datum_t * <var>e</var>)</em></dt>
<dd><p><var>key</var>: Is a structure will hold the parameters
</p>
<p><var>m</var>: holds the modulus
</p>
<p><var>e</var>: holds the public exponent
</p>
<p>This function will replace the parameters in the given structure.
The new parameters should be stored in the appropriate
gnutls_datum.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005ftpm_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_import_tpm_raw</h4>
<a name="gnutls_005fpubkey_005fimport_005ftpm_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005ftpm_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_tpm_raw</strong> <em>(gnutls_pubkey_t <var>pkey</var>, const gnutls_datum_t * <var>fdata</var>, gnutls_tpmkey_fmt_t <var>format</var>, const char * <var>srk_password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The public key
</p>
<p><var>fdata</var>: The TPM key to be imported
</p>
<p><var>format</var>: The format of the private key
</p>
<p><var>srk_password</var>: The password for the SRK key (optional)
</p>
<p><var>flags</var>: One of the GNUTLS_PUBKEY_* flags
</p>
<p>This function will import the public key from the provided TPM key
structure.
</p>
<p>With respect to passwords the same as in
<code>gnutls_pubkey_import_tpm_url()</code> apply.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005ftpm_005furl-1"></a>
<h4 class="subheading">gnutls_pubkey_import_tpm_url</h4>
<a name="gnutls_005fpubkey_005fimport_005ftpm_005furl"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005ftpm_005furl-1"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_tpm_url</strong> <em>(gnutls_pubkey_t <var>pkey</var>, const char* <var>url</var>, const char * <var>srk_password</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The public key
</p>
<p><var>url</var>: The URL of the TPM key to be imported
</p>
<p><var>srk_password</var>: The password for the SRK key (optional)
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import the given private key to the abstract
<code>gnutls_privkey_t</code> structure.
</p>
<p>Note that unless <code>GNUTLS_PUBKEY_DISABLE_CALLBACKS</code>
is specified, if incorrect (or NULL) passwords are given
the PKCS11 callback functions will be used to obtain the
correct passwords. Otherwise if the SRK password is wrong
<code>GNUTLS_E_TPM_SRK_PASSWORD_ERROR</code> is returned.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005furl-1"></a>
<h4 class="subheading">gnutls_pubkey_import_url</h4>
<a name="gnutls_005fpubkey_005fimport_005furl"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005furl"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_url</strong> <em>(gnutls_pubkey_t <var>key</var>, const char * <var>url</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_pubkey_t</code>
</p>
<p><var>url</var>: A PKCS 11 url
</p>
<p><var>flags</var>: One of GNUTLS_PKCS11_OBJ_* flags
</p>
<p>This function will import a PKCS11 certificate or a TPM key
as a public key.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fx509-1"></a>
<h4 class="subheading">gnutls_pubkey_import_x509</h4>
<a name="gnutls_005fpubkey_005fimport_005fx509"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fx509"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_x509</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The public key
</p>
<p><var>crt</var>: The certificate to be imported
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import the given public key to the abstract
<code>gnutls_pubkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fx509_005fcrq-1"></a>
<h4 class="subheading">gnutls_pubkey_import_x509_crq</h4>
<a name="gnutls_005fpubkey_005fimport_005fx509_005fcrq"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fx509_005fcrq"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_x509_crq</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_x509_crq_t <var>crq</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>key</var>: The public key
</p>
<p><var>crq</var>: The certificate to be imported
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import the given public key to the abstract
<code>gnutls_pubkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.5
</p></dd></dl>
<a name="gnutls_005fpubkey_005fimport_005fx509_005fraw-1"></a>
<h4 class="subheading">gnutls_pubkey_import_x509_raw</h4>
<a name="gnutls_005fpubkey_005fimport_005fx509_005fraw"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fimport_005fx509_005fraw"></a>Function: <em>int</em> <strong>gnutls_pubkey_import_x509_raw</strong> <em>(gnutls_pubkey_t <var>pkey</var>, const gnutls_datum_t * <var>data</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>pkey</var>: The public key
</p>
<p><var>data</var>: The public key data to be imported
</p>
<p><var>format</var>: The format of the public key
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will import the given public key to the abstract
<code>gnutls_pubkey_t</code> structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.3
</p></dd></dl>
<a name="gnutls_005fpubkey_005finit-1"></a>
<h4 class="subheading">gnutls_pubkey_init</h4>
<a name="gnutls_005fpubkey_005finit"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005finit"></a>Function: <em>int</em> <strong>gnutls_pubkey_init</strong> <em>(gnutls_pubkey_t * <var>key</var>)</em></dt>
<dd><p><var>key</var>: The structure to be initialized
</p>
<p>This function will initialize an public key structure.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fprint-1"></a>
<h4 class="subheading">gnutls_pubkey_print</h4>
<a name="gnutls_005fpubkey_005fprint"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fprint"></a>Function: <em>int</em> <strong>gnutls_pubkey_print</strong> <em>(gnutls_pubkey_t <var>pubkey</var>, gnutls_certificate_print_formats_t <var>format</var>, gnutls_datum_t * <var>out</var>)</em></dt>
<dd><p><var>pubkey</var>: The structure to be printed
</p>
<p><var>format</var>: Indicate the format to use
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p>This function will pretty print public key information, suitable for
display to a human.
</p>
<p>Only <code>GNUTLS_CRT_PRINT_FULL</code> and <code>GNUTLS_CRT_PRINT_FULL_NUMBERS</code>
are implemented.
</p>
<p>The output <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 3.1.5
</p></dd></dl>
<a name="gnutls_005fpubkey_005fset_005fkey_005fusage-1"></a>
<h4 class="subheading">gnutls_pubkey_set_key_usage</h4>
<a name="gnutls_005fpubkey_005fset_005fkey_005fusage"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fset_005fkey_005fusage"></a>Function: <em>int</em> <strong>gnutls_pubkey_set_key_usage</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int <var>usage</var>)</em></dt>
<dd><p><var>key</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>usage</var>: an ORed sequence of the GNUTLS_KEY_* elements.
</p>
<p>This function will set the key usage flags of the public key. This
is only useful if the key is to be exported to a certificate or
certificate request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fset_005fpin_005ffunction-1"></a>
<h4 class="subheading">gnutls_pubkey_set_pin_function</h4>
<a name="gnutls_005fpubkey_005fset_005fpin_005ffunction"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fset_005fpin_005ffunction"></a>Function: <em>void</em> <strong>gnutls_pubkey_set_pin_function</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_pin_callback_t <var>fn</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>key</var>: A key of type <code>gnutls_pubkey_t</code>
</p>
<p><var>fn</var>: the callback
</p>
<p><var>userdata</var>: data associated with the callback
</p>
<p>This function will set a callback function to be used when
required to access the object. This function overrides any other
global PIN functions.
</p>
<p>Note that this function must be called right after initialization
to have effect.
</p>
<p><strong>Since:</strong> 3.1.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fverify_005fdata-1"></a>
<h4 class="subheading">gnutls_pubkey_verify_data</h4>
<a name="gnutls_005fpubkey_005fverify_005fdata"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fverify_005fdata"></a>Function: <em>int</em> <strong>gnutls_pubkey_verify_data</strong> <em>(gnutls_pubkey_t <var>pubkey</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>pubkey</var>: Holds the public key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the signed data
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed data, using the
parameters from the certificate.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p>Deprecated. Use <code>gnutls_pubkey_verify_data2()</code> instead of this function.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fverify_005fdata2-1"></a>
<h4 class="subheading">gnutls_pubkey_verify_data2</h4>
<a name="gnutls_005fpubkey_005fverify_005fdata2"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fverify_005fdata2-1"></a>Function: <em>int</em> <strong>gnutls_pubkey_verify_data2</strong> <em>(gnutls_pubkey_t <var>pubkey</var>, gnutls_sign_algorithm_t <var>algo</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>pubkey</var>: Holds the public key
</p>
<p><var>algo</var>: The signature algorithm used
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the signed data
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed data, using the
parameters from the certificate.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fverify_005fhash-1"></a>
<h4 class="subheading">gnutls_pubkey_verify_hash</h4>
<a name="gnutls_005fpubkey_005fverify_005fhash"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fverify_005fhash"></a>Function: <em>int</em> <strong>gnutls_pubkey_verify_hash</strong> <em>(gnutls_pubkey_t <var>key</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>hash</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>hash</var>: holds the hash digest to be verified
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed digest, using the
parameters from the public key.
</p>
<p>Deprecated. Use <code>gnutls_pubkey_verify_hash2()</code> instead of this function.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fpubkey_005fverify_005fhash2-1"></a>
<h4 class="subheading">gnutls_pubkey_verify_hash2</h4>
<a name="gnutls_005fpubkey_005fverify_005fhash2"></a><dl>
<dt><a name="index-gnutls_005fpubkey_005fverify_005fhash2-1"></a>Function: <em>int</em> <strong>gnutls_pubkey_verify_hash2</strong> <em>(gnutls_pubkey_t <var>key</var>, gnutls_sign_algorithm_t <var>algo</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>hash</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>key</var>: Holds the public key
</p>
<p><var>algo</var>: The signature algorithm used
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>hash</var>: holds the hash digest to be verified
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed digest, using the
parameters from the public key.
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fprivkey_005fsign-1"></a>
<h4 class="subheading">gnutls_x509_crl_privkey_sign</h4>
<a name="gnutls_005fx509_005fcrl_005fprivkey_005fsign"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fprivkey_005fsign-1"></a>Function: <em>int</em> <strong>gnutls_x509_crl_privkey_sign</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p><var>dig</var>: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you’re doing.
</p>
<p><var>flags</var>: must be 0
</p>
<p>This function will sign the CRL with the issuer’s private key, and
will copy the issuer’s information into the CRL.
</p>
<p>This must be the last step in a certificate CRL since all
the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p>Since 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fprivkey_005fsign-1"></a>
<h4 class="subheading">gnutls_x509_crq_privkey_sign</h4>
<a name="gnutls_005fx509_005fcrq_005fprivkey_005fsign"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fprivkey_005fsign"></a>Function: <em>int</em> <strong>gnutls_x509_crq_privkey_sign</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_privkey_t <var>key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a private key
</p>
<p><var>dig</var>: The message digest to use, i.e., <code>GNUTLS_DIG_SHA1</code>
</p>
<p><var>flags</var>: must be 0
</p>
<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>
<p>This must be the last step in a certificate request generation
since all the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, otherwise a negative error code.
<code>GNUTLS_E_ASN1_VALUE_NOT_FOUND</code> is returned if you didn’t set all
information in the certificate request (e.g., the version using
<code>gnutls_x509_crq_set_version()</code> ).
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fset_005fpubkey-1"></a>
<h4 class="subheading">gnutls_x509_crq_set_pubkey</h4>
<a name="gnutls_005fx509_005fcrq_005fset_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fset_005fpubkey-1"></a>Function: <em>int</em> <strong>gnutls_x509_crq_set_pubkey</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_pubkey_t <var>key</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a public key
</p>
<p>This function will set the public parameters from the given public
key to the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fprivkey_005fsign-1"></a>
<h4 class="subheading">gnutls_x509_crt_privkey_sign</h4>
<a name="gnutls_005fx509_005fcrt_005fprivkey_005fsign"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fprivkey_005fsign"></a>Function: <em>int</em> <strong>gnutls_x509_crt_privkey_sign</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_privkey_t <var>issuer_key</var>, gnutls_digest_algorithm_t <var>dig</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>crt</var>: a certificate of type <code>gnutls_x509_crt_t</code>
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p><var>dig</var>: The message digest to use, <code>GNUTLS_DIG_SHA1</code> is a safe choice
</p>
<p><var>flags</var>: must be 0
</p>
<p>This function will sign the certificate with the issuer’s private key, and
will copy the issuer’s information into the certificate.
</p>
<p>This must be the last step in a certificate generation since all
the previously set parameters are now signed.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fset_005fpubkey-1"></a>
<h4 class="subheading">gnutls_x509_crt_set_pubkey</h4>
<a name="gnutls_005fx509_005fcrt_005fset_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fset_005fpubkey-1"></a>Function: <em>int</em> <strong>gnutls_x509_crt_set_pubkey</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_pubkey_t <var>key</var>)</em></dt>
<dd><p><var>crt</var>: should contain a <code>gnutls_x509_crt_t</code> structure
</p>
<p><var>key</var>: holds a public key
</p>
<p>This function will set the public parameters from the given public
key to the request.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<hr>
<a name="DANE-API"></a>
<div class="header">
<p>
Next: <a href="#Cryptographic-API" accesskey="n" rel="next">Cryptographic API</a>, Previous: <a href="#Abstract-key-API" accesskey="p" rel="previous">Abstract key API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="DANE-API-1"></a>
<h3 class="section">E.11 DANE API</h3>
<p>The following functions are to be used for DANE certificate verification.
Their prototypes lie in <samp>gnutls/dane.h</samp>. Note that you need to link
with the <code>libgnutls-dane</code> library to use them.
</p>
<a name="dane_005fcert_005ftype_005fname-1"></a>
<h4 class="subheading">dane_cert_type_name</h4>
<a name="dane_005fcert_005ftype_005fname"></a><dl>
<dt><a name="index-dane_005fcert_005ftype_005fname"></a>Function: <em>const char*</em> <strong>dane_cert_type_name</strong> <em>(dane_cert_type_t <var>type</var>)</em></dt>
<dd><p><var>type</var>: is a DANE match type
</p>
<p>Convert a <code>dane_cert_type_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified
type, or <code>NULL</code> .
</p></dd></dl>
<a name="dane_005fcert_005fusage_005fname-1"></a>
<h4 class="subheading">dane_cert_usage_name</h4>
<a name="dane_005fcert_005fusage_005fname"></a><dl>
<dt><a name="index-dane_005fcert_005fusage_005fname"></a>Function: <em>const char*</em> <strong>dane_cert_usage_name</strong> <em>(dane_cert_usage_t <var>usage</var>)</em></dt>
<dd><p><var>usage</var>: – undescribed –
</p>
<p>Convert a <code>dane_cert_usage_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified
type, or <code>NULL</code> .
</p></dd></dl>
<a name="dane_005fmatch_005ftype_005fname-1"></a>
<h4 class="subheading">dane_match_type_name</h4>
<a name="dane_005fmatch_005ftype_005fname"></a><dl>
<dt><a name="index-dane_005fmatch_005ftype_005fname"></a>Function: <em>const char*</em> <strong>dane_match_type_name</strong> <em>(dane_match_type_t <var>type</var>)</em></dt>
<dd><p><var>type</var>: is a DANE match type
</p>
<p>Convert a <code>dane_match_type_t</code> value to a string.
</p>
<p><strong>Returns:</strong> a string that contains the name of the specified
type, or <code>NULL</code> .
</p></dd></dl>
<a name="dane_005fquery_005fdata-1"></a>
<h4 class="subheading">dane_query_data</h4>
<a name="dane_005fquery_005fdata"></a><dl>
<dt><a name="index-dane_005fquery_005fdata"></a>Function: <em>int</em> <strong>dane_query_data</strong> <em>(dane_query_t <var>q</var>, unsigned int <var>idx</var>, unsigned int * <var>usage</var>, unsigned int * <var>type</var>, unsigned int * <var>match</var>, gnutls_datum_t * <var>data</var>)</em></dt>
<dd><p><var>q</var>: The query result structure
</p>
<p><var>idx</var>: The index of the query response.
</p>
<p><var>usage</var>: The certificate usage (see <code>dane_cert_usage_t</code> )
</p>
<p><var>type</var>: The certificate type (see <code>dane_cert_type_t</code> )
</p>
<p><var>match</var>: The DANE matching type (see <code>dane_match_type_t</code> )
</p>
<p><var>data</var>: The DANE data.
</p>
<p>This function will provide the DANE data from the query
response.
</p>
<p><strong>Returns:</strong> On success, <code>DANE_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="dane_005fquery_005fdeinit-1"></a>
<h4 class="subheading">dane_query_deinit</h4>
<a name="dane_005fquery_005fdeinit"></a><dl>
<dt><a name="index-dane_005fquery_005fdeinit"></a>Function: <em>void</em> <strong>dane_query_deinit</strong> <em>(dane_query_t <var>q</var>)</em></dt>
<dd><p><var>q</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a DANE query result structure.
</p></dd></dl>
<a name="dane_005fquery_005fentries-1"></a>
<h4 class="subheading">dane_query_entries</h4>
<a name="dane_005fquery_005fentries"></a><dl>
<dt><a name="index-dane_005fquery_005fentries"></a>Function: <em>unsigned int</em> <strong>dane_query_entries</strong> <em>(dane_query_t <var>q</var>)</em></dt>
<dd><p><var>q</var>: The query result structure
</p>
<p>This function will return the number of entries in a query.
</p>
<p><strong>Returns:</strong> The number of entries.
</p></dd></dl>
<a name="dane_005fquery_005fstatus-1"></a>
<h4 class="subheading">dane_query_status</h4>
<a name="dane_005fquery_005fstatus"></a><dl>
<dt><a name="index-dane_005fquery_005fstatus"></a>Function: <em>dane_query_status_t</em> <strong>dane_query_status</strong> <em>(dane_query_t <var>q</var>)</em></dt>
<dd><p><var>q</var>: The query result structure
</p>
<p>This function will return the status of the query response.
See <code>dane_query_status_t</code> for the possible types.
</p>
<p><strong>Returns:</strong> The status type.
</p></dd></dl>
<a name="dane_005fquery_005ftlsa-1"></a>
<h4 class="subheading">dane_query_tlsa</h4>
<a name="dane_005fquery_005ftlsa"></a><dl>
<dt><a name="index-dane_005fquery_005ftlsa"></a>Function: <em>int</em> <strong>dane_query_tlsa</strong> <em>(dane_state_t <var>s</var>, dane_query_t * <var>r</var>, const char* <var>host</var>, const char* <var>proto</var>, unsigned int <var>port</var>)</em></dt>
<dd><p><var>s</var>: The DANE state structure
</p>
<p><var>r</var>: A structure to place the result
</p>
<p><var>host</var>: The host name to resolve.
</p>
<p><var>proto</var>: The protocol type (tcp, udp, etc.)
</p>
<p><var>port</var>: The service port number (eg. 443).
</p>
<p>This function will query the DNS server for the TLSA (DANE)
data for the given host.
</p>
<p><strong>Returns:</strong> On success, <code>DANE_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="dane_005fstate_005fdeinit-1"></a>
<h4 class="subheading">dane_state_deinit</h4>
<a name="dane_005fstate_005fdeinit"></a><dl>
<dt><a name="index-dane_005fstate_005fdeinit"></a>Function: <em>void</em> <strong>dane_state_deinit</strong> <em>(dane_state_t <var>s</var>)</em></dt>
<dd><p><var>s</var>: The structure to be deinitialized
</p>
<p>This function will deinitialize a DANE query structure.
</p></dd></dl>
<a name="dane_005fstate_005finit-1"></a>
<h4 class="subheading">dane_state_init</h4>
<a name="dane_005fstate_005finit"></a><dl>
<dt><a name="index-dane_005fstate_005finit"></a>Function: <em>int</em> <strong>dane_state_init</strong> <em>(dane_state_t* <var>s</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>s</var>: The structure to be initialized
</p>
<p><var>flags</var>: flags from the <code>dane_state_flags</code> enumeration
</p>
<p>This function will initialize a DANE query structure.
</p>
<p><strong>Returns:</strong> On success, <code>DANE_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="dane_005fstate_005fset_005fdlv_005ffile-1"></a>
<h4 class="subheading">dane_state_set_dlv_file</h4>
<a name="dane_005fstate_005fset_005fdlv_005ffile"></a><dl>
<dt><a name="index-dane_005fstate_005fset_005fdlv_005ffile"></a>Function: <em>int</em> <strong>dane_state_set_dlv_file</strong> <em>(dane_state_t <var>s</var>, const char* <var>file</var>)</em></dt>
<dd><p><var>s</var>: The structure to be deinitialized
</p>
<p><var>file</var>: The file holding the DLV keys.
</p>
<p>This function will set a file with trusted keys
for DLV (DNSSEC Lookaside Validation).
</p></dd></dl>
<a name="dane_005fstrerror-1"></a>
<h4 class="subheading">dane_strerror</h4>
<a name="dane_005fstrerror"></a><dl>
<dt><a name="index-dane_005fstrerror"></a>Function: <em>const char *</em> <strong>dane_strerror</strong> <em>(int <var>error</var>)</em></dt>
<dd><p><var>error</var>: is a DANE error code, a negative error code
</p>
<p>This function is similar to strerror. The difference is that it
accepts an error number returned by a gnutls function; In case of
an unknown error a descriptive string is sent instead of <code>NULL</code> .
</p>
<p>Error codes are always a negative error code.
</p>
<p><strong>Returns:</strong> A string explaining the DANE error message.
</p></dd></dl>
<a name="dane_005fverification_005fstatus_005fprint-1"></a>
<h4 class="subheading">dane_verification_status_print</h4>
<a name="dane_005fverification_005fstatus_005fprint"></a><dl>
<dt><a name="index-dane_005fverification_005fstatus_005fprint"></a>Function: <em>int</em> <strong>dane_verification_status_print</strong> <em>(unsigned int <var>status</var>, gnutls_datum_t * <var>out</var>, unsigned int <var>flags</var>)</em></dt>
<dd><p><var>status</var>: The status flags to be printed
</p>
<p><var>out</var>: Newly allocated datum with (0) terminated string.
</p>
<p><var>flags</var>: should be zero
</p>
<p>This function will pretty print the status of a verification
process – eg. the one obtained by <code>dane_verify_crt()</code> .
</p>
<p>The output <code>out</code> needs to be deallocated using <code>gnutls_free()</code> .
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="dane_005fverify_005fcrt-1"></a>
<h4 class="subheading">dane_verify_crt</h4>
<a name="dane_005fverify_005fcrt"></a><dl>
<dt><a name="index-dane_005fverify_005fcrt-1"></a>Function: <em>int</em> <strong>dane_verify_crt</strong> <em>(dane_state_t <var>s</var>, const gnutls_datum_t * <var>chain</var>, unsigned <var>chain_size</var>, gnutls_certificate_type_t <var>chain_type</var>, const char * <var>hostname</var>, const char* <var>proto</var>, unsigned int <var>port</var>, unsigned int <var>sflags</var>, unsigned int <var>vflags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>s</var>: A DANE state structure (may be NULL)
</p>
<p><var>chain</var>: A certificate chain
</p>
<p><var>chain_size</var>: The size of the chain
</p>
<p><var>chain_type</var>: The type of the certificate chain
</p>
<p><var>hostname</var>: The hostname associated with the chain
</p>
<p><var>proto</var>: The protocol of the service connecting (e.g. tcp)
</p>
<p><var>port</var>: The port of the service connecting (e.g. 443)
</p>
<p><var>sflags</var>: Flags for the the initialization of <code>s</code> (if NULL)
</p>
<p><var>vflags</var>: Verification flags; should be zero
</p>
<p><var>verify</var>: An OR’ed list of <code>dane_verify_status_t</code> .
</p>
<p>This function will verify the given certificate chain against the
CA constrains and/or the certificate available via DANE.
If no information via DANE can be obtained the flag <code>DANE_VERIFY_NO_DANE_INFO</code>
is set. If a DNSSEC signature is not available for the DANE
record then the verify flag <code>DANE_VERIFY_NO_DNSSEC_DATA</code> is set.
</p>
<p>Due to the many possible options of DANE, there is no single threat
model countered. When notifying the user about DANE verification results
it may be better to mention: DANE verification did not reject the certificate,
rather than mentioning a successful DANE verication.
</p>
<p>If the <code>q</code> parameter is provided it will be used for caching entries.
</p>
<p><strong>Returns:</strong> On success, <code>DANE_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<a name="dane_005fverify_005fsession_005fcrt-1"></a>
<h4 class="subheading">dane_verify_session_crt</h4>
<a name="dane_005fverify_005fsession_005fcrt"></a><dl>
<dt><a name="index-dane_005fverify_005fsession_005fcrt"></a>Function: <em>int</em> <strong>dane_verify_session_crt</strong> <em>(dane_state_t <var>s</var>, gnutls_session_t <var>session</var>, const char * <var>hostname</var>, const char* <var>proto</var>, unsigned int <var>port</var>, unsigned int <var>sflags</var>, unsigned int <var>vflags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>s</var>: A DANE state structure (may be NULL)
</p>
<p><var>session</var>: A gnutls session
</p>
<p><var>hostname</var>: The hostname associated with the chain
</p>
<p><var>proto</var>: The protocol of the service connecting (e.g. tcp)
</p>
<p><var>port</var>: The port of the service connecting (e.g. 443)
</p>
<p><var>sflags</var>: Flags for the the initialization of <code>s</code> (if NULL)
</p>
<p><var>vflags</var>: Verification flags; should be zero
</p>
<p><var>verify</var>: An OR’ed list of <code>dane_verify_status_t</code> .
</p>
<p>This function will verify session’s certificate chain against the
CA constrains and/or the certificate available via DANE.
See <code>dane_verify_crt()</code> for more information.
</p>
<p><strong>Returns:</strong> On success, <code>DANE_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p></dd></dl>
<hr>
<a name="Cryptographic-API"></a>
<div class="header">
<p>
Next: <a href="#Compatibility-API" accesskey="n" rel="next">Compatibility API</a>, Previous: <a href="#DANE-API" accesskey="p" rel="previous">DANE API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Cryptographic-API-1"></a>
<h3 class="section">E.12 Cryptographic API</h3>
<p>The following functions are to be used for low-level cryptographic operations.
Their prototypes lie in <samp>gnutls/crypto.h</samp>.
</p>
<a name="gnutls_005fcipher_005fadd_005fauth-1"></a>
<h4 class="subheading">gnutls_cipher_add_auth</h4>
<a name="gnutls_005fcipher_005fadd_005fauth"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fadd_005fauth"></a>Function: <em>int</em> <strong>gnutls_cipher_add_auth</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>text_size</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>text</var>: the data to be authenticated
</p>
<p><var>text_size</var>: The length of the data
</p>
<p>This function operates on authenticated encryption with
associated data (AEAD) ciphers and authenticate the
input data. This function can only be called once
and before any encryption operations.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fdecrypt-1"></a>
<h4 class="subheading">gnutls_cipher_decrypt</h4>
<a name="gnutls_005fcipher_005fdecrypt"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fdecrypt"></a>Function: <em>int</em> <strong>gnutls_cipher_decrypt</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>ciphertext</var>: the data to encrypt
</p>
<p><var>ciphertextlen</var>: The length of data to encrypt
</p>
<p>This function will decrypt the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fdecrypt2-1"></a>
<h4 class="subheading">gnutls_cipher_decrypt2</h4>
<a name="gnutls_005fcipher_005fdecrypt2"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fdecrypt2"></a>Function: <em>int</em> <strong>gnutls_cipher_decrypt2</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, const void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>, void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>ciphertext</var>: the data to encrypt
</p>
<p><var>ciphertextlen</var>: The length of data to encrypt
</p>
<p><var>text</var>: the decrypted data
</p>
<p><var>textlen</var>: The available length for decrypted data
</p>
<p>This function will decrypt the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fdeinit-1"></a>
<h4 class="subheading">gnutls_cipher_deinit</h4>
<a name="gnutls_005fcipher_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_cipher_deinit</strong> <em>(gnutls_cipher_hd_t <var>handle</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p>This function will deinitialize all resources occupied by the given
encryption context.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fencrypt-1"></a>
<h4 class="subheading">gnutls_cipher_encrypt</h4>
<a name="gnutls_005fcipher_005fencrypt"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fencrypt"></a>Function: <em>int</em> <strong>gnutls_cipher_encrypt</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>text</var>: the data to encrypt
</p>
<p><var>textlen</var>: The length of data to encrypt
</p>
<p>This function will encrypt the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fencrypt2-1"></a>
<h4 class="subheading">gnutls_cipher_encrypt2</h4>
<a name="gnutls_005fcipher_005fencrypt2"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fencrypt2"></a>Function: <em>int</em> <strong>gnutls_cipher_encrypt2</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>ciphertext</var>, size_t <var>ciphertextlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>text</var>: the data to encrypt
</p>
<p><var>textlen</var>: The length of data to encrypt
</p>
<p><var>ciphertext</var>: the encrypted data
</p>
<p><var>ciphertextlen</var>: The available length for encrypted data
</p>
<p>This function will encrypt the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fget_005fblock_005fsize-1"></a>
<h4 class="subheading">gnutls_cipher_get_block_size</h4>
<a name="gnutls_005fcipher_005fget_005fblock_005fsize"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fget_005fblock_005fsize"></a>Function: <em>int</em> <strong>gnutls_cipher_get_block_size</strong> <em>(gnutls_cipher_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: is an encryption algorithm
</p>
<p>Get block size for encryption algorithm.
</p>
<p><strong>Returns:</strong> block size for encryption algorithm.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fcipher_005finit-1"></a>
<h4 class="subheading">gnutls_cipher_init</h4>
<a name="gnutls_005fcipher_005finit"></a><dl>
<dt><a name="index-gnutls_005fcipher_005finit"></a>Function: <em>int</em> <strong>gnutls_cipher_init</strong> <em>(gnutls_cipher_hd_t * <var>handle</var>, gnutls_cipher_algorithm_t <var>cipher</var>, const gnutls_datum_t * <var>key</var>, const gnutls_datum_t * <var>iv</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>cipher</var>: the encryption algorithm to use
</p>
<p><var>key</var>: The key to be used for encryption
</p>
<p><var>iv</var>: The IV to use (if not applicable set NULL)
</p>
<p>This function will initialize an context that can be used for
encryption/decryption of data. This will effectively use the
current crypto backend in use by gnutls or the cryptographic
accelerator in use.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fcipher_005fset_005fiv-1"></a>
<h4 class="subheading">gnutls_cipher_set_iv</h4>
<a name="gnutls_005fcipher_005fset_005fiv"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fset_005fiv"></a>Function: <em>void</em> <strong>gnutls_cipher_set_iv</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>iv</var>, size_t <var>ivlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>iv</var>: the IV to set
</p>
<p><var>ivlen</var>: The length of the IV
</p>
<p>This function will set the IV to be used for the next
encryption block.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fcipher_005ftag-1"></a>
<h4 class="subheading">gnutls_cipher_tag</h4>
<a name="gnutls_005fcipher_005ftag"></a><dl>
<dt><a name="index-gnutls_005fcipher_005ftag"></a>Function: <em>int</em> <strong>gnutls_cipher_tag</strong> <em>(gnutls_cipher_hd_t <var>handle</var>, void * <var>tag</var>, size_t <var>tag_size</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>tag</var>: will hold the tag
</p>
<p><var>tag_size</var>: The length of the tag to return
</p>
<p>This function operates on authenticated encryption with
associated data (AEAD) ciphers and will return the
output tag.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 3.0
</p></dd></dl>
<a name="gnutls_005fhash-1"></a>
<h4 class="subheading">gnutls_hash</h4>
<a name="gnutls_005fhash"></a><dl>
<dt><a name="index-gnutls_005fhash"></a>Function: <em>int</em> <strong>gnutls_hash</strong> <em>(gnutls_hash_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p>This function will hash the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhash_005fdeinit-1"></a>
<h4 class="subheading">gnutls_hash_deinit</h4>
<a name="gnutls_005fhash_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fhash_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_hash_deinit</strong> <em>(gnutls_hash_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hash_hd_t</code> structure.
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This function will deinitialize all resources occupied by
the given hash context.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhash_005ffast-1"></a>
<h4 class="subheading">gnutls_hash_fast</h4>
<a name="gnutls_005fhash_005ffast"></a><dl>
<dt><a name="index-gnutls_005fhash_005ffast"></a>Function: <em>int</em> <strong>gnutls_hash_fast</strong> <em>(gnutls_digest_algorithm_t <var>algorithm</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>algorithm</var>: the hash algorithm to use
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This convenience function will hash the given data and return output
on a single call.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhash_005fget_005flen-1"></a>
<h4 class="subheading">gnutls_hash_get_len</h4>
<a name="gnutls_005fhash_005fget_005flen"></a><dl>
<dt><a name="index-gnutls_005fhash_005fget_005flen"></a>Function: <em>int</em> <strong>gnutls_hash_get_len</strong> <em>(gnutls_digest_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: the hash algorithm to use
</p>
<p>This function will return the length of the output data
of the given hash algorithm.
</p>
<p><strong>Returns:</strong> The length or zero on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhash_005finit-1"></a>
<h4 class="subheading">gnutls_hash_init</h4>
<a name="gnutls_005fhash_005finit"></a><dl>
<dt><a name="index-gnutls_005fhash_005finit"></a>Function: <em>int</em> <strong>gnutls_hash_init</strong> <em>(gnutls_hash_hd_t * <var>dig</var>, gnutls_digest_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>dig</var>: is a <code>gnutls_hash_hd_t</code> structure.
</p>
<p><var>algorithm</var>: the hash algorithm to use
</p>
<p>This function will initialize an context that can be used to
produce a Message Digest of data. This will effectively use the
current crypto backend in use by gnutls or the cryptographic
accelerator in use.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhash_005foutput-1"></a>
<h4 class="subheading">gnutls_hash_output</h4>
<a name="gnutls_005fhash_005foutput"></a><dl>
<dt><a name="index-gnutls_005fhash_005foutput"></a>Function: <em>void</em> <strong>gnutls_hash_output</strong> <em>(gnutls_hash_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hash_hd_t</code> structure.
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This function will output the current hash value.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhmac-1"></a>
<h4 class="subheading">gnutls_hmac</h4>
<a name="gnutls_005fhmac"></a><dl>
<dt><a name="index-gnutls_005fhmac"></a>Function: <em>int</em> <strong>gnutls_hmac</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, const void * <var>text</var>, size_t <var>textlen</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_cipher_hd_t</code> structure.
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p>This function will hash the given data using the algorithm
specified by the context.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhmac_005fdeinit-1"></a>
<h4 class="subheading">gnutls_hmac_deinit</h4>
<a name="gnutls_005fhmac_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005fhmac_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_hmac_deinit</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hmac_hd_t</code> structure.
</p>
<p><var>digest</var>: is the output value of the MAC
</p>
<p>This function will deinitialize all resources occupied by
the given hmac context.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhmac_005ffast-1"></a>
<h4 class="subheading">gnutls_hmac_fast</h4>
<a name="gnutls_005fhmac_005ffast"></a><dl>
<dt><a name="index-gnutls_005fhmac_005ffast"></a>Function: <em>int</em> <strong>gnutls_hmac_fast</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>, const void * <var>key</var>, size_t <var>keylen</var>, const void * <var>text</var>, size_t <var>textlen</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>algorithm</var>: the hash algorithm to use
</p>
<p><var>key</var>: the key to use
</p>
<p><var>keylen</var>: The length of the key
</p>
<p><var>text</var>: the data to hash
</p>
<p><var>textlen</var>: The length of data to hash
</p>
<p><var>digest</var>: is the output value of the hash
</p>
<p>This convenience function will hash the given data and return output
on a single call.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhmac_005fget_005flen-1"></a>
<h4 class="subheading">gnutls_hmac_get_len</h4>
<a name="gnutls_005fhmac_005fget_005flen"></a><dl>
<dt><a name="index-gnutls_005fhmac_005fget_005flen"></a>Function: <em>int</em> <strong>gnutls_hmac_get_len</strong> <em>(gnutls_mac_algorithm_t <var>algorithm</var>)</em></dt>
<dd><p><var>algorithm</var>: the hmac algorithm to use
</p>
<p>This function will return the length of the output data
of the given hmac algorithm.
</p>
<p><strong>Returns:</strong> The length or zero on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhmac_005finit-1"></a>
<h4 class="subheading">gnutls_hmac_init</h4>
<a name="gnutls_005fhmac_005finit"></a><dl>
<dt><a name="index-gnutls_005fhmac_005finit"></a>Function: <em>int</em> <strong>gnutls_hmac_init</strong> <em>(gnutls_hmac_hd_t * <var>dig</var>, gnutls_mac_algorithm_t <var>algorithm</var>, const void * <var>key</var>, size_t <var>keylen</var>)</em></dt>
<dd><p><var>dig</var>: is a <code>gnutls_hmac_hd_t</code> structure.
</p>
<p><var>algorithm</var>: the HMAC algorithm to use
</p>
<p><var>key</var>: The key to be used for encryption
</p>
<p><var>keylen</var>: The length of the key
</p>
<p>This function will initialize an context that can be used to
produce a Message Authentication Code (MAC) of data. This will
effectively use the current crypto backend in use by gnutls or the
cryptographic accelerator in use.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005fhmac_005foutput-1"></a>
<h4 class="subheading">gnutls_hmac_output</h4>
<a name="gnutls_005fhmac_005foutput"></a><dl>
<dt><a name="index-gnutls_005fhmac_005foutput"></a>Function: <em>void</em> <strong>gnutls_hmac_output</strong> <em>(gnutls_hmac_hd_t <var>handle</var>, void * <var>digest</var>)</em></dt>
<dd><p><var>handle</var>: is a <code>gnutls_hmac_hd_t</code> structure.
</p>
<p><var>digest</var>: is the output value of the MAC
</p>
<p>This function will output the current MAC value.
</p>
<p><strong>Since:</strong> 2.10.0
</p></dd></dl>
<a name="gnutls_005frnd-1"></a>
<h4 class="subheading">gnutls_rnd</h4>
<a name="gnutls_005frnd"></a><dl>
<dt><a name="index-gnutls_005frnd-1"></a>Function: <em>int</em> <strong>gnutls_rnd</strong> <em>(gnutls_rnd_level_t <var>level</var>, void * <var>data</var>, size_t <var>len</var>)</em></dt>
<dd><p><var>level</var>: a security level
</p>
<p><var>data</var>: place to store random bytes
</p>
<p><var>len</var>: The requested size
</p>
<p>This function will generate random data and store it to output
buffer.
</p>
<p><strong>Returns:</strong> Zero or a negative error code on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005frnd_005frefresh-1"></a>
<h4 class="subheading">gnutls_rnd_refresh</h4>
<a name="gnutls_005frnd_005frefresh"></a><dl>
<dt><a name="index-gnutls_005frnd_005frefresh"></a>Function: <em>void</em> <strong>gnutls_rnd_refresh</strong> <em>()</em></dt>
<dd>
<p>This function refreshes the random generator state.
That is the current precise time, CPU usage, and
other values are input into its state.
</p>
<p>On a slower rate input from /dev/urandom is mixed too.
</p>
<p><strong>Since:</strong> 3.1.7
</p></dd></dl>
<hr>
<a name="Compatibility-API"></a>
<div class="header">
<p>
Previous: <a href="#Cryptographic-API" accesskey="p" rel="previous">Cryptographic API</a>, Up: <a href="#API-reference" accesskey="u" rel="up">API reference</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Compatibility-API-1"></a>
<h3 class="section">E.13 Compatibility API</h3>
<p>The following functions are carried over from old GnuTLS released. They might be removed at a later version.
Their prototypes lie in <samp>gnutls/compat.h</samp>.
</p>
<a name="gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams-1"></a>
<h4 class="subheading">gnutls_certificate_set_rsa_export_params</h4>
<a name="gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams"></a>Function: <em>void</em> <strong>gnutls_certificate_set_rsa_export_params</strong> <em>(gnutls_certificate_credentials_t <var>res</var>, gnutls_rsa_params_t <var>rsa_params</var>)</em></dt>
<dd><p><var>res</var>: is a gnutls_certificate_credentials_t structure
</p>
<p><var>rsa_params</var>: is a structure that holds temporary RSA parameters.
</p>
<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></dd></dl>
<a name="gnutls_005fcertificate_005ftype_005fset_005fpriority-1"></a>
<h4 class="subheading">gnutls_certificate_type_set_priority</h4>
<a name="gnutls_005fcertificate_005ftype_005fset_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fcertificate_005ftype_005fset_005fpriority"></a>Function: <em>int</em> <strong>gnutls_certificate_type_set_priority</strong> <em>(gnutls_session_t <var>session</var>, const int * <var>list</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>list</var>: is a 0 terminated list of gnutls_certificate_type_t elements.
</p>
<p>Sets the priority on the certificate types supported by gnutls.
Priority is higher for elements 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fcipher_005fset_005fpriority-1"></a>
<h4 class="subheading">gnutls_cipher_set_priority</h4>
<a name="gnutls_005fcipher_005fset_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fcipher_005fset_005fpriority"></a>Function: <em>int</em> <strong>gnutls_cipher_set_priority</strong> <em>(gnutls_session_t <var>session</var>, const int * <var>list</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>list</var>: is a 0 terminated list of gnutls_cipher_algorithm_t elements.
</p>
<p>Sets the priority on the ciphers supported by gnutls. Priority is
higher for elements 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> (0) on success, or a negative error code.
</p></dd></dl>
<a name="gnutls_005fcompression_005fset_005fpriority-1"></a>
<h4 class="subheading">gnutls_compression_set_priority</h4>
<a name="gnutls_005fcompression_005fset_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fcompression_005fset_005fpriority"></a>Function: <em>int</em> <strong>gnutls_compression_set_priority</strong> <em>(gnutls_session_t <var>session</var>, const int * <var>list</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>list</var>: is a 0 terminated list of gnutls_compression_method_t elements.
</p>
<p>Sets the priority on the compression algorithms supported by
gnutls. Priority is higher for elements 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>
<p>TLS 1.0 does not define any compression algorithms except
NULL. Other compression algorithms are to be considered as gnutls
extensions.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fkx_005fset_005fpriority-1"></a>
<h4 class="subheading">gnutls_kx_set_priority</h4>
<a name="gnutls_005fkx_005fset_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fkx_005fset_005fpriority"></a>Function: <em>int</em> <strong>gnutls_kx_set_priority</strong> <em>(gnutls_session_t <var>session</var>, const int * <var>list</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>list</var>: is a 0 terminated list of gnutls_kx_algorithm_t elements.
</p>
<p>Sets the priority on the key exchange algorithms supported by
gnutls. Priority is higher for elements 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fmac_005fset_005fpriority-1"></a>
<h4 class="subheading">gnutls_mac_set_priority</h4>
<a name="gnutls_005fmac_005fset_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fmac_005fset_005fpriority"></a>Function: <em>int</em> <strong>gnutls_mac_set_priority</strong> <em>(gnutls_session_t <var>session</var>, const int * <var>list</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>list</var>: is a 0 terminated list of gnutls_mac_algorithm_t elements.
</p>
<p>Sets the priority on the mac algorithms supported by gnutls.
Priority is higher for elements 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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fopenpgp_005fprivkey_005fsign_005fhash-1"></a>
<h4 class="subheading">gnutls_openpgp_privkey_sign_hash</h4>
<a name="gnutls_005fopenpgp_005fprivkey_005fsign_005fhash"></a><dl>
<dt><a name="index-gnutls_005fopenpgp_005fprivkey_005fsign_005fhash"></a>Function: <em>int</em> <strong>gnutls_openpgp_privkey_sign_hash</strong> <em>(gnutls_openpgp_privkey_t <var>key</var>, const gnutls_datum_t * <var>hash</var>, gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>hash</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain newly allocated signature
</p>
<p>This function will sign the given hash using the private key. You
should use <code>gnutls_openpgp_privkey_set_preferred_key_id()</code> before
calling this function to set the subkey to use.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Deprecated:</strong> Use <code>gnutls_privkey_sign_hash()</code> instead.
</p></dd></dl>
<a name="gnutls_005fprotocol_005fset_005fpriority-1"></a>
<h4 class="subheading">gnutls_protocol_set_priority</h4>
<a name="gnutls_005fprotocol_005fset_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fprotocol_005fset_005fpriority"></a>Function: <em>int</em> <strong>gnutls_protocol_set_priority</strong> <em>(gnutls_session_t <var>session</var>, const int * <var>list</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p><var>list</var>: is a 0 terminated list of gnutls_protocol_t elements.
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits-1"></a>
<h4 class="subheading">gnutls_rsa_export_get_modulus_bits</h4>
<a name="gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits"></a><dl>
<dt><a name="index-gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits"></a>Function: <em>int</em> <strong>gnutls_rsa_export_get_modulus_bits</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p>Get the export RSA parameter’s modulus size.
</p>
<p><strong>Returns:</strong> The bits used in the last RSA-EXPORT key exchange with the
peer, or a negative error code in case of error.
</p></dd></dl>
<a name="gnutls_005frsa_005fexport_005fget_005fpubkey-1"></a>
<h4 class="subheading">gnutls_rsa_export_get_pubkey</h4>
<a name="gnutls_005frsa_005fexport_005fget_005fpubkey"></a><dl>
<dt><a name="index-gnutls_005frsa_005fexport_005fget_005fpubkey"></a>Function: <em>int</em> <strong>gnutls_rsa_export_get_pubkey</strong> <em>(gnutls_session_t <var>session</var>, gnutls_datum_t * <var>exponent</var>, gnutls_datum_t * <var>modulus</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>exponent</var>: will hold the exponent.
</p>
<p><var>modulus</var>: will hold the modulus.
</p>
<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>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise
an error code is returned.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fcpy-1"></a>
<h4 class="subheading">gnutls_rsa_params_cpy</h4>
<a name="gnutls_005frsa_005fparams_005fcpy"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fcpy"></a>Function: <em>int</em> <strong>gnutls_rsa_params_cpy</strong> <em>(gnutls_rsa_params_t <var>dst</var>, gnutls_rsa_params_t <var>src</var>)</em></dt>
<dd><p><var>dst</var>: Is the destination structure, which should be initialized.
</p>
<p><var>src</var>: Is the source structure
</p>
<p>This function will copy the RSA parameters structure from source
to destination.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fdeinit-1"></a>
<h4 class="subheading">gnutls_rsa_params_deinit</h4>
<a name="gnutls_005frsa_005fparams_005fdeinit"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fdeinit"></a>Function: <em>void</em> <strong>gnutls_rsa_params_deinit</strong> <em>(gnutls_rsa_params_t <var>rsa_params</var>)</em></dt>
<dd><p><var>rsa_params</var>: Is a structure that holds the parameters
</p>
<p>This function will deinitialize the RSA parameters structure.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fexport_005fpkcs1-1"></a>
<h4 class="subheading">gnutls_rsa_params_export_pkcs1</h4>
<a name="gnutls_005frsa_005fparams_005fexport_005fpkcs1"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fexport_005fpkcs1"></a>Function: <em>int</em> <strong>gnutls_rsa_params_export_pkcs1</strong> <em>(gnutls_rsa_params_t <var>params</var>, gnutls_x509_crt_fmt_t <var>format</var>, unsigned char * <var>params_data</var>, size_t * <var>params_data_size</var>)</em></dt>
<dd><p><var>params</var>: Holds the RSA parameters
</p>
<p><var>format</var>: the format of output params. One of PEM or DER.
</p>
<p><var>params_data</var>: will contain a PKCS1 RSAPrivateKey structure PEM or DER encoded
</p>
<p><var>params_data_size</var>: holds the size of params_data (and will be replaced by the actual size of parameters)
</p>
<p>This function will export the given RSA parameters to a PKCS1
RSAPrivateKey structure. If the buffer provided is not long enough to
hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
</p>
<p>If the structure is PEM encoded, it will have a header
of "BEGIN RSA PRIVATE KEY".
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fexport_005fraw-1"></a>
<h4 class="subheading">gnutls_rsa_params_export_raw</h4>
<a name="gnutls_005frsa_005fparams_005fexport_005fraw"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fexport_005fraw"></a>Function: <em>int</em> <strong>gnutls_rsa_params_export_raw</strong> <em>(gnutls_rsa_params_t <var>rsa</var>, gnutls_datum_t * <var>m</var>, gnutls_datum_t * <var>e</var>, gnutls_datum_t * <var>d</var>, gnutls_datum_t * <var>p</var>, gnutls_datum_t * <var>q</var>, gnutls_datum_t * <var>u</var>, unsigned int * <var>bits</var>)</em></dt>
<dd><p><var>rsa</var>: a structure that holds the rsa parameters
</p>
<p><var>m</var>: will hold the modulus
</p>
<p><var>e</var>: will hold the public exponent
</p>
<p><var>d</var>: will hold the private exponent
</p>
<p><var>p</var>: will hold the first prime (p)
</p>
<p><var>q</var>: will hold the second prime (q)
</p>
<p><var>u</var>: will hold the coefficient
</p>
<p><var>bits</var>: if non null will hold the prime’s number of bits
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fgenerate2-1"></a>
<h4 class="subheading">gnutls_rsa_params_generate2</h4>
<a name="gnutls_005frsa_005fparams_005fgenerate2"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fgenerate2"></a>Function: <em>int</em> <strong>gnutls_rsa_params_generate2</strong> <em>(gnutls_rsa_params_t <var>params</var>, unsigned int <var>bits</var>)</em></dt>
<dd><p><var>params</var>: The structure where the parameters will be stored
</p>
<p><var>bits</var>: is the prime’s number of bits
</p>
<p>This function will generate new temporary RSA parameters for use in
RSA-EXPORT ciphersuites. This function is normally slow.
</p>
<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>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fimport_005fpkcs1-1"></a>
<h4 class="subheading">gnutls_rsa_params_import_pkcs1</h4>
<a name="gnutls_005frsa_005fparams_005fimport_005fpkcs1"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fimport_005fpkcs1"></a>Function: <em>int</em> <strong>gnutls_rsa_params_import_pkcs1</strong> <em>(gnutls_rsa_params_t <var>params</var>, const gnutls_datum_t * <var>pkcs1_params</var>, gnutls_x509_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>params</var>: A structure where the parameters will be copied to
</p>
<p><var>pkcs1_params</var>: should contain a PKCS1 RSAPrivateKey structure PEM or DER encoded
</p>
<p><var>format</var>: the format of params. PEM or DER.
</p>
<p>This function will extract the RSAPrivateKey found in a PKCS1 formatted
structure.
</p>
<p>If the structure is PEM encoded, it should have a header
of "BEGIN RSA PRIVATE KEY".
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005fimport_005fraw-1"></a>
<h4 class="subheading">gnutls_rsa_params_import_raw</h4>
<a name="gnutls_005frsa_005fparams_005fimport_005fraw"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005fimport_005fraw"></a>Function: <em>int</em> <strong>gnutls_rsa_params_import_raw</strong> <em>(gnutls_rsa_params_t <var>rsa_params</var>, const gnutls_datum_t * <var>m</var>, const gnutls_datum_t * <var>e</var>, const gnutls_datum_t * <var>d</var>, const gnutls_datum_t * <var>p</var>, const gnutls_datum_t * <var>q</var>, const gnutls_datum_t * <var>u</var>)</em></dt>
<dd><p><var>rsa_params</var>: Is a structure will hold the parameters
</p>
<p><var>m</var>: holds the modulus
</p>
<p><var>e</var>: holds the public exponent
</p>
<p><var>d</var>: holds the private exponent
</p>
<p><var>p</var>: holds the first prime (p)
</p>
<p><var>q</var>: holds the second prime (q)
</p>
<p><var>u</var>: holds the coefficient
</p>
<p>This function will replace the parameters in the given structure.
The new parameters should be stored in the appropriate
gnutls_datum.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005frsa_005fparams_005finit-1"></a>
<h4 class="subheading">gnutls_rsa_params_init</h4>
<a name="gnutls_005frsa_005fparams_005finit"></a><dl>
<dt><a name="index-gnutls_005frsa_005fparams_005finit"></a>Function: <em>int</em> <strong>gnutls_rsa_params_init</strong> <em>(gnutls_rsa_params_t * <var>rsa_params</var>)</em></dt>
<dd><p><var>rsa_params</var>: Is a structure that will hold the parameters
</p>
<p>This function will initialize the temporary RSA parameters structure.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an negative error code.
</p></dd></dl>
<a name="gnutls_005fset_005fdefault_005fexport_005fpriority-1"></a>
<h4 class="subheading">gnutls_set_default_export_priority</h4>
<a name="gnutls_005fset_005fdefault_005fexport_005fpriority"></a><dl>
<dt><a name="index-gnutls_005fset_005fdefault_005fexport_005fpriority"></a>Function: <em>int</em> <strong>gnutls_set_default_export_priority</strong> <em>(gnutls_session_t <var>session</var>)</em></dt>
<dd><p><var>session</var>: is a <code>gnutls_session_t</code> structure.
</p>
<p>Sets some default priority on the ciphers, key exchange methods, macs
and compression methods. This function also includes weak algorithms.
</p>
<p>This is the same as calling:
</p>
<p>gnutls_priority_set_direct (session, "EXPORT", NULL);
</p>
<p>This function is kept around for backwards compatibility, but
because of its wide use it is still fully supported. If you wish
to allow users to provide a string that specify which ciphers to
use (which is recommended), you should use
<code>gnutls_priority_set_direct()</code> or <code>gnutls_priority_set()</code> instead.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code> on success, or an error code.
</p></dd></dl>
<a name="gnutls_005fsign_005fcallback_005fget-1"></a>
<h4 class="subheading">gnutls_sign_callback_get</h4>
<a name="gnutls_005fsign_005fcallback_005fget"></a><dl>
<dt><a name="index-gnutls_005fsign_005fcallback_005fget"></a>Function: <em>gnutls_sign_func</em> <strong>gnutls_sign_callback_get</strong> <em>(gnutls_session_t <var>session</var>, void ** <var>userdata</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>userdata</var>: if non-<code>NULL</code> , will be set to abstract callback pointer.
</p>
<p>Retrieve the callback function, and its userdata pointer.
</p>
<p><strong>Returns:</strong> The function pointer set by <code>gnutls_sign_callback_set()</code> , or
if not set, <code>NULL</code> .
</p>
<p><strong>Deprecated:</strong> Use the PKCS 11 interfaces instead.
</p></dd></dl>
<a name="gnutls_005fsign_005fcallback_005fset-1"></a>
<h4 class="subheading">gnutls_sign_callback_set</h4>
<a name="gnutls_005fsign_005fcallback_005fset"></a><dl>
<dt><a name="index-gnutls_005fsign_005fcallback_005fset"></a>Function: <em>void</em> <strong>gnutls_sign_callback_set</strong> <em>(gnutls_session_t <var>session</var>, gnutls_sign_func <var>sign_func</var>, void * <var>userdata</var>)</em></dt>
<dd><p><var>session</var>: is a gnutls session
</p>
<p><var>sign_func</var>: function pointer to application’s sign callback.
</p>
<p><var>userdata</var>: void pointer that will be passed to sign callback.
</p>
<p>Set the callback function. The function must have this prototype:
</p>
<p>typedef int (*gnutls_sign_func) (gnutls_session_t session,
void *userdata,
gnutls_certificate_type_t cert_type,
const gnutls_datum_t * cert,
const gnutls_datum_t * hash,
gnutls_datum_t * signature);
</p>
<p>The <code>userdata</code> parameter is passed to the <code>sign_func</code> verbatim, and
can be used to store application-specific data needed in the
callback function. See also <code>gnutls_sign_callback_get()</code> .
</p>
<p><strong>Deprecated:</strong> Use the PKCS 11 or <code>gnutls_privkey_t</code> interfacess like <code>gnutls_privkey_import_ext()</code> instead.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrl_005fsign-1"></a>
<h4 class="subheading">gnutls_x509_crl_sign</h4>
<a name="gnutls_005fx509_005fcrl_005fsign"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrl_005fsign"></a>Function: <em>int</em> <strong>gnutls_x509_crl_sign</strong> <em>(gnutls_x509_crl_t <var>crl</var>, gnutls_x509_crt_t <var>issuer</var>, gnutls_x509_privkey_t <var>issuer_key</var>)</em></dt>
<dd><p><var>crl</var>: should contain a gnutls_x509_crl_t structure
</p>
<p><var>issuer</var>: is the certificate of the certificate issuer
</p>
<p><var>issuer_key</var>: holds the issuer’s private key
</p>
<p>This function is the same a <code>gnutls_x509_crl_sign2()</code> with no flags, and
SHA1 as the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Deprecated:</strong> Use <code>gnutls_x509_crl_privkey_sign()</code> .
</p></dd></dl>
<a name="gnutls_005fx509_005fcrq_005fsign-1"></a>
<h4 class="subheading">gnutls_x509_crq_sign</h4>
<a name="gnutls_005fx509_005fcrq_005fsign"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrq_005fsign"></a>Function: <em>int</em> <strong>gnutls_x509_crq_sign</strong> <em>(gnutls_x509_crq_t <var>crq</var>, gnutls_x509_privkey_t <var>key</var>)</em></dt>
<dd><p><var>crq</var>: should contain a <code>gnutls_x509_crq_t</code> structure
</p>
<p><var>key</var>: holds a private key
</p>
<p>This function is the same a <code>gnutls_x509_crq_sign2()</code> with no flags,
and SHA1 as the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Deprecated:</strong> Use <code>gnutls_x509_crq_privkey_sign()</code> instead.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fpreferred_005fhash_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_preferred_hash_algorithm</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fpreferred_005fhash_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fpreferred_005fhash_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_preferred_hash_algorithm</strong> <em>(gnutls_x509_crt_t <var>crt</var>, gnutls_digest_algorithm_t * <var>hash</var>, unsigned int * <var>mand</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>hash</var>: The result of the call with the hash algorithm used for signature
</p>
<p><var>mand</var>: If non-zero it means that the algorithm MUST use this hash. May be NULL.
</p>
<p>This function will read the certifcate and return the appropriate digest
algorithm to use for signing with this certificate. Some certificates (i.e.
DSA might not be able to sign without the preferred algorithm).
</p>
<p><strong>Deprecated:</strong> Please use <code>gnutls_pubkey_get_preferred_hash_algorithm()</code> .
</p>
<p><strong>Returns:</strong> the 0 if the hash algorithm is found. A negative error code is
returned on error.
</p>
<p><strong>Since:</strong> 2.12.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fget_005fverify_005falgorithm-1"></a>
<h4 class="subheading">gnutls_x509_crt_get_verify_algorithm</h4>
<a name="gnutls_005fx509_005fcrt_005fget_005fverify_005falgorithm"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fget_005fverify_005falgorithm"></a>Function: <em>int</em> <strong>gnutls_x509_crt_get_verify_algorithm</strong> <em>(gnutls_x509_crt_t <var>crt</var>, const gnutls_datum_t * <var>signature</var>, gnutls_digest_algorithm_t * <var>hash</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>signature</var>: contains the signature
</p>
<p><var>hash</var>: The result of the call with the hash algorithm used for signature
</p>
<p>This function will read the certifcate and the signed data to
determine the hash algorithm used to generate the signature.
</p>
<p><strong>Deprecated:</strong> Use <code>gnutls_pubkey_get_verify_algorithm()</code> instead.
</p>
<p><strong>Returns:</strong> the 0 if the hash algorithm is found. A negative error code is
returned on error.
</p>
<p><strong>Since:</strong> 2.8.0
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fverify_005fdata-1"></a>
<h4 class="subheading">gnutls_x509_crt_verify_data</h4>
<a name="gnutls_005fx509_005fcrt_005fverify_005fdata"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fverify_005fdata"></a>Function: <em>int</em> <strong>gnutls_x509_crt_verify_data</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the data to be signed
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed data, using the
parameters from the certificate.
</p>
<p>Deprecated. Please use <code>gnutls_pubkey_verify_data()</code> .
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p></dd></dl>
<a name="gnutls_005fx509_005fcrt_005fverify_005fhash-1"></a>
<h4 class="subheading">gnutls_x509_crt_verify_hash</h4>
<a name="gnutls_005fx509_005fcrt_005fverify_005fhash"></a><dl>
<dt><a name="index-gnutls_005fx509_005fcrt_005fverify_005fhash"></a>Function: <em>int</em> <strong>gnutls_x509_crt_verify_hash</strong> <em>(gnutls_x509_crt_t <var>crt</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>hash</var>, const gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>crt</var>: Holds the certificate
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>hash</var>: holds the hash digest to be verified
</p>
<p><var>signature</var>: contains the signature
</p>
<p>This function will verify the given signed digest, using the
parameters from the certificate.
</p>
<p>Deprecated. Please use <code>gnutls_pubkey_verify_data2()</code> or <code>gnutls_pubkey_verify_hash2()</code> .
</p>
<p><strong>Returns:</strong> In case of a verification failure <code>GNUTLS_E_PK_SIG_VERIFY_FAILED</code>
is returned, and zero or positive code on success.
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fsign_005fdata-1"></a>
<h4 class="subheading">gnutls_x509_privkey_sign_data</h4>
<a name="gnutls_005fx509_005fprivkey_005fsign_005fdata"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fsign_005fdata"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_sign_data</strong> <em>(gnutls_x509_privkey_t <var>key</var>, gnutls_digest_algorithm_t <var>digest</var>, unsigned int <var>flags</var>, const gnutls_datum_t * <var>data</var>, void * <var>signature</var>, size_t * <var>signature_size</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>digest</var>: should be MD5 or SHA1
</p>
<p><var>flags</var>: should be 0 for now
</p>
<p><var>data</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain the signature
</p>
<p><var>signature_size</var>: holds the size of signature (and will be replaced
by the new size)
</p>
<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>
<p>If the buffer provided is not long enough to hold the output, then
* <code>signature_size</code> is updated and <code>GNUTLS_E_SHORT_MEMORY_BUFFER</code> will
be returned.
</p>
<p>Use <code>gnutls_x509_crt_get_preferred_hash_algorithm()</code> to determine
the hash algorithm.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p><strong>Deprecated:</strong> Use <code>gnutls_privkey_sign_data()</code> .
</p></dd></dl>
<a name="gnutls_005fx509_005fprivkey_005fsign_005fhash-1"></a>
<h4 class="subheading">gnutls_x509_privkey_sign_hash</h4>
<a name="gnutls_005fx509_005fprivkey_005fsign_005fhash"></a><dl>
<dt><a name="index-gnutls_005fx509_005fprivkey_005fsign_005fhash"></a>Function: <em>int</em> <strong>gnutls_x509_privkey_sign_hash</strong> <em>(gnutls_x509_privkey_t <var>key</var>, const gnutls_datum_t * <var>hash</var>, gnutls_datum_t * <var>signature</var>)</em></dt>
<dd><p><var>key</var>: Holds the key
</p>
<p><var>hash</var>: holds the data to be signed
</p>
<p><var>signature</var>: will contain newly allocated signature
</p>
<p>This function will sign the given hash using the private key. Do not
use this function directly unless you know what it is. Typical signing
requires the data to be hashed and stored in special formats
(e.g. BER Digest-Info for RSA).
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code> (0) is returned, otherwise a
negative error value.
</p>
<p>Deprecated in: 2.12.0
</p></dd></dl>
<hr>
<a name="Copying-Information"></a>
<div class="header">
<p>
Next: <a href="#Bibliography" accesskey="n" rel="next">Bibliography</a>, Previous: <a href="#API-reference" accesskey="p" rel="previous">API reference</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Copying-Information-1"></a>
<h2 class="appendix">Appendix F Copying Information</h2>
<a name="index-FDL_002c-GNU-Free-Documentation-License"></a>
<a name="GNU-Free-Documentation-License"></a>
<h3 class="heading">GNU Free Documentation License</h3>
<div align="center">Version 1.3, 3 November 2008
</div>
<div class="display">
<pre class="display">Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
<a href="http://fsf.org/">http://fsf.org/</a>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
</pre></div>
<ol>
<li> PREAMBLE
<p>The purpose of this License is to make a manual, textbook, or other
functional and useful document <em>free</em> 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>
<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>
<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.
</p>
</li><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>
<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>
<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>
<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>
<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>
<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>
<p>Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification. Examples
of transparent image formats include PNG, XCF and
JPG. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
</p>
<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>
<p>The “publisher” means any person or entity that distributes copies
of the Document to the public.
</p>
<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>
<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.
</p>
</li><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>
<p>You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
</p>
</li><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>
<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>
<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>
<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.
</p>
</li><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:
</p>
<ol>
<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><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><li> State on the Title page the name of the publisher of the
Modified Version, as the publisher.
</li><li> Preserve all the copyright notices of the Document.
</li><li> Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
</li><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><li> Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document’s license notice.
</li><li> Include an unaltered copy of this License.
</li><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><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><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><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><li> Delete any section Entitled “Endorsements”. Such a section
may not be included in the Modified Version.
</li><li> Do not retitle any existing section to be Entitled “Endorsements” or
to conflict in title with any Invariant Section.
</li><li> Preserve any Warranty Disclaimers.
</li></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>
<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>
<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>
<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.
</p>
</li><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>
<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>
<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.”
</p>
</li><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>
<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.
</p>
</li><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>
<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.
</p>
</li><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>
<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.
</p>
</li><li> TERMINATION
<p>You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
</p>
<p>However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
</p>
<p>Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
</p>
<p>Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
</p>
</li><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>
<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. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy’s public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
</p>
</li><li> RELICENSING
<p>“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
“Massive Multiauthor Collaboration” (or “MMC”) contained in the
site means any set of copyrightable works thus published on the MMC
site.
</p>
<p>“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
</p>
<p>“Incorporate” means to publish or republish a Document, in whole or
in part, as part of another Document.
</p>
<p>An MMC is “eligible for relicensing” if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
</p>
<p>The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
</p>
</li></ol>
<a name="ADDENDUM_003a-How-to-use-this-License-for-your-documents"></a>
<h3 class="heading">ADDENDUM: How to use this License for your documents</h3>
<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:
</p>
<div class="example">
<pre class="example"> 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.3
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></div>
<p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the “with…Texts.” line with this:
</p>
<div class="example">
<pre class="example"> 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></div>
<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>
<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.
</p>
<hr>
<a name="Bibliography"></a>
<div class="header">
<p>
Next: <a href="#Function-and-Data-Index" accesskey="n" rel="next">Function and Data Index</a>, Previous: <a href="#Copying-Information" accesskey="p" rel="previous">Copying Information</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Bibliography-1"></a>
<h2 class="unnumbered">Bibliography</h2>
<dl compact="compact">
<dt><a name="CBCATT"></a>[CBCATT]</dt>
<dd><p>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>.
</p>
</dd>
<dt><a name="GPGH"></a>[GPGH]</dt>
<dd><p>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>.
</p>
</dd>
<dt><a name="GUTPKI"></a>[GUTPKI]</dt>
<dd><p>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>.
</p>
</dd>
<dt><a name="KEYPIN"></a>[KEYPIN]</dt>
<dd><p>Chris Evans and Chris Palmer, "Public Key Pinning Extension for HTTP",
Available from <a href="http://tools.ietf.org/html/draft-ietf-websec-key-pinning-01">http://tools.ietf.org/html/draft-ietf-websec-key-pinning-01</a>.
</p>
</dd>
<dt><a name="NISTSP80057"></a>[NISTSP80057]</dt>
<dd><p>NIST Special Publication 800-57, "Recommendation for Key Management -
Part 1: General (Revised)", March 2007, available from
<a href="http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57-Part1-revised2_Mar08-2007.pdf">http://csrc.nist.gov/publications/nistpubs/800-57/sp800-57-Part1-revised2_Mar08-2007.pdf</a>.
</p>
</dd>
<dt><a name="RFC2246"></a>[RFC2246]</dt>
<dd><p>Tim Dierks and Christopher Allen, "The TLS Protocol Version 1.0",
January 1999, Available from
<a href="http://www.ietf.org/rfc/rfc2246.txt">http://www.ietf.org/rfc/rfc2246.txt</a>.
</p>
</dd>
<dt><a name="RFC4680"></a>[RFC4680]</dt>
<dd><p>S. Santesson, "TLS Handshake Message for Supplemental Data",
September 2006, Available from
<a href="http://www.ietf.org/rfc/rfc4680.txt">http://www.ietf.org/rfc/rfc4680.txt</a>.
</p>
</dd>
<dt><a name="RFC4514"></a>[RFC4514]</dt>
<dd><p>Kurt D. Zeilenga, "Lightweight Directory Access Protocol (LDAP): String Representation of Distinguished Names",
June 2006, Available from
<a href="http://www.ietf.org/rfc/rfc4513.txt">http://www.ietf.org/rfc/rfc4513.txt</a>.
</p>
</dd>
<dt><a name="RFC4346"></a>[RFC4346]</dt>
<dd><p>Tim Dierks and Eric Rescorla, "The TLS Protocol Version 1.1", Match
2006, Available from <a href="http://www.ietf.org/rfc/rfc4346.txt">http://www.ietf.org/rfc/rfc4346.txt</a>.
</p>
</dd>
<dt><a name="RFC4347"></a>[RFC4347]</dt>
<dd><p>Eric Rescorla and Nagendra Modadugu, "Datagram Transport Layer Security", April
2006, Available from <a href="http://www.ietf.org/rfc/rfc4347.txt">http://www.ietf.org/rfc/rfc4347.txt</a>.
</p>
</dd>
<dt><a name="RFC5246"></a>[RFC5246]</dt>
<dd><p>Tim Dierks and Eric Rescorla, "The TLS Protocol Version 1.2", August
2008, Available from <a href="http://www.ietf.org/rfc/rfc5246.txt">http://www.ietf.org/rfc/rfc5246.txt</a>.
</p>
</dd>
<dt><a name="RFC2440"></a>[RFC2440]</dt>
<dd><p>Jon Callas, Lutz Donnerhacke, Hal Finney and Rodney Thayer, "OpenPGP
Message Format", November 1998, Available from
<a href="http://www.ietf.org/rfc/rfc2440.txt">http://www.ietf.org/rfc/rfc2440.txt</a>.
</p>
</dd>
<dt><a name="RFC4880"></a>[RFC4880]</dt>
<dd><p>Jon Callas, Lutz Donnerhacke, Hal Finney, David Shaw and Rodney
Thayer, "OpenPGP Message Format", November 2007, Available from
<a href="http://www.ietf.org/rfc/rfc4880.txt">http://www.ietf.org/rfc/rfc4880.txt</a>.
</p>
</dd>
<dt><a name="RFC4211"></a>[RFC4211]</dt>
<dd><p>J. Schaad, "Internet X.509 Public Key Infrastructure Certificate
Request Message Format (CRMF)", September 2005, Available from
<a href="http://www.ietf.org/rfc/rfc4211.txt">http://www.ietf.org/rfc/rfc4211.txt</a>.
</p>
</dd>
<dt><a name="RFC2817"></a>[RFC2817]</dt>
<dd><p>Rohit Khare and Scott Lawrence, "Upgrading to TLS Within HTTP/1.1",
May 2000, Available from <a href="http://www.ietf.org/rfc/rfc2817.txt">http://www.ietf.org/rfc/rfc2817.txt</a>
</p>
</dd>
<dt><a name="RFC2818"></a>[RFC2818]</dt>
<dd><p>Eric Rescorla, "HTTP Over TLS", May 2000, Available from
<a href="http://www.ietf/rfc/rfc2818.txt">http://www.ietf/rfc/rfc2818.txt</a>.
</p>
</dd>
<dt><a name="RFC2945"></a>[RFC2945]</dt>
<dd><p>Tom Wu, "The SRP Authentication and Key Exchange System", September
2000, Available from <a href="http://www.ietf.org/rfc/rfc2945.txt">http://www.ietf.org/rfc/rfc2945.txt</a>.
</p>
</dd>
<dt><a name="RFC2986"></a>[RFC2986]</dt>
<dd><p>Magnus Nystrom and Burt Kaliski, "PKCS 10 v1.7: Certification Request
Syntax Specification", November 2000, Available from
<a href="http://www.ietf.org/rfc/rfc2986.txt">http://www.ietf.org/rfc/rfc2986.txt</a>.
</p>
</dd>
<dt><a name="PKIX"></a>[PKIX]</dt>
<dd><p>D. Cooper, S. Santesson, S. Farrel, S. Boeyen, R. Housley, W. Polk,
"Internet X.509 Public Key Infrastructure Certificate and Certificate
Revocation List (CRL) Profile", May 2008, available from
<a href="http://www.ietf.org/rfc/rfc5280.txt">http://www.ietf.org/rfc/rfc5280.txt</a>.
</p>
</dd>
<dt><a name="RFC3749"></a>[RFC3749]</dt>
<dd><p>Scott Hollenbeck, "Transport Layer Security Protocol Compression
Methods", May 2004, available from
<a href="http://www.ietf.org/rfc/rfc3749.txt">http://www.ietf.org/rfc/rfc3749.txt</a>.
</p>
</dd>
<dt><a name="RFC3820"></a>[RFC3820]</dt>
<dd><p>Steven Tuecke, Von Welch, Doug Engert, Laura Pearlman, and Mary
Thompson, "Internet X.509 Public Key Infrastructure (PKI) Proxy
Certificate Profile", June 2004, available from
<a href="http://www.ietf.org/rfc/rfc3820">http://www.ietf.org/rfc/rfc3820</a>.
</p>
</dd>
<dt><a name="RFC6520"></a>[RFC6520]</dt>
<dd><p>R. Seggelmann, M. Tuexen, and M. Williams, "Transport Layer Security (TLS) and
Datagram Transport Layer Security (DTLS) Heartbeat Extension", February 2012, available from
<a href="http://www.ietf.org/rfc/rfc6520">http://www.ietf.org/rfc/rfc6520</a>.
</p>
</dd>
<dt><a name="RFC5746"></a>[RFC5746]</dt>
<dd><p>E. Rescorla, M. Ray, S. Dispensa, and N. Oskov, "Transport Layer
Security (TLS) Renegotiation Indication Extension", February 2010,
available from <a href="http://www.ietf.org/rfc/rfc5746">http://www.ietf.org/rfc/rfc5746</a>.
</p>
</dd>
<dt><a name="TLSTKT"></a>[TLSTKT]</dt>
<dd><p>Joseph Salowey, Hao Zhou, Pasi Eronen, Hannes Tschofenig, "Transport
Layer Security (TLS) Session Resumption without Server-Side State",
January 2008, available from <a href="http://www.ietf.org/rfc/rfc5077">http://www.ietf.org/rfc/rfc5077</a>.
</p>
</dd>
<dt><a name="PKCS12"></a>[PKCS12]</dt>
<dd><p>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>.
</p>
</dd>
<dt><a name="PKCS11"></a>[PKCS11]</dt>
<dd><p>RSA Laboratories, "PKCS #11 Base Functionality v2.30: Cryptoki – Draft 4",
July 2009, Available from <a href="http://www.rsa.com">http://www.rsa.com</a>.
</p>
</dd>
<dt><a name="RESCORLA"></a>[RESCORLA]</dt>
<dd><p>Eric Rescorla, "SSL and TLS: Designing and Building Secure Systems",
2001
</p>
</dd>
<dt><a name="SELKEY"></a>[SELKEY]</dt>
<dd><p>Arjen Lenstra and Eric Verheul, "Selecting Cryptographic Key Sizes",
2003, available from <a href="http://www.win.tue.nl/~klenstra/key.pdf">http://www.win.tue.nl/~klenstra/key.pdf</a>.
</p>
</dd>
<dt><a name="SSL3"></a>[SSL3]</dt>
<dd><p>Alan Freier, Philip Karlton and Paul Kocher, "The Secure Sockets Layer (SSL) Protocol Version 3.0",
August 2011, Available from <a href="http://www.ietf.org/rfc/rfc6101.txt">http://www.ietf.org/rfc/rfc6101.txt</a>.
</p>
</dd>
<dt><a name="STEVENS"></a>[STEVENS]</dt>
<dd><p>Richard Stevens, "UNIX Network Programming, Volume 1", Prentice Hall
PTR, January 1998
</p>
</dd>
<dt><a name="TLSEXT"></a>[TLSEXT]</dt>
<dd><p>Simon Blake-Wilson, Magnus Nystrom, David Hopwood, Jan Mikkelsen and
Tim Wright, "Transport Layer Security (TLS) Extensions", June 2003,
Available from <a href="http://www.ietf.org/rfc/rfc3546.txt">http://www.ietf.org/rfc/rfc3546.txt</a>.
</p>
</dd>
<dt><a name="TLSPGP"></a>[TLSPGP]</dt>
<dd><p>Nikos Mavrogiannopoulos, "Using OpenPGP keys for TLS authentication",
January 2011. Available from
<a href="http://www.ietf.org/rfc/rfc6091.txt">http://www.ietf.org/rfc/rfc6091.txt</a>.
</p>
</dd>
<dt><a name="TLSSRP"></a>[TLSSRP]</dt>
<dd><p>David Taylor, Trevor Perrin, Tom Wu and Nikos Mavrogiannopoulos,
"Using SRP for TLS Authentication", November 2007. Available from
<a href="http://www.ietf.org/rfc/rfc5054.txt">http://www.ietf.org/rfc/rfc5054.txt</a>.
</p>
</dd>
<dt><a name="TLSPSK"></a>[TLSPSK]</dt>
<dd><p>Pasi Eronen and Hannes Tschofenig, "Pre-shared key Ciphersuites for
TLS", December 2005, Available from
<a href="http://www.ietf.org/rfc/rfc4279.txt">http://www.ietf.org/rfc/rfc4279.txt</a>.
</p>
</dd>
<dt><a name="TOMSRP"></a>[TOMSRP]</dt>
<dd><p>Tom Wu, "The Stanford SRP Authentication Project", Available at
<a href="http://srp.stanford.edu/">http://srp.stanford.edu/</a>.
</p>
</dd>
<dt><a name="WEGER"></a>[WEGER]</dt>
<dd><p>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>.
</p>
</dd>
<dt><a name="ECRYPT"></a>[ECRYPT]</dt>
<dd><p>European Network of Excellence in Cryptology II, "ECRYPT II Yearly
Report on Algorithms and Keysizes (2009-2010)", Available
at <a href="http://www.ecrypt.eu.org/documents/D.SPA.13.pdf">http://www.ecrypt.eu.org/documents/D.SPA.13.pdf</a>.
</p>
</dd>
<dt><a name="RFC5056"></a>[RFC5056]</dt>
<dd><p>N. Williams, "On the Use of Channel Bindings to Secure Channels",
November 2007, available from <a href="http://www.ietf.org/rfc/rfc5056">http://www.ietf.org/rfc/rfc5056</a>.
</p>
</dd>
<dt><a name="RFC5929"></a>[RFC5929]</dt>
<dd><p>J. Altman, N. Williams, L. Zhu, "Channel Bindings for TLS", July 2010,
available from <a href="http://www.ietf.org/rfc/rfc5929">http://www.ietf.org/rfc/rfc5929</a>.
</p>
</dd>
<dt><a name="PKCS11URI"></a>[PKCS11URI]</dt>
<dd><p>J. Pechanec, D. Moffat, "The PKCS#11 URI Scheme", August 2011,
Work in progress, available from <a href="http://tools.ietf.org/html/draft-pechanec-pkcs11uri-05">http://tools.ietf.org/html/draft-pechanec-pkcs11uri-05</a>.
</p>
</dd>
<dt><a name="ANDERSON"></a>[ANDERSON]</dt>
<dd><p>R. J. Anderson, "Security Engineering: A Guide to Building Dependable Distributed Systems",
John Wiley \& Sons, Inc., 2001.
</p>
</dd>
<dt><a name="RFC4821"></a>[RFC4821]</dt>
<dd><p>M. Mathis, J. Heffner, "Packetization Layer Path MTU Discovery", March 2007,
available from <a href="http://www.ietf.org/rfc/rfc4821.txt">http://www.ietf.org/rfc/rfc4821.txt</a>.
</p>
</dd>
<dt><a name="RFC2560"></a>[RFC2560]</dt>
<dd><p>M. Myers et al, "X.509 Internet Public Key Infrastructure Online
Certificate Status Protocol - OCSP", June 1999, Available from
<a href="http://www.ietf.org/rfc/rfc2560.txt">http://www.ietf.org/rfc/rfc2560.txt</a>.
</p>
</dd>
<dt><a name="RIVESTCRL"></a>[RIVESTCRL]</dt>
<dd><p>R. L. Rivest, "Can We Eliminate Certificate Revocation Lists?",
Proceedings of Financial Cryptography ’98; Springer Lecture Notes in
Computer Science No. 1465 (Rafael Hirschfeld, ed.), February 1998),
pages 178–183, available from
<a href="http://people.csail.mit.edu/rivest/Rivest-CanWeEliminateCertificateRevocationLists.pdf">http://people.csail.mit.edu/rivest/Rivest-CanWeEliminateCertificateRevocationLists.pdf</a>.
</p>
</dd>
</dl>
<hr>
<a name="Function-and-Data-Index"></a>
<div class="header">
<p>
Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previous: <a href="#Bibliography" accesskey="p" rel="previous">Bibliography</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Function-and-Data-Index-1"></a>
<h2 class="unnumbered">Function and Data Index</h2>
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Function-and-Data-Index_fn_letter-D"><b>D</b></a>
<a class="summary-letter" href="#Function-and-Data-Index_fn_letter-G"><b>G</b></a>
</td></tr></table>
<table class="index-fn" border="0">
<tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Function-and-Data-Index_fn_letter-D">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fcert_005ftype_005fname"><code>dane_cert_type_name</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fcert_005fusage_005fname"><code>dane_cert_usage_name</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fmatch_005ftype_005fname"><code>dane_match_type_name</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fquery_005fdata"><code>dane_query_data</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fquery_005fdeinit"><code>dane_query_deinit</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fquery_005fentries"><code>dane_query_entries</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fquery_005fstatus"><code>dane_query_status</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fquery_005ftlsa"><code>dane_query_tlsa</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fstate_005fdeinit"><code>dane_state_deinit</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fstate_005finit"><code>dane_state_init</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fstate_005fset_005fdlv_005ffile"><code>dane_state_set_dlv_file</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fstrerror"><code>dane_strerror</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fverification_005fstatus_005fprint"><code>dane_verification_status_print</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fverify_005fcrt"><code>dane_verify_crt</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fverify_005fcrt-1"><code>dane_verify_crt</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-dane_005fverify_005fsession_005fcrt"><code>dane_verify_session_crt</code></a>:</td><td> </td><td valign="top"><a href="#DANE-API">DANE API</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Function-and-Data-Index_fn_letter-G">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fget"><code>gnutls_alert_get</code></a>:</td><td> </td><td valign="top"><a href="#Handling-alerts">Handling alerts</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fget-1"><code>gnutls_alert_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fget_005fname"><code>gnutls_alert_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Handling-alerts">Handling alerts</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fget_005fname-1"><code>gnutls_alert_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fget_005fstrname"><code>gnutls_alert_get_strname</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fsend"><code>gnutls_alert_send</code></a>:</td><td> </td><td valign="top"><a href="#Handling-alerts">Handling alerts</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fsend-1"><code>gnutls_alert_send</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005falert_005fsend_005fappropriate"><code>gnutls_alert_send_appropriate</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005fallocate_005fclient_005fcredentials"><code>gnutls_anon_allocate_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005fallocate_005fserver_005fcredentials"><code>gnutls_anon_allocate_server_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005ffree_005fclient_005fcredentials"><code>gnutls_anon_free_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005ffree_005fserver_005fcredentials"><code>gnutls_anon_free_server_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005fset_005fparams_005ffunction"><code>gnutls_anon_set_params_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005fset_005fserver_005fdh_005fparams"><code>gnutls_anon_set_server_dh_params</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fanon_005fset_005fserver_005fparams_005ffunction"><code>gnutls_anon_set_server_params_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fauth_005fclient_005fget_005ftype"><code>gnutls_auth_client_get_type</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fauth_005fget_005ftype"><code>gnutls_auth_get_type</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fauth_005fserver_005fget_005ftype"><code>gnutls_auth_server_get_type</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fbye"><code>gnutls_bye</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fbye-1"><code>gnutls_bye</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005factivation_005ftime_005fpeers"><code>gnutls_certificate_activation_time_peers</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fallocate_005fcredentials"><code>gnutls_certificate_allocate_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fclient_005fget_005frequest_005fstatus"><code>gnutls_certificate_client_get_request_status</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fexpiration_005ftime_005fpeers"><code>gnutls_certificate_expiration_time_peers</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ffree_005fcas"><code>gnutls_certificate_free_cas</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ffree_005fca_005fnames"><code>gnutls_certificate_free_ca_names</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ffree_005fcredentials"><code>gnutls_certificate_free_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ffree_005fcrls"><code>gnutls_certificate_free_crls</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ffree_005fkeys"><code>gnutls_certificate_free_keys</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fget_005fissuer"><code>gnutls_certificate_get_issuer</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fget_005fours"><code>gnutls_certificate_get_ours</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fget_005fpeers"><code>gnutls_certificate_get_peers</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fget_005fpeers_005fsubkey_005fid"><code>gnutls_certificate_get_peers_subkey_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence"><code>gnutls_certificate_send_x509_rdn_sequence</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-credentials">Certificate credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fsend_005fx509_005frdn_005fsequence-1"><code>gnutls_certificate_send_x509_rdn_sequence</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fserver_005fset_005frequest"><code>gnutls_certificate_server_set_request</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-credentials">Certificate credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fserver_005fset_005frequest-1"><code>gnutls_certificate_server_set_request</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fdh_005fparams"><code>gnutls_certificate_set_dh_params</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fkey"><code>gnutls_certificate_set_key</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-credentials">Certificate credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fkey-1"><code>gnutls_certificate_set_key</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffile"><code>gnutls_certificate_set_ocsp_status_request_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005focsp_005fstatus_005frequest_005ffunction"><code>gnutls_certificate_set_ocsp_status_request_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey"><code>gnutls_certificate_set_openpgp_key</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile"><code>gnutls_certificate_set_openpgp_keyring_file</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-certificates">OpenPGP certificates</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile-1"><code>gnutls_certificate_set_openpgp_keyring_file</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005fmem"><code>gnutls_certificate_set_openpgp_keyring_mem</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile"><code>gnutls_certificate_set_openpgp_key_file</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005ffile2"><code>gnutls_certificate_set_openpgp_key_file2</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem"><code>gnutls_certificate_set_openpgp_key_mem</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fopenpgp_005fkey_005fmem2"><code>gnutls_certificate_set_openpgp_key_mem2</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fparams_005ffunction"><code>gnutls_certificate_set_params_function</code></a>:</td><td> </td><td valign="top"><a href="#Parameter-generation">Parameter generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fparams_005ffunction-1"><code>gnutls_certificate_set_params_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fpin_005ffunction"><code>gnutls_certificate_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-credentials">Certificate credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fpin_005ffunction-1"><code>gnutls_certificate_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fretrieve_005ffunction"><code>gnutls_certificate_set_retrieve_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fretrieve_005ffunction2"><code>gnutls_certificate_set_retrieve_function2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005frsa_005fexport_005fparams"><code>gnutls_certificate_set_rsa_export_params</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fverify_005fflags"><code>gnutls_certificate_set_verify_flags</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fverify_005ffunction"><code>gnutls_certificate_set_verify_function</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-credentials">Certificate credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fverify_005ffunction-1"><code>gnutls_certificate_set_verify_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fverify_005flimits"><code>gnutls_certificate_set_verify_limits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fcrl"><code>gnutls_certificate_set_x509_crl</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005ffile"><code>gnutls_certificate_set_x509_crl_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fcrl_005fmem"><code>gnutls_certificate_set_x509_crl_mem</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fkey"><code>gnutls_certificate_set_x509_key</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fkey_005ffile"><code>gnutls_certificate_set_x509_key_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fkey_005fmem"><code>gnutls_certificate_set_x509_key_mem</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005ffile"><code>gnutls_certificate_set_x509_simple_pkcs12_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fsimple_005fpkcs12_005fmem"><code>gnutls_certificate_set_x509_simple_pkcs12_mem</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust"><code>gnutls_certificate_set_x509_system_trust</code></a>:</td><td> </td><td valign="top"><a href="#Using-a-PKCS11-token-with-TLS">Using a PKCS11 token with TLS</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005fsystem_005ftrust-1"><code>gnutls_certificate_set_x509_system_trust</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005ftrust"><code>gnutls_certificate_set_x509_trust</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005ffile"><code>gnutls_certificate_set_x509_trust_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fset_005fx509_005ftrust_005fmem"><code>gnutls_certificate_set_x509_trust_mem</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ftype_005fget"><code>gnutls_certificate_type_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ftype_005fget_005fid"><code>gnutls_certificate_type_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ftype_005fget_005fname"><code>gnutls_certificate_type_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ftype_005flist"><code>gnutls_certificate_type_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005ftype_005fset_005fpriority"><code>gnutls_certificate_type_set_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fverification_005fstatus_005fprint"><code>gnutls_certificate_verification_status_print</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fverify_005fflags"><code>gnutls_certificate_verify_flags</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-in-the-context-of-TLS-session">Verifying a certificate in the context of TLS session</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fverify_005fflags-1"><code>gnutls_certificate_verify_flags</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fverify_005fpeers2"><code>gnutls_certificate_verify_peers2</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fverify_005fpeers3"><code>gnutls_certificate_verify_peers3</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-credentials">Certificate credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcertificate_005fverify_005fpeers3-1"><code>gnutls_certificate_verify_peers3</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcheck_005fversion"><code>gnutls_check_version</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fadd_005fauth"><code>gnutls_cipher_add_auth</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fdecrypt"><code>gnutls_cipher_decrypt</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fdecrypt2"><code>gnutls_cipher_decrypt2</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fdeinit"><code>gnutls_cipher_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fencrypt"><code>gnutls_cipher_encrypt</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fencrypt2"><code>gnutls_cipher_encrypt2</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fget"><code>gnutls_cipher_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fget_005fblock_005fsize"><code>gnutls_cipher_get_block_size</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fget_005fid"><code>gnutls_cipher_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fget_005fkey_005fsize"><code>gnutls_cipher_get_key_size</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fget_005fname"><code>gnutls_cipher_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005finit"><code>gnutls_cipher_init</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005flist"><code>gnutls_cipher_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fset_005fiv"><code>gnutls_cipher_set_iv</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fset_005fpriority"><code>gnutls_cipher_set_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fsuite_005fget_005fname"><code>gnutls_cipher_suite_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005fsuite_005finfo"><code>gnutls_cipher_suite_info</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcipher_005ftag"><code>gnutls_cipher_tag</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcompression_005fget"><code>gnutls_compression_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcompression_005fget_005fid"><code>gnutls_compression_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcompression_005fget_005fname"><code>gnutls_compression_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcompression_005flist"><code>gnutls_compression_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcompression_005fset_005fpriority"><code>gnutls_compression_set_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcredentials_005fclear"><code>gnutls_credentials_clear</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcredentials_005fset"><code>gnutls_credentials_set</code></a>:</td><td> </td><td valign="top"><a href="#Session-initialization">Session initialization</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fcredentials_005fset-1"><code>gnutls_credentials_set</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fcheck_005fentry"><code>gnutls_db_check_entry</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fcheck_005fentry_005ftime"><code>gnutls_db_check_entry_time</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fget_005fptr"><code>gnutls_db_get_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fremove_005fsession"><code>gnutls_db_remove_session</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fset_005fcache_005fexpiration"><code>gnutls_db_set_cache_expiration</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fset_005fptr"><code>gnutls_db_set_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fset_005fremove_005ffunction"><code>gnutls_db_set_remove_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fset_005fretrieve_005ffunction"><code>gnutls_db_set_retrieve_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdb_005fset_005fstore_005ffunction"><code>gnutls_db_set_store_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdeinit"><code>gnutls_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdeinit-1"><code>gnutls_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fget_005fgroup"><code>gnutls_dh_get_group</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fget_005fpeers_005fpublic_005fbits"><code>gnutls_dh_get_peers_public_bits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fget_005fprime_005fbits"><code>gnutls_dh_get_prime_bits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fget_005fpubkey"><code>gnutls_dh_get_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fget_005fsecret_005fbits"><code>gnutls_dh_get_secret_bits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fcpy"><code>gnutls_dh_params_cpy</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fdeinit"><code>gnutls_dh_params_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fexport2_005fpkcs3"><code>gnutls_dh_params_export2_pkcs3</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fexport_005fpkcs3"><code>gnutls_dh_params_export_pkcs3</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fexport_005fraw"><code>gnutls_dh_params_export_raw</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fgenerate2"><code>gnutls_dh_params_generate2</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fimport_005fpkcs3"><code>gnutls_dh_params_import_pkcs3</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005fimport_005fraw"><code>gnutls_dh_params_import_raw</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fparams_005finit"><code>gnutls_dh_params_init</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdh_005fset_005fprime_005fbits"><code>gnutls_dh_set_prime_bits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fcookie_005fsend"><code>gnutls_dtls_cookie_send</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fcookie_005fverify"><code>gnutls_dtls_cookie_verify</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fget_005fdata_005fmtu"><code>gnutls_dtls_get_data_mtu</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fget_005fmtu"><code>gnutls_dtls_get_mtu</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fget_005ftimeout"><code>gnutls_dtls_get_timeout</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fget_005ftimeout-1"><code>gnutls_dtls_get_timeout</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fprestate_005fset"><code>gnutls_dtls_prestate_set</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fset_005fdata_005fmtu"><code>gnutls_dtls_set_data_mtu</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fset_005fmtu"><code>gnutls_dtls_set_mtu</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fdtls_005fset_005ftimeouts"><code>gnutls_dtls_set_timeouts</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fecc_005fcurve_005fget"><code>gnutls_ecc_curve_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fecc_005fcurve_005fget_005fname"><code>gnutls_ecc_curve_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fecc_005fcurve_005fget_005fsize"><code>gnutls_ecc_curve_get_size</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fecc_005fcurve_005flist"><code>gnutls_ecc_curve_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ferror_005fis_005ffatal"><code>gnutls_error_is_fatal</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ferror_005fis_005ffatal-1"><code>gnutls_error_is_fatal</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ferror_005fto_005falert"><code>gnutls_error_to_alert</code></a>:</td><td> </td><td valign="top"><a href="#Handling-alerts">Handling alerts</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ferror_005fto_005falert-1"><code>gnutls_error_to_alert</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ffingerprint"><code>gnutls_fingerprint</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fdeinit"><code>gnutls_global_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005finit"><code>gnutls_global_init</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005faudit_005flog_005ffunction"><code>gnutls_global_set_audit_log_function</code></a>:</td><td> </td><td valign="top"><a href="#Debugging-and-auditing">Debugging and auditing</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005faudit_005flog_005ffunction-1"><code>gnutls_global_set_audit_log_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005flog_005ffunction"><code>gnutls_global_set_log_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005flog_005flevel"><code>gnutls_global_set_log_level</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005fmem_005ffunctions"><code>gnutls_global_set_mem_functions</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005fmutex"><code>gnutls_global_set_mutex</code></a>:</td><td> </td><td valign="top"><a href="#Thread-safety">Thread safety</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005fmutex-1"><code>gnutls_global_set_mutex</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fglobal_005fset_005ftime_005ffunction"><code>gnutls_global_set_time_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake"><code>gnutls_handshake</code></a>:</td><td> </td><td valign="top"><a href="#TLS-handshake">TLS handshake</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake-1"><code>gnutls_handshake</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fget_005flast_005fin"><code>gnutls_handshake_get_last_in</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fget_005flast_005fout"><code>gnutls_handshake_get_last_out</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fset_005fmax_005fpacket_005flength"><code>gnutls_handshake_set_max_packet_length</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fset_005fpost_005fclient_005fhello_005ffunction"><code>gnutls_handshake_set_post_client_hello_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fset_005fprivate_005fextensions"><code>gnutls_handshake_set_private_extensions</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fset_005ftimeout"><code>gnutls_handshake_set_timeout</code></a>:</td><td> </td><td valign="top"><a href="#TLS-handshake">TLS handshake</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhandshake_005fset_005ftimeout-1"><code>gnutls_handshake_set_timeout</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhash"><code>gnutls_hash</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhash_005fdeinit"><code>gnutls_hash_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhash_005ffast"><code>gnutls_hash_fast</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhash_005fget_005flen"><code>gnutls_hash_get_len</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhash_005finit"><code>gnutls_hash_init</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhash_005foutput"><code>gnutls_hash_output</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fheartbeat_005fallowed"><code>gnutls_heartbeat_allowed</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fheartbeat_005fenable"><code>gnutls_heartbeat_enable</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fheartbeat_005fget_005ftimeout"><code>gnutls_heartbeat_get_timeout</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fheartbeat_005fping"><code>gnutls_heartbeat_ping</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fheartbeat_005fpong"><code>gnutls_heartbeat_pong</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fheartbeat_005fset_005ftimeouts"><code>gnutls_heartbeat_set_timeouts</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhex2bin"><code>gnutls_hex2bin</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhex_005fdecode"><code>gnutls_hex_decode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhex_005fencode"><code>gnutls_hex_encode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhmac"><code>gnutls_hmac</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhmac_005fdeinit"><code>gnutls_hmac_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhmac_005ffast"><code>gnutls_hmac_fast</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhmac_005fget_005flen"><code>gnutls_hmac_get_len</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhmac_005finit"><code>gnutls_hmac_init</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fhmac_005foutput"><code>gnutls_hmac_output</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005finit"><code>gnutls_init</code></a>:</td><td> </td><td valign="top"><a href="#Session-initialization">Session initialization</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005finit-1"><code>gnutls_init</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fkey_005fgenerate"><code>gnutls_key_generate</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fkx_005fget"><code>gnutls_kx_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fkx_005fget_005fid"><code>gnutls_kx_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fkx_005fget_005fname"><code>gnutls_kx_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fkx_005flist"><code>gnutls_kx_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fkx_005fset_005fpriority"><code>gnutls_kx_set_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fload_005ffile"><code>gnutls_load_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fmac_005fget"><code>gnutls_mac_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fmac_005fget_005fid"><code>gnutls_mac_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fmac_005fget_005fkey_005fsize"><code>gnutls_mac_get_key_size</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fmac_005fget_005fname"><code>gnutls_mac_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fmac_005flist"><code>gnutls_mac_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fmac_005fset_005fpriority"><code>gnutls_mac_set_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fadd_005fcert"><code>gnutls_ocsp_req_add_cert</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fadd_005fcert_005fid"><code>gnutls_ocsp_req_add_cert_id</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fdeinit"><code>gnutls_ocsp_req_deinit</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fexport"><code>gnutls_ocsp_req_export</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fget_005fcert_005fid"><code>gnutls_ocsp_req_get_cert_id</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fget_005fextension"><code>gnutls_ocsp_req_get_extension</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fget_005fnonce"><code>gnutls_ocsp_req_get_nonce</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fget_005fversion"><code>gnutls_ocsp_req_get_version</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fimport"><code>gnutls_ocsp_req_import</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005finit"><code>gnutls_ocsp_req_init</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fprint"><code>gnutls_ocsp_req_print</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005frandomize_005fnonce"><code>gnutls_ocsp_req_randomize_nonce</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fset_005fextension"><code>gnutls_ocsp_req_set_extension</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005freq_005fset_005fnonce"><code>gnutls_ocsp_req_set_nonce</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fcheck_005fcrt"><code>gnutls_ocsp_resp_check_crt</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fdeinit"><code>gnutls_ocsp_resp_deinit</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fexport"><code>gnutls_ocsp_resp_export</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fcerts"><code>gnutls_ocsp_resp_get_certs</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fextension"><code>gnutls_ocsp_resp_get_extension</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fnonce"><code>gnutls_ocsp_resp_get_nonce</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fproduced"><code>gnutls_ocsp_resp_get_produced</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fresponder"><code>gnutls_ocsp_resp_get_responder</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fresponse"><code>gnutls_ocsp_resp_get_response</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fsignature"><code>gnutls_ocsp_resp_get_signature</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fsignature_005falgorithm"><code>gnutls_ocsp_resp_get_signature_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fsingle"><code>gnutls_ocsp_resp_get_single</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-certificate-status-checking">OCSP certificate status checking</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fsingle-1"><code>gnutls_ocsp_resp_get_single</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fstatus"><code>gnutls_ocsp_resp_get_status</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fget_005fversion"><code>gnutls_ocsp_resp_get_version</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fimport"><code>gnutls_ocsp_resp_import</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005finit"><code>gnutls_ocsp_resp_init</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fprint"><code>gnutls_ocsp_resp_print</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fverify"><code>gnutls_ocsp_resp_verify</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fresp_005fverify_005fdirect"><code>gnutls_ocsp_resp_verify_direct</code></a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fstatus_005frequest_005fenable_005fclient"><code>gnutls_ocsp_status_request_enable_client</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fstatus_005frequest_005fget"><code>gnutls_ocsp_status_request_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005focsp_005fstatus_005frequest_005fis_005fchecked"><code>gnutls_ocsp_status_request_is_checked</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fcheck_005fhostname"><code>gnutls_openpgp_crt_check_hostname</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fdeinit"><code>gnutls_openpgp_crt_deinit</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fexport"><code>gnutls_openpgp_crt_export</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fexport2"><code>gnutls_openpgp_crt_export2</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fauth_005fsubkey"><code>gnutls_openpgp_crt_get_auth_subkey</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fcreation_005ftime"><code>gnutls_openpgp_crt_get_creation_time</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fexpiration_005ftime"><code>gnutls_openpgp_crt_get_expiration_time</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005ffingerprint"><code>gnutls_openpgp_crt_get_fingerprint</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fid"><code>gnutls_openpgp_crt_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fkey_005fusage"><code>gnutls_openpgp_crt_get_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fname"><code>gnutls_openpgp_crt_get_name</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fpk_005falgorithm"><code>gnutls_openpgp_crt_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fpk_005fdsa_005fraw"><code>gnutls_openpgp_crt_get_pk_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fpk_005frsa_005fraw"><code>gnutls_openpgp_crt_get_pk_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fpreferred_005fkey_005fid"><code>gnutls_openpgp_crt_get_preferred_key_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005frevoked_005fstatus"><code>gnutls_openpgp_crt_get_revoked_status</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcount"><code>gnutls_openpgp_crt_get_subkey_count</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fcreation_005ftime"><code>gnutls_openpgp_crt_get_subkey_creation_time</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fexpiration_005ftime"><code>gnutls_openpgp_crt_get_subkey_expiration_time</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005ffingerprint"><code>gnutls_openpgp_crt_get_subkey_fingerprint</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fid"><code>gnutls_openpgp_crt_get_subkey_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fidx"><code>gnutls_openpgp_crt_get_subkey_idx</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005falgorithm"><code>gnutls_openpgp_crt_get_subkey_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005fdsa_005fraw"><code>gnutls_openpgp_crt_get_subkey_pk_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fpk_005frsa_005fraw"><code>gnutls_openpgp_crt_get_subkey_pk_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005frevoked_005fstatus"><code>gnutls_openpgp_crt_get_subkey_revoked_status</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fsubkey_005fusage"><code>gnutls_openpgp_crt_get_subkey_usage</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fget_005fversion"><code>gnutls_openpgp_crt_get_version</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fimport"><code>gnutls_openpgp_crt_import</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005finit"><code>gnutls_openpgp_crt_init</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fprint"><code>gnutls_openpgp_crt_print</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fset_005fpreferred_005fkey_005fid"><code>gnutls_openpgp_crt_set_preferred_key_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fverify_005fring"><code>gnutls_openpgp_crt_verify_ring</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-certificates">OpenPGP certificates</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fverify_005fring-1"><code>gnutls_openpgp_crt_verify_ring</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fverify_005fself"><code>gnutls_openpgp_crt_verify_self</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-certificates">OpenPGP certificates</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fcrt_005fverify_005fself-1"><code>gnutls_openpgp_crt_verify_self</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fkeyring_005fcheck_005fid"><code>gnutls_openpgp_keyring_check_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fkeyring_005fdeinit"><code>gnutls_openpgp_keyring_deinit</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fkeyring_005fget_005fcrt"><code>gnutls_openpgp_keyring_get_crt</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fkeyring_005fget_005fcrt_005fcount"><code>gnutls_openpgp_keyring_get_crt_count</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fkeyring_005fimport"><code>gnutls_openpgp_keyring_import</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fkeyring_005finit"><code>gnutls_openpgp_keyring_init</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fdeinit"><code>gnutls_openpgp_privkey_deinit</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fexport"><code>gnutls_openpgp_privkey_export</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fexport2"><code>gnutls_openpgp_privkey_export2</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fexport_005fdsa_005fraw"><code>gnutls_openpgp_privkey_export_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fexport_005frsa_005fraw"><code>gnutls_openpgp_privkey_export_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005fdsa_005fraw"><code>gnutls_openpgp_privkey_export_subkey_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fexport_005fsubkey_005frsa_005fraw"><code>gnutls_openpgp_privkey_export_subkey_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005ffingerprint"><code>gnutls_openpgp_privkey_get_fingerprint</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fkey_005fid"><code>gnutls_openpgp_privkey_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fpk_005falgorithm"><code>gnutls_openpgp_privkey_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fpreferred_005fkey_005fid"><code>gnutls_openpgp_privkey_get_preferred_key_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005frevoked_005fstatus"><code>gnutls_openpgp_privkey_get_revoked_status</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcount"><code>gnutls_openpgp_privkey_get_subkey_count</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fcreation_005ftime"><code>gnutls_openpgp_privkey_get_subkey_creation_time</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005ffingerprint"><code>gnutls_openpgp_privkey_get_subkey_fingerprint</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fid"><code>gnutls_openpgp_privkey_get_subkey_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fidx"><code>gnutls_openpgp_privkey_get_subkey_idx</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005fpk_005falgorithm"><code>gnutls_openpgp_privkey_get_subkey_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fget_005fsubkey_005frevoked_005fstatus"><code>gnutls_openpgp_privkey_get_subkey_revoked_status</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fimport"><code>gnutls_openpgp_privkey_import</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005finit"><code>gnutls_openpgp_privkey_init</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fsec_005fparam"><code>gnutls_openpgp_privkey_sec_param</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fset_005fpreferred_005fkey_005fid"><code>gnutls_openpgp_privkey_set_preferred_key_id</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fprivkey_005fsign_005fhash"><code>gnutls_openpgp_privkey_sign_hash</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fsend_005fcert"><code>gnutls_openpgp_send_cert</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fopenpgp_005fset_005frecv_005fkey_005ffunction"><code>gnutls_openpgp_set_recv_key_function</code></a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpcert_005fdeinit"><code>gnutls_pcert_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpcert_005fimport_005fopenpgp"><code>gnutls_pcert_import_openpgp</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpcert_005fimport_005fopenpgp_005fraw"><code>gnutls_pcert_import_openpgp_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpcert_005fimport_005fx509"><code>gnutls_pcert_import_x509</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpcert_005fimport_005fx509_005fraw"><code>gnutls_pcert_import_x509_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpcert_005flist_005fimport_005fx509_005fraw"><code>gnutls_pcert_list_import_x509_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpem_005fbase64_005fdecode"><code>gnutls_pem_base64_decode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpem_005fbase64_005fdecode_005falloc"><code>gnutls_pem_base64_decode_alloc</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpem_005fbase64_005fencode"><code>gnutls_pem_base64_encode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpem_005fbase64_005fencode_005falloc"><code>gnutls_pem_base64_encode_alloc</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fperror"><code>gnutls_perror</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fadd_005fprovider"><code>gnutls_pkcs11_add_provider</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fcopy_005fsecret_005fkey"><code>gnutls_pkcs11_copy_secret_key</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fcopy_005fx509_005fcrt"><code>gnutls_pkcs11_copy_x509_crt</code></a>:</td><td> </td><td valign="top"><a href="#Writing-objects">Writing objects</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fcopy_005fx509_005fcrt-1"><code>gnutls_pkcs11_copy_x509_crt</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey"><code>gnutls_pkcs11_copy_x509_privkey</code></a>:</td><td> </td><td valign="top"><a href="#Writing-objects">Writing objects</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fcopy_005fx509_005fprivkey-1"><code>gnutls_pkcs11_copy_x509_privkey</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fdeinit"><code>gnutls_pkcs11_deinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fdelete_005furl"><code>gnutls_pkcs11_delete_url</code></a>:</td><td> </td><td valign="top"><a href="#Writing-objects">Writing objects</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fdelete_005furl-1"><code>gnutls_pkcs11_delete_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fget_005fpin_005ffunction"><code>gnutls_pkcs11_get_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005finit"><code>gnutls_pkcs11_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS11-Initialization">PKCS11 Initialization</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005finit-1"><code>gnutls_pkcs11_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fdeinit"><code>gnutls_pkcs11_obj_deinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fexport"><code>gnutls_pkcs11_obj_export</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fexport2"><code>gnutls_pkcs11_obj_export2</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fexport_005furl"><code>gnutls_pkcs11_obj_export_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fget_005finfo"><code>gnutls_pkcs11_obj_get_info</code></a>:</td><td> </td><td valign="top"><a href="#Reading-objects">Reading objects</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fget_005finfo-1"><code>gnutls_pkcs11_obj_get_info</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fget_005ftype"><code>gnutls_pkcs11_obj_get_type</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fimport_005furl"><code>gnutls_pkcs11_obj_import_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005finit"><code>gnutls_pkcs11_obj_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl"><code>gnutls_pkcs11_obj_list_import_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005flist_005fimport_005furl2"><code>gnutls_pkcs11_obj_list_import_url2</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fobj_005fset_005fpin_005ffunction"><code>gnutls_pkcs11_obj_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fdeinit"><code>gnutls_pkcs11_privkey_deinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fexport_005furl"><code>gnutls_pkcs11_privkey_export_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fgenerate"><code>gnutls_pkcs11_privkey_generate</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fgenerate2"><code>gnutls_pkcs11_privkey_generate2</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fget_005finfo"><code>gnutls_pkcs11_privkey_get_info</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fget_005fpk_005falgorithm"><code>gnutls_pkcs11_privkey_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fimport_005furl"><code>gnutls_pkcs11_privkey_import_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005finit"><code>gnutls_pkcs11_privkey_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fprivkey_005fset_005fpin_005ffunction"><code>gnutls_pkcs11_privkey_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005freinit"><code>gnutls_pkcs11_reinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS11-Initialization">PKCS11 Initialization</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005freinit-1"><code>gnutls_pkcs11_reinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fset_005fpin_005ffunction"><code>gnutls_pkcs11_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005fset_005ftoken_005ffunction"><code>gnutls_pkcs11_set_token_function</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftoken_005fget_005fflags"><code>gnutls_pkcs11_token_get_flags</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftoken_005fget_005finfo"><code>gnutls_pkcs11_token_get_info</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftoken_005fget_005fmechanism"><code>gnutls_pkcs11_token_get_mechanism</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftoken_005fget_005furl"><code>gnutls_pkcs11_token_get_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftoken_005finit"><code>gnutls_pkcs11_token_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftoken_005fset_005fpin"><code>gnutls_pkcs11_token_set_pin</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs11_005ftype_005fget_005fname"><code>gnutls_pkcs11_type_get_name</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fdecrypt"><code>gnutls_pkcs12_bag_decrypt</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fdeinit"><code>gnutls_pkcs12_bag_deinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fencrypt"><code>gnutls_pkcs12_bag_encrypt</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005fcount"><code>gnutls_pkcs12_bag_get_count</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005fdata"><code>gnutls_pkcs12_bag_get_data</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005ffriendly_005fname"><code>gnutls_pkcs12_bag_get_friendly_name</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005fkey_005fid"><code>gnutls_pkcs12_bag_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fget_005ftype"><code>gnutls_pkcs12_bag_get_type</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005finit"><code>gnutls_pkcs12_bag_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fcrl"><code>gnutls_pkcs12_bag_set_crl</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fcrt"><code>gnutls_pkcs12_bag_set_crt</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fdata"><code>gnutls_pkcs12_bag_set_data</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005ffriendly_005fname"><code>gnutls_pkcs12_bag_set_friendly_name</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fbag_005fset_005fkey_005fid"><code>gnutls_pkcs12_bag_set_key_id</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fdeinit"><code>gnutls_pkcs12_deinit</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fexport"><code>gnutls_pkcs12_export</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fexport2"><code>gnutls_pkcs12_export2</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fgenerate_005fmac"><code>gnutls_pkcs12_generate_mac</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fget_005fbag"><code>gnutls_pkcs12_get_bag</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fimport"><code>gnutls_pkcs12_import</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005finit"><code>gnutls_pkcs12_init</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fset_005fbag"><code>gnutls_pkcs12_set_bag</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fsimple_005fparse"><code>gnutls_pkcs12_simple_parse</code></a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fsimple_005fparse-1"><code>gnutls_pkcs12_simple_parse</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs12_005fverify_005fmac"><code>gnutls_pkcs12_verify_mac</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-12-API">PKCS 12 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fdeinit"><code>gnutls_pkcs7_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fdelete_005fcrl"><code>gnutls_pkcs7_delete_crl</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fdelete_005fcrt"><code>gnutls_pkcs7_delete_crt</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fexport"><code>gnutls_pkcs7_export</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fexport2"><code>gnutls_pkcs7_export2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fget_005fcrl_005fcount"><code>gnutls_pkcs7_get_crl_count</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fget_005fcrl_005fraw"><code>gnutls_pkcs7_get_crl_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fget_005fcrt_005fcount"><code>gnutls_pkcs7_get_crt_count</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fget_005fcrt_005fraw"><code>gnutls_pkcs7_get_crt_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fimport"><code>gnutls_pkcs7_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005finit"><code>gnutls_pkcs7_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fset_005fcrl"><code>gnutls_pkcs7_set_crl</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fset_005fcrl_005fraw"><code>gnutls_pkcs7_set_crl_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fset_005fcrt"><code>gnutls_pkcs7_set_crt</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpkcs7_005fset_005fcrt_005fraw"><code>gnutls_pkcs7_set_crt_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005falgorithm_005fget_005fname"><code>gnutls_pk_algorithm_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005fbits_005fto_005fsec_005fparam"><code>gnutls_pk_bits_to_sec_param</code></a>:</td><td> </td><td valign="top"><a href="#Selecting-cryptographic-key-sizes">Selecting cryptographic key sizes</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005fbits_005fto_005fsec_005fparam-1"><code>gnutls_pk_bits_to_sec_param</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005fget_005fid"><code>gnutls_pk_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005fget_005fname"><code>gnutls_pk_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005flist"><code>gnutls_pk_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpk_005fto_005fsign"><code>gnutls_pk_to_sign</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprf"><code>gnutls_prf</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprf_005fraw"><code>gnutls_prf_raw</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fcertificate_005ftype_005flist"><code>gnutls_priority_certificate_type_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fcompression_005flist"><code>gnutls_priority_compression_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fdeinit"><code>gnutls_priority_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fecc_005fcurve_005flist"><code>gnutls_priority_ecc_curve_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fget_005fcipher_005fsuite_005findex"><code>gnutls_priority_get_cipher_suite_index</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005finit"><code>gnutls_priority_init</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fprotocol_005flist"><code>gnutls_priority_protocol_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fset"><code>gnutls_priority_set</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fset_005fdirect"><code>gnutls_priority_set_direct</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpriority_005fsign_005flist"><code>gnutls_priority_sign_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fdecrypt_005fdata"><code>gnutls_privkey_decrypt_data</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fdecrypt_005fdata-1"><code>gnutls_privkey_decrypt_data</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fdeinit"><code>gnutls_privkey_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fget_005fpk_005falgorithm"><code>gnutls_privkey_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fget_005ftype"><code>gnutls_privkey_get_type</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fext"><code>gnutls_privkey_import_ext</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fext2"><code>gnutls_privkey_import_ext2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-private-keys">Abstract private keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fext2-1"><code>gnutls_privkey_import_ext2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fopenpgp"><code>gnutls_privkey_import_openpgp</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fopenpgp_005fraw"><code>gnutls_privkey_import_openpgp_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fpkcs11"><code>gnutls_privkey_import_pkcs11</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fpkcs11_005furl"><code>gnutls_privkey_import_pkcs11_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005ftpm_005fraw"><code>gnutls_privkey_import_tpm_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005ftpm_005furl"><code>gnutls_privkey_import_tpm_url</code></a>:</td><td> </td><td valign="top"><a href="#Using-keys">Using keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005ftpm_005furl-1"><code>gnutls_privkey_import_tpm_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005furl"><code>gnutls_privkey_import_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-private-keys">Abstract private keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005furl-1"><code>gnutls_privkey_import_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fx509"><code>gnutls_privkey_import_x509</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fx509_005fraw"><code>gnutls_privkey_import_x509_raw</code></a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fimport_005fx509_005fraw-1"><code>gnutls_privkey_import_x509_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005finit"><code>gnutls_privkey_init</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fset_005fpin_005ffunction"><code>gnutls_privkey_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fsign_005fdata"><code>gnutls_privkey_sign_data</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fsign_005fdata-1"><code>gnutls_privkey_sign_data</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fsign_005fhash"><code>gnutls_privkey_sign_hash</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprivkey_005fsign_005fhash-1"><code>gnutls_privkey_sign_hash</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprotocol_005fget_005fid"><code>gnutls_protocol_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprotocol_005fget_005fname"><code>gnutls_protocol_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprotocol_005fget_005fversion"><code>gnutls_protocol_get_version</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprotocol_005flist"><code>gnutls_protocol_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fprotocol_005fset_005fpriority"><code>gnutls_protocol_set_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fallocate_005fclient_005fcredentials"><code>gnutls_psk_allocate_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fallocate_005fserver_005fcredentials"><code>gnutls_psk_allocate_server_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fclient_005fget_005fhint"><code>gnutls_psk_client_get_hint</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005ffree_005fclient_005fcredentials"><code>gnutls_psk_free_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005ffree_005fserver_005fcredentials"><code>gnutls_psk_free_server_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fserver_005fget_005fusername"><code>gnutls_psk_server_get_username</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fclient_005fcredentials"><code>gnutls_psk_set_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction"><code>gnutls_psk_set_client_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#PSK-credentials">PSK credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fclient_005fcredentials_005ffunction-1"><code>gnutls_psk_set_client_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fparams_005ffunction"><code>gnutls_psk_set_params_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile"><code>gnutls_psk_set_server_credentials_file</code></a>:</td><td> </td><td valign="top"><a href="#PSK-credentials">PSK credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffile-1"><code>gnutls_psk_set_server_credentials_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005ffunction"><code>gnutls_psk_set_server_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fserver_005fcredentials_005fhint"><code>gnutls_psk_set_server_credentials_hint</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fserver_005fdh_005fparams"><code>gnutls_psk_set_server_dh_params</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpsk_005fset_005fserver_005fparams_005ffunction"><code>gnutls_psk_set_server_params_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fdeinit"><code>gnutls_pubkey_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fencrypt_005fdata"><code>gnutls_pubkey_encrypt_data</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fencrypt_005fdata-1"><code>gnutls_pubkey_encrypt_data</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fexport"><code>gnutls_pubkey_export</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fexport2"><code>gnutls_pubkey_export2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-public-keys">Abstract public keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fexport2-1"><code>gnutls_pubkey_export2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fkey_005fid"><code>gnutls_pubkey_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fkey_005fusage"><code>gnutls_pubkey_get_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fopenpgp_005fkey_005fid"><code>gnutls_pubkey_get_openpgp_key_id</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fpk_005falgorithm"><code>gnutls_pubkey_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fpk_005fdsa_005fraw"><code>gnutls_pubkey_get_pk_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fpk_005fecc_005fraw"><code>gnutls_pubkey_get_pk_ecc_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fpk_005fecc_005fx962"><code>gnutls_pubkey_get_pk_ecc_x962</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fpk_005frsa_005fraw"><code>gnutls_pubkey_get_pk_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fpreferred_005fhash_005falgorithm"><code>gnutls_pubkey_get_preferred_hash_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fget_005fverify_005falgorithm"><code>gnutls_pubkey_get_verify_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport"><code>gnutls_pubkey_import</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fdsa_005fraw"><code>gnutls_pubkey_import_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fecc_005fraw"><code>gnutls_pubkey_import_ecc_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fecc_005fx962"><code>gnutls_pubkey_import_ecc_x962</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fopenpgp"><code>gnutls_pubkey_import_openpgp</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fopenpgp_005fraw"><code>gnutls_pubkey_import_openpgp_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fpkcs11"><code>gnutls_pubkey_import_pkcs11</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fpkcs11_005furl"><code>gnutls_pubkey_import_pkcs11_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fprivkey"><code>gnutls_pubkey_import_privkey</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005frsa_005fraw"><code>gnutls_pubkey_import_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005ftpm_005fraw"><code>gnutls_pubkey_import_tpm_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005ftpm_005furl"><code>gnutls_pubkey_import_tpm_url</code></a>:</td><td> </td><td valign="top"><a href="#Using-keys">Using keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005ftpm_005furl-1"><code>gnutls_pubkey_import_tpm_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005furl"><code>gnutls_pubkey_import_url</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fx509"><code>gnutls_pubkey_import_x509</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fx509_005fcrq"><code>gnutls_pubkey_import_x509_crq</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fimport_005fx509_005fraw"><code>gnutls_pubkey_import_x509_raw</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005finit"><code>gnutls_pubkey_init</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fprint"><code>gnutls_pubkey_print</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fset_005fkey_005fusage"><code>gnutls_pubkey_set_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fset_005fpin_005ffunction"><code>gnutls_pubkey_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fverify_005fdata"><code>gnutls_pubkey_verify_data</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fverify_005fdata2"><code>gnutls_pubkey_verify_data2</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fverify_005fdata2-1"><code>gnutls_pubkey_verify_data2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fverify_005fhash"><code>gnutls_pubkey_verify_hash</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fverify_005fhash2"><code>gnutls_pubkey_verify_hash2</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fpubkey_005fverify_005fhash2-1"><code>gnutls_pubkey_verify_hash2</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frandom_005fart"><code>gnutls_random_art</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frange_005fsplit"><code>gnutls_range_split</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fcan_005fuse_005flength_005fhiding"><code>gnutls_record_can_use_length_hiding</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fcheck_005fpending"><code>gnutls_record_check_pending</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fcheck_005fpending-1"><code>gnutls_record_check_pending</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fcork"><code>gnutls_record_cork</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-data-transfer">Buffered data transfer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fcork-1"><code>gnutls_record_cork</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fdisable_005fpadding"><code>gnutls_record_disable_padding</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fget_005fdirection"><code>gnutls_record_get_direction</code></a>:</td><td> </td><td valign="top"><a href="#Asynchronous-operation">Asynchronous operation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fget_005fdirection-1"><code>gnutls_record_get_direction</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fget_005fdiscarded"><code>gnutls_record_get_discarded</code></a>:</td><td> </td><td valign="top"><a href="#Datagram-TLS-API">Datagram TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fget_005fmax_005fsize"><code>gnutls_record_get_max_size</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005frecv"><code>gnutls_record_recv</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005frecv-1"><code>gnutls_record_recv</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005frecv_005fseq"><code>gnutls_record_recv_seq</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005frecv_005fseq-1"><code>gnutls_record_recv_seq</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fsend"><code>gnutls_record_send</code></a>:</td><td> </td><td valign="top"><a href="#Data-transfer-and-termination">Data transfer and termination</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fsend-1"><code>gnutls_record_send</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fsend_005frange"><code>gnutls_record_send_range</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fset_005fmax_005fempty_005frecords"><code>gnutls_record_set_max_empty_records</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fset_005fmax_005fsize"><code>gnutls_record_set_max_size</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005fset_005ftimeout"><code>gnutls_record_set_timeout</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005funcork"><code>gnutls_record_uncork</code></a>:</td><td> </td><td valign="top"><a href="#Buffered-data-transfer">Buffered data transfer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frecord_005funcork-1"><code>gnutls_record_uncork</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frehandshake"><code>gnutls_rehandshake</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frnd"><code>gnutls_rnd</code></a>:</td><td> </td><td valign="top"><a href="#Random-number-generation">Random number generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frnd-1"><code>gnutls_rnd</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frnd_005frefresh"><code>gnutls_rnd_refresh</code></a>:</td><td> </td><td valign="top"><a href="#Cryptographic-API">Cryptographic API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fexport_005fget_005fmodulus_005fbits"><code>gnutls_rsa_export_get_modulus_bits</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fexport_005fget_005fpubkey"><code>gnutls_rsa_export_get_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fcpy"><code>gnutls_rsa_params_cpy</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fdeinit"><code>gnutls_rsa_params_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fexport_005fpkcs1"><code>gnutls_rsa_params_export_pkcs1</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fexport_005fraw"><code>gnutls_rsa_params_export_raw</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fgenerate2"><code>gnutls_rsa_params_generate2</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fimport_005fpkcs1"><code>gnutls_rsa_params_import_pkcs1</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005fimport_005fraw"><code>gnutls_rsa_params_import_raw</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005frsa_005fparams_005finit"><code>gnutls_rsa_params_init</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsafe_005frenegotiation_005fstatus"><code>gnutls_safe_renegotiation_status</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsec_005fparam_005fget_005fname"><code>gnutls_sec_param_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsec_005fparam_005fto_005fpk_005fbits"><code>gnutls_sec_param_to_pk_bits</code></a>:</td><td> </td><td valign="top"><a href="#Selecting-cryptographic-key-sizes">Selecting cryptographic key sizes</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsec_005fparam_005fto_005fpk_005fbits-1"><code>gnutls_sec_param_to_pk_bits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fserver_005fname_005fget"><code>gnutls_server_name_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fserver_005fname_005fset"><code>gnutls_server_name_set</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fchannel_005fbinding"><code>gnutls_session_channel_binding</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fenable_005fcompatibility_005fmode"><code>gnutls_session_enable_compatibility_mode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fforce_005fvalid"><code>gnutls_session_force_valid</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fget_005fdata"><code>gnutls_session_get_data</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fget_005fdata2"><code>gnutls_session_get_data2</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fget_005fid"><code>gnutls_session_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fget_005fid2"><code>gnutls_session_get_id2</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fget_005fptr"><code>gnutls_session_get_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fget_005frandom"><code>gnutls_session_get_random</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fis_005fresumed"><code>gnutls_session_is_resumed</code></a>:</td><td> </td><td valign="top"><a href="#Session-resumption">Session resumption</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fis_005fresumed-1"><code>gnutls_session_is_resumed</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fresumption_005frequested"><code>gnutls_session_resumption_requested</code></a>:</td><td> </td><td valign="top"><a href="#Session-resumption">Session resumption</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fresumption_005frequested-1"><code>gnutls_session_resumption_requested</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fset_005fdata"><code>gnutls_session_set_data</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fset_005fpremaster"><code>gnutls_session_set_premaster</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fset_005fptr"><code>gnutls_session_set_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fticket_005fenable_005fclient"><code>gnutls_session_ticket_enable_client</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fticket_005fenable_005fserver"><code>gnutls_session_ticket_enable_server</code></a>:</td><td> </td><td valign="top"><a href="#Session-resumption">Session resumption</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fticket_005fenable_005fserver-1"><code>gnutls_session_ticket_enable_server</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fticket_005fkey_005fgenerate"><code>gnutls_session_ticket_key_generate</code></a>:</td><td> </td><td valign="top"><a href="#Session-resumption">Session resumption</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsession_005fticket_005fkey_005fgenerate-1"><code>gnutls_session_ticket_key_generate</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fset_005fdefault_005fexport_005fpriority"><code>gnutls_set_default_export_priority</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fset_005fdefault_005fpriority"><code>gnutls_set_default_priority</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005falgorithm_005fget"><code>gnutls_sign_algorithm_get</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005falgorithm_005fget_005frequested"><code>gnutls_sign_algorithm_get_requested</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fcallback_005fget"><code>gnutls_sign_callback_get</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fcallback_005fset"><code>gnutls_sign_callback_set</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fget_005fhash_005falgorithm"><code>gnutls_sign_get_hash_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fget_005fid"><code>gnutls_sign_get_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fget_005fname"><code>gnutls_sign_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fget_005fpk_005falgorithm"><code>gnutls_sign_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005fis_005fsecure"><code>gnutls_sign_is_secure</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsign_005flist"><code>gnutls_sign_list</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fallocate_005fclient_005fcredentials"><code>gnutls_srp_allocate_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fallocate_005fserver_005fcredentials"><code>gnutls_srp_allocate_server_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fbase64_005fdecode"><code>gnutls_srp_base64_decode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fbase64_005fdecode_005falloc"><code>gnutls_srp_base64_decode_alloc</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fbase64_005fencode"><code>gnutls_srp_base64_encode</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fbase64_005fencode_005falloc"><code>gnutls_srp_base64_encode_alloc</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005ffree_005fclient_005fcredentials"><code>gnutls_srp_free_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005ffree_005fserver_005fcredentials"><code>gnutls_srp_free_server_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fserver_005fget_005fusername"><code>gnutls_srp_server_get_username</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fclient_005fcredentials"><code>gnutls_srp_set_client_credentials</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction"><code>gnutls_srp_set_client_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#SRP-credentials">SRP credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fclient_005fcredentials_005ffunction-1"><code>gnutls_srp_set_client_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fprime_005fbits"><code>gnutls_srp_set_prime_bits</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile"><code>gnutls_srp_set_server_credentials_file</code></a>:</td><td> </td><td valign="top"><a href="#SRP-credentials">SRP credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffile-1"><code>gnutls_srp_set_server_credentials_file</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction"><code>gnutls_srp_set_server_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#SRP-credentials">SRP credentials</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fset_005fserver_005fcredentials_005ffunction-1"><code>gnutls_srp_set_server_credentials_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fverifier"><code>gnutls_srp_verifier</code></a>:</td><td> </td><td valign="top"><a href="#Authentication-using-SRP">Authentication using SRP</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrp_005fverifier-1"><code>gnutls_srp_verifier</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fget_005fkeys"><code>gnutls_srtp_get_keys</code></a>:</td><td> </td><td valign="top"><a href="#SRTP">SRTP</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fget_005fkeys-1"><code>gnutls_srtp_get_keys</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fget_005fmki"><code>gnutls_srtp_get_mki</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fget_005fprofile_005fid"><code>gnutls_srtp_get_profile_id</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fget_005fprofile_005fname"><code>gnutls_srtp_get_profile_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fget_005fselected_005fprofile"><code>gnutls_srtp_get_selected_profile</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fset_005fmki"><code>gnutls_srtp_set_mki</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fset_005fprofile"><code>gnutls_srtp_set_profile</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsrtp_005fset_005fprofile_005fdirect"><code>gnutls_srtp_set_profile_direct</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fstore_005fcommitment"><code>gnutls_store_commitment</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fstore_005fcommitment-1"><code>gnutls_store_commitment</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fstore_005fpubkey"><code>gnutls_store_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fstore_005fpubkey-1"><code>gnutls_store_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fstrerror"><code>gnutls_strerror</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fstrerror_005fname"><code>gnutls_strerror_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fsupplemental_005fget_005fname"><code>gnutls_supplemental_get_name</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftdb_005fdeinit"><code>gnutls_tdb_deinit</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftdb_005finit"><code>gnutls_tdb_init</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftdb_005fset_005fstore_005fcommitment_005ffunc"><code>gnutls_tdb_set_store_commitment_func</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftdb_005fset_005fstore_005ffunc"><code>gnutls_tdb_set_store_func</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftdb_005fset_005fverify_005ffunc"><code>gnutls_tdb_set_verify_func</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fget_005fregistered"><code>gnutls_tpm_get_registered</code></a>:</td><td> </td><td valign="top"><a href="#TPM-API">TPM API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fkey_005flist_005fdeinit"><code>gnutls_tpm_key_list_deinit</code></a>:</td><td> </td><td valign="top"><a href="#TPM-API">TPM API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fkey_005flist_005fget_005furl"><code>gnutls_tpm_key_list_get_url</code></a>:</td><td> </td><td valign="top"><a href="#TPM-API">TPM API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fprivkey_005fdelete"><code>gnutls_tpm_privkey_delete</code></a>:</td><td> </td><td valign="top"><a href="#Key-generation">Key generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fprivkey_005fdelete-1"><code>gnutls_tpm_privkey_delete</code></a>:</td><td> </td><td valign="top"><a href="#Using-keys">Using keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fprivkey_005fdelete-2"><code>gnutls_tpm_privkey_delete</code></a>:</td><td> </td><td valign="top"><a href="#TPM-API">TPM API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fprivkey_005fgenerate"><code>gnutls_tpm_privkey_generate</code></a>:</td><td> </td><td valign="top"><a href="#Key-generation">Key generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftpm_005fprivkey_005fgenerate-1"><code>gnutls_tpm_privkey_generate</code></a>:</td><td> </td><td valign="top"><a href="#TPM-API">TPM API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fget_005fptr"><code>gnutls_transport_get_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fget_005fptr2"><code>gnutls_transport_get_ptr2</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005ferrno"><code>gnutls_transport_set_errno</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005ferrno-1"><code>gnutls_transport_set_errno</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005ferrno_005ffunction"><code>gnutls_transport_set_errno_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fptr"><code>gnutls_transport_set_ptr</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fptr2"><code>gnutls_transport_set_ptr2</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fptr2-1"><code>gnutls_transport_set_ptr2</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fpull_005ffunction"><code>gnutls_transport_set_pull_function</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fpull_005ffunction-1"><code>gnutls_transport_set_pull_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction"><code>gnutls_transport_set_pull_timeout_function</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction-1"><code>gnutls_transport_set_pull_timeout_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fpush_005ffunction"><code>gnutls_transport_set_push_function</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fpush_005ffunction-1"><code>gnutls_transport_set_push_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fvec_005fpush_005ffunction"><code>gnutls_transport_set_vec_push_function</code></a>:</td><td> </td><td valign="top"><a href="#Setting-up-the-transport-layer">Setting up the transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005ftransport_005fset_005fvec_005fpush_005ffunction-1"><code>gnutls_transport_set_vec_push_function</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005furl_005fis_005fsupported"><code>gnutls_url_is_supported</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-public-keys">Abstract public keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005furl_005fis_005fsupported-1"><code>gnutls_url_is_supported</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fverify_005fstored_005fpubkey"><code>gnutls_verify_stored_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fverify_005fstored_005fpubkey-1"><code>gnutls_verify_stored_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Core-TLS-API">Core TLS API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fcheck_005fissuer"><code>gnutls_x509_crl_check_issuer</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fdeinit"><code>gnutls_x509_crl_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fexport"><code>gnutls_x509_crl_export</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fexport2"><code>gnutls_x509_crl_export2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fgn_005fserial"><code>gnutls_x509_crl_get_authority_key_gn_serial</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fauthority_005fkey_005fid"><code>gnutls_x509_crl_get_authority_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fcount"><code>gnutls_x509_crl_get_crt_count</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial"><code>gnutls_x509_crl_get_crt_serial</code></a>:</td><td> </td><td valign="top"><a href="#PKIX-certificate-revocation-lists">PKIX certificate revocation lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fcrt_005fserial-1"><code>gnutls_x509_crl_get_crt_serial</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fdn_005foid"><code>gnutls_x509_crl_get_dn_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fextension_005fdata"><code>gnutls_x509_crl_get_extension_data</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fextension_005finfo"><code>gnutls_x509_crl_get_extension_info</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fextension_005foid"><code>gnutls_x509_crl_get_extension_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn"><code>gnutls_x509_crl_get_issuer_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fissuer_005fdn_005fby_005foid"><code>gnutls_x509_crl_get_issuer_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fnext_005fupdate"><code>gnutls_x509_crl_get_next_update</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fnumber"><code>gnutls_x509_crl_get_number</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fraw_005fissuer_005fdn"><code>gnutls_x509_crl_get_raw_issuer_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fsignature"><code>gnutls_x509_crl_get_signature</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fsignature_005falgorithm"><code>gnutls_x509_crl_get_signature_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fthis_005fupdate"><code>gnutls_x509_crl_get_this_update</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fget_005fversion"><code>gnutls_x509_crl_get_version</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fimport"><code>gnutls_x509_crl_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005finit"><code>gnutls_x509_crl_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005flist_005fimport"><code>gnutls_x509_crl_list_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005flist_005fimport2"><code>gnutls_x509_crl_list_import2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fprint"><code>gnutls_x509_crl_print</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fprivkey_005fsign"><code>gnutls_x509_crl_privkey_sign</code></a>:</td><td> </td><td valign="top"><a href="#PKIX-certificate-revocation-lists">PKIX certificate revocation lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fprivkey_005fsign-1"><code>gnutls_x509_crl_privkey_sign</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fauthority_005fkey_005fid"><code>gnutls_x509_crl_set_authority_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fcrt"><code>gnutls_x509_crl_set_crt</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fcrt_005fserial"><code>gnutls_x509_crl_set_crt_serial</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fnext_005fupdate"><code>gnutls_x509_crl_set_next_update</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fnumber"><code>gnutls_x509_crl_set_number</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fthis_005fupdate"><code>gnutls_x509_crl_set_this_update</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fset_005fversion"><code>gnutls_x509_crl_set_version</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fsign"><code>gnutls_x509_crl_sign</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fsign2"><code>gnutls_x509_crl_sign2</code></a>:</td><td> </td><td valign="top"><a href="#PKIX-certificate-revocation-lists">PKIX certificate revocation lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fsign2-1"><code>gnutls_x509_crl_sign2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrl_005fverify"><code>gnutls_x509_crl_verify</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fdeinit"><code>gnutls_x509_crq_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fexport"><code>gnutls_x509_crq_export</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fexport2"><code>gnutls_x509_crq_export2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fattribute_005fby_005foid"><code>gnutls_x509_crq_get_attribute_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fattribute_005fdata"><code>gnutls_x509_crq_get_attribute_data</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fattribute_005finfo"><code>gnutls_x509_crq_get_attribute_info</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fbasic_005fconstraints"><code>gnutls_x509_crq_get_basic_constraints</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fchallenge_005fpassword"><code>gnutls_x509_crq_get_challenge_password</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fdn"><code>gnutls_x509_crq_get_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fdn_005fby_005foid"><code>gnutls_x509_crq_get_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fdn_005foid"><code>gnutls_x509_crq_get_dn_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fextension_005fby_005foid"><code>gnutls_x509_crq_get_extension_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fextension_005fdata"><code>gnutls_x509_crq_get_extension_data</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fextension_005finfo"><code>gnutls_x509_crq_get_extension_info</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fkey_005fid"><code>gnutls_x509_crq_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fkey_005fpurpose_005foid"><code>gnutls_x509_crq_get_key_purpose_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fkey_005frsa_005fraw"><code>gnutls_x509_crq_get_key_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fkey_005fusage"><code>gnutls_x509_crq_get_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fpk_005falgorithm"><code>gnutls_x509_crq_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fprivate_005fkey_005fusage_005fperiod"><code>gnutls_x509_crq_get_private_key_usage_period</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fname"><code>gnutls_x509_crq_get_subject_alt_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fsubject_005falt_005fothername_005foid"><code>gnutls_x509_crq_get_subject_alt_othername_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fget_005fversion"><code>gnutls_x509_crq_get_version</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fimport"><code>gnutls_x509_crq_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005finit"><code>gnutls_x509_crq_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fprint"><code>gnutls_x509_crq_print</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fprivkey_005fsign"><code>gnutls_x509_crq_privkey_sign</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fattribute_005fby_005foid"><code>gnutls_x509_crq_set_attribute_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fbasic_005fconstraints"><code>gnutls_x509_crq_set_basic_constraints</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fchallenge_005fpassword"><code>gnutls_x509_crq_set_challenge_password</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fdn"><code>gnutls_x509_crq_set_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fdn_005fby_005foid"><code>gnutls_x509_crq_set_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fkey"><code>gnutls_x509_crq_set_key</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-10-certificate-requests">PKCS 10 certificate requests</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fkey-1"><code>gnutls_x509_crq_set_key</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fkey_005fpurpose_005foid"><code>gnutls_x509_crq_set_key_purpose_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fkey_005frsa_005fraw"><code>gnutls_x509_crq_set_key_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fkey_005fusage"><code>gnutls_x509_crq_set_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fprivate_005fkey_005fusage_005fperiod"><code>gnutls_x509_crq_set_private_key_usage_period</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fpubkey"><code>gnutls_x509_crq_set_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fpubkey-1"><code>gnutls_x509_crq_set_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fsubject_005falt_005fname"><code>gnutls_x509_crq_set_subject_alt_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fset_005fversion"><code>gnutls_x509_crq_set_version</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fsign"><code>gnutls_x509_crq_sign</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fsign2"><code>gnutls_x509_crq_sign2</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-10-certificate-requests">PKCS 10 certificate requests</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fsign2-1"><code>gnutls_x509_crq_sign2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrq_005fverify"><code>gnutls_x509_crq_verify</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fcheck_005fhostname"><code>gnutls_x509_crt_check_hostname</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fcheck_005fissuer"><code>gnutls_x509_crt_check_issuer</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fcheck_005frevocation"><code>gnutls_x509_crt_check_revocation</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fcpy_005fcrl_005fdist_005fpoints"><code>gnutls_x509_crt_cpy_crl_dist_points</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fdeinit"><code>gnutls_x509_crt_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fexport"><code>gnutls_x509_crt_export</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fexport2"><code>gnutls_x509_crt_export2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005factivation_005ftime"><code>gnutls_x509_crt_get_activation_time</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fauthority_005finfo_005faccess"><code>gnutls_x509_crt_get_authority_info_access</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fgn_005fserial"><code>gnutls_x509_crt_get_authority_key_gn_serial</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fauthority_005fkey_005fid"><code>gnutls_x509_crt_get_authority_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fbasic_005fconstraints"><code>gnutls_x509_crt_get_basic_constraints</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fca_005fstatus"><code>gnutls_x509_crt_get_ca_status</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fcrl_005fdist_005fpoints"><code>gnutls_x509_crt_get_crl_dist_points</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn"><code>gnutls_x509_crt_get_dn</code></a>:</td><td> </td><td valign="top"><a href="#X_002e509-distinguished-names">X.509 distinguished names</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn-1"><code>gnutls_x509_crt_get_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid"><code>gnutls_x509_crt_get_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X_002e509-distinguished-names">X.509 distinguished names</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn_005fby_005foid-1"><code>gnutls_x509_crt_get_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn_005foid"><code>gnutls_x509_crt_get_dn_oid</code></a>:</td><td> </td><td valign="top"><a href="#X_002e509-distinguished-names">X.509 distinguished names</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fdn_005foid-1"><code>gnutls_x509_crt_get_dn_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fexpiration_005ftime"><code>gnutls_x509_crt_get_expiration_time</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fextension_005fby_005foid"><code>gnutls_x509_crt_get_extension_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fextension_005fdata"><code>gnutls_x509_crt_get_extension_data</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fextension_005finfo"><code>gnutls_x509_crt_get_extension_info</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fextension_005foid"><code>gnutls_x509_crt_get_extension_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005ffingerprint"><code>gnutls_x509_crt_get_fingerprint</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer"><code>gnutls_x509_crt_get_issuer</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname"><code>gnutls_x509_crt_get_issuer_alt_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fname2"><code>gnutls_x509_crt_get_issuer_alt_name2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005falt_005fothername_005foid"><code>gnutls_x509_crt_get_issuer_alt_othername_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn"><code>gnutls_x509_crt_get_issuer_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005fby_005foid"><code>gnutls_x509_crt_get_issuer_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005fdn_005foid"><code>gnutls_x509_crt_get_issuer_dn_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fissuer_005funique_005fid"><code>gnutls_x509_crt_get_issuer_unique_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fid"><code>gnutls_x509_crt_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X_002e509-public-and-private-keys">X.509 public and private keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fid-1"><code>gnutls_x509_crt_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fpurpose_005foid"><code>gnutls_x509_crt_get_key_purpose_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fkey_005fusage"><code>gnutls_x509_crt_get_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpk_005falgorithm"><code>gnutls_x509_crt_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpk_005fdsa_005fraw"><code>gnutls_x509_crt_get_pk_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpk_005frsa_005fraw"><code>gnutls_x509_crt_get_pk_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpolicy"><code>gnutls_x509_crt_get_policy</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fpreferred_005fhash_005falgorithm"><code>gnutls_x509_crt_get_preferred_hash_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fprivate_005fkey_005fusage_005fperiod"><code>gnutls_x509_crt_get_private_key_usage_period</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fproxy"><code>gnutls_x509_crt_get_proxy</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fraw_005fdn"><code>gnutls_x509_crt_get_raw_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fraw_005fissuer_005fdn"><code>gnutls_x509_crt_get_raw_issuer_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fserial"><code>gnutls_x509_crt_get_serial</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsignature"><code>gnutls_x509_crt_get_signature</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsignature_005falgorithm"><code>gnutls_x509_crt_get_signature_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject"><code>gnutls_x509_crt_get_subject</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname"><code>gnutls_x509_crt_get_subject_alt_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fname2"><code>gnutls_x509_crt_get_subject_alt_name2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005falt_005fothername_005foid"><code>gnutls_x509_crt_get_subject_alt_othername_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005fkey_005fid"><code>gnutls_x509_crt_get_subject_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fsubject_005funique_005fid"><code>gnutls_x509_crt_get_subject_unique_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fverify_005falgorithm"><code>gnutls_x509_crt_get_verify_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fget_005fversion"><code>gnutls_x509_crt_get_version</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fimport"><code>gnutls_x509_crt_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fimport_005fpkcs11"><code>gnutls_x509_crt_import_pkcs11</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fimport_005fpkcs11_005furl"><code>gnutls_x509_crt_import_pkcs11_url</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005finit"><code>gnutls_x509_crt_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005flist_005fimport"><code>gnutls_x509_crt_list_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005flist_005fimport2"><code>gnutls_x509_crt_list_import2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005flist_005fimport_005fpkcs11"><code>gnutls_x509_crt_list_import_pkcs11</code></a>:</td><td> </td><td valign="top"><a href="#PKCS-11-API">PKCS 11 API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005flist_005fverify"><code>gnutls_x509_crt_list_verify</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fprint"><code>gnutls_x509_crt_print</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fprivkey_005fsign"><code>gnutls_x509_crt_privkey_sign</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005factivation_005ftime"><code>gnutls_x509_crt_set_activation_time</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fauthority_005finfo_005faccess"><code>gnutls_x509_crt_set_authority_info_access</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fauthority_005fkey_005fid"><code>gnutls_x509_crt_set_authority_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fbasic_005fconstraints"><code>gnutls_x509_crt_set_basic_constraints</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fca_005fstatus"><code>gnutls_x509_crt_set_ca_status</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints"><code>gnutls_x509_crt_set_crl_dist_points</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fcrl_005fdist_005fpoints2"><code>gnutls_x509_crt_set_crl_dist_points2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fcrq"><code>gnutls_x509_crt_set_crq</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fcrq_005fextensions"><code>gnutls_x509_crt_set_crq_extensions</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fdn"><code>gnutls_x509_crt_set_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fdn_005fby_005foid"><code>gnutls_x509_crt_set_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fexpiration_005ftime"><code>gnutls_x509_crt_set_expiration_time</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fextension_005fby_005foid"><code>gnutls_x509_crt_set_extension_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn"><code>gnutls_x509_crt_set_issuer_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fissuer_005fdn_005fby_005foid"><code>gnutls_x509_crt_set_issuer_dn_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fkey"><code>gnutls_x509_crt_set_key</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fkey_005fpurpose_005foid"><code>gnutls_x509_crt_set_key_purpose_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fkey_005fusage"><code>gnutls_x509_crt_set_key_usage</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fpin_005ffunction"><code>gnutls_x509_crt_set_pin_function</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fpolicy"><code>gnutls_x509_crt_set_policy</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fprivate_005fkey_005fusage_005fperiod"><code>gnutls_x509_crt_set_private_key_usage_period</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fproxy"><code>gnutls_x509_crt_set_proxy</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fproxy_005fdn"><code>gnutls_x509_crt_set_proxy_dn</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fpubkey"><code>gnutls_x509_crt_set_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Operations">Operations</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fpubkey-1"><code>gnutls_x509_crt_set_pubkey</code></a>:</td><td> </td><td valign="top"><a href="#Abstract-key-API">Abstract key API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fserial"><code>gnutls_x509_crt_set_serial</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fsubject_005falternative_005fname"><code>gnutls_x509_crt_set_subject_alternative_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fsubject_005falt_005fname"><code>gnutls_x509_crt_set_subject_alt_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fsubject_005fkey_005fid"><code>gnutls_x509_crt_set_subject_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fset_005fversion"><code>gnutls_x509_crt_set_version</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fsign"><code>gnutls_x509_crt_sign</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fsign2"><code>gnutls_x509_crt_sign2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fverify"><code>gnutls_x509_crt_verify</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fverify_005fdata"><code>gnutls_x509_crt_verify_data</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fcrt_005fverify_005fhash"><code>gnutls_x509_crt_verify_hash</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005fdeinit"><code>gnutls_x509_dn_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005fexport"><code>gnutls_x509_dn_export</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005fexport2"><code>gnutls_x509_dn_export2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005fget_005frdn_005fava"><code>gnutls_x509_dn_get_rdn_ava</code></a>:</td><td> </td><td valign="top"><a href="#X_002e509-distinguished-names">X.509 distinguished names</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005fget_005frdn_005fava-1"><code>gnutls_x509_dn_get_rdn_ava</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005fimport"><code>gnutls_x509_dn_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005finit"><code>gnutls_x509_dn_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005foid_005fknown"><code>gnutls_x509_dn_oid_known</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fdn_005foid_005fname"><code>gnutls_x509_dn_oid_name</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fpolicy_005frelease"><code>gnutls_x509_policy_release</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fcpy"><code>gnutls_x509_privkey_cpy</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fdeinit"><code>gnutls_x509_privkey_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport"><code>gnutls_x509_privkey_export</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport2"><code>gnutls_x509_privkey_export2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport2_005fpkcs8"><code>gnutls_x509_privkey_export2_pkcs8</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005fdsa_005fraw"><code>gnutls_x509_privkey_export_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005fecc_005fraw"><code>gnutls_x509_privkey_export_ecc_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005fpkcs8"><code>gnutls_x509_privkey_export_pkcs8</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw"><code>gnutls_x509_privkey_export_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fexport_005frsa_005fraw2"><code>gnutls_x509_privkey_export_rsa_raw2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005ffix"><code>gnutls_x509_privkey_fix</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fgenerate"><code>gnutls_x509_privkey_generate</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fget_005fkey_005fid"><code>gnutls_x509_privkey_get_key_id</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm"><code>gnutls_x509_privkey_get_pk_algorithm</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fget_005fpk_005falgorithm2"><code>gnutls_x509_privkey_get_pk_algorithm2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport"><code>gnutls_x509_privkey_import</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport2"><code>gnutls_x509_privkey_import2</code></a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport2-1"><code>gnutls_x509_privkey_import2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fdsa_005fraw"><code>gnutls_x509_privkey_import_dsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fecc_005fraw"><code>gnutls_x509_privkey_import_ecc_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fopenssl"><code>gnutls_x509_privkey_import_openssl</code></a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fopenssl-1"><code>gnutls_x509_privkey_import_openssl</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005fpkcs8"><code>gnutls_x509_privkey_import_pkcs8</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw"><code>gnutls_x509_privkey_import_rsa_raw</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fimport_005frsa_005fraw2"><code>gnutls_x509_privkey_import_rsa_raw2</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005finit"><code>gnutls_x509_privkey_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fsec_005fparam"><code>gnutls_x509_privkey_sec_param</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fsign_005fdata"><code>gnutls_x509_privkey_sign_data</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fsign_005fhash"><code>gnutls_x509_privkey_sign_hash</code></a>:</td><td> </td><td valign="top"><a href="#Compatibility-API">Compatibility API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005fprivkey_005fverify_005fparams"><code>gnutls_x509_privkey_verify_params</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005frdn_005fget"><code>gnutls_x509_rdn_get</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005frdn_005fget_005fby_005foid"><code>gnutls_x509_rdn_get_by_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005frdn_005fget_005foid"><code>gnutls_x509_rdn_get_oid</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcas"><code>gnutls_x509_trust_list_add_cas</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcas-1"><code>gnutls_x509_trust_list_add_cas</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcrls"><code>gnutls_x509_trust_list_add_crls</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fcrls-1"><code>gnutls_x509_trust_list_add_crls</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt"><code>gnutls_x509_trust_list_add_named_crt</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fnamed_005fcrt-1"><code>gnutls_x509_trust_list_add_named_crt</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fsystem_005ftrust"><code>gnutls_x509_trust_list_add_system_trust</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005fsystem_005ftrust-1"><code>gnutls_x509_trust_list_add_system_trust</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005ffile"><code>gnutls_x509_trust_list_add_trust_file</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005ffile-1"><code>gnutls_x509_trust_list_add_trust_file</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005fmem"><code>gnutls_x509_trust_list_add_trust_mem</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fadd_005ftrust_005fmem-1"><code>gnutls_x509_trust_list_add_trust_mem</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fdeinit"><code>gnutls_x509_trust_list_deinit</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fget_005fissuer"><code>gnutls_x509_trust_list_get_issuer</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005finit"><code>gnutls_x509_trust_list_init</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt"><code>gnutls_x509_trust_list_verify_crt</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fverify_005fcrt-1"><code>gnutls_x509_trust_list_verify_crt</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt"><code>gnutls_x509_trust_list_verify_named_crt</code></a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_005fx509_005ftrust_005flist_005fverify_005fnamed_005fcrt-1"><code>gnutls_x509_trust_list_verify_named_crt</code></a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Function-and-Data-Index_fn_letter-D"><b>D</b></a>
<a class="summary-letter" href="#Function-and-Data-Index_fn_letter-G"><b>G</b></a>
</td></tr></table>
<hr>
<a name="Concept-Index"></a>
<div class="header">
<p>
Previous: <a href="#Function-and-Data-Index" accesskey="p" rel="previous">Function and Data Index</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Concept-Index-1"></a>
<h2 class="unnumbered">Concept Index</h2>
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-G"><b>G</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-U"><b>U</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-X"><b>X</b></a>
</td></tr></table>
<table class="index-cp" border="0">
<tr><td></td><th align="left">Index Entry</th><td> </td><th align="left"> Section</th></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-A">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-abstract-types">abstract types</a>:</td><td> </td><td valign="top"><a href="#Abstract-key-types">Abstract key types</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-alert-protocol">alert protocol</a>:</td><td> </td><td valign="top"><a href="#The-TLS-Alert-Protocol">The TLS Alert Protocol</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-anonymous-authentication">anonymous authentication</a>:</td><td> </td><td valign="top"><a href="#Anonymous-authentication">Anonymous authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-API-reference">API reference</a>:</td><td> </td><td valign="top"><a href="#API-reference">API reference</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-authentication-methods">authentication methods</a>:</td><td> </td><td valign="top"><a href="#Authentication-methods">Authentication methods</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-B">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-bad_005frecord_005fmac">bad_record_mac</a>:</td><td> </td><td valign="top"><a href="#On-Record-Padding">On Record Padding</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-C">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-callback-functions">callback functions</a>:</td><td> </td><td valign="top"><a href="#Callback-functions">Callback functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certificate-authentication">certificate authentication</a>:</td><td> </td><td valign="top"><a href="#Certificate-authentication">Certificate authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certificate-authentication-1">certificate authentication</a>:</td><td> </td><td valign="top"><a href="#More-on-certificate-authentication">More on certificate authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certificate-requests">certificate requests</a>:</td><td> </td><td valign="top"><a href="#PKCS-10-certificate-requests">PKCS 10 certificate requests</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certificate-revocation-lists">certificate revocation lists</a>:</td><td> </td><td valign="top"><a href="#PKIX-certificate-revocation-lists">PKIX certificate revocation lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certificate-status">certificate status</a>:</td><td> </td><td valign="top"><a href="#OCSP-certificate-status-checking">OCSP certificate status checking</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Certificate-status-request">Certificate status request</a>:</td><td> </td><td valign="top"><a href="#OCSP-status-request">OCSP status request</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Certificate-verification">Certificate verification</a>:</td><td> </td><td valign="top"><a href="#Advanced-certificate-verification">Advanced certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certtool"><code>certtool</code></a>:</td><td> </td><td valign="top"><a href="#certtool-Invocation">certtool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-certtool-help">certtool help</a>:</td><td> </td><td valign="top"><a href="#certtool-Invocation">certtool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-channel-bindings">channel bindings</a>:</td><td> </td><td valign="top"><a href="#Channel-Bindings">Channel Bindings</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-ciphersuites">ciphersuites</a>:</td><td> </td><td valign="top"><a href="#Supported-ciphersuites">Supported ciphersuites</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-client-certificate-authentication">client certificate authentication</a>:</td><td> </td><td valign="top"><a href="#Client-Authentication">Client Authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-compression-algorithms">compression algorithms</a>:</td><td> </td><td valign="top"><a href="#Compression-algorithms-used-in-the-record-layer">Compression algorithms used in the record layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-contributing">contributing</a>:</td><td> </td><td valign="top"><a href="#Contributing">Contributing</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-CRL">CRL</a>:</td><td> </td><td valign="top"><a href="#PKIX-certificate-revocation-lists">PKIX certificate revocation lists</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-D">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-DANE">DANE</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-DANE">Verifying a certificate using DANE</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-DANE-1">DANE</a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-danetool"><code>danetool</code></a>:</td><td> </td><td valign="top"><a href="#danetool-Invocation">danetool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-danetool-help">danetool help</a>:</td><td> </td><td valign="top"><a href="#danetool-Invocation">danetool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-digital-signatures">digital signatures</a>:</td><td> </td><td valign="top"><a href="#Digital-signatures">Digital signatures</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-DNSSEC">DNSSEC</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-DANE">Verifying a certificate using DANE</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-DNSSEC-1">DNSSEC</a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-download">download</a>:</td><td> </td><td valign="top"><a href="#Downloading-and-installing">Downloading and installing</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-E">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-Encrypted-keys">Encrypted keys</a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-encryption-algorithms">encryption algorithms</a>:</td><td> </td><td valign="top"><a href="#Encryption-algorithms">Encryption algorithms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-error-codes">error codes</a>:</td><td> </td><td valign="top"><a href="#Error-codes">Error codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-example-programs">example programs</a>:</td><td> </td><td valign="top"><a href="#GnuTLS-application-examples">GnuTLS application examples</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-examples">examples</a>:</td><td> </td><td valign="top"><a href="#GnuTLS-application-examples">GnuTLS application examples</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-exporting-keying-material">exporting keying material</a>:</td><td> </td><td valign="top"><a href="#Keying-Material-Exporters">Keying Material Exporters</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-F">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-FDL_002c-GNU-Free-Documentation-License">FDL, GNU Free Documentation License</a>:</td><td> </td><td valign="top"><a href="#Copying-Information">Copying Information</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-G">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-generating-parameters">generating parameters</a>:</td><td> </td><td valign="top"><a href="#Parameter-generation">Parameter generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_002dcli"><code>gnutls-cli</code></a>:</td><td> </td><td valign="top"><a href="#gnutls_002dcli-Invocation">gnutls-cli Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_002dcli-help">gnutls-cli help</a>:</td><td> </td><td valign="top"><a href="#gnutls_002dcli-Invocation">gnutls-cli Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_002dcli_002ddebug"><code>gnutls-cli-debug</code></a>:</td><td> </td><td valign="top"><a href="#gnutls_002dcli_002ddebug-Invocation">gnutls-cli-debug Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_002dcli_002ddebug-help">gnutls-cli-debug help</a>:</td><td> </td><td valign="top"><a href="#gnutls_002dcli_002ddebug-Invocation">gnutls-cli-debug Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_002dserv"><code>gnutls-serv</code></a>:</td><td> </td><td valign="top"><a href="#gnutls_002dserv-Invocation">gnutls-serv Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-gnutls_002dserv-help">gnutls-serv help</a>:</td><td> </td><td valign="top"><a href="#gnutls_002dserv-Invocation">gnutls-serv Invocation</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-H">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-hacking">hacking</a>:</td><td> </td><td valign="top"><a href="#Contributing">Contributing</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-handshake-protocol">handshake protocol</a>:</td><td> </td><td valign="top"><a href="#The-TLS-Handshake-Protocol">The TLS Handshake Protocol</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-hardware-security-modules">hardware security modules</a>:</td><td> </td><td valign="top"><a href="#Smart-cards-and-HSMs">Smart cards and HSMs</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-hardware-tokens">hardware tokens</a>:</td><td> </td><td valign="top"><a href="#Smart-cards-and-HSMs">Smart cards and HSMs</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-hash-functions">hash functions</a>:</td><td> </td><td valign="top"><a href="#Hash-and-HMAC-functions">Hash and HMAC functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-heartbeat">heartbeat</a>:</td><td> </td><td valign="top"><a href="#HeartBeat">HeartBeat</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-HMAC-functions">HMAC functions</a>:</td><td> </td><td valign="top"><a href="#Hash-and-HMAC-functions">Hash and HMAC functions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-I">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-installation">installation</a>:</td><td> </td><td valign="top"><a href="#Downloading-and-installing">Downloading and installing</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-internal-architecture">internal architecture</a>:</td><td> </td><td valign="top"><a href="#Internal-architecture-of-GnuTLS">Internal architecture of GnuTLS</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-K">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-Key-pinning">Key pinning</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Key-pinning-1">Key pinning</a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-key-sizes">key sizes</a>:</td><td> </td><td valign="top"><a href="#Selecting-cryptographic-key-sizes">Selecting cryptographic key sizes</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-keying-material-exporters">keying material exporters</a>:</td><td> </td><td valign="top"><a href="#Keying-Material-Exporters">Keying Material Exporters</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-M">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-maximum-fragment-length">maximum fragment length</a>:</td><td> </td><td valign="top"><a href="#Maximum-fragment-length-negotiation">Maximum fragment length negotiation</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-O">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-OCSP">OCSP</a>:</td><td> </td><td valign="top"><a href="#OCSP-certificate-status-checking">OCSP certificate status checking</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OCSP-Functions">OCSP Functions</a>:</td><td> </td><td valign="top"><a href="#OCSP-API">OCSP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OCSP-status-request">OCSP status request</a>:</td><td> </td><td valign="top"><a href="#OCSP-status-request">OCSP status request</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-ocsptool"><code>ocsptool</code></a>:</td><td> </td><td valign="top"><a href="#ocsptool-Invocation">ocsptool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-ocsptool-help">ocsptool help</a>:</td><td> </td><td valign="top"><a href="#ocsptool-Invocation">ocsptool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Online-Certificate-Status-Protocol">Online Certificate Status Protocol</a>:</td><td> </td><td valign="top"><a href="#OCSP-certificate-status-checking">OCSP certificate status checking</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenPGP-API">OpenPGP API</a>:</td><td> </td><td valign="top"><a href="#OpenPGP-API">OpenPGP API</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenPGP-certificates">OpenPGP certificates</a>:</td><td> </td><td valign="top"><a href="#OpenPGP-certificates">OpenPGP certificates</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenPGP-server">OpenPGP server</a>:</td><td> </td><td valign="top"><a href="#Echo-server-with-OpenPGP-authentication">Echo server with OpenPGP authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenSSL">OpenSSL</a>:</td><td> </td><td valign="top"><a href="#Compatibility-with-the-OpenSSL-library">Compatibility with the OpenSSL library</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-OpenSSL-encrypted-keys">OpenSSL encrypted keys</a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-P">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-p11tool"><code>p11tool</code></a>:</td><td> </td><td valign="top"><a href="#p11tool-Invocation">p11tool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-p11tool-help">p11tool help</a>:</td><td> </td><td valign="top"><a href="#p11tool-Invocation">p11tool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-parameter-generation">parameter generation</a>:</td><td> </td><td valign="top"><a href="#Parameter-generation">Parameter generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-PCT">PCT</a>:</td><td> </td><td valign="top"><a href="#On-SSL-2-and-older-protocols">On SSL 2 and older protocols</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-PKCS-_002310">PKCS #10</a>:</td><td> </td><td valign="top"><a href="#PKCS-10-certificate-requests">PKCS 10 certificate requests</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-PKCS-_002311-tokens">PKCS #11 tokens</a>:</td><td> </td><td valign="top"><a href="#Smart-cards-and-HSMs">Smart cards and HSMs</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-PKCS-_002312">PKCS #12</a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-PKCS-_00238">PKCS #8</a>:</td><td> </td><td valign="top"><a href="#Managing-encrypted-keys">Managing encrypted keys</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Priority-strings">Priority strings</a>:</td><td> </td><td valign="top"><a href="#Priority-Strings">Priority Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-PSK-authentication">PSK authentication</a>:</td><td> </td><td valign="top"><a href="#Authentication-using-PSK">Authentication using PSK</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-psktool"><code>psktool</code></a>:</td><td> </td><td valign="top"><a href="#psktool-Invocation">psktool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-psktool-help">psktool help</a>:</td><td> </td><td valign="top"><a href="#psktool-Invocation">psktool Invocation</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-R">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-random-numbers">random numbers</a>:</td><td> </td><td valign="top"><a href="#Random-number-generation">Random number generation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-record-padding">record padding</a>:</td><td> </td><td valign="top"><a href="#On-Record-Padding">On Record Padding</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-record-protocol">record protocol</a>:</td><td> </td><td valign="top"><a href="#The-TLS-record-protocol">The TLS record protocol</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-renegotiation">renegotiation</a>:</td><td> </td><td valign="top"><a href="#Safe-renegotiation">Safe renegotiation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-reporting-bugs">reporting bugs</a>:</td><td> </td><td valign="top"><a href="#Bug-Reports">Bug Reports</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-resuming-sessions">resuming sessions</a>:</td><td> </td><td valign="top"><a href="#Resuming-Sessions">Resuming Sessions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-resuming-sessions-1">resuming sessions</a>:</td><td> </td><td valign="top"><a href="#Session-resumption">Session resumption</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-S">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-safe-renegotiation">safe renegotiation</a>:</td><td> </td><td valign="top"><a href="#Safe-renegotiation">Safe renegotiation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Secure-RTP">Secure RTP</a>:</td><td> </td><td valign="top"><a href="#SRTP">SRTP</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-server-name-indication">server name indication</a>:</td><td> </td><td valign="top"><a href="#Server-name-indication">Server name indication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-session-resumption">session resumption</a>:</td><td> </td><td valign="top"><a href="#Resuming-Sessions">Resuming Sessions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-session-resumption-1">session resumption</a>:</td><td> </td><td valign="top"><a href="#Session-resumption">Session resumption</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-session-tickets">session tickets</a>:</td><td> </td><td valign="top"><a href="#Session-tickets">Session tickets</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Smart-card-example">Smart card example</a>:</td><td> </td><td valign="top"><a href="#Client-using-a-smart-card-with-TLS">Client using a smart card with TLS</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-smart-cards">smart cards</a>:</td><td> </td><td valign="top"><a href="#Smart-cards-and-HSMs">Smart cards and HSMs</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SRP-authentication">SRP authentication</a>:</td><td> </td><td valign="top"><a href="#Authentication-using-SRP">Authentication using SRP</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-srptool"><code>srptool</code></a>:</td><td> </td><td valign="top"><a href="#srptool-Invocation">srptool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-srptool-help">srptool help</a>:</td><td> </td><td valign="top"><a href="#srptool-Invocation">srptool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SRTP">SRTP</a>:</td><td> </td><td valign="top"><a href="#SRTP">SRTP</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SSH_002dstyle-authentication">SSH-style authentication</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SSH_002dstyle-authentication-1">SSH-style authentication</a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-SSL-2">SSL 2</a>:</td><td> </td><td valign="top"><a href="#On-SSL-2-and-older-protocols">On SSL 2 and older protocols</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-symmetric-cryptography">symmetric cryptography</a>:</td><td> </td><td valign="top"><a href="#Encryption-algorithms">Encryption algorithms</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-symmetric-encryption-algorithms">symmetric encryption algorithms</a>:</td><td> </td><td valign="top"><a href="#Encryption-algorithms-used-in-the-record-layer">Encryption algorithms used in the record layer</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-T">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-thread-safety">thread safety</a>:</td><td> </td><td valign="top"><a href="#Thread-safety">Thread safety</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tickets">tickets</a>:</td><td> </td><td valign="top"><a href="#Session-tickets">Session tickets</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLS-extensions">TLS extensions</a>:</td><td> </td><td valign="top"><a href="#TLS-Extensions">TLS Extensions</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLS-extensions-1">TLS extensions</a>:</td><td> </td><td valign="top"><a href="#Maximum-fragment-length-negotiation">Maximum fragment length negotiation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLS-extensions-2">TLS extensions</a>:</td><td> </td><td valign="top"><a href="#Server-name-indication">Server name indication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLS-extensions-3">TLS extensions</a>:</td><td> </td><td valign="top"><a href="#Session-tickets">Session tickets</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLS-extensions-4">TLS extensions</a>:</td><td> </td><td valign="top"><a href="#HeartBeat">HeartBeat</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TLS-layers">TLS layers</a>:</td><td> </td><td valign="top"><a href="#TLS-layers">TLS layers</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-TPM">TPM</a>:</td><td> </td><td valign="top"><a href="#Trusted-Platform-Module">Trusted Platform Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tpmtool"><code>tpmtool</code></a>:</td><td> </td><td valign="top"><a href="#tpmtool-Invocation">tpmtool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-tpmtool-help">tpmtool help</a>:</td><td> </td><td valign="top"><a href="#tpmtool-Invocation">tpmtool Invocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-transport-layer">transport layer</a>:</td><td> </td><td valign="top"><a href="#The-transport-layer">The transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-transport-protocol">transport protocol</a>:</td><td> </td><td valign="top"><a href="#The-transport-layer">The transport layer</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Trust-on-first-use">Trust on first use</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-Trust-on-first-use-1">Trust on first use</a>:</td><td> </td><td valign="top"><a href="#Certificate-verification">Certificate verification</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-trusted-platform-module">trusted platform module</a>:</td><td> </td><td valign="top"><a href="#Trusted-Platform-Module">Trusted Platform Module</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-U">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-upgrading">upgrading</a>:</td><td> </td><td valign="top"><a href="#Upgrading-from-previous-versions">Upgrading from previous versions</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-V">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-verifying-certificate-paths">verifying certificate paths</a>:</td><td> </td><td valign="top"><a href="#Verifying-X_002e509-certificate-paths">Verifying X.509 certificate paths</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-verifying-certificate-paths-1">verifying certificate paths</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-in-the-context-of-TLS-session">Verifying a certificate in the context of TLS session</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-verifying-certificate-paths-2">verifying certificate paths</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-trust-on-first-use-authentication">Verifying a certificate using trust on first use authentication</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-verifying-certificate-paths-3">verifying certificate paths</a>:</td><td> </td><td valign="top"><a href="#Verifying-a-certificate-using-DANE">Verifying a certificate using DANE</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th><a name="Concept-Index_cp_letter-X">X</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-X_002e509-certificates">X.509 certificates</a>:</td><td> </td><td valign="top"><a href="#X_002e509-certificates">X.509 certificates</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-X_002e509-distinguished-name">X.509 distinguished name</a>:</td><td> </td><td valign="top"><a href="#X_002e509-distinguished-names">X.509 distinguished names</a></td></tr>
<tr><td></td><td valign="top"><a href="#index-X_002e509-Functions">X.509 Functions</a>:</td><td> </td><td valign="top"><a href="#X509-certificate-API">X509 certificate API</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a class="summary-letter" href="#Concept-Index_cp_letter-A"><b>A</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-B"><b>B</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-C"><b>C</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-D"><b>D</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-E"><b>E</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-F"><b>F</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-G"><b>G</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-H"><b>H</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-I"><b>I</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-K"><b>K</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-M"><b>M</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-O"><b>O</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-P"><b>P</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-R"><b>R</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-S"><b>S</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-T"><b>T</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-U"><b>U</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-V"><b>V</b></a>
<a class="summary-letter" href="#Concept-Index_cp_letter-X"><b>X</b></a>
</td></tr></table>
<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>
<h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
<p><a href="http://www.gnu.org/software/libtasn1/">http://www.gnu.org/software/libtasn1/</a></p>
<h3><a name="FOOT2" href="#DOCF2">(2)</a></h3>
<p><a href="http://www.lysator.liu.se/~nisse/nettle/">http://www.lysator.liu.se/~nisse/nettle/</a></p>
<h3><a name="FOOT3" href="#DOCF3">(3)</a></h3>
<p>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>
<h3><a name="FOOT4" href="#DOCF4">(4)</a></h3>
<p>If this is not possible then please consult <a href="#Interoperability">Interoperability</a>.</p>
<h3><a name="FOOT5" href="#DOCF5">(5)</a></h3>
<p>MAC stands for Message Authentication Code. It can be described as a keyed hash algorithm. See RFC2104.</p>
<h3><a name="FOOT6" href="#DOCF6">(6)</a></h3>
<p>See also the Server Name Indication extension on
<a href="#serverind">serverind</a>.</p>
<h3><a name="FOOT7" href="#DOCF7">(7)</a></h3>
<p>See LDAP, IMAP etc.</p>
<h3><a name="FOOT8" href="#DOCF8">(8)</a></h3>
<p><a href="http://www.gnupg.org/related_software/gpgme/">http://www.gnupg.org/related_software/gpgme/</a></p>
<h3><a name="FOOT9" href="#DOCF9">(9)</a></h3>
<p><a href="http://www.opensc-project.org">http://www.opensc-project.org</a></p>
<h3><a name="FOOT10" href="#DOCF10">(10)</a></h3>
<p><a href="http://p11-glue.freedesktop.org/">http://p11-glue.freedesktop.org/</a></p>
<h3><a name="FOOT11" href="#DOCF11">(11)</a></h3>
<p>The first message in a <acronym>TLS</acronym> handshake</p>
<h3><a name="FOOT12" href="#DOCF12">(12)</a></h3>
<p>A key of 128 bits or 16 bytes should be sufficient for this purpose.</p>
<h3><a name="FOOT13" href="#DOCF13">(13)</a></h3>
<p>Except for the RSA-EXPORT which is only enabled in
EXPORT level.</p>
<h3><a name="FOOT14" href="#DOCF14">(14)</a></h3>
<p>It depends on the group used. Primes with
lesser bits are always faster, but also easier to break. See <a href="#Selecting-cryptographic-key-sizes">Selecting cryptographic key sizes</a>
for the acceptable security levels.</p>
<h3><a name="FOOT15" href="#DOCF15">(15)</a></h3>
<p>such as the
<code>gnutls_certificate_credentials_t</code> structures</p>
<h3><a name="FOOT16" href="#DOCF16">(16)</a></h3>
<p>See
<a href="http://lists.gnu.org/archive/html/gnutls-devel/2011-02/msg00079.html">http://lists.gnu.org/archive/html/gnutls-devel/2011-02/msg00079.html</a>.</p>
<h3><a name="FOOT17" href="#DOCF17">(17)</a></h3>
<p>Check <a href="http://home.gna.org/cryptodev-linux/">http://home.gna.org/cryptodev-linux/</a>
for the Linux kernel implementation of <code>/dev/crypto</code>.</p>
</div>
<hr>
</body>
</html>
|