1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Vary cmdgen's default key size based on key type.

It's a bit silly to have 'puttygen -t ecdsa' immediately crash out
because the default key size is 2048 and we don't know a 2048-bit
elliptic curve.
This commit is contained in:
Simon Tatham 2015-05-09 15:02:47 +01:00
parent a63435f6cc
commit ba3d8fd1b9

View File

@ -273,7 +273,7 @@ int main(int argc, char **argv)
char *outfile = NULL, *outfiletmp = NULL;
enum { PRIVATE, PUBLIC, PUBLICO, FP, OPENSSH_PEM,
OPENSSH_NEW, SSHCOM } outtype = PRIVATE;
int bits = 2048;
int bits = -1;
char *comment = NULL, *origcomment = NULL;
int change_passphrase = FALSE;
int errs = FALSE, nogo = FALSE;
@ -507,6 +507,21 @@ int main(int argc, char **argv)
}
}
if (bits == -1) {
/*
* No explicit key size was specified. Default varies
* depending on key type.
*/
switch (keytype) {
case ECDSA:
bits = 384;
break;
default:
bits = 2048;
break;
}
}
if (keytype == ECDSA && (bits != 256 && bits != 384 && bits != 521)) {
fprintf(stderr, "puttygen: invalid bits for ECDSA, choose 256, 384 or 521\n");
errs = TRUE;