numbits = num;
private = genkey ? 1 : 0;
- out = bio_open_owner(outfile, outformat, private);
- if (out == NULL)
- goto end;
-
ctx = EVP_PKEY_CTX_new_from_name(app_get0_libctx(), "DSA", app_get0_propq());
if (ctx == NULL) {
BIO_printf(bio_err,
goto end;
}
+ out = bio_open_owner(outfile, outformat, private);
+ if (out == NULL)
+ goto end;
+
if (text) {
EVP_PKEY_print_params(out, params, 0, 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. If the I<numbits> parameter is included then
this option will be ignored.
=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<-noout>
use warnings;
use File::Spec;
+use File::Copy;
+use File::Compare qw/compare/;
use OpenSSL::Glob;
use OpenSSL::Test qw/:DEFAULT data_file/;
use OpenSSL::Test::Utils;
my @valid = glob(data_file("valid", "*.pem"));
my @invalid = glob(data_file("invalid", "*.pem"));
-my $num_tests = scalar @valid + scalar @invalid;
+my $num_tests = scalar @valid + scalar @invalid + 2;
plan tests => $num_tests;
foreach (@valid) {
foreach (@invalid) {
ok(!run(app([qw{openssl pkeyparam -noout -check -in}, $_])));
}
+
+my $input = data_file("valid", "p3072_q256_t1864.pem");
+my $inout = "inout.pem";
+copy($input, $inout);
+ok(run(app(['openssl', 'dsaparam', '-in', $inout, '-out', $inout])),
+ "identical infile and outfile");
+ok(!compare($input, $inout), "converted file $inout did not change");