本文整理汇总了C++中CK_FUNCTION_LIST_PTR::C_GetSessionInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ CK_FUNCTION_LIST_PTR::C_GetSessionInfo方法的具体用法?C++ CK_FUNCTION_LIST_PTR::C_GetSessionInfo怎么用?C++ CK_FUNCTION_LIST_PTR::C_GetSessionInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CK_FUNCTION_LIST_PTR
的用法示例。
在下文中一共展示了CK_FUNCTION_LIST_PTR::C_GetSessionInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_session
static void test_session() {
CK_SESSION_HANDLE session;
CK_SESSION_INFO info;
asrt(funcs->C_Initialize(NULL), CKR_OK, "INITIALIZE");
asrt(funcs->C_OpenSession(0, CKF_SERIAL_SESSION, NULL, NULL, &session), CKR_OK, "OpenSession1");
asrt(funcs->C_CloseSession(session), CKR_OK, "CloseSession");
asrt(funcs->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, &session), CKR_OK, "OpenSession2");
asrt(funcs->C_GetSessionInfo(session, &info), CKR_OK, "GetSessionInfo");
asrt(info.state, CKS_RW_PUBLIC_SESSION, "CHECK STATE");
asrt(info.flags, CKF_SERIAL_SESSION | CKF_RW_SESSION, "CHECK FLAGS");
asrt(info.ulDeviceError, 0, "CHECK DEVICE ERROR");
asrt(funcs->C_CloseSession(session), CKR_OK, "CloseSession");
asrt(funcs->C_OpenSession(0, CKF_SERIAL_SESSION, NULL, NULL, &session), CKR_OK, "OpenSession3");
asrt(funcs->C_CloseAllSessions(0), CKR_OK, "CloseAllSessions");
asrt(funcs->C_Finalize(NULL), CKR_OK, "FINALIZE");
}
示例2: usage
//.........这里部分代码省略.........
PR_fprintf(PR_STDOUT, " -> VERIFY_RECOVER = %s\n", minfo.flags & CKF_VERIFY_RECOVER ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> GENERATE = %s\n", minfo.flags & CKF_GENERATE ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> GENERATE_KEY_PAIR = %s\n", minfo.flags & CKF_GENERATE_KEY_PAIR ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> WRAP = %s\n", minfo.flags & CKF_WRAP ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> UNWRAP = %s\n", minfo.flags & CKF_UNWRAP ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> DERIVE = %s\n", minfo.flags & CKF_DERIVE ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> EXTENSION = %s\n", minfo.flags & CKF_EXTENSION ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, "\n");
}
if( tinfo.flags & CKF_LOGIN_REQUIRED ) {
PR_fprintf(PR_STDERR, "*** LOGIN REQUIRED but not yet implemented ***\n");
/* all the stuff about logging in as SO and setting the user pin if needed, etc. */
return 2;
}
/* session to find objects */
{
CK_SESSION_HANDLE h = (CK_SESSION_HANDLE)0;
CK_SESSION_INFO sinfo;
CK_ATTRIBUTE_PTR pTemplate;
CK_ULONG tnObjects = 0;
ck_rv = epv->C_OpenSession(pSlots[i], CKF_SERIAL_SESSION, (CK_VOID_PTR)CK_NULL_PTR, (CK_NOTIFY)CK_NULL_PTR, &h);
if( CKR_OK != ck_rv ) {
PR_fprintf(PR_STDERR, "C_OpenSession(%lu, CKF_SERIAL_SESSION, , ) returned 0x%08x\n", pSlots[i], ck_rv);
return 1;
}
PR_fprintf(PR_STDOUT, " Opened a session: handle = 0x%08x\n", h);
(void)memset(&sinfo, 0, sizeof(CK_SESSION_INFO));
ck_rv = epv->C_GetSessionInfo(h, &sinfo);
if( CKR_OK != ck_rv ) {
PR_fprintf(PR_STDOUT, "C_GetSessionInfo(%lu, ) returned 0x%08x\n", h, ck_rv);
return 1;
}
PR_fprintf(PR_STDOUT, " SESSION INFO:\n");
PR_fprintf(PR_STDOUT, " slotID = %lu\n", sinfo.slotID);
PR_fprintf(PR_STDOUT, " state = %lu\n", sinfo.state);
PR_fprintf(PR_STDOUT, " flags = 0x%08x\n", sinfo.flags);
#ifdef CKF_EXCLUSIVE_SESSION
PR_fprintf(PR_STDOUT, " -> EXCLUSIVE SESSION = %s\n", sinfo.flags & CKF_EXCLUSIVE_SESSION ? "TRUE" : "FALSE");
#endif /* CKF_EXCLUSIVE_SESSION */
PR_fprintf(PR_STDOUT, " -> RW SESSION = %s\n", sinfo.flags & CKF_RW_SESSION ? "TRUE" : "FALSE");
PR_fprintf(PR_STDOUT, " -> SERIAL SESSION = %s\n", sinfo.flags & CKF_SERIAL_SESSION ? "TRUE" : "FALSE");
#ifdef CKF_INSERTION_CALLBACK
PR_fprintf(PR_STDOUT, " -> INSERTION CALLBACK = %s\n", sinfo.flags & CKF_INSERTION_CALLBACK ? "TRUE" : "FALSE");
#endif /* CKF_INSERTION_CALLBACK */
PR_fprintf(PR_STDOUT, " ulDeviceError = %lu\n", sinfo.ulDeviceError);
PR_fprintf(PR_STDOUT, "\n");
ck_rv = epv->C_FindObjectsInit(h, (CK_ATTRIBUTE_PTR)CK_NULL_PTR, 0);
if( CKR_OK != ck_rv ) {
PR_fprintf(PR_STDOUT, "C_FindObjectsInit(%lu, NULL_PTR, 0) returned 0x%08x\n", h, ck_rv);
return 1;
}
pTemplate = (CK_ATTRIBUTE_PTR)PR_Calloc(number_of_all_known_attribute_types, sizeof(CK_ATTRIBUTE));
if( (CK_ATTRIBUTE_PTR)NULL == pTemplate ) {
PR_fprintf(PR_STDERR, "[memory allocation of %lu bytes failed]\n",
number_of_all_known_attribute_types * sizeof(CK_ATTRIBUTE));
return 1;
}
示例3: DataMarshalling
//.........这里部分代码省略.........
dataLen = d->unpackInt();
data = (char *)d->unpackInt();
if (data != NULL) {
data = (char *)calloc(1, dataLen);
if (!data) {
printf("ERROR: NO MEM C_GenerateRandom\n");
break;
}
//d->unpackMem((char *)data, dataLen);
}
{
CK_RV ret = 0;
DataMarshalling *d2 = new DataMarshalling(client);
/*
* Opening session
*/
ret = pFunctionList->C_GenerateRandom(sessionId, (CK_BYTE_PTR)data, dataLen);
d2->setMsgType(d->getMsgType());
d2->packInt((char *)&ret);
if (data != NULL)
d2->packMem((char *)data, dataLen);
d2->sendData();
delete d2;
}
} else if (!strcmp(d->getMsgType(), "C_SeedRandom")) {
CK_SESSION_HANDLE sessionId = 0;
char *data = NULL;
CK_ULONG dataLen = 0;
printf("Processing: C_SeedRandom\n");
sessionId = d->unpackInt();
dataLen = d->unpackInt();
data = (char *)d->unpackInt();
if (data != NULL) {
data = (char *)calloc(1, dataLen);
if (!data) {
printf("ERROR: NO MEM C_SeedRandom\n");
break;
}
d->unpackMem((char *)data, dataLen);
}
{
CK_RV ret = 0;
DataMarshalling *d2 = new DataMarshalling(client);
/*
* Opening session
*/
ret = pFunctionList->C_SeedRandom(sessionId, (CK_BYTE_PTR)data, dataLen);
d2->setMsgType(d->getMsgType());
d2->packInt((char *)&ret);
d2->sendData();
delete d2;
}
} else if (!strcmp(d->getMsgType(), "C_GetSessionInfo")) {
CK_SESSION_HANDLE sessionId = 0;
printf("Processing: C_GetSessionInfo\n");
sessionId = d->unpackInt();
{
CK_RV ret = 0;
CK_SESSION_INFO info;
DataMarshalling *d2 = new DataMarshalling(client);
/*
* Opening session
*/
ret = pFunctionList->C_GetSessionInfo(sessionId, &info);
d2->setMsgType(d->getMsgType());
d2->packInt((char *)&ret);
d2->packInt((char *)&info.slotID);
d2->packInt((char *)&info.state);
d2->packInt((char *)&info.flags);
d2->packInt((char *)&info.ulDeviceError);
d2->sendData();
delete d2;
}
} else if (!strcmp(d->getMsgType(), "C_CloseAllSessions")) {
CK_SLOT_ID slotID = 0;
printf("Processing: C_Logout\n");
slotID = d->unpackInt();
{
CK_RV ret = 0;
DataMarshalling *d2 = new DataMarshalling(client);
/*
* Opening session
*/
ret = pFunctionList->C_CloseAllSessions(slotID);
d2->setMsgType(d->getMsgType());
d2->packInt((char *)&ret);
d2->sendData();
delete d2;
}
} else {
pFunctionList->C_Finalize(NULL);
}
delete d;
}
}