1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #ifndef cmCryptoHash_h
13 #define cmCryptoHash_h
15 #include "cmStandardIncludes.h"
17 #include <cmsys/auto_ptr.hxx>
22 virtual ~cmCryptoHash() {}
23 static cmsys::auto_ptr<cmCryptoHash> New(const char* algo);
24 std::string HashString(const char* input);
25 std::string HashFile(const char* file);
27 virtual void Initialize()=0;
28 virtual void Append(unsigned char const*, int)=0;
29 virtual std::string Finalize()=0;
32 class cmCryptoHashMD5: public cmCryptoHash
34 struct cmsysMD5_s* MD5;
39 virtual void Initialize();
40 virtual void Append(unsigned char const* buf, int sz);
41 virtual std::string Finalize();
44 #define cmCryptoHash_SHA_CLASS_DECL(SHA) \
45 class cmCryptoHash##SHA: public cmCryptoHash \
47 union _SHA_CTX* SHA; \
49 cmCryptoHash##SHA(); \
50 ~cmCryptoHash##SHA(); \
52 virtual void Initialize(); \
53 virtual void Append(unsigned char const* buf, int sz); \
54 virtual std::string Finalize(); \
57 cmCryptoHash_SHA_CLASS_DECL(SHA1);
58 cmCryptoHash_SHA_CLASS_DECL(SHA224);
59 cmCryptoHash_SHA_CLASS_DECL(SHA256);
60 cmCryptoHash_SHA_CLASS_DECL(SHA384);
61 cmCryptoHash_SHA_CLASS_DECL(SHA512);
63 #undef cmCryptoHash_SHA_CLASS_DECL