mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-13 06:33: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;
|
BOOL bSystemIsGPT = FALSE;
|
||||||
|
|
||||||
|
KeyFile *FirstCmdKeyFile = NULL;
|
||||||
|
|
||||||
int nPbar = 0; /* Control ID of progress bar:- for format code */
|
int nPbar = 0; /* Control ID of progress bar:- for format code */
|
||||||
|
|
||||||
wchar_t HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
|
wchar_t HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
|
||||||
@ -488,6 +490,8 @@ static void localcleanup (void)
|
|||||||
burn (szFileName, sizeof(szFileName));
|
burn (szFileName, sizeof(szFileName));
|
||||||
burn (szDiskFile, sizeof(szDiskFile));
|
burn (szDiskFile, sizeof(szDiskFile));
|
||||||
|
|
||||||
|
KeyFileRemoveAll (&FirstCmdKeyFile);
|
||||||
|
|
||||||
// Attempt to wipe the GUI fields showing portions of randpool, of the master and header keys
|
// Attempt to wipe the GUI fields showing portions of randpool, of the master and header keys
|
||||||
wmemset (tmp, L'X', ARRAYSIZE(tmp));
|
wmemset (tmp, L'X', ARRAYSIZE(tmp));
|
||||||
tmp [ARRAYSIZE(tmp)-1] = 0;
|
tmp [ARRAYSIZE(tmp)-1] = 0;
|
||||||
@ -6176,7 +6180,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
showKeys = FALSE;
|
showKeys = FALSE;
|
||||||
bGuiMode = FALSE;
|
bGuiMode = FALSE;
|
||||||
|
|
||||||
if (CmdVolumePassword.Length == 0)
|
if (CmdVolumePassword.Length == 0 && !FirstCmdKeyFile)
|
||||||
AbortProcess ("ERR_PASSWORD_MISSING");
|
AbortProcess ("ERR_PASSWORD_MISSING");
|
||||||
|
|
||||||
if (CmdVolumeFileSize == 0)
|
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);
|
volTransformThreadFunction (hwndDlg);
|
||||||
|
|
||||||
exit (bOperationSuccess? 0 : 1);
|
exit (bOperationSuccess? 0 : 1);
|
||||||
@ -9008,6 +9017,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
|||||||
OptionQuickFormat,
|
OptionQuickFormat,
|
||||||
OptionFastCreateFile,
|
OptionFastCreateFile,
|
||||||
OptionEnableMemoryProtection,
|
OptionEnableMemoryProtection,
|
||||||
|
OptionKeyfile,
|
||||||
};
|
};
|
||||||
|
|
||||||
argument args[]=
|
argument args[]=
|
||||||
@ -9032,6 +9042,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
|||||||
{ OptionQuickFormat, L"/quick", NULL, FALSE },
|
{ OptionQuickFormat, L"/quick", NULL, FALSE },
|
||||||
{ OptionFastCreateFile, L"/fastcreatefile", NULL, FALSE },
|
{ OptionFastCreateFile, L"/fastcreatefile", NULL, FALSE },
|
||||||
{ OptionEnableMemoryProtection, L"/protectMemory", NULL, FALSE },
|
{ OptionEnableMemoryProtection, L"/protectMemory", NULL, FALSE },
|
||||||
|
{ OptionKeyfile, L"/keyfile", L"/k", FALSE },
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
{ CommandResumeSysEncLogOn, L"/acsysenc", L"/a", TRUE },
|
{ CommandResumeSysEncLogOn, L"/acsysenc", L"/a", TRUE },
|
||||||
@ -9450,6 +9461,27 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_COMMANDHELP_DLG), hwndDlg, (DLGPROC)
|
DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_COMMANDHELP_DLG), hwndDlg, (DLGPROC)
|
||||||
CommandHelpDlgProc, (LPARAM) &as);
|
CommandHelpDlgProc, (LPARAM) &as);
|
||||||
|
Loading…
Reference in New Issue
Block a user