Mercurial > dropbear
comparison dropbearkey.c @ 1256:506f7681d0f8 coverity
merge up to date
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 15 Mar 2016 22:45:43 +0800 |
parents | 2bb4c662d1c2 |
children | 750ec4ec4cbe efad433418c4 |
comparison
equal
deleted
inserted
replaced
1219:84cf9062718d | 1256:506f7681d0f8 |
---|---|
103 } | 103 } |
104 | 104 |
105 /* fails fatally */ | 105 /* fails fatally */ |
106 static void check_signkey_bits(enum signkey_type type, int bits) | 106 static void check_signkey_bits(enum signkey_type type, int bits) |
107 { | 107 { |
108 switch (type) { | 108 switch (type) { |
109 #ifdef DROPBEAR_RSA | 109 #ifdef DROPBEAR_RSA |
110 case DROPBEAR_SIGNKEY_RSA: | 110 case DROPBEAR_SIGNKEY_RSA: |
111 if (bits < 512 || bits > 4096 || (bits % 8 != 0)) { | 111 if (bits < 512 || bits > 4096 || (bits % 8 != 0)) { |
112 dropbear_exit("Bits must satisfy 512 <= bits <= 4096, and be a" | 112 dropbear_exit("Bits must satisfy 512 <= bits <= 4096, and be a" |
113 " multiple of 8\n"); | 113 " multiple of 8\n"); |
114 } | 114 } |
115 break; | 115 break; |
116 #endif | 116 #endif |
117 #ifdef DROPEAR_DSS | 117 #ifdef DROPEAR_DSS |
118 case DROPBEAR_SIGNKEY_DSS: | 118 case DROPBEAR_SIGNKEY_DSS: |
119 if (bits != 1024) { | 119 if (bits != 1024) { |
120 dropbear_exit("DSS keys have a fixed size of 1024 bits\n"); | 120 dropbear_exit("DSS keys have a fixed size of 1024 bits\n"); |
121 exit(EXIT_FAILURE); | 121 exit(EXIT_FAILURE); |
122 } | 122 } |
123 #endif | 123 #endif |
124 default: | 124 default: |
125 (void)0; /* quiet, compiler. ecdsa handles checks itself */ | 125 (void)0; /* quiet, compiler. ecdsa handles checks itself */ |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 #if defined(DBMULTI_dropbearkey) || !defined(DROPBEAR_MULTI) | 129 #if defined(DBMULTI_dropbearkey) || !defined(DROPBEAR_MULTI) |
130 #if defined(DBMULTI_dropbearkey) && defined(DROPBEAR_MULTI) | 130 #if defined(DBMULTI_dropbearkey) && defined(DROPBEAR_MULTI) |
131 int dropbearkey_main(int argc, char ** argv) { | 131 int dropbearkey_main(int argc, char ** argv) { |
236 fprintf(stderr, "Bits must be an integer\n"); | 236 fprintf(stderr, "Bits must be an integer\n"); |
237 exit(EXIT_FAILURE); | 237 exit(EXIT_FAILURE); |
238 } | 238 } |
239 | 239 |
240 check_signkey_bits(keytype, bits);; | 240 check_signkey_bits(keytype, bits);; |
241 } | 241 } |
242 | 242 |
243 fprintf(stderr, "Generating key, this may take a while...\n"); | 243 fprintf(stderr, "Generating key, this may take a while...\n"); |
244 if (signkey_generate(keytype, bits, filename) == DROPBEAR_FAILURE) | 244 if (signkey_generate(keytype, bits, filename) == DROPBEAR_FAILURE) |
245 { | 245 { |
246 dropbear_exit("Failed to generate key.\n"); | 246 dropbear_exit("Failed to generate key.\n"); |
247 } | 247 } |
248 | 248 |
249 printpubfile(filename); | 249 printpubfile(filename); |
250 | 250 |
251 return EXIT_SUCCESS; | 251 return EXIT_SUCCESS; |
252 } | 252 } |