diff options
Diffstat (limited to 'src/lib/libssl/src/apps/genrsa.c')
-rw-r--r-- | src/lib/libssl/src/apps/genrsa.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c index e7445e6a49..515bd7c901 100644 --- a/src/lib/libssl/src/apps/genrsa.c +++ b/src/lib/libssl/src/apps/genrsa.c | |||
@@ -56,7 +56,7 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef NO_RSA | 59 | #ifndef OPENSSL_NO_RSA |
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> |
@@ -69,7 +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 | #include <openssl/rand.h> |
73 | 73 | ||
74 | #define DEFBITS 512 | 74 | #define DEFBITS 512 |
75 | #undef PROG | 75 | #undef PROG |
@@ -86,7 +86,7 @@ int MAIN(int argc, char **argv) | |||
86 | RSA *rsa=NULL; | 86 | RSA *rsa=NULL; |
87 | int i,num=DEFBITS; | 87 | int i,num=DEFBITS; |
88 | long l; | 88 | long l; |
89 | EVP_CIPHER *enc=NULL; | 89 | const EVP_CIPHER *enc=NULL; |
90 | unsigned long f4=RSA_F4; | 90 | unsigned long f4=RSA_F4; |
91 | char *outfile=NULL; | 91 | char *outfile=NULL; |
92 | char *passargout = NULL, *passout = NULL; | 92 | char *passargout = NULL, *passout = NULL; |
@@ -99,6 +99,9 @@ int MAIN(int argc, char **argv) | |||
99 | if (bio_err == NULL) | 99 | if (bio_err == NULL) |
100 | if ((bio_err=BIO_new(BIO_s_file())) != NULL) | 100 | if ((bio_err=BIO_new(BIO_s_file())) != NULL) |
101 | BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); | 101 | BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); |
102 | |||
103 | if (!load_config(bio_err, NULL)) | ||
104 | goto err; | ||
102 | if ((out=BIO_new(BIO_s_file())) == NULL) | 105 | if ((out=BIO_new(BIO_s_file())) == NULL) |
103 | { | 106 | { |
104 | BIO_printf(bio_err,"unable to create BIO for output\n"); | 107 | BIO_printf(bio_err,"unable to create BIO for output\n"); |
@@ -129,16 +132,24 @@ int MAIN(int argc, char **argv) | |||
129 | if (--argc < 1) goto bad; | 132 | if (--argc < 1) goto bad; |
130 | inrand= *(++argv); | 133 | inrand= *(++argv); |
131 | } | 134 | } |
132 | #ifndef NO_DES | 135 | #ifndef OPENSSL_NO_DES |
133 | else if (strcmp(*argv,"-des") == 0) | 136 | else if (strcmp(*argv,"-des") == 0) |
134 | enc=EVP_des_cbc(); | 137 | enc=EVP_des_cbc(); |
135 | else if (strcmp(*argv,"-des3") == 0) | 138 | else if (strcmp(*argv,"-des3") == 0) |
136 | enc=EVP_des_ede3_cbc(); | 139 | enc=EVP_des_ede3_cbc(); |
137 | #endif | 140 | #endif |
138 | #ifndef NO_IDEA | 141 | #ifndef OPENSSL_NO_IDEA |
139 | else if (strcmp(*argv,"-idea") == 0) | 142 | else if (strcmp(*argv,"-idea") == 0) |
140 | enc=EVP_idea_cbc(); | 143 | enc=EVP_idea_cbc(); |
141 | #endif | 144 | #endif |
145 | #ifndef OPENSSL_NO_AES | ||
146 | else if (strcmp(*argv,"-aes128") == 0) | ||
147 | enc=EVP_aes_128_cbc(); | ||
148 | else if (strcmp(*argv,"-aes192") == 0) | ||
149 | enc=EVP_aes_192_cbc(); | ||
150 | else if (strcmp(*argv,"-aes256") == 0) | ||
151 | enc=EVP_aes_256_cbc(); | ||
152 | #endif | ||
142 | else if (strcmp(*argv,"-passout") == 0) | 153 | else if (strcmp(*argv,"-passout") == 0) |
143 | { | 154 | { |
144 | if (--argc < 1) goto bad; | 155 | if (--argc < 1) goto bad; |
@@ -155,9 +166,13 @@ bad: | |||
155 | BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n"); | 166 | BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n"); |
156 | BIO_printf(bio_err," -des encrypt the generated key with DES in cbc mode\n"); | 167 | BIO_printf(bio_err," -des encrypt the generated key with DES in cbc mode\n"); |
157 | BIO_printf(bio_err," -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); | 168 | BIO_printf(bio_err," -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)\n"); |
158 | #ifndef NO_IDEA | 169 | #ifndef OPENSSL_NO_IDEA |
159 | BIO_printf(bio_err," -idea encrypt the generated key with IDEA in cbc mode\n"); | 170 | BIO_printf(bio_err," -idea encrypt the generated key with IDEA in cbc mode\n"); |
160 | #endif | 171 | #endif |
172 | #ifndef OPENSSL_NO_AES | ||
173 | BIO_printf(bio_err," -aes128, -aes192, -aes256\n"); | ||
174 | BIO_printf(bio_err," encrypt PEM output with cbc aes\n"); | ||
175 | #endif | ||
161 | BIO_printf(bio_err," -out file output the key to 'file\n"); | 176 | BIO_printf(bio_err," -out file output the key to 'file\n"); |
162 | BIO_printf(bio_err," -passout arg output file pass phrase source\n"); | 177 | BIO_printf(bio_err," -passout arg output file pass phrase source\n"); |
163 | BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n"); | 178 | BIO_printf(bio_err," -f4 use F4 (0x10001) for the E value\n"); |
@@ -176,28 +191,12 @@ bad: | |||
176 | goto err; | 191 | goto err; |
177 | } | 192 | } |
178 | 193 | ||
179 | if (engine != NULL) | 194 | e = setup_engine(bio_err, engine, 0); |
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 | 195 | ||
197 | if (outfile == NULL) | 196 | if (outfile == NULL) |
198 | { | 197 | { |
199 | BIO_set_fp(out,stdout,BIO_NOCLOSE); | 198 | BIO_set_fp(out,stdout,BIO_NOCLOSE); |
200 | #ifdef VMS | 199 | #ifdef OPENSSL_SYS_VMS |
201 | { | 200 | { |
202 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); | 201 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); |
203 | out = BIO_push(tmpbio, out); | 202 | out = BIO_push(tmpbio, out); |
@@ -242,8 +241,14 @@ bad: | |||
242 | l+=rsa->e->d[i]; | 241 | l+=rsa->e->d[i]; |
243 | } | 242 | } |
244 | BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l); | 243 | BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l); |
245 | if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL, passout)) | 244 | { |
245 | PW_CB_DATA cb_data; | ||
246 | cb_data.password = passout; | ||
247 | cb_data.prompt_info = outfile; | ||
248 | if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0, | ||
249 | (pem_password_cb *)password_callback,&cb_data)) | ||
246 | goto err; | 250 | goto err; |
251 | } | ||
247 | 252 | ||
248 | ret=0; | 253 | ret=0; |
249 | err: | 254 | err: |
@@ -252,6 +257,7 @@ err: | |||
252 | if(passout) OPENSSL_free(passout); | 257 | if(passout) OPENSSL_free(passout); |
253 | if (ret != 0) | 258 | if (ret != 0) |
254 | ERR_print_errors(bio_err); | 259 | ERR_print_errors(bio_err); |
260 | apps_shutdown(); | ||
255 | EXIT(ret); | 261 | EXIT(ret); |
256 | } | 262 | } |
257 | 263 | ||
@@ -269,7 +275,7 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg) | |||
269 | p=n; | 275 | p=n; |
270 | #endif | 276 | #endif |
271 | } | 277 | } |
272 | #else /* !NO_RSA */ | 278 | #else /* !OPENSSL_NO_RSA */ |
273 | 279 | ||
274 | # if PEDANTIC | 280 | # if PEDANTIC |
275 | static void *dummy=&dummy; | 281 | static void *dummy=&dummy; |