2 # Copyright 2018 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
13 use OpenSSL::Test qw/:DEFAULT srctop_file/;
14 use OpenSSL::Test::Utils;
16 setup("test_pkeyutl");
20 # For the tests below we use the cert itself as the TBS file
23 skip "Skipping tests that require EC, SM2 or SM3", 2
24 if disabled("ec") || disabled("sm2") || disabled("sm3");
27 ok(run(app(([ 'openssl', 'pkeyutl', '-sign',
28 '-in', srctop_file('test', 'certs', 'sm2.crt'),
29 '-inkey', srctop_file('test', 'certs', 'sm2.key'),
30 '-out', 'signature.dat', '-rawin',
31 '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))),
32 "Sign a piece of data using SM2");
33 ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin',
34 '-in', srctop_file('test', 'certs', 'sm2.crt'),
35 '-inkey', srctop_file('test', 'certs', 'sm2.crt'),
36 '-sigfile', 'signature.dat', '-rawin',
37 '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))),
38 "Verify an SM2 signature against a piece of data");
42 skip "Skipping tests that require EC", 4
46 ok(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in',
47 srctop_file('test', 'certs', 'server-ed25519-cert.pem'),
48 '-inkey', srctop_file('test', 'certs', 'server-ed25519-key.pem'),
49 '-out', 'signature.dat', '-rawin']))),
50 "Sign a piece of data using Ed25519");
51 ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', '-in',
52 srctop_file('test', 'certs', 'server-ed25519-cert.pem'),
53 '-inkey', srctop_file('test', 'certs', 'server-ed25519-cert.pem'),
54 '-sigfile', 'signature.dat', '-rawin']))),
55 "Verify an Ed25519 signature against a piece of data");
58 ok(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in',
59 srctop_file('test', 'certs', 'server-ed448-cert.pem'),
60 '-inkey', srctop_file('test', 'certs', 'server-ed448-key.pem'),
61 '-out', 'signature.dat', '-rawin']))),
62 "Sign a piece of data using Ed448");
63 ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', '-in',
64 srctop_file('test', 'certs', 'server-ed448-cert.pem'),
65 '-inkey', srctop_file('test', 'certs', 'server-ed448-cert.pem'),
66 '-sigfile', 'signature.dat', '-rawin']))),
67 "Verify an Ed448 signature against a piece of data");
70 unlink 'signature.dat';