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


C++ CK_FUNCTION_LIST_PTR::C_FindObjectsFinal方法代码示例

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


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

示例1: EstEID_RealSign

int EstEID_RealSign(CK_SESSION_HANDLE session, char **signature, unsigned int *signatureLength, const char *hash, unsigned int hashLength, char* name) {
	CK_OBJECT_HANDLE privateKeyHandle;
	CK_ULONG objectCount;
	unsigned int hashWithPaddingLength = 0;
	char *hashWithPadding;
	CK_MECHANISM mechanism = {CKM_RSA_PKCS, 0, 0};
	CK_OBJECT_CLASS objectClass = CKO_PRIVATE_KEY;
	CK_ATTRIBUTE searchAttribute = {CKA_CLASS, &objectClass, sizeof(objectClass)};

	if (EstEID_CK_failure("C_FindObjectsInit", fl->C_FindObjectsInit(session, &searchAttribute, 1))) CLOSE_SESSION_AND_RETURN(FAILURE);

	if (EstEID_CK_failure("C_FindObjects", fl->C_FindObjects(session, &privateKeyHandle, 1, &objectCount))) CLOSE_SESSION_AND_RETURN(FAILURE);
	if (EstEID_CK_failure("C_FindObjectsFinal", fl->C_FindObjectsFinal(session))) CLOSE_SESSION_AND_RETURN(FAILURE);

	if (objectCount == 0) CLOSE_SESSION_AND_RETURN(FAILURE); // todo ?? set error message

	if (EstEID_CK_failure("C_SignInit", fl->C_SignInit(session, &mechanism, privateKeyHandle))) CLOSE_SESSION_AND_RETURN(FAILURE);

	hashWithPadding = EstEID_addPadding(hash, hashLength, &hashWithPaddingLength);
	if (hashWithPadding) { // This is additional safeguard, as digest length is checked already before calling EstEID_addPadding()
		CK_ULONG len;
		if (EstEID_CK_failure("C_Sign", fl->C_Sign(session, (CK_BYTE_PTR)hashWithPadding, hashWithPaddingLength, NULL, &len))) {
			free(hashWithPadding);
			CLOSE_SESSION_AND_RETURN(FAILURE);
		}
		*signature = (char *)malloc(len);
		if (EstEID_CK_failure("C_Sign", fl->C_Sign(session, (CK_BYTE_PTR)hashWithPadding, hashWithPaddingLength, (CK_BYTE_PTR) * signature, &len))) {
			free(hashWithPadding);
			CLOSE_SESSION_AND_RETURN(FAILURE);
		}
		*signatureLength = len;
		free(hashWithPadding);		
	}

	if (session) {
		if (EstEID_CK_failure("C_CloseSession", fl->C_CloseSession(session))) {
			return FAILURE;
		}
	}

	if(name) {
		free(name);
	}
  
	if (!hashWithPaddingLength) { // This is additional safeguard, as digest length is checked already before calling EstEID_addPadding()
		EstEID_log("will not sign due to incorrect incoming message digest length");
		return FAILURE;
	}
	EstEID_log("successfully signed");
	return SUCCESS;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:51,代码来源:esteid_sign.c

示例2:

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

示例3: usage


//.........这里部分代码省略.........

              if( pT2[l].ulValueLen <= 8 ) {
                PR_fprintf(PR_STDOUT, ", value = ");
              } else {
                PR_fprintf(PR_STDOUT, ", value = \n                ");
              }

              for( m = 0; (m < pT2[l].ulValueLen) && (m < 20); m++ ) {
                PR_fprintf(PR_STDOUT, "%02x", (CK_ULONG)(0xff & ((CK_CHAR_PTR)pT2[l].pValue)[m]));
              }

              PR_fprintf(PR_STDOUT, " ");

              for( m = 0; (m < pT2[l].ulValueLen) && (m < 20); m++ ) {
                CK_CHAR c = ((CK_CHAR_PTR)pT2[l].pValue)[m];
                if( (c < 0x20) || (c >= 0x7f) ) {
                  c = '.';
                }
                PR_fprintf(PR_STDOUT, "%c", c);
              }
            }

            PR_fprintf(PR_STDOUT, "\n");
          }
          
          PR_fprintf(PR_STDOUT, "\n");

          for( l = 0; l < nAttributes; l++ ) {
            PR_Free(pT2[l].pValue);
          }
          PR_Free(pT2);
        } /* while(1) */

        ck_rv = epv->C_FindObjectsFinal(h);
        if( CKR_OK != ck_rv ) {
          PR_fprintf(PR_STDERR, "C_FindObjectsFinal(%lu) returned 0x%08x\n", h, ck_rv);
          return 1;
        }

        PR_fprintf(PR_STDOUT, "    (%lu objects total)\n", tnObjects);

        ck_rv = epv->C_CloseSession(h);
        if( CKR_OK != ck_rv ) {
          PR_fprintf(PR_STDERR, "C_CloseSession(%lu) returned 0x%08x\n", h, ck_rv);
          return 1;
        }
      } /* session to find objects */

      /* session to create, find, and delete a couple session objects */
      {
        CK_SESSION_HANDLE h = (CK_SESSION_HANDLE)0;
        CK_ATTRIBUTE one[7], two[7], three[7], delta[1], mask[1];
        CK_OBJECT_CLASS cko_data = CKO_DATA;
        CK_BBOOL false = CK_FALSE, true = CK_TRUE;
        char *key = "TEST PROGRAM";
        CK_ULONG key_len = strlen(key);
        CK_OBJECT_HANDLE hOneIn = (CK_OBJECT_HANDLE)0, hTwoIn = (CK_OBJECT_HANDLE)0, 
          hThreeIn = (CK_OBJECT_HANDLE)0, hDeltaIn = (CK_OBJECT_HANDLE)0;
        CK_OBJECT_HANDLE found[10];
        CK_ULONG nFound;

        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;
        }
开发者ID:AOSC-Dev,项目名称:nss-purified,代码行数:67,代码来源:trivial.c

示例4: DataMarshalling


//.........这里部分代码省略.........
					//d->unpackMem((char *)attr[i].pValue, attr[i].ulValueLen);
				}
			}
			{
				CK_RV			ret = 0;
				DataMarshalling	*d2 = new DataMarshalling(client);

				ret = pFunctionList->C_GetAttributeValue(sessionId, hObject, attr, len);
				d2->setMsgType(d->getMsgType());
				d2->packInt((char *)&ret);
				for (int i = 0; i < len; i ++) {
					d2->packInt((char *)&attr[i].type);
					d2->packInt((char *)&attr[i].ulValueLen);
					d2->packInt((char *)&attr[i].pValue);
					if (attr[i].pValue != NULL) {
						d2->packMem((char *)attr[i].pValue, attr[i].ulValueLen);
#ifdef FUNC_DEBUG_
						if (i == 2) {
							PCCERT_CONTEXT	pCertContext;

							pCertContext = CertCreateCertificateContext(X509_ASN_ENCODING,((BYTE *)attr[i].pValue),attr[i].ulValueLen);
							printf("data len: %d\n", attr[i].ulValueLen);
							printf("issuer len: %d\n", pCertContext->pCertInfo->Issuer.cbData);
							std::wcout << byte2str(pCertContext->pCertInfo->Issuer.pbData, pCertContext->pCertInfo->Issuer.cbData);
							CertFreeCertificateContext(pCertContext);
						}
		
#endif
					}
				}
				d2->sendData();
				delete d2;
			}
		} else if (!strcmp(d->getMsgType(), "C_FindObjectsFinal")) {
			CK_SESSION_HANDLE	sessionId = 0;

			printf("Processing: C_FindObjectsFinal\n");

			sessionId = d->unpackInt();
			{
				CK_RV			ret = 0;
				DataMarshalling	*d2 = new DataMarshalling(client);
				/*
				 * Opening session
				 */
				ret = pFunctionList->C_FindObjectsFinal(sessionId);
				d2->setMsgType(d->getMsgType());
				d2->packInt((char *)&ret);
				d2->sendData();
				delete d2;
			}
		} else if (!strcmp(d->getMsgType(), "C_SignInit")) {
			CK_SESSION_HANDLE	sessionId = 0;
			CK_MECHANISM		mechanism;
			CK_OBJECT_HANDLE	hKey;

			printf("Processing: C_SignInit\n");

			sessionId = d->unpackInt();
			hKey = d->unpackInt();
			mechanism.mechanism = d->unpackInt();
			mechanism.ulParameterLen = d->unpackInt();
			mechanism.pParameter = NULL;
			{
				CK_RV			ret = 0;
				DataMarshalling	*d2 = new DataMarshalling(client);
开发者ID:ggonzalez,项目名称:Man-In-Remote,代码行数:67,代码来源:main.cpp

示例5: EstEID_signHash


//.........这里部分代码省略.........
		}
		else {
			// PIN pad			
#ifdef _WIN32
			EstEID_log("creating pinpad dialog UI thread");
			pinpad_thread_result = -1;
			FAIL_IF_THREAD_ERROR("CreateMutex", (pinpad_thread_mutex = CreateMutex(NULL, FALSE, NULL)));
#else
			EstEID_log("creating pinpad worker thread");
			pinpad_thread_result = -1;
			FAIL_IF_PTHREAD_ERROR("pthread_mutex_init", pthread_mutex_init(&pinpad_thread_mutex, NULL));
			FAIL_IF_PTHREAD_ERROR("pthread_cond_init", pthread_cond_init(&pinpad_thread_condition, NULL));
			pthread_t pinpad_thread;
			EstEID_PINPadThreadData threadData;
			threadData.session = session;
			threadData.result = CKR_OK;
#endif
			EstEID_log("thread launched");
#ifdef _WIN32
			/*
			NB! Due to Firefox for Windows specific behaviour C_Login() is launched from main thread
			and UI code is running in separate thread if running on Windows.
			*/
			EstEID_PINPromptDataEx pinPromptDataEx;
			pinPromptDataEx.pinPromptData = pinPromptData;
			pinPromptDataEx.message = message;
			pinPromptDataEx.name = name;
			CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&EstEID_pinPadLogin, (LPVOID)&pinPromptDataEx, 0, NULL);
			loginResult = fl->C_Login(session, CKU_USER, NULL, 0);
			closePinPadModalSheet();
#else
			FAIL_IF_PTHREAD_ERROR("pthread_create", pthread_create(&pinpad_thread, NULL, EstEID_pinPadLogin, (void*)&threadData));
			pinPromptData.promptFunction(pinPromptData.nativeWindowHandle, name, message, 0, isPinPad);
			loginResult = threadData.result;
#endif
			EstEID_log("pinpad sheet/dialog closed");			
			if (loginResult == CKR_FUNCTION_CANCELED) {
				setUserCancelErrorCodeAndMessage();				
				CLOSE_SESSION_AND_FAIL;				
			}
		}
		EstEID_log("loginResult = %s", pkcs11_error_message(loginResult));
		switch (loginResult) {
			case CKR_PIN_LOCKED:
				blocked = TRUE;
			case CKR_PIN_INCORRECT:
			case CKR_PIN_INVALID:
			case CKR_PIN_LEN_RANGE:
				EstEID_log("this was attempt %i, loginResult causes to run next round", attempt);
				continue;
			default:
				if (EstEID_CK_failure("C_Login", loginResult)) CLOSE_SESSION_AND_FAIL;
		}
		break; // Login successful - correct PIN supplied
	}

	if (name){
		free(name);
		name = NULL;
	}

	CK_OBJECT_CLASS objectClass = CKO_PRIVATE_KEY;
	CK_ATTRIBUTE searchAttribute = {CKA_CLASS, &objectClass, sizeof(objectClass)};
	if (EstEID_CK_failure("C_FindObjectsInit", fl->C_FindObjectsInit(session, &searchAttribute, 1))) CLOSE_SESSION_AND_FAIL;

	CK_OBJECT_HANDLE privateKeyHandle;
	CK_ULONG objectCount;
	if (EstEID_CK_failure("C_FindObjects", fl->C_FindObjects(session, &privateKeyHandle, 1, &objectCount))) CLOSE_SESSION_AND_FAIL;
	if (EstEID_CK_failure("C_FindObjectsFinal", fl->C_FindObjectsFinal(session))) CLOSE_SESSION_AND_FAIL;

	if (objectCount == 0) CLOSE_SESSION_AND_FAIL; // todo ?? set error message

	CK_MECHANISM mechanism = {CKM_RSA_PKCS, 0, 0};
	if (EstEID_CK_failure("C_SignInit", fl->C_SignInit(session, &mechanism, privateKeyHandle))) CLOSE_SESSION_AND_FAIL;

	unsigned int hashWithPaddingLength;
	char *hashWithPadding = EstEID_addPadding(hash, hashLength, &hashWithPaddingLength);

	CK_ULONG len;
	if (EstEID_CK_failure("C_Sign", fl->C_Sign(session, (CK_BYTE_PTR)hashWithPadding, hashWithPaddingLength, NULL, &len))) {
		free(hashWithPadding);
		CLOSE_SESSION_AND_FAIL;
	}
	*signature = (char *)malloc(len);
	if (EstEID_CK_failure("C_Sign", fl->C_Sign(session, (CK_BYTE_PTR)hashWithPadding, hashWithPaddingLength, (CK_BYTE_PTR) * signature, &len))) {
		free(hashWithPadding);
		CLOSE_SESSION_AND_FAIL;
	}
	*signatureLength = len;
	free(hashWithPadding);

	if (session) {
		if (EstEID_CK_failure("C_CloseSession", fl->C_CloseSession(session))) {
			return FAILURE;
		}
	}
	
	EstEID_log("successfully signed");
	return SUCCESS;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:101,代码来源:esteid_sign.c


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