mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-10 13:13:34 +01:00
Windows: Support using token keyfile when creating file container using command line
This commit is contained in:
parent
6550030540
commit
fa72ac51c4
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user