00001
00010 #ifndef _PKIFCRYPTOPPRAW_H_
00011 #define _PKIFCRYPTOPPRAW_H_
00012
00013 #include "PKIFdll.h"
00014 #include "IPKIFColleague.h"
00015 #include "IPKIFCryptoRaw.h"
00016 #include "IPKIFCryptoMisc.h"
00017 #include "components.h"
00018
00027 class CAC_API CPKIFCryptoPPRaw : public IPKIFColleague,
00028 public IPKIFCryptoRaw,
00029 public IPKIFCryptoMisc
00030 {
00031 public:
00032 CPKIFCryptoPPRaw(void);
00033 virtual ~CPKIFCryptoPPRaw(void);
00034
00035
00036 void Initialize();
00037
00038
00039 void GenRandom(unsigned char* buf, int len);
00040 IPKIFHashContext* HashInit(PKIFCRYPTO::HASH_ALG alg);
00041 void HashUpdate(IPKIFHashContext* hash, unsigned char* pData, int nDataLen);
00042 void HashFinal(IPKIFHashContext* hash, unsigned char* pResult, int* pnResultLen);
00043
00044
00045 bool SupportsAlgorithm(const CPKIFKeyMaterial& key);
00046
00047
00048 void Sign(const CPKIFKeyMaterial& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int* nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00049 void Decrypt(const CPKIFKeyMaterial& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool pad = true);
00050 void Encrypt(const CPKIFKeyMaterial& key, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool pad = true);
00051 bool Verify(const CPKIFKeyMaterial& key, unsigned char* pHashData, int nHashDataLen, unsigned char* pSignature, int nSignatureLen, PKIFCRYPTO::HASH_ALG hashAlg);
00052 bool VerifyCertificate(const CPKIFCertificate& issCert, const CPKIFCertificate& subCert);
00053
00054 IPKIFRawCryptContext* CryptInit(const CPKIFKeyMaterial& key, bool pad = true);
00055 void Decrypt(IPKIFRawCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00056 void Encrypt(IPKIFRawCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00057
00058 IPKIFRawCryptContext* HMACInit(const CPKIFKeyMaterial &key, PKIFCRYPTO::HASH_ALG ha);
00059 void HMACUpdate(IPKIFRawCryptContext* ctx, unsigned char* pData, int nDataLen);
00060 void HMACFinal(IPKIFRawCryptContext* ctx, unsigned char* pResult, int* pnResultLen);
00061
00062
00063
00064 enum { thisComponent = TOOLKIT_CRYPTO_CRYPTOPPRAW };
00065
00066 protected:
00067 template <bool _CryptDirection> void CryptFunc(IPKIFRawCryptContext* cryptContext, unsigned char* pData, int nDataLen, unsigned char* pResult, int* pnResultLen, bool final);
00068
00069 private:
00071 CPKIFCryptoPPRaw(const CPKIFCryptoPPRaw& copy);
00073 CPKIFCryptoPPRaw& operator=(const CPKIFCryptoPPRaw& rhs);
00074
00075 };
00076 DECLARE_SMART_POINTERS(CPKIFCryptoPPRaw);
00077
00078 #endif // !defined(_PKIFCRYPTOPPRAW_H_)
00079