PKIFCAPI2.h
Go to the documentation of this file.00001
00009 #ifndef __PKIFCAPI2_H__
00010 #define __PKIFCAPI2_H__
00011
00012 #include "PKIFdll.h"
00013 #include "IPKIFCryptoKeyID.h"
00014 #include "IPKIFCAPISource.h"
00015 #include "components.h"
00016
00017 #include <wincrypt.h>
00018 #include <bitset>
00019
00020
00021 struct CPKIFCAPI2Impl;
00022 FD_LIST_PTR(CPKIFCredential);
00023 FD_SMART_PTR(CPKIFKeyUsage);
00024
00025
00026 enum BYTESREVERSED
00027 {
00028 NOTREV,
00029 REV,
00030 UNSET,
00031
00032 };
00033
00034
00092 class CAC_API CPKIFCAPI2 : public IPKIFColleague, public IPKIFCryptoKeyID, public IPKIFCAPISource
00093 {
00094 friend struct CPKIFCAPI2Impl;
00095 public:
00096 CPKIFCAPI2(const char* provider = NULL, int provType = 0, int sysStoRegLoc = CERT_SYSTEM_STORE_CURRENT_USER);
00097 virtual ~CPKIFCAPI2(void);
00098
00099
00100 void Initialize();
00101
00102
00103 void GetKeyList(CPKIFCredentialList& v,std::bitset<9>* = NULL);
00104 void GetKeyList(CPKIFCredentialList& v, CPKIFKeyUsagePtr& ku);
00105
00106
00107 bool OwnsKey(const CPKIFCredential& keyID) const;
00108 CPKIFCredentialPtr MakeKeyID(const std::string& asciiHexKeyID);
00109
00110
00111 void Sign(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00112 void Decrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00113 void Encrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00114 bool Verify(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00115
00116 IPKIFCryptContext* CryptInit(CPKIFCredentialPtr& key, bool pad = true);
00117 void Decrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00118 void Encrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00119
00120 private:
00122 CPKIFCAPI2(const CPKIFCAPI2& copy);
00124 CPKIFCAPI2& operator=(const CPKIFCAPI2& rhs);
00125
00126 enum { thisComponent = TOOLKIT_CRYPTO_CAPI };
00127
00128 struct CPKIFCAPI2Impl *m_impl;
00129
00130 };
00131 DECLARE_SMART_POINTERS(CPKIFCAPI2);
00132
00133 #endif