1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Pass more information to interactive host key check.

Now we pass the whole set of fingerprints, and also a displayable
format for the full host public key.

NFC: this commit doesn't modify any of the host key prompts to _use_
any of the new information. That's coming next.
This commit is contained in:
Simon Tatham
2021-03-13 10:59:47 +00:00
parent 04758cb3ec
commit 3461196197
10 changed files with 51 additions and 33 deletions

View File

@ -31,6 +31,7 @@
#include "dialog.h"
#include "tree234.h"
#include "licence.h"
#include "ssh.h"
#if GTK_CHECK_VERSION(2,0,0)
/* Decide which of GtkFileChooserDialog and GtkFileSelection to use */
@ -3461,8 +3462,8 @@ static void verify_ssh_host_key_result_callback(void *vctx, int result)
}
int gtk_seat_verify_ssh_host_key(
Seat *seat, const char *host, int port,
const char *keytype, char *keystr, char *fingerprint,
Seat *seat, const char *host, int port, const char *keytype,
char *keystr, const char *keydisp, char **fingerprints,
void (*callback)(void *ctx, int result), void *ctx)
{
static const char absenttxt[] =
@ -3513,7 +3514,11 @@ int gtk_seat_verify_ssh_host_key(
if (ret == 0) /* success - key matched OK */
return 1;
text = dupprintf((ret == 2 ? wrongtxt : absenttxt), keytype, fingerprint);
FingerprintType fptype_default =
ssh2_pick_default_fingerprint(fingerprints);
text = dupprintf((ret == 2 ? wrongtxt : absenttxt), keytype,
fingerprints[fptype_default]);
result_ctx = snew(struct verify_ssh_host_key_result_ctx);
result_ctx->callback = callback;
@ -3526,7 +3531,8 @@ int gtk_seat_verify_ssh_host_key(
mainwin = GTK_WIDGET(gtk_seat_get_window(seat));
msgbox = create_message_box(
mainwin, "PuTTY Security Alert", text, string_width(fingerprint), true,
mainwin, "PuTTY Security Alert", text,
string_width(fingerprints[fptype_default]), true,
&buttons_hostkey, verify_ssh_host_key_result_callback, result_ctx);
register_dialog(seat, DIALOG_SLOT_NETWORK_PROMPT, msgbox);

View File

@ -218,8 +218,8 @@ void logevent_dlg(eventlog_stuff *estuff, const char *string);
int gtkdlg_askappend(Seat *seat, Filename *filename,
void (*callback)(void *ctx, int result), void *ctx);
int gtk_seat_verify_ssh_host_key(
Seat *seat, const char *host, int port,
const char *keytype, char *keystr, char *fingerprint,
Seat *seat, const char *host, int port, const char *keytype,
char *keystr, const char *keydisp, char **fingerprints,
void (*callback)(void *ctx, int result), void *ctx);
int gtk_seat_confirm_weak_crypto_primitive(
Seat *seat, const char *algtype, const char *algname,

View File

@ -103,8 +103,8 @@ static int block_and_read(int fd, void *buf, size_t len)
}
int console_verify_ssh_host_key(
Seat *seat, const char *host, int port,
const char *keytype, char *keystr, char *fingerprint,
Seat *seat, const char *host, int port, const char *keytype,
char *keystr, const char *keydisp, char **fingerprints,
void (*callback)(void *ctx, int result), void *ctx)
{
int ret;
@ -132,7 +132,10 @@ int console_verify_ssh_host_key(
prompt = hk_absentmsg_interactive_prompt;
}
fprintf(stderr, common_fmt, keytype, fingerprint);
FingerprintType fptype_default =
ssh2_pick_default_fingerprint(fingerprints);
fprintf(stderr, common_fmt, keytype, fingerprints[fptype_default]);
if (console_batch_mode) {
fputs(console_abandoned_msg, stderr);
return 0;