--- gvpe/src/gvpectrl.C 2011/03/06 13:49:50 1.12 +++ gvpe/src/gvpectrl.C 2013/07/05 10:04:22 1.13 @@ -2,7 +2,7 @@ gvpectrl.C -- the main file for gvpectrl Copyright (C) 1998-2002 Ivo Timmermans 2000-2002 Guus Sliepen - 2003-2011 Marc Lehmann + 2003-2013 Marc Lehmann This file is part of GVPE. @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -185,11 +186,11 @@ } // this function prettyprints the key generation process -static void -indicator (int a, int b, void *p) +static int +indicator (int a, int b, BN_GENCB *cb) { if (quiet) - return; + return 1; switch (a) { @@ -224,6 +225,8 @@ default: fprintf (stderr, "?"); } + + return 1; } /* @@ -232,7 +235,6 @@ static int keygen (int bits) { - RSA *rsa_key; FILE *f; char *name = NULL; char *fname; @@ -273,17 +275,17 @@ fprintf (stderr, _("generating %d bits key for %s:\n"), bits, node->nodename); - rsa_key = RSA_generate_key (bits, 0xFFFF, indicator, NULL); + RSA *rsa = RSA_new (); + BIGNUM *e = BN_new (); + BN_set_bit (e, 0); BN_set_bit (e, 16); // 0x10001, 65537 + BN_GENCB cb; + BN_GENCB_set (&cb, indicator, 0); - if (!rsa_key) - { - fprintf (stderr, _("error during key generation!\n")); - return -1; - } - else - fprintf (stderr, _("Done.\n")); + require (RSA_generate_key_ex (rsa, bits, e, &cb)); + + fprintf (stderr, _("Done.\n")); - require (PEM_write_RSAPublicKey (f, rsa_key)); + require (PEM_write_RSAPublicKey (f, rsa)); fclose (f); free (fname); @@ -296,9 +298,12 @@ exit (EXIT_FAILURE); } - require (PEM_write_RSAPrivateKey (f, rsa_key, NULL, NULL, 0, NULL, NULL)); + require (PEM_write_RSAPrivateKey (f, rsa, NULL, NULL, 0, NULL, NULL)); fclose (f); free (fname); + + BN_free (e); + RSA_free (rsa); } return 0; @@ -322,7 +327,7 @@ VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); printf (_ - ("Copyright (C) 2003-2008 Marc Lehmann and others.\n" + ("Copyright (C) 2003-2013 Marc Lehmann and others.\n" "See the AUTHORS file for a complete list.\n\n" "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n"