]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/15-test_rsa.t
Copyright year updates
[thirdparty/openssl.git] / test / recipes / 15-test_rsa.t
CommitLineData
596d6b7e 1#! /usr/bin/env perl
da1c088f 2# Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved.
596d6b7e 3#
909f1a2e 4# Licensed under the Apache License 2.0 (the "License"). You may not use
596d6b7e
RS
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
0c85cc50
RL
9
10use strict;
11use warnings;
12
13use File::Spec;
42e0ccdf 14use OpenSSL::Test qw/:DEFAULT srctop_file/;
340166a9 15use OpenSSL::Test::Utils;
0c85cc50
RL
16
17setup("test_rsa");
18
bcd94b63 19plan tests => 14;
c5f87134
P
20
21require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
0c85cc50
RL
22
23ok(run(test(["rsa_test"])), "running rsatest");
24
c5f87134 25run_rsa_tests("pkey");
464d59a5 26
b0cfe526 27run_rsa_tests("rsa");
d8594555 28
c5f87134
P
29sub run_rsa_tests {
30 my $cmd = shift;
31
32 ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
33 "$cmd -check" );
34
bcd94b63 35 SKIP: {
36 skip "Skipping Deprecated rsa_x931_test", 1 if disabled("deprecated-3.0");
37 ok(run(test(['rsa_x931_test'])), "RSA X931 test");
38 };
39
a44eb842 40 SKIP: {
c5f87134 41 skip "Skipping $cmd conversion test", 3
a0430488 42 if disabled("rsa");
c5f87134
P
43
44 subtest "$cmd conversions -- private key" => sub {
a0430488 45 tconversion( -type => $cmd, -prefix => "$cmd-priv",
b40498c6 46 -in => srctop_file("test", "testrsa.pem") );
c5f87134
P
47 };
48 subtest "$cmd conversions -- private key PKCS#8" => sub {
a0430488 49 tconversion( -type => $cmd, -prefix => "$cmd-pkcs8",
b40498c6
RL
50 -in => srctop_file("test", "testrsa.pem"),
51 -args => ["pkey"] );
c5f87134
P
52 };
53 }
54
a44eb842 55 SKIP: {
c5f87134 56 skip "Skipping msblob conversion test", 1
a0430488 57 if disabled($cmd) || $cmd eq 'pkey';
c5f87134
P
58
59 subtest "$cmd conversions -- public key" => sub {
a0430488 60 tconversion( -type => 'msb', -prefix => "$cmd-msb-pub",
b40498c6
RL
61 -in => srctop_file("test", "testrsapub.pem"),
62 -args => ["rsa", "-pubin", "-pubout"] );
c5f87134
P
63 };
64 }
a44eb842
TM
65 SKIP: {
66 skip "Skipping PVK conversion test", 1
67 if disabled($cmd) || $cmd eq 'pkey' || disabled("rc4")
68 || disabled ("legacy");
69
70 subtest "$cmd conversions -- private key" => sub {
71 tconversion( -type => 'pvk', -prefix => "$cmd-pvk",
72 -in => srctop_file("test", "testrsa.pem"),
73 -args => ["rsa", "-passin", "pass:testpass",
74 "-passout", "pass:testpass",
75 "-provider", "default",
76 "-provider", "legacy"] );
77 };
78 }
0c85cc50 79}