- if (!noout)
- {
- if (outformat == FORMAT_ASN1)
- i=i2d_DHparams_bio(out,dh);
- else if (outformat == FORMAT_PEM)
- i=PEM_write_bio_DHparams(out,dh);
- else {
- BIO_printf(bio_err,"bad output format specified for outfile\n");
- goto end;
- }
- if (!i)
- {
- BIO_printf(bio_err,"unable to write DH paramaters\n");
- ERR_print_errors(bio_err);
- goto end;
- }
- }
- ret=0;
-end:
- if (in != NULL) BIO_free(in);
- if (out != NULL) BIO_free(out);
- if (dh != NULL) DH_free(dh);
- EXIT(ret);
- }
+ l = BN_bn2bin(dh->g, data);
+ printf("static unsigned char dh%d_g[]={", bits);
+ for (i = 0; i < l; i++) {
+ if ((i % 12) == 0)
+ printf("\n\t");
+ printf("0x%02X,", data[i]);
+ }
+ printf("\n\t};\n\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",
+ bits, bits);
+ printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
+ bits, bits);
+ printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
+ printf("\t\treturn(NULL);\n");
+ printf("\treturn(dh);\n\t}\n");
+ OPENSSL_free(data);
+ }
+
+ if (!noout) {
+ if (outformat == FORMAT_ASN1)
+ i = i2d_DHparams_bio(out, dh);
+ else if (outformat == FORMAT_PEM)
+ i = PEM_write_bio_DHparams(out, dh);
+ else {
+ BIO_printf(bio_err, "bad output format specified for outfile\n");
+ goto end;
+ }
+ if (!i) {
+ BIO_printf(bio_err, "unable to write DH parameters\n");
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+ }
+ ret = 0;
+ end:
+ if (in != NULL)
+ BIO_free(in);
+ if (out != NULL)
+ BIO_free_all(out);
+ if (dh != NULL)
+ DH_free(dh);
+ apps_shutdown();
+ OPENSSL_EXIT(ret);
+}
+#else /* !OPENSSL_NO_DH */
+
+# if PEDANTIC
+static void *dummy = &dummy;
+# endif
+
+#endif