56 {
57
58class Dynamically_Loaded_Library;
59
60namespace PKCS11 {
61
63
65 {
174 };
175
177 {
182 };
183
184
185
187 {
192 };
193
195 {
205 };
206
208 {
264 };
265
266inline Flag operator | (Flag a, Flag b)
267 {
269 }
270
272 {
278 };
279
281 {
286 };
287
289 {
334 };
335
337 {
671 };
672
674 {
677 };
678
680 {
691 };
692
694 {
703 };
704
706 {
712 };
713
715 {
811 };
812
814 {
818 };
819
821 {
824 };
825
853
855
858
859inline Flags flags(Flag flags)
860 {
862 }
863
864class Slot;
865
866
867
868
869
870
871
872
873BOTAN_PUBLIC_API(2,0) void initialize_token(Slot& slot, const
std::
string& label, const secure_string& so_pin,
874 const secure_string& pin);
875
876
877
878
879
880
881
882
883BOTAN_PUBLIC_API(2,0)
void change_pin(Slot& slot, const secure_string& old_pin, const secure_string& new_pin);
884
885
886
887
888
889
890
891BOTAN_PUBLIC_API(2,0)
void change_so_pin(Slot& slot, const secure_string& old_so_pin, const secure_string& new_so_pin);
892
893
894
895
896
897
898
899BOTAN_PUBLIC_API(2,0)
void set_pin(Slot& slot, const secure_string& so_pin, const secure_string& pin);
900
901
903 {
904 public:
905
906 explicit LowLevel(FunctionListPtr ptr);
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921 bool C_Initialize(VoidPtr init_args,
922 ReturnValue* return_value = ThrowException) const;
923
924
925
926
927
928
929
930
931
932
933
934 bool C_Finalize(VoidPtr reserved,
935 ReturnValue* return_value = ThrowException) const;
936
937
938
939
940
941
942
943
944
945
946
947 bool C_GetInfo(Info* info_ptr,
948 ReturnValue* return_value = ThrowException) const;
949
950
951
952
953
954
955
956
957
958
959
960
961 static bool C_GetFunctionList(Dynamically_Loaded_Library& pkcs11_module, FunctionListPtr* function_list_ptr_ptr,
962 ReturnValue* return_value = ThrowException);
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979 bool C_GetSlotList(Bbool token_present,
980 SlotId* slot_list_ptr,
981 Ulong* count_ptr,
982 ReturnValue* return_value = ThrowException) const;
983
984
985
986
987
988
989
990
991
992
993
994
995
996 bool C_GetSlotList(bool token_present,
997 std::vector<SlotId>& slot_ids,
998 ReturnValue* return_value = ThrowException) const;
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012 bool C_GetSlotInfo(SlotId slot_id,
1013 SlotInfo* info_ptr,
1014 ReturnValue* return_value = ThrowException) const;
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029 bool C_GetTokenInfo(SlotId slot_id,
1030 TokenInfo* info_ptr,
1031 ReturnValue* return_value = ThrowException) const;
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046 bool C_WaitForSlotEvent(Flags flags,
1047 SlotId* slot_ptr,
1048 VoidPtr reserved,
1049 ReturnValue* return_value = ThrowException) const;
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066 bool C_GetMechanismList(SlotId slot_id,
1067 MechanismType* mechanism_list_ptr,
1068 Ulong* count_ptr,
1069 ReturnValue* return_value = ThrowException) const;
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085 bool C_GetMechanismList(SlotId slot_id,
1086 std::vector<MechanismType>& mechanisms,
1087 ReturnValue* return_value = ThrowException) const;
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104 bool C_GetMechanismInfo(SlotId slot_id,
1106 MechanismInfo* info_ptr,
1107 ReturnValue* return_value = ThrowException) const;
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126 bool C_InitToken(SlotId slot_id,
1127 Utf8Char* so_pin_ptr,
1128 Ulong so_pin_len,
1129 Utf8Char* label_ptr,
1130 ReturnValue* return_value = ThrowException) const;
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148 template<typename TAlloc>
1149 bool C_InitToken(SlotId slot_id,
1150 const std::vector<uint8_t, TAlloc>& so_pin,
1151 const std::string& label,
1152 ReturnValue* return_value = ThrowException) const
1153 {
1154 std::string padded_label = label;
1155 if(label.size() < 32)
1156 {
1157 padded_label.insert(padded_label.end(), 32 - label.size(), ' ');
1158 }
1159
1160 return C_InitToken(slot_id,
1161 reinterpret_cast< Utf8Char*
>(
const_cast< uint8_t*
>(so_pin.data())),
1162 static_cast<Ulong>(so_pin.size()),
1163 reinterpret_cast< Utf8Char*
>(
const_cast< char*
>(padded_label.c_str())),
1164 return_value);
1165 }
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183 bool C_InitPIN(SessionHandle session,
1184 Utf8Char* pin_ptr,
1185 Ulong pin_len,
1186 ReturnValue* return_value = ThrowException) const;
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203 template<typename TAlloc>
1204 bool C_InitPIN(SessionHandle session,
1205 const std::vector<uint8_t, TAlloc>& pin,
1206 ReturnValue* return_value = ThrowException) const
1207 {
1208 return C_InitPIN(session,
1209 reinterpret_cast< Utf8Char*
>(
const_cast< uint8_t*
>(pin.data())),
1210 static_cast<Ulong>(pin.size()),
1211 return_value);
1212 }
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232 bool C_SetPIN(SessionHandle session,
1233 Utf8Char* old_pin_ptr,
1234 Ulong old_len,
1235 Utf8Char* new_pin_ptr,
1236 Ulong new_len,
1237 ReturnValue* return_value = ThrowException) const;
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255 template<typename TAlloc>
1256 bool C_SetPIN(SessionHandle session,
1257 const std::vector<uint8_t, TAlloc>& old_pin,
1258 const std::vector<uint8_t, TAlloc>& new_pin,
1259 ReturnValue* return_value = ThrowException) const
1260 {
1261 return C_SetPIN(session,
1262 reinterpret_cast< Utf8Char*
>(
const_cast< uint8_t*
>(old_pin.data())),
1263 static_cast<Ulong>(old_pin.size()),
1264 reinterpret_cast< Utf8Char*
>(
const_cast< uint8_t*
>(new_pin.data())),
1265 static_cast<Ulong>(new_pin.size()),
1266 return_value);
1267 }
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290 bool C_OpenSession(SlotId slot_id,
1291 Flags flags,
1292 VoidPtr application,
1293 Notify notify,
1294 SessionHandle* session_ptr,
1295 ReturnValue* return_value = ThrowException) const;
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309 bool C_CloseSession(SessionHandle session,
1310 ReturnValue* return_value = ThrowException) const;
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324 bool C_CloseAllSessions(SlotId slot_id,
1325 ReturnValue* return_value = ThrowException) const;
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340 bool C_GetSessionInfo(SessionHandle session,
1341 SessionInfo* info_ptr,
1342 ReturnValue* return_value = ThrowException) const;
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359 bool C_GetOperationState(SessionHandle session,
1360 Byte* operation_state_ptr,
1361 Ulong* operation_state_len_ptr,
1362 ReturnValue* return_value = ThrowException) const;
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381 bool C_SetOperationState(SessionHandle session,
1382 Byte* operation_state_ptr,
1383 Ulong operation_state_len,
1384 ObjectHandle encryption_key,
1385 ObjectHandle authentication_key,
1386 ReturnValue* return_value = ThrowException) const;
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406 bool C_Login(SessionHandle session,
1407 UserType user_type,
1408 Utf8Char* pin_ptr,
1409 Ulong pin_len,
1410 ReturnValue* return_value = ThrowException) const;
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429 template<typename TAlloc>
1430 bool C_Login(SessionHandle session,
1431 UserType user_type,
1432 const std::vector<uint8_t, TAlloc>& pin,
1433 ReturnValue* return_value = ThrowException) const
1434 {
1435 return C_Login(session, user_type,
1436 reinterpret_cast< Utf8Char*
>(
const_cast< uint8_t*
>(pin.data())),
1437 static_cast<Ulong>(pin.size()),
1438 return_value);
1439 }
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453 bool C_Logout(SessionHandle session,
1454 ReturnValue* return_value = ThrowException) const;
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477 bool C_CreateObject(SessionHandle session,
1478 Attribute* attribute_template_ptr,
1479 Ulong count,
1480 ObjectHandle* object_ptr,
1481 ReturnValue* return_value = ThrowException) const;
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502 bool C_CopyObject(SessionHandle session,
1503 ObjectHandle object,
1504 Attribute* attribute_template_ptr,
1505 Ulong count,
1506 ObjectHandle* new_object_ptr,
1507 ReturnValue* return_value = ThrowException) const;
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523 bool C_DestroyObject(SessionHandle session,
1524 ObjectHandle object,
1525 ReturnValue* return_value = ThrowException) const;
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542 bool C_GetObjectSize(SessionHandle session,
1543 ObjectHandle object,
1544 Ulong* size_ptr,
1545 ReturnValue* return_value = ThrowException) const;
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563 bool C_GetAttributeValue(SessionHandle session,
1564 ObjectHandle object,
1565 Attribute* attribute_template_ptr,
1566 Ulong count,
1567 ReturnValue* return_value = ThrowException) const;
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584 template<typename TAlloc>
1585 bool C_GetAttributeValue(SessionHandle session,
1586 ObjectHandle object,
1587 std::map<AttributeType, std::vector<uint8_t, TAlloc>>& attribute_values,
1588 ReturnValue* return_value = ThrowException) const
1589 {
1590 std::vector<Attribute> getter_template;
1591
1592 for(const auto& entry : attribute_values)
1593 {
1594 getter_template.emplace_back(Attribute{
static_cast< CK_ATTRIBUTE_TYPE >(entry.first),
nullptr, 0 });
1595 }
1596
1597 bool success = C_GetAttributeValue(session,
1598 object,
1599 const_cast< Attribute*
>(getter_template.data()),
1600 static_cast<Ulong>(getter_template.size()),
1601 return_value);
1602
1603 if(!success)
1604 {
1605 return success;
1606 }
1607
1608 size_t i = 0;
1609 for(auto& entry : attribute_values)
1610 {
1611 entry.second.clear();
1612 entry.second.resize(getter_template.at(i).ulValueLen);
1613 getter_template.at(i).pValue = const_cast< uint8_t* >(entry.second.data());
1614 i++;
1615 }
1616
1617 return C_GetAttributeValue(session, object,
1618 const_cast< Attribute*
>(getter_template.data()),
1619 static_cast<Ulong>(getter_template.size()),
1620 return_value);
1621 }
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641 bool C_SetAttributeValue(SessionHandle session,
1642 ObjectHandle object,
1643 Attribute* attribute_template_ptr,
1644 Ulong count,
1645 ReturnValue* return_value = ThrowException) const;
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664 template<typename TAlloc>
1665 bool C_SetAttributeValue(SessionHandle session,
1666 ObjectHandle object,
1667 std::map<AttributeType, std::vector<uint8_t, TAlloc>>& attribute_values,
1668 ReturnValue* return_value = ThrowException) const
1669 {
1670 std::vector<Attribute> setter_template;
1671
1672 for(auto& entry : attribute_values)
1673 {
1674 setter_template.emplace_back(Attribute{
static_cast< CK_ATTRIBUTE_TYPE >(entry.first), entry.second.data(),
static_cast<CK_ULONG>(entry.second.size()) });
1675 }
1676
1677 return C_SetAttributeValue(session, object,
1678 const_cast< Attribute*
>(setter_template.data()),
1679 static_cast<Ulong>(setter_template.size()),
1680 return_value);
1681 }
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698 bool C_FindObjectsInit(SessionHandle session,
1699 Attribute* attribute_template_ptr,
1700 Ulong count,
1701 ReturnValue* return_value = ThrowException) const;
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718 bool C_FindObjects(SessionHandle session,
1719 ObjectHandle* object_ptr,
1720 Ulong max_object_count,
1721 Ulong* object_count_ptr,
1722 ReturnValue* return_value = ThrowException) const;
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736 bool C_FindObjectsFinal(SessionHandle session,
1737 ReturnValue* return_value = ThrowException) const;
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758 bool C_EncryptInit(SessionHandle session,
1759 Mechanism* mechanism_ptr,
1760 ObjectHandle key,
1761 ReturnValue* return_value = ThrowException) const;
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781 bool C_Encrypt(SessionHandle session,
1782 Byte* data_ptr,
1783 Ulong data_len,
1784 Byte* encrypted_data,
1785 Ulong* encrypted_data_len_ptr,
1786 ReturnValue* return_value = ThrowException) const;
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804 template<typename TAllocA, typename TAllocB>
1805 bool C_Encrypt(SessionHandle session,
1806 const std::vector<uint8_t, TAllocA>& plaintext_data,
1807 std::vector<uint8_t, TAllocB>& encrypted_data,
1808 ReturnValue* return_value = ThrowException) const
1809 {
1810 Ulong encrypted_size = 0;
1811 if(!C_Encrypt(session,
1812 const_cast<Byte*
>((plaintext_data.data())),
1813 static_cast<Ulong>(plaintext_data.size()),
1814 nullptr, &encrypted_size,
1815 return_value))
1816 {
1817 return false;
1818 }
1819
1820 encrypted_data.resize(encrypted_size);
1821 if (!C_Encrypt(session,
1822 const_cast<Byte*
>(plaintext_data.data()),
1823 static_cast<Ulong>(plaintext_data.size()),
1824 encrypted_data.data(),
1825 &encrypted_size, return_value))
1826 {
1827 return false;
1828 }
1829 encrypted_data.resize(encrypted_size);
1830 return true;
1831 }
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850 bool C_EncryptUpdate(SessionHandle session,
1851 Byte* part_ptr,
1852 Ulong part_len,
1853 Byte* encrypted_part_ptr,
1854 Ulong* encrypted_part_len_ptr,
1855 ReturnValue* return_value = ThrowException) const;
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872 bool C_EncryptFinal(SessionHandle session,
1873 Byte* last_encrypted_part_ptr,
1874 Ulong* last_encrypted_part_len_ptr,
1875 ReturnValue* return_value = ThrowException) const;
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896 bool C_DecryptInit(SessionHandle session,
1897 Mechanism* mechanism_ptr,
1898 ObjectHandle key,
1899 ReturnValue* return_value = ThrowException) const;
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919 bool C_Decrypt(SessionHandle session,
1920 Byte* encrypted_data_ptr,
1921 Ulong encrypted_data_len,
1922 Byte* data_ptr,
1923 Ulong* data_len_ptr,
1924 ReturnValue* return_value = ThrowException) const;
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942 template<typename TAllocA, typename TAllocB>
1943 bool C_Decrypt(SessionHandle session,
1944 const std::vector<uint8_t, TAllocA>& encrypted_data,
1945 std::vector<uint8_t, TAllocB>& decrypted_data,
1946 ReturnValue* return_value = ThrowException) const
1947 {
1948 Ulong decrypted_size = 0;
1949 if(!C_Decrypt(session,
1950 const_cast<Byte*
>((encrypted_data.data())),
1951 static_cast<Ulong>(encrypted_data.size()),
1952 nullptr, &decrypted_size,
1953 return_value))
1954 {
1955 return false;
1956 }
1957
1958 decrypted_data.resize(decrypted_size);
1959 if(!C_Decrypt(session,
1960 const_cast<Byte*
>(encrypted_data.data()),
1961 static_cast<Ulong>(encrypted_data.size()),
1962 decrypted_data.data(),
1963 &decrypted_size, return_value))
1964 {
1965 return false;
1966 }
1967 decrypted_data.resize(decrypted_size);
1968 return true;
1969 }
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989 bool C_DecryptUpdate(SessionHandle session,
1990 Byte* encrypted_part_ptr,
1991 Ulong encrypted_part_len,
1992 Byte* part_ptr,
1993 Ulong* part_len_ptr,
1994 ReturnValue* return_value = ThrowException) const;
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012 bool C_DecryptFinal(SessionHandle session,
2013 Byte* last_part_ptr,
2014 Ulong* last_part_len_ptr,
2015 ReturnValue* return_value = ThrowException) const;
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034 bool C_DigestInit(SessionHandle session,
2035 Mechanism* mechanism_ptr,
2036 ReturnValue* return_value = ThrowException) const;
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055 bool C_Digest(SessionHandle session,
2056 Byte* data_ptr,
2057 Ulong data_len,
2058 Byte* digest_ptr,
2059 Ulong* digest_len_ptr,
2060 ReturnValue* return_value = ThrowException) const;
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077 bool C_DigestUpdate(SessionHandle session,
2078 Byte* part_ptr,
2079 Ulong part_len,
2080 ReturnValue* return_value = ThrowException) const;
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096 bool C_DigestKey(SessionHandle session,
2097 ObjectHandle key,
2098 ReturnValue* return_value = ThrowException) const;
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115 bool C_DigestFinal(SessionHandle session,
2116 Byte* digest_ptr,
2117 Ulong* digest_len_ptr,
2118 ReturnValue* return_value = ThrowException) const;
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139 bool C_SignInit(SessionHandle session,
2140 Mechanism* mechanism_ptr,
2141 ObjectHandle key,
2142 ReturnValue* return_value = ThrowException) const;
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162 bool C_Sign(SessionHandle session,
2163 Byte* data_ptr,
2164 Ulong data_len,
2165 Byte* signature_ptr,
2166 Ulong* signature_len_ptr,
2167 ReturnValue* return_value = ThrowException) const;
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185 template<typename TAllocA, typename TAllocB>
2186 bool C_Sign(SessionHandle session,
2187 const std::vector<uint8_t, TAllocA>& data,
2188 std::vector<uint8_t, TAllocB>& signature,
2189 ReturnValue* return_value = ThrowException) const
2190 {
2191 Ulong signature_size = 0;
2192 if(!C_Sign(session,
2193 const_cast<Byte*
>((data.data())),
2194 static_cast<Ulong>(data.size()),
2195 nullptr,
2196 &signature_size,
2197 return_value))
2198 {
2199 return false;
2200 }
2201
2202 signature.resize(signature_size);
2203 if (!C_Sign(session,
2204 const_cast<Byte*
>(data.data()),
2205 static_cast<Ulong>(data.size()),
2206 signature.data(),
2207 &signature_size,
2208 return_value))
2209 {
2210 return false;
2211 }
2212 signature.resize(signature_size);
2213 return true;
2214 }
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231 bool C_SignUpdate(SessionHandle session,
2232 Byte* part_ptr,
2233 Ulong part_len,
2234 ReturnValue* return_value = ThrowException) const;
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250 template<typename TAlloc>
2251 bool C_SignUpdate(SessionHandle session,
2252 const std::vector<uint8_t, TAlloc>& part,
2253 ReturnValue* return_value = ThrowException) const
2254 {
2255 return C_SignUpdate(session,
2256 const_cast<Byte*
>(part.data()),
2257 static_cast<Ulong>(part.size()),
2258 return_value);
2259 }
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277 bool C_SignFinal(SessionHandle session,
2278 Byte* signature_ptr,
2279 Ulong* signature_len_ptr,
2280 ReturnValue* return_value = ThrowException) const;
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297 template<typename TAlloc>
2298 bool C_SignFinal(SessionHandle session,
2299 std::vector<uint8_t, TAlloc>& signature,
2300 ReturnValue* return_value = ThrowException) const
2301 {
2302 Ulong signature_size = 0;
2303 if(!C_SignFinal(session, nullptr, &signature_size, return_value))
2304 {
2305 return false;
2306 }
2307
2308 signature.resize(signature_size);
2309 if (!C_SignFinal(session, signature.data(), &signature_size, return_value))
2310 {
2311 return false;
2312 }
2313 signature.resize(signature_size);
2314 return true;
2315 }
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334 bool C_SignRecoverInit(SessionHandle session,
2335 Mechanism* mechanism_ptr,
2336 ObjectHandle key,
2337 ReturnValue* return_value = ThrowException) const;
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357 bool C_SignRecover(SessionHandle session,
2358 Byte* data_ptr,
2359 Ulong data_len,
2360 Byte* signature_ptr,
2361 Ulong* signature_len_ptr,
2362 ReturnValue* return_value = ThrowException) const;
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383 bool C_VerifyInit(SessionHandle session,
2384 Mechanism* mechanism_ptr,
2385 ObjectHandle key,
2386 ReturnValue* return_value = ThrowException) const;
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406 bool C_Verify(SessionHandle session,
2407 Byte* data_ptr,
2408 Ulong data_len,
2409 Byte* signature_ptr,
2410 Ulong signature_len,
2411 ReturnValue* return_value = ThrowException) const;
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429 template<typename TAllocA, typename TAllocB>
2430 bool C_Verify(SessionHandle session,
2431 const std::vector<uint8_t, TAllocA>& data,
2432 std::vector<uint8_t, TAllocB>& signature,
2433 ReturnValue* return_value = ThrowException) const
2434 {
2435 return C_Verify(session,
2436 const_cast<Byte*
>(data.data()),
2437 static_cast<Ulong>(data.size()),
2438 signature.data(),
2439 static_cast<Ulong>(signature.size()),
2440 return_value);
2441 }
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458 bool C_VerifyUpdate(SessionHandle session,
2459 Byte* part_ptr,
2460 Ulong part_len,
2461 ReturnValue* return_value = ThrowException) const;
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477 template<typename TAlloc>
2478 bool C_VerifyUpdate(SessionHandle session,
2479 std::vector<uint8_t, TAlloc> part,
2480 ReturnValue* return_value = ThrowException) const
2481 {
2482 return C_VerifyUpdate(session, part.data(),
static_cast<Ulong>(part.size()), return_value);
2483 }
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501 bool C_VerifyFinal(SessionHandle session,
2502 Byte* signature_ptr,
2503 Ulong signature_len,
2504 ReturnValue* return_value = ThrowException) const;
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523 bool C_VerifyRecoverInit(SessionHandle session,
2524 Mechanism* mechanism_ptr,
2525 ObjectHandle key,
2526 ReturnValue* return_value = ThrowException) const;
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546 bool C_VerifyRecover(SessionHandle session,
2547 Byte* signature_ptr,
2548 Ulong signature_len,
2549 Byte* data_ptr,
2550 Ulong* data_len_ptr,
2551 ReturnValue* return_value = ThrowException) const;
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572 bool C_DigestEncryptUpdate(SessionHandle session,
2573 Byte* part_ptr,
2574 Ulong part_len,
2575 Byte* encrypted_part_ptr,
2576 Ulong* encrypted_part_len_ptr,
2577 ReturnValue* return_value = ThrowException) const ;
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597 bool C_DecryptDigestUpdate(SessionHandle session,
2598 Byte* encrypted_part_ptr,
2599 Ulong encrypted_part_len,
2600 Byte* part_ptr,
2601 Ulong* part_len_ptr,
2602 ReturnValue* return_value = ThrowException) const;
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622 bool C_SignEncryptUpdate(SessionHandle session,
2623 Byte* part_ptr,
2624 Ulong part_len,
2625 Byte* encrypted_part_ptr,
2626 Ulong* encrypted_part_len_ptr,
2627 ReturnValue* return_value = ThrowException) const;
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647 bool C_DecryptVerifyUpdate(SessionHandle session,
2648 Byte* encrypted_part_ptr,
2649 Ulong encrypted_part_len,
2650 Byte* part_ptr,
2651 Ulong* part_len_ptr,
2652 ReturnValue* return_value = ThrowException) const;
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 bool C_GenerateKey(SessionHandle session,
2678 Mechanism* mechanism_ptr,
2679 Attribute* attribute_template_ptr,
2680 Ulong count,
2681 ObjectHandle* key_ptr,
2682 ReturnValue* return_value = ThrowException) const;
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 bool C_GenerateKeyPair(SessionHandle session,
2709 Mechanism* mechanism_ptr,
2710 Attribute* public_key_template_ptr,
2711 Ulong public_key_attribute_count,
2712 Attribute* private_key_template_ptr,
2713 Ulong private_key_attribute_count,
2714 ObjectHandle* public_key_ptr,
2715 ObjectHandle* private_key_ptr,
2716 ReturnValue* return_value = ThrowException) const;
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740 bool C_WrapKey(SessionHandle session,
2741 Mechanism* mechanism_ptr,
2742 ObjectHandle wrapping_key,
2743 ObjectHandle key,
2744 Byte* wrapped_key_ptr,
2745 Ulong* wrapped_key_len_ptr,
2746 ReturnValue* return_value = ThrowException) const;
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 bool C_UnwrapKey(SessionHandle session,
2775 Mechanism* mechanism_ptr,
2776 ObjectHandle unwrapping_key,
2777 Byte* wrapped_key_ptr,
2778 Ulong wrapped_key_len,
2779 Attribute* attribute_template_ptr,
2780 Ulong attribute_count,
2781 ObjectHandle* key_ptr,
2782 ReturnValue* return_value = ThrowException) const;
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 bool C_DeriveKey(SessionHandle session,
2808 Mechanism* mechanism_ptr,
2809 ObjectHandle base_key,
2810 Attribute* attribute_template_ptr,
2811 Ulong attribute_count,
2812 ObjectHandle* key_ptr,
2813 ReturnValue* return_value = ThrowException) const;
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833 bool C_SeedRandom(SessionHandle session,
2834 Byte* seed_ptr,
2835 Ulong seed_len,
2836 ReturnValue* return_value = ThrowException) const;
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853 bool C_GenerateRandom(SessionHandle session,
2854 Byte* random_data_ptr,
2855 Ulong random_len,
2856 ReturnValue* return_value = ThrowException) const;
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871 bool C_GetFunctionStatus(SessionHandle session,
2872 ReturnValue* return_value = ThrowException) const;
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885 bool C_CancelFunction(SessionHandle session,
2886 ReturnValue* return_value = ThrowException) const;
2887
2888 private:
2890 };
2891
2893 {
2894 public:
2895 explicit PKCS11_Error(const std::string& what) :
2896 Exception("PKCS11 error", what)
2897 {
2898 }
2899
2900 ErrorType error_type() const noexcept
override {
return ErrorType::Pkcs11Error; }
2901 };
2902
2904 {
2905 public:
2906 explicit PKCS11_ReturnError(ReturnValue return_val) :
2907 PKCS11_Error(
std::
to_string(static_cast< uint32_t >(return_val))),
2908 m_return_val(return_val)
2909 {}
2910
2912 {
2913 return m_return_val;
2914 }
2915
2916 int error_code() const noexcept override
2917 {
2918 return static_cast<int>(m_return_val);
2919 }
2920
2921 private:
2923 };
2924
2925}
2926
2927}
2928
2929#endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
std::string to_string(const BER_Object &obj)
@ Pkcs5Pbkd2HmacSha512256
@ Pkcs5Pbkd2HmacGostr3411
@ Pkcs5Pbkd2HmacSha512224
CK_RSA_PKCS_OAEP_PARAMS RsaPkcsOaepParams
CK_RSA_PKCS_PSS_PARAMS RsaPkcsPssParams
CK_SESSION_INFO SessionInfo
@ OtpChallengeRequirement
@ DsaShaweTaylorParameterGen
@ WtlsServerKeyAndMacDerive
@ WtlsClientKeyAndMacDerive
@ DsaProbablisticParameterGen
@ WtlsMasterKeyDeriveDhEcc
CK_FUNCTION_LIST_PTR FunctionListPtr
CK_ECDH1_DERIVE_PARAMS Ecdh1DeriveParams
CK_C_INITIALIZE_ARGS C_InitializeArgs
@ LibraryCantCreateOsThreads
@ ProtectedAuthenticationPath
@ SecondaryAuthentication
secure_vector< uint8_t > secure_string
CK_UNLOCKMUTEX UnlockMutex
CK_DESTROYMUTEX DestroyMutex
CK_SESSION_HANDLE SessionHandle
CK_OBJECT_HANDLE ObjectHandle
CK_MECHANISM_INFO MechanismInfo
CK_CREATEMUTEX CreateMutex
@ SessionReadWriteSoExists
@ SessionParallelNotSupported
@ UnwrappingKeyHandleInvalid
@ UserAnotherAlreadyLoggedIn
@ UnwrappingKeyTypeInconsistent
@ KeyFunctionNotPermitted
@ CryptokiAlreadyInitialized
@ WrappingKeyTypeInconsistent
@ OperationNotInitialized
@ WrappingKeyHandleInvalid
#define CKA_NEVER_EXTRACTABLE
#define CKM_TLS_MASTER_KEY_DERIVE
#define CKM_DSA_PARAMETER_GEN
#define CKR_SESSION_COUNT
#define CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE
#define CKM_CONCATENATE_BASE_AND_DATA
#define CKR_DEVICE_MEMORY
#define CKA_JAVA_MIDP_SECURITY_DOMAIN
#define CKM_SSL3_SHA1_MAC
#define CKA_OTP_TIME_INTERVAL
#define CKA_SECONDARY_AUTH
#define CKR_GENERAL_ERROR
#define CKR_MECHANISM_INVALID
#define CKR_SLOT_ID_INVALID
#define CKC_VENDOR_DEFINED
#define CKM_SSL3_MASTER_KEY_DERIVE
#define CKR_ATTRIBUTE_TYPE_INVALID
#define CKA_OTP_SERVICE_IDENTIFIER
#define CKM_GOSTR3411_HMAC
#define CKM_WTLS_PRE_MASTER_KEY_GEN
#define CKA_AUTH_PIN_FLAGS
#define CKM_SHA256_KEY_DERIVATION
#define CKA_SERIAL_NUMBER
#define CKM_CAST5_MAC_GENERAL
#define CKF_LOGIN_REQUIRED
#define CKF_EC_UNCOMPRESS
#define CKA_SUB_PRIME_BITS
#define CKF_LIBRARY_CANT_CREATE_OS_THREADS
#define CKM_SEED_MAC_GENERAL
#define CKF_PROTECTED_AUTHENTICATION_PATH
#define CKA_HASH_OF_SUBJECT_PUBLIC_KEY
#define CKR_FUNCTION_CANCELED
#define CKM_DSA_PROBABLISTIC_PARAMETER_GEN
#define CKM_TWOFISH_CBC_PAD
#define CKM_SKIPJACK_CFB8
#define CKM_RSA_X9_31_KEY_PAIR_GEN
#define CKR_KEY_UNEXTRACTABLE
#define CKR_UNWRAPPING_KEY_HANDLE_INVALID
#define CKM_CONCATENATE_BASE_AND_KEY
#define CKR_NEED_TO_CREATE_THREADS
#define CKM_SEED_ECB_ENCRYPT_DATA
#define CKR_WRAPPING_KEY_SIZE_RANGE
#define CKM_FORTEZZA_TIMESTAMP
#define CKS_RW_PUBLIC_SESSION
#define CKR_MECHANISM_PARAM_INVALID
#define CKA_SUPPORTED_CMS_ATTRIBUTES
#define CKF_TOKEN_INITIALIZED
#define CKR_TOKEN_NOT_RECOGNIZED
#define CKM_SHA512_HMAC_GENERAL
#define CKM_SKIPJACK_CFB64
#define CKM_DES_CBC_ENCRYPT_DATA
#define CKD_SHA1_KDF_ASN1
#define CKR_ATTRIBUTE_SENSITIVE
#define CKM_ECDH1_COFACTOR_DERIVE
#define CKR_RANDOM_NO_RNG
#define CKM_ARIA_CBC_ENCRYPT_DATA
#define CKM_CAMELLIA_KEY_GEN
#define CKR_PIN_LEN_RANGE
#define CKF_USER_PIN_FINAL_TRY
#define CKM_BATON_KEY_GEN
#define CKA_PRIVATE_EXPONENT
#define CKR_RANDOM_SEED_NOT_SUPPORTED
#define CKR_SESSION_PARALLEL_NOT_SUPPORTED
#define CKM_VENDOR_DEFINED
#define CKR_ATTRIBUTE_READ_ONLY
#define CKR_KEY_FUNCTION_NOT_PERMITTED
#define CKA_HW_FEATURE_TYPE
#define CKM_TWOFISH_KEY_GEN
#define CKR_WRAPPING_KEY_TYPE_INCONSISTENT
#define CKA_VERIFY_RECOVER
#define CKM_SHA512_224_HMAC_GENERAL
#define CKM_SKIPJACK_RELAYX
#define CKM_SHA512_224_HMAC
#define CKR_SESSION_EXISTS
#define CKM_MD5_HMAC_GENERAL
#define CKR_FUNCTION_REJECTED
#define CKM_SHA_1_HMAC_GENERAL
#define CKM_TLS10_MAC_CLIENT
unsigned long int CK_ULONG
#define CKM_JUNIPER_ECB128
#define CKA_PUBLIC_EXPONENT
#define CKM_SKIPJACK_CBC64
#define CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE
#define CKM_PBE_SHA1_DES2_EDE_CBC
#define CKM_X9_42_DH_KEY_PAIR_GEN
#define CKM_RSA_PKCS_KEY_PAIR_GEN
#define CKR_SESSION_READ_ONLY
#define CKA_OTP_TIME_REQUIREMENT
#define CKM_PBE_MD5_CAST5_CBC
#define CKM_KEA_KEY_DERIVE
#define CKC_X_509_ATTR_CERT
#define CKM_JUNIPER_KEY_GEN
#define CKR_ENCRYPTED_DATA_LEN_RANGE
#define CKM_SHA512_KEY_DERIVATION
#define CKA_BITS_PER_PIXEL
#define CKR_SIGNATURE_INVALID
#define CKM_AES_MAC_GENERAL
#define CKM_CAST128_CBC_PAD
#define CKA_OTP_USER_IDENTIFIER
#define CKR_SESSION_HANDLE_INVALID
#define CK_CERTIFICATE_CATEGORY_OTHER_ENTITY
#define CKF_USER_PIN_INITIALIZED
#define CKA_PUBLIC_KEY_INFO
#define CKA_OTP_USER_FRIENDLY_MODE
#define CKM_SHA384_HMAC_GENERAL
#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN
#define CKM_SECURID_KEY_GEN
#define CKM_IDEA_MAC_GENERAL
#define CKS_RO_USER_FUNCTIONS
#define CKM_TLS_KEY_AND_MAC_DERIVE
#define CKM_GOST28147_ECB
#define CKR_ARGUMENTS_BAD
#define CKM_SHA512_224_KEY_DERIVATION
#define CKM_SHA512_T_HMAC_GENERAL
#define CKM_TLS_MASTER_KEY_DERIVE_DH
#define CKM_CAST3_MAC_GENERAL
#define CKM_CAST5_CBC_PAD
#define CKM_PBE_SHA1_RC2_128_CBC
#define CKA_NAME_HASH_ALGORITHM
#define CKM_SSL3_PRE_MASTER_KEY_GEN
#define CKM_SSL3_MASTER_KEY_DERIVE_DH
#define CKR_LIBRARY_LOAD_FAILED
#define CKM_RIPEMD128_HMAC_GENERAL
#define CKM_PBA_SHA1_WITH_SHA1_HMAC
#define CKA_OTP_SERVICE_LOGO_TYPE
CK_ULONG CK_SESSION_HANDLE
#define CKA_OTP_CHALLENGE_REQUIREMENT
#define CKR_TOKEN_NOT_PRESENT
#define CKM_SHA512_T_KEY_DERIVATION
#define CKR_CRYPTOKI_NOT_INITIALIZED
#define CKM_DH_PKCS_DERIVE
#define CKM_CAMELLIA_MAC_GENERAL
#define CKM_MD2_HMAC_GENERAL
#define CKM_SEED_CBC_ENCRYPT_DATA
#define CKM_DES3_CMAC_GENERAL
#define CKR_PIN_INCORRECT
#define CKM_CAST128_MAC_GENERAL
#define CK_CERTIFICATE_CATEGORY_TOKEN_USER
#define CKM_PBE_SHA1_RC4_40
#define CKM_PBE_SHA1_CAST5_CBC
#define CKM_TLS10_MAC_SERVER
#define CKM_X9_42_DH_DERIVE
#define CKF_GENERATE_KEY_PAIR
#define CKM_SKIPJACK_PRIVATE_WRAP
#define CKM_KEY_WRAP_LYNKS
#define CKM_SHA512_RSA_PKCS_PSS
#define CKM_CAST5_KEY_GEN
#define CKF_REMOVABLE_DEVICE
#define CKP_PKCS5_PBKD2_HMAC_SHA512_256
#define CKM_RSA_PKCS_OAEP
#define CKR_WRAPPED_KEY_INVALID
#define CKF_SECONDARY_AUTHENTICATION
#define CKM_PBE_SHA1_RC4_128
#define CKM_RSA_PKCS_OAEP_TPM_1_1
#define CKM_SHA512_RSA_PKCS
#define CKM_DES3_MAC_GENERAL
#define CKP_PKCS5_PBKD2_HMAC_SHA224
#define CKM_EXTRACT_KEY_FROM_KEY
#define CKM_SKIPJACK_CFB32
#define CKF_USER_FRIENDLY_OTP
#define CKR_WRAPPING_KEY_HANDLE_INVALID
#define CKR_MUTEX_NOT_LOCKED
#define CKR_USER_TOO_MANY_TYPES
#define CKM_CAST_MAC_GENERAL
#define CKF_USER_PIN_COUNT_LOW
#define CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC
#define CKR_SESSION_CLOSED
#define CKK_RIPEMD160_HMAC
#define CKM_DSA_KEY_PAIR_GEN
#define CKM_SHA1_RSA_X9_31
#define CKM_AES_CBC_ENCRYPT_DATA
#define CKM_CAMELLIA_CBC_PAD
#define CKF_EXCLUDE_COUNTER
CK_FUNCTION_LIST CK_PTR CK_FUNCTION_LIST_PTR
#define CKM_CAMELLIA_ECB_ENCRYPT_DATA
#define CKM_SKIPJACK_CFB16
#define CKM_WTLS_MASTER_KEY_DERIVE
#define CKM_SKIPJACK_KEY_GEN
#define CKH_MONOTONIC_COUNTER
#define CKF_OS_LOCKING_OK
#define CKM_GOST28147_KEY_WRAP
#define CKM_SHA224_RSA_PKCS_PSS
#define CKM_MD5_KEY_DERIVATION
#define CKP_PKCS5_PBKD2_HMAC_SHA384
#define CKR_OBJECT_HANDLE_INVALID
#define CKF_EC_ECPARAMETERS
#define CKM_KEA_KEY_PAIR_GEN
#define CKA_RESET_ON_INIT
#define CKA_OTP_PIN_REQUIREMENT
CK_ULONG CK_RSA_PKCS_MGF_TYPE
#define CKR_UNWRAPPING_KEY_SIZE_RANGE
#define CKM_X9_42_MQV_DERIVE
#define CKD_CPDIVERSIFY_KDF
#define CKM_TLS12_MASTER_KEY_DERIVE
#define CKM_BATON_SHUFFLE
#define CKM_SHA512_256_HMAC_GENERAL
#define CKM_RC5_MAC_GENERAL
#define CKR_ENCRYPTED_DATA_INVALID
#define CKP_PKCS5_PBKD2_HMAC_GOSTR3411
#define CKR_CRYPTOKI_ALREADY_INITIALIZED
#define CKM_GENERIC_SECRET_KEY_GEN
#define CKM_DH_PKCS_KEY_PAIR_GEN
#define CKM_DES3_ECB_ENCRYPT_DATA
#define CKA_ALLOWED_MECHANISMS
#define CKF_SERIAL_SESSION
#define CKR_FUNCTION_FAILED
#define CKM_CDMF_MAC_GENERAL
#define CKA_OTP_COUNTER_REQUIREMENT
#define CKF_DUAL_CRYPTO_OPERATIONS
#define CKR_OPERATION_NOT_INITIALIZED
#define CKR_ACTION_PROHIBITED
#define CKF_SO_PIN_TO_BE_CHANGED
#define CKR_SESSION_READ_ONLY_EXISTS
#define CKM_TLS_PRE_MASTER_KEY_GEN
#define CKM_EC_KEY_PAIR_GEN
#define CKR_SESSION_READ_WRITE_SO_EXISTS
#define CKR_KEY_SIZE_RANGE
#define CKM_DH_PKCS_PARAMETER_GEN
#define CKM_PBE_MD5_CAST128_CBC
#define CKR_TEMPLATE_INCONSISTENT
#define CKR_OPERATION_ACTIVE
#define CKR_DATA_LEN_RANGE
#define CKM_SHA1_RSA_PKCS
#define CKF_ARRAY_ATTRIBUTE
#define CKM_MD2_KEY_DERIVATION
#define CKM_DSA_SHAWE_TAYLOR_PARAMETER_GEN
#define CKA_WRAP_WITH_TRUSTED
CK_ULONG CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE
#define CKR_BUFFER_TOO_SMALL
#define CKM_ARIA_MAC_GENERAL
#define CKM_CAMELLIA_CBC_ENCRYPT_DATA
#define CKS_RW_USER_FUNCTIONS
#define CKM_AES_CMAC_GENERAL
#define CKS_RO_PUBLIC_SESSION
#define CKM_PBE_MD5_CAST_CBC
#define CKM_SHA1_KEY_DERIVATION
#define CKF_EXCLUDE_CHALLENGE
#define CKO_VENDOR_DEFINED
#define CKP_PKCS5_PBKD2_HMAC_SHA512
#define CKR_USER_PIN_NOT_INITIALIZED
#define CKA_ALWAYS_AUTHENTICATE
#define CKM_BATON_COUNTER
#define CKM_CAST3_KEY_GEN
#define CKM_JUNIPER_CBC128
#define CKM_SHA224_RSA_PKCS
#define CKM_PBE_SHA1_DES3_EDE_CBC
#define CKR_USER_ALREADY_LOGGED_IN
#define CKR_STATE_UNSAVEABLE
#define CKM_RIPEMD160_RSA_PKCS
#define CKP_PKCS5_PBKD2_HMAC_SHA1
#define CKA_GOST28147_PARAMS
#define CKM_X9_42_DH_PARAMETER_GEN
#define CKK_RIPEMD128_HMAC
#define CKM_JUNIPER_COUNTER
#define CKD_SHA1_KDF_CONCATENATE
#define CKM_SHA512_256_HMAC
CK_ULONG CK_MECHANISM_TYPE
#define CKK_GENERIC_SECRET
#define CKM_TLS12_KEY_SAFE_DERIVE
#define CKM_PBE_SHA1_CAST128_CBC
#define CKU_CONTEXT_SPECIFIC
#define CKP_PKCS5_PBKD2_HMAC_SHA512_224
#define CKF_SO_PIN_FINAL_TRY
#define CKR_INFORMATION_SENSITIVE
#define CKM_AES_KEY_WRAP_PAD
#define CKM_CONCATENATE_DATA_AND_BASE
#define CKM_GOSTR3410_KEY_WRAP
#define CKM_XOR_BASE_AND_DATA
#define CKM_GOST28147_KEY_GEN
#define CKR_ATTRIBUTE_VALUE_INVALID
#define CKA_REQUIRED_CMS_ATTRIBUTES
#define CK_CERTIFICATE_CATEGORY_AUTHORITY
#define CKM_PBE_MD2_DES_CBC
#define CKM_RIPEMD160_HMAC
#define CKM_KEY_WRAP_SET_OAEP
#define CKM_CAST3_CBC_PAD
#define CKA_CERTIFICATE_CATEGORY
#define CKK_VENDOR_DEFINED
#define CKR_FUNCTION_NOT_SUPPORTED
#define CKF_RESTORE_KEY_NOT_NEEDED
#define CKA_GOSTR3410_PARAMS
#define CKR_USER_NOT_LOGGED_IN
#define CKA_ALWAYS_SENSITIVE
#define CKM_DES_ECB_ENCRYPT_DATA
#define CKR_DEVICE_REMOVED
#define CKA_VENDOR_DEFINED
#define CKM_PBE_SHA1_RC2_40_CBC
#define CKM_GOSTR3410_DERIVE
#define CKP_PKCS5_PBKD2_HMAC_SHA256
#define CKM_SHA256_HMAC_GENERAL
#define CKF_USER_PIN_TO_BE_CHANGED
#define CKM_AES_ECB_ENCRYPT_DATA
#define CKM_RIPEMD128_RSA_PKCS
#define CK_CERTIFICATE_CATEGORY_UNSPECIFIED
#define CKR_DOMAIN_PARAMS_INVALID
#define CKA_CERTIFICATE_TYPE
#define CKF_SO_PIN_LOCKED
CK_ULONG CK_CERTIFICATE_TYPE
#define CKR_TOKEN_WRITE_PROTECTED
#define CKA_HASH_OF_ISSUER_PUBLIC_KEY
#define CKH_VENDOR_DEFINED
#define CKM_RIPEMD128_HMAC
#define CKR_TEMPLATE_INCOMPLETE
#define CKM_DES3_CBC_ENCRYPT_DATA
#define CKF_SO_PIN_COUNT_LOW
CK_ULONG CK_OBJECT_HANDLE
#define CKA_ENCODING_METHODS
CK_ULONG CK_HW_FEATURE_TYPE
#define CKM_SHA256_RSA_PKCS_PSS
#define CKR_KEY_NOT_NEEDED
#define CKM_SKIPJACK_WRAP
#define CKR_VENDOR_DEFINED
#define CKM_SKIPJACK_ECB64
#define CKM_SHA384_KEY_DERIVATION
#define CKA_SUBPRIME_BITS
#define CKM_SKIPJACK_OFB64
#define CKM_GOSTR3410_WITH_GOSTR3411
#define CKM_SHA1_RSA_PKCS_PSS
#define CKM_GOSTR3410_KEY_PAIR_GEN
#define CKA_DEFAULT_CMS_ATTRIBUTES
#define CKM_SHA512_256_KEY_DERIVATION
#define CKA_GOSTR3411_PARAMS
#define CKM_SHA384_RSA_PKCS
CK_ULONG CK_ATTRIBUTE_TYPE
#define CKR_FUNCTION_NOT_PARALLEL
#define CKA_UNWRAP_TEMPLATE
#define CKR_SIGNATURE_LEN_RANGE
#define CKR_CURVE_NOT_SUPPORTED
#define CKM_SHA224_KEY_DERIVATION
#define CKA_KEY_GEN_MECHANISM
#define CKR_FIPS_SELF_TEST_FAILED
#define CKM_JUNIPER_SHUFFLE
#define CKR_USER_TYPE_INVALID
#define CKM_ECDH_AES_KEY_WRAP
#define CKO_DOMAIN_PARAMETERS
#define CKM_PBE_MD5_CAST3_CBC
#define CKM_RSA_AES_KEY_WRAP
#define CKF_USER_PIN_LOCKED
#define CKM_PBE_MD5_DES_CBC
#define CKM_SHA512_T_HMAC
#define CKM_RIPEMD160_HMAC_GENERAL
#define CKM_SHA256_RSA_PKCS
#define CKR_KEY_HANDLE_INVALID
#define CKM_RC2_MAC_GENERAL
#define CKM_CAST128_KEY_GEN
#define CKF_TOKEN_PRESENT
#define CKM_SHA384_RSA_PKCS_PSS
#define CKM_RSA_PKCS_TPM_1_1
#define CKM_SSL3_KEY_AND_MAC_DERIVE
#define CKM_DES_MAC_GENERAL
#define CKR_SAVED_STATE_INVALID
#define CKM_ARIA_ECB_ENCRYPT_DATA
#define CKA_WRAP_TEMPLATE
#define CKR_WRAPPED_KEY_LEN_RANGE
#define CKM_X9_42_DH_HYBRID_DERIVE
#define CKR_EXCEEDED_MAX_ITERATIONS
#define CKM_BLOWFISH_KEY_GEN
#define CKM_GOST28147_MAC
#define CKR_KEY_INDIGESTIBLE
#define CKH_USER_INTERFACE
#define CKF_VERIFY_RECOVER
#define CKA_MECHANISM_TYPE
#define CKF_CLOCK_ON_TOKEN
#define CKS_RW_SO_FUNCTIONS
#define CKM_BLOWFISH_CBC_PAD
#define CKR_PUBLIC_KEY_INVALID
#define CKR_KEY_TYPE_INCONSISTENT
#define CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
#define CKM_AES_XCBC_MAC_96
#define CKM_ECDSA_KEY_PAIR_GEN
#define CKF_WRITE_PROTECTED
#define CKM_TLS12_KEY_AND_MAC_DERIVE
#define CKR_KEY_NOT_WRAPPABLE
#define CKA_DERIVE_TEMPLATE
#define CKF_EC_NAMEDCURVE
#define CKM_TLS12_MASTER_KEY_DERIVE_DH
#define CKM_SHA224_HMAC_GENERAL
#define CKA_OTP_SERVICE_LOGO