mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Remove the list of key algorithms in pageant.c.
The only reason those couldn't be replaced with a call to the centralised find_pubkey_alg is because that function takes a zero- terminated string and instead we had a (length,pointer) string. Easily fixed; there's now a find_pubkey_alg_len(), and we call that. This also fixes a string-matching bug in which the sense of memcmp was reversed by mistake for ECDSA keys!
This commit is contained in:
parent
47c9a6ef0b
commit
1f4dc6faa7
14
pageant.c
14
pageant.c
@ -682,18 +682,8 @@ void *pageant_handle_msg(const void *msg, int msglen, int *outlen,
|
|||||||
p += alglen;
|
p += alglen;
|
||||||
|
|
||||||
key = snew(struct ssh2_userkey);
|
key = snew(struct ssh2_userkey);
|
||||||
/* Add further algorithm names here. */
|
key->alg = find_pubkey_alg_len(alglen, alg);
|
||||||
if (alglen == 7 && !memcmp(alg, "ssh-rsa", 7))
|
if (!key->alg) {
|
||||||
key->alg = &ssh_rsa;
|
|
||||||
else if (alglen == 7 && !memcmp(alg, "ssh-dss", 7))
|
|
||||||
key->alg = &ssh_dss;
|
|
||||||
else if (alglen == 19 && memcmp(alg, "ecdsa-sha2-nistp256", 19))
|
|
||||||
key->alg = &ssh_ecdsa_nistp256;
|
|
||||||
else if (alglen == 19 && memcmp(alg, "ecdsa-sha2-nistp384", 19))
|
|
||||||
key->alg = &ssh_ecdsa_nistp384;
|
|
||||||
else if (alglen == 19 && memcmp(alg, "ecdsa-sha2-nistp521", 19))
|
|
||||||
key->alg = &ssh_ecdsa_nistp521;
|
|
||||||
else {
|
|
||||||
sfree(key);
|
sfree(key);
|
||||||
fail_reason = "algorithm unknown";
|
fail_reason = "algorithm unknown";
|
||||||
goto failure;
|
goto failure;
|
||||||
|
1
ssh.h
1
ssh.h
@ -634,6 +634,7 @@ unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
|
|||||||
int ssh2_save_userkey(const Filename *filename, struct ssh2_userkey *key,
|
int ssh2_save_userkey(const Filename *filename, struct ssh2_userkey *key,
|
||||||
char *passphrase);
|
char *passphrase);
|
||||||
const struct ssh_signkey *find_pubkey_alg(const char *name);
|
const struct ssh_signkey *find_pubkey_alg(const char *name);
|
||||||
|
const struct ssh_signkey *find_pubkey_alg_len(int namelen, const char *name);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SSH_KEYTYPE_UNOPENABLE,
|
SSH_KEYTYPE_UNOPENABLE,
|
||||||
|
17
sshpubk.c
17
sshpubk.c
@ -557,22 +557,27 @@ struct ssh2_userkey ssh2_wrong_passphrase = {
|
|||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct ssh_signkey *find_pubkey_alg(const char *name)
|
const struct ssh_signkey *find_pubkey_alg_len(int namelen, const char *name)
|
||||||
{
|
{
|
||||||
if (!strcmp(name, "ssh-rsa"))
|
if (match_ssh_id(namelen, name, "ssh-rsa"))
|
||||||
return &ssh_rsa;
|
return &ssh_rsa;
|
||||||
else if (!strcmp(name, "ssh-dss"))
|
else if (match_ssh_id(namelen, name, "ssh-dss"))
|
||||||
return &ssh_dss;
|
return &ssh_dss;
|
||||||
else if (!strcmp(name, "ecdsa-sha2-nistp256"))
|
else if (match_ssh_id(namelen, name, "ecdsa-sha2-nistp256"))
|
||||||
return &ssh_ecdsa_nistp256;
|
return &ssh_ecdsa_nistp256;
|
||||||
else if (!strcmp(name, "ecdsa-sha2-nistp384"))
|
else if (match_ssh_id(namelen, name, "ecdsa-sha2-nistp384"))
|
||||||
return &ssh_ecdsa_nistp384;
|
return &ssh_ecdsa_nistp384;
|
||||||
else if (!strcmp(name, "ecdsa-sha2-nistp521"))
|
else if (match_ssh_id(namelen, name, "ecdsa-sha2-nistp521"))
|
||||||
return &ssh_ecdsa_nistp521;
|
return &ssh_ecdsa_nistp521;
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct ssh_signkey *find_pubkey_alg(const char *name)
|
||||||
|
{
|
||||||
|
return find_pubkey_alg_len(strlen(name), name);
|
||||||
|
}
|
||||||
|
|
||||||
struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
|
struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
|
||||||
char *passphrase, const char **errorstr)
|
char *passphrase, const char **errorstr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user