Commit d1d74cf253 for openssl.org
commit d1d74cf253d376b47015b675a7400800729253aa
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date: Tue Jul 7 23:05:33 2026 +0200
apps: test dsa app -modulus option
Add coverage for the -modulus option of the dsa app, checking the
public value is printed for both private and public key input.
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:31:54 2026
(Merged from https://github.com/openssl/openssl/pull/31887)
diff --git a/test/recipes/15-test_dsa.t b/test/recipes/15-test_dsa.t
index 602e94e6a0..2d16ebd02c 100644
--- a/test/recipes/15-test_dsa.t
+++ b/test/recipes/15-test_dsa.t
@@ -17,7 +17,7 @@ use OpenSSL::Test::Utils;
setup("test_dsa");
plan skip_all => 'DSA is not supported in this build' if disabled('dsa');
-plan tests => 9;
+plan tests => 10;
require_ok(srctop_file('test','recipes','tconversion.pl'));
@@ -60,6 +60,34 @@ SKIP: {
};
}
+subtest "dsa -modulus prints the DSA public value" => sub {
+ plan tests => 2;
+
+ # The public value (y) of the committed testdsa.pem / testdsapub.pem
+ # keypair, i.e. the "pub:" field of 'openssl pkey -text'.
+ my $expected = "Public Key=CC99A07D9817BFF03BB09B183E9B19EB77ABECF192"
+ . "C3A9FBA833DBE69EDB719A8E9777BB82736CEC6A8E4E2FAD0693ACC3D1456"
+ . "5D62710B95B02CC6A5CF091EEF9C22F20193EBE114C45A0B5E54A645037E8"
+ . "787FE01B3871508A25BDBF7C6B81428F89858F133FDB858C390C2EF7BCF7E"
+ . "41D7C66578F792A2488C787EF7C7D41";
+
+ my @priv = run(app(['openssl', 'dsa', '-modulus', '-noout',
+ '-in', srctop_file("test", "testdsa.pem")],
+ stderr => undef),
+ capture => 1);
+ chomp @priv;
+ ok(grep(/^\Q$expected\E$/, @priv),
+ "-modulus prints the expected public value for a private key");
+
+ my @pub = run(app(['openssl', 'dsa', '-pubin', '-modulus', '-noout',
+ '-in', srctop_file("test", "testdsapub.pem")],
+ stderr => undef),
+ capture => 1);
+ chomp @pub;
+ ok(grep(/^\Q$expected\E$/, @pub),
+ "-modulus prints the expected public value for a public key");
+};
+
subtest "dsa PVK output is rejected for public key input" => sub {
plan tests => 1;