/* 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. */ #include "Volume/EncryptionMode.h" #include "Volume/EncryptionModeXTS.h" #include "VolumeLayout.h" #include "Boot/Windows/BootCommon.h" namespace VeraCrypt { VolumeLayout::VolumeLayout () { } VolumeLayout::~VolumeLayout () { } VolumeLayoutList VolumeLayout::GetAvailableLayouts (VolumeType::Enum type) { VolumeLayoutList layouts; layouts.push_back (shared_ptr (new VolumeLayoutV2Normal ())); layouts.push_back (shared_ptr (new VolumeLayoutV1Normal ())); layouts.push_back (shared_ptr (new VolumeLayoutV2Hidden ())); layouts.push_back (shared_ptr (new VolumeLayoutSystemEncryption ())); if (type != VolumeType::Unknown) { VolumeLayoutList l; foreach (shared_ptr vl, layouts) { if (vl->GetType() == type) l.push_back (vl); } layouts = l; } return layouts; } shared_ptr VolumeLayout::GetHeader () { if (Header.get() == nullptr) Header.reset (new VolumeHeader (GetHeaderSize())); return Header; } VolumeLayoutV1Normal::VolumeLayoutV1Normal () { Type = VolumeType::Normal; HeaderOffset = TC_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY; SupportedEncryptionAlgorithms.push_back (shared_ptr (new AES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new TwofishSerpent ())); SupportedEncryptionModes.push_back (shared_ptr (new EncryptionModeXTS ())); } uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const { return HeaderSize; } uint64 VolumeLayoutV1Normal::GetDataSize (uint64 volumeHostSize) const { return volumeHostSize - GetHeaderSize(); } VolumeLayoutV2Normal::VolumeLayoutV2Normal () { Type = VolumeType::Normal; HeaderOffset = TC_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE; BackupHeaderOffset = -TC_VOLUME_HEADER_GROUP_SIZE; SupportedEncryptionAlgorithms.push_back (shared_ptr (new AES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new TwofishSerpent ())); SupportedEncryptionModes.push_back (shared_ptr (new EncryptionModeXTS ())); } uint64 VolumeLayoutV2Normal::GetDataOffset (uint64 volumeHostSize) const { return Header->GetEncryptedAreaStart(); } uint64 VolumeLayoutV2Normal::GetDataSize (uint64 volumeHostSize) const { return Header->GetVolumeDataSize(); } uint64 VolumeLayoutV2Normal::GetMaxDataSize (uint64 volumeSize) const { if (volumeSize < TC_TOTAL_VOLUME_HEADERS_SIZE) return 0; return volumeSize - TC_TOTAL_VOLUME_HEADERS_SIZE; } VolumeLayoutV2Hidden::VolumeLayoutV2Hidden () { Type = VolumeType::Hidden; HeaderOffset = TC_HIDDEN_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE; BackupHeaderOffset = -TC_HIDDEN_VOLUME_HEADER_OFFSET; SupportedEncryptionAlgorithms.push_back (shared_ptr (new AES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr (new
/*
 Copyright (c) 2007-2010 TrueCrypt Developers Association. All rights reserved.

 Governed by the TrueCrypt License 3.0 the full text of which is contained in
 the file License.txt included in TrueCrypt binary and source code distribution
 packages.
*/

import "wtypes.idl";
import "..\Common\Password.h";

[
	uuid(9ACF6176-5FC4-4690-A025-B3306A50EB6A),
	helpstring("VeraCrypt Main UAC Support Library"),
	version(2.4)	// Update ComSetup.cpp when changing version number
]
library TrueCryptMainCom
{
	[
		uuid(C786E27C-2801-482c-B45D-D4357B270A29),
		object,
		oleautomation,
		helpstring("VeraCrypt Main UAC Support Interface")
	]
	interface ITrueCryptMainCom : IUnknown
	{
		void AnalyzeKernelMiniDump (LONG_PTR hwndDlg);
		int BackupVolumeHeader (LONG_PTR hwndDlg, BOOL bRequireConfirmation, BSTR lpszVolume);
		DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output);
		int ChangePassword (BSTR volumePath, Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount, LONG_PTR hWnd);
		DWORD CopyFile (BSTR sourceFile, BSTR destinationFile);
		DWORD DeleteFile (BSTR file);
		BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
		DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone);
		DWORD RegisterFilterDriver (BOOL registerDriver, int filterType);
		DWORD RegisterSystemFavoritesService (BOOL registerService);
		int RestoreVolumeHeader (LONG_PTR hwndDlg, BSTR lpszVolume);
		DWORD SetDriverServiceStartType (DWORD startType);
		DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value);
	};

	[
		uuid(FE8B3B95-C80C-41f7-830F-FBA271C26F7E),
		helpstring("VeraCrypt Main UAC Support Coclass")
	]
	coclass TrueCryptMainCom
	{
		[default] interface ITrueCryptMainCom;
	}
}