亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? enumobjdlg.cpp

?? PKCS#11 讀取USB KEY證書
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
					CERT_SIMPLE_NAME_STR |
					CERT_OID_NAME_STR |
					CERT_NAME_STR_CRLF_FLAG
					;

				DWORD dwName = 0;
				dwName = CertNameToStr(
					MY_ENCODING_TYPE,
					&SubName,
					dwStrDetailType,
					NULL,
					0);

				if (0 == dwName)
				{
					//AfxMessageBox("error get Subject Name length");
					//return;
					strRet += "[!! ERROR !!]"NEWLINE;
					continue;
				}

				char* pszTemp = NULL;
				if(!(pszTemp = new char[dwName]))
				{
					//AfxMessageBox("malloc memory  for subject name fail");
					//return;
					strRet += "[!! ERROR !!]"NEWLINE;
					continue;
				}

				//--------------------------------------------------------------------
				//       Call the function again to get the string 
				dwName = CertNameToStr(
					MY_ENCODING_TYPE,
					&SubName,
					dwStrDetailType,
					pszTemp,
					dwName);
				
				//--------------------------------------------------------------------
				//      If the function succeeded, it returns the 
				//      number of bytes copied to the pszName buffer.
				if (dwName > 1)
				{
					strRet += pszTemp;
					strRet += NEWLINE;
				}
				else
					strRet += "[!! ERROR !!]"NEWLINE;
				delete[] pszTemp;
			}
			break;

		}

	}

	return true;
}

/////////////////////////////////////////////////////////////////////////////
// CEnumObjDlg dialog

CEnumObjDlg::CEnumObjDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CEnumObjDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CEnumObjDlg)
	m_strInfo = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	
	m_pSlotList = NULL_PTR;
	m_pApplication = new char[255];
	ZeroMemory(m_pApplication, 255);
	lstrcpy((char*)m_pApplication, "Enum Object App");
	m_hSession = NULL_PTR;
}

CEnumObjDlg::~CEnumObjDlg()
{
	if(m_hSession)
	{
		C_CloseSession(m_hSession);
		m_hSession = NULL_PTR;
	}
	delete[] m_pApplication;
	if(m_pSlotList)
	{
		delete[] m_pSlotList;
		m_pSlotList = NULL_PTR;
	}

}


void CEnumObjDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEnumObjDlg)
	DDX_Control(pDX, IDC_BTN_SECRET, m_btnSecret);
	DDX_Control(pDX, IDC_BTN_PUBLIC, m_btnPublic);
	DDX_Control(pDX, IDC_BTN_PRIVATE, m_btnPrivate);
	DDX_Control(pDX, IDC_BTN_DATA, m_btnData);
	DDX_Control(pDX, IDC_BTN_LOGIN, m_btnLogin);
	DDX_Control(pDX, IDC_BTN_ENUM, m_btnEnum);
	DDX_Control(pDX, IDC_BTN_CONNECT, m_btnConnect);
	DDX_Control(pDX, IDC_INFO, m_edtInfo);
	DDX_Text(pDX, IDC_INFO, m_strInfo);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CEnumObjDlg, CDialog)
	//{{AFX_MSG_MAP(CEnumObjDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BTN_CONNECT, OnBtnConnect)
	ON_BN_CLICKED(IDC_BTN_CLEARINFO, OnBtnClearinfo)
	ON_BN_CLICKED(IDC_BTN_ENUM, OnBtnEnum)
	ON_BN_CLICKED(IDC_BTN_LOGIN, OnBtnLogin)
	ON_BN_CLICKED(IDC_BTN_DATA, OnBtnData)
	ON_BN_CLICKED(IDC_BTN_PUBLIC, OnBtnPublic)
	ON_BN_CLICKED(IDC_BTN_PRIVATE, OnBtnPrivate)
	ON_BN_CLICKED(IDC_BTN_SECRET, OnBtnSecret)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEnumObjDlg message handlers

BOOL CEnumObjDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here	
	ShowMsg("First, you need connect to token!"NEWLINE);
	m_btnLogin.EnableWindow(FALSE);
	m_btnEnum.EnableWindow(FALSE);
	m_btnData.EnableWindow(FALSE);
	m_btnPublic.EnableWindow(FALSE);
	m_btnPrivate.EnableWindow(FALSE);
	m_btnSecret.EnableWindow(FALSE);

	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CEnumObjDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CEnumObjDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CEnumObjDlg::OnBtnConnect() 
{
	// TODO: Add your control notification handler code here
	if(m_hSession)
		return;
	
	::SetCursor(::LoadCursor(NULL, IDC_WAIT));
	
	StartOP();
	
	CK_RV rv;
	CK_ULONG ulCount = 0;
	rv = C_GetSlotList(TRUE, NULL_PTR, &ulCount);
	if(CKR_OK != rv )
	{
		ShowErr(NEWLINE"Can't acquire the information of token, ErrorCode: 0x%08X."NEWLINE, rv);
		return;
	}
	if(0 >= ulCount)
	{
		ShowMsg(NEWLINE"Can't connect to token, make sure one USB Token has been inserted."NEWLINE);
		return;
	}
	
	m_pSlotList = (CK_SLOT_ID_PTR)new CK_SLOT_ID[ulCount];
	if (! m_pSlotList) 
	{
		ShowMsg(NEWLINE"Can't allocate enough memory!"NEWLINE);
		return;
	}
	
	rv = C_GetSlotList(TRUE, m_pSlotList, &ulCount);
	if(CKR_OK != rv )
	{
		ShowErr(NEWLINE"Can't acquire the information of token, ErrorCode: 0x%08X."NEWLINE, rv);
		return;
	}
	if(0 >= ulCount)
	{
		ShowMsg(NEWLINE"Can't connect to token, make sure one USB Token has been inserted."NEWLINE);
		return;
	}
	
	rv = C_OpenSession(
		m_pSlotList[0],  CKF_RW_SESSION | CKF_SERIAL_SESSION,
		&m_pApplication, NULL_PTR, &m_hSession);
	if(CKR_OK != rv )
	{
		ShowErr(NEWLINE"Can't Connect to token, Error Code 0x%08X."NEWLINE, rv);
		delete[] m_pSlotList;
		m_pSlotList = NULL_PTR;
	}
	else
	{
		ShowMsg(NEWLINE"Connect to token Successfully!"NEWLINE);
		m_btnConnect.EnableWindow(FALSE);
		ShowMsg(NEWLINE"Now You need to login with User PIN!"NEWLINE);
		m_btnLogin.EnableWindow(TRUE);

	}
	
}

void CEnumObjDlg::ShowMsg(CString strInfo)
{
	m_strInfo += strInfo;
	UpdateData(FALSE);
	
	int nLastLine = m_edtInfo.GetLineCount();// GetFirstVisibleLine();
	
	if (nLastLine > 0)
	{
		m_edtInfo.LineScroll(nLastLine, 0);
	}
}

void CEnumObjDlg::StartOP()
{
	ShowMsg(NEWLINE"================================================");
}

void CEnumObjDlg::ShowErr(CString strInfo, CK_RV rv)
{
	CString strTemp("");
	strTemp.Format(strInfo.GetBuffer(strInfo.GetLength()), rv);
	ShowMsg(strTemp);
}

void CEnumObjDlg::OnBtnClearinfo() 
{
	// TODO: Add your control notification handler code here
	m_strInfo = "";
	UpdateData(FALSE);
}

void CEnumObjDlg::OnBtnEnum() 
{
	
	CK_OBJECT_CLASS dataClass = CKO_CERTIFICATE;
	BOOL IsToken=true;
	CK_ATTRIBUTE pTempl[] = 
	{
		{CKA_CLASS, &dataClass, sizeof(CKO_CERTIFICATE)},
		{CKA_TOKEN, &IsToken, sizeof(true)}
	};

	
	C_FindObjectsInit(m_hSession, pTempl, 2);
	
	CK_OBJECT_HANDLE hCKObj;
	CK_ULONG ulRetCount = 0;
	CK_RV ckrv = 0;
	int numObj=0;//object numbers
	do
	{
		ckrv = C_FindObjects(m_hSession, &hCKObj, 1, &ulRetCount);
		if(CKR_OK != ckrv)
		{
			break;	
		}
		if(1 != ulRetCount)
			break;
		
		CK_ATTRIBUTE pAttrTemp[] = 
		{
			{CKA_CLASS, NULL, 0},
			{CKA_CERTIFICATE_TYPE,NULL,0},
			{CKA_LABEL, NULL, 0},
			{CKA_SUBJECT,NULL,0},
			{CKA_ID,NULL,0},
			{CKA_VALUE,NULL,0}
		};
		
		ckrv = C_GetAttributeValue(m_hSession, hCKObj, pAttrTemp, 6);
		if(ckrv != CKR_OK)
		{
			break;
		}
		
		pAttrTemp[0].pValue = new char[pAttrTemp[0].ulValueLen];
		pAttrTemp[1].pValue = new char[pAttrTemp[1].ulValueLen];
		pAttrTemp[2].pValue = new char[pAttrTemp[2].ulValueLen+1];
		pAttrTemp[3].pValue = new char[pAttrTemp[3].ulValueLen+1];
		pAttrTemp[4].pValue = new char[pAttrTemp[4].ulValueLen+1];
		pAttrTemp[5].pValue = new char[pAttrTemp[5].ulValueLen ];
		
		ZeroMemory(pAttrTemp[0].pValue, pAttrTemp[0].ulValueLen);
		ZeroMemory(pAttrTemp[1].pValue, pAttrTemp[1].ulValueLen);
		ZeroMemory(pAttrTemp[2].pValue, pAttrTemp[2].ulValueLen+1);	
		ZeroMemory(pAttrTemp[3].pValue, pAttrTemp[3].ulValueLen+1);
		ZeroMemory(pAttrTemp[4].pValue, pAttrTemp[4].ulValueLen+1);
		ZeroMemory(pAttrTemp[5].pValue, pAttrTemp[5].ulValueLen);
		
		ckrv = C_GetAttributeValue(m_hSession, hCKObj, pAttrTemp, 6);
		if(ckrv != CKR_OK)
		{
			delete[] pAttrTemp[0].pValue;
			delete[] pAttrTemp[1].pValue;
			delete[] pAttrTemp[2].pValue;
			delete[] pAttrTemp[3].pValue;
			delete[] pAttrTemp[4].pValue;
			delete[] pAttrTemp[5].pValue;
			break;
		}

		numObj++;
		//CString strvale = (char*)pAttrTemp[2].pValue;
/*
		CString strsubject;
		CERT_NAME_BLOB  SubName;
		SubName.cbData=pAttrTemp[3].ulValueLen;
		SubName.pbData=(BYTE*)pAttrTemp[3].pValue;

		DWORD dwStrDetailType =
			CERT_NAME_STR_NO_QUOTING_FLAG | 
			CERT_NAME_STR_REVERSE_FLAG |
			CERT_SIMPLE_NAME_STR |
			CERT_OID_NAME_STR |
			CERT_NAME_STR_CRLF_FLAG
			;

		DWORD dwName = 0;
		dwName = CertNameToStr(
			MY_ENCODING_TYPE,
			&SubName,
			dwStrDetailType,
			NULL,
			0);
		
		if (0 == dwName)
		{
			AfxMessageBox("error get Subject Name length");
			return;
		}
		
		char* pszTemp = NULL;
		if(!(pszTemp = new char[dwName]))
		{
			AfxMessageBox("malloc memory  for subject name fail");
			return;
		}
		
		//--------------------------------------------------------------------
		//       Call the function again to get the string 
		dwName = CertNameToStr(
			MY_ENCODING_TYPE,
			&SubName,
			dwStrDetailType,
			pszTemp,
			dwName);
		
		//--------------------------------------------------------------------
		//      If the function succeeded, it returns the 
		//      number of bytes copied to the pszName buffer.
		if (1 < dwName)
		{
			strsubject = pszTemp;
		}
		delete[] pszTemp;
*/
//		CString strckaid=(char*)pAttrTemp[4].pValue;
		
		ShowMsg(NEWLINE);
		StartOP();
		CString strShow;
		parse_object(pAttrTemp, 6, strShow);
		ShowMsg(strShow);
/*
		ShowMsg(NEWLINE"Begin this Object's Output:"NEWLINE);
		ShowMsg("The Attribute CKA_CLASS of this Obj is:: CKO_CERTIFICATE"NEWLINE);
		
		if(*(int*)pAttrTemp[1].pValue==CKC_X_509)
		{
		ShowMsg("The Attribute CKA_CERTIFICATE_TYPE is: CKC_X_509"NEWLINE);
		}
		else 
			if(*(int*)pAttrTemp[1].pValue==CKC_X_509_ATTR_CERT)
			{
				ShowMsg("CKA_CERTIFICATE_TYPE is CKC_X_509_ATTR_CERT"NEWLINE);
			}
		ShowMsg("The Attribute CKA_LABEL of this Obj is: ");
		ShowMsg(strvale);
		ShowMsg(NEWLINE"The Attribute CKA_SUBJECT of this Obj is: ");
		ShowMsg(strsubject);
		ShowMsg(NEWLINE"The Attribute CKA_ID of this Obj is: ");
		ShowMsg(strckaid);
		ShowMsg(NEWLINE"The Content of this Obj(CKA_VALUE) is:"NEWLINE);
		ShowMsg(nByteToStr(pAttrTemp[5].ulValueLen, pAttrTemp[5].pValue, 1, 16));
		ShowMsg(NEWLINE"Finish Output Obj"NEWLINE);
*/

		delete[] pAttrTemp[0].pValue;
		delete[] pAttrTemp[1].pValue;
		delete[] pAttrTemp[2].pValue;
		delete[] pAttrTemp[3].pValue;
		delete[] pAttrTemp[4].pValue;
		delete[] pAttrTemp[5].pValue;
		
	}while(true);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩在线视频| 91玉足脚交白嫩脚丫在线播放| 综合av第一页| 久久日韩精品一区二区五区| 欧美一区二区三区公司| 91精品国产综合久久福利| 在线视频一区二区三区| 91久久精品国产91性色tv| 一本大道久久a久久综合婷婷| 色诱视频网站一区| 99久久综合狠狠综合久久| 99精品视频在线观看免费| 91黄色激情网站| 欧美日韩中文另类| 欧美高清视频不卡网| 精品成人私密视频| 国产精品少妇自拍| 一区二区视频在线看| 亚洲6080在线| 黑人巨大精品欧美一区| 国产成人精品一区二| 高清国产一区二区三区| 一本高清dvd不卡在线观看| 欧美性生活久久| 欧美电影免费观看高清完整版在线 | 日本道免费精品一区二区三区| 欧美在线视频全部完| 91精品国产色综合久久| 精品久久久久久久人人人人传媒 | 丁香婷婷综合激情五月色| 色综合久久久久综合| 91精品国产综合久久福利| 久久久久久久国产精品影院| 亚洲精品你懂的| 麻豆成人久久精品二区三区红 | 亚洲一区电影777| 麻豆成人免费电影| 成人黄页在线观看| 精品视频在线看| 国产亚洲一区二区三区在线观看| 亚洲国产视频在线| 国产一区二区精品久久| 91成人免费电影| 亚洲精品一区二区三区影院 | 2021中文字幕一区亚洲| 亚洲欧美区自拍先锋| 国内精品视频666| 在线看国产一区| 国产日韩精品一区二区三区| 亚洲国产精品久久久久秋霞影院 | 狠狠色丁香久久婷婷综合_中| 91麻豆免费看| 久久奇米777| 爽好久久久欧美精品| 91啪亚洲精品| 久久综合久久99| 日韩vs国产vs欧美| 色噜噜狠狠色综合中国| 国产日本欧美一区二区| 久久精品久久99精品久久| 欧美四级电影网| 亚洲视频网在线直播| 国产91对白在线观看九色| 日韩欧美一级片| 日韩精品乱码av一区二区| 91免费版在线看| 国产精品久久午夜| 成人禁用看黄a在线| 久久久美女毛片| 国内偷窥港台综合视频在线播放| 欧美日韩一区国产| 亚洲最快最全在线视频| 色88888久久久久久影院野外| 国产精品网站在线| 成人精品免费看| 亚洲国产精品成人综合| 国产成人精品免费| 国产日产精品1区| 成人黄页在线观看| 亚洲欧洲日韩av| 色综合视频一区二区三区高清| 国产精品三级久久久久三级| 国产精品羞羞答答xxdd| 久久亚洲一区二区三区四区| 国产麻豆日韩欧美久久| 精品日韩一区二区三区| 秋霞午夜av一区二区三区| 日韩视频不卡中文| 九九国产精品视频| 久久精品水蜜桃av综合天堂| 成人性生交大合| 亚洲视频综合在线| 欧美日韩视频在线观看一区二区三区 | 日本一区二区三区久久久久久久久不| 国产伦精品一区二区三区免费迷 | 午夜a成v人精品| 日韩一级片网站| 国产精品亚洲综合一区在线观看| 中文子幕无线码一区tr| 91福利在线播放| 蜜臀精品一区二区三区在线观看| 久久久午夜精品理论片中文字幕| 成人性视频免费网站| 一区二区日韩av| 日韩限制级电影在线观看| 国产麻豆精品95视频| 中文字幕欧美一区| 91精品欧美综合在线观看最新| 激情小说欧美图片| 亚洲男人电影天堂| 欧美一区二区三区视频| 国产成人精品一区二区三区网站观看| 亚洲日本va在线观看| 欧美日韩精品一区二区天天拍小说| 蜜臀av性久久久久蜜臀av麻豆| 国产精品免费丝袜| 日韩一区二区三区免费看| av激情综合网| 精品一区二区三区av| 日韩美女久久久| 久久日韩粉嫩一区二区三区| 欧美亚洲尤物久久| 盗摄精品av一区二区三区| 视频一区在线视频| 国产精品乱码妇女bbbb| 91精品国产综合久久精品麻豆| 国产a区久久久| 久久精品国产成人一区二区三区 | 一本色道久久加勒比精品 | 欧美精品18+| zzijzzij亚洲日本少妇熟睡| 麻豆精品视频在线| 亚洲主播在线播放| 精品av综合导航| 日韩一级成人av| 亚洲狠狠爱一区二区三区| 欧美视频在线一区| 亚洲精品欧美激情| 国产丶欧美丶日本不卡视频| 亚洲美女在线一区| 337p粉嫩大胆色噜噜噜噜亚洲 | av不卡一区二区三区| 奇米一区二区三区| 亚洲视频精选在线| 国产精品久久久久久久浪潮网站| 91精品国产aⅴ一区二区| 欧美亚洲综合另类| 91在线观看地址| 成人影视亚洲图片在线| 国内精品国产三级国产a久久| 免费在线观看视频一区| 爽好多水快深点欧美视频| 亚洲电影一级片| 亚洲精品精品亚洲| 亚洲综合色区另类av| 亚洲第一狼人社区| 一区二区成人在线| 亚洲一区二区偷拍精品| 亚洲一区二区三区中文字幕在线| 亚洲三级久久久| 亚洲激情校园春色| 亚洲国产欧美一区二区三区丁香婷| 亚洲黄色小说网站| 亚洲大型综合色站| 日韩中文字幕亚洲一区二区va在线| 日韩精品三区四区| 日韩电影在线一区二区| 丝袜亚洲精品中文字幕一区| 日韩高清在线观看| 精品在线观看免费| 国产传媒欧美日韩成人| 成人午夜av电影| 91国内精品野花午夜精品| 欧美日韩卡一卡二| 日韩精品一区二区在线| 久久一留热品黄| 一区二区在线电影| 日韩精品成人一区二区在线| 国产一区二区视频在线| www.66久久| 欧美精品一级二级| 久久免费美女视频| 亚洲欧美日韩国产中文在线| 日韩精品视频网站| 成人免费视频网站在线观看| 色呦呦网站一区| 欧美一区二区三区视频免费| 国产丝袜美腿一区二区三区| 亚洲欧美精品午睡沙发| 美国av一区二区| 99在线精品一区二区三区| 欧美一区二区三区四区五区 | 日本一区二区三区高清不卡 | 麻豆成人91精品二区三区| 福利电影一区二区| 制服丝袜亚洲色图| 中文子幕无线码一区tr| 奇米综合一区二区三区精品视频| 国产 欧美在线| 日韩精品在线一区|