mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Reorganise host key checking and confirmation.
Previously, checking the host key against the persistent cache managed by the storage.h API was done as part of the seat_verify_ssh_host_key method, i.e. separately by each Seat. Now that check is done by verify_ssh_host_key(), which is a new function in ssh/common.c that centralises all the parts of host key checking that don't need an interactive prompt. It subsumes the previous verify_ssh_manual_host_key() that checked against the Conf, and it does the check against the storage API that each Seat was previously doing separately. If it can't confirm or definitively reject the host key by itself, _then_ it calls out to the Seat, once an interactive prompt is definitely needed. The main point of doing this is so that when SshProxy forwards a Seat call from the proxy SSH connection to the primary Seat, it won't print an announcement of which connection is involved unless it's actually going to do something interactive. (Not that we're printing those announcements _yet_ anyway, but this is a piece of groundwork that works towards doing so.) But while I'm at it, I've also taken the opportunity to clean things up a bit by renaming functions sensibly. Previously we had three very similarly named functions verify_ssh_manual_host_key(), SeatVtable's 'verify_ssh_host_key' method, and verify_host_key() in storage.h. Now the Seat method is called 'confirm' rather than 'verify' (since its job is now always to print an interactive prompt, so it looks more like the other confirm_foo methods), and the storage.h function is called check_stored_host_key(), which goes better with store_host_key and avoids having too many functions with similar names. And the 'manual' function is subsumed into the new centralised code, so there's now just *one* host key function with 'verify' in the name. Several functions are reindented in this commit. Best viewed with whitespace changes ignored.
This commit is contained in:
@ -16,9 +16,9 @@ void nullseat_connection_fatal(Seat *seat, const char *message) {}
|
||||
void nullseat_update_specials_menu(Seat *seat) {}
|
||||
char *nullseat_get_ttymode(Seat *seat, const char *mode) { return NULL; }
|
||||
void nullseat_set_busy_status(Seat *seat, BusyStatus status) {}
|
||||
int nullseat_verify_ssh_host_key(
|
||||
int nullseat_confirm_ssh_host_key(
|
||||
Seat *seat, const char *host, int port, const char *keytype,
|
||||
char *keystr, const char *keydisp, char **key_fingerprints,
|
||||
char *keystr, const char *keydisp, char **key_fingerprints, bool mismatch,
|
||||
void (*callback)(void *ctx, int result), void *ctx) { return 0; }
|
||||
int nullseat_confirm_weak_crypto_primitive(
|
||||
Seat *seat, const char *algtype, const char *algname,
|
||||
|
@ -224,12 +224,12 @@ static int tempseat_get_userpass_input(Seat *seat, prompts_t *p)
|
||||
unreachable("get_userpass_input should never be called on TempSeat");
|
||||
}
|
||||
|
||||
static int tempseat_verify_ssh_host_key(
|
||||
static int tempseat_confirm_ssh_host_key(
|
||||
Seat *seat, const char *host, int port, const char *keytype,
|
||||
char *keystr, const char *keydisp, char **key_fingerprints,
|
||||
char *keystr, const char *keydisp, char **key_fingerprints, bool mismatch,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
unreachable("verify_ssh_host_key should never be called on TempSeat");
|
||||
unreachable("confirm_ssh_host_key should never be called on TempSeat");
|
||||
}
|
||||
|
||||
static int tempseat_confirm_weak_crypto_primitive(
|
||||
@ -307,7 +307,7 @@ static const struct SeatVtable tempseat_vt = {
|
||||
.update_specials_menu = tempseat_update_specials_menu,
|
||||
.get_ttymode = tempseat_get_ttymode,
|
||||
.set_busy_status = tempseat_set_busy_status,
|
||||
.verify_ssh_host_key = tempseat_verify_ssh_host_key,
|
||||
.confirm_ssh_host_key = tempseat_confirm_ssh_host_key,
|
||||
.confirm_weak_crypto_primitive = tempseat_confirm_weak_crypto_primitive,
|
||||
.confirm_weak_cached_hostkey = tempseat_confirm_weak_cached_hostkey,
|
||||
.is_utf8 = tempseat_is_utf8,
|
||||
|
Reference in New Issue
Block a user