Add support for experimental code, not compiled in by default and
[openssl.git] / apps / genrsa.c
index 1599bb7a69d6472bad3bf80cd7ccc78fbbf58dcf..fdc0d4a07dfe159ea8a5f8d38fa0b43ba36a3f2f 100644 (file)
@@ -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);