]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/15-test_rsax931.t
2 # Copyright 2023 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
12 use OpenSSL
::Test
qw(:DEFAULT srctop_file);
13 use OpenSSL
::Test
::Utils
;
16 setup
("test_rsax931");
21 my $infile = srctop_file
("test", "certs", "sm2.key");
22 my $inkey = srctop_file
("test", "testrsa2048.pem");
24 ok
(run
(app
(['openssl', 'pkeyutl', '-in', $infile, '-rawin', '-inkey', $inkey,
26 '-pkeyopt', 'pad-mode:x931',
28 '-out', 'sigx931.txt'])),
29 "RSA Sign with x931 padding using SHA256");
31 ok
(run
(app
(['openssl', 'pkeyutl', '-in', $infile, '-rawin', '-inkey', $inkey,
33 '-pkeyopt', 'pad-mode:x931',
35 '-sigfile', 'sigx931.txt'])),
36 "RSA Verify with x931 padding using SHA256");
38 ok
(!run
(app
(['openssl', 'pkeyutl', '-in', $infile, '-rawin', '-inkey', $inkey,
40 '-pkeyopt', 'pad-mode:x931',
42 '-sigfile', 'sigx931.txt'])),
43 "RSA Verify with x931 padding fails if digest is different");
45 ok
(!run
(app
(['openssl', 'pkeyutl', '-in', $infile, '-rawin', '-inkey', $inkey,
46 '-digest', 'SHA512-256',
47 '-pkeyopt', 'pad-mode:x931',
49 "RSA Sign with x931 padding using unsupported digest should fail");
51 ok
(run
(app
(['openssl', 'pkeyutl', '-in', $infile, '-rawin', '-inkey', $inkey,
53 '-pkeyopt', 'pad-mode:oaep',
55 '-out', 'sigoaep.txt'])),
56 "RSA Sign with oaep padding using SHA256");
58 ok
(!run
(app
(['openssl', 'pkeyutl', '-in', $infile, '-rawin', '-inkey', $inkey,
60 '-pkeyopt', 'pad-mode:x931',
62 '-sigfile', 'sigoaep.txt'])),
63 "RSA Verify with x931 padding using data signed with oaep padding should fail");