From c3c1bdd29d932f2b38e7c3995498f9a4eab8702b Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 7 Jun 2015 01:37:23 +0200 Subject: Windows: Add support for PIN in favorites. Several enhancements to GUI handling of Dynamic Mode. --- src/Common/Apidrvr.h | 1 + src/Common/Crypto.h | 1 + src/Common/Dlgcode.c | 34 ++++++++++++++++++++++++++-------- src/Common/Dlgcode.h | 2 ++ src/Common/Language.xml | 12 +++++++----- src/Common/Volumes.c | 4 ++++ 6 files changed, 41 insertions(+), 13 deletions(-) (limited to 'src/Common') diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index d168cf74..b61370c7 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -145,6 +145,7 @@ typedef struct unsigned __int64 totalBytesWritten; int hiddenVolProtection; /* Hidden volume protection status (e.g. HIDVOL_PROT_STATUS_NONE, HIDVOL_PROT_STATUS_ACTIVE, etc.) */ int volFormatVersion; + int volumePin; } VOLUME_PROPERTIES_STRUCT; typedef struct diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h index 038e5430..ff743890 100644 --- a/src/Common/Crypto.h +++ b/src/Common/Crypto.h @@ -213,6 +213,7 @@ typedef struct CRYPTO_INFO_t unsigned __int8 salt[PKCS5_SALT_SIZE]; int noIterations; BOOL bTrueCryptMode; + int volumePin; uint64 volume_creation_time; // Legacy uint64 header_creation_time; // Legacy diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index bfa8a32e..cc66506c 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -4353,6 +4353,22 @@ string GetUserFriendlyVersionString (int version) return (versionString); } +string IntToString (int val) +{ + char szTmp [64]; + StringCbPrintfA (szTmp, sizeof(szTmp), "%d", val); + + return szTmp; +} + +wstring IntToWideString (int val) +{ + wchar_t szTmp [64]; + StringCbPrintfW (szTmp, sizeof(szTmp), L"%d", val); + + return szTmp; +} + void GetSizeString (unsigned __int64 size, wchar_t *str, size_t cbStr) { static wchar_t *b, *kb, *mb, *gb, *tb, *pb; @@ -10720,14 +10736,16 @@ std::string FindLatestFileOrDirectory (const std::string &directory, const char 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; + if (IsWindowEnabled (GetDlgItem (hwndDlg, ctrlId))) + { + char szTmp[MAX_PIN + 1] = {0}; + if (GetDlgItemText (hwndDlg, ctrlId, szTmp, MAX_PIN + 1) > 0) + { + char* endPtr = NULL; + pin = strtol(szTmp, &endPtr, 10); + 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 781efeee..a8d571dd 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -548,6 +548,8 @@ std::string VolumeGuidPathToDevicePath (std::string volumeGuidPath); std::string HarddiskVolumePathToPartitionPath (const std::string &harddiskVolumePath); std::string FindLatestFileOrDirectory (const std::string &directory, const char *namePattern, bool findDirectory, bool findFile); std::string GetUserFriendlyVersionString (int version); +std::string IntToString (int val); +std::wstring IntToWideString (int val); // Display a wait dialog while calling the provided callback with the given parameter typedef void (CALLBACK* WaitThreadProc)(void* pArg, HWND hWaitDlg); diff --git a/src/Common/Language.xml b/src/Common/Language.xml index e1cdcde7..fe94ab2e 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -597,7 +597,7 @@ 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. 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). Please enter the password and/or keyfile(s) for the non-system VeraCrypt volume that you want to decrypt. - 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 more than 20 characters (the longer, the better). The maximum possible length is 64 characters. + 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. Please choose a password for the hidden volume. Please choose a password for the hidden operating system (i.e. for the hidden volume). 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). @@ -607,7 +607,7 @@ Outer Volume Password Hidden Volume Password Password for Hidden Operating System - WARNING: Short passwords are easy to crack using brute force techniques!\n\nWe recommend choosing a password consisting of more than 20 characters. Are you sure you want to use a short password? + WARNING: Short passwords are easy to crack using brute force techniques!\n\nWe recommend choosing a password consisting of 20 or more characters. Are you sure you want to use a short password? Volume Password Incorrect password/PRF or not a valid volume. Incorrect keyfile(s) and/or password/PRF or not a valid volume. @@ -616,6 +616,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. + Remember Number to Mount Volume + Remember Number to Boot System 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). @@ -1068,9 +1070,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. + PIN (Personal Iteration Number) not supported for TrueCrypt mode. + Password must contain 20 or more characters in order to use the specified PIN.\nShorter passwords can only be used if the PIN is 485 or greater. + Pre-boot authentication Password must contain 20 or more characters in order to use the specified PIN.\nShorter passwords can only be used if the PIN is 98 or greater. 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/Volumes.c b/src/Common/Volumes.c index 567df7ee..283be2ea 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -494,6 +494,7 @@ KeyReady: ; cryptoInfo->pkcs5 = pkcs5_prf; cryptoInfo->noIterations = keyInfo.noIterations; cryptoInfo->bTrueCryptMode = truecryptMode; + cryptoInfo->volumePin = pin; goto ret; } @@ -516,6 +517,7 @@ KeyReady: ; cryptoInfo->pkcs5 = pkcs5_prf; cryptoInfo->noIterations = keyInfo.noIterations; cryptoInfo->bTrueCryptMode = truecryptMode; + cryptoInfo->volumePin = pin; // Init the cipher with the decrypted master key status = EAInit (cryptoInfo->ea, keyInfo.master_keydata + primaryKeyOffset, cryptoInfo->ks); @@ -805,6 +807,8 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, // User selected PRF cryptoInfo->pkcs5 = pkcs5_prf; cryptoInfo->bTrueCryptMode = FALSE; + cryptoInfo->noIterations = keyInfo.noIterations; + cryptoInfo->volumePin = pin; // Mode of operation cryptoInfo->mode = mode; -- cgit v1.2.3