]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps: test dsaparam app DER output paths
authorJakub Zelenka <jakub.zelenka@openssl.foundation>
Tue, 7 Jul 2026 21:11:44 +0000 (23:11 +0200)
committerTomas Mraz <tomas@openssl.foundation>
Mon, 13 Jul 2026 15:32:28 +0000 (17:32 +0200)
Add coverage for the DER (ASN.1) output of the dsaparam app, exercising
both the parameter output (i2d_KeyParams_bio) and the -genkey private key
output (i2d_PrivateKey_bio).

Assisted-by: Claude:claude-opus-4-8
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Mon Jul 13 15:32:33 2026
(Merged from https://github.com/openssl/openssl/pull/31888)

test/recipes/15-test_dsaparam.t

index 8f7d2af1754ee024eaef2536567075437383d945..fe7a52d8361d20b1dee10bb3cfbaa0eac0922696 100644 (file)
@@ -68,7 +68,7 @@ plan skip_all => "DSA isn't supported in this build"
 my @valid = glob(data_file("valid", "*.pem"));
 my @invalid = glob(data_file("invalid", "*.pem"));
 
-my $num_tests = scalar @valid + scalar @invalid + 2;
+my $num_tests = scalar @valid + scalar @invalid + 4;
 plan tests => $num_tests;
 
 foreach (@valid) {
@@ -85,3 +85,32 @@ copy($input, $inout);
 ok(run(app(['openssl', 'dsaparam', '-in', $inout, '-out', $inout])),
     "identical infile and outfile");
 ok(!compare_text($input, $inout), "converted file $inout did not change");
+
+# Cover the DER (ASN.1) output paths of the dsaparam app.
+my $srcparams = data_file("valid", "p1024_q160_t1862.pem");
+my $params_der = "dsaparam.der";
+my $key_der = "dsakey.der";
+
+subtest "dsaparam DER parameter output" => sub {
+    plan tests => 2;
+
+    # Exercises i2d_KeyParams_bio().
+    ok(run(app(['openssl', 'dsaparam', '-in', $srcparams,
+                '-outform', 'DER', '-out', $params_der])),
+       "write DSA parameters in DER form");
+    ok(run(app(['openssl', 'dsaparam', '-inform', 'DER', '-in', $params_der,
+                '-noout'])),
+       "read the DER DSA parameters back");
+};
+
+subtest "dsaparam DER private key output with -genkey" => sub {
+    plan tests => 2;
+
+    # Exercises i2d_PrivateKey_bio().
+    ok(run(app(['openssl', 'dsaparam', '-in', $srcparams, '-genkey',
+                '-outform', 'DER', '-out', $key_der])),
+       "generate a DSA key and write it in DER form");
+    ok(run(app(['openssl', 'pkey', '-inform', 'DER', '-in', $key_der,
+                '-noout', '-check'])),
+       "read the DER DSA private key back");
+};