VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-03-03 01:34:21 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-03-10 10:32:45 +0100
commitfa72ac51c4cb7d7a3184c718a48af589ebf9cf94 (patch)
tree04b57bd1b49c9ef0bf7204be7c8555138c396e57
parent65500305404a6100b50161343637c115e5718c9e (diff)
downloadVeraCrypt-fa72ac51c4cb7d7a3184c718a48af589ebf9cf94.tar.gz
VeraCrypt-fa72ac51c4cb7d7a3184c718a48af589ebf9cf94.zip
Windows: Support using token keyfile when creating file container using command line
-rw-r--r--src/Format/Tcformat.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 3d394c16..976809de 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -260,6 +260,8 @@ BOOL bGuiMode = TRUE;
BOOL bSystemIsGPT = FALSE;
+KeyFile *FirstCmdKeyFile = NULL;
+
int nPbar = 0; /* Control ID of progress bar:- for format code */
wchar_t HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
@@ -488,6 +490,8 @@ static void localcleanup (void)
burn (szFileName, sizeof(szFileName));
burn (szDiskFile, sizeof(szDiskFile));
+ KeyFileRemoveAll (&FirstCmdKeyFile);
+
// Attempt to wipe the GUI fields showing portions of randpool, of the master and header keys
wmemset (tmp, L'X', ARRAYSIZE(tmp));
tmp [ARRAYSIZE(tmp)-1] = 0;
@@ -6176,7 +6180,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
showKeys = FALSE;
bGuiMode = FALSE;
- if (CmdVolumePassword.Length == 0)
+ if (CmdVolumePassword.Length == 0 && !FirstCmdKeyFile)
AbortProcess ("ERR_PASSWORD_MISSING");
if (CmdVolumeFileSize == 0)
@@ -6331,6 +6335,11 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
}
+ if (!KeyFilesApply (hwndDlg, &volumePassword, FirstCmdKeyFile, NULL))
+ {
+ exit (1);
+ }
+
volTransformThreadFunction (hwndDlg);
exit (bOperationSuccess? 0 : 1);
@@ -9008,6 +9017,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
OptionQuickFormat,
OptionFastCreateFile,
OptionEnableMemoryProtection,
+ OptionKeyfile,
};
argument args[]=
@@ -9032,6 +9042,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
{ OptionQuickFormat, L"/quick", NULL, FALSE },
{ OptionFastCreateFile, L"/fastcreatefile", NULL, FALSE },
{ OptionEnableMemoryProtection, L"/protectMemory", NULL, FALSE },
+ { OptionKeyfile, L"/keyfile", L"/k", FALSE },
// Internal
{ CommandResumeSysEncLogOn, L"/acsysenc", L"/a", TRUE },
@@ -9450,6 +9461,27 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
}
break;
+ case OptionKeyfile:
+ {
+ wchar_t tmpPath [2 * TC_MAX_PATH] = {0};
+ if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i,
+ nNoCommandLineArgs, tmpPath, ARRAYSIZE (tmpPath)))
+ {
+ KeyFile *kf;
+ RelativePath2Absolute (tmpPath);
+ kf = (KeyFile *) malloc (sizeof (KeyFile));
+ if (kf)
+ {
+ StringCchCopyW (kf->FileName, ARRAYSIZE(kf->FileName), tmpPath);
+ FirstCmdKeyFile = KeyFileAdd (FirstCmdKeyFile, kf);
+ }
+ }
+ else
+ AbortProcess ("COMMAND_LINE_ERROR");
+ }
+
+ break;
+
default:
DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_COMMANDHELP_DLG), hwndDlg, (DLGPROC)
CommandHelpDlgProc, (LPARAM) &as);