Deleted Added
full compact
dh.c (59191) dh.c (68651)
1/* apps/dh.c */
2/* obsoleted by dhparam.c */
3/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
4 * All rights reserved.
5 *
6 * This package is an SSL implementation written
7 * by Eric Young (eay@cryptsoft.com).
8 * The implementation was written so as to conform with Netscapes SSL.

--- 170 unchanged lines hidden (view full) ---

179 {
180 if (BIO_read_filename(in,infile) <= 0)
181 {
182 perror(infile);
183 goto end;
184 }
185 }
186 if (outfile == NULL)
1/* apps/dh.c */
2/* obsoleted by dhparam.c */
3/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
4 * All rights reserved.
5 *
6 * This package is an SSL implementation written
7 * by Eric Young (eay@cryptsoft.com).
8 * The implementation was written so as to conform with Netscapes SSL.

--- 170 unchanged lines hidden (view full) ---

179 {
180 if (BIO_read_filename(in,infile) <= 0)
181 {
182 perror(infile);
183 goto end;
184 }
185 }
186 if (outfile == NULL)
187 {
187 BIO_set_fp(out,stdout,BIO_NOCLOSE);
188 BIO_set_fp(out,stdout,BIO_NOCLOSE);
189#ifdef VMS
190 {
191 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
192 out = BIO_push(tmpbio, out);
193 }
194#endif
195 }
188 else
189 {
190 if (BIO_write_filename(out,outfile) <= 0)
191 {
192 perror(outfile);
193 goto end;
194 }
195 }

--- 50 unchanged lines hidden (view full) ---

246 }
247 if (C)
248 {
249 unsigned char *data;
250 int len,l,bits;
251
252 len=BN_num_bytes(dh->p);
253 bits=BN_num_bits(dh->p);
196 else
197 {
198 if (BIO_write_filename(out,outfile) <= 0)
199 {
200 perror(outfile);
201 goto end;
202 }
203 }

--- 50 unchanged lines hidden (view full) ---

254 }
255 if (C)
256 {
257 unsigned char *data;
258 int len,l,bits;
259
260 len=BN_num_bytes(dh->p);
261 bits=BN_num_bits(dh->p);
254 data=(unsigned char *)Malloc(len);
262 data=(unsigned char *)OPENSSL_malloc(len);
255 if (data == NULL)
256 {
263 if (data == NULL)
264 {
257 perror("Malloc");
265 perror("OPENSSL_malloc");
258 goto end;
259 }
260 l=BN_bn2bin(dh->p,data);
261 printf("static unsigned char dh%d_p[]={",bits);
262 for (i=0; i<l; i++)
263 {
264 if ((i%12) == 0) printf("\n\t");
265 printf("0x%02X,",data[i]);

--- 14 unchanged lines hidden (view full) ---

280 printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
281 printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
282 bits,bits);
283 printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
284 bits,bits);
285 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
286 printf("\t\treturn(NULL);\n");
287 printf("\treturn(dh);\n\t}\n");
266 goto end;
267 }
268 l=BN_bn2bin(dh->p,data);
269 printf("static unsigned char dh%d_p[]={",bits);
270 for (i=0; i<l; i++)
271 {
272 if ((i%12) == 0) printf("\n\t");
273 printf("0x%02X,",data[i]);

--- 14 unchanged lines hidden (view full) ---

288 printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
289 printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
290 bits,bits);
291 printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
292 bits,bits);
293 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
294 printf("\t\treturn(NULL);\n");
295 printf("\treturn(dh);\n\t}\n");
288 Free(data);
296 OPENSSL_free(data);
289 }
290
291
292 if (!noout)
293 {
294 if (outformat == FORMAT_ASN1)
295 i=i2d_DHparams_bio(out,dh);
296 else if (outformat == FORMAT_PEM)

--- 7 unchanged lines hidden (view full) ---

304 BIO_printf(bio_err,"unable to write DH parameters\n");
305 ERR_print_errors(bio_err);
306 goto end;
307 }
308 }
309 ret=0;
310end:
311 if (in != NULL) BIO_free(in);
297 }
298
299
300 if (!noout)
301 {
302 if (outformat == FORMAT_ASN1)
303 i=i2d_DHparams_bio(out,dh);
304 else if (outformat == FORMAT_PEM)

--- 7 unchanged lines hidden (view full) ---

312 BIO_printf(bio_err,"unable to write DH parameters\n");
313 ERR_print_errors(bio_err);
314 goto end;
315 }
316 }
317 ret=0;
318end:
319 if (in != NULL) BIO_free(in);
312 if (out != NULL) BIO_free(out);
320 if (out != NULL) BIO_free_all(out);
313 if (dh != NULL) DH_free(dh);
314 EXIT(ret);
315 }
316#endif
321 if (dh != NULL) DH_free(dh);
322 EXIT(ret);
323 }
324#endif