Exemplo n.º 1
0
PCCERT_CONTEXT  DigiCrypt_FindContext(BOOL fByKeyContainer, DWORD *dwResult, DWORD* dwSelectedCert)
{
PCCERT_CONTEXT hCert = NULL;
char *psCSPName;
char *psDefaultKeyContainerName;
//char buff[200];
oG_fDialogUserCancel = FALSE;
oG_selectedCert=*dwSelectedCert;

*dwResult = dDigiCrypt_Okey;
lstrcpy(oG_sCSPName,"");
lstrcpy(oG_sKeyContainerName,"");

if (fByKeyContainer == TRUE)
  {  

  hCert = DigiCrypt_ReadCertFromCard();
  
  if (hCert == NULL)
    {
    psCSPName = DigiCrypt_GetFirstAllowedCSPNameNew();
    if (psCSPName == NULL)
      *dwResult = dDigiCrypt_Error_NotFoundCSP;
    else
      {
      psDefaultKeyContainerName = DigiCrypt_GetDefaultKeyContainerName(oG_sCSPName);
      if (psDefaultKeyContainerName == NULL)
        *dwResult = dDigiCrypt_Error_NoDefaultKey;
      else
        hCert = DigiCrypt_SelectFromAllKeysCerts(oG_hProvider);
      }
    }
  }
else
  {
  
  hCert = DigiCrypt_SelectFromAllCerts();
  if (hCert != NULL)
  {
	  DigiCrypt_GetDataFromCert(hCert);
  }
    *dwSelectedCert=oG_selectedCert;
  }
if (hCert == NULL)
  {
  if (oG_fDialogUserCancel == TRUE)
    *dwResult = dDigiCrypt_Error_UserCancel;
  else
    {
    if (*dwResult == dDigiCrypt_Okey) 
      *dwResult = dDIgiCrypt_Error_NotFoundCert;
    }
  }
return(hCert); 
}
Exemplo n.º 2
0
PCCERT_CONTEXT  DigiCrypt_FindContext(BOOL fByKeyContainer, DWORD *dwResult)
{
  PCCERT_CONTEXT hCert = NULL;
  char *psCSPName;
  char *psDefaultKeyContainerName;
  oG_fDialogUserCancel = FALSE;

  *dwResult = dDigiCrypt_Okey;
  memset(oG_sCSPName, 0, sizeof(oG_sCSPName));
  memset(oG_sKeyContainerName, 0, sizeof(oG_sKeyContainerName));

  if (fByKeyContainer == TRUE)  {  
    hCert = DigiCrypt_ReadCertFromCard();
    //TEST
    //Test_ReadCertDataC(hCert);
    //ENDTEST
    if (hCert == NULL) {
      psCSPName = DigiCrypt_GetFirstAllowedCSPNameNew();
      if (psCSPName == NULL)
	*dwResult = dDigiCrypt_Error_NotFoundCSP;
      else {
	psDefaultKeyContainerName = DigiCrypt_GetDefaultKeyContainerName(oG_sCSPName);
	if (psDefaultKeyContainerName == NULL)
	  *dwResult = dDigiCrypt_Error_NoDefaultKey;
	else
	  hCert = DigiCrypt_SelectFromAllKeysCerts(oG_hProvider);
      }
    }
  } else {
    hCert = DigiCrypt_SelectFromAllCerts();
    if (hCert != NULL)
      DigiCrypt_GetDataFromCert(hCert);
  }
  if (hCert == NULL) {
    if (oG_fDialogUserCancel == TRUE)
      *dwResult = dDigiCrypt_Error_UserCancel;
    else {
      if (*dwResult == dDigiCrypt_Okey) 
	*dwResult = dDIgiCrypt_Error_NotFoundCert;
    }
  }
  return(hCert); 
}