VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Keyfiles.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-01-28 14:58:41 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-01-28 17:16:33 +0100
commitcdd1179c63bb892696adfad1818d65e3026916ca (patch)
treee2d7265440b8cc51ca544d2c2412041b0d18439d /src/Common/Keyfiles.c
parent54e46c260cf04861c99d8b2590999c1eb33f0cb1 (diff)
downloadVeraCrypt-cdd1179c63bb892696adfad1818d65e3026916ca.tar.gz
VeraCrypt-cdd1179c63bb892696adfad1818d65e3026916ca.zip
Increase password maximum length to 128 bytes from 64 bytes
Diffstat (limited to 'src/Common/Keyfiles.c')
-rw-r--r--src/Common/Keyfiles.c21
1 files changed, 11 insertions, 10 deletions
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));