1e1051a39Sopenharmony_ci#! /usr/bin/env perl 2e1051a39Sopenharmony_ci# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci# 4e1051a39Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci# this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci# in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci# https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ciuse strict; 11e1051a39Sopenharmony_ciuse warnings; 12e1051a39Sopenharmony_ci 13e1051a39Sopenharmony_ciuse File::Spec; 14e1051a39Sopenharmony_ciuse OpenSSL::Test qw/:DEFAULT srctop_file/; 15e1051a39Sopenharmony_ciuse OpenSSL::Test::Utils; 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_cisetup("test_rsa"); 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_ciplan tests => 12; 20e1051a39Sopenharmony_ci 21e1051a39Sopenharmony_cirequire_ok(srctop_file('test', 'recipes', 'tconversion.pl')); 22e1051a39Sopenharmony_ci 23e1051a39Sopenharmony_ciok(run(test(["rsa_test"])), "running rsatest"); 24e1051a39Sopenharmony_ci 25e1051a39Sopenharmony_cirun_rsa_tests("pkey"); 26e1051a39Sopenharmony_ci 27e1051a39Sopenharmony_cirun_rsa_tests("rsa"); 28e1051a39Sopenharmony_ci 29e1051a39Sopenharmony_cisub run_rsa_tests { 30e1051a39Sopenharmony_ci my $cmd = shift; 31e1051a39Sopenharmony_ci 32e1051a39Sopenharmony_ci ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])), 33e1051a39Sopenharmony_ci "$cmd -check" ); 34e1051a39Sopenharmony_ci 35e1051a39Sopenharmony_ci SKIP: { 36e1051a39Sopenharmony_ci skip "Skipping $cmd conversion test", 3 37e1051a39Sopenharmony_ci if disabled("rsa"); 38e1051a39Sopenharmony_ci 39e1051a39Sopenharmony_ci subtest "$cmd conversions -- private key" => sub { 40e1051a39Sopenharmony_ci tconversion( -type => $cmd, -prefix => "$cmd-priv", 41e1051a39Sopenharmony_ci -in => srctop_file("test", "testrsa.pem") ); 42e1051a39Sopenharmony_ci }; 43e1051a39Sopenharmony_ci subtest "$cmd conversions -- private key PKCS#8" => sub { 44e1051a39Sopenharmony_ci tconversion( -type => $cmd, -prefix => "$cmd-pkcs8", 45e1051a39Sopenharmony_ci -in => srctop_file("test", "testrsa.pem"), 46e1051a39Sopenharmony_ci -args => ["pkey"] ); 47e1051a39Sopenharmony_ci }; 48e1051a39Sopenharmony_ci } 49e1051a39Sopenharmony_ci 50e1051a39Sopenharmony_ci SKIP: { 51e1051a39Sopenharmony_ci skip "Skipping msblob conversion test", 1 52e1051a39Sopenharmony_ci if disabled($cmd) || $cmd eq 'pkey'; 53e1051a39Sopenharmony_ci 54e1051a39Sopenharmony_ci subtest "$cmd conversions -- public key" => sub { 55e1051a39Sopenharmony_ci tconversion( -type => 'msb', -prefix => "$cmd-msb-pub", 56e1051a39Sopenharmony_ci -in => srctop_file("test", "testrsapub.pem"), 57e1051a39Sopenharmony_ci -args => ["rsa", "-pubin", "-pubout"] ); 58e1051a39Sopenharmony_ci }; 59e1051a39Sopenharmony_ci } 60e1051a39Sopenharmony_ci SKIP: { 61e1051a39Sopenharmony_ci skip "Skipping PVK conversion test", 1 62e1051a39Sopenharmony_ci if disabled($cmd) || $cmd eq 'pkey' || disabled("rc4") 63e1051a39Sopenharmony_ci || disabled ("legacy"); 64e1051a39Sopenharmony_ci 65e1051a39Sopenharmony_ci subtest "$cmd conversions -- private key" => sub { 66e1051a39Sopenharmony_ci tconversion( -type => 'pvk', -prefix => "$cmd-pvk", 67e1051a39Sopenharmony_ci -in => srctop_file("test", "testrsa.pem"), 68e1051a39Sopenharmony_ci -args => ["rsa", "-passin", "pass:testpass", 69e1051a39Sopenharmony_ci "-passout", "pass:testpass", 70e1051a39Sopenharmony_ci "-provider", "default", 71e1051a39Sopenharmony_ci "-provider", "legacy"] ); 72e1051a39Sopenharmony_ci }; 73e1051a39Sopenharmony_ci } 74e1051a39Sopenharmony_ci} 75