ParallelHash.h

Go to the documentation of this file.
00001 
00009 #ifndef __PARALLELHASH_H__
00010 #define __PARALLELHASH_H__
00011 
00012 #include "PKIFCMSDLL.h"
00013 #include "PKIFCMSUtils.h"
00014 
00015 class IPKIFHashContext;
00016 class IPKIFCryptoMisc;
00017 
00018 //CPKIFParallelHash is intended for use by CPKIFSignedData.  It could probably be used
00019 //elsewhere if similar, parallel hashing functionality is needed (and Objective 
00020 //structures are used).  It is up to the called to make sure that the IPKIFCryptoMisc
00021 //interface used to create the hash contexts remains active until FreeHashVector has been
00022 //called (which is called by the destructor if necessary).
00023 //
00024 //This class may thrown CPKIFMessageExceptions or CPKIFCryptoExceptions.
00025 
00026 struct HashInfo
00027 {
00035     HashInfo(){m_hashContext = NULL;m_hashAlg = PKIFCRYPTO::SHA1;}
00036     PKIFCRYPTO::HASH_ALG m_hashAlg;
00037     IPKIFHashContext* m_hashContext;
00038     unsigned char m_hashResult[MAXHASH];
00039 };
00053 class PKIFCMS_API CPKIFParallelHash
00054 {
00055 public:
00056     CPKIFParallelHash();
00057     virtual ~CPKIFParallelHash();
00058 
00059     //1) Always add ALL hash algorithms that are necessary.
00060     void SetDigestAlgs(IPKIFCryptoMisc* cMisc, CPKIFBufferPtr digestAlgsBuf);
00061     void SetDigestAlgs(IPKIFCryptoMisc* cMisc, CCACDigestAlgorithmIdentifiers& digestAlgs);  //added for TAP purposes 9/5/03
00062 
00063     //2) Next, add data iteratively or in a single shot.
00064     void UpdateMessage(IPKIFCryptoMisc* cMisc, unsigned char* buf, int bufLen); 
00065     
00066     //3) After all calls to UpdateMessage have been made call FinalizeHashes to finish the process.
00067     void FinalizeHashes(IPKIFCryptoMisc* cMisc);
00068 
00069     //4) Call GetHashInfo with a HASH_ALG identifier to retrieve result for that algorithm.
00070     HashInfo* GetHashInfo(PKIFCRYPTO::HASH_ALG alg);
00071 
00072     //5) Be sure to call FreeHashVector before reusing a CPKIFParallelHash object.
00073     void FreeHashVector();
00074 
00075     //This class silently ignores unsupported algorithms.  If usage in cases other than CPKIFSignedData
00076     //is desired this may not be a good thing.  This flag was added to facilitate alternate uses.
00077     //By default it is set to true.
00078     void SetIgnoreUnsupportedAlgs(bool b);
00079 
00080 private:
00082     CPKIFParallelHash(const CPKIFParallelHash& copy);
00084     CPKIFParallelHash& operator=(const CPKIFParallelHash& rhs); //added 4/6/2004
00085 
00086     struct CPKIFParallelHashImpl *m_impl;
00087 };
00088 DECLARE_SMART_POINTERS(CPKIFParallelHash);
00089 
00090 #endif //__PARALLELHASH_H__

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