]> asedeno.scripts.mit.edu Git - PuTTY.git/commit - cmdgen.c
Clean up elliptic curve selection and naming.
authorSimon Tatham <anakin@pobox.com>
Fri, 15 May 2015 09:13:05 +0000 (10:13 +0100)
committerSimon Tatham <anakin@pobox.com>
Fri, 15 May 2015 09:15:35 +0000 (10:15 +0100)
commit7db526c7306a12d86bff9ce1de00e9838987c0af
tree3eba8e8220d6069e2ec516f6c6e121023d848675
parent1293334ebf50805a3e150d8808f7013bdcf8f1b3
Clean up elliptic curve selection and naming.

The ec_name_to_curve and ec_curve_to_name functions shouldn't really
have had to exist at all: whenever any part of the PuTTY codebase
starts using sshecc.c, it's starting from an ssh_signkey or ssh_kex
pointer already found by some other means. So if we make sure not to
lose that pointer, we should never need to do any string-based lookups
to find the curve we want, and conversely, when we need to know the
name of our curve or our algorithm, we should be able to look it up as
a straightforward const char * starting from the algorithm pointer.

This commit cleans things up so that that is indeed what happens. The
ssh_signkey and ssh_kex structures defined in sshecc.c now have
'extra' fields containing pointers to all the necessary stuff;
ec_name_to_curve and ec_curve_to_name have been completely removed;
struct ec_curve has a string field giving the curve's name (but only
for those curves which _have_ a name exposed in the wire protocol,
i.e. the three NIST ones); struct ec_key keeps a pointer to the
ssh_signkey it started from, and uses that to remember the algorithm
name rather than reconstructing it from the curve. And I think I've
got rid of all the ad-hockery scattered around the code that switches
on curve->fieldBits or manually constructs curve names using stuff
like sprintf("nistp%d"); the only remaining switch on fieldBits
(necessary because that's the UI for choosing a curve in PuTTYgen) is
at least centralised into one place in sshecc.c.

One user-visible result is that the format of ed25519 host keys in the
registry has changed: there's now no curve name prefix on them,
because I think it's not really right to make up a name to use. So any
early adopters who've been using snapshot PuTTY in the last week will
be inconvenienced; sorry about that.
cmdgen.c
import.c
ssh.c
ssh.h
sshecc.c
sshecdsag.c
windows/winpgen.c