mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Expose a global list of known host key algorithms.
The information was already centralised in find_pubkey_alg, but that had a query-based API that couldn't enumerate the key types. Now I expose an underlying array so that it's possible to iterate over them. Also, I'd forgotten to add the two new rsa-sha2-* algorithms to find_pubkey_alg. That's also done as part of this commit.
This commit is contained in:
parent
e105908661
commit
24444eb396
2
ssh.h
2
ssh.h
@ -1230,6 +1230,8 @@ int rsa1_loadpub_s(BinarySource *src, BinarySink *bs,
|
|||||||
int rsa1_loadpub_f(const Filename *filename, BinarySink *bs,
|
int rsa1_loadpub_f(const Filename *filename, BinarySink *bs,
|
||||||
char **commentptr, const char **errorstr);
|
char **commentptr, const char **errorstr);
|
||||||
|
|
||||||
|
extern const ssh_keyalg *const all_keyalgs[];
|
||||||
|
extern const size_t n_keyalgs;
|
||||||
const ssh_keyalg *find_pubkey_alg(const char *name);
|
const ssh_keyalg *find_pubkey_alg(const char *name);
|
||||||
const ssh_keyalg *find_pubkey_alg_len(ptrlen name);
|
const ssh_keyalg *find_pubkey_alg_len(ptrlen name);
|
||||||
|
|
||||||
|
34
sshpubk.c
34
sshpubk.c
@ -634,24 +634,26 @@ static bool read_blob(BinarySource *src, int nlines, BinarySink *bs)
|
|||||||
*/
|
*/
|
||||||
ssh2_userkey ssh2_wrong_passphrase = { NULL, NULL };
|
ssh2_userkey ssh2_wrong_passphrase = { NULL, NULL };
|
||||||
|
|
||||||
|
const ssh_keyalg *const all_keyalgs[] = {
|
||||||
|
&ssh_rsa,
|
||||||
|
&ssh_rsa_sha256,
|
||||||
|
&ssh_rsa_sha512,
|
||||||
|
&ssh_dss,
|
||||||
|
&ssh_ecdsa_nistp256,
|
||||||
|
&ssh_ecdsa_nistp384,
|
||||||
|
&ssh_ecdsa_nistp521,
|
||||||
|
&ssh_ecdsa_ed25519,
|
||||||
|
&ssh_ecdsa_ed448,
|
||||||
|
};
|
||||||
|
const size_t n_keyalgs = lenof(all_keyalgs);
|
||||||
|
|
||||||
const ssh_keyalg *find_pubkey_alg_len(ptrlen name)
|
const ssh_keyalg *find_pubkey_alg_len(ptrlen name)
|
||||||
{
|
{
|
||||||
if (ptrlen_eq_string(name, "ssh-rsa"))
|
for (size_t i = 0; i < n_keyalgs; i++)
|
||||||
return &ssh_rsa;
|
if (ptrlen_eq_string(name, all_keyalgs[i]->ssh_id))
|
||||||
else if (ptrlen_eq_string(name, "ssh-dss"))
|
return all_keyalgs[i];
|
||||||
return &ssh_dss;
|
|
||||||
else if (ptrlen_eq_string(name, "ecdsa-sha2-nistp256"))
|
return NULL;
|
||||||
return &ssh_ecdsa_nistp256;
|
|
||||||
else if (ptrlen_eq_string(name, "ecdsa-sha2-nistp384"))
|
|
||||||
return &ssh_ecdsa_nistp384;
|
|
||||||
else if (ptrlen_eq_string(name, "ecdsa-sha2-nistp521"))
|
|
||||||
return &ssh_ecdsa_nistp521;
|
|
||||||
else if (ptrlen_eq_string(name, "ssh-ed25519"))
|
|
||||||
return &ssh_ecdsa_ed25519;
|
|
||||||
else if (ptrlen_eq_string(name, "ssh-ed448"))
|
|
||||||
return &ssh_ecdsa_ed448;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ssh_keyalg *find_pubkey_alg(const char *name)
|
const ssh_keyalg *find_pubkey_alg(const char *name)
|
||||||
|
Loading…
Reference in New Issue
Block a user