#include ".\opencsp_key.h"
#include ".\opencsp_m$csp.h"
#include ".\opencsp_alg.h"
OPENCSP_M$CSP* OPENCSP_Key::_csp;
OPENCSP_Key::OPENCSP_Key(ALG_ID algId, DWORD dwFlags)
:_hKey(0), _perms(0), _algId(algId), _flags(dwFlags), _hKeyOfMSCSP(0)
{
_hKey = getHandle();
_csp = OPENCSP_M$CSP::createM$Instance();
}
OPENCSP_Key::~OPENCSP_Key(void)
{
if (_hKeyOfMSCSP)
_csp->destroyKey(_hKeyOfMSCSP);
}
DWORD OPENCSP_Key::generate(ALG_ID algId, DWORD dwFlags, OPENCSP_Key*& pKey) //产生密钥
{
DWORD dwRet;
switch(algId)
{
case CALG_RC2: //微软提供产生私钥的算法
case CALG_RC4:
case CALG_DES:
case CALG_3DES:
case CALG_3DES_112: