PKIFCNGCAPI.h

Go to the documentation of this file.
00001 
00009 #ifndef __PKIFCNGCAPI_H__
00010 #define __PKIFCNGCAPI_H__
00011 
00012 #include "PKIFdll.h"
00013 #include "IPKIFCryptoKeyID.h"
00014 #include "IPKIFCAPISource.h"
00015 #include "IPKIFCryptoKeyAgree.h"
00016 #include "components.h"
00017 
00018 #include <wincrypt.h>
00019 #include <bitset>
00020 
00021 
00022 struct CPKIFCNGCAPIImpl;
00023 FD_LIST_PTR(CPKIFCredential);
00024 FD_SMART_PTR(CPKIFKeyUsage);
00025 
00083 class CAC_API CPKIFCNGCAPI : public IPKIFColleague, public IPKIFCryptoKeyID, public IPKIFCAPISource, public IPKIFCryptoKeyAgree
00084 {
00085     friend struct CPKIFCNGCAPIImpl;
00086 public:
00087     CPKIFCNGCAPI(const char* provider = NULL, int provType = 0, int sysStoRegLoc = CERT_SYSTEM_STORE_CURRENT_USER);
00088     virtual ~CPKIFCNGCAPI(void);
00089 
00090     //IPKIFColleague functions
00091     void Initialize();
00092 
00093     //Miscellaneous functions
00094     void GetKeyList(CPKIFCredentialList& v,std::bitset<9>* = NULL);
00095     void GetKeyList(CPKIFCredentialList& v, CPKIFKeyUsagePtr& ku);
00096 
00097     //key management
00098     bool OwnsKey(const CPKIFCredential& keyID) const;
00099     CPKIFCredentialPtr MakeKeyID(const std::string& asciiHexKeyID);
00100 
00101     //functions that operate on key handles
00102     void Sign(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00103     void Decrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00104     void Encrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00105     bool Verify(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00106 
00107     IPKIFCryptContext* CryptInit(CPKIFCredentialPtr& key, bool pad = true);
00108     void Decrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00109     void Encrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00110 
00111     //IPKIFCryptoKeyAgree methods
00112     // ephemeral-static or static-static key agreement
00113     virtual IPKIFKeyAgreeContextPtr SecretAgree(CPKIFCredentialPtr& myPrivateKey, const CPKIFCertificatePtr& theirCert, 
00114         const CPKIFAlgorithm * alg);
00115     virtual IPKIFKeyAgreeContextPtr SecretAgree(CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& theirPublicKey, 
00116         const CPKIFAlgorithm * alg);
00117 
00118     // (single-pass only) authenticated key agreement
00119     // originator interfaces
00120     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, CPKIFCredentialPtr & ephemeralKeyPair,
00121         const CPKIFCertificatePtr& theirCert, const CPKIFAlgorithm * alg);
00122     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, CPKIFCredentialPtr & ephemeralKeyPair,
00123         const CPKIFBufferPtr& theirPublicKey, const CPKIFAlgorithm * alg);
00124     // recipient interfaces
00125     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& ephemeralPublicKey, 
00126         const CPKIFCertificatePtr& theirCert, const CPKIFAlgorithm * alg);
00127     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& ephemeralPublicKey, 
00128         const CPKIFBufferPtr& theirPublicKey, const CPKIFAlgorithm * alg);
00129     
00130     virtual CPKIFKeyMaterialPtr DeriveKey(const IPKIFKeyAgreeContextPtr & context, unsigned long keyLen);
00131 
00132 
00133 private:
00135     CPKIFCNGCAPI(const CPKIFCNGCAPI& copy);
00137     CPKIFCNGCAPI& operator=(const CPKIFCNGCAPI& rhs); //added 4/6/2004
00138     
00139     enum { thisComponent = TOOLKIT_CRYPTO_CAPI };
00140     
00141     struct CPKIFCNGCAPIImpl *m_impl;
00142 
00143 };
00144 DECLARE_SMART_POINTERS(CPKIFCNGCAPI);
00145 
00146 #endif

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