mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-23 15:09:24 -05: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:
parent
a63435f6cc
commit
ba3d8fd1b9
17
cmdgen.c
17
cmdgen.c
@ -273,7 +273,7 @@ int main(int argc, char **argv)
|
|||||||
char *outfile = NULL, *outfiletmp = NULL;
|
char *outfile = NULL, *outfiletmp = NULL;
|
||||||
enum { PRIVATE, PUBLIC, PUBLICO, FP, OPENSSH_PEM,
|
enum { PRIVATE, PUBLIC, PUBLICO, FP, OPENSSH_PEM,
|
||||||
OPENSSH_NEW, SSHCOM } outtype = PRIVATE;
|
OPENSSH_NEW, SSHCOM } outtype = PRIVATE;
|
||||||
int bits = 2048;
|
int bits = -1;
|
||||||
char *comment = NULL, *origcomment = NULL;
|
char *comment = NULL, *origcomment = NULL;
|
||||||
int change_passphrase = FALSE;
|
int change_passphrase = FALSE;
|
||||||
int errs = FALSE, nogo = 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)) {
|
if (keytype == ECDSA && (bits != 256 && bits != 384 && bits != 521)) {
|
||||||
fprintf(stderr, "puttygen: invalid bits for ECDSA, choose 256, 384 or 521\n");
|
fprintf(stderr, "puttygen: invalid bits for ECDSA, choose 256, 384 or 521\n");
|
||||||
errs = TRUE;
|
errs = TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user