Digest.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 
00023 #include "dwfcore/Core.h"
00024 #include "dwfcore/String.h"
00025 
00026 #ifndef _DWFCORE_DIGEST_H
00027 #define _DWFCORE_DIGEST_H
00028 
00033 
00037 
00038 //
00039 // fwd declarations that must live outside the namespace (coming from C)
00040 //
00041 struct md5_state_s;
00042 struct SHA1Context;
00043 
00044 namespace DWFCore
00045 {
00046 
00054 class DWFDigest : virtual public DWFCoreMemory
00055 {
00056 
00057 public:
00058 
00064     _DWFCORE_API
00065     virtual ~DWFDigest()
00066         throw()
00067     {;}
00068 
00076     _DWFCORE_API
00077     virtual void update( const char* pBuffer, size_t nBytes )
00078         throw( DWFException ) = 0;
00079 
00088     _DWFCORE_API
00089     virtual bool isProgressive()
00090         throw() = 0;
00091 
00101     _DWFCORE_API
00102     virtual DWFString digest()
00103         throw( DWFException ) = 0;
00104 
00118     _DWFCORE_API
00119     virtual size_t digestRawBytes( unsigned char*& rpBytes )
00120         throw( DWFException ) = 0;
00121 
00132     _DWFCORE_API
00133     virtual DWFString digestBase64()
00134         throw( DWFException ) = 0;
00135 
00141     _DWFCORE_API
00142     virtual void reset()
00143         throw() = 0;
00144 };
00145 
00146 
00147 
00148 //
00149 // fwd declaration
00150 //
00151 struct _DWFMD5Digest_t;
00152 
00161 class DWFMD5Digest : public DWFDigest
00162 {
00163 
00164 public:
00165 
00169     _DWFCORE_API
00170     DWFMD5Digest()
00171         throw();
00172 
00178     _DWFCORE_API
00179     virtual ~DWFMD5Digest()
00180         throw();
00181 
00185     _DWFCORE_API
00186     virtual void update( const char* pBuffer, size_t nBytes )
00187         throw( DWFException );
00188 
00192     _DWFCORE_API
00193     virtual bool isProgressive()
00194         throw();
00195 
00199     _DWFCORE_API
00200     virtual DWFString digest()
00201         throw( DWFException );
00202 
00206     _DWFCORE_API
00207     virtual size_t digestRawBytes( unsigned char*& rpBytes )
00208         throw( DWFException );
00209 
00213     _DWFCORE_API
00214     virtual DWFString digestBase64()
00215         throw( DWFException );
00216 
00220     _DWFCORE_API
00221     virtual void reset()
00222         throw();
00223 
00224 private:
00225 
00226     // This does the actual digest computation. The public digest calls take the result and
00227     // format it into the requested output form.
00228     void _computeDigest( _DWFMD5Digest_t& oDigest )
00229         throw( DWFException );
00230 
00231 private:
00232 
00233     // A pointer to the structure that stores the state of the MD5 computation as bytes are read in
00234     md5_state_s* _pState;
00235 
00236 };
00237 
00238 
00239 //
00240 // fwd declaration
00241 //
00242 struct _DWFSHA1Digest_t;
00243 
00252 class DWFSHA1Digest : public DWFDigest
00253 {
00254 
00255 public:
00256 
00260     _DWFCORE_API
00261     DWFSHA1Digest()
00262         throw();
00263 
00269     _DWFCORE_API
00270     virtual ~DWFSHA1Digest()
00271         throw();
00272 
00276     _DWFCORE_API
00277     virtual void update( const char* pBuffer, size_t nBytes )
00278         throw( DWFException );
00279 
00283     _DWFCORE_API
00284     virtual bool isProgressive()
00285         throw();
00286 
00290     _DWFCORE_API
00291     virtual DWFString digest()
00292         throw( DWFException );
00293 
00297     _DWFCORE_API
00298     virtual size_t digestRawBytes( unsigned char*& rpBytes )
00299         throw( DWFException );
00300 
00304     _DWFCORE_API
00305     virtual DWFString digestBase64()
00306         throw( DWFException );
00307 
00311     _DWFCORE_API
00312     virtual void reset()
00313         throw();
00314 
00315 private:
00316 
00317     // This does the actual digest computation. The public digest calls take the result and
00318     // format it into the requested output form.
00319     void _computeDigest( unsigned int _oDigest[5] )
00320         throw( DWFException );
00321 
00322 private:
00323 
00324     // A pointer to the structure that stores the state of the MD5 computation as bytes are read in
00325     SHA1Context*    _pState;
00326 };
00327 
00328 
00329 }
00330 
00331 #endif
00332 
00333 

Generated on Tue Jan 6 22:39:28 2009 for Autodesk DWF Core Library by  doxygen 1.4.5