private = genkey ? 1 : 0;
- out = bio_open_owner(outfile, outformat, private);
- if (out == NULL)
- goto end;
-
- if (list_curves) {
- if (list_builtin_curves(out))
- ret = 0;
- goto end;
- }
-
if (curve_name != NULL) {
OSSL_PARAM params[4];
OSSL_PARAM *p = params;
goto end;
}
+ out = bio_open_owner(outfile, outformat, private);
+ if (out == NULL)
+ goto end;
+
+ if (list_curves) {
+ if (list_builtin_curves(out))
+ ret = 0;
+ goto end;
+ }
+
if (text
&& !EVP_PKEY_print_params(out, params_key, 0, NULL)) {
BIO_printf(bio_err, "unable to print params\n");
in = bio_open_default(infile, 'r', FORMAT_PEM);
if (in == NULL)
goto end;
- out = bio_open_default(outfile, 'w', FORMAT_PEM);
- if (out == NULL)
- goto end;
pkey = PEM_read_bio_Parameters_ex(in, NULL, app_get0_libctx(),
app_get0_propq());
if (pkey == NULL) {
ERR_print_errors(bio_err);
goto end;
}
+ out = bio_open_default(outfile, 'w', FORMAT_PEM);
+ if (out == NULL)
+ goto end;
if (check) {
if (e == 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.
+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>
=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 to write parameters to or standard output if
this option is not specified.
+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<-text>
use warnings;
use File::Spec;
-use File::Compare qw/compare_text/;
+use File::Copy;
+use File::Compare qw/compare_text compare/;
use OpenSSL::Glob;
use OpenSSL::Test qw/:DEFAULT data_file srctop_file bldtop_dir/;
use OpenSSL::Test::Utils;
@valid = grep { !/sm2-.*\.pem/} @valid;
}
-plan tests => 12;
+plan tests => 13;
sub checkload {
my $files = shift; # List of files
}
}
+sub check_identical {
+ my $apps = shift; # List of applications
+
+ foreach (@$apps) {
+ my $inout = "$_.tst";
+ my $backup = "backup.tst";
+
+ copy($inout, $backup);
+ ok(run(app(['openssl', $_, '-in', $inout, '-out', $inout])));
+ ok(!compare($inout, $backup), "converted file $inout did not change");
+ }
+}
+
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
subtest "Check loading valid parameters by ecparam with -check" => sub {
checkcompare(\@valid, "pkeyparam");
};
+my @apps = ("ecparam", "pkeyparam");
+subtest "Check param apps do not garble infile identical to outfile" => sub {
+ plan tests => 2 * scalar(@apps);
+ check_identical(\@apps);
+};
+
subtest "Check loading of fips and non-fips params" => sub {
plan skip_all => "FIPS is disabled"
if $no_fips;