comparison dropbearkey.c @ 795:7f604f9b3756 ecc

ecdsa is working
author Matt Johnston <matt@ucc.asn.au>
date Fri, 03 May 2013 23:07:48 +0800
parents d386defb5376
children 45f1bc96f357
comparison
equal deleted inserted replaced
794:d386defb5376 795:7f604f9b3756
51 51
52 #include "genrsa.h" 52 #include "genrsa.h"
53 #include "gendss.h" 53 #include "gendss.h"
54 #include "ecdsa.h" 54 #include "ecdsa.h"
55 #include "crypto_desc.h" 55 #include "crypto_desc.h"
56 #include "random.h"
56 57
57 static void printhelp(char * progname); 58 static void printhelp(char * progname);
58 59
59 #define RSA_DEFAULT_SIZE 1024 60 #define RSA_DEFAULT_SIZE 1024
60 #define DSS_DEFAULT_SIZE 1024 61 #define DSS_DEFAULT_SIZE 1024
118 char * typetext = NULL; 119 char * typetext = NULL;
119 char * sizetext = NULL; 120 char * sizetext = NULL;
120 unsigned int bits; 121 unsigned int bits;
121 int printpub = 0; 122 int printpub = 0;
122 123
124 crypto_init();
125 seedrandom();
126
123 /* get the commandline options */ 127 /* get the commandline options */
124 for (i = 1; i < argc; i++) { 128 for (i = 1; i < argc; i++) {
125 if (argv[i] == NULL) { 129 if (argv[i] == NULL) {
126 continue; /* Whack */ 130 continue; /* Whack */
127 } 131 }
221 typetext, filename); 225 typetext, filename);
222 226
223 /* don't want the file readable by others */ 227 /* don't want the file readable by others */
224 umask(077); 228 umask(077);
225 229
226 crypto_init();
227 seedrandom();
228
229
230 /* now we can generate the key */ 230 /* now we can generate the key */
231 key = new_sign_key(); 231 key = new_sign_key();
232 232
233 fprintf(stderr, "Generating key, this may take a while...\n"); 233 fprintf(stderr, "Generating key, this may take a while...\n");
234 switch(keytype) { 234 switch(keytype) {
243 break; 243 break;
244 #endif 244 #endif
245 #ifdef DROPBEAR_ECDSA 245 #ifdef DROPBEAR_ECDSA
246 case DROPBEAR_SIGNKEY_ECDSA_KEYGEN: 246 case DROPBEAR_SIGNKEY_ECDSA_KEYGEN:
247 key->ecckey = gen_ecdsa_priv_key(bits); 247 key->ecckey = gen_ecdsa_priv_key(bits);
248 keytype = ecdsa_signkey_type(key->ecckey);
248 break; 249 break;
249 #endif 250 #endif
250 default: 251 default:
251 fprintf(stderr, "Internal error, bad key type\n"); 252 fprintf(stderr, "Internal error, bad key type\n");
252 exit(EXIT_FAILURE); 253 exit(EXIT_FAILURE);