goto end;
}
- out = bio_open_default(outfile, 'w', outformat);
- if (out == NULL)
- goto end;
-
/* DH parameters */
if (num && !g)
g = 2;
}
}
+ out = bio_open_default(outfile, 'w', outformat);
+ if (out == NULL)
+ goto end;
+
if (text)
EVP_PKEY_print_params(out, pkey, 4, NULL);
=item B<-in> I<filename>
-This specifies the input filename to read parameters from or standard input if
+This specifies the input file to read parameters from or standard input if
this option is not specified.
=item B<-out> I<filename>
-This specifies the output filename parameters to. Standard output is used
-if this option is not present. The output filename should B<not> be the same
-as the input filename.
+This specifies the output file to write parameters to.
+Standard output is used if this option is not present.
+The output filename can be the same as the input filename,
+which leads to replacing the file contents.
+Note that file I/O is not atomic. The output file is truncated and then written.
=item B<-dsaparam>
use strict;
use warnings;
+use File::Copy;
+use File::Compare qw/compare/;
use OpenSSL::Test qw(:DEFAULT data_file srctop_file);
use OpenSSL::Test::Utils;
plan skip_all => "DH is not supported in this build"
if disabled("dh");
-plan tests => 21;
+plan tests => 23;
my $fipsconf = srctop_file("test", "fips-and-base.cnf");
delete $ENV{OPENSSL_CONF};
}
+my $input = data_file("pkcs3-2-1024.pem");
ok(run(app(["openssl", "dhparam", "-noout", "-text"],
- stdin => data_file("pkcs3-2-1024.pem"))),
+ stdin => $input)),
"stdinbuffer input test that uses BIO_gets");
+
+my $inout = "inout.pem";
+copy($input, $inout);
+ok(run(app(['openssl', 'dhparam', '-in', $inout, '-out', $inout])),
+ "identical infile and outfile");
+ok(!compare($input, $inout), "converted file $inout did not change");