Kalev Lember ca8adb3
diff -up openssl-1.0.0c/apps/genrsa.c.x931 openssl-1.0.0c/apps/genrsa.c
Kalev Lember ca8adb3
--- openssl-1.0.0c/apps/genrsa.c.x931	2010-03-01 15:22:02.000000000 +0100
Kalev Lember ca8adb3
+++ openssl-1.0.0c/apps/genrsa.c	2011-02-01 18:32:05.000000000 +0100
Kalev Lember ca8adb3
@@ -95,6 +95,7 @@ int MAIN(int argc, char **argv)
Kalev Lember ca8adb3
 	int ret=1;
Kalev Lember ca8adb3
 	int i,num=DEFBITS;
Kalev Lember ca8adb3
 	long l;
Kalev Lember ca8adb3
+	int use_x931 = 0;
Kalev Lember ca8adb3
 	const EVP_CIPHER *enc=NULL;
Kalev Lember ca8adb3
 	unsigned long f4=RSA_F4;
Kalev Lember ca8adb3
 	char *outfile=NULL;
Kalev Lember ca8adb3
@@ -138,6 +139,8 @@ int MAIN(int argc, char **argv)
Kalev Lember ca8adb3
 			f4=3;
Kalev Lember ca8adb3
 		else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0)
Kalev Lember ca8adb3
 			f4=RSA_F4;
Kalev Lember ca8adb3
+		else if (strcmp(*argv,"-x931") == 0)
Kalev Lember ca8adb3
+			use_x931 = 1;
Kalev Lember ca8adb3
 #ifndef OPENSSL_NO_ENGINE
Kalev Lember ca8adb3
 		else if (strcmp(*argv,"-engine") == 0)
Kalev Lember ca8adb3
 			{
Kalev Lember ca8adb3
@@ -273,7 +276,14 @@ bad:
Kalev Lember ca8adb3
 	if (!rsa)
Kalev Lember ca8adb3
 		goto err;
Kalev Lember ca8adb3
 
Kalev Lember ca8adb3
-	if(!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
Kalev Lember ca8adb3
+	if (use_x931)
Kalev Lember ca8adb3
+		{
Kalev Lember ca8adb3
+		if (!BN_set_word(bn, f4))
Kalev Lember ca8adb3
+			goto err;
Kalev Lember ca8adb3
+		if (!RSA_X931_generate_key_ex(rsa, num, bn, &cb))
Kalev Lember ca8adb3
+			goto err;
Kalev Lember ca8adb3
+		}
Kalev Lember ca8adb3
+	else if(!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
Kalev Lember ca8adb3
 		goto err;
Kalev Lember ca8adb3
 		
Kalev Lember ca8adb3
 	app_RAND_write_file(NULL, bio_err);