"Fossies" - the Fresh Open Source Software Archive

Member "src/Core/CoreBase.h" (10 Oct 2018, 6213 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 "CoreBase.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_Core_CoreBase
   14 #define TC_HEADER_Core_CoreBase
   15 
   16 #include "Platform/Platform.h"
   17 #include "Platform/Functor.h"
   18 #include "Platform/User.h"
   19 #include "Common/Crypto.h"
   20 #include "Volume/Keyfile.h"
   21 #include "Volume/VolumeInfo.h"
   22 #include "Volume/Volume.h"
   23 #include "Volume/VolumePassword.h"
   24 #include "CoreException.h"
   25 #include "HostDevice.h"
   26 #include "MountOptions.h"
   27 #include "VolumeCreator.h"
   28 
   29 namespace VeraCrypt
   30 {
   31     class CoreBase
   32     {
   33     public:
   34         virtual ~CoreBase ();
   35 
   36         virtual void ChangePassword (shared_ptr <Volume> openVolume, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const;
   37         virtual void ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const;
   38         virtual void CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair = false) const = 0;
   39         virtual void CoalesceSlotNumberAndMountPoint (MountOptions &options) const;
   40         virtual void CreateKeyfile (const FilePath &keyfilePath) const;
   41         virtual void DismountFilesystem (const DirectoryPath &mountPoint, bool force) const = 0;
   42         virtual shared_ptr <VolumeInfo> DismountVolume (shared_ptr <VolumeInfo> mountedVolume, bool ignoreOpenFiles = false, bool syncVolumeInfo = false) = 0;
   43         virtual bool FilesystemSupportsLargeFiles (const FilePath &filePath) const = 0;
   44         virtual DirectoryPath GetDeviceMountPoint (const DevicePath &devicePath) const = 0;
   45         virtual uint32 GetDeviceSectorSize (const DevicePath &devicePath) const = 0;
   46         virtual uint64 GetDeviceSize (const DevicePath &devicePath) const = 0;
   47         virtual VolumeSlotNumber GetFirstFreeSlotNumber (VolumeSlotNumber startFrom = 0) const;
   48         virtual VolumeSlotNumber GetFirstSlotNumber () const { return 1; }
   49         virtual VolumeSlotNumber GetLastSlotNumber () const { return 64; }
   50         virtual HostDeviceList GetHostDevices (bool pathListOnly = false) const = 0;
   51         virtual FilePath GetApplicationExecutablePath () const { return ApplicationExecutablePath; }
   52         virtual uint64 GetMaxHiddenVolumeSize (shared_ptr <Volume> outerVolume) const;
   53         virtual int GetOSMajorVersion () const = 0;
   54         virtual int GetOSMinorVersion () const = 0;
   55         virtual shared_ptr <VolumeInfo> GetMountedVolume (const VolumePath &volumePath) const;
   56         virtual shared_ptr <VolumeInfo> GetMountedVolume (VolumeSlotNumber slot) const;
   57         virtual VolumeInfoList GetMountedVolumes (const VolumePath &volumePath = VolumePath()) const = 0;
   58         virtual bool HasAdminPrivileges () const = 0;
   59         virtual void Init () { }
   60         virtual bool IsDeviceChangeInProgress () const { return DeviceChangeInProgress; }
   61         virtual bool IsDevicePresent (const DevicePath &device) const = 0;
   62         virtual bool IsInPortableMode () const = 0;
   63         virtual bool IsMountPointAvailable (const DirectoryPath &mountPoint) const = 0;
   64         virtual bool IsOSVersion (int major, int minor) const = 0;
   65         virtual bool IsOSVersionLower (int major, int minor) const = 0;
   66         virtual bool IsPasswordCacheEmpty () const = 0;
   67         virtual bool IsSlotNumberAvailable (VolumeSlotNumber slotNumber) const;
   68         virtual bool IsSlotNumberValid (VolumeSlotNumber slotNumber) const { return slotNumber >= GetFirstSlotNumber() && slotNumber <= GetLastSlotNumber(); }
   69         virtual bool IsVolumeMounted (const VolumePath &volumePath) const;
   70         virtual VolumeSlotNumber MountPointToSlotNumber (const DirectoryPath &mountPoint) const = 0;
   71         virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) = 0;
   72         virtual shared_ptr <Volume> OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr<Pkcs5Kdf> Kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false) const;
   73         virtual void RandomizeEncryptionAlgorithmKey (shared_ptr <EncryptionAlgorithm> encryptionAlgorithm) const;
   74         virtual void ReEncryptVolumeHeaderWithNewSalt (const BufferPtr &newHeaderBuffer, shared_ptr <VolumeHeader> header, shared_ptr <VolumePassword> password, int pim, shared_ptr <KeyfileList> keyfiles) const;
   75         virtual void SetAdminPasswordCallback (shared_ptr <GetStringFunctor> functor) { }
   76         virtual void SetApplicationExecutablePath (const FilePath &path) { ApplicationExecutablePath = path; }
   77         virtual void SetFileOwner (const FilesystemPath &path, const UserId &owner) const = 0;
   78         virtual DirectoryPath SlotNumberToMountPoint (VolumeSlotNumber slotNumber) const = 0;
   79         virtual void WipePasswordCache () const = 0;
   80 
   81         Event VolumeDismountedEvent;
   82         Event VolumeMountedEvent;
   83         Event WarningEvent;
   84 
   85     protected:
   86         CoreBase ();
   87 
   88         bool DeviceChangeInProgress;
   89         FilePath ApplicationExecutablePath;
   90 
   91     private:
   92         CoreBase (const CoreBase &);
   93         CoreBase &operator= (const CoreBase &);
   94     };
   95 
   96     struct VolumeEventArgs : EventArgs
   97     {
   98         VolumeEventArgs (shared_ptr <VolumeInfo> volume) : mVolume (volume) { }
   99         shared_ptr <VolumeInfo> mVolume;
  100     };
  101 }
  102 
  103 #endif // TC_HEADER_Core_CoreBase