VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/EncryptionAlgorithm.h
blob: e068faaae44ca917bd51ab166c7ffff9fdb17ff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 Derived from source code of TrueCrypt 7.1a, which is
 Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
 by the TrueCrypt License 3.0.

 Modifications and additions to the original source code (contained in this file) 
 and all other portions of this file are Copyright (c) 2013-2015 IDRIX
 and are governed by the Apache License 2.0 the full text of which is
 contained in the file License.txt included in VeraCrypt binary and source
 code distribution packages.
*/

#ifndef TC_HEADER_Encryption_EncryptionAlgorithm
#define TC_HEADER_Encryption_EncryptionAlgorithm

#include "Platform/Platform.h"
#include "Cipher.h"
#include "EncryptionMode.h"

namespace VeraCrypt
{
	class EncryptionAlgorithm;
	typedef list < shared_ptr <EncryptionAlgorithm> > EncryptionAlgorithmList;

	class EncryptionAlgorithm
	{
	public:
		virtual ~EncryptionAlgorithm ();

		virtual void Decrypt (byte *data, uint64 length) const;
		virtual void Decrypt (const BufferPtr &data) const;
		virtual void DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
		virtual void Encrypt (byte *data, uint64 length) const;
		virtual void Encrypt (const BufferPtr &data) const;
		virtual void EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
		static EncryptionAlgorithmList GetAvailableAlgorithms ();
		virtual const CipherList &GetCiphers () const { return Ciphers; }
		virtual shared_ptr <EncryptionAlgorithm> GetNew () const = 0;
		virtual size_t GetMaxBlockSize () const;
		virtual size_t GetMinBlockSize () const;
		static size_t GetLargestKeySize (const EncryptionAlgorithmList &algorithms);
		virtual size_t GetKeySize () const;
		virtual shared_ptr <EncryptionMode> GetMode () const;
		virtual wstring GetName (bool forGuiDisplay = false) const;
		bool IsDeprecated () const { return Deprecated; }
		virtual bool IsModeSupported (const EncryptionMode &mode) const;
		virtual bool IsModeSupported (const shared_ptr <EncryptionMode> mode) const;
		virtual void SetKey (const ConstBufferPtr &key);
		virtual void SetMode (shared_ptr <EncryptionMode> mode);

	protected:
		EncryptionAlgorithm ();

		void ValidateState () const;

		CipherList Ciphers;
		bool Deprecated;
		shared_ptr <EncryptionMode> Mode;
		EncryptionModeList SupportedModes;

	private:
		EncryptionAlgorithm (const EncryptionAlgorithm &);
		EncryptionAlgorithm &operator= (const EncryptionAlgorithm &);
	};

#define TC_ENCRYPTION_ALGORITHM(NAME) \
	class NAME : public EncryptionAlgorithm \
	{ \
	public: \
		NAME (); \
		virtual ~NAME () { } \
\
		virtual shared_ptr <EncryptionAlgorithm> GetNew () const { return shared_ptr <EncryptionAlgorithm> (new NAME()); } \
\
	private: \
		NAME (const NAME &); \
		NAME &operator= (const NAME &); \
	}

	TC_ENCRYPTION_ALGORITHM (AES);
	TC_ENCRYPTION_ALGORITHM (AESTwofish);
	TC_ENCRYPTION_ALGORITHM (AESTwofishSerpent);
	TC_ENCRYPTION_ALGORITHM (Serpent);
	TC_ENCRYPTION_ALGORITHM (SerpentAES);
	TC_ENCRYPTION_ALGORITHM (Twofish);
	TC_ENCRYPTION_ALGORITHM (TwofishSerpent);
	TC_ENCRYPTION_ALGORITHM (SerpentTwofishAES);

#undef TC_ENCRYPTION_ALGORITHM
}

#endif // TC_HEADER_Encryption_EncryptionAlgorithm
wing command: $ make or if you have no wxWidgets shared library installed: $ make WXSTATIC=1 4) If successful, the VeraCrypt executable should be located in the directory 'Main'. By default, a universal executable supporting both graphical and text user interface (through the switch --text) is built. On Linux, a console-only executable, which requires no GUI library, can be built using the 'NOGUI' parameter: $ make NOGUI=1 WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild $ make NOGUI=1 WXSTATIC=1 On MacOSX, building a console-only executable is not supported. Mac OS X specifics: ----------------------------------------------------------- Under MacOSX, the SDK for OSX 10.7 is used by default. To use another version of the SDK (e.i. 10.6), you can export the environment variable VC_OSX_TARGET : $ export VC_OSX_TARGET=10.6 Before building under MacOSX, pkg-config must be installed if not yet available. Get it from http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz and compile using the following commands : $ ./configure --with-internal-glib $ make $ sudo make install After making sure pkg-config is available, download and install OSXFuse from https://osxfuse.github.io/ (MacFUSE compatibility layer must selected) The script build_veracrypt_macosx.sh available under "src/Build" performs the full build of VeraCrypt including the creation of the installer pkg. It expects to find the wxWidgets 3.0.2 sources at the same level as where you put VeraCrypt sources (e.i. if "src" path is "/Users/joe/Projects/VeraCrypt/src" then wxWidgets should be at "/Users/joe/Projects/wxWidgets-wxWidgets-3.0.2") The build process uses Code Signing certificates whose ID is specified in src/Main/Main.make (lines 167 & 169). You'll have to modify these lines to put the ID of your Code Signing certificates or comment them if you don't have one. Because of incompatibility issues with OSXFUSE, the SDK 10.9 generates a VeraCrypt binary that has issues communicating with the OSXFUSE kernel extension. Thus, we recommend to use the SDK 10.8 or earlier for building VeraCrypt. III. FreeBSD and OpenSolaris ============================ FreeBSD and OpenSolaris are not yet supported. IV. Third-Party Developers (Contributors) ========================================= If you intend to implement a feature, please contact us first to make sure: 1) That the feature has not been implemented (we may have already implemented it, but haven't released the code yet). 2) That the feature is acceptable. 3) Whether we need help of third-party developers with implementing the feature. Information on how to contact us can be found at: https://veracrypt.codeplex.com/ V. Legal Information ==================== Copyright Information --------------------- This software as a whole: Copyright (c) 2013-2015 IDRIX. All rights reserved. Portions of this software: Copyright (c) 2003-2012 TrueCrypt Developers Association. All rights reserved. Copyright (c) 1998-2000 Paul Le Roux. All rights reserved. Copyright (c) 1998-2008 Brian Gladman, Worcester, UK. All rights reserved. Copyright (c) 2002-2004 Mark Adler. All rights reserved. For more information, please see the legal notices attached to parts of the source code. Trademark Information --------------------- Any trademarks contained in the source code, binaries, and/or in the documentation, are the sole property of their respective owners. VI. Further Information ======================= http://www.veracrypt.fr