From: Jakub Zelenka Date: Tue, 30 Jun 2026 17:21:26 +0000 (+0200) Subject: apps: test ecparam app -param_enc option X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=2c471635734f03166906bd1a2db3f2ca0bf3b192;p=thirdparty%2Fopenssl.git apps: test ecparam app -param_enc option Exercise the previously untested -param_enc option of the ecparam app by round-tripping the secp384r1 fixtures between named_curve and explicit encodings (compared byte for byte against the reference files), and check that an invalid value is rejected. Assisted-by: Claude:claude-opus-4-8 Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz MergeDate: Mon Jul 13 15:00:27 2026 (Merged from https://github.com/openssl/openssl/pull/31799) --- diff --git a/test/recipes/15-test_ecparam.t b/test/recipes/15-test_ecparam.t index 0d721547451..571c62cf1a0 100644 --- a/test/recipes/15-test_ecparam.t +++ b/test/recipes/15-test_ecparam.t @@ -30,7 +30,7 @@ if (disabled("sm2")) { @valid = grep { !/sm2-.*\.pem/} @valid; } -plan tests => 14; +plan tests => 15; sub checkload { my $files = shift; # List of files @@ -199,4 +199,29 @@ subtest "Check loading of fips and non-fips params" => sub { $ENV{OPENSSL_CONF} = $defaultconf; }; +subtest "Check ecparam -param_enc converts between named and explicit" => sub { + plan tests => 3; + + my $named = data_file('valid', 'secp384r1-named.pem'); + my $explicit = data_file('valid', 'secp384r1-explicit.pem'); + + # The encodings are canonical, so re-encoding a named curve as explicit + # (and vice versa) must reproduce the matching reference file byte for byte. + my $to_explicit = 'param-explicit.tst'; + ok(run(app(['openssl', 'ecparam', '-in', $named, '-param_enc', 'explicit', + '-out', $to_explicit])) + && !compare($to_explicit, $explicit), + "named_curve params re-encoded as explicit match the reference file"); + + my $to_named = 'param-named.tst'; + ok(run(app(['openssl', 'ecparam', '-in', $explicit, '-param_enc', + 'named_curve', '-out', $to_named])) + && !compare($to_named, $named), + "explicit params re-encoded as named_curve match the reference file"); + + ok(!run(app(['openssl', 'ecparam', '-in', $named, '-noout', + '-param_enc', 'bogus'])), + "an invalid parameter encoding is rejected"); +}; + ok(run(app(['openssl', 'ecparam', '-list_curves'])), "Test -list_curves");