"Fossies" - the Fresh Open Source Software Archive

Member "src/Core/VolumeCreator.h" (10 Oct 2018, 2791 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "VolumeCreator.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #ifndef TC_HEADER_Volume_VolumeCreator
   14 #define TC_HEADER_Volume_VolumeCreator
   15 
   16 #include "Platform/Platform.h"
   17 #include "Volume/Volume.h"
   18 #include "RandomNumberGenerator.h"
   19 
   20 namespace VeraCrypt
   21 {
   22 
   23     struct VolumeCreationOptions
   24     {
   25         VolumePath Path;
   26         VolumeType::Enum Type;
   27         uint64 Size;
   28         shared_ptr <VolumePassword> Password;
   29         int Pim;
   30         shared_ptr <KeyfileList> Keyfiles;
   31         shared_ptr <Pkcs5Kdf> VolumeHeaderKdf;
   32         shared_ptr <EncryptionAlgorithm> EA;
   33         bool Quick;
   34 
   35         struct FilesystemType
   36         {
   37             enum Enum
   38             {
   39                 Unknown = 0,
   40                 None,
   41                 FAT,
   42                 exFAT,
   43                 NTFS,
   44                 Ext2,
   45                 Ext3,
   46                 Ext4,
   47                 MacOsExt,
   48                 UFS
   49             };
   50 
   51             static Enum GetPlatformNative ()
   52             {
   53 #ifdef TC_WINDOWS
   54                 return VolumeCreationOptions::FilesystemType::NTFS;
   55 #elif defined (TC_LINUX)
   56                 return VolumeCreationOptions::FilesystemType::Ext3;
   57 #elif defined (TC_MACOSX)
   58                 return VolumeCreationOptions::FilesystemType::MacOsExt;
   59 #elif defined (TC_FREEBSD) || defined (TC_SOLARIS)
   60                 return VolumeCreationOptions::FilesystemType::UFS;
   61 #else
   62                 return VolumeCreationOptions::FilesystemType::FAT;
   63 #endif
   64             }
   65         };
   66 
   67         FilesystemType::Enum Filesystem;
   68         uint32 FilesystemClusterSize;
   69         uint32 SectorSize;
   70     };
   71 
   72     class VolumeCreator
   73     {
   74     public:
   75 
   76         struct ProgressInfo
   77         {
   78             bool CreationInProgress;
   79             uint64 TotalSize;
   80             uint64 SizeDone;
   81         };
   82 
   83         struct KeyInfo
   84         {
   85             ConstBufferPtr HeaderKey;
   86             ConstBufferPtr MasterKey;
   87         };
   88 
   89         VolumeCreator ();
   90         virtual ~VolumeCreator ();
   91 
   92         void Abort ();
   93         void CheckResult ();
   94         void CreateVolume (shared_ptr <VolumeCreationOptions> options);
   95         KeyInfo GetKeyInfo () const;
   96         ProgressInfo GetProgressInfo ();
   97 
   98     protected:
   99         void CreationThread ();
  100 
  101         volatile bool AbortRequested;
  102         volatile bool CreationInProgress;
  103         uint64 DataStart;
  104         uint64 HostSize;
  105         shared_ptr <VolumeCreationOptions> Options;
  106         shared_ptr <Exception> ThreadException;
  107         uint64 VolumeSize;
  108 
  109         shared_ptr <VolumeLayout> Layout;
  110         shared_ptr <File> VolumeFile;
  111         SharedVal <uint64> SizeDone;
  112         uint64 WriteOffset;
  113         ProgressInfo mProgressInfo;
  114 
  115         SecureBuffer HeaderKey;
  116         shared_ptr <VolumePassword> PasswordKey;
  117         SecureBuffer MasterKey;
  118 
  119     private:
  120         VolumeCreator (const VolumeCreator &);
  121         VolumeCreator &operator= (const VolumeCreator &);
  122     };
  123 }
  124 
  125 #endif // TC_HEADER_Volume_VolumeCreator