Annotation of truecrypt/volume/volumepassword.h, revision 1.1.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_Password
                     10: #define TC_HEADER_Encryption_Password
                     11: 
                     12: #include "Platform/Platform.h"
                     13: #include "Platform/Serializable.h"
                     14: 
                     15: namespace TrueCrypt
                     16: {
                     17:        class VolumePassword : public Serializable
                     18:        {
                     19:        public:
                     20:                VolumePassword ();
                     21:                VolumePassword (const byte *password, size_t size);   
                     22:                VolumePassword (const char *password, size_t size);
                     23:                VolumePassword (const wchar_t *password, size_t charCount);
                     24:                VolumePassword (const wstring &password);
                     25:                VolumePassword (const VolumePassword &password) { Set (password); }
                     26:                virtual ~VolumePassword ();
                     27: 
                     28:                bool operator== (const VolumePassword &other) const { return ConstBufferPtr (DataPtr(), Size()).IsDataEqual (ConstBufferPtr (other.DataPtr(), other.Size())); }
                     29:                bool operator!= (const VolumePassword &other) const { return !(*this == other); }
                     30:                VolumePassword &operator= (const VolumePassword &password) { Set (password); return *this; }
                     31: 
                     32:                operator BufferPtr () const { return BufferPtr (PasswordBuffer); }
                     33: 
                     34:                void CheckPortability () const;
                     35:                byte *DataPtr () const { return PasswordBuffer; }
                     36:                bool IsEmpty () const { return PasswordSize == 0; }
                     37:                size_t Size () const { return PasswordSize; }
                     38:                void Set (const byte *password, size_t size);
                     39:                void Set (const wchar_t *password, size_t charCount);
                     40:                void Set (const ConstBufferPtr &password);
                     41:                void Set (const VolumePassword &password);
                     42: 
                     43:                TC_SERIALIZABLE (VolumePassword);
                     44: 
                     45:                static const size_t MaxSize = 64;
                     46:                static const size_t WarningSizeThreshold = 12;
                     47: 
                     48:        protected:
                     49:                void AllocateBuffer ();
                     50:                bool IsPortable () const;
                     51: 
                     52:                SecureBuffer PasswordBuffer;
                     53: 
                     54:                size_t PasswordSize;
                     55:                bool Unportable;
                     56:        };
                     57: 
                     58:        struct PasswordException : public Exception
                     59:        {
                     60:        protected:
                     61:                PasswordException () { }
                     62:                PasswordException (const string &message) : Exception (message) { }
                     63:                PasswordException (const string &message, const wstring &subject) : Exception (message, subject) { }
                     64:        };
                     65: 
                     66:        TC_EXCEPTION_DECL (PasswordIncorrect, PasswordException);
                     67:        TC_EXCEPTION_DECL (PasswordKeyfilesIncorrect, PasswordIncorrect);
                     68:        TC_EXCEPTION_DECL (ProtectionPasswordIncorrect, PasswordIncorrect);
                     69:        TC_EXCEPTION_DECL (ProtectionPasswordKeyfilesIncorrect, PasswordIncorrect);
                     70: 
                     71: #define TC_EXCEPTION(NAME) TC_EXCEPTION_DECL(NAME,PasswordException)
                     72: 
                     73: #undef TC_EXCEPTION_SET
                     74: #define TC_EXCEPTION_SET \
                     75:        TC_EXCEPTION_NODECL (PasswordIncorrect); \
                     76:        TC_EXCEPTION_NODECL (PasswordKeyfilesIncorrect); \
                     77:        TC_EXCEPTION_NODECL (ProtectionPasswordIncorrect); \
                     78:        TC_EXCEPTION_NODECL (ProtectionPasswordKeyfilesIncorrect); \
                     79:        TC_EXCEPTION (PasswordEmpty); \
                     80:        TC_EXCEPTION (PasswordTooLong); \
                     81:        TC_EXCEPTION (UnportablePassword);
                     82: 
                     83:        TC_EXCEPTION_SET;
                     84: 
                     85: #undef TC_EXCEPTION
                     86: }
                     87: 
                     88: #endif // TC_HEADER_Encryption_Password

unix.superglobalmegacorp.com

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