#include <stdio.h>
#include <stdlib.h>
-#include "apps.h"
#include <time.h>
#include <string.h>
#include "apps.h"
static int verbose = 0;
-static int gendsa_cb(EVP_PKEY_CTX *ctx);
-
typedef enum OPTION_choice {
OPT_COMMON,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT,
if (argc == 1) {
if (!opt_int(argv[0], &num) || num < 0)
goto opthelp;
- } else if (argc != 0) {
+ } else if (!opt_check_rest_arg(NULL)) {
goto opthelp;
}
if (!app_RAND_load())
" Your key size is %d! Larger key size may behave not as expected.\n",
OPENSSL_DSA_MAX_MODULUS_BITS, numbits);
- EVP_PKEY_CTX_set_cb(ctx, gendsa_cb);
EVP_PKEY_CTX_set_app_data(ctx, bio_err);
if (verbose) {
+ EVP_PKEY_CTX_set_cb(ctx, progress_cb);
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
num);
BIO_printf(bio_err, "This could take some time\n");
"Error, DSA key generation context allocation failed\n");
goto end;
}
- if (!EVP_PKEY_keygen_init(ctx)) {
+ if (EVP_PKEY_keygen_init(ctx) <= 0) {
BIO_printf(bio_err,
"Error, unable to initialise for key generation\n");
goto end;
return ret;
}
-static int gendsa_cb(EVP_PKEY_CTX *ctx)
-{
- static const char symbols[] = ".+*\n";
- int p;
- char c;
- BIO *b;
-
- if (!verbose)
- return 1;
-
- b = EVP_PKEY_CTX_get_app_data(ctx);
- p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
- c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
-
- BIO_write(b, &c, 1);
- (void)BIO_flush(b);
- return 1;
-}