资源简介
淘宝买的epass2001 ukey,然后附带的开发指南,里面有三平台通用的开发工具,以及证书管理工具,可以进行导入,导出,但是私钥没办法进行导出,因为ukey本身安全性限制
代码片段和文件信息
#include
#include
#include
#include “../../include/cryptoki_ext.h“
#include “enumobj.h“
using namespace std;
EnumObj::EnumObj()
{
m_pSlotList = NULL_PTR;
m_hSession = NULL_PTR;
}
EnumObj::~EnumObj()
{
if(m_hSession)
{
C_CloseSession(m_hSession);
m_hSession = NULL_PTR;
}
if(m_pSlotList)
{
delete[] m_pSlotList;
m_pSlotList = NULL_PTR;
}
}
CK_RV EnumObj::Connect()
{
CK_RV rv;
CK_ULONG ulCount = 0;
rv = C_GetSlotList(TRUE NULL_PTR &ulCount);
if(CKR_OK != rv )
{
printf(“\nCan‘t Acquire the Inoformation of Token.Error Code 0x%08X.\n“ rv);
return rv;
}
if(0 >= ulCount)
{
printf(“\nCan‘t Connect to Token.Make Sure You have inserted USB Token.\n“);
return CKR_GENERAL_ERROR;
}
m_pSlotList = (CK_SLOT_ID_PTR)new CK_SLOT_ID[ulCount];
if (! m_pSlotList)
{
printf(“\nCan‘t allocate enough memory\n“);
return CKR_HOST_MEMORY;
}
rv = C_GetSlotList(TRUE m_pSlotList &ulCount);
if(CKR_OK != rv )
{
printf(“\nCan‘t Acquire the Inoformation of Token.Error Code 0x%08X.\n“ rv);
return rv;
}
if(0 >= ulCount)
{
printf(“\nCan‘t Connect to Token.Make Sure You have inserted Token.\n“);
return CKR_HOST_MEMORY;
}
rv = C_OpenSession(
m_pSlotList[0] CKF_RW_SESSION | CKF_SERIAL_SESSION
NULL_PTR NULL_PTR &m_hSession);
if(CKR_OK != rv )
{
printf(“\nCan‘t Connect to Token.Error Code 0x%08X.\n“ rv);
delete[] m_pSlotList;
m_pSlotList = NULL_PTR;
return rv;
}
else
{
printf(“Success connect to Token\n“);
return CKR_OK;
}
}
void EnumObj::StartOP()
{
printf(“\n================================================“);
}
void EnumObj::Enum()
{
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;
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_TYPENULL0}
{CKA_LABEL NULL 0}
{CKA_SUBJECTNULL0}
{CKA_IDNULL0}
{CKA_VALUENULL0}
};
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 ];
memset(pAttrTemp[0].pValue 0 pAttrTemp[0].ulValueLen);
memset(pAttrTemp[1].pV
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
.CA.... 3907 2009-04-03 17:13 ePass2001\linux1.0\config\config.sh
.CA.... 1299 2009-04-03 17:13 ePass2001\linux1.0\config\unconfig.sh
.CA.... 11884 2009-04-03 17:13 ePass2001\linux1.0\docs\license_en.rtf
.CA.... 779488 2009-04-03 17:15 ePass2001\linux1.0\docs\Shuttle_UserGuide.pdf
.CA.... 1722 2009-04-03 17:14 ePass2001\linux1.0\readme
.CA.... 5626 2009-04-03 17:13 ePass2001\linux1.0\redist\lang\pkimanager_1033.lng
.CA.... 11070 2009-04-03 17:13 ePass2001\linux1.0\redist\lang\pkimanager_2052.lng
.CA..H. 9 2009-08-12 09:02 ePass2001\linux1.0\redist\lang\_desktop.ini
.CA.... 2505968 2009-04-03 17:13 ePass2001\linux1.0\redist\libshuttle_p11v220.so.1.0.0
.CA.... 4529760 2009-04-03 17:13 ePass2001\linux1.0\redist\pkimanager
.CA.... 4530112 2009-04-03 17:13 ePass2001\linux1.0\redist\pkimanager_admin
.CA.... 9752 2009-04-03 17:13 ePass2001\linux1.0\sample\include\auxiliary.h
.CA.... 2112 2009-04-03 17:13 ePass2001\linux1.0\sample\include\cryptoki.h
.CA.... 2479 2009-04-03 17:13 ePass2001\linux1.0\sample\include\cryptoki_ext.h
.CA.... 1436 2009-04-03 17:13 ePass2001\linux1.0\sample\include\cryptoki_linux.h
.CA.... 2110 2009-04-03 17:13 ePass2001\linux1.0\sample\include\cryptoki_win32.h
.CA.... 9578 2009-04-03 17:13 ePass2001\linux1.0\sample\include\pkcs11.h
.CA.... 29258 2009-04-03 17:13 ePass2001\linux1.0\sample\include\pkcs11f.h
.CA.... 70934 2009-04-03 17:13 ePass2001\linux1.0\sample\include\pkcs11t.h
.CA.... 22053 2009-04-03 17:13 ePass2001\linux1.0\sample\source\EnumObj\enumobj.cpp
.CA.... 389 2009-04-03 17:13 ePass2001\linux1.0\sample\source\EnumObj\enumobj.h
.CA.... 1401 2009-04-03 17:13 ePass2001\linux1.0\sample\source\EnumObj\main.cpp
.CA.... 209 2009-04-03 17:13 ePass2001\linux1.0\sample\source\EnumObj\Makefile
.CA..H. 9 2009-08-12 09:02 ePass2001\linux1.0\sample\source\EnumObj\_desktop.ini
.CA.... 4441 2009-04-03 17:13 ePass2001\linux1.0\sample\source\ExportCert\exportcert.cpp
.CA.... 298 2009-04-03 17:13 ePass2001\linux1.0\sample\source\ExportCert\exportcert.h
.CA.... 447 2009-04-03 17:13 ePass2001\linux1.0\sample\source\ExportCert\main.cpp
.CA.... 218 2009-04-03 17:13 ePass2001\linux1.0\sample\source\ExportCert\Makefile
.CA..H. 9 2009-08-12 09:02 ePass2001\linux1.0\sample\source\ExportCert\_desktop.ini
.CA.... 2412 2009-04-03 17:13 ePass2001\linux1.0\sample\source\GetPinInfo\GetPinInfo.cpp
............此处省略272个文件信息
评论
共有 条评论