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


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

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


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

示例1: malloc

CK_RV pkcs11_get_slots(CK_FUNCTION_LIST_PTR funcs, FILE *out,
                       CK_SLOT_ID_PTR *slots, CK_ULONG_PTR nslots)
{
    CK_SLOT_ID *s;
    CK_ULONG n;
    CK_RV rc;

    if(!slots || !nslots) {
        return CKR_ARGUMENTS_BAD;
    }

    rc = funcs->C_GetSlotList(0, NULL_PTR, &n);
    if (rc != CKR_OK) {
        if(out) {
            show_error(out, "C_GetSlotList", rc);
        }
        return rc;
    }
    s = malloc(sizeof(CK_SLOT_ID) * n);
    rc = funcs->C_GetSlotList(0, s, &n);
    if (rc != CKR_OK) {
        if(out) {
            show_error(out, "C_GetSlotList", rc);
        }
        return rc;
    }

    *slots = s;
    *nslots = n;

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

示例2: EstEID_loadSlotIDs

int EstEID_loadSlotIDs(EstEID_Certs *certs) {
	CK_ULONG slotCount;
	FAIL_IF(EstEID_CK_failure("C_GetSlotList", fl->C_GetSlotList(CK_TRUE, NULL_PTR, &slotCount)));

	certs->count = slotCount;
	certs->slotIDs = (CK_SLOT_ID_PTR)malloc(sizeof(CK_SLOT_ID) * slotCount);
	certs->certs = (EstEID_Map *)malloc(sizeof(EstEID_Map) * slotCount);

	FAIL_IF(EstEID_CK_failure("C_GetSlotList", fl->C_GetSlotList(CK_TRUE, certs->slotIDs, &slotCount)));

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

示例3:

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

示例4: 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

示例5: usage

int
rmain
(
  int argc,
  char *argv[]
)
{
  char *argv0 = argv[0];
  PRLibrary *lib;
  CK_C_GetFunctionList gfl;
  CK_FUNCTION_LIST_PTR epv = (CK_FUNCTION_LIST_PTR)NULL;
  CK_RV ck_rv;
  CK_INFO info;
  CK_ULONG nSlots;
  CK_SLOT_ID *pSlots;
  CK_ULONG i;
  CK_C_INITIALIZE_ARGS ia, *iap;

  (void)memset(&ia, 0, sizeof(CK_C_INITIALIZE_ARGS));
  iap = (CK_C_INITIALIZE_ARGS *)NULL;
  while( argv++, --argc ) {
    if( '-' == argv[0][0] ) {
      switch( argv[0][1] ) {
      case 'i':
        iap = &ia;
        if( ((char *)NULL != argv[1]) && ('-' != argv[1][0]) ) {
#ifdef WITH_NSS
          ia.pConfig = argv[1];
          ia.ulConfigLen = strlen(argv[1]);
          argv++, --argc;
#else
          return usage(argv0);
#endif /* WITH_NSS */
        }
        break;
      case '-':
        argv++, --argc;
        goto endargs;
      default:
        return usage(argv0);
      }
    } else {
      break;
    }
  }
 endargs:;

  if( 1 != argc ) {
    return usage(argv0);
  }

  lib = PR_LoadLibrary(argv[0]);
  if( (PRLibrary *)NULL == lib ) {
    PR_fprintf(PR_STDERR, "Can't load %s: %ld, %ld\n", argv[1], PR_GetError(), PR_GetOSError());
    return 1;
  }

  gfl = (CK_C_GetFunctionList)PR_FindSymbol(lib, "C_GetFunctionList");
  if( (CK_C_GetFunctionList)NULL == gfl ) {
    PR_fprintf(PR_STDERR, "Can't find C_GetFunctionList in %s: %ld, %ld\n", argv[1], 
               PR_GetError(), PR_GetOSError());
    return 1;
  }

  ck_rv = (*gfl)(&epv);
  if( CKR_OK != ck_rv ) {
    PR_fprintf(PR_STDERR, "CK_GetFunctionList returned 0x%08x\n", ck_rv);
    return 1;
  }

  PR_fprintf(PR_STDOUT, "Module %s loaded, epv = 0x%08x.\n\n", argv[1], (CK_ULONG)epv);

  /* C_Initialize */
  ck_rv = epv->C_Initialize(iap);
  if( CKR_OK != ck_rv ) {
    PR_fprintf(PR_STDERR, "C_Initialize returned 0x%08x\n", ck_rv);
    return 1;
  }

  /* C_GetInfo */
  (void)memset(&info, 0, sizeof(CK_INFO));
  ck_rv = epv->C_GetInfo(&info);
  if( CKR_OK != ck_rv ) {
    PR_fprintf(PR_STDERR, "C_GetInfo returned 0x%08x\n", ck_rv);
    return 1;
  }

  PR_fprintf(PR_STDOUT, "Module Info:\n");
  PR_fprintf(PR_STDOUT, "    cryptokiVersion = %lu.%02lu\n", 
             (PRUint32)info.cryptokiVersion.major, (PRUint32)info.cryptokiVersion.minor);
  PR_fprintf(PR_STDOUT, "    manufacturerID = \"%.32s\"\n", info.manufacturerID);
  PR_fprintf(PR_STDOUT, "    flags = 0x%08lx\n", info.flags);
  PR_fprintf(PR_STDOUT, "    libraryDescription = \"%.32s\"\n", info.libraryDescription);
  PR_fprintf(PR_STDOUT, "    libraryVersion = %lu.%02lu\n", 
             (PRUint32)info.libraryVersion.major, (PRUint32)info.libraryVersion.minor);
  PR_fprintf(PR_STDOUT, "\n");

  /* C_GetSlotList */
  nSlots = 0;
  ck_rv = epv->C_GetSlotList(CK_FALSE, (CK_SLOT_ID_PTR)CK_NULL_PTR, &nSlots);
//.........这里部分代码省略.........
开发者ID:AOSC-Dev,项目名称:nss-purified,代码行数:101,代码来源:trivial.c

示例6: DataMarshalling

void
processRequest(int client)
{
	DataMarshalling	*d = NULL;

	while (1) {
		d = new DataMarshalling(client);
		d->recvData();
		if (!strcmp(d->getMsgType(), "C_Initialize")) {
			int	p = 0;
			printf("Processing: C_Initialize\n");
			p = d->unpackInt();
			if (p == 0)
				pFunctionList->C_Initialize(NULL);
			else {
				printf("ERROR: C_Initialize shouldn't be called with not NULL\n");
			}
		} else if (!strcmp(d->getMsgType(), "C_Finalize")) {
			int		p = 0;
			CK_RV	ret = 0;

			printf("Processing: C_Finalize\n");
			p = d->unpackInt();
			if (p == NULL) {
				ret = pFunctionList->C_Finalize(NULL);
			} else {
				printf("ERROR: C_Finalize shouldn't be called with not NULL\n");
				ret = CKR_CANCEL;
			}
			{
				CK_ULONG		count = 0;
				
				DataMarshalling	*d2 = new DataMarshalling(client);
				d2->setMsgType(d->getMsgType());
				d2->packInt((char *)&ret);
				d2->sendData();
				delete d2;
			}
			break;
		} else if (!strcmp(d->getMsgType(), "C_GetSlotList")) {
			int	p = 0;
			printf("Processing: C_GetSlotList\n");
			p = d->unpackInt();
			if (p == 0) {
				CK_ULONG		count = 0;
				CK_RV			ret = 0;
				DataMarshalling	*d2 = new DataMarshalling(client);
				/*
				 * Retrieving Slots size
				 */
				ret = pFunctionList->C_GetSlotList(TRUE, NULL, &count);
				d2->setMsgType(d->getMsgType());
				d2->packInt((char *)&ret);
				d2->packInt((char *)&count);
				d2->sendData();
				delete d2;
			} else {
				CK_ULONG		count = 0;
				CK_SLOT_ID_PTR	slot = NULL;
				CK_RV			ret = 0;
				DataMarshalling	*d2 = new DataMarshalling(client);
				/*
				 * Retrieving Slots size
				 */
				pFunctionList->C_GetSlotList(TRUE, NULL, &count);
				slot = new(CK_SLOT_ID[count]);

				ret = pFunctionList->C_GetSlotList(TRUE, slot, &count);
				d2->setMsgType(d->getMsgType());
				d2->packInt((char *)&ret);
				d2->packInt((char *)&count);
				for (int i = 0; i < count; i ++)
					d2->packInt((char *)&slot[i]);
				d2->sendData();
				delete d2;
			}
		} else if (!strcmp(d->getMsgType(), "C_OpenSession")) {
			unsigned int	slotId = 0, flags = 0;
			CK_SESSION_HANDLE	sessionId = 0;
			printf("Processing: C_OpenSession\n");
			slotId = d->unpackInt();
			flags = d->unpackInt();
			{
				CK_RV			ret = 0;
				DataMarshalling	*d2 = new DataMarshalling(client);
				/*
				 * Opening session
				 */
				ret = pFunctionList->C_OpenSession(slotId, flags, NULL, NULL, &sessionId);
				d2->setMsgType(d->getMsgType());
				d2->packInt((char *)&ret);
				d2->packInt((char *)&sessionId);
				d2->sendData();
				delete d2;
			}
		} else if (!strcmp(d->getMsgType(), "C_CloseSession")) {
			CK_SESSION_HANDLE	sessionId = 0;
			printf("Processing: C_CloseSession\n");
			sessionId = d->unpackInt();
			{
//.........这里部分代码省略.........
开发者ID:ggonzalez,项目名称:Man-In-Remote,代码行数:101,代码来源:main.cpp

示例7: WaitForCardEvent

CK_RV WaitForCardEvent(HWND hTextEdit, CK_FUNCTION_LIST_PTR functions, DWORD *pAutoFlags)
{
	CK_RV retVal = CKR_OK; 
	CK_FLAGS flags = 0;
	CK_SLOT_ID slotID;
	CK_SLOT_INFO slotInfo;
	CK_TOKEN_INFO tokenInfo;
	CK_ULONG ulPreviousCount = 0;
	CK_ULONG ulCount = 0;
	CK_ULONG ulCounter = 0;
	CK_SLOT_ID_PTR pSlotList;
	CK_ULONG_PTR pCardPresentList;
	//CK_BYTE_PTR pserialNumberList;
	//CK_ULONG_PTR pserialNumberLenList;
								//CK_ULONG certContextLen = 5;
	PCCERT_CONTEXT**	pCertContextArray;

	retVal = functions->C_GetSlotList(FALSE, NULL_PTR, &ulCount);
	ulPreviousCount = ulCount;
	pSlotList = (CK_SLOT_ID_PTR) malloc(ulCount*sizeof(CK_SLOT_ID));
	pCardPresentList = (CK_ULONG_PTR)malloc(ulCount*sizeof(CK_SLOT_ID));
	//pserialNumberList = (CK_BYTE*)malloc(ulCount*sizeof(CK_BYTE));
	//memset(pserialNumberList,0,ulCount*sizeof(CK_BYTE));
	//pserialNumberLenList = (CK_ULONG*)malloc(ulCount*sizeof(CK_ULONG));
	//allocate space for the array of certificate pointers per slot
	pCertContextArray = malloc(ulCount*sizeof(PCCERT_CONTEXT*));
	//initialize with zero's
	memset(pCertContextArray,0,ulCount*sizeof(PCCERT_CONTEXT*));

	if((pSlotList != NULL) &&(pCardPresentList != NULL) &&(pCertContextArray != NULL))
	{
		//retVal = functions->C_GetSlotList(FALSE, NULL_PTR, &ulCount);
		//if(retVal != CKR_OK){}
		if ((retVal == CKR_OK) && (ulCount > 0)) {
			SendMessage(hTextEdit, EM_REPLACESEL, 0, (LPARAM)"Readers found: \r\n");
			retVal = functions->C_GetSlotList(FALSE, pSlotList, &ulCount);
			if(retVal != CKR_OK){}

			//ulCount readers found, now fill in the certificate context array,
			//and register all certificates found
			while(ulCounter < ulCount)
			{
				/* Get slot information*/
				retVal = functions->C_GetSlotInfo(pSlotList[ulCounter], &slotInfo);
				if(retVal != CKR_OK){}
				else
				{
					slotInfo.slotDescription[63] = 0;
					//do not display the PnP slot
					if(strncmp(slotInfo.slotDescription,"\\\\?PnP?\\Notification",20) != 0)
					{
						SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"- ");
						SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)slotInfo.slotDescription);
						//SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"\r\n");

						/* Get token information*/
						retVal = functions->C_GetTokenInfo(pSlotList[ulCounter], &tokenInfo);
						if (retVal == CKR_TOKEN_NOT_PRESENT) {
							pCardPresentList[ulCounter] = 0;
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"  No Card Found \r\n");
						}
						else if (retVal==CKR_OK)
						{
							pCardPresentList[ulCounter] = 1;
							tokenInfo.label[31]=0;
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"  Card Found: ");
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)tokenInfo.label);
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"\r\n");
							//allocate space for 5 certificate context pointers
							pCertContextArray[ulCounter] = malloc (5*sizeof(PCCERT_CONTEXT));
							memset(pCertContextArray[ulCounter],0,5*sizeof(PCCERT_CONTEXT));
							if(pCertContextArray[ulCounter] != NULL)
							{
								memset(pCertContextArray[ulCounter],0,5*sizeof(PCCERT_CONTEXT));
								if(*pAutoFlags & AUTO_REGISTER)
									retVal = HandleNewCardFound(hTextEdit, functions, ulCounter, pSlotList,pCertContextArray[ulCounter], 5);						
							}
							else
							{
								SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"ERROR:  Out of memory\r\n");
							}
						}
					}
				}
				ulCounter++;
			}//end of while
		}

		//as long as the readercount didn't change; keep the current slotlist
		//TODO: match the entire slotList, not just checking its size
		while(ulCount == ulPreviousCount)
		{
			/* Block and wait for a slot event */
			retVal = functions->C_WaitForSlotEvent(flags, &slotID, NULL_PTR);
			if(retVal != CKR_OK)
			{
				SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"WARNING: C_WaitForSlotEvent returned an error \r\n");
				return retVal;

				//	printError()
//.........这里部分代码省略.........
开发者ID:Andhr3y,项目名称:dcfd-mw-applet,代码行数:101,代码来源:carddata.c

示例8: sc_get_session

CK_SESSION_HANDLE sc_get_session(void *f, int try_write_syslog, CK_FUNCTION_LIST_PTR fl,
                                 const char *token_label) {
#define SC_MAX_SLOT 16
    CK_SESSION_HANDLE session = 0;
    unsigned long slot_count = SC_MAX_SLOT;
    CK_TOKEN_INFO token_info;
    CK_SLOT_ID slots[SC_MAX_SLOT];
    CK_SLOT_ID c_slot = SC_MAX_SLOT;
    CK_SLOT_ID slot = SC_MAX_SLOT;
    CK_RV rv  = 0;
    int i;
    char msg[SC_STR_MAX_LEN] = "";

    if(fl == 0) {
        sprintf(msg, "sc: Invalid state, no function list");
        goto err;
    }
    rv = fl->C_GetSlotList(TRUE, slots, &slot_count);
    if(CKR_OK != rv) {
        sprintf(msg, "sc: C_GetSlotList failed 0x%.4x", (int)rv);
        goto err;
    }
    if(slot_count < 1) {
        sprintf(msg, "sc: No token available");
        goto err;
    }
    for(i=0; i<slot_count; i++) {
        slot = slots[i];
        rv = fl->C_GetTokenInfo(slot,&token_info);
        if (CKR_OK != rv) {
            sprintf(msg, "sc: C_GetTokenInfo failed for token in slot %i", i);
            goto err;
        }
        {
            char buf[40];
            memset(buf, 0, 40);
            int j;
            strncpy(buf, token_info.label, 30);
            for(j=29;j>0;j--) {
                if(buf[j] == ' ') {
                    buf[j] = '\0';
                } else {
                    break;
                }
            }
            sprintf(msg, "sc: Found token in slot %i: %s", i, buf);
            if(f) {
                logevent(f, msg);
                if(try_write_syslog) sc_write_syslog(msg);
            }
        }
        if(strncmp(token_label, token_info.label, strlen(token_label)) == 0) {
            c_slot = i;
            break;
        }
    }
    if(c_slot == 64) {
        sprintf(msg, "sc: No token named: %s", token_label);
        goto err;
    }              
    rv = fl->C_OpenSession(slots[c_slot],CKF_SERIAL_SESSION|CKF_RW_SESSION, 0, 0, &session);
    if (CKR_OK != rv) {
        sprintf(msg, "sc: C_OpenSession failed");
        goto err;
    } else {
        if(f) logevent(f, "sc: Session opened");
    }
    return session;
 err:
    if(f) {
        logevent(f, msg);
        if(try_write_syslog) sc_write_syslog(msg);
    }
    //  m_fl->C_Finalize(0);
    //  m_fl = 0;
    return 0;
}
开发者ID:OldsSourcesBackups,项目名称:kitty,代码行数:77,代码来源:sc.c


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