mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 20:42:48 -05:00
ssh_keyalg: new method 'alternate_ssh_id'.
Previously, the fact that "ssh-rsa" sometimes comes with two subtypes "rsa-sha2-256" and "rsa-sha2-512" was known to three different parts of the code - two in userauth and one in transport. Now the knowledge of what those ids are, which one goes with which signing flags, and which key types have subtypes at all, is centralised into a method of the key algorithm, and all those locations just query it. This will enable the introduction of further key algorithms that have a parallel upgrade system.
This commit is contained in:
12
crypto/rsa.c
12
crypto/rsa.c
@ -844,6 +844,15 @@ static unsigned ssh_rsa_supported_flags(const ssh_keyalg *self)
|
||||
return SSH_AGENT_RSA_SHA2_256 | SSH_AGENT_RSA_SHA2_512;
|
||||
}
|
||||
|
||||
const char *ssh_rsa_alternate_ssh_id(const ssh_keyalg *self, unsigned flags)
|
||||
{
|
||||
if (flags & SSH_AGENT_RSA_SHA2_512)
|
||||
return ssh_rsa_sha512.ssh_id;
|
||||
if (flags & SSH_AGENT_RSA_SHA2_256)
|
||||
return ssh_rsa_sha256.ssh_id;
|
||||
return self->ssh_id;
|
||||
}
|
||||
|
||||
static const struct ssh2_rsa_extra
|
||||
rsa_extra = { 0 },
|
||||
rsa_sha256_extra = { SSH_AGENT_RSA_SHA2_256 },
|
||||
@ -869,6 +878,7 @@ const ssh_keyalg ssh_rsa = {
|
||||
COMMON_KEYALG_FIELDS,
|
||||
.ssh_id = "ssh-rsa",
|
||||
.supported_flags = ssh_rsa_supported_flags,
|
||||
.alternate_ssh_id = ssh_rsa_alternate_ssh_id,
|
||||
.extra = &rsa_extra,
|
||||
};
|
||||
|
||||
@ -876,6 +886,7 @@ const ssh_keyalg ssh_rsa_sha256 = {
|
||||
COMMON_KEYALG_FIELDS,
|
||||
.ssh_id = "rsa-sha2-256",
|
||||
.supported_flags = nullkey_supported_flags,
|
||||
.alternate_ssh_id = nullkey_alternate_ssh_id,
|
||||
.extra = &rsa_sha256_extra,
|
||||
};
|
||||
|
||||
@ -883,6 +894,7 @@ const ssh_keyalg ssh_rsa_sha512 = {
|
||||
COMMON_KEYALG_FIELDS,
|
||||
.ssh_id = "rsa-sha2-512",
|
||||
.supported_flags = nullkey_supported_flags,
|
||||
.alternate_ssh_id = nullkey_alternate_ssh_id,
|
||||
.extra = &rsa_sha512_extra,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user