⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passport.cpp

📁 可用于生成证书请求、安装和验证数字证书的activex控件
💻 CPP
字号:
/*  
 *	Date		:	2004-09-13
 *	Author		:	Junhui Yang
 *	Filename	:	CPassPort.cpp
 *	Description	:	CPassPort is a activex control class
*/

#include "stdafx.h"
#include "FGCPassPortActiveX.h"
#include "PassPort.h"
#include "FGCCryptoAPI.h"

/////////////////////////////////////////////////////////////////////////////
// CPassPort


STDMETHODIMP CPassPort::get_CertSubject(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_certsubject.String ();
	*pVal = newecode.m_str;

	return S_OK;
}

STDMETHODIMP CPassPort::put_CertSubject(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_certsubject = tempbuf;

	return S_OK;
}
 
STDMETHODIMP CPassPort::get_DoPks10(short *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	*pVal = m_dopks10;

	return S_OK;
}
 
STDMETHODIMP CPassPort::put_DoPks10(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	m_dopks10 = newVal;
	if (m_dopks10==1) {
		BOOL ism = TRUE;
		if (m_isTemp==1) {
			ism = FALSE;
		}
		if (!FGCCryptoAPI::CreatePKS10 (m_certsubject, m_pks10str, ism)) {
			m_error = 0;
		}
	}

	return S_OK;
}

STDMETHODIMP CPassPort::get_DelAccount(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_delaccount.String ();
	*pVal = newecode.m_str;

	return S_OK;
}

STDMETHODIMP CPassPort::put_DelAccount(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_delaccount = tempbuf;

	return S_OK;
}

STDMETHODIMP CPassPort::get_DoDel(short *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	*pVal = m_dodel;

	return S_OK;
}

STDMETHODIMP CPassPort::put_DoDel(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	m_dodel = newVal;
	if (m_dodel==1) {
		BOOL ism = TRUE;
		if (m_isTemp==1) {
			ism = FALSE;
		}
		if (!FGCCryptoAPI::DelAccountInStore (m_delaccount, ism)) {
			m_error = 0;
		}
	}

	return S_OK;
}

STDMETHODIMP CPassPort::get_Err(short *pVal)
{
	// TODO: Add your implementation code here

	*pVal = m_error;
	return S_OK;
}

STDMETHODIMP CPassPort::put_Err(short newVal)
{
	// TODO: Add your implementation code here

	m_error = newVal;
	return S_OK;
}

STDMETHODIMP CPassPort::get_Pks10Str(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_pks10str.String ();
	*pVal = newecode.m_str;

	return S_OK;
}

STDMETHODIMP CPassPort::put_Pks10Str(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
/*	char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_pks10str = tempbuf;
*/
	return S_OK;
}

STDMETHODIMP CPassPort::get_Pks7Str(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_pks7str.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_Pks7Str(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
    char tempbuf[3000];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, 3000, "", NULL);
	m_pks7str = tempbuf;

	m_pks7str.TrimRight ();

	return S_OK;
}

STDMETHODIMP CPassPort::get_DoSetupCert(short *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	*pVal = m_dosetup;
	return S_OK;
}

STDMETHODIMP CPassPort::put_DoSetupCert(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	m_dosetup = newVal;
	if (m_dosetup==1) {
		if (!FGCCryptoAPI::SetupCert (m_pks7str)) {
			m_error = 0;
		}
	}

	return S_OK;
}

STDMETHODIMP CPassPort::get_RamdonStr(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_ramdonstr.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_RamdonStr(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
    char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_ramdonstr = tempbuf;

	return S_OK;
}

STDMETHODIMP CPassPort::get_DoSign(short *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	*pVal = m_dosign;
	return S_OK;
}

STDMETHODIMP CPassPort::put_DoSign(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	m_dosign = newVal;
	if (m_dosign==1) {
		if (m_isTemp==1) {
			if (!FGCCryptoAPI::SignData (m_accountstr, m_ramdonstr, m_signedstr, FALSE)) {
				m_error = 0;
			}
		} else {
			if (!FGCCryptoAPI::SignData (m_accountstr, m_ramdonstr, m_signedstr, TRUE)) {
				m_error = 0;
			}
		}
	}

	return S_OK;
}

STDMETHODIMP CPassPort::get_SignedStr(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_signedstr.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_SignedStr(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
    char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_signedstr = tempbuf;
	return S_OK;
}

STDMETHODIMP CPassPort::get_AccountStr(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_accountstr.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_AccountStr(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
    char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_accountstr = tempbuf;
	return S_OK;
}

STDMETHODIMP CPassPort::get_IsTemp(short *pVal)
{
	// TODO: Add your implementation code here

	m_error = 1;
	*pVal = m_isTemp;

	return S_OK;
}

STDMETHODIMP CPassPort::put_IsTemp(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	m_isTemp = newVal;

	return S_OK;
}

STDMETHODIMP CPassPort::get_isHasCert(short *pVal)
{
	// TODO: Add your implementation code here
	 
	*pVal = 1;
	if (m_isTemp==0) {
		if (!FGCCryptoAPI::isHere (m_accountstr, TRUE)) {
			*pVal = 0;
		}
	} else {
		if (!FGCCryptoAPI::isHere (m_accountstr, FALSE)) {
			*pVal = 0;
		}
	}

	return S_OK;
}

STDMETHODIMP CPassPort::put_isHasCert(short newVal)
{
	// TODO: Add your implementation code here

	return S_OK;
}

STDMETHODIMP CPassPort::get_CertNumStr(BSTR *pVal)
{
	// TODO: Add your implementation code here

	return S_OK;
}

STDMETHODIMP CPassPort::put_CertNumStr(BSTR newVal)
{
	// TODO: Add your implementation code here

	return S_OK;
}

STDMETHODIMP CPassPort::get_PasswordStr(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_passwordstr.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_PasswordStr(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
    char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_passwordstr = tempbuf;
	return S_OK;
}

STDMETHODIMP CPassPort::get_DoMD5(short *pVal)
{
	// TODO: Add your implementation code here

	return S_OK;
}

STDMETHODIMP CPassPort::put_DoMD5(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	if (newVal==1) {
		if (!FGCCryptoAPI::EncodeMD5 (m_ramdonstr, m_passwordstr, m_md5str)) {
			m_error = 0;
		}
	}
	return S_OK;
}

STDMETHODIMP CPassPort::get_EncodedMD5Str(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	CComBSTR newecode = m_md5str.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_EncodedMD5Str(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
/*    char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_md5str = tempbuf;*/
	return S_OK;
}

STDMETHODIMP CPassPort::get_PubKey(BSTR *pVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	return S_OK;
}

STDMETHODIMP CPassPort::put_PubKey(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
    char tempbuf[_MAX_PATH];
	memset (tempbuf, '\0', _MAX_PATH);
	WideCharToMultiByte(CP_ACP, 0, newVal, -1, tempbuf, _MAX_PATH, "", NULL);
	m_PubKey = tempbuf;
	return S_OK;
}

STDMETHODIMP CPassPort::get_EncodedPsw(BSTR *pVal)
{
	// TODO: Add your implementation code here

	m_error = 1;
	CComBSTR newecode = m_EncodedPsw.String ();
	*pVal = newecode.m_str;
	return S_OK;
}

STDMETHODIMP CPassPort::put_EncodedPsw(BSTR newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;

	return S_OK;
}

STDMETHODIMP CPassPort::get_DoEncodePsw(short *pVal)
{
	// TODO: Add your implementation code here

	return S_OK;
}

STDMETHODIMP CPassPort::put_DoEncodePsw(short newVal)
{
	// TODO: Add your implementation code here
	m_error = 1;
	if (newVal==1) {
		if (!FGCCryptoAPI::EncodePSW (m_PubKey, m_passwordstr, m_EncodedPsw)) {
			m_error = 0;
		}
	}
	return S_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -