00001
00010 #ifndef _PKFICRYPTOPP_H_
00011 #define _PKFICRYPTOPP_H_
00012
00013 #include "PKIFdll.h"
00014 #include "IPKIFCryptoKeyID.h"
00015 #include "IPKIFCryptoKeyAgree.h"
00016 #include "components.h"
00017
00018 #include <bitset>
00019
00020 struct CPKIFCryptoPPImpl;
00021 FD_LIST_PTR(CPKIFCredential);
00022 FD_SMART_PTR(CPKIFKeyUsage);
00023 FD_SMART_PTR(CPKIFBuffer);
00033 class CAC_API CPKIFCryptoPP : public IPKIFColleague, public IPKIFCryptoKeyID, public IPKIFCryptoKeyAgree
00034 {
00035 public:
00036 CPKIFCryptoPP();
00037 virtual ~CPKIFCryptoPP(void);
00038
00039
00040 void Initialize();
00041
00042
00043 void GetKeyList(CPKIFCredentialList& v,std::bitset<9>* = NULL);
00044 void GetKeyList(CPKIFCredentialList& v,CPKIFKeyUsagePtr& ku);
00045
00046
00047 bool OwnsKey(const CPKIFCredential& keyID) const;
00048 CPKIFCredentialPtr MakeKeyID(const std::string& asciiHexKeyID);
00049
00050
00051 void Sign(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG ha);
00052 void Decrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00053 void Encrypt(const CPKIFCredential& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen);
00054 bool Verify(const CPKIFCredential& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG ha);
00055
00056 IPKIFCryptContext* CryptInit(CPKIFCredentialPtr& key, bool pad = true);
00057 void Decrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00058 void Encrypt(IPKIFCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00059
00060
00061
00062 virtual IPKIFKeyAgreeContextPtr SecretAgree(CPKIFCredentialPtr& myPrivateKey, const CPKIFCertificatePtr& theirCert,
00063 const CPKIFAlgorithm * alg);
00064 virtual IPKIFKeyAgreeContextPtr SecretAgree(CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& theirPublicKey,
00065 const CPKIFAlgorithm * alg);
00066
00067
00068
00069 virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, CPKIFCredentialPtr & ephemeralKeyPair,
00070 const CPKIFCertificatePtr& theirCert, const CPKIFAlgorithm * alg);
00071 virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, CPKIFCredentialPtr & ephemeralKeyPair,
00072 const CPKIFBufferPtr& theirPublicKey, const CPKIFAlgorithm * alg);
00073
00074 virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& ephemeralPublicKey,
00075 const CPKIFCertificatePtr& theirCert, const CPKIFAlgorithm * alg);
00076 virtual IPKIFKeyAgreeContextPtr SecretAgree(const CPKIFCredentialPtr& myPrivateKey, const CPKIFBufferPtr& ephemeralPublicKey,
00077 const CPKIFBufferPtr& theirPublicKey, const CPKIFAlgorithm * alg);
00078
00079 virtual CPKIFKeyMaterialPtr DeriveKey(const IPKIFKeyAgreeContextPtr & context, unsigned long keyLen);
00080
00081 enum { thisComponent = TOOLKIT_CRYPTO_CRYPTOPP };
00082
00083 private:
00085 CPKIFCryptoPP(const CPKIFCryptoPP& copy);
00087 CPKIFCryptoPP& operator=(const CPKIFCryptoPP& rhs);
00088
00089 CPKIFCryptoPPImpl * m_impl;
00090
00091
00092 };
00093 DECLARE_SMART_POINTERS(CPKIFCryptoPP);
00094
00095 #endif