15-test_rsa.t 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2021 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 => 12;
  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) || $cmd eq '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. SKIP: {
  46. skip "Skipping PVK conversion test", 1
  47. if disabled($cmd) || $cmd eq 'pkey' || disabled("rc4")
  48. || disabled ("legacy");
  49. subtest "$cmd conversions -- private key" => sub {
  50. tconversion( -type => 'pvk', -prefix => "$cmd-pvk",
  51. -in => srctop_file("test", "testrsa.pem"),
  52. -args => ["rsa", "-passin", "pass:testpass",
  53. "-passout", "pass:testpass",
  54. "-provider", "default",
  55. "-provider", "legacy"] );
  56. };
  57. }
  58. }