aboutsummaryrefslogtreecommitdiff
path: root/apps/genrsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/genrsa.c')
-rw-r--r--apps/genrsa.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/genrsa.c b/apps/genrsa.c
index 1599bb7a69d6..fdc0d4a07dfe 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -95,6 +95,7 @@ int MAIN(int argc, char **argv)
int ret=1;
int i,num=DEFBITS;
long l;
+ int use_x931 = 0;
const EVP_CIPHER *enc=NULL;
unsigned long f4=RSA_F4;
char *outfile=NULL;
@@ -138,6 +139,8 @@ int MAIN(int argc, char **argv)
f4=3;
else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0)
f4=RSA_F4;
+ else if (strcmp(*argv,"-x931") == 0)
+ use_x931 = 1;
#ifndef OPENSSL_NO_ENGINE
else if (strcmp(*argv,"-engine") == 0)
{
@@ -266,7 +269,17 @@ bad:
BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
num);
- if(!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
+ if (use_x931)
+ {
+ BIGNUM *pubexp;
+ pubexp = BN_new();
+ if (!BN_set_word(pubexp, f4))
+ goto err;
+ if (!RSA_X931_generate_key_ex(rsa, num, pubexp, &cb))
+ goto err;
+ BN_free(pubexp);
+ }
+ else if(!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
goto err;
app_RAND_write_file(NULL, bio_err);