Deleted Added
full compact
15-test_rsapss.t (1.1.1.4) 15-test_rsapss.t (1.1.1.5)
1#! /usr/bin/env perl
1#! /usr/bin/env perl
2# Copyright 2017-2022 The OpenSSL Project Authors. All Rights Reserved.
2# Copyright 2017-2023 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
10use strict;
11use warnings;
12
13use File::Spec;
14use OpenSSL::Test qw/:DEFAULT with srctop_file data_file/;
15use OpenSSL::Test::Utils;
16
17setup("test_rsapss");
18
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
10use strict;
11use warnings;
12
13use File::Spec;
14use OpenSSL::Test qw/:DEFAULT with srctop_file data_file/;
15use OpenSSL::Test::Utils;
16
17setup("test_rsapss");
18
19plan tests => 11;
19plan tests => 13;
20
21#using test/testrsa.pem which happens to be a 512 bit RSA
22ok(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')])),

--- 46 unchanged lines hidden (view full) ---

74 srctop_file('test', 'testrsa.pem')])),
75 "openssl dgst -prverify [plain RSA key, PSS padding mode, no PSS restrictions]");
76
77# Test that RSA-PSS keys are supported by genpkey and rsa commands.
78{
79 my $rsapss = "rsapss.key";
80 ok(run(app(['openssl', 'genpkey', '-algorithm', 'RSA-PSS',
81 '-pkeyopt', 'rsa_keygen_bits:1024',
20
21#using test/testrsa.pem which happens to be a 512 bit RSA
22ok(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')])),

--- 46 unchanged lines hidden (view full) ---

74 srctop_file('test', 'testrsa.pem')])),
75 "openssl dgst -prverify [plain RSA key, PSS padding mode, no PSS restrictions]");
76
77# Test that RSA-PSS keys are supported by genpkey and rsa commands.
78{
79 my $rsapss = "rsapss.key";
80 ok(run(app(['openssl', 'genpkey', '-algorithm', 'RSA-PSS',
81 '-pkeyopt', 'rsa_keygen_bits:1024',
82 '-pkeyopt', 'rsa_keygen_pubexp:65537',
83 '-pkeyopt', 'rsa_keygen_primes:2',
82 '--out', $rsapss])));
83 ok(run(app(['openssl', 'rsa', '-check',
84 '-in', $rsapss])));
85}
86
87ok(!run(app([ 'openssl', 'rsa',
88 '-in' => data_file('negativesaltlen.pem')],
89 '-out' => 'badout')));
84 '--out', $rsapss])));
85 ok(run(app(['openssl', 'rsa', '-check',
86 '-in', $rsapss])));
87}
88
89ok(!run(app([ 'openssl', 'rsa',
90 '-in' => data_file('negativesaltlen.pem')],
91 '-out' => 'badout')));
92
93ok(run(app(['openssl', 'genpkey', '-algorithm', 'RSA-PSS', '-pkeyopt', 'rsa_keygen_bits:1024',
94 '-pkeyopt', 'rsa_pss_keygen_md:SHA256', '-pkeyopt', 'rsa_pss_keygen_saltlen:10',
95 '-out', 'testrsapss.pem'])),
96 "openssl genpkey RSA-PSS with pss parameters");
97ok(run(app(['openssl', 'pkey', '-in', 'testrsapss.pem', '-pubout', '-text'])),
98 "openssl pkey, execute rsa_pub_encode with pss parameters");
99unlink 'testrsapss.pem';