From 8ebf5ac605d57eab80b600a7827d2ba48668d887 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Tue, 26 May 2015 01:36:20 +0200 Subject: Windows: first implementation of dynamic mode --- src/Common/Apidrvr.h | 3 ++ src/Common/BootEncryption.cpp | 16 ++++++----- src/Common/BootEncryption.h | 6 ++-- src/Common/Cache.c | 6 ++-- src/Common/Cache.h | 2 +- src/Common/Common.h | 1 + src/Common/Crypto.h | 1 + src/Common/Dlgcode.c | 39 +++++++++++++++++++------ src/Common/Dlgcode.h | 7 +++-- src/Common/Format.c | 4 ++- src/Common/Format.h | 1 + src/Common/Language.xml | 5 ++++ src/Common/Password.c | 21 ++++++++++++-- src/Common/Password.h | 7 +++-- src/Common/Pkcs5.c | 67 ++++++++++++++++++++++++++++--------------- src/Common/Pkcs5.h | 10 +++---- src/Common/Volumes.c | 21 ++++++++------ src/Common/Volumes.h | 6 ++-- 18 files changed, 152 insertions(+), 71 deletions(-) (limited to 'src/Common') diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index 83d30595..d168cf74 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -104,6 +104,8 @@ typedef struct int ProtectedHidVolPkcs5Prf; BOOL bTrueCryptMode; uint32 BytesPerPhysicalSector; + int VolumePin; + int ProtectedHidVolPin; } MOUNT_STRUCT; typedef struct @@ -241,6 +243,7 @@ typedef struct { Password VolumePassword; int pkcs5_prf; + int pin; } ReopenBootVolumeHeaderRequest; diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 3678bc71..9f080f18 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -1737,21 +1737,21 @@ namespace VeraCrypt #ifndef SETUP - void BootEncryption::CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5) + void BootEncryption::CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pin) { PCRYPTO_INFO cryptoInfo = NULL; if (!IsRandomNumberGeneratorStarted()) throw ParameterIncorrect (SRC_POS); - throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, NULL, &cryptoInfo, + throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, pin, NULL, &cryptoInfo, volumeSize, 0, encryptedAreaStart, 0, TC_SYSENC_KEYSCOPE_MIN_REQ_PROG_VERSION, TC_HEADER_FLAG_ENCRYPTED_SYSTEM, TC_SECTOR_SIZE_BIOS, FALSE) != 0); finally_do_arg (PCRYPTO_INFO*, &cryptoInfo, { crypto_close (*finally_arg); }); // Initial rescue disk assumes encryption of the drive has been completed (EncryptedAreaLength == volumeSize) memcpy (RescueVolumeHeader, VolumeHeader, sizeof (RescueVolumeHeader)); - if (0 != ReadVolumeHeader (TRUE, (char *) RescueVolumeHeader, password, pkcs5, FALSE, NULL, cryptoInfo)) + if (0 != ReadVolumeHeader (TRUE, (char *) RescueVolumeHeader, password, pkcs5, pin, FALSE, NULL, cryptoInfo)) throw ParameterIncorrect (SRC_POS); DecryptBuffer (RescueVolumeHeader + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); @@ -2234,7 +2234,7 @@ namespace VeraCrypt } - int BootEncryption::ChangePassword (Password *oldPassword, int old_pkcs5,Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg) + int BootEncryption::ChangePassword (Password *oldPassword, int old_pkcs5, int old_pin, Password *newPassword, int pkcs5, int pin, int wipePassCount, HWND hwndDlg) { BootEncryptionStatus encStatus = GetStatus(); @@ -2277,7 +2277,7 @@ namespace VeraCrypt PCRYPTO_INFO cryptoInfo = NULL; - int status = ReadVolumeHeader (!encStatus.HiddenSystem, header, oldPassword, old_pkcs5, FALSE, &cryptoInfo, NULL); + int status = ReadVolumeHeader (!encStatus.HiddenSystem, header, oldPassword, old_pkcs5, old_pin, FALSE, &cryptoInfo, NULL); finally_do_arg (PCRYPTO_INFO, cryptoInfo, { if (finally_arg) crypto_close (finally_arg); }); if (status != 0) @@ -2339,6 +2339,7 @@ namespace VeraCrypt cryptoInfo->mode, newPassword, cryptoInfo->pkcs5, + pin, (char *) cryptoInfo->master_keydata, &tmpCryptoInfo, cryptoInfo->VolumeSize.Value, @@ -2382,6 +2383,7 @@ namespace VeraCrypt ReopenBootVolumeHeaderRequest reopenRequest; reopenRequest.VolumePassword = *newPassword; reopenRequest.pkcs5_prf = cryptoInfo->pkcs5; + reopenRequest.pin = pin; finally_do_arg (ReopenBootVolumeHeaderRequest*, &reopenRequest, { burn (finally_arg, sizeof (*finally_arg)); }); CallDriver (TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER, &reopenRequest, sizeof (reopenRequest)); @@ -2442,7 +2444,7 @@ namespace VeraCrypt } - void BootEncryption::PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, const string &rescueIsoImagePath) + void BootEncryption::PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pin, const string &rescueIsoImagePath) { BootEncryptionStatus encStatus = GetStatus(); if (encStatus.DriveMounted) @@ -2495,7 +2497,7 @@ namespace VeraCrypt SelectedEncryptionAlgorithmId = ea; SelectedPrfAlgorithmId = pkcs5; - CreateVolumeHeader (volumeSize, encryptedAreaStart, &password, ea, mode, pkcs5); + CreateVolumeHeader (volumeSize, encryptedAreaStart, &password, ea, mode, pkcs5, pin); if (!rescueIsoImagePath.empty()) CreateRescueIsoImage (true, rescueIsoImagePath); diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h index 3665a9bc..a73ce6fc 100644 --- a/src/Common/BootEncryption.h +++ b/src/Common/BootEncryption.h @@ -144,7 +144,7 @@ namespace VeraCrypt void AbortSetup (); void AbortSetupWait (); void CallDriver (DWORD ioctl, void *input = nullptr, DWORD inputSize = 0, void *output = nullptr, DWORD outputSize = 0); - int ChangePassword (Password *oldPassword, int old_pkcs5, Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg); + int ChangePassword (Password *oldPassword, int old_pkcs5, int old_pin, Password *newPassword, int pkcs5, int pin, int wipePassCount, HWND hwndDlg); void CheckDecoyOSWipeResult (); void CheckEncryptionSetupResult (); void CheckRequirements (); @@ -170,7 +170,7 @@ namespace VeraCrypt bool IsHiddenSystemRunning (); bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); void PrepareHiddenOSCreation (int ea, int mode, int pkcs5); - void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, const string &rescueIsoImagePath); + void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pin, const string &rescueIsoImagePath); void ProbeRealSystemDriveSize (); void ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr); uint32 ReadDriverConfigurationFlags (); @@ -204,7 +204,7 @@ namespace VeraCrypt void BackupSystemLoader (); void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false); - void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5); + void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pin); string GetSystemLoaderBackupPath (); uint32 GetChecksum (byte *data, size_t size); DISK_GEOMETRY GetDriveGeometry (int driveNumber); diff --git a/src/Common/Cache.c b/src/Common/Cache.c index 33043f78..f4489ccf 100644 --- a/src/Common/Cache.c +++ b/src/Common/Cache.c @@ -21,7 +21,7 @@ Password CachedPasswords[CACHE_SIZE]; int cacheEmpty = 1; static int nPasswordIdx = 0; -int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, char *header, Password *password, int pkcs5_prf, BOOL truecryptMode, PCRYPTO_INFO *retInfo) +int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, char *header, Password *password, int pkcs5_prf, int pin, BOOL truecryptMode, PCRYPTO_INFO *retInfo) { int nReturnCode = ERR_PASSWORD_WRONG; int i; @@ -29,7 +29,7 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, char *header, Password *pas /* Attempt to recognize volume using mount password */ if (password->Length > 0) { - nReturnCode = ReadVolumeHeader (bBoot, header, password, pkcs5_prf, truecryptMode, retInfo, NULL); + nReturnCode = ReadVolumeHeader (bBoot, header, password, pkcs5_prf, pin, truecryptMode, retInfo, NULL); /* Save mount passwords back into cache if asked to do so */ if (bCache && (nReturnCode == 0 || nReturnCode == ERR_CIPHER_INIT_WEAK_KEY)) @@ -59,7 +59,7 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, char *header, Password *pas { if (CachedPasswords[i].Length > 0) { - nReturnCode = ReadVolumeHeader (bBoot, header, &CachedPasswords[i], pkcs5_prf, truecryptMode, retInfo, NULL); + nReturnCode = ReadVolumeHeader (bBoot, header, &CachedPasswords[i], pkcs5_prf, pin, truecryptMode, retInfo, NULL); if (nReturnCode != ERR_PASSWORD_WRONG) break; diff --git a/src/Common/Cache.h b/src/Common/Cache.h index 10f120b0..bdd96e98 100644 --- a/src/Common/Cache.h +++ b/src/Common/Cache.h @@ -19,5 +19,5 @@ extern int cacheEmpty; void AddPasswordToCache (Password *password); -int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, char *header, Password *password, int pkcs5_prf, BOOL truecryptMode, PCRYPTO_INFO *retInfo); +int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, char *header, Password *password, int pkcs5_prf, int pin, BOOL truecryptMode, PCRYPTO_INFO *retInfo); void WipeCache (void); diff --git a/src/Common/Common.h b/src/Common/Common.h index 3e68f402..5893a268 100644 --- a/src/Common/Common.h +++ b/src/Common/Common.h @@ -76,6 +76,7 @@ typedef struct BOOL UseBackupHeader; BOOL RecoveryMode; int ProtectedHidVolPkcs5Prf; + int ProtectedHidVolPin; } MountOptions; #endif diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h index 208e72a1..038e5430 100644 --- a/src/Common/Crypto.h +++ b/src/Common/Crypto.h @@ -197,6 +197,7 @@ typedef struct CRYPTO_INFO_t int ea; /* Encryption algorithm ID */ int mode; /* Mode of operation (e.g., XTS) */ int pkcs5; /* PRF algorithm */ + unsigned __int8 ks[MAX_EXPANDED_KEY]; /* Primary key schedule (if it is a cascade, it conatins multiple concatenated keys) */ unsigned __int8 ks2[MAX_EXPANDED_KEY]; /* Secondary key schedule (if cascade, multiple concatenated) for XTS mode. */ diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index a6700e29..5cf6dbaf 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -4680,22 +4680,22 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) case SHA512: /* PKCS-5 test with HMAC-SHA-512 used as the PRF */ - derive_key_sha512 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); + derive_key_sha512 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, 0, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); break; case SHA256: /* PKCS-5 test with HMAC-SHA-256 used as the PRF */ - derive_key_sha256 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); + derive_key_sha256 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, 0, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); break; case RIPEMD160: /* PKCS-5 test with HMAC-RIPEMD-160 used as the PRF */ - derive_key_ripemd160 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); + derive_key_ripemd160 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, 0, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); break; case WHIRLPOOL: /* PKCS-5 test with HMAC-Whirlpool used as the PRF */ - derive_key_whirlpool ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); + derive_key_whirlpool ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, 0, FALSE, FALSE), dk, MASTER_KEYDATA_SIZE); break; } } @@ -6522,6 +6522,7 @@ int MountVolume (HWND hwndDlg, char *volumePath, Password *password, int pkcs5, + int pin, BOOL truecryptMode, BOOL cachePassword, BOOL sharedAccess, @@ -6584,6 +6585,7 @@ retry: mount.ProtectedHidVolPassword = mountOptions->ProtectedHidVolPassword; mount.bProtectHiddenVolume = TRUE; mount.ProtectedHidVolPkcs5Prf = mountOptions->ProtectedHidVolPkcs5Prf; + mount.ProtectedHidVolPin = mountOptions->ProtectedHidVolPin; } else mount.bProtectHiddenVolume = FALSE; @@ -6595,6 +6597,7 @@ retry: mount.bMountManager = TRUE; mount.pkcs5_prf = pkcs5; mount.bTrueCryptMode = truecryptMode; + mount.VolumePin = pin; // Windows 2000 mount manager causes problems with remounted volumes if (CurrentOSMajor == 5 && CurrentOSMinor == 0) @@ -7315,7 +7318,7 @@ int64 FindString (const char *buf, const char *str, int64 bufLen, int64 strLen, for (int64 i = startOffset; i <= bufLen - strLen; i++) { - if (memcmp (buf + i, str, strLen) == 0) + if (memcmp (buf + i, str, (size_t) strLen) == 0) return i; } @@ -8803,6 +8806,9 @@ BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack) BOOL Is64BitOs () { +#ifdef _WIN64 + return TRUE; +#else static BOOL isWow64 = FALSE; static BOOL valid = FALSE; typedef BOOL (__stdcall *LPFN_ISWOW64PROCESS ) (HANDLE hProcess,PBOOL Wow64Process); @@ -8819,6 +8825,7 @@ BOOL Is64BitOs () valid = TRUE; return isWow64; +#endif } @@ -9247,7 +9254,7 @@ void ReportUnexpectedState (char *techInfo) #ifndef SETUP -int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader) +int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, int pin, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader) { int status = ERR_PARAMETER_INCORRECT; int volumeType; @@ -9397,7 +9404,7 @@ int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *pa } // Decrypt volume header - status = ReadVolumeHeader (FALSE, buffer, password, pkcs5_prf, truecryptMode, &context->CryptoInfo, NULL); + status = ReadVolumeHeader (FALSE, buffer, password, pkcs5_prf, pin, truecryptMode, &context->CryptoInfo, NULL); if (status == ERR_PASSWORD_WRONG) continue; // Try next volume type @@ -9442,7 +9449,7 @@ void CloseVolume (OpenVolumeContext *context) } -int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, BOOL wipeMode) +int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pin, BOOL wipeMode) { CRYPTO_INFO *newCryptoInfo = NULL; @@ -9464,6 +9471,7 @@ int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO * cryptoInfo->mode, password, cryptoInfo->pkcs5, + pin, (char *) cryptoInfo->master_keydata, &newCryptoInfo, cryptoInfo->VolumeSize.Value, @@ -10693,3 +10701,18 @@ std::string FindLatestFileOrDirectory (const std::string &directory, const char return string (directory) + "\\" + name; } + +int GetPin (HWND hwndDlg, UINT ctrlId) +{ + int pin = 0; + char szTmp[MAX_PIN + 1] = {0}; + GetDlgItemText (hwndDlg, ctrlId, szTmp, MAX_PIN + 1); + if (strlen(szTmp)) + { + char* endPtr = NULL; + pin = strtol(szTmp, &endPtr, 0); + if (pin < 0 || endPtr == szTmp || !endPtr || *endPtr != '\0') + pin = 0; + } + return pin; +} diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index e45a9b87..1fd12d40 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -332,7 +332,7 @@ BOOL IsDriveAvailable (int driveNo); BOOL IsDeviceMounted (char *deviceName); int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced); void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap); -int MountVolume (HWND hwndDlg, int driveNo, char *volumePath, Password *password, int pkcs5, BOOL truecryptMode, BOOL cachePassword, BOOL sharedAccess, const MountOptions* const mountOptions, BOOL quiet, BOOL bReportWrongPassword); +int MountVolume (HWND hwndDlg, int driveNo, char *volumePath, Password *password, int pkcs5, int pin, BOOL truecryptMode, BOOL cachePassword, BOOL sharedAccess, const MountOptions* const mountOptions, BOOL quiet, BOOL bReportWrongPassword); BOOL UnmountVolume (HWND hwndDlg , int nDosDriveNo, BOOL forceUnmount); BOOL IsPasswordCacheEmpty (void); BOOL IsMountedVolume (const char *volname); @@ -459,9 +459,9 @@ void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT h BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize); BOOL GetSysDevicePaths (HWND hwndDlg); BOOL DoDriverInstall (HWND hwndDlg); -int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader); +int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, int pin, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader); void CloseVolume (OpenVolumeContext *context); -int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, BOOL wipeMode); +int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pin, BOOL wipeMode); BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); BOOL IsPagingFileWildcardActive (); BOOL DisablePagingFile (); @@ -480,6 +480,7 @@ BOOL VolumePathExists (const char *volumePath); BOOL IsWindowsIsoBurnerAvailable (); BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath); BOOL IsApplicationInstalled (const char *appName); +int GetPin (HWND hwndDlg, UINT ctrlId); #ifdef __cplusplus } diff --git a/src/Common/Format.c b/src/Common/Format.c index 54dddf64..37fa38da 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -146,6 +146,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) FIRST_MODE_OF_OPERATION_ID, volParams->password, volParams->pkcs5, + volParams->pin, NULL, &cryptoInfo, dataAreaSize, @@ -538,6 +539,7 @@ begin_format: FIRST_MODE_OF_OPERATION_ID, volParams->password, volParams->pkcs5, + volParams->pin, cryptoInfo->master_keydata, &cryptoInfo, dataAreaSize, @@ -624,7 +626,7 @@ error: mountOptions.PartitionInInactiveSysEncScope = FALSE; mountOptions.UseBackupHeader = FALSE; - if (MountVolume (volParams->hwndDlg, driveNo, volParams->volumePath, volParams->password, volParams->pkcs5, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) + if (MountVolume (volParams->hwndDlg, driveNo, volParams->volumePath, volParams->password, volParams->pkcs5, volParams->pin, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1) { MessageBoxW (volParams->hwndDlg, GetString ("CANT_MOUNT_VOLUME"), lpszTitle, ICON_HAND); MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND); diff --git a/src/Common/Format.h b/src/Common/Format.h index 584d98d9..c636e3a6 100644 --- a/src/Common/Format.h +++ b/src/Common/Format.h @@ -39,6 +39,7 @@ typedef struct int sectorSize; int *realClusterSize; Password *password; + int pin; HWND hwndDlg; } FORMAT_VOL_PARAMETERS; diff --git a/src/Common/Language.xml b/src/Common/Language.xml index 3feb51dd..9ae289d9 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -612,6 +612,8 @@ Incorrect password/PRF or no valid volume found. Incorrect keyfile(s)/password/PRF or no valid volume found. \n\nWarning: Caps Lock is on. This may cause you to enter your password incorrectly. + You have chosen a Personal Iteration Number (PIN) that is smaller than the default VeraCrypt value. Please note that if your password is not strong enough, this could lead to a weaker security.\n\nDo you confirm that you are using a strong password? + Personal Iteration Number (PIN) maximum value for system encryption is 65535. \n\nWARNING: Hidden file(s) have been found in a keyfile search path. Such hidden files cannot be used as keyfiles. If you need to use them as keyfiles, remove their 'Hidden' attribute (right-click each of them, select 'Properties', uncheck 'Hidden' and click OK). Note: Hidden files are visible only if the corresponding option is enabled (Computer > Organize > 'Folder and search options' > View). If you are attempting to protect a hidden volume containing a hidden system, please make sure you are using the standard US keyboard layout when typing the password for the hidden volume. This is required due to the fact that the password needs to be typed in the pre-boot environment (before Windows starts) where non-US Windows keyboard layouts are not available. VeraCrypt has not found any volume where the process of encryption/decryption of a non-system volume has been interrupted and where the volume header can be deciphered using the supplied password and/or keyfile(s).\n\nPlease make sure the password and/or keyfile(s) are correct and that the partition/volume is not being used by the system or applications (including antivirus software). @@ -1062,6 +1064,9 @@ Warning: There is unallocated space between the system partition and the first partition behind it. After you create the hidden operating system, you must not create any new partitions in that unallocated space. Otherwise, the hidden operating system will be impossible to boot (until you delete such newly created partitions). This algorithm is currently not supported for system encryption. This algorithm is not supported for TrueCrypt mode. + PIN (Personal Iteration Count) not supported for TrueCrypt mode. + Password must contain more than 20 characters in order to use the specified PIN.\nShorter passwords can only be used if the PIN is greater than 485. + Pre-boot authentication Password must contain more than 20 characters in order to use the specified PIN.\nShorter passwords can only be used if the PIN is greater than 98. Keyfiles are currently not supported for system encryption. Warning: VeraCrypt could not restore the original keyboard layout. This may cause you to enter a password incorrectly. Error: Cannot set the keyboard layout for VeraCrypt to the standard US keyboard layout.\n\nNote that the password needs to be typed in the pre-boot environment (before Windows starts) where non-US Windows keyboard layouts are not available. Therefore, the password must always be typed using the standard US keyboard layout. diff --git a/src/Common/Password.c b/src/Common/Password.c index 8014713c..63b099b4 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -107,19 +107,33 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw) } -BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem) +BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem, int pin, BOOL bForBoot) { + BOOL bCustomPinSmall = ((pin != 0) && (pin < (bForBoot? 98 : 485)))? TRUE : FALSE; if (GetWindowTextLength (hwndItem) < PASSWORD_LEN_WARNING) { + if (bCustomPinSmall) + { + Error (bForBoot? "BOOT_PIN_REQUIRE_LONG_PASSWORD": "PIN_REQUIRE_LONG_PASSWORD", hwndDlg); + return FALSE; + } + #ifndef _DEBUG if (MessageBoxW (hwndDlg, GetString ("PASSWORD_LENGTH_WARNING"), lpszTitle, MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2) != IDYES) return FALSE; #endif } +#ifndef _DEBUG + else if (bCustomPinSmall) + { + if (MessageBoxW (hwndDlg, GetString ("PIN_SMALL_WARNING"), lpszTitle, MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2) != IDYES) + return FALSE; + } +#endif return TRUE; } -int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, BOOL truecryptMode, Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg) +int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pin, BOOL truecryptMode, Password *newPassword, int pkcs5, int pin, int wipePassCount, HWND hwndDlg) { int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR; char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH]; @@ -287,7 +301,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, BOO /* Try to decrypt the header */ - nStatus = ReadVolumeHeader (FALSE, buffer, oldPassword, old_pkcs5, truecryptMode, &cryptoInfo, NULL); + nStatus = ReadVolumeHeader (FALSE, buffer, oldPassword, old_pkcs5, old_pin, truecryptMode, &cryptoInfo, NULL); if (nStatus == ERR_CIPHER_INIT_WEAK_KEY) nStatus = 0; // We can ignore this error here @@ -353,6 +367,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, BOO cryptoInfo->mode, newPassword, cryptoInfo->pkcs5, + pin, cryptoInfo->master_keydata, &ci, cryptoInfo->VolumeSize.Value, diff --git a/src/Common/Password.h b/src/Common/Password.h index 62fe23a7..5ccc44b3 100644 --- a/src/Common/Password.h +++ b/src/Common/Password.h @@ -15,6 +15,9 @@ // User text input limits #define MIN_PASSWORD 1 // Minimum possible password length #define MAX_PASSWORD 64 // Maximum possible password length +#define MAX_PIN 10 // Maximum allowed digits in a PIN (enough for 32-bit value) +#define MAX_BOOT_PIN 5 // Maximum allowed digits in a PIN for boot (enough for 16-bit value) +#define MAX_BOOT_PIN_VALUE 65535 #define PASSWORD_LEN_WARNING 20 // Display a warning when a password is shorter than this @@ -33,9 +36,9 @@ typedef struct #if defined(_WIN32) && !defined(TC_WINDOWS_DRIVER) void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled ); -BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem); +BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem, int pin, BOOL bForBoot); BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw); -int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, BOOL truecryptMode, Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg); +int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pin, BOOL truecryptMode, Password *newPassword, int pkcs5, int pin, int wipePassCount, HWND hwndDlg); #endif // defined(_WIN32) && !defined(TC_WINDOWS_DRIVER) diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c index 6585704c..adce567b 100644 --- a/src/Common/Pkcs5.c +++ b/src/Common/Pkcs5.c @@ -120,7 +120,7 @@ void hmac_sha256 } #endif -static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, int b, hmac_sha256_ctx* hmac) +static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, int b, hmac_sha256_ctx* hmac) { char* k = hmac->k; char* u = hmac->u; @@ -128,13 +128,16 @@ static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, i int i; #ifdef TC_WINDOWS_BOOT - /* In bootloader, iterations is a boolean : TRUE for boot derivation mode, FALSE otherwise + /* In bootloader mode, least significant bit of iterations is a boolean (TRUE for boot derivation mode, FALSE otherwise) + * and the most significant 16 bits hold the pin value * This enables us to save code space needed for implementing other features. */ - if (iterations) - c = 200000; + c = iterations >> 16; + i = ((int) iterations) & 0x01; + if (i) + c = (c == 0)? 200000 : c << 11; else - c = 500000; + c = (c == 0)? 500000 : 15000 + c * 1000; #else c = iterations; #endif @@ -162,7 +165,7 @@ static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, i } -void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, int 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) { hmac_sha256_ctx hmac; int b, l, r; @@ -305,11 +308,11 @@ void hmac_sha512 burn (key, sizeof(key)); } -static void derive_u_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, int b, hmac_sha512_ctx* hmac) +static void derive_u_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, int b, hmac_sha512_ctx* hmac) { char* k = hmac->k; char* u = hmac->u; - int c, i; + uint32 c, i; /* iteration 1 */ memcpy (k, salt, salt_len); /* salt */ @@ -332,7 +335,7 @@ static void derive_u_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, i } -void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int 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) { hmac_sha512_ctx hmac; int b, l, r; @@ -471,7 +474,7 @@ void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len) #endif -static void derive_u_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, int b, hmac_ripemd160_ctx* hmac) +static void derive_u_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, int b, hmac_ripemd160_ctx* hmac) { char* k = hmac->k; char* u = hmac->u; @@ -479,13 +482,16 @@ static void derive_u_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len int i; #ifdef TC_WINDOWS_BOOT - /* In bootloader, iterations is a boolean : TRUE for boot derivation mode, FALSE otherwise + /* In bootloader mode, least significant bit of iterations is a boolean (TRUE for boot derivation mode, FALSE otherwise) + * and the most significant 16 bits hold the pin value * This enables us to save code space needed for implementing other features. */ - if (iterations) - c = 327661; + c = iterations >> 16; + i = ((int) iterations) & 0x01; + if (i) + c = (c == 0)? 327661 : c << 11; else - c = 655331; + c = (c == 0)? 655331 : 15000 + c * 1000; #else c = iterations; #endif @@ -512,7 +518,7 @@ static void derive_u_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len } } -void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen) +void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) { int b, l, r; hmac_ripemd160_ctx hmac; @@ -651,11 +657,11 @@ void hmac_whirlpool burn(&hmac, sizeof(hmac)); } -static void derive_u_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, int b, hmac_whirlpool_ctx* hmac) +static void derive_u_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, int b, hmac_whirlpool_ctx* hmac) { char* u = hmac->u; char* k = hmac->k; - int c, i; + uint32 c, i; /* iteration 1 */ memcpy (k, salt, salt_len); /* salt */ @@ -677,7 +683,7 @@ static void derive_u_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len } } -void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen) +void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) { hmac_whirlpool_ctx hmac; char key[WHIRLPOOL_DIGESTSIZE]; @@ -751,28 +757,43 @@ char *get_pkcs5_prf_name (int pkcs5_prf_id) -int get_pkcs5_iteration_count (int pkcs5_prf_id, BOOL truecryptMode, BOOL bBoot) +int get_pkcs5_iteration_count (int pkcs5_prf_id, int pin, BOOL truecryptMode, BOOL bBoot) { + if ( (pin < 0) + || (truecryptMode && pin > 0) /* No PIN for TrueCrypt mode */ + ) + { + return 0; + } + switch (pkcs5_prf_id) { case RIPEMD160: if (truecryptMode) return bBoot ? 1000 : 2000; - else + else if (pin == 0) return bBoot? 327661 : 655331; + else + { + return bBoot? pin * 2048 : 15000 + pin * 1000; + } case SHA512: - return truecryptMode? 1000 : 500000; + return truecryptMode? 1000 : ((pin == 0)? 500000 : 15000 + pin * 1000); case WHIRLPOOL: - return truecryptMode? 1000 : 500000; + return truecryptMode? 1000 : ((pin == 0)? 500000 : 15000 + pin * 1000); case SHA256: if (truecryptMode) return 0; // SHA-256 not supported by TrueCrypt - else + else if (pin == 0) return bBoot? 200000 : 500000; + else + { + return bBoot? pin * 2048 : 15000 + pin * 1000; + } default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h index ef931397..d1dca7e3 100644 --- a/src/Common/Pkcs5.h +++ b/src/Common/Pkcs5.h @@ -20,21 +20,21 @@ extern "C" #endif /* output written to d which must be at lease 32 bytes long */ void hmac_sha256 (char *k, int lk, char *d, int ld); -void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, int 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); /* output written to d which must be at lease 64 bytes long */ void hmac_sha512 (char *k, int lk, char *d, int ld); -void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int 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); /* output written to input_digest which must be at lease 20 bytes long */ void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len); -void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen); +void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); /* output written to d which must be at lease 64 bytes long */ void hmac_whirlpool (char *k, int lk, char *d, int ld); -void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen); +void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); -int get_pkcs5_iteration_count (int pkcs5_prf_id, BOOL truecryptMode, BOOL bBoot); +int get_pkcs5_iteration_count (int pkcs5_prf_id, int pin, BOOL truecryptMode, BOOL bBoot); char *get_pkcs5_prf_name (int pkcs5_prf_id); #if defined(__cplusplus) diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index 73598c64..567df7ee 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -163,7 +163,7 @@ typedef struct BOOL ReadVolumeHeaderRecoveryMode = FALSE; -int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int selected_pkcs5_prf, BOOL truecryptMode, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) +int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int selected_pkcs5_prf, int pin, BOOL truecryptMode, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) { char header[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; KEY_INFO keyInfo; @@ -274,7 +274,7 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int EncryptionThreadPoolBeginKeyDerivation (&keyDerivationCompletedEvent, &noOutstandingWorkItemEvent, &item->KeyReady, &outstandingWorkItemCount, enqPkcs5Prf, keyInfo.userKey, - keyInfo.keyLength, keyInfo.salt, get_pkcs5_iteration_count (enqPkcs5Prf, truecryptMode, bBoot), item->DerivedKey); + keyInfo.keyLength, keyInfo.salt, get_pkcs5_iteration_count (enqPkcs5Prf, pin, truecryptMode, bBoot), item->DerivedKey); ++queuedWorkItems; break; @@ -296,7 +296,7 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int if (!item->Free && InterlockedExchangeAdd (&item->KeyReady, 0) == TRUE) { pkcs5_prf = item->Pkcs5Prf; - keyInfo.noIterations = get_pkcs5_iteration_count (pkcs5_prf, truecryptMode, bBoot); + keyInfo.noIterations = get_pkcs5_iteration_count (pkcs5_prf, pin, truecryptMode, bBoot); memcpy (dk, item->DerivedKey, sizeof (dk)); item->Free = TRUE; @@ -314,7 +314,7 @@ KeyReady: ; else { pkcs5_prf = enqPkcs5Prf; - keyInfo.noIterations = get_pkcs5_iteration_count (enqPkcs5Prf, truecryptMode, bBoot); + keyInfo.noIterations = get_pkcs5_iteration_count (enqPkcs5Prf, pin, truecryptMode, bBoot); switch (pkcs5_prf) { @@ -578,7 +578,7 @@ ret: #else // TC_WINDOWS_BOOT -int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) +int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pin, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) { #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE char dk[32 * 2]; // 2 * 256-bit key @@ -588,6 +588,9 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, PCRYPTO_INFO PCRYPTO_INFO cryptoInfo; int status = ERR_SUCCESS; + uint32 iterations = pin; + iterations <<= 16; + iterations |= bBoot; if (retHeaderCryptoInfo != NULL) cryptoInfo = retHeaderCryptoInfo; @@ -597,10 +600,10 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, PCRYPTO_INFO // PKCS5 PRF #ifdef TC_WINDOWS_BOOT_SHA2 derive_key_sha256 (password->Text, (int) password->Length, header + HEADER_SALT_OFFSET, - PKCS5_SALT_SIZE, bBoot, dk, sizeof (dk)); + PKCS5_SALT_SIZE, iterations, dk, sizeof (dk)); #else derive_key_ripemd160 (password->Text, (int) password->Length, header + HEADER_SALT_OFFSET, - PKCS5_SALT_SIZE, bBoot, dk, sizeof (dk)); + PKCS5_SALT_SIZE, iterations, dk, sizeof (dk)); #endif // Mode of operation @@ -745,7 +748,7 @@ ret: // Creates a volume header in memory int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, int mode, Password *password, - int pkcs5_prf, char *masterKeydata, PCRYPTO_INFO *retInfo, + int pkcs5_prf, int pin, 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) { @@ -794,7 +797,7 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, // User key memcpy (keyInfo.userKey, password->Text, nUserKeyLen); keyInfo.keyLength = nUserKeyLen; - keyInfo.noIterations = get_pkcs5_iteration_count (pkcs5_prf, FALSE, bBoot); + keyInfo.noIterations = get_pkcs5_iteration_count (pkcs5_prf, pin, FALSE, bBoot); // User selected encryption algorithm cryptoInfo->ea = ea; diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h index 7021ab86..080589ff 100644 --- a/src/Common/Volumes.h +++ b/src/Common/Volumes.h @@ -127,13 +127,13 @@ uint16 GetHeaderField16 (byte *header, int offset); uint32 GetHeaderField32 (byte *header, int offset); UINT64_STRUCT GetHeaderField64 (byte *header, int offset); #ifdef TC_WINDOWS_BOOT -int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); +int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pin, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); #else -int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, BOOL truecryptMode, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); +int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, int pin, BOOL truecryptMode, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); #endif #if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) -int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, 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 pin, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode); BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead); BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header); int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly); -- cgit v1.2.3