"Fossies" - the Fresh Open Source Software Archive

Member "src/Volume/EncryptionMode.h" (10 Oct 2018, 2560 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 "EncryptionMode.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_Encryption_EncryptionMode
   14 #define TC_HEADER_Encryption_EncryptionMode
   15 
   16 #include "Platform/Platform.h"
   17 #include "Common/Crypto.h"
   18 #include "Cipher.h"
   19 
   20 namespace VeraCrypt
   21 {
   22     class EncryptionMode;
   23     typedef list < shared_ptr <EncryptionMode> > EncryptionModeList;
   24 
   25     class EncryptionMode
   26     {
   27     public:
   28         virtual ~EncryptionMode ();
   29 
   30         virtual void Decrypt (byte *data, uint64 length) const = 0;
   31         virtual void DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
   32         virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0;
   33         virtual void Encrypt (byte *data, uint64 length) const = 0;
   34         virtual void EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
   35         virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0;
   36         static EncryptionModeList GetAvailableModes ();
   37         virtual const SecureBuffer &GetKey () const { throw NotApplicable (SRC_POS); }
   38         virtual size_t GetKeySize () const = 0;
   39         virtual wstring GetName () const = 0;
   40         virtual shared_ptr <EncryptionMode> GetNew () const = 0;
   41         virtual uint64 GetSectorOffset () const { return SectorOffset; }
   42         virtual bool IsKeySet () const { return KeySet; }
   43         virtual void SetKey (const ConstBufferPtr &key) = 0;
   44         virtual void SetCiphers (const CipherList &ciphers) { Ciphers = ciphers; }
   45         virtual void SetSectorOffset (int64 offset) { SectorOffset = offset; }
   46 
   47     protected:
   48         EncryptionMode ();
   49 
   50         virtual void ValidateState () const;
   51         void ValidateParameters (byte *data, uint64 length) const;
   52         virtual void ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const;
   53 
   54         static const size_t EncryptionDataUnitSize = ENCRYPTION_DATA_UNIT_SIZE;
   55 
   56         CipherList Ciphers;
   57         bool KeySet;
   58         uint64 SectorOffset;
   59 
   60     private:
   61         EncryptionMode (const EncryptionMode &);
   62         EncryptionMode &operator= (const EncryptionMode &);
   63     };
   64 }
   65 
   66 #endif // TC_HEADER_Encryption_EncryptionMode