Deprecate the low level RSA functions.
[openssl.git] / test / recipes / 15-test_rsa.t
1 #! /usr/bin/env perl
2 # Copyright 2015-2016 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
10 use strict;
11 use warnings;
12
13 use File::Spec;
14 use OpenSSL::Test qw/:DEFAULT srctop_file/;
15 use OpenSSL::Test::Utils;
16
17 setup("test_rsa");
18
19 #plan skip_all => "RSA command line tool not built"
20 #    if disabled("deprecated-3.0");
21
22 plan tests => 10;
23
24 require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
25
26 ok(run(test(["rsa_test"])), "running rsatest");
27
28 run_rsa_tests("pkey");
29
30  SKIP: {
31     skip "Skipping rsa command line tests", 4 if disabled('deprecated-3.0');
32
33     run_rsa_tests("rsa");
34 }
35
36 sub run_rsa_tests {
37     my $cmd = shift;
38
39     ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
40            "$cmd -check" );
41
42      SKIP: {
43          skip "Skipping $cmd conversion test", 3
44              if disabled("rsa");
45
46          subtest "$cmd conversions -- private key" => sub {
47              tconversion($cmd, srctop_file("test", "testrsa.pem"));
48          };
49          subtest "$cmd conversions -- private key PKCS#8" => sub {
50              tconversion($cmd, srctop_file("test", "testrsa.pem"), "pkey");
51          };
52     }
53
54      SKIP: {
55          skip "Skipping msblob conversion test", 1
56              if disabled($cmd) || disabled("dsa") || $cmd == 'pkey';
57
58          subtest "$cmd conversions -- public key" => sub {
59              tconversion("msb", srctop_file("test", "testrsapub.pem"), "rsa",
60                          "-pubin", "-pubout");
61          };
62     }
63 }