blob: 65ec6f3d75289d5d8f53d95f6818ecefdb925642 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#! /usr/bin/env perl
2# Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the OpenSSL license (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/;
15use OpenSSL::Test::Utils;
16
17setup("test_rsapss");
18
19plan tests => 5;
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', '-sigopt', 'rsa_pss_saltlen:max',
24 '-sigopt', 'rsa_mgf1_md:sha512', '-out', 'testrsapss.sig',
25 srctop_file('test', 'testrsa.pem')])),
26 "openssl dgst -sign");
27
28with({ exit_checker => sub { return shift == 1; } },
29 sub { ok(run(app(['openssl', 'dgst', '-sign', srctop_file('test', 'testrsa.pem'), '-sha512',
30 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
31 '-sigopt', 'rsa_mgf1_md:sha512', srctop_file('test', 'testrsa.pem')])),
32 "openssl dgst -sign, expect to fail gracefully");
33 ok(run(app(['openssl', 'dgst', '-sign', srctop_file('test', 'testrsa.pem'), '-sha512',
34 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:2147483647',
35 '-sigopt', 'rsa_mgf1_md:sha1', srctop_file('test', 'testrsa.pem')])),
36 "openssl dgst -sign, expect to fail gracefully");
37 ok(run(app(['openssl', 'dgst', '-prverify', srctop_file('test', 'testrsa.pem'), '-sha512',
38 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
39 '-sigopt', 'rsa_mgf1_md:sha512', '-signature', 'testrsapss.sig',
40 srctop_file('test', 'testrsa.pem')])),
41 "openssl dgst -prverify, expect to fail gracefully");
42 });
43
44ok(run(app(['openssl', 'dgst', '-prverify', srctop_file('test', 'testrsa.pem'), '-sha1',
45 '-sigopt', 'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:max',
46 '-sigopt', 'rsa_mgf1_md:sha512', '-signature', 'testrsapss.sig',
47 srctop_file('test', 'testrsa.pem')])),
48 "openssl dgst -prverify");
49unlink 'testrsapss.sig';