Module: Miscellaneous
Definition in file CAPIUtils.cpp.
#include "CAPIUtils.h"
#include "ToolkitUtils.h"
#include "PKIFException.h"
#include "PKIFCryptoErrors.h"
#include "components.h"
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) |
bool CertHasKey | ( | PCCERT_CONTEXT | pPrevCertContent | ) |
Interface: Subsystem
This function simply determines if there is a private key associated with a given cert.
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.
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;
CPKIFException(CRYPTO_ALG_NOT_SUPPORTED) |
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;
CPKIFException(CRYPTO_ALG_NOT_SUPPORTED) |
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.
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
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
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().