]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/20-test_pkeyutl.t
Support raw input data in apps/pkeyutl
[thirdparty/openssl.git] / test / recipes / 20-test_pkeyutl.t
1 #! /usr/bin/env perl
2 # Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
3 #
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
8
9 use strict;
10 use warnings;
11
12 use File::Spec;
13 use OpenSSL::Test qw/:DEFAULT srctop_file/;
14 use OpenSSL::Test::Utils;
15
16 setup("test_pkeyutl");
17
18 plan tests => 2;
19
20 sub sign
21 {
22 # Utilize the sm2.crt as the TBS file
23 return run(app(([ 'openssl', 'pkeyutl', '-sign',
24 '-in', srctop_file('test', 'certs', 'sm2.crt'),
25 '-inkey', srctop_file('test', 'certs', 'sm2.key'),
26 '-out', 'signature.sm2', '-rawin',
27 '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid'])));
28 }
29
30 sub verify
31 {
32 # Utilize the sm2.crt as the TBS file
33 return 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.sm2', '-rawin',
37 '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid'])));
38 }
39
40 ok(sign, "Sign a piece of data using SM2");
41 ok(verify, "Verify an SM2 signature against a piece of data");
42
43 unlink 'signature.sm2';