mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-12 08:43:53 -05:00
Refactor confirm_weak to use SeatDialogText.
This centralises the messages for weak crypto algorithms (general, and host keys in particular, the latter including a list of all the other available host key types) into ssh/common.c, in much the same way as we previously did for ordinary host key warnings. The reason is the same too: I'm about to want to vary the text in one of those dialog boxes, so it's convenient to start by putting it somewhere that I can modify just once.
This commit is contained in:
73
ssh/common.c
73
ssh/common.c
@ -1085,6 +1085,79 @@ SeatPromptResult verify_ssh_host_key(
|
||||
return toret;
|
||||
}
|
||||
|
||||
SeatPromptResult confirm_weak_crypto_primitive(
|
||||
InteractionReadySeat iseat, const char *algtype, const char *algname,
|
||||
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
|
||||
{
|
||||
SeatDialogText *text = seat_dialog_text_new();
|
||||
const SeatDialogPromptDescriptions *pds =
|
||||
seat_prompt_descriptions(iseat.seat);
|
||||
|
||||
seat_dialog_text_append(text, SDT_TITLE, "%s Security Alert", appname);
|
||||
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA,
|
||||
"The first %s supported by the server is %s, "
|
||||
"which is below the configured warning threshold.",
|
||||
algtype, algname);
|
||||
|
||||
/* In batch mode, we print the above information and then this
|
||||
* abort message, and stop. */
|
||||
seat_dialog_text_append(text, SDT_BATCH_ABORT, "Connection abandoned.");
|
||||
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "To accept the risk and continue, %s. "
|
||||
"To abandon the connection, %s.",
|
||||
pds->weak_accept_action, pds->weak_cancel_action);
|
||||
|
||||
seat_dialog_text_append(text, SDT_PROMPT, "Continue with connection?");
|
||||
|
||||
SeatPromptResult toret = seat_confirm_weak_crypto_primitive(
|
||||
iseat, text, callback, ctx);
|
||||
seat_dialog_text_free(text);
|
||||
return toret;
|
||||
}
|
||||
|
||||
SeatPromptResult confirm_weak_cached_hostkey(
|
||||
InteractionReadySeat iseat, const char *algname, const char **betteralgs,
|
||||
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
|
||||
{
|
||||
SeatDialogText *text = seat_dialog_text_new();
|
||||
const SeatDialogPromptDescriptions *pds =
|
||||
seat_prompt_descriptions(iseat.seat);
|
||||
|
||||
seat_dialog_text_append(text, SDT_TITLE, "%s Security Alert", appname);
|
||||
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA,
|
||||
"The first host key type we have stored for this server "
|
||||
"is %s, which is below the configured warning threshold.", algname);
|
||||
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA,
|
||||
"The server also provides the following types of host key "
|
||||
"above the threshold, which we do not have stored:");
|
||||
|
||||
for (const char **p = betteralgs; *p; p++)
|
||||
seat_dialog_text_append(text, SDT_DISPLAY, "%s", *p);
|
||||
|
||||
/* In batch mode, we print the above information and then this
|
||||
* abort message, and stop. */
|
||||
seat_dialog_text_append(text, SDT_BATCH_ABORT, "Connection abandoned.");
|
||||
|
||||
seat_dialog_text_append(
|
||||
text, SDT_PARA, "To accept the risk and continue, %s. "
|
||||
"To abandon the connection, %s.",
|
||||
pds->weak_accept_action, pds->weak_cancel_action);
|
||||
|
||||
seat_dialog_text_append(text, SDT_PROMPT, "Continue with connection?");
|
||||
|
||||
SeatPromptResult toret = seat_confirm_weak_cached_hostkey(
|
||||
iseat, text, callback, ctx);
|
||||
seat_dialog_text_free(text);
|
||||
return toret;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Common functions shared between SSH-1 layers.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user