]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/15-test_rsapss.t
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
14 use OpenSSL
::Test qw
/:DEFAULT with srctop_file/;
15 use OpenSSL
::Test
::Utils
;
21 #using test/testrsa.pem which happens to be a 512 bit RSA
22 ok
(run
(app
(['openssl', 'dgst', '-sign', srctop_file
('test', 'testrsa.pem'), '-sha1',
23 '-sigopt', 'rsa_padding_mode:pss',
24 '-sigopt', 'rsa_pss_saltlen:max',
25 '-sigopt', 'rsa_mgf1_md:sha512',
26 '-out', 'testrsapss-restricted.sig',
27 srctop_file
('test', 'testrsa.pem')])),
28 "openssl dgst -sign [plain RSA key, PSS padding mode, PSS restrictions]");
30 ok
(run
(app
(['openssl', 'dgst', '-sign', srctop_file
('test', 'testrsa.pem'), '-sha1',
31 '-sigopt', 'rsa_padding_mode:pss',
32 '-out', 'testrsapss-unrestricted.sig',
33 srctop_file
('test', 'testrsa.pem')])),
34 "openssl dgst -sign [plain RSA key, PSS padding mode, no PSS restrictions]");
36 with
({ exit_checker
=> sub { return shift == 1; } },
37 sub { ok
(run
(app
(['openssl', 'dgst', '-sign', srctop_file
('test', 'testrsa.pem'), '-sha512',
38 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
39 '-sigopt', 'rsa_mgf1_md:sha512', srctop_file
('test', 'testrsa.pem')])),
40 "openssl dgst -sign, expect to fail gracefully");
41 ok
(run
(app
(['openssl', 'dgst', '-sign', srctop_file
('test', 'testrsa.pem'), '-sha512',
42 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:2147483647',
43 '-sigopt', 'rsa_mgf1_md:sha1', srctop_file
('test', 'testrsa.pem')])),
44 "openssl dgst -sign, expect to fail gracefully");
45 ok
(run
(app
(['openssl', 'dgst', '-prverify', srctop_file
('test', 'testrsa.pem'), '-sha512',
46 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
47 '-sigopt', 'rsa_mgf1_md:sha512', '-signature', 'testrsapss.sig',
48 srctop_file
('test', 'testrsa.pem')])),
49 "openssl dgst -prverify, expect to fail gracefully");
52 ok
(run
(app
(['openssl', 'dgst', '-prverify', srctop_file
('test', 'testrsa.pem'),
54 '-sigopt', 'rsa_padding_mode:pss',
55 '-sigopt', 'rsa_pss_saltlen:max',
56 '-sigopt', 'rsa_mgf1_md:sha512',
57 '-signature', 'testrsapss-restricted.sig',
58 srctop_file
('test', 'testrsa.pem')])),
59 "openssl dgst -prverify [plain RSA key, PSS padding mode, PSS restrictions]");
61 ok
(run
(app
(['openssl', 'dgst', '-prverify', srctop_file
('test', 'testrsa.pem'),
63 '-sigopt', 'rsa_padding_mode:pss',
64 '-signature', 'testrsapss-unrestricted.sig',
65 srctop_file
('test', 'testrsa.pem')])),
66 "openssl dgst -prverify [plain RSA key, PSS padding mode, no PSS restrictions]");