diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-01-28 14:58:41 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-01-28 17:16:33 +0100 |
commit | cdd1179c63bb892696adfad1818d65e3026916ca (patch) | |
tree | e2d7265440b8cc51ca544d2c2412041b0d18439d /src | |
parent | 54e46c260cf04861c99d8b2590999c1eb33f0cb1 (diff) | |
download | VeraCrypt-cdd1179c63bb892696adfad1818d65e3026916ca.tar.gz VeraCrypt-cdd1179c63bb892696adfad1818d65e3026916ca.zip |
Increase password maximum length to 128 bytes from 64 bytes
Diffstat (limited to 'src')
-rw-r--r-- | src/Boot/Windows/BootCommon.h | 6 | ||||
-rw-r--r-- | src/Common/Cache.c | 10 | ||||
-rw-r--r-- | src/Common/Cache.h | 1 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 3 | ||||
-rw-r--r-- | src/Common/Keyfiles.c | 21 | ||||
-rw-r--r-- | src/Common/Keyfiles.h | 3 | ||||
-rw-r--r-- | src/Common/Language.xml | 10 | ||||
-rw-r--r-- | src/Common/Password.h | 19 | ||||
-rw-r--r-- | src/Driver/DriveFilter.c | 16 | ||||
-rw-r--r-- | src/Main/Forms/MountOptionsDialog.cpp | 7 | ||||
-rw-r--r-- | src/Volume/Keyfile.cpp | 2 | ||||
-rw-r--r-- | src/Volume/VolumePassword.h | 3 |
12 files changed, 74 insertions, 27 deletions
diff --git a/src/Boot/Windows/BootCommon.h b/src/Boot/Windows/BootCommon.h index 6de6ca6e..3bbd09b2 100644 --- a/src/Boot/Windows/BootCommon.h +++ b/src/Boot/Windows/BootCommon.h @@ -58,7 +58,7 @@ typedef struct uint16 CryptoInfoOffset; uint16 CryptoInfoLength; uint32 HeaderSaltCrc32; - Password BootPassword; + PasswordLegacy BootPassword; uint64 HiddenSystemPartitionStart; uint64 DecoySystemPartitionStart; uint32 Flags; @@ -206,9 +206,9 @@ typedef struct _DCS_DEP_PWD_CACHE { uint64 Sign; uint32 CRC; uint32 Count; - Password Pwd[4]; + PasswordLegacy Pwd[4]; int32 Pim[4]; - byte pad[512 - 8 - 4 - 4 - (sizeof(Password) + 4) * 4]; + byte pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4]; } DCS_DEP_PWD_CACHE; CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE); #pragma pack() diff --git a/src/Common/Cache.c b/src/Common/Cache.c index 2412ba59..4a4ebc9a 100644 --- a/src/Common/Cache.c +++ b/src/Common/Cache.c @@ -105,6 +105,16 @@ void AddPasswordToCache (Password *password, int pim) cacheEmpty = 0; } +void AddLegacyPasswordToCache (PasswordLegacy *password, int pim) +{ + Password inputPass = {0}; + inputPass.Length = password->Length; + memcpy (inputPass.Text, password->Text, password->Length); + + AddPasswordToCache (&inputPass, pim); + + burn (&inputPass, sizeof (inputPass)); +} void WipeCache () { diff --git a/src/Common/Cache.h b/src/Common/Cache.h index e73cea77..a9ed58a7 100644 --- a/src/Common/Cache.h +++ b/src/Common/Cache.h @@ -21,5 +21,6 @@ extern int cacheEmpty; void AddPasswordToCache (Password *password, int pim); +void AddLegacyPasswordToCache (PasswordLegacy *password, int pim); int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim,char *header, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, PCRYPTO_INFO *retInfo); void WipeCache (void); diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 3de37b7c..44cf623b 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -1195,6 +1195,9 @@ void ToBootPwdField (HWND hwndDlg, UINT ctrlId) { HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId); WNDPROC originalwp = (WNDPROC) GetWindowLongPtrW (hwndCtrl, GWLP_USERDATA); + + SendMessage (hwndCtrl, EM_LIMITTEXT, MAX_LEGACY_PASSWORD, 0); + // if ToNormalPwdField has been called before, GWLP_USERDATA already contains original WNDPROC if (!originalwp) { diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c index 9f756e53..686f3ca8 100644 --- a/src/Common/Keyfiles.c +++ b/src/Common/Keyfiles.c @@ -147,12 +147,12 @@ void KeyFileCloneAll (KeyFile *firstKeyFile, KeyFile **outputKeyFile) } -static BOOL KeyFileProcess (unsigned __int8 *keyPool, KeyFile *keyFile) +static BOOL KeyFileProcess (unsigned __int8 *keyPool, unsigned __int32 keyPoolSize, KeyFile *keyFile) { FILE *f; unsigned __int8 buffer[64 * 1024]; unsigned __int32 crc = 0xffffffff; - int writePos = 0; + unsigned __int32 writePos = 0; size_t bytesRead, totalRead = 0; int status = TRUE; @@ -203,7 +203,7 @@ static BOOL KeyFileProcess (unsigned __int8 *keyPool, KeyFile *keyFile) keyPool[writePos++] += (unsigned __int8) (crc >> 8); keyPool[writePos++] += (unsigned __int8) crc; - if (writePos >= KEYFILE_POOL_SIZE) + if (writePos >= keyPoolSize) writePos = 0; if (++totalRead >= KEYFILE_MAX_READ_LEN) @@ -248,6 +248,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con wchar_t searchPath [TC_MAX_PATH*2]; struct _wfinddata_t fBuf; intptr_t searchHandle; + unsigned __int32 keyPoolSize = password->Length <= MAX_LEGACY_PASSWORD? KEYFILE_POOL_LEGACY_SIZE : KEYFILE_POOL_SIZE; HiddenFilesPresentInKeyfilePath = FALSE; @@ -278,7 +279,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con } unsigned __int32 crc = 0xffffffff; - int writePos = 0; + unsigned __int32 writePos = 0; size_t totalRead = 0; for (size_t i = 0; i < keyfileData.size(); i++) @@ -290,7 +291,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con keyPool[writePos++] += (unsigned __int8) (crc >> 8); keyPool[writePos++] += (unsigned __int8) crc; - if (writePos >= KEYFILE_POOL_SIZE) + if (writePos >= keyPoolSize) writePos = 0; if (++totalRead >= KEYFILE_MAX_READ_LEN) @@ -371,7 +372,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con ++keyfileCount; // Apply keyfile to the pool - if (!KeyFileProcess (keyPool, kfSub)) + if (!KeyFileProcess (keyPool, keyPoolSize, kfSub)) { handleWin32Error (hwndDlg, SRC_POS); Error ("ERR_PROCESS_KEYFILE", hwndDlg); @@ -390,7 +391,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con } } // Apply keyfile to the pool - else if (!KeyFileProcess (keyPool, kf)) + else if (!KeyFileProcess (keyPool, keyPoolSize, kf)) { handleWin32Error (hwndDlg, SRC_POS); Error ("ERR_PROCESS_KEYFILE", hwndDlg); @@ -400,7 +401,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con /* Mix the keyfile pool contents into the password */ - for (i = 0; i < sizeof (keyPool); i++) + for (i = 0; i < keyPoolSize; i++) { if (i < password->Length) password->Text[i] += keyPool[i]; @@ -408,8 +409,8 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con password->Text[i] = keyPool[i]; } - if (password->Length < (int)sizeof (keyPool)) - password->Length = sizeof (keyPool); + if (password->Length < keyPoolSize) + password->Length = keyPoolSize; burn (keyPool, sizeof (keyPool)); diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h index fb90a9d5..a13666fb 100644 --- a/src/Common/Keyfiles.h +++ b/src/Common/Keyfiles.h @@ -19,7 +19,8 @@ extern "C" { #include "Common.h" -#define KEYFILE_POOL_SIZE 64 +#define KEYFILE_POOL_LEGACY_SIZE 64 +#define KEYFILE_POOL_SIZE 128 #define KEYFILE_MAX_READ_LEN (1024*1024) typedef struct KeyFileStruct diff --git a/src/Common/Language.xml b/src/Common/Language.xml index 1921b1aa..47d99764 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -618,12 +618,12 @@ <entry lang="en" key="NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE_HELP">Please enter the password and/or keyfile(s) for the non-system volume where you want to resume the process of in-place encryption/decryption.\n\nRemark: After you click Next, VeraCrypt will attempt to find all non-system volumes where the process of encryption/decryption has been interrupted and where the VeraCrypt volume header can be deciphered using the supplied password and/or keyfile(s). If more than one such volume is found, you will need to select one of them in the next step.</entry> <entry lang="en" key="NONSYS_INPLACE_ENC_RESUME_VOL_SELECT_HELP">Please select one of the listed volumes. The list contains each accessible non-system volume where the process of encryption/decryption has been interrupted and where the volume header was successfully deciphered using the supplied password and/or keyfile(s).</entry> <entry lang="en" key="NONSYS_INPLACE_DEC_PASSWORD_PAGE_HELP">Please enter the password and/or keyfile(s) for the non-system VeraCrypt volume that you want to decrypt.</entry> - <entry lang="en" key="PASSWORD_HELP">It is very important that you choose a good password. You should avoid choosing one that contains only a single word that can be found in a dictionary (or a combination of 2, 3, or 4 such words). It should not contain any names or dates of birth. It should not be easy to guess. A good password is a random combination of upper and lower case letters, numbers, and special characters, such as @ ^ = $ * + etc. We recommend choosing a password consisting of 20 or more characters (the longer, the better). The maximum possible length is 64 characters.</entry> + <entry lang="en" key="PASSWORD_HELP">It is very important that you choose a good password. You should avoid choosing one that contains only a single word that can be found in a dictionary (or a combination of 2, 3, or 4 such words). It should not contain any names or dates of birth. It should not be easy to guess. A good password is a random combination of upper and lower case letters, numbers, and special characters, such as @ ^ = $ * + etc. We recommend choosing a password consisting of 20 or more characters (the longer, the better). The maximum possible length is 128 characters.</entry> <entry lang="en" key="PASSWORD_HIDDENVOL_HELP">Please choose a password for the hidden volume. </entry> <entry lang="en" key="PASSWORD_HIDDEN_OS_HELP">Please choose a password for the hidden operating system (i.e. for the hidden volume). </entry> <entry lang="en" key="PASSWORD_HIDDEN_OS_NOTE">IMPORTANT: The password that you choose for the hidden operating system in this step must be substantially different from the other two passwords (i.e. from the password for the outer volume and from the password for the decoy operating system).</entry> <entry lang="en" key="PASSWORD_HIDDENVOL_HOST_DIRECT_HELP">Please enter the password for the volume within which you wish to create a hidden volume.\n\nAfter you click Next, VeraCrypt will attempt to mount the volume. As soon as the volume is mounted, its cluster bitmap will be scanned to determine the size of the uninterrupted area of free space (if there is any) whose end is aligned with the end of the volume. This area will accommodate the hidden volume and therefore will limit its maximum possible size. Cluster map scanning is necessary to ensure that no data on the outer volume will be overwritten by the hidden volume.</entry> - <entry lang="en" key="PASSWORD_HIDDENVOL_HOST_HELP">\nPlease choose a password for the outer volume. This will be the password that you will be able to reveal to an adversary if you are asked or forced to do so.\n\nIMPORTANT: The password must be substantially different from the one you will choose for the hidden volume.\n\nNote: The maximum possible password length is 64 characters.</entry> + <entry lang="en" key="PASSWORD_HIDDENVOL_HOST_HELP">\nPlease choose a password for the outer volume. This will be the password that you will be able to reveal to an adversary if you are asked or forced to do so.\n\nIMPORTANT: The password must be substantially different from the one you will choose for the hidden volume.\n\nNote: The maximum possible password length is 128 characters.</entry> <entry lang="en" key="PASSWORD_SYSENC_OUTERVOL_HELP">Please choose a password for the outer volume. This will be the password you will be able to reveal to anyone forcing you to disclose the password for the first partition behind the system partition, where both the outer volume and the hidden volume (containing the hidden operating system) will reside. The existence of the hidden volume (and of the hidden operating system) will remain secret. Note that this password is not for the decoy operating system.\n\nIMPORTANT: The password must be substantially different from the one you will choose for the hidden volume (i.e. for the hidden operating system).</entry> <entry lang="en" key="PASSWORD_HIDVOL_HOST_TITLE">Outer Volume Password</entry> <entry lang="en" key="PASSWORD_HIDVOL_TITLE">Hidden Volume Password</entry> @@ -1378,7 +1378,7 @@ <entry lang="en" key="IDC_BOOT_LOADER_CACHE_PIM">Include &PIM when caching pre-boot authentication password</entry> <entry lang="en" key="IDC_PREF_CACHE_PIM">Include PIM when caching a password</entry> <entry lang="en" key="IDC_SHOW_DISCONNECTED_NETWORK_DRIVES">Make disconnected network drives available for mounting</entry> - <entry lang="en" key="PASSWORD_UTF8_TOO_LONG">The entered password is too long: its UTF-8 representation exceeds 64 bytes.</entry> + <entry lang="en" key="PASSWORD_UTF8_TOO_LONG">The entered password is too long: its UTF-8 representation exceeds 128 bytes.</entry> <entry lang="en" key="PASSWORD_UTF8_INVALID">The entered password contains Unicode characters that couldn't be converted to UTF-8 representation.</entry> <entry lang="en" key="INIT_DLL">Error: Failed to load a system library.</entry> <entry lang="en" key="ERR_EXFAT_INVALID_VOLUME_SIZE">The volume file size specified in the command line is incompatible with selected exFAT filesystem.</entry> @@ -1421,8 +1421,8 @@ <entry lang="en" key="IDC_BLOCK_SYSENC_TRIM">Block TRIM command on system partition/drive</entry> <entry lang="en" key="WINDOWS_EFI_BOOT_LOADER_MISSING">ERROR: Windows EFI system loader could not be located on the disk. Operation will be aborted.</entry> <entry lang="en" key="SYSENC_EFI_UNSUPPORTED_SECUREBOOT">It is currently not possible to encrypt a system if SecureBoot is enabled and if VeraCrypt custom keys are not loaded into the machine firmware. SecureBoot needs to be disabled in the BIOS configuration in order to allow system encryption to proceed.</entry> - <entry lang="en" key="PASSWORD_PASTED_TRUNCATED">Pasted text truncated because the password maximum length is 64 characters</entry> - <entry lang="en" key="PASSWORD_MAXLENGTH_REACHED">Password already reached its maximum length of 64 characters.\nNo additional character is allowed.</entry> + <entry lang="en" key="PASSWORD_PASTED_TRUNCATED">Pasted text truncated because the password maximum length is 128 characters</entry> + <entry lang="en" key="PASSWORD_MAXLENGTH_REACHED">Password already reached its maximum length of 128 characters.\nNo additional character is allowed.</entry> <entry lang="en" key="IDC_SELECT_LANGUAGE_LABEL">Select the language to use during the installation:</entry> <entry lang="en" key="VOLUME_TOO_LARGE_FOR_HOST">ERROR: The size of the file container is larger than the available free space on disk.</entry> <entry lang="en" key="IDC_ALLOW_WINDOWS_DEFRAG">Allow Windows Disk Defragmenter to defragment non-system partition/drive</entry> diff --git a/src/Common/Password.h b/src/Common/Password.h index b2b0511d..550558db 100644 --- a/src/Common/Password.h +++ b/src/Common/Password.h @@ -16,7 +16,12 @@ // User text input limits #define MIN_PASSWORD 1 // Minimum possible password length -#define MAX_PASSWORD 64 // Maximum possible password length +#if defined(TC_WINDOWS_BOOT) || defined(_UEFI) +#define MAX_PASSWORD 64 // Maximum possible password length +#else +#define MAX_LEGACY_PASSWORD 64 // Maximum possible legacy password length +#define MAX_PASSWORD 128 // Maximum possible password length +#endif #define MAX_PIM 7 // Maximum allowed digits in a PIM (enough for maximum value) #define MAX_PIM_VALUE 2147468 // Maximum value to have a positive 32-bit result for formula 15000 + (PIM x 1000) #define MAX_BOOT_PIM 5 // Maximum allowed digits in a PIM for boot (enough for 16-bit value) @@ -36,6 +41,18 @@ typedef struct char Pad[3]; // keep 64-bit alignment } Password; +#if defined(TC_WINDOWS_BOOT) || defined(_UEFI) +#define PasswordLegacy Password +#else +typedef struct +{ + // Modifying this structure can introduce incompatibility with previous versions + unsigned __int32 Length; + unsigned char Text[MAX_LEGACY_PASSWORD + 1]; + char Pad[3]; // keep 64-bit alignment +} PasswordLegacy; +#endif + #if defined(_WIN32) && !defined(TC_WINDOWS_DRIVER) && !defined(_UEFI) void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled ); diff --git a/src/Driver/DriveFilter.c b/src/Driver/DriveFilter.c index 7105838a..c17410df 100644 --- a/src/Driver/DriveFilter.c +++ b/src/Driver/DriveFilter.c @@ -114,7 +114,7 @@ NTSTATUS LoadBootArguments () } // Sanity check: for valid boot argument, the password is less than 64 bytes long - if (bootArguments->BootPassword.Length <= MAX_PASSWORD) + if (bootArguments->BootPassword.Length <= MAX_LEGACY_PASSWORD) { BootLoaderArgsPtr = BootArgsRegions[bootLoaderArgsIndex]; @@ -594,7 +594,7 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, for(i = 0; i<pwdCache->Count; ++i){ if (CacheBootPassword && pwdCache->Pwd[i].Length > 0) { int cachedPim = CacheBootPim? (int) (pwdCache->Pim[i]) : 0; - AddPasswordToCache (&pwdCache->Pwd[i], cachedPim); + AddLegacyPasswordToCache (&pwdCache->Pwd[i], cachedPim); } } burn(pwdCache, sizeof(*pwdCache)); @@ -606,7 +606,7 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, if (CacheBootPassword && BootArgs.BootPassword.Length > 0) { int cachedPim = CacheBootPim? pim : 0; - AddPasswordToCache (&BootArgs.BootPassword, cachedPim); + AddLegacyPasswordToCache (&BootArgs.BootPassword, cachedPim); } burn (&BootArgs.BootPassword, sizeof (BootArgs.BootPassword)); @@ -808,7 +808,13 @@ static void CheckDeviceTypeAndMount (DriveFilterExtension *filterExtension) TC_BUG_CHECK (status); if (!BootDriveFound) - MountDrive (filterExtension, &BootArgs.BootPassword, &BootArgs.HeaderSaltCrc32); + { + Password bootPass = {0}; + bootPass.Length = BootArgs.BootPassword.Length; + memcpy (bootPass.Text, BootArgs.BootPassword.Text, BootArgs.BootPassword.Length); + MountDrive (filterExtension, &bootPass, &BootArgs.HeaderSaltCrc32); + burn (&bootPass, sizeof (bootPass)); + } KeReleaseMutex (&MountMutex, FALSE); } @@ -1101,7 +1107,7 @@ void ReopenBootVolumeHeader (PIRP irp, PIO_STACK_LOCATION irpSp) return; if (!BootDriveFound || !BootDriveFilterExtension || !BootDriveFilterExtension->DriveMounted || !BootDriveFilterExtension->HeaderCryptoInfo - || request->VolumePassword.Length > MAX_PASSWORD + || request->VolumePassword.Length > MAX_LEGACY_PASSWORD || request->pkcs5_prf < 0 || request->pkcs5_prf > LAST_PRF_ID || request->pim < 0 diff --git a/src/Main/Forms/MountOptionsDialog.cpp b/src/Main/Forms/MountOptionsDialog.cpp index 815cd523..c980133f 100644 --- a/src/Main/Forms/MountOptionsDialog.cpp +++ b/src/Main/Forms/MountOptionsDialog.cpp @@ -140,6 +140,13 @@ namespace VeraCrypt Gui->ShowWarning (e); return; } + + if (Options.PartitionInSystemEncryptionScope && Options.Password->Size() > VolumePassword::MaxLegacySize) + { + Gui->ShowWarning (StringFormatter (_("System Encryption password is longer than {0} characters."), (int) VolumePassword::MaxLegacySize)); + return; + } + Options.Pim = Pim; Options.Kdf = PasswordPanel->GetPkcs5Kdf(bUnsupportedKdf); if (bUnsupportedKdf) diff --git a/src/Volume/Keyfile.cpp b/src/Volume/Keyfile.cpp index e52d58f7..d15dc0d7 100644 --- a/src/Volume/Keyfile.cpp +++ b/src/Volume/Keyfile.cpp @@ -134,7 +134,7 @@ done: } else { - SecureBuffer keyfilePool (VolumePassword::MaxSize); + SecureBuffer keyfilePool (password->Size() <= VolumePassword::MaxLegacySize? VolumePassword::MaxLegacySize: VolumePassword::MaxSize); // Pad password with zeros if shorter than max length keyfilePool.Zero(); diff --git a/src/Volume/VolumePassword.h b/src/Volume/VolumePassword.h index 6154bc0b..5e319774 100644 --- a/src/Volume/VolumePassword.h +++ b/src/Volume/VolumePassword.h @@ -41,7 +41,8 @@ namespace VeraCrypt TC_SERIALIZABLE (VolumePassword); - static const size_t MaxSize = 64; + static const size_t MaxLegacySize = 64; + static const size_t MaxSize = 128; static const size_t WarningSizeThreshold = 12; protected: |