Module: CPKIFCAPIRaw
Definition in file CACCAPIRaw.cpp.
#include "PKIFCAPIRaw.h"
#include "PKIFCAPICryptContext2.h"
#include "PKIFCAPIHashContext.h"
#include "CAPIUtils.h"
#include "PKIFCryptoException.h"
#include "PKIFKeyMaterial.h"
#include "PKIFCryptoErrors.h"
#include "PKIFCAPIErrors.h"
#include "CAPIRawCryptContext.h"
#include "PKIFAlgorithm.h"
#include "AlgorithmIdentifier.h"
#include "Buffer.h"
#include "Certificate.h"
#include "ToolkitUtils.h"
#include "components.h"
#include "PKIFException.h"
#include "SubjectPublicKeyInfo.h"
#include "ASN1Helper.h"
#include "PKIX1Algorithms88.h"
#include <iostream>
#include <sstream>
Go to the source code of this file.
Defines | |
#define | ALG_SID_SHA_256 12 |
#define | ALG_SID_SHA_384 13 |
#define | ALG_SID_SHA_512 14 |
#define | CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256) |
#define | CALG_SHA_384 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384) |
#define | CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) |
#define | CLEANUP |
#define | CLEANUP |
#define | CLEANUP |
Functions | |
ALG_ID | GetSymAlgorithm (const CPKIFKeyMaterial &key) |
DWORD | GetProvType (PCCERT_CONTEXT cert) |
DWORD | GetProvType (const char *oidString) |
HCRYPTHASH | CreateHashObjectFromData (HCRYPTPROV hProv, unsigned char *pHashData, int nHashDataLen) |
bool | _Verify (const CPKIFKeyMaterial &key, unsigned char *pHashData, int nHashDataLen, unsigned char *pSignature, int nSignatureLen) |
Variables | |
CAC_API char | g_defCACCAPITrustStore [] = "Root" |
defined(ALG_SID_SHA_256) |
#define ALG_SID_SHA_256 12 |
Definition at line 38 of file CACCAPIRaw.cpp.
#define ALG_SID_SHA_384 13 |
Definition at line 39 of file CACCAPIRaw.cpp.
#define ALG_SID_SHA_512 14 |
Definition at line 40 of file CACCAPIRaw.cpp.
#define CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256) |
#define CALG_SHA_384 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384) |
#define CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) |
#define CLEANUP |
Value:
{ \ if (capiSpki.Algorithm.Parameters.cbData) \ { delete[] capiSpki.Algorithm.Parameters.pbData; capiSpki.Algorithm.Parameters.pbData = NULL; capiSpki.Algorithm.Parameters.cbData = 0;} \ if (clearParams) \ { delete[] cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.Parameters.pbData; cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.Parameters.pbData = NULL; cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.Parameters.cbData = 0;} \ if (NULL != cert) \ { CertFreeCertificateContext(cert); cert = NULL; } \ if (NULL != hHash) \ { CryptDestroyHash(hHash); hHash = NULL; } \ if (NULL != hKey) \ { CryptDestroyKey(hKey); hKey = NULL; } \ if (NULL != hProv) \ { CryptReleaseContext(hProv, 0); hProv = NULL; } \ }
#define CLEANUP |
Value:
{ \
if (NULL != hHash) \
{ CryptDestroyHash(hHash); hHash = NULL; } \
}
#define CLEANUP |
Value:
{ \ if (NULL != hSessionKey) \ { BOOL succ = CryptDestroyKey(hSessionKey); hSessionKey = NULL;} \ if (NULL != hTmpProv) \ { CryptReleaseContext(hTmpProv, 0); hTmpProv = NULL; } \ if (NULL != cert) \ { CertFreeCertificateContext(cert); cert = NULL; } \ }
Referenced by _Verify(), CreateHashObjectFromData(), CPKIFCAPI2::Decrypt(), GetCertfromLDAPURL(), CPKIFLDAPRepository::GetCertificates(), GetCRLfromLDAPURL(), CPKIFLDAPRepository::GetCRLs(), CPKIFCAPI2::MakeKeyID(), CPKIFCAPI2::Sign(), and CPKIFNSSRaw::VerifyCertificate().
bool _Verify | ( | const CPKIFKeyMaterial & | key, | |
unsigned char * | pHashData, | |||
int | nHashDataLen, | |||
unsigned char * | pSignature, | |||
int | nSignatureLen | |||
) |
Interface: Module
This is a helper function called in Verify
CPKIFCryptoException(PKIFCAPI_CREATE_CERT_FAILED) | ||
CPKIFCryptoException(PKIFCAPI_ACQUIRE_CONTEXT_FAILED) | ||
CPKIFCryptoException(PKIFCAPI_KEY_IMPORT_FAILED) | ||
CPKIFCryptoException(PKIFCAPI_KEY_MATERIAL_NOT_SUPPORTED) |
key | [in] Reference to a CPKIFKeyMaterial object containing key material to use when verifying the signature |
pHashData | [in] Pointer to a buffer containing the message digest that was signed to produce the signature conveyed via the pSignature parameter |
nHashDataLen | [in] Integer indicating the length of the value passed via the pHashData parameter |
pSignature | [in] Pointer to a buffer containing the signature to verify |
nSignatureLen | [in] Integer indicating the size of the value passed via the pSignature parameter |
Definition at line 734 of file CACCAPIRaw.cpp.
References atob(), CACASNWRAPPER_CREATE, CLEANUP, CPKIFKeyMaterial::ContainsCertificate(), CPKIFKeyMaterial::ContainsPublicKeyMaterial(), CreateHashObjectFromData(), CPKIFKeyMaterial::GetCertificate(), CPKIFKeyMaterial::GetCertificateLength(), GetProvType(), CPKIFKeyMaterial::GetSubjectPublicKeyInfo(), CPKIFKeyMaterial::GetWorkingParameters(), LOG_STRING_DEBUG, MAXHASH, PKIFCAPI_ACQUIRE_CONTEXT_FAILED, PKIFCAPI_CREATE_CERT_FAILED, PKIFCAPI_KEY_IMPORT_FAILED, PKIFCAPI_KEY_MATERIAL_NOT_SUPPORTED, RAISE_CRYPTO_EXCEPTION, ReverseBytes(), TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_CAPIRAW.
Referenced by CPKIFNSSRaw::Verify(), CPKIFCryptoPPRaw::Verify(), CPKIFCAPIRaw::Verify(), CPKIFCryptoPPRaw::VerifyCertificate(), and VerifyCertificateWithCryptoPP().
HCRYPTHASH CreateHashObjectFromData | ( | HCRYPTPROV | hProv, | |
unsigned char * | pHashData, | |||
int | nHashDataLen | |||
) |
Interface: Module
This function creates a hash object from data
CPKIFCryptoException(PKIFCAPI_CREATE_HASH_FAILED) | ||
CPKIFCryptoException(PKIFCAPI_MISC_HASH_CALL_FAILED) |
hProv | CAPI Cryptographic privider |
pHashData | [in] Pointer to a buffer containing the message digest that was signed to produce the signature conveyed via the pSignature parameter |
nHashDataLen | [in] Integer indicating the length of the value passed via the pHashData parameter |
Definition at line 660 of file CACCAPIRaw.cpp.
References CLEANUP, GetHashAlg(), LOG_STRING_DEBUG, PKIFCAPI_CREATE_HASH_FAILED, PKIFCAPI_MISC_HASH_CALL_FAILED, RAISE_CRYPTO_EXCEPTION, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_CAPIRAW.
Referenced by _Verify().
DWORD GetProvType | ( | const char * | oidString | ) |
Interface: Module
This function is used to retrive provider type
CPKIFCryptoException(CRYPTO_ALG_NOT_SUPPORTED) |
oidString | [in]Pointer to string representation of algorithm OID |
Definition at line 249 of file CACCAPIRaw.cpp.
References CRYPTO_ALG_NOT_SUPPORTED, RAISE_CRYPTO_EXCEPTION, and TOOLKIT_CRYPTO_CAPIRAW.
DWORD GetProvType | ( | PCCERT_CONTEXT | cert | ) |
Interface: Module
This function is used to retrive provider type
CPKIFCryptoException(CRYPTO_ALG_NOT_SUPPORTED) |
cert | [in]Certificate in PCCERT_CONTEXT format |
Definition at line 225 of file CACCAPIRaw.cpp.
References CRYPTO_ALG_NOT_SUPPORTED, RAISE_CRYPTO_EXCEPTION, and TOOLKIT_CRYPTO_CAPIRAW.
Referenced by _Verify(), and CPKIFCAPIRaw::SupportsAlgorithm().
ALG_ID GetSymAlgorithm | ( | const CPKIFKeyMaterial & | key | ) |
Interface: Module
This function is used to retrive symmetric algorithm
CPKIFCryptoException(CRYPTO_ALG_NOT_SUPPORTED) |
key | [in]CPKIFKeyMaterial object |
Definition at line 194 of file CACCAPIRaw.cpp.
References CRYPTO_ALG_NOT_SUPPORTED, PKIFCRYPTO::DES, CPKIFKeyMaterial::GetSymmetricKeyAlgorithm(), RAISE_CRYPTO_EXCEPTION, PKIFCRYPTO::TDES, and TOOLKIT_CRYPTO.
Referenced by CPKIFCAPIRaw::CryptInit(), and CPKIFCAPIRaw::SupportsAlgorithm().
CAC_API char g_defCACCAPITrustStore[] = "Root" |
defined(ALG_SID_SHA_256)
Definition at line 47 of file CACCAPIRaw.cpp.
Referenced by LoadStorageAndRetrievalComponents(), MakeDefaultMediator(), and SaveStorageAndRetrievalComponents().