本文整理汇总了C++中CK_FUNCTION_LIST_PTR::C_Logout方法的典型用法代码示例。如果您正苦于以下问题:C++ CK_FUNCTION_LIST_PTR::C_Logout方法的具体用法?C++ CK_FUNCTION_LIST_PTR::C_Logout怎么用?C++ CK_FUNCTION_LIST_PTR::C_Logout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CK_FUNCTION_LIST_PTR
的用法示例。
在下文中一共展示了CK_FUNCTION_LIST_PTR::C_Logout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_login
static void test_login() {
CK_SESSION_HANDLE session;
CK_SESSION_INFO info;
asrt(funcs->C_Initialize(NULL), CKR_OK, "INITIALIZE");
asrt(funcs->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, &session), CKR_OK, "OpenSession1");
asrt(funcs->C_Login(session, CKU_USER, "123456", 6), CKR_OK, "Login USER");
asrt(funcs->C_Logout(session), CKR_OK, "Logout USER");
asrt(funcs->C_Login(session, CKU_SO, "010203040506070801020304050607080102030405060708", 48), CKR_OK, "Login SO");
asrt(funcs->C_Logout(session), CKR_OK, "Logout SO");
asrt(funcs->C_CloseSession(session), CKR_OK, "CloseSession");
asrt(funcs->C_Finalize(NULL), CKR_OK, "FINALIZE");
}
示例2:
CK_RV pkcs11_close(FILE *err, CK_FUNCTION_LIST_PTR funcs, CK_SESSION_HANDLE h_session)
{
CK_RV rc = funcs->C_Logout(h_session);
if (rc != CKR_OK) {
show_error(err, "C_Logout", rc);
return rc;
}
rc = funcs->C_CloseSession(h_session);
if (rc != CKR_OK) {
show_error(err, "C_CloseSession", rc);
return rc;
}
rc = funcs->C_Finalize(NULL);
if (rc != CKR_OK) {
show_error(err, "C_Finalize", rc);
return rc;
}
return rc;
}
示例3:
static CK_RV
hacky_perform_initialize_pin (GP11Slot *slot)
{
CK_FUNCTION_LIST_PTR funcs;
CK_SESSION_HANDLE session;
CK_SLOT_ID slot_id;
CK_RV rv;
/*
* This hack only works when:
*
* - Module is protected authentication path
* - No other sessions are open.
*
* Thankfully this is the case with mate-keyring-daemon and
* the mate-keyring tool.
*/
funcs = gp11_module_get_functions (gp11_slot_get_module (slot));
g_return_val_if_fail (funcs, CKR_GENERAL_ERROR);
slot_id = gp11_slot_get_handle (slot);
rv = funcs->C_OpenSession (slot_id, CKF_RW_SESSION | CKF_SERIAL_SESSION, NULL, NULL, &session);
if (rv != CKR_OK)
return rv;
rv = funcs->C_Login (session, CKU_SO, NULL, 0);
if (rv == CKR_OK) {
rv = funcs->C_InitPIN (session, NULL, 0);
funcs->C_Logout (session);
}
funcs->C_CloseSession (session);
return rv;
}
示例4: DataMarshalling
//.........这里部分代码省略.........
d2->packInt((char *)&mechanism.ulMaxKeySize);
d2->packInt((char *)&mechanism.flags);
d2->sendData();
delete d2;
}
} else if (!strcmp(d->getMsgType(), "C_Login")) {
CK_SESSION_HANDLE sessionId = 0;
unsigned int user = 0, len = 0;
CK_CHAR_PTR pin = NULL;
printf("Processing: C_Login\n");
sessionId = d->unpackInt();
user = d->unpackInt();
len = d->unpackInt();
pin = (CK_CHAR_PTR) calloc(1, len + 1);
if (!pin) {
printf("ERROR: NO MEMORY\n");
break;
}
d->unpackMem((char *)pin, len);
{
CK_RV ret = 0;
DataMarshalling *d2 = new DataMarshalling(client);
/*
* Opening session
*/
ret = pFunctionList->C_Login(sessionId, user, pin, len);
d2->setMsgType(d->getMsgType());
d2->packInt((char *)&ret);
d2->sendData();
delete d2;
}
} else if (!strcmp(d->getMsgType(), "C_Logout")) {
CK_SESSION_HANDLE sessionId = 0;
printf("Processing: C_Logout\n");
sessionId = d->unpackInt();
{
CK_RV ret = 0;
DataMarshalling *d2 = new DataMarshalling(client);
/*
* Opening session
*/
ret = pFunctionList->C_Logout(sessionId);
d2->setMsgType(d->getMsgType());
d2->packInt((char *)&ret);
d2->sendData();
delete d2;
}
} else if (!strcmp(d->getMsgType(), "C_FindObjectsInit")) {
CK_SESSION_HANDLE sessionId = 0;
unsigned int len = 0;
CK_ATTRIBUTE_PTR attr = NULL;
printf("Processing: C_FindObjectsInit\n");
sessionId = d->unpackInt();
len = d->unpackInt();
attr = (CK_ATTRIBUTE_PTR) calloc(len, sizeof(CK_ATTRIBUTE));
if (!attr) {
printf("ERROR: NO MEMORY\n");
break;
}
for (int i = 0; i < len; i ++) {
示例5: sizeof
//.........这里部分代码省略.........
if (X509_set_pubkey(cert, evp) == 0)
exit(EXIT_FAILURE);
tm = ASN1_TIME_new();
if (tm == NULL)
exit(EXIT_FAILURE);
ASN1_TIME_set_string(tm, "000001010000Z");
X509_set_notBefore(cert, tm);
X509_set_notAfter(cert, tm);
cert->sig_alg->algorithm = OBJ_nid2obj(8);
cert->cert_info->signature->algorithm = OBJ_nid2obj(8);
ASN1_BIT_STRING_set_bit(cert->signature, 8, 1);
ASN1_BIT_STRING_set(cert->signature, "\x00", 1);
px = value_c;
if ((cert_len = (CK_ULONG) i2d_X509(cert, &px)) == 0 || cert_len > sizeof(value_c))
exit(EXIT_FAILURE);
publicKeyTemplate[2].ulValueLen = cert_len;
asrt(funcs->C_Initialize(NULL), CKR_OK, "INITIALIZE");
asrt(funcs->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, &session), CKR_OK, "OpenSession1");
asrt(funcs->C_Login(session, CKU_SO, "010203040506070801020304050607080102030405060708", 48), CKR_OK, "Login SO");
for (i = 0; i < 24; i++) {
id = i;
asrt(funcs->C_CreateObject(session, publicKeyTemplate, 3, obj + i), CKR_OK, "IMPORT CERT");
asrt(funcs->C_CreateObject(session, privateKeyTemplate, 9, obj + i), CKR_OK, "IMPORT KEY");
}
asrt(funcs->C_Logout(session), CKR_OK, "Logout SO");
for (i = 0; i < 24; i++) {
for (j = 0; j < 10; j++) {
if(RAND_pseudo_bytes(some_data, sizeof(some_data)) == -1)
exit(EXIT_FAILURE);
asrt(funcs->C_Login(session, CKU_USER, "123456", 6), CKR_OK, "Login USER");
asrt(funcs->C_SignInit(session, &mech, obj[i]), CKR_OK, "SignInit");
recv_len = sizeof(sig);
asrt(funcs->C_Sign(session, some_data, sizeof(some_data), sig, &recv_len), CKR_OK, "Sign");
/* r_len = 32; */
/* s_len = 32; */
/* der_ptr = der_encoded; */
/* *der_ptr++ = 0x30; */
/* *der_ptr++ = 0xff; // placeholder, fix below */
/* r_ptr = sig; */
/* *der_ptr++ = 0x02; */
/* *der_ptr++ = r_len; */
/* if (*r_ptr >= 0x80) { */
/* *(der_ptr - 1) = *(der_ptr - 1) + 1; */
/* *der_ptr++ = 0x00; */
/* } */
/* else if (*r_ptr == 0x00 && *(r_ptr + 1) < 0x80) { */
/* r_len--; */
/* *(der_ptr - 1) = *(der_ptr - 1) - 1; */
/* r_ptr++; */
示例6: if
//.........这里部分代码省略.........
if (X509_set_pubkey(cert, evp) == 0)
exit(EXIT_FAILURE);
tm = ASN1_TIME_new();
if (tm == NULL)
exit(EXIT_FAILURE);
ASN1_TIME_set_string(tm, "000001010000Z");
X509_set_notBefore(cert, tm);
X509_set_notAfter(cert, tm);
cert->sig_alg->algorithm = OBJ_nid2obj(8);
cert->cert_info->signature->algorithm = OBJ_nid2obj(8);
ASN1_BIT_STRING_set_bit(cert->signature, 8, 1);
ASN1_BIT_STRING_set(cert->signature, "\x00", 1);
p = value_c;
if ((cert_len = (CK_ULONG) i2d_X509(cert, &p)) == 0 || cert_len > sizeof(value_c))
exit(EXIT_FAILURE);
publicKeyTemplate[2].ulValueLen = cert_len;
asrt(funcs->C_Initialize(NULL), CKR_OK, "INITIALIZE");
asrt(funcs->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, &session), CKR_OK, "OpenSession1");
asrt(funcs->C_Login(session, CKU_SO, "010203040506070801020304050607080102030405060708", 48), CKR_OK, "Login SO");
for (i = 0; i < 24; i++) {
id = i;
asrt(funcs->C_CreateObject(session, publicKeyTemplate, 3, obj + i), CKR_OK, "IMPORT CERT");
asrt(funcs->C_CreateObject(session, privateKeyTemplate, 5, obj + i), CKR_OK, "IMPORT KEY");
}
asrt(funcs->C_Logout(session), CKR_OK, "Logout SO");
for (i = 0; i < 24; i++) {
for (j = 0; j < 10; j++) {
if(RAND_pseudo_bytes(some_data, sizeof(some_data)) == -1)
exit(EXIT_FAILURE);
asrt(funcs->C_Login(session, CKU_USER, "123456", 6), CKR_OK, "Login USER");
asrt(funcs->C_SignInit(session, &mech, obj[i]), CKR_OK, "SignInit");
recv_len = sizeof(sig);
asrt(funcs->C_Sign(session, some_data, sizeof(some_data), sig, &recv_len), CKR_OK, "Sign");
r_len = 32;
s_len = 32;
der_ptr = der_encoded;
*der_ptr++ = 0x30;
*der_ptr++ = 0xff; // placeholder, fix below
r_ptr = sig;
*der_ptr++ = 0x02;
*der_ptr++ = r_len;
if (*r_ptr >= 0x80) {
*(der_ptr - 1) = *(der_ptr - 1) + 1;
*der_ptr++ = 0x00;
}
else if (*r_ptr == 0x00 && *(r_ptr + 1) < 0x80) {
r_len--;
*(der_ptr - 1) = *(der_ptr - 1) - 1;
r_ptr++;