This file is indexed.

/usr/include/Qca-qt5/QtCrypto/qcaprovider.h is in libqca-qt5-2-dev 2.1.1-4+b2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
/*
 * qcaprovider.h - QCA Plugin API
 * Copyright (C) 2003-2007  Justin Karneges <justin@affinix.com>
 * Copyright (C) 2004,2005  Brad Hards <bradh@frogmouth.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301  USA
 *
 */

/**
   \file qcaprovider.h

   Header file for provider implementation classes (plugins)

   \note You should not use this header directly from an
   application. You should just use <tt> \#include \<QtCrypto>
   </tt> instead.
*/

#ifndef QCAPROVIDER_H
#define QCAPROVIDER_H

#include "qca_core.h"
#include "qca_basic.h"
#include "qca_publickey.h"
#include "qca_cert.h"
#include "qca_keystore.h"
#include "qca_securelayer.h"
#include "qca_securemessage.h"

#include <limits>

#ifndef DOXYGEN_NO_PROVIDER_API

/**
   \defgroup ProviderAPI QCA provider API

   This group of classes is not normally needed 
   by application writers, but can be used to extend QCA if
   required
*/

/**
   \class QCAPlugin qcaprovider.h QtCrypto

   Provider plugin base class

   QCA loads cryptographic provider plugins with QPluginLoader.  The QObject
   obtained when loading the plugin must implement the QCAPlugin interface.
   This is done by inheriting QCAPlugin, and including
   Q_INTERFACES(QCAPlugin) in your class declaration.

   For example:
\code
class MyPlugin : public QObject, public QCAPlugin
{
	Q_OBJECT
	Q_INTERFACES(QCAPlugin)
public:
	virtual Provider *createProvider() { ... }
};
\endcode

   There is only one function to reimplement, called createProvider().  This
   function should return a newly allocated Provider instance.

   \ingroup ProviderAPI
*/
class QCA_EXPORT QCAPlugin
{
public:
	/**
	   Destructs the object
	*/
	virtual ~QCAPlugin() {}

	/**
	   Returns a newly allocated Provider instance.
	*/
	virtual QCA::Provider *createProvider() = 0;
};

Q_DECLARE_INTERFACE(QCAPlugin, "com.affinix.qca.Plugin/1.0")

namespace QCA {

/**
   \class InfoContext qcaprovider.h QtCrypto

   Extended provider information

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.

   \ingroup ProviderAPI
*/
class QCA_EXPORT InfoContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	InfoContext(Provider *p) : BasicContext(p, QStringLiteral("info") ) {}

	/**
	   The hash algorithms supported by the provider
	*/
	virtual QStringList supportedHashTypes() const;

	/**
	   The cipher algorithms supported by the provider
	*/
	virtual QStringList supportedCipherTypes() const;

	/**
	   The mac algorithms supported by the provider
	*/
	virtual QStringList supportedMACTypes() const;
};

/**
   \class RandomContext qcaprovider.h QtCrypto

   Random provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want Random instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT RandomContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	RandomContext(Provider *p) : BasicContext(p, QStringLiteral("random")) {}

	/**
	   Return an array of random bytes

	   \param size the number of random bytes to return
	*/
	virtual SecureArray nextBytes(int size) = 0;
};

/**
   \class HashContext qcaprovider.h QtCrypto

   Hash provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want Hash instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT HashContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	   \param type the name of the type of hash provided by this context
	*/
	HashContext(Provider *p, const QString &type) : BasicContext(p, type) {}

	/**
	   Reset the object to its initial state
	*/
	virtual void clear() = 0;

	/**
	   Process a chunk of data

	   \param a the input data to process
	*/
	virtual void update(const MemoryRegion &a) = 0;

	/**
	   Return the computed hash
	*/
	virtual MemoryRegion final() = 0;
};

/**
   \class CipherContext qcaprovider.h QtCrypto

   Cipher provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want Cipher instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CipherContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	   \param type the name of the type of cipher provided by this context

	   \note type includes the name of the cipher (e.g. "aes256"), the operating
	   mode (e.g. "cbc" or "ofb") and the padding type (e.g. "pkcs7") if any.
	*/
	CipherContext(Provider *p, const QString &type) : BasicContext(p, type) {}

	/**
	   Set up the object for encrypt/decrypt

	   \param dir the direction for the cipher (encryption/decryption)
	   \param key the symmetric key to use for the cipher
	   \param iv the initialization vector to use for the cipher (not used in ECB mode)
	*/
	virtual void setup(Direction dir, const SymmetricKey &key, const InitializationVector &iv) = 0;

	/**
	   Returns the KeyLength for this cipher
	*/
	virtual KeyLength keyLength() const = 0;

	/**
	   Returns the block size for this cipher
	*/
	virtual int blockSize() const = 0;

	/**
	   Process a chunk of data.  Returns true if successful.

	   \param in the input data to process
	   \param out pointer to an array that should store the result
	*/
	virtual bool update(const SecureArray &in, SecureArray *out) = 0;

	/**
	   Finish the cipher processing.  Returns true if successful.

	   \param out pointer to an array that should store the result
	*/
	virtual bool final(SecureArray *out) = 0;
};

/**
   \class MACContext qcaprovider.h QtCrypto

   Message authentication code provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want
   MessageAuthenticationCode instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT MACContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor
	   \param p the provider associated with this context
	   \param type the name of the type of MAC algorithm provided by this context
	*/
	MACContext(Provider *p, const QString &type) : BasicContext(p, type) {}

	/**
	   Set up the object for hashing

	   \param key the key to use with the MAC.
	*/
	virtual void setup(const SymmetricKey &key) = 0;

	/**
	   Returns the KeyLength for this MAC algorithm
	*/
	virtual KeyLength keyLength() const = 0;

	/**
	   Process a chunk of data

	   \param in the input data to process
	*/
	virtual void update(const MemoryRegion &in) = 0;

	/**
	   Compute the result after processing all data

	   \param out pointer to an array that should store the result
	*/
	virtual void final(MemoryRegion *out) = 0;

protected:
	/**
	   Returns a KeyLength that supports any length
	*/
	KeyLength anyKeyLength() const
	{
		// this is used instead of a default implementation to make sure that
		// provider authors think about it, at least a bit.
		// See Meyers, Effective C++, Effective C++ (2nd Ed), Item 36
		return KeyLength( 0, INT_MAX, 1 );
	}
};

/**
   \class KDFContext qcaprovider.h QtCrypto

   Key derivation function provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want KeyDerivationFunction
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT KDFContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	   \param type the name of the KDF provided by this context (including algorithm)
	*/
	KDFContext(Provider *p, const QString &type) : BasicContext(p, type) {}

	/**
	   Create a key and return it

	   \param secret the secret part (typically password)
	   \param salt the salt / initialization vector
	   \param keyLength the length of the key to be produced
	   \param iterationCount the number of iterations of the derivation algorith,
	*/
	virtual SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;

	/**
	   Create a key and return it

	   \param secret the secret part (typically password)
	   \param salt the salt / initialization vector
	   \param keyLength the length of the key to be produced
	   \param msecInterval the maximum time to compute the key, in milliseconds
	   \param iterationCount a pointer to store the number of iterations of the derivation algorithm,
	*/
	virtual SymmetricKey makeKey(const SecureArray &secret,
								 const InitializationVector &salt,
								 unsigned int keyLength,
								 int msecInterval,
								 unsigned int *iterationCount) = 0;
};

/**
   \class DLGroupContext qcaprovider.h QtCrypto

   Discrete logarithm provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want DLGroup instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT DLGroupContext : public Provider::Context
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	DLGroupContext(Provider *p) : Provider::Context(p, QStringLiteral("dlgroup")) {}

	/**
	   The DLGroupSets supported by this object
	*/
	virtual QList<DLGroupSet> supportedGroupSets() const = 0;

	/**
	   Returns true if there is a result to obtain
	*/
	virtual bool isNull() const = 0;

	/**
	   Attempt to create P, Q, and G values from the specified group set

	   If \a block is true, then this function blocks until completion.
	   Otherwise, this function returns immediately and finished() is
	   emitted when the operation completes.

	   If an error occurs during generation, then the operation will
	   complete and isNull() will return true.

	   \param set the group set to generate the key from
	   \param block whether to block (true) or not (false)
	*/
	virtual void fetchGroup(DLGroupSet set, bool block) = 0;

	/**
	   Obtain the result of the operation.  Ensure isNull() returns false
	   before calling this function.

	   \param p the P value
	   \param q the Q value
	   \param g the G value
	*/
	virtual void getResult(BigInteger *p, BigInteger *q, BigInteger *g) const = 0;

Q_SIGNALS:
	/**
	   Emitted when the fetchGroup() operation completes in non-blocking
	   mode.
	*/
	void finished();
};

/**
   \class PKeyBase qcaprovider.h QtCrypto

   Public key implementation provider base

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want PKey, PublicKey, or
   PrivateKey instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT PKeyBase : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	   \param type type of key provided by this context
	*/
	PKeyBase(Provider *p, const QString &type);

	/**
	   Returns true if this object is not valid.  This is the default
	   state, and the object may also become this state if a conversion
	   or generation function fails.
	*/
	virtual bool isNull() const = 0;

	/**
	   Returns the type of public key
	*/
	virtual PKey::Type type() const = 0;

	/**
	   Returns true if this is a private key, otherwise false
	*/
	virtual bool isPrivate() const = 0;

	/**
	   Returns true if the components of this key are accessible and
	   whether it can be serialized into an output format.  Private keys
	   from a smart card device will often not be exportable.
	*/
	virtual bool canExport() const = 0;

	/**
	   If the key is a private key, this function will convert it into a
	   public key (all private key data includes the public data as well,
	   which is why this is possible).  If the key is already a public
	   key, then this function has no effect.
	*/
	virtual void convertToPublic() = 0;

	/**
	   Returns the number of bits in the key
	*/
	virtual int bits() const = 0;

	/**
	   Returns the maximum number of bytes that can be encrypted by this
	   key

	   \param alg the algorithm to be used for encryption
	*/
	virtual int maximumEncryptSize(EncryptionAlgorithm alg) const;

	/**
	   Encrypt data

	   \param in the input data to encrypt
	   \param alg the encryption algorithm to use
	*/
	virtual SecureArray encrypt(const SecureArray &in, EncryptionAlgorithm alg);

	/**
	   Decrypt data

	   \param in the input data to decrypt
	   \param out pointer to an array to store the plaintext result
	   \param alg the encryption algorithm used to generate the input
	   data
	*/
	virtual bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);

	/**
	   Begin a signing operation

	   \param alg the signature algorithm to use
	   \param format the signature format to use
	*/
	virtual void startSign(SignatureAlgorithm alg, SignatureFormat format);

	/**
	   Begin a verify operation

	   \param alg the signature algorithm used by the input signature
	   \param format the signature format used by the input signature
	*/
	virtual void startVerify(SignatureAlgorithm alg, SignatureFormat format);

	/**
	   Process the plaintext input data for either signing or verifying,
	   whichever operation is active.

	   \param in the input data to process
	*/
	virtual void update(const MemoryRegion &in);

	/**
	   Complete a signing operation, and return the signature value

	   If there is an error signing, an empty array is returned.
	*/
	virtual QByteArray endSign();

	/**
	   Complete a verify operation, and return true if successful

	   If there is an error verifying, this function returns false.

	   \param sig the signature to verify with the input data
	*/
	virtual bool endVerify(const QByteArray &sig);

	/**
	   Compute a symmetric key based on this private key and some other
	   public key

	   Essentially for Diffie-Hellman only.

	   \param theirs the other side (public key) to be used for key generation.
	*/
	virtual SymmetricKey deriveKey(const PKeyBase &theirs);

Q_SIGNALS:
	/**
	   Emitted when an asynchronous operation completes on this key.
	   Such operations will be documented that they emit this signal.
	*/
	void finished();
};

/**
   \class RSAContext qcaprovider.h QtCrypto

   RSA provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want RSAPublicKey or
   RSAPrivateKey instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT RSAContext : public PKeyBase
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	RSAContext(Provider *p) : PKeyBase(p, QStringLiteral("rsa")) {}

	/**
	   Generate an RSA private key

	   If \a block is true, then this function blocks until completion.
	   Otherwise, this function returns immediately and finished() is
	   emitted when the operation completes.

	   If an error occurs during generation, then the operation will
	   complete and isNull() will return true.

	   \param bits the length of the key to generate, in bits
	   \param exp the exponent to use for generation
	   \param block whether to use blocking mode
	*/
	virtual void createPrivate(int bits, int exp, bool block) = 0;

	/**
	   Create an RSA private key based on the five components

	   \param n the N parameter
	   \param e the public exponent
	   \param p the P parameter
	   \param q the Q parameter
	   \param d the D parameter
	*/
	virtual void createPrivate(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d) = 0;

	/**
	   Create an RSA public key based on the two public components

	   \param n the N parameter
	   \param e the public exponent
	*/
	virtual void createPublic(const BigInteger &n, const BigInteger &e) = 0;

	/**
	   Returns the public N component of this RSA key
	*/
	virtual BigInteger n() const = 0;

	/**
	   Returns the public E component of this RSA key
	*/
	virtual BigInteger e() const = 0;

	/**
	   Returns the private P component of this RSA key
	*/
	virtual BigInteger p() const = 0;

	/**
	   Returns the private Q component of this RSA key
	*/
	virtual BigInteger q() const = 0;

	/**
	   Returns the private D component of this RSA key
	*/
	virtual BigInteger d() const = 0;
};

/**
   \class DSAContext qcaprovider.h QtCrypto

   DSA provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want DSAPublicKey or
   DSAPrivateKey instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT DSAContext : public PKeyBase
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	DSAContext(Provider *p) : PKeyBase(p, QStringLiteral("dsa")) {}

	/**
	   Generate a DSA private key

	   If \a block is true, then this function blocks until completion.
	   Otherwise, this function returns immediately and finished() is
	   emitted when the operation completes.

	   If an error occurs during generation, then the operation will
	   complete and isNull() will return true.

	   \param domain the domain values to use for generation
	   \param block whether to use blocking mode
	*/
	virtual void createPrivate(const DLGroup &domain, bool block) = 0;

	/**
	   Create a DSA private key based on its numeric components

	   \param domain the domain values to use for generation
	   \param y the public Y component
	   \param x the private X component
	*/
	virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;

	/**
	   Create a DSA public key based on its numeric components

	   \param domain the domain values to use for generation
	   \param y the public Y component
	*/
	virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;

	/**
	   Returns the public domain component of this DSA key
	*/
	virtual DLGroup domain() const = 0;

	/**
	   Returns the public Y component of this DSA key
	*/
	virtual BigInteger y() const = 0;

	/**
	   Returns the private X component of this DSA key
	*/
	virtual BigInteger x() const = 0;
};

/**
   \class DHContext qcaprovider.h QtCrypto

   Diffie-Hellman provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want DHPublicKey or
   DHPrivateKey instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT DHContext : public PKeyBase
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	DHContext(Provider *p) : PKeyBase(p, QStringLiteral("dh")) {}

	/**
	   Generate a Diffie-Hellman private key

	   If \a block is true, then this function blocks until completion.
	   Otherwise, this function returns immediately and finished() is
	   emitted when the operation completes.

	   If an error occurs during generation, then the operation will
	   complete and isNull() will return true.

	   \param domain the domain values to use for generation
	   \param block whether to use blocking mode
	*/
	virtual void createPrivate(const DLGroup &domain, bool block) = 0;

	/**
	   Create a Diffie-Hellman private key based on its numeric
	   components

	   \param domain the domain values to use for generation
	   \param y the public Y component
	   \param x the private X component
	*/
	virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;

	/**
	   Create a Diffie-Hellman public key based on its numeric
	   components

	   \param domain the domain values to use for generation
	   \param y the public Y component
	*/
	virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;

	/**
	   Returns the public domain component of this Diffie-Hellman key
	*/
	virtual DLGroup domain() const = 0;

	/**
	   Returns the public Y component of this Diffie-Hellman key
	*/
	virtual BigInteger y() const = 0;

	/**
	   Returns the private X component of this Diffie-Hellman key
	*/
	virtual BigInteger x() const = 0;
};

/**
   \class PKeyContext qcaprovider.h QtCrypto

   Public key container provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want PKey, PublicKey, or
   PrivateKey instead.

   This object "holds" a public key object.  By default it contains no key
   (key() returns 0), but you can put a key into it with setKey(), or you
   can call an import function such as publicFromDER().

   \ingroup ProviderAPI
*/
class QCA_EXPORT PKeyContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	PKeyContext(Provider *p) : BasicContext(p, QStringLiteral("pkey")) {}

	/**
	   Returns a list of supported public key types
	*/
	virtual QList<PKey::Type> supportedTypes() const = 0;

	/**
	   Returns a list of public key types that can be serialized and
	   deserialized into DER and PEM format
	*/
	virtual QList<PKey::Type> supportedIOTypes() const = 0;

	/**
	   Returns a list of password-based encryption algorithms that are
	   supported for private key serialization and deserialization
	*/
	virtual QList<PBEAlgorithm> supportedPBEAlgorithms() const = 0;

	/**
	   Returns the key held by this object, or 0 if there is no key
	*/
	virtual PKeyBase *key() = 0;

	/**
	   Returns the key held by this object, or 0 if there is no key
	*/
	virtual const PKeyBase *key() const = 0;

	/**
	   Sets the key for this object.  If this object already had a key,
	   then the old one is destructed.  This object takes ownership of
	   the key.

	   \param key the key to be set for this object
	*/
	virtual void setKey(PKeyBase *key) = 0;

	/**
	   Attempt to import a key from another provider.  Returns true if
	   successful, otherwise false.

	   Generally this function is used if the specified key's provider
	   does not support serialization, but your provider does.  The call
	   to this function would then be followed by an export function,
	   such as publicToDER().

	   \param key the key to be imported
	*/
	virtual bool importKey(const PKeyBase *key) = 0;

	/**
	   Convert a public key to DER format, and return the value

	   Returns an empty array on error.
	*/
	virtual QByteArray publicToDER() const;

	/**
	   Convert a public key to PEM format, and return the value

	   Returns an empty string on error.
	*/
	virtual QString publicToPEM() const;

	/**
	   Read DER-formatted input and convert it into a public key

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param a the input data
	*/
	virtual ConvertResult publicFromDER(const QByteArray &a);

	/**
	   Read PEM-formatted input and convert it into a public key

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param s the input data
	*/
	virtual ConvertResult publicFromPEM(const QString &s);

	/**
	   Convert a private key to DER format, and return the value

	   Returns an empty array on error.

	   \param passphrase the passphrase to encode the result with, or an
	   empty array if no encryption is desired
	   \param pbe the encryption algorithm to use, if applicable
	*/
	virtual SecureArray privateToDER(const SecureArray &passphrase, PBEAlgorithm pbe) const;

	/**
	   Convert a private key to PEM format, and return the value

	   Returns an empty string on error.

	   \param passphrase the passphrase to encode the result with, or an
	   empty array if no encryption is desired
	   \param pbe the encryption algorithm to use, if applicable
	*/
	virtual QString privateToPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const;

	/**
	   Read DER-formatted input and convert it into a private key

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param a the input data
	   \param passphrase the passphrase needed to decrypt, if applicable
	*/
	virtual ConvertResult privateFromDER(const SecureArray &a, const SecureArray &passphrase);

	/**
	   Read PEM-formatted input and convert it into a private key

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param s the input data
	   \param passphrase the passphrase needed to decrypt, if applicable
	*/
	virtual ConvertResult privateFromPEM(const QString &s, const SecureArray &passphrase);
};

/**
   \class CertBase qcaprovider.h QtCrypto

   X.509 certificate and certificate request provider base

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want Certificate,
   CertificateRequest, or CRL instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CertBase : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	   \param type the type of certificate-like object provided by this context
	*/
	CertBase(Provider *p, const QString &type) : BasicContext(p, type) {}

	/**
	   Convert this object to DER format, and return the value

	   Returns an empty array on error.
	*/
	virtual QByteArray toDER() const = 0;

	/**
	   Convert this object to PEM format, and return the value

	   Returns an empty string on error.
	*/
	virtual QString toPEM() const = 0;

	/**
	   Read DER-formatted input and convert it into this object

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param a the input data
	*/
	virtual ConvertResult fromDER(const QByteArray &a) = 0;

	/**
	   Read PEM-formatted input and convert it into this object

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param s the input data
	*/
	virtual ConvertResult fromPEM(const QString &s) = 0;
};

/**
   \class CertContextProps qcaprovider.h QtCrypto

   X.509 certificate or certificate request properties

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want Certificate or
   CertificateRequest instead.

   Some fields are only for certificates or only for certificate requests,
   and these fields are noted.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CertContextProps
{
public:
	/**
	   The X.509 certificate version, usually 3

	   This field is for certificates only.
	*/
	int version;

	/**
	   The time the certificate becomes valid (often the time of create)

	   This field is for certificates only.
	*/
	QDateTime start;

	/**
	   The time the certificate expires

	   This field is for certificates only.
	*/
	QDateTime end;

	/**
	   The subject information
	*/
	CertificateInfoOrdered subject;

	/**
	   The issuer information

	   This field is for certificates only.
	*/
	CertificateInfoOrdered issuer;

	/**
	   The constraints
	*/
	Constraints constraints;

	/**
	   The policies
	*/
	QStringList policies;

	/**
	   A list of URIs for CRLs

	   This field is for certificates only.
	*/
	QStringList crlLocations;

	/**
	   A list of URIs for issuer certificates

	   This field is for certificates only.
	*/
	QStringList issuerLocations;

	/**
	   A list of URIs for OCSP services

	   This field is for certificates only.
	*/
	QStringList ocspLocations;

	/**
	   The certificate serial number

	   This field is for certificates only.
	*/
	BigInteger serial;

	/**
	   True if the certificate is a CA or the certificate request is
	   requesting to be a CA, otherwise false
	*/
	bool isCA;

	/**
	   True if the certificate is self-signed

	   This field is for certificates only.
	*/
	bool isSelfSigned;

	/**
	   The path limit
	*/
	int pathLimit;

	/**
	   The signature data
	*/
	QByteArray sig;

	/**
	   The signature algorithm used to create the signature
	*/
	SignatureAlgorithm sigalgo;

	/**
	   The subject id

	   This field is for certificates only.
	*/
	QByteArray subjectId;

	/**
	   The issuer id

	   This field is for certificates only.
	*/
	QByteArray issuerId;

	/**
	   The SPKAC challenge value

	   This field is for certificate requests only.
	*/
	QString challenge;

	/**
	   The format used for the certificate request

	   This field is for certificate requests only.
	*/
	CertificateRequestFormat format;
};

/**
   \class CRLContextProps qcaprovider.h QtCrypto

   X.509 certificate revocation list properties

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want CRL instead.

   For efficiency and simplicity, the members are directly accessed.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CRLContextProps
{
public:
	/**
	   The issuer information of the CRL
	*/
	CertificateInfoOrdered issuer;

	/**
	   The CRL number, which increases at each update
	*/
	int number;

	/**
	   The time this CRL was created
	*/
	QDateTime thisUpdate;

	/**
	   The time this CRL expires, and the next CRL should be fetched
	*/
	QDateTime nextUpdate;

	/**
	   The revoked entries
	*/
	QList<CRLEntry> revoked;

	/**
	   The signature data of the CRL
	*/
	QByteArray sig;

	/**
	   The signature algorithm used by the issuer to sign the CRL
	*/
	SignatureAlgorithm sigalgo;

	/**
	   The issuer id
	*/
	QByteArray issuerId;
};

class CRLContext;

/**
   \class CertContext qcaprovider.h QtCrypto

   X.509 certificate provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want Certificate instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CertContext : public CertBase
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	CertContext(Provider *p) : CertBase(p, QStringLiteral("cert")) {}

	/**
	   Create a self-signed certificate based on the given options and
	   private key.  Returns true if successful, otherwise false.

	   If successful, this object becomes the self-signed certificate.
	   If unsuccessful, this object is considered to be in an
	   uninitialized state.

	   \param opts the options to set on the certificate
	   \param priv the key to be used to sign the certificate 
	*/
	virtual bool createSelfSigned(const CertificateOptions &opts, const PKeyContext &priv) = 0;

	/**
	   Returns a pointer to the properties of this certificate
	*/
	virtual const CertContextProps *props() const = 0;

	/**
	   Returns true if this certificate is equal to another certificate,
	   otherwise false

	   \param other the certificate to compare with
	*/
	virtual bool compare(const CertContext *other) const = 0;

	/**
	   Returns a copy of this certificate's public key.  The caller is
	   responsible for deleting it.
	*/
	virtual PKeyContext *subjectPublicKey() const = 0;

	/**
	   Returns true if this certificate is an issuer of another
	   certificate, otherwise false

	   \param other the issued certificate to check
	*/
	virtual bool isIssuerOf(const CertContext *other) const = 0;

	/**
	   Validate this certificate

	   This function is blocking.

	   \param trusted list of trusted certificates
	   \param untrusted list of untrusted certificates (can be empty)
	   \param crls list of CRLs (can be empty)
	   \param u the desired usage for this certificate
	   \param vf validation options
	*/
	virtual Validity validate(const QList<CertContext*> &trusted, const QList<CertContext*> &untrusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;

	/**
	   Validate a certificate chain.  This function makes no use of the
	   certificate represented by this object, and it can be used even
	   if this object is in an uninitialized state.

	   This function is blocking.

	   \param chain list of certificates in the chain, starting with the
	   user certificate.  It is not necessary for the chain to contain
	   the final root certificate.
	   \param trusted list of trusted certificates
	   \param crls list of CRLs (can be empty)
	   \param u the desired usage for the user certificate in the chain
	   \param vf validation options
	*/
	virtual Validity validate_chain(const QList<CertContext*> &chain, const QList<CertContext*> &trusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
};

/**
   \class CSRContext qcaprovider.h QtCrypto

   X.509 certificate request provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want CertificateRequest
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CSRContext : public CertBase
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	CSRContext(Provider *p) : CertBase(p, QStringLiteral("csr")) {}

	/**
	   Returns true if the provider of this object supports the specified
	   format, otherwise false

	   \param f the format to test for support for.
	*/
	virtual bool canUseFormat(CertificateRequestFormat f) const = 0;

	/**
	   Create a certificate request based on the given options and
	   private key.  Returns true if successful, otherwise false.

	   If successful, this object becomes the certificate request.
	   If unsuccessful, this object is considered to be in an
	   uninitialized state.

	   \param opts the options to set on the certificate
	   \param priv the key to be used to sign the certificate 
	*/
	virtual bool createRequest(const CertificateOptions &opts, const PKeyContext &priv) = 0;

	/**
	   Returns a pointer to the properties of this certificate request
	*/
	virtual const CertContextProps *props() const = 0;

	/**
	   Returns true if this certificate request is equal to another
	   certificate request, otherwise false

	   \param other the certificate request to compare with
	*/
	virtual bool compare(const CSRContext *other) const = 0;

	/**
	   Returns a copy of this certificate request's public key.  The
	   caller is responsible for deleting it.
	*/
	virtual PKeyContext *subjectPublicKey() const = 0;

	/**
	   Convert this certificate request to Netscape SPKAC format, and
	   return the value

	   Returns an empty string on error.
	*/
	virtual QString toSPKAC() const = 0;

	/**
	   Read Netscape SPKAC input and convert it into a certificate
	   request

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param s the input data
	*/
	virtual ConvertResult fromSPKAC(const QString &s) = 0;
};

/**
   \class CRLContext qcaprovider.h QtCrypto

   X.509 certificate revocation list provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want CRL instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CRLContext : public CertBase
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	CRLContext(Provider *p) : CertBase(p, QStringLiteral("crl")) {}

	/**
	   Returns a pointer to the properties of this CRL
	*/
	virtual const CRLContextProps *props() const = 0;

	/**
	   Returns true if this CRL is equal to another CRL, otherwise false

	   \param other the CRL to compare with
	*/
	virtual bool compare(const CRLContext *other) const = 0;
};

/**
   \class CertCollectionContext qcaprovider.h QtCrypto

   X.509 certificate collection provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want CertificateCollection
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CertCollectionContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	*/
	CertCollectionContext(Provider *p) : BasicContext(p, QStringLiteral("certcollection")) {}

	/**
	   Create PKCS#7 DER output based on the input certificates and CRLs

	   Returns an empty array on error.

	   \param certs list of certificates to store in the output
	   \param crls list of CRLs to store in the output
	*/
	virtual QByteArray toPKCS7(const QList<CertContext*> &certs, const QList<CRLContext*> &crls) const = 0;

	/**
	   Read PKCS#7 DER input and convert it into a list of certificates
	   and CRLs

	   The caller is responsible for deleting the returned items.

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param a the input data
	   \param certs the destination list for the certificates
	   \param crls the destination list for the CRLs
	*/
	virtual ConvertResult fromPKCS7(const QByteArray &a, QList<CertContext*> *certs, QList<CRLContext*> *crls) const = 0;
};

/**
   \class CAContext qcaprovider.h QtCrypto

   X.509 certificate authority provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want CertificateAuthority
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT CAContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	CAContext(Provider *p) : BasicContext(p, QStringLiteral("ca")) {}

	/**
	   Prepare the object for usage

	   This must be called before any CA operations are performed.

	   \param cert the certificate of the CA
	   \param priv the private key of the CA
	*/
	virtual void setup(const CertContext &cert, const PKeyContext &priv) = 0;

	/**
	   Returns a copy of the CA's certificate.  The caller is responsible
	   for deleting it.
	*/
	virtual CertContext *certificate() const = 0;

	/**
	   Issue a certificate based on a certificate request, and return
	   the certificate.  The caller is responsible for deleting it.

	   \param req the certificate request
	   \param notValidAfter the expiration date
	*/
	virtual CertContext *signRequest(const CSRContext &req, const QDateTime &notValidAfter) const = 0;

	/**
	   Issue a certificate based on a public key and options, and return
	   the certificate.  The caller is responsible for deleting it.

	   \param pub the public key of the certificate
	   \param opts the options to use for generation
	*/
	virtual CertContext *createCertificate(const PKeyContext &pub, const CertificateOptions &opts) const = 0;

	/**
	   Create a new CRL and return it.  The caller is responsible for
	   deleting it.

	   The CRL has no entries in it.

	   \param nextUpdate the expiration date of the CRL
	*/
	virtual CRLContext *createCRL(const QDateTime &nextUpdate) const = 0;

	/**
	   Update an existing CRL, by examining an old one and creating a new
	   one based on it.  The new CRL is returned, and the caller is
	   responsible for deleting it.

	   \param crl an existing CRL issued by this CA
	   \param entries the list of revoked entries
	   \param nextUpdate the expiration date of the new CRL
	*/
	virtual CRLContext *updateCRL(const CRLContext &crl, const QList<CRLEntry> &entries, const QDateTime &nextUpdate) const = 0;
};

/**
   \class PKCS12Context qcaprovider.h QtCrypto

   PKCS#12 provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want KeyBundle instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT PKCS12Context : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	PKCS12Context(Provider *p) : BasicContext(p, QStringLiteral("pkcs12")) {}

	/**
	   Create PKCS#12 DER output based on a set of input items

	   Returns an empty array on error.

	   \param name the friendly name of the data
	   \param chain the certificate chain to store
	   \param priv the private key to store
	   \param passphrase the passphrase to encrypt the PKCS#12 data with
	*/
	virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const SecureArray &passphrase) const = 0;

	/**
	   Read PKCS#12 DER input and convert it into a set of output items

	   The caller is responsible for deleting the returned items.

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param in the input data
	   \param passphrase the passphrase needed to decrypt the input data
	   \param name the destination string for the friendly name
	   \param chain the destination list for the certificate chain
	   \param priv address of a pointer to accept the private key
	*/
	virtual ConvertResult fromPKCS12(const QByteArray &in, const SecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
};

/**
   \class PGPKeyContextProps qcaprovider.h QtCrypto

   OpenPGP key properties

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want PGPKey instead.

   For efficiency and simplicity, the members are directly accessed.

   \ingroup ProviderAPI
*/
class QCA_EXPORT PGPKeyContextProps
{
public:
	/**
	   The key id
	*/
	QString keyId;

	/**
	   List of user id strings for the key, the first one being the
	   primary user id
	*/
	QStringList userIds;

	/**
	   True if this key is a secret key, otherwise false
	*/
	bool isSecret;

	/**
	   The time the key was created
	*/
	QDateTime creationDate;

	/**
	   The time the key expires
	*/
	QDateTime expirationDate;

	/**
	   The hex fingerprint of the key

	   The format is all lowercase with no spaces.
	*/
	QString fingerprint;

	/**
	   True if this key is in a keyring (and thus usable), otherwise
	   false
	*/
	bool inKeyring;

	/**
	   True if this key is trusted (e.g. signed by the keyring owner or
	   via some web-of-trust), otherwise false
	*/
	bool isTrusted;
};

/**
   \class PGPKeyContext qcaprovider.h QtCrypto

   OpenPGP key provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want PGPKey instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT PGPKeyContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	PGPKeyContext(Provider *p) : BasicContext(p, QStringLiteral("pgpkey")) {}

	/**
	   Returns a pointer to the properties of this key
	*/
	virtual const PGPKeyContextProps *props() const = 0;

	/**
	   Convert the key to binary format, and return the value
	*/
	virtual QByteArray toBinary() const = 0;

	/**
	   Convert the key to ascii-armored format, and return the value
	*/
	virtual QString toAscii() const = 0;

	/**
	   Read binary input and convert it into a key

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param a the input data
	*/
	virtual ConvertResult fromBinary(const QByteArray &a) = 0;

	/**
	   Read ascii-armored input and convert it into a key

	   Returns QCA::ConvertGood if successful, otherwise some error
	   value.

	   \param s the input data
	*/
	virtual ConvertResult fromAscii(const QString &s) = 0;
};

/**
   \class KeyStoreEntryContext qcaprovider.h QtCrypto

   KeyStoreEntry provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want KeyStoreEntry
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT KeyStoreEntryContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	KeyStoreEntryContext(Provider *p) : BasicContext(p, QStringLiteral("keystoreentry")) {}

	/**
	   Returns the entry type
	*/
	virtual KeyStoreEntry::Type type() const = 0;

	/**
	   Returns the entry id

	   This id must be unique among all other entries in the same store.
	*/
	virtual QString id() const = 0;

	/**
	   Returns the name of this entry
	*/
	virtual QString name() const = 0;

	/**
	   Returns the id of the store that contains this entry
	*/
	virtual QString storeId() const = 0;

	/**
	   Returns the name of the store that contains this entry
	*/
	virtual QString storeName() const = 0;

	/**
	   Returns true if the private key of this entry is present for use
	*/
	virtual bool isAvailable() const;

	/**
	   Serialize the information about this entry

	   This allows the entry object to be restored later, even if the
	   store that contains it is not present.

	   \sa KeyStoreListContext::entryPassive()
	*/
	virtual QString serialize() const = 0;

	/**
	   If this entry is of type KeyStoreEntry::TypeKeyBundle, this
	   function returns the KeyBundle of the entry
	*/
	virtual KeyBundle keyBundle() const;

	/**
	   If this entry is of type KeyStoreEntry::TypeCertificate, this
	   function returns the Certificate of the entry
	*/
	virtual Certificate certificate() const;

	/**
	   If this entry is of type KeyStoreEntry::TypeCRL, this function
	   returns the CRL of the entry
	*/
	virtual CRL crl() const;

	/**
	   If this entry is of type KeyStoreEntry::TypePGPSecretKey, this
	   function returns the secret PGPKey of the entry
	*/
	virtual PGPKey pgpSecretKey() const;

	/**
	   If this entry is of type KeyStoreEntry::TypePGPPublicKey or
	   KeyStoreEntry::TypePGPSecretKey, this function returns the public
	   PGPKey of the entry
	*/
	virtual PGPKey pgpPublicKey() const;

	/**
	   Attempt to ensure the private key of this entry is usable and
	   accessible, potentially prompting the user and/or performing a
	   login to a token device.  Returns true if the entry is now
	   accessible, or false if the entry cannot be made accessible.

	   This function is blocking.
	*/
	virtual bool ensureAccess();
};

/**
   \class KeyStoreListContext qcaprovider.h QtCrypto

   KeyStore provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want KeyStore instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT KeyStoreListContext : public Provider::Context
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	KeyStoreListContext(Provider *p) : Provider::Context(p, QStringLiteral("keystorelist")) {}

	/**
	   Starts the keystore provider
	*/
	virtual void start();

	/**
	   Enables or disables update events

	   The updated() and storeUpdated() signals might not be emitted if
	   updates are not enabled.

	   \param enabled whether update notifications are enabled (true) or disabled (false)
	*/
	virtual void setUpdatesEnabled(bool enabled);

	/**
	   Returns a list of integer context ids, each representing a
	   keystore instance

	   If a keystore becomes unavailable and then later becomes
	   available again (for example, if a smart card is removed and
	   then the same one is inserted again), the integer context id
	   must be different than last time.
	*/
	virtual QList<int> keyStores() = 0;

	/**
	   Returns the type of the specified store, or -1 if the integer
	   context id is invalid

	   \param id the id for the store context
	*/
	virtual KeyStore::Type type(int id) const = 0;

	/**
	   Returns the string id of the store, or an empty string if the
	   integer context id is invalid

	   The string id of the store should be unique to a single store, and
	   it should persist between availability/unavailability.  For
	   example, a smart card that is removed and inserted again should
	   have the same string id (despite having a new integer context id).

	   \param id the id for the store context
	*/
	virtual QString storeId(int id) const = 0;

	/**
	   Returns the friendly name of the store, or an empty string if the
	   integer context id is invalid

	   \param id the id for the store context
	*/
	virtual QString name(int id) const = 0;

	/**
	   Returns true if the store is read-only

	   If the integer context id is invalid, this function should return
	   true.

	   \param id the id for the store context
	*/
	virtual bool isReadOnly(int id) const;

	/**
	   Returns the types supported by the store, or an empty list if the
	   integer context id is invalid

	   This function should return all supported types, even if the store
	   doesn't actually contain entries for all of the types.

	   \param id the id for the store context
	*/
	virtual QList<KeyStoreEntry::Type> entryTypes(int id) const = 0;

	/**
	   Returns the entries of the store, or an empty list if the integer
	   context id is invalid

	   The caller is responsible for deleting the returned entry objects.

	   \param id the id for the store context
	*/
	virtual QList<KeyStoreEntryContext*> entryList(int id) = 0;

	/**
	   Returns a single entry in the store, if the entry id is already
	   known.  If the entry does not exist, the function returns 0.

	   The caller is responsible for deleting the returned entry object.

	   \param id the id for the store context
	   \param entryId the entry to retrieve
	*/
	virtual KeyStoreEntryContext *entry(int id, const QString &entryId);

	/**
	   Returns a single entry, created from the serialization string of
	   a previous entry (using KeyStoreEntryContext::serialize()).  If
	   the serialization string cannot be parsed by this provider, or the
	   entry cannot otherwise be created, the function returns 0.

	   The caller is responsible for deleting the returned entry object.

	   This function must be thread-safe.

	   \param serialized the serialized data to create the entry from
	*/
	virtual KeyStoreEntryContext *entryPassive(const QString &serialized);

	/**
	   Write a KeyBundle to the store

	   Returns the entry id of the new item, or an empty string if there
	   was an error writing the item.

	   \param id the id for the store context
	   \param kb the key bundle to add to the store
	*/
	virtual QString writeEntry(int id, const KeyBundle &kb);

	/**
	   Write a Certificate to the store

	   Returns the entry id of the new item, or an empty string if there
	   was an error writing the item.

	   \param id the id for the store context
	   \param cert the certificate to add to the store
	*/
	virtual QString writeEntry(int id, const Certificate &cert);

	/**
	   Write a CRL to the store

	   Returns the entry id of the new item, or an empty string if there
	   was an error writing the item.

	   \param id the id for the store context
	   \param crl the revocation list to add to the store
	*/
	virtual QString writeEntry(int id, const CRL &crl);

	/**
	   Write a PGPKey to the store

	   Returns the entry id of the new item, or an empty string if there
	   was an error writing the item.

	   \param id the id for the store context
	   \param key the PGP key to add to the store
	*/
	virtual QString writeEntry(int id, const PGPKey &key);

	/**
	   Remove an entry from the store

	   Returns true if the entry is successfully removed, otherwise
	   false.

	   \param id the id for the store context
	   \param entryId the entry to remove from the store
	*/
	virtual bool removeEntry(int id, const QString &entryId);

Q_SIGNALS:
	/**
	   Emit this when the provider is busy looking for keystores.  The
	   provider goes into a busy state when it has reason to believe
	   there are keystores present, but it still needs to check or query
	   some devices to see for sure.

	   For example, if a smart card is inserted, then the provider may
	   immediately go into a busy state upon detecting the insert.
	   However, it may take some seconds before the smart card
	   information can be queried and reported by the provider.  Once
	   the card is queried successfully, the provider would leave the
	   busy state and report the new keystore.

	   When this object is first started with start(), it is assumed to
	   be in the busy state, so there is no need to emit this signal at
	   the beginning.
	*/
	void busyStart();

	/**
	   Emit this to leave the busy state

	   When this object is first started with start(), it is assumed to
	   be in the busy state.  You must emit busyEnd() at some point, or
	   QCA will never ask you about keystores.
	*/
	void busyEnd();

	/**
	   Indicates the list of keystores has changed, and that QCA should
	   call keyStores() to obtain the latest list
	*/
	void updated();

	/**
	   Emitted when there is diagnostic text to report

	   \param str the diagnostic text
	*/
	void diagnosticText(const QString &str);

	/**
	   Indicates that the entry list of a keystore has changed (entries
	   added, removed, or modified)

	   \param id the id of the key store that has changed
	*/
	void storeUpdated(int id);
};

/**
   \class TLSSessionContext qcaprovider.h QtCrypto

   TLS "session" provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want TLSSession instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT TLSSessionContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	TLSSessionContext(Provider *p) : BasicContext(p, QStringLiteral("tlssession")) {}
};

/**
   \class TLSContext qcaprovider.h QtCrypto

   TLS provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want TLS instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT TLSContext : public Provider::Context
{
	Q_OBJECT
public:
	/**
	   \class QCA::TLSContext::SessionInfo qcaprovider.h QtCrypto

	   Information about an active TLS connection

	   For efficiency and simplicity, the members are directly accessed.

	   \ingroup ProviderAPI
	*/
	class SessionInfo
	{
	public:
		/**
		   True if the TLS connection is compressed, otherwise false
		*/
		bool isCompressed;

		/**
		   The TLS protocol version being used for this connection
		*/
		TLS::Version version;

		/**
		   The cipher suite being used for this connection

		   \sa TLSContext::supportedCipherSuites()
		*/
		QString cipherSuite;

		/**
		   The bit size of the cipher used for this connection
		*/
		int cipherBits;

		/**
		   The maximum bit size possible of the cipher used for this
		   connection
		*/
		int cipherMaxBits;

		/**
		   Pointer to the id of this TLS session, for use with
		   resuming
		*/
		TLSSessionContext *id;
	};

	/**
	   Result of a TLS operation
	*/
	enum Result
	{
		Success, ///< Operation completed
		Error,   ///< Operation failed
		Continue ///< More data needed to complete operation
	};

	/**
	   Standard constructor

	   \param p the Provider associated with this context
	   \param type the name of the type of feature that supported by this context
	*/
	TLSContext(Provider *p, const QString &type) : Provider::Context(p, type) {}

	/**
	   Reset the object to its initial state
	*/
	virtual void reset() = 0;

	/**
	   Returns a list of supported cipher suites for the specified
	   SSL/TLS version.  The cipher suites are specified as strings, for
	   example: "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" (without quotes).

	   \param version the version of TLS to search for
	*/
	virtual QStringList supportedCipherSuites(const TLS::Version &version) const = 0;

	/**
	   Returns true if the provider supports compression
	*/
	virtual bool canCompress() const = 0;

	/**
	   Returns true if the provider supports server name indication
	*/
	virtual bool canSetHostName() const = 0;

	/**
	   Returns the maximum SSF supported by this provider
	*/
	virtual int maxSSF() const = 0;

	/**
	   Configure a new session

	   This function will be called before any other configuration
	   functions.

	   \param serverMode whether to operate as a server (true) or client (false)
	   \param hostName the hostname to use
	   \param compress whether to compress (true) or not (false)
	*/
	virtual void setup(bool serverMode, const QString &hostName, bool compress) = 0;

	/**
	   Set the constraints of the session using SSF values

	   This function will be called before start().

	   \param minSSF the minimum strength factor that is acceptable 
	   \param maxSSF the maximum strength factor that is acceptable
	*/
	virtual void setConstraints(int minSSF, int maxSSF) = 0;

	/**
	   \overload

	   Set the constraints of the session using a cipher suite list

	   This function will be called before start().

	   \param cipherSuiteList the list of cipher suites that may be used for
	   this session.

	   \sa supportedCipherSuites
	*/
	virtual void setConstraints(const QStringList &cipherSuiteList) = 0;

	/**
	   Set the list of trusted certificates

	   This function may be called at any time.

	   \param trusted the trusted certificates and CRLs to be used.
	*/
	virtual void setTrustedCertificates(const CertificateCollection &trusted) = 0;

	/**
	   Set the list of acceptable issuers

	   This function may be called at any time.

	   This function is for server mode only.

	   \param issuerList the list of issuers that may be used
	*/
	virtual void setIssuerList(const QList<CertificateInfoOrdered> &issuerList) = 0;

	/**
	   Set the local certificate

	   This function may be called at any time.

	   \param cert the certificate and associated trust chain
	   \param key the private key for the local certificate
	*/
	virtual void setCertificate(const CertificateChain &cert, const PrivateKey &key) = 0;

	/**
	   Set the TLS session id, for session resuming

	   This function will be called before start().

	   \param id the session identification
	*/
	virtual void setSessionId(const TLSSessionContext &id) = 0;

	/**
	   Sets the session to the shutdown state.

	   The actual shutdown operation will happen at a future call to
	   update().

	   This function is for normal TLS only (not DTLS).
	*/
	virtual void shutdown() = 0;

	/**
	   Set the maximum transmission unit size

	   This function is for DTLS only.

	   \param size the maximum number of bytes in a datagram
	*/
	virtual void setMTU(int size);

	/**
	   Begins the session, starting with the handshake

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, the result() function will return Success if the
	   TLS session is able to begin, or Error if there is a failure to
	   initialize the TLS subsystem.  If successful, the session is now
	   in the handshake state, and update() will be called repeatedly
	   until the session ends.
	*/
	virtual void start() = 0;

	/**
	   Performs one iteration of the TLS session processing

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   If the session is in a handshake state, result() and to_net() will
	   be valid.  If result() is Success, then the session is now in the
	   connected state.

	   If the session is in a shutdown state, result() and to_net() will
	   be valid.  If result() is Success, then the session has ended.

	   If the session is in a connected state, result(), to_net(),
	   encoded(), to_app(), and eof() are valid.  The result() function
	   will return Success or Error.  Note that eof() does not apply
	   to DTLS.

	   For DTLS, this function operates with single packets.  Many
	   update() operations must be performed repeatedly to exchange
	   multiple packets.

	   \param from_net the data from the "other side" of the connection
	   \param from_app the data from the application of the protocol
	*/
	virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;

	/**
	   Waits for a start() or update() operation to complete.  In this
	   case, the resultsReady() signal is not emitted.  Returns true if
	   the operation completed or false if this function times out.

	   This function is blocking.

	   \param msecs number of milliseconds to wait (-1 to wait forever)
	*/
	virtual bool waitForResultsReady(int msecs) = 0;

	/**
	   Returns the result code of an operation
	*/
	virtual Result result() const = 0;

	/**
	   Returns data that should be sent across the network
	*/
	virtual QByteArray to_net() = 0;

	/**
	   Returns the number of bytes of plaintext data that is encoded
	   inside of to_net()
	*/
	virtual int encoded() const = 0;

	/**
	   Returns data that is decoded from the network and should be
	   processed by the application
	*/
	virtual QByteArray to_app() = 0;

	/**
	   Returns true if the peer has closed the stream
	*/
	virtual bool eof() const = 0;

	/**
	   Returns true if the TLS client hello has been received

	   This is only valid if a handshake is in progress or
	   completed.
	*/
	virtual bool clientHelloReceived() const = 0;

	/**
	   Returns true if the TLS server hello has been received

	   This is only valid if a handshake is in progress or completed.
	*/
	virtual bool serverHelloReceived() const = 0;

	/**
	   Returns the host name sent by the client using server name
	   indication (server mode only)

	   This is only valid if a handshake is in progress or completed.
	*/
	virtual QString hostName() const = 0;

	/**
	   Returns true if the peer is requesting a certificate

	   This is only valid if a handshake is in progress or completed.
	*/
	virtual bool certificateRequested() const = 0;

	/**
	   Returns the issuer list sent by the server (client mode only)

	   This is only valid if a handshake is in progress or completed.
	*/
	virtual QList<CertificateInfoOrdered> issuerList() const = 0;

	/**
	   Returns the QCA::Validity of the peer certificate

	   This is only valid if a handshake is completed.
	*/
	virtual Validity peerCertificateValidity() const = 0;

	/**
	   Returns the peer certificate chain

	   This is only valid if a handshake is completed.
	*/
	virtual CertificateChain peerCertificateChain() const = 0;

	/**
	   Returns information about the active TLS session

	   This is only valid if a handshake is completed.
	*/
	virtual SessionInfo sessionInfo() const = 0;

	/**
	   Returns any unprocessed network input data

	   This is only valid after a successful shutdown.
	*/
	virtual QByteArray unprocessed() = 0;

Q_SIGNALS:
	/**
	   Emit this when a start() or update() operation has completed.
	*/
	void resultsReady();

	/**
	   Emit this to force the application to call update(), even with
	   empty arguments.
	*/
	void dtlsTimeout();
};

/**
   \class SASLContext qcaprovider.h QtCrypto

   SASL provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want SASL instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT SASLContext : public Provider::Context
{
	Q_OBJECT
public:
	/**
	   \class QCA::SASLContext::HostPort qcaprovider.h QtCrypto

	   Convenience class to hold an IP address and an associated port

	   For efficiency and simplicity, the members are directly accessed.

	   \ingroup ProviderAPI
	*/
	class HostPort
	{
	public:
		/**
		   The IP address
		*/
		QString addr;

		/**
		   The port
		*/
		quint16 port;
	};

	/**
	   Result of a SASL operation
	*/
	enum Result
	{
		Success,   ///< Operation completed
		Error,     ///< Operation failed
		Params,    ///< Parameters are needed to complete authentication
		AuthCheck, ///< Client login can be inspected (server only)
		Continue   ///< More steps needed to complete authentication
	};

	/**
	   Standard constructor

	   \param p the Provider associated with this context
	*/
	SASLContext(Provider *p) : Provider::Context(p, QStringLiteral("sasl")) {}

	/**
	   Reset the object to its initial state
	*/
	virtual void reset() = 0;

	/**
	   Configure a new session

	   This function will be called before any other configuration
	   functions.

	   \param service the name of the network service being provided by
	   this application, which can be used by the SASL system for policy
	   control.  Examples: "imap", "xmpp"
	   \param host the hostname that the application is interacting with
	   or as
	   \param local pointer to a HostPort representing the local end of a
	   network socket, or 0 if this information is unknown or not
	   available
	   \param remote pointer to a HostPort representing the peer end of a
	   network socket, or 0 if this information is unknown or not
	   available
	   \param ext_id the id to be used for SASL EXTERNAL (client only)
	   \param ext_ssf the SSF of the external authentication channel
	   (client only)
	*/
	virtual void setup(const QString &service, const QString &host, const HostPort *local, const HostPort *remote, const QString &ext_id, int ext_ssf) = 0;

	/**
	   Set the constraints of the session using SSF values

	   This function will be called before startClient() or
	   startServer().

	   \param f the flags to use
	   \param minSSF the minimum strength factor that is acceptable 
	   \param maxSSF the maximum strength factor that is acceptable
	*/
	virtual void setConstraints(SASL::AuthFlags f, int minSSF, int maxSSF) = 0;

	/**
	   Begins the session in client mode, starting with the
	   authentication

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, result(), mech(), haveClientInit(), and stepData()
	   will be valid.  If result() is Success, then the session is now in
	   the connected state.

	   \param mechlist the list of mechanisms
	   \param allowClientSendFirst whether the client sends first (true) or the server
	   sends first (false)
	*/
	virtual void startClient(const QStringList &mechlist, bool allowClientSendFirst) = 0;

	/**
	   Begins the session in server mode, starting with the
	   authentication

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, result() and mechlist() will be valid.  The
	   result() function will return Success or Error.  If the result is
	   Success, then serverFirstStep() will be called next.

	   \param realm the realm to authenticate in
	   \param disableServerSendLast whether the client sends first (true)
	   or the server sends first (false)
	*/
	virtual void startServer(const QString &realm, bool disableServerSendLast) = 0;

	/**
	   Finishes server startup

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, result() and stepData() will be valid.  If result()
	   is Success, then the session is now in the connected state.

	   \param mech the mechanism to use
	   \param clientInit initial data from the client, or 0 if there is
	   no such data
	*/
	virtual void serverFirstStep(const QString &mech, const QByteArray *clientInit) = 0;

	/**
	   Perform another step of the SASL authentication

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, result() and stepData() will be valid.

	   \param from_net the data from the "other side" of the protocol
	   to be used for the next step.
	*/
	virtual void nextStep(const QByteArray &from_net) = 0;

	/**
	   Attempt the most recent operation again.  This is used if the
	   result() of an operation is Params or AuthCheck.

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, result() and stepData() will be valid.
	*/
	virtual void tryAgain() = 0;

	/**
	   Performs one iteration of the SASL security layer processing

	   This function returns immediately, and completion is signaled with
	   the resultsReady() signal.

	   On completion, result(), to_net(), encoded(), and to_app() will be
	   valid.  The result() function will return Success or Error.

	   \param from_net the data from the "other side" of the protocol
	   \param from_app the data from the application of the protocol
	*/
	virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;

	/**
	   Waits for a startClient(), startServer(), serverFirstStep(),
	   nextStep(), tryAgain(), or update() operation to complete.  In
	   this case, the resultsReady() signal is not emitted.  Returns true
	   if the operation completed or false if this function times out.

	   This function is blocking.

	   \param msecs number of milliseconds to wait (-1 to wait forever)
	*/
	virtual bool waitForResultsReady(int msecs) = 0;

	/**
	   Returns the result code of an operation
	*/
	virtual Result result() const = 0;

	/**
	   Returns the mechanism list (server mode only)
	*/
	virtual QStringList mechlist() const = 0;

	/**
	   Returns the mechanism selected
	*/
	virtual QString mech() const = 0;

	/**
	   Returns true if the client has initialization data
	*/
	virtual bool haveClientInit() const = 0;

	/**
	   Returns an authentication payload for to be transmitted over the
	   network
	*/
	virtual QByteArray stepData() const = 0;

	/**
	   Returns data that should be sent across the network (for the
	   security layer)
	*/
	virtual QByteArray to_net() = 0;

	/**
	   Returns the number of bytes of plaintext data that is encoded
	   inside of to_net()
	*/
	virtual int encoded() const = 0;

	/**
	   Returns data that is decoded from the network and should be
	   processed by the application
	*/
	virtual QByteArray to_app() = 0;

	/**
	   Returns the SSF of the active SASL session

	   This is only valid after authentication success.
	*/
	virtual int ssf() const = 0;

	/**
	   Returns the reason for failure, if the authentication was not
	   successful.

	   This is only valid after authentication failure.
	*/
	virtual SASL::AuthCondition authCondition() const = 0;

	/**
	   Returns the needed/optional client parameters

	   This is only valid after receiving the Params result code.
	*/
	virtual SASL::Params clientParams() const = 0;

	/**
	   Set some of the client parameters (pass 0 to not set a field)

	   \param user the user name
	   \param authzid the authorization name / role
	   \param pass the password
	   \param realm the realm to authenticate in
	*/
	virtual void setClientParams(const QString *user, const QString *authzid, const SecureArray *pass, const QString *realm) = 0;

	/**
	   Returns the realm list (client mode only)

	   This is only valid after receiving the Params result code and
	   SASL::Params::canSendRealm is set to true.
	*/
	virtual QStringList realmlist() const = 0;

	/**
	   Returns the username attempting to authenticate (server mode only)

	   This is only valid after receiving the AuthCheck result code.
	*/
	virtual QString username() const = 0;

	/**
	   Returns the authzid attempting to authorize (server mode only)

	   This is only valid after receiving the AuthCheck result code.
	*/
	virtual QString authzid() const = 0;

Q_SIGNALS:
	/**
	   Emit this when a startClient(), startServer(), serverFirstStep(),
	   nextStep(), tryAgain(), or update() operation has completed.
	*/
	void resultsReady();
};

/**
   \class MessageContext qcaprovider.h QtCrypto

   SecureMessage provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want SecureMessage
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT MessageContext : public Provider::Context
{
	Q_OBJECT
public:
	/**
	   The type of operation being performed
	*/
	enum Operation
	{
		Encrypt,       ///< Encrypt operation
		Decrypt,       ///< Decrypt (or Decrypt and Verify) operation
		Sign,          ///< Sign operation
		Verify,        ///< Verify operation
		SignAndEncrypt ///< Sign and Encrypt operation
	};

	/**
	   Standard constructor

	   \param p the Provider associated with this context
	   \param type the name of the type of secure message to be created
	*/
	MessageContext(Provider *p, const QString &type) : Provider::Context(p, type) {}

	/**
	   Returns true if the provider supports multiple signers for
	   signature creation or signature verification
	*/
	virtual bool canSignMultiple() const = 0;

	/**
	   The type of secure message (e.g. PGP or CMS)
	*/
	virtual SecureMessage::Type type() const = 0;

	/**
	   Reset the object to its initial state
	*/
	virtual void reset() = 0;

	/**
	   Configure a new encrypting operation

	   \param keys the keys to be used for encryption.
	*/
	virtual void setupEncrypt(const SecureMessageKeyList &keys) = 0;

	/**
	   Configure a new signing operation

	   \param keys the keys to use for signing
	   \param m the mode to sign in
	   \param bundleSigner whether to bundle the signing keys (true) or not (false)
	   \param smime whether to use smime format (true) or not (false)
	*/
	virtual void setupSign(const SecureMessageKeyList &keys, SecureMessage::SignMode m, bool bundleSigner, bool smime) = 0;

	/**
	   Configure a new verify operation

	   \param detachedSig the detached signature to use (if applicable) for verification
	*/
	virtual void setupVerify(const QByteArray &detachedSig) = 0;

	/**
	   Begins the secure message operation

	   This function returns immediately.

	   If there is input data, update() will be called (potentially
	   repeatedly) afterwards.  Emit updated() if there is data to
	   read, if input data has been accepted, or if the operation has
	   finished.

	   \param f the format of the message to be produced
	   \param op the operation to be performed
	*/
	virtual void start(SecureMessage::Format f, Operation op) = 0;

	/**
	   Provide input to the message operation

	   \param in the data to use for the message operation
	*/
	virtual void update(const QByteArray &in) = 0;

	/**
	   Extract output from the message operation
	*/
	virtual QByteArray read() = 0;

	/**
	   Returns the number of input bytes accepted since the last call to
	   update()
	*/
	virtual int written() = 0;

	/**
	   Indicates the end of input
	*/
	virtual void end() = 0;

	/**
	   Returns true if the operation has finished, otherwise false
	*/
	virtual bool finished() const = 0;

	/**
	   Waits for the secure message operation to complete.  In this case,
	   the updated() signal is not emitted.  Returns true if the
	   operation completed or false if this function times out.

	   This function is blocking.

	   \param msecs number of milliseconds to wait (-1 to wait forever)
	*/
	virtual bool waitForFinished(int msecs) = 0;

	/**
	   Returns true if the operation was successful

	   This is only valid if the operation has finished.
	*/
	virtual bool success() const = 0;

	/**
	   Returns the reason for failure, if the operation was not
	   successful

	   This is only valid if the operation has finished.
	*/
	virtual SecureMessage::Error errorCode() const = 0;

	/**
	   Returns the signature, in the case of a detached signature
	   operation

	   This is only valid if the operation has finished.
	*/
	virtual QByteArray signature() const = 0;

	/**
	   Returns the name of the hash used to generate the signature, in
	   the case of a signature operation

	   This is only valid if the operation has finished.
	*/
	virtual QString hashName() const = 0;

	/**
	   Returns a list of signatures, in the case of a verify or decrypt
	   and verify operation

	   This is only valid if the operation has finished.
	*/
	virtual SecureMessageSignatureList signers() const = 0;

	/**
	   Returns any diagnostic text for the operation, potentially useful
	   to show the user in the event the operation is unsuccessful.  For
	   example, this could be the stderr output of gpg.

	   This is only valid if the operation has finished.
	*/
	virtual QString diagnosticText() const;

Q_SIGNALS:
	/**
	   Emitted when there is data to read, if input data has been
	   accepted, or if the operation has finished
	*/
	void updated();
};

/**
   \class SMSContext qcaprovider.h QtCrypto

   SecureMessageSystem provider

   \note This class is part of the provider plugin interface and should not
   be used directly by applications.  You probably want SecureMessageSystem
   instead.

   \ingroup ProviderAPI
*/
class QCA_EXPORT SMSContext : public BasicContext
{
	Q_OBJECT
public:
	/**
	   Standard constructor

	   \param p the provider associated with this context
	   \param type the name of the type of secure message system
	*/
	SMSContext(Provider *p, const QString &type) : BasicContext(p, type) {}

	/**
	   Set the trusted certificates and for this secure message system,
	   to be used for validation

	   The collection may also contain CRLs.

	   This function is only valid for CMS.

	   \param trusted a set of trusted certificates and CRLs.
	*/
	virtual void setTrustedCertificates(const CertificateCollection &trusted);

	/**
	   Set the untrusted certificates and CRLs for this secure message
	   system, to be used for validation

	   This function is only valid for CMS.

	   \param untrusted a set of untrusted certificates and CRLs.
	*/
	virtual void setUntrustedCertificates(const CertificateCollection &untrusted);

	/**
	   Set the private keys for this secure message system, to be used
	   for decryption

	   This function is only valid for CMS.

	   \param keys the keys to be used for decryption
	*/
	virtual void setPrivateKeys(const QList<SecureMessageKey> &keys);

	/**
	   Create a new message object for this system.  The caller is
	   responsible for deleting it.
	*/
	virtual MessageContext *createMessage() = 0;
};

}
#endif

#endif