diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-11-04 12:31:16 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-07 14:41:03 +0100 |
commit | 42e1a641a48d43d27ae49090d03e5e1ba2417e3d (patch) | |
tree | 784ac7512510a42b6aeae56fea693e6f4f0789e6 /test/recipes | |
parent | 0391198f48f86170a866820b2eb58c3fd91f858c (diff) | |
download | openssl-new-42e1a641a48d43d27ae49090d03e5e1ba2417e3d.tar.gz |
Test that signatures using hash name commands work properly
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/19606)
(cherry picked from commit e9e6827445528caf1d9d6647953fbe67a0c78716)
Diffstat (limited to 'test/recipes')
-rw-r--r-- | test/recipes/20-test_dgst.t | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/test/recipes/20-test_dgst.t b/test/recipes/20-test_dgst.t index f5895747ca..96744b3741 100644 --- a/test/recipes/20-test_dgst.t +++ b/test/recipes/20-test_dgst.t @@ -17,7 +17,7 @@ use OpenSSL::Test::Utils; setup("test_dgst"); -plan tests => 12; +plan tests => 13; sub tsignverify { my $testtext = shift; @@ -51,6 +51,43 @@ sub tsignverify { $testtext.": Expect failure verifying mismatching data"); } +sub tsignverify_sha512 { + my $testtext = shift; + my $privkey = shift; + my $pubkey = shift; + + my $data_to_sign = srctop_file('test', 'data.bin'); + my $other_data = srctop_file('test', 'data2.bin'); + + my $sigfile = basename($privkey, '.pem') . '.sig'; + plan tests => 5; + + ok(run(app(['openssl', 'sha512', '-sign', $privkey, + '-out', $sigfile, + $data_to_sign])), + $testtext.": Generating signature using sha512 command"); + + ok(run(app(['openssl', 'sha512', '-verify', $pubkey, + '-signature', $sigfile, + $data_to_sign])), + $testtext.": Verify signature with public key using sha512 command"); + + ok(run(app(['openssl', 'dgst', '-sha512', '-prverify', $privkey, + '-signature', $sigfile, + $data_to_sign])), + $testtext.": Verify signature with private key"); + + ok(run(app(['openssl', 'dgst', '-sha512', '-verify', $pubkey, + '-signature', $sigfile, + $data_to_sign])), + $testtext.": Verify signature with public key"); + + ok(!run(app(['openssl', 'dgst', '-sha512', '-verify', $pubkey, + '-signature', $sigfile, + $other_data])), + $testtext.": Expect failure verifying mismatching data"); +} + SKIP: { skip "RSA is not supported by this OpenSSL build", 1 if disabled("rsa"); @@ -60,6 +97,12 @@ SKIP: { srctop_file("test","testrsa.pem"), srctop_file("test","testrsapub.pem")); }; + + subtest "RSA signature generation and verification with `sha512` CLI" => sub { + tsignverify_sha512("RSA", + srctop_file("test","testrsa2048.pem"), + srctop_file("test","testrsa2048pub.pem")); + }; } SKIP: { |