diff options
Diffstat (limited to 'src/lib/libssl/src/apps/gendsa.c')
| -rw-r--r-- | src/lib/libssl/src/apps/gendsa.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/lib/libssl/src/apps/gendsa.c b/src/lib/libssl/src/apps/gendsa.c index b1a1c4fcfa..1c0ec371d2 100644 --- a/src/lib/libssl/src/apps/gendsa.c +++ b/src/lib/libssl/src/apps/gendsa.c | |||
| @@ -68,6 +68,7 @@ | |||
| 68 | #include <openssl/dsa.h> | 68 | #include <openssl/dsa.h> |
| 69 | #include <openssl/x509.h> | 69 | #include <openssl/x509.h> |
| 70 | #include <openssl/pem.h> | 70 | #include <openssl/pem.h> |
| 71 | #include <openssl/engine.h> | ||
| 71 | 72 | ||
| 72 | #define DEFBITS 512 | 73 | #define DEFBITS 512 |
| 73 | #undef PROG | 74 | #undef PROG |
| @@ -77,6 +78,7 @@ int MAIN(int, char **); | |||
| 77 | 78 | ||
| 78 | int MAIN(int argc, char **argv) | 79 | int MAIN(int argc, char **argv) |
| 79 | { | 80 | { |
| 81 | ENGINE *e = NULL; | ||
| 80 | DSA *dsa=NULL; | 82 | DSA *dsa=NULL; |
| 81 | int ret=1; | 83 | int ret=1; |
| 82 | char *outfile=NULL; | 84 | char *outfile=NULL; |
| @@ -84,6 +86,7 @@ int MAIN(int argc, char **argv) | |||
| 84 | char *passargout = NULL, *passout = NULL; | 86 | char *passargout = NULL, *passout = NULL; |
| 85 | BIO *out=NULL,*in=NULL; | 87 | BIO *out=NULL,*in=NULL; |
| 86 | EVP_CIPHER *enc=NULL; | 88 | EVP_CIPHER *enc=NULL; |
| 89 | char *engine=NULL; | ||
| 87 | 90 | ||
| 88 | apps_startup(); | 91 | apps_startup(); |
| 89 | 92 | ||
| @@ -106,6 +109,11 @@ int MAIN(int argc, char **argv) | |||
| 106 | if (--argc < 1) goto bad; | 109 | if (--argc < 1) goto bad; |
| 107 | passargout= *(++argv); | 110 | passargout= *(++argv); |
| 108 | } | 111 | } |
| 112 | else if (strcmp(*argv,"-engine") == 0) | ||
| 113 | { | ||
| 114 | if (--argc < 1) goto bad; | ||
| 115 | engine= *(++argv); | ||
| 116 | } | ||
| 109 | else if (strcmp(*argv,"-rand") == 0) | 117 | else if (strcmp(*argv,"-rand") == 0) |
| 110 | { | 118 | { |
| 111 | if (--argc < 1) goto bad; | 119 | if (--argc < 1) goto bad; |
| @@ -145,6 +153,7 @@ bad: | |||
| 145 | #ifndef NO_IDEA | 153 | #ifndef NO_IDEA |
| 146 | BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n"); | 154 | BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n"); |
| 147 | #endif | 155 | #endif |
| 156 | BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n"); | ||
| 148 | BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); | 157 | BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); |
| 149 | BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); | 158 | BIO_printf(bio_err," - load the file (or the files in the directory) into\n"); |
| 150 | BIO_printf(bio_err," the random number generator\n"); | 159 | BIO_printf(bio_err," the random number generator\n"); |
| @@ -153,6 +162,24 @@ bad: | |||
| 153 | goto end; | 162 | goto end; |
| 154 | } | 163 | } |
| 155 | 164 | ||
| 165 | if (engine != NULL) | ||
| 166 | { | ||
| 167 | if((e = ENGINE_by_id(engine)) == NULL) | ||
| 168 | { | ||
| 169 | BIO_printf(bio_err,"invalid engine \"%s\"\n", | ||
| 170 | engine); | ||
| 171 | goto end; | ||
| 172 | } | ||
| 173 | if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) | ||
| 174 | { | ||
| 175 | BIO_printf(bio_err,"can't use that engine\n"); | ||
| 176 | goto end; | ||
| 177 | } | ||
| 178 | BIO_printf(bio_err,"engine \"%s\" set.\n", engine); | ||
| 179 | /* Free our "structural" reference. */ | ||
| 180 | ENGINE_free(e); | ||
| 181 | } | ||
| 182 | |||
| 156 | if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { | 183 | if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { |
| 157 | BIO_printf(bio_err, "Error getting password\n"); | 184 | BIO_printf(bio_err, "Error getting password\n"); |
| 158 | goto end; | 185 | goto end; |
| @@ -178,7 +205,15 @@ bad: | |||
| 178 | if (out == NULL) goto end; | 205 | if (out == NULL) goto end; |
| 179 | 206 | ||
| 180 | if (outfile == NULL) | 207 | if (outfile == NULL) |
| 208 | { | ||
| 181 | BIO_set_fp(out,stdout,BIO_NOCLOSE); | 209 | BIO_set_fp(out,stdout,BIO_NOCLOSE); |
| 210 | #ifdef VMS | ||
| 211 | { | ||
| 212 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); | ||
| 213 | out = BIO_push(tmpbio, out); | ||
| 214 | } | ||
| 215 | #endif | ||
| 216 | } | ||
| 182 | else | 217 | else |
| 183 | { | 218 | { |
| 184 | if (BIO_write_filename(out,outfile) <= 0) | 219 | if (BIO_write_filename(out,outfile) <= 0) |
| @@ -209,9 +244,9 @@ end: | |||
| 209 | if (ret != 0) | 244 | if (ret != 0) |
| 210 | ERR_print_errors(bio_err); | 245 | ERR_print_errors(bio_err); |
| 211 | if (in != NULL) BIO_free(in); | 246 | if (in != NULL) BIO_free(in); |
| 212 | if (out != NULL) BIO_free(out); | 247 | if (out != NULL) BIO_free_all(out); |
| 213 | if (dsa != NULL) DSA_free(dsa); | 248 | if (dsa != NULL) DSA_free(dsa); |
| 214 | if(passout) Free(passout); | 249 | if(passout) OPENSSL_free(passout); |
| 215 | EXIT(ret); | 250 | EXIT(ret); |
| 216 | } | 251 | } |
| 217 | #endif | 252 | #endif |
