mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-08 08:58:00 +00:00
PuTTYgen: option to control Argon2 flavour.
I left this out of yesterday's collection of cmdgen CLI options and GUI PuTTYgen dialog box, but only because I forgot about it. I don't know off the top of my head why someone would particularly want to configure this detail, but given that it _is_ configurable, it seems like no extra trouble to expose it along with the rest of the parameters, just in case.
This commit is contained in:
parent
ee6b0724c5
commit
c289ad3607
25
cmdgen.c
25
cmdgen.c
@ -155,11 +155,13 @@ void help(void)
|
||||
"format:\n"
|
||||
" version PPK format version (min 2, max 3, "
|
||||
"default 3)\n"
|
||||
" kdf key derivation function (argon2id, "
|
||||
"argon2i, argon2d)\n"
|
||||
" memory Kb of memory to use in password hash "
|
||||
"(default 8192)\n"
|
||||
" time approx milliseconds to hash for "
|
||||
"(default 100)\n"
|
||||
" passes exact number of hash passes to run "
|
||||
" passes number of hash passes to run "
|
||||
"(alternative to 'time')\n"
|
||||
" parallelism number of parallelisable threads in the "
|
||||
"hash function\n"
|
||||
@ -403,8 +405,27 @@ int main(int argc, char **argv)
|
||||
"'%s' expected a value\n", val);
|
||||
continue;
|
||||
}
|
||||
|
||||
*optvalue++ = '\0';
|
||||
|
||||
/* Non-numeric options */
|
||||
if (!strcmp(val, "kdf")) {
|
||||
if (!strcmp(optvalue, "Argon2id") ||
|
||||
!strcmp(optvalue, "argon2id")) {
|
||||
params.argon2_flavour = Argon2id;
|
||||
} else if (!strcmp(optvalue, "Argon2i") ||
|
||||
!strcmp(optvalue, "argon2i")) {
|
||||
params.argon2_flavour = Argon2i;
|
||||
} else if (!strcmp(optvalue, "Argon2d") ||
|
||||
!strcmp(optvalue, "argon2d")) {
|
||||
params.argon2_flavour = Argon2d;
|
||||
} else {
|
||||
errs = true;
|
||||
fprintf(stderr, "puttygen: unrecognise"
|
||||
"d kdf '%s'\n", optvalue);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
char *end;
|
||||
unsigned long n = strtoul(optvalue, &end, 0);
|
||||
if (!*optvalue || *end) {
|
||||
|
@ -1,13 +1,17 @@
|
||||
#define IDC_PPKVER_STATIC 100
|
||||
#define IDC_PPKVER_2 101
|
||||
#define IDC_PPKVER_3 102
|
||||
#define IDC_ARGON2_MEM_STATIC 103
|
||||
#define IDC_ARGON2_MEM 104
|
||||
#define IDC_ARGON2_MEM_STATIC2 105
|
||||
#define IDC_PPK_AUTO_STATIC 106
|
||||
#define IDC_PPK_AUTO_YES 107
|
||||
#define IDC_PPK_AUTO_NO 108
|
||||
#define IDC_ARGON2_TIME_STATIC 109
|
||||
#define IDC_ARGON2_TIME 110
|
||||
#define IDC_ARGON2_PARALLEL_STATIC 111
|
||||
#define IDC_ARGON2_PARALLEL 112
|
||||
#define IDC_KDF_STATIC 103
|
||||
#define IDC_KDF_ARGON2ID 104
|
||||
#define IDC_KDF_ARGON2I 105
|
||||
#define IDC_KDF_ARGON2D 106
|
||||
#define IDC_ARGON2_MEM_STATIC 107
|
||||
#define IDC_ARGON2_MEM 108
|
||||
#define IDC_ARGON2_MEM_STATIC2 109
|
||||
#define IDC_PPK_AUTO_STATIC 110
|
||||
#define IDC_PPK_AUTO_YES 111
|
||||
#define IDC_PPK_AUTO_NO 112
|
||||
#define IDC_ARGON2_TIME_STATIC 113
|
||||
#define IDC_ARGON2_TIME 114
|
||||
#define IDC_ARGON2_PARALLEL_STATIC 115
|
||||
#define IDC_ARGON2_PARALLEL 116
|
||||
|
@ -54,7 +54,7 @@ BEGIN
|
||||
EDITTEXT 1000, 10, 10, 306, 200, ES_READONLY | ES_MULTILINE | ES_LEFT, WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
215 DIALOG DISCARDABLE 0, 0, 240, 84
|
||||
215 DIALOG DISCARDABLE 0, 0, 255, 98
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "PuTTYgen: Private Key File Parameters"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
@ -62,21 +62,24 @@ BEGIN
|
||||
LTEXT "PPK file version:", IDC_PPKVER_STATIC, 5, 6, 115, 8
|
||||
AUTORADIOBUTTON "2", IDC_PPKVER_2, 120, 5, 30, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "3", IDC_PPKVER_3, 150, 5, 30, 10
|
||||
LTEXT "Key derivation function:", IDC_KDF_STATIC, 5, 22, 115, 8
|
||||
AUTORADIOBUTTON "Argon2id", IDC_KDF_ARGON2ID, 120, 21, 45, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "Argon2i", IDC_KDF_ARGON2I, 165, 21, 45, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "Argon2d", IDC_KDF_ARGON2D, 210, 21, 45, 10
|
||||
LTEXT "Memory to use for password hash:", IDC_ARGON2_MEM_STATIC,
|
||||
5, 22, 115, 8
|
||||
EDITTEXT IDC_ARGON2_MEM, 120, 20, 40, 12
|
||||
LTEXT "Kb", IDC_ARGON2_MEM_STATIC2,
|
||||
170, 22, 20, 8
|
||||
LTEXT "Time to use for password hash:", IDC_ARGON2_TIME_STATIC,
|
||||
5, 36, 115, 8
|
||||
EDITTEXT IDC_ARGON2_TIME, 120, 34, 40, 12
|
||||
AUTORADIOBUTTON "ms", IDC_PPK_AUTO_YES, 170, 35, 20, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "passes", IDC_PPK_AUTO_NO, 200, 35, 40, 10
|
||||
LTEXT "Parallelism for password hash:", IDC_ARGON2_PARALLEL_STATIC,
|
||||
EDITTEXT IDC_ARGON2_MEM, 120, 34, 40, 12
|
||||
LTEXT "Kb", IDC_ARGON2_MEM_STATIC2, 170, 36, 34, 8
|
||||
LTEXT "Time to use for password hash:", IDC_ARGON2_TIME_STATIC,
|
||||
5, 50, 115, 8
|
||||
EDITTEXT IDC_ARGON2_PARALLEL, 120, 48, 60, 12
|
||||
DEFPUSHBUTTON "O&K", IDOK, 70, 66, 40, 14
|
||||
PUSHBUTTON "&Cancel", IDCANCEL, 130, 66, 40, 14
|
||||
EDITTEXT IDC_ARGON2_TIME, 120, 48, 40, 12
|
||||
AUTORADIOBUTTON "ms", IDC_PPK_AUTO_YES, 170, 49, 20, 10, WS_GROUP
|
||||
AUTORADIOBUTTON "passes", IDC_PPK_AUTO_NO, 200, 49, 40, 10
|
||||
LTEXT "Parallelism for password hash:", IDC_ARGON2_PARALLEL_STATIC,
|
||||
5, 64, 115, 8
|
||||
EDITTEXT IDC_ARGON2_PARALLEL, 120, 62, 60, 12
|
||||
DEFPUSHBUTTON "O&K", IDOK, 70, 80, 40, 14
|
||||
PUSHBUTTON "&Cancel", IDCANCEL, 130, 80, 40, 14
|
||||
END
|
||||
|
||||
#include "version.rc2"
|
||||
|
@ -328,6 +328,12 @@ static INT_PTR CALLBACK PPKParamsProc(HWND hwnd, UINT msg,
|
||||
CheckRadioButton(hwnd, IDC_PPKVER_2, IDC_PPKVER_3,
|
||||
IDC_PPKVER_2 + (pp->params.fmt_version - 2));
|
||||
|
||||
CheckRadioButton(
|
||||
hwnd, IDC_KDF_ARGON2ID, IDC_KDF_ARGON2D,
|
||||
(pp->params.argon2_flavour == Argon2id ? IDC_KDF_ARGON2ID :
|
||||
pp->params.argon2_flavour == Argon2i ? IDC_KDF_ARGON2I :
|
||||
/* pp->params.argon2_flavour == Argon2d ? */ IDC_KDF_ARGON2D));
|
||||
|
||||
buf = dupprintf("%"PRIu32, pp->params.argon2_mem);
|
||||
SetDlgItemText(hwnd, IDC_ARGON2_MEM, buf);
|
||||
sfree(buf);
|
||||
@ -365,6 +371,15 @@ static INT_PTR CALLBACK PPKParamsProc(HWND hwnd, UINT msg,
|
||||
case IDC_PPKVER_3:
|
||||
pp->params.fmt_version = 3;
|
||||
return 0;
|
||||
case IDC_KDF_ARGON2ID:
|
||||
pp->params.argon2_flavour = Argon2id;
|
||||
return 0;
|
||||
case IDC_KDF_ARGON2I:
|
||||
pp->params.argon2_flavour = Argon2i;
|
||||
return 0;
|
||||
case IDC_KDF_ARGON2D:
|
||||
pp->params.argon2_flavour = Argon2d;
|
||||
return 0;
|
||||
case IDC_ARGON2_MEM:
|
||||
try_get_dlg_item_uint32(hwnd, IDC_ARGON2_MEM,
|
||||
&pp->params.argon2_mem);
|
||||
|
Loading…
Reference in New Issue
Block a user