summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/apps/dsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/apps/dsa.c')
-rw-r--r--src/lib/libssl/src/apps/dsa.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/lib/libssl/src/apps/dsa.c b/src/lib/libssl/src/apps/dsa.c
index 4977671b8a..49ca9003ac 100644
--- a/src/lib/libssl/src/apps/dsa.c
+++ b/src/lib/libssl/src/apps/dsa.c
@@ -68,6 +68,7 @@
68#include <openssl/evp.h> 68#include <openssl/evp.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#undef PROG 73#undef PROG
73#define PROG dsa_main 74#define PROG dsa_main
@@ -87,6 +88,7 @@ int MAIN(int, char **);
87 88
88int MAIN(int argc, char **argv) 89int MAIN(int argc, char **argv)
89 { 90 {
91 ENGINE *e = NULL;
90 int ret=1; 92 int ret=1;
91 DSA *dsa=NULL; 93 DSA *dsa=NULL;
92 int i,badops=0; 94 int i,badops=0;
@@ -94,7 +96,7 @@ int MAIN(int argc, char **argv)
94 BIO *in=NULL,*out=NULL; 96 BIO *in=NULL,*out=NULL;
95 int informat,outformat,text=0,noout=0; 97 int informat,outformat,text=0,noout=0;
96 int pubin = 0, pubout = 0; 98 int pubin = 0, pubout = 0;
97 char *infile,*outfile,*prog; 99 char *infile,*outfile,*prog,*engine;
98 char *passargin = NULL, *passargout = NULL; 100 char *passargin = NULL, *passargout = NULL;
99 char *passin = NULL, *passout = NULL; 101 char *passin = NULL, *passout = NULL;
100 int modulus=0; 102 int modulus=0;
@@ -105,6 +107,7 @@ int MAIN(int argc, char **argv)
105 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 107 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
106 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 108 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
107 109
110 engine=NULL;
108 infile=NULL; 111 infile=NULL;
109 outfile=NULL; 112 outfile=NULL;
110 informat=FORMAT_PEM; 113 informat=FORMAT_PEM;
@@ -145,6 +148,11 @@ int MAIN(int argc, char **argv)
145 if (--argc < 1) goto bad; 148 if (--argc < 1) goto bad;
146 passargout= *(++argv); 149 passargout= *(++argv);
147 } 150 }
151 else if (strcmp(*argv,"-engine") == 0)
152 {
153 if (--argc < 1) goto bad;
154 engine= *(++argv);
155 }
148 else if (strcmp(*argv,"-noout") == 0) 156 else if (strcmp(*argv,"-noout") == 0)
149 noout=1; 157 noout=1;
150 else if (strcmp(*argv,"-text") == 0) 158 else if (strcmp(*argv,"-text") == 0)
@@ -176,6 +184,7 @@ bad:
176 BIO_printf(bio_err," -passin arg input file pass phrase source\n"); 184 BIO_printf(bio_err," -passin arg input file pass phrase source\n");
177 BIO_printf(bio_err," -out arg output file\n"); 185 BIO_printf(bio_err," -out arg output file\n");
178 BIO_printf(bio_err," -passout arg output file pass phrase source\n"); 186 BIO_printf(bio_err," -passout arg output file pass phrase source\n");
187 BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n");
179 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n"); 188 BIO_printf(bio_err," -des encrypt PEM output with cbc des\n");
180 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n"); 189 BIO_printf(bio_err," -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
181#ifndef NO_IDEA 190#ifndef NO_IDEA
@@ -189,6 +198,24 @@ bad:
189 198
190 ERR_load_crypto_strings(); 199 ERR_load_crypto_strings();
191 200
201 if (engine != NULL)
202 {
203 if((e = ENGINE_by_id(engine)) == NULL)
204 {
205 BIO_printf(bio_err,"invalid engine \"%s\"\n",
206 engine);
207 goto end;
208 }
209 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
210 {
211 BIO_printf(bio_err,"can't use that engine\n");
212 goto end;
213 }
214 BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
215 /* Free our "structural" reference. */
216 ENGINE_free(e);
217 }
218
192 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { 219 if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
193 BIO_printf(bio_err, "Error getting passwords\n"); 220 BIO_printf(bio_err, "Error getting passwords\n");
194 goto end; 221 goto end;
@@ -233,7 +260,15 @@ bad:
233 } 260 }
234 261
235 if (outfile == NULL) 262 if (outfile == NULL)
263 {
236 BIO_set_fp(out,stdout,BIO_NOCLOSE); 264 BIO_set_fp(out,stdout,BIO_NOCLOSE);
265#ifdef VMS
266 {
267 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
268 out = BIO_push(tmpbio, out);
269 }
270#endif
271 }
237 else 272 else
238 { 273 {
239 if (BIO_write_filename(out,outfile) <= 0) 274 if (BIO_write_filename(out,outfile) <= 0)
@@ -281,10 +316,10 @@ bad:
281 ret=0; 316 ret=0;
282end: 317end:
283 if(in != NULL) BIO_free(in); 318 if(in != NULL) BIO_free(in);
284 if(out != NULL) BIO_free(out); 319 if(out != NULL) BIO_free_all(out);
285 if(dsa != NULL) DSA_free(dsa); 320 if(dsa != NULL) DSA_free(dsa);
286 if(passin) Free(passin); 321 if(passin) OPENSSL_free(passin);
287 if(passout) Free(passout); 322 if(passout) OPENSSL_free(passout);
288 EXIT(ret); 323 EXIT(ret);
289 } 324 }
290#endif 325#endif