VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Apidrvr.h10
-rw-r--r--src/Common/BaseCom.cpp2
-rw-r--r--src/Common/BootEncryption.cpp216
-rw-r--r--src/Common/BootEncryption.h62
-rw-r--r--src/Common/CommandAPDU.cpp66
-rw-r--r--src/Common/CommandAPDU.h32
-rw-r--r--src/Common/Crypto.c40
-rw-r--r--src/Common/Dlgcode.c48
-rw-r--r--src/Common/Dlgcode.h10
-rw-r--r--src/Common/EMVCard.cpp54
-rw-r--r--src/Common/EMVCard.h22
-rw-r--r--src/Common/EMVToken.cpp10
-rw-r--r--src/Common/EMVToken.h4
-rw-r--r--src/Common/EncryptionThreadPool.c6
-rw-r--r--src/Common/EncryptionThreadPool.h2
-rw-r--r--src/Common/Fat.h2
-rw-r--r--src/Common/Format.c4
-rw-r--r--src/Common/Keyfiles.c2
-rw-r--r--src/Common/ResponseAPDU.cpp32
-rw-r--r--src/Common/ResponseAPDU.h18
-rw-r--r--src/Common/SCardLoader.h4
-rw-r--r--src/Common/SCardReader.cpp18
-rw-r--r--src/Common/SCardReader.h114
-rw-r--r--src/Common/SecurityToken.cpp16
-rw-r--r--src/Common/SecurityToken.h8
-rw-r--r--src/Common/TLVParser.cpp12
-rw-r--r--src/Common/TLVParser.h14
-rw-r--r--src/Common/Tcdefs.h2
-rw-r--r--src/Common/Tests.c4
-rw-r--r--src/Common/Token.h2
-rw-r--r--src/Common/Volumes.c18
-rw-r--r--src/Common/Volumes.h12
-rw-r--r--src/Common/Wipe.c16
-rw-r--r--src/Common/Wipe.h2
34 files changed, 441 insertions, 443 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h
index 463d4fa6..4074503d 100644
--- a/src/Common/Apidrvr.h
+++ b/src/Common/Apidrvr.h
@@ -344,23 +344,23 @@ typedef struct
typedef struct
{
- byte Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
+ uint8 Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
} BootLoaderFingerprintRequest;
typedef struct
{
wchar_t DevicePath[TC_MAX_PATH];
- byte Configuration;
+ uint8 Configuration;
BOOL DriveIsDynamic;
uint16 BootLoaderVersion;
- byte UserConfiguration;
+ uint8 UserConfiguration;
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
} GetSystemDriveConfigurationRequest;
typedef struct
{
WipeAlgorithmId WipeAlgorithm;
- CRYPTOPP_ALIGN_DATA(16) byte WipeKey[MASTER_KEYDATA_SIZE];
+ CRYPTOPP_ALIGN_DATA(16) uint8 WipeKey[MASTER_KEYDATA_SIZE];
} WipeDecoySystemRequest;
typedef struct
@@ -373,7 +373,7 @@ typedef struct
typedef struct
{
LARGE_INTEGER Offset;
- byte Data[TC_SECTOR_SIZE_BIOS];
+ uint8 Data[TC_SECTOR_SIZE_BIOS];
} WriteBootDriveSectorRequest;
typedef struct
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp
index 3eaaf809..25c70963 100644
--- a/src/Common/BaseCom.cpp
+++ b/src/Common/BaseCom.cpp
@@ -450,7 +450,7 @@ DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMe
msg [maxSize - 1] = 0;
std::string msgStr = maxSize > 0 ? msg : "";
BootEncryption bootEnc (NULL);
- bootEnc.WriteEfiBootSectorUserConfig ((byte) userConfig, msgStr, pim, hashAlg);
+ bootEnc.WriteEfiBootSectorUserConfig ((uint8) userConfig, msgStr, pim, hashAlg);
}
catch (SystemException &)
{
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index af6063e4..2080a44b 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -275,10 +275,10 @@ bool ZipAdd (zip_t *z, const char* name, const unsigned char* pbData, DWORD cbDa
return true;
}
-static BOOL IsWindowsMBR (const byte *buffer, size_t bufferSize)
+static BOOL IsWindowsMBR (const uint8 *buffer, size_t bufferSize)
{
BOOL bRet = FALSE;
- byte g_pbMsSignature[4] = {0x33, 0xc0, 0x8e, 0xd0};
+ uint8 g_pbMsSignature[4] = {0x33, 0xc0, 0x8e, 0xd0};
const char* g_szStr1 = "Invalid partition table";
const char* g_szStr2 = "Error loading operating system";
const char* g_szStr3 = "Missing operating system";
@@ -390,7 +390,7 @@ namespace VeraCrypt
}
}
- static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
+ static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, uint8 *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
{
Elevate();
@@ -631,7 +631,7 @@ namespace VeraCrypt
}
}
- static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg)
+ static void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg)
{
Elevate();
@@ -742,7 +742,7 @@ namespace VeraCrypt
public:
static void AddReference () { }
static void CallDriver (DWORD ioctl, void *input, DWORD inputSize, void *output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); }
- static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); }
+ static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, uint8 *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); }
static void RegisterFilterDriver (bool registerDriver, BootEncryption::FilterType filterType) { throw ParameterIncorrect (SRC_POS); }
static void Release () { }
static void SetDriverServiceStartType (DWORD startType) { throw ParameterIncorrect (SRC_POS); }
@@ -752,7 +752,7 @@ namespace VeraCrypt
static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { throw ParameterIncorrect (SRC_POS); }
- static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); }
+ static void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); }
static void UpdateSetupConfigFile (bool bForInstall) { throw ParameterIncorrect (SRC_POS); }
static void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { throw ParameterIncorrect (SRC_POS); }
};
@@ -796,7 +796,7 @@ namespace VeraCrypt
FileOpen = false;
}
- DWORD File::Read (byte *buffer, DWORD size)
+ DWORD File::Read (uint8 *buffer, DWORD size)
{
DWORD bytesRead;
@@ -901,7 +901,7 @@ namespace VeraCrypt
dwSize = (DWORD) size64;
}
- void File::Write (byte *buffer, DWORD size)
+ void File::Write (uint8 *buffer, DWORD size)
{
DWORD bytesWritten;
@@ -1423,7 +1423,7 @@ namespace VeraCrypt
return version;
}
- void BootEncryption::GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE])
+ void BootEncryption::GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE])
{
BootLoaderFingerprintRequest request;
CallDriver (VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT, NULL, 0, &request, sizeof (request));
@@ -1485,12 +1485,12 @@ namespace VeraCrypt
}
- bool BootEncryption::SystemDriveContainsPartitionType (byte type)
+ bool BootEncryption::SystemDriveContainsPartitionType (uint8 type)
{
Device device (GetSystemDriveConfiguration().DevicePath, true);
device.CheckOpened (SRC_POS);
- byte mbrBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrBuf, sizeof (mbrBuf));
@@ -1532,7 +1532,7 @@ namespace VeraCrypt
continue;
}
- if (SystemDriveContainsPartitionType ((byte) partitionType))
+ if (SystemDriveContainsPartitionType ((uint8) partitionType))
return true;
}
@@ -1650,7 +1650,7 @@ namespace VeraCrypt
}
- uint32 BootEncryption::GetChecksum (byte *data, size_t size)
+ uint32 BootEncryption::GetChecksum (uint8 *data, size_t size)
{
uint32 sum = 0;
@@ -1664,7 +1664,7 @@ namespace VeraCrypt
}
- void BootEncryption::CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation)
+ void BootEncryption::CreateBootLoaderInMemory (uint8 *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation)
{
if (bufferSize < TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE)
throw ParameterIncorrect (SRC_POS);
@@ -1809,7 +1809,7 @@ namespace VeraCrypt
// Boot sector
DWORD size;
- byte *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size);
+ uint8 *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size);
if (!bootSecResourceImg || size != TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
@@ -1827,7 +1827,7 @@ namespace VeraCrypt
{
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
- byte headerSector[TC_SECTOR_SIZE_BIOS];
+ uint8 headerSector[TC_SECTOR_SIZE_BIOS];
device.SeekAt (HiddenOSCandidatePartition.Info.StartingOffset.QuadPart + HiddenOSCandidatePartition.Info.PartitionLength.QuadPart - TC_VOLUME_HEADER_GROUP_SIZE + TC_VOLUME_HEADER_EFFECTIVE_SIZE);
device.Read (headerSector, sizeof (headerSector));
@@ -1836,14 +1836,14 @@ namespace VeraCrypt
}
// Decompressor
- byte *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size);
+ uint8 *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size);
if (!decompressor || size > TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
memcpy (buffer + TC_SECTOR_SIZE_BIOS, decompressor, size);
// Compressed boot loader
- byte *bootLoader = MapResource (L"BIN", bootLoaderId, &size);
+ uint8 *bootLoader = MapResource (L"BIN", bootLoaderId, &size);
if (!bootLoader || size > TC_MAX_BOOT_LOADER_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
@@ -1869,7 +1869,7 @@ namespace VeraCrypt
}
// return false when the user cancel an elevation request
- bool BootEncryption::ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig, string *customUserMessage, uint16 *bootLoaderVersion)
+ bool BootEncryption::ReadBootSectorConfig (uint8 *config, size_t bufLength, uint8 *userConfig, string *customUserMessage, uint16 *bootLoaderVersion)
{
bool bCanceled = false, bExceptionOccured = false;
try
@@ -1962,11 +1962,11 @@ namespace VeraCrypt
}
- void BootEncryption::WriteBootSectorConfig (const byte newConfig[])
+ void BootEncryption::WriteBootSectorConfig (const uint8 newConfig[])
{
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -1976,7 +1976,7 @@ namespace VeraCrypt
device.SeekAt (0);
device.Write (mbr, sizeof (mbr));
- byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
@@ -1984,7 +1984,7 @@ namespace VeraCrypt
throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
}
- void BootEncryption::WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg)
+ void BootEncryption::WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg)
{
if (!IsAdmin() && IsUacSupported())
{
@@ -2003,7 +2003,7 @@ namespace VeraCrypt
}
}
- void BootEncryption::WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg)
+ void BootEncryption::WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg)
{
if (GetSystemDriveConfiguration().SystemPartition.IsGPT)
{
@@ -2013,7 +2013,7 @@ namespace VeraCrypt
{
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -2048,7 +2048,7 @@ namespace VeraCrypt
device.SeekAt (0);
device.Write (mbr, sizeof (mbr));
- byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
@@ -2060,7 +2060,7 @@ namespace VeraCrypt
unsigned int BootEncryption::GetHiddenOSCreationPhase ()
{
- byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
+ uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
ReadBootSectorConfig (configFlags, sizeof(configFlags));
@@ -2073,11 +2073,11 @@ namespace VeraCrypt
#if TC_BOOT_CFG_FLAG_AREA_SIZE != 1
# error TC_BOOT_CFG_FLAG_AREA_SIZE != 1; revise GetHiddenOSCreationPhase() and SetHiddenOSCreationPhase()
#endif
- byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
+ uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
ReadBootSectorConfig (configFlags, sizeof(configFlags));
- configFlags[0] &= (byte) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
+ configFlags[0] &= (uint8) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
configFlags[0] |= newPhase;
@@ -2154,7 +2154,7 @@ namespace VeraCrypt
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened(SRC_POS);
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -2171,7 +2171,7 @@ namespace VeraCrypt
# error PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE
#endif
- byte randData[PRAND_DISK_WIPE_PASSES];
+ uint8 randData[PRAND_DISK_WIPE_PASSES];
if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE))
throw ParameterIncorrect (SRC_POS);
@@ -2182,7 +2182,7 @@ namespace VeraCrypt
mbr[TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET + i] = randData[wipePass];
}
- mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] &= (byte) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
+ mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] &= (uint8) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] |= randData[wipePass] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
if (wipePass == PRAND_DISK_WIPE_PASSES - 1)
@@ -2384,7 +2384,7 @@ namespace VeraCrypt
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
@@ -2699,8 +2699,8 @@ namespace VeraCrypt
uint32 varSize = 56;
varSize += ((uint32) description.length()) * 2 + 2;
varSize += ((uint32) execPath.length()) * 2 + 2;
- byte *startVar = new byte[varSize];
- byte *pVar = startVar;
+ uint8 *startVar = new uint8[varSize];
+ uint8 *pVar = startVar;
// Attributes (1b Active, 1000b - Hidden)
*(uint32 *)pVar = attr;
@@ -2721,12 +2721,12 @@ namespace VeraCrypt
/* EFI_DEVICE_PATH_PROTOCOL (HARDDRIVE_DEVICE_PATH \ FILE_PATH \ END) */
// Type
- *(byte *)pVar = 0x04;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x04;
+ pVar += sizeof(uint8);
// SubType
- *(byte *)pVar = 0x01;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x01;
+ pVar += sizeof(uint8);
// HDD dev path length
*(uint16 *)pVar = 0x2A; // 42
@@ -2749,12 +2749,12 @@ namespace VeraCrypt
pVar += 16;
// MbrType
- *(byte *)pVar = 0x02;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x02;
+ pVar += sizeof(uint8);
// SigType
- *(byte *)pVar = 0x02;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x02;
+ pVar += sizeof(uint8);
// Type and sub type 04 04 (file path)
*(uint16 *)pVar = 0x0404;
@@ -2781,7 +2781,7 @@ namespace VeraCrypt
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum);
// only set value if it doesn't already exist
- byte* existingVar = new byte[varSize];
+ uint8* existingVar = new uint8[varSize];
DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, varSize);
if ((existingVarLen != varSize) || (0 != memcmp (existingVar, startVar, varSize)))
SetFirmwareEnvironmentVariable(varName, EfiVarGuid, startVar, varSize);
@@ -2813,7 +2813,7 @@ namespace VeraCrypt
wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, startOrder[0]);
- byte* existingVar = new byte[512];
+ uint8* existingVar = new uint8[512];
DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, 512);
if (existingVarLen > 0)
{
@@ -2884,8 +2884,8 @@ namespace VeraCrypt
if (size1 == size2)
{
// same size, so now we compare content
- std::vector<byte> file1Buf (8096);
- std::vector<byte> file2Buf (8096);
+ std::vector<uint8> file1Buf (8096);
+ std::vector<uint8> file2Buf (8096);
DWORD remainingBytes = size1, dataToRead;
while (remainingBytes)
@@ -2920,7 +2920,7 @@ namespace VeraCrypt
return bRet;
}
- bool EfiBoot::CompareFileData (const wchar_t* fileName, const byte* data, DWORD size)
+ bool EfiBoot::CompareFileData (const wchar_t* fileName, const uint8* data, DWORD size)
{
bool bRet = false;
@@ -2937,7 +2937,7 @@ namespace VeraCrypt
if (existingSize == size)
{
- std::vector<byte> fileBuf (8096);
+ std::vector<uint8> fileBuf (8096);
DWORD remainingBytes = size, dataOffset = 0, dataToRead;
while (remainingBytes)
@@ -2971,7 +2971,7 @@ namespace VeraCrypt
return bRet;
}
- void EfiBoot::SaveFile(const wchar_t* name, byte* data, DWORD size) {
+ void EfiBoot::SaveFile(const wchar_t* name, uint8* data, DWORD size) {
wstring path = EfiBootPartPath;
path += name;
@@ -3000,7 +3000,7 @@ namespace VeraCrypt
f.Close();
}
- void EfiBoot::ReadFile(const wchar_t* name, byte* data, DWORD size) {
+ void EfiBoot::ReadFile(const wchar_t* name, uint8* data, DWORD size) {
wstring path = EfiBootPartPath;
path += name;
File f(path, true);
@@ -3297,51 +3297,51 @@ namespace VeraCrypt
}
DWORD sizeDcsBoot;
#ifdef _WIN64
- byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
+ uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
#else
- byte *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot);
+ uint8 *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot);
#endif
if (!dcsBootImg)
throw ErrorException(L"Out of resource DcsBoot", SRC_POS);
DWORD sizeDcsInt;
#ifdef _WIN64
- byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
+ uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
#else
- byte *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt);
+ uint8 *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt);
#endif
if (!dcsIntImg)
throw ErrorException(L"Out of resource DcsInt", SRC_POS);
DWORD sizeDcsCfg;
#ifdef _WIN64
- byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
+ uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
#else
- byte *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg);
+ uint8 *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg);
#endif
if (!dcsCfgImg)
throw ErrorException(L"Out of resource DcsCfg", SRC_POS);
DWORD sizeLegacySpeaker;
#ifdef _WIN64
- byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
+ uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
#else
- byte *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker);
+ uint8 *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker);
#endif
if (!LegacySpeakerImg)
throw ErrorException(L"Out of resource LegacySpeaker", SRC_POS);
#ifdef VC_EFI_CUSTOM_MODE
DWORD sizeBootMenuLocker;
#ifdef _WIN64
- byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
+ uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
#else
- byte *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker);
+ uint8 *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker);
#endif
if (!BootMenuLockerImg)
throw ErrorException(L"Out of resource DcsBml", SRC_POS);
#endif
DWORD sizeDcsInfo;
#ifdef _WIN64
- byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
+ uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
#else
- byte *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo);
+ uint8 *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo);
#endif
if (!DcsInfoImg)
throw ErrorException(L"Out of resource DcsInfo", SRC_POS);
@@ -3373,7 +3373,7 @@ namespace VeraCrypt
{
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
@@ -3391,7 +3391,7 @@ namespace VeraCrypt
// DcsBoot.efi is always smaller than 32KB
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
@@ -3420,7 +3420,7 @@ namespace VeraCrypt
{
// look for bootmgfw.efi identifiant string
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize);
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
@@ -3453,7 +3453,7 @@ namespace VeraCrypt
EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize);
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize);
@@ -3487,7 +3487,7 @@ namespace VeraCrypt
// check if standard bootloader under EFI\Boot is Microsoft one or if it is ours
// if both cases, replace it with our bootloader otherwise do nothing
EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize);
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi or VeraCrypt identifiant strings
@@ -3539,11 +3539,11 @@ namespace VeraCrypt
{
try
{
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, hiddenOSCreation);
// Write MBR
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -3578,7 +3578,7 @@ namespace VeraCrypt
device.SeekAt (0);
device.Write (mbr, sizeof (mbr));
- byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
@@ -3620,9 +3620,9 @@ namespace VeraCrypt
if (config.SystemPartition.IsGPT)
return true;
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
- byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
- byte expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
+ uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
+ uint8 expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
bool bRet = false;
try
@@ -3694,59 +3694,59 @@ namespace VeraCrypt
// create EFI disk structure
DWORD sizeDcsBoot;
#ifdef _WIN64
- byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
+ uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
#else
- byte *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot);
+ uint8 *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot);
#endif
if (!dcsBootImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsInt;
#ifdef _WIN64
- byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
+ uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
#else
- byte *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt);
+ uint8 *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt);
#endif
if (!dcsIntImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsCfg;
#ifdef _WIN64
- byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
+ uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
#else
- byte *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg);
+ uint8 *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg);
#endif
if (!dcsCfgImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeLegacySpeaker;
#ifdef _WIN64
- byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
+ uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
#else
- byte *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker);
+ uint8 *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker);
#endif
if (!LegacySpeakerImg)
throw ParameterIncorrect (SRC_POS);
#ifdef VC_EFI_CUSTOM_MODE
DWORD sizeBootMenuLocker;
#ifdef _WIN64
- byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
+ uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
#else
- byte *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker);
+ uint8 *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker);
#endif
if (!BootMenuLockerImg)
throw ParameterIncorrect (SRC_POS);
#endif
DWORD sizeDcsRescue;
#ifdef _WIN64
- byte *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue);
+ uint8 *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue);
#else
- byte *DcsRescueImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSRE: IDR_EFI_DCSRE32, &sizeDcsRescue);
+ uint8 *DcsRescueImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSRE: IDR_EFI_DCSRE32, &sizeDcsRescue);
#endif
if (!DcsRescueImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsInfo;
#ifdef _WIN64
- byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
+ uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
#else
- byte *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo);
+ uint8 *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo);
#endif
if (!DcsInfoImg)
throw ParameterIncorrect (SRC_POS);
@@ -3866,7 +3866,7 @@ namespace VeraCrypt
finally_do_arg (FILE*, ftmpFile, { fclose (finally_arg); });
unsigned long ulZipSize = (unsigned long) _filelength (_fileno (ftmpFile));
- RescueZipData = new byte[ulZipSize];
+ RescueZipData = new uint8[ulZipSize];
if (!RescueZipData)
throw bad_alloc();
@@ -3889,7 +3889,7 @@ namespace VeraCrypt
{
Buffer imageBuf (RescueIsoImageSize);
- byte *image = imageBuf.Ptr();
+ uint8 *image = imageBuf.Ptr();
memset (image, 0, RescueIsoImageSize);
// Primary volume descriptor
@@ -3997,7 +3997,7 @@ namespace VeraCrypt
// Boot loader backup
CreateBootLoaderInMemory (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET, TC_BOOT_LOADER_AREA_SIZE, false);
- RescueIsoImage = new byte[RescueIsoImageSize];
+ RescueIsoImage = new uint8[RescueIsoImageSize];
if (!RescueIsoImage)
throw bad_alloc();
memcpy (RescueIsoImage, image, RescueIsoImageSize);
@@ -4370,7 +4370,7 @@ namespace VeraCrypt
if (GetHeaderField32 (RescueVolumeHeader, TC_HEADER_OFFSET_MAGIC) != 0x56455241)
throw ParameterIncorrect (SRC_POS);
- byte *fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH;
+ uint8 *fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH;
mputInt64 (fieldPos, volumeSize);
// CRC of the header fields
@@ -4394,7 +4394,7 @@ namespace VeraCrypt
device.CheckOpened (SRC_POS);
device.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
- device.Write ((byte *) VolumeHeader, sizeof (VolumeHeader));
+ device.Write ((uint8 *) VolumeHeader, sizeof (VolumeHeader));
}
@@ -4435,7 +4435,7 @@ namespace VeraCrypt
}
}
unsigned __int64 loaderSize = 0;
- std::vector<byte> bootLoaderBuf;
+ std::vector<uint8> bootLoaderBuf;
const wchar_t * szStdMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi";
const wchar_t * szBackupMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc";
const char* g_szMsBootString = "bootmgfw.pdb";
@@ -4495,7 +4495,7 @@ namespace VeraCrypt
{
Device device (GetSystemDriveConfiguration().DevicePath, true);
device.CheckOpened (SRC_POS);
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (bootLoaderBuf, sizeof (bootLoaderBuf));
@@ -4558,7 +4558,7 @@ namespace VeraCrypt
const char* g_szMsBootString = "bootmgfw.pdb";
unsigned __int64 loaderSize = 0;
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize);
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
@@ -4592,7 +4592,7 @@ namespace VeraCrypt
}
else
{
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
File backupFile (GetSystemLoaderBackupPath(), true);
backupFile.CheckOpened(SRC_POS);
@@ -4603,7 +4603,7 @@ namespace VeraCrypt
device.CheckOpened (SRC_POS);
// Preserve current partition table
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
memcpy (bootLoaderBuf + TC_MAX_MBR_BOOT_CODE_SIZE, mbr + TC_MAX_MBR_BOOT_CODE_SIZE, sizeof (mbr) - TC_MAX_MBR_BOOT_CODE_SIZE);
@@ -4743,7 +4743,7 @@ namespace VeraCrypt
// Register class filter below all other filters in the stack
size_t strSize = filter.size() + 1;
- byte regKeyBuf[65536];
+ uint8 regKeyBuf[65536];
DWORD size = (DWORD) (sizeof (regKeyBuf) - strSize);
// SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly
@@ -4761,8 +4761,8 @@ namespace VeraCrypt
// read initial value
DWORD strSize = (DWORD) filter.size() + 1, expectedSize;
Buffer expectedRegKeyBuf(65536), outputRegKeyBuf(65536);
- byte* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr ();
- byte* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr ();
+ uint8* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr ();
+ uint8* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr ();
DWORD initialSize = (DWORD) (expectedRegKeyBuf.Size() - strSize - 2);
if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbExpectedRegKeyBuf, &initialSize) != ERROR_SUCCESS)
@@ -4814,7 +4814,7 @@ namespace VeraCrypt
// remove value in case it was not done properly
Buffer regKeyBuf(65536);
- byte* pbRegKeyBuf = regKeyBuf.Ptr ();
+ uint8* pbRegKeyBuf = regKeyBuf.Ptr ();
DWORD initialSize = (DWORD) regKeyBuf.Size() - 2;
@@ -5302,12 +5302,12 @@ namespace VeraCrypt
// Verify CRC of header salt
Device device(config.DevicePath, true);
device.CheckOpened(SRC_POS);
- byte header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
+ uint8 header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
device.SeekAt(TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
device.Read(header, sizeof(header));
- if (encStatus.VolumeHeaderSaltCrc32 != GetCrc32((byte *)header, PKCS5_SALT_SIZE))
+ if (encStatus.VolumeHeaderSaltCrc32 != GetCrc32((uint8 *)header, PKCS5_SALT_SIZE))
throw ParameterIncorrect(SRC_POS);
}
}
@@ -5394,7 +5394,7 @@ namespace VeraCrypt
}
device.SeekAt (headerOffset);
- device.Read ((byte *) header, sizeof (header));
+ device.Read ((uint8 *) header, sizeof (header));
PCRYPTO_INFO cryptoInfo = NULL;
@@ -5482,7 +5482,7 @@ namespace VeraCrypt
}
device.SeekAt (headerOffset);
- device.Write ((byte *) header, sizeof (header));
+ device.Write ((uint8 *) header, sizeof (header));
headerUpdated = true;
}
@@ -5513,7 +5513,7 @@ namespace VeraCrypt
try
{
// check if PIM is stored in MBR
- byte userConfig = 0;
+ uint8 userConfig = 0;
if ( ReadBootSectorConfig (nullptr, 0, &userConfig)
&& (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)
)
@@ -5790,7 +5790,7 @@ namespace VeraCrypt
return configMap;
}
- void BootEncryption::WriteBootDriveSector (uint64 offset, byte *data)
+ void BootEncryption::WriteBootDriveSector (uint64 offset, uint8 *data)
{
WriteBootDriveSectorRequest request;
request.Offset.QuadPart = offset;
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index ddf6f3e5..2ec92503 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -37,8 +37,8 @@ namespace VeraCrypt
bool IsOpened () const { return FileOpen;}
void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
void Close ();
- DWORD Read (byte *buffer, DWORD size);
- void Write (byte *buffer, DWORD size);
+ DWORD Read (uint8 *buffer, DWORD size);
+ void Write (uint8 *buffer, DWORD size);
void SeekAt (int64 position);
void GetFileSize (unsigned __int64& size);
void GetFileSize (DWORD& dwSize);
@@ -70,19 +70,19 @@ namespace VeraCrypt
public:
Buffer (size_t size) : DataSize (size)
{
- DataPtr = new byte[size];
+ DataPtr = new uint8[size];
if (!DataPtr)
throw bad_alloc();
}
~Buffer () { delete[] DataPtr; }
- byte *Ptr () const { return DataPtr; }
+ uint8 *Ptr () const { return DataPtr; }
size_t Size () const { return DataSize; }
void Resize (size_t newSize)
{
if (newSize > DataSize)
{
- byte *tmp = new byte[newSize];
+ uint8 *tmp = new uint8[newSize];
if (!tmp)
throw bad_alloc();
memcpy (tmp, DataPtr, DataSize);
@@ -93,7 +93,7 @@ namespace VeraCrypt
}
protected:
- byte *DataPtr;
+ uint8 *DataPtr;
size_t DataSize;
};
@@ -115,17 +115,17 @@ namespace VeraCrypt
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;
@@ -133,7 +133,7 @@ namespace VeraCrypt
struct MBR
{
- byte Code[446];
+ uint8 Code[446];
PartitionEntryMBR Partitions[4];
uint16 Signature;
};
@@ -200,13 +200,13 @@ namespace VeraCrypt
void DeleteStartExec(uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL);
void SetStartExec(wstring description, wstring execPath, bool setBootEntry = true, bool forceFirstBootEntry = true, bool setBootNext = true, uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL, uint32 attr = 1);
- void SaveFile(const wchar_t* name, byte* data, DWORD size);
+ void SaveFile(const wchar_t* name, uint8* data, DWORD size);
void GetFileSize(const wchar_t* name, unsigned __int64& size);
- void ReadFile(const wchar_t* name, byte* data, DWORD size);
+ void ReadFile(const wchar_t* name, uint8* data, DWORD size);
void CopyFile(const wchar_t* name, const wchar_t* targetName);
bool FileExists(const wchar_t* name);
static bool CompareFiles (const wchar_t* fileName1, const wchar_t* fileName2);
- static bool CompareFileData (const wchar_t* fileName, const byte* data, DWORD size);
+ static bool CompareFileData (const wchar_t* fileName, const uint8* data, DWORD size);
BOOL RenameFile(const wchar_t* name, const wchar_t* nameNew, BOOL bForce);
BOOL DelFile(const wchar_t* name);
@@ -258,7 +258,7 @@ namespace VeraCrypt
DWORD GetDriverServiceStartType ();
unsigned int GetHiddenOSCreationPhase ();
uint16 GetInstalledBootLoaderVersion ();
- void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
+ void GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
Partition GetPartitionForHiddenOS ();
bool IsBootLoaderOnDrive (wchar_t *devicePath);
BootEncryptionStatus GetStatus ();
@@ -275,7 +275,7 @@ namespace VeraCrypt
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5);
void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath);
void ProbeRealSystemDriveSize ();
- bool ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
+ bool ReadBootSectorConfig (uint8 *config, size_t bufLength, uint8 *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
uint32 ReadDriverConfigurationFlags ();
uint32 ReadServiceConfigurationFlags ();
void RegisterBootDriver (bool hiddenSystem);
@@ -295,7 +295,7 @@ namespace VeraCrypt
void StartDecryption (BOOL discardUnreadableEncryptedSectors);
void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm);
void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors);
- bool SystemDriveContainsPartitionType (byte type);
+ bool SystemDriveContainsPartitionType (uint8 type);
bool SystemDriveContainsExtendedPartition ();
bool SystemDriveContainsNonStandardPartitions ();
bool SystemPartitionCoversWholeDrive ();
@@ -303,10 +303,10 @@ namespace VeraCrypt
bool VerifyRescueDisk ();
bool VerifyRescueDiskImage (const wchar_t* imageFile);
void WipeHiddenOSCreationConfig ();
- void WriteBootDriveSector (uint64 offset, byte *data);
- void WriteBootSectorConfig (const byte newConfig[]);
- void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg);
- void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg);
+ void WriteBootDriveSector (uint64 offset, uint8 *data);
+ void WriteBootSectorConfig (const uint8 newConfig[]);
+ void WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg);
+ void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg);
void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value);
void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn);
void BackupSystemLoader ();
@@ -318,10 +318,10 @@ namespace VeraCrypt
protected:
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
- void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
+ void CreateBootLoaderInMemory (uint8 *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim);
wstring GetSystemLoaderBackupPath ();
- uint32 GetChecksum (byte *data, size_t size);
+ uint32 GetChecksum (uint8 *data, size_t size);
DISK_GEOMETRY_EX GetDriveGeometry (int driveNumber);
PartitionList GetDrivePartitions (int driveNumber);
wstring GetRemarksOnHiddenOS ();
@@ -334,11 +334,11 @@ namespace VeraCrypt
int SelectedEncryptionAlgorithmId;
int SelectedPrfAlgorithmId;
Partition HiddenOSCandidatePartition;
- byte *RescueIsoImage;
- byte *RescueZipData;
+ uint8 *RescueIsoImage;
+ uint8 *RescueZipData;
unsigned long RescueZipSize;
- byte RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
- byte VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
+ uint8 RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
+ uint8 VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
bool DriveConfigValid;
bool RealSystemDriveSizeValid;
bool RescueVolumeHeaderValid;
diff --git a/src/Common/CommandAPDU.cpp b/src/Common/CommandAPDU.cpp
index b202cb13..46aab465 100644
--- a/src/Common/CommandAPDU.cpp
+++ b/src/Common/CommandAPDU.cpp
@@ -116,7 +116,7 @@ namespace VeraCrypt
clear();
}
- void CommandAPDU::init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
+ void CommandAPDU::init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
{
m_nc = 0;
m_ne = 0;
@@ -156,7 +156,7 @@ namespace VeraCrypt
{
// case 2s
// 256 is encoded as 0x00
- byte len = (m_ne != 256) ? (byte)m_ne : 0;
+ uint8 len = (m_ne != 256) ? (uint8)m_ne : 0;
m_apdu.resize(5, 0);
setHeader(cla, ins, p1, p2);
m_apdu[4] = len;
@@ -164,7 +164,7 @@ namespace VeraCrypt
else
{
// case 2e
- byte l1, l2;
+ uint8 l1, l2;
// 65536 is encoded as 0x00 0x00
if (m_ne == 65536)
{
@@ -173,8 +173,8 @@ namespace VeraCrypt
}
else
{
- l1 = (byte)(m_ne >> 8);
- l2 = (byte)m_ne;
+ l1 = (uint8)(m_ne >> 8);
+ l2 = (uint8)m_ne;
}
m_apdu.resize(7, 0);
setHeader(cla, ins, p1, p2);
@@ -194,7 +194,7 @@ namespace VeraCrypt
// case 3s
m_apdu.resize(4 + 1 + dataLength, 0);
setHeader(cla, ins, p1, p2);
- m_apdu[4] = (byte)dataLength;
+ m_apdu[4] = (uint8)dataLength;
m_dataOffset = 5;
memcpy(m_apdu.data() + 5, data + dataOffset, dataLength);
}
@@ -204,8 +204,8 @@ namespace VeraCrypt
m_apdu.resize(4 + 3 + dataLength, 0);
setHeader(cla, ins, p1, p2);
m_apdu[4] = 0;
- m_apdu[5] = (byte)(dataLength >> 8);
- m_apdu[6] = (byte)dataLength;
+ m_apdu[5] = (uint8)(dataLength >> 8);
+ m_apdu[6] = (uint8)dataLength;
m_dataOffset = 7;
memcpy(m_apdu.data() + 7, data + dataOffset, dataLength);
m_isExtendedAPDU = true;
@@ -219,10 +219,10 @@ namespace VeraCrypt
// case 4s
m_apdu.resize(4 + 2 + dataLength, 0);
setHeader(cla, ins, p1, p2);
- m_apdu[4] = (byte)dataLength;
+ m_apdu[4] = (uint8)dataLength;
m_dataOffset = 5;
memcpy(m_apdu.data() + 5, data + dataOffset, dataLength);
- m_apdu[m_apdu.size() - 1] = (m_ne != 256) ? (byte)m_ne : 0;
+ m_apdu[m_apdu.size() - 1] = (m_ne != 256) ? (uint8)m_ne : 0;
}
else
{
@@ -230,15 +230,15 @@ namespace VeraCrypt
m_apdu.resize(4 + 5 + dataLength, 0);
setHeader(cla, ins, p1, p2);
m_apdu[4] = 0;
- m_apdu[5] = (byte)(dataLength >> 8);
- m_apdu[6] = (byte)dataLength;
+ m_apdu[5] = (uint8)(dataLength >> 8);
+ m_apdu[6] = (uint8)dataLength;
m_dataOffset = 7;
memcpy(m_apdu.data() + 7, data + dataOffset, dataLength);
if (ne != 65536)
{
size_t leOfs = m_apdu.size() - 2;
- m_apdu[leOfs] = (byte)(m_ne >> 8);
- m_apdu[leOfs + 1] = (byte)m_ne;
+ m_apdu[leOfs] = (uint8)(m_ne >> 8);
+ m_apdu[leOfs + 1] = (uint8)m_ne;
} // else le == 65536: no need to fill in, encoded as 0
m_isExtendedAPDU = true;
}
@@ -248,12 +248,12 @@ namespace VeraCrypt
m_parsedSuccessfully = true;
}
- void CommandAPDU::setHeader(byte cla, byte ins, byte p1, byte p2)
+ void CommandAPDU::setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2)
{
- m_apdu[0] = (byte)cla;
- m_apdu[1] = (byte)ins;
- m_apdu[2] = (byte)p1;
- m_apdu[3] = (byte)p2;
+ m_apdu[0] = (uint8)cla;
+ m_apdu[1] = (uint8)ins;
+ m_apdu[2] = (uint8)p1;
+ m_apdu[3] = (uint8)p2;
}
void CommandAPDU::clear()
@@ -264,58 +264,58 @@ namespace VeraCrypt
m_dataOffset = 0;
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
{
init(cla, ins, p1, p2, data, dataOffset, dataLength, ne);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2)
{
init(cla, ins, p1, p2, NULL, 0, 0, 0);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, uint32 ne)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, uint32 ne)
{
init(cla, ins, p1, p2, NULL, 0, 0, ne);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data)
{
init(cla, ins, p1, p2, data.data(), 0, (uint32)data.size(), 0);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength)
{
init(cla, ins, p1, p2, data, dataOffset, dataLength, 0);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data, uint32 ne)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data, uint32 ne)
{
init(cla, ins, p1, p2, data.data(), 0, (uint32)data.size(), ne);
}
- CommandAPDU::CommandAPDU(const vector<byte>& apdu) : m_nc(0), m_ne(0), m_dataOffset(0), m_isExtendedAPDU(false)
+ CommandAPDU::CommandAPDU(const vector<uint8>& apdu) : m_nc(0), m_ne(0), m_dataOffset(0), m_isExtendedAPDU(false)
{
m_apdu = apdu;
parse();
}
- byte CommandAPDU::getCLA()
+ uint8 CommandAPDU::getCLA()
{
return m_apdu[0] & 0xff;
}
- byte CommandAPDU::getINS()
+ uint8 CommandAPDU::getINS()
{
return m_apdu[1] & 0xff;
}
- byte CommandAPDU::getP1()
+ uint8 CommandAPDU::getP1()
{
return m_apdu[2] & 0xff;
}
- byte CommandAPDU::getP2()
+ uint8 CommandAPDU::getP2()
{
return m_apdu[3] & 0xff;
}
@@ -325,9 +325,9 @@ namespace VeraCrypt
return m_nc;
}
- const vector<byte> CommandAPDU::getData()
+ const vector<uint8> CommandAPDU::getData()
{
- vector<byte> data;
+ vector<uint8> data;
if (m_nc > 0)
{
@@ -343,7 +343,7 @@ namespace VeraCrypt
return m_ne;
}
- const vector<byte> CommandAPDU::getAPDU()
+ const vector<uint8> CommandAPDU::getAPDU()
{
return m_apdu;
}
diff --git a/src/Common/CommandAPDU.h b/src/Common/CommandAPDU.h
index 98825faa..f1adf176 100644
--- a/src/Common/CommandAPDU.h
+++ b/src/Common/CommandAPDU.h
@@ -34,7 +34,7 @@ namespace VeraCrypt
{
protected:
- vector<byte> m_apdu;
+ vector<uint8> m_apdu;
uint32 m_nc;
uint32 m_ne;
uint32 m_dataOffset;
@@ -43,8 +43,8 @@ namespace VeraCrypt
bool m_parsedSuccessfully;
void parse();
- void init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
- void setHeader(byte cla, byte ins, byte p1, byte p2);
+ void init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
+ void setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2);
public:
@@ -52,35 +52,35 @@ namespace VeraCrypt
CommandAPDU();
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, uint32 ne);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, uint32 ne);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data, uint32 ne);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data, uint32 ne);
- CommandAPDU(const vector<byte>& apdu);
+ CommandAPDU(const vector<uint8>& apdu);
- byte getCLA();
+ uint8 getCLA();
- byte getINS();
+ uint8 getINS();
- byte getP1();
+ uint8 getP1();
- byte getP2();
+ uint8 getP2();
uint32 getNc();
- const vector<byte> getData();
+ const vector<uint8> getData();
uint32 getNe();
- const vector<byte> getAPDU();
+ const vector<uint8> getAPDU();
bool isValid();
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index 49948107..9c4ee5a3 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -219,7 +219,7 @@ void EncipherBlock(int cipher, void *data, void *ks)
void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{
- byte *data = dataPtr;
+ uint8 *data = dataPtr;
#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
KFLOATING_SAVE floatingPointState;
#endif
@@ -317,7 +317,7 @@ void DecipherBlock(int cipher, void *data, void *ks)
case AES:
#if defined (_WIN64) || !defined (TC_WINDOWS_DRIVER)
if (IsAesHwCpuSupported())
- aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx), data);
+ aes_hw_cpu_decrypt ((uint8 *) ks + sizeof (aes_encrypt_ctx), data);
else
#endif
aes_decrypt (data, data, (void *) ((char *) ks + sizeof(aes_encrypt_ctx)));
@@ -334,7 +334,7 @@ void DecipherBlock(int cipher, void *data, void *ks)
void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{
- byte *data = dataPtr;
+ uint8 *data = dataPtr;
#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
KFLOATING_SAVE floatingPointState;
#endif
@@ -349,7 +349,7 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{
while (blockCount > 0)
{
- aes_hw_cpu_decrypt_32_blocks ((byte *) ks + sizeof (aes_encrypt_ctx), data);
+ aes_hw_cpu_decrypt_32_blocks ((uint8 *) ks + sizeof (aes_encrypt_ctx), data);
data += 32 * 16;
blockCount -= 32;
@@ -855,7 +855,7 @@ int GetMaxPkcs5OutSize (void)
#ifdef TC_WINDOWS_BOOT
-static byte CryptoInfoBufferInUse = 0;
+static uint8 CryptoInfoBufferInUse = 0;
CRYPTO_INFO CryptoInfoBuffer;
#endif
@@ -1118,7 +1118,7 @@ void EncipherBlock(int cipher, void *data, void *ks)
{
#ifdef TC_WINDOWS_BOOT_AES
if (IsAesHwCpuSupported())
- aes_hw_cpu_encrypt ((byte *) ks, data);
+ aes_hw_cpu_encrypt ((uint8 *) ks, data);
else
aes_encrypt (data, data, ks);
#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
@@ -1134,9 +1134,9 @@ void DecipherBlock(int cipher, void *data, void *ks)
{
#ifdef TC_WINDOWS_BOOT_AES
if (IsAesHwCpuSupported())
- aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data);
+ aes_hw_cpu_decrypt ((uint8 *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data);
else
- aes_decrypt (data, data, (aes_decrypt_ctx *) ((byte *) ks + sizeof(aes_encrypt_ctx)));
+ aes_decrypt (data, data, (aes_decrypt_ctx *) ((uint8 *) ks + sizeof(aes_encrypt_ctx)));
#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_decrypt (data, data, ks);
#elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
@@ -1278,7 +1278,7 @@ BOOL IsRamEncryptionEnabled ()
}
/* masking for random index to remove bias */
-byte GetRngMask (byte count)
+uint8 GetRngMask (uint8 count)
{
if (count >= 128)
return 0xFF;
@@ -1297,10 +1297,10 @@ byte GetRngMask (byte count)
return 1;
}
-byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte elementsCount)
+uint8 GetRandomIndex (ChaCha20RngCtx* pCtx, uint8 elementsCount)
{
- byte index = 0;
- byte mask = GetRngMask (elementsCount);
+ uint8 index = 0;
+ uint8 mask = GetRngMask (elementsCount);
while (TRUE)
{
@@ -1315,7 +1315,7 @@ byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte elementsCount)
#if defined(_WIN64) && !defined (_UEFI)
/* declaration of variables and functions used for RAM encryption on 64-bit build */
-static byte* pbKeyDerivationArea = NULL;
+static uint8* pbKeyDerivationArea = NULL;
static ULONG cbKeyDerivationArea = 0;
static uint64 HashSeedMask = 0;
@@ -1331,9 +1331,9 @@ ULONG AllocTag = 'MMCV';
BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback)
{
ChaCha20RngCtx ctx;
- byte pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
+ uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
#ifdef TC_WINDOWS_DRIVER
- byte i;
+ uint8 i;
char randomStr[4];
Dump ("InitializeSecurityParameters BEGIN\n");
#endif
@@ -1390,7 +1390,7 @@ BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback)
cbKeyDerivationArea = 1024 * 1024;
do
{
- pbKeyDerivationArea = (byte*) TCalloc(cbKeyDerivationArea);
+ pbKeyDerivationArea = (uint8*) TCalloc(cbKeyDerivationArea);
if (!pbKeyDerivationArea)
cbKeyDerivationArea >>= 1;
} while (!pbKeyDerivationArea && (cbKeyDerivationArea >= (2*PAGE_SIZE)));
@@ -1531,25 +1531,25 @@ void VcUnprotectKeys (PCRYPTO_INFO pCryptoInfo, uint64 encID)
#if defined(_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__)
/* dummy implementation that should never be called */
-void aes_hw_cpu_decrypt(const byte* ks, byte* data)
+void aes_hw_cpu_decrypt(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
-void aes_hw_cpu_decrypt_32_blocks(const byte* ks, byte* data)
+void aes_hw_cpu_decrypt_32_blocks(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
-void aes_hw_cpu_encrypt(const byte* ks, byte* data)
+void aes_hw_cpu_encrypt(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
}
-void aes_hw_cpu_encrypt_32_blocks(const byte* ks, byte* data)
+void aes_hw_cpu_encrypt_32_blocks(const uint8* ks, uint8* data)
{
ks = ks;
data = data;
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 4ea10aaa..e7103d0d 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -2884,7 +2884,7 @@ LRESULT CALLBACK CustomDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
static BOOL IsReturnAddress (DWORD64 address)
{
static size_t codeEnd = 0;
- byte *sp = (byte *) address;
+ uint8 *sp = (uint8 *) address;
if (codeEnd == 0)
{
@@ -3018,7 +3018,7 @@ void ExceptionHandlerThread (void *threadArg)
MEMORY_BASIC_INFORMATION mi;
VirtualQuery (sp, &mi, sizeof (mi));
- PDWORD stackTop = (PDWORD)((byte *) mi.BaseAddress + mi.RegionSize);
+ PDWORD stackTop = (PDWORD)((uint8 *) mi.BaseAddress + mi.RegionSize);
int i = 0;
while (retAddrs.size() < 16 && &sp[i] < stackTop)
@@ -5796,24 +5796,24 @@ wstring ArrayToHexWideString (const unsigned char* pbData, int cbData)
return result;
}
-bool HexToByte (wchar_t c, byte& b)
+bool HexToByte (wchar_t c, uint8& b)
{
bool bRet = true;
if (c >= L'0' && c <= L'9')
- b = (byte) (c - L'0');
+ b = (uint8) (c - L'0');
else if (c >= L'a' && c <= L'z')
- b = (byte) (c - L'a' + 10);
+ b = (uint8) (c - L'a' + 10);
else if (c >= L'A' && c <= L'Z')
- b = (byte) (c - L'A' + 10);
+ b = (uint8) (c - L'A' + 10);
else
bRet = false;
return bRet;
}
-bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr)
+bool HexWideStringToArray (const wchar_t* hexStr, std::vector<uint8>& arr)
{
- byte b1, b2;
+ uint8 b1, b2;
size_t i, len = wcslen (hexStr);
arr.clear();
@@ -8716,7 +8716,7 @@ retry:
if ((path.length () >= 3) && (_wcsnicmp (path.c_str(), L"ID:", 3) == 0))
{
- std::vector<byte> arr;
+ std::vector<uint8> arr;
if ( (path.length() == (3 + 2*VOLUME_ID_SIZE))
&& HexWideStringToArray (path.c_str() + 3, arr)
&& (arr.size() == VOLUME_ID_SIZE)
@@ -9168,7 +9168,7 @@ BOOL IsMountedVolume (const wchar_t *volname)
if ((wcslen (volname) == (3 + 2*VOLUME_ID_SIZE)) && _wcsnicmp (volname, L"ID:", 3) == 0)
{
/* Volume ID specified. Use it for matching mounted volumes. */
- std::vector<byte> arr;
+ std::vector<uint8> arr;
if (HexWideStringToArray (&volname[3], arr) && (arr.size() == VOLUME_ID_SIZE))
{
return IsMountedVolumeID (&arr[0]);
@@ -11577,7 +11577,7 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password
// Read volume header
DWORD bytesRead;
- if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (byte *) buffer, &bytesRead))
+ if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (uint8 *) buffer, &bytesRead))
{
status = ERR_OS_ERROR;
goto error;
@@ -12162,7 +12162,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE))
{
DWORD keyfileSize;
- byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize);
+ uint8 *keyfileData = (uint8 *) LoadFile (keyfilePath, &keyfileSize);
if (!keyfileData)
{
handleWin32Error (hwndDlg, SRC_POS);
@@ -12180,7 +12180,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_NEW_TOKEN_KEYFILE), hwndDlg, (DLGPROC) NewSecurityTokenKeyfileDlgProc, (LPARAM) &newParams) == IDOK)
{
- vector <byte> keyfileDataVector (keyfileSize);
+ vector <uint8> keyfileDataVector (keyfileSize);
memcpy (&keyfileDataVector.front(), keyfileData, keyfileSize);
try
@@ -12229,7 +12229,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
WaitCursor();
finally_do ({ NormalCursor(); });
- vector <byte> keyfileData;
+ vector <uint8> keyfileData;
keyfile->GetKeyfileData (keyfileData);
@@ -12240,7 +12240,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
return 1;
}
- finally_do_arg (vector <byte> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
+ finally_do_arg (vector <uint8> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, (DWORD) keyfileData.size(), FALSE, FALSE))
throw SystemException (SRC_POS);
@@ -13023,7 +13023,7 @@ void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors)
ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", cmdPath, param, NULL, SW_SHOW);
}
-BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize)
+BOOL BufferContainsPattern (const uint8 *buffer, size_t bufferSize, const uint8 *pattern, size_t patternSize)
{
if (bufferSize < patternSize)
return FALSE;
@@ -13040,14 +13040,14 @@ BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *p
}
-BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str)
+BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *str)
{
- return BufferContainsPattern (buffer, bufferSize, (const byte*) str, strlen (str));
+ return BufferContainsPattern (buffer, bufferSize, (const uint8*) str, strlen (str));
}
-BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str)
+BOOL BufferContainsWideString (const uint8 *buffer, size_t bufferSize, const wchar_t *str)
{
- return BufferContainsPattern (buffer, bufferSize, (const byte*) str, 2 * wcslen (str));
+ return BufferContainsPattern (buffer, bufferSize, (const uint8*) str, 2 * wcslen (str));
}
@@ -13507,7 +13507,7 @@ void RegisterDriverInf (bool registerFilter, const string& filter, const string&
"[veracrypt_reg]\r\n"
"HKR,,\"" + filterReg + "\",0x0001" + string (registerFilter ? "0008" : "8002") + ",\"" + filter + "\"\r\n";
- infFile.Write ((byte *) infTxt.c_str(), (DWORD) infTxt.size());
+ infFile.Write ((uint8 *) infTxt.c_str(), (DWORD) infTxt.size());
infFile.Close();
HINF hInf = SetupOpenInfFileW (infFileName.c_str(), NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL);
@@ -13582,7 +13582,7 @@ void AllowMessageInUIPI (UINT msg)
ChangeWindowMessageFilter (msg, MSGFLT_ADD);
}
-BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize)
+BOOL IsRepeatedByteArray (uint8 value, const uint8* buffer, size_t bufferSize)
{
if (buffer && bufferSize)
{
@@ -13606,7 +13606,7 @@ BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue)
size_t pathLen = pathValue? wcslen (pathValue) : 0;
if ((pathLen >= 3) && (_wcsnicmp (pathValue, L"ID:", 3) == 0))
{
- std::vector<byte> arr;
+ std::vector<uint8> arr;
if ( (pathLen == (3 + 2*VOLUME_ID_SIZE))
&& HexWideStringToArray (pathValue + 3, arr)
&& (arr.size() == VOLUME_ID_SIZE)
@@ -14758,7 +14758,7 @@ void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
{
LARGE_INTEGER iSeed;
SYSTEMTIME sysTime;
- byte digest[WHIRLPOOL_DIGESTSIZE];
+ uint8 digest[WHIRLPOOL_DIGESTSIZE];
WHIRLPOOL_CTX tctx;
size_t count;
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 750b4dc7..288daecd 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -550,9 +550,9 @@ BOOL InitSecurityTokenLibrary (HWND hwndDlg);
BOOL FileHasReadOnlyAttribute (const wchar_t *path);
BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path);
void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors);
-BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize);
-BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str);
-BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str);
+BOOL BufferContainsPattern (const uint8 *buffer, size_t bufferSize, const uint8 *pattern, size_t patternSize);
+BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *str);
+BOOL BufferContainsWideString (const uint8 *buffer, size_t bufferSize, const wchar_t *str);
int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt);
BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath);
void EnableElevatedCursorChange (HWND parent);
@@ -573,7 +573,7 @@ int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
void AllowMessageInUIPI (UINT msg);
-BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize);
+BOOL IsRepeatedByteArray (uint8 value, const uint8* buffer, size_t bufferSize);
BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue);
BOOL CopyTextToClipboard (const wchar_t* txtValue);
BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args);
@@ -714,7 +714,7 @@ std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wch
std::wstring GetUserFriendlyVersionString (int version);
std::wstring IntToWideString (int val);
std::wstring ArrayToHexWideString (const unsigned char* pbData, int cbData);
-bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr);
+bool HexWideStringToArray (const wchar_t* hexStr, std::vector<uint8>& arr);
std::wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromService);
void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey);
std::wstring GetTempPathString ();
diff --git a/src/Common/EMVCard.cpp b/src/Common/EMVCard.cpp
index e96422b1..59dc3cf0 100644
--- a/src/Common/EMVCard.cpp
+++ b/src/Common/EMVCard.cpp
@@ -40,19 +40,19 @@ namespace VeraCrypt
}
#endif
- map<EMVCardType, vector<byte>> InitializeSupportedAIDs()
+ map<EMVCardType, vector<uint8>> InitializeSupportedAIDs()
{
- map<EMVCardType, vector<byte>> supportedAIDs;
- supportedAIDs.insert(std::make_pair(EMVCardType::AMEX, vector<byte>(EMVCard::AMEX_AID, EMVCard::AMEX_AID + sizeof(EMVCard::AMEX_AID))));
- supportedAIDs.insert(std::make_pair(EMVCardType::MASTERCARD, vector<byte>(EMVCard::MASTERCARD_AID, EMVCard::MASTERCARD_AID + sizeof(EMVCard::MASTERCARD_AID))));
- supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<byte>(EMVCard::VISA_AID, EMVCard::VISA_AID + sizeof(EMVCard::VISA_AID))));
+ map<EMVCardType, vector<uint8>> supportedAIDs;
+ supportedAIDs.insert(std::make_pair(EMVCardType::AMEX, vector<uint8>(EMVCard::AMEX_AID, EMVCard::AMEX_AID + sizeof(EMVCard::AMEX_AID))));
+ supportedAIDs.insert(std::make_pair(EMVCardType::MASTERCARD, vector<uint8>(EMVCard::MASTERCARD_AID, EMVCard::MASTERCARD_AID + sizeof(EMVCard::MASTERCARD_AID))));
+ supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<uint8>(EMVCard::VISA_AID, EMVCard::VISA_AID + sizeof(EMVCard::VISA_AID))));
return supportedAIDs;
}
- const byte EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10};
- const byte EMVCard::MASTERCARD_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10};
- const byte EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10};
- const map<EMVCardType, vector<byte>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs();
+ const uint8 EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10};
+ const uint8 EMVCard::MASTERCARD_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10};
+ const uint8 EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10};
+ const map<EMVCardType, vector<uint8>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs();
EMVCard::EMVCard() : SCard(), m_lastPANDigits(L"")
{
@@ -130,15 +130,15 @@ namespace VeraCrypt
m_lastPANDigits.clear();
}
- vector<byte> EMVCard::GetCardAID(bool forceContactless)
+ vector<uint8> EMVCard::GetCardAID(bool forceContactless)
{
- vector<vector<byte>> supportedAIDs;
- vector<byte> supportedAIDsPriorities;
- vector<pair<byte, vector<byte>>> supportedAIDsSorted;
+ vector<vector<uint8>> supportedAIDs;
+ vector<uint8> supportedAIDsPriorities;
+ vector<pair<uint8, vector<uint8>>> supportedAIDsSorted;
bool hasBeenReset = false;
CommandAPDU command;
ResponseAPDU response;
- vector<byte> responseData;
+ vector<uint8> responseData;
shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> fciNode;
shared_ptr<TLVNode> dfNameNode;
@@ -149,7 +149,7 @@ namespace VeraCrypt
vector<shared_ptr<TLVNode>> pseDirectoryNodes;
unsigned char sfi;
bool usingContactless = false;
- vector<byte> tokenAID;
+ vector<uint8> tokenAID;
if (m_aid.size())
return m_aid;
@@ -241,7 +241,7 @@ namespace VeraCrypt
{
sfi = sfiNode->Value->at(0);
- byte rec = 1;
+ uint8 rec = 1;
do
{
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec++, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
@@ -316,20 +316,20 @@ namespace VeraCrypt
return tokenAID;
}
- void EMVCard::GetCardContent(vector<byte>& iccCert, vector<byte>& issuerCert, vector<byte>& cplcData)
+ void EMVCard::GetCardContent(vector<uint8>& iccCert, vector<uint8>& issuerCert, vector<uint8>& cplcData)
{
bool hasBeenReset = false;
bool aidSelected = false;
bool iccFound = false;
bool issuerFound = false;
bool cplcFound = false;
- vector<byte> emvCardAid;
+ vector<uint8> emvCardAid;
shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> iccPublicKeyCertNode;
shared_ptr<TLVNode> issuerPublicKeyCertNode;
CommandAPDU command;
ResponseAPDU response;
- vector<byte> responseData;
+ vector<uint8> responseData;
iccCert.clear();
issuerCert.clear();
@@ -374,9 +374,9 @@ namespace VeraCrypt
// TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL,
// which will then be used to get the actual start and end of sfi and rec.
- for (byte sfi = 1; sfi < 32 && (!iccFound || !issuerFound); sfi++)
+ for (uint8 sfi = 1; sfi < 32 && (!iccFound || !issuerFound); sfi++)
{
- for (byte rec = 1; rec < 17 && (!iccFound || !issuerFound); rec++)
+ for (uint8 rec = 1; rec < 17 && (!iccFound || !issuerFound); rec++)
{
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response);
@@ -436,13 +436,13 @@ namespace VeraCrypt
bool hasBeenReset = false;
bool panFound = false;
bool aidSelected = false;
- vector<byte> EMVCardAid;
- vector<byte> panData;
+ vector<uint8> EMVCardAid;
+ vector<uint8> panData;
shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> panNode;
CommandAPDU command;
ResponseAPDU response;
- vector<byte> responseData;
+ vector<uint8> responseData;
lastPANDigits = L"";
@@ -474,9 +474,9 @@ namespace VeraCrypt
// TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL,
// which will then be used to get the actual start and end of sfi and rec.
- for (byte sfi = 1; sfi < 32 && !panFound; sfi++)
+ for (uint8 sfi = 1; sfi < 32 && !panFound; sfi++)
{
- for (byte rec = 1; rec < 17 && !panFound; rec++)
+ for (uint8 rec = 1; rec < 17 && !panFound; rec++)
{
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response);
@@ -498,7 +498,7 @@ namespace VeraCrypt
{
panFound = true;
panData = *panNode->Value.get();
- panData = vector<byte>(panData.rbegin(), panData.rbegin() + 2); // only interested in last digits
+ panData = vector<uint8>(panData.rbegin(), panData.rbegin() + 2); // only interested in last digits
std::swap(panData[0], panData[1]);
lastPANDigits = ArrayToHexWideString(panData.data(), (int) panData.size());
}
diff --git a/src/Common/EMVCard.h b/src/Common/EMVCard.h
index 116de705..70ef035f 100644
--- a/src/Common/EMVCard.h
+++ b/src/Common/EMVCard.h
@@ -29,11 +29,11 @@ namespace VeraCrypt
// After the card has been read, and if some or all fields cannot be read, the EMVCard
// object will be considered invalid and will not be included in the list of available cards
// of EMVToken.
- vector<byte> m_aid;
- vector<vector<byte>> m_supportedAids;
- vector<byte> m_iccCert;
- vector<byte> m_issuerCert;
- vector<byte> m_cplcData;
+ vector<uint8> m_aid;
+ vector<vector<uint8>> m_supportedAids;
+ vector<uint8> m_iccCert;
+ vector<uint8> m_issuerCert;
+ vector<uint8> m_cplcData;
wstring m_lastPANDigits;
public:
@@ -41,10 +41,10 @@ namespace VeraCrypt
// Add other AIDS
// https://gist.github.com/pvieito/6224eed92c99b069f6401996c548d0e4
// https://ambimat.com/developer-resources/list-of-application-identifiers-aid/
- const static byte AMEX_AID[7];
- const static byte MASTERCARD_AID[7];
- const static byte VISA_AID[7];
- const static map<EMVCardType, vector<byte>> SUPPORTED_AIDS;
+ const static uint8 AMEX_AID[7];
+ const static uint8 MASTERCARD_AID[7];
+ const static uint8 VISA_AID[7];
+ const static map<EMVCardType, vector<uint8>> SUPPORTED_AIDS;
EMVCard();
EMVCard(size_t slotId);
@@ -59,9 +59,9 @@ namespace VeraCrypt
// Retrieves the card's AID.
// It first checks the card against a list of supported AIDs.
// If that fails, it tries getting the AID from the card using PSE
- vector<byte> GetCardAID(bool forceContactless = false);
+ vector<uint8> GetCardAID(bool forceContactless = false);
- void GetCardContent(vector<byte>& iccCert, vector<byte>& issuerCert, vector<byte>& cplcData);
+ void GetCardContent(vector<uint8>& iccCert, vector<uint8>& issuerCert, vector<uint8>& cplcData);
void GetCardPAN(wstring& lastPANDigits);
};
}
diff --git a/src/Common/EMVToken.cpp b/src/Common/EMVToken.cpp
index 0fe3dc1f..8f89cb7e 100644
--- a/src/Common/EMVToken.cpp
+++ b/src/Common/EMVToken.cpp
@@ -22,7 +22,7 @@ using namespace std;
namespace VeraCrypt
{
- void AppendData(vector<byte>& buffer, const unsigned char* pbData, size_t cbData, size_t from, size_t length, bool bEncodeLength = false)
+ void AppendData(vector<uint8>& buffer, const unsigned char* pbData, size_t cbData, size_t from, size_t length, bool bEncodeLength = false)
{
if (cbData > 0 && from <= cbData - 2 && length > 0 && length <= cbData - from)
{
@@ -74,13 +74,13 @@ namespace VeraCrypt
return path.str();
}
- void EMVTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const
+ void EMVTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const
{
map <unsigned long int, shared_ptr<EMVCard>>::iterator emvCardsIt;
shared_ptr<EMVCard> card;
- vector<byte> iccCert;
- vector<byte> issuerCert;
- vector<byte> cplcData;
+ vector<uint8> iccCert;
+ vector<uint8> issuerCert;
+ vector<uint8> cplcData;
bool addNewCard = true;
keyfileData.clear();
diff --git a/src/Common/EMVToken.h b/src/Common/EMVToken.h
index a1c0a2e1..d82ea542 100644
--- a/src/Common/EMVToken.h
+++ b/src/Common/EMVToken.h
@@ -23,7 +23,7 @@ namespace VeraCrypt
virtual ~EMVTokenKeyfile() {};
virtual operator TokenKeyfilePath () const;
- virtual void GetKeyfileData(vector <byte>& keyfileData) const;
+ virtual void GetKeyfileData(vector <uint8>& keyfileData) const;
};
class EMVToken
@@ -33,7 +33,7 @@ namespace VeraCrypt
static vector<EMVTokenKeyfile> GetAvailableKeyfiles(unsigned long int* slotIdFilter = nullptr, const wstring& keyfileIdFilter = wstring());
static EMVTokenInfo GetTokenInfo(unsigned long int slotId);
- friend void EMVTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const;
+ friend void EMVTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const;
static map <unsigned long int, shared_ptr<EMVCard>> EMVCards;
};
diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c
index 62b2cae8..79f1c890 100644
--- a/src/Common/EncryptionThreadPool.c
+++ b/src/Common/EncryptionThreadPool.c
@@ -88,7 +88,7 @@ typedef struct EncryptionThreadPoolWorkItemStruct
struct
{
PCRYPTO_INFO CryptoInfo;
- byte *Data;
+ uint8 *Data;
UINT64_STRUCT StartUnitNo;
uint32 UnitCount;
@@ -606,13 +606,13 @@ void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivat
}
-void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo)
+void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo)
{
uint32 fragmentCount;
uint32 unitsPerFragment;
uint32 remainder;
- byte *fragmentData;
+ uint8 *fragmentData;
uint64 fragmentStartUnitNo;
EncryptionThreadPoolWorkItem *workItem;
diff --git a/src/Common/EncryptionThreadPool.h b/src/Common/EncryptionThreadPool.h
index 053d4107..71df4e4d 100644
--- a/src/Common/EncryptionThreadPool.h
+++ b/src/Common/EncryptionThreadPool.h
@@ -34,7 +34,7 @@ size_t GetCpuCount (WORD* pGroupCount);
void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, char *derivedKey);
void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivationCompletedEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG* outstandingWorkItemCount, void* keyInfoBuffer, int keyInfoBufferSize, void* keyDerivationWorkItems, int keyDerivationWorkItemsSize);
-void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo);
+void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo);
BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount);
void EncryptionThreadPoolStop ();
size_t GetEncryptionThreadCount ();
diff --git a/src/Common/Fat.h b/src/Common/Fat.h
index b2457be2..19b5cebb 100644
--- a/src/Common/Fat.h
+++ b/src/Common/Fat.h
@@ -14,7 +14,7 @@
typedef struct fatparams_t
{
char volume_name[11];
- byte volume_id[4];
+ uint8 volume_id[4];
unsigned int num_sectors; /* total number of sectors */
int cluster_count; /* number of clusters */
int size_root_dir; /* size of the root directory in bytes */
diff --git a/src/Common/Format.c b/src/Common/Format.c
index 4d8dfed9..7eff80e6 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -532,7 +532,7 @@ begin_format:
// To prevent fragmentation, write zeroes to reserved header sectors which are going to be filled with random data
if (!volParams->bDevice && !volParams->hiddenVol)
{
- byte buf[TC_VOLUME_HEADER_GROUP_SIZE - TC_VOLUME_HEADER_EFFECTIVE_SIZE];
+ uint8 buf[TC_VOLUME_HEADER_GROUP_SIZE - TC_VOLUME_HEADER_EFFECTIVE_SIZE];
DWORD bytesWritten;
ZeroMemory (buf, sizeof (buf));
@@ -1392,7 +1392,7 @@ static volatile BOOL WriteThreadRunning;
static volatile BOOL WriteThreadExitRequested;
static HANDLE WriteThreadHandle;
-static byte *WriteThreadBuffer;
+static uint8 *WriteThreadBuffer;
static HANDLE WriteBufferEmptyEvent;
static HANDLE WriteBufferFullEvent;
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index d10daa06..6d9907cd 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -253,7 +253,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
if (Token::IsKeyfilePathValid (kf->FileName, EMVSupportEnabled? true : false))
{
// Apply security token keyfile
- vector <byte> keyfileData;
+ vector <uint8> keyfileData;
TokenKeyfilePath secPath (kf->FileName);
Token::getTokenKeyfile (secPath)->GetKeyfileData (keyfileData);
diff --git a/src/Common/ResponseAPDU.cpp b/src/Common/ResponseAPDU.cpp
index 8a7f069c..3fe3b6de 100644
--- a/src/Common/ResponseAPDU.cpp
+++ b/src/Common/ResponseAPDU.cpp
@@ -5,7 +5,7 @@ using namespace std;
namespace VeraCrypt
{
- uint16 BytesToUInt16(const vector<byte>& buff)
+ uint16 BytesToUInt16(const vector<uint8>& buff)
{
uint16 value = 0;
for (uint16 i = 0; i < buff.size(); i++)
@@ -17,7 +17,7 @@ namespace VeraCrypt
return value;
}
- void AppendData (vector<byte>& buffer, const byte* pbData, size_t cbData)
+ void AppendData (vector<uint8>& buffer, const uint8* pbData, size_t cbData)
{
size_t orgSize = buffer.size ();
buffer.resize (orgSize + cbData);
@@ -36,7 +36,7 @@ namespace VeraCrypt
{
}
- ResponseAPDU::ResponseAPDU(const vector<byte>& data, uint16 SW)
+ ResponseAPDU::ResponseAPDU(const vector<uint8>& data, uint16 SW)
{
m_data = data;
m_SW = SW;
@@ -47,19 +47,19 @@ namespace VeraCrypt
return (uint32)m_data.size();
}
- const vector<byte> ResponseAPDU::getData()
+ const vector<uint8> ResponseAPDU::getData()
{
return m_data;
}
- byte ResponseAPDU::getSW1()
+ uint8 ResponseAPDU::getSW1()
{
- return (byte)((0xFF00 & m_SW) >> 8);
+ return (uint8)((0xFF00 & m_SW) >> 8);
}
- byte ResponseAPDU::getSW2()
+ uint8 ResponseAPDU::getSW2()
{
- return (byte)(0x00FF & m_SW);
+ return (uint8)(0x00FF & m_SW);
}
uint16 ResponseAPDU::getSW()
@@ -67,23 +67,23 @@ namespace VeraCrypt
return m_SW;
}
- const vector<byte> ResponseAPDU::getBytes()
+ const vector<uint8> ResponseAPDU::getBytes()
{
- vector<byte> apdu;
+ vector<uint8> apdu;
AppendData(apdu, m_data.data(), m_data.size());
- apdu.push_back((byte)getSW1());
- apdu.push_back((byte)getSW2());
+ apdu.push_back((uint8)getSW1());
+ apdu.push_back((uint8)getSW2());
return apdu;
}
- void ResponseAPDU::appendData(const vector<byte>& data)
+ void ResponseAPDU::appendData(const vector<uint8>& data)
{
appendData(data.data(), data.size());
}
- void ResponseAPDU::appendData(const byte* data, size_t dataLen)
+ void ResponseAPDU::appendData(const uint8* data, size_t dataLen)
{
AppendData(m_data, data, dataLen);
}
@@ -93,12 +93,12 @@ namespace VeraCrypt
m_SW = SW;
}
- void ResponseAPDU::setBytes(const vector<byte>& bytes)
+ void ResponseAPDU::setBytes(const vector<uint8>& bytes)
{
clear();
if (bytes.size() >= 2)
{
- vector<byte> SWBytes;
+ vector<uint8> SWBytes;
m_data.resize(bytes.size() - 2);
SWBytes.resize(2);
diff --git a/src/Common/ResponseAPDU.h b/src/Common/ResponseAPDU.h
index b9aa4adc..f279afca 100644
--- a/src/Common/ResponseAPDU.h
+++ b/src/Common/ResponseAPDU.h
@@ -9,7 +9,7 @@ namespace VeraCrypt
{
protected:
- vector<byte> m_data;
+ vector<uint8> m_data;
uint16 m_SW;
@@ -19,25 +19,25 @@ namespace VeraCrypt
ResponseAPDU();
- ResponseAPDU(const vector<byte>& data, uint16 SW);
+ ResponseAPDU(const vector<uint8>& data, uint16 SW);
uint32 getNr();
- const vector<byte> getData();
+ const vector<uint8> getData();
- byte getSW1();
+ uint8 getSW1();
- byte getSW2();
+ uint8 getSW2();
uint16 getSW();
- const vector<byte> getBytes();
+ const vector<uint8> getBytes();
void setSW(uint16 SW);
- void setBytes(const vector<byte>& bytes);
+ void setBytes(const vector<uint8>& bytes);
- void appendData(const vector<byte>& data);
- void appendData(const byte* data, size_t dataLen);
+ void appendData(const vector<uint8>& data);
+ void appendData(const uint8* data, size_t dataLen);
};
};
diff --git a/src/Common/SCardLoader.h b/src/Common/SCardLoader.h
index b1ab114b..a7243d82 100644
--- a/src/Common/SCardLoader.h
+++ b/src/Common/SCardLoader.h
@@ -14,7 +14,7 @@
#include <PCSC/wintypes.h>
#include "reader.h"
typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE;
-using VeraCrypt::byte;
+using VeraCrypt::uint8;
#define BOOL int
#else
#undef BOOL
@@ -22,7 +22,7 @@ using VeraCrypt::byte;
#include <winscard.h>
#include <wintypes.h>
#include <reader.h>
-using VeraCrypt::byte;
+using VeraCrypt::uint8;
#define BOOL int
#endif
#endif
diff --git a/src/Common/SCardReader.cpp b/src/Common/SCardReader.cpp
index 3a762415..de269ce6 100644
--- a/src/Common/SCardReader.cpp
+++ b/src/Common/SCardReader.cpp
@@ -117,7 +117,7 @@ namespace VeraCrypt
return name;
}
- bool SCardReader::IsCardPresent(vector<byte>& cardAtr)
+ bool SCardReader::IsCardPresent(vector<uint8>& cardAtr)
{
LONG lRet = SCARD_S_SUCCESS;
SCARD_READERSTATE state;
@@ -165,7 +165,7 @@ namespace VeraCrypt
bool SCardReader::IsCardPresent()
{
- vector<byte> dummy;
+ vector<uint8> dummy;
return IsCardPresent(dummy);
}
@@ -398,8 +398,8 @@ namespace VeraCrypt
size_t indexOfLe = 0;
size_t indexOfLcData = 0;
- vector<byte> pbSendBuffer;
- vector<byte> pbRecvBuffer;
+ vector<uint8> pbSendBuffer;
+ vector<uint8> pbRecvBuffer;
DWORD cbSendLength = 0;
DWORD cbRecvLength = 0;
@@ -460,7 +460,7 @@ namespace VeraCrypt
// 256 is encoded as 0x00
pbSendBuffer[4] = (BYTE)ne;
indexOfLe = 4;
- cbSendLength = 4 + 1; // header || Le (1 byte)
+ cbSendLength = 4 + 1; // header || Le (1 uint8)
}
else
{
@@ -494,7 +494,7 @@ namespace VeraCrypt
// case 3s
pbSendBuffer[4] = (BYTE)nc;
indexOfLcData = 5;
- cbSendLength = 4 + 1 + nc; // header || Lc (1 byte) || Data
+ cbSendLength = 4 + 1 + nc; // header || Lc (1 uint8) || Data
memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc);
}
else
@@ -518,7 +518,7 @@ namespace VeraCrypt
// case 4s
pbSendBuffer[4] = (BYTE)nc;
indexOfLcData = 5;
- cbSendLength = 4 + 1 + nc + 1; // header || Lc (1 byte) || Data || Le (1 byte)
+ cbSendLength = 4 + 1 + nc + 1; // header || Lc (1 uint8) || Data || Le (1 uint8)
memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc);
pbSendBuffer[indexOfLcData + nc] = (ne != 256) ? (BYTE)ne : 0;
indexOfLe = indexOfLcData + nc;
@@ -646,9 +646,9 @@ namespace VeraCrypt
throw PCSCException(lRet);
}
- void SCardReader::GetATRFromHandle(vector<byte>& atrValue)
+ void SCardReader::GetATRFromHandle(vector<uint8>& atrValue)
{
- vector<byte> pbATR;
+ vector<uint8> pbATR;
DWORD cByte = 0;
LONG lRet = 0;
diff --git a/src/Common/SCardReader.h b/src/Common/SCardReader.h
index 95586963..8814bce0 100644
--- a/src/Common/SCardReader.h
+++ b/src/Common/SCardReader.h
@@ -51,52 +51,52 @@ namespace VeraCrypt
/* ================================================================================================ */
/* CLA values */
/* ================================================================================================ */
- const byte CLA_ISO7816 = (byte)0x00;
- const byte CLA_COMMAND_CHAINING = (byte)0x10;
+ const uint8 CLA_ISO7816 = (uint8)0x00;
+ const uint8 CLA_COMMAND_CHAINING = (uint8)0x10;
/* ================================================================================================ */
/* INS values */
/* ================================================================================================ */
- const byte INS_ERASE_BINARY = 0x0E;
- const byte INS_VERIFY = 0x20;
- const byte INS_CHANGE_CHV = 0x24;
- const byte INS_UNBLOCK_CHV = 0x2C;
- const byte INS_DECREASE = 0x30;
- const byte INS_INCREASE = 0x32;
- const byte INS_DECREASE_STAMPED = 0x34;
- const byte INS_REHABILITATE_CHV = 0x44;
- const byte INS_MANAGE_CHANNEL = 0x70;
- const byte INS_EXTERNAL_AUTHENTICATE = (byte)0x82;
- const byte INS_MUTUAL_AUTHENTICATE = (byte)0x82;
- const byte INS_GET_CHALLENGE = (byte)0x84;
- const byte INS_ASK_RANDOM = (byte)0x84;
- const byte INS_GIVE_RANDOM = (byte)0x86;
- const byte INS_INTERNAL_AUTHENTICATE = (byte)0x88;
- const byte INS_SEEK = (byte)0xA2;
- const byte INS_SELECT = (byte)0xA4;
- const byte INS_SELECT_FILE = (byte)0xA4;
- const byte INS_CLOSE_APPLICATION = (byte)0xAC;
- const byte INS_READ_BINARY = (byte)0xB0;
- const byte INS_READ_BINARY2 = (byte)0xB1;
- const byte INS_READ_RECORD = (byte)0xB2;
- const byte INS_READ_RECORD2 = (byte)0xB3;
- const byte INS_READ_RECORDS = (byte)0xB2;
- const byte INS_READ_BINARY_STAMPED = (byte)0xB4;
- const byte INS_READ_RECORD_STAMPED = (byte)0xB6;
- const byte INS_GET_RESPONSE = (byte)0xC0;
- const byte INS_ENVELOPE = (byte)0xC2;
- const byte INS_GET_DATA = (byte)0xCA;
- const byte INS_WRITE_BINARY = (byte)0xD0;
- const byte INS_WRITE_RECORD = (byte)0xD2;
- const byte INS_UPDATE_BINARY = (byte)0xD6;
- const byte INS_LOAD_KEY_FILE = (byte)0xD8;
- const byte INS_PUT_DATA = (byte)0xDA;
- const byte INS_UPDATE_RECORD = (byte)0xDC;
- const byte INS_CREATE_FILE = (byte)0xE0;
- const byte INS_APPEND_RECORD = (byte)0xE2;
- const byte INS_DELETE_FILE = (byte)0xE4;
- const byte INS_PSO = (byte)0x2A;
- const byte INS_MSE = (byte)0x22;
+ const uint8 INS_ERASE_BINARY = 0x0E;
+ const uint8 INS_VERIFY = 0x20;
+ const uint8 INS_CHANGE_CHV = 0x24;
+ const uint8 INS_UNBLOCK_CHV = 0x2C;
+ const uint8 INS_DECREASE = 0x30;
+ const uint8 INS_INCREASE = 0x32;
+ const uint8 INS_DECREASE_STAMPED = 0x34;
+ const uint8 INS_REHABILITATE_CHV = 0x44;
+ const uint8 INS_MANAGE_CHANNEL = 0x70;
+ const uint8 INS_EXTERNAL_AUTHENTICATE = (uint8)0x82;
+ const uint8 INS_MUTUAL_AUTHENTICATE = (uint8)0x82;
+ const uint8 INS_GET_CHALLENGE = (uint8)0x84;
+ const uint8 INS_ASK_RANDOM = (uint8)0x84;
+ const uint8 INS_GIVE_RANDOM = (uint8)0x86;
+ const uint8 INS_INTERNAL_AUTHENTICATE = (uint8)0x88;
+ const uint8 INS_SEEK = (uint8)0xA2;
+ const uint8 INS_SELECT = (uint8)0xA4;
+ const uint8 INS_SELECT_FILE = (uint8)0xA4;
+ const uint8 INS_CLOSE_APPLICATION = (uint8)0xAC;
+ const uint8 INS_READ_BINARY = (uint8)0xB0;
+ const uint8 INS_READ_BINARY2 = (uint8)0xB1;
+ const uint8 INS_READ_RECORD = (uint8)0xB2;
+ const uint8 INS_READ_RECORD2 = (uint8)0xB3;
+ const uint8 INS_READ_RECORDS = (uint8)0xB2;
+ const uint8 INS_READ_BINARY_STAMPED = (uint8)0xB4;
+ const uint8 INS_READ_RECORD_STAMPED = (uint8)0xB6;
+ const uint8 INS_GET_RESPONSE = (uint8)0xC0;
+ const uint8 INS_ENVELOPE = (uint8)0xC2;
+ const uint8 INS_GET_DATA = (uint8)0xCA;
+ const uint8 INS_WRITE_BINARY = (uint8)0xD0;
+ const uint8 INS_WRITE_RECORD = (uint8)0xD2;
+ const uint8 INS_UPDATE_BINARY = (uint8)0xD6;
+ const uint8 INS_LOAD_KEY_FILE = (uint8)0xD8;
+ const uint8 INS_PUT_DATA = (uint8)0xDA;
+ const uint8 INS_UPDATE_RECORD = (uint8)0xDC;
+ const uint8 INS_CREATE_FILE = (uint8)0xE0;
+ const uint8 INS_APPEND_RECORD = (uint8)0xE2;
+ const uint8 INS_DELETE_FILE = (uint8)0xE4;
+ const uint8 INS_PSO = (uint8)0x2A;
+ const uint8 INS_MSE = (uint8)0x22;
/* ================================================================================================ */
/* EMV values */
@@ -104,19 +104,19 @@ namespace VeraCrypt
const uint16 EMV_CPLC_TAG = (uint16)0x9F7F;
const uint16 EMV_ICC_PK_CERT_TAG = (uint16)0x9F46;
const uint16 EMV_FCI_ISSUER_DISCRETIONARY_DATA_TAG = (uint16)0xBF0C;
- const byte EMV_ISS_PK_CERT_TAG = (byte)0x90;
- const byte EMV_PAN_TAG = (byte)0x5A;
- const byte EMV_FCI_TAG = (byte)0x6F;
- const byte EMV_DFNAME_TAG = (byte)0x84;
- const byte EMV_FCI_ISSUER_TAG = (byte)0xA5;
- const byte EMV_DIRECTORY_ENTRY_TAG = (byte)0x61;
- const byte EMV_SFI_TAG = (byte)0x88;
- const byte EMV_TEMPLATE_TAG = (byte)0x70;
- const byte EMV_AID_TAG = (byte)0x4F;
- const byte EMV_LABEL_TAG = (byte)0x50;
- const byte EMV_PRIORITY_TAG = (byte)0x87;
- const byte EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact)
- const byte EMV_PSE2[] = { 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "2PAY.SYS.DDF01" (contactless)
+ const uint8 EMV_ISS_PK_CERT_TAG = (uint8)0x90;
+ const uint8 EMV_PAN_TAG = (uint8)0x5A;
+ const uint8 EMV_FCI_TAG = (uint8)0x6F;
+ const uint8 EMV_DFNAME_TAG = (uint8)0x84;
+ const uint8 EMV_FCI_ISSUER_TAG = (uint8)0xA5;
+ const uint8 EMV_DIRECTORY_ENTRY_TAG = (uint8)0x61;
+ const uint8 EMV_SFI_TAG = (uint8)0x88;
+ const uint8 EMV_TEMPLATE_TAG = (uint8)0x70;
+ const uint8 EMV_AID_TAG = (uint8)0x4F;
+ const uint8 EMV_LABEL_TAG = (uint8)0x50;
+ const uint8 EMV_PRIORITY_TAG = (uint8)0x87;
+ const uint8 EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact)
+ const uint8 EMV_PSE2[] = { 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "2PAY.SYS.DDF01" (contactless)
/* ================================================================================================ */
@@ -173,7 +173,7 @@ namespace VeraCrypt
// Card Connection management methods
// ------------------------------------------------------------------------------------------------------------------------------------- //
- bool IsCardPresent(vector<byte>& cardAtr);
+ bool IsCardPresent(vector<uint8>& cardAtr);
bool IsCardPresent();
LONG CardHandleStatus();
@@ -193,7 +193,7 @@ namespace VeraCrypt
void ApduProcessData(CommandAPDU commandAPDU, ResponseAPDU& responseAPDU) const;
- void GetATRFromHandle(vector<byte>& atrValue);
+ void GetATRFromHandle(vector<uint8>& atrValue);
};
};
diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp
index ad8ed33e..2a8222e6 100644
--- a/src/Common/SecurityToken.cpp
+++ b/src/Common/SecurityToken.cpp
@@ -123,7 +123,7 @@ namespace VeraCrypt
Sessions.erase(Sessions.find(slotId));
}
- void SecurityToken::CreateKeyfile(CK_SLOT_ID slotId, vector <byte>& keyfileData, const string& name)
+ void SecurityToken::CreateKeyfile(CK_SLOT_ID slotId, vector <uint8>& keyfileData, const string& name)
{
if (name.empty())
throw ParameterIncorrect(SRC_POS);
@@ -167,10 +167,10 @@ namespace VeraCrypt
throw Pkcs11Exception(status);
// Some tokens report success even if the new object was truncated to fit in the available memory
- vector <byte> objectData;
+ vector <uint8> objectData;
GetObjectAttribute(slotId, keyfileHandle, CKA_VALUE, objectData);
- finally_do_arg(vector <byte> *, &objectData, { if (!finally_arg->empty()) burn(&finally_arg->front(), finally_arg->size()); });
+ finally_do_arg(vector <uint8> *, &objectData, { if (!finally_arg->empty()) burn(&finally_arg->front(), finally_arg->size()); });
if (objectData.size() != keyfileData.size())
{
@@ -227,13 +227,13 @@ namespace VeraCrypt
keyfile.Token->SlotId = slotId;
keyfile.Token = shared_ptr<SecurityTokenInfo>(new SecurityTokenInfo(token));
- vector <byte> privateAttrib;
+ vector <uint8> privateAttrib;
GetObjectAttribute(slotId, dataHandle, CKA_PRIVATE, privateAttrib);
if (privateAttrib.size() == sizeof(CK_BBOOL) && *(CK_BBOOL*)&privateAttrib.front() != CK_TRUE)
continue;
- vector <byte> label;
+ vector <uint8> label;
GetObjectAttribute(slotId, dataHandle, CKA_LABEL, label);
label.push_back(0);
@@ -320,7 +320,7 @@ namespace VeraCrypt
return token;
}
- void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const
+ void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const
{
SecurityToken::LoginUserIfRequired(Token->SlotId);
SecurityToken::GetObjectAttribute(Token->SlotId, Handle, CKA_VALUE, keyfileData);
@@ -361,7 +361,7 @@ namespace VeraCrypt
return objects;
}
- void SecurityToken::GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <byte>& attributeValue)
+ void SecurityToken::GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <uint8>& attributeValue)
{
attributeValue.clear();
@@ -379,7 +379,7 @@ namespace VeraCrypt
if (attribute.ulValueLen == 0)
return;
- attributeValue = vector <byte>(attribute.ulValueLen);
+ attributeValue = vector <uint8>(attribute.ulValueLen);
attribute.pValue = &attributeValue.front();
status = Pkcs11Functions->C_GetAttributeValue(Sessions[slotId].Handle, tokenObject, &attribute, 1);
diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h
index 4dff42fa..6c454def 100644
--- a/src/Common/SecurityToken.h
+++ b/src/Common/SecurityToken.h
@@ -76,7 +76,7 @@ namespace VeraCrypt
operator TokenKeyfilePath () const;
- void GetKeyfileData(vector<byte>& keyfileData) const;
+ void GetKeyfileData(vector<uint8>& keyfileData) const;
string IdUtf8;
CK_OBJECT_HANDLE Handle;
@@ -181,7 +181,7 @@ namespace VeraCrypt
public:
static void CloseAllSessions() throw ();
static void CloseLibrary();
- static void CreateKeyfile(CK_SLOT_ID slotId, vector <byte>& keyfileData, const string& name);
+ static void CreateKeyfile(CK_SLOT_ID slotId, vector <uint8>& keyfileData, const string& name);
static void DeleteKeyfile(const SecurityTokenKeyfile& keyfile);
static vector <SecurityTokenKeyfile> GetAvailableKeyfiles(CK_SLOT_ID* slotIdFilter = nullptr, const wstring keyfileIdFilter = wstring());
static list <SecurityTokenInfo> GetAvailableTokens();
@@ -199,7 +199,7 @@ namespace VeraCrypt
protected:
static void CloseSession(CK_SLOT_ID slotId);
static vector <CK_OBJECT_HANDLE> GetObjects(CK_SLOT_ID slotId, CK_ATTRIBUTE_TYPE objectClass);
- static void GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <byte>& attributeValue);
+ static void GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <uint8>& attributeValue);
static list <CK_SLOT_ID> GetTokenSlots();
static void Login(CK_SLOT_ID slotId, const char* pin);
static void LoginUserIfRequired(CK_SLOT_ID slotId);
@@ -217,7 +217,7 @@ namespace VeraCrypt
static map <CK_SLOT_ID, Pkcs11Session> Sessions;
static unique_ptr <SendExceptionFunctor> WarningCallback;
- friend void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const;
+ friend void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const;
};
}
diff --git a/src/Common/TLVParser.cpp b/src/Common/TLVParser.cpp
index 9a177007..1e51739c 100644
--- a/src/Common/TLVParser.cpp
+++ b/src/Common/TLVParser.cpp
@@ -13,7 +13,7 @@ namespace VeraCrypt
}
/* Check if the bit is correct */
- uint16 TLVParser::CheckBit(byte value, int bit)
+ uint16 TLVParser::CheckBit(uint8 value, int bit)
{
unsigned char bitvalue[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
@@ -36,13 +36,13 @@ namespace VeraCrypt
}
/* Parsing one TLV node */
- shared_ptr<TLVNode> TLVParser::TLV_Parse_One(byte* buf, size_t size)
+ shared_ptr<TLVNode> TLVParser::TLV_Parse_One(uint8* buf, size_t size)
{
size_t index = 0;
size_t i = 0;
- byte tag1, tag2, tagsize;
- byte len, lensize;
- shared_ptr<vector<byte>> value = make_shared<vector<byte>>();
+ uint8 tag1, tag2, tagsize;
+ uint8 len, lensize;
+ shared_ptr<vector<uint8>> value = make_shared<vector<uint8>>();
shared_ptr<TLVNode> node = TLV_CreateNode();
tag1 = tag2 = 0;
@@ -157,7 +157,7 @@ namespace VeraCrypt
}
/* Parsing TLV from a buffer and constructing TLV structure */
- shared_ptr<TLVNode> TLVParser::TLV_Parse(byte* buf, size_t size)
+ shared_ptr<TLVNode> TLVParser::TLV_Parse(uint8* buf, size_t size)
{
shared_ptr<TLVNode> node = TLV_Parse_One(buf, size);
TLV_Parse_Sub(node);
diff --git a/src/Common/TLVParser.h b/src/Common/TLVParser.h
index b989ca41..2fc4a27c 100644
--- a/src/Common/TLVParser.h
+++ b/src/Common/TLVParser.h
@@ -10,16 +10,16 @@ namespace VeraCrypt
{
uint16 Tag; /* T */
uint16 Length; /* L */
- shared_ptr<vector<byte>> Value; /* V */
- byte TagSize;
- byte LengthSize;
+ shared_ptr<vector<uint8>> Value; /* V */
+ uint8 TagSize;
+ uint8 LengthSize;
uint16 MoreFlag; /* Used In Sub */
uint16 SubFlag; /* Does it have sub-nodes? */
shared_ptr<vector<shared_ptr<TLVNode>>> Subs;
TLVNode() : Tag(0), Length(0), TagSize(0), LengthSize(0), MoreFlag(0), SubFlag(0)
{
- Value = make_shared<vector<byte>>();
+ Value = make_shared<vector<uint8>>();
Subs = make_shared<vector<shared_ptr<TLVNode>>>();
}
@@ -37,10 +37,10 @@ namespace VeraCrypt
static shared_ptr<TLVNode> TLV_CreateNode();
/* Check if the bit is correct */
- static uint16 CheckBit(byte value, int bit);
+ static uint16 CheckBit(uint8 value, int bit);
/* Parsing one TLV node */
- static shared_ptr<TLVNode> TLV_Parse_One(byte* buf, size_t size);
+ static shared_ptr<TLVNode> TLV_Parse_One(uint8* buf, size_t size);
/* Parsing all TLV nodes */
static int TLV_Parse_SubNodes(shared_ptr<TLVNode> parent);
@@ -54,7 +54,7 @@ namespace VeraCrypt
public:
/* Parsing TLV from a buffer and constructing TLV structure */
- static shared_ptr<TLVNode> TLV_Parse(byte* buf, size_t size);
+ static shared_ptr<TLVNode> TLV_Parse(uint8* buf, size_t size);
/* Finding a TLV node with a particular tag */
static shared_ptr<TLVNode> TLV_Find(shared_ptr<TLVNode> node, uint16 tag);
diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h
index 1118e522..377ac388 100644
--- a/src/Common/Tcdefs.h
+++ b/src/Common/Tcdefs.h
@@ -95,7 +95,6 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift);
typedef __int8 int8;
typedef __int16 int16;
typedef __int32 int32;
-typedef unsigned __int8 byte;
typedef unsigned __int8 uint8;
typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
@@ -122,7 +121,6 @@ typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
-typedef uint8_t byte;
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
diff --git a/src/Common/Tests.c b/src/Common/Tests.c
index 82564a84..530e7577 100644
--- a/src/Common/Tests.c
+++ b/src/Common/Tests.c
@@ -1340,13 +1340,13 @@ static BOOL DoAutoTestAlgorithms (void)
// AES EncipherBlocks()/DecipherBlocks()
{
- byte testData[1024];
+ uint8 testData[1024];
uint32 origCrc;
size_t i;
for (i = 0; i < sizeof (testData); ++i)
{
- testData[i] = (byte) i;
+ testData[i] = (uint8) i;
}
origCrc = GetCrc32 (testData, sizeof (testData));
diff --git a/src/Common/Token.h b/src/Common/Token.h
index 754e2830..959c7e24 100644
--- a/src/Common/Token.h
+++ b/src/Common/Token.h
@@ -41,7 +41,7 @@ namespace VeraCrypt
{
virtual ~TokenKeyfile() {}
virtual operator TokenKeyfilePath () const = 0;
- virtual void GetKeyfileData(vector <byte>& keyfileData) const = 0;
+ virtual void GetKeyfileData(vector <uint8>& keyfileData) const = 0;
shared_ptr<TokenInfo> Token;
wstring Id;
diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c
index 989b2d14..df1cd1e3 100644
--- a/src/Common/Volumes.c
+++ b/src/Common/Volumes.c
@@ -130,19 +130,19 @@
-uint16 GetHeaderField16 (byte *header, int offset)
+uint16 GetHeaderField16 (uint8 *header, int offset)
{
return BE16 (*(uint16 *) (header + offset));
}
-uint32 GetHeaderField32 (byte *header, int offset)
+uint32 GetHeaderField32 (uint8 *header, int offset)
{
return BE32 (*(uint32 *) (header + offset));
}
-UINT64_STRUCT GetHeaderField64 (byte *header, int offset)
+UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset)
{
UINT64_STRUCT uint64Struct;
@@ -640,7 +640,7 @@ ret:
}
#if defined(_WIN32) && !defined(_UEFI)
-void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderSize, byte* fingerprint)
+void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoaderSize, uint8* fingerprint)
{
// compute Whirlpool+SHA512 fingerprint of bootloader including MBR
// we skip user configuration fields:
@@ -1214,13 +1214,13 @@ err:
}
#if !defined(_UEFI)
-BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead)
+BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header, DWORD *bytesRead)
{
#if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#endif
- byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
+ uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DISK_GEOMETRY geometry;
if (!device)
@@ -1247,13 +1247,13 @@ BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DW
}
-BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header)
+BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header)
{
#if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#endif
- byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
+ uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DWORD bytesDone;
DISK_GEOMETRY geometry;
@@ -1322,7 +1322,7 @@ int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO
char temporaryKey[MASTER_KEYDATA_SIZE];
char originalK2[MASTER_KEYDATA_SIZE];
- byte buf[TC_VOLUME_HEADER_GROUP_SIZE];
+ uint8 buf[TC_VOLUME_HEADER_GROUP_SIZE];
LARGE_INTEGER offset;
int nStatus = ERR_SUCCESS;
diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h
index 1c9981c2..daad25e3 100644
--- a/src/Common/Volumes.h
+++ b/src/Common/Volumes.h
@@ -129,9 +129,9 @@ extern "C" {
extern BOOL ReadVolumeHeaderRecoveryMode;
-uint16 GetHeaderField16 (byte *header, int offset);
-uint32 GetHeaderField32 (byte *header, int offset);
-UINT64_STRUCT GetHeaderField64 (byte *header, int offset);
+uint16 GetHeaderField16 (uint8 *header, int offset);
+uint32 GetHeaderField32 (uint8 *header, int offset);
+UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset);
#if defined(TC_WINDOWS_BOOT)
int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo);
#elif defined(_UEFI)
@@ -141,14 +141,14 @@ BOOL RandgetBytes(unsigned char *buf, int len, BOOL forceSlowPoll);
#else
int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo);
#if defined(_WIN32) && !defined(_UEFI)
-void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderSize, byte* fingerprint);
+void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoaderSize, uint8* fingerprint);
#endif
#endif
#if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) && !defined(_UEFI)
int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, int pim, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode);
-BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead);
-BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header);
+BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header, DWORD *bytesRead);
+BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header);
int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly);
#endif
diff --git a/src/Common/Wipe.c b/src/Common/Wipe.c
index 2fe6aa03..d68b517b 100644
--- a/src/Common/Wipe.c
+++ b/src/Common/Wipe.c
@@ -14,7 +14,7 @@
#include "Wipe.h"
-static BOOL Wipe1PseudoRandom (int pass, byte *buffer, size_t size)
+static BOOL Wipe1PseudoRandom (int pass, uint8 *buffer, size_t size)
{
return FALSE;
}
@@ -23,9 +23,9 @@ static BOOL Wipe1PseudoRandom (int pass, byte *buffer, size_t size)
// Fill buffer with wipe patterns defined in "National Industrial Security Program Operating Manual", US DoD 5220.22-M.
// Return: FALSE = buffer must be filled with random data
-static BOOL Wipe3Dod5220 (int pass, byte *buffer, size_t size)
+static BOOL Wipe3Dod5220 (int pass, uint8 *buffer, size_t size)
{
- byte wipeChar;
+ uint8 wipeChar;
switch (pass)
{
@@ -46,9 +46,9 @@ static BOOL Wipe3Dod5220 (int pass, byte *buffer, size_t size)
}
-static BOOL Wipe7Dod5220 (int pass, byte randChars[TC_WIPE_RAND_CHAR_COUNT], byte *buffer, size_t size)
+static BOOL Wipe7Dod5220 (int pass, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], uint8 *buffer, size_t size)
{
- byte wipeChar;
+ uint8 wipeChar;
switch (pass)
{
@@ -84,9 +84,9 @@ static BOOL Wipe7Dod5220 (int pass, byte randChars[TC_WIPE_RAND_CHAR_COUNT], byt
// Fill the buffer with wipe patterns defined in the paper "Secure Deletion of Data from Magnetic and Solid-State Memory" by Peter Gutmann.
// Return: FALSE = buffer must be filled with random data
-static BOOL Wipe35Gutmann (int pass, byte *buffer, size_t size)
+static BOOL Wipe35Gutmann (int pass, uint8 *buffer, size_t size)
{
- byte wipePat3[] = { 0x92, 0x49, 0x24 };
+ uint8 wipePat3[] = { 0x92, 0x49, 0x24 };
int wipePat3Pos;
size_t i;
@@ -167,7 +167,7 @@ int GetWipePassCount (WipeAlgorithmId algorithm)
}
-BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, byte *buffer, size_t size)
+BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, uint8 *buffer, size_t size)
{
switch (algorithm)
{
diff --git a/src/Common/Wipe.h b/src/Common/Wipe.h
index ef27eb06..09b9d71e 100644
--- a/src/Common/Wipe.h
+++ b/src/Common/Wipe.h
@@ -36,7 +36,7 @@ typedef enum
#define TC_WIPE_RAND_CHAR_COUNT 3
int GetWipePassCount (WipeAlgorithmId algorithm);
-BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, byte *buffer, size_t size);
+BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, uint8 *buffer, size_t size);
#ifdef __cplusplus
}