Annotation of truecrypt/volume/hash.h, revision 1.1

1.1     ! root        1: /*
        !             2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
        !             3: 
        !             4:  Governed by the TrueCrypt License 2.4 the full text of which is contained
        !             5:  in the file License.txt included in TrueCrypt binary and source code
        !             6:  distribution packages.
        !             7: */
        !             8: 
        !             9: #ifndef TC_HEADER_Encryption_Hash
        !            10: #define TC_HEADER_Encryption_Hash
        !            11: 
        !            12: #include "Platform/Platform.h"
        !            13: 
        !            14: namespace TrueCrypt
        !            15: {
        !            16:        class Hash;
        !            17:        typedef list < shared_ptr <Hash> > HashList;
        !            18: 
        !            19:        class Hash
        !            20:        {
        !            21:        public:
        !            22:                Hash () : Deprecated (false) { }
        !            23:                virtual ~Hash () { }
        !            24: 
        !            25:                static HashList GetAvailableAlgorithms ();
        !            26:                virtual void GetDigest (const BufferPtr &buffer) = 0;
        !            27:                virtual size_t GetBlockSize () const = 0;
        !            28:                virtual size_t GetDigestSize () const = 0;
        !            29:                virtual wstring GetName () const = 0;
        !            30:                virtual shared_ptr <Hash> GetNew () const = 0;
        !            31:                virtual void Init () = 0;
        !            32:                bool IsDeprecated () const { return Deprecated; }
        !            33:                virtual void ProcessData (const ConstBufferPtr &data) = 0;
        !            34:                virtual void ValidateDataParameters (const ConstBufferPtr &data) const;
        !            35:                virtual void ValidateDigestParameters (const BufferPtr &buffer) const;
        !            36: 
        !            37:        protected:
        !            38:                SecureBuffer Context;
        !            39:                bool Deprecated;
        !            40: 
        !            41:        private:
        !            42:                Hash (const Hash &);
        !            43:                Hash &operator= (const Hash &);
        !            44:        };
        !            45: 
        !            46:        // RIPEMD-160
        !            47:        class Ripemd160 : public Hash
        !            48:        {
        !            49:        public:
        !            50:                Ripemd160 ();
        !            51:                virtual ~Ripemd160 () { }
        !            52: 
        !            53:                virtual void GetDigest (const BufferPtr &buffer);
        !            54:                virtual size_t GetBlockSize () const { return 64; }
        !            55:                virtual size_t GetDigestSize () const { return 160 / 8; }
        !            56:                virtual wstring GetName () const { return L"RIPEMD-160"; }
        !            57:                virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Ripemd160); }
        !            58:                virtual void Init ();
        !            59:                virtual void ProcessData (const ConstBufferPtr &data);
        !            60: 
        !            61:        protected:
        !            62: 
        !            63:        private:
        !            64:                Ripemd160 (const Ripemd160 &);
        !            65:                Ripemd160 &operator= (const Ripemd160 &);
        !            66:        };
        !            67: 
        !            68:        // SHA-1
        !            69:        class Sha1 : public Hash
        !            70:        {
        !            71:        public:
        !            72:                Sha1 ();
        !            73:                virtual ~Sha1 () { }
        !            74: 
        !            75:                virtual void GetDigest (const BufferPtr &buffer);
        !            76:                virtual size_t GetBlockSize () const { return 64; }
        !            77:                virtual size_t GetDigestSize () const { return 160 / 8; }
        !            78:                virtual wstring GetName () const { return L"SHA-1"; }
        !            79:                virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha1); }
        !            80:                virtual void Init ();
        !            81:                virtual void ProcessData (const ConstBufferPtr &data);
        !            82: 
        !            83:        protected:
        !            84: 
        !            85:        private:
        !            86:                Sha1 (const Sha1 &);
        !            87:                Sha1 &operator= (const Sha1 &);
        !            88:        };
        !            89: 
        !            90:        // SHA-512
        !            91:        class Sha512 : public Hash
        !            92:        {
        !            93:        public:
        !            94:                Sha512 ();
        !            95:                virtual ~Sha512 () { }
        !            96: 
        !            97:                virtual void GetDigest (const BufferPtr &buffer);
        !            98:                virtual size_t GetBlockSize () const { return 128; }
        !            99:                virtual size_t GetDigestSize () const { return 512 / 8; }
        !           100:                virtual wstring GetName () const { return L"SHA-512"; }
        !           101:                virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha512); }
        !           102:                virtual void Init ();
        !           103:                virtual void ProcessData (const ConstBufferPtr &data);
        !           104: 
        !           105:        protected:
        !           106: 
        !           107:        private:
        !           108:                Sha512 (const Sha512 &);
        !           109:                Sha512 &operator= (const Sha512 &);
        !           110:        };
        !           111: 
        !           112:        // Whirlpool
        !           113:        class Whirlpool : public Hash
        !           114:        {
        !           115:        public:
        !           116:                Whirlpool ();
        !           117:                virtual ~Whirlpool () { }
        !           118: 
        !           119:                virtual void GetDigest (const BufferPtr &buffer);
        !           120:                virtual size_t GetBlockSize () const { return 64; }
        !           121:                virtual size_t GetDigestSize () const { return 512 / 8; }
        !           122:                virtual wstring GetName () const { return L"Whirlpool"; }
        !           123:                virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Whirlpool); }
        !           124:                virtual void Init ();
        !           125:                virtual void ProcessData (const ConstBufferPtr &data);
        !           126: 
        !           127:        protected:
        !           128: 
        !           129:        private:
        !           130:                Whirlpool (const Whirlpool &);
        !           131:                Whirlpool &operator= (const Whirlpool &);
        !           132:        };
        !           133: }
        !           134: 
        !           135: #endif // TC_HEADER_Encryption_Hash

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.