diff options
Diffstat (limited to 'src/lib/libssl/src/apps/genrsa.c')
| -rw-r--r-- | src/lib/libssl/src/apps/genrsa.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c index 63be873b7b..7dbd0923b6 100644 --- a/src/lib/libssl/src/apps/genrsa.c +++ b/src/lib/libssl/src/apps/genrsa.c | |||
| @@ -88,6 +88,9 @@ int MAIN(int argc, char **argv) | |||
| 88 | RSA *rsa=NULL; | 88 | RSA *rsa=NULL; |
| 89 | int i,num=DEFBITS; | 89 | int i,num=DEFBITS; |
| 90 | long l; | 90 | long l; |
| 91 | #ifdef OPENSSL_FIPS | ||
| 92 | int use_x931 = 0; | ||
| 93 | #endif | ||
| 91 | const EVP_CIPHER *enc=NULL; | 94 | const EVP_CIPHER *enc=NULL; |
| 92 | unsigned long f4=RSA_F4; | 95 | unsigned long f4=RSA_F4; |
| 93 | char *outfile=NULL; | 96 | char *outfile=NULL; |
| @@ -126,6 +129,10 @@ int MAIN(int argc, char **argv) | |||
| 126 | f4=3; | 129 | f4=3; |
| 127 | else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0) | 130 | else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0) |
| 128 | f4=RSA_F4; | 131 | f4=RSA_F4; |
| 132 | #ifdef OPENSSL_FIPS | ||
| 133 | else if (strcmp(*argv,"-x931") == 0) | ||
| 134 | use_x931 = 1; | ||
| 135 | #endif | ||
| 129 | #ifndef OPENSSL_NO_ENGINE | 136 | #ifndef OPENSSL_NO_ENGINE |
| 130 | else if (strcmp(*argv,"-engine") == 0) | 137 | else if (strcmp(*argv,"-engine") == 0) |
| 131 | { | 138 | { |
| @@ -233,11 +240,27 @@ bad: | |||
| 233 | 240 | ||
| 234 | BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n", | 241 | BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n", |
| 235 | num); | 242 | num); |
| 236 | rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err); | 243 | #ifdef OPENSSL_FIPS |
| 244 | if (use_x931) | ||
| 245 | { | ||
| 246 | BIGNUM *pubexp; | ||
| 247 | pubexp = BN_new(); | ||
| 248 | BN_set_word(pubexp, f4); | ||
| 249 | rsa = RSA_X931_generate_key(num, pubexp, genrsa_cb, bio_err); | ||
| 250 | BN_free(pubexp); | ||
| 251 | } | ||
| 252 | else | ||
| 253 | #endif | ||
| 254 | rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err); | ||
| 237 | 255 | ||
| 238 | app_RAND_write_file(NULL, bio_err); | 256 | app_RAND_write_file(NULL, bio_err); |
| 239 | 257 | ||
| 240 | if (rsa == NULL) goto err; | 258 | if (rsa == NULL) |
| 259 | { | ||
| 260 | BIO_printf(bio_err, "Key Generation error\n"); | ||
| 261 | |||
| 262 | goto err; | ||
| 263 | } | ||
| 241 | 264 | ||
| 242 | /* We need to do the following for when the base number size is < | 265 | /* We need to do the following for when the base number size is < |
| 243 | * long, esp windows 3.1 :-(. */ | 266 | * long, esp windows 3.1 :-(. */ |
