DSA *dsa;
BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
- dsa = DSA_generate_parameters(num, NULL, 0, NULL, NULL, dh_cb, bio_err);
+ dsa = DSA_generate_parameters(num, NULL, 0, NULL, NULL, dh_cb, bio_err);
if (dsa == NULL)
{
ERR_print_errors(bio_err);
goto end;
}
if (outfile == NULL)
+ {
BIO_set_fp(out,stdout,BIO_NOCLOSE);
+#ifdef VMS
+ {
+ BIO *tmpbio = BIO_new(BIO_f_linebuffer());
+ out = BIO_push(tmpbio, out);
+ }
+#endif
+ }
else
{
if (BIO_write_filename(out,outfile) <= 0)
len=BN_num_bytes(dh->p);
bits=BN_num_bits(dh->p);
- data=(unsigned char *)Malloc(len);
+ data=(unsigned char *)OPENSSL_malloc(len);
if (data == NULL)
{
- perror("Malloc");
+ perror("OPENSSL_malloc");
goto end;
}
+ printf("#ifndef HEADER_DH_H\n"
+ "#include <openssl/dh.h>\n"
+ "#endif\n");
+ printf("DH *get_dh%d()\n\t{\n",bits);
+
l=BN_bn2bin(dh->p,data);
- printf("static unsigned char dh%d_p[]={",bits);
+ printf("\tstatic unsigned char dh%d_p[]={",bits);
for (i=0; i<l; i++)
{
- if ((i%12) == 0) printf("\n\t");
+ if ((i%12) == 0) printf("\n\t\t");
printf("0x%02X,",data[i]);
}
- printf("\n\t};\n");
+ printf("\n\t\t};\n");
l=BN_bn2bin(dh->g,data);
- printf("static unsigned char dh%d_g[]={",bits);
+ printf("\tstatic unsigned char dh%d_g[]={",bits);
for (i=0; i<l; i++)
{
- if ((i%12) == 0) printf("\n\t");
+ if ((i%12) == 0) printf("\n\t\t");
printf("0x%02X,",data[i]);
}
- printf("\n\t};\n\n");
+ printf("\n\t\t};\n");
- printf("DH *get_dh%d()\n\t{\n",bits);
printf("\tDH *dh;\n\n");
printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
if (dh->length)
printf("\tdh->length = %d;\n", dh->length);
printf("\treturn(dh);\n\t}\n");
- Free(data);
+ OPENSSL_free(data);
}
ret=0;
end:
if (in != NULL) BIO_free(in);
- if (out != NULL) BIO_free(out);
+ if (out != NULL) BIO_free_all(out);
if (dh != NULL) DH_free(dh);
EXIT(ret);
}