15-test_rsa.t 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2023 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 => 14;
  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 Deprecated rsa_x931_test", 1 if disabled("deprecated-3.0");
  25. ok(run(test(['rsa_x931_test'])), "RSA X931 test");
  26. };
  27. SKIP: {
  28. skip "Skipping $cmd conversion test", 3
  29. if disabled("rsa");
  30. subtest "$cmd conversions -- private key" => sub {
  31. tconversion( -type => $cmd, -prefix => "$cmd-priv",
  32. -in => srctop_file("test", "testrsa.pem") );
  33. };
  34. subtest "$cmd conversions -- private key PKCS#8" => sub {
  35. tconversion( -type => $cmd, -prefix => "$cmd-pkcs8",
  36. -in => srctop_file("test", "testrsa.pem"),
  37. -args => ["pkey"] );
  38. };
  39. }
  40. SKIP: {
  41. skip "Skipping msblob conversion test", 1
  42. if disabled($cmd) || $cmd eq 'pkey';
  43. subtest "$cmd conversions -- public key" => sub {
  44. tconversion( -type => 'msb', -prefix => "$cmd-msb-pub",
  45. -in => srctop_file("test", "testrsapub.pem"),
  46. -args => ["rsa", "-pubin", "-pubout"] );
  47. };
  48. }
  49. SKIP: {
  50. skip "Skipping PVK conversion test", 1
  51. if disabled($cmd) || $cmd eq 'pkey' || disabled("rc4")
  52. || disabled ("legacy");
  53. subtest "$cmd conversions -- private key" => sub {
  54. tconversion( -type => 'pvk', -prefix => "$cmd-pvk",
  55. -in => srctop_file("test", "testrsa.pem"),
  56. -args => ["rsa", "-passin", "pass:testpass",
  57. "-passout", "pass:testpass",
  58. "-provider", "default",
  59. "-provider", "legacy"] );
  60. };
  61. }
  62. }