summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/apps/gendsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/apps/gendsa.c')
-rw-r--r--src/lib/libssl/src/apps/gendsa.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/lib/libssl/src/apps/gendsa.c b/src/lib/libssl/src/apps/gendsa.c
index 1c0ec371d2..1e1e9f3e4c 100644
--- a/src/lib/libssl/src/apps/gendsa.c
+++ b/src/lib/libssl/src/apps/gendsa.c
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef NO_DSA 59#ifndef OPENSSL_NO_DSA
60#include <stdio.h> 60#include <stdio.h>
61#include <string.h> 61#include <string.h>
62#include <sys/types.h> 62#include <sys/types.h>
@@ -68,7 +68,6 @@
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>
72 71
73#define DEFBITS 512 72#define DEFBITS 512
74#undef PROG 73#undef PROG
@@ -85,7 +84,7 @@ int MAIN(int argc, char **argv)
85 char *inrand=NULL,*dsaparams=NULL; 84 char *inrand=NULL,*dsaparams=NULL;
86 char *passargout = NULL, *passout = NULL; 85 char *passargout = NULL, *passout = NULL;
87 BIO *out=NULL,*in=NULL; 86 BIO *out=NULL,*in=NULL;
88 EVP_CIPHER *enc=NULL; 87 const EVP_CIPHER *enc=NULL;
89 char *engine=NULL; 88 char *engine=NULL;
90 89
91 apps_startup(); 90 apps_startup();
@@ -94,6 +93,9 @@ int MAIN(int argc, char **argv)
94 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 93 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
95 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 94 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
96 95
96 if (!load_config(bio_err, NULL))
97 goto end;
98
97 argv++; 99 argv++;
98 argc--; 100 argc--;
99 for (;;) 101 for (;;)
@@ -121,16 +123,24 @@ int MAIN(int argc, char **argv)
121 } 123 }
122 else if (strcmp(*argv,"-") == 0) 124 else if (strcmp(*argv,"-") == 0)
123 goto bad; 125 goto bad;
124#ifndef NO_DES 126#ifndef OPENSSL_NO_DES
125 else if (strcmp(*argv,"-des") == 0) 127 else if (strcmp(*argv,"-des") == 0)
126 enc=EVP_des_cbc(); 128 enc=EVP_des_cbc();
127 else if (strcmp(*argv,"-des3") == 0) 129 else if (strcmp(*argv,"-des3") == 0)
128 enc=EVP_des_ede3_cbc(); 130 enc=EVP_des_ede3_cbc();
129#endif 131#endif
130#ifndef NO_IDEA 132#ifndef OPENSSL_NO_IDEA
131 else if (strcmp(*argv,"-idea") == 0) 133 else if (strcmp(*argv,"-idea") == 0)
132 enc=EVP_idea_cbc(); 134 enc=EVP_idea_cbc();
133#endif 135#endif
136#ifndef OPENSSL_NO_AES
137 else if (strcmp(*argv,"-aes128") == 0)
138 enc=EVP_aes_128_cbc();
139 else if (strcmp(*argv,"-aes192") == 0)
140 enc=EVP_aes_192_cbc();
141 else if (strcmp(*argv,"-aes256") == 0)
142 enc=EVP_aes_256_cbc();
143#endif
134 else if (**argv != '-' && dsaparams == NULL) 144 else if (**argv != '-' && dsaparams == NULL)
135 { 145 {
136 dsaparams = *argv; 146 dsaparams = *argv;
@@ -146,13 +156,17 @@ int MAIN(int argc, char **argv)
146bad: 156bad:
147 BIO_printf(bio_err,"usage: gendsa [args] dsaparam-file\n"); 157 BIO_printf(bio_err,"usage: gendsa [args] dsaparam-file\n");
148 BIO_printf(bio_err," -out file - output the key to 'file'\n"); 158 BIO_printf(bio_err," -out file - output the key to 'file'\n");
149#ifndef NO_DES 159#ifndef OPENSSL_NO_DES
150 BIO_printf(bio_err," -des - encrypt the generated key with DES in cbc mode\n"); 160 BIO_printf(bio_err," -des - encrypt the generated key with DES in cbc mode\n");
151 BIO_printf(bio_err," -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); 161 BIO_printf(bio_err," -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
152#endif 162#endif
153#ifndef NO_IDEA 163#ifndef OPENSSL_NO_IDEA
154 BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n"); 164 BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode\n");
155#endif 165#endif
166#ifndef OPENSSL_NO_AES
167 BIO_printf(bio_err," -aes128, -aes192, -aes256\n");
168 BIO_printf(bio_err," encrypt PEM output with cbc aes\n");
169#endif
156 BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n"); 170 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); 171 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"); 172 BIO_printf(bio_err," - load the file (or the files in the directory) into\n");
@@ -162,23 +176,7 @@ bad:
162 goto end; 176 goto end;
163 } 177 }
164 178
165 if (engine != NULL) 179 e = setup_engine(bio_err, engine, 0);
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 180
183 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { 181 if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
184 BIO_printf(bio_err, "Error getting password\n"); 182 BIO_printf(bio_err, "Error getting password\n");
@@ -207,7 +205,7 @@ bad:
207 if (outfile == NULL) 205 if (outfile == NULL)
208 { 206 {
209 BIO_set_fp(out,stdout,BIO_NOCLOSE); 207 BIO_set_fp(out,stdout,BIO_NOCLOSE);
210#ifdef VMS 208#ifdef OPENSSL_SYS_VMS
211 { 209 {
212 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 210 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
213 out = BIO_push(tmpbio, out); 211 out = BIO_push(tmpbio, out);
@@ -247,6 +245,7 @@ end:
247 if (out != NULL) BIO_free_all(out); 245 if (out != NULL) BIO_free_all(out);
248 if (dsa != NULL) DSA_free(dsa); 246 if (dsa != NULL) DSA_free(dsa);
249 if(passout) OPENSSL_free(passout); 247 if(passout) OPENSSL_free(passout);
248 apps_shutdown();
250 EXIT(ret); 249 EXIT(ret);
251 } 250 }
252#endif 251#endif