mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-24 03:53:29 +01:00
Windows: reduce size of MBR bootloader by removing unused functions in each build type.
This commit is contained in:
parent
0fb2befe3a
commit
ff871511af
@ -19,17 +19,19 @@
|
|||||||
|
|
||||||
static int ScreenOutputDisabled = 0;
|
static int ScreenOutputDisabled = 0;
|
||||||
|
|
||||||
|
#if defined(TC_TRACE_INT13) || !defined(TC_WINDOWS_BOOT_RESCUE_DISK_MODE)
|
||||||
void DisableScreenOutput ()
|
void DisableScreenOutput ()
|
||||||
{
|
{
|
||||||
++ScreenOutputDisabled;
|
++ScreenOutputDisabled;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TC_TRACE_INT13
|
||||||
void EnableScreenOutput ()
|
void EnableScreenOutput ()
|
||||||
{
|
{
|
||||||
--ScreenOutputDisabled;
|
--ScreenOutputDisabled;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PrintChar (char c)
|
void PrintChar (char c)
|
||||||
{
|
{
|
||||||
|
@ -157,6 +157,7 @@ BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffs
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
|
||||||
|
|
||||||
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
@ -165,18 +166,19 @@ BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddr
|
|||||||
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 (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
|
return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
|
return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 §or, uint16 sectorCount, bool silent)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,7 @@ unsigned __int32 GetCrc32 (unsigned char *data, int length)
|
|||||||
return r ^ 0xFFFFFFFFUL;
|
return r ^ 0xFFFFFFFFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
BOOL crc32_selftests ()
|
BOOL crc32_selftests ()
|
||||||
{
|
{
|
||||||
unsigned __int8 testData[32];
|
unsigned __int8 testData[32];
|
||||||
@ -131,5 +132,6 @@ BOOL crc32_selftests ()
|
|||||||
|
|
||||||
return GetCrc32 (testData, sizeof (testData)) == 0x91267E8AUL;
|
return GetCrc32 (testData, sizeof (testData)) == 0x91267E8AUL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TC_MINIMIZE_CODE_SIZE
|
#endif // TC_MINIMIZE_CODE_SIZE
|
||||||
|
@ -393,17 +393,13 @@ const wchar_t *CipherGetName (int cipherId)
|
|||||||
Cipher* pCipher = CipherGet (cipherId);
|
Cipher* pCipher = CipherGet (cipherId);
|
||||||
return pCipher? pCipher -> Name : L"";
|
return pCipher? pCipher -> Name : L"";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int CipherGetBlockSize (int cipherId)
|
int CipherGetBlockSize (int cipherId)
|
||||||
{
|
{
|
||||||
#ifdef TC_WINDOWS_BOOT
|
|
||||||
return CipherGet (cipherId) -> BlockSize;
|
|
||||||
#else
|
|
||||||
Cipher* pCipher = CipherGet (cipherId);
|
Cipher* pCipher = CipherGet (cipherId);
|
||||||
return pCipher? pCipher -> BlockSize : 0;
|
return pCipher? pCipher -> BlockSize : 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int CipherGetKeySize (int cipherId)
|
int CipherGetKeySize (int cipherId)
|
||||||
{
|
{
|
||||||
@ -451,6 +447,7 @@ int EAGetFirst ()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TC_WINDOWS_BOOT
|
||||||
// Returns number of EAs
|
// Returns number of EAs
|
||||||
int EAGetCount (void)
|
int EAGetCount (void)
|
||||||
{
|
{
|
||||||
@ -462,6 +459,7 @@ int EAGetCount (void)
|
|||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int EAGetNext (int previousEA)
|
int EAGetNext (int previousEA)
|
||||||
{
|
{
|
||||||
@ -593,6 +591,8 @@ int EAGetKeySize (int ea)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TC_WINDOWS_BOOT
|
||||||
|
|
||||||
// Returns the first mode of operation of EA
|
// Returns the first mode of operation of EA
|
||||||
int EAGetFirstMode (int ea)
|
int EAGetFirstMode (int ea)
|
||||||
{
|
{
|
||||||
@ -612,9 +612,6 @@ int EAGetNextMode (int ea, int previousModeId)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
|
||||||
|
|
||||||
// Returns the name of the mode of operation of the whole EA
|
// Returns the name of the mode of operation of the whole EA
|
||||||
wchar_t *EAGetModeName (int ea, int mode, BOOL capitalLetters)
|
wchar_t *EAGetModeName (int ea, int mode, BOOL capitalLetters)
|
||||||
{
|
{
|
||||||
@ -645,38 +642,7 @@ int EAGetKeyScheduleSize (int ea)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TC_WINDOWS_BOOT
|
||||||
// Returns the largest key size needed by an EA for the specified mode of operation
|
|
||||||
int EAGetLargestKeyForMode (int mode)
|
|
||||||
{
|
|
||||||
int ea, key = 0;
|
|
||||||
|
|
||||||
for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea))
|
|
||||||
{
|
|
||||||
if (!EAIsModeSupported (ea, mode))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (EAGetKeySize (ea) >= key)
|
|
||||||
key = EAGetKeySize (ea);
|
|
||||||
}
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns the largest key needed by any EA for any mode
|
|
||||||
int EAGetLargestKey ()
|
|
||||||
{
|
|
||||||
int ea, key = 0;
|
|
||||||
|
|
||||||
for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea))
|
|
||||||
{
|
|
||||||
if (EAGetKeySize (ea) >= key)
|
|
||||||
key = EAGetKeySize (ea);
|
|
||||||
}
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns number of ciphers in EA
|
// Returns number of ciphers in EA
|
||||||
int EAGetCipherCount (int ea)
|
int EAGetCipherCount (int ea)
|
||||||
@ -687,6 +653,7 @@ int EAGetCipherCount (int ea)
|
|||||||
return i - 1;
|
return i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
int EAGetFirstCipher (int ea)
|
int EAGetFirstCipher (int ea)
|
||||||
{
|
{
|
||||||
@ -732,18 +699,16 @@ int EAGetPreviousCipher (int ea, int previousCipherId)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TC_WINDOWS_BOOT
|
||||||
int EAIsFormatEnabled (int ea)
|
int EAIsFormatEnabled (int ea)
|
||||||
{
|
{
|
||||||
return EncryptionAlgorithms[ea].FormatEnabled;
|
return EncryptionAlgorithms[ea].FormatEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
|
||||||
int EAIsMbrSysEncEnabled (int ea)
|
int EAIsMbrSysEncEnabled (int ea)
|
||||||
{
|
{
|
||||||
return EncryptionAlgorithms[ea].MbrSysEncEnabled;
|
return EncryptionAlgorithms[ea].MbrSysEncEnabled;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Returns TRUE if the mode of operation is supported for the encryption algorithm
|
// Returns TRUE if the mode of operation is supported for the encryption algorithm
|
||||||
BOOL EAIsModeSupported (int ea, int testedMode)
|
BOOL EAIsModeSupported (int ea, int testedMode)
|
||||||
@ -758,7 +723,6 @@ BOOL EAIsModeSupported (int ea, int testedMode)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
|
||||||
Hash *HashGet (int id)
|
Hash *HashGet (int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -810,6 +774,22 @@ BOOL HashForSystemEncryption (int hashId)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the largest key size needed by an EA for the specified mode of operation
|
||||||
|
int EAGetLargestKeyForMode (int mode)
|
||||||
|
{
|
||||||
|
int ea, key = 0;
|
||||||
|
|
||||||
|
for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea))
|
||||||
|
{
|
||||||
|
if (!EAIsModeSupported (ea, mode))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (EAGetKeySize (ea) >= key)
|
||||||
|
key = EAGetKeySize (ea);
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the maximum number of bytes necessary to be generated by the PBKDF2 (PKCS #5)
|
// Returns the maximum number of bytes necessary to be generated by the PBKDF2 (PKCS #5)
|
||||||
int GetMaxPkcs5OutSize (void)
|
int GetMaxPkcs5OutSize (void)
|
||||||
{
|
{
|
||||||
|
@ -354,8 +354,8 @@ int EAGetFirstCipher (int ea);
|
|||||||
int EAGetLastCipher (int ea);
|
int EAGetLastCipher (int ea);
|
||||||
int EAGetNextCipher (int ea, int previousCipherId);
|
int EAGetNextCipher (int ea, int previousCipherId);
|
||||||
int EAGetPreviousCipher (int ea, int previousCipherId);
|
int EAGetPreviousCipher (int ea, int previousCipherId);
|
||||||
int EAIsFormatEnabled (int ea);
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
|
int EAIsFormatEnabled (int ea);
|
||||||
int EAIsMbrSysEncEnabled (int ea);
|
int EAIsMbrSysEncEnabled (int ea);
|
||||||
#endif
|
#endif
|
||||||
BOOL EAIsModeSupported (int ea, int testedMode);
|
BOOL EAIsModeSupported (int ea, int testedMode);
|
||||||
|
@ -43,17 +43,3 @@ uint64 MirrorBytes64 (uint64 x)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
LongReverse (unsigned __int32 *buffer, unsigned byteCount)
|
|
||||||
{
|
|
||||||
unsigned __int32 value;
|
|
||||||
|
|
||||||
byteCount /= sizeof (unsigned __int32);
|
|
||||||
while (byteCount--)
|
|
||||||
{
|
|
||||||
value = *buffer;
|
|
||||||
value = ((value & 0xFF00FF00L) >> 8) | \
|
|
||||||
((value & 0x00FF00FFL) << 8);
|
|
||||||
*buffer++ = (value << 16) | (value >> 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -140,7 +140,6 @@ unsigned __int32 MirrorBytes32 (unsigned __int32 x);
|
|||||||
#ifndef TC_NO_COMPILER_INT64
|
#ifndef TC_NO_COMPILER_INT64
|
||||||
uint64 MirrorBytes64 (uint64 x);
|
uint64 MirrorBytes64 (uint64 x);
|
||||||
#endif
|
#endif
|
||||||
void LongReverse ( unsigned __int32 *buffer , unsigned byteCount );
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
@ -36,18 +36,6 @@
|
|||||||
#include "Pkcs5.h"
|
#include "Pkcs5.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
|
|
||||||
void hmac_truncate
|
|
||||||
(
|
|
||||||
char *d1, /* data to be truncated */
|
|
||||||
char *d2, /* truncated data */
|
|
||||||
int len /* length in bytes to keep */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
d2[i] = d1[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(TC_WINDOWS_BOOT) || defined(TC_WINDOWS_BOOT_SHA2)
|
#if !defined(TC_WINDOWS_BOOT) || defined(TC_WINDOWS_BOOT_SHA2)
|
||||||
|
|
||||||
typedef struct hmac_sha256_ctx_struct
|
typedef struct hmac_sha256_ctx_struct
|
||||||
|
Loading…
Reference in New Issue
Block a user