@valid = grep { !/sm2-.*\.pem/} @valid;
}
-plan tests => 14;
+plan tests => 15;
sub checkload {
my $files = shift; # List of files
$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");