decoders.inc 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2020-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. */
  9. #ifndef DECODER_PROVIDER
  10. # error Macro DECODER_PROVIDER undefined
  11. #endif
  12. #define DECODER_STRUCTURE_type_specific_keypair "type-specific"
  13. #define DECODER_STRUCTURE_type_specific_params "type-specific"
  14. #define DECODER_STRUCTURE_type_specific "type-specific"
  15. #define DECODER_STRUCTURE_type_specific_no_pub "type-specific"
  16. #define DECODER_STRUCTURE_EncryptedPrivateKeyInfo "EncryptedPrivateKeyInfo"
  17. #define DECODER_STRUCTURE_PrivateKeyInfo "PrivateKeyInfo"
  18. #define DECODER_STRUCTURE_SubjectPublicKeyInfo "SubjectPublicKeyInfo"
  19. #define DECODER_STRUCTURE_DH "dh"
  20. #define DECODER_STRUCTURE_DHX "dhx"
  21. #define DECODER_STRUCTURE_DSA "dsa"
  22. #define DECODER_STRUCTURE_EC "ec"
  23. #define DECODER_STRUCTURE_RSA "rsa"
  24. /* Arguments are prefixed with '_' to avoid build breaks on certain platforms */
  25. #define DECODER(_name, _input, _output, _fips) \
  26. { _name, \
  27. "provider=" DECODER_PROVIDER ",fips=" #_fips ",input=" #_input, \
  28. (ossl_##_input##_to_##_output##_decoder_functions) }
  29. #define DECODER_w_structure(_name, _input, _structure, _output, _fips) \
  30. { _name, \
  31. "provider=" DECODER_PROVIDER ",fips=" #_fips ",input=" #_input \
  32. ",structure=" DECODER_STRUCTURE_##_structure, \
  33. (ossl_##_structure##_##_input##_to_##_output##_decoder_functions) }
  34. #ifndef OPENSSL_NO_DH
  35. DECODER_w_structure("DH", der, PrivateKeyInfo, dh, yes),
  36. DECODER_w_structure("DH", der, SubjectPublicKeyInfo, dh, yes),
  37. DECODER_w_structure("DH", der, type_specific_params, dh, yes),
  38. DECODER_w_structure("DH", der, DH, dh, yes),
  39. DECODER_w_structure("DHX", der, PrivateKeyInfo, dhx, yes),
  40. DECODER_w_structure("DHX", der, SubjectPublicKeyInfo, dhx, yes),
  41. DECODER_w_structure("DHX", der, type_specific_params, dhx, yes),
  42. DECODER_w_structure("DHX", der, DHX, dhx, yes),
  43. #endif
  44. #ifndef OPENSSL_NO_DSA
  45. DECODER_w_structure("DSA", der, PrivateKeyInfo, dsa, yes),
  46. DECODER_w_structure("DSA", der, SubjectPublicKeyInfo, dsa, yes),
  47. DECODER_w_structure("DSA", der, type_specific, dsa, yes),
  48. DECODER_w_structure("DSA", der, DSA, dsa, yes),
  49. DECODER("DSA", msblob, dsa, yes),
  50. DECODER("DSA", pvk, dsa, yes),
  51. #endif
  52. #ifndef OPENSSL_NO_EC
  53. DECODER_w_structure("EC", der, PrivateKeyInfo, ec, yes),
  54. DECODER_w_structure("EC", der, SubjectPublicKeyInfo, ec, yes),
  55. DECODER_w_structure("EC", der, type_specific_no_pub, ec, yes),
  56. DECODER_w_structure("EC", der, EC, ec, yes),
  57. # ifndef OPENSSL_NO_ECX
  58. DECODER_w_structure("ED25519", der, PrivateKeyInfo, ed25519, yes),
  59. DECODER_w_structure("ED25519", der, SubjectPublicKeyInfo, ed25519, yes),
  60. DECODER_w_structure("ED448", der, PrivateKeyInfo, ed448, yes),
  61. DECODER_w_structure("ED448", der, SubjectPublicKeyInfo, ed448, yes),
  62. DECODER_w_structure("X25519", der, PrivateKeyInfo, x25519, yes),
  63. DECODER_w_structure("X25519", der, SubjectPublicKeyInfo, x25519, yes),
  64. DECODER_w_structure("X448", der, PrivateKeyInfo, x448, yes),
  65. DECODER_w_structure("X448", der, SubjectPublicKeyInfo, x448, yes),
  66. # endif
  67. # ifndef OPENSSL_NO_SM2
  68. DECODER_w_structure("SM2", der, PrivateKeyInfo, sm2, no),
  69. DECODER_w_structure("SM2", der, SubjectPublicKeyInfo, sm2, no),
  70. DECODER_w_structure("SM2", der, type_specific_no_pub, sm2, no),
  71. # endif
  72. #endif
  73. DECODER_w_structure("RSA", der, PrivateKeyInfo, rsa, yes),
  74. DECODER_w_structure("RSA", der, SubjectPublicKeyInfo, rsa, yes),
  75. DECODER_w_structure("RSA", der, type_specific_keypair, rsa, yes),
  76. DECODER_w_structure("RSA", der, RSA, rsa, yes),
  77. DECODER_w_structure("RSA-PSS", der, PrivateKeyInfo, rsapss, yes),
  78. DECODER_w_structure("RSA-PSS", der, SubjectPublicKeyInfo, rsapss, yes),
  79. DECODER("RSA", msblob, rsa, yes),
  80. DECODER("RSA", pvk, rsa, yes),
  81. /*
  82. * A decoder that takes a SubjectPublicKeyInfo and figures out the types of key
  83. * that it contains. The output is the same SubjectPublicKeyInfo
  84. */
  85. DECODER_w_structure("DER", der, SubjectPublicKeyInfo, der, yes),
  86. DECODER("DER", pem, der, yes),
  87. /*
  88. * A decoder that recognises PKCS#8 EncryptedPrivateKeyInfo structure
  89. * and decrypts it, passing on the unencrypted PrivateKeyInfo in DER
  90. * form to the next decoder.
  91. */
  92. DECODER_w_structure("DER", der, EncryptedPrivateKeyInfo, der, yes),