15-test_ec.t 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_ec");
  14. plan tests => 14;
  15. require_ok(srctop_file('test','recipes','tconversion.pl'));
  16. ok(run(test(["ectest"])), "running ectest");
  17. # TODO: remove these when the 'ec' app is removed.
  18. # Also consider moving this to the 20-25 test section because it is testing
  19. # the command line tool in addition to the algorithm.
  20. SKIP: {
  21. skip "Skipping EC conversion test", 3
  22. if disabled("ec");
  23. subtest 'EC conversions -- private key' => sub {
  24. tconversion( -type => 'ec', -prefix => 'ec-priv',
  25. -in => srctop_file("test","testec-p256.pem") );
  26. };
  27. subtest 'EC conversions -- private key PKCS#8' => sub {
  28. tconversion( -type => 'ec', -prefix => 'ec-pkcs8',
  29. -in => srctop_file("test","testec-p256.pem"),
  30. -args => "pkey" );
  31. };
  32. subtest 'EC conversions -- public key' => sub {
  33. tconversion( -type => 'ec', -prefix => 'ec-pub',
  34. -in => srctop_file("test","testecpub-p256.pem"),
  35. -args => [ "ec", "-pubin", "-pubout" ] );
  36. };
  37. }
  38. SKIP: {
  39. skip "Skipping PKEY conversion test", 3
  40. if disabled("ec");
  41. subtest 'PKEY conversions -- private key' => sub {
  42. tconversion( -type => 'pkey', -prefix => 'ec-pkey-priv',
  43. -in => srctop_file("test","testec-p256.pem") );
  44. };
  45. subtest 'PKEY conversions -- private key PKCS#8' => sub {
  46. tconversion( -type => 'pkey', -prefix => 'ec-pkey-pkcs8',
  47. -in => srctop_file("test","testec-p256.pem"),
  48. -args => "pkey" );
  49. };
  50. subtest 'PKEY conversions -- public key' => sub {
  51. tconversion( -type => 'pkey', -prefix => 'ec-pkey-pub',
  52. -in => srctop_file("test","testecpub-p256.pem"),
  53. -args => [ "pkey", "-pubin", "-pubout" ] );
  54. };
  55. }
  56. SKIP: {
  57. skip "Skipping EdDSA conversion test", 6
  58. if disabled("ec");
  59. subtest 'Ed25519 conversions -- private key' => sub {
  60. tconversion( -type => "pkey", -prefix => "ed25519-pkey-priv",
  61. -in => srctop_file("test", "tested25519.pem") );
  62. };
  63. subtest 'Ed25519 conversions -- private key PKCS#8' => sub {
  64. tconversion( -type => "pkey", -prefix => "ed25519-pkey-pkcs8",
  65. -in => srctop_file("test", "tested25519.pem"),
  66. -args => ["pkey"] );
  67. };
  68. subtest 'Ed25519 conversions -- public key' => sub {
  69. tconversion( -type => "pkey", -prefix => "ed25519-pkey-pub",
  70. -in => srctop_file("test", "tested25519pub.pem"),
  71. -args => ["pkey", "-pubin", "-pubout"] );
  72. };
  73. subtest 'Ed448 conversions -- private key' => sub {
  74. tconversion( -type => "pkey", -prefix => "ed448-pkey-priv",
  75. -in => srctop_file("test", "tested448.pem") );
  76. };
  77. subtest 'Ed448 conversions -- private key PKCS#8' => sub {
  78. tconversion( -type => "pkey", -prefix => "ed448-pkey-pkcs8",
  79. -in => srctop_file("test", "tested448.pem"),
  80. -args => ["pkey"] );
  81. };
  82. subtest 'Ed448 conversions -- public key' => sub {
  83. tconversion( -type => "pkey", -prefix => "ed448-pkey-pub",
  84. -in => srctop_file("test", "tested448pub.pem"),
  85. -args => ["pkey", "-pubin", "-pubout"] );
  86. };
  87. }