| ||||
| ||||
//--------------------------------------------------------------------------- DWORD CEToken::vReadDataObject(CK_BYTE *Password) { DWORD dwRes; DWORD dwSlotsCount = 1; //сколько слотов DWORD dwCount; if (dwSlotsCount < 0 || dwSlotsCount > 1) { dwRes = CKR_USER_TOO_MANY_TYPES; return dwRes; } CK_SESSION_HANDLE hSession = 0; size_t PasswordLen = strlen((const char *)Password); //открываем сессию dwRes = pFunctionList->C_OpenSession ( 0, (CKF_SERIAL_SESSION | CKF_RW_SESSION), 0, 0, &hSession); //логинимся dwRes = pFunctionList->C_Login(hSession, CKU_USER, CK_CHAR_PTR(Password), (CK_ULONG)PasswordLen); //dwRes = 0 //данные CK_OBJECT_CLASS clazz = CKO_DATA; CK_BYTE atrLABEL[] = {""}; CK_BYTE atrVALUE[] = {""}; CK_ATTRIBUTE Template[] = { {CKA_CLASS, &clazz, sizeof(clazz) }, {CKA_LABEL, &atrLABEL, sizeof(atrLABEL)}, {CKA_VALUE, &atrVALUE, sizeof(atrVALUE)}, }; CK_ULONG num_template = sizeof(Template) / sizeof(Template[0]); CK_OBJECT_HANDLE hObject = NULL; CK_ULONG num_handles = NULL; dwRes = pFunctionList->C_FindObjectsInit(hSession, Template, num_template); //dwRes = 0 dwRes = pFunctionList->C_FindObjects(hSession, &hObject, /*1*/3, &num_handles); //dwRes = 0 dwRes = pFunctionList->C_FindObjectsFinal(hSession); //dwRes = 0 //здесь dwRes = 130, а должна быть 0, что не так????? dwRes = pFunctionList->C_GetAttributeValue(hSession, hObject, Template, num_template); //dwRes = 130 AnsiString asTmp = ""; AnsiString asTmp2 = ""; for (CK_ULONG i = 0; i < Template[0].ulValueLen; i ++) { asTmp2.sprintf("%02x ", ((BYTE*)(Template[0].pValue))[i]); asTmp = asTmp + asTmp2; } asTmp = AnsiString("Template[0].pValue") + " = " + asTmp; //в asTmp нули - нет данных, хотя в токене существует объект MessageBox(0, asTmp.c_str(), "Debug", MB_OK); //<-- 00 00 00 00 //делогинимся if (dwRes == CKR_OK) { dwRes = pFunctionList->C_Logout (hSession); dwRes = pFunctionList->C_CloseSession (hSession); } return dwRes; } //--------------------------------------------------------------------------- |