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
|
This is gnupg.info, produced by makeinfo version 6.5 from gnupg.texi.
This is the 'The GNU Privacy Guard Manual' (version 2.2.26-beta25,
December 2020).
(C) 2002, 2004, 2005, 2006, 2007, 2010 Free Software Foundation, Inc.
(C) 2013, 2014, 2015 Werner Koch.
(C) 2015, 2016, 2017 g10 Code GmbH.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version. The text of the
license can be found in the section entitled "Copying".
INFO-DIR-SECTION GNU Utilities
START-INFO-DIR-ENTRY
* gpg2: (gnupg). OpenPGP encryption and signing tool.
* gpgsm: (gnupg). S/MIME encryption and signing tool.
* gpg-agent: (gnupg). The secret key daemon.
* dirmngr: (gnupg). X.509 CRL and OCSP server.
* dirmngr-client: (gnupg). X.509 CRL and OCSP client.
END-INFO-DIR-ENTRY
File: gnupg.info, Node: GPGSM GENKEY, Next: GPGSM LISTKEYS, Prev: GPGSM VERIFY, Up: GPGSM Protocol
5.6.5 Generating a Key
----------------------
This is used to generate a new keypair, store the secret part in the PSE
and the public key in the key database. We will probably add optional
commands to allow the client to select whether a hardware token is used
to store the key. Configuration options to 'GPGSM' can be used to
restrict the use of this command.
GENKEY
'GPGSM' checks whether this command is allowed and then does an
INQUIRY to get the key parameters, the client should then send the key
parameters in the native format:
S: INQUIRE KEY_PARAM native
C: D foo:fgfgfg
C: D bar
C: END
Please note that the server may send Status info lines while reading
the data lines from the client. After this the key generation takes
place and the server eventually does send an ERR or OK response. Status
lines may be issued as a progress indicator.
File: gnupg.info, Node: GPGSM LISTKEYS, Next: GPGSM EXPORT, Prev: GPGSM GENKEY, Up: GPGSM Protocol
5.6.6 List available keys
-------------------------
To list the keys in the internal database or using an external key
provider, the command:
LISTKEYS PATTERN
is used. To allow multiple patterns (which are ORed during the
search) quoting is required: Spaces are to be translated into "+" or
into "%20"; in turn this requires that the usual escape quoting rules
are done.
LISTSECRETKEYS PATTERN
Lists only the keys where a secret key is available.
The list commands are affected by the option
OPTION list-mode=MODE
where mode may be:
'0'
Use default (which is usually the same as 1).
'1'
List only the internal keys.
'2'
List only the external keys.
'3'
List internal and external keys.
Note that options are valid for the entire session.
File: gnupg.info, Node: GPGSM EXPORT, Next: GPGSM IMPORT, Prev: GPGSM LISTKEYS, Up: GPGSM Protocol
5.6.7 Export certificates
-------------------------
To export certificate from the internal key database the command:
EXPORT [--data [--armor] [--base64]] [--] PATTERN
is used. To allow multiple patterns (which are ORed) quoting is
required: Spaces are to be translated into "+" or into "%20"; in turn
this requires that the usual escape quoting rules are done.
If the '--data' option has not been given, the format of the output
depends on what was set with the 'OUTPUT' command. When using PEM
encoding a few informational lines are prepended.
If the '--data' has been given, a target set via 'OUTPUT' is ignored
and the data is returned inline using standard 'D'-lines. This avoids
the need for an extra file descriptor. In this case the options
'--armor' and '--base64' may be used in the same way as with the
'OUTPUT' command.
File: gnupg.info, Node: GPGSM IMPORT, Next: GPGSM DELETE, Prev: GPGSM EXPORT, Up: GPGSM Protocol
5.6.8 Import certificates
-------------------------
To import certificates into the internal key database, the command
IMPORT [--re-import]
is used. The data is expected on the file descriptor set with the
'INPUT' command. Certain checks are performed on the certificate. Note
that the code will also handle PKCS#12 files and import private keys; a
helper program is used for that.
With the option '--re-import' the input data is expected to a be a
linefeed separated list of fingerprints. The command will re-import the
corresponding certificates; that is they are made permanent by removing
their ephemeral flag.
File: gnupg.info, Node: GPGSM DELETE, Next: GPGSM GETAUDITLOG, Prev: GPGSM IMPORT, Up: GPGSM Protocol
5.6.9 Delete certificates
-------------------------
To delete a certificate the command
DELKEYS PATTERN
is used. To allow multiple patterns (which are ORed) quoting is
required: Spaces are to be translated into "+" or into "%20"; in turn
this requires that the usual escape quoting rules are done.
The certificates must be specified unambiguously otherwise an error
is returned.
File: gnupg.info, Node: GPGSM GETAUDITLOG, Next: GPGSM GETINFO, Prev: GPGSM DELETE, Up: GPGSM Protocol
5.6.10 Retrieve an audit log
----------------------------
This command is used to retrieve an audit log.
GETAUDITLOG [--data] [--html]
If '--data' is used, the audit log is send using D-lines instead of
being sent to the file descriptor given by an 'OUTPUT' command. If
'--html' is used, the output is formatted as an XHTML block. This is
designed to be incorporated into a HTML document.
File: gnupg.info, Node: GPGSM GETINFO, Next: GPGSM OPTION, Prev: GPGSM GETAUDITLOG, Up: GPGSM Protocol
5.6.11 Return information about the process
-------------------------------------------
This is a multipurpose function to return a variety of information.
GETINFO WHAT
The value of WHAT specifies the kind of information returned:
'version'
Return the version of the program.
'pid'
Return the process id of the process.
'agent-check'
Return OK if the agent is running.
'cmd_has_option CMD OPT'
Return OK if the command CMD implements the option OPT. The
leading two dashes usually used with OPT shall not be given.
'offline'
Return OK if the connection is in offline mode. This may be either
due to a 'OPTION offline=1' or due to 'gpgsm' being started with
option '--disable-dirmngr'.
File: gnupg.info, Node: GPGSM OPTION, Prev: GPGSM GETINFO, Up: GPGSM Protocol
5.6.12 Session options
----------------------
The standard Assuan option handler supports these options.
OPTION NAME[=VALUE]
These NAMEs are recognized:
'putenv'
Change the session's environment to be passed via gpg-agent to
Pinentry. VALUE is a string of the form '<KEY>[=[<STRING>]]'. If
only '<KEY>' is given the environment variable '<KEY>' is removed
from the session environment, if '<KEY>=' is given that environment
variable is set to the empty string, and if '<STRING>' is given it
is set to that string.
'display'
Set the session environment variable 'DISPLAY' is set to VALUE.
'ttyname'
Set the session environment variable 'GPG_TTY' is set to VALUE.
'ttytype'
Set the session environment variable 'TERM' is set to VALUE.
'lc-ctype'
Set the session environment variable 'LC_CTYPE' is set to VALUE.
'lc-messages'
Set the session environment variable 'LC_MESSAGES' is set to VALUE.
'xauthority'
Set the session environment variable 'XAUTHORITY' is set to VALUE.
'pinentry-user-data'
Set the session environment variable 'PINENTRY_USER_DATA' is set to
VALUE.
'include-certs'
This option overrides the command line option '--include-certs'. A
VALUE of -2 includes all certificates except for the root
certificate, -1 includes all certificates, 0 does not include any
certificates, 1 includes only the signers certificate and all other
positive values include up to VALUE certificates starting with the
signer cert.
'list-mode'
*Note gpgsm-cmd listkeys::.
'list-to-output'
If VALUE is true the output of the list commands (*note gpgsm-cmd
listkeys::) is written to the file descriptor set with the last
'OUTPUT' command. If VALUE is false the output is written via data
lines; this is the default.
'with-validation'
If VALUE is true for each listed certificate the validation status
is printed. This may result in the download of a CRL or the user
being asked about the trustworthiness of a root certificate. The
default is given by a command line option (*note gpgsm-option
--with-validation::).
'with-secret'
If VALUE is true certificates with a corresponding private key are
marked by the list commands.
'validation-model'
This option overrides the command line option 'validation-model'
for the session. (*Note gpgsm-option --validation-model::.)
'with-key-data'
This option globally enables the command line option
'--with-key-data'. (*Note gpgsm-option --with-key-data::.)
'enable-audit-log'
If VALUE is true data to write an audit log is gathered. (*Note
gpgsm-cmd getauditlog::.)
'allow-pinentry-notify'
If this option is used notifications about the launch of a Pinentry
are passed back to the client.
'with-ephemeral-keys'
If VALUE is true ephemeral certificates are included in the output
of the list commands.
'no-encrypt-to'
If this option is used all keys set by the command line option
'--encrypt-to' are ignored.
'offline'
If VALUE is true or VALUE is not given all network access is
disabled for this session. This is the same as the command line
option '--disable-dirmngr'.
File: gnupg.info, Node: Invoking SCDAEMON, Next: Specify a User ID, Prev: Invoking GPGSM, Up: Top
6 Invoking the SCDAEMON
***********************
The 'scdaemon' is a daemon to manage smartcards. It is usually invoked
by 'gpg-agent' and in general not used directly.
*Note Option Index::, for an index to 'scdaemon''s commands and
options.
* Menu:
* Scdaemon Commands:: List of all commands.
* Scdaemon Options:: List of all options.
* Card applications:: Description of card applications.
* Scdaemon Configuration:: Configuration files.
* Scdaemon Examples:: Some usage examples.
* Scdaemon Protocol:: The protocol the daemon uses.
File: gnupg.info, Node: Scdaemon Commands, Next: Scdaemon Options, Up: Invoking SCDAEMON
6.1 Commands
============
Commands are not distinguished from options except for the fact that
only one command is allowed.
'--version'
Print the program version and licensing information. Note that you
cannot abbreviate this command.
'--help, -h'
Print a usage message summarizing the most useful command-line
options. Note that you cannot abbreviate this command.
'--dump-options'
Print a list of all available options and commands. Note that you
cannot abbreviate this command.
'--server'
Run in server mode and wait for commands on the 'stdin'. The
default mode is to create a socket and listen for commands there.
'--multi-server'
Run in server mode and wait for commands on the 'stdin' as well as
on an additional Unix Domain socket. The server command 'GETINFO'
may be used to get the name of that extra socket.
'--daemon'
Run the program in the background. This option is required to
prevent it from being accidentally running in the background.
File: gnupg.info, Node: Scdaemon Options, Next: Card applications, Prev: Scdaemon Commands, Up: Invoking SCDAEMON
6.2 Option Summary
==================
'--options FILE'
Reads configuration from FILE instead of from the default per-user
configuration file. The default configuration file is named
'scdaemon.conf' and expected in the '.gnupg' directory directly
below the home directory of the user.
'--homedir DIR'
Set the name of the home directory to DIR. If this option is not
used, the home directory defaults to '~/.gnupg'. It is only
recognized when given on the command line. It also overrides any
home directory stated through the environment variable 'GNUPGHOME'
or (on Windows systems) by means of the Registry entry
HKCU\SOFTWARE\GNU\GNUPG:HOMEDIR.
On Windows systems it is possible to install GnuPG as a portable
application. In this case only this command line option is
considered, all other ways to set a home directory are ignored.
To install GnuPG as a portable application under Windows, create an
empty file named 'gpgconf.ctl' in the same directory as the tool
'gpgconf.exe'. The root of the installation is then that
directory; or, if 'gpgconf.exe' has been installed directly below a
directory named 'bin', its parent directory. You also need to make
sure that the following directories exist and are writable:
'ROOT/home' for the GnuPG home and 'ROOT/usr/local/var/cache/gnupg'
for internal cache files.
'-v'
'--verbose'
Outputs additional information while running. You can increase the
verbosity by giving several verbose commands to 'gpgsm', such as
'-vv'.
'--debug-level LEVEL'
Select the debug level for investigating problems. LEVEL may be a
numeric value or a keyword:
'none'
No debugging at all. A value of less than 1 may be used
instead of the keyword.
'basic'
Some basic debug messages. A value between 1 and 2 may be
used instead of the keyword.
'advanced'
More verbose debug messages. A value between 3 and 5 may be
used instead of the keyword.
'expert'
Even more detailed messages. A value between 6 and 8 may be
used instead of the keyword.
'guru'
All of the debug messages you can get. A value greater than 8
may be used instead of the keyword. The creation of hash
tracing files is only enabled if the keyword is used.
How these messages are mapped to the actual debugging flags is not
specified and may change with newer releases of this program. They
are however carefully selected to best aid in debugging.
Note: All debugging options are subject to change and thus
should not be used by any application program. As the name
says, they are only used as helpers to debug problems.
'--debug FLAGS'
This option is only useful for debugging and the behavior may
change at any time without notice. FLAGS are bit encoded and may
be given in usual C-Syntax. The currently defined bits are:
'0 (1)'
command I/O
'1 (2)'
values of big number integers
'2 (4)'
low level crypto operations
'5 (32)'
memory allocation
'6 (64)'
caching
'7 (128)'
show memory statistics
'9 (512)'
write hashed data to files named 'dbgmd-000*'
'10 (1024)'
trace Assuan protocol. See also option
'--debug-assuan-log-cats'.
'11 (2048)'
trace APDU I/O to the card. This may reveal sensitive data.
'12 (4096)'
trace some card reader related function calls.
'--debug-all'
Same as '--debug=0xffffffff'
'--debug-wait N'
When running in server mode, wait N seconds before entering the
actual processing loop and print the pid. This gives time to
attach a debugger.
'--debug-ccid-driver'
Enable debug output from the included CCID driver for smartcards.
Using this option twice will also enable some tracing of the T=1
protocol. Note that this option may reveal sensitive data.
'--debug-disable-ticker'
This option disables all ticker functions like checking for card
insertions.
'--debug-allow-core-dump'
For security reasons we won't create a core dump when the process
aborts. For debugging purposes it is sometimes better to allow
core dump. This option enables it and also changes the working
directory to '/tmp' when running in '--server' mode.
'--debug-log-tid'
This option appends a thread ID to the PID in the log output.
'--debug-assuan-log-cats CATS'
Changes the active Libassuan logging categories to CATS. The value
for CATS is an unsigned integer given in usual C-Syntax. A value
of 0 switches to a default category. If this option is not used
the categories are taken from the environment variable
'ASSUAN_DEBUG'. Note that this option has only an effect if the
Assuan debug flag has also been with the option '--debug'. For a
list of categories see the Libassuan manual.
'--no-detach'
Don't detach the process from the console. This is mainly useful
for debugging.
'--listen-backlog N'
Set the size of the queue for pending connections. The default is
64. This option has an effect only if '--multi-server' is also
used.
'--log-file FILE'
Append all logging output to FILE. This is very helpful in seeing
what the agent actually does. Use 'socket://' to log to socket.
'--pcsc-driver LIBRARY'
Use LIBRARY to access the smartcard reader. The current default is
'libpcsclite.so'. Instead of using this option you might also want
to install a symbolic link to the default file name (e.g. from
'libpcsclite.so.1').
'--ctapi-driver LIBRARY'
Use LIBRARY to access the smartcard reader. The current default is
'libtowitoko.so'. Note that the use of this interface is
deprecated; it may be removed in future releases.
'--disable-ccid'
Disable the integrated support for CCID compliant readers. This
allows falling back to one of the other drivers even if the
internal CCID driver can handle the reader. Note, that CCID
support is only available if libusb was available at build time.
'--reader-port NUMBER_OR_STRING'
This option may be used to specify the port of the card terminal.
A value of 0 refers to the first serial device; add 32768 to access
USB devices. The default is 32768 (first USB device). PC/SC or
CCID readers might need a string here; run the program in verbose
mode to get a list of available readers. The default is then the
first reader found.
To get a list of available CCID readers you may use this command:
echo scd getinfo reader_list \
| gpg-connect-agent --decode | awk '/^D/ {print $2}'
'--card-timeout N'
If N is not 0 and no client is actively using the card, the card
will be powered down after N seconds. Powering down the card
avoids a potential risk of damaging a card when used with certain
cheap readers. This also allows applications that are not aware of
Scdaemon to access the card. The disadvantage of using a card
timeout is that accessing the card takes longer and that the user
needs to enter the PIN again after the next power up.
Note that with the current version of Scdaemon the card is powered
down immediately at the next timer tick for any value of N other
than 0.
'--enable-pinpad-varlen'
Please specify this option when the card reader supports variable
length input for pinpad (default is no). For known readers (listed
in ccid-driver.c and apdu.c), this option is not needed. Note that
if your card reader doesn't supports variable length input but you
want to use it, you need to specify your pinpad request on your
card.
'--disable-pinpad'
Even if a card reader features a pinpad, do not try to use it.
'--deny-admin'
This option disables the use of admin class commands for card
applications where this is supported. Currently we support it for
the OpenPGP card. This option is useful to inhibit accidental
access to admin class command which could ultimately lock the card
through wrong PIN numbers. Note that GnuPG versions older than
2.0.11 featured an '--allow-admin' option which was required to use
such admin commands. This option has no more effect today because
the default is now to allow admin commands.
'--disable-application NAME'
This option disables the use of the card application named NAME.
This is mainly useful for debugging or if a application with lower
priority should be used by default.
All the long options may also be given in the configuration file
after stripping off the two leading dashes.
File: gnupg.info, Node: Card applications, Next: Scdaemon Configuration, Prev: Scdaemon Options, Up: Invoking SCDAEMON
6.3 Description of card applications
====================================
'scdaemon' supports the card applications as described below.
* Menu:
* OpenPGP Card:: The OpenPGP card application
* NKS Card:: The Telesec NetKey card application
* DINSIG Card:: The DINSIG card application
* PKCS#15 Card:: The PKCS#15 card application
* Geldkarte Card:: The Geldkarte application
* SmartCard-HSM:: The SmartCard-HSM application
* Undefined Card:: The Undefined stub application
File: gnupg.info, Node: OpenPGP Card, Next: NKS Card, Up: Card applications
6.3.1 The OpenPGP card application "openpgp"
--------------------------------------------
This application is currently only used by 'gpg' but may in future also
be useful with 'gpgsm'. Version 1 and version 2 of the card is
supported.
The specifications for these cards are available at
<http://g10code.com/docs/openpgp-card-1.0.pdf> and
<http://g10code.com/docs/openpgp-card-2.0.pdf>.
File: gnupg.info, Node: NKS Card, Next: DINSIG Card, Prev: OpenPGP Card, Up: Card applications
6.3.2 The Telesec NetKey card "nks"
-----------------------------------
This is the main application of the Telesec cards as available in
Germany. It is a superset of the German DINSIG card. The card is used
by 'gpgsm'.
File: gnupg.info, Node: DINSIG Card, Next: PKCS#15 Card, Prev: NKS Card, Up: Card applications
6.3.3 The DINSIG card application "dinsig"
------------------------------------------
This is an application as described in the German draft standard _DIN V
66291-1_. It is intended to be used by cards supporting the German
signature law and its bylaws (SigG and SigV).
File: gnupg.info, Node: PKCS#15 Card, Next: Geldkarte Card, Prev: DINSIG Card, Up: Card applications
6.3.4 The PKCS#15 card application "p15"
----------------------------------------
This is common framework for smart card applications. It is used by
'gpgsm'.
File: gnupg.info, Node: Geldkarte Card, Next: SmartCard-HSM, Prev: PKCS#15 Card, Up: Card applications
6.3.5 The Geldkarte card application "geldkarte"
------------------------------------------------
This is a simple application to display information of a German
Geldkarte. The Geldkarte is a small amount debit card application which
comes with almost all German banking cards.
File: gnupg.info, Node: SmartCard-HSM, Next: Undefined Card, Prev: Geldkarte Card, Up: Card applications
6.3.6 The SmartCard-HSM card application "sc-hsm"
-------------------------------------------------
This application adds read-only support for keys and certificates stored
on a SmartCard-HSM (http://www.smartcard-hsm.com).
To generate keys and store certificates you may use OpenSC
(https://github.com/OpenSC/OpenSC/wiki/SmartCardHSM) or the tools from
OpenSCDP (http://www.openscdp.org).
The SmartCard-HSM cards requires a card reader that supports Extended
Length APDUs.
File: gnupg.info, Node: Undefined Card, Prev: SmartCard-HSM, Up: Card applications
6.3.7 The Undefined card application "undefined"
------------------------------------------------
This is a stub application to allow the use of the APDU command even if
no supported application is found on the card. This application is not
used automatically but must be explicitly requested using the SERIALNO
command.
File: gnupg.info, Node: Scdaemon Configuration, Next: Scdaemon Examples, Prev: Card applications, Up: Invoking SCDAEMON
6.4 Configuration files
=======================
There are a few configuration files to control certain aspects of
'scdaemons''s operation. Unless noted, they are expected in the current
home directory (*note option --homedir::).
'scdaemon.conf'
This is the standard configuration file read by 'scdaemon' on
startup. It may contain any valid long option; the leading two
dashes may not be entered and the option may not be abbreviated.
This default name may be changed on the command line (*note option
--options::).
'scd-event'
If this file is present and executable, it will be called on every
card reader's status change. An example of this script is provided
with the distribution
'reader_N.status'
This file is created by 'scdaemon' to let other applications now
about reader status changes. Its use is now deprecated in favor of
'scd-event'.
File: gnupg.info, Node: Scdaemon Examples, Next: Scdaemon Protocol, Prev: Scdaemon Configuration, Up: Invoking SCDAEMON
6.5 Examples
============
$ scdaemon --server -v
File: gnupg.info, Node: Scdaemon Protocol, Prev: Scdaemon Examples, Up: Invoking SCDAEMON
6.6 Scdaemon's Assuan Protocol
==============================
The SC-Daemon should be started by the system to provide access to
external tokens. Using Smartcards on a multi-user system does not make
much sense except for system services, but in this case no regular user
accounts are hosted on the machine.
A client connects to the SC-Daemon by connecting to the socket named
'/usr/local/var/run/gnupg/scdaemon/socket', configuration information is
read from /ETC/GNUPG/SCDAEMON.CONF
Each connection acts as one session, SC-Daemon takes care of
synchronizing access to a token between sessions.
* Menu:
* Scdaemon SERIALNO:: Return the serial number.
* Scdaemon LEARN:: Read all useful information from the card.
* Scdaemon READCERT:: Return a certificate.
* Scdaemon READKEY:: Return a public key.
* Scdaemon PKSIGN:: Signing data with a Smartcard.
* Scdaemon PKDECRYPT:: Decrypting data with a Smartcard.
* Scdaemon GETATTR:: Read an attribute's value.
* Scdaemon SETATTR:: Update an attribute's value.
* Scdaemon WRITEKEY:: Write a key to a card.
* Scdaemon GENKEY:: Generate a new key on-card.
* Scdaemon RANDOM:: Return random bytes generated on-card.
* Scdaemon PASSWD:: Change PINs.
* Scdaemon CHECKPIN:: Perform a VERIFY operation.
* Scdaemon RESTART:: Restart connection
* Scdaemon APDU:: Send a verbatim APDU to the card
File: gnupg.info, Node: Scdaemon SERIALNO, Next: Scdaemon LEARN, Up: Scdaemon Protocol
6.6.1 Return the serial number
------------------------------
This command should be used to check for the presence of a card. It is
special in that it can be used to reset the card. Most other commands
will return an error when a card change has been detected and the use of
this function is therefore required.
Background: We want to keep the client clear of handling card changes
between operations; i.e. the client can assume that all operations are
done on the same card unless he call this function.
SERIALNO
Return the serial number of the card using a status response like:
S SERIALNO D27600000000000000000000
The serial number is the hex encoded value identified by the '0x5A'
tag in the GDO file (FIX=0x2F02).
File: gnupg.info, Node: Scdaemon LEARN, Next: Scdaemon READCERT, Prev: Scdaemon SERIALNO, Up: Scdaemon Protocol
6.6.2 Read all useful information from the card
-----------------------------------------------
LEARN [--force]
Learn all useful information of the currently inserted card. When
used without the '--force' option, the command might do an INQUIRE like
this:
INQUIRE KNOWNCARDP <hexstring_with_serialNumber>
The client should just send an 'END' if the processing should go on
or a 'CANCEL' to force the function to terminate with a cancel error
message. The response of this command is a list of status lines
formatted as this:
S KEYPAIRINFO HEXSTRING_WITH_KEYGRIP HEXSTRING_WITH_ID
If there is no certificate yet stored on the card a single "X" is
returned in HEXSTRING_WITH_KEYGRIP.
File: gnupg.info, Node: Scdaemon READCERT, Next: Scdaemon READKEY, Prev: Scdaemon LEARN, Up: Scdaemon Protocol
6.6.3 Return a certificate
--------------------------
READCERT HEXIFIED_CERTID|KEYID
This function is used to read a certificate identified by
HEXIFIED_CERTID from the card. With OpenPGP cards the keyid 'OpenPGP.3'
may be used to read the certificate of version 2 cards.
File: gnupg.info, Node: Scdaemon READKEY, Next: Scdaemon PKSIGN, Prev: Scdaemon READCERT, Up: Scdaemon Protocol
6.6.4 Return a public key
-------------------------
READKEY HEXIFIED_CERTID
Return the public key for the given cert or key ID as an standard
S-Expression.
File: gnupg.info, Node: Scdaemon PKSIGN, Next: Scdaemon PKDECRYPT, Prev: Scdaemon READKEY, Up: Scdaemon Protocol
6.6.5 Signing data with a Smartcard
-----------------------------------
To sign some data the caller should use the command
SETDATA HEXSTRING
to tell 'scdaemon' about the data to be signed. The data must be
given in hex notation. The actual signing is done using the command
PKSIGN KEYID
where KEYID is the hexified ID of the key to be used. The key id may
have been retrieved using the command 'LEARN'. If another hash
algorithm than SHA-1 is used, that algorithm may be given like:
PKSIGN --hash=ALGONAME KEYID
With ALGONAME are one of 'sha1', 'rmd160' or 'md5'.
File: gnupg.info, Node: Scdaemon PKDECRYPT, Next: Scdaemon GETATTR, Prev: Scdaemon PKSIGN, Up: Scdaemon Protocol
6.6.6 Decrypting data with a Smartcard
--------------------------------------
To decrypt some data the caller should use the command
SETDATA HEXSTRING
to tell 'scdaemon' about the data to be decrypted. The data must be
given in hex notation. The actual decryption is then done using the
command
PKDECRYPT KEYID
where KEYID is the hexified ID of the key to be used.
If the card is aware of the apdding format a status line with padding
information is send before the plaintext data. The key for this status
line is 'PADDING' with the only defined value being 0 and meaning
padding has been removed.
File: gnupg.info, Node: Scdaemon GETATTR, Next: Scdaemon SETATTR, Prev: Scdaemon PKDECRYPT, Up: Scdaemon Protocol
6.6.7 Read an attribute's value
-------------------------------
TO BE WRITTEN.
File: gnupg.info, Node: Scdaemon SETATTR, Next: Scdaemon WRITEKEY, Prev: Scdaemon GETATTR, Up: Scdaemon Protocol
6.6.8 Update an attribute's value
---------------------------------
TO BE WRITTEN.
File: gnupg.info, Node: Scdaemon WRITEKEY, Next: Scdaemon GENKEY, Prev: Scdaemon SETATTR, Up: Scdaemon Protocol
6.6.9 Write a key to a card
---------------------------
WRITEKEY [--force] KEYID
This command is used to store a secret key on a smartcard. The
allowed keyids depend on the currently selected smartcard application.
The actual keydata is requested using the inquiry 'KEYDATA' and need to
be provided without any protection. With '--force' set an existing key
under this KEYID will get overwritten. The key data is expected to be
the usual canonical encoded S-expression.
A PIN will be requested in most cases. This however depends on the
actual card application.
File: gnupg.info, Node: Scdaemon GENKEY, Next: Scdaemon RANDOM, Prev: Scdaemon WRITEKEY, Up: Scdaemon Protocol
6.6.10 Generate a new key on-card
---------------------------------
TO BE WRITTEN.
File: gnupg.info, Node: Scdaemon RANDOM, Next: Scdaemon PASSWD, Prev: Scdaemon GENKEY, Up: Scdaemon Protocol
6.6.11 Return random bytes generated on-card
--------------------------------------------
TO BE WRITTEN.
File: gnupg.info, Node: Scdaemon PASSWD, Next: Scdaemon CHECKPIN, Prev: Scdaemon RANDOM, Up: Scdaemon Protocol
6.6.12 Change PINs
------------------
PASSWD [--reset] [--nullpin] CHVNO
Change the PIN or reset the retry counter of the card holder
verification vector number CHVNO. The option '--nullpin' is used to
initialize the PIN of TCOS cards (6 byte NullPIN only).
File: gnupg.info, Node: Scdaemon CHECKPIN, Next: Scdaemon RESTART, Prev: Scdaemon PASSWD, Up: Scdaemon Protocol
6.6.13 Perform a VERIFY operation
---------------------------------
CHECKPIN IDSTR
Perform a VERIFY operation without doing anything else. This may be
used to initialize a the PIN cache earlier to long lasting operations.
Its use is highly application dependent:
*OpenPGP*
Perform a simple verify operation for CHV1 and CHV2, so that
further operations won't ask for CHV2 and it is possible to do a
cheap check on the PIN: If there is something wrong with the PIN
entry system, only the regular CHV will get blocked and not the
dangerous CHV3. IDSTR is the usual card's serial number in hex
notation; an optional fingerprint part will get ignored.
There is however a special mode if IDSTR is suffixed with the
literal string '[CHV3]': In this case the Admin PIN is checked if
and only if the retry counter is still at 3.
File: gnupg.info, Node: Scdaemon RESTART, Next: Scdaemon APDU, Prev: Scdaemon CHECKPIN, Up: Scdaemon Protocol
6.6.14 Perform a RESTART operation
----------------------------------
RESTART
Restart the current connection; this is a kind of warm reset. It
deletes the context used by this connection but does not actually reset
the card.
This is used by gpg-agent to reuse a primary pipe connection and may
be used by clients to backup from a conflict in the serial command; i.e.
to select another application.
File: gnupg.info, Node: Scdaemon APDU, Prev: Scdaemon RESTART, Up: Scdaemon Protocol
6.6.15 Send a verbatim APDU to the card
---------------------------------------
APDU [--atr] [--more] [--exlen[=N]] [HEXSTRING]
Send an APDU to the current reader. This command bypasses the high
level functions and sends the data directly to the card. HEXSTRING is
expected to be a proper APDU. If HEXSTRING is not given no commands are
send to the card; However the command will implicitly check whether the
card is ready for use.
Using the option '--atr' returns the ATR of the card as a status
message before any data like this:
S CARD-ATR 3BFA1300FF813180450031C173C00100009000B1
Using the option '--more' handles the card status word MORE_DATA
(61xx) and concatenate all responses to one block.
Using the option '--exlen' the returned APDU may use extended length
up to N bytes. If N is not given a default value is used (currently
4096).
File: gnupg.info, Node: Specify a User ID, Next: Trust Values, Prev: Invoking SCDAEMON, Up: Top
7 How to Specify a User Id
**************************
There are different ways to specify a user ID to GnuPG. Some of them are
only valid for 'gpg' others are only good for 'gpgsm'. Here is the
entire list of ways to specify a key:
* By key Id. This format is deduced from the length of the string
and its content or '0x' prefix. The key Id of an X.509 certificate
are the low 64 bits of its SHA-1 fingerprint. The use of key Ids
is just a shortcut, for all automated processing the fingerprint
should be used.
When using 'gpg' an exclamation mark (!) may be appended to force
using the specified primary or secondary key and not to try and
calculate which primary or secondary key to use.
The last four lines of the example give the key ID in their long
form as internally used by the OpenPGP protocol. You can see the
long key ID using the option '--with-colons'.
234567C4
0F34E556E
01347A56A
0xAB123456
234AABBCC34567C4
0F323456784E56EAB
01AB3FED1347A5612
0x234AABBCC34567C4
* By fingerprint. This format is deduced from the length of the
string and its content or the '0x' prefix. Note, that only the 20
byte version fingerprint is available with 'gpgsm' (i.e. the SHA-1
hash of the certificate).
When using 'gpg' an exclamation mark (!) may be appended to force
using the specified primary or secondary key and not to try and
calculate which primary or secondary key to use.
The best way to specify a key Id is by using the fingerprint. This
avoids any ambiguities in case that there are duplicated key IDs.
1234343434343434C434343434343434
123434343434343C3434343434343734349A3434
0E12343434343434343434EAB3484343434343434
0xE12343434343434343434EAB3484343434343434
'gpgsm' also accepts colons between each pair of hexadecimal digits
because this is the de-facto standard on how to present X.509
fingerprints. 'gpg' also allows the use of the space separated
SHA-1 fingerprint as printed by the key listing commands.
* By exact match on OpenPGP user ID. This is denoted by a leading
equal sign. It does not make sense for X.509 certificates.
=Heinrich Heine <heinrichh@uni-duesseldorf.de>
* By exact match on an email address. This is indicated by enclosing
the email address in the usual way with left and right angles.
<heinrichh@uni-duesseldorf.de>
* By partial match on an email address. This is indicated by
prefixing the search string with an '@'. This uses a substring
search but considers only the mail address (i.e. inside the angle
brackets).
@heinrichh
* By exact match on the subject's DN. This is indicated by a leading
slash, directly followed by the RFC-2253 encoded DN of the subject.
Note that you can't use the string printed by 'gpgsm --list-keys'
because that one has been reordered and modified for better
readability; use '--with-colons' to print the raw (but standard
escaped) RFC-2253 string.
/CN=Heinrich Heine,O=Poets,L=Paris,C=FR
* By exact match on the issuer's DN. This is indicated by a leading
hash mark, directly followed by a slash and then directly followed
by the RFC-2253 encoded DN of the issuer. This should return the
Root cert of the issuer. See note above.
#/CN=Root Cert,O=Poets,L=Paris,C=FR
* By exact match on serial number and issuer's DN. This is indicated
by a hash mark, followed by the hexadecimal representation of the
serial number, then followed by a slash and the RFC-2253 encoded DN
of the issuer. See note above.
#4F03/CN=Root Cert,O=Poets,L=Paris,C=FR
* By keygrip. This is indicated by an ampersand followed by the 40
hex digits of a keygrip. 'gpgsm' prints the keygrip when using the
command '--dump-cert'.
&D75F22C3F86E355877348498CDC92BD21010A480
* By substring match. This is the default mode but applications may
want to explicitly indicate this by putting the asterisk in front.
Match is not case sensitive.
Heine
*Heine
* . and + prefixes These prefixes are reserved for looking up mails
anchored at the end and for a word search mode. They are not yet
implemented and using them is undefined.
Please note that we have reused the hash mark identifier which was
used in old GnuPG versions to indicate the so called local-id. It is
not anymore used and there should be no conflict when used with X.509
stuff.
Using the RFC-2253 format of DNs has the drawback that it is not
possible to map them back to the original encoding, however we don't
have to do this because our key database stores this encoding as meta
data.
File: gnupg.info, Node: Trust Values, Next: Helper Tools, Prev: Specify a User ID, Up: Top
8 Trust Values
**************
Trust values are used to indicate ownertrust and validity of keys and
user IDs. They are displayed with letters or strings:
-
unknown
No ownertrust assigned / not yet calculated.
e
expired
Trust calculation has failed; probably due to an expired key.
q
undefined, undef
Not enough information for calculation.
n
never
Never trust this key.
m
marginal
Marginally trusted.
f
full
Fully trusted.
u
ultimate
Ultimately trusted.
r
revoked
For validity only: the key or the user ID has been revoked.
?
err
The program encountered an unknown trust value.
File: gnupg.info, Node: Helper Tools, Next: Web Key Service, Prev: Trust Values, Up: Top
9 Helper Tools
**************
GnuPG comes with a couple of smaller tools:
* Menu:
* watchgnupg:: Read logs from a socket.
* gpgv:: Verify OpenPGP signatures.
* addgnupghome:: Create .gnupg home directories.
* gpgconf:: Modify .gnupg home directories.
* applygnupgdefaults:: Run gpgconf for all users.
* gpg-preset-passphrase:: Put a passphrase into the cache.
* gpg-connect-agent:: Communicate with a running agent.
* dirmngr-client:: How to use the Dirmngr client tool.
* gpgparsemail:: Parse a mail message into an annotated format
* symcryptrun:: Call a simple symmetric encryption tool.
* gpgtar:: Encrypt or sign files into an archive.
File: gnupg.info, Node: watchgnupg, Next: gpgv, Up: Helper Tools
9.1 Read logs from a socket
===========================
Most of the main utilities are able to write their log files to a Unix
Domain socket if configured that way. 'watchgnupg' is a simple listener
for such a socket. It ameliorates the output with a time stamp and
makes sure that long lines are not interspersed with log output from
other utilities. This tool is not available for Windows.
'watchgnupg' is commonly invoked as
watchgnupg --force $(gpgconf --list-dirs socketdir)/S.log
This starts it on the current terminal for listening on the standard
logging socket (which is either '~/.gnupg/S.log' or
'/var/run/user/UID/gnupg/S.log').
'watchgnupg' understands these options:
'--force'
Delete an already existing socket file.
'--tcp N'
Instead of reading from a local socket, listen for connects on TCP
port N.
'--time-only'
Do not print the date part of the timestamp.
'--verbose'
Enable extra informational output.
'--version'
Print version of the program and exit.
'--help'
Display a brief help page and exit.
Examples
********
$ watchgnupg --force --time-only $(gpgconf --list-dirs socketdir)/S.log
This waits for connections on the local socket (e.g.
'/home/foo/.gnupg/S.log') and shows all log entries. To make this work
the option 'log-file' needs to be used with all modules which logs are
to be shown. The suggested entry for the configuration files is:
log-file socket://
If the default socket as given above and returned by "echo $(gpgconf
-list-dirs socketdir)/S.log" is not desired an arbitrary socket name can
be specified, for example 'socket:///home/foo/bar/mysocket'. For
debugging purposes it is also possible to do remote logging. Take care
if you use this feature because the information is send in the clear
over the network. Use this syntax in the conf files:
log-file tcp://192.168.1.1:4711
You may use any port and not just 4711 as shown above; only IP
addresses are supported (v4 and v6) and no host names. You need to
start 'watchgnupg' with the 'tcp' option. Note that under Windows the
registry entry HKCU\SOFTWARE\GNU\GNUPG:DEFAULTLOGFILE can be used to
change the default log output from 'stderr' to whatever is given by that
entry. However the only useful entry is a TCP name for remote
debugging.
File: gnupg.info, Node: gpgv, Next: addgnupghome, Prev: watchgnupg, Up: Helper Tools
9.2 Verify OpenPGP signatures
=============================
'gpgv' is an OpenPGP signature verification tool.
This program is actually a stripped-down version of 'gpg' which is
only able to check signatures. It is somewhat smaller than the
fully-blown 'gpg' and uses a different (and simpler) way to check that
the public keys used to make the signature are valid. There are no
configuration files and only a few options are implemented.
'gpgv' assumes that all keys in the keyring are trustworthy. That
does also mean that it does not check for expired or revoked keys.
If no '--keyring' option is given, 'gpgv' looks for a "default"
keyring named 'trustedkeys.kbx' (preferred) or 'trustedkeys.gpg' in the
home directory of GnuPG, either the default home directory or the one
set by the '--homedir' option or the 'GNUPGHOME' environment variable.
If any '--keyring' option is used, 'gpgv' will not look for the default
keyring. The '--keyring' option may be used multiple times and all
specified keyrings will be used together.
'gpgv' recognizes these options:
'--verbose'
'-v'
Gives more information during processing. If used twice, the input
data is listed in detail.
'--quiet'
'-q'
Try to be as quiet as possible.
'--keyring FILE'
Add FILE to the list of keyrings. If FILE begins with a tilde and
a slash, these are replaced by the HOME directory. If the filename
does not contain a slash, it is assumed to be in the home-directory
("~/.gnupg" if -homedir is not used).
'--output FILE'
'-o FILE'
Write output to FILE; to write to stdout use '-'. This option can
be used to get the signed text from a cleartext or binary
signature; it also works for detached signatures, but in that case
this option is in general not useful. Note that an existing file
will be overwritten.
'--status-fd N'
Write special status strings to the file descriptor N. See the
file DETAILS in the documentation for a listing of them.
'--logger-fd n'
Write log output to file descriptor 'n' and not to stderr.
'--log-file file'
Same as '--logger-fd', except the logger data is written to file
'file'. Use 'socket://' to log to socket.
'--ignore-time-conflict'
GnuPG normally checks that the timestamps associated with keys and
signatures have plausible values. However, sometimes a signature
seems to be older than the key due to clock problems. This option
turns these checks into warnings.
'--homedir DIR'
Set the name of the home directory to DIR. If this option is not
used, the home directory defaults to '~/.gnupg'. It is only
recognized when given on the command line. It also overrides any
home directory stated through the environment variable 'GNUPGHOME'
or (on Windows systems) by means of the Registry entry
HKCU\SOFTWARE\GNU\GNUPG:HOMEDIR.
On Windows systems it is possible to install GnuPG as a portable
application. In this case only this command line option is
considered, all other ways to set a home directory are ignored.
To install GnuPG as a portable application under Windows, create an
empty file named 'gpgconf.ctl' in the same directory as the tool
'gpgconf.exe'. The root of the installation is then that
directory; or, if 'gpgconf.exe' has been installed directly below a
directory named 'bin', its parent directory. You also need to make
sure that the following directories exist and are writable:
'ROOT/home' for the GnuPG home and 'ROOT/usr/local/var/cache/gnupg'
for internal cache files.
'--weak-digest name'
Treat the specified digest algorithm as weak. Signatures made over
weak digests algorithms are normally rejected. This option can be
supplied multiple times if multiple algorithms should be considered
weak. MD5 is always considered weak, and does not need to be
listed explicitly.
'--enable-special-filenames'
This option enables a mode in which filenames of the form '-&n',
where n is a non-negative decimal number, refer to the file
descriptor n and not to a file with that name.
The program returns 0 if everything is fine, 1 if at least one
signature was bad, and other error codes for fatal errors.
9.2.1 Examples
--------------
gpgv 'pgpfile'
gpgv 'sigfile' ['datafile']
Verify the signature of the file. The second form is used for
detached signatures, where 'sigfile' is the detached signature
(either ASCII-armored or binary) and 'datafile' contains the signed
data; if 'datafile' is "-" the signed data is expected on 'stdin';
if 'datafile' is not given the name of the file holding the signed
data is constructed by cutting off the extension (".asc", ".sig" or
".sign") from 'sigfile'.
9.2.2 Environment
-----------------
HOME
Used to locate the default home directory.
GNUPGHOME
If set directory used instead of "~/.gnupg".
9.2.3 FILES
-----------
~/.gnupg/trustedkeys.gpg
The default keyring with the allowed keys.
'gpg'(1)
File: gnupg.info, Node: addgnupghome, Next: gpgconf, Prev: gpgv, Up: Helper Tools
9.3 Create .gnupg home directories
==================================
If GnuPG is installed on a system with existing user accounts, it is
sometimes required to populate the GnuPG home directory with existing
files. Especially a 'trustlist.txt' and a keybox with some initial
certificates are often desired. This script helps to do this by copying
all files from '/etc/skel/.gnupg' to the home directories of the
accounts given on the command line. It takes care not to overwrite
existing GnuPG home directories.
'addgnupghome' is invoked by root as:
addgnupghome account1 account2 ... accountn
File: gnupg.info, Node: gpgconf, Next: applygnupgdefaults, Prev: addgnupghome, Up: Helper Tools
9.4 Modify .gnupg home directories
==================================
The 'gpgconf' is a utility to automatically and reasonable safely query
and modify configuration files in the '.gnupg' home directory. It is
designed not to be invoked manually by the user, but automatically by
graphical user interfaces (GUI).(1)
'gpgconf' provides access to the configuration of one or more
components of the GnuPG system. These components correspond more or
less to the programs that exist in the GnuPG framework, like GPG, GPGSM,
DirMngr, etc. But this is not a strict one-to-one relationship. Not
all configuration options are available through 'gpgconf'. 'gpgconf'
provides a generic and abstract method to access the most important
configuration options that can feasibly be controlled via such a
mechanism.
'gpgconf' can be used to gather and change the options available in
each component, and can also provide their default values. 'gpgconf'
will give detailed type information that can be used to restrict the
user's input without making an attempt to commit the changes.
'gpgconf' provides the backend of a configuration editor. The
configuration editor would usually be a graphical user interface program
that displays the current options, their default values, and allows the
user to make changes to the options. These changes can then be made
active with 'gpgconf' again. Such a program that uses 'gpgconf' in this
way will be called GUI throughout this section.
* Menu:
* Invoking gpgconf:: List of all commands and options.
* Format conventions:: Formatting conventions relevant for all commands.
* Listing components:: List all gpgconf components.
* Checking programs:: Check all programs known to gpgconf.
* Listing options:: List all options of a component.
* Changing options:: Changing options of a component.
* Listing global options:: List all global options.
* Querying versions:: Get and compare software versions.
* Files used by gpgconf:: What files are used by gpgconf.
---------- Footnotes ----------
(1) Please note that currently no locking is done, so concurrent
access should be avoided. There are some precautions to avoid
corruption with concurrent usage, but results may be inconsistent and
some changes may get lost. The stateless design makes it difficult to
provide more guarantees.
File: gnupg.info, Node: Invoking gpgconf, Next: Format conventions, Up: gpgconf
9.4.1 Invoking gpgconf
----------------------
One of the following commands must be given:
'--list-components'
List all components. This is the default command used if none is
specified.
'--check-programs'
List all available backend programs and test whether they are
runnable.
'--list-options COMPONENT'
List all options of the component COMPONENT.
'--change-options COMPONENT'
Change the options of the component COMPONENT.
'--check-options COMPONENT'
Check the options for the component COMPONENT.
'--apply-profile FILE'
Apply the configuration settings listed in FILE to the
configuration files. If FILE has no suffix and no slashes the
command first tries to read a file with the suffix '.prf' from the
data directory ('gpgconf --list-dirs datadir') before it reads the
file verbatim. A profile is divided into sections using the
bracketed component name. Each section then lists the option which
shall go into the respective configuration file.
'--apply-defaults'
Update all configuration files with values taken from the global
configuration file (usually '/etc/gnupg/gpgconf.conf').
'--list-dirs [NAMES]'
Lists the directories used by 'gpgconf'. One directory is listed
per line, and each line consists of a colon-separated list where
the first field names the directory type (for example 'sysconfdir')
and the second field contains the percent-escaped directory.
Although they are not directories, the socket file names used by
'gpg-agent' and 'dirmngr' are printed as well. Note that the
socket file names and the 'homedir' lines are the default names and
they may be overridden by command line switches. If NAMES are
given only the directories or file names specified by the list
names are printed without any escaping.
'--list-config [FILENAME]'
List the global configuration file in a colon separated format. If
FILENAME is given, check that file instead.
'--check-config [FILENAME]'
Run a syntax check on the global configuration file. If FILENAME
is given, check that file instead.
'--query-swdb PACKAGE_NAME [VERSION_STRING]'
Returns the current version for PACKAGE_NAME and if VERSION_STRING
is given also an indicator on whether an update is available. The
actual file with the software version is automatically downloaded
and checked by 'dirmngr'. 'dirmngr' uses a thresholds to avoid
download the file too often and it does this by default only if it
can be done via Tor. To force an update of that file this command
can be used:
gpg-connect-agent --dirmngr 'loadswdb --force' /bye
'--reload [COMPONENT]'
Reload all or the given component. This is basically the same as
sending a SIGHUP to the component. Components which don't support
reloading are ignored. Without COMPONENT or by using "all" for
COMPONENT all components which are daemons are reloaded.
'--launch [COMPONENT]'
If the COMPONENT is not already running, start it. 'component'
must be a daemon. This is in general not required because the
system starts these daemons as needed. However, external software
making direct use of 'gpg-agent' or 'dirmngr' may use this command
to ensure that they are started. Using "all" for COMPONENT
launches all components which are daemons.
'--kill [COMPONENT]'
Kill the given component that runs as a daemon, including
'gpg-agent', 'dirmngr', and 'scdaemon'. A 'component' which does
not run as a daemon will be ignored. Using "all" for COMPONENT
kills all components running as daemons. Note that as of now
reload and kill have the same effect for 'scdaemon'.
'--create-socketdir'
Create a directory for sockets below /run/user or /var/run/user.
This is command is only required if a non default home directory is
used and the /run based sockets shall be used. For the default
home directory GnUPG creates a directory on the fly.
'--remove-socketdir'
Remove a directory created with command '--create-socketdir'.
The following options may be used:
'-o FILE'
'--output FILE'
Write output to FILE. Default is to write to stdout.
'-v'
'--verbose'
Outputs additional information while running. Specifically, this
extends numerical field values by human-readable descriptions.
'-q'
'--quiet'
Try to be as quiet as possible.
'--homedir DIR'
Set the name of the home directory to DIR. If this option is not
used, the home directory defaults to '~/.gnupg'. It is only
recognized when given on the command line. It also overrides any
home directory stated through the environment variable 'GNUPGHOME'
or (on Windows systems) by means of the Registry entry
HKCU\SOFTWARE\GNU\GNUPG:HOMEDIR.
On Windows systems it is possible to install GnuPG as a portable
application. In this case only this command line option is
considered, all other ways to set a home directory are ignored.
To install GnuPG as a portable application under Windows, create an
empty file named 'gpgconf.ctl' in the same directory as the tool
'gpgconf.exe'. The root of the installation is then that
directory; or, if 'gpgconf.exe' has been installed directly below a
directory named 'bin', its parent directory. You also need to make
sure that the following directories exist and are writable:
'ROOT/home' for the GnuPG home and 'ROOT/usr/local/var/cache/gnupg'
for internal cache files.
'-n'
'--dry-run'
Do not actually change anything. This is currently only
implemented for '--change-options' and can be used for testing
purposes.
'-r'
'--runtime'
Only used together with '--change-options'. If one of the modified
options can be changed in a running daemon process, signal the
running daemon to ask it to reparse its configuration file after
changing.
This means that the changes will take effect at run-time, as far as
this is possible. Otherwise, they will take effect at the next
start of the respective backend programs.
'--status-fd N'
Write special status strings to the file descriptor N. This
program returns the status messages SUCCESS or FAILURE which are
helpful when the caller uses a double fork approach and can't
easily get the return code of the process.
File: gnupg.info, Node: Format conventions, Next: Listing components, Prev: Invoking gpgconf, Up: gpgconf
9.4.2 Format conventions
------------------------
Some lines in the output of 'gpgconf' contain a list of colon-separated
fields. The following conventions apply:
* The GUI program is required to strip off trailing newline and/or
carriage return characters from the output.
* 'gpgconf' will never leave out fields. If a certain version
provides a certain field, this field will always be present in all
'gpgconf' versions from that time on.
* Future versions of 'gpgconf' might append fields to the list. New
fields will always be separated from the previously last field by a
colon separator. The GUI should be prepared to parse the last
field it knows about up until a colon or end of line.
* Not all fields are defined under all conditions. You are required
to ignore the content of undefined fields.
There are several standard types for the content of a field:
verbatim
Some fields contain strings that are not escaped in any way. Such
fields are described to be used _verbatim_. These fields will
never contain a colon character (for obvious reasons). No
de-escaping or other formatting is required to use the field
content. This is for easy parsing of the output, when it is known
that the content can never contain any special characters.
percent-escaped
Some fields contain strings that are described to be
_percent-escaped_. Such strings need to be de-escaped before their
content can be presented to the user. A percent-escaped string is
de-escaped by replacing all occurrences of '%XY' by the byte that
has the hexadecimal value 'XY'. 'X' and 'Y' are from the set
'0-9a-f'.
localized
Some fields contain strings that are described to be _localized_.
Such strings are translated to the active language and formatted in
the active character set.
unsigned number
Some fields contain an _unsigned number_. This number will always
fit into a 32-bit unsigned integer variable. The number may be
followed by a space, followed by a human readable description of
that value (if the verbose option is used). You should ignore
everything in the field that follows the number.
signed number
Some fields contain a _signed number_. This number will always fit
into a 32-bit signed integer variable. The number may be followed
by a space, followed by a human readable description of that value
(if the verbose option is used). You should ignore everything in
the field that follows the number.
boolean value
Some fields contain a _boolean value_. This is a number with
either the value 0 or 1. The number may be followed by a space,
followed by a human readable description of that value (if the
verbose option is used). You should ignore everything in the field
that follows the number; checking just the first character is
sufficient in this case.
option
Some fields contain an _option_ argument. The format of an option
argument depends on the type of the option and on some flags:
no argument
The simplest case is that the option does not take an argument
at all (TYPE '0'). Then the option argument is an unsigned
number that specifies how often the option occurs. If the
'list' flag is not set, then the only valid number is '1'.
Options that do not take an argument never have the 'default'
or 'optional arg' flag set.
number
If the option takes a number argument (ALT-TYPE is '2' or
'3'), and it can only occur once ('list' flag is not set),
then the option argument is either empty (only allowed if the
argument is optional), or it is a number. A number is a
string that begins with an optional minus character, followed
by one or more digits. The number must fit into an integer
variable (unsigned or signed, depending on ALT-TYPE).
number list
If the option takes a number argument and it can occur more
than once, then the option argument is either empty, or it is
a comma-separated list of numbers as described above.
string
If the option takes a string argument (ALT-TYPE is 1), and it
can only occur once ('list' flag is not set) then the option
argument is either empty (only allowed if the argument is
optional), or it starts with a double quote character ('"')
followed by a percent-escaped string that is the argument
value. Note that there is only a leading double quote
character, no trailing one. The double quote character is
only needed to be able to differentiate between no value and
the empty string as value.
string list
If the option takes a string argument and it can occur more
than once, then the option argument is either empty, or it is
a comma-separated list of string arguments as described above.
The active language and character set are currently determined from
the locale environment of the 'gpgconf' program.
File: gnupg.info, Node: Listing components, Next: Checking programs, Prev: Format conventions, Up: gpgconf
9.4.3 Listing components
------------------------
The command '--list-components' will list all components that can be
configured with 'gpgconf'. Usually, one component will correspond to
one GnuPG-related program and contain the options of that program's
configuration file that can be modified using 'gpgconf'. However, this
is not necessarily the case. A component might also be a group of
selected options from several programs, or contain entirely virtual
options that have a special effect rather than changing exactly one
option in one configuration file.
A component is a set of configuration options that semantically
belong together. Furthermore, several changes to a component can be
made in an atomic way with a single operation. The GUI could for
example provide a menu with one entry for each component, or a window
with one tabulator sheet per component.
The command '--list-components' lists all available components, one
per line. The format of each line is:
'NAME:DESCRIPTION:PGMNAME:'
NAME
This field contains a name tag of the component. The name tag is
used to specify the component in all communication with 'gpgconf'.
The name tag is to be used _verbatim_. It is thus not in any
escaped format.
DESCRIPTION
The _string_ in this field contains a human-readable description of
the component. It can be displayed to the user of the GUI for
informational purposes. It is _percent-escaped_ and _localized_.
PGMNAME
The _string_ in this field contains the absolute name of the
program's file. It can be used to unambiguously invoke that
program. It is _percent-escaped_.
Example:
$ gpgconf --list-components
gpg:GPG for OpenPGP:/usr/local/bin/gpg2:
gpg-agent:GPG Agent:/usr/local/bin/gpg-agent:
scdaemon:Smartcard Daemon:/usr/local/bin/scdaemon:
gpgsm:GPG for S/MIME:/usr/local/bin/gpgsm:
dirmngr:Directory Manager:/usr/local/bin/dirmngr:
File: gnupg.info, Node: Checking programs, Next: Listing options, Prev: Listing components, Up: gpgconf
9.4.4 Checking programs
-----------------------
The command '--check-programs' is similar to '--list-components' but
works on backend programs and not on components. It runs each program
to test whether it is installed and runnable. This also includes a
syntax check of all config file options of the program.
The command '--check-programs' lists all available programs, one per
line. The format of each line is:
'NAME:DESCRIPTION:PGMNAME:AVAIL:OKAY:CFGFILE:LINE:ERROR:'
NAME
This field contains a name tag of the program which is identical to
the name of the component. The name tag is to be used _verbatim_.
It is thus not in any escaped format. This field may be empty to
indicate a continuation of error descriptions for the last name.
The description and pgmname fields are then also empty.
DESCRIPTION
The _string_ in this field contains a human-readable description of
the component. It can be displayed to the user of the GUI for
informational purposes. It is _percent-escaped_ and _localized_.
PGMNAME
The _string_ in this field contains the absolute name of the
program's file. It can be used to unambiguously invoke that
program. It is _percent-escaped_.
AVAIL
The _boolean value_ in this field indicates whether the program is
installed and runnable.
OKAY
The _boolean value_ in this field indicates whether the program's
config file is syntactically okay.
CFGFILE
If an error occurred in the configuration file (as indicated by a
false value in the field 'okay'), this field has the name of the
failing configuration file. It is _percent-escaped_.
LINE
If an error occurred in the configuration file, this field has the
line number of the failing statement in the configuration file. It
is an _unsigned number_.
ERROR
If an error occurred in the configuration file, this field has the
error text of the failing statement in the configuration file. It
is _percent-escaped_ and _localized_.
In the following example the 'dirmngr' is not runnable and the
configuration file of 'scdaemon' is not okay.
$ gpgconf --check-programs
gpg:GPG for OpenPGP:/usr/local/bin/gpg2:1:1:
gpg-agent:GPG Agent:/usr/local/bin/gpg-agent:1:1:
scdaemon:Smartcard Daemon:/usr/local/bin/scdaemon:1:0:
gpgsm:GPG for S/MIME:/usr/local/bin/gpgsm:1:1:
dirmngr:Directory Manager:/usr/local/bin/dirmngr:0:0:
The command '--check-options COMPONENT' will verify the configuration
file in the same manner as '--check-programs', but only for the
component COMPONENT.
File: gnupg.info, Node: Listing options, Next: Changing options, Prev: Checking programs, Up: gpgconf
9.4.5 Listing options
---------------------
Every component contains one or more options. Options may be gathered
into option groups to allow the GUI to give visual hints to the user
about which options are related.
The command '--list-options COMPONENT' lists all options (and the
groups they belong to) in the component COMPONENT, one per line.
COMPONENT must be the string in the field NAME in the output of the
'--list-components' command.
There is one line for each option and each group. First come all
options that are not in any group. Then comes a line describing a
group. Then come all options that belong into each group. Then comes
the next group and so on. There does not need to be any group (and in
this case the output will stop after the last non-grouped option).
The format of each line is:
'NAME:FLAGS:LEVEL:DESCRIPTION:TYPE:ALT-TYPE:ARGNAME:DEFAULT:ARGDEF:VALUE'
NAME
This field contains a name tag for the group or option. The name
tag is used to specify the group or option in all communication
with 'gpgconf'. The name tag is to be used _verbatim_. It is thus
not in any escaped format.
FLAGS
The flags field contains an _unsigned number_. Its value is the
OR-wise combination of the following flag values:
'group (1)'
If this flag is set, this is a line describing a group and not
an option.
The following flag values are only defined for options (that is, if
the 'group' flag is not used).
'optional arg (2)'
If this flag is set, the argument is optional. This is never
set for TYPE '0' (none) options.
'list (4)'
If this flag is set, the option can be given multiple times.
'runtime (8)'
If this flag is set, the option can be changed at runtime.
'default (16)'
If this flag is set, a default value is available.
'default desc (32)'
If this flag is set, a (runtime) default is available. This
and the 'default' flag are mutually exclusive.
'no arg desc (64)'
If this flag is set, and the 'optional arg' flag is set, then
the option has a special meaning if no argument is given.
'no change (128)'
If this flag is set, 'gpgconf' ignores requests to change the
value. GUI frontends should grey out this option. Note, that
manual changes of the configuration files are still possible.
LEVEL
This field is defined for options and for groups. It contains an
_unsigned number_ that specifies the expert level under which this
group or option should be displayed. The following expert levels
are defined for options (they have analogous meaning for groups):
'basic (0)'
This option should always be offered to the user.
'advanced (1)'
This option may be offered to advanced users.
'expert (2)'
This option should only be offered to expert users.
'invisible (3)'
This option should normally never be displayed, not even to
expert users.
'internal (4)'
This option is for internal use only. Ignore it.
The level of a group will always be the lowest level of all options
it contains.
DESCRIPTION
This field is defined for options and groups. The _string_ in this
field contains a human-readable description of the option or group.
It can be displayed to the user of the GUI for informational
purposes. It is _percent-escaped_ and _localized_.
TYPE
This field is only defined for options. It contains an _unsigned
number_ that specifies the type of the option's argument, if any.
The following types are defined:
Basic types:
'none (0)'
No argument allowed.
'string (1)'
An _unformatted string_.
'int32 (2)'
A _signed number_.
'uint32 (3)'
An _unsigned number_.
Complex types:
'pathname (32)'
A _string_ that describes the pathname of a file. The file
does not necessarily need to exist.
'ldap server (33)'
A _string_ that describes an LDAP server in the format:
'HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN'
'key fingerprint (34)'
A _string_ with a 40 digit fingerprint specifying a
certificate.
'pub key (35)'
A _string_ that describes a certificate by user ID, key ID or
fingerprint.
'sec key (36)'
A _string_ that describes a certificate with a key by user ID,
key ID or fingerprint.
'alias list (37)'
A _string_ that describes an alias list, like the one used
with gpg's group option. The list consists of a key, an equal
sign and space separated values.
More types will be added in the future. Please see the ALT-TYPE
field for information on how to cope with unknown types.
ALT-TYPE
This field is identical to TYPE, except that only the types '0' to
'31' are allowed. The GUI is expected to present the user the
option in the format specified by TYPE. But if the argument type
TYPE is not supported by the GUI, it can still display the option
in the more generic basic type ALT-TYPE. The GUI must support all
the defined basic types to be able to display all options. More
basic types may be added in future versions. If the GUI encounters
a basic type it doesn't support, it should report an error and
abort the operation.
ARGNAME
This field is only defined for options with an argument type TYPE
that is not '0'. In this case it may contain a _percent-escaped_
and _localized string_ that gives a short name for the argument.
The field may also be empty, though, in which case a short name is
not known.
DEFAULT
This field is defined only for options for which the 'default' or
'default desc' flag is set. If the 'default' flag is set, its
format is that of an _option argument_ (*note Format conventions::,
for details). If the default value is empty, then no default is
known. Otherwise, the value specifies the default value for this
option. If the 'default desc' flag is set, the field is either
empty or contains a description of the effect if the option is not
given.
ARGDEF
This field is defined only for options for which the 'optional arg'
flag is set. If the 'no arg desc' flag is not set, its format is
that of an _option argument_ (*note Format conventions::, for
details). If the default value is empty, then no default is known.
Otherwise, the value specifies the default argument for this
option. If the 'no arg desc' flag is set, the field is either
empty or contains a description of the effect of this option if no
argument is given.
VALUE
This field is defined only for options. Its format is that of an
_option argument_. If it is empty, then the option is not
explicitly set in the current configuration, and the default
applies (if any). Otherwise, it contains the current value of the
option. Note that this field is also meaningful if the option
itself does not take a real argument (in this case, it contains the
number of times the option appears).
File: gnupg.info, Node: Changing options, Next: Listing global options, Prev: Listing options, Up: gpgconf
9.4.6 Changing options
----------------------
The command '--change-options COMPONENT' will attempt to change the
options of the component COMPONENT to the specified values. COMPONENT
must be the string in the field NAME in the output of the
'--list-components' command. You have to provide the options that shall
be changed in the following format on standard input:
'NAME:FLAGS:NEW-VALUE'
NAME
This is the name of the option to change. NAME must be the string
in the field NAME in the output of the '--list-options' command.
FLAGS
The flags field contains an _unsigned number_. Its value is the
OR-wise combination of the following flag values:
'default (16)'
If this flag is set, the option is deleted and the default
value is used instead (if applicable).
NEW-VALUE
The new value for the option. This field is only defined if the
'default' flag is not set. The format is that of an _option
argument_. If it is empty (or the field is omitted), the default
argument is used (only allowed if the argument is optional for this
option). Otherwise, the option will be set to the specified value.
The output of the command is the same as that of '--check-options' for
the modified configuration file.
Examples:
To set the force option, which is of basic type 'none (0)':
$ echo 'force:0:1' | gpgconf --change-options dirmngr
To delete the force option:
$ echo 'force:16:' | gpgconf --change-options dirmngr
The '--runtime' option can influence when the changes take effect.
File: gnupg.info, Node: Listing global options, Next: Querying versions, Prev: Changing options, Up: gpgconf
9.4.7 Listing global options
----------------------------
Sometimes it is useful for applications to look at the global options
file 'gpgconf.conf'. The colon separated listing format is record
oriented and uses the first field to identify the record type:
'k'
This describes a key record to start the definition of a new
ruleset for a user/group. The format of a key record is:
'k:USER:GROUP:'
USER
This is the user field of the key. It is percent escaped.
See the definition of the gpgconf.conf format for details.
GROUP
This is the group field of the key. It is percent escaped.
'r'
This describes a rule record. All rule records up to the next key
record make up a rule set for that key. The format of a rule
record is:
'r:::COMPONENT:OPTION:FLAG:VALUE:'
COMPONENT
This is the component part of a rule. It is a plain string.
OPTION
This is the option part of a rule. It is a plain string.
FLAG
This is the flags part of a rule. There may be only one flag
per rule but by using the same component and option, several
flags may be assigned to an option. It is a plain string.
VALUE
This is the optional value for the option. It is a percent
escaped string with a single quotation mark to indicate a
string. The quotation mark is only required to distinguish
between no value specified and an empty string.
Unknown record types should be ignored. Note that there is
intentionally no feature to change the global option file through
'gpgconf'.
File: gnupg.info, Node: Querying versions, Next: Files used by gpgconf, Prev: Listing global options, Up: gpgconf
9.4.8 Get and compare software versions.
----------------------------------------
The GnuPG Project operates a server to query the current versions of
software packages related to GnuPG. 'gpgconf' can be used to access this
online database. To allow for offline operations, this feature works by
having 'dirmngr' download a file from 'https://versions.gnupg.org',
checking the signature of that file and storing the file in the GnuPG
home directory. If 'gpgconf' is used and 'dirmngr' is running, it may
ask 'dirmngr' to refresh that file before itself uses the file.
The command '--query-swdb' returns information for the given package
in a colon delimited format:
NAME
This is the name of the package as requested. Note that "gnupg" is
a special name which is replaced by the actual package implementing
this version of GnuPG. For this name it is also not required to
specify a version because 'gpgconf' takes its own version in this
case.
IVERSION
The currently installed version or an empty string. The value is
taken from the command line argument but may be provided by gpg if
not given.
STATUS
The status of the software package according to this table:
'-'
No information available. This is either because no current
version has been specified or due to an error.
'?'
The given name is not known in the online database.
'u'
An update of the software is available.
'c'
The installed version of the software is current.
'n'
The installed version is already newer than the released
version.
URGENCY
If the value (the empty string should be considered as zero) is
greater than zero an important update is available.
ERROR
This returns an 'gpg-error' error code to distinguish between
various failure modes.
FILEDATE
This gives the date of the file with the version numbers in
standard ISO format ('yyyymmddThhmmss'). The date has been
extracted by 'dirmngr' from the signature of the file.
VERIFIED
This gives the date in ISO format the file was downloaded. This
value can be used to evaluate the freshness of the information.
VERSION
This returns the version string for the requested software from the
file.
RELDATE
This returns the release date in ISO format.
SIZE
This returns the size of the package as decimal number of bytes.
HASH
This returns a hexified SHA-2 hash of the package.
More fields may be added in future to the output.
File: gnupg.info, Node: Files used by gpgconf, Prev: Querying versions, Up: gpgconf
9.4.9 Files used by gpgconf
---------------------------
'/etc/gnupg/gpgconf.conf'
If this file exists, it is processed as a global configuration
file. A commented example can be found in the 'examples' directory
of the distribution.
'GNUPGHOME/swdb.lst'
A file with current software versions. 'dirmngr' creates this file
on demand from an online resource.
File: gnupg.info, Node: applygnupgdefaults, Next: gpg-preset-passphrase, Prev: gpgconf, Up: Helper Tools
9.5 Run gpgconf for all users
=============================
This script is a wrapper around 'gpgconf' to run it with the command
'--apply-defaults' for all real users with an existing GnuPG home
directory. Admins might want to use this script to update he GnuPG
configuration files for all users after '/etc/gnupg/gpgconf.conf' has
been changed. This allows enforcing certain policies for all users.
Note, that this is not a bulletproof way to force a user to use certain
options. A user may always directly edit the configuration files and
bypass gpgconf.
'applygnupgdefaults' is invoked by root as:
applygnupgdefaults
File: gnupg.info, Node: gpg-preset-passphrase, Next: gpg-connect-agent, Prev: applygnupgdefaults, Up: Helper Tools
9.6 Put a passphrase into the cache
===================================
The 'gpg-preset-passphrase' is a utility to seed the internal cache of a
running 'gpg-agent' with passphrases. It is mainly useful for
unattended machines, where the usual 'pinentry' tool may not be used and
the passphrases for the to be used keys are given at machine startup.
This program works with GnuPG 2 and later. GnuPG 1.x is not
supported.
Passphrases set with this utility don't expire unless the '--forget'
option is used to explicitly clear them from the cache -- or 'gpg-agent'
is either restarted or reloaded (by sending a SIGHUP to it). Note that
the maximum cache time as set with '--max-cache-ttl' is still honored.
It is necessary to allow this passphrase presetting by starting
'gpg-agent' with the '--allow-preset-passphrase'.
* Menu:
* Invoking gpg-preset-passphrase:: List of all commands and options.
File: gnupg.info, Node: Invoking gpg-preset-passphrase, Up: gpg-preset-passphrase
9.6.1 List of all commands and options
--------------------------------------
'gpg-preset-passphrase' is invoked this way:
gpg-preset-passphrase [options] [command] CACHEID
CACHEID is either a 40 character keygrip of hexadecimal characters
identifying the key for which the passphrase should be set or cleared.
The keygrip is listed along with the key when running the command:
'gpgsm --with-keygrip --list-secret-keys'. Alternatively an arbitrary
string may be used to identify a passphrase; it is suggested that such a
string is prefixed with the name of the application (e.g 'foo:12346').
Scripts should always use the option '--with-colons', which provides the
keygrip in a "grp" line (cf. 'doc/DETAILS')/
One of the following command options must be given:
'--preset'
Preset a passphrase. This is what you usually will use.
'gpg-preset-passphrase' will then read the passphrase from 'stdin'.
'--forget'
Flush the passphrase for the given cache ID from the cache.
The following additional options may be used:
'-v'
'--verbose'
Output additional information while running.
'-P STRING'
'--passphrase STRING'
Instead of reading the passphrase from 'stdin', use the supplied
STRING as passphrase. Note that this makes the passphrase visible
for other users.
File: gnupg.info, Node: gpg-connect-agent, Next: dirmngr-client, Prev: gpg-preset-passphrase, Up: Helper Tools
9.7 Communicate with a running agent
====================================
The 'gpg-connect-agent' is a utility to communicate with a running
'gpg-agent'. It is useful to check out the commands 'gpg-agent'
provides using the Assuan interface. It might also be useful for
scripting simple applications. Input is expected at stdin and output
gets printed to stdout.
It is very similar to running 'gpg-agent' in server mode; but here we
connect to a running instance.
* Menu:
* Invoking gpg-connect-agent:: List of all options.
* Controlling gpg-connect-agent:: Control commands.
File: gnupg.info, Node: Invoking gpg-connect-agent, Next: Controlling gpg-connect-agent, Up: gpg-connect-agent
9.7.1 List of all options
-------------------------
'gpg-connect-agent' is invoked this way:
gpg-connect-agent [options] [commands]
The following options may be used:
'-v'
'--verbose'
Output additional information while running.
'-q'
'--quiet'
Try to be as quiet as possible.
'--homedir DIR'
Set the name of the home directory to DIR. If this option is not
used, the home directory defaults to '~/.gnupg'. It is only
recognized when given on the command line. It also overrides any
home directory stated through the environment variable 'GNUPGHOME'
or (on Windows systems) by means of the Registry entry
HKCU\SOFTWARE\GNU\GNUPG:HOMEDIR.
On Windows systems it is possible to install GnuPG as a portable
application. In this case only this command line option is
considered, all other ways to set a home directory are ignored.
To install GnuPG as a portable application under Windows, create an
empty file named 'gpgconf.ctl' in the same directory as the tool
'gpgconf.exe'. The root of the installation is then that
directory; or, if 'gpgconf.exe' has been installed directly below a
directory named 'bin', its parent directory. You also need to make
sure that the following directories exist and are writable:
'ROOT/home' for the GnuPG home and 'ROOT/usr/local/var/cache/gnupg'
for internal cache files.
'--agent-program FILE'
Specify the agent program to be started if none is running. The
default value is determined by running 'gpgconf' with the option
'--list-dirs'. Note that the pipe symbol ('|') is used for a
regression test suite hack and may thus not be used in the file
name.
'--dirmngr-program FILE'
Specify the directory manager (keyserver client) program to be
started if none is running. This has only an effect if used
together with the option '--dirmngr'.
'--dirmngr'
Connect to a running directory manager (keyserver client) instead
of to the gpg-agent. If a dirmngr is not running, start it.
'-S'
'--raw-socket NAME'
Connect to socket NAME assuming this is an Assuan style server. Do
not run any special initializations or environment checks. This
may be used to directly connect to any Assuan style socket server.
'-E'
'--exec'
Take the rest of the command line as a program and it's arguments
and execute it as an Assuan server. Here is how you would run
'gpgsm':
gpg-connect-agent --exec gpgsm --server
Note that you may not use options on the command line in this case.
'--no-ext-connect'
When using '-S' or '--exec', 'gpg-connect-agent' connects to the
Assuan server in extended mode to allow descriptor passing. This
option makes it use the old mode.
'--no-autostart'
Do not start the gpg-agent or the dirmngr if it has not yet been
started.
'-r FILE'
'--run FILE'
Run the commands from FILE at startup and then continue with the
regular input method. Note, that commands given on the command
line are executed after this file.
'-s'
'--subst'
Run the command '/subst' at startup.
'--hex'
Print data lines in a hex format and the ASCII representation of
non-control characters.
'--decode'
Decode data lines. That is to remove percent escapes but make sure
that a new line always starts with a D and a space.
File: gnupg.info, Node: Controlling gpg-connect-agent, Prev: Invoking gpg-connect-agent, Up: gpg-connect-agent
9.7.2 Control commands
----------------------
While reading Assuan commands, gpg-agent also allows a few special
commands to control its operation. These control commands all start
with a slash ('/').
'/echo ARGS'
Just print ARGS.
'/let NAME VALUE'
Set the variable NAME to VALUE. Variables are only substituted on
the input if the '/subst' has been used. Variables are referenced
by prefixing the name with a dollar sign and optionally include the
name in curly braces. The rules for a valid name are identically
to those of the standard bourne shell. This is not yet enforced
but may be in the future. When used with curly braces no leading
or trailing white space is allowed.
If a variable is not found, it is searched in the environment and
if found copied to the table of variables.
Variable functions are available: The name of the function must be
followed by at least one space and the at least one argument. The
following functions are available:
'get'
Return a value described by the argument. Available arguments
are:
'cwd'
The current working directory.
'homedir'
The gnupg homedir.
'sysconfdir'
GnuPG's system configuration directory.
'bindir'
GnuPG's binary directory.
'libdir'
GnuPG's library directory.
'libexecdir'
GnuPG's library directory for executable files.
'datadir'
GnuPG's data directory.
'serverpid'
The PID of the current server. Command '/serverpid' must
have been given to return a useful value.
'unescape ARGS'
Remove C-style escapes from ARGS. Note that '\0' and '\x00'
terminate the returned string implicitly. The string to be
converted are the entire arguments right behind the delimiting
space of the function name.
'unpercent ARGS'
'unpercent+ ARGS'
Remove percent style escaping from ARGS. Note that '%00'
terminates the string implicitly. The string to be converted
are the entire arguments right behind the delimiting space of
the function name. 'unpercent+' also maps plus signs to a
spaces.
'percent ARGS'
'percent+ ARGS'
Escape the ARGS using percent style escaping. Tabs,
formfeeds, linefeeds, carriage returns and colons are escaped.
'percent+' also maps spaces to plus signs.
'errcode ARG'
'errsource ARG'
'errstring ARG'
Assume ARG is an integer and evaluate it using 'strtol'.
Return the gpg-error error code, error source or a formatted
string with the error code and error source.
'+'
'-'
'*'
'/'
'%'
Evaluate all arguments as long integers using 'strtol' and
apply this operator. A division by zero yields an empty
string.
'!'
'|'
'&'
Evaluate all arguments as long integers using 'strtol' and
apply the logical operators NOT, OR or AND. The NOT operator
works on the last argument only.
'/definq NAME VAR'
Use content of the variable VAR for inquiries with NAME. NAME may
be an asterisk ('*') to match any inquiry.
'/definqfile NAME FILE'
Use content of FILE for inquiries with NAME. NAME may be an
asterisk ('*') to match any inquiry.
'/definqprog NAME PROG'
Run PROG for inquiries matching NAME and pass the entire line to it
as command line arguments.
'/datafile NAME'
Write all data lines from the server to the file NAME. The file is
opened for writing and created if it does not exists. An existing
file is first truncated to 0. The data written to the file fully
decoded. Using a single dash for NAME writes to stdout. The file
is kept open until a new file is set using this command or this
command is used without an argument.
'/showdef'
Print all definitions
'/cleardef'
Delete all definitions
'/sendfd FILE MODE'
Open FILE in MODE (which needs to be a valid 'fopen' mode string)
and send the file descriptor to the server. This is usually
followed by a command like 'INPUT FD' to set the input source for
other commands.
'/recvfd'
Not yet implemented.
'/open VAR FILE [MODE]'
Open FILE and assign the file descriptor to VAR. Warning: This
command is experimental and might change in future versions.
'/close FD'
Close the file descriptor FD. Warning: This command is
experimental and might change in future versions.
'/showopen'
Show a list of open files.
'/serverpid'
Send the Assuan command 'GETINFO pid' to the server and store the
returned PID for internal purposes.
'/sleep'
Sleep for a second.
'/hex'
'/nohex'
Same as the command line option '--hex'.
'/decode'
'/nodecode'
Same as the command line option '--decode'.
'/subst'
'/nosubst'
Enable and disable variable substitution. It defaults to disabled
unless the command line option '--subst' has been used. If /subst
as been enabled once, leading whitespace is removed from input
lines which makes scripts easier to read.
'/while CONDITION'
'/end'
These commands provide a way for executing loops. All lines
between the 'while' and the corresponding 'end' are executed as
long as the evaluation of CONDITION yields a non-zero value or is
the string 'true' or 'yes'. The evaluation is done by passing
CONDITION to the 'strtol' function. Example:
/subst
/let i 3
/while $i
/echo loop counter is $i
/let i ${- $i 1}
/end
'/if CONDITION'
'/end'
These commands provide a way for conditional execution. All lines
between the 'if' and the corresponding 'end' are executed only if
the evaluation of CONDITION yields a non-zero value or is the
string 'true' or 'yes'. The evaluation is done by passing
CONDITION to the 'strtol' function.
'/run FILE'
Run commands from FILE.
'/bye'
Terminate the connection and the program.
'/help'
Print a list of available control commands.
File: gnupg.info, Node: dirmngr-client, Next: gpgparsemail, Prev: gpg-connect-agent, Up: Helper Tools
9.8 The Dirmngr Client Tool
===========================
The 'dirmngr-client' is a simple tool to contact a running dirmngr and
test whether a certificate has been revoked -- either by being listed in
the corresponding CRL or by running the OCSP protocol. If no dirmngr is
running, a new instances will be started but this is in general not a
good idea due to the huge performance overhead.
The usual way to run this tool is either:
dirmngr-client ACERT
or
dirmngr-client <ACERT
Where ACERT is one DER encoded (binary) X.509 certificates to be
tested. The return value of this command is
'0'
The certificate under question is valid; i.e. there is a valid CRL
available and it is not listed there or the OCSP request returned
that that certificate is valid.
'1'
The certificate has been revoked
'2 (and other values)'
There was a problem checking the revocation state of the
certificate. A message to stderr has given more detailed
information. Most likely this is due to a missing or expired CRL
or due to a network problem.
'dirmngr-client' may be called with the following options:
'--version'
Print the program version and licensing information. Note that you
cannot abbreviate this command.
'--help, -h'
Print a usage message summarizing the most useful command-line
options. Note that you cannot abbreviate this command.
'--quiet, -q'
Make the output extra brief by suppressing any informational
messages.
'-v'
'--verbose'
Outputs additional information while running. You can increase the
verbosity by giving several verbose commands to DIRMNGR, such as
'-vv'.
'--pem'
Assume that the given certificate is in PEM (armored) format.
'--ocsp'
Do the check using the OCSP protocol and ignore any CRLs.
'--force-default-responder'
When checking using the OCSP protocol, force the use of the default
OCSP responder. That is not to use the Reponder as given by the
certificate.
'--ping'
Check whether the dirmngr daemon is up and running.
'--cache-cert'
Put the given certificate into the cache of a running dirmngr.
This is mainly useful for debugging.
'--validate'
Validate the given certificate using dirmngr's internal validation
code. This is mainly useful for debugging.
'--load-crl'
This command expects a list of filenames with DER encoded CRL
files. With the option '--url' URLs are expected in place of
filenames and they are loaded directly from the given location.
All CRLs will be validated and then loaded into dirmngr's cache.
'--lookup'
Take the remaining arguments and run a lookup command on each of
them. The results are Base-64 encoded outputs (without header
lines). This may be used to retrieve certificates from a server.
However the output format is not very well suited if more than one
certificate is returned.
'--url'
'-u'
Modify the 'lookup' and 'load-crl' commands to take an URL.
'--local'
'-l'
Let the 'lookup' command only search the local cache.
'--squid-mode'
Run DIRMNGR-CLIENT in a mode suitable as a helper program for
Squid's 'external_acl_type' option.
File: gnupg.info, Node: gpgparsemail, Next: symcryptrun, Prev: dirmngr-client, Up: Helper Tools
9.9 Parse a mail message into an annotated format
=================================================
The 'gpgparsemail' is a utility currently only useful for debugging.
Run it with '--help' for usage information.
File: gnupg.info, Node: symcryptrun, Next: gpgtar, Prev: gpgparsemail, Up: Helper Tools
9.10 Call a simple symmetric encryption tool
============================================
Sometimes simple encryption tools are already in use for a long time and
there might be a desire to integrate them into the GnuPG framework. The
protocols and encryption methods might be non-standard or not even
properly documented, so that a full-fledged encryption tool with an
interface like 'gpg' is not doable. 'symcryptrun' provides a solution:
It operates by calling the external encryption/decryption module and
provides a passphrase for a key using the standard 'pinentry' based
mechanism through 'gpg-agent'.
Note, that 'symcryptrun' is only available if GnuPG has been
configured with '--enable-symcryptrun' at build time.
* Menu:
* Invoking symcryptrun:: List of all commands and options.
File: gnupg.info, Node: Invoking symcryptrun, Up: symcryptrun
9.10.1 List of all commands and options
---------------------------------------
'symcryptrun' is invoked this way:
symcryptrun --class CLASS --program PROGRAM --keyfile KEYFILE
[--decrypt | --encrypt] [inputfile]
For encryption, the plain text must be provided on STDIN or as the
argument INPUTFILE, and the ciphertext will be output to STDOUT. For
decryption vice versa.
CLASS describes the calling conventions of the external tool.
Currently it must be given as 'confucius'. PROGRAM is the full filename
of that external tool.
For the class 'confucius' the option '--keyfile' is required; KEYFILE
is the name of a file containing the secret key, which may be protected
by a passphrase. For detailed calling conventions, see the source code.
Note, that 'gpg-agent' must be running before starting 'symcryptrun'.
The following additional options may be used:
'-v'
'--verbose'
Output additional information while running.
'-q'
'--quiet'
Try to be as quiet as possible.
'--homedir DIR'
Set the name of the home directory to DIR. If this option is not
used, the home directory defaults to '~/.gnupg'. It is only
recognized when given on the command line. It also overrides any
home directory stated through the environment variable 'GNUPGHOME'
or (on Windows systems) by means of the Registry entry
HKCU\SOFTWARE\GNU\GNUPG:HOMEDIR.
On Windows systems it is possible to install GnuPG as a portable
application. In this case only this command line option is
considered, all other ways to set a home directory are ignored.
To install GnuPG as a portable application under Windows, create an
empty file named 'gpgconf.ctl' in the same directory as the tool
'gpgconf.exe'. The root of the installation is then that
directory; or, if 'gpgconf.exe' has been installed directly below a
directory named 'bin', its parent directory. You also need to make
sure that the following directories exist and are writable:
'ROOT/home' for the GnuPG home and 'ROOT/usr/local/var/cache/gnupg'
for internal cache files.
'--log-file FILE'
Append all logging output to FILE. Use 'socket://' to log to
socket. Default is to write logging information to STDERR.
The possible exit status codes of 'symcryptrun' are:
'0'
Success.
'1'
Some error occurred.
'2'
No valid passphrase was provided.
'3'
The operation was canceled by the user.
File: gnupg.info, Node: gpgtar, Prev: symcryptrun, Up: Helper Tools
9.11 Encrypt or sign files into an archive
==========================================
'gpgtar' encrypts or signs files into an archive. It is an gpg-ized tar
using the same format as used by PGP's PGP Zip.
'gpgtar' is invoked this way:
gpgtar [options] FILENAME1 [FILENAME2, ...] DIRECTORY [DIRECTORY2, ...]
'gpgtar' understands these options:
'--create'
Put given files and directories into a vanilla "ustar" archive.
'--extract'
Extract all files from a vanilla "ustar" archive.
'--encrypt'
'-e'
Encrypt given files and directories into an archive. This option
may be combined with option '--symmetric' for an archive that may
be decrypted via a secret key or a passphrase.
'--decrypt'
'-d'
Extract all files from an encrypted archive.
'--sign'
'-s'
Make a signed archive from the given files and directories. This
can be combined with option '--encrypt' to create a signed and then
encrypted archive.
'--list-archive'
'-t'
List the contents of the specified archive.
'--symmetric'
'-c'
Encrypt with a symmetric cipher using a passphrase. The default
symmetric cipher used is AES-128, but may be chosen with the
'--cipher-algo' option to 'gpg'.
'--recipient USER'
'-r USER'
Encrypt for user id USER. For details see 'gpg'.
'--local-user USER'
'-u USER'
Use USER as the key to sign with. For details see 'gpg'.
'--output FILE'
'-o FILE'
Write the archive to the specified file FILE.
'--verbose'
'-v'
Enable extra informational output.
'--quiet'
'-q'
Try to be as quiet as possible.
'--skip-crypto'
Skip all crypto operations and create or extract vanilla "ustar"
archives.
'--dry-run'
Do not actually output the extracted files.
'--directory DIR'
'-C DIR'
Extract the files into the directory DIR. The default is to take
the directory name from the input filename. If no input filename
is known a directory named 'GPGARCH' is used. For tarball
creation, switch to directory DIR before performing any operations.
'--files-from FILE'
'-T FILE'
Take the file names to work from the file FILE; one file per line.
'--null'
Modify option '--files-from' to use a binary nul instead of a
linefeed to separate file names.
'--utf8-strings'
Assume that the file names read by '--files-from' are UTF-8
encoded. This option has an effect only on Windows where the
active code page is otherwise assumed.
'--openpgp'
This option has no effect because OpenPGP encryption and signing is
the default.
'--cms'
This option is reserved and shall not be used. It will eventually
be used to encrypt or sign using the CMS protocol; but that is not
yet implemented.
'--set-filename FILE'
Use the last component of FILE as the output directory. The
default is to take the directory name from the input filename. If
no input filename is known a directory named 'GPGARCH' is used.
This option is deprecated in favor of option '--directory'.
'--gpg GPGCMD'
Use the specified command GPGCMD instead of 'gpg'.
'--gpg-args ARGS'
Pass the specified extra options to 'gpg'.
'--tar-args ARGS'
Assume ARGS are standard options of the command 'tar' and parse
them. The only supported tar options are "-directory",
"-files-from", and "-null" This is an obsolete options because
those supported tar options can also be given directly.
'--version'
Print version of the program and exit.
'--help'
Display a brief help page and exit.
The program returns 0 if everything was fine, 1 otherwise.
Some examples:
Encrypt the contents of directory 'mydocs' for user Bob to file 'test1':
gpgtar --encrypt --output test1 -r Bob mydocs
List the contents of archive 'test1':
gpgtar --list-archive test1
File: gnupg.info, Node: Web Key Service, Next: Howtos, Prev: Helper Tools, Up: Top
10 Web Key Service
******************
GnuPG comes with tools used to maintain and access a Web Key Directory.
* Menu:
* gpg-wks-client:: Send requests via WKS
* gpg-wks-server:: Server to provide the WKS.
File: gnupg.info, Node: gpg-wks-client, Next: gpg-wks-server, Up: Web Key Service
10.1 Send requests via WKS
==========================
The 'gpg-wks-client' is used to send requests to a Web Key Service
provider. This is usuallay done to upload a key into a Web Key
Directory.
With the '--supported' command the caller can test whether a site
supports the Web Key Service. The argument is an arbitrary address in
the to be tested domain. For example 'foo@example.net'. The command
returns success if the Web Key Service is supported. The operation is
silent; to get diagnostic output use the option '--verbose'. See option
'--with-colons' for a variant of this command.
With the '--check' command the caller can test whether a key exists
for a supplied mail address. The command returns success if a key is
available.
The '--create' command is used to send a request for publication in
the Web Key Directory. The arguments are the fingerprint of the key and
the user id to publish. The output from the command is a properly
formatted mail with all standard headers. This mail can be fed to
'sendmail(8)' or any other tool to actually send that mail. If
'sendmail(8)' is installed the option '--send' can be used to directly
send the created request. If the provider request a 'mailbox-only' user
id and no such user id is found, 'gpg-wks-client' will try an additional
user id.
The '--receive' and '--read' commands are used to process
confirmation mails as send from the service provider. The former
expects an encrypted MIME messages, the latter an already decrypted MIME
message. The result of these commands are another mail which can be
send in the same way as the mail created with '--create'.
The command '--install-key' manually installs a key into a local
directory (see option '-C') reflecting the structure of a WKD. The
arguments are a file with the keyblock and the user-id to install. If
the first argument resembles a fingerprint the key is taken from the
current keyring; to force the use of a file, prefix the first argument
with "./". If no arguments are given the parameters are read from
stdin; the expected format are lines with the fingerprint and the
mailbox separated by a space. The command '--remove-key' removes a key
from that directory, its only argument is a user-id.
The command '--print-wkd-hash' prints the WKD user-id identifiers and
the corresponding mailboxes from the user-ids given on the command line
or via stdin (one user-id per line).
The command '--print-wkd-url' prints the URLs used to fetch the key
for the given user-ids from WKD. The meanwhile preferred format with
sub-domains is used here.
'gpg-wks-client' is not commonly invoked directly and thus it is not
installed in the bin directory. Here is an example how it can be
invoked manually to check for a Web Key Directory entry for
'foo@example.org':
$(gpgconf --list-dirs libexecdir)/gpg-wks-client --check foo@example.net
'gpg-wks-client' understands these options:
'--send'
Directly send created mails using the 'sendmail' command. Requires
installation of that command.
'--with-colons'
This option has currently only an effect on the '--supported'
command. If it is used all arguments on the command line are taken
as domain names and tested for WKD support. The output format is
one line per domain with colon delimited fields. The currently
specified fields are (future versions may specify additional
fields):
1 - domain
This is the domain name. Although quoting is not required for
valid domain names this field is specified to be quoted in
standard C manner.
2 - WKD
If the value is true the domain supports the Web Key
Directory.
3 - WKS
If the value is true the domain supports the Web Key Service
protocol to upload keys to the directory.
4 - error-code
This may contain an gpg-error code to describe certain
failures. Use 'gpg-error CODE' to explain the code.
5 - protocol-version
The minimum protocol version supported by the server.
6 - auth-submit
The auth-submit flag from the policy file of the server.
7 - mailbox-only
The mailbox-only flag from the policy file of the server.
'--output FILE'
'-o'
Write the created mail to FILE instead of stdout. Note that the
value '-' for FILE is the same as writing to stdout.
'--status-fd N'
Write special status strings to the file descriptor N. This
program returns only the status messages SUCCESS or FAILURE which
are helpful when the caller uses a double fork approach and can't
easily get the return code of the process.
'-C DIR'
'--directory DIR'
Use DIR as top level directory for the commands '--install-key' and
'--remove-key'. The default is 'openpgpkey'.
'--verbose'
Enable extra informational output.
'--quiet'
Disable almost all informational output.
'--version'
Print version of the program and exit.
'--help'
Display a brief help page and exit.
File: gnupg.info, Node: gpg-wks-server, Prev: gpg-wks-client, Up: Web Key Service
10.2 Provide the Web Key Service
================================
The 'gpg-wks-server' is a server site implementation of the Web Key
Service. It receives requests for publication, sends confirmation
requests, receives confirmations, and published the key. It also has
features to ease the setup and maintenance of a Web Key Directory.
When used with the command '--receive' a single Web Key Service mail
is processed. Commonly this command is used with the option '--send' to
directly send the crerated mails back. See below for an installation
example.
The command '--cron' is used for regualr cleanup tasks. For example
non-confirmed requested should be removed after their expire time. It
is best to run this command once a day from a cronjob.
The command '--list-domains' prints all configured domains. Further
it creates missing directories for the configuration and prints warnings
pertaining to problems in the configuration.
The command '--check-key' (or just '--check') checks whether a key
with the given user-id is installed. The process returns success in
this case; to also print a diagnostic use the option '-v'. If the key
is not installed a diagnostic is printed and the process returns
failure; to suppress the diagnostic, use option '-q'. More than one
user-id can be given; see also option 'with-file'.
The command '--install-key' manually installs a key into the WKD. The
arguments are a file with the keyblock and the user-id to install. If
the first argument resembles a fingerprint the key is taken from the
current keyring; to force the use of a file, prefix the first argument
with "./". If no arguments are given the parameters are read from
stdin; the expected format are lines with the fingerprint and the
mailbox separated by a space.
The command '--remove-key' uninstalls a key from the WKD. The process
returns success in this case; to also print a diagnostic, use option
'-v'. If the key is not installed a diagnostic is printed and the
process returns failure; to suppress the diagnostic, use option '-q'.
The command '--revoke-key' is not yet functional.
'gpg-wks-server' understands these options:
'-C DIR'
'--directory DIR'
Use DIR as top level directory for domains. The default is
'/var/lib/gnupg/wks'.
'--from MAILADDR'
Use MAILADDR as the default sender address.
'--header NAME=VALUE'
Add the mail header "NAME: VALUE" to all outgoing mails.
'--send'
Directly send created mails using the 'sendmail' command. Requires
installation of that command.
'-o FILE'
'--output FILE'
Write the created mail also to FILE. Note that the value '-' for
FILE would write it to stdout.
'--with-dir'
When used with the command '--list-domains' print for each
installed domain the domain name and its directory name.
'--with-file'
When used with the command '--check-key' print for each user-id,
the address, 'i' for installed key or 'n' for not installed key,
and the filename.
'--verbose'
Enable extra informational output.
'--quiet'
Disable almost all informational output.
'--version'
Print version of the program and exit.
'--help'
Display a brief help page and exit.
Examples
********
The Web Key Service requires a working directory to store keys pending
for publication. As root create a working directory:
# mkdir /var/lib/gnupg/wks
# chown webkey:webkey /var/lib/gnupg/wks
# chmod 2750 /var/lib/gnupg/wks
Then under your webkey account create directories for all your
domains. Here we do it for "example.net":
$ mkdir /var/lib/gnupg/wks/example.net
Finally run
$ gpg-wks-server --list-domains
to create the required sub-directories with the permissions set
correctly. For each domain a submission address needs to be configured.
All service mails are directed to that address. It can be the same
address for all configured domains, for example:
$ cd /var/lib/gnupg/wks/example.net
$ echo key-submission@example.net >submission-address
The protocol requires that the key to be published is send with an
encrypted mail to the service. Thus you need to create a key for the
submission address:
$ gpg --batch --passphrase '' --quick-gen-key key-submission@example.net
$ gpg -K key-submission@example.net
The output of the last command looks similar to this:
sec rsa2048 2016-08-30 [SC]
C0FCF8642D830C53246211400346653590B3795B
uid [ultimate] key-submission@example.net
ssb rsa2048 2016-08-30 [E]
Take the fingerprint from that output and manually publish the key:
$ gpg-wks-server --install-key C0FCF8642D830C53246211400346653590B3795B \
> key-submission@example.net
Finally that submission address needs to be redirected to a script
running 'gpg-wks-server'. The 'procmail' command can be used for this:
Redirect the submission address to the user "webkey" and put this into
webkey's '.procmailrc':
:0
* !^From: webkey@example.net
* !^X-WKS-Loop: webkey.example.net
|gpg-wks-server -v --receive \
--header X-WKS-Loop=webkey.example.net \
--from webkey@example.net --send
File: gnupg.info, Node: Howtos, Next: System Notes, Prev: Web Key Service, Up: Top
11 How to do certain things
***************************
This is a collection of small howto documents.
* Menu:
* Howto Create a Server Cert:: Creating a TLS server certificate.
File: gnupg.info, Node: Howto Create a Server Cert, Up: Howtos
11.1 Creating a TLS server certificate
======================================
Here is a brief run up on how to create a server certificate. It has
actually been done this way to get a certificate from CAcert to be used
on a real server. It has only been tested with this CA, but there
shouldn't be any problem to run this against any other CA.
We start by generating an X.509 certificate signing request. As
there is no need for a configuration file, you may simply enter:
$ gpgsm --generate-key >example.com.cert-req.pem
Please select what kind of key you want:
(1) RSA
(2) Existing key
(3) Existing key from card
Your selection? 1
I opted for creating a new RSA key. The other option is to use an
already existing key, by selecting '2' and entering the so-called
keygrip. Running the command 'gpgsm --dump-secret-key USERID' shows you
this keygrip. Using '3' offers another menu to create a certificate
directly from a smart card based key.
Let's continue:
What keysize do you want? (3072)
Requested keysize is 3072 bits
Hitting enter chooses the default RSA key size of 3072 bits. Keys
smaller than 2048 bits are too weak on the modern Internet. If you
choose a larger (stronger) key, your server will need to do more work.
Possible actions for a RSA key:
(1) sign, encrypt
(2) sign
(3) encrypt
Your selection? 1
Selecting "sign" enables use of the key for Diffie-Hellman key
exchange mechanisms (DHE and ECDHE) in TLS, which are preferred because
they offer forward secrecy. Selecting "encrypt" enables RSA key
exchange mechanisms, which are still common in some places. Selecting
both enables both key exchange mechanisms.
Now for some real data:
Enter the X.509 subject name: CN=example.com
This is the most important value for a server certificate. Enter
here the canonical name of your server machine. You may add other
virtual server names later.
E-Mail addresses (end with an empty line):
>
We don't need email addresses in a TLS server certificate and CAcert
would anyway ignore such a request. Thus just hit enter.
If you want to create a client certificate for email encryption, this
would be the place to enter your mail address (e.g. <joe@example.org>).
You may enter as many addresses as you like, however the CA may not
accept them all or reject the entire request.
Enter DNS names (optional; end with an empty line):
> example.com
> www.example.com
>
Here I entered the names of the services which the machine actually
provides. You almost always want to include the canonical name here
too. The browser will accept a certificate for any of these names. As
usual the CA must approve all of these names.
URIs (optional; end with an empty line):
>
It is possible to insert arbitrary URIs into a certificate; for a
server certificate this does not make sense.
Create self-signed certificate? (y/N)
Since we are creating a certificate signing request, and not a full
certificate, we answer no here, or just hit enter for the default.
We have now entered all required information and 'gpgsm' will display
what it has gathered and ask whether to create the certificate request:
These parameters are used:
Key-Type: RSA
Key-Length: 3072
Key-Usage: sign, encrypt
Name-DN: CN=example.com
Name-DNS: example.com
Name-DNS: www.example.com
Proceed with creation? (y/N) y
'gpgsm' will now start working on creating the request. As this
includes the creation of an RSA key it may take a while. During this
time you will be asked 3 times for a passphrase to protect the created
private key on your system. A pop up window will appear to ask for it.
The first two prompts are for the new passphrase and for re-entering it;
the third one is required to actually create the certificate signing
request.
When it is ready, you should see the final notice:
Ready. You should now send this request to your CA.
Now, you may look at the created request:
$ cat example.com.cert-req.pem
-----BEGIN CERTIFICATE REQUEST-----
MIIClTCCAX0CAQAwFjEUMBIGA1UEAxMLZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQDP1QEcbTvOLLCX4gAoOzH9AW7jNOMj7OSOL0uW
h2bCdkK5YVpnX212Z6COTC3ZG0pJiCeGt1TbbDJUlTa4syQ6JXavjK66N8ASZsyC
Rwcl0m6hbXp541t1dbgt2VgeGk25okWw3j+brw6zxLD2TnthJxOatID0lDIG47HW
GqzZmA6WHbIBIONmGnReIHTpPAPCDm92vUkpKG1xLPszuRmsQbwEl870W/FHrsvm
DPvVUUSdIvTV9NuRt7/WY6G4nPp9QlIuTf1ESPzIuIE91gKPdrRCAx0yuT708S1n
xCv3ETQ/bKPoAQ67eE3mPBqkcVwv9SE/2/36Lz06kAizRgs5AgMBAAGgOjA4Bgkq
hkiG9w0BCQ4xKzApMCcGA1UdEQQgMB6CC2V4YW1wbGUuY29tgg93d3cuZXhhbXBs
ZS5jb20wDQYJKoZIhvcNAQELBQADggEBAEWD0Qqz4OENLYp6yyO/KqF0ig9FDsLN
b5/R+qhms5qlhdB5+Dh+j693Sj0UgbcNKc6JT86IuBqEBZmRCJuXRoKoo5aMS1cJ
hXga7N9IA3qb4VBUzBWvlL92U2Iptr/cEbikFlYZF2Zv3PBv8RfopVlI3OLbKV9D
bJJTt/6kuoydXKo/Vx4G0DFzIKNdFdJk86o/Ziz8NOs9JjZxw9H9VY5sHKFM5LKk
VcLwnnLRlNjBGB+9VK/Tze575eG0cJomTp7UGIB+1xzIQVAhUZOizRDv9tHDeaK3
k+tUhV0kuJcYHucpJycDSrP/uAY5zuVJ0rs2QSjdnav62YrRgEsxJrU=
-----END CERTIFICATE REQUEST-----
$
You may now proceed by logging into your account at the CAcert
website, choose 'Server Certificates - New', check 'sign by class 3 root
certificate', paste the above request block into the text field and
click on 'Submit'.
If everything works out fine, a certificate will be shown. Now run
$ gpgsm --import
and paste the certificate from the CAcert page into your terminal
followed by a Ctrl-D
-----BEGIN CERTIFICATE-----
MIIEIjCCAgqgAwIBAgIBTDANBgkqhkiG9w0BAQQFADBUMRQwEgYDVQQKEwtDQWNl
[...]
rUTFlNElRXCwIl0YcJkIaYYqWf7+A/aqYJCi8+51usZwMy3Jsq3hJ6MA3h1BgwZs
Rtct3tIX
-----END CERTIFICATE-----
gpgsm: issuer certificate (#/CN=CAcert Class 3 Ro[...]) not found
gpgsm: certificate imported
gpgsm: total number processed: 1
gpgsm: imported: 1
'gpgsm' tells you that it has imported the certificate. It is now
associated with the key you used when creating the request. The root
certificate has not been found, so you may want to import it from the
CACert website.
To see the content of your certificate, you may now enter:
$ gpgsm -K example.com
/home/foo/.gnupg/pubring.kbx
---------------------------
Serial number: 4C
Issuer: /CN=CAcert Class 3 Root/OU=http:\x2f\x2fwww.[...]
Subject: /CN=example.com
aka: (dns-name example.com)
aka: (dns-name www.example.com)
validity: 2015-07-01 16:20:51 through 2016-07-01 16:20:51
key type: 3072 bit RSA
key usage: digitalSignature keyEncipherment
ext key usage: clientAuth (suggested), serverAuth (suggested), [...]
fingerprint: 0F:9C:27:B2:DA:05:5F:CB:33:D8:19:E9:65:B9:4F:BD:B1:98:CC:57
I used '-K' above because this will only list certificates for which
a private key is available. To see more details, you may use
'--dump-secret-keys' instead of '-K'.
To make actual use of the certificate you need to install it on your
server. Server software usually expects a PKCS\#12 file with key and
certificate. To create such a file, run:
$ gpgsm --export-secret-key-p12 -a >example.com-cert.pem
You will be asked for the passphrase as well as for a new passphrase
to be used to protect the PKCS\#12 file. The file now contains the
certificate as well as the private key:
$ cat example-cert.pem
Issuer ...: /CN=CAcert Class 3 Root/OU=http:\x2f\x2fwww.CA[...]
Serial ...: 4C
Subject ..: /CN=example.com
aka ..: (dns-name example.com)
aka ..: (dns-name www.example.com)
-----BEGIN PKCS12-----
MIIHlwIBAzCCB5AGCSqGSIb37QdHAaCCB4EEggd9MIIHeTk1BJ8GCSqGSIb3DQEu
[...many more lines...]
-----END PKCS12-----
$
Copy this file in a secure way to the server, install it there and
delete the file then. You may export the file again at any time as long
as it is available in GnuPG's private key database.
File: gnupg.info, Node: System Notes, Next: Debugging, Prev: Howtos, Up: Top
12 Notes pertaining to certain OSes
***********************************
GnuPG has been developed on GNU/Linux systems and is know to work on
almost all Free OSes. All modern POSIX systems should be supported
right now, however there are probably a lot of smaller glitches we need
to fix first. The major problem areas are:
* We are planning to use file descriptor passing for interprocess
communication. This will allow us save a lot of resources and
improve performance of certain operations a lot. Systems not
supporting this won't gain these benefits but we try to keep them
working the standard way as it is done today.
* We require more or less full POSIX compatibility. This has been
around for 15 years now and thus we don't believe it makes sense to
support non POSIX systems anymore. Well, we of course the usual
workarounds for near POSIX systems well be applied.
There is one exception of this rule: Systems based the Microsoft
Windows API (called here _W32_) will be supported to some extend.
* Menu:
* W32 Notes:: Microsoft Windows Notes
File: gnupg.info, Node: W32 Notes, Up: System Notes
12.1 Microsoft Windows Notes
============================
Current limitations are:
* 'gpgconf' does not create backup files, so in case of trouble your
configuration file might get lost.
* 'watchgnupg' is not available. Logging to sockets is not possible.
* The periodical smartcard status checking done by 'scdaemon' is not
yet supported.
File: gnupg.info, Node: Debugging, Next: Copying, Prev: System Notes, Up: Top
13 How to solve problems
************************
Everyone knows that software often does not do what it should do and
thus there is a need to track down problems. We call this debugging in
a reminiscent to the moth jamming a relay in a Mark II box back in 1947.
Most of the problems a merely configuration and user problems but
nevertheless they are the most annoying ones and responsible for many
gray hairs. We try to give some guidelines here on how to identify and
solve the problem at hand.
* Menu:
* Debugging Tools:: Description of some useful tools.
* Debugging Hints:: Various hints on debugging.
* Common Problems:: Commonly seen problems.
* Architecture Details:: How the whole thing works internally.
File: gnupg.info, Node: Debugging Tools, Next: Debugging Hints, Up: Debugging
13.1 Debugging Tools
====================
The GnuPG distribution comes with a couple of tools, useful to help find
and solving problems.
* Menu:
* kbxutil:: Scrutinizing a keybox file.
File: gnupg.info, Node: kbxutil, Up: Debugging Tools
13.1.1 Scrutinizing a keybox file
---------------------------------
A keybox is a file format used to store public keys along with meta
information and indices. The commonly used one is the file
'pubring.kbx' in the '.gnupg' directory. It contains all X.509
certificates as well as OpenPGP keys.
When called the standard way, e.g.:
'kbxutil ~/.gnupg/pubring.kbx'
it lists all records (called blobs) with there meta-information in a
human readable format.
To see statistics on the keybox in question, run it using
'kbxutil --stats ~/.gnupg/pubring.kbx'
and you get an output like:
Total number of blobs: 99
header: 1
empty: 0
openpgp: 0
x509: 98
non flagged: 81
secret flagged: 0
ephemeral flagged: 17
In this example you see that the keybox does not have any OpenPGP
keys but contains 98 X.509 certificates and a total of 17 keys or
certificates are flagged as ephemeral, meaning that they are only
temporary stored (cached) in the keybox and won't get listed using the
usual commands provided by 'gpgsm' or 'gpg'. 81 certificates are stored
in a standard way and directly available from 'gpgsm'.
To find duplicated certificates and keyblocks in a keybox file (this
should not occur but sometimes things go wrong), run it using
'kbxutil --find-dups ~/.gnupg/pubring.kbx'
File: gnupg.info, Node: Debugging Hints, Next: Common Problems, Prev: Debugging Tools, Up: Debugging
13.2 Various hints on debugging
===============================
* How to find the IP address of a keyserver
If a round robin URL of is used for a keyserver (e.g.
subkeys.gnupg.org); it is not easy to see what server is actually
used. Using the keyserver debug option as in
gpg --keyserver-options debug=1 -v --refresh-key 1E42B367
is thus often helpful. Note that the actual output depends on the
backend and may change from release to release.
* Logging on WindowsCE
For development, the best logging method on WindowsCE is the use of
remote debugging using a log file name of 'tcp://<ip-addr>:<port>'.
The command 'watchgnupg' may be used on the remote host to listen
on the given port (*note option watchgnupg --tcp::). For in the
field tests it is better to make use of the logging facility
provided by the 'gpgcedev' driver (part of libassuan); this is
enabled by using a log file name of 'GPG2:' (*note option
--log-file::).
File: gnupg.info, Node: Common Problems, Next: Architecture Details, Prev: Debugging Hints, Up: Debugging
13.3 Commonly Seen Problems
===========================
* Error code 'Not supported' from Dirmngr
Most likely the option 'enable-ocsp' is active for gpgsm but
Dirmngr's OCSP feature has not been enabled using 'allow-ocsp' in
'dirmngr.conf'.
* The Curses based Pinentry does not work
The far most common reason for this is that the environment
variable 'GPG_TTY' has not been set correctly. Make sure that it
has been set to a real tty device and not just to '/dev/tty'; i.e.
'GPG_TTY=tty' is plainly wrong; what you want is 'GPG_TTY=`tty`' --
note the back ticks. Also make sure that this environment variable
gets exported, that is you should follow up the setting with an
'export GPG_TTY' (assuming a Bourne style shell). Even for GUI
based Pinentries; you should have set 'GPG_TTY'. See the section
on installing the 'gpg-agent' on how to do it.
* SSH hangs while a popping up pinentry was expected
SSH has no way to tell the gpg-agent what terminal or X display it
is running on. So when remotely logging into a box where a
gpg-agent with SSH support is running, the pinentry will get popped
up on whatever display the gpg-agent has been started. To solve
this problem you may issue the command
echo UPDATESTARTUPTTY | gpg-connect-agent
and the next pinentry will pop up on your display or screen.
However, you need to kill the running pinentry first because only
one pinentry may be running at once. If you plan to use ssh on a
new display you should issue the above command before invoking ssh
or any other service making use of ssh.
* Exporting a secret key without a certificate
It may happen that you have created a certificate request using
'gpgsm' but not yet received and imported the certificate from the
CA. However, you want to export the secret key to another machine
right now to import the certificate over there then. You can do
this with a little trick but it requires that you know the
approximate time you created the signing request. By running the
command
ls -ltr ~/.gnupg/private-keys-v1.d
you get a listing of all private keys under control of 'gpg-agent'.
Pick the key which best matches the creation time and run the
command
/usr/local/libexec/gpg-protect-tool --p12-export \
~/.gnupg/private-keys-v1.d/FOO >FOO.p12
(Please adjust the path to 'gpg-protect-tool' to the appropriate
location). FOO is the name of the key file you picked (it should
have the suffix '.key'). A Pinentry box will pop up and ask you
for the current passphrase of the key and a new passphrase to
protect it in the pkcs#12 file.
To import the created file on the machine you use this command:
/usr/local/libexec/gpg-protect-tool --p12-import --store FOO.p12
You will be asked for the pkcs#12 passphrase and a new passphrase
to protect the imported private key at its new location.
Note that there is no easy way to match existing certificates with
stored private keys because some private keys are used for Secure
Shell or other purposes and don't have a corresponding certificate.
* A root certificate does not verify
A common problem is that the root certificate misses the required
basicConstraints attribute and thus 'gpgsm' rejects this
certificate. An error message indicating "no value" is a sign for
such a certificate. You may use the 'relax' flag in
'trustlist.txt' to accept the certificate anyway. Note that the
fingerprint and this flag may only be added manually to
'trustlist.txt'.
* Error message: "digest algorithm N has not been enabled"
The signature is broken. You may try the option
'--extra-digest-algo SHA256' to workaround the problem. The number
N is the internal algorithm identifier; for example 8 refers to
SHA-256.
* The Windows version does not work under Wine
When running the W32 version of 'gpg' under Wine you may get an
error messages like:
gpg: fatal: WriteConsole failed: Access denied
The solution is to use the command 'wineconsole'.
Some operations like '--generate-key' really want to talk to the
console directly for increased security (for example to prevent the
passphrase from appearing on the screen). So, you should use
'wineconsole' instead of 'wine', which will launch a windows
console that implements those additional features.
* Why does GPG's -search-key list weird keys?
For performance reasons the keyservers do not check the keys the
same way 'gpg' does. It may happen that the listing of keys
available on the keyservers shows keys with wrong user IDs or with
user Ids from other keys. If you try to import this key, the bad
keys or bad user ids won't get imported, though. This is a bit
unfortunate but we can't do anything about it without actually
downloading the keys.
File: gnupg.info, Node: Architecture Details, Prev: Common Problems, Up: Debugging
13.4 How the whole thing works internally
=========================================
* Menu:
* Component interaction:: How the components work together.
* GnuPG-1 and GnuPG-2:: Relationship between GnuPG 1.4 and 2.x.
File: gnupg.info, Node: Component interaction, Next: GnuPG-1 and GnuPG-2, Up: Architecture Details
13.4.1 How the components work together
---------------------------------------
[image src="gnupg-module-overview.png" alt="GnuPG modules"
|