2 # Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
15 use OpenSSL::Test qw/:DEFAULT with srctop_file/;
16 use OpenSSL::Test::Utils;
27 my $data_to_sign = srctop_file('test', 'README');
28 my $other_data = srctop_file('test', 'README.external');
30 my $sigfile = basename($privkey, '.pem') . '.sig';
33 ok(run(app(['openssl', 'dgst', '-sign', $privkey,
36 $testtext.": Generating signature");
38 ok(run(app(['openssl', 'dgst', '-prverify', $privkey,
39 '-signature', $sigfile,
41 $testtext.": Verify signature with private key");
43 ok(run(app(['openssl', 'dgst', '-verify', $pubkey,
44 '-signature', $sigfile,
46 $testtext.": Verify signature with public key");
48 ok(!run(app(['openssl', 'dgst', '-verify', $pubkey,
49 '-signature', $sigfile,
51 $testtext.": Expect failure verifying mismatching data");
55 skip "RSA is not supported by this OpenSSL build", 1
58 subtest "RSA signature generation and verification with `dgst` CLI" => sub {
60 srctop_file("test","testrsa.pem"),
61 srctop_file("test","testrsapub.pem"));
66 skip "DSA is not supported by this OpenSSL build", 1
69 subtest "DSA signature generation and verification with `dgst` CLI" => sub {
71 srctop_file("test","testdsa.pem"),
72 srctop_file("test","testdsapub.pem"));
77 skip "ECDSA is not supported by this OpenSSL build", 1
80 subtest "ECDSA signature generation and verification with `dgst` CLI" => sub {
82 srctop_file("test","testec-p256.pem"),
83 srctop_file("test","testecpub-p256.pem"));
88 skip "EdDSA is not supported by this OpenSSL build", 2
91 skip "EdDSA is not supported with `dgst` CLI", 2;
93 subtest "Ed25519 signature generation and verification with `dgst` CLI" => sub {
94 tsignverify("Ed25519",
95 srctop_file("test","tested25519.pem"),
96 srctop_file("test","tested25519pub.pem"));
99 subtest "Ed448 signature generation and verification with `dgst` CLI" => sub {
101 srctop_file("test","tested448.pem"),
102 srctop_file("test","tested448pub.pem"));