ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/gvpectrl.C
(Generate patch)

Comparing gvpe/src/gvpectrl.C (file contents):
Revision 1.12 by root, Sun Mar 6 13:49:50 2011 UTC vs.
Revision 1.13 by root, Fri Jul 5 10:04:22 2013 UTC

1/* 1/*
2 gvpectrl.C -- the main file for gvpectrl 2 gvpectrl.C -- the main file for gvpectrl
3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl> 3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
4 2000-2002 Guus Sliepen <guus@sliepen.eu.org> 4 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
5 2003-2011 Marc Lehmann <gvpe@schmorp.de> 5 2003-2013 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE. 7 This file is part of GVPE.
8 8
9 GVPE is free software; you can redistribute it and/or modify it 9 GVPE is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
44#include <sys/stat.h> 44#include <sys/stat.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <unistd.h> 46#include <unistd.h>
47#include <signal.h> 47#include <signal.h>
48 48
49#include <openssl/bn.h>
49#include <openssl/rand.h> 50#include <openssl/rand.h>
50#include <openssl/rsa.h> 51#include <openssl/rsa.h>
51#include <openssl/pem.h> 52#include <openssl/pem.h>
52#include <openssl/evp.h> 53#include <openssl/evp.h>
53 54
183 } 184 }
184 } 185 }
185} 186}
186 187
187// this function prettyprints the key generation process 188// this function prettyprints the key generation process
188static void 189static int
189indicator (int a, int b, void *p) 190indicator (int a, int b, BN_GENCB *cb)
190{ 191{
191 if (quiet) 192 if (quiet)
192 return; 193 return 1;
193 194
194 switch (a) 195 switch (a)
195 { 196 {
196 case 0: 197 case 0:
197 fprintf (stderr, "."); 198 fprintf (stderr, ".");
222 break; 223 break;
223 224
224 default: 225 default:
225 fprintf (stderr, "?"); 226 fprintf (stderr, "?");
226 } 227 }
228
229 return 1;
227} 230}
228 231
229/* 232/*
230 * generate public/private RSA keypairs for all hosts that don't have one. 233 * generate public/private RSA keypairs for all hosts that don't have one.
231 */ 234 */
232static int 235static int
233keygen (int bits) 236keygen (int bits)
234{ 237{
235 RSA *rsa_key;
236 FILE *f; 238 FILE *f;
237 char *name = NULL; 239 char *name = NULL;
238 char *fname; 240 char *fname;
239 241
240 asprintf (&fname, "%s/hostkeys", confbase); 242 asprintf (&fname, "%s/hostkeys", confbase);
271 } 273 }
272 274
273 fprintf (stderr, _("generating %d bits key for %s:\n"), bits, 275 fprintf (stderr, _("generating %d bits key for %s:\n"), bits,
274 node->nodename); 276 node->nodename);
275 277
276 rsa_key = RSA_generate_key (bits, 0xFFFF, indicator, NULL); 278 RSA *rsa = RSA_new ();
279 BIGNUM *e = BN_new ();
280 BN_set_bit (e, 0); BN_set_bit (e, 16); // 0x10001, 65537
281 BN_GENCB cb;
282 BN_GENCB_set (&cb, indicator, 0);
277 283
278 if (!rsa_key) 284 require (RSA_generate_key_ex (rsa, bits, e, &cb));
279 { 285
280 fprintf (stderr, _("error during key generation!\n"));
281 return -1;
282 }
283 else
284 fprintf (stderr, _("Done.\n")); 286 fprintf (stderr, _("Done.\n"));
285 287
286 require (PEM_write_RSAPublicKey (f, rsa_key)); 288 require (PEM_write_RSAPublicKey (f, rsa));
287 fclose (f); 289 fclose (f);
288 free (fname); 290 free (fname);
289 291
290 asprintf (&fname, "%s/hostkeys/%s", confbase, node->nodename); 292 asprintf (&fname, "%s/hostkeys/%s", confbase, node->nodename);
291 293
294 { 296 {
295 perror (fname); 297 perror (fname);
296 exit (EXIT_FAILURE); 298 exit (EXIT_FAILURE);
297 } 299 }
298 300
299 require (PEM_write_RSAPrivateKey (f, rsa_key, NULL, NULL, 0, NULL, NULL)); 301 require (PEM_write_RSAPrivateKey (f, rsa, NULL, NULL, 0, NULL, NULL));
300 fclose (f); 302 fclose (f);
301 free (fname); 303 free (fname);
304
305 BN_free (e);
306 RSA_free (rsa);
302 } 307 }
303 308
304 return 0; 309 return 0;
305} 310}
306 311
320 { 325 {
321 printf (_("%s version %s (built %s %s, protocol version %d.%d)\n"), get_identity (), 326 printf (_("%s version %s (built %s %s, protocol version %d.%d)\n"), get_identity (),
322 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 327 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
323 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); 328 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
324 printf (_ 329 printf (_
325 ("Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de> and others.\n" 330 ("Copyright (C) 2003-2013 Marc Lehmann <gvpe@schmorp.de> and others.\n"
326 "See the AUTHORS file for a complete list.\n\n" 331 "See the AUTHORS file for a complete list.\n\n"
327 "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n" 332 "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
328 "and you are welcome to redistribute it under certain conditions;\n" 333 "and you are welcome to redistribute it under certain conditions;\n"
329 "see the file COPYING for details.\n")); 334 "see the file COPYING for details.\n"));
330 335

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines