Skip to content

Commit

Permalink
TrueCrypt Source Version 6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Truecrypt Foundation authored and FreeApophis committed May 29, 2014
1 parent 9ed1652 commit 322f10f
Show file tree
Hide file tree
Showing 139 changed files with 4,191 additions and 1,423 deletions.
6 changes: 3 additions & 3 deletions Boot/Windows/BootConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved.
Governed by the TrueCrypt License 2.6 the full text of which is contained
in the file License.txt included in TrueCrypt binary and source code
Expand All @@ -16,7 +16,7 @@ bool BootDriveGeometryValid = false;
bool PreventNormalSystemBoot = false;
bool PreventBootMenu = false;
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
uint16 OuterVolumeBackupHeaderCrc;
uint32 OuterVolumeBackupHeaderCrc;

bool BootStarted = false;

Expand Down Expand Up @@ -56,7 +56,7 @@ void ReadBootSectorUserConfiguration ()
DisableScreenOutput();
}

OuterVolumeBackupHeaderCrc = *(uint16 *) (SectorBuffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET);
OuterVolumeBackupHeaderCrc = *(uint32 *) (SectorBuffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET);

ret:
ReleaseSectorBuffer();
Expand Down
4 changes: 2 additions & 2 deletions Boot/Windows/BootConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved.
Governed by the TrueCrypt License 2.6 the full text of which is contained
in the file License.txt included in TrueCrypt binary and source code
Expand All @@ -22,7 +22,7 @@ extern DriveGeometry BootDriveGeometry;
extern bool PreventNormalSystemBoot;
extern bool PreventBootMenu;
extern char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
extern uint16 OuterVolumeBackupHeaderCrc;
extern uint32 OuterVolumeBackupHeaderCrc;

extern bool BootStarted;

Expand Down
25 changes: 15 additions & 10 deletions Boot/Windows/BootDefs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved.
Governed by the TrueCrypt License 2.6 the full text of which is contained
in the file License.txt included in TrueCrypt binary and source code
Expand Down Expand Up @@ -34,16 +34,20 @@

#endif

// Windows Vista boot loader uses memory up to 8000:FFFF, disregarding the BIOS memory map and the amount
// of available memory at 40:0013. Therefore, the code has to be loaded at or above 9000:0000.

// Modifying this value can introduce incompatibility with previous versions
#define TC__BOOT_LOADER_SEGMENT TC_HEX (9000)
#define TC__COM_EXECUTABLE_OFFSET TC_HEX (100)
#define TC__BOOT_LOADER_SEGMENT TC_HEX (9000) // Memory reserved in the segment 8000 is always destroyed by Vista with no SP

#if TC__BOOT_MEMORY_REQUIRED <= 32
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 32 * 1024 / 16)
#else
# define TC__BOOT_LOADER_SEGMENT_LOW (TC__BOOT_LOADER_SEGMENT - 64 * 1024 / 16)
#endif

#define TC__COM_EXECUTABLE_OFFSET TC_HEX (100)

#define TC__BOOT_LOADER_LOWMEM_SEGMENT TC_HEX (2000)
#define TC__BOOT_LOADER_BUFFER_SEGMENT TC_HEX (5000)
#define TC__BOOT_LOADER_ALT_SEGMENT TC_HEX (7000)
#define TC__BOOT_LOADER_LOWMEM_SEGMENT TC_HEX (2000)
#define TC__BOOT_LOADER_BUFFER_SEGMENT TC_HEX (4000)
#define TC__BOOT_LOADER_ALT_SEGMENT TC_HEX (6000)

#define TC__BOOT_LOADER_STACK_TOP (TC_BOOT_MEMORY_REQUIRED * TC_UNSIGNED (1024) - 4)

Expand All @@ -59,7 +63,7 @@
#define TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH 24
#define TC__BOOT_SECTOR_USER_MESSAGE_OFFSET (TC__BOOT_SECTOR_VERSION_OFFSET - TC__BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)

#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE 2
#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE 4
#define TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET (TC__BOOT_SECTOR_USER_MESSAGE_OFFSET - TC__BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE)

#define TC__BOOT_LOADER_DECOMPRESSOR_START_SECTOR 2
Expand Down Expand Up @@ -102,6 +106,7 @@

TC_BOOT_MEMORY_REQUIRED = TC__BOOT_MEMORY_REQUIRED
TC_BOOT_LOADER_SEGMENT = TC__BOOT_LOADER_SEGMENT
TC_BOOT_LOADER_SEGMENT_LOW = TC__BOOT_LOADER_SEGMENT_LOW
TC_COM_EXECUTABLE_OFFSET = TC__COM_EXECUTABLE_OFFSET
TC_BOOT_LOADER_LOWMEM_SEGMENT = TC__BOOT_LOADER_LOWMEM_SEGMENT
TC_BOOT_LOADER_BUFFER_SEGMENT = TC__BOOT_LOADER_BUFFER_SEGMENT
Expand Down
3 changes: 2 additions & 1 deletion Boot/Windows/BootDiskIo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved.
Governed by the TrueCrypt License 2.6 the full text of which is contained
in the file License.txt included in TrueCrypt binary and source code
Expand Down Expand Up @@ -96,6 +96,7 @@ void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba
bool GetActiveAndFollowingPartition (byte drive);
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false);
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false);
bool IsLbaSupported (byte drive);
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs);
void Print (const ChsAddress &chs);
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr);
Expand Down
34 changes: 18 additions & 16 deletions Boot/Windows/BootMain.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved.
Governed by the TrueCrypt License 2.6 the full text of which is contained
in the file License.txt included in TrueCrypt binary and source code
Expand Down Expand Up @@ -30,13 +30,17 @@ static void InitScreen ()
{
ClearScreen();

Print (
const char *title =
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
" TrueCrypt Boot Loader "
#else
" TrueCrypt Rescue Disk "
#endif
VERSION_STRING " Copyright (C) 2008 TrueCrypt Foundation\r\n");
VERSION_STRING;

Print (title);
PrintRepeatedChar (' ', title[26] ? 8 : 9);
Print ("Copyright (C) 2008-2009 TrueCrypt Foundation\r\n");

PrintRepeatedChar ('\xDC', TC_BIOS_MAX_CHARS_PER_LINE);

Expand Down Expand Up @@ -213,13 +217,16 @@ static void ExecuteBootSector (byte drive, byte *sectorBuffer)
__asm
{
cli
mov dl, drive
mov dl, drive // Boot drive
mov dh, 0
xor ax, ax
mov si, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0xffff
mov sp, 0x7c00
sti

jmp cs:addr
}
}
Expand Down Expand Up @@ -297,16 +304,7 @@ static bool CheckMemoryRequirements ()
}

Print (memFree);

Print ("\r\nThis is not a bug in TrueCrypt.\r\n"
"- Disable unneeded components (RAID, AHCI) in BIOS setup menu\r\n"
" (invoked by pressing Del or F2 after turning on your computer)\r\n");
#ifndef TC_WINDOWS_BOOT_AES
Print ("- Use the AES encryption algorithm to reduce memory requirements\r\n");
#endif
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
Print ("- Boot from HDD\r\n");
#endif
PrintEndl();
Print (TC_BOOT_STR_UPGRADE_BIOS);

return false;
Expand Down Expand Up @@ -468,6 +466,7 @@ static void BootMenu ()
// NTFS/FAT partitions must have the boot indicator set to be considered bootable.
if (!partition.Active
&& (*(uint32 *) (SectorBuffer + 3) == 0x5346544e // 'NTFS'
|| *(uint32 *) (SectorBuffer + 3) == 0x41465845 && SectorBuffer[7] == 'T' // 'exFAT'
|| *(uint16 *) (SectorBuffer + 54) == 0x4146 && SectorBuffer[56] == 'T' // 'FAT'
|| *(uint16 *) (SectorBuffer + 82) == 0x4146 && SectorBuffer[84] == 'T'))
{
Expand Down Expand Up @@ -565,8 +564,11 @@ static bool CopyActivePartitionToHiddenVolume (byte drive, byte &exitKey)
AcquireSectorBuffer();

if (ReadSectors (SectorBuffer, PartitionFollowingActive.Drive, PartitionFollowingActive.EndSector - (TC_VOLUME_HEADER_GROUP_SIZE / TC_LB_SIZE - 2), 1) != BiosResultSuccess
|| (uint16) GetCrc32 (SectorBuffer, sizeof (SectorBuffer)) != OuterVolumeBackupHeaderCrc)
|| GetCrc32 (SectorBuffer, sizeof (SectorBuffer)) != OuterVolumeBackupHeaderCrc)
{
if (!IsLbaSupported (PartitionFollowingActive.Drive))
Print ("BIOS: LBA N/A\r\n");

PrintError ("Your BIOS does not support large drives");
Print (TC_BOOT_STR_UPGRADE_BIOS);

Expand Down
43 changes: 25 additions & 18 deletions Boot/Windows/BootSector.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;
; Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
; Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved.
;
; Governed by the TrueCrypt License 2.6 the full text of which is contained
; in the file License.txt included in TrueCrypt binary and source code
Expand All @@ -23,10 +23,14 @@ start:
loader_name_msg:
db ' TrueCrypt Boot Loader', 13, 10, 0
main:
main:
cli
xor ax, ax
mov ds, ax
mov ss, ax
mov sp, 7C00h
sti

; Display boot loader name
test byte ptr [start + TC_BOOT_SECTOR_USER_CONFIG_OFFSET], TC_BOOT_USER_CFG_FLAG_SILENT_MODE
jnz skip_loader_name_msg
Expand All @@ -35,17 +39,23 @@ main:
call print
skip_loader_name_msg:

; Determine boot loader segment
mov ax, TC_BOOT_LOADER_SEGMENT
mov es, ax ; Default boot loader segment

; Check available memory
cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
jge memory_ok
mov ax, TC_BOOT_LOADER_SEGMENT_LOW
cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT_LOW / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
jge memory_ok
; Insufficient memory
mov ax, TC_BOOT_LOADER_LOWMEM_SEGMENT
mov es, ax

memory_ok:
mov es, ax

; Clear BSS section
xor al, al
Expand Down Expand Up @@ -110,8 +120,6 @@ loader_damaged:
call print
lea si, loader_name_msg
call print
lea si, beep_msg
call print
jmp $
checksum_ok:

Expand All @@ -130,24 +138,25 @@ checksum_ok:
push TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE ; Output buffer size
push TC_BOOT_LOADER_DECOMPRESSOR_MEMORY_SIZE + TC_COM_EXECUTABLE_OFFSET ; Output buffer

mov word ptr [cs:decompressor_seg], es
db 9Ah ; call [decompressor_seg]:TC_COM_EXECUTABLE_OFFSET
dw TC_COM_EXECUTABLE_OFFSET
decompressor_seg:
dw 0
push cs
push decompressor_ret
push es
push TC_COM_EXECUTABLE_OFFSET
retf
decompressor_ret:

add sp, 6
pop dx
; Restore boot sector segment
mov bx, cs
mov ds, bx
push cs
pop ds

; Check decompression result
test ax, ax
jz decompression_ok

lea si, decompression_err_msg
lea si, loader_damaged_msg
call print
jmp $
decompression_ok:
Expand Down Expand Up @@ -218,10 +227,8 @@ checksum:

backup_loader_used db 0
beep_msg db 7, 0
disk_error_msg db 'Disk error', 13, 10, 7, 0
loader_damaged_msg db 'Loader damaged! Use Rescue Disk: Repair Options > Restore', 0
decompression_err_msg db 'DC', 0
loader_damaged_msg db 7, 'Loader damaged! Use Rescue Disk: Repair Options > Restore', 0

ORG 7C00h + 508
dw 0, 0AA55h ; Boot sector signature
Expand Down
8 changes: 7 additions & 1 deletion Common/APIDRVR.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
Agreement for Encryption for the Masses'. Modifications and additions to
the original source code (contained in this file) and all other portions of
this file are Copyright (c) 2003-2008 TrueCrypt Foundation and are governed
this file are Copyright (c) 2003-2009 TrueCrypt Foundation and are governed
by the TrueCrypt License 2.6 the full text of which is contained in the
file License.txt included in TrueCrypt binary and source code distribution
packages. */
Expand Down Expand Up @@ -75,6 +75,7 @@ typedef struct
int nReturnCode; /* Return code back from driver */
BOOL FilesystemDirty;
BOOL VolumeMountedReadOnlyAfterAccessDenied;
BOOL VolumeMountedReadOnlyAfterDeviceWriteProtected;

short wszVolume[TC_MAX_PATH]; /* Volume to be mounted */
Password VolumePassword; /* User password */
Expand Down Expand Up @@ -124,6 +125,7 @@ typedef struct
int pkcs5Iterations;
BOOL hiddenVolume;
BOOL readOnly;
BOOL removable;
#if 0
unsigned __int64 volumeCreationTime; // Deprecated in v6.0
unsigned __int64 headerCreationTime; // Deprecated in v6.0
Expand Down Expand Up @@ -168,6 +170,9 @@ typedef struct
{
short wszFileName[TC_MAX_PATH]; // Volume to be "open tested"
BOOL bDetectTCBootLoader; // Whether the driver is to determine if the first sector contains a portion of the TrueCrypt Boot Loader
BOOL TCBootLoaderDetected;
BOOL DetectFilesystem;
BOOL FilesystemDetected;
} OPEN_TEST_STRUCT;


Expand Down Expand Up @@ -220,6 +225,7 @@ typedef struct
BootEncryptionSetupMode SetupMode;
WipeAlgorithmId WipeAlgorithm;
BOOL ZeroUnreadableSectors;
BOOL DiscardUnreadableEncryptedSectors;
} BootEncryptionSetupRequest;


Expand Down
Loading

0 comments on commit 322f10f

Please sign in to comment.