diff options
Diffstat (limited to 'src/lib/libssl/src/apps/genrsa.c')
| -rw-r--r-- | src/lib/libssl/src/apps/genrsa.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c index 6fe578d69f..e7445e6a49 100644 --- a/src/lib/libssl/src/apps/genrsa.c +++ b/src/lib/libssl/src/apps/genrsa.c | |||
| @@ -69,6 +69,7 @@ | |||
| 69 | #include <openssl/evp.h> | 69 | #include <openssl/evp.h> |
| 70 | #include <openssl/x509.h> | 70 | #include <openssl/x509.h> |
| 71 | #include <openssl/pem.h> | 71 | #include <openssl/pem.h> |
| 72 | #include <openssl/engine.h> | ||
| 72 | 73 | ||
| 73 | #define DEFBITS 512 | 74 | #define DEFBITS 512 |
| 74 | #undef PROG | 75 | #undef PROG |
| @@ -80,6 +81,7 @@ int MAIN(int, char **); | |||
| 80 | 81 | ||
| 81 | int MAIN(int argc, char **argv) | 82 | int MAIN(int argc, char **argv) |
| 82 | { | 83 | { |
| 84 | ENGINE *e = NULL; | ||
| 83 | int ret=1; | 85 | int ret=1; |
| 84 | RSA *rsa=NULL; | 86 | RSA *rsa=NULL; |
| 85 | int i,num=DEFBITS; | 87 | int i,num=DEFBITS; |
| @@ -88,6 +90,7 @@ int MAIN(int argc, char **argv) | |||
| 88 | unsigned long f4=RSA_F4; | 90 | unsigned long f4=RSA_F4; |
| 89 | char *outfile=NULL; | 91 | char *outfile=NULL; |
| 90 | char *passargout = NULL, *passout = NULL; | 92 | char *passargout = NULL, *passout = NULL; |
| 93 | char *engine=NULL; | ||
| 91 | char *inrand=NULL; | 94 | char *inrand=NULL; |
| 92 | BIO *out=NULL; | 95 | BIO *out=NULL; |
| 93 | 96 | ||
| @@ -114,8 +117,13 @@ int MAIN(int argc, char **argv) | |||
| 114 | } | 117 | } |
| 115 | else if (strcmp(*argv,"-3") == 0) | 118 | else if (strcmp(*argv,"-3") == 0) |
| 116 | f4=3; | 119 | f4=3; |
| 117 | else if (strcmp(*argv,"-F4") == 0) | 120 | else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0) |
| 118 | f4=RSA_F4; | 121 | f4=RSA_F4; |
| 122 | else if (strcmp(*argv,"-engine") == 0) | ||
| 123 | { | ||
| 124 | if (--argc < 1) goto bad; | ||
| 125 | engine= *(++argv); | ||
| 126 | } | ||
| 119 | else if (strcmp(*argv,"-rand") == 0) | 127 | else if (strcmp(*argv,"-rand") == 0) |
| 120 | { | 128 | { |
| 121 | if (--argc < 1) goto bad; | 129 | if (--argc < 1) goto bad; |
| @@ -154,6 +162,7 @@ bad: | |||
| 154 | BIO_printf(bio_err," -passout arg output file pass phrase source\n"); | 162 | BIO_printf(bio_err," -passout arg output file pass phrase source\n"); |
| 155 | BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n"); | 163 | BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n"); |
| 156 | BIO_printf(bio_err," -3 use 3 for the E value\n"); | 164 | BIO_printf(bio_err," -3 use 3 for the E value\n"); |
| 165 | BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); | ||
| 157 | BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); | 166 | BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); |
| 158 | BIO_printf(bio_err," load the file (or the files in the directory) into\n"); | 167 | BIO_printf(bio_err," load the file (or the files in the directory) into\n"); |
| 159 | BIO_printf(bio_err," the random number generator\n"); | 168 | BIO_printf(bio_err," the random number generator\n"); |
| @@ -167,8 +176,34 @@ bad: | |||
| 167 | goto err; | 176 | goto err; |
| 168 | } | 177 | } |
| 169 | 178 | ||
| 179 | if (engine != NULL) | ||
| 180 | { | ||
| 181 | if((e = ENGINE_by_id(engine)) == NULL) | ||
| 182 | { | ||
| 183 | BIO_printf(bio_err,"invalid engine \"%s\"\n", | ||
| 184 | engine); | ||
| 185 | goto err; | ||
| 186 | } | ||
| 187 | if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) | ||
| 188 | { | ||
| 189 | BIO_printf(bio_err,"can't use that engine\n"); | ||
| 190 | goto err; | ||
| 191 | } | ||
| 192 | BIO_printf(bio_err,"engine \"%s\" set.\n", engine); | ||
| 193 | /* Free our "structural" reference. */ | ||
| 194 | ENGINE_free(e); | ||
| 195 | } | ||
| 196 | |||
| 170 | if (outfile == NULL) | 197 | if (outfile == NULL) |
| 198 | { | ||
| 171 | BIO_set_fp(out,stdout,BIO_NOCLOSE); | 199 | BIO_set_fp(out,stdout,BIO_NOCLOSE); |
| 200 | #ifdef VMS | ||
| 201 | { | ||
| 202 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); | ||
| 203 | out = BIO_push(tmpbio, out); | ||
| 204 | } | ||
| 205 | #endif | ||
| 206 | } | ||
| 172 | else | 207 | else |
| 173 | { | 208 | { |
| 174 | if (BIO_write_filename(out,outfile) <= 0) | 209 | if (BIO_write_filename(out,outfile) <= 0) |
| @@ -178,7 +213,8 @@ bad: | |||
| 178 | } | 213 | } |
| 179 | } | 214 | } |
| 180 | 215 | ||
| 181 | if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL) | 216 | if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL |
| 217 | && !RAND_status()) | ||
| 182 | { | 218 | { |
| 183 | BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n"); | 219 | BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n"); |
| 184 | } | 220 | } |
| @@ -212,8 +248,8 @@ bad: | |||
| 212 | ret=0; | 248 | ret=0; |
| 213 | err: | 249 | err: |
| 214 | if (rsa != NULL) RSA_free(rsa); | 250 | if (rsa != NULL) RSA_free(rsa); |
| 215 | if (out != NULL) BIO_free(out); | 251 | if (out != NULL) BIO_free_all(out); |
| 216 | if(passout) Free(passout); | 252 | if(passout) OPENSSL_free(passout); |
| 217 | if (ret != 0) | 253 | if (ret != 0) |
| 218 | ERR_print_errors(bio_err); | 254 | ERR_print_errors(bio_err); |
| 219 | EXIT(ret); | 255 | EXIT(ret); |
