TclPKCS11

Check-in [e7904ef06a]
Login

Check-in [e7904ef06a]

Overview
Comment:Fixed bug with finalizing Encrypt/Sign operations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e7904ef06a3db7e7c21a165e3b6161abafbc8e985980e78fbe9174a683ed0a55
User & Date: rkeene on 2011-06-29 23:56:08
Other Links: manifest | tags
Context
2011-06-30
00:06
Fixed issue with threads check-in: f16ee55999 user: rkeene tags: trunk
2011-06-29
23:56
Fixed bug with finalizing Encrypt/Sign operations check-in: e7904ef06a user: rkeene tags: trunk
2010-12-14
13:16
TclPKCS11 0.9.8 Corrected install target check-in: a8ce30ea73 user: rkeene tags: release-0.9.8, trunk
Changes

Modified tclpkcs11.c from [5545ced6e8] to [b28d164d97].

1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
	Tcl_Obj *tcl_mode, *tcl_input;
	Tcl_Obj *tcl_handle = NULL, *tcl_slotid = NULL, *tcl_objid = NULL;
	Tcl_Obj *tcl_result;
	long slotid_long;
	int tcl_keylist_llength, idx;
	int input_len;
	CK_ULONG resultbuf_len;
	int sign;
	int tcl_rv;

	CK_SLOT_ID slotid;
	CK_OBJECT_HANDLE hObject;
	CK_ULONG foundObjs;
	CK_OBJECT_CLASS objectclass_pk;
	CK_ATTRIBUTE template[] = {







|







1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
	Tcl_Obj *tcl_mode, *tcl_input;
	Tcl_Obj *tcl_handle = NULL, *tcl_slotid = NULL, *tcl_objid = NULL;
	Tcl_Obj *tcl_result;
	long slotid_long;
	int tcl_keylist_llength, idx;
	int input_len;
	CK_ULONG resultbuf_len;
	int sign, terminate;
	int tcl_rv;

	CK_SLOT_ID slotid;
	CK_OBJECT_HANDLE hObject;
	CK_ULONG foundObjs;
	CK_OBJECT_CLASS objectclass_pk;
	CK_ATTRIBUTE template[] = {
1476
1477
1478
1479
1480
1481
1482


1483


1484
1485





1486


1487
1488


1489
1490
1491
1492
1493
1494
1495
						}
					}
				}
			}

			chk_rv = handle->pkcs11->C_Sign(handle->session, input, input_len, resultbuf, &resultbuf_len);
		}


		if (chk_rv != CKR_OK) {


			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);
		}
	} else {
		chk_rv = handle->pkcs11->C_DecryptInit(handle->session, &mechanism, hObject);
		if (chk_rv != CKR_OK) {







>
>
|
>
>

|
>
>
>
>
>
|
>
>

|
>
>







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
						}
					}
				}
			}

			chk_rv = handle->pkcs11->C_Sign(handle->session, input, input_len, resultbuf, &resultbuf_len);
		}

		terminate = 0;
		if (chk_rv == CKR_OK) {
			terminate = 1;
		} else {
			if (chk_rv == CKR_BUFFER_TOO_SMALL) {
				terminate = 1;
			}
		}

		if (terminate) {
			if (!sign) {
				handle->pkcs11->C_EncryptFinal(handle->session, NULL, 0);
			} else {
				handle->pkcs11->C_SignFinal(handle->session, NULL, 0);
			}
		}

		if (chk_rv != CKR_OK) {
			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) {

Modified usage.txt from [584fd1a98e] to [6fe644f73c].

1
2
3
4
5
6
7
8



::pki::pkcs11::loadmodule <filename>                       -> handle
::pki::pkcs11::unloadmodule <handle>                       -> true/false
::pki::pkcs11::listslots  <handle>                         -> list: slotId label flags
::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











>
>
>
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::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

# Future
::pki::pkcs11::listobjects <handle> <slotId>               -> list: ....