diff options
Diffstat (limited to 'src/Boot')
105 files changed, 290 insertions, 519 deletions
diff --git a/src/Boot/EFI/DcsBml.efi b/src/Boot/EFI/DcsBml.efi Binary files differdeleted file mode 100644 index 8775ce4c..00000000 --- a/src/Boot/EFI/DcsBml.efi +++ /dev/null diff --git a/src/Boot/EFI/DcsBml32.efi b/src/Boot/EFI/DcsBml32.efi Binary files differdeleted file mode 100644 index 8b3df11d..00000000 --- a/src/Boot/EFI/DcsBml32.efi +++ /dev/null diff --git a/src/Boot/EFI/DcsBoot.efi b/src/Boot/EFI/DcsBoot.efi Binary files differindex d6703d23..02884df9 100644 --- a/src/Boot/EFI/DcsBoot.efi +++ b/src/Boot/EFI/DcsBoot.efi diff --git a/src/Boot/EFI/DcsBoot32.efi b/src/Boot/EFI/DcsBoot32.efi Binary files differdeleted file mode 100644 index 93806f24..00000000 --- a/src/Boot/EFI/DcsBoot32.efi +++ /dev/null diff --git a/src/Boot/EFI/DcsCfg.efi b/src/Boot/EFI/DcsCfg.efi Binary files differindex 30490532..82dc446a 100644 --- a/src/Boot/EFI/DcsCfg.efi +++ b/src/Boot/EFI/DcsCfg.efi diff --git a/src/Boot/EFI/DcsCfg32.efi b/src/Boot/EFI/DcsCfg32.efi Binary files differdeleted file mode 100644 index 4fd3dcae..00000000 --- a/src/Boot/EFI/DcsCfg32.efi +++ /dev/null diff --git a/src/Boot/EFI/DcsInfo.efi b/src/Boot/EFI/DcsInfo.efi Binary files differnew file mode 100644 index 00000000..15810f4d --- /dev/null +++ b/src/Boot/EFI/DcsInfo.efi diff --git a/src/Boot/EFI/DcsInt.efi b/src/Boot/EFI/DcsInt.efi Binary files differindex 1f22ce10..3816327a 100644 --- a/src/Boot/EFI/DcsInt.efi +++ b/src/Boot/EFI/DcsInt.efi diff --git a/src/Boot/EFI/DcsInt32.efi b/src/Boot/EFI/DcsInt32.efi Binary files differdeleted file mode 100644 index f0a58235..00000000 --- a/src/Boot/EFI/DcsInt32.efi +++ /dev/null diff --git a/src/Boot/EFI/DcsRe.efi b/src/Boot/EFI/DcsRe.efi Binary files differindex 2208851d..599f7026 100644 --- a/src/Boot/EFI/DcsRe.efi +++ b/src/Boot/EFI/DcsRe.efi diff --git a/src/Boot/EFI/DcsRe32.efi b/src/Boot/EFI/DcsRe32.efi Binary files differdeleted file mode 100644 index 100a3d8b..00000000 --- a/src/Boot/EFI/DcsRe32.efi +++ /dev/null diff --git a/src/Boot/EFI/LegacySpeaker.efi b/src/Boot/EFI/LegacySpeaker.efi Binary files differindex 5f49a76a..034c760b 100644 --- a/src/Boot/EFI/LegacySpeaker.efi +++ b/src/Boot/EFI/LegacySpeaker.efi diff --git a/src/Boot/EFI/LegacySpeaker32.efi b/src/Boot/EFI/LegacySpeaker32.efi Binary files differdeleted file mode 100644 index e92ec411..00000000 --- a/src/Boot/EFI/LegacySpeaker32.efi +++ /dev/null diff --git a/src/Boot/EFI/Readme.txt b/src/Boot/EFI/Readme.txt index f396b324..ed732bc2 100644 --- a/src/Boot/EFI/Readme.txt +++ b/src/Boot/EFI/Readme.txt @@ -1,35 +1,16 @@ The source code for VeraCrypt EFI bootloader files is available at: https://github.com/veracrypt/VeraCrypt-DCS -Use tag "VeraCrypt_1.18" to extract the sources that were used when building VeraCrypt 1.18. -VeraCrypt-DCS uses EDK II as its UEFI development environement. +VeraCrypt-DCS uses EDK II as its UEFI development environment. VeraCrypt-DCS is licensed under LGPL: https://github.com/veracrypt/VeraCrypt-DCS/blob/master/LICENSE Here the steps to build VeraCrypt-DCS (Visual Studio 2010 SP1 should be installed) - * Clone EDK: git clone https://github.com/tianocore/tianocore.github.io.git edk2 + * Clone EDK: git clone https://github.com/tianocore/edk2.git edk2 * Switch to UDK2015 branche: git checkout UDK2015 - * Clone VeraCrypt-DCS as DcsPkg inside edk2 folder: git clone https://github.com/veracrypt/VeraCrypt-DCS.git DcsPkg + * Clone VeraCrypt-DCS as DcsPkg inside edk2 folder: git clone https://github.com/veracrypt/VeraCrypt-DCS.git DcsPkg * Switch to VeraCrypt_1.18 branche: git checkout VeraCrypt_1.18 * Setup EDK by typing edksetup.bat at the root of folder edk2 * change directoty to DcsPkg and then type setenv.bat. * change directory to DcsPkg\Library\VeraCryptLib and then type mklinks_src.bat: you will be asked to provide the path to VeraCrypt src folder. * change directory to DcsPkg and then type dcs_bld.bat X64Rel * After the build is finished, EFI bootloader files will be present at edk2\Build\DcsPkg\RELEASE_VS2010x86\X64 - -Secure Boot: -In order to allow VeraCrypt EFI bootloader to run when EFI Secure Boot is enabled, VeraCrypt EFI bootloader files are signed -using a custom key whose public part can be loader into Secure Boot to allow the verification of VeraCrypt EFI files. - -below are instruction to update Secure Boot configuration: -1. Enter BIOS configuration -2. Switch Secure boot to setup mode (or custom mode). It deletes PK (platform certificate) and allows to load DCS platform key. -3. Boot Windows -4. execute from admin command prompt - powershell -File sb_set_siglists.ps1 -It sets in PK (platform key) - DCS_platform -It sets in KEK (key exchange key) - DCS_key_exchange -It sets in db - DCS_sign MicWinProPCA2011_2011-10-19 MicCorUEFCA2011_2011-06-27 - -All DCS modules are protected by DCS_sign. -All Windows modules are protected by MicWinProPCA2011_2011-10-19 -All SHIM(linux) modules are protected by MicCorUEFCA2011_2011-06-27
\ No newline at end of file diff --git a/src/Boot/EFI/certs/DCS_key_exchange.crt b/src/Boot/EFI/certs/DCS_key_exchange.crt Binary files differdeleted file mode 100644 index 80bc7ca4..00000000 --- a/src/Boot/EFI/certs/DCS_key_exchange.crt +++ /dev/null diff --git a/src/Boot/EFI/certs/DCS_platform.crt b/src/Boot/EFI/certs/DCS_platform.crt Binary files differdeleted file mode 100644 index a7cf8ce9..00000000 --- a/src/Boot/EFI/certs/DCS_platform.crt +++ /dev/null diff --git a/src/Boot/EFI/certs/DCS_sign.crt b/src/Boot/EFI/certs/DCS_sign.crt Binary files differdeleted file mode 100644 index f0538dbb..00000000 --- a/src/Boot/EFI/certs/DCS_sign.crt +++ /dev/null diff --git a/src/Boot/EFI/certs/MicCorUEFCA2011_2011-06-27.crt b/src/Boot/EFI/certs/MicCorUEFCA2011_2011-06-27.crt Binary files differdeleted file mode 100644 index 9aa6ac6c..00000000 --- a/src/Boot/EFI/certs/MicCorUEFCA2011_2011-06-27.crt +++ /dev/null diff --git a/src/Boot/EFI/certs/MicWinProPCA2011_2011-10-19.crt b/src/Boot/EFI/certs/MicWinProPCA2011_2011-10-19.crt Binary files differdeleted file mode 100644 index a6d001c2..00000000 --- a/src/Boot/EFI/certs/MicWinProPCA2011_2011-10-19.crt +++ /dev/null diff --git a/src/Boot/EFI/certs/Readme.txt b/src/Boot/EFI/certs/Readme.txt deleted file mode 100644 index 6663a5d1..00000000 --- a/src/Boot/EFI/certs/Readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -Apart from DCS certificates, there are two public DB entries - one for Windows and one for the UEFI Certificate Authority (CA). -Windows DB: http://www.microsoft.com/pkiops/certs/MicWinProPCA2011_2011-10-19.crt -UEFI DB: http://www.microsoft.com/pkiops/certs/MicCorUEFCA2011_2011-06-27.crt diff --git a/src/Boot/EFI/sb_set_siglists.ps1 b/src/Boot/EFI/sb_set_siglists.ps1 deleted file mode 100644 index 5f664f21..00000000 --- a/src/Boot/EFI/sb_set_siglists.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -Set-ExecutionPolicy Bypass -Force -Import-Module secureboot - -Set-SecureBootUEFI -Name PK -Time 2015-09-11 -Content $null -Set-SecureBootUEFI -Name KEK -Time 2015-09-11 -Content $null -Set-SecureBootUEFI -Name db -Time 2015-09-11 -Content $null -Set-SecureBootUEFI -Name dbx -Time 2015-09-11 -Content $null - -Write-Host "Setting self-signed PK..." -Set-SecureBootUEFI -Time 2016-08-08T00:00:00Z -ContentFilePath siglists\DCS_platform_SigList.bin -SignedFilePath siglists\DCS_platform_SigList_Serialization.bin.p7 -Name PK - -Write-Host "Setting PK-signed KEK..." -Set-SecureBootUEFI -Time 2016-08-08T00:00:00Z -ContentFilePath siglists\DCS_key_exchange_SigList.bin -SignedFilePath siglists\DCS_key_exchange_SigList_Serialization.bin.p7 -Name KEK - -Write-Host "Setting KEK-signed DCS cert in db..." -Set-SecureBootUEFI -Time 2016-08-08T00:00:00Z -ContentFilePath siglists\DCS_sign_SigList.bin -SignedFilePath siglists\DCS_sign_SigList_Serialization.bin.p7 -Name db - -Write-Host "Setting KEK-signed MS cert in db..." -Set-SecureBootUEFI -Time 2016-08-08T00:00:00Z -ContentFilePath siglists\MicWinProPCA2011_2011-10-19_SigList.bin -SignedFilePath siglists\MicWinProPCA2011_2011-10-19_SigList_Serialization.bin.p7 -Name db -AppendWrite:$true - -Write-Host "Setting KEK-signed MS UEFI cert in db..." -Set-SecureBootUEFI -Time 2016-08-08T00:00:00Z -ContentFilePath siglists\MicCorUEFCA2011_2011-06-27_SigList.bin -SignedFilePath siglists\MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin.p7 -Name db -AppendWrite:$true diff --git a/src/Boot/EFI/siglists/DCS_key_exchange_SigList.bin b/src/Boot/EFI/siglists/DCS_key_exchange_SigList.bin Binary files differdeleted file mode 100644 index 62f5cc6f..00000000 --- a/src/Boot/EFI/siglists/DCS_key_exchange_SigList.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_key_exchange_SigList_Serialization.bin b/src/Boot/EFI/siglists/DCS_key_exchange_SigList_Serialization.bin Binary files differdeleted file mode 100644 index 1cffcf0c..00000000 --- a/src/Boot/EFI/siglists/DCS_key_exchange_SigList_Serialization.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_key_exchange_SigList_Serialization.bin.p7 b/src/Boot/EFI/siglists/DCS_key_exchange_SigList_Serialization.bin.p7 Binary files differdeleted file mode 100644 index 1e9d29ae..00000000 --- a/src/Boot/EFI/siglists/DCS_key_exchange_SigList_Serialization.bin.p7 +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_platform_SigList.bin b/src/Boot/EFI/siglists/DCS_platform_SigList.bin Binary files differdeleted file mode 100644 index 0b6d7e12..00000000 --- a/src/Boot/EFI/siglists/DCS_platform_SigList.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_platform_SigList_Serialization.bin b/src/Boot/EFI/siglists/DCS_platform_SigList_Serialization.bin Binary files differdeleted file mode 100644 index e8fbf79a..00000000 --- a/src/Boot/EFI/siglists/DCS_platform_SigList_Serialization.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_platform_SigList_Serialization.bin.p7 b/src/Boot/EFI/siglists/DCS_platform_SigList_Serialization.bin.p7 Binary files differdeleted file mode 100644 index 19cb86db..00000000 --- a/src/Boot/EFI/siglists/DCS_platform_SigList_Serialization.bin.p7 +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_sign_SigList.bin b/src/Boot/EFI/siglists/DCS_sign_SigList.bin Binary files differdeleted file mode 100644 index 9a3f568b..00000000 --- a/src/Boot/EFI/siglists/DCS_sign_SigList.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_sign_SigList_Serialization.bin b/src/Boot/EFI/siglists/DCS_sign_SigList_Serialization.bin Binary files differdeleted file mode 100644 index de58d77d..00000000 --- a/src/Boot/EFI/siglists/DCS_sign_SigList_Serialization.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/DCS_sign_SigList_Serialization.bin.p7 b/src/Boot/EFI/siglists/DCS_sign_SigList_Serialization.bin.p7 Binary files differdeleted file mode 100644 index 01753a8b..00000000 --- a/src/Boot/EFI/siglists/DCS_sign_SigList_Serialization.bin.p7 +++ /dev/null diff --git a/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList.bin b/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList.bin Binary files differdeleted file mode 100644 index 413ccab9..00000000 --- a/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin b/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin Binary files differdeleted file mode 100644 index 735d9626..00000000 --- a/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin.p7 b/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin.p7 Binary files differdeleted file mode 100644 index ed8cefda..00000000 --- a/src/Boot/EFI/siglists/MicCorUEFCA2011_2011-06-27_SigList_Serialization.bin.p7 +++ /dev/null diff --git a/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList.bin b/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList.bin Binary files differdeleted file mode 100644 index ac542ca0..00000000 --- a/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList_Serialization.bin b/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList_Serialization.bin Binary files differdeleted file mode 100644 index 9138dae9..00000000 --- a/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList_Serialization.bin +++ /dev/null diff --git a/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList_Serialization.bin.p7 b/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList_Serialization.bin.p7 Binary files differdeleted file mode 100644 index b08c60a3..00000000 --- a/src/Boot/EFI/siglists/MicWinProPCA2011_2011-10-19_SigList_Serialization.bin.p7 +++ /dev/null diff --git a/src/Boot/Windows/Bios.h b/src/Boot/Windows/Bios.h index e6f9ec89..0282fad7 100644 --- a/src/Boot/Windows/Bios.h +++ b/src/Boot/Windows/Bios.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -23,10 +23,11 @@ enum { BiosResultSuccess = 0x00, - BiosResultInvalidFunction = 0x01 + BiosResultInvalidFunction = 0x01, + BiosResultTimeout = 0x80 }; -typedef byte BiosResult; +typedef uint8 BiosResult; #endif // TC_HEADER_Boot_Bios diff --git a/src/Boot/Windows/Boot.vcproj b/src/Boot/Windows/Boot.vcproj deleted file mode 100644 index c73b099e..00000000 --- a/src/Boot/Windows/Boot.vcproj +++ /dev/null @@ -1,250 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9.00" - Name="Boot" - ProjectGUID="{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}" - RootNamespace="Boot" - Keyword="MakeFileProj" - TargetFrameworkVersion="131072" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Release|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="0" - > - <Tool - Name="VCNMakeTool" - BuildCommandLine="md Release 2>NUL:
nmake.exe /nologo RELEASE=1

md Release_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_PRF=SHA2

md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

md Release_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES SINGLE_PRF=SHA2

md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

md Release_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT SINGLE_PRF=SHA2

md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH

md Release_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH SINGLE_PRF=SHA2

md Release_Camellia 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA

md Release_Camellia_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA SINGLE_PRF=SHA2

md Rescue 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1

md Rescue_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1

md Rescue_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1

md Rescue_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1

md Rescue_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1 SINGLE_PRF=SHA2

md Rescue_Camellia 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA RESCUE_DISK=1

md Rescue_Camellia_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA RESCUE_DISK=1 SINGLE_PRF=SHA2" - ReBuildCommandLine="del /q /s Release >NUL:
md Release 2>NUL:
nmake.exe /nologo RELEASE=1

del /q /s Release_SHA2 >NUL:
md Release_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_PRF=SHA2

del /q /s Release_AES >NUL:
md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

del /q /s Release_AES_SHA2 >NUL:
md Release_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES SINGLE_PRF=SHA2

del /q /s Release_Serpent >NUL:
md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

del /q /s Release_Serpent_SHA2 >NUL:
md Release_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT SINGLE_PRF=SHA2

del /q /s Release_Twofish >NUL:
md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH

del /q /s Release_Twofish_SHA2 >NUL:
md Release_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH SINGLE_PRF=SHA2

del /q /s Release_Camellia >NUL:
md Release_Camellia 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA

del /q /s Release_Camellia_SHA2 >NUL:
md Release_Camellia_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA SINGLE_PRF=SHA2

del /q /s Rescue >NUL:
md Rescue 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1

del /q /s Rescue_SHA2 >NUL:
md Rescue_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_AES >NUL:
md Rescue_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1

del /q /s Rescue_AES_SHA2 >NUL:
md Rescue_AES_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Serpent >NUL:
md Rescue_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1

del /q /s Rescue_Serpent_SHA2 >NUL:
md Rescue_Serpent_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Twofish >NUL:
md Rescue_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1

del /q /s Rescue_Twofish_SHA2 >NUL:
md Rescue_Twofish_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH RESCUE_DISK=1 SINGLE_PRF=SHA2

del /q /s Rescue_Camellia >NUL:
md Rescue_Camellia 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA RESCUE_DISK=1

del /q /s Rescue_Camellia_SHA2 >NUL:
md Rescue_Camellia_SHA2 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=CAMELLIA RESCUE_DISK=1 SINGLE_PRF=SHA2" - CleanCommandLine="del /q /s Release Release_AES Release_Serpent Release_Twofish Release_Camellia Rescue Rescue_AES Rescue_Serpent Rescue_Twofish Rescue_Camellia >NUL:
del /q /s Release_SHA2 Release_AES_SHA2 Release_Serpent_SHA2 Release_Twofish_SHA2 Release_Camellia_SHA2 Rescue_SHA2 Rescue_AES_SHA2 Rescue_Serpent_SHA2 Rescue_Twofish_SHA2 Rescue_Camellia_SHA2 >NUL:
" - Output="Release\BootLoader.com" - PreprocessorDefinitions="WIN32;NDEBUG" - IncludeSearchPath=""$(SolutionDir)";"$(SolutionDir)\Common";"$(SolutionDir)\Crypto";"$(MSVC16_ROOT)\Include"" - ForcedIncludes="" - AssemblySearchPath="" - ForcedUsingAssemblies="" - CompileAsManaged="" - /> - </Configuration> - <Configuration - Name="Release Loader|Win32" - OutputDirectory="$(ConfigurationName)" - IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="0" - > - <Tool - Name="VCNMakeTool" - BuildCommandLine="md Release 2>NUL:
nmake.exe /nologo RELEASE=1

md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH" - ReBuildCommandLine="del /q /s Release >NUL:
md Release 2>NUL:
nmake.exe /nologo RELEASE=1

del /q /s Release_AES >NUL:
md Release_AES 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=AES

del /q /s Release_Serpent >NUL:
md Release_Serpent 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=SERPENT

del /q /s Release_Twofish >NUL:
md Release_Twofish 2>NUL:
nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH" - CleanCommandLine="del /q /s Release Release_AES Release_Serpent Release_Twofish >NUL:" - Output="Release\BootLoader.com" - PreprocessorDefinitions="WIN32;NDEBUG" - IncludeSearchPath=""$(SolutionDir)";"$(SolutionDir)\Common";"$(SolutionDir)\Crypto";"$(MSVC16_ROOT)\Include"" - ForcedIncludes="" - AssemblySearchPath="" - ForcedUsingAssemblies="" - CompileAsManaged="" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\BootConfig.cpp" - > - </File> - <File - RelativePath=".\BootConsoleIo.cpp" - > - </File> - <File - RelativePath=".\BootCrt.asm" - > - </File> - <File - RelativePath=".\BootDebug.cpp" - > - </File> - <File - RelativePath=".\BootDiskIo.cpp" - > - </File> - <File - RelativePath=".\BootEncryptedIo.cpp" - > - </File> - <File - RelativePath=".\BootMain.cpp" - > - </File> - <File - RelativePath=".\BootMemory.cpp" - > - </File> - <File - RelativePath=".\BootSector.asm" - > - </File> - <File - RelativePath=".\Decompressor.c" - > - </File> - <File - RelativePath=".\IntFilter.cpp" - > - </File> - <File - RelativePath=".\Platform.cpp" - > - </File> - <Filter - Name="Common" - > - <File - RelativePath="..\..\Common\Crc.c" - > - </File> - <File - RelativePath="..\..\Common\Crypto.c" - > - </File> - <File - RelativePath="..\..\Common\Endian.c" - > - </File> - <File - RelativePath="..\..\Common\Pkcs5.c" - > - </File> - <File - RelativePath="..\..\Common\Volumes.c" - > - </File> - <File - RelativePath="..\..\Common\Xts.c" - > - </File> - </Filter> - <Filter - Name="Crypto" - > - <File - RelativePath="..\..\Crypto\Aes_hw_cpu.asm" - > - </File> - <File - RelativePath="..\..\Crypto\AesSmall.c" - > - </File> - <File - RelativePath="..\..\Crypto\AesSmall_x86.asm" - > - </File> - <File - RelativePath="..\..\Crypto\CamelliaSmall.c" - > - </File> - <File - RelativePath="..\..\Crypto\Rmd160.c" - > - </File> - <File - RelativePath="..\..\Crypto\Serpent.c" - > - </File> - <File - RelativePath="..\..\Crypto\Sha2Small.c" - > - </File> - <File - RelativePath="..\..\Crypto\Twofish.c" - > - </File> - </Filter> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath=".\Bios.h" - > - </File> - <File - RelativePath=".\BootCommon.h" - > - </File> - <File - RelativePath=".\BootConfig.h" - > - </File> - <File - RelativePath=".\BootConsoleIo.h" - > - </File> - <File - RelativePath=".\BootDebug.h" - > - </File> - <File - RelativePath=".\BootDefs.h" - > - </File> - <File - RelativePath=".\BootDiskIo.h" - > - </File> - <File - RelativePath=".\BootEncryptedIo.h" - > - </File> - <File - RelativePath=".\BootMain.h" - > - </File> - <File - RelativePath=".\BootMemory.h" - > - </File> - <File - RelativePath=".\BootStrings.h" - > - </File> - <File - RelativePath=".\IntFilter.h" - > - </File> - <File - RelativePath=".\Platform.h" - > - </File> - </Filter> - <Filter - Name="Build Files" - > - <File - RelativePath=".\Makefile" - > - </File> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/src/Boot/Windows/Boot.vcxproj b/src/Boot/Windows/Boot.vcxproj index 68d5d270..b9a04d80 100644 --- a/src/Boot/Windows/Boot.vcxproj +++ b/src/Boot/Windows/Boot.vcxproj @@ -221,8 +221,9 @@ nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH</NMakeReBuildCommandLine> </PropertyGroup> <ItemDefinitionGroup> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="..\..\Crypto\blake2s-ref.c" /> <ClCompile Include="BootConfig.cpp" /> <ClCompile Include="BootConsoleIo.cpp" /> <ClCompile Include="BootDebug.cpp" /> <ClCompile Include="BootDiskIo.cpp" /> @@ -239,9 +240,8 @@ nmake.exe /nologo RELEASE=1 SINGLE_CIPHER=TWOFISH</NMakeReBuildCommandLine> <ClCompile Include="..\..\Common\Volumes.c" /> <ClCompile Include="..\..\Common\Xts.c" /> <ClCompile Include="..\..\Crypto\AesSmall.c" /> <ClCompile Include="..\..\Crypto\CamelliaSmall.c" /> - <ClCompile Include="..\..\Crypto\Rmd160.c" /> <ClCompile Include="..\..\Crypto\Serpent.c" /> <ClCompile Include="..\..\Crypto\Sha2Small.c" /> <ClCompile Include="..\..\Crypto\Twofish.c" /> </ItemGroup> diff --git a/src/Boot/Windows/Boot.vcxproj.filters b/src/Boot/Windows/Boot.vcxproj.filters index 1a60ac81..24d23894 100644 --- a/src/Boot/Windows/Boot.vcxproj.filters +++ b/src/Boot/Windows/Boot.vcxproj.filters @@ -73,11 +73,8 @@ </ClCompile> <ClCompile Include="..\..\Crypto\CamelliaSmall.c"> <Filter>Source Files\Crypto</Filter> </ClCompile> - <ClCompile Include="..\..\Crypto\Rmd160.c"> - <Filter>Source Files\Crypto</Filter> - </ClCompile> <ClCompile Include="..\..\Crypto\Serpent.c"> <Filter>Source Files\Crypto</Filter> </ClCompile> <ClCompile Include="..\..\Crypto\Sha2Small.c"> @@ -85,8 +82,11 @@ </ClCompile> <ClCompile Include="..\..\Crypto\Twofish.c"> <Filter>Source Files\Crypto</Filter> </ClCompile> + <ClCompile Include="..\..\Crypto\blake2s-ref.c"> + <Filter>Source Files\Crypto</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <None Include="BootCrt.asm"> <Filter>Source Files</Filter> diff --git a/src/Boot/Windows/BootCommon.h b/src/Boot/Windows/BootCommon.h index 5d099a21..45a1a650 100644 --- a/src/Boot/Windows/BootCommon.h +++ b/src/Boot/Windows/BootCommon.h @@ -2,10 +2,10 @@ 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-2016 IDRIX + 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. */ @@ -16,9 +16,9 @@ #include "Common/Password.h" #include "BootDefs.h" // The user will be advised to upgrade the rescue disk if upgrading from the following or any previous version -#define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0118 +#define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0125 #define TC_BOOT_LOADER_AREA_SIZE (TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS) #define TC_BOOT_VOLUME_HEADER_SECTOR (TC_BOOT_LOADER_AREA_SECTOR_COUNT - 1) @@ -42,9 +42,9 @@ #pragma pack (1) typedef struct { - byte Flags; + uint8 Flags; } BootSectorConfiguration; // Modifying this value can introduce incompatibility with previous versions @@ -57,9 +57,9 @@ typedef struct uint16 BootLoaderVersion; uint16 CryptoInfoOffset; uint16 CryptoInfoLength; uint32 HeaderSaltCrc32; - Password BootPassword; + PasswordLegacy BootPassword; uint64 HiddenSystemPartitionStart; uint64 DecoySystemPartitionStart; uint32 Flags; uint32 BootDriveSignature; @@ -81,8 +81,12 @@ typedef struct #if defined(_MSC_VER) && !defined(TC_WINDOWS_BOOT) #define DCS_DISK_ENTRY_LIST_HEADER_SIGN SIGNATURE_64 ('D','C','S','D','E','L','S','T') +#ifndef CSTATIC_ASSERT +#define CSTATIC_ASSERT(b, name) typedef int StaticAssertFailed##name[b ? 1 : -1]; +#endif + #define DE_IDX_CRYPTOHEADER 0 #define DE_IDX_LIST 1 #define DE_IDX_DISKID 2 #define DE_IDX_MAINGPTHDR 3 @@ -92,9 +96,9 @@ typedef struct #define DE_IDX_EXEC 7 #define DE_IDX_PWDCACHE 8 #define DE_IDX_RND 9 #define DE_IDX_TOTAL 10 -static_assert(DE_IDX_TOTAL <= 15, "DE_IDX_TOTAL too big"); +CSTATIC_ASSERT(DE_IDX_TOTAL <= 15, DE_IDX_TOTAL_too_big); enum DcsDiskEntryTypes { DE_Unused = 0, DE_Sectors, @@ -115,9 +119,9 @@ typedef struct _SECREGION_BOOT_PARAMS { typedef struct { uint32 Data1; uint16 Data2; uint16 Data3; - byte Data4[8]; + uint8 Data4[8]; } DCS_GUID; // DE types typedef struct _DCS_DISK_ENTRY_SECTORS { @@ -126,56 +130,56 @@ typedef struct _DCS_DISK_ENTRY_SECTORS { uint64 Reserved; uint64 Start; // Start on disk (byte) uint64 Length; // length on disk (byte) } DCS_DISK_ENTRY_SECTORS; -static_assert(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, "Wrong size DCS_DISK_ENTRY_SECTORS"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, Wrong_size_DCS_DISK_ENTRY_SECTORS); typedef struct _DCS_DISK_ENTRY_PARAMS { uint32 Type; uint32 Offset; uint64 Reserved[2]; uint64 Length; // size of data } DCS_DISK_ENTRY_PARAMS; -static_assert(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, "Wrong size DCS_DISK_ENTRY_PARAMS"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, Wrong_size_DCS_DISK_ENTRY_PARAMS); typedef struct _DCS_DISK_ENTRY_DISKID { uint32 Type; uint32 MbrID; uint64 ReservedDiskId; DCS_GUID GptID; } DCS_DISK_ENTRY_DISKID; -static_assert(sizeof(DCS_DISK_ENTRY_DISKID) == 32, "Wrong size DCS_DISK_ENTRY_DISKID"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_DISKID) == 32, Wrong_size_DCS_DISK_ENTRY_DISKID); #pragma warning(disable:4201) typedef struct _DCS_DISK_ENTRY { union { struct { uint32 Type; uint32 Offset; - byte reserved[16]; + uint8 reserved[16]; uint64 Length; // size of structure at Offset }; DCS_DISK_ENTRY_SECTORS Sectors; DCS_DISK_ENTRY_DISKID DiskId; DCS_DISK_ENTRY_PARAMS Prm; }; } DCS_DISK_ENTRY; #pragma warning(default:4201) -static_assert(sizeof(DCS_DISK_ENTRY) == 32, "Wrong size DCS_DISK_ENTRY"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY) == 32, Wrong_size_DCS_DISK_ENTRY); // Static compile time checks field offsets #ifndef FIELD_OFFSET #define FIELD_OFFSET(t, f) ((UINTN)(&((t*)0)->f)) #endif -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), "Wrong Type offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), "Wrong Type offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), "Wrong Type offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), "Wrong Length offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), "Wrong Length offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), "Wrong Offset offset"); -static_assert(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), "Wrong Offset offset"); - -// DE type specific data +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), Wrong_Type_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), Wrong_Type_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), Wrong_Type_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), Wrong_Length_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), Wrong_Length_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), Wrong_Offset_offset); +CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), Wrong_Offset_offset); + +// DE type specific data // DE List typedef struct _DCS_DISK_ENTRY_LIST { // EFI_TABLE_HEADER uint64 Signature; @@ -188,26 +192,26 @@ typedef struct _DCS_DISK_ENTRY_LIST { uint32 DataSize; // DCS_DISK_ENTRY DE[15]; } DCS_DISK_ENTRY_LIST; -static_assert(sizeof(DCS_DISK_ENTRY_LIST) == 512, "Wrong size DCS_DISK_ENTRY_LIST"); +CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_LIST) == 512, Wrong_size_DCS_DISK_ENTRY_LIST); typedef struct _DCS_DEP_EXEC { DCS_GUID ExecPartGuid; uint16 ExecCmd[248]; } DCS_DEP_EXEC; -static_assert(sizeof(DCS_DEP_EXEC) == 512, "Wrong size DCS_DEP_EXEC"); +CSTATIC_ASSERT(sizeof(DCS_DEP_EXEC) == 512, Wrong_size_DCS_DEP_EXEC); #define DCS_DEP_PWD_CACHE_SIGN SIGNATURE_64 ('P','W','D','C','A','C','H','E') typedef struct _DCS_DEP_PWD_CACHE { uint64 Sign; uint32 CRC; uint32 Count; - Password Pwd[4]; + PasswordLegacy Pwd[4]; int32 Pim[4]; - byte pad[512 - 8 - 4 - 4 - (sizeof(Password) + 4) * 4]; + uint8 pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4]; } DCS_DEP_PWD_CACHE; -static_assert(sizeof(DCS_DEP_PWD_CACHE) == 512, "Wrong size DCS_DEP_PWD_CACHE"); +CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE); #pragma pack() #endif // #if !defined(TC_WINDOWS_BOOT) diff --git a/src/Boot/Windows/BootConfig.cpp b/src/Boot/Windows/BootConfig.cpp index 3e41d610..948dfd93 100644 --- a/src/Boot/Windows/BootConfig.cpp +++ b/src/Boot/Windows/BootConfig.cpp @@ -3,20 +3,20 @@ 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-2016 IDRIX + 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. */ #include "BootConfig.h" -byte BootSectorFlags; +uint8 BootSectorFlags; -byte BootLoaderDrive; -byte BootDrive; +uint8 BootLoaderDrive; +uint8 BootDrive; bool BootDriveGeometryValid = false; bool PreventNormalSystemBoot = false; bool PreventBootMenu = false; char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1]; @@ -38,9 +38,9 @@ uint64 HiddenVolumeStartSector; #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE void ReadBootSectorUserConfiguration () { - byte userConfig; + uint8 userConfig; AcquireSectorBuffer(); if (ReadWriteMBR (false, BootLoaderDrive, true) != BiosResultSuccess) @@ -82,18 +82,33 @@ ret: ReleaseSectorBuffer(); } -BiosResult UpdateBootSectorConfiguration (byte drive) +BiosResult UpdateBootSectorConfiguration (uint8 drive) { - AcquireSectorBuffer(); + uint64 mbrSector; + mbrSector.HighPart = 0; + mbrSector.LowPart = 0; + AcquireSectorBuffer(); +/* BiosResult result = ReadWriteMBR (false, drive); if (result != BiosResultSuccess) goto ret; SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags; result = ReadWriteMBR (true, drive); +*/ + + BiosResult result = ReadWriteSectors (false, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, mbrSector, 8, false); + if (result != BiosResultSuccess) + goto ret; + + CopyMemory (TC_BOOT_LOADER_BUFFER_SEGMENT, 0, SectorBuffer, TC_LB_SIZE); + SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags; + CopyMemory (SectorBuffer, TC_BOOT_LOADER_BUFFER_SEGMENT,0, TC_LB_SIZE); + + result = ReadWriteSectors (true, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, mbrSector, 8, false); ret: ReleaseSectorBuffer(); return result; diff --git a/src/Boot/Windows/BootConfig.h b/src/Boot/Windows/BootConfig.h index 428d713c..5338109f 100644 --- a/src/Boot/Windows/BootConfig.h +++ b/src/Boot/Windows/BootConfig.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -16,12 +16,12 @@ #include "Crypto.h" #include "Platform.h" #include "BootDiskIo.h" -extern byte BootSectorFlags; +extern uint8 BootSectorFlags; -extern byte BootLoaderDrive; -extern byte BootDrive; +extern uint8 BootLoaderDrive; +extern uint8 BootDrive; extern bool BootDriveGeometryValid; extern DriveGeometry BootDriveGeometry; extern bool PreventNormalSystemBoot; extern bool PreventBootMenu; @@ -40,7 +40,7 @@ extern uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stor extern uint64 HiddenVolumeStartSector; void ReadBootSectorUserConfiguration (); -BiosResult UpdateBootSectorConfiguration (byte drive); +BiosResult UpdateBootSectorConfiguration (uint8 drive); #endif // TC_HEADER_Boot_BootConfig diff --git a/src/Boot/Windows/BootConsoleIo.cpp b/src/Boot/Windows/BootConsoleIo.cpp index 60305ea1..046f580b 100644 --- a/src/Boot/Windows/BootConsoleIo.cpp +++ b/src/Boot/Windows/BootConsoleIo.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -18,19 +18,21 @@ static int ScreenOutputDisabled = 0; +#if defined(TC_TRACE_INT13) || !defined(TC_WINDOWS_BOOT_RESCUE_DISK_MODE) void DisableScreenOutput () { ++ScreenOutputDisabled; } +#endif - +#ifdef TC_TRACE_INT13 void EnableScreenOutput () { --ScreenOutputDisabled; } - +#endif void PrintChar (char c) { #ifdef TC_BOOT_TRACING_ENABLED @@ -98,19 +100,19 @@ void Print (const uint64 &number) PrintHex (number); } -void PrintHex (byte b) +void PrintHex (uint8 b) { PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4)); PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF)); } void PrintHex (uint16 data) { - PrintHex (byte (data >> 8)); - PrintHex (byte (data)); + PrintHex (uint8 (data >> 8)); + PrintHex (uint8 (data)); } void PrintHex (uint32 data) @@ -216,11 +218,11 @@ void PrintErrorNoEndl (const char *message) Beep(); } -byte GetShiftFlags () +uint8 GetShiftFlags () { - byte flags; + uint8 flags; __asm { mov ah, 2 int 0x16 @@ -230,21 +232,42 @@ byte GetShiftFlags () return flags; } -byte GetKeyboardChar () +uint8 GetKeyboardChar () { return GetKeyboardChar (nullptr); } +/* +inline void Sleep () +{ + __asm + { + mov al, 0 + mov ah, 0x86 + // Sleep for 250 milliseconds = 250 000 microseconds = 0x0003D090 + mov cx, 0x0003 + mov dx, 0xD090 + int 0x15 + } +} +*/ -byte GetKeyboardChar (byte *scanCode) +uint8 GetKeyboardChar (uint8 *scanCode) { // Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer) - while (!IsKeyboardCharAvailable()); + while (!IsKeyboardCharAvailable()) + { + // reduce CPU usage by halting CPU until the next external interrupt is fired + __asm + { + hlt + } + } - byte asciiCode; - byte scan; + uint8 asciiCode; + uint8 scan; __asm { mov ah, 0 int 0x16 @@ -278,9 +301,9 @@ bool IsKeyboardCharAvailable () bool EscKeyPressed () { if (IsKeyboardCharAvailable ()) { - byte keyScanCode; + uint8 keyScanCode; GetKeyboardChar (&keyScanCode); return keyScanCode == TC_BIOS_KEY_ESC; } @@ -322,10 +345,10 @@ bool IsDigit (char c) int GetString (char *buffer, size_t bufferSize) { - byte c; - byte scanCode; + uint8 c; + uint8 scanCode; size_t pos = 0; while (pos < bufferSize) { diff --git a/src/Boot/Windows/BootConsoleIo.h b/src/Boot/Windows/BootConsoleIo.h index 52a054fe..cf10d2c6 100644 --- a/src/Boot/Windows/BootConsoleIo.h +++ b/src/Boot/Windows/BootConsoleIo.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -44,11 +44,11 @@ void ClearBiosKeystrokeBuffer (); void ClearScreen (); void DisableScreenOutput (); void EnableScreenOutput (); bool EscKeyPressed (); -byte GetKeyboardChar (); -byte GetKeyboardChar (byte *scanCode); -byte GetShiftFlags (); +uint8 GetKeyboardChar (); +uint8 GetKeyboardChar (uint8 *scanCode); +uint8 GetShiftFlags (); int GetString (char *buffer, size_t bufferSize); void InitVideoMode (); bool IsKeyboardCharAvailable (); bool IsPrintable (char c); @@ -63,9 +63,9 @@ void PrintEndl (); void PrintEndl (int cnt); void PrintRepeatedChar (char c, int n); void PrintError (const char *message); void PrintErrorNoEndl (const char *message); -void PrintHex (byte b); +void PrintHex (uint8 b); void PrintHex (uint16 data); void PrintHex (uint32 data); void PrintHex (const uint64 &data); diff --git a/src/Boot/Windows/BootCrt.asm b/src/Boot/Windows/BootCrt.asm index 92ac1563..046c93af 100644 --- a/src/Boot/Windows/BootCrt.asm +++ b/src/Boot/Windows/BootCrt.asm @@ -3,9 +3,9 @@ ; 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-2016 IDRIX +; 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. ; diff --git a/src/Boot/Windows/BootDebug.cpp b/src/Boot/Windows/BootDebug.cpp index dd0863a0..b490f5e8 100644 --- a/src/Boot/Windows/BootDebug.cpp +++ b/src/Boot/Windows/BootDebug.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -33,9 +33,9 @@ void InitDebugPort () } } -void WriteDebugPort (byte dataByte) +void WriteDebugPort (uint8 dataByte) { __asm { mov al, dataByte @@ -81,9 +81,9 @@ void PrintVal (const char *message, const uint64 &value, bool newLine, bool hex) PrintEndl(); } -void PrintHexDump (byte *mem, size_t size, uint16 *memSegment) +void PrintHexDump (uint8 *mem, size_t size, uint16 *memSegment) { const size_t width = 16; for (size_t pos = 0; pos < size; ) { @@ -91,9 +91,9 @@ void PrintHexDump (byte *mem, size_t size, uint16 *memSegment) { size_t i; for (i = 0; i < width && pos < size; ++i) { - byte dataByte; + uint8 dataByte; if (memSegment) { __asm { @@ -133,9 +133,9 @@ void PrintHexDump (byte *mem, size_t size, uint16 *memSegment) void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size) { - PrintHexDump ((byte *) memOffset, size, &memSegment); + PrintHexDump ((uint8 *) memOffset, size, &memSegment); } #endif // TC_BOOT_DEBUG_ENABLED diff --git a/src/Boot/Windows/BootDebug.h b/src/Boot/Windows/BootDebug.h index e7ae4134..35fce41f 100644 --- a/src/Boot/Windows/BootDebug.h +++ b/src/Boot/Windows/BootDebug.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -50,10 +50,10 @@ #endif void InitDebugPort (); void InitStackChecker (); -void WriteDebugPort (byte dataByte); -void PrintHexDump (byte *mem, size_t size, uint16 *memSegment = nullptr); +void WriteDebugPort (uint8 dataByte); +void PrintHexDump (uint8 *mem, size_t size, uint16 *memSegment = nullptr); void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size); void PrintVal (const char *message, const uint32 value, bool newLine = true, bool hex = false); void PrintVal (const char *message, const uint64 &value, bool newLine = true, bool hex = false); diff --git a/src/Boot/Windows/BootDefs.h b/src/Boot/Windows/BootDefs.h index 3db227fd..3d65f0a0 100644 --- a/src/Boot/Windows/BootDefs.h +++ b/src/Boot/Windows/BootDefs.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -204,7 +204,8 @@ TC_HIDDEN_OS_CREATION_PHASE_WIPED = TC__HIDDEN_OS_CREATION_PHASE_WIPED #define EFI_BOOTARGS_REGIONS_HIGH \ 0x100000, 0x200000, 0x300000, 0x400000, 0x500000, 0x600000, 0x700000, 0x800000, \ 0x900000, 0xA00000, 0xB00000, 0xC00000, 0xD00000, 0xE00000, 0xF00000, 0x1000000 -#define EFI_BOOTARGS_REGIONS EFI_BOOTARGS_REGIONS_LOW, EFI_BOOTARGS_REGIONS_HIGH +#define EFI_BOOTARGS_REGIONS_DEFAULT EFI_BOOTARGS_REGIONS_LOW, EFI_BOOTARGS_REGIONS_HIGH +#define EFI_BOOTARGS_REGIONS_EFI EFI_BOOTARGS_REGIONS_HIGH, EFI_BOOTARGS_REGIONS_LOW #endif // TC_HEADER_Boot_BootDefs diff --git a/src/Boot/Windows/BootDiskIo.cpp b/src/Boot/Windows/BootDiskIo.cpp index 15d6f711..ddd00e1c 100644 --- a/src/Boot/Windows/BootDiskIo.cpp +++ b/src/Boot/Windows/BootDiskIo.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -18,9 +18,9 @@ #include "BootDiskIo.h" #include "BootStrings.h" -byte SectorBuffer[TC_LB_SIZE]; +uint8 SectorBuffer[TC_LB_SIZE]; #ifdef TC_BOOT_DEBUG_ENABLED static bool SectorBufferInUse = false; @@ -40,11 +40,11 @@ void ReleaseSectorBuffer () #endif -bool IsLbaSupported (byte drive) +bool IsLbaSupported (uint8 drive) { - static byte CachedDrive = TC_INVALID_BIOS_DRIVE; + static uint8 CachedDrive = TC_INVALID_BIOS_DRIVE; static bool CachedStatus; uint16 result = 0; if (CachedDrive == drive) @@ -67,9 +67,9 @@ ret: return CachedStatus; } -void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs) +void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs) { PrintEndl(); Print (write ? "Write" : "Read"); Print (" error:"); Print (error); @@ -104,23 +104,23 @@ void Print (const ChsAddress &chs) void PrintSectorCountInMB (const uint64 §orCount) { - Print (sectorCount >> (TC_LB_SIZE_BIT_SHIFT_DIVISOR + 2)); Print (" MB "); + Print (sectorCount >> (TC_LB_SIZE_BIT_SHIFT_DIVISOR + 2)); Print (" MiB "); } -BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { CheckStack(); - byte cylinderLow = (byte) chs.Cylinder; - byte sector = chs.Sector; - sector |= byte (chs.Cylinder >> 2) & 0xc0; - byte function = write ? 0x03 : 0x02; + uint8 cylinderLow = (uint8) chs.Cylinder; + uint8 sector = chs.Sector; + sector |= uint8 (chs.Cylinder >> 2) & 0xc0; + uint8 function = write ? 0x03 : 0x02; BiosResult result; - byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; + uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; do { result = BiosResultSuccess; @@ -156,30 +156,32 @@ BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffs return result; } +#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE -BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { uint16 codeSeg; __asm mov codeSeg, cs return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent); } - -BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent); } - -BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +#if 0 +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent); } +#endif +#endif -static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { CheckStack(); if (!IsLbaSupported (drive)) @@ -199,12 +201,12 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d dapPacket.Reserved = 0; dapPacket.SectorCount = sectorCount; dapPacket.Sector = sector; - byte function = write ? 0x43 : 0x42; + uint8 function = write ? 0x43 : 0x42; BiosResult result; - byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; + uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; do { result = BiosResultSuccess; @@ -234,30 +236,30 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d return result; } -static BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { BiosLbaPacket dapPacket; dapPacket.Buffer = (uint32) buffer; return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent); } -BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { BiosLbaPacket dapPacket; dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset; return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent); } -BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent); } -BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { BiosResult result; uint16 codeSeg; __asm mov codeSeg, cs @@ -271,19 +273,19 @@ BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 s return result; } -BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent); } -BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent) +BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent) { CheckStack(); - byte maxCylinderLow, maxHead, maxSector; + uint8 maxCylinderLow, maxHead, maxSector; BiosResult result; __asm { push es @@ -326,11 +328,11 @@ void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs) { - chs.Sector = (byte) ((lba.LowPart % geometry.Sectors) + 1); + chs.Sector = (uint8) ((lba.LowPart % geometry.Sectors) + 1); uint32 ch = lba.LowPart / geometry.Sectors; - chs.Head = (byte) (ch % geometry.Heads); + chs.Head = (uint8) (ch % geometry.Heads); chs.Cylinder = (uint16) (ch / geometry.Heads); } @@ -346,9 +348,9 @@ void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition partition.Type = partEntry.Type; } -BiosResult ReadWriteMBR (bool write, byte drive, bool silent) +BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent) { uint64 mbrSector; mbrSector.HighPart = 0; mbrSector.LowPart = 0; @@ -359,9 +361,9 @@ BiosResult ReadWriteMBR (bool write, byte drive, bool silent) return ReadSectors (SectorBuffer, drive, mbrSector, 1, silent); // Uses alternative segment } -BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent) +BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent) { Partition *followingPartition; Partition tmpPartition; @@ -416,9 +418,9 @@ BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t par uint64 extStartLBA = partition.StartSector; MBR *extMbr = (MBR *) SectorBuffer; while (partitionArrayPos < partitionArrayCapacity && - (result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess + (result = ReadSectors ((uint8 *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess && extMbr->Signature == 0xaa55) { if (extMbr->Partitions[0].SectorCountLBA > 0) { @@ -475,9 +477,9 @@ BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t par return result; } -bool GetActivePartition (byte drive) +bool GetActivePartition (uint8 drive) { size_t partCount; if (GetDrivePartitions (drive, &ActivePartition, 1, partCount, true) != BiosResultSuccess || partCount < 1) diff --git a/src/Boot/Windows/BootDiskIo.h b/src/Boot/Windows/BootDiskIo.h index ad9d1437..0b92aa29 100644 --- a/src/Boot/Windows/BootDiskIo.h +++ b/src/Boot/Windows/BootDiskIo.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -27,35 +27,35 @@ enum #pragma pack(1) struct PartitionEntryMBR { - byte BootIndicator; + uint8 BootIndicator; - byte StartHead; - byte StartCylSector; - byte StartCylinder; + uint8 StartHead; + uint8 StartCylSector; + uint8 StartCylinder; - byte Type; + uint8 Type; - byte EndHead; - byte EndSector; - byte EndCylinder; + uint8 EndHead; + uint8 EndSector; + uint8 EndCylinder; uint32 StartLBA; uint32 SectorCountLBA; }; struct MBR { - byte Code[446]; + uint8 Code[446]; PartitionEntryMBR Partitions[4]; uint16 Signature; }; struct BiosLbaPacket { - byte Size; - byte Reserved; + uint8 Size; + uint8 Reserved; uint16 SectorCount; uint32 Buffer; uint64 Sector; }; @@ -65,29 +65,29 @@ struct BiosLbaPacket struct ChsAddress { uint16 Cylinder; - byte Head; - byte Sector; + uint8 Head; + uint8 Sector; }; struct Partition { - byte Number; - byte Drive; + uint8 Number; + uint8 Drive; bool Active; uint64 EndSector; bool Primary; uint64 SectorCount; uint64 StartSector; - byte Type; + uint8 Type; }; struct DriveGeometry { uint16 Cylinders; - byte Heads; - byte Sectors; + uint8 Heads; + uint8 Sectors; }; #ifdef TC_BOOT_DEBUG_ENABLED @@ -98,23 +98,24 @@ void ReleaseSectorBuffer (); # define ReleaseSectorBuffer() #endif void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba); -bool GetActivePartition (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); +bool GetActivePartition (uint8 drive); +BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent = false); +BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false); +bool IsLbaSupported (uint8 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); +void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs = nullptr); void PrintSectorCountInMB (const uint64 §orCount); -BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false); -BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); -BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); -BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); -BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent); -BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); -BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); - -extern byte SectorBuffer[TC_LB_SIZE]; +BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent = false); +BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent = false); +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent = false); +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent = false); +BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent); +BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent); +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent = false); +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent = false); + +extern uint8 SectorBuffer[TC_LB_SIZE]; #endif // TC_HEADER_Boot_BootDiskIo diff --git a/src/Boot/Windows/BootEncryptedIo.cpp b/src/Boot/Windows/BootEncryptedIo.cpp index 63fd0f47..24fbbbd0 100644 --- a/src/Boot/Windows/BootEncryptedIo.cpp +++ b/src/Boot/Windows/BootEncryptedIo.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -18,9 +18,9 @@ #include "BootDiskIo.h" #include "BootEncryptedIo.h" -BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount) +BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount) { BiosResult result; bool decrypt = true; @@ -75,9 +75,9 @@ BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte dri return result; } -BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount) +BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount) { BiosResult result = BiosResultSuccess; AcquireSectorBuffer(); uint64 dataUnitNo; @@ -107,12 +107,24 @@ BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byt { EncryptDataUnits (SectorBuffer, &dataUnitNo, 1, BootCryptoInfo); } - result = WriteSectors (SectorBuffer, drive, sector + writeOffset, 1); + result = ReadWriteSectors (true, SectorBuffer, drive, sector + writeOffset, 1, true); + if (BiosResultTimeout == result) + { + if (BiosResultSuccess == ReadWriteSectors (false, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, sector + writeOffset, 8, false)) + { + CopyMemory (SectorBuffer, TC_BOOT_LOADER_BUFFER_SEGMENT,0, TC_LB_SIZE); + result = ReadWriteSectors (true, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, sector + writeOffset, 8, true); + } + } if (result != BiosResultSuccess) + { + sector += writeOffset; + PrintDiskError (result, true, drive, §or); break; + } ++sector; ++dataUnitNo; sourceOffset += TC_LB_SIZE; diff --git a/src/Boot/Windows/BootEncryptedIo.h b/src/Boot/Windows/BootEncryptedIo.h index d27ec9ea..d2fa6d96 100644 --- a/src/Boot/Windows/BootEncryptedIo.h +++ b/src/Boot/Windows/BootEncryptedIo.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -14,9 +14,9 @@ #define TC_HEADER_Boot_BootEncryptionIo #include "Platform.h" -BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount); -BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount); +BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount); +BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount); static bool ReadWritePartiallyCoversEncryptedArea (const uint64 §or, uint16 sectorCount); #endif // TC_HEADER_Boot_BootEncryptionIo diff --git a/src/Boot/Windows/BootMain.cpp b/src/Boot/Windows/BootMain.cpp index acae03a9..f6024d34 100644 --- a/src/Boot/Windows/BootMain.cpp +++ b/src/Boot/Windows/BootMain.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -83,9 +83,9 @@ static void PrintMainMenu () PrintEndl (3); } -static bool IsMenuKey (byte scanCode) +static bool IsMenuKey (uint8 scanCode) { #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE return scanCode == TC_MENU_KEY_REPAIR; #else @@ -148,14 +148,14 @@ static int AskSelection (const char *options[], size_t optionCount) } } -static byte AskPassword (Password &password, int& pim) +static uint8 AskPassword (Password &password, int& pim) { size_t pos = 0; - byte scanCode; - byte asciiCode; - byte hidePassword = 1; + uint8 scanCode; + uint8 asciiCode; + uint8 hidePassword = 1; pim = 0; Print ("Enter password"); @@ -311,9 +311,9 @@ static byte AskPassword (Password &password, int& pim) } } -static void ExecuteBootSector (byte drive, byte *sectorBuffer) +static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer) { Print ("Booting...\r\n"); CopyMemory (sectorBuffer, 0x0000, 0x7c00, TC_LB_SIZE); @@ -337,9 +337,9 @@ static void ExecuteBootSector (byte drive, byte *sectorBuffer) } } -static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden) +static bool OpenVolume (uint8 drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden) { int volumeType; bool hiddenVolume; uint64 headerSec; @@ -368,9 +368,9 @@ static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **c if (ReadSectors (SectorBuffer, drive, headerSec, 1) != BiosResultSuccess) continue; - if (ReadVolumeHeader (!hiddenVolume, (char *) SectorBuffer, &password, pim, cryptoInfo, nullptr) == ERR_SUCCESS) + if (ReadVolumeHeader (!hiddenVolume, SectorBuffer, &password, pim, cryptoInfo, nullptr) == ERR_SUCCESS) { // Prevent opening a non-system hidden volume if (hiddenVolume && !((*cryptoInfo)->HeaderFlags & TC_HEADER_FLAG_ENCRYPTED_SYSTEM)) { @@ -419,9 +419,9 @@ static bool CheckMemoryRequirements () return true; } -static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHidden) +static bool MountVolume (uint8 drive, uint8 &exitKey, bool skipNormal, bool skipHidden) { BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; int incorrectPasswordCount = 0, pim = 0; @@ -498,9 +498,9 @@ static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHi return true; } -static bool GetSystemPartitions (byte drive) +static bool GetSystemPartitions (uint8 drive) { size_t partCount; if (!GetActivePartition (drive)) @@ -523,12 +523,12 @@ static bool GetSystemPartitions (byte drive) return true; } -static byte BootEncryptedDrive () +static uint8 BootEncryptedDrive () { BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; - byte exitKey; + uint8 exitKey; BootCryptoInfo = NULL; if (!GetSystemPartitions (BootDrive)) goto err; @@ -555,9 +555,9 @@ static byte BootEncryptedDrive () if (!InstallInterruptFilters()) goto err; - bootArguments->BootArgumentsCrc32 = GetCrc32 ((byte *) bootArguments, (byte *) &bootArguments->BootArgumentsCrc32 - (byte *) bootArguments); + bootArguments->BootArgumentsCrc32 = GetCrc32 ((uint8 *) bootArguments, (uint8 *) &bootArguments->BootArgumentsCrc32 - (uint8 *) bootArguments); while (true) { // Execute boot sector of the active partition @@ -586,9 +586,9 @@ err: #endif EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE; EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments)); - byte scanCode; + uint8 scanCode; GetKeyboardChar (&scanCode); return scanCode; } @@ -600,9 +600,9 @@ static void BootMenu () Partition bootablePartitions[9]; size_t partitionCount; size_t bootablePartitionCount = 0; - for (byte drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive) + for (uint8 drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive) { if (GetDrivePartitions (drive, partitions, array_capacity (partitions), partitionCount, false, nullptr, true) == BiosResultSuccess) { for (size_t i = 0; i < partitionCount; ++i) @@ -688,9 +688,9 @@ static void BootMenu () #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE -static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey) +static bool CopySystemPartitionToHiddenVolume (uint8 drive, uint8 &exitKey) { bool status = false; uint64 sectorsRemaining; @@ -811,11 +811,11 @@ ret: #else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE -static void DecryptDrive (byte drive) +static void DecryptDrive (uint8 drive) { - byte exitKey; + uint8 exitKey; if (!MountVolume (drive, exitKey, false, true)) return; BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; @@ -916,25 +916,25 @@ askBadSectorSkip: CRYPTO_INFO *headerCryptoInfo = crypto_open(); while (ReadSectors (SectorBuffer, drive, headerSector, 1) != BiosResultSuccess); - if (ReadVolumeHeader (TRUE, (char *) SectorBuffer, &bootArguments->BootPassword, (int) (bootArguments->Flags >> 16), NULL, headerCryptoInfo) == 0) + if (ReadVolumeHeader (TRUE, SectorBuffer, &bootArguments->BootPassword, (int) (bootArguments->Flags >> 16), NULL, headerCryptoInfo) == 0) { DecryptBuffer (SectorBuffer + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo); uint64 encryptedAreaLength = sectorsRemaining << TC_LB_SIZE_BIT_SHIFT_DIVISOR; for (int i = 7; i >= 0; --i) { - SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (byte) encryptedAreaLength.LowPart; + SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (uint8) encryptedAreaLength.LowPart; encryptedAreaLength = encryptedAreaLength >> 8; } uint32 headerCrc32 = GetCrc32 (SectorBuffer + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC); for (i = 3; i >= 0; --i) { - SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (byte) headerCrc32; + SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (uint8) headerCrc32; headerCrc32 >>= 8; } EncryptBuffer (SectorBuffer + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo); @@ -1019,9 +1019,9 @@ static void RepairMenu () uint64 sector; sector.HighPart = 0; ChsAddress chs; - byte mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE]; + uint8 mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE]; AcquireSectorBuffer(); for (int i = (selection == RestoreVolumeHeader ? TC_BOOT_VOLUME_HEADER_SECTOR : TC_MBR_SECTOR); i < TC_BOOT_LOADER_AREA_SECTOR_COUNT; ++i) @@ -1072,9 +1072,9 @@ static void RepairMenu () uint32 masterKeyScheduleCrc; Password password; int pim; - byte exitKey = AskPassword (password, pim); + uint8 exitKey = AskPassword (password, pim); if (exitKey != TC_BIOS_KEY_ENTER) goto abort; @@ -1093,9 +1093,9 @@ static void RepairMenu () AcquireSectorBuffer(); CopyMemory (TC_BOOT_LOADER_BUFFER_SEGMENT, 0, SectorBuffer, TC_LB_SIZE); - if (ReadVolumeHeader (TRUE, (char *) SectorBuffer, &password, pim, &cryptoInfo, nullptr) == 0) + if (ReadVolumeHeader (TRUE, SectorBuffer, &password, pim, &cryptoInfo, nullptr) == 0) { if (validHeaderPresent) { if (masterKeyScheduleCrc == GetCrc32 (cryptoInfo->ks, sizeof (cryptoInfo->ks))) @@ -1220,15 +1220,15 @@ void main () // Main menu while (true) { - byte exitKey; + uint8 exitKey; InitScreen(); #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE // Hidden system setup - byte hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; + uint8 hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; if (hiddenSystemCreationPhase != TC_HIDDEN_OS_CREATION_PHASE_NONE) { PreventNormalSystemBoot = true; diff --git a/src/Boot/Windows/BootMain.h b/src/Boot/Windows/BootMain.h index 0f89179a..af445024 100644 --- a/src/Boot/Windows/BootMain.h +++ b/src/Boot/Windows/BootMain.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -15,18 +15,18 @@ #include "TCdefs.h" #include "Platform.h" -static byte AskPassword (Password &password, int& pim); +static uint8 AskPassword (Password &password, int& pim); static int AskSelection (const char *options[], size_t optionCount); static bool AskYesNo (const char *message); -static byte BootEncryptedDrive (); +static uint8 BootEncryptedDrive (); static void BootMenu (); -static void ExecuteBootSector (byte drive, byte *sectorBuffer); +static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer); static void InitScreen (); -static bool IsMenuKey (byte scanCode); -static bool MountVolume (byte drive, byte &exitKey); -static bool OpenVolume (byte drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false); +static bool IsMenuKey (uint8 scanCode); +static bool MountVolume (uint8 drive, uint8 &exitKey); +static bool OpenVolume (uint8 drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false); static void PrintMainMenu (); static void RepairMenu (); #define TC_MENU_KEY_REPAIR TC_BIOS_KEY_F8 diff --git a/src/Boot/Windows/BootMemory.cpp b/src/Boot/Windows/BootMemory.cpp index 5729142f..9eed757f 100644 --- a/src/Boot/Windows/BootMemory.cpp +++ b/src/Boot/Windows/BootMemory.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ diff --git a/src/Boot/Windows/BootMemory.h b/src/Boot/Windows/BootMemory.h index d08e88ac..183c4469 100644 --- a/src/Boot/Windows/BootMemory.h +++ b/src/Boot/Windows/BootMemory.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ diff --git a/src/Boot/Windows/BootSector.asm b/src/Boot/Windows/BootSector.asm index 833ff616..0d2bbdca 100644 --- a/src/Boot/Windows/BootSector.asm +++ b/src/Boot/Windows/BootSector.asm @@ -3,9 +3,9 @@ ; 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-2016 IDRIX +; 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. ; @@ -42,25 +42,26 @@ main: lea si, loader_name_msg call print skip_loader_name_msg: - ; Determine boot loader segment - mov ax, TC_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 + ; Determine boot loader segment + mov ax, word ptr [ds:413h] ;available kB from BIOS + sub ax, TC_BOOT_MEMORY_REQUIRED ;minus TC_BOOT_MEMORY_REQUIRED + jc mem_toolow + and ax, 0FFE0h ;32K align + shl ax, 6 ;convert kB to segment addr (*1024/16) + cmp ax, 8000h + jb mem_toolow ;we can't load below 8000h + cmp ax, TC_BOOT_LOADER_SEGMENT + jbe memory_ok ;don't load above TC_BOOT_LOADER_SEGMENT (9000h) + mov ax, TC_BOOT_LOADER_SEGMENT + jmp memory_ok + +mem_toolow: + mov ax, TC_BOOT_LOADER_LOWMEM_SEGMENT memory_ok: - mov es, ax + mov es, ax ; Clear BSS section xor al, al mov di, TC_COM_EXECUTABLE_OFFSET @@ -137,9 +138,9 @@ checksum_ok: push dx ; Decompress boot loader - mov cx, word ptr [start + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET] + mov cx, word ptr cs:[start + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET] sub cx, TC_GZIP_HEADER_SIZE push cx ; Compressed data size push TC_BOOT_LOADER_COMPRESSED_BUFFER_OFFSET + TC_GZIP_HEADER_SIZE ; Compressed data push TC_MAX_BOOT_LOADER_DECOMPRESSED_SIZE ; Output buffer size diff --git a/src/Boot/Windows/BootStrings.h b/src/Boot/Windows/BootStrings.h index 6c5d7847..b7cfe703 100644 --- a/src/Boot/Windows/BootStrings.h +++ b/src/Boot/Windows/BootStrings.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ diff --git a/src/Boot/Windows/IntFilter.cpp b/src/Boot/Windows/IntFilter.cpp index 4a39fd14..36837d58 100644 --- a/src/Boot/Windows/IntFilter.cpp +++ b/src/Boot/Windows/IntFilter.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -37,9 +37,9 @@ bool Int13Filter () static int ReEntryCount = -1; ++ReEntryCount; - byte function = (byte) (regs.AX >> 8); + uint8 function = (uint8) (regs.AX >> 8); #ifdef TC_TRACE_INT13 DisableScreenOutput(); @@ -62,16 +62,16 @@ bool Int13Filter () { case 0x2: // Read sectors case 0x3: // Write sectors { - byte drive = (byte) regs.DX; + uint8 drive = (uint8) regs.DX; ChsAddress chs; chs.Cylinder = ((regs.CX << 2) & 0x300) | (regs.CX >> 8); chs.Head = regs.DX >> 8; chs.Sector = regs.CX & 0x3f; - byte sectorCount = (byte) regs.AX; + uint8 sectorCount = (uint8) regs.AX; #ifdef TC_TRACE_INT13 PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false); Print (" Chs: "); Print (chs); @@ -124,12 +124,12 @@ bool Int13Filter () case 0x42: // Read sectors LBA case 0x43: // Write sectors LBA { - byte drive = (byte) regs.DX; + uint8 drive = (uint8) regs.DX; BiosLbaPacket lba; - CopyMemory (regs.DS, regs.SI, (byte *) &lba, sizeof (lba)); + CopyMemory (regs.DS, regs.SI, (uint8 *) &lba, sizeof (lba)); #ifdef TC_TRACE_INT13 PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false); PrintVal (" Sec", lba.Sector.LowPart, false); @@ -336,9 +336,9 @@ bool Int15Filter () IntRegisters.AX = -1; } else { - CopyMemory ((byte *) &BiosMemoryMap[IntRegisters.EBX], IntRegisters.ES, IntRegisters.DI, sizeof (BiosMemoryMap[0])); + CopyMemory ((uint8 *) &BiosMemoryMap[IntRegisters.EBX], IntRegisters.ES, IntRegisters.DI, sizeof (BiosMemoryMap[0])); IntRegisters.Flags &= ~TC_X86_CARRY_FLAG; IntRegisters.EAX = 0x534D4150UL; @@ -379,9 +379,9 @@ bool Int15Filter () } #ifdef TC_TRACE_INT15 BiosMemoryMapEntry entry; - CopyMemory (IntRegisters.ES, IntRegisters.DI, (byte *) &entry, sizeof (entry)); + CopyMemory (IntRegisters.ES, IntRegisters.DI, (uint8 *) &entry, sizeof (entry)); PrintHex (entry.Type); PrintChar (' '); PrintHex (entry.BaseAddress); PrintChar (' '); PrintHex (entry.Length); PrintChar (' '); PrintHex (entry.BaseAddress + entry.Length); PrintEndl(); diff --git a/src/Boot/Windows/IntFilter.h b/src/Boot/Windows/IntFilter.h index 3f3a486a..65b0c7ce 100644 --- a/src/Boot/Windows/IntFilter.h +++ b/src/Boot/Windows/IntFilter.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ diff --git a/src/Boot/Windows/Makefile b/src/Boot/Windows/Makefile index 1e6e21ae..d08e1f50 100644 --- a/src/Boot/Windows/Makefile +++ b/src/Boot/Windows/Makefile @@ -3,9 +3,9 @@ # 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-2016 IDRIX +# 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. @@ -45,9 +45,9 @@ CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE /D TC_WINDOWS_BOOT_$(SI !ifdef SINGLE_PRF OBJDIR = $(OBJDIR)_$(SINGLE_PRF) CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_$(SINGLE_PRF) !else -CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_RIPEMD160 +CFLAGS = $(CFLAGS) /D TC_WINDOWS_BOOT_BLAKE2S !endif OUTDIR = $(OBJDIR) TARGETEXT = com @@ -84,9 +84,9 @@ OBJS = $(OBJS) $(OUTDIR)\Xts.obj !if "$(SINGLE_PRF)" == "SHA2" OBJS = $(OBJS) $(OUTDIR)\Sha2Small.obj !else -OBJS = $(OBJS) $(OUTDIR)\Rmd160.obj +OBJS = $(OBJS) $(OUTDIR)\blake2s-ref.obj !endif !if !DEFINED (SINGLE_CIPHER) OBJS = $(OBJS) $(OUTDIR)\AesSmall.obj @@ -195,11 +195,11 @@ $(LIBS) $(LD) $(LFLAGS) @$(PROJ).crf del $(PROJ).crf $(PROJ).crf2 -# Compress the Rescue Disk botloader for Cascades and Serpent since it is too big (size > 31232 bytes) -!if DEFINED(RESCUE_DISK) && (!DEFINED (SINGLE_CIPHER) || ("$(SINGLE_CIPHER)" == "SERPENT") || ("$(SINGLE_CIPHER)" == "CAMELLIA")) +# Compress the Rescue Disk bootloader for Cascades and Serpent since it is too big (size > 31232 bytes) +#!if DEFINED(RESCUE_DISK) && (!DEFINED (SINGLE_CIPHER) || ("$(SINGLE_CIPHER)" == "SERPENT") || ("$(SINGLE_CIPHER)" == "CAMELLIA")) upx $(PROJ).$(TARGETEXT) -!endif +#!endif gzip.exe -c -n --best $(PROJ).$(TARGETEXT) >$(PROJ).$(TARGETEXT).gz -dd.exe conv=notrunc,sync bs=512 seek=5 if=$(PROJ).$(TARGETEXT).gz of=$(PROJ).flp 2>NUL: cd .. diff --git a/src/Boot/Windows/Platform.cpp b/src/Boot/Windows/Platform.cpp index 0a45bba6..3b94d22c 100644 --- a/src/Boot/Windows/Platform.cpp +++ b/src/Boot/Windows/Platform.cpp @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -83,9 +83,9 @@ uint64 operator>> (const uint64 &a, int shiftCount) while (shiftCount--) { r.LowPart >>= 1; - if ((byte) r.HighPart & 1) + if ((uint8) r.HighPart & 1) r.LowPart |= 0x80000000UL; r.HighPart >>= 1; } @@ -136,8 +136,10 @@ bool operator<= (const uint64 &a, const uint64 &b) { return a < b || a == b; } +#ifdef TC_BOOT_DEBUG_ENABLED + bool TestInt64 () { uint64 a, b, c; a.HighPart = 0x00112233UL; @@ -160,8 +162,9 @@ bool TestInt64 () c = c << 9; return c.HighPart == 0x22446755UL && c.LowPart == 0x78024600UL; } +#endif void CopyMemory (void *source, uint16 destSegment, uint16 destOffset, uint16 blockSize) { __asm diff --git a/src/Boot/Windows/Platform.h b/src/Boot/Windows/Platform.h index a8e83bec..1c41ec03 100644 --- a/src/Boot/Windows/Platform.h +++ b/src/Boot/Windows/Platform.h @@ -3,9 +3,9 @@ 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-2016 IDRIX + 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. */ @@ -109,8 +109,10 @@ void CopyMemory (void *source, uint16 destSegment, uint16 destOffset, uint16 blo void CopyMemory (uint16 sourceSegment, uint16 sourceOffset, void *destination, uint16 blockSize); extern "C" void EraseMemory (void *memory, int size); uint32 GetLinearAddress (uint16 segment, uint16 offset); bool RegionsIntersect (const uint64 &start1, uint32 length1, const uint64 &start2, const uint64 &end2); +#ifdef TC_BOOT_DEBUG_ENABLED bool TestInt64 (); +#endif extern "C" void ThrowFatalException (int line); #endif // TC_HEADER_Boot_Platform diff --git a/src/Boot/Windows/Release/BootLoader.com.gz b/src/Boot/Windows/Release/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..248f7833 --- /dev/null +++ b/src/Boot/Windows/Release/BootLoader.com.gz diff --git a/src/Boot/Windows/Release/BootSector.bin b/src/Boot/Windows/Release/BootSector.bin Binary files differnew file mode 100644 index 00000000..556a2036 --- /dev/null +++ b/src/Boot/Windows/Release/BootSector.bin diff --git a/src/Boot/Windows/Release/Decompressor.com b/src/Boot/Windows/Release/Decompressor.com Binary files differnew file mode 100644 index 00000000..14b4e5d4 --- /dev/null +++ b/src/Boot/Windows/Release/Decompressor.com diff --git a/src/Boot/Windows/Release_AES/BootLoader.com.gz b/src/Boot/Windows/Release_AES/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..a674bb0b --- /dev/null +++ b/src/Boot/Windows/Release_AES/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_AES/BootSector.bin b/src/Boot/Windows/Release_AES/BootSector.bin Binary files differnew file mode 100644 index 00000000..7d041a36 --- /dev/null +++ b/src/Boot/Windows/Release_AES/BootSector.bin diff --git a/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..298b3ac2 --- /dev/null +++ b/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_AES_SHA2/BootSector.bin b/src/Boot/Windows/Release_AES_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..7d041a36 --- /dev/null +++ b/src/Boot/Windows/Release_AES_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Release_Camellia/BootLoader.com.gz b/src/Boot/Windows/Release_Camellia/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..b8cbc0a9 --- /dev/null +++ b/src/Boot/Windows/Release_Camellia/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Camellia/BootSector.bin b/src/Boot/Windows/Release_Camellia/BootSector.bin Binary files differnew file mode 100644 index 00000000..9ff1b39e --- /dev/null +++ b/src/Boot/Windows/Release_Camellia/BootSector.bin diff --git a/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..62b2b111 --- /dev/null +++ b/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Camellia_SHA2/BootSector.bin b/src/Boot/Windows/Release_Camellia_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..9ff1b39e --- /dev/null +++ b/src/Boot/Windows/Release_Camellia_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Release_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..f660e397 --- /dev/null +++ b/src/Boot/Windows/Release_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_SHA2/BootSector.bin b/src/Boot/Windows/Release_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..556a2036 --- /dev/null +++ b/src/Boot/Windows/Release_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Release_Serpent/BootLoader.com.gz b/src/Boot/Windows/Release_Serpent/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..2526d68b --- /dev/null +++ b/src/Boot/Windows/Release_Serpent/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Serpent/BootSector.bin b/src/Boot/Windows/Release_Serpent/BootSector.bin Binary files differnew file mode 100644 index 00000000..8020da87 --- /dev/null +++ b/src/Boot/Windows/Release_Serpent/BootSector.bin diff --git a/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..1446855b --- /dev/null +++ b/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Serpent_SHA2/BootSector.bin b/src/Boot/Windows/Release_Serpent_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..8020da87 --- /dev/null +++ b/src/Boot/Windows/Release_Serpent_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Release_Twofish/BootLoader.com.gz b/src/Boot/Windows/Release_Twofish/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..f9463c1c --- /dev/null +++ b/src/Boot/Windows/Release_Twofish/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Twofish/BootSector.bin b/src/Boot/Windows/Release_Twofish/BootSector.bin Binary files differnew file mode 100644 index 00000000..eff8e12a --- /dev/null +++ b/src/Boot/Windows/Release_Twofish/BootSector.bin diff --git a/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..e736e85e --- /dev/null +++ b/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Twofish_SHA2/BootSector.bin b/src/Boot/Windows/Release_Twofish_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..eff8e12a --- /dev/null +++ b/src/Boot/Windows/Release_Twofish_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Rescue/BootLoader.com.gz b/src/Boot/Windows/Rescue/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..2e852d6c --- /dev/null +++ b/src/Boot/Windows/Rescue/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue/BootSector.bin b/src/Boot/Windows/Rescue/BootSector.bin Binary files differnew file mode 100644 index 00000000..556a2036 --- /dev/null +++ b/src/Boot/Windows/Rescue/BootSector.bin diff --git a/src/Boot/Windows/Rescue_AES/BootLoader.com.gz b/src/Boot/Windows/Rescue_AES/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..ff0f10a8 --- /dev/null +++ b/src/Boot/Windows/Rescue_AES/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_AES/BootSector.bin b/src/Boot/Windows/Rescue_AES/BootSector.bin Binary files differnew file mode 100644 index 00000000..9ff1b39e --- /dev/null +++ b/src/Boot/Windows/Rescue_AES/BootSector.bin diff --git a/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..2218aced --- /dev/null +++ b/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_AES_SHA2/BootSector.bin b/src/Boot/Windows/Rescue_AES_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..9ff1b39e --- /dev/null +++ b/src/Boot/Windows/Rescue_AES_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz b/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..88db9603 --- /dev/null +++ b/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Camellia/BootSector.bin b/src/Boot/Windows/Rescue_Camellia/BootSector.bin Binary files differnew file mode 100644 index 00000000..9ff1b39e --- /dev/null +++ b/src/Boot/Windows/Rescue_Camellia/BootSector.bin diff --git a/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..57ff5be5 --- /dev/null +++ b/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Camellia_SHA2/BootSector.bin b/src/Boot/Windows/Rescue_Camellia_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..9ff1b39e --- /dev/null +++ b/src/Boot/Windows/Rescue_Camellia_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..a95efbfb --- /dev/null +++ b/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_SHA2/BootSector.bin b/src/Boot/Windows/Rescue_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..556a2036 --- /dev/null +++ b/src/Boot/Windows/Rescue_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz b/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..944f5d81 --- /dev/null +++ b/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Serpent/BootSector.bin b/src/Boot/Windows/Rescue_Serpent/BootSector.bin Binary files differnew file mode 100644 index 00000000..8020da87 --- /dev/null +++ b/src/Boot/Windows/Rescue_Serpent/BootSector.bin diff --git a/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..fff9856b --- /dev/null +++ b/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Serpent_SHA2/BootSector.bin b/src/Boot/Windows/Rescue_Serpent_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..8020da87 --- /dev/null +++ b/src/Boot/Windows/Rescue_Serpent_SHA2/BootSector.bin diff --git a/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz b/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..79281133 --- /dev/null +++ b/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Twofish/BootSector.bin b/src/Boot/Windows/Rescue_Twofish/BootSector.bin Binary files differnew file mode 100644 index 00000000..eff8e12a --- /dev/null +++ b/src/Boot/Windows/Rescue_Twofish/BootSector.bin diff --git a/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz Binary files differnew file mode 100644 index 00000000..40960c8a --- /dev/null +++ b/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Twofish_SHA2/BootSector.bin b/src/Boot/Windows/Rescue_Twofish_SHA2/BootSector.bin Binary files differnew file mode 100644 index 00000000..eff8e12a --- /dev/null +++ b/src/Boot/Windows/Rescue_Twofish_SHA2/BootSector.bin |