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