CAPIUtils.cpp File Reference


Detailed Description

Subsystem: Miscellaneous/Utility (PKIFUTILS)

Module: Miscellaneous

Id
CAPIUtils.cpp 11149 2010-01-21 16:40:51Z agalustyan

Definition in file CAPIUtils.cpp.

#include "CAPIUtils.h"
#include "ToolkitUtils.h"
#include "PKIFException.h"
#include "PKIFCryptoErrors.h"
#include "components.h"

Include dependency graph for CAPIUtils.cpp:

Go to the source code of this file.

Functions

void CAC_API ReverseBytes (unsigned char *buf, int bufLen)
BOOL CreatePrivateExponentOneKey (LPTSTR szProvider, DWORD dwProvType, LPTSTR szContainer, DWORD dwKeySpec, HCRYPTPROV *hProv, HCRYPTKEY *hPrivateKey)
BOOL ImportPlainSessionBlob (HCRYPTPROV hProv, HCRYPTKEY hPrivateKey, ALG_ID dwAlgId, LPBYTE pbKeyMaterial, DWORD dwKeyMaterial, HCRYPTKEY *hSessionKey)
bool CertHasKey (PCCERT_CONTEXT pPrevCertContent)
ALG_ID GetHashAlg (PKIFCRYPTO::HASH_ALG alg)
wchar_t * GetCNGHashAlg (PKIFCRYPTO::HASH_ALG alg)
void StrToName (const char *dn, unsigned char **enc, DWORD *len)


Function Documentation

bool CertHasKey ( PCCERT_CONTEXT  pPrevCertContent  ) 

Interface: Subsystem

This function simply determines if there is a private key associated with a given cert.

Returns:
True if a private key associated with a given cert.
Parameters:
pPrevCertContent  [in] PCCERT_CONTEXT obeject

Definition at line 363 of file CAPIUtils.cpp.

Referenced by CPKIFCNGCAPI::GetKeyList(), and CPKIFCAPI2::GetKeyList().

BOOL CreatePrivateExponentOneKey ( LPTSTR  szProvider,
DWORD  dwProvType,
LPTSTR  szContainer,
DWORD  dwKeySpec,
HCRYPTPROV *  hProv,
HCRYPTKEY *  hPrivateKey 
)

Interface: Subsystem

The next two functions (CreatePrivateExponentOneKey and ImportPlainSessionBlob) were taken directly from the Microsoft Knowledge Base. There's a Q article there describing that the Microsoft CSPs do not allow import of plaintext symmetric keys. Thus we have to do the dance of these functions to achieve that functionality.

Returns:
None
Parameters:
szProvider  LPTSTR
dwProvType  DWORD
szContainer  LPTSTR
dwKeySpec  DWORD
hProv  Pointer to HCRYPTPROV object
hPrivateKey  Pointer to HCRYPTKEY object

Definition at line 53 of file CAPIUtils.cpp.

Referenced by CPKIFCAPIRaw::CryptInit().

wchar_t* GetCNGHashAlg ( PKIFCRYPTO::HASH_ALG  alg  ) 

Interface: External

This function is used to get CNG algorithm identifier from HASH_ALG enum.

ALD_ID definition

typedef unsigned int ALG_ID;

Returns:
The function returns ALG_ID which specifies hash algorithm.
Exceptions:
CPKIFException(CRYPTO_ALG_NOT_SUPPORTED) 
Parameters:
alg  [in] HASH_ALG enum which specifies the hashing algorithm

Definition at line 423 of file CAPIUtils.cpp.

References CRYPTO_ALG_NOT_SUPPORTED, PKIFCRYPTO::MD5, PKIFCRYPTO::SHA1, PKIFCRYPTO::SHA256, PKIFCRYPTO::SHA384, PKIFCRYPTO::SHA512, and TOOLKIT_CRYPTO.

Referenced by CPKIFCNGCAPIRaw::HashInit().

ALG_ID GetHashAlg ( PKIFCRYPTO::HASH_ALG  alg  ) 

Interface: External

This function is used to get algorithm identifier from HASH_ALG enum.

ALD_ID definition

typedef unsigned int ALG_ID;

Returns:
The function returns ALG_ID which specifies hash algorithm.
Exceptions:
CPKIFException(CRYPTO_ALG_NOT_SUPPORTED) 
Parameters:
alg  [in] HASH_ALG enum which specifies the hashing algorithm

Definition at line 395 of file CAPIUtils.cpp.

References CRYPTO_ALG_NOT_SUPPORTED, PKIFCRYPTO::MD5, PKIFCRYPTO::SHA1, and TOOLKIT_CRYPTO.

Referenced by CreateHashObjectFromData(), and CPKIFCAPI2::Sign().

BOOL ImportPlainSessionBlob ( HCRYPTPROV  hProv,
HCRYPTKEY  hPrivateKey,
ALG_ID  dwAlgId,
LPBYTE  pbKeyMaterial,
DWORD  dwKeyMaterial,
HCRYPTKEY *  hSessionKey 
)

Interface: Subsystem

The next two functions (CreatePrivateExponentOneKey and ImportPlainSessionBlob) were taken directly from the Microsoft Knowledge Base. There's a Q article there describing that the Microsoft CSPs do not allow import of plaintext symmetric keys. Thus we have to do the dance of these functions to achieve that functionality.

Returns:
None
Parameters:
hProv  HCRYPTPROV
hPrivateKey  HCRYPTKEY
dwAlgId  ALG_ID
pbKeyMaterial  LPBYTE
dwKeyMaterial  DWORD
hSessionKey  Pointer to HCRYPTKEY

Definition at line 219 of file CAPIUtils.cpp.

Referenced by CPKIFCAPIRaw::CryptInit().

void CAC_API ReverseBytes ( unsigned char *  buf,
int  bufLen 
)

Interface: External

This function reverses bytes in the buffer that was passed as a parameter

Returns:
None
Parameters:
buf  [in] A pointer to a buffer that will be reversed
bufLen  [in] Integer value containing the length of the buffer

Definition at line 21 of file CAPIUtils.cpp.

Referenced by _Verify(), CPKIFCAPI2::Decrypt(), CPKIFCAPIUserRepository2::FindCertificates(), CPKIFCAPITrustStore2::FindCertificates(), CPKIFCAPIRepository2::FindCertificates(), and CPKIFCAPI2::Sign().

void StrToName ( const char *  dn,
unsigned char **  enc,
DWORD len 
)

Interface: External

This function encodes the distinguished name using CAPI

Returns:
None
Parameters:
dn  [in] A NULL terminated string containing the distinguished name
enc  [in] A pointer to a buffer which contains the encoding
len  [in] DWORD which contains the length of the buffer

Definition at line 450 of file CAPIUtils.cpp.

Referenced by CPKIFCAPIUserRepository2::FindCertificates(), CPKIFCAPITrustStore2::FindCertificates(), and CPKIFCAPIRepository2::FindCertificates().


Generated on Mon Nov 15 11:16:17 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6