Commit 83ba3cb69c for openssl.org
commit 83ba3cb69c3ac30c2d03d2c577c6fc53dbcca856
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date: Sat Aug 29 11:32:13 2026 +0200
apps: cover the dhparam -dsaparam file input in the test recipe
Reading DSA parameters from a file with -dsaparam and converting them
to X9.42 DH parameters was not covered, nor were the error paths when
the input file key type does not match the -dsaparam expectation.
Assisted-by: Claude:claude-fable-5
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Merge-date: Mon Sep 7 14:14:08 2026
Merged-from: https://github.com/openssl/openssl/pull/32588
diff --git a/test/recipes/20-test_dhparam.t b/test/recipes/20-test_dhparam.t
index f08e8dd437..3af50d580c 100644
--- a/test/recipes/20-test_dhparam.t
+++ b/test/recipes/20-test_dhparam.t
@@ -21,7 +21,7 @@ setup("test_dhparam");
plan skip_all => "DH is not supported in this build"
if disabled("dh");
-plan tests => 23;
+plan tests => 26;
my $fipsconf = srctop_file("test", "fips-and-base.cnf");
@@ -156,7 +156,7 @@ subtest "Generate: 512 bit PKCS3 params, generator 2, explicit PEM file" => sub
checkdhparams("gen-pkcs3-2-512.exp.pem", "PKCS3", 2, "PEM", 512, 125);
};
SKIP: {
- skip "Skipping tests that require DSA", 4 if disabled("dsa");
+ skip "Skipping tests that require DSA", 7 if disabled("dsa");
subtest "Generate: 512 bit X9.42 params, generator 0, PEM file" => sub {
plan tests => 5;
@@ -182,6 +182,19 @@ SKIP: {
'-dsaparam', '-outform', 'DER', '512' ])));
checkdhparams("gen-x942-0-512.der", "X9.42", 0, "DER", 512);
};
+ subtest "Convert: 1024 bit DSA params to X9.42 params, PEM file" => sub {
+ plan tests => 5;
+ ok(run(app([ 'openssl', 'dhparam', '-dsaparam',
+ '-in', data_file("dsa-1024.pem"),
+ '-out', 'conv-x942-0-1024.pem' ])));
+ checkdhparams("conv-x942-0-1024.pem", "X9.42", 0, "PEM", 1024);
+ };
+ ok(!run(app([ 'openssl', 'dhparam', '-dsaparam', '-noout',
+ '-in', data_file("pkcs3-2-1024.pem") ])),
+ "Reading PKCS3 DH params with -dsaparam should fail");
+ ok(!run(app([ 'openssl', 'dhparam', '-noout',
+ '-in', data_file("dsa-1024.pem") ])),
+ "Reading DSA params without -dsaparam should fail");
}
SKIP: {
skip "Skipping tests that are only supported in a fips build with security ".
diff --git a/test/recipes/20-test_dhparam_data/dsa-1024.pem b/test/recipes/20-test_dhparam_data/dsa-1024.pem
new file mode 100644
index 0000000000..8943961b08
--- /dev/null
+++ b/test/recipes/20-test_dhparam_data/dsa-1024.pem
@@ -0,0 +1,9 @@
+-----BEGIN DSA PARAMETERS-----
+MIIBJgKBgQCyCgpMap62rzzHrKhlctvB7OT4mQWQgV7M1pkWGA5eCTh1ZmboddAP
+olr83vzRBGdWcHc4WfNEeY5qYHs0TfvDZF/RAc/OFJeiWd6+3ezPw5RwBLAklsbo
+Xfox5gsQnduwBp+cXt0aHUT5jX64TIp+C1ErFBBgjCDXyamzXDqRVwIdAPW2VkVB
+HAMQPUa0H4+dZfFt4Qj2Dks6p1q0vNcCgYA0h5PdB4LFgNKtaKxgH45sWlUwv8IX
+YeAW8ESHUDtvyshR8TMtT17SBhUBDLWdYdANv3eqAI7gEDbp/smgNcWkseT9hzfl
+gXCM4op79P8FpecP5dxWgjkglCmn5m2g0PDb+pO0tSunX1aJ+Taj8uwHgLKGm8gz
+NIPXl2GH69SDnA==
+-----END DSA PARAMETERS-----