summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/apps/genrsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/apps/genrsa.c')
-rw-r--r--src/lib/libssl/src/apps/genrsa.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c
index fdc0d4a07d..37e9310910 100644
--- a/src/lib/libssl/src/apps/genrsa.c
+++ b/src/lib/libssl/src/apps/genrsa.c
@@ -95,7 +95,6 @@ int MAIN(int argc, char **argv)
95 int ret=1; 95 int ret=1;
96 int i,num=DEFBITS; 96 int i,num=DEFBITS;
97 long l; 97 long l;
98 int use_x931 = 0;
99 const EVP_CIPHER *enc=NULL; 98 const EVP_CIPHER *enc=NULL;
100 unsigned long f4=RSA_F4; 99 unsigned long f4=RSA_F4;
101 char *outfile=NULL; 100 char *outfile=NULL;
@@ -106,9 +105,9 @@ int MAIN(int argc, char **argv)
106 char *inrand=NULL; 105 char *inrand=NULL;
107 BIO *out=NULL; 106 BIO *out=NULL;
108 BIGNUM *bn = BN_new(); 107 BIGNUM *bn = BN_new();
109 RSA *rsa = RSA_new(); 108 RSA *rsa = NULL;
110 109
111 if(!bn || !rsa) goto err; 110 if(!bn) goto err;
112 111
113 apps_startup(); 112 apps_startup();
114 BN_GENCB_set(&cb, genrsa_cb, bio_err); 113 BN_GENCB_set(&cb, genrsa_cb, bio_err);
@@ -139,8 +138,6 @@ int MAIN(int argc, char **argv)
139 f4=3; 138 f4=3;
140 else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0) 139 else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0)
141 f4=RSA_F4; 140 f4=RSA_F4;
142 else if (strcmp(*argv,"-x931") == 0)
143 use_x931 = 1;
144#ifndef OPENSSL_NO_ENGINE 141#ifndef OPENSSL_NO_ENGINE
145 else if (strcmp(*argv,"-engine") == 0) 142 else if (strcmp(*argv,"-engine") == 0)
146 { 143 {
@@ -268,18 +265,15 @@ bad:
268 265
269 BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n", 266 BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
270 num); 267 num);
268#ifdef OPENSSL_NO_ENGINE
269 rsa = RSA_new();
270#else
271 rsa = RSA_new_method(e);
272#endif
273 if (!rsa)
274 goto err;
271 275
272 if (use_x931) 276 if(!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
273 {
274 BIGNUM *pubexp;
275 pubexp = BN_new();
276 if (!BN_set_word(pubexp, f4))
277 goto err;
278 if (!RSA_X931_generate_key_ex(rsa, num, pubexp, &cb))
279 goto err;
280 BN_free(pubexp);
281 }
282 else if(!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
283 goto err; 277 goto err;
284 278
285 app_RAND_write_file(NULL, bio_err); 279 app_RAND_write_file(NULL, bio_err);