CPKIFCryptoMediator2.h

Go to the documentation of this file.
00001 
00009 #ifndef __PKIFCRYPTOMEDIATOR2_H__
00010 #define __PKIFCRYPTOMEDIATOR2_H__
00011 
00012 //include toolkit header files
00013 #include "PKIFdll.h"
00014 #include "components.h"
00015 
00016 //include necessary standard library pieces
00017 #include <vector>
00018 #include <bitset>
00019 
00020 // forward declarations
00021 class CPKIFException;
00022 FD_SMART_PTR(CPKIFCredential);
00023 FD_SMART_PTR(CPKIFKeyUsage);
00024 
00025 #include "PKIFMediators.h"
00026 #include "IPKIFCryptoRawOperations.h"
00027 #include "IPKIFCryptoKeyIDOperations.h"
00028 #include "IPKIFCryptoMisc.h"
00029 #include "IPKIFDefaultKeyManagement.h"
00030 #include "IPKIFCryptoKeyAgree.h"
00031 
00057 class CAC_API CPKIFCryptoMediator2 :    public IPKIFMediator,public IPKIFCryptoRawOperations, public IPKIFCryptoKeyIDOperations, public IPKIFCryptoMisc, public IPKIFDefaultKeyManagement, public IPKIFCryptoKeyAgree
00058 {
00059     friend struct CPKIFCryptoMediator2Impl;
00060 public:
00061     CPKIFCryptoMediator2(bool addDefaultColleagues = false);
00062     virtual ~CPKIFCryptoMediator2(void);
00063 
00064     //IPKIFMediator functions
00065     void InitializeMediator(std::vector<CPKIFException*>* errorInfo);
00066     void Terminate();
00067 
00068     //IPKIFColleague functions
00069     void Initialize();
00070 
00071     void GetColleagues(std::vector<IPKIFColleaguePtr>& v) const;
00072 
00073     //Miscellaneous functions
00074     void AddColleague(IPKIFColleaguePtr& module);
00075     const CPKIFCredentialPtr SetDefaultKey(const std::string& asciiHexKeyID, PKIFCRYPTO::DefaultKeyType op);
00076     CPKIFCredentialPtr GetDefaultKey(PKIFCRYPTO::DefaultKeyType op);
00077 
00078     //IPKIFCryptoMisc functions
00079     void GenRandom(unsigned char* buf, int len);
00080     IPKIFHashContext* HashInit(PKIFCRYPTO::HASH_ALG alg);
00081     void HashUpdate(IPKIFHashContext* hash, unsigned char* pData, int nDataLen);
00082     void HashFinal(IPKIFHashContext* hash, unsigned char* pResult, int* pnResultLen);
00083 
00084     //IPKIFCryptoKeyID functions
00085     void Sign(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00086     void Decrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00087     void Encrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00088     bool Verify(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00089     void GetKeyList(CPKIFCredentialList& v, std::bitset<9>* ku=NULL);
00090     void GetKeyList(CPKIFCredentialList& v,CPKIFKeyUsagePtr& ku);
00091 
00092     IPKIFCryptContext* CryptInit(CPKIFCredentialPtr& key, bool pad = true);
00093     void Decrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00094     void Encrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00095 
00096     void Sign(const CPKIFCredentialPtr& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00097     void Decrypt(const CPKIFCredentialPtr& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00098     void Encrypt(const CPKIFCredentialPtr& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00099     bool Verify(const CPKIFCredentialPtr& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00100 
00101     //IPKIFCryptoRaw functions
00102     void Sign(const CPKIFKeyMaterial& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00103     void Encrypt(const CPKIFKeyMaterial& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool pad = true);
00104     void Decrypt(const CPKIFKeyMaterial& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool pad = true);
00105     bool Verify(const CPKIFKeyMaterial& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00106     bool VerifyCertificate(const CPKIFCertificate& issCert, const CPKIFCertificate& subCert);
00107 
00108     IPKIFRawCryptContext* CryptInit(const CPKIFKeyMaterial& key, bool pad = true);
00109     void Decrypt(IPKIFRawCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00110     void Encrypt(IPKIFRawCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00111 
00112     IPKIFRawCryptContext* HMACInit(const CPKIFKeyMaterial &key, PKIFCRYPTO::HASH_ALG ha);
00113     void HMACUpdate(IPKIFRawCryptContext* ctx, unsigned char* pData, int nDataLen);
00114     void HMACFinal(IPKIFRawCryptContext* ctx, unsigned char* pResult, int* pnResultLen);
00115 
00116     // ephemeral-static or static-static key agreement
00117     virtual IPKIFKeyAgreeContextPtr SecretAgree(CPKIFCredentialPtr& myPrivateKey, const CPKIFCertificatePtr& theirCert, 
00118         const CPKIFAlgorithm * alg);
00119     virtual IPKIFKeyAgreeContextPtr SecretAgree(CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& theirPublicKey, 
00120         const CPKIFAlgorithm * alg);
00121 
00122     // (single-pass only) authenticated key agreement
00123     // originator interfaces
00124     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, CPKIFCredentialPtr & ephemeralKeyPair,
00125         const CPKIFCertificatePtr& theirCert, const CPKIFAlgorithm * alg);
00126     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, CPKIFCredentialPtr & ephemeralKeyPair,
00127         const CPKIFBufferPtr& theirPublicKey, const CPKIFAlgorithm * alg);
00128     // recipient interfaces
00129     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& ephemeralPublicKey, 
00130         const CPKIFCertificatePtr& theirCert, const CPKIFAlgorithm * alg);
00131     virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& ephemeralPublicKey, 
00132         const CPKIFBufferPtr& theirPublicKey, const CPKIFAlgorithm * alg);
00133     
00134     virtual CPKIFKeyMaterialPtr DeriveKey(const IPKIFKeyAgreeContextPtr & context, unsigned long keyLen);
00135 
00136     // IPKIFCryptoAlgSupport
00137     virtual bool SupportsAlgorithm(const CPKIFKeyMaterial& key);
00138     
00139 private:
00141     CPKIFCryptoMediator2(const CPKIFCryptoMediator2& copy);
00143     CPKIFCryptoMediator2& operator=(const CPKIFCryptoMediator2& rhs); //added 4/6/2004
00144 
00145     enum {thisComponent = TOOLKIT_CRYPTO_MEDIATOR};
00146 
00147     struct CPKIFCryptoMediator2Impl *m_impl;
00148 
00149 };
00150 DECLARE_SMART_POINTERS(CPKIFCryptoMediator2);
00151 
00152 
00153 #endif

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