Avoid conflict with C++17 features std::byte by using uint8 type instead of byte

This commit is contained in:
Mounir IDRASSI 2024-06-12 12:30:04 +02:00
parent bf9f3ec4f0
commit 455a4f2176
No known key found for this signature in database
GPG Key ID: FC1B00364B3FE937
132 changed files with 1032 additions and 1035 deletions

View File

@ -28,6 +28,6 @@ enum
BiosResultTimeout = 0x80 BiosResultTimeout = 0x80
}; };
typedef byte BiosResult; typedef uint8 BiosResult;
#endif // TC_HEADER_Boot_Bios #endif // TC_HEADER_Boot_Bios

View File

@ -43,7 +43,7 @@
typedef struct typedef struct
{ {
byte Flags; uint8 Flags;
} BootSectorConfiguration; } BootSectorConfiguration;
@ -120,7 +120,7 @@ typedef struct {
uint32 Data1; uint32 Data1;
uint16 Data2; uint16 Data2;
uint16 Data3; uint16 Data3;
byte Data4[8]; uint8 Data4[8];
} DCS_GUID; } DCS_GUID;
// DE types // DE types
@ -155,7 +155,7 @@ typedef struct _DCS_DISK_ENTRY {
struct { struct {
uint32 Type; uint32 Type;
uint32 Offset; uint32 Offset;
byte reserved[16]; uint8 reserved[16];
uint64 Length; // size of structure at Offset uint64 Length; // size of structure at Offset
}; };
DCS_DISK_ENTRY_SECTORS Sectors; DCS_DISK_ENTRY_SECTORS Sectors;
@ -208,7 +208,7 @@ typedef struct _DCS_DEP_PWD_CACHE {
uint32 Count; uint32 Count;
PasswordLegacy Pwd[4]; PasswordLegacy Pwd[4];
int32 Pim[4]; int32 Pim[4];
byte pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4]; uint8 pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4];
} DCS_DEP_PWD_CACHE; } DCS_DEP_PWD_CACHE;
CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE); CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE);
#pragma pack() #pragma pack()

View File

@ -12,10 +12,10 @@
#include "BootConfig.h" #include "BootConfig.h"
byte BootSectorFlags; uint8 BootSectorFlags;
byte BootLoaderDrive; uint8 BootLoaderDrive;
byte BootDrive; uint8 BootDrive;
bool BootDriveGeometryValid = false; bool BootDriveGeometryValid = false;
bool PreventNormalSystemBoot = false; bool PreventNormalSystemBoot = false;
bool PreventBootMenu = false; bool PreventBootMenu = false;
@ -39,7 +39,7 @@ uint64 HiddenVolumeStartSector;
void ReadBootSectorUserConfiguration () void ReadBootSectorUserConfiguration ()
{ {
byte userConfig; uint8 userConfig;
AcquireSectorBuffer(); AcquireSectorBuffer();
@ -83,7 +83,7 @@ void ReadBootSectorUserConfiguration ()
} }
BiosResult UpdateBootSectorConfiguration (byte drive) BiosResult UpdateBootSectorConfiguration (uint8 drive)
{ {
uint64 mbrSector; uint64 mbrSector;
mbrSector.HighPart = 0; mbrSector.HighPart = 0;

View File

@ -17,10 +17,10 @@
#include "Platform.h" #include "Platform.h"
#include "BootDiskIo.h" #include "BootDiskIo.h"
extern byte BootSectorFlags; extern uint8 BootSectorFlags;
extern byte BootLoaderDrive; extern uint8 BootLoaderDrive;
extern byte BootDrive; extern uint8 BootDrive;
extern bool BootDriveGeometryValid; extern bool BootDriveGeometryValid;
extern DriveGeometry BootDriveGeometry; extern DriveGeometry BootDriveGeometry;
extern bool PreventNormalSystemBoot; extern bool PreventNormalSystemBoot;
@ -41,6 +41,6 @@ extern uint64 HiddenVolumeStartSector;
void ReadBootSectorUserConfiguration (); void ReadBootSectorUserConfiguration ();
BiosResult UpdateBootSectorConfiguration (byte drive); BiosResult UpdateBootSectorConfiguration (uint8 drive);
#endif // TC_HEADER_Boot_BootConfig #endif // TC_HEADER_Boot_BootConfig

View File

@ -101,7 +101,7 @@ void Print (const uint64 &number)
} }
void PrintHex (byte b) void PrintHex (uint8 b)
{ {
PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4)); PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4));
PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF)); PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF));
@ -110,8 +110,8 @@ void PrintHex (byte b)
void PrintHex (uint16 data) void PrintHex (uint16 data)
{ {
PrintHex (byte (data >> 8)); PrintHex (uint8 (data >> 8));
PrintHex (byte (data)); PrintHex (uint8 (data));
} }
@ -219,9 +219,9 @@ void PrintErrorNoEndl (const char *message)
} }
byte GetShiftFlags () uint8 GetShiftFlags ()
{ {
byte flags; uint8 flags;
__asm __asm
{ {
mov ah, 2 mov ah, 2
@ -233,7 +233,7 @@ byte GetShiftFlags ()
} }
byte GetKeyboardChar () uint8 GetKeyboardChar ()
{ {
return GetKeyboardChar (nullptr); return GetKeyboardChar (nullptr);
} }
@ -253,7 +253,7 @@ inline void Sleep ()
} }
*/ */
byte GetKeyboardChar (byte *scanCode) uint8 GetKeyboardChar (uint8 *scanCode)
{ {
// Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer) // Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer)
while (!IsKeyboardCharAvailable()) while (!IsKeyboardCharAvailable())
@ -265,8 +265,8 @@ byte GetKeyboardChar (byte *scanCode)
} }
} }
byte asciiCode; uint8 asciiCode;
byte scan; uint8 scan;
__asm __asm
{ {
mov ah, 0 mov ah, 0
@ -302,7 +302,7 @@ bool EscKeyPressed ()
{ {
if (IsKeyboardCharAvailable ()) if (IsKeyboardCharAvailable ())
{ {
byte keyScanCode; uint8 keyScanCode;
GetKeyboardChar (&keyScanCode); GetKeyboardChar (&keyScanCode);
return keyScanCode == TC_BIOS_KEY_ESC; return keyScanCode == TC_BIOS_KEY_ESC;
} }
@ -346,8 +346,8 @@ bool IsDigit (char c)
int GetString (char *buffer, size_t bufferSize) int GetString (char *buffer, size_t bufferSize)
{ {
byte c; uint8 c;
byte scanCode; uint8 scanCode;
size_t pos = 0; size_t pos = 0;
while (pos < bufferSize) while (pos < bufferSize)

View File

@ -45,9 +45,9 @@ void ClearScreen ();
void DisableScreenOutput (); void DisableScreenOutput ();
void EnableScreenOutput (); void EnableScreenOutput ();
bool EscKeyPressed (); bool EscKeyPressed ();
byte GetKeyboardChar (); uint8 GetKeyboardChar ();
byte GetKeyboardChar (byte *scanCode); uint8 GetKeyboardChar (uint8 *scanCode);
byte GetShiftFlags (); uint8 GetShiftFlags ();
int GetString (char *buffer, size_t bufferSize); int GetString (char *buffer, size_t bufferSize);
void InitVideoMode (); void InitVideoMode ();
bool IsKeyboardCharAvailable (); bool IsKeyboardCharAvailable ();
@ -64,7 +64,7 @@ void PrintEndl (int cnt);
void PrintRepeatedChar (char c, int n); void PrintRepeatedChar (char c, int n);
void PrintError (const char *message); void PrintError (const char *message);
void PrintErrorNoEndl (const char *message); void PrintErrorNoEndl (const char *message);
void PrintHex (byte b); void PrintHex (uint8 b);
void PrintHex (uint16 data); void PrintHex (uint16 data);
void PrintHex (uint32 data); void PrintHex (uint32 data);
void PrintHex (const uint64 &data); void PrintHex (const uint64 &data);

View File

@ -34,7 +34,7 @@ void InitDebugPort ()
} }
void WriteDebugPort (byte dataByte) void WriteDebugPort (uint8 dataByte)
{ {
__asm __asm
{ {
@ -82,7 +82,7 @@ void PrintVal (const char *message, const uint64 &value, bool newLine, bool hex)
} }
void PrintHexDump (byte *mem, size_t size, uint16 *memSegment) void PrintHexDump (uint8 *mem, size_t size, uint16 *memSegment)
{ {
const size_t width = 16; const size_t width = 16;
for (size_t pos = 0; pos < size; ) for (size_t pos = 0; pos < size; )
@ -92,7 +92,7 @@ void PrintHexDump (byte *mem, size_t size, uint16 *memSegment)
size_t i; size_t i;
for (i = 0; i < width && pos < size; ++i) for (i = 0; i < width && pos < size; ++i)
{ {
byte dataByte; uint8 dataByte;
if (memSegment) if (memSegment)
{ {
__asm __asm
@ -134,7 +134,7 @@ void PrintHexDump (byte *mem, size_t size, uint16 *memSegment)
void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size) void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size)
{ {
PrintHexDump ((byte *) memOffset, size, &memSegment); PrintHexDump ((uint8 *) memOffset, size, &memSegment);
} }
#endif // TC_BOOT_DEBUG_ENABLED #endif // TC_BOOT_DEBUG_ENABLED

View File

@ -51,8 +51,8 @@
void InitDebugPort (); void InitDebugPort ();
void InitStackChecker (); void InitStackChecker ();
void WriteDebugPort (byte dataByte); void WriteDebugPort (uint8 dataByte);
void PrintHexDump (byte *mem, size_t size, uint16 *memSegment = nullptr); void PrintHexDump (uint8 *mem, size_t size, uint16 *memSegment = nullptr);
void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size); void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size);
void PrintVal (const char *message, const uint32 value, bool newLine = true, bool hex = false); void PrintVal (const char *message, const uint32 value, bool newLine = true, bool hex = false);
void PrintVal (const char *message, const uint64 &value, bool newLine = true, bool hex = false); void PrintVal (const char *message, const uint64 &value, bool newLine = true, bool hex = false);

View File

@ -19,7 +19,7 @@
#include "BootStrings.h" #include "BootStrings.h"
byte SectorBuffer[TC_LB_SIZE]; uint8 SectorBuffer[TC_LB_SIZE];
#ifdef TC_BOOT_DEBUG_ENABLED #ifdef TC_BOOT_DEBUG_ENABLED
static bool SectorBufferInUse = false; static bool SectorBufferInUse = false;
@ -41,9 +41,9 @@ void ReleaseSectorBuffer ()
#endif #endif
bool IsLbaSupported (byte drive) bool IsLbaSupported (uint8 drive)
{ {
static byte CachedDrive = TC_INVALID_BIOS_DRIVE; static uint8 CachedDrive = TC_INVALID_BIOS_DRIVE;
static bool CachedStatus; static bool CachedStatus;
uint16 result = 0; uint16 result = 0;
@ -68,7 +68,7 @@ bool IsLbaSupported (byte drive)
} }
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs) void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs)
{ {
PrintEndl(); PrintEndl();
Print (write ? "Write" : "Read"); Print (" error:"); Print (write ? "Write" : "Read"); Print (" error:");
@ -109,17 +109,17 @@ void PrintSectorCountInMB (const uint64 &sectorCount)
} }
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{ {
CheckStack(); CheckStack();
byte cylinderLow = (byte) chs.Cylinder; uint8 cylinderLow = (uint8) chs.Cylinder;
byte sector = chs.Sector; uint8 sector = chs.Sector;
sector |= byte (chs.Cylinder >> 2) & 0xc0; sector |= uint8 (chs.Cylinder >> 2) & 0xc0;
byte function = write ? 0x03 : 0x02; uint8 function = write ? 0x03 : 0x02;
BiosResult result; BiosResult result;
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
do do
{ {
@ -159,20 +159,20 @@ BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffs
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{ {
uint16 codeSeg; uint16 codeSeg;
__asm mov codeSeg, cs __asm mov codeSeg, cs
return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent); return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent);
} }
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{ {
return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent); return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
} }
#if 0 #if 0
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent)
{ {
return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent); return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
} }
@ -180,7 +180,7 @@ BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte s
#endif #endif
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 &sector, uint16 sectorCount, bool silent) static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{ {
CheckStack(); CheckStack();
@ -202,10 +202,10 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d
dapPacket.SectorCount = sectorCount; dapPacket.SectorCount = sectorCount;
dapPacket.Sector = sector; dapPacket.Sector = sector;
byte function = write ? 0x43 : 0x42; uint8 function = write ? 0x43 : 0x42;
BiosResult result; BiosResult result;
byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES;
do do
{ {
@ -237,7 +237,7 @@ static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte d
} }
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent) BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{ {
BiosLbaPacket dapPacket; BiosLbaPacket dapPacket;
dapPacket.Buffer = (uint32) buffer; dapPacket.Buffer = (uint32) buffer;
@ -245,20 +245,20 @@ BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64
} }
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent) BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{ {
BiosLbaPacket dapPacket; BiosLbaPacket dapPacket;
dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset; dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset;
return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent); return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent);
} }
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent) BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{ {
return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent); return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent);
} }
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent) BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{ {
BiosResult result; BiosResult result;
uint16 codeSeg; uint16 codeSeg;
@ -274,17 +274,17 @@ BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 s
} }
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent) BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent)
{ {
return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent); return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent);
} }
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent) BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent)
{ {
CheckStack(); CheckStack();
byte maxCylinderLow, maxHead, maxSector; uint8 maxCylinderLow, maxHead, maxSector;
BiosResult result; BiosResult result;
__asm __asm
{ {
@ -329,9 +329,9 @@ void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs) void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs)
{ {
chs.Sector = (byte) ((lba.LowPart % geometry.Sectors) + 1); chs.Sector = (uint8) ((lba.LowPart % geometry.Sectors) + 1);
uint32 ch = lba.LowPart / geometry.Sectors; uint32 ch = lba.LowPart / geometry.Sectors;
chs.Head = (byte) (ch % geometry.Heads); chs.Head = (uint8) (ch % geometry.Heads);
chs.Cylinder = (uint16) (ch / geometry.Heads); chs.Cylinder = (uint16) (ch / geometry.Heads);
} }
@ -349,7 +349,7 @@ void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition
} }
BiosResult ReadWriteMBR (bool write, byte drive, bool silent) BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent)
{ {
uint64 mbrSector; uint64 mbrSector;
mbrSector.HighPart = 0; mbrSector.HighPart = 0;
@ -362,7 +362,7 @@ BiosResult ReadWriteMBR (bool write, byte drive, bool silent)
} }
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent) BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent)
{ {
Partition *followingPartition; Partition *followingPartition;
Partition tmpPartition; Partition tmpPartition;
@ -419,7 +419,7 @@ BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t par
MBR *extMbr = (MBR *) SectorBuffer; MBR *extMbr = (MBR *) SectorBuffer;
while (partitionArrayPos < partitionArrayCapacity && while (partitionArrayPos < partitionArrayCapacity &&
(result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess (result = ReadSectors ((uint8 *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess
&& extMbr->Signature == 0xaa55) && extMbr->Signature == 0xaa55)
{ {
if (extMbr->Partitions[0].SectorCountLBA > 0) if (extMbr->Partitions[0].SectorCountLBA > 0)
@ -478,7 +478,7 @@ BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t par
} }
bool GetActivePartition (byte drive) bool GetActivePartition (uint8 drive)
{ {
size_t partCount; size_t partCount;

View File

@ -28,17 +28,17 @@ enum
struct PartitionEntryMBR struct PartitionEntryMBR
{ {
byte BootIndicator; uint8 BootIndicator;
byte StartHead; uint8 StartHead;
byte StartCylSector; uint8 StartCylSector;
byte StartCylinder; uint8 StartCylinder;
byte Type; uint8 Type;
byte EndHead; uint8 EndHead;
byte EndSector; uint8 EndSector;
byte EndCylinder; uint8 EndCylinder;
uint32 StartLBA; uint32 StartLBA;
uint32 SectorCountLBA; uint32 SectorCountLBA;
@ -46,15 +46,15 @@ struct PartitionEntryMBR
struct MBR struct MBR
{ {
byte Code[446]; uint8 Code[446];
PartitionEntryMBR Partitions[4]; PartitionEntryMBR Partitions[4];
uint16 Signature; uint16 Signature;
}; };
struct BiosLbaPacket struct BiosLbaPacket
{ {
byte Size; uint8 Size;
byte Reserved; uint8 Reserved;
uint16 SectorCount; uint16 SectorCount;
uint32 Buffer; uint32 Buffer;
uint64 Sector; uint64 Sector;
@ -66,27 +66,27 @@ struct BiosLbaPacket
struct ChsAddress struct ChsAddress
{ {
uint16 Cylinder; uint16 Cylinder;
byte Head; uint8 Head;
byte Sector; uint8 Sector;
}; };
struct Partition struct Partition
{ {
byte Number; uint8 Number;
byte Drive; uint8 Drive;
bool Active; bool Active;
uint64 EndSector; uint64 EndSector;
bool Primary; bool Primary;
uint64 SectorCount; uint64 SectorCount;
uint64 StartSector; uint64 StartSector;
byte Type; uint8 Type;
}; };
struct DriveGeometry struct DriveGeometry
{ {
uint16 Cylinders; uint16 Cylinders;
byte Heads; uint8 Heads;
byte Sectors; uint8 Sectors;
}; };
@ -99,23 +99,23 @@ void ReleaseSectorBuffer ();
#endif #endif
void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba); void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba);
bool GetActivePartition (byte drive); bool GetActivePartition (uint8 drive);
BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false); BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent = false);
BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false); BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false);
bool IsLbaSupported (byte drive); bool IsLbaSupported (uint8 drive);
void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs); void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs);
void Print (const ChsAddress &chs); void Print (const ChsAddress &chs);
void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr); void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs = nullptr);
void PrintSectorCountInMB (const uint64 &sectorCount); void PrintSectorCountInMB (const uint64 &sectorCount);
BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false); BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent = false);
BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent = false); BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent = false);
BiosResult ReadSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent = false); BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent = false);
BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent = false);
BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 &sector, uint16 sectorCount, bool silent); BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent);
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent); BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent);
BiosResult WriteSectors (byte *buffer, byte drive, const uint64 &sector, uint16 sectorCount, bool silent = false); BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 &sector, uint16 sectorCount, bool silent = false);
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent = false);
extern byte SectorBuffer[TC_LB_SIZE]; extern uint8 SectorBuffer[TC_LB_SIZE];
#endif // TC_HEADER_Boot_BootDiskIo #endif // TC_HEADER_Boot_BootDiskIo

View File

@ -19,7 +19,7 @@
#include "BootEncryptedIo.h" #include "BootEncryptedIo.h"
BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount) BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount)
{ {
BiosResult result; BiosResult result;
bool decrypt = true; bool decrypt = true;
@ -76,7 +76,7 @@ BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte dri
} }
BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount) BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount)
{ {
BiosResult result = BiosResultSuccess; BiosResult result = BiosResultSuccess;
AcquireSectorBuffer(); AcquireSectorBuffer();

View File

@ -15,8 +15,8 @@
#include "Platform.h" #include "Platform.h"
BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount); BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount);
BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount); BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount);
static bool ReadWritePartiallyCoversEncryptedArea (const uint64 &sector, uint16 sectorCount); static bool ReadWritePartiallyCoversEncryptedArea (const uint64 &sector, uint16 sectorCount);
#endif // TC_HEADER_Boot_BootEncryptionIo #endif // TC_HEADER_Boot_BootEncryptionIo

View File

@ -84,7 +84,7 @@ static void PrintMainMenu ()
} }
static bool IsMenuKey (byte scanCode) static bool IsMenuKey (uint8 scanCode)
{ {
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
return scanCode == TC_MENU_KEY_REPAIR; return scanCode == TC_MENU_KEY_REPAIR;
@ -149,12 +149,12 @@ static int AskSelection (const char *options[], size_t optionCount)
} }
static byte AskPassword (Password &password, int& pim) static uint8 AskPassword (Password &password, int& pim)
{ {
size_t pos = 0; size_t pos = 0;
byte scanCode; uint8 scanCode;
byte asciiCode; uint8 asciiCode;
byte hidePassword = 1; uint8 hidePassword = 1;
pim = 0; pim = 0;
@ -312,7 +312,7 @@ static byte AskPassword (Password &password, int& pim)
} }
static void ExecuteBootSector (byte drive, byte *sectorBuffer) static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer)
{ {
Print ("Booting...\r\n"); Print ("Booting...\r\n");
CopyMemory (sectorBuffer, 0x0000, 0x7c00, TC_LB_SIZE); CopyMemory (sectorBuffer, 0x0000, 0x7c00, TC_LB_SIZE);
@ -338,7 +338,7 @@ static void ExecuteBootSector (byte drive, byte *sectorBuffer)
} }
static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden) static bool OpenVolume (uint8 drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden)
{ {
int volumeType; int volumeType;
bool hiddenVolume; bool hiddenVolume;
@ -420,7 +420,7 @@ static bool CheckMemoryRequirements ()
} }
static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHidden) static bool MountVolume (uint8 drive, uint8 &exitKey, bool skipNormal, bool skipHidden)
{ {
BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET;
int incorrectPasswordCount = 0, pim = 0; int incorrectPasswordCount = 0, pim = 0;
@ -499,7 +499,7 @@ static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHi
} }
static bool GetSystemPartitions (byte drive) static bool GetSystemPartitions (uint8 drive)
{ {
size_t partCount; size_t partCount;
@ -524,10 +524,10 @@ static bool GetSystemPartitions (byte drive)
} }
static byte BootEncryptedDrive () static uint8 BootEncryptedDrive ()
{ {
BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET;
byte exitKey; uint8 exitKey;
BootCryptoInfo = NULL; BootCryptoInfo = NULL;
if (!GetSystemPartitions (BootDrive)) if (!GetSystemPartitions (BootDrive))
@ -556,7 +556,7 @@ static byte BootEncryptedDrive ()
if (!InstallInterruptFilters()) if (!InstallInterruptFilters())
goto err; goto err;
bootArguments->BootArgumentsCrc32 = GetCrc32 ((byte *) bootArguments, (byte *) &bootArguments->BootArgumentsCrc32 - (byte *) bootArguments); bootArguments->BootArgumentsCrc32 = GetCrc32 ((uint8 *) bootArguments, (uint8 *) &bootArguments->BootArgumentsCrc32 - (uint8 *) bootArguments);
while (true) while (true)
{ {
@ -587,7 +587,7 @@ static byte BootEncryptedDrive ()
EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE; EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE;
EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments)); EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments));
byte scanCode; uint8 scanCode;
GetKeyboardChar (&scanCode); GetKeyboardChar (&scanCode);
return scanCode; return scanCode;
} }
@ -601,7 +601,7 @@ static void BootMenu ()
size_t partitionCount; size_t partitionCount;
size_t bootablePartitionCount = 0; size_t bootablePartitionCount = 0;
for (byte drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive) for (uint8 drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive)
{ {
if (GetDrivePartitions (drive, partitions, array_capacity (partitions), partitionCount, false, nullptr, true) == BiosResultSuccess) if (GetDrivePartitions (drive, partitions, array_capacity (partitions), partitionCount, false, nullptr, true) == BiosResultSuccess)
{ {
@ -689,7 +689,7 @@ static void BootMenu ()
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey) static bool CopySystemPartitionToHiddenVolume (uint8 drive, uint8 &exitKey)
{ {
bool status = false; bool status = false;
@ -812,9 +812,9 @@ static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey)
#else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE #else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE
static void DecryptDrive (byte drive) static void DecryptDrive (uint8 drive)
{ {
byte exitKey; uint8 exitKey;
if (!MountVolume (drive, exitKey, false, true)) if (!MountVolume (drive, exitKey, false, true))
return; return;
@ -925,7 +925,7 @@ static void DecryptDrive (byte drive)
for (int i = 7; i >= 0; --i) for (int i = 7; i >= 0; --i)
{ {
SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (byte) encryptedAreaLength.LowPart; SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (uint8) encryptedAreaLength.LowPart;
encryptedAreaLength = encryptedAreaLength >> 8; encryptedAreaLength = encryptedAreaLength >> 8;
} }
@ -933,7 +933,7 @@ static void DecryptDrive (byte drive)
for (i = 3; i >= 0; --i) for (i = 3; i >= 0; --i)
{ {
SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (byte) headerCrc32; SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (uint8) headerCrc32;
headerCrc32 >>= 8; headerCrc32 >>= 8;
} }
@ -1020,7 +1020,7 @@ static void RepairMenu ()
sector.HighPart = 0; sector.HighPart = 0;
ChsAddress chs; ChsAddress chs;
byte mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE]; uint8 mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE];
AcquireSectorBuffer(); AcquireSectorBuffer();
for (int i = (selection == RestoreVolumeHeader ? TC_BOOT_VOLUME_HEADER_SECTOR : TC_MBR_SECTOR); for (int i = (selection == RestoreVolumeHeader ? TC_BOOT_VOLUME_HEADER_SECTOR : TC_MBR_SECTOR);
@ -1073,7 +1073,7 @@ static void RepairMenu ()
Password password; Password password;
int pim; int pim;
byte exitKey = AskPassword (password, pim); uint8 exitKey = AskPassword (password, pim);
if (exitKey != TC_BIOS_KEY_ENTER) if (exitKey != TC_BIOS_KEY_ENTER)
goto abort; goto abort;
@ -1221,13 +1221,13 @@ void main ()
while (true) while (true)
{ {
byte exitKey; uint8 exitKey;
InitScreen(); InitScreen();
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
// Hidden system setup // Hidden system setup
byte hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; uint8 hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
if (hiddenSystemCreationPhase != TC_HIDDEN_OS_CREATION_PHASE_NONE) if (hiddenSystemCreationPhase != TC_HIDDEN_OS_CREATION_PHASE_NONE)
{ {

View File

@ -16,16 +16,16 @@
#include "TCdefs.h" #include "TCdefs.h"
#include "Platform.h" #include "Platform.h"
static byte AskPassword (Password &password, int& pim); static uint8 AskPassword (Password &password, int& pim);
static int AskSelection (const char *options[], size_t optionCount); static int AskSelection (const char *options[], size_t optionCount);
static bool AskYesNo (const char *message); static bool AskYesNo (const char *message);
static byte BootEncryptedDrive (); static uint8 BootEncryptedDrive ();
static void BootMenu (); static void BootMenu ();
static void ExecuteBootSector (byte drive, byte *sectorBuffer); static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer);
static void InitScreen (); static void InitScreen ();
static bool IsMenuKey (byte scanCode); static bool IsMenuKey (uint8 scanCode);
static bool MountVolume (byte drive, byte &exitKey); static bool MountVolume (uint8 drive, uint8 &exitKey);
static bool OpenVolume (byte drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false); static bool OpenVolume (uint8 drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false);
static void PrintMainMenu (); static void PrintMainMenu ();
static void RepairMenu (); static void RepairMenu ();

View File

@ -38,7 +38,7 @@ bool Int13Filter ()
static int ReEntryCount = -1; static int ReEntryCount = -1;
++ReEntryCount; ++ReEntryCount;
byte function = (byte) (regs.AX >> 8); uint8 function = (uint8) (regs.AX >> 8);
#ifdef TC_TRACE_INT13 #ifdef TC_TRACE_INT13
DisableScreenOutput(); DisableScreenOutput();
@ -63,14 +63,14 @@ bool Int13Filter ()
case 0x2: // Read sectors case 0x2: // Read sectors
case 0x3: // Write sectors case 0x3: // Write sectors
{ {
byte drive = (byte) regs.DX; uint8 drive = (uint8) regs.DX;
ChsAddress chs; ChsAddress chs;
chs.Cylinder = ((regs.CX << 2) & 0x300) | (regs.CX >> 8); chs.Cylinder = ((regs.CX << 2) & 0x300) | (regs.CX >> 8);
chs.Head = regs.DX >> 8; chs.Head = regs.DX >> 8;
chs.Sector = regs.CX & 0x3f; chs.Sector = regs.CX & 0x3f;
byte sectorCount = (byte) regs.AX; uint8 sectorCount = (uint8) regs.AX;
#ifdef TC_TRACE_INT13 #ifdef TC_TRACE_INT13
PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false); PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false);
@ -125,10 +125,10 @@ bool Int13Filter ()
case 0x42: // Read sectors LBA case 0x42: // Read sectors LBA
case 0x43: // Write sectors LBA case 0x43: // Write sectors LBA
{ {
byte drive = (byte) regs.DX; uint8 drive = (uint8) regs.DX;
BiosLbaPacket lba; BiosLbaPacket lba;
CopyMemory (regs.DS, regs.SI, (byte *) &lba, sizeof (lba)); CopyMemory (regs.DS, regs.SI, (uint8 *) &lba, sizeof (lba));
#ifdef TC_TRACE_INT13 #ifdef TC_TRACE_INT13
PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false); PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false);
@ -337,7 +337,7 @@ bool Int15Filter ()
} }
else else
{ {
CopyMemory ((byte *) &BiosMemoryMap[IntRegisters.EBX], IntRegisters.ES, IntRegisters.DI, sizeof (BiosMemoryMap[0])); CopyMemory ((uint8 *) &BiosMemoryMap[IntRegisters.EBX], IntRegisters.ES, IntRegisters.DI, sizeof (BiosMemoryMap[0]));
IntRegisters.Flags &= ~TC_X86_CARRY_FLAG; IntRegisters.Flags &= ~TC_X86_CARRY_FLAG;
IntRegisters.EAX = 0x534D4150UL; IntRegisters.EAX = 0x534D4150UL;
@ -380,7 +380,7 @@ bool Int15Filter ()
#ifdef TC_TRACE_INT15 #ifdef TC_TRACE_INT15
BiosMemoryMapEntry entry; BiosMemoryMapEntry entry;
CopyMemory (IntRegisters.ES, IntRegisters.DI, (byte *) &entry, sizeof (entry)); CopyMemory (IntRegisters.ES, IntRegisters.DI, (uint8 *) &entry, sizeof (entry));
PrintHex (entry.Type); PrintChar (' '); PrintHex (entry.Type); PrintChar (' ');
PrintHex (entry.BaseAddress); PrintChar (' '); PrintHex (entry.BaseAddress); PrintChar (' ');
PrintHex (entry.Length); PrintChar (' '); PrintHex (entry.Length); PrintChar (' ');

View File

@ -84,7 +84,7 @@ uint64 operator>> (const uint64 &a, int shiftCount)
{ {
r.LowPart >>= 1; r.LowPart >>= 1;
if ((byte) r.HighPart & 1) if ((uint8) r.HighPart & 1)
r.LowPart |= 0x80000000UL; r.LowPart |= 0x80000000UL;
r.HighPart >>= 1; r.HighPart >>= 1;

View File

@ -344,23 +344,23 @@ typedef struct
typedef struct typedef struct
{ {
byte Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; uint8 Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
} BootLoaderFingerprintRequest; } BootLoaderFingerprintRequest;
typedef struct typedef struct
{ {
wchar_t DevicePath[TC_MAX_PATH]; wchar_t DevicePath[TC_MAX_PATH];
byte Configuration; uint8 Configuration;
BOOL DriveIsDynamic; BOOL DriveIsDynamic;
uint16 BootLoaderVersion; uint16 BootLoaderVersion;
byte UserConfiguration; uint8 UserConfiguration;
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1]; char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
} GetSystemDriveConfigurationRequest; } GetSystemDriveConfigurationRequest;
typedef struct typedef struct
{ {
WipeAlgorithmId WipeAlgorithm; WipeAlgorithmId WipeAlgorithm;
CRYPTOPP_ALIGN_DATA(16) byte WipeKey[MASTER_KEYDATA_SIZE]; CRYPTOPP_ALIGN_DATA(16) uint8 WipeKey[MASTER_KEYDATA_SIZE];
} WipeDecoySystemRequest; } WipeDecoySystemRequest;
typedef struct typedef struct
@ -373,7 +373,7 @@ typedef struct
typedef struct typedef struct
{ {
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
byte Data[TC_SECTOR_SIZE_BIOS]; uint8 Data[TC_SECTOR_SIZE_BIOS];
} WriteBootDriveSectorRequest; } WriteBootDriveSectorRequest;
typedef struct typedef struct

View File

@ -450,7 +450,7 @@ DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMe
msg [maxSize - 1] = 0; msg [maxSize - 1] = 0;
std::string msgStr = maxSize > 0 ? msg : ""; std::string msgStr = maxSize > 0 ? msg : "";
BootEncryption bootEnc (NULL); BootEncryption bootEnc (NULL);
bootEnc.WriteEfiBootSectorUserConfig ((byte) userConfig, msgStr, pim, hashAlg); bootEnc.WriteEfiBootSectorUserConfig ((uint8) userConfig, msgStr, pim, hashAlg);
} }
catch (SystemException &) catch (SystemException &)
{ {

View File

@ -275,10 +275,10 @@ bool ZipAdd (zip_t *z, const char* name, const unsigned char* pbData, DWORD cbDa
return true; return true;
} }
static BOOL IsWindowsMBR (const byte *buffer, size_t bufferSize) static BOOL IsWindowsMBR (const uint8 *buffer, size_t bufferSize)
{ {
BOOL bRet = FALSE; 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_szStr1 = "Invalid partition table";
const char* g_szStr2 = "Error loading operating system"; const char* g_szStr2 = "Error loading operating system";
const char* g_szStr3 = "Missing 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(); 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(); Elevate();
@ -742,7 +742,7 @@ namespace VeraCrypt
public: public:
static void AddReference () { } static void AddReference () { }
static void CallDriver (DWORD ioctl, void *input, DWORD inputSize, void *output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); } 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 RegisterFilterDriver (bool registerDriver, BootEncryption::FilterType filterType) { throw ParameterIncorrect (SRC_POS); }
static void Release () { } static void Release () { }
static void SetDriverServiceStartType (DWORD startType) { throw ParameterIncorrect (SRC_POS); } static void SetDriverServiceStartType (DWORD startType) { throw ParameterIncorrect (SRC_POS); }
@ -752,7 +752,7 @@ namespace VeraCrypt
static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { 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 UpdateSetupConfigFile (bool bForInstall) { throw ParameterIncorrect (SRC_POS); }
static void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { throw ParameterIncorrect (SRC_POS); } static void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { throw ParameterIncorrect (SRC_POS); }
}; };
@ -796,7 +796,7 @@ namespace VeraCrypt
FileOpen = false; FileOpen = false;
} }
DWORD File::Read (byte *buffer, DWORD size) DWORD File::Read (uint8 *buffer, DWORD size)
{ {
DWORD bytesRead; DWORD bytesRead;
@ -901,7 +901,7 @@ namespace VeraCrypt
dwSize = (DWORD) size64; dwSize = (DWORD) size64;
} }
void File::Write (byte *buffer, DWORD size) void File::Write (uint8 *buffer, DWORD size)
{ {
DWORD bytesWritten; DWORD bytesWritten;
@ -1423,7 +1423,7 @@ namespace VeraCrypt
return version; return version;
} }
void BootEncryption::GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]) void BootEncryption::GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE])
{ {
BootLoaderFingerprintRequest request; BootLoaderFingerprintRequest request;
CallDriver (VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT, NULL, 0, &request, sizeof (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 device (GetSystemDriveConfiguration().DevicePath, true);
device.CheckOpened (SRC_POS); device.CheckOpened (SRC_POS);
byte mbrBuf[TC_SECTOR_SIZE_BIOS]; uint8 mbrBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbrBuf, sizeof (mbrBuf)); device.Read (mbrBuf, sizeof (mbrBuf));
@ -1532,7 +1532,7 @@ namespace VeraCrypt
continue; continue;
} }
if (SystemDriveContainsPartitionType ((byte) partitionType)) if (SystemDriveContainsPartitionType ((uint8) partitionType))
return true; 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; 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) if (bufferSize < TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
@ -1809,7 +1809,7 @@ namespace VeraCrypt
// Boot sector // Boot sector
DWORD size; DWORD size;
byte *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size); uint8 *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size);
if (!bootSecResourceImg || size != TC_SECTOR_SIZE_BIOS) if (!bootSecResourceImg || size != TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
@ -1827,7 +1827,7 @@ namespace VeraCrypt
{ {
Device device (GetSystemDriveConfiguration().DevicePath); Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS); 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.SeekAt (HiddenOSCandidatePartition.Info.StartingOffset.QuadPart + HiddenOSCandidatePartition.Info.PartitionLength.QuadPart - TC_VOLUME_HEADER_GROUP_SIZE + TC_VOLUME_HEADER_EFFECTIVE_SIZE);
device.Read (headerSector, sizeof (headerSector)); device.Read (headerSector, sizeof (headerSector));
@ -1836,14 +1836,14 @@ namespace VeraCrypt
} }
// Decompressor // 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) if (!decompressor || size > TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
memcpy (buffer + TC_SECTOR_SIZE_BIOS, decompressor, size); memcpy (buffer + TC_SECTOR_SIZE_BIOS, decompressor, size);
// Compressed boot loader // 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) if (!bootLoader || size > TC_MAX_BOOT_LOADER_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
@ -1869,7 +1869,7 @@ namespace VeraCrypt
} }
// return false when the user cancel an elevation request // 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; bool bCanceled = false, bExceptionOccured = false;
try try
@ -1962,11 +1962,11 @@ namespace VeraCrypt
} }
void BootEncryption::WriteBootSectorConfig (const byte newConfig[]) void BootEncryption::WriteBootSectorConfig (const uint8 newConfig[])
{ {
Device device (GetSystemDriveConfiguration().DevicePath); Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS); device.CheckOpened (SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbr, sizeof (mbr)); device.Read (mbr, sizeof (mbr));
@ -1976,7 +1976,7 @@ namespace VeraCrypt
device.SeekAt (0); device.SeekAt (0);
device.Write (mbr, sizeof (mbr)); device.Write (mbr, sizeof (mbr));
byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr)); device.Read (mbrVerificationBuf, sizeof (mbr));
@ -1984,7 +1984,7 @@ namespace VeraCrypt
throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS); 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()) 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) if (GetSystemDriveConfiguration().SystemPartition.IsGPT)
{ {
@ -2013,7 +2013,7 @@ namespace VeraCrypt
{ {
Device device (GetSystemDriveConfiguration().DevicePath); Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS); device.CheckOpened (SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbr, sizeof (mbr)); device.Read (mbr, sizeof (mbr));
@ -2048,7 +2048,7 @@ namespace VeraCrypt
device.SeekAt (0); device.SeekAt (0);
device.Write (mbr, sizeof (mbr)); device.Write (mbr, sizeof (mbr));
byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr)); device.Read (mbrVerificationBuf, sizeof (mbr));
@ -2060,7 +2060,7 @@ namespace VeraCrypt
unsigned int BootEncryption::GetHiddenOSCreationPhase () unsigned int BootEncryption::GetHiddenOSCreationPhase ()
{ {
byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE]; uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
ReadBootSectorConfig (configFlags, sizeof(configFlags)); ReadBootSectorConfig (configFlags, sizeof(configFlags));
@ -2073,11 +2073,11 @@ namespace VeraCrypt
#if TC_BOOT_CFG_FLAG_AREA_SIZE != 1 #if TC_BOOT_CFG_FLAG_AREA_SIZE != 1
# error TC_BOOT_CFG_FLAG_AREA_SIZE != 1; revise GetHiddenOSCreationPhase() and SetHiddenOSCreationPhase() # error TC_BOOT_CFG_FLAG_AREA_SIZE != 1; revise GetHiddenOSCreationPhase() and SetHiddenOSCreationPhase()
#endif #endif
byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE]; uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
ReadBootSectorConfig (configFlags, sizeof(configFlags)); 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; configFlags[0] |= newPhase;
@ -2154,7 +2154,7 @@ namespace VeraCrypt
Device device (GetSystemDriveConfiguration().DevicePath); Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened(SRC_POS); device.CheckOpened(SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbr, sizeof (mbr)); device.Read (mbr, sizeof (mbr));
@ -2171,7 +2171,7 @@ namespace VeraCrypt
# error PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE # error PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE
#endif #endif
byte randData[PRAND_DISK_WIPE_PASSES]; uint8 randData[PRAND_DISK_WIPE_PASSES];
if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE)) if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE))
throw ParameterIncorrect (SRC_POS); 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_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; mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] |= randData[wipePass] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
if (wipePass == PRAND_DISK_WIPE_PASSES - 1) if (wipePass == PRAND_DISK_WIPE_PASSES - 1)
@ -2384,7 +2384,7 @@ namespace VeraCrypt
if (loaderSize > 32768) 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); EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
@ -2699,8 +2699,8 @@ namespace VeraCrypt
uint32 varSize = 56; uint32 varSize = 56;
varSize += ((uint32) description.length()) * 2 + 2; varSize += ((uint32) description.length()) * 2 + 2;
varSize += ((uint32) execPath.length()) * 2 + 2; varSize += ((uint32) execPath.length()) * 2 + 2;
byte *startVar = new byte[varSize]; uint8 *startVar = new uint8[varSize];
byte *pVar = startVar; uint8 *pVar = startVar;
// Attributes (1b Active, 1000b - Hidden) // Attributes (1b Active, 1000b - Hidden)
*(uint32 *)pVar = attr; *(uint32 *)pVar = attr;
@ -2721,12 +2721,12 @@ namespace VeraCrypt
/* EFI_DEVICE_PATH_PROTOCOL (HARDDRIVE_DEVICE_PATH \ FILE_PATH \ END) */ /* EFI_DEVICE_PATH_PROTOCOL (HARDDRIVE_DEVICE_PATH \ FILE_PATH \ END) */
// Type // Type
*(byte *)pVar = 0x04; *(uint8 *)pVar = 0x04;
pVar += sizeof(byte); pVar += sizeof(uint8);
// SubType // SubType
*(byte *)pVar = 0x01; *(uint8 *)pVar = 0x01;
pVar += sizeof(byte); pVar += sizeof(uint8);
// HDD dev path length // HDD dev path length
*(uint16 *)pVar = 0x2A; // 42 *(uint16 *)pVar = 0x2A; // 42
@ -2749,12 +2749,12 @@ namespace VeraCrypt
pVar += 16; pVar += 16;
// MbrType // MbrType
*(byte *)pVar = 0x02; *(uint8 *)pVar = 0x02;
pVar += sizeof(byte); pVar += sizeof(uint8);
// SigType // SigType
*(byte *)pVar = 0x02; *(uint8 *)pVar = 0x02;
pVar += sizeof(byte); pVar += sizeof(uint8);
// Type and sub type 04 04 (file path) // Type and sub type 04 04 (file path)
*(uint16 *)pVar = 0x0404; *(uint16 *)pVar = 0x0404;
@ -2781,7 +2781,7 @@ namespace VeraCrypt
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum); StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum);
// only set value if it doesn't already exist // 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); DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, varSize);
if ((existingVarLen != varSize) || (0 != memcmp (existingVar, startVar, varSize))) if ((existingVarLen != varSize) || (0 != memcmp (existingVar, startVar, varSize)))
SetFirmwareEnvironmentVariable(varName, EfiVarGuid, startVar, varSize); SetFirmwareEnvironmentVariable(varName, EfiVarGuid, startVar, varSize);
@ -2813,7 +2813,7 @@ namespace VeraCrypt
wchar_t varName[256]; wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, startOrder[0]); 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); DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, 512);
if (existingVarLen > 0) if (existingVarLen > 0)
{ {
@ -2884,8 +2884,8 @@ namespace VeraCrypt
if (size1 == size2) if (size1 == size2)
{ {
// same size, so now we compare content // same size, so now we compare content
std::vector<byte> file1Buf (8096); std::vector<uint8> file1Buf (8096);
std::vector<byte> file2Buf (8096); std::vector<uint8> file2Buf (8096);
DWORD remainingBytes = size1, dataToRead; DWORD remainingBytes = size1, dataToRead;
while (remainingBytes) while (remainingBytes)
@ -2920,7 +2920,7 @@ namespace VeraCrypt
return bRet; 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; bool bRet = false;
@ -2937,7 +2937,7 @@ namespace VeraCrypt
if (existingSize == size) if (existingSize == size)
{ {
std::vector<byte> fileBuf (8096); std::vector<uint8> fileBuf (8096);
DWORD remainingBytes = size, dataOffset = 0, dataToRead; DWORD remainingBytes = size, dataOffset = 0, dataToRead;
while (remainingBytes) while (remainingBytes)
@ -2971,7 +2971,7 @@ namespace VeraCrypt
return bRet; 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; wstring path = EfiBootPartPath;
path += name; path += name;
@ -3000,7 +3000,7 @@ namespace VeraCrypt
f.Close(); 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; wstring path = EfiBootPartPath;
path += name; path += name;
File f(path, true); File f(path, true);
@ -3297,51 +3297,51 @@ namespace VeraCrypt
} }
DWORD sizeDcsBoot; DWORD sizeDcsBoot;
#ifdef _WIN64 #ifdef _WIN64
byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
#else #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 #endif
if (!dcsBootImg) if (!dcsBootImg)
throw ErrorException(L"Out of resource DcsBoot", SRC_POS); throw ErrorException(L"Out of resource DcsBoot", SRC_POS);
DWORD sizeDcsInt; DWORD sizeDcsInt;
#ifdef _WIN64 #ifdef _WIN64
byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
#else #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 #endif
if (!dcsIntImg) if (!dcsIntImg)
throw ErrorException(L"Out of resource DcsInt", SRC_POS); throw ErrorException(L"Out of resource DcsInt", SRC_POS);
DWORD sizeDcsCfg; DWORD sizeDcsCfg;
#ifdef _WIN64 #ifdef _WIN64
byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
#else #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 #endif
if (!dcsCfgImg) if (!dcsCfgImg)
throw ErrorException(L"Out of resource DcsCfg", SRC_POS); throw ErrorException(L"Out of resource DcsCfg", SRC_POS);
DWORD sizeLegacySpeaker; DWORD sizeLegacySpeaker;
#ifdef _WIN64 #ifdef _WIN64
byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
#else #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 #endif
if (!LegacySpeakerImg) if (!LegacySpeakerImg)
throw ErrorException(L"Out of resource LegacySpeaker", SRC_POS); throw ErrorException(L"Out of resource LegacySpeaker", SRC_POS);
#ifdef VC_EFI_CUSTOM_MODE #ifdef VC_EFI_CUSTOM_MODE
DWORD sizeBootMenuLocker; DWORD sizeBootMenuLocker;
#ifdef _WIN64 #ifdef _WIN64
byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
#else #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 #endif
if (!BootMenuLockerImg) if (!BootMenuLockerImg)
throw ErrorException(L"Out of resource DcsBml", SRC_POS); throw ErrorException(L"Out of resource DcsBml", SRC_POS);
#endif #endif
DWORD sizeDcsInfo; DWORD sizeDcsInfo;
#ifdef _WIN64 #ifdef _WIN64
byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
#else #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 #endif
if (!DcsInfoImg) if (!DcsInfoImg)
throw ErrorException(L"Out of resource DcsInfo", SRC_POS); throw ErrorException(L"Out of resource DcsInfo", SRC_POS);
@ -3373,7 +3373,7 @@ namespace VeraCrypt
{ {
if (loaderSize > 32768) 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); 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 // DcsBoot.efi is always smaller than 32KB
if (loaderSize > 32768) 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); EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
@ -3420,7 +3420,7 @@ namespace VeraCrypt
{ {
// look for bootmgfw.efi identifiant string // look for bootmgfw.efi identifiant string
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize); 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); EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
@ -3453,7 +3453,7 @@ namespace VeraCrypt
EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize); EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize);
if (loaderSize > 32768) if (loaderSize > 32768)
{ {
std::vector<byte> bootLoaderBuf ((size_t) loaderSize); std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) 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 // 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 // if both cases, replace it with our bootloader otherwise do nothing
EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize); 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); EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi or VeraCrypt identifiant strings // look for bootmgfw.efi or VeraCrypt identifiant strings
@ -3539,11 +3539,11 @@ namespace VeraCrypt
{ {
try 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); CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, hiddenOSCreation);
// Write MBR // Write MBR
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbr, sizeof (mbr)); device.Read (mbr, sizeof (mbr));
@ -3578,7 +3578,7 @@ namespace VeraCrypt
device.SeekAt (0); device.SeekAt (0);
device.Write (mbr, sizeof (mbr)); device.Write (mbr, sizeof (mbr));
byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr)); device.Read (mbrVerificationBuf, sizeof (mbr));
@ -3620,9 +3620,9 @@ namespace VeraCrypt
if (config.SystemPartition.IsGPT) if (config.SystemPartition.IsGPT)
return true; return true;
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};
byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
byte expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; uint8 expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
bool bRet = false; bool bRet = false;
try try
@ -3694,59 +3694,59 @@ namespace VeraCrypt
// create EFI disk structure // create EFI disk structure
DWORD sizeDcsBoot; DWORD sizeDcsBoot;
#ifdef _WIN64 #ifdef _WIN64
byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
#else #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 #endif
if (!dcsBootImg) if (!dcsBootImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsInt; DWORD sizeDcsInt;
#ifdef _WIN64 #ifdef _WIN64
byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
#else #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 #endif
if (!dcsIntImg) if (!dcsIntImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsCfg; DWORD sizeDcsCfg;
#ifdef _WIN64 #ifdef _WIN64
byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
#else #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 #endif
if (!dcsCfgImg) if (!dcsCfgImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
DWORD sizeLegacySpeaker; DWORD sizeLegacySpeaker;
#ifdef _WIN64 #ifdef _WIN64
byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
#else #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 #endif
if (!LegacySpeakerImg) if (!LegacySpeakerImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
#ifdef VC_EFI_CUSTOM_MODE #ifdef VC_EFI_CUSTOM_MODE
DWORD sizeBootMenuLocker; DWORD sizeBootMenuLocker;
#ifdef _WIN64 #ifdef _WIN64
byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
#else #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 #endif
if (!BootMenuLockerImg) if (!BootMenuLockerImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
#endif #endif
DWORD sizeDcsRescue; DWORD sizeDcsRescue;
#ifdef _WIN64 #ifdef _WIN64
byte *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue); uint8 *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue);
#else #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 #endif
if (!DcsRescueImg) if (!DcsRescueImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsInfo; DWORD sizeDcsInfo;
#ifdef _WIN64 #ifdef _WIN64
byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
#else #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 #endif
if (!DcsInfoImg) if (!DcsInfoImg)
throw ParameterIncorrect (SRC_POS); throw ParameterIncorrect (SRC_POS);
@ -3866,7 +3866,7 @@ namespace VeraCrypt
finally_do_arg (FILE*, ftmpFile, { fclose (finally_arg); }); finally_do_arg (FILE*, ftmpFile, { fclose (finally_arg); });
unsigned long ulZipSize = (unsigned long) _filelength (_fileno (ftmpFile)); unsigned long ulZipSize = (unsigned long) _filelength (_fileno (ftmpFile));
RescueZipData = new byte[ulZipSize]; RescueZipData = new uint8[ulZipSize];
if (!RescueZipData) if (!RescueZipData)
throw bad_alloc(); throw bad_alloc();
@ -3889,7 +3889,7 @@ namespace VeraCrypt
{ {
Buffer imageBuf (RescueIsoImageSize); Buffer imageBuf (RescueIsoImageSize);
byte *image = imageBuf.Ptr(); uint8 *image = imageBuf.Ptr();
memset (image, 0, RescueIsoImageSize); memset (image, 0, RescueIsoImageSize);
// Primary volume descriptor // Primary volume descriptor
@ -3997,7 +3997,7 @@ namespace VeraCrypt
// Boot loader backup // Boot loader backup
CreateBootLoaderInMemory (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET, TC_BOOT_LOADER_AREA_SIZE, false); 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) if (!RescueIsoImage)
throw bad_alloc(); throw bad_alloc();
memcpy (RescueIsoImage, image, RescueIsoImageSize); memcpy (RescueIsoImage, image, RescueIsoImageSize);
@ -4370,7 +4370,7 @@ namespace VeraCrypt
if (GetHeaderField32 (RescueVolumeHeader, TC_HEADER_OFFSET_MAGIC) != 0x56455241) if (GetHeaderField32 (RescueVolumeHeader, TC_HEADER_OFFSET_MAGIC) != 0x56455241)
throw ParameterIncorrect (SRC_POS); 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); mputInt64 (fieldPos, volumeSize);
// CRC of the header fields // CRC of the header fields
@ -4394,7 +4394,7 @@ namespace VeraCrypt
device.CheckOpened (SRC_POS); device.CheckOpened (SRC_POS);
device.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET); 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; 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 * szStdMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi";
const wchar_t * szBackupMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc"; const wchar_t * szBackupMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc";
const char* g_szMsBootString = "bootmgfw.pdb"; const char* g_szMsBootString = "bootmgfw.pdb";
@ -4495,7 +4495,7 @@ namespace VeraCrypt
{ {
Device device (GetSystemDriveConfiguration().DevicePath, true); Device device (GetSystemDriveConfiguration().DevicePath, true);
device.CheckOpened (SRC_POS); 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.SeekAt (0);
device.Read (bootLoaderBuf, sizeof (bootLoaderBuf)); device.Read (bootLoaderBuf, sizeof (bootLoaderBuf));
@ -4558,7 +4558,7 @@ namespace VeraCrypt
const char* g_szMsBootString = "bootmgfw.pdb"; const char* g_szMsBootString = "bootmgfw.pdb";
unsigned __int64 loaderSize = 0; unsigned __int64 loaderSize = 0;
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize); 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); EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
@ -4592,7 +4592,7 @@ namespace VeraCrypt
} }
else 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); File backupFile (GetSystemLoaderBackupPath(), true);
backupFile.CheckOpened(SRC_POS); backupFile.CheckOpened(SRC_POS);
@ -4603,7 +4603,7 @@ namespace VeraCrypt
device.CheckOpened (SRC_POS); device.CheckOpened (SRC_POS);
// Preserve current partition table // Preserve current partition table
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0); device.SeekAt (0);
device.Read (mbr, sizeof (mbr)); 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); 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 // Register class filter below all other filters in the stack
size_t strSize = filter.size() + 1; size_t strSize = filter.size() + 1;
byte regKeyBuf[65536]; uint8 regKeyBuf[65536];
DWORD size = (DWORD) (sizeof (regKeyBuf) - strSize); DWORD size = (DWORD) (sizeof (regKeyBuf) - strSize);
// SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly // SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly
@ -4761,8 +4761,8 @@ namespace VeraCrypt
// read initial value // read initial value
DWORD strSize = (DWORD) filter.size() + 1, expectedSize; DWORD strSize = (DWORD) filter.size() + 1, expectedSize;
Buffer expectedRegKeyBuf(65536), outputRegKeyBuf(65536); Buffer expectedRegKeyBuf(65536), outputRegKeyBuf(65536);
byte* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr (); uint8* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr ();
byte* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr (); uint8* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr ();
DWORD initialSize = (DWORD) (expectedRegKeyBuf.Size() - strSize - 2); DWORD initialSize = (DWORD) (expectedRegKeyBuf.Size() - strSize - 2);
if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbExpectedRegKeyBuf, &initialSize) != ERROR_SUCCESS) 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 // remove value in case it was not done properly
Buffer regKeyBuf(65536); Buffer regKeyBuf(65536);
byte* pbRegKeyBuf = regKeyBuf.Ptr (); uint8* pbRegKeyBuf = regKeyBuf.Ptr ();
DWORD initialSize = (DWORD) regKeyBuf.Size() - 2; DWORD initialSize = (DWORD) regKeyBuf.Size() - 2;
@ -5302,12 +5302,12 @@ namespace VeraCrypt
// Verify CRC of header salt // Verify CRC of header salt
Device device(config.DevicePath, true); Device device(config.DevicePath, true);
device.CheckOpened(SRC_POS); 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.SeekAt(TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
device.Read(header, sizeof(header)); 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); throw ParameterIncorrect(SRC_POS);
} }
} }
@ -5394,7 +5394,7 @@ namespace VeraCrypt
} }
device.SeekAt (headerOffset); device.SeekAt (headerOffset);
device.Read ((byte *) header, sizeof (header)); device.Read ((uint8 *) header, sizeof (header));
PCRYPTO_INFO cryptoInfo = NULL; PCRYPTO_INFO cryptoInfo = NULL;
@ -5482,7 +5482,7 @@ namespace VeraCrypt
} }
device.SeekAt (headerOffset); device.SeekAt (headerOffset);
device.Write ((byte *) header, sizeof (header)); device.Write ((uint8 *) header, sizeof (header));
headerUpdated = true; headerUpdated = true;
} }
@ -5513,7 +5513,7 @@ namespace VeraCrypt
try try
{ {
// check if PIM is stored in MBR // check if PIM is stored in MBR
byte userConfig = 0; uint8 userConfig = 0;
if ( ReadBootSectorConfig (nullptr, 0, &userConfig) if ( ReadBootSectorConfig (nullptr, 0, &userConfig)
&& (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM) && (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)
) )
@ -5790,7 +5790,7 @@ namespace VeraCrypt
return configMap; return configMap;
} }
void BootEncryption::WriteBootDriveSector (uint64 offset, byte *data) void BootEncryption::WriteBootDriveSector (uint64 offset, uint8 *data)
{ {
WriteBootDriveSectorRequest request; WriteBootDriveSectorRequest request;
request.Offset.QuadPart = offset; request.Offset.QuadPart = offset;

View File

@ -37,8 +37,8 @@ namespace VeraCrypt
bool IsOpened () const { return FileOpen;} bool IsOpened () const { return FileOpen;}
void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} } void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
void Close (); void Close ();
DWORD Read (byte *buffer, DWORD size); DWORD Read (uint8 *buffer, DWORD size);
void Write (byte *buffer, DWORD size); void Write (uint8 *buffer, DWORD size);
void SeekAt (int64 position); void SeekAt (int64 position);
void GetFileSize (unsigned __int64& size); void GetFileSize (unsigned __int64& size);
void GetFileSize (DWORD& dwSize); void GetFileSize (DWORD& dwSize);
@ -70,19 +70,19 @@ namespace VeraCrypt
public: public:
Buffer (size_t size) : DataSize (size) Buffer (size_t size) : DataSize (size)
{ {
DataPtr = new byte[size]; DataPtr = new uint8[size];
if (!DataPtr) if (!DataPtr)
throw bad_alloc(); throw bad_alloc();
} }
~Buffer () { delete[] DataPtr; } ~Buffer () { delete[] DataPtr; }
byte *Ptr () const { return DataPtr; } uint8 *Ptr () const { return DataPtr; }
size_t Size () const { return DataSize; } size_t Size () const { return DataSize; }
void Resize (size_t newSize) void Resize (size_t newSize)
{ {
if (newSize > DataSize) if (newSize > DataSize)
{ {
byte *tmp = new byte[newSize]; uint8 *tmp = new uint8[newSize];
if (!tmp) if (!tmp)
throw bad_alloc(); throw bad_alloc();
memcpy (tmp, DataPtr, DataSize); memcpy (tmp, DataPtr, DataSize);
@ -93,7 +93,7 @@ namespace VeraCrypt
} }
protected: protected:
byte *DataPtr; uint8 *DataPtr;
size_t DataSize; size_t DataSize;
}; };
@ -115,17 +115,17 @@ namespace VeraCrypt
struct PartitionEntryMBR struct PartitionEntryMBR
{ {
byte BootIndicator; uint8 BootIndicator;
byte StartHead; uint8 StartHead;
byte StartCylSector; uint8 StartCylSector;
byte StartCylinder; uint8 StartCylinder;
byte Type; uint8 Type;
byte EndHead; uint8 EndHead;
byte EndSector; uint8 EndSector;
byte EndCylinder; uint8 EndCylinder;
uint32 StartLBA; uint32 StartLBA;
uint32 SectorCountLBA; uint32 SectorCountLBA;
@ -133,7 +133,7 @@ namespace VeraCrypt
struct MBR struct MBR
{ {
byte Code[446]; uint8 Code[446];
PartitionEntryMBR Partitions[4]; PartitionEntryMBR Partitions[4];
uint16 Signature; uint16 Signature;
}; };
@ -200,13 +200,13 @@ namespace VeraCrypt
void DeleteStartExec(uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL); 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 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 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); void CopyFile(const wchar_t* name, const wchar_t* targetName);
bool FileExists(const wchar_t* name); bool FileExists(const wchar_t* name);
static bool CompareFiles (const wchar_t* fileName1, const wchar_t* fileName2); 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 RenameFile(const wchar_t* name, const wchar_t* nameNew, BOOL bForce);
BOOL DelFile(const wchar_t* name); BOOL DelFile(const wchar_t* name);
@ -258,7 +258,7 @@ namespace VeraCrypt
DWORD GetDriverServiceStartType (); DWORD GetDriverServiceStartType ();
unsigned int GetHiddenOSCreationPhase (); unsigned int GetHiddenOSCreationPhase ();
uint16 GetInstalledBootLoaderVersion (); uint16 GetInstalledBootLoaderVersion ();
void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]); void GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
Partition GetPartitionForHiddenOS (); Partition GetPartitionForHiddenOS ();
bool IsBootLoaderOnDrive (wchar_t *devicePath); bool IsBootLoaderOnDrive (wchar_t *devicePath);
BootEncryptionStatus GetStatus (); BootEncryptionStatus GetStatus ();
@ -275,7 +275,7 @@ namespace VeraCrypt
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5); 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 PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath);
void ProbeRealSystemDriveSize (); 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 ReadDriverConfigurationFlags ();
uint32 ReadServiceConfigurationFlags (); uint32 ReadServiceConfigurationFlags ();
void RegisterBootDriver (bool hiddenSystem); void RegisterBootDriver (bool hiddenSystem);
@ -295,7 +295,7 @@ namespace VeraCrypt
void StartDecryption (BOOL discardUnreadableEncryptedSectors); void StartDecryption (BOOL discardUnreadableEncryptedSectors);
void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm); void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm);
void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors); void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors);
bool SystemDriveContainsPartitionType (byte type); bool SystemDriveContainsPartitionType (uint8 type);
bool SystemDriveContainsExtendedPartition (); bool SystemDriveContainsExtendedPartition ();
bool SystemDriveContainsNonStandardPartitions (); bool SystemDriveContainsNonStandardPartitions ();
bool SystemPartitionCoversWholeDrive (); bool SystemPartitionCoversWholeDrive ();
@ -303,10 +303,10 @@ namespace VeraCrypt
bool VerifyRescueDisk (); bool VerifyRescueDisk ();
bool VerifyRescueDiskImage (const wchar_t* imageFile); bool VerifyRescueDiskImage (const wchar_t* imageFile);
void WipeHiddenOSCreationConfig (); void WipeHiddenOSCreationConfig ();
void WriteBootDriveSector (uint64 offset, byte *data); void WriteBootDriveSector (uint64 offset, uint8 *data);
void WriteBootSectorConfig (const byte newConfig[]); void WriteBootSectorConfig (const uint8 newConfig[]);
void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg); void WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg);
void WriteEfiBootSectorUserConfig (byte 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 WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value);
void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn); void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn);
void BackupSystemLoader (); void BackupSystemLoader ();
@ -318,10 +318,10 @@ namespace VeraCrypt
protected: protected:
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image 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); void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim);
wstring GetSystemLoaderBackupPath (); wstring GetSystemLoaderBackupPath ();
uint32 GetChecksum (byte *data, size_t size); uint32 GetChecksum (uint8 *data, size_t size);
DISK_GEOMETRY_EX GetDriveGeometry (int driveNumber); DISK_GEOMETRY_EX GetDriveGeometry (int driveNumber);
PartitionList GetDrivePartitions (int driveNumber); PartitionList GetDrivePartitions (int driveNumber);
wstring GetRemarksOnHiddenOS (); wstring GetRemarksOnHiddenOS ();
@ -334,11 +334,11 @@ namespace VeraCrypt
int SelectedEncryptionAlgorithmId; int SelectedEncryptionAlgorithmId;
int SelectedPrfAlgorithmId; int SelectedPrfAlgorithmId;
Partition HiddenOSCandidatePartition; Partition HiddenOSCandidatePartition;
byte *RescueIsoImage; uint8 *RescueIsoImage;
byte *RescueZipData; uint8 *RescueZipData;
unsigned long RescueZipSize; unsigned long RescueZipSize;
byte RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; uint8 RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
byte VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; uint8 VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
bool DriveConfigValid; bool DriveConfigValid;
bool RealSystemDriveSizeValid; bool RealSystemDriveSizeValid;
bool RescueVolumeHeaderValid; bool RescueVolumeHeaderValid;

View File

@ -116,7 +116,7 @@ namespace VeraCrypt
clear(); 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_nc = 0;
m_ne = 0; m_ne = 0;
@ -156,7 +156,7 @@ namespace VeraCrypt
{ {
// case 2s // case 2s
// 256 is encoded as 0x00 // 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); m_apdu.resize(5, 0);
setHeader(cla, ins, p1, p2); setHeader(cla, ins, p1, p2);
m_apdu[4] = len; m_apdu[4] = len;
@ -164,7 +164,7 @@ namespace VeraCrypt
else else
{ {
// case 2e // case 2e
byte l1, l2; uint8 l1, l2;
// 65536 is encoded as 0x00 0x00 // 65536 is encoded as 0x00 0x00
if (m_ne == 65536) if (m_ne == 65536)
{ {
@ -173,8 +173,8 @@ namespace VeraCrypt
} }
else else
{ {
l1 = (byte)(m_ne >> 8); l1 = (uint8)(m_ne >> 8);
l2 = (byte)m_ne; l2 = (uint8)m_ne;
} }
m_apdu.resize(7, 0); m_apdu.resize(7, 0);
setHeader(cla, ins, p1, p2); setHeader(cla, ins, p1, p2);
@ -194,7 +194,7 @@ namespace VeraCrypt
// case 3s // case 3s
m_apdu.resize(4 + 1 + dataLength, 0); m_apdu.resize(4 + 1 + dataLength, 0);
setHeader(cla, ins, p1, p2); setHeader(cla, ins, p1, p2);
m_apdu[4] = (byte)dataLength; m_apdu[4] = (uint8)dataLength;
m_dataOffset = 5; m_dataOffset = 5;
memcpy(m_apdu.data() + 5, data + dataOffset, dataLength); memcpy(m_apdu.data() + 5, data + dataOffset, dataLength);
} }
@ -204,8 +204,8 @@ namespace VeraCrypt
m_apdu.resize(4 + 3 + dataLength, 0); m_apdu.resize(4 + 3 + dataLength, 0);
setHeader(cla, ins, p1, p2); setHeader(cla, ins, p1, p2);
m_apdu[4] = 0; m_apdu[4] = 0;
m_apdu[5] = (byte)(dataLength >> 8); m_apdu[5] = (uint8)(dataLength >> 8);
m_apdu[6] = (byte)dataLength; m_apdu[6] = (uint8)dataLength;
m_dataOffset = 7; m_dataOffset = 7;
memcpy(m_apdu.data() + 7, data + dataOffset, dataLength); memcpy(m_apdu.data() + 7, data + dataOffset, dataLength);
m_isExtendedAPDU = true; m_isExtendedAPDU = true;
@ -219,10 +219,10 @@ namespace VeraCrypt
// case 4s // case 4s
m_apdu.resize(4 + 2 + dataLength, 0); m_apdu.resize(4 + 2 + dataLength, 0);
setHeader(cla, ins, p1, p2); setHeader(cla, ins, p1, p2);
m_apdu[4] = (byte)dataLength; m_apdu[4] = (uint8)dataLength;
m_dataOffset = 5; m_dataOffset = 5;
memcpy(m_apdu.data() + 5, data + dataOffset, dataLength); 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 else
{ {
@ -230,15 +230,15 @@ namespace VeraCrypt
m_apdu.resize(4 + 5 + dataLength, 0); m_apdu.resize(4 + 5 + dataLength, 0);
setHeader(cla, ins, p1, p2); setHeader(cla, ins, p1, p2);
m_apdu[4] = 0; m_apdu[4] = 0;
m_apdu[5] = (byte)(dataLength >> 8); m_apdu[5] = (uint8)(dataLength >> 8);
m_apdu[6] = (byte)dataLength; m_apdu[6] = (uint8)dataLength;
m_dataOffset = 7; m_dataOffset = 7;
memcpy(m_apdu.data() + 7, data + dataOffset, dataLength); memcpy(m_apdu.data() + 7, data + dataOffset, dataLength);
if (ne != 65536) if (ne != 65536)
{ {
size_t leOfs = m_apdu.size() - 2; size_t leOfs = m_apdu.size() - 2;
m_apdu[leOfs] = (byte)(m_ne >> 8); m_apdu[leOfs] = (uint8)(m_ne >> 8);
m_apdu[leOfs + 1] = (byte)m_ne; m_apdu[leOfs + 1] = (uint8)m_ne;
} // else le == 65536: no need to fill in, encoded as 0 } // else le == 65536: no need to fill in, encoded as 0
m_isExtendedAPDU = true; m_isExtendedAPDU = true;
} }
@ -248,12 +248,12 @@ namespace VeraCrypt
m_parsedSuccessfully = true; 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[0] = (uint8)cla;
m_apdu[1] = (byte)ins; m_apdu[1] = (uint8)ins;
m_apdu[2] = (byte)p1; m_apdu[2] = (uint8)p1;
m_apdu[3] = (byte)p2; m_apdu[3] = (uint8)p2;
} }
void CommandAPDU::clear() void CommandAPDU::clear()
@ -264,58 +264,58 @@ namespace VeraCrypt
m_dataOffset = 0; 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); 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); 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); 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); 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); 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); 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; m_apdu = apdu;
parse(); parse();
} }
byte CommandAPDU::getCLA() uint8 CommandAPDU::getCLA()
{ {
return m_apdu[0] & 0xff; return m_apdu[0] & 0xff;
} }
byte CommandAPDU::getINS() uint8 CommandAPDU::getINS()
{ {
return m_apdu[1] & 0xff; return m_apdu[1] & 0xff;
} }
byte CommandAPDU::getP1() uint8 CommandAPDU::getP1()
{ {
return m_apdu[2] & 0xff; return m_apdu[2] & 0xff;
} }
byte CommandAPDU::getP2() uint8 CommandAPDU::getP2()
{ {
return m_apdu[3] & 0xff; return m_apdu[3] & 0xff;
} }
@ -325,9 +325,9 @@ namespace VeraCrypt
return m_nc; return m_nc;
} }
const vector<byte> CommandAPDU::getData() const vector<uint8> CommandAPDU::getData()
{ {
vector<byte> data; vector<uint8> data;
if (m_nc > 0) if (m_nc > 0)
{ {
@ -343,7 +343,7 @@ namespace VeraCrypt
return m_ne; return m_ne;
} }
const vector<byte> CommandAPDU::getAPDU() const vector<uint8> CommandAPDU::getAPDU()
{ {
return m_apdu; return m_apdu;
} }

View File

@ -34,7 +34,7 @@ namespace VeraCrypt
{ {
protected: protected:
vector<byte> m_apdu; vector<uint8> m_apdu;
uint32 m_nc; uint32 m_nc;
uint32 m_ne; uint32 m_ne;
uint32 m_dataOffset; uint32 m_dataOffset;
@ -43,8 +43,8 @@ namespace VeraCrypt
bool m_parsedSuccessfully; bool m_parsedSuccessfully;
void parse(); void parse();
void init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne); void init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
void setHeader(byte cla, byte ins, byte p1, byte p2); void setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2);
public: public:
@ -52,35 +52,35 @@ namespace VeraCrypt
CommandAPDU(); 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(); uint32 getNc();
const vector<byte> getData(); const vector<uint8> getData();
uint32 getNe(); uint32 getNe();
const vector<byte> getAPDU(); const vector<uint8> getAPDU();
bool isValid(); bool isValid();

View File

@ -219,7 +219,7 @@ void EncipherBlock(int cipher, void *data, void *ks)
void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{ {
byte *data = dataPtr; uint8 *data = dataPtr;
#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
KFLOATING_SAVE floatingPointState; KFLOATING_SAVE floatingPointState;
#endif #endif
@ -317,7 +317,7 @@ void DecipherBlock(int cipher, void *data, void *ks)
case AES: case AES:
#if defined (_WIN64) || !defined (TC_WINDOWS_DRIVER) #if defined (_WIN64) || !defined (TC_WINDOWS_DRIVER)
if (IsAesHwCpuSupported()) 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 else
#endif #endif
aes_decrypt (data, data, (void *) ((char *) ks + sizeof(aes_encrypt_ctx))); 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) void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{ {
byte *data = dataPtr; uint8 *data = dataPtr;
#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
KFLOATING_SAVE floatingPointState; KFLOATING_SAVE floatingPointState;
#endif #endif
@ -349,7 +349,7 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{ {
while (blockCount > 0) 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; data += 32 * 16;
blockCount -= 32; blockCount -= 32;
@ -855,7 +855,7 @@ int GetMaxPkcs5OutSize (void)
#ifdef TC_WINDOWS_BOOT #ifdef TC_WINDOWS_BOOT
static byte CryptoInfoBufferInUse = 0; static uint8 CryptoInfoBufferInUse = 0;
CRYPTO_INFO CryptoInfoBuffer; CRYPTO_INFO CryptoInfoBuffer;
#endif #endif
@ -1118,7 +1118,7 @@ void EncipherBlock(int cipher, void *data, void *ks)
{ {
#ifdef TC_WINDOWS_BOOT_AES #ifdef TC_WINDOWS_BOOT_AES
if (IsAesHwCpuSupported()) if (IsAesHwCpuSupported())
aes_hw_cpu_encrypt ((byte *) ks, data); aes_hw_cpu_encrypt ((uint8 *) ks, data);
else else
aes_encrypt (data, data, ks); aes_encrypt (data, data, ks);
#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) #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 #ifdef TC_WINDOWS_BOOT_AES
if (IsAesHwCpuSupported()) 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 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) #elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_decrypt (data, data, ks); serpent_decrypt (data, data, ks);
#elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
@ -1278,7 +1278,7 @@ BOOL IsRamEncryptionEnabled ()
} }
/* masking for random index to remove bias */ /* masking for random index to remove bias */
byte GetRngMask (byte count) uint8 GetRngMask (uint8 count)
{ {
if (count >= 128) if (count >= 128)
return 0xFF; return 0xFF;
@ -1297,10 +1297,10 @@ byte GetRngMask (byte count)
return 1; return 1;
} }
byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte elementsCount) uint8 GetRandomIndex (ChaCha20RngCtx* pCtx, uint8 elementsCount)
{ {
byte index = 0; uint8 index = 0;
byte mask = GetRngMask (elementsCount); uint8 mask = GetRngMask (elementsCount);
while (TRUE) while (TRUE)
{ {
@ -1315,7 +1315,7 @@ byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte elementsCount)
#if defined(_WIN64) && !defined (_UEFI) #if defined(_WIN64) && !defined (_UEFI)
/* declaration of variables and functions used for RAM encryption on 64-bit build */ /* 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 ULONG cbKeyDerivationArea = 0;
static uint64 HashSeedMask = 0; static uint64 HashSeedMask = 0;
@ -1331,9 +1331,9 @@ ULONG AllocTag = 'MMCV';
BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback) BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback)
{ {
ChaCha20RngCtx ctx; ChaCha20RngCtx ctx;
byte pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ]; uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
#ifdef TC_WINDOWS_DRIVER #ifdef TC_WINDOWS_DRIVER
byte i; uint8 i;
char randomStr[4]; char randomStr[4];
Dump ("InitializeSecurityParameters BEGIN\n"); Dump ("InitializeSecurityParameters BEGIN\n");
#endif #endif
@ -1390,7 +1390,7 @@ BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback)
cbKeyDerivationArea = 1024 * 1024; cbKeyDerivationArea = 1024 * 1024;
do do
{ {
pbKeyDerivationArea = (byte*) TCalloc(cbKeyDerivationArea); pbKeyDerivationArea = (uint8*) TCalloc(cbKeyDerivationArea);
if (!pbKeyDerivationArea) if (!pbKeyDerivationArea)
cbKeyDerivationArea >>= 1; cbKeyDerivationArea >>= 1;
} while (!pbKeyDerivationArea && (cbKeyDerivationArea >= (2*PAGE_SIZE))); } 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__) #if defined(_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__)
/* dummy implementation that should never be called */ /* 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; ks = ks;
data = data; 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; ks = ks;
data = data; data = data;
} }
void aes_hw_cpu_encrypt(const byte* ks, byte* data) void aes_hw_cpu_encrypt(const uint8* ks, uint8* data)
{ {
ks = ks; ks = ks;
data = data; 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; ks = ks;
data = data; data = data;

View File

@ -2884,7 +2884,7 @@ LRESULT CALLBACK CustomDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
static BOOL IsReturnAddress (DWORD64 address) static BOOL IsReturnAddress (DWORD64 address)
{ {
static size_t codeEnd = 0; static size_t codeEnd = 0;
byte *sp = (byte *) address; uint8 *sp = (uint8 *) address;
if (codeEnd == 0) if (codeEnd == 0)
{ {
@ -3018,7 +3018,7 @@ void ExceptionHandlerThread (void *threadArg)
MEMORY_BASIC_INFORMATION mi; MEMORY_BASIC_INFORMATION mi;
VirtualQuery (sp, &mi, sizeof (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; int i = 0;
while (retAddrs.size() < 16 && &sp[i] < stackTop) while (retAddrs.size() < 16 && &sp[i] < stackTop)
@ -5796,24 +5796,24 @@ wstring ArrayToHexWideString (const unsigned char* pbData, int cbData)
return result; return result;
} }
bool HexToByte (wchar_t c, byte& b) bool HexToByte (wchar_t c, uint8& b)
{ {
bool bRet = true; bool bRet = true;
if (c >= L'0' && c <= L'9') 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') 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') else if (c >= L'A' && c <= L'Z')
b = (byte) (c - L'A' + 10); b = (uint8) (c - L'A' + 10);
else else
bRet = false; bRet = false;
return bRet; 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); size_t i, len = wcslen (hexStr);
arr.clear(); arr.clear();
@ -8716,7 +8716,7 @@ int MountVolume (HWND hwndDlg,
if ((path.length () >= 3) && (_wcsnicmp (path.c_str(), L"ID:", 3) == 0)) 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)) if ( (path.length() == (3 + 2*VOLUME_ID_SIZE))
&& HexWideStringToArray (path.c_str() + 3, arr) && HexWideStringToArray (path.c_str() + 3, arr)
&& (arr.size() == VOLUME_ID_SIZE) && (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) if ((wcslen (volname) == (3 + 2*VOLUME_ID_SIZE)) && _wcsnicmp (volname, L"ID:", 3) == 0)
{ {
/* Volume ID specified. Use it for matching mounted volumes. */ /* 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)) if (HexWideStringToArray (&volname[3], arr) && (arr.size() == VOLUME_ID_SIZE))
{ {
return IsMountedVolumeID (&arr[0]); return IsMountedVolumeID (&arr[0]);
@ -11577,7 +11577,7 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password
// Read volume header // Read volume header
DWORD bytesRead; DWORD bytesRead;
if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (byte *) buffer, &bytesRead)) if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (uint8 *) buffer, &bytesRead))
{ {
status = ERR_OS_ERROR; status = ERR_OS_ERROR;
goto error; goto error;
@ -12162,7 +12162,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE)) if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE))
{ {
DWORD keyfileSize; DWORD keyfileSize;
byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize); uint8 *keyfileData = (uint8 *) LoadFile (keyfilePath, &keyfileSize);
if (!keyfileData) if (!keyfileData)
{ {
handleWin32Error (hwndDlg, SRC_POS); 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) 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); memcpy (&keyfileDataVector.front(), keyfileData, keyfileSize);
try try
@ -12229,7 +12229,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
WaitCursor(); WaitCursor();
finally_do ({ NormalCursor(); }); finally_do ({ NormalCursor(); });
vector <byte> keyfileData; vector <uint8> keyfileData;
keyfile->GetKeyfileData (keyfileData); keyfile->GetKeyfileData (keyfileData);
@ -12240,7 +12240,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
return 1; 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)) if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, (DWORD) keyfileData.size(), FALSE, FALSE))
throw SystemException (SRC_POS); 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); 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) if (bufferSize < patternSize)
return FALSE; 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" "[veracrypt_reg]\r\n"
"HKR,,\"" + filterReg + "\",0x0001" + string (registerFilter ? "0008" : "8002") + ",\"" + filter + "\"\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(); infFile.Close();
HINF hInf = SetupOpenInfFileW (infFileName.c_str(), NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); 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); 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) if (buffer && bufferSize)
{ {
@ -13606,7 +13606,7 @@ BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue)
size_t pathLen = pathValue? wcslen (pathValue) : 0; size_t pathLen = pathValue? wcslen (pathValue) : 0;
if ((pathLen >= 3) && (_wcsnicmp (pathValue, L"ID:", 3) == 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)) if ( (pathLen == (3 + 2*VOLUME_ID_SIZE))
&& HexWideStringToArray (pathValue + 3, arr) && HexWideStringToArray (pathValue + 3, arr)
&& (arr.size() == VOLUME_ID_SIZE) && (arr.size() == VOLUME_ID_SIZE)
@ -14758,7 +14758,7 @@ void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
{ {
LARGE_INTEGER iSeed; LARGE_INTEGER iSeed;
SYSTEMTIME sysTime; SYSTEMTIME sysTime;
byte digest[WHIRLPOOL_DIGESTSIZE]; uint8 digest[WHIRLPOOL_DIGESTSIZE];
WHIRLPOOL_CTX tctx; WHIRLPOOL_CTX tctx;
size_t count; size_t count;

View File

@ -550,9 +550,9 @@ BOOL InitSecurityTokenLibrary (HWND hwndDlg);
BOOL FileHasReadOnlyAttribute (const wchar_t *path); BOOL FileHasReadOnlyAttribute (const wchar_t *path);
BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path); BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path);
void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors); void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors);
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);
BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str); BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *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);
int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt); int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt);
BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath); BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath);
void EnableElevatedCursorChange (HWND parent); void EnableElevatedCursorChange (HWND parent);
@ -573,7 +573,7 @@ int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz); HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy); void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
void AllowMessageInUIPI (UINT msg); 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 TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue);
BOOL CopyTextToClipboard (const wchar_t* txtValue); BOOL CopyTextToClipboard (const wchar_t* txtValue);
BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args); 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 GetUserFriendlyVersionString (int version);
std::wstring IntToWideString (int val); std::wstring IntToWideString (int val);
std::wstring ArrayToHexWideString (const unsigned char* pbData, int cbData); 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); 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); void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey);
std::wstring GetTempPathString (); std::wstring GetTempPathString ();

View File

@ -40,19 +40,19 @@ namespace VeraCrypt
} }
#endif #endif
map<EMVCardType, vector<byte>> InitializeSupportedAIDs() map<EMVCardType, vector<uint8>> InitializeSupportedAIDs()
{ {
map<EMVCardType, vector<byte>> supportedAIDs; map<EMVCardType, vector<uint8>> 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::AMEX, vector<uint8>(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::MASTERCARD, vector<uint8>(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)))); supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<uint8>(EMVCard::VISA_AID, EMVCard::VISA_AID + sizeof(EMVCard::VISA_AID))));
return supportedAIDs; return supportedAIDs;
} }
const byte EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10}; const uint8 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 uint8 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 uint8 EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10};
const map<EMVCardType, vector<byte>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs(); const map<EMVCardType, vector<uint8>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs();
EMVCard::EMVCard() : SCard(), m_lastPANDigits(L"") EMVCard::EMVCard() : SCard(), m_lastPANDigits(L"")
{ {
@ -130,15 +130,15 @@ namespace VeraCrypt
m_lastPANDigits.clear(); m_lastPANDigits.clear();
} }
vector<byte> EMVCard::GetCardAID(bool forceContactless) vector<uint8> EMVCard::GetCardAID(bool forceContactless)
{ {
vector<vector<byte>> supportedAIDs; vector<vector<uint8>> supportedAIDs;
vector<byte> supportedAIDsPriorities; vector<uint8> supportedAIDsPriorities;
vector<pair<byte, vector<byte>>> supportedAIDsSorted; vector<pair<uint8, vector<uint8>>> supportedAIDsSorted;
bool hasBeenReset = false; bool hasBeenReset = false;
CommandAPDU command; CommandAPDU command;
ResponseAPDU response; ResponseAPDU response;
vector<byte> responseData; vector<uint8> responseData;
shared_ptr<TLVNode> rootNode; shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> fciNode; shared_ptr<TLVNode> fciNode;
shared_ptr<TLVNode> dfNameNode; shared_ptr<TLVNode> dfNameNode;
@ -149,7 +149,7 @@ namespace VeraCrypt
vector<shared_ptr<TLVNode>> pseDirectoryNodes; vector<shared_ptr<TLVNode>> pseDirectoryNodes;
unsigned char sfi; unsigned char sfi;
bool usingContactless = false; bool usingContactless = false;
vector<byte> tokenAID; vector<uint8> tokenAID;
if (m_aid.size()) if (m_aid.size())
return m_aid; return m_aid;
@ -241,7 +241,7 @@ namespace VeraCrypt
{ {
sfi = sfiNode->Value->at(0); sfi = sfiNode->Value->at(0);
byte rec = 1; uint8 rec = 1;
do do
{ {
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec++, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize); command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec++, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
@ -316,20 +316,20 @@ namespace VeraCrypt
return tokenAID; 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 hasBeenReset = false;
bool aidSelected = false; bool aidSelected = false;
bool iccFound = false; bool iccFound = false;
bool issuerFound = false; bool issuerFound = false;
bool cplcFound = false; bool cplcFound = false;
vector<byte> emvCardAid; vector<uint8> emvCardAid;
shared_ptr<TLVNode> rootNode; shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> iccPublicKeyCertNode; shared_ptr<TLVNode> iccPublicKeyCertNode;
shared_ptr<TLVNode> issuerPublicKeyCertNode; shared_ptr<TLVNode> issuerPublicKeyCertNode;
CommandAPDU command; CommandAPDU command;
ResponseAPDU response; ResponseAPDU response;
vector<byte> responseData; vector<uint8> responseData;
iccCert.clear(); iccCert.clear();
issuerCert.clear(); issuerCert.clear();
@ -374,9 +374,9 @@ namespace VeraCrypt
// TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL, // 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. // 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); command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response); m_reader->ApduProcessData(command, response);
@ -436,13 +436,13 @@ namespace VeraCrypt
bool hasBeenReset = false; bool hasBeenReset = false;
bool panFound = false; bool panFound = false;
bool aidSelected = false; bool aidSelected = false;
vector<byte> EMVCardAid; vector<uint8> EMVCardAid;
vector<byte> panData; vector<uint8> panData;
shared_ptr<TLVNode> rootNode; shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> panNode; shared_ptr<TLVNode> panNode;
CommandAPDU command; CommandAPDU command;
ResponseAPDU response; ResponseAPDU response;
vector<byte> responseData; vector<uint8> responseData;
lastPANDigits = L""; lastPANDigits = L"";
@ -474,9 +474,9 @@ namespace VeraCrypt
// TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL, // 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. // 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); command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response); m_reader->ApduProcessData(command, response);
@ -498,7 +498,7 @@ namespace VeraCrypt
{ {
panFound = true; panFound = true;
panData = *panNode->Value.get(); 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]); std::swap(panData[0], panData[1]);
lastPANDigits = ArrayToHexWideString(panData.data(), (int) panData.size()); lastPANDigits = ArrayToHexWideString(panData.data(), (int) panData.size());
} }

View File

@ -29,11 +29,11 @@ namespace VeraCrypt
// After the card has been read, and if some or all fields cannot be read, the EMVCard // 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 // object will be considered invalid and will not be included in the list of available cards
// of EMVToken. // of EMVToken.
vector<byte> m_aid; vector<uint8> m_aid;
vector<vector<byte>> m_supportedAids; vector<vector<uint8>> m_supportedAids;
vector<byte> m_iccCert; vector<uint8> m_iccCert;
vector<byte> m_issuerCert; vector<uint8> m_issuerCert;
vector<byte> m_cplcData; vector<uint8> m_cplcData;
wstring m_lastPANDigits; wstring m_lastPANDigits;
public: public:
@ -41,10 +41,10 @@ namespace VeraCrypt
// Add other AIDS // Add other AIDS
// https://gist.github.com/pvieito/6224eed92c99b069f6401996c548d0e4 // https://gist.github.com/pvieito/6224eed92c99b069f6401996c548d0e4
// https://ambimat.com/developer-resources/list-of-application-identifiers-aid/ // https://ambimat.com/developer-resources/list-of-application-identifiers-aid/
const static byte AMEX_AID[7]; const static uint8 AMEX_AID[7];
const static byte MASTERCARD_AID[7]; const static uint8 MASTERCARD_AID[7];
const static byte VISA_AID[7]; const static uint8 VISA_AID[7];
const static map<EMVCardType, vector<byte>> SUPPORTED_AIDS; const static map<EMVCardType, vector<uint8>> SUPPORTED_AIDS;
EMVCard(); EMVCard();
EMVCard(size_t slotId); EMVCard(size_t slotId);
@ -59,9 +59,9 @@ namespace VeraCrypt
// Retrieves the card's AID. // Retrieves the card's AID.
// It first checks the card against a list of supported AIDs. // It first checks the card against a list of supported AIDs.
// If that fails, it tries getting the AID from the card using PSE // 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); void GetCardPAN(wstring& lastPANDigits);
}; };
} }

View File

@ -22,7 +22,7 @@ using namespace std;
namespace VeraCrypt 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) if (cbData > 0 && from <= cbData - 2 && length > 0 && length <= cbData - from)
{ {
@ -74,13 +74,13 @@ namespace VeraCrypt
return path.str(); 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; map <unsigned long int, shared_ptr<EMVCard>>::iterator emvCardsIt;
shared_ptr<EMVCard> card; shared_ptr<EMVCard> card;
vector<byte> iccCert; vector<uint8> iccCert;
vector<byte> issuerCert; vector<uint8> issuerCert;
vector<byte> cplcData; vector<uint8> cplcData;
bool addNewCard = true; bool addNewCard = true;
keyfileData.clear(); keyfileData.clear();

View File

@ -23,7 +23,7 @@ namespace VeraCrypt
virtual ~EMVTokenKeyfile() {}; virtual ~EMVTokenKeyfile() {};
virtual operator TokenKeyfilePath () const; virtual operator TokenKeyfilePath () const;
virtual void GetKeyfileData(vector <byte>& keyfileData) const; virtual void GetKeyfileData(vector <uint8>& keyfileData) const;
}; };
class EMVToken class EMVToken
@ -33,7 +33,7 @@ namespace VeraCrypt
static vector<EMVTokenKeyfile> GetAvailableKeyfiles(unsigned long int* slotIdFilter = nullptr, const wstring& keyfileIdFilter = wstring()); static vector<EMVTokenKeyfile> GetAvailableKeyfiles(unsigned long int* slotIdFilter = nullptr, const wstring& keyfileIdFilter = wstring());
static EMVTokenInfo GetTokenInfo(unsigned long int slotId); 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; static map <unsigned long int, shared_ptr<EMVCard>> EMVCards;
}; };

View File

@ -88,7 +88,7 @@ typedef struct EncryptionThreadPoolWorkItemStruct
struct struct
{ {
PCRYPTO_INFO CryptoInfo; PCRYPTO_INFO CryptoInfo;
byte *Data; uint8 *Data;
UINT64_STRUCT StartUnitNo; UINT64_STRUCT StartUnitNo;
uint32 UnitCount; 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 fragmentCount;
uint32 unitsPerFragment; uint32 unitsPerFragment;
uint32 remainder; uint32 remainder;
byte *fragmentData; uint8 *fragmentData;
uint64 fragmentStartUnitNo; uint64 fragmentStartUnitNo;
EncryptionThreadPoolWorkItem *workItem; EncryptionThreadPoolWorkItem *workItem;

View File

@ -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 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 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); BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount);
void EncryptionThreadPoolStop (); void EncryptionThreadPoolStop ();
size_t GetEncryptionThreadCount (); size_t GetEncryptionThreadCount ();

View File

@ -14,7 +14,7 @@
typedef struct fatparams_t typedef struct fatparams_t
{ {
char volume_name[11]; char volume_name[11];
byte volume_id[4]; uint8 volume_id[4];
unsigned int num_sectors; /* total number of sectors */ unsigned int num_sectors; /* total number of sectors */
int cluster_count; /* number of clusters */ int cluster_count; /* number of clusters */
int size_root_dir; /* size of the root directory in bytes */ int size_root_dir; /* size of the root directory in bytes */

View File

@ -532,7 +532,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
// To prevent fragmentation, write zeroes to reserved header sectors which are going to be filled with random data // To prevent fragmentation, write zeroes to reserved header sectors which are going to be filled with random data
if (!volParams->bDevice && !volParams->hiddenVol) 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; DWORD bytesWritten;
ZeroMemory (buf, sizeof (buf)); ZeroMemory (buf, sizeof (buf));
@ -1392,7 +1392,7 @@ static volatile BOOL WriteThreadRunning;
static volatile BOOL WriteThreadExitRequested; static volatile BOOL WriteThreadExitRequested;
static HANDLE WriteThreadHandle; static HANDLE WriteThreadHandle;
static byte *WriteThreadBuffer; static uint8 *WriteThreadBuffer;
static HANDLE WriteBufferEmptyEvent; static HANDLE WriteBufferEmptyEvent;
static HANDLE WriteBufferFullEvent; static HANDLE WriteBufferFullEvent;

View File

@ -253,7 +253,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
if (Token::IsKeyfilePathValid (kf->FileName, EMVSupportEnabled? true : false)) if (Token::IsKeyfilePathValid (kf->FileName, EMVSupportEnabled? true : false))
{ {
// Apply security token keyfile // Apply security token keyfile
vector <byte> keyfileData; vector <uint8> keyfileData;
TokenKeyfilePath secPath (kf->FileName); TokenKeyfilePath secPath (kf->FileName);
Token::getTokenKeyfile (secPath)->GetKeyfileData (keyfileData); Token::getTokenKeyfile (secPath)->GetKeyfileData (keyfileData);

View File

@ -5,7 +5,7 @@ using namespace std;
namespace VeraCrypt namespace VeraCrypt
{ {
uint16 BytesToUInt16(const vector<byte>& buff) uint16 BytesToUInt16(const vector<uint8>& buff)
{ {
uint16 value = 0; uint16 value = 0;
for (uint16 i = 0; i < buff.size(); i++) for (uint16 i = 0; i < buff.size(); i++)
@ -17,7 +17,7 @@ namespace VeraCrypt
return value; 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 (); size_t orgSize = buffer.size ();
buffer.resize (orgSize + cbData); 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_data = data;
m_SW = SW; m_SW = SW;
@ -47,19 +47,19 @@ namespace VeraCrypt
return (uint32)m_data.size(); return (uint32)m_data.size();
} }
const vector<byte> ResponseAPDU::getData() const vector<uint8> ResponseAPDU::getData()
{ {
return m_data; 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() uint16 ResponseAPDU::getSW()
@ -67,23 +67,23 @@ namespace VeraCrypt
return m_SW; 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()); AppendData(apdu, m_data.data(), m_data.size());
apdu.push_back((byte)getSW1()); apdu.push_back((uint8)getSW1());
apdu.push_back((byte)getSW2()); apdu.push_back((uint8)getSW2());
return apdu; return apdu;
} }
void ResponseAPDU::appendData(const vector<byte>& data) void ResponseAPDU::appendData(const vector<uint8>& data)
{ {
appendData(data.data(), data.size()); 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); AppendData(m_data, data, dataLen);
} }
@ -93,12 +93,12 @@ namespace VeraCrypt
m_SW = SW; m_SW = SW;
} }
void ResponseAPDU::setBytes(const vector<byte>& bytes) void ResponseAPDU::setBytes(const vector<uint8>& bytes)
{ {
clear(); clear();
if (bytes.size() >= 2) if (bytes.size() >= 2)
{ {
vector<byte> SWBytes; vector<uint8> SWBytes;
m_data.resize(bytes.size() - 2); m_data.resize(bytes.size() - 2);
SWBytes.resize(2); SWBytes.resize(2);

View File

@ -9,7 +9,7 @@ namespace VeraCrypt
{ {
protected: protected:
vector<byte> m_data; vector<uint8> m_data;
uint16 m_SW; uint16 m_SW;
@ -19,25 +19,25 @@ namespace VeraCrypt
ResponseAPDU(); ResponseAPDU();
ResponseAPDU(const vector<byte>& data, uint16 SW); ResponseAPDU(const vector<uint8>& data, uint16 SW);
uint32 getNr(); uint32 getNr();
const vector<byte> getData(); const vector<uint8> getData();
byte getSW1(); uint8 getSW1();
byte getSW2(); uint8 getSW2();
uint16 getSW(); uint16 getSW();
const vector<byte> getBytes(); const vector<uint8> getBytes();
void setSW(uint16 SW); 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 vector<uint8>& data);
void appendData(const byte* data, size_t dataLen); void appendData(const uint8* data, size_t dataLen);
}; };
}; };

View File

@ -14,7 +14,7 @@
#include <PCSC/wintypes.h> #include <PCSC/wintypes.h>
#include "reader.h" #include "reader.h"
typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE; typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE;
using VeraCrypt::byte; using VeraCrypt::uint8;
#define BOOL int #define BOOL int
#else #else
#undef BOOL #undef BOOL
@ -22,7 +22,7 @@ using VeraCrypt::byte;
#include <winscard.h> #include <winscard.h>
#include <wintypes.h> #include <wintypes.h>
#include <reader.h> #include <reader.h>
using VeraCrypt::byte; using VeraCrypt::uint8;
#define BOOL int #define BOOL int
#endif #endif
#endif #endif

View File

@ -117,7 +117,7 @@ namespace VeraCrypt
return name; return name;
} }
bool SCardReader::IsCardPresent(vector<byte>& cardAtr) bool SCardReader::IsCardPresent(vector<uint8>& cardAtr)
{ {
LONG lRet = SCARD_S_SUCCESS; LONG lRet = SCARD_S_SUCCESS;
SCARD_READERSTATE state; SCARD_READERSTATE state;
@ -165,7 +165,7 @@ namespace VeraCrypt
bool SCardReader::IsCardPresent() bool SCardReader::IsCardPresent()
{ {
vector<byte> dummy; vector<uint8> dummy;
return IsCardPresent(dummy); return IsCardPresent(dummy);
} }
@ -398,8 +398,8 @@ namespace VeraCrypt
size_t indexOfLe = 0; size_t indexOfLe = 0;
size_t indexOfLcData = 0; size_t indexOfLcData = 0;
vector<byte> pbSendBuffer; vector<uint8> pbSendBuffer;
vector<byte> pbRecvBuffer; vector<uint8> pbRecvBuffer;
DWORD cbSendLength = 0; DWORD cbSendLength = 0;
DWORD cbRecvLength = 0; DWORD cbRecvLength = 0;
@ -460,7 +460,7 @@ namespace VeraCrypt
// 256 is encoded as 0x00 // 256 is encoded as 0x00
pbSendBuffer[4] = (BYTE)ne; pbSendBuffer[4] = (BYTE)ne;
indexOfLe = 4; indexOfLe = 4;
cbSendLength = 4 + 1; // header || Le (1 byte) cbSendLength = 4 + 1; // header || Le (1 uint8)
} }
else else
{ {
@ -494,7 +494,7 @@ namespace VeraCrypt
// case 3s // case 3s
pbSendBuffer[4] = (BYTE)nc; pbSendBuffer[4] = (BYTE)nc;
indexOfLcData = 5; 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); memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc);
} }
else else
@ -518,7 +518,7 @@ namespace VeraCrypt
// case 4s // case 4s
pbSendBuffer[4] = (BYTE)nc; pbSendBuffer[4] = (BYTE)nc;
indexOfLcData = 5; 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); memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc);
pbSendBuffer[indexOfLcData + nc] = (ne != 256) ? (BYTE)ne : 0; pbSendBuffer[indexOfLcData + nc] = (ne != 256) ? (BYTE)ne : 0;
indexOfLe = indexOfLcData + nc; indexOfLe = indexOfLcData + nc;
@ -646,9 +646,9 @@ namespace VeraCrypt
throw PCSCException(lRet); throw PCSCException(lRet);
} }
void SCardReader::GetATRFromHandle(vector<byte>& atrValue) void SCardReader::GetATRFromHandle(vector<uint8>& atrValue)
{ {
vector<byte> pbATR; vector<uint8> pbATR;
DWORD cByte = 0; DWORD cByte = 0;
LONG lRet = 0; LONG lRet = 0;

View File

@ -51,52 +51,52 @@ namespace VeraCrypt
/* ================================================================================================ */ /* ================================================================================================ */
/* CLA values */ /* CLA values */
/* ================================================================================================ */ /* ================================================================================================ */
const byte CLA_ISO7816 = (byte)0x00; const uint8 CLA_ISO7816 = (uint8)0x00;
const byte CLA_COMMAND_CHAINING = (byte)0x10; const uint8 CLA_COMMAND_CHAINING = (uint8)0x10;
/* ================================================================================================ */ /* ================================================================================================ */
/* INS values */ /* INS values */
/* ================================================================================================ */ /* ================================================================================================ */
const byte INS_ERASE_BINARY = 0x0E; const uint8 INS_ERASE_BINARY = 0x0E;
const byte INS_VERIFY = 0x20; const uint8 INS_VERIFY = 0x20;
const byte INS_CHANGE_CHV = 0x24; const uint8 INS_CHANGE_CHV = 0x24;
const byte INS_UNBLOCK_CHV = 0x2C; const uint8 INS_UNBLOCK_CHV = 0x2C;
const byte INS_DECREASE = 0x30; const uint8 INS_DECREASE = 0x30;
const byte INS_INCREASE = 0x32; const uint8 INS_INCREASE = 0x32;
const byte INS_DECREASE_STAMPED = 0x34; const uint8 INS_DECREASE_STAMPED = 0x34;
const byte INS_REHABILITATE_CHV = 0x44; const uint8 INS_REHABILITATE_CHV = 0x44;
const byte INS_MANAGE_CHANNEL = 0x70; const uint8 INS_MANAGE_CHANNEL = 0x70;
const byte INS_EXTERNAL_AUTHENTICATE = (byte)0x82; const uint8 INS_EXTERNAL_AUTHENTICATE = (uint8)0x82;
const byte INS_MUTUAL_AUTHENTICATE = (byte)0x82; const uint8 INS_MUTUAL_AUTHENTICATE = (uint8)0x82;
const byte INS_GET_CHALLENGE = (byte)0x84; const uint8 INS_GET_CHALLENGE = (uint8)0x84;
const byte INS_ASK_RANDOM = (byte)0x84; const uint8 INS_ASK_RANDOM = (uint8)0x84;
const byte INS_GIVE_RANDOM = (byte)0x86; const uint8 INS_GIVE_RANDOM = (uint8)0x86;
const byte INS_INTERNAL_AUTHENTICATE = (byte)0x88; const uint8 INS_INTERNAL_AUTHENTICATE = (uint8)0x88;
const byte INS_SEEK = (byte)0xA2; const uint8 INS_SEEK = (uint8)0xA2;
const byte INS_SELECT = (byte)0xA4; const uint8 INS_SELECT = (uint8)0xA4;
const byte INS_SELECT_FILE = (byte)0xA4; const uint8 INS_SELECT_FILE = (uint8)0xA4;
const byte INS_CLOSE_APPLICATION = (byte)0xAC; const uint8 INS_CLOSE_APPLICATION = (uint8)0xAC;
const byte INS_READ_BINARY = (byte)0xB0; const uint8 INS_READ_BINARY = (uint8)0xB0;
const byte INS_READ_BINARY2 = (byte)0xB1; const uint8 INS_READ_BINARY2 = (uint8)0xB1;
const byte INS_READ_RECORD = (byte)0xB2; const uint8 INS_READ_RECORD = (uint8)0xB2;
const byte INS_READ_RECORD2 = (byte)0xB3; const uint8 INS_READ_RECORD2 = (uint8)0xB3;
const byte INS_READ_RECORDS = (byte)0xB2; const uint8 INS_READ_RECORDS = (uint8)0xB2;
const byte INS_READ_BINARY_STAMPED = (byte)0xB4; const uint8 INS_READ_BINARY_STAMPED = (uint8)0xB4;
const byte INS_READ_RECORD_STAMPED = (byte)0xB6; const uint8 INS_READ_RECORD_STAMPED = (uint8)0xB6;
const byte INS_GET_RESPONSE = (byte)0xC0; const uint8 INS_GET_RESPONSE = (uint8)0xC0;
const byte INS_ENVELOPE = (byte)0xC2; const uint8 INS_ENVELOPE = (uint8)0xC2;
const byte INS_GET_DATA = (byte)0xCA; const uint8 INS_GET_DATA = (uint8)0xCA;
const byte INS_WRITE_BINARY = (byte)0xD0; const uint8 INS_WRITE_BINARY = (uint8)0xD0;
const byte INS_WRITE_RECORD = (byte)0xD2; const uint8 INS_WRITE_RECORD = (uint8)0xD2;
const byte INS_UPDATE_BINARY = (byte)0xD6; const uint8 INS_UPDATE_BINARY = (uint8)0xD6;
const byte INS_LOAD_KEY_FILE = (byte)0xD8; const uint8 INS_LOAD_KEY_FILE = (uint8)0xD8;
const byte INS_PUT_DATA = (byte)0xDA; const uint8 INS_PUT_DATA = (uint8)0xDA;
const byte INS_UPDATE_RECORD = (byte)0xDC; const uint8 INS_UPDATE_RECORD = (uint8)0xDC;
const byte INS_CREATE_FILE = (byte)0xE0; const uint8 INS_CREATE_FILE = (uint8)0xE0;
const byte INS_APPEND_RECORD = (byte)0xE2; const uint8 INS_APPEND_RECORD = (uint8)0xE2;
const byte INS_DELETE_FILE = (byte)0xE4; const uint8 INS_DELETE_FILE = (uint8)0xE4;
const byte INS_PSO = (byte)0x2A; const uint8 INS_PSO = (uint8)0x2A;
const byte INS_MSE = (byte)0x22; const uint8 INS_MSE = (uint8)0x22;
/* ================================================================================================ */ /* ================================================================================================ */
/* EMV values */ /* EMV values */
@ -104,19 +104,19 @@ namespace VeraCrypt
const uint16 EMV_CPLC_TAG = (uint16)0x9F7F; const uint16 EMV_CPLC_TAG = (uint16)0x9F7F;
const uint16 EMV_ICC_PK_CERT_TAG = (uint16)0x9F46; const uint16 EMV_ICC_PK_CERT_TAG = (uint16)0x9F46;
const uint16 EMV_FCI_ISSUER_DISCRETIONARY_DATA_TAG = (uint16)0xBF0C; const uint16 EMV_FCI_ISSUER_DISCRETIONARY_DATA_TAG = (uint16)0xBF0C;
const byte EMV_ISS_PK_CERT_TAG = (byte)0x90; const uint8 EMV_ISS_PK_CERT_TAG = (uint8)0x90;
const byte EMV_PAN_TAG = (byte)0x5A; const uint8 EMV_PAN_TAG = (uint8)0x5A;
const byte EMV_FCI_TAG = (byte)0x6F; const uint8 EMV_FCI_TAG = (uint8)0x6F;
const byte EMV_DFNAME_TAG = (byte)0x84; const uint8 EMV_DFNAME_TAG = (uint8)0x84;
const byte EMV_FCI_ISSUER_TAG = (byte)0xA5; const uint8 EMV_FCI_ISSUER_TAG = (uint8)0xA5;
const byte EMV_DIRECTORY_ENTRY_TAG = (byte)0x61; const uint8 EMV_DIRECTORY_ENTRY_TAG = (uint8)0x61;
const byte EMV_SFI_TAG = (byte)0x88; const uint8 EMV_SFI_TAG = (uint8)0x88;
const byte EMV_TEMPLATE_TAG = (byte)0x70; const uint8 EMV_TEMPLATE_TAG = (uint8)0x70;
const byte EMV_AID_TAG = (byte)0x4F; const uint8 EMV_AID_TAG = (uint8)0x4F;
const byte EMV_LABEL_TAG = (byte)0x50; const uint8 EMV_LABEL_TAG = (uint8)0x50;
const byte EMV_PRIORITY_TAG = (byte)0x87; const uint8 EMV_PRIORITY_TAG = (uint8)0x87;
const byte EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact) const uint8 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_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 // Card Connection management methods
// ------------------------------------------------------------------------------------------------------------------------------------- // // ------------------------------------------------------------------------------------------------------------------------------------- //
bool IsCardPresent(vector<byte>& cardAtr); bool IsCardPresent(vector<uint8>& cardAtr);
bool IsCardPresent(); bool IsCardPresent();
LONG CardHandleStatus(); LONG CardHandleStatus();
@ -193,7 +193,7 @@ namespace VeraCrypt
void ApduProcessData(CommandAPDU commandAPDU, ResponseAPDU& responseAPDU) const; void ApduProcessData(CommandAPDU commandAPDU, ResponseAPDU& responseAPDU) const;
void GetATRFromHandle(vector<byte>& atrValue); void GetATRFromHandle(vector<uint8>& atrValue);
}; };
}; };

View File

@ -123,7 +123,7 @@ namespace VeraCrypt
Sessions.erase(Sessions.find(slotId)); 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()) if (name.empty())
throw ParameterIncorrect(SRC_POS); throw ParameterIncorrect(SRC_POS);
@ -167,10 +167,10 @@ namespace VeraCrypt
throw Pkcs11Exception(status); throw Pkcs11Exception(status);
// Some tokens report success even if the new object was truncated to fit in the available memory // 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); 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()) if (objectData.size() != keyfileData.size())
{ {
@ -227,13 +227,13 @@ namespace VeraCrypt
keyfile.Token->SlotId = slotId; keyfile.Token->SlotId = slotId;
keyfile.Token = shared_ptr<SecurityTokenInfo>(new SecurityTokenInfo(token)); keyfile.Token = shared_ptr<SecurityTokenInfo>(new SecurityTokenInfo(token));
vector <byte> privateAttrib; vector <uint8> privateAttrib;
GetObjectAttribute(slotId, dataHandle, CKA_PRIVATE, privateAttrib); GetObjectAttribute(slotId, dataHandle, CKA_PRIVATE, privateAttrib);
if (privateAttrib.size() == sizeof(CK_BBOOL) && *(CK_BBOOL*)&privateAttrib.front() != CK_TRUE) if (privateAttrib.size() == sizeof(CK_BBOOL) && *(CK_BBOOL*)&privateAttrib.front() != CK_TRUE)
continue; continue;
vector <byte> label; vector <uint8> label;
GetObjectAttribute(slotId, dataHandle, CKA_LABEL, label); GetObjectAttribute(slotId, dataHandle, CKA_LABEL, label);
label.push_back(0); label.push_back(0);
@ -320,7 +320,7 @@ namespace VeraCrypt
return token; return token;
} }
void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const
{ {
SecurityToken::LoginUserIfRequired(Token->SlotId); SecurityToken::LoginUserIfRequired(Token->SlotId);
SecurityToken::GetObjectAttribute(Token->SlotId, Handle, CKA_VALUE, keyfileData); SecurityToken::GetObjectAttribute(Token->SlotId, Handle, CKA_VALUE, keyfileData);
@ -361,7 +361,7 @@ namespace VeraCrypt
return objects; 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(); attributeValue.clear();
@ -379,7 +379,7 @@ namespace VeraCrypt
if (attribute.ulValueLen == 0) if (attribute.ulValueLen == 0)
return; return;
attributeValue = vector <byte>(attribute.ulValueLen); attributeValue = vector <uint8>(attribute.ulValueLen);
attribute.pValue = &attributeValue.front(); attribute.pValue = &attributeValue.front();
status = Pkcs11Functions->C_GetAttributeValue(Sessions[slotId].Handle, tokenObject, &attribute, 1); status = Pkcs11Functions->C_GetAttributeValue(Sessions[slotId].Handle, tokenObject, &attribute, 1);

View File

@ -76,7 +76,7 @@ namespace VeraCrypt
operator TokenKeyfilePath () const; operator TokenKeyfilePath () const;
void GetKeyfileData(vector<byte>& keyfileData) const; void GetKeyfileData(vector<uint8>& keyfileData) const;
string IdUtf8; string IdUtf8;
CK_OBJECT_HANDLE Handle; CK_OBJECT_HANDLE Handle;
@ -181,7 +181,7 @@ namespace VeraCrypt
public: public:
static void CloseAllSessions() throw (); static void CloseAllSessions() throw ();
static void CloseLibrary(); 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 void DeleteKeyfile(const SecurityTokenKeyfile& keyfile);
static vector <SecurityTokenKeyfile> GetAvailableKeyfiles(CK_SLOT_ID* slotIdFilter = nullptr, const wstring keyfileIdFilter = wstring()); static vector <SecurityTokenKeyfile> GetAvailableKeyfiles(CK_SLOT_ID* slotIdFilter = nullptr, const wstring keyfileIdFilter = wstring());
static list <SecurityTokenInfo> GetAvailableTokens(); static list <SecurityTokenInfo> GetAvailableTokens();
@ -199,7 +199,7 @@ namespace VeraCrypt
protected: protected:
static void CloseSession(CK_SLOT_ID slotId); static void CloseSession(CK_SLOT_ID slotId);
static vector <CK_OBJECT_HANDLE> GetObjects(CK_SLOT_ID slotId, CK_ATTRIBUTE_TYPE objectClass); 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 list <CK_SLOT_ID> GetTokenSlots();
static void Login(CK_SLOT_ID slotId, const char* pin); static void Login(CK_SLOT_ID slotId, const char* pin);
static void LoginUserIfRequired(CK_SLOT_ID slotId); static void LoginUserIfRequired(CK_SLOT_ID slotId);
@ -217,7 +217,7 @@ namespace VeraCrypt
static map <CK_SLOT_ID, Pkcs11Session> Sessions; static map <CK_SLOT_ID, Pkcs11Session> Sessions;
static unique_ptr <SendExceptionFunctor> WarningCallback; static unique_ptr <SendExceptionFunctor> WarningCallback;
friend void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const; friend void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const;
}; };
} }

View File

@ -13,7 +13,7 @@ namespace VeraCrypt
} }
/* Check if the bit is correct */ /* 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}; unsigned char bitvalue[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
@ -36,13 +36,13 @@ namespace VeraCrypt
} }
/* Parsing one TLV node */ /* 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 index = 0;
size_t i = 0; size_t i = 0;
byte tag1, tag2, tagsize; uint8 tag1, tag2, tagsize;
byte len, lensize; uint8 len, lensize;
shared_ptr<vector<byte>> value = make_shared<vector<byte>>(); shared_ptr<vector<uint8>> value = make_shared<vector<uint8>>();
shared_ptr<TLVNode> node = TLV_CreateNode(); shared_ptr<TLVNode> node = TLV_CreateNode();
tag1 = tag2 = 0; tag1 = tag2 = 0;
@ -157,7 +157,7 @@ namespace VeraCrypt
} }
/* Parsing TLV from a buffer and constructing TLV structure */ /* 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); shared_ptr<TLVNode> node = TLV_Parse_One(buf, size);
TLV_Parse_Sub(node); TLV_Parse_Sub(node);

View File

@ -10,16 +10,16 @@ namespace VeraCrypt
{ {
uint16 Tag; /* T */ uint16 Tag; /* T */
uint16 Length; /* L */ uint16 Length; /* L */
shared_ptr<vector<byte>> Value; /* V */ shared_ptr<vector<uint8>> Value; /* V */
byte TagSize; uint8 TagSize;
byte LengthSize; uint8 LengthSize;
uint16 MoreFlag; /* Used In Sub */ uint16 MoreFlag; /* Used In Sub */
uint16 SubFlag; /* Does it have sub-nodes? */ uint16 SubFlag; /* Does it have sub-nodes? */
shared_ptr<vector<shared_ptr<TLVNode>>> Subs; shared_ptr<vector<shared_ptr<TLVNode>>> Subs;
TLVNode() : Tag(0), Length(0), TagSize(0), LengthSize(0), MoreFlag(0), SubFlag(0) 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>>>(); Subs = make_shared<vector<shared_ptr<TLVNode>>>();
} }
@ -37,10 +37,10 @@ namespace VeraCrypt
static shared_ptr<TLVNode> TLV_CreateNode(); static shared_ptr<TLVNode> TLV_CreateNode();
/* Check if the bit is correct */ /* Check if the bit is correct */
static uint16 CheckBit(byte value, int bit); static uint16 CheckBit(uint8 value, int bit);
/* Parsing one TLV node */ /* 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 */ /* Parsing all TLV nodes */
static int TLV_Parse_SubNodes(shared_ptr<TLVNode> parent); static int TLV_Parse_SubNodes(shared_ptr<TLVNode> parent);
@ -54,7 +54,7 @@ namespace VeraCrypt
public: public:
/* Parsing TLV from a buffer and constructing TLV structure */ /* 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 */ /* Finding a TLV node with a particular tag */
static shared_ptr<TLVNode> TLV_Find(shared_ptr<TLVNode> node, uint16 tag); static shared_ptr<TLVNode> TLV_Find(shared_ptr<TLVNode> node, uint16 tag);

View File

@ -95,7 +95,6 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift);
typedef __int8 int8; typedef __int8 int8;
typedef __int16 int16; typedef __int16 int16;
typedef __int32 int32; typedef __int32 int32;
typedef unsigned __int8 byte;
typedef unsigned __int8 uint8; typedef unsigned __int8 uint8;
typedef unsigned __int16 uint16; typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32; typedef unsigned __int32 uint32;
@ -122,7 +121,6 @@ typedef int8_t int8;
typedef int16_t int16; typedef int16_t int16;
typedef int32_t int32; typedef int32_t int32;
typedef int64_t int64; typedef int64_t int64;
typedef uint8_t byte;
typedef uint8_t uint8; typedef uint8_t uint8;
typedef uint16_t uint16; typedef uint16_t uint16;
typedef uint32_t uint32; typedef uint32_t uint32;

View File

@ -1340,13 +1340,13 @@ static BOOL DoAutoTestAlgorithms (void)
// AES EncipherBlocks()/DecipherBlocks() // AES EncipherBlocks()/DecipherBlocks()
{ {
byte testData[1024]; uint8 testData[1024];
uint32 origCrc; uint32 origCrc;
size_t i; size_t i;
for (i = 0; i < sizeof (testData); ++i) for (i = 0; i < sizeof (testData); ++i)
{ {
testData[i] = (byte) i; testData[i] = (uint8) i;
} }
origCrc = GetCrc32 (testData, sizeof (testData)); origCrc = GetCrc32 (testData, sizeof (testData));

View File

@ -41,7 +41,7 @@ namespace VeraCrypt
{ {
virtual ~TokenKeyfile() {} virtual ~TokenKeyfile() {}
virtual operator TokenKeyfilePath () const = 0; 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; shared_ptr<TokenInfo> Token;
wstring Id; wstring Id;

View File

@ -130,19 +130,19 @@
uint16 GetHeaderField16 (byte *header, int offset) uint16 GetHeaderField16 (uint8 *header, int offset)
{ {
return BE16 (*(uint16 *) (header + offset)); return BE16 (*(uint16 *) (header + offset));
} }
uint32 GetHeaderField32 (byte *header, int offset) uint32 GetHeaderField32 (uint8 *header, int offset)
{ {
return BE32 (*(uint32 *) (header + offset)); return BE32 (*(uint32 *) (header + offset));
} }
UINT64_STRUCT GetHeaderField64 (byte *header, int offset) UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset)
{ {
UINT64_STRUCT uint64Struct; UINT64_STRUCT uint64Struct;
@ -640,7 +640,7 @@ KeyReady: ;
} }
#if defined(_WIN32) && !defined(_UEFI) #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 // compute Whirlpool+SHA512 fingerprint of bootloader including MBR
// we skip user configuration fields: // we skip user configuration fields:
@ -1214,13 +1214,13 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea,
} }
#if !defined(_UEFI) #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 #if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE #error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#endif #endif
byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DISK_GEOMETRY geometry; DISK_GEOMETRY geometry;
if (!device) 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 #if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE #error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#endif #endif
byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DWORD bytesDone; DWORD bytesDone;
DISK_GEOMETRY geometry; DISK_GEOMETRY geometry;
@ -1322,7 +1322,7 @@ int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO
char temporaryKey[MASTER_KEYDATA_SIZE]; char temporaryKey[MASTER_KEYDATA_SIZE];
char originalK2[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; LARGE_INTEGER offset;
int nStatus = ERR_SUCCESS; int nStatus = ERR_SUCCESS;

View File

@ -129,9 +129,9 @@ extern "C" {
extern BOOL ReadVolumeHeaderRecoveryMode; extern BOOL ReadVolumeHeaderRecoveryMode;
uint16 GetHeaderField16 (byte *header, int offset); uint16 GetHeaderField16 (uint8 *header, int offset);
uint32 GetHeaderField32 (byte *header, int offset); uint32 GetHeaderField32 (uint8 *header, int offset);
UINT64_STRUCT GetHeaderField64 (byte *header, int offset); UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset);
#if defined(TC_WINDOWS_BOOT) #if defined(TC_WINDOWS_BOOT)
int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo);
#elif defined(_UEFI) #elif defined(_UEFI)
@ -141,14 +141,14 @@ BOOL RandgetBytes(unsigned char *buf, int len, BOOL forceSlowPoll);
#else #else
int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo);
#if defined(_WIN32) && !defined(_UEFI) #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
#endif #endif
#if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) && !defined(_UEFI) #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); 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 ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header, DWORD *bytesRead);
BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header); BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header);
int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly); int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly);
#endif #endif

View File

@ -14,7 +14,7 @@
#include "Wipe.h" #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; 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. // 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 // 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) 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) 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. // 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 // 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; int wipePat3Pos;
size_t i; 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) switch (algorithm)
{ {

View File

@ -36,7 +36,7 @@ typedef enum
#define TC_WIPE_RAND_CHAR_COUNT 3 #define TC_WIPE_RAND_CHAR_COUNT 3
int GetWipePassCount (WipeAlgorithmId algorithm); 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 #ifdef __cplusplus
} }

View File

@ -144,7 +144,7 @@ namespace VeraCrypt
outerVolume->ReadSectors (bootSectorBuffer, 0); outerVolume->ReadSectors (bootSectorBuffer, 0);
int fatType; int fatType;
byte *bootSector = bootSectorBuffer.Ptr(); uint8 *bootSector = bootSectorBuffer.Ptr();
if (memcmp (bootSector + 54, "FAT12", 5) == 0) if (memcmp (bootSector + 54, "FAT12", 5) == 0)
fatType = 12; fatType = 12;

View File

@ -149,7 +149,7 @@ namespace VeraCrypt
} }
} }
static void PutBoot (fatparams * ft, byte *boot, uint32 volumeId) static void PutBoot (fatparams * ft, uint8 *boot, uint32 volumeId)
{ {
int cnt = 0; int cnt = 0;
@ -244,7 +244,7 @@ namespace VeraCrypt
/* FAT32 FSInfo */ /* FAT32 FSInfo */
static void PutFSInfo (byte *sector, fatparams *ft) static void PutFSInfo (uint8 *sector, fatparams *ft)
{ {
memset (sector, 0, ft->sector_size); memset (sector, 0, ft->sector_size);
sector[3] = 0x41; /* LeadSig */ sector[3] = 0x41; /* LeadSig */
@ -294,16 +294,16 @@ namespace VeraCrypt
sector.Zero(); sector.Zero();
uint32 volumeId; uint32 volumeId;
RandomNumberGenerator::GetDataFast (BufferPtr ((byte *) &volumeId, sizeof (volumeId))); RandomNumberGenerator::GetDataFast (BufferPtr ((uint8 *) &volumeId, sizeof (volumeId)));
PutBoot (ft, (byte *) sector, volumeId); PutBoot (ft, (uint8 *) sector, volumeId);
writeSector (sector); ++sectorNumber; writeSector (sector); ++sectorNumber;
/* fat32 boot area */ /* fat32 boot area */
if (ft->size_fat == 32) if (ft->size_fat == 32)
{ {
/* fsinfo */ /* fsinfo */
PutFSInfo((byte *) sector, ft); PutFSInfo((uint8 *) sector, ft);
writeSector (sector); ++sectorNumber; writeSector (sector); ++sectorNumber;
/* reserved */ /* reserved */
@ -317,10 +317,10 @@ namespace VeraCrypt
/* bootsector backup */ /* bootsector backup */
sector.Zero(); sector.Zero();
PutBoot (ft, (byte *) sector, volumeId); PutBoot (ft, (uint8 *) sector, volumeId);
writeSector (sector); ++sectorNumber; writeSector (sector); ++sectorNumber;
PutFSInfo((byte *) sector, ft); PutFSInfo((uint8 *) sector, ft);
writeSector (sector); ++sectorNumber; writeSector (sector); ++sectorNumber;
} }
@ -340,10 +340,10 @@ namespace VeraCrypt
if (n == 0) if (n == 0)
{ {
byte fat_sig[12]; uint8 fat_sig[12];
if (ft->size_fat == 32) if (ft->size_fat == 32)
{ {
fat_sig[0] = (byte) ft->media; fat_sig[0] = (uint8) ft->media;
fat_sig[1] = fat_sig[2] = 0xff; fat_sig[1] = fat_sig[2] = 0xff;
fat_sig[3] = 0x0f; fat_sig[3] = 0x0f;
fat_sig[4] = fat_sig[5] = fat_sig[6] = 0xff; fat_sig[4] = fat_sig[5] = fat_sig[6] = 0xff;
@ -354,7 +354,7 @@ namespace VeraCrypt
} }
else if (ft->size_fat == 16) else if (ft->size_fat == 16)
{ {
fat_sig[0] = (byte) ft->media; fat_sig[0] = (uint8) ft->media;
fat_sig[1] = 0xff; fat_sig[1] = 0xff;
fat_sig[2] = 0xff; fat_sig[2] = 0xff;
fat_sig[3] = 0xff; fat_sig[3] = 0xff;
@ -362,7 +362,7 @@ namespace VeraCrypt
} }
else if (ft->size_fat == 12) else if (ft->size_fat == 12)
{ {
fat_sig[0] = (byte) ft->media; fat_sig[0] = (uint8) ft->media;
fat_sig[1] = 0xff; fat_sig[1] = 0xff;
fat_sig[2] = 0xff; fat_sig[2] = 0xff;
fat_sig[3] = 0x00; fat_sig[3] = 0x00;

View File

@ -114,7 +114,7 @@ namespace VeraCrypt
ScopeLock lock (AccessMutex); ScopeLock lock (AccessMutex);
size_t bufferLen = buffer.Size(), loopLen; size_t bufferLen = buffer.Size(), loopLen;
byte* pbBuffer = buffer.Get(); uint8* pbBuffer = buffer.Get();
// Initialize JitterEntropy RNG for this call // Initialize JitterEntropy RNG for this call
if (0 == jent_entropy_init ()) if (0 == jent_entropy_init ())
@ -267,7 +267,7 @@ namespace VeraCrypt
Buffer buffer (1); Buffer buffer (1);
for (size_t i = 0; i < PoolSize * 10; ++i) for (size_t i = 0; i < PoolSize * 10; ++i)
{ {
buffer[0] = (byte) i; buffer[0] = (uint8) i;
AddToPool (buffer); AddToPool (buffer);
} }

View File

@ -57,7 +57,7 @@ namespace VeraCrypt
// Wait for sync code // Wait for sync code
while (true) while (true)
{ {
byte b; uint8 b;
throw_sys_if (read (STDIN_FILENO, &b, 1) != 1); throw_sys_if (read (STDIN_FILENO, &b, 1) != 1);
if (b != 0x00) if (b != 0x00)
continue; continue;
@ -543,7 +543,7 @@ namespace VeraCrypt
try try
{ {
shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((byte *) &errOutput[0], errOutput.size()))); shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((uint8 *) &errOutput[0], errOutput.size())));
deserializedObject.reset (Serializable::DeserializeNew (stream)); deserializedObject.reset (Serializable::DeserializeNew (stream));
deserializedException = dynamic_cast <Exception*> (deserializedObject.get()); deserializedException = dynamic_cast <Exception*> (deserializedObject.get());
} }
@ -575,7 +575,7 @@ namespace VeraCrypt
ServiceOutputStream = shared_ptr <Stream> (new FileStream (outPipe->GetReadFD())); ServiceOutputStream = shared_ptr <Stream> (new FileStream (outPipe->GetReadFD()));
// Send sync code // Send sync code
byte sync[] = { 0, 0x11, 0x22 }; uint8 sync[] = { 0, 0x11, 0x22 };
ServiceInputStream->Write (ConstBufferPtr (sync, array_capacity (sync))); ServiceInputStream->Write (ConstBufferPtr (sync, array_capacity (sync)));
AdminInputPipe = move_ptr(inPipe); AdminInputPipe = move_ptr(inPipe);

View File

@ -241,7 +241,7 @@ namespace VeraCrypt
device.SeekAt (0); device.SeekAt (0);
device.ReadCompleteBuffer (bootSector); device.ReadCompleteBuffer (bootSector);
byte *b = bootSector.Ptr(); uint8 *b = bootSector.Ptr();
return memcmp (b + 3, "NTFS", 4) != 0 return memcmp (b + 3, "NTFS", 4) != 0
&& memcmp (b + 54, "FAT", 3) != 0 && memcmp (b + 54, "FAT", 3) != 0

View File

@ -386,7 +386,7 @@ namespace VeraCrypt
dmCreateArgs << nativeDevPath << " 0"; dmCreateArgs << nativeDevPath << " 0";
SecureBuffer dmCreateArgsBuf (dmCreateArgs.str().size()); SecureBuffer dmCreateArgsBuf (dmCreateArgs.str().size());
dmCreateArgsBuf.CopyFrom (ConstBufferPtr ((byte *) dmCreateArgs.str().c_str(), dmCreateArgs.str().size())); dmCreateArgsBuf.CopyFrom (ConstBufferPtr ((uint8 *) dmCreateArgs.str().c_str(), dmCreateArgs.str().size()));
// Keys // Keys
const SecureBuffer &cipherKey = cipher.GetKey(); const SecureBuffer &cipherKey = cipher.GetKey();

View File

@ -21,13 +21,13 @@ extern "C"
#endif #endif
#if defined (TC_WINDOWS_BOOT) #if defined (TC_WINDOWS_BOOT)
byte is_aes_hw_cpu_supported (); uint8 is_aes_hw_cpu_supported ();
#endif #endif
void aes_hw_cpu_enable_sse (); void aes_hw_cpu_enable_sse ();
void aes_hw_cpu_decrypt (const byte *ks, byte *data); void aes_hw_cpu_decrypt (const uint8 *ks, uint8 *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);
void aes_hw_cpu_encrypt (const byte *ks, byte *data); void aes_hw_cpu_encrypt (const uint8 *ks, uint8 *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);
#if defined(__cplusplus) #if defined(__cplusplus)
} }

View File

@ -11,10 +11,10 @@
* NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved. * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
* *
* SuperCop integration: * SuperCop integration:
* Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> * Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi>
* *
* VeraCrypt integration: * VeraCrypt integration:
* Copyright © 2017 Mounir IDRASSI <mounir.idrassi@idrix.fr> * Copyright © 2017 Mounir IDRASSI <mounir.idrassi@idrix.fr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -51,12 +51,12 @@
extern int IsAesHwCpuSupported (); extern int IsAesHwCpuSupported ();
#endif #endif
void camellia_encrypt_asm(const byte *ctx, void *dst, const void *src); void camellia_encrypt_asm(const uint8 *ctx, void *dst, const void *src);
void camellia_decrypt_asm(const byte *ctx, void *dst, const void *src); void camellia_decrypt_asm(const uint8 *ctx, void *dst, const void *src);
void camellia_enc_blk2(const byte *ctx, byte *dst, const byte *src); void camellia_enc_blk2(const uint8 *ctx, uint8 *dst, const uint8 *src);
void camellia_dec_blk2(const byte *ctx, byte *dst, const byte *src); void camellia_dec_blk2(const uint8 *ctx, uint8 *dst, const uint8 *src);
void camellia_ecb_enc_16way(const byte *ctx, byte *dst, const byte *src); void camellia_ecb_enc_16way(const uint8 *ctx, uint8 *dst, const uint8 *src);
void camellia_ecb_dec_16way(const byte *ctx, byte *dst, const byte *src); void camellia_ecb_dec_16way(const uint8 *ctx, uint8 *dst, const uint8 *src);
/* key constants */ /* key constants */
@ -1093,7 +1093,7 @@ void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock
camellia_decrypt_asm (ks, outBlock, inBlock); camellia_decrypt_asm (ks, outBlock, inBlock);
} }
void camellia_encrypt_blocks(unsigned __int8 *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) void camellia_encrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount)
{ {
#if !defined (_UEFI) #if !defined (_UEFI)
if ((blockCount >= 16) && IsCpuIntel() && IsAesHwCpuSupported () && HasSAVX()) /* on AMD cpu, AVX is too slow */ if ((blockCount >= 16) && IsCpuIntel() && IsAesHwCpuSupported () && HasSAVX()) /* on AMD cpu, AVX is too slow */
@ -1129,7 +1129,7 @@ void camellia_encrypt_blocks(unsigned __int8 *instance, const byte* in_blk, byte
camellia_encrypt (in_blk, out_blk, instance); camellia_encrypt (in_blk, out_blk, instance);
} }
void camellia_decrypt_blocks(unsigned __int8 *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) void camellia_decrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount)
{ {
#if !defined (_UEFI) #if !defined (_UEFI)
if ((blockCount >= 16) && IsCpuIntel() && IsAesHwCpuSupported () && HasSAVX()) /* on AMD cpu, AVX is too slow */ if ((blockCount >= 16) && IsCpuIntel() && IsAesHwCpuSupported () && HasSAVX()) /* on AMD cpu, AVX is too slow */

View File

@ -18,8 +18,8 @@ void camellia_encrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock,
void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks); void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks);
#if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
void camellia_encrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount); void camellia_encrypt_blocks(unsigned __int8 *ks, const uint8* in_blk, uint8* out_blk, uint32 blockCount);
void camellia_decrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount); void camellia_decrypt_blocks(unsigned __int8 *ks, const uint8* in_blk, uint8* out_blk, uint32 blockCount);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -447,7 +447,7 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(uint_32t *state, const uint_
#if defined(__GNUC__) #if defined(__GNUC__)
#if CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64
CRYPTOPP_ALIGN_DATA(16) byte workspace[LOCALS_SIZE] ; CRYPTOPP_ALIGN_DATA(16) uint8 workspace[LOCALS_SIZE] ;
#endif #endif
__asm__ __volatile__ __asm__ __volatile__
( (

View File

@ -20,7 +20,7 @@
#pragma optimize ("tl", on) #pragma optimize ("tl", on)
typedef unsigned __int32 uint32; typedef unsigned __int32 uint32;
typedef unsigned __int8 byte; typedef unsigned __int8 uint8;
#include <stdlib.h> #include <stdlib.h>
#pragma intrinsic(_lrotr) #pragma intrinsic(_lrotr)

View File

@ -2253,7 +2253,7 @@ stage3(STREEBOG_CTX *CTX)
memcpy((CTX->hash), (CTX->h), 8 * sizeof(unsigned long long)); memcpy((CTX->hash), (CTX->h), 8 * sizeof(unsigned long long));
} }
void STREEBOG_add(STREEBOG_CTX *CTX, const byte *data, size_t len) void STREEBOG_add(STREEBOG_CTX *CTX, const uint8 *data, size_t len)
{ {
size_t chunksize; size_t chunksize;
@ -2286,7 +2286,7 @@ void STREEBOG_add(STREEBOG_CTX *CTX, const byte *data, size_t len)
} }
} }
void STREEBOG_finalize(STREEBOG_CTX *CTX, byte *digest) void STREEBOG_finalize(STREEBOG_CTX *CTX, uint8 *digest)
{ {
stage3(CTX); stage3(CTX);

View File

@ -31,8 +31,8 @@ typedef STREEBOG_ALIGN(16) struct _STREEBOG_CTX
void STREEBOG_init(STREEBOG_CTX *ctx); void STREEBOG_init(STREEBOG_CTX *ctx);
void STREEBOG_init256(STREEBOG_CTX *ctx); void STREEBOG_init256(STREEBOG_CTX *ctx);
void STREEBOG_add(STREEBOG_CTX *ctx, const byte *msg, size_t len); void STREEBOG_add(STREEBOG_CTX *ctx, const uint8 *msg, size_t len);
void STREEBOG_finalize(STREEBOG_CTX *ctx, byte *out); void STREEBOG_finalize(STREEBOG_CTX *ctx, uint8 *out);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -57,25 +57,25 @@
#if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
/* these are 64-bit assembly implementation taken from https://github.com/jkivilin/supercop-blockciphers /* these are 64-bit assembly implementation taken from https://github.com/jkivilin/supercop-blockciphers
Copyright © 2011-2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> Copyright © 2011-2013 Jussi Kivilinna <jussi.kivilinna@iki.fi>
*/ */
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" extern "C"
{ {
#endif #endif
void twofish_enc_blk(TwofishInstance *ks, byte *dst, const byte *src); void twofish_enc_blk(TwofishInstance *ks, uint8 *dst, const uint8 *src);
void twofish_dec_blk(TwofishInstance *ks, byte *dst, const byte *src); void twofish_dec_blk(TwofishInstance *ks, uint8 *dst, const uint8 *src);
void twofish_enc_blk2(TwofishInstance *ks, byte *dst, const byte *src); void twofish_enc_blk2(TwofishInstance *ks, uint8 *dst, const uint8 *src);
void twofish_dec_blk2(TwofishInstance *ks, byte *dst, const byte *src); void twofish_dec_blk2(TwofishInstance *ks, uint8 *dst, const uint8 *src);
void twofish_enc_blk3(TwofishInstance *ks, byte *dst, const byte *src); void twofish_enc_blk3(TwofishInstance *ks, uint8 *dst, const uint8 *src);
void twofish_dec_blk3(TwofishInstance *ks, byte *dst, const byte *src); void twofish_dec_blk3(TwofishInstance *ks, uint8 *dst, const uint8 *src);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) void twofish_encrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount)
{ {
while (blockCount >= 3) while (blockCount >= 3)
{ {
@ -96,7 +96,7 @@ void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte*
} }
void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) void twofish_decrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount)
{ {
while (blockCount >= 3) while (blockCount >= 3)
{ {
@ -120,7 +120,7 @@ void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte*
#endif #endif
static const byte Q[2][256] = { static const uint8 Q[2][256] = {
{ {
0xa9, 0x67, 0xb3, 0xe8, 0x04, 0xfd, 0xa3, 0x76, 0x9a, 0x92, 0x80, 0x78, 0xe4, 0xdd, 0xd1, 0x38, 0xa9, 0x67, 0xb3, 0xe8, 0x04, 0xfd, 0xa3, 0x76, 0x9a, 0x92, 0x80, 0x78, 0xe4, 0xdd, 0xd1, 0x38,
0x0d, 0xc6, 0x35, 0x98, 0x18, 0xf7, 0xec, 0x6c, 0x43, 0x75, 0x37, 0x26, 0xfa, 0x13, 0x94, 0x48, 0x0d, 0xc6, 0x35, 0x98, 0x18, 0xf7, 0xec, 0x6c, 0x43, 0x75, 0x37, 0x26, 0xfa, 0x13, 0x94, 0x48,
@ -604,11 +604,11 @@ static const uint32 RS[8][256] = {
void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]) void twofish_set_key(TwofishInstance *instance, const u4byte in_key[])
{ {
union { union {
byte S8[16]; uint8 S8[16];
uint32 S32[4]; uint32 S32[4];
} us; } us;
unsigned int i; unsigned int i;
const byte* key = (const byte*) in_key; const uint8* key = (const uint8*) in_key;
us.S32[0] = RS[0][key[0]] ^ RS[1][key[1]] ^ RS[2][key[2]] ^ RS[3][key[3]] ^ RS[4][key[4]] ^ RS[5][key[5]] ^ RS[6][key[6]] ^ RS[7][key[7]]; us.S32[0] = RS[0][key[0]] ^ RS[1][key[1]] ^ RS[2][key[2]] ^ RS[3][key[3]] ^ RS[4][key[4]] ^ RS[5][key[5]] ^ RS[6][key[6]] ^ RS[7][key[7]];
us.S32[1] = RS[0][key[8]] ^ RS[1][key[9]] ^ RS[2][key[10]] ^ RS[3][key[11]] ^ RS[4][key[12]] ^ RS[5][key[13]] ^ RS[6][key[14]] ^ RS[7][key[15]]; us.S32[1] = RS[0][key[8]] ^ RS[1][key[9]] ^ RS[2][key[10]] ^ RS[3][key[11]] ^ RS[4][key[12]] ^ RS[5][key[13]] ^ RS[6][key[14]] ^ RS[7][key[15]];

View File

@ -55,10 +55,10 @@ typedef struct
/* in_key must be 32-bytes long */ /* in_key must be 32-bytes long */
void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]); void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]);
#if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount); void twofish_encrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount);
void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount); void twofish_decrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount);
#define twofish_encrypt(instance,in_blk,out_blk) twofish_encrypt_blocks(instance, (const byte*) in_blk, (byte*) out_blk, 1) #define twofish_encrypt(instance,in_blk,out_blk) twofish_encrypt_blocks(instance, (const uint8*) in_blk, (uint8*) out_blk, 1)
#define twofish_decrypt(instance,in_blk,out_blk) twofish_decrypt_blocks(instance, (const byte*) in_blk, (byte*) out_blk, 1) #define twofish_decrypt(instance,in_blk,out_blk) twofish_decrypt_blocks(instance, (const uint8*) in_blk, (uint8*) out_blk, 1)
#else #else
void twofish_encrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte out_blk[4]); void twofish_encrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte out_blk[4]);
void twofish_decrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte out_blk[4]); void twofish_decrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte out_blk[4]);

View File

@ -936,7 +936,7 @@ void WHIRLPOOL_add(const unsigned char * input,
else else
{ {
uint64* dataBuf = ctx->data; uint64* dataBuf = ctx->data;
byte* data = (byte *)dataBuf; uint8* data = (uint8 *)dataBuf;
num = oldCountLo & 63; num = oldCountLo & 63;
if (num != 0) // process left over data if (num != 0) // process left over data
@ -996,7 +996,7 @@ void WHIRLPOOL_finalize(WHIRLPOOL_CTX * const ctx,
unsigned int num = ctx->countLo & 63; unsigned int num = ctx->countLo & 63;
uint64* dataBuf = ctx->data; uint64* dataBuf = ctx->data;
uint64* stateBuf = ctx->state; uint64* stateBuf = ctx->state;
byte* data = (byte *)dataBuf; uint8* data = (uint8 *)dataBuf;
data[num++] = 0x80; data[num++] = 0x80;
if (num <= 32) if (num <= 32)

View File

@ -43,7 +43,6 @@ __inline __m128i _mm_set1_epi64x(int64 a)
#endif #endif
#endif #endif
#define uint8 byte
#define U32V(v) (v) #define U32V(v) (v)
#define ROTL32(x,n) rotl32(x, n) #define ROTL32(x,n) rotl32(x, n)

View File

@ -209,8 +209,8 @@
#define GETBYTE(x, y) (unsigned int)((unsigned char)((x)>>(8*(y)))) #define GETBYTE(x, y) (unsigned int)((unsigned char)((x)>>(8*(y))))
// these may be faster on other CPUs/compilers // these may be faster on other CPUs/compilers
// #define GETBYTE(x, y) (unsigned int)(((x)>>(8*(y)))&255) // #define GETBYTE(x, y) (unsigned int)(((x)>>(8*(y)))&255)
// #define GETBYTE(x, y) (((byte *)&(x))[y]) // #define GETBYTE(x, y) (((uint8 *)&(x))[y])
#define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) ((byte)((x)>>(8*(y)))) #define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) ((uint8)((x)>>(8*(y))))
#endif #endif

View File

@ -12,16 +12,16 @@ and released into public domain.
#endif #endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
void kuznyechik_set_key_simd(const byte* key, kuznyechik_kds *kds); void kuznyechik_set_key_simd(const uint8* key, kuznyechik_kds *kds);
void kuznyechik_encrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds); void kuznyechik_encrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds);
void kuznyechik_encrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); void kuznyechik_encrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds);
void kuznyechik_decrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds); void kuznyechik_decrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds);
void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); void kuznyechik_decrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds);
#endif #endif
//#define CPPCRYPTO_DEBUG //#define CPPCRYPTO_DEBUG
static const byte S[256] = { static const uint8 S[256] = {
252, 238, 221, 17, 207, 110, 49, 22, 251, 196, 250, 218, 35, 197, 4, 77, 233, 119, 240, 219, 147, 46, 153, 186, 23, 54, 241, 187, 20, 205, 95, 193, 252, 238, 221, 17, 207, 110, 49, 22, 251, 196, 250, 218, 35, 197, 4, 77, 233, 119, 240, 219, 147, 46, 153, 186, 23, 54, 241, 187, 20, 205, 95, 193,
249, 24, 101, 90, 226, 92, 239, 33, 129, 28, 60, 66, 139, 1, 142, 79, 5, 132, 2, 174, 227, 106, 143, 160, 6, 11, 237, 152, 127, 212, 211, 31, 249, 24, 101, 90, 226, 92, 239, 33, 129, 28, 60, 66, 139, 1, 142, 79, 5, 132, 2, 174, 227, 106, 143, 160, 6, 11, 237, 152, 127, 212, 211, 31,
235, 52, 44, 81, 234, 200, 72, 171, 242, 42, 104, 162, 253, 58, 206, 204, 181, 112, 14, 86, 8, 12, 118, 18, 191, 114, 19, 71, 156, 183, 93, 135, 235, 52, 44, 81, 234, 200, 72, 171, 242, 42, 104, 162, 253, 58, 206, 204, 181, 112, 14, 86, 8, 12, 118, 18, 191, 114, 19, 71, 156, 183, 93, 135,
@ -32,7 +32,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
32, 113, 103, 164, 45, 43, 9, 91, 203, 155, 37, 208, 190, 229, 108, 82, 89, 166, 116, 210, 230, 244, 180, 192, 209, 102, 175, 194, 57, 75, 99, 182 32, 113, 103, 164, 45, 43, 9, 91, 203, 155, 37, 208, 190, 229, 108, 82, 89, 166, 116, 210, 230, 244, 180, 192, 209, 102, 175, 194, 57, 75, 99, 182
}; };
static const byte IS[256] = { static const uint8 IS[256] = {
165, 45, 50, 143, 14, 48, 56, 192, 84, 230, 158, 57, 85, 126, 82, 145, 100, 3, 87, 90, 28, 96, 7, 24, 33, 114, 168, 209, 41, 198, 164, 63, 165, 45, 50, 143, 14, 48, 56, 192, 84, 230, 158, 57, 85, 126, 82, 145, 100, 3, 87, 90, 28, 96, 7, 24, 33, 114, 168, 209, 41, 198, 164, 63,
224, 39, 141, 12, 130, 234, 174, 180, 154, 99, 73, 229, 66, 228, 21, 183, 200, 6, 112, 157, 65, 117, 25, 201, 170, 252, 77, 191, 42, 115, 132, 213, 224, 39, 141, 12, 130, 234, 174, 180, 154, 99, 73, 229, 66, 228, 21, 183, 200, 6, 112, 157, 65, 117, 25, 201, 170, 252, 77, 191, 42, 115, 132, 213,
195, 175, 43, 134, 167, 177, 178, 91, 70, 211, 159, 253, 212, 15, 156, 47, 155, 67, 239, 217, 121, 182, 83, 127, 193, 240, 35, 231, 37, 94, 181, 30, 195, 175, 43, 134, 167, 177, 178, 91, 70, 211, 159, 253, 212, 15, 156, 47, 155, 67, 239, 217, 121, 182, 83, 127, 193, 240, 35, 231, 37, 94, 181, 30,
@ -2144,30 +2144,30 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
}; };
#define LS(x1,x2,t1,t2) { \ #define LS(x1,x2,t1,t2) { \
t1 = T[0][(byte)(x1)][0] ^ T[1][(byte)(x1 >> 8)][0] ^ T[2][(byte)(x1 >> 16)][0] ^ T[3][(byte)(x1 >> 24)][0] ^ T[4][(byte)(x1 >> 32)][0] ^ T[5][(byte)(x1 >> 40)][0] ^ \ t1 = T[0][(uint8)(x1)][0] ^ T[1][(uint8)(x1 >> 8)][0] ^ T[2][(uint8)(x1 >> 16)][0] ^ T[3][(uint8)(x1 >> 24)][0] ^ T[4][(uint8)(x1 >> 32)][0] ^ T[5][(uint8)(x1 >> 40)][0] ^ \
T[6][(byte)(x1 >> 48)][0] ^ T[7][(byte)(x1 >> 56)][0] ^ T[8][(byte)(x2)][0] ^ T[9][(byte)(x2 >> 8)][0] ^ T[10][(byte)(x2 >> 16)][0] ^ T[11][(byte)(x2 >> 24)][0] ^ \ T[6][(uint8)(x1 >> 48)][0] ^ T[7][(uint8)(x1 >> 56)][0] ^ T[8][(uint8)(x2)][0] ^ T[9][(uint8)(x2 >> 8)][0] ^ T[10][(uint8)(x2 >> 16)][0] ^ T[11][(uint8)(x2 >> 24)][0] ^ \
T[12][(byte)(x2 >> 32)][0] ^ T[13][(byte)(x2 >> 40)][0] ^ T[14][(byte)(x2 >> 48)][0] ^ T[15][(byte)(x2 >> 56)][0]; \ T[12][(uint8)(x2 >> 32)][0] ^ T[13][(uint8)(x2 >> 40)][0] ^ T[14][(uint8)(x2 >> 48)][0] ^ T[15][(uint8)(x2 >> 56)][0]; \
t2 = T[0][(byte)(x1)][1] ^ T[1][(byte)(x1 >> 8)][1] ^ T[2][(byte)(x1 >> 16)][1] ^ T[3][(byte)(x1 >> 24)][1] ^ T[4][(byte)(x1 >> 32)][1] ^ T[5][(byte)(x1 >> 40)][1] ^ \ t2 = T[0][(uint8)(x1)][1] ^ T[1][(uint8)(x1 >> 8)][1] ^ T[2][(uint8)(x1 >> 16)][1] ^ T[3][(uint8)(x1 >> 24)][1] ^ T[4][(uint8)(x1 >> 32)][1] ^ T[5][(uint8)(x1 >> 40)][1] ^ \
T[6][(byte)(x1 >> 48)][1] ^ T[7][(byte)(x1 >> 56)][1] ^ T[8][(byte)(x2)][1] ^ T[9][(byte)(x2 >> 8)][1] ^ T[10][(byte)(x2 >> 16)][1] ^ T[11][(byte)(x2 >> 24)][1] ^ \ T[6][(uint8)(x1 >> 48)][1] ^ T[7][(uint8)(x1 >> 56)][1] ^ T[8][(uint8)(x2)][1] ^ T[9][(uint8)(x2 >> 8)][1] ^ T[10][(uint8)(x2 >> 16)][1] ^ T[11][(uint8)(x2 >> 24)][1] ^ \
T[12][(byte)(x2 >> 32)][1] ^ T[13][(byte)(x2 >> 40)][1] ^ T[14][(byte)(x2 >> 48)][1] ^ T[15][(byte)(x2 >> 56)][1]; \ T[12][(uint8)(x2 >> 32)][1] ^ T[13][(uint8)(x2 >> 40)][1] ^ T[14][(uint8)(x2 >> 48)][1] ^ T[15][(uint8)(x2 >> 56)][1]; \
} }
#define ILS(x1,x2,t1,t2) { \ #define ILS(x1,x2,t1,t2) { \
t1 = IT[0][(byte)(x1)][0] ^ IT[1][(byte)(x1 >> 8)][0] ^ IT[2][(byte)(x1 >> 16)][0] ^ IT[3][(byte)(x1 >> 24)][0] ^ IT[4][(byte)(x1 >> 32)][0] ^ IT[5][(byte)(x1 >> 40)][0] ^ \ t1 = IT[0][(uint8)(x1)][0] ^ IT[1][(uint8)(x1 >> 8)][0] ^ IT[2][(uint8)(x1 >> 16)][0] ^ IT[3][(uint8)(x1 >> 24)][0] ^ IT[4][(uint8)(x1 >> 32)][0] ^ IT[5][(uint8)(x1 >> 40)][0] ^ \
IT[6][(byte)(x1 >> 48)][0] ^ IT[7][(byte)(x1 >> 56)][0] ^ IT[8][(byte)(x2)][0] ^ IT[9][(byte)(x2 >> 8)][0] ^ IT[10][(byte)(x2 >> 16)][0] ^ IT[11][(byte)(x2 >> 24)][0] ^ \ IT[6][(uint8)(x1 >> 48)][0] ^ IT[7][(uint8)(x1 >> 56)][0] ^ IT[8][(uint8)(x2)][0] ^ IT[9][(uint8)(x2 >> 8)][0] ^ IT[10][(uint8)(x2 >> 16)][0] ^ IT[11][(uint8)(x2 >> 24)][0] ^ \
IT[12][(byte)(x2 >> 32)][0] ^ IT[13][(byte)(x2 >> 40)][0] ^ IT[14][(byte)(x2 >> 48)][0] ^ IT[15][(byte)(x2 >> 56)][0]; \ IT[12][(uint8)(x2 >> 32)][0] ^ IT[13][(uint8)(x2 >> 40)][0] ^ IT[14][(uint8)(x2 >> 48)][0] ^ IT[15][(uint8)(x2 >> 56)][0]; \
t2 = IT[0][(byte)(x1)][1] ^ IT[1][(byte)(x1 >> 8)][1] ^ IT[2][(byte)(x1 >> 16)][1] ^ IT[3][(byte)(x1 >> 24)][1] ^ IT[4][(byte)(x1 >> 32)][1] ^ IT[5][(byte)(x1 >> 40)][1] ^ \ t2 = IT[0][(uint8)(x1)][1] ^ IT[1][(uint8)(x1 >> 8)][1] ^ IT[2][(uint8)(x1 >> 16)][1] ^ IT[3][(uint8)(x1 >> 24)][1] ^ IT[4][(uint8)(x1 >> 32)][1] ^ IT[5][(uint8)(x1 >> 40)][1] ^ \
IT[6][(byte)(x1 >> 48)][1] ^ IT[7][(byte)(x1 >> 56)][1] ^ IT[8][(byte)(x2)][1] ^ IT[9][(byte)(x2 >> 8)][1] ^ IT[10][(byte)(x2 >> 16)][1] ^ IT[11][(byte)(x2 >> 24)][1] ^ \ IT[6][(uint8)(x1 >> 48)][1] ^ IT[7][(uint8)(x1 >> 56)][1] ^ IT[8][(uint8)(x2)][1] ^ IT[9][(uint8)(x2 >> 8)][1] ^ IT[10][(uint8)(x2 >> 16)][1] ^ IT[11][(uint8)(x2 >> 24)][1] ^ \
IT[12][(byte)(x2 >> 32)][1] ^ IT[13][(byte)(x2 >> 40)][1] ^ IT[14][(byte)(x2 >> 48)][1] ^ IT[15][(byte)(x2 >> 56)][1]; \ IT[12][(uint8)(x2 >> 32)][1] ^ IT[13][(uint8)(x2 >> 40)][1] ^ IT[14][(uint8)(x2 >> 48)][1] ^ IT[15][(uint8)(x2 >> 56)][1]; \
} }
#define ILSS(x1,x2,t1,t2) { \ #define ILSS(x1,x2,t1,t2) { \
t1 = IT[0][S[(byte)(x1)]][0] ^ IT[1][S[(byte)(x1 >> 8)]][0] ^ IT[2][S[(byte)(x1 >> 16)]][0] ^ IT[3][S[(byte)(x1 >> 24)]][0] ^ IT[4][S[(byte)(x1 >> 32)]][0] ^ IT[5][S[(byte)(x1 >> 40)]][0] ^ \ t1 = IT[0][S[(uint8)(x1)]][0] ^ IT[1][S[(uint8)(x1 >> 8)]][0] ^ IT[2][S[(uint8)(x1 >> 16)]][0] ^ IT[3][S[(uint8)(x1 >> 24)]][0] ^ IT[4][S[(uint8)(x1 >> 32)]][0] ^ IT[5][S[(uint8)(x1 >> 40)]][0] ^ \
IT[6][S[(byte)(x1 >> 48)]][0] ^ IT[7][S[(byte)(x1 >> 56)]][0] ^ IT[8][S[(byte)(x2)]][0] ^ IT[9][S[(byte)(x2 >> 8)]][0] ^ IT[10][S[(byte)(x2 >> 16)]][0] ^ IT[11][S[(byte)(x2 >> 24)]][0] ^ \ IT[6][S[(uint8)(x1 >> 48)]][0] ^ IT[7][S[(uint8)(x1 >> 56)]][0] ^ IT[8][S[(uint8)(x2)]][0] ^ IT[9][S[(uint8)(x2 >> 8)]][0] ^ IT[10][S[(uint8)(x2 >> 16)]][0] ^ IT[11][S[(uint8)(x2 >> 24)]][0] ^ \
IT[12][S[(byte)(x2 >> 32)]][0] ^ IT[13][S[(byte)(x2 >> 40)]][0] ^ IT[14][S[(byte)(x2 >> 48)]][0] ^ IT[15][S[(byte)(x2 >> 56)]][0]; \ IT[12][S[(uint8)(x2 >> 32)]][0] ^ IT[13][S[(uint8)(x2 >> 40)]][0] ^ IT[14][S[(uint8)(x2 >> 48)]][0] ^ IT[15][S[(uint8)(x2 >> 56)]][0]; \
t2 = IT[0][S[(byte)(x1)]][1] ^ IT[1][S[(byte)(x1 >> 8)]][1] ^ IT[2][S[(byte)(x1 >> 16)]][1] ^ IT[3][S[(byte)(x1 >> 24)]][1] ^ IT[4][S[(byte)(x1 >> 32)]][1] ^ IT[5][S[(byte)(x1 >> 40)]][1] ^ \ t2 = IT[0][S[(uint8)(x1)]][1] ^ IT[1][S[(uint8)(x1 >> 8)]][1] ^ IT[2][S[(uint8)(x1 >> 16)]][1] ^ IT[3][S[(uint8)(x1 >> 24)]][1] ^ IT[4][S[(uint8)(x1 >> 32)]][1] ^ IT[5][S[(uint8)(x1 >> 40)]][1] ^ \
IT[6][S[(byte)(x1 >> 48)]][1] ^ IT[7][S[(byte)(x1 >> 56)]][1] ^ IT[8][S[(byte)(x2)]][1] ^ IT[9][S[(byte)(x2 >> 8)]][1] ^ IT[10][S[(byte)(x2 >> 16)]][1] ^ IT[11][S[(byte)(x2 >> 24)]][1] ^ \ IT[6][S[(uint8)(x1 >> 48)]][1] ^ IT[7][S[(uint8)(x1 >> 56)]][1] ^ IT[8][S[(uint8)(x2)]][1] ^ IT[9][S[(uint8)(x2 >> 8)]][1] ^ IT[10][S[(uint8)(x2 >> 16)]][1] ^ IT[11][S[(uint8)(x2 >> 24)]][1] ^ \
IT[12][S[(byte)(x2 >> 32)]][1] ^ IT[13][S[(byte)(x2 >> 40)]][1] ^ IT[14][S[(byte)(x2 >> 48)]][1] ^ IT[15][S[(byte)(x2 >> 56)]][1]; \ IT[12][S[(uint8)(x2 >> 32)]][1] ^ IT[13][S[(uint8)(x2 >> 40)]][1] ^ IT[14][S[(uint8)(x2 >> 48)]][1] ^ IT[15][S[(uint8)(x2 >> 56)]][1]; \
} }
#define ISI(val) { \ #define ISI(val) { \
@ -2199,7 +2199,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
} \ } \
} }
void kuznyechik_set_key(const byte* key, kuznyechik_kds* kds) void kuznyechik_set_key(const uint8* key, kuznyechik_kds* kds)
{ {
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64))) #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64)))
if(HasSSE2()) if(HasSSE2())
@ -2258,7 +2258,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
} }
void kuznyechik_encrypt_block(byte* out, const byte* in, kuznyechik_kds* kds) void kuznyechik_encrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds)
{ {
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64))) #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64)))
if(HasSSE2()) if(HasSSE2())
@ -2305,7 +2305,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
} }
} }
void kuznyechik_encrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) void kuznyechik_encrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds)
{ {
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (DEBUG) || !defined (TC_WINDOWS_DRIVER)) #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (DEBUG) || !defined (TC_WINDOWS_DRIVER))
if(HasSSE2()) if(HasSSE2())
@ -2325,7 +2325,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
} }
} }
void kuznyechik_decrypt_block(byte* out, const byte* in, kuznyechik_kds* kds) void kuznyechik_decrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds)
{ {
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64))) #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64)))
if(HasSSE2()) if(HasSSE2())
@ -2366,8 +2366,8 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
ILS(x1, x2, t1, t2); ILS(x1, x2, t1, t2);
t1 ^= kds->rkd[2]; t1 ^= kds->rkd[2];
t2 ^= kds->rkd[3]; t2 ^= kds->rkd[3];
ISI((byte*)&t1); ISI((uint8*)&t1);
ISI((byte*)&t2); ISI((uint8*)&t2);
t1 ^= kds->rkd[0]; t1 ^= kds->rkd[0];
t2 ^= kds->rkd[1]; t2 ^= kds->rkd[1];
*(uint64*)out = t1; *(uint64*)out = t1;
@ -2375,7 +2375,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
} }
} }
void kuznyechik_decrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) void kuznyechik_decrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds)
{ {
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (DEBUG) || !defined (TC_WINDOWS_DRIVER)) #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (DEBUG) || !defined (TC_WINDOWS_DRIVER))
if(HasSSE2()) if(HasSSE2())

View File

@ -22,11 +22,11 @@ typedef struct _kuznyechik_kds
#define KUZNYECHIK_KS (sizeof(kuznyechik_kds)) #define KUZNYECHIK_KS (sizeof(kuznyechik_kds))
void kuznyechik_encrypt_block(byte* out, const byte* in, kuznyechik_kds* kds); void kuznyechik_encrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds);
void kuznyechik_encrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); void kuznyechik_encrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds);
void kuznyechik_decrypt_block(byte* out, const byte* in, kuznyechik_kds* kds); void kuznyechik_decrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds);
void kuznyechik_decrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); void kuznyechik_decrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds);
void kuznyechik_set_key(const byte* key, kuznyechik_kds *kds); void kuznyechik_set_key(const uint8* key, kuznyechik_kds *kds);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -9169,7 +9169,7 @@ VC_INLINE void scheduleDecryptionRoundKeysForGost15(
applyLSTransformation_4(data1_, data2_, data3_,data4_); \ applyLSTransformation_4(data1_, data2_, data3_,data4_); \
} }
void kuznyechik_encrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds) void kuznyechik_encrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds)
{ {
const uint_64t *roundKeys_ = (const uint_64t *) kds->rke; const uint_64t *roundKeys_ = (const uint_64t *) kds->rke;
__m128i data_; __m128i data_;
@ -9200,7 +9200,7 @@ void kuznyechik_encrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kd
_mm_storeu_si128((__m128i*) out, data_); _mm_storeu_si128((__m128i*) out, data_);
} }
void kuznyechik_encrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) void kuznyechik_encrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds)
{ {
const uint_64t *roundKeys_ = (const uint_64t *) kds->rke; const uint_64t *roundKeys_ = (const uint_64t *) kds->rke;
__m128i data1_, data2_, data3_, data4_; __m128i data1_, data2_, data3_, data4_;
@ -9347,7 +9347,7 @@ void kuznyechik_encrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
data4_ = _mm_xor_si128(data4_, cache11_); \ data4_ = _mm_xor_si128(data4_, cache11_); \
} }
void kuznyechik_decrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds) void kuznyechik_decrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds)
{ {
const uint_64t *roundKeys_ = kds->rkd; const uint_64t *roundKeys_ = kds->rkd;
__m128i data_; __m128i data_;
@ -9383,7 +9383,7 @@ void kuznyechik_decrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kd
_mm_storeu_si128((__m128i*) out, data_); _mm_storeu_si128((__m128i*) out, data_);
} }
void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) void kuznyechik_decrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds)
{ {
const uint_64t *roundKeys_ = kds->rkd; const uint_64t *roundKeys_ = kds->rkd;
__m128i data1_, data2_,data3_,data4_; __m128i data1_, data2_,data3_,data4_;
@ -9508,7 +9508,7 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku
kuznyechik_decrypt_block_simd (out, in, kds); kuznyechik_decrypt_block_simd (out, in, kds);
} }
void kuznyechik_set_key_simd(const byte* key, kuznyechik_kds *kds) void kuznyechik_set_key_simd(const uint8* key, kuznyechik_kds *kds)
{ {
scheduleEncryptionRoundKeysForGost15 (kds->rke, key); scheduleEncryptionRoundKeysForGost15 (kds->rke, key);
scheduleDecryptionRoundKeysForGost15 (kds->rkd, key); scheduleDecryptionRoundKeysForGost15 (kds->rkd, key);

View File

@ -6,8 +6,8 @@
#include "cpu.h" #include "cpu.h"
#include "misc.h" #include "misc.h"
void CRYPTOPP_FASTCALL MASM_RDRAND_GenerateBlock(byte*, size_t); void CRYPTOPP_FASTCALL MASM_RDRAND_GenerateBlock(uint8*, size_t);
void CRYPTOPP_FASTCALL MASM_RDSEED_GenerateBlock(byte*, size_t); void CRYPTOPP_FASTCALL MASM_RDSEED_GenerateBlock(uint8*, size_t);
int RDRAND_getBytes(unsigned char* buf, size_t bufLen) int RDRAND_getBytes(unsigned char* buf, size_t bufLen)
{ {

View File

@ -183,7 +183,7 @@ extern "C" {
#define T1HA_ALIGN_SUFFIX #define T1HA_ALIGN_SUFFIX
#ifdef _MSC_VER #ifdef _MSC_VER
#define uint8_t byte #define uint8_t uint8
#define uint16_t uint16 #define uint16_t uint16
#define uint32_t uint32 #define uint32_t uint32
#define uint64_t uint64 #define uint64_t uint64

View File

@ -234,10 +234,10 @@ void sha512(unsigned char * result, const unsigned char* source, uint_64t source
void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) { void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) {
(void) iterations; (void) iterations;
wc_HKDF(WC_SHA512, (byte*)pwd, (word32)pwd_len, (byte*)salt, (word32)salt_len, NULL, 0, (byte*)dk, (word32)dklen); wc_HKDF(WC_SHA512, (uint8*)pwd, (word32)pwd_len, (uint8*)salt, (word32)salt_len, NULL, 0, (uint8*)dk, (word32)dklen);
} }
void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) { void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) {
(void) iterations; (void) iterations;
wc_HKDF(WC_SHA256, (byte*)pwd, (word32)pwd_len, (byte*)salt, (word32)salt_len, NULL, 0, (byte*)dk, (word32)dklen); wc_HKDF(WC_SHA256, (uint8*)pwd, (word32)pwd_len, (uint8*)salt, (word32)salt_len, NULL, 0, (uint8*)dk, (word32)dklen);
} }

View File

@ -35,7 +35,7 @@ static BOOL DeviceFilterActive = FALSE;
BOOL BootArgsValid = FALSE; BOOL BootArgsValid = FALSE;
BootArguments BootArgs; BootArguments BootArgs;
byte* BootSecRegionData = NULL; uint8* BootSecRegionData = NULL;
uint32 BootSecRegionSize = 0; uint32 BootSecRegionSize = 0;
uint32 BootPkcs5 = 0; uint32 BootPkcs5 = 0;
@ -47,13 +47,13 @@ static KMUTEX MountMutex;
static volatile BOOL BootDriveFound = FALSE; static volatile BOOL BootDriveFound = FALSE;
static DriveFilterExtension *BootDriveFilterExtension = NULL; static DriveFilterExtension *BootDriveFilterExtension = NULL;
static LARGE_INTEGER BootDriveLength; static LARGE_INTEGER BootDriveLength;
static byte BootLoaderFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; static uint8 BootLoaderFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
static BOOL CrashDumpEnabled = FALSE; static BOOL CrashDumpEnabled = FALSE;
static BOOL HibernationEnabled = FALSE; static BOOL HibernationEnabled = FALSE;
static BOOL LegacyHibernationDriverFilterActive = FALSE; static BOOL LegacyHibernationDriverFilterActive = FALSE;
static byte *HibernationWriteBuffer = NULL; static uint8 *HibernationWriteBuffer = NULL;
static MDL *HibernationWriteBufferMdl = NULL; static MDL *HibernationWriteBufferMdl = NULL;
static uint32 HibernationPreventionCount = 0; static uint32 HibernationPreventionCount = 0;
@ -82,8 +82,8 @@ NTSTATUS LoadBootArguments (BOOL bIsEfi)
{ {
NTSTATUS status = STATUS_UNSUCCESSFUL; NTSTATUS status = STATUS_UNSUCCESSFUL;
PHYSICAL_ADDRESS bootArgsAddr; PHYSICAL_ADDRESS bootArgsAddr;
byte *mappedBootArgs; uint8 *mappedBootArgs;
byte *mappedCryptoInfo = NULL; uint8 *mappedCryptoInfo = NULL;
uint16 bootLoaderArgsIndex; uint16 bootLoaderArgsIndex;
uint64* BootArgsRegionsPtr = bIsEfi? BootArgsRegionsEFI : BootArgsRegionsDefault; uint64* BootArgsRegionsPtr = bIsEfi? BootArgsRegionsEFI : BootArgsRegionsDefault;
size_t BootArgsRegionsCount = bIsEfi? sizeof(BootArgsRegionsEFI)/ sizeof(BootArgsRegionsEFI[0]) : sizeof(BootArgsRegionsDefault)/ sizeof(BootArgsRegionsDefault[0]); size_t BootArgsRegionsCount = bIsEfi? sizeof(BootArgsRegionsEFI)/ sizeof(BootArgsRegionsEFI[0]) : sizeof(BootArgsRegionsDefault)/ sizeof(BootArgsRegionsDefault[0]);
@ -109,7 +109,7 @@ NTSTATUS LoadBootArguments (BOOL bIsEfi)
DumpMem (mappedBootArgs, sizeof (BootArguments)); DumpMem (mappedBootArgs, sizeof (BootArguments));
if (bootArguments->BootLoaderVersion == VERSION_NUM if (bootArguments->BootLoaderVersion == VERSION_NUM
&& bootArguments->BootArgumentsCrc32 != GetCrc32 ((byte *) bootArguments, (int) ((byte *) &bootArguments->BootArgumentsCrc32 - (byte *) bootArguments))) && bootArguments->BootArgumentsCrc32 != GetCrc32 ((uint8 *) bootArguments, (int) ((uint8 *) &bootArguments->BootArgumentsCrc32 - (uint8 *) bootArguments)))
{ {
Dump ("BootArguments CRC incorrect\n"); Dump ("BootArguments CRC incorrect\n");
burn (mappedBootArgs, sizeof (BootArguments)); burn (mappedBootArgs, sizeof (BootArguments));
@ -166,13 +166,13 @@ NTSTATUS LoadBootArguments (BOOL bIsEfi)
uint32 crc; uint32 crc;
PHYSICAL_ADDRESS SecRegionAddress; PHYSICAL_ADDRESS SecRegionAddress;
SECREGION_BOOT_PARAMS* SecRegionParams = (SECREGION_BOOT_PARAMS*) (mappedCryptoInfo + sizeof(BOOT_CRYPTO_HEADER) + 2); SECREGION_BOOT_PARAMS* SecRegionParams = (SECREGION_BOOT_PARAMS*) (mappedCryptoInfo + sizeof(BOOT_CRYPTO_HEADER) + 2);
byte *secRegionData = NULL; uint8 *secRegionData = NULL;
SecRegionAddress.QuadPart = SecRegionParams->Ptr; SecRegionAddress.QuadPart = SecRegionParams->Ptr;
Dump ("SecRegion memory 0x%x %d\n", SecRegionAddress.LowPart, SecRegionParams->Size); Dump ("SecRegion memory 0x%x %d\n", SecRegionAddress.LowPart, SecRegionParams->Size);
// SecRegion correct? // SecRegion correct?
if( (SecRegionParams->Ptr != 0) && (SecRegionParams->Size > 0)) { if( (SecRegionParams->Ptr != 0) && (SecRegionParams->Size > 0)) {
crc = GetCrc32((byte*)SecRegionParams, 12); crc = GetCrc32((uint8*)SecRegionParams, 12);
if(crc == SecRegionParams->Crc) { if(crc == SecRegionParams->Crc) {
Dump ("SecRegion crc ok\n"); Dump ("SecRegion crc ok\n");
secRegionData = MmMapIoSpace (SecRegionAddress, SecRegionParams->Size, MmCached); secRegionData = MmMapIoSpace (SecRegionAddress, SecRegionParams->Size, MmCached);
@ -329,7 +329,7 @@ static void InvalidateDriveFilterKeys (DriveFilterExtension *Extension)
Dump ("Drive filter encryption keys invalidated!\n"); Dump ("Drive filter encryption keys invalidated!\n");
} }
static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, byte* ioBuffer /* ioBuffer must be at least 512 bytes long */) static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8* ioBuffer /* ioBuffer must be at least 512 bytes long */)
{ {
NTSTATUS status; NTSTATUS status;
LARGE_INTEGER offset; LARGE_INTEGER offset;
@ -433,7 +433,7 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password,
// Check disk MBR id and GPT ID if BootSecRegion is available to detect boot drive // Check disk MBR id and GPT ID if BootSecRegion is available to detect boot drive
if (BootSecRegionData != NULL && BootSecRegionSize >= 1024) { if (BootSecRegionData != NULL && BootSecRegionSize >= 1024) {
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
DCS_DISK_ENTRY_LIST* DeList = (DCS_DISK_ENTRY_LIST*)(BootSecRegionData + 512); DCS_DISK_ENTRY_LIST* DeList = (DCS_DISK_ENTRY_LIST*)(BootSecRegionData + 512);
offset.QuadPart = 0; offset.QuadPart = 0;
status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS); status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS);
@ -459,7 +459,7 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password,
// Check boot drive signature first (header CRC search could fail if a user restored the header to a non-boot drive) // Check boot drive signature first (header CRC search could fail if a user restored the header to a non-boot drive)
if (BootDriveSignatureValid) if (BootDriveSignatureValid)
{ {
byte mbr[TC_SECTOR_SIZE_BIOS]; uint8 mbr[TC_SECTOR_SIZE_BIOS];
offset.QuadPart = 0; offset.QuadPart = 0;
status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS); status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS);
@ -585,7 +585,7 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password,
uint32 crcSaved; uint32 crcSaved;
crcSaved = DeList->CRC32; crcSaved = DeList->CRC32;
DeList->CRC32 = 0; DeList->CRC32 = 0;
crc = GetCrc32((byte*)DeList, 512); crc = GetCrc32((uint8*)DeList, 512);
if(crc == crcSaved){ if(crc == crcSaved){
if(DeList->DE[DE_IDX_PWDCACHE].Type == DE_PwdCache) { if(DeList->DE[DE_IDX_PWDCACHE].Type == DE_PwdCache) {
uint64 sector = 0; uint64 sector = 0;
@ -696,7 +696,7 @@ static NTSTATUS SaveDriveVolumeHeader (DriveFilterExtension *Extension)
{ {
NTSTATUS status = STATUS_SUCCESS; NTSTATUS status = STATUS_SUCCESS;
LARGE_INTEGER offset; LARGE_INTEGER offset;
byte *header; uint8 *header;
header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE);
if (!header) if (!header)
@ -727,7 +727,7 @@ static NTSTATUS SaveDriveVolumeHeader (DriveFilterExtension *Extension)
{ {
uint32 headerCrc32; uint32 headerCrc32;
uint64 encryptedAreaLength = Extension->Queue.EncryptedAreaEnd + 1 - Extension->Queue.EncryptedAreaStart; uint64 encryptedAreaLength = Extension->Queue.EncryptedAreaEnd + 1 - Extension->Queue.EncryptedAreaStart;
byte *fieldPos = header + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH; uint8 *fieldPos = header + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH;
PCRYPTO_INFO pCryptoInfo = Extension->HeaderCryptoInfo; PCRYPTO_INFO pCryptoInfo = Extension->HeaderCryptoInfo;
#ifdef _WIN64 #ifdef _WIN64
CRYPTO_INFO tmpCI; CRYPTO_INFO tmpCI;
@ -1234,16 +1234,16 @@ typedef NTSTATUS (*HiberDriverWriteFunctionB) (PLARGE_INTEGER writeOffset, PMDL
typedef struct typedef struct
{ {
#ifdef _WIN64 #ifdef _WIN64
byte FieldPad1[64]; uint8 FieldPad1[64];
HiberDriverWriteFunctionB WriteFunctionB; HiberDriverWriteFunctionB WriteFunctionB;
byte FieldPad2[56]; uint8 FieldPad2[56];
#else #else
byte FieldPad1[48]; uint8 FieldPad1[48];
HiberDriverWriteFunctionB WriteFunctionB; HiberDriverWriteFunctionB WriteFunctionB;
byte FieldPad2[32]; uint8 FieldPad2[32];
#endif #endif
HiberDriverWriteFunctionA WriteFunctionA; HiberDriverWriteFunctionA WriteFunctionA;
byte FieldPad3[24]; uint8 FieldPad3[24];
LARGE_INTEGER PartitionStartOffset; LARGE_INTEGER PartitionStartOffset;
} HiberDriverContext; } HiberDriverContext;
@ -1253,16 +1253,16 @@ typedef struct
{ {
LIST_ENTRY ModuleList; LIST_ENTRY ModuleList;
#ifdef _WIN64 #ifdef _WIN64
byte FieldPad1[32]; uint8 FieldPad1[32];
#else #else
byte FieldPad1[16]; uint8 FieldPad1[16];
#endif #endif
PVOID ModuleBaseAddress; PVOID ModuleBaseAddress;
HiberDriverEntry ModuleEntryAddress; HiberDriverEntry ModuleEntryAddress;
#ifdef _WIN64 #ifdef _WIN64
byte FieldPad2[24]; uint8 FieldPad2[24];
#else #else
byte FieldPad2[12]; uint8 FieldPad2[12];
#endif #endif
UNICODE_STRING ModuleName; UNICODE_STRING ModuleName;
} ModuleTableItem; } ModuleTableItem;
@ -1572,10 +1572,10 @@ static VOID SetupThreadProc (PVOID threadArg)
BOOL headerUpdateRequired = FALSE; BOOL headerUpdateRequired = FALSE;
int64 bytesWrittenSinceHeaderUpdate = 0; int64 bytesWrittenSinceHeaderUpdate = 0;
byte *buffer = NULL; uint8 *buffer = NULL;
byte *wipeBuffer = NULL; uint8 *wipeBuffer = NULL;
byte wipeRandChars[TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandChars[TC_WIPE_RAND_CHAR_COUNT];
byte wipeRandCharsUpdate[TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandCharsUpdate[TC_WIPE_RAND_CHAR_COUNT];
KIRQL irql; KIRQL irql;
NTSTATUS status; NTSTATUS status;
@ -1583,7 +1583,7 @@ static VOID SetupThreadProc (PVOID threadArg)
// generate real random values for wipeRandChars and // generate real random values for wipeRandChars and
// wipeRandCharsUpdate instead of relying on uninitialized stack memory // wipeRandCharsUpdate instead of relying on uninitialized stack memory
ChaCha20RngCtx rngCtx; ChaCha20RngCtx rngCtx;
byte pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ]; uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
GetDriverRandomSeed (pbSeed, sizeof (pbSeed)); GetDriverRandomSeed (pbSeed, sizeof (pbSeed));
ChaCha20RngInit (&rngCtx, pbSeed, GetDriverRandomSeed, 0); ChaCha20RngInit (&rngCtx, pbSeed, GetDriverRandomSeed, 0);
@ -1757,7 +1757,7 @@ static VOID SetupThreadProc (PVOID threadArg)
if (SetupRequest.WipeAlgorithm != TC_WIPE_NONE) if (SetupRequest.WipeAlgorithm != TC_WIPE_NONE)
{ {
byte wipePass; uint8 wipePass;
int wipePassCount = GetWipePassCount (SetupRequest.WipeAlgorithm); int wipePassCount = GetWipePassCount (SetupRequest.WipeAlgorithm);
if (wipePassCount <= 0) if (wipePassCount <= 0)
{ {
@ -2193,9 +2193,9 @@ static VOID DecoySystemWipeThreadProc (PVOID threadArg)
ULONG wipeBlockSize = TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE; ULONG wipeBlockSize = TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE;
CRYPTO_INFO *wipeCryptoInfo = NULL; CRYPTO_INFO *wipeCryptoInfo = NULL;
byte *wipeBuffer = NULL; uint8 *wipeBuffer = NULL;
byte *wipeRandBuffer = NULL; uint8 *wipeRandBuffer = NULL;
byte wipeRandChars[TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandChars[TC_WIPE_RAND_CHAR_COUNT];
int wipePass, wipePassCount; int wipePass, wipePassCount;
int ea = Extension->Queue.CryptoInfo->ea; int ea = Extension->Queue.CryptoInfo->ea;

View File

@ -18,7 +18,7 @@
static DriveFilterExtension *BootDriveFilterExtension = NULL; static DriveFilterExtension *BootDriveFilterExtension = NULL;
static LARGE_INTEGER DumpPartitionOffset; static LARGE_INTEGER DumpPartitionOffset;
static byte *WriteFilterBuffer = NULL; static uint8 *WriteFilterBuffer = NULL;
static SIZE_T WriteFilterBufferSize; static SIZE_T WriteFilterBufferSize;

View File

@ -191,7 +191,7 @@ static NTSTATUS CompleteOriginalIrp (EncryptedIoQueueItem *item, NTSTATUS status
} }
static void AcquireFragmentBuffer (EncryptedIoQueue *queue, byte *buffer) static void AcquireFragmentBuffer (EncryptedIoQueue *queue, uint8 *buffer)
{ {
NTSTATUS status = STATUS_INVALID_PARAMETER; NTSTATUS status = STATUS_INVALID_PARAMETER;
@ -209,7 +209,7 @@ static void AcquireFragmentBuffer (EncryptedIoQueue *queue, byte *buffer)
} }
static void ReleaseFragmentBuffer (EncryptedIoQueue *queue, byte *buffer) static void ReleaseFragmentBuffer (EncryptedIoQueue *queue, uint8 *buffer)
{ {
if (buffer == queue->FragmentBufferA) if (buffer == queue->FragmentBufferA)
{ {
@ -227,8 +227,8 @@ static void ReleaseFragmentBuffer (EncryptedIoQueue *queue, byte *buffer)
BOOL BOOL
UpdateBuffer( UpdateBuffer(
byte* buffer, uint8* buffer,
byte* secRegion, uint8* secRegion,
uint64 bufferDiskOffset, uint64 bufferDiskOffset,
uint32 bufferLength, uint32 bufferLength,
BOOL doUpadte BOOL doUpadte
@ -393,7 +393,7 @@ static VOID IoThreadProc (PVOID threadArg)
{ {
// Up to three subfragments may be required to handle a partially remapped fragment // Up to three subfragments may be required to handle a partially remapped fragment
int subFragment; int subFragment;
byte *subFragmentData = request->Data; uint8 *subFragmentData = request->Data;
for (subFragment = 0 ; subFragment < 3; ++subFragment) for (subFragment = 0 ; subFragment < 3; ++subFragment)
{ {
@ -615,7 +615,7 @@ static VOID MainThreadProc (PVOID threadArg)
&& (item->OriginalLength & (ENCRYPTION_DATA_UNIT_SIZE - 1)) == 0 && (item->OriginalLength & (ENCRYPTION_DATA_UNIT_SIZE - 1)) == 0
&& (item->OriginalOffset.QuadPart & (ENCRYPTION_DATA_UNIT_SIZE - 1)) != 0) && (item->OriginalOffset.QuadPart & (ENCRYPTION_DATA_UNIT_SIZE - 1)) != 0)
{ {
byte *buffer; uint8 *buffer;
ULONG alignedLength; ULONG alignedLength;
LARGE_INTEGER alignedOffset; LARGE_INTEGER alignedOffset;
hResult = ULongAdd(item->OriginalLength, ENCRYPTION_DATA_UNIT_SIZE, &alignedLength); hResult = ULongAdd(item->OriginalLength, ENCRYPTION_DATA_UNIT_SIZE, &alignedLength);

View File

@ -83,8 +83,8 @@ typedef struct
KEVENT CompletionThreadQueueNotEmptyEvent; KEVENT CompletionThreadQueueNotEmptyEvent;
// Fragment buffers // Fragment buffers
byte *FragmentBufferA; uint8 *FragmentBufferA;
byte *FragmentBufferB; uint8 *FragmentBufferB;
KEVENT FragmentBufferAFreeEvent; KEVENT FragmentBufferAFreeEvent;
KEVENT FragmentBufferBFreeEvent; KEVENT FragmentBufferBFreeEvent;
@ -94,7 +94,7 @@ typedef struct
ULONG LastReadLength; ULONG LastReadLength;
LARGE_INTEGER ReadAheadOffset; LARGE_INTEGER ReadAheadOffset;
ULONG ReadAheadLength; ULONG ReadAheadLength;
byte *ReadAheadBuffer; uint8 *ReadAheadBuffer;
LARGE_INTEGER MaxReadAheadOffset; LARGE_INTEGER MaxReadAheadOffset;
LONG OutstandingIoCount; LONG OutstandingIoCount;
@ -119,7 +119,7 @@ typedef struct
LARGE_INTEGER LastPerformanceCounter; LARGE_INTEGER LastPerformanceCounter;
#endif #endif
byte* SecRegionData; uint8* SecRegionData;
SIZE_T SecRegionSize; SIZE_T SecRegionSize;
volatile BOOL ThreadBlockReadWrite; volatile BOOL ThreadBlockReadWrite;
@ -153,8 +153,8 @@ typedef struct
ULONG Length; ULONG Length;
int64 EncryptedOffset; int64 EncryptedOffset;
ULONG EncryptedLength; ULONG EncryptedLength;
byte *Data; uint8 *Data;
byte *OrigDataBufferFragment; uint8 *OrigDataBufferFragment;
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
LIST_ENTRY CompletionListEntry; LIST_ENTRY CompletionListEntry;

View File

@ -223,11 +223,11 @@ namespace VeraCrypt
SecureBuffer alignedBuffer (alignedSize); SecureBuffer alignedBuffer (alignedSize);
FuseService::ReadVolumeSectors (alignedBuffer, alignedOffset); FuseService::ReadVolumeSectors (alignedBuffer, alignedOffset);
BufferPtr ((byte *) buf, size).CopyFrom (alignedBuffer.GetRange (offset % sectorSize, size)); BufferPtr ((uint8 *) buf, size).CopyFrom (alignedBuffer.GetRange (offset % sectorSize, size));
} }
else else
{ {
FuseService::ReadVolumeSectors (BufferPtr ((byte *) buf, size), offset); FuseService::ReadVolumeSectors (BufferPtr ((uint8 *) buf, size), offset);
} }
} }
catch (MissingVolumeData&) catch (MissingVolumeData&)
@ -241,7 +241,7 @@ namespace VeraCrypt
if (strcmp (path, FuseService::GetControlPath()) == 0) if (strcmp (path, FuseService::GetControlPath()) == 0)
{ {
shared_ptr <Buffer> infoBuf = FuseService::GetVolumeInfo(); shared_ptr <Buffer> infoBuf = FuseService::GetVolumeInfo();
BufferPtr outBuf ((byte *)buf, size); BufferPtr outBuf ((uint8 *)buf, size);
if (offset >= (off_t) infoBuf->Size()) if (offset >= (off_t) infoBuf->Size())
return 0; return 0;
@ -293,7 +293,7 @@ namespace VeraCrypt
if (strcmp (path, FuseService::GetVolumeImagePath()) == 0) if (strcmp (path, FuseService::GetVolumeImagePath()) == 0)
{ {
FuseService::WriteVolumeSectors (BufferPtr ((byte *) buf, size), offset); FuseService::WriteVolumeSectors (BufferPtr ((uint8 *) buf, size), offset);
return size; return size;
} }
@ -302,7 +302,7 @@ namespace VeraCrypt
if (FuseService::AuxDeviceInfoReceived()) if (FuseService::AuxDeviceInfoReceived())
return -EACCES; return -EACCES;
FuseService::ReceiveAuxDeviceInfo (ConstBufferPtr ((const byte *)buf, size)); FuseService::ReceiveAuxDeviceInfo (ConstBufferPtr ((const uint8 *)buf, size));
return size; return size;
} }
} }
@ -584,7 +584,7 @@ namespace VeraCrypt
sigaction (SIGTERM, &action, nullptr); sigaction (SIGTERM, &action, nullptr);
// Wait for the exit of the main service // Wait for the exit of the main service
byte buf[1]; uint8 buf[1];
if (read (SignalHandlerPipe->GetReadFD(), buf, sizeof (buf))) { } // Errors ignored if (read (SignalHandlerPipe->GetReadFD(), buf, sizeof (buf))) { } // Errors ignored
_exit (0); _exit (0);

View File

@ -216,7 +216,7 @@ BOOL IsUefiBoot ()
void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed) void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
{ {
LARGE_INTEGER iSeed, iSeed2; LARGE_INTEGER iSeed, iSeed2;
byte digest[WHIRLPOOL_DIGESTSIZE]; uint8 digest[WHIRLPOOL_DIGESTSIZE];
WHIRLPOOL_CTX tctx; WHIRLPOOL_CTX tctx;
size_t count; size_t count;
@ -2070,7 +2070,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem || opentest->bComputeVolumeIDs) if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem || opentest->bComputeVolumeIDs)
{ {
byte *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE); uint8 *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE);
if (!readBuffer) if (!readBuffer)
{ {
ntStatus = STATUS_INSUFFICIENT_RESOURCES; ntStatus = STATUS_INSUFFICIENT_RESOURCES;
@ -2233,7 +2233,7 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex
if (NT_SUCCESS (ntStatus)) if (NT_SUCCESS (ntStatus))
{ {
byte *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE); uint8 *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE);
if (!readBuffer) if (!readBuffer)
{ {
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
@ -3717,7 +3717,7 @@ NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *dr
NTSTATUS status; NTSTATUS status;
LARGE_INTEGER sysLength; LARGE_INTEGER sysLength;
LARGE_INTEGER offset; LARGE_INTEGER offset;
byte *sectorBuffer; uint8 *sectorBuffer;
ULONGLONG startTime; ULONGLONG startTime;
ULONG sectorSize; ULONG sectorSize;
@ -4919,7 +4919,7 @@ NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER start
NTSTATUS status; NTSTATUS status;
ULONG sectorSize; ULONG sectorSize;
ULONG sectorCount; ULONG sectorCount;
byte *sectorBuffer = NULL; uint8 *sectorBuffer = NULL;
*zeroedSectorCount = 0; *zeroedSectorCount = 0;
@ -4957,7 +4957,7 @@ NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER start
} }
NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, byte *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount) NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, uint8 *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount)
{ {
NTSTATUS status; NTSTATUS status;
ULONG sectorSize; ULONG sectorSize;

View File

@ -191,7 +191,7 @@ NTSTATUS WriteRegistryConfigFlags (uint32 flags);
BOOL ValidateIOBufferSize (PIRP irp, size_t requiredBufferSize, ValidateIOBufferSizeType type); BOOL ValidateIOBufferSize (PIRP irp, size_t requiredBufferSize, ValidateIOBufferSizeType type);
NTSTATUS GetDeviceSectorSize (PDEVICE_OBJECT deviceObject, ULONG *bytesPerSector); NTSTATUS GetDeviceSectorSize (PDEVICE_OBJECT deviceObject, ULONG *bytesPerSector);
NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER startOffset, ULONG size, uint64 *zeroedSectorCount); NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER startOffset, ULONG size, uint64 *zeroedSectorCount);
NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, byte *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount); NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, uint8 *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount);
BOOL IsVolumeAccessibleByCurrentUser (PEXTENSION volumeDeviceExtension); BOOL IsVolumeAccessibleByCurrentUser (PEXTENSION volumeDeviceExtension);
void GetElapsedTimeInit (LARGE_INTEGER *lastPerfCounter); void GetElapsedTimeInit (LARGE_INTEGER *lastPerfCounter);
int64 GetElapsedTime (LARGE_INTEGER *lastPerfCounter); int64 GetElapsedTime (LARGE_INTEGER *lastPerfCounter);

View File

@ -98,7 +98,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject,
LARGE_INTEGER diskLengthInfo; LARGE_INTEGER diskLengthInfo;
DISK_GEOMETRY_EX dg; DISK_GEOMETRY_EX dg;
STORAGE_PROPERTY_QUERY storagePropertyQuery = {0}; STORAGE_PROPERTY_QUERY storagePropertyQuery = {0};
byte* dgBuffer; uint8* dgBuffer;
STORAGE_DEVICE_NUMBER storageDeviceNumber; STORAGE_DEVICE_NUMBER storageDeviceNumber;
ntStatus = IoGetDeviceObjectPointer (&FullFileName, ntStatus = IoGetDeviceObjectPointer (&FullFileName,

View File

@ -518,7 +518,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
BOOL bTimeStampValid = FALSE; BOOL bTimeStampValid = FALSE;
LARGE_INTEGER headerOffset; LARGE_INTEGER headerOffset;
BOOL backupHeader; BOOL backupHeader;
byte *wipeBuffer = NULL; uint8 *wipeBuffer = NULL;
uint32 workChunkSize = TC_VOLUME_HEADER_GROUP_SIZE; uint32 workChunkSize = TC_VOLUME_HEADER_GROUP_SIZE;
#ifdef _WIN64 #ifdef _WIN64
CRYPTO_INFO tmpCI; CRYPTO_INFO tmpCI;
@ -1023,9 +1023,9 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
/* wipe old backup header */ /* wipe old backup header */
if ( !cryptoInfo->LegacyVolume ) if ( !cryptoInfo->LegacyVolume )
{ {
byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandChars [TC_WIPE_RAND_CHAR_COUNT];
byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT];
byte wipePass; uint8 wipePass;
UINT64_STRUCT unitNo; UINT64_STRUCT unitNo;
LARGE_INTEGER offset; LARGE_INTEGER offset;
WipeAlgorithmId wipeAlgorithm = TC_WIPE_35_GUTMANN; WipeAlgorithmId wipeAlgorithm = TC_WIPE_35_GUTMANN;
@ -1040,7 +1040,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas
DebugAddProgressDlgStatus(hwndDlg, GetString("EXPANDER_WIPING_OLD_HEADER")); DebugAddProgressDlgStatus(hwndDlg, GetString("EXPANDER_WIPING_OLD_HEADER"));
wipeBuffer = (byte *) TCalloc (workChunkSize); wipeBuffer = (uint8 *) TCalloc (workChunkSize);
if (!wipeBuffer) if (!wipeBuffer)
{ {
nStatus = ERR_OUTOFMEMORY; nStatus = ERR_OUTOFMEMORY;

View File

@ -216,7 +216,7 @@ static volatile BOOL WriteThreadRunning;
static volatile BOOL WriteThreadExitRequested; static volatile BOOL WriteThreadExitRequested;
static HANDLE WriteThreadHandle; static HANDLE WriteThreadHandle;
static byte *WriteThreadBuffer; static uint8 *WriteThreadBuffer;
static HANDLE WriteBufferEmptyEvent; static HANDLE WriteBufferEmptyEvent;
static HANDLE WriteBufferFullEvent; static HANDLE WriteBufferFullEvent;

View File

@ -600,7 +600,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
} }
// Write the backup header to the partition // Write the backup header to the partition
if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) if (!WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header))
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
goto closing_seq; goto closing_seq;
@ -646,7 +646,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
} }
// Write the fake hidden backup header to the partition // Write the fake hidden backup header to the partition
if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) if (!WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header))
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
goto closing_seq; goto closing_seq;
@ -754,9 +754,9 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL, tmpCryptoInfo = NULL; PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL, tmpCryptoInfo = NULL;
UINT64_STRUCT unitNo; UINT64_STRUCT unitNo;
char *buf = NULL, *header = NULL; char *buf = NULL, *header = NULL;
byte *wipeBuffer = NULL; uint8 *wipeBuffer = NULL;
byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandChars [TC_WIPE_RAND_CHAR_COUNT];
byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; uint8 wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT];
WCHAR dosDev[TC_MAX_PATH] = {0}; WCHAR dosDev[TC_MAX_PATH] = {0};
WCHAR devName[MAX_PATH] = {0}; WCHAR devName[MAX_PATH] = {0};
WCHAR deviceName[MAX_PATH]; WCHAR deviceName[MAX_PATH];
@ -801,7 +801,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
if (wipeAlgorithm != TC_WIPE_NONE) if (wipeAlgorithm != TC_WIPE_NONE)
{ {
wipeBuffer = (byte *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); wipeBuffer = (uint8 *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE);
if (!wipeBuffer) if (!wipeBuffer)
{ {
nStatus = ERR_OUTOFMEMORY; nStatus = ERR_OUTOFMEMORY;
@ -974,14 +974,14 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
// Encrypt the plaintext in RAM // Encrypt the plaintext in RAM
EncryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); EncryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
// If enabled, wipe the area to which we will write the ciphertext // If enabled, wipe the area to which we will write the ciphertext
if (wipeAlgorithm != TC_WIPE_NONE) if (wipeAlgorithm != TC_WIPE_NONE)
{ {
byte wipePass; uint8 wipePass;
int wipePassCount = GetWipePassCount (wipeAlgorithm); int wipePassCount = GetWipePassCount (wipeAlgorithm);
if (wipePassCount <= 0) if (wipePassCount <= 0)
@ -1016,7 +1016,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
// Undo failed write operation // Undo failed write operation
if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset)) if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset))
{ {
DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); DecryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL); WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL);
} }
@ -1048,7 +1048,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
// Undo failed write operation // Undo failed write operation
if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset)) if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset))
{ {
DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); DecryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL); WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL);
} }
@ -1149,7 +1149,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
offset.QuadPart = TC_VOLUME_HEADER_OFFSET; offset.QuadPart = TC_VOLUME_HEADER_OFFSET;
if (MoveFilePointer (dev, offset) == 0 if (MoveFilePointer (dev, offset) == 0
|| !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) || !WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header))
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
goto closing_seq; goto closing_seq;
@ -1208,7 +1208,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET;
if (MoveFilePointer (dev, offset) == 0 if (MoveFilePointer (dev, offset) == 0
|| !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) || !WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header))
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
goto closing_seq; goto closing_seq;
@ -1316,7 +1316,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL; PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL;
UINT64_STRUCT unitNo; UINT64_STRUCT unitNo;
char *buf = NULL; char *buf = NULL;
byte *tmpSectorBuf = NULL; uint8 *tmpSectorBuf = NULL;
WCHAR dosDev[TC_MAX_PATH] = {0}; WCHAR dosDev[TC_MAX_PATH] = {0};
WCHAR devName[MAX_PATH] = {0}; WCHAR devName[MAX_PATH] = {0};
WCHAR deviceName[MAX_PATH]; WCHAR deviceName[MAX_PATH];
@ -1432,7 +1432,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
sectorSize = driveGeometry.BytesPerSector; sectorSize = driveGeometry.BytesPerSector;
tmpSectorBuf = (byte *) TCalloc (sectorSize); tmpSectorBuf = (uint8 *) TCalloc (sectorSize);
if (!tmpSectorBuf) if (!tmpSectorBuf)
{ {
nStatus = ERR_OUTOFMEMORY; nStatus = ERR_OUTOFMEMORY;
@ -1620,7 +1620,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
// Decrypt the ciphertext in RAM // Decrypt the ciphertext in RAM
DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); DecryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);
@ -1843,16 +1843,16 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN
LARGE_INTEGER offset; LARGE_INTEGER offset;
DWORD n; DWORD n;
int nStatus = ERR_SUCCESS; int nStatus = ERR_SUCCESS;
byte *header; uint8 *header;
DWORD dwError; DWORD dwError;
uint32 headerCrc32; uint32 headerCrc32;
byte *fieldPos; uint8 *fieldPos;
PCRYPTO_INFO pCryptoInfo = headerCryptoInfo; PCRYPTO_INFO pCryptoInfo = headerCryptoInfo;
#ifdef _WIN64 #ifdef _WIN64
BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled(); BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled();
#endif #endif
header = (byte *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE); header = (uint8 *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE);
if (!header) if (!header)
return ERR_OUTOFMEMORY; return ERR_OUTOFMEMORY;
@ -1860,7 +1860,7 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN
VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
fieldPos = (byte *) header + TC_HEADER_OFFSET_ENCRYPTED_AREA_START; fieldPos = (uint8 *) header + TC_HEADER_OFFSET_ENCRYPTED_AREA_START;
offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE; offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE;
@ -1902,12 +1902,12 @@ int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_IN
// were decrypted in place, it would be possible to mount them partially encrypted and it wouldn't be possible // were decrypted in place, it would be possible to mount them partially encrypted and it wouldn't be possible
// to resume interrupted decryption after the wizard exits. // to resume interrupted decryption after the wizard exits.
masterCryptoInfo->HeaderFlags |= TC_HEADER_FLAG_NONSYS_INPLACE_ENC; masterCryptoInfo->HeaderFlags |= TC_HEADER_FLAG_NONSYS_INPLACE_ENC;
fieldPos = (byte *) header + TC_HEADER_OFFSET_FLAGS; fieldPos = (uint8 *) header + TC_HEADER_OFFSET_FLAGS;
mputLong (fieldPos, (masterCryptoInfo->HeaderFlags)); mputLong (fieldPos, (masterCryptoInfo->HeaderFlags));
headerCrc32 = GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC); headerCrc32 = GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC);
fieldPos = (byte *) header + TC_HEADER_OFFSET_HEADER_CRC; fieldPos = (uint8 *) header + TC_HEADER_OFFSET_HEADER_CRC;
mputLong (fieldPos, headerCrc32); mputLong (fieldPos, headerCrc32);
EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo); EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo);
@ -2239,12 +2239,12 @@ int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, in
DWORD n; DWORD n;
int64 sectorCount; int64 sectorCount;
LARGE_INTEGER workOffset; LARGE_INTEGER workOffset;
byte *sectorBuffer = NULL; uint8 *sectorBuffer = NULL;
DWORD dwError; DWORD dwError;
workOffset.QuadPart = startOffset.QuadPart; workOffset.QuadPart = startOffset.QuadPart;
sectorBuffer = (byte *) TCalloc (sectorSize); sectorBuffer = (uint8 *) TCalloc (sectorSize);
if (!sectorBuffer) if (!sectorBuffer)
return ERR_OUTOFMEMORY; return ERR_OUTOFMEMORY;
@ -2315,7 +2315,7 @@ static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *pa
offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE; offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE;
if (MoveFilePointer (dev, offset) == 0 if (MoveFilePointer (dev, offset) == 0
|| !ReadEffectiveVolumeHeader (TRUE, dev, (byte *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE) || !ReadEffectiveVolumeHeader (TRUE, dev, (uint8 *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE)
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
goto closing_seq; goto closing_seq;
@ -2347,7 +2347,7 @@ static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *pa
static BOOL GetFreeClusterBeforeThreshold (HANDLE volumeHandle, int64 *freeCluster, int64 clusterThreshold) static BOOL GetFreeClusterBeforeThreshold (HANDLE volumeHandle, int64 *freeCluster, int64 clusterThreshold)
{ {
const int bitmapSize = 65536; const int bitmapSize = 65536;
byte bitmapBuffer[bitmapSize + sizeof (VOLUME_BITMAP_BUFFER)]; uint8 bitmapBuffer[bitmapSize + sizeof (VOLUME_BITMAP_BUFFER)];
VOLUME_BITMAP_BUFFER *bitmap = (VOLUME_BITMAP_BUFFER *) bitmapBuffer; VOLUME_BITMAP_BUFFER *bitmap = (VOLUME_BITMAP_BUFFER *) bitmapBuffer;
STARTING_LCN_INPUT_BUFFER startLcn; STARTING_LCN_INPUT_BUFFER startLcn;
startLcn.StartingLcn.QuadPart = 0; startLcn.StartingLcn.QuadPart = 0;

View File

@ -834,7 +834,7 @@ namespace VeraCrypt
if (wxCONV_FAILED == ulen) if (wxCONV_FAILED == ulen)
throw PasswordUTF8Invalid (SRC_POS); throw PasswordUTF8Invalid (SRC_POS);
SecureBuffer passwordBuf(ulen); SecureBuffer passwordBuf(ulen);
ulen = utf8.FromWChar ((char*) (byte*) passwordBuf, ulen, str, charCount); ulen = utf8.FromWChar ((char*) (uint8*) passwordBuf, ulen, str, charCount);
if (wxCONV_FAILED == ulen) if (wxCONV_FAILED == ulen)
throw PasswordUTF8Invalid (SRC_POS); throw PasswordUTF8Invalid (SRC_POS);
if (ulen > maxUtf8Len) if (ulen > maxUtf8Len)
@ -845,7 +845,7 @@ namespace VeraCrypt
throw PasswordUTF8TooLong (SRC_POS); throw PasswordUTF8TooLong (SRC_POS);
} }
ConstBufferPtr utf8Buffer ((byte*) passwordBuf, ulen); ConstBufferPtr utf8Buffer ((uint8*) passwordBuf, ulen);
return shared_ptr<SecureBuffer>(new SecureBuffer (utf8Buffer)); return shared_ptr<SecureBuffer>(new SecureBuffer (utf8Buffer));
} }
else else

View File

@ -281,7 +281,7 @@ namespace VeraCrypt
const char *tmp_salt = {"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"}; const char *tmp_salt = {"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"};
unsigned long pim; unsigned long pim;
Pkcs5KdfList prfList = Pkcs5Kdf::GetAvailableAlgorithms (); Pkcs5KdfList prfList = Pkcs5Kdf::GetAvailableAlgorithms ();
VolumePassword password ((const byte*) "passphrase-1234567890", 21); VolumePassword password ((const uint8*) "passphrase-1234567890", 21);
memcpy (&pim, buffer.Ptr (), sizeof (unsigned long)); memcpy (&pim, buffer.Ptr (), sizeof (unsigned long));
memcpy (salt.Ptr(), tmp_salt, 64); memcpy (salt.Ptr(), tmp_salt, 64);

View File

@ -141,7 +141,7 @@ namespace VeraCrypt
void EncryptionTestDialog::GetTextCtrlData (wxTextCtrl *textCtrl, Buffer &buffer) const void EncryptionTestDialog::GetTextCtrlData (wxTextCtrl *textCtrl, Buffer &buffer) const
{ {
vector <byte> data; vector <uint8> data;
string dataStr = StringConverter::ToSingle (wstring (textCtrl->GetValue())); string dataStr = StringConverter::ToSingle (wstring (textCtrl->GetValue()));
for (size_t i = 0; i < dataStr.size() / 2; ++i) for (size_t i = 0; i < dataStr.size() / 2; ++i)
@ -153,7 +153,7 @@ namespace VeraCrypt
throw StringConversionFailed (SRC_POS); throw StringConversionFailed (SRC_POS);
} }
data.push_back ((byte) dataByte); data.push_back ((uint8) dataByte);
} }
if (data.empty()) if (data.empty())

View File

@ -164,12 +164,12 @@ namespace VeraCrypt
{ {
event.Skip(); event.Skip();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&event), sizeof (event)));
long coord = event.GetX(); long coord = event.GetX();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord)));
coord = event.GetY(); coord = event.GetY();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord)));
if (ShowRandomPoolCheckBox->IsChecked()) if (ShowRandomPoolCheckBox->IsChecked())
ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24)); ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24));

View File

@ -1437,7 +1437,7 @@ namespace VeraCrypt
#if defined(TC_UNIX) && !defined(TC_MACOSX) #if defined(TC_UNIX) && !defined(TC_MACOSX)
try try
{ {
byte buf[128]; uint8 buf[128];
if (read (ShowRequestFifo, buf, sizeof (buf)) > 0 && Gui->IsInBackgroundMode()) if (read (ShowRequestFifo, buf, sizeof (buf)) > 0 && Gui->IsInBackgroundMode())
Gui->SetBackgroundMode (false); Gui->SetBackgroundMode (false);
} }

View File

@ -63,12 +63,12 @@ namespace VeraCrypt
{ {
event.Skip(); event.Skip();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&event), sizeof (event)));
long coord = event.GetX(); long coord = event.GetX();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord)));
coord = event.GetY(); coord = event.GetY();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord)));
if (ShowRandomPoolCheckBox->IsChecked()) if (ShowRandomPoolCheckBox->IsChecked())
ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24)); ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24));

View File

@ -103,7 +103,7 @@ namespace VeraCrypt
{ {
wxBusyCursor busy; wxBusyCursor busy;
vector <byte> keyfileData; vector <uint8> keyfileData;
keyfile->GetKeyfileData (keyfileData); keyfile->GetKeyfileData (keyfileData);
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
@ -141,7 +141,7 @@ namespace VeraCrypt
if (keyfile.Length() > 0) if (keyfile.Length() > 0)
{ {
vector <byte> keyfileData (keyfile.Length()); vector <uint8> keyfileData (keyfile.Length());
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
keyfile.ReadCompleteBuffer (keyfileDataBuf); keyfile.ReadCompleteBuffer (keyfileDataBuf);

View File

@ -390,12 +390,12 @@ namespace VeraCrypt
event.Skip(); event.Skip();
if (!IsWorkInProgress() && RandomNumberGenerator::IsRunning()) if (!IsWorkInProgress() && RandomNumberGenerator::IsRunning())
{ {
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&event), sizeof (event)));
long coord = event.GetX(); long coord = event.GetX();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord)));
coord = event.GetY(); coord = event.GetY();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord)));
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
if (page) if (page)
@ -442,7 +442,7 @@ namespace VeraCrypt
if (!IsWorkInProgress()) if (!IsWorkInProgress())
{ {
wxLongLong time = wxGetLocalTimeMillis(); wxLongLong time = wxGetLocalTimeMillis();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&time), sizeof (time))); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&time), sizeof (time)));
} }
} }

View File

@ -214,7 +214,7 @@ namespace VeraCrypt
shared_ptr <VolumePassword> password; shared_ptr <VolumePassword> password;
wchar_t passwordBuf[VolumePassword::MaxSize + 1]; wchar_t passwordBuf[VolumePassword::MaxSize + 1];
size_t maxPasswordLength = (bLegacyPassword || CmdLine->ArgUseLegacyPassword)? VolumePassword::MaxLegacySize: VolumePassword::MaxSize; size_t maxPasswordLength = (bLegacyPassword || CmdLine->ArgUseLegacyPassword)? VolumePassword::MaxLegacySize: VolumePassword::MaxSize;
finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <byte *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); }); finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <uint8 *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); });
#ifdef TC_WINDOWS #ifdef TC_WINDOWS
int len = GetWindowText (static_cast <HWND> (textCtrl->GetHandle()), passwordBuf, VolumePassword::MaxSize + 1); int len = GetWindowText (static_cast <HWND> (textCtrl->GetHandle()), passwordBuf, VolumePassword::MaxSize + 1);

View File

@ -992,7 +992,7 @@ namespace VeraCrypt
int showFifo = open (string (MainFrame::GetShowRequestFifoPath()).c_str(), O_WRONLY | O_NONBLOCK); int showFifo = open (string (MainFrame::GetShowRequestFifoPath()).c_str(), O_WRONLY | O_NONBLOCK);
throw_sys_if (showFifo == -1); throw_sys_if (showFifo == -1);
byte buf[1] = { 1 }; uint8 buf[1] = { 1 };
if (write (showFifo, buf, 1) == 1) if (write (showFifo, buf, 1) == 1)
{ {
close (showFifo); close (showFifo);

View File

@ -43,7 +43,7 @@ namespace VeraCrypt
void LanguageStrings::Init () void LanguageStrings::Init ()
{ {
static byte LanguageXml[] = static uint8 LanguageXml[] =
{ {
# include "Common/Language.xml.h" # include "Common/Language.xml.h"
, 0 , 0

View File

@ -40,7 +40,7 @@ namespace VeraCrypt
hResL = LoadResource (NULL, hRes); hResL = LoadResource (NULL, hRes);
throw_sys_if (!hResL); throw_sys_if (!hResL);
const byte *resPtr = (const byte *) LockResource (hResL); const uint8 *resPtr = (const uint8 *) LockResource (hResL);
throw_sys_if (!resPtr); throw_sys_if (!resPtr);
return ConstBufferPtr (resPtr, SizeofResource (NULL, hRes)); return ConstBufferPtr (resPtr, SizeofResource (NULL, hRes));
@ -132,14 +132,14 @@ namespace VeraCrypt
if ( xml.IsFile() ){ if ( xml.IsFile() ){
File file; File file;
file.Open (xml, File::OpenRead, File::ShareRead); file.Open (xml, File::OpenRead, File::ShareRead);
vector <byte> keyfileData (file.Length()); vector <uint8> keyfileData (file.Length());
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
file.ReadCompleteBuffer (keyfileDataBuf); file.ReadCompleteBuffer (keyfileDataBuf);
file.Close(); file.Close();
string langxml(keyfileData.begin(), keyfileData.end()); string langxml(keyfileData.begin(), keyfileData.end());
return langxml; return langxml;
} }
static byte LanguageXml[] = static uint8 LanguageXml[] =
{ {
# include "Common/Language.xml.h" # include "Common/Language.xml.h"
, 0 , 0
@ -158,7 +158,7 @@ namespace VeraCrypt
strBuf.CopyFrom (res); strBuf.CopyFrom (res);
return string (reinterpret_cast <char *> (strBuf.Ptr())); return string (reinterpret_cast <char *> (strBuf.Ptr()));
#else #else
static byte License[] = static uint8 License[] =
{ {
# include "License.txt.h" # include "License.txt.h"
, 0 , 0
@ -176,7 +176,7 @@ namespace VeraCrypt
#ifdef TC_WINDOWS #ifdef TC_WINDOWS
return wxBitmap (L"IDB_DRIVE_ICON", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0)); return wxBitmap (L"IDB_DRIVE_ICON", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0));
#else #else
static const byte DriveIcon[] = static const uint8 DriveIcon[] =
{ {
# include "Mount/Drive_icon_96dpi.bmp.h" # include "Mount/Drive_icon_96dpi.bmp.h"
}; };
@ -192,7 +192,7 @@ namespace VeraCrypt
wxImage image = wxBitmap (L"IDB_DRIVE_ICON_MASK", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0)); wxImage image = wxBitmap (L"IDB_DRIVE_ICON_MASK", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0));
return wxBitmap (image.ConvertToMono (0, 0, 0), 1); return wxBitmap (image.ConvertToMono (0, 0, 0), 1);
#else #else
static const byte DriveIconMask[] = static const uint8 DriveIconMask[] =
{ {
# include "Mount/Drive_icon_mask_96dpi.bmp.h" # include "Mount/Drive_icon_mask_96dpi.bmp.h"
}; };
@ -215,7 +215,7 @@ namespace VeraCrypt
#ifdef TC_WINDOWS #ifdef TC_WINDOWS
return wxBitmap (L"IDB_LOGO", wxBITMAP_TYPE_BMP_RESOURCE); return wxBitmap (L"IDB_LOGO", wxBITMAP_TYPE_BMP_RESOURCE);
#else #else
static const byte Logo[] = static const uint8 Logo[] =
{ {
# include "Mount/Logo_96dpi.bmp.h" # include "Mount/Logo_96dpi.bmp.h"
}; };
@ -230,7 +230,7 @@ namespace VeraCrypt
#ifdef TC_WINDOWS #ifdef TC_WINDOWS
return wxBitmap (L"IDB_TEXTUAL_LOGO", wxBITMAP_TYPE_BMP_RESOURCE); return wxBitmap (L"IDB_TEXTUAL_LOGO", wxBITMAP_TYPE_BMP_RESOURCE);
#else #else
static const byte Logo[] = static const uint8 Logo[] =
{ {
# include "Common/Textual_logo_96dpi.bmp.h" # include "Common/Textual_logo_96dpi.bmp.h"
}; };
@ -255,7 +255,7 @@ namespace VeraCrypt
#ifdef TC_WINDOWS #ifdef TC_WINDOWS
return wxBitmap (L"IDB_VOLUME_WIZARD_BITMAP", wxBITMAP_TYPE_BMP_RESOURCE); return wxBitmap (L"IDB_VOLUME_WIZARD_BITMAP", wxBITMAP_TYPE_BMP_RESOURCE);
#else #else
static const byte VolumeWizardIcon[] = static const uint8 VolumeWizardIcon[] =
{ {
# include "Format/VeraCrypt_Wizard.bmp.h" # include "Format/VeraCrypt_Wizard.bmp.h"
}; };

View File

@ -100,7 +100,7 @@ namespace VeraCrypt
finally_do ({ TextUserInterface::SetTerminalEcho (true); }); finally_do ({ TextUserInterface::SetTerminalEcho (true); });
wchar_t passwordBuf[4096]; wchar_t passwordBuf[4096];
finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <byte *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); }); finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <uint8 *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); });
shared_ptr<VolumePassword> password; shared_ptr<VolumePassword> password;
@ -1077,7 +1077,7 @@ namespace VeraCrypt
shared_ptr<TokenKeyfile> tokenKeyfile = Token::getTokenKeyfile(keyfilePath); shared_ptr<TokenKeyfile> tokenKeyfile = Token::getTokenKeyfile(keyfilePath);
vector <byte> keyfileData; vector <uint8> keyfileData;
tokenKeyfile->GetKeyfileData (keyfileData); tokenKeyfile->GetKeyfileData (keyfileData);
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
@ -1164,7 +1164,7 @@ namespace VeraCrypt
if (keyfile.Length() > 0) if (keyfile.Length() > 0)
{ {
vector <byte> keyfileData (keyfile.Length()); vector <uint8> keyfileData (keyfile.Length());
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
keyfile.ReadCompleteBuffer (keyfileDataBuf); keyfile.ReadCompleteBuffer (keyfileDataBuf);
@ -1784,7 +1784,7 @@ namespace VeraCrypt
while (randCharsRequired > 0) while (randCharsRequired > 0)
{ {
wstring randStr = AskString(); wstring randStr = AskString();
RandomNumberGenerator::AddToPool (ConstBufferPtr ((byte *) randStr.c_str(), randStr.size() * sizeof (wchar_t))); RandomNumberGenerator::AddToPool (ConstBufferPtr ((uint8 *) randStr.c_str(), randStr.size() * sizeof (wchar_t)));
randCharsRequired -= randStr.size(); randCharsRequired -= randStr.size();

View File

@ -108,7 +108,7 @@ namespace VeraCrypt
*TextOutStream << L"</VeraCrypt>" << endl; *TextOutStream << L"</VeraCrypt>" << endl;
wxStreamBuffer *buf = MemOutStream->GetOutputStreamBuffer(); wxStreamBuffer *buf = MemOutStream->GetOutputStreamBuffer();
OutFile.Write (ConstBufferPtr (reinterpret_cast <byte *> (buf->GetBufferStart()), buf->GetBufferSize())); OutFile.Write (ConstBufferPtr (reinterpret_cast <uint8 *> (buf->GetBufferStart()), buf->GetBufferSize()));
OutFile.Close(); OutFile.Close();
TextOutStream.reset(); TextOutStream.reset();

View File

@ -617,7 +617,7 @@ namespace VeraCrypt
XmlGetAttributeText (xml, "ID", label, sizeof (label)); XmlGetAttributeText (xml, "ID", label, sizeof (label));
if (strlen (label) == (2*VOLUME_ID_SIZE)) if (strlen (label) == (2*VOLUME_ID_SIZE))
{ {
std::vector<byte> arr; std::vector<uint8> arr;
if (HexWideStringToArray (Utf8StringToWide (label).c_str(), arr) && arr.size() == VOLUME_ID_SIZE) if (HexWideStringToArray (Utf8StringToWide (label).c_str(), arr) && arr.size() == VOLUME_ID_SIZE)
{ {
memcpy (favorite.VolumeID, &arr[0], VOLUME_ID_SIZE); memcpy (favorite.VolumeID, &arr[0], VOLUME_ID_SIZE);

Some files were not shown because too many files have changed in this diff Show More