comparison dropbearkey.c @ 797:45f1bc96f357 ecc

Fix build for dropbearkey and ecdsa with certain options
author Matt Johnston <matt@ucc.asn.au>
date Thu, 09 May 2013 23:24:58 +0800
parents 7f604f9b3756
children c344607b7341
comparison
equal deleted inserted replaced
795:7f604f9b3756 797:45f1bc96f357
74 #endif 74 #endif
75 #ifdef DROPBEAR_DSS 75 #ifdef DROPBEAR_DSS
76 " dss\n" 76 " dss\n"
77 #endif 77 #endif
78 #ifdef DROPBEAR_ECDSA 78 #ifdef DROPBEAR_ECDSA
79 " ecdsa\n" 79 " ecdsa\n"
80 #endif 80 #endif
81 "-f filename Use filename for the secret key\n" 81 "-f filename Use filename for the secret key\n"
82 "-s bits Key size in bits, should be a multiple of 8 (optional)\n" 82 "-s bits Key size in bits, should be a multiple of 8 (optional)\n"
83 #ifdef DROPBEAR_DSS 83 #ifdef DROPBEAR_DSS
84 " DSS has a fixed size of 1024 bits\n" 84 " DSS has a fixed size of 1024 bits\n"
198 fprintf(stderr, "Bits must be an integer\n"); 198 fprintf(stderr, "Bits must be an integer\n");
199 exit(EXIT_FAILURE); 199 exit(EXIT_FAILURE);
200 } 200 }
201 201
202 // TODO: put RSA and DSS size checks into genrsa.c etc 202 // TODO: put RSA and DSS size checks into genrsa.c etc
203 if (keytype == DROPBEAR_SIGNKEY_DSS && bits != 1024) { 203 switch (keytype) {
204 fprintf(stderr, "DSS keys have a fixed size of 1024 bits\n"); 204 #ifdef DROPBEAR_RSA
205 exit(EXIT_FAILURE); 205 case DROPBEAR_SIGNKEY_RSA:
206 } else if (bits < 512 || bits > 4096 || (bits % 8 != 0)) { 206 if (bits < 512 || bits > 4096 || (bits % 8 != 0)) {
207 fprintf(stderr, "Bits must satisfy 512 <= bits <= 4096, and be a" 207 fprintf(stderr, "Bits must satisfy 512 <= bits <= 4096, and be a"
208 " multiple of 8\n"); 208 " multiple of 8\n");
209 exit(EXIT_FAILURE); 209 exit(EXIT_FAILURE);
210 } 210 }
211 } else { 211 break;
212 if (keytype == DROPBEAR_SIGNKEY_DSS) { 212 #endif
213 bits = DSS_DEFAULT_SIZE; 213 #ifdef DROPEAR_DSS
214 } else if (keytype == DROPBEAR_SIGNKEY_RSA) { 214 case DROPBEAR_SIGNKEY_DSS:
215 bits = RSA_DEFAULT_SIZE; 215 if (bits != 1024) {
216 } else if (keytype == DROPBEAR_SIGNKEY_ECDSA_KEYGEN) { 216 fprintf(stderr, "DSS keys have a fixed size of 1024 bits\n");
217 bits = ECDSA_DEFAULT_SIZE; 217 exit(EXIT_FAILURE);
218 } else { 218 }
219 exit(EXIT_FAILURE); /* not reached */ 219 #endif
220 // pass. ecdsa handles checks itself
221 }
222
223 switch (keytype) {
224 #ifdef DROPBEAR_RSA
225 case DROPBEAR_SIGNKEY_RSA:
226 bits = RSA_DEFAULT_SIZE;
227 break;
228 #endif
229 #ifdef DROPBEAR_DSS
230 case DROPBEAR_SIGNKEY_DSS:
231 bits = DSS_DEFAULT_SIZE;
232 break;
233 #endif
234 #ifdef DROPBEAR_ECDSA
235 case DROPBEAR_SIGNKEY_ECDSA_KEYGEN:
236 bits = ECDSA_DEFAULT_SIZE;
237 break;
238 #endif
239 default:
240 exit(EXIT_FAILURE); /* not reached */
220 } 241 }
221 } 242 }
222 243
223 244
224 fprintf(stderr, "Will output %d bit %s secret key to '%s'\n", bits, 245 fprintf(stderr, "Will output %d bit %s secret key to '%s'\n", bits,