VeraCrypt

Documentation >> Technical Details >> Modes of Operation

Modes of Operation


The mode of operation used by VeraCrypt for encrypted partitions, drives, and virtual volumes is XTS.

XTS mode is in fact XEX mode [12], which was designed by Phillip Rogaway in 2003, with a minor modification (XEX mode uses a single key for two different purposes, whereas XTS mode uses two independent keys).

In 2010, XTS mode was approved by NIST for protecting the confidentiality of data on storage devices [24]. In 2007, it was also approved by the IEEE for cryptographic protection of data on block-oriented storage devices (IEEE 1619).
 

Description of XTS mode:

Ci = EK1(Pi ^ (EK2(n) ai)) ^ (EK2(n) ai)
Where:
   denotes multiplication of two polynomials over the binary field GF(2) modulo x128+x7+x2+x+1

K1

is the encryption key (256-bit for each supported cipher; i.e, AES, Serpent, and Twofish)

K2

is the secondary key (256-bit for each supported cipher; i.e, AES, Serpent, and Twofish)

i

is the cipher block index within a data unit;   for the first cipher block within a data unit, i = 0

n

is the data unit index within the scope of K1;   for the first data unit, n = 0

a

is a primitive element of Galois Field (2128) that corresponds to polynomial x (i.e., 2)

Note: The remaining symbols are defined in the section Notation.

The size of each data unit is always 512 bytes (regardless of the sector size).
For further information pertaining to XTS mode, see e.g. [12] and [24].
Next Section >>
hlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 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-2017 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_Main_StringFormatter
#define TC_HEADER_Main_StringFormatter

#include "System.h"
#include "Main.h"

namespace VeraCrypt
{
	class StringFormatterArg
	{
	public:
		StringFormatterArg () : Empty (true) { }

		StringFormatterArg (const char c) :			Empty (false) { string s; s += c; StringArg = StringConverter::ToWide (s); }
		StringFormatterArg (const wchar_t c) :		Empty (false), Referenced (false), StringArg (c) { }
		StringFormatterArg (const char *str) :		Empty (false), Referenced (false), StringArg (StringConverter::ToWide (str)) { }
		StringFormatterArg (const wchar_t *str) :	Empty (false), Referenced (false), StringArg (str) { }
		StringFormatterArg (const string &str) :	Empty (false), Referenced (false), StringArg (StringConverter::ToWide (str)) { }
		StringFormatterArg (const wstring &str) :	Empty (false), Referenced (false), StringArg (str) { }
		StringFormatterArg (const wxString &str) :	Empty (false), Referenced (false), StringArg (str) { }
		StringFormatterArg (int32 number) :			Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { }
		StringFormatterArg (uint32 number) :		Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { }
		StringFormatterArg (int64 number) :			Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { }
		StringFormatterArg (uint64 number) :		Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { }

		operator wxString () { Referenced = true; return StringArg; }

		bool IsEmpty () const { return Empty; }
		bool WasReferenced() const { return Referenced; }

	protected:
		bool Empty;
		bool Referenced;
		wxString StringArg;
	};

	class StringFormatter
	{
	public:
		StringFormatter (const wxString &format, StringFormatterArg arg0 = StringFormatterArg(), StringFormatterArg arg1 = StringFormatterArg(), StringFormatterArg arg2 = StringFormatterArg(), StringFormatterArg arg3 = StringFormatterArg(), StringFormatterArg arg4 = StringFormatterArg(), StringFormatterArg arg5 = StringFormatterArg(), StringFormatterArg arg6 = StringFormatterArg(), StringFormatterArg arg7 = StringFormatterArg(), StringFormatterArg arg8 = StringFormatterArg(), StringFormatterArg arg9 = StringFormatterArg());
		virtual ~StringFormatter ();

#if (__cplusplus >= 201103L)
		explicit 
#endif
		operator wstring () const { return wstring (FormattedString); }
		operator wxString () const { return FormattedString; }
		operator StringFormatterArg () const { return FormattedString; }

	protected:
		wxString FormattedString;

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

#endif // TC_HEADER_Main_StringFormatter