2
0

15-test_rsa.t 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2020 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. use strict;
  9. use warnings;
  10. use File::Spec;
  11. use OpenSSL::Test qw/:DEFAULT srctop_file/;
  12. use OpenSSL::Test::Utils;
  13. setup("test_rsa");
  14. plan tests => 10;
  15. require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
  16. ok(run(test(["rsa_test"])), "running rsatest");
  17. run_rsa_tests("pkey");
  18. run_rsa_tests("rsa");
  19. sub run_rsa_tests {
  20. my $cmd = shift;
  21. ok(run(app([ 'openssl', $cmd, '-check', '-in', srctop_file('test', 'testrsa.pem'), '-noout'])),
  22. "$cmd -check" );
  23. SKIP: {
  24. skip "Skipping $cmd conversion test", 3
  25. if disabled("rsa");
  26. subtest "$cmd conversions -- private key" => sub {
  27. tconversion( -type => $cmd, -prefix => "$cmd-priv",
  28. -in => srctop_file("test", "testrsa.pem") );
  29. };
  30. subtest "$cmd conversions -- private key PKCS#8" => sub {
  31. tconversion( -type => $cmd, -prefix => "$cmd-pkcs8",
  32. -in => srctop_file("test", "testrsa.pem"),
  33. -args => ["pkey"] );
  34. };
  35. }
  36. SKIP: {
  37. skip "Skipping msblob conversion test", 1
  38. if disabled($cmd) || disabled("dsa") || $cmd == 'pkey';
  39. subtest "$cmd conversions -- public key" => sub {
  40. tconversion( -type => 'msb', -prefix => "$cmd-msb-pub",
  41. -in => srctop_file("test", "testrsapub.pem"),
  42. -args => ["rsa", "-pubin", "-pubout"] );
  43. };
  44. }
  45. }