Overview
Comment: | Support listing keys |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
53e9d23ecb14c3cfda257eae6c3cf670 |
User & Date: | rkeene on 2023-05-26 23:46:43 |
Other Links: | manifest | tags |
Context
2023-05-26
| ||
23:48 | TclPKCS11 0.9.14 Leaf check-in: 0096de45c4 user: rkeene tags: release-0.9.14, trunk | |
23:46 | Support listing keys check-in: 53e9d23ecb user: rkeene tags: trunk | |
2019-06-12
| ||
21:52 | TclPKCS 0.9.13 with many build-related cleanups check-in: 8e5c0ef367 user: rkeene tags: release-0.9.13, trunk | |
Changes
Modified aclocal/shobj.m4 from [3e4d5c6545] to [2123b62392].
︙ | |||
162 163 164 165 166 167 168 | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | - | *) SHOBJEXT="sl" ;; esac ;; mingw32|mingw32msvc*) SHOBJEXT="dll" |
︙ |
Modified tclpkcs11.c from [6a093d42b0] to [ee9f1102e4].
︙ | |||
353 354 355 356 357 358 359 | 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 | + + + + + + - + + + + + + + + + + + | } for (bufidx = idx = 0; (idx < datalen) && (bufidx < sizeof(buf)); idx++) { buf[bufidx++] = alphabet[(data[idx] >> 4) & 0xf]; buf[bufidx++] = alphabet[data[idx] & 0xf]; } retval = Tcl_NewStringObj(buf, bufidx); return(retval); } MODULE_SCOPE Tcl_Obj *tclpkcs11_bytearray_to_string_from_obj(Tcl_Obj *data) { |
︙ | |||
676 677 678 679 680 681 682 683 684 685 686 | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | + + + + - + | initargs.UnlockMutex = tclpkcs11_unlock_mutex; initargs.flags = 0; initargs.LibraryFlags = NULL; initargs.pReserved = NULL; chk_rv = pkcs11_function_list->C_Initialize(&initargs); if (chk_rv == CKR_CANT_LOCK) { /* * If the PKCS#11 module rejects using our locking * functions, retry with OS locking functions. */ initargs.CreateMutex = NULL; initargs.DestroyMutex = NULL; initargs.LockMutex = NULL; initargs.UnlockMutex = NULL; |
︙ | |||
994 995 996 997 998 999 1000 | 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 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | CK_ATTRIBUTE template[] = { {CKA_CLASS, NULL, 0}, {CKA_LABEL, NULL, 0}, {CKA_ID, NULL, 0}, {CKA_VALUE, NULL, 0} }, *curr_attr; CK_ULONG curr_attr_idx; |
︙ | |||
1120 1121 1122 1123 1124 1125 1126 | 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 | - + + - - + + + + + + + + + + - + - - + - - - - - - + + + + + - - - - + + + + + - + + + + + + + + + - + - - - + + - + - - - + + + + - - + + | Tcl_SetObjResult(interp, tclpkcs11_pkcs11_error(chk_rv)); handle->pkcs11->C_FindObjectsFinal(handle->session); return(TCL_ERROR); } |
︙ | |||
1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 | 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 | + + - + + - + + + + + + | /* CKA_CLASS */ objectclass_pk = CKO_PRIVATE_KEY; template[1].pValue = &objectclass_pk; template[1].ulValueLen = sizeof(objectclass_pk); chk_rv = handle->pkcs11->C_FindObjectsInit(handle->session, template, sizeof(template) / sizeof(template[0])); if (chk_rv != CKR_OK) { tclpkcs11_close_session(handle); Tcl_SetObjResult(interp, tclpkcs11_pkcs11_error(chk_rv)); return(TCL_ERROR); } foundObjs = 0; chk_rv = handle->pkcs11->C_FindObjects(handle->session, &hObject, 1, &foundObjs); if (chk_rv != CKR_OK) { |
︙ | |||
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 | 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 | + + + + + + + + | handle->pkcs11->C_EncryptFinal(handle->session, dummybuf, &dummybuf_len); } else { handle->pkcs11->C_SignFinal(handle->session, dummybuf, &dummybuf_len); } } if (chk_rv != CKR_OK) { tclpkcs11_close_session(handle); Tcl_SetObjResult(interp, tclpkcs11_pkcs11_error(chk_rv)); return(TCL_ERROR); } } else { chk_rv = handle->pkcs11->C_DecryptInit(handle->session, &mechanism, hObject); if (chk_rv != CKR_OK) { tclpkcs11_close_session(handle); Tcl_SetObjResult(interp, tclpkcs11_pkcs11_error(chk_rv)); return(TCL_ERROR); } resultbuf_len = sizeof(resultbuf); chk_rv = handle->pkcs11->C_Decrypt(handle->session, input, input_len, resultbuf, &resultbuf_len); if (chk_rv != CKR_OK) { tclpkcs11_close_session(handle); if (chk_rv == CKR_BUFFER_TOO_SMALL) { /* Terminate decryption operation */ handle->pkcs11->C_DecryptFinal(handle->session, NULL, 0); } Tcl_SetObjResult(interp, tclpkcs11_pkcs11_error(chk_rv)); return(TCL_ERROR); } } tclpkcs11_close_session(handle); tcl_result = Tcl_NewByteArrayObj(resultbuf, resultbuf_len); Tcl_SetObjResult(interp, tcl_result); return(TCL_OK); } |
︙ | |||
1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 | 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 | + + + + + | return(TCL_ERROR); } tclCreatComm_ret = Tcl_CreateObjCommand(interp, "pki::pkcs11::listcerts", tclpkcs11_list_certs, interpdata, NULL); if (!tclCreatComm_ret) { return(TCL_ERROR); } tclCreatComm_ret = Tcl_CreateObjCommand(interp, "pki::pkcs11::listkeys", tclpkcs11_list_keys, interpdata, NULL); if (!tclCreatComm_ret) { return(TCL_ERROR); } tclCreatComm_ret = Tcl_CreateObjCommand(interp, "pki::pkcs11::login", tclpkcs11_login, interpdata, NULL); if (!tclCreatComm_ret) { return(TCL_ERROR); } tclCreatComm_ret = Tcl_CreateObjCommand(interp, "pki::pkcs11::logout", tclpkcs11_logout, interpdata, NULL); |
︙ |
Modified test.tcl from [e1ed48f58d] to [cc7cb624cf].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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 | + + + + + + + + + - - + + + + + + + + + + + + + + + + + + | #! /usr/bin/env tclsh lappend auto_path [file join [pwd] work lib] lappend auto_path [file join [pwd] lib] set pkcs11_module "/usr/local/lib/libcackey.so" set pkcs11_module /home/rkeene/devel/cackey/libcackey.so set pkcs11_module /home/rkeene/devel/saml-idp/archive/gcp-pkcs11.so if {0} { set env(PKCS11SPY) $pkcs11_module set env(PKCS11SPY_OUTPUT) /dev/stderr set pkcs11_module /usr/lib/x86_64-linux-gnu/pkcs11/pkcs11-spy.so } load ./tclpkcs11.so Tclpkcs11 set handle [pki::pkcs11::loadmodule $pkcs11_module] puts "Handle: $handle" set slots [pki::pkcs11::listslots $handle] puts "Slots: $slots" foreach slotinfo $slots { set slotid [lindex $slotinfo 0] set slotlabel [lindex $slotinfo 1] set slotflags [lindex $slotinfo 2] if {[lsearch -exact $slotflags TOKEN_PRESENT] != -1} { if {![info exists token_slotid]} { |
︙ | |||
73 74 75 76 77 78 79 80 81 82 | 98 99 100 101 102 103 104 105 106 107 108 109 | + + | set verify [pki::verify $sig $orig $certinfo_list] if {!$verify} { puts "Signature verification error!" break } puts "OK" } pki::pkcs11::unloadmodule $handle |
Modified usage.txt from [d81f14eb4c] to [3e25197791].
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 | + | ::pki::pkcs11::loadmodule <filename> -> handle ::pki::pkcs11::unloadmodule <handle> -> true/false ::pki::pkcs11::listslots <handle> -> list: slotId label flags ::pki::pkcs11::listkeys <handle> <slotId> -> list: keylist ::pki::pkcs11::listcerts <handle> <slotId> -> list: keylist ::pki::pkcs11::encrypt <mode> <input> <keylist> -> data ::pki::pkcs11::decrypt <mode> <input> <keylist> -> data ::pki::pkcs11::login <handle> <slotId> <password> -> true/false ::pki::pkcs11::logout <handle> <slotId> -> true/false ::pki::pkcs11::setpin <handle> <slotId> <oldPass> <newPass> -> true/false |
︙ |