当前位置: 首页>>代码示例>>C++>>正文


C++ CK_FUNCTION_LIST_PTR类代码示例

本文整理汇总了C++中CK_FUNCTION_LIST_PTR的典型用法代码示例。如果您正苦于以下问题:C++ CK_FUNCTION_LIST_PTR类的具体用法?C++ CK_FUNCTION_LIST_PTR怎么用?C++ CK_FUNCTION_LIST_PTR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CK_FUNCTION_LIST_PTR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sc_init_library

int sc_init_library(void *f, int try_write_syslog, sc_lib *sclib,
                    Filename *pkcs11_libfile) {
    CK_FUNCTION_LIST_PTR fl  = 0;
    CK_C_GetFunctionList pGFL  = 0;
    unsigned long slot_count = 16;
    CK_SLOT_ID slots[16];
    CK_RV rv = 0;
    char *msg = "";
    sclib->hLib = LoadLibrary((char *)pkcs11_libfile);

    if (sclib->hLib == NULL) {
        msg = "sc: Cannot load PKCS 11 DLL.";
        goto err;
    }
    pGFL= (CK_RV (*)(CK_FUNCTION_LIST_PTR_PTR))GetProcAddress(sclib->hLib, "C_GetFunctionList");
    if (pGFL == NULL) {
        msg = "sc: Cannot find GetFunctionList()";
        goto err;
    }
    rv = pGFL(&fl);
    if(rv != CKR_OK) {
        msg = "sc: Can't get function list";
        goto err;
    }
    rv = fl->C_Initialize (0); 
    if (CKR_OK != rv ) {
        msg = "sc: C_Initialize failed";
        goto err;
    }   
    rv = fl->C_GetSlotList (TRUE, slots, &slot_count);
    if (CKR_OK != rv) {
        msg = "sc: C_GetSlotList failed";
        goto err;
    }                       
    if (slot_count < 1) {
        msg = "sc: No token available";
        goto err;
    }
    sclib->m_fl = fl;
    return TRUE;
    
 err:
    logevent(f, msg);
    if(try_write_syslog) sc_write_syslog(msg);
    FreeLibrary(sclib->hLib);
    return FALSE;
}
开发者ID:OldsSourcesBackups,项目名称:kitty,代码行数:47,代码来源:sc.c

示例2: teardown_mock_module

static void
teardown_mock_module (CK_FUNCTION_LIST_PTR module)
{
	CK_RV rv;

	rv = module->C_Finalize (NULL);
	assert (rv == CKR_OK);
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:8,代码来源:test-proxy.c

示例3: test_initialize_finalize

static void
test_initialize_finalize (void)
{
	CK_FUNCTION_LIST_PTR proxy;
	CK_RV rv;

	rv = C_GetFunctionList (&proxy);
	assert (rv == CKR_OK);

	assert (p11_proxy_module_check (proxy));

	rv = proxy->C_Initialize (NULL);
	assert (rv == CKR_OK);

	rv = proxy->C_Finalize (NULL);
	assert_num_eq (rv, CKR_OK);

	p11_proxy_module_cleanup ();
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:19,代码来源:test-proxy.c

示例4: test_initialize_multiple

static void
test_initialize_multiple (void)
{
	CK_FUNCTION_LIST_PTR proxy;
	CK_RV rv;

	rv = C_GetFunctionList (&proxy);
	assert (rv == CKR_OK);

	assert (p11_proxy_module_check (proxy));

	rv = proxy->C_Initialize (NULL);
	assert (rv == CKR_OK);

	rv = proxy->C_Initialize (NULL);
	assert (rv == CKR_OK);

	rv = proxy->C_Finalize (NULL);
	assert (rv == CKR_OK);

	rv = proxy->C_Finalize (NULL);
	assert (rv == CKR_OK);

	rv = proxy->C_Finalize (NULL);
	assert (rv == CKR_CRYPTOKI_NOT_INITIALIZED);

	p11_proxy_module_cleanup ();
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:28,代码来源:test-proxy.c

示例5: pkcs11_find_object

CK_RV pkcs11_find_object(CK_FUNCTION_LIST_PTR funcs, FILE *out,
                         CK_SESSION_HANDLE h_session,
                         CK_ATTRIBUTE_PTR search, CK_ULONG length,
                         CK_OBJECT_HANDLE_PTR objects,
                         CK_ULONG count, CK_ULONG_PTR found)
{
    CK_ULONG f;
    CK_RV rc;

    rc = funcs->C_FindObjectsInit(h_session, search, length);
    if (rc != CKR_OK) {
        if(out) {
            show_error(out, "C_FindObjectsInit", rc);
        }
        return rc;
    }

    rc = funcs->C_FindObjects(h_session, objects, count, &f);
    if (rc != CKR_OK) {
        if(out) {
            show_error(out, "C_FindObjects", rc);
        }
        return rc;
    }

    rc = funcs->C_FindObjectsFinal(h_session);
    if (rc != CKR_OK) {
        if(out) {
            show_error(out, "C_FindObjectsFinal", rc);
        }
        return rc;
    }

    if(found) {
        *found = f;
    }

    return rc;
}
开发者ID:mbrossard,项目名称:pkcs11,代码行数:39,代码来源:common.c

示例6: pkcs11_close

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;
}
开发者ID:mbrossard,项目名称:pkcs11,代码行数:22,代码来源:common.c

示例7: lib_info

static void lib_info() {

  CK_INFO info;
  CK_FUNCTION_LIST_PTR funcs;

  if (C_GetFunctionList(&funcs) != CKR_OK) {
    fprintf(stderr, "Get function list failed\n");
    exit(EXIT_FAILURE);
  }

  if (funcs->C_GetInfo(&info) != CKR_OK) {
    fprintf(stderr, "GetInfo failed\n");
    exit(EXIT_FAILURE);
  }

  if (strcmp(info.manufacturerID, MANUFACTURER_ID) != 0) {
    fprintf(stderr, "unexpected manufacturer ID %s\n", info.manufacturerID);
    exit(EXIT_FAILURE);
  }

  if (info.cryptokiVersion.major != CRYPTOKI_VERSION_MAJ ||
      info.cryptokiVersion.minor != CRYPTOKI_VERSION_MIN ) {
    fprintf(stderr, "unexpected Cryptoki version %d.%d\n", info.cryptokiVersion.major, info.cryptokiVersion.minor);
    exit(EXIT_FAILURE);
  }

  if (info.libraryVersion.major != YKCS11_VERSION_MAJOR ||
      info.libraryVersion.minor != ((YKCS11_VERSION_MINOR * 100) + YKCS11_VERSION_PATCH )) {
    fprintf(stderr, "unexpected YKCS11 version %d.%d\n", info.libraryVersion.major, info.libraryVersion.minor);
    exit(EXIT_FAILURE);
  }

  if (strcmp(info.libraryDescription, YKCS11_DESCRIPTION) != 0) {
    fprintf(stderr, "unexpected description %s\n", info.libraryDescription);
    exit(EXIT_FAILURE);
  }

}
开发者ID:akgood,项目名称:yubico-piv-tool,代码行数:38,代码来源:ykcs11_tests.c

示例8: login

CK_RV login(CK_FUNCTION_LIST_PTR p11p, CK_SESSION_HANDLE hSession, int admin, CK_UTF8CHAR *password, CK_ULONG passwordLen) {
    CK_UTF8CHAR pin[64];
    CK_ULONG pinLen = sizeof(pin) - 1;
    CK_RV rv;
    
    if (passwordLen > 0 && password != NULL && passwordLen <= pinLen) {
        memcpy(pin, password, passwordLen);
        pinLen = passwordLen;
    } else {
        printf("Enter %sPIN: ", (admin == 1) ? "admin " : "");
        rv = getPassword(pin, &pinLen);
        if (rv!= 0)
            return(-1);
    }
    
    if (admin == 1)
        rv = p11p->C_Login(hSession, CKU_SO, pin, pinLen);
    else
        rv = p11p->C_Login(hSession, CKU_USER, pin, pinLen);
    
    memset(pin, 0, sizeof(pin));
    return(rv);
}
开发者ID:dariaphoebe,项目名称:KeychainToken,代码行数:23,代码来源:dump_info.c

示例9: setup_mock_module

static CK_FUNCTION_LIST_PTR
setup_mock_module (CK_SESSION_HANDLE *session)
{
	CK_FUNCTION_LIST_PTR proxy;
	CK_SLOT_ID slots[32];
	CK_RV rv;

	rv = C_GetFunctionList (&proxy);
	assert (rv == CKR_OK);

	assert (p11_proxy_module_check (proxy));

	rv = proxy->C_Initialize (NULL);
	assert (rv == CKR_OK);

	mock_slots_all = 32;
	rv = proxy->C_GetSlotList (CK_FALSE, slots, &mock_slots_all);
	assert (rv == CKR_OK);
	assert (mock_slots_all >= 2);

	/* Assume this is the slot we want to deal with */
	mock_slot_one_id = slots[0];
	mock_slot_two_id = slots[1];

	rv = proxy->C_GetSlotList (CK_TRUE, NULL, &mock_slots_present);
	assert (rv == CKR_OK);
	assert (mock_slots_present > 1);

	if (session) {
		rv = (proxy->C_OpenSession) (mock_slot_one_id,
		                             CKF_RW_SESSION | CKF_SERIAL_SESSION,
		                             NULL, NULL, session);
		assert (rv == CKR_OK);
	}

	return proxy;
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:37,代码来源:test-proxy.c

示例10: EstEID_tokensChanged

int EstEID_tokensChanged() {
  LOG_LOCATION;
	CK_SLOT_ID slotID;
	int changed = FALSE;
	while (fl->C_WaitForSlotEvent(CKF_DONT_BLOCK, &slotID, NULL_PTR) == CKR_OK) {
    EstEID_log("C_WaitForSlotEvent() pass cycle 1");
		changed = TRUE;
	}
	if (!changed) {
		while (fl->C_WaitForSlotEvent(CKF_DONT_BLOCK, &slotID, NULL_PTR) == CKR_OK) {
      EstEID_log("C_WaitForSlotEvent() pass cycle 2");
			changed = TRUE;
		}
	}  
  EstEID_log("tokens change %sdetected", changed ? "" : "not ");
	return changed;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:17,代码来源:esteid_certinfo.c

示例11: EstEID_loadCertInfo

int EstEID_loadCertInfo(EstEID_Certs *certs, int index) {
	CK_SLOT_ID slotID = certs->slotIDs[index];

	CK_SLOT_INFO slotInfo;
	FAIL_IF(EstEID_CK_failure("C_GetSlotInfo", fl->C_GetSlotInfo(slotID, &slotInfo)));

	if (!(slotInfo.flags & CKF_TOKEN_PRESENT)) return SUCCESS;

	CK_TOKEN_INFO tokenInfo;
	FAIL_IF(EstEID_CK_failure("C_GetTokenInfo", fl->C_GetTokenInfo(slotID, &tokenInfo)));

	certs->certs[index] = EstEID_createCertMap(tokenInfo);

	FAIL_UNLESS(EstEID_loadCertInfoEntries(certs, index));

	return SUCCESS;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:17,代码来源:esteid_certinfo.c

示例12: EstEID_getRemainingTries

int EstEID_getRemainingTries(CK_SLOT_ID slotID) {
	CK_TOKEN_INFO tokenInfo;
	if (EstEID_CK_failure("C_GetTokenInfo", fl->C_GetTokenInfo(slotID, &tokenInfo))) return -1;
	EstEID_log("flags: %li (%lx)", tokenInfo.flags, tokenInfo.flags);
	if (tokenInfo.flags & CKF_USER_PIN_LOCKED) return 0;
	else if (tokenInfo.flags & CKF_USER_PIN_FINAL_TRY) return 1;
	else if (tokenInfo.flags & CKF_USER_PIN_COUNT_LOW) return 2;
	else return 3;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:9,代码来源:esteid_sign.c

示例13:

int testStability_sign
(
	CK_SESSION_HANDLE hSession,
	CK_OBJECT_HANDLE hPrivateKey,
	CK_BYTE_PTR pData,
	CK_ULONG ulDataLen,
	CK_BYTE_PTR *ppSignature,
	CK_ULONG_PTR pulSignatureLen
)
{
	CK_RV rv;
	CK_MECHANISM mechanism = {
		CKM_RSA_PKCS, NULL_PTR, 0
	};

	rv = p11->C_SignInit(hSession, &mechanism, hPrivateKey);
	if (rv != CKR_OK)
	{
		printf("ERROR: Failed to initialize signing. rv=%s\n", rv2string(rv));
		return 1;
	}

	*pulSignatureLen = 0;
	rv = p11->C_Sign(hSession, pData, ulDataLen, NULL_PTR, pulSignatureLen);
	if (rv != CKR_OK)
	{
		printf("ERROR: Failed to check the size of the signature. rv=%s\n", rv2string(rv));
		return 1;
	}
	*ppSignature = (CK_BYTE_PTR)malloc(*pulSignatureLen);

	rv = p11->C_Sign(hSession, pData, ulDataLen, *ppSignature, pulSignatureLen);
	if (rv != CKR_OK)
	{
		printf("ERROR: Failed to sign the data. rv=%s\n", rv2string(rv));
		free(*ppSignature);
		*ppSignature = NULL;
		*pulSignatureLen = 0;
		return 1;
	}

	return 0;
}
开发者ID:opendnssec,项目名称:pkcs11-testing,代码行数:43,代码来源:stability.cpp

示例14: openP11

// Connect and login to the token
int openP11(CK_SLOT_ID slotID, char* userPIN, CK_SESSION_HANDLE* hSession)
{
	char user_pin_copy[MAX_PIN_LEN+1];
	CK_RV rv;

	rv = p11->C_OpenSession(slotID, CKF_SERIAL_SESSION | CKF_RW_SESSION,
					NULL_PTR, NULL_PTR, hSession);
	if (rv != CKR_OK)
	{
		if (rv == CKR_SLOT_ID_INVALID)
		{
			fprintf(stderr, "ERROR: The given slot does not exist.\n");
		}
		else
		{
			fprintf(stderr, "ERROR: Could not open a session on the given slot.\n");
		}
		return 1;
	}

	// Get the password
	if (getPW(userPIN, user_pin_copy, CKU_USER) != 0)
	{
		fprintf(stderr, "ERROR: Could not get user PIN\n");
		return 1;
	}

	rv = p11->C_Login(*hSession, CKU_USER, (CK_UTF8CHAR_PTR)user_pin_copy, strlen(user_pin_copy));
	if (rv != CKR_OK)
	{
		if (rv == CKR_PIN_INCORRECT) {
			fprintf(stderr, "ERROR: The given user PIN does not match the one in the token.\n");
		}
		else
		{
			fprintf(stderr, "ERROR: Could not log in on the token.\n");
		}
		return 1;
	}

	return 0;
}
开发者ID:fxdupont,项目名称:SoftHSMv2,代码行数:43,代码来源:softhsm2-migrate.cpp

示例15: dbRSAPub2session

// Extract the information about the public RSA key and save it in the token
int dbRSAPub2session(sqlite3* /*db*/, CK_OBJECT_HANDLE objectID, CK_SESSION_HANDLE hSession)
{
	int result = 0;
	int i;
	CK_OBJECT_HANDLE hKey;
	CK_RV rv;

	CK_ATTRIBUTE pubTemplate[] = {
		{ CKA_CLASS,		NULL,	0 },
		{ CKA_KEY_TYPE,		NULL,	0 },
		{ CKA_TOKEN,		NULL,	0 },
		{ CKA_PRIVATE,		NULL,	0 },
		{ CKA_MODIFIABLE,	NULL,	0 },
		{ CKA_LABEL,		NULL,	0 },
		{ CKA_ID,		NULL,	0 },
		{ CKA_START_DATE,	NULL,	0 },
		{ CKA_END_DATE,		NULL,	0 },
		{ CKA_DERIVE,		NULL,	0 },
		{ CKA_SUBJECT,		NULL,	0 },
		{ CKA_ENCRYPT,		NULL,	0 },
		{ CKA_VERIFY,		NULL,	0 },
		{ CKA_VERIFY_RECOVER,	NULL,	0 },
		{ CKA_WRAP,		NULL,	0 },
		{ CKA_MODULUS,		NULL,	0 },
		{ CKA_PUBLIC_EXPONENT,	NULL,	0 }
	};

	for (i = 0; i < 17; i++)
	{
		result = getAttribute(objectID, &pubTemplate[i]);
		if (result)
		{
			freeTemplate(pubTemplate, 17);
			return 1;
		}
	}

	rv = p11->C_CreateObject(hSession, pubTemplate, 17, &hKey);
	if (rv != CKR_OK)
	{
		fprintf(stderr, "ERROR %X: Could not save the public key in the token. "
				"Skipping object %lu\n", (unsigned int)rv, objectID);
		result = 1;
	}
	else
	{
		printf("Object %lu has been migrated\n", objectID);
	}

	freeTemplate(pubTemplate, 17);

	return result;
}
开发者ID:fxdupont,项目名称:SoftHSMv2,代码行数:54,代码来源:softhsm2-migrate.cpp


注:本文中的CK_FUNCTION_LIST_PTR类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。