OSSL_DECODER_CTX_new_by_EVP_PKEY.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. =pod
  2. =head1 NAME
  3. OSSL_DECODER_CTX_new_by_EVP_PKEY,
  4. OSSL_DECODER_CTX_set_passphrase,
  5. OSSL_DECODER_CTX_set_pem_password_cb,
  6. OSSL_DECODER_CTX_set_passphrase_ui
  7. - Decoder routines to decode EVP_PKEYs
  8. =head1 SYNOPSIS
  9. #include <openssl/decoder.h>
  10. OSSL_DECODER_CTX *
  11. OSSL_DECODER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey, const char *input_type,
  12. OPENSSL_CTX *libctx, const char *propquery);
  13. int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx,
  14. const unsigned char *kstr,
  15. size_t klen);
  16. int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx,
  17. pem_password_cb *cb,
  18. void *cbarg);
  19. int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx,
  20. const UI_METHOD *ui_method,
  21. void *ui_data);
  22. =head1 DESCRIPTION
  23. OSSL_DECODER_CTX_new_by_EVP_PKEY() is a utility function that
  24. creates a B<OSSL_DECODER_CTX>, finds all applicable decoder
  25. implementations and sets them up, so all the caller has to do next is
  26. call functions like OSSL_DECODE_from_bio().
  27. Internally OSSL_DECODER_CTX_new_by_EVP_PKEY() searches for all
  28. available L<EVP_KEYMGMT(3)> implementations, and then builds a list of all
  29. potential decoder implementations that may be able to process the
  30. encoded input into data suitable for B<EVP_PKEY>s. All these
  31. implementations are implicitly fetched using I<libctx> and I<propquery>.
  32. The search of decoder implementations can be limited with
  33. I<input_type>, which specifies a starting input type. This is further
  34. explained in L<OSSL_DECODER_CTX_set_input_type(3)>.
  35. If no suitable decoder was found, OSSL_DECODER_CTX_new_by_EVP_PKEY()
  36. still creates a B<OSSL_DECODER_CTX>, but with no associated
  37. decoder (L<OSSL_DECODER_CTX_num_decoders(3)> returns
  38. zero). This helps the caller distinguish between an error when
  39. creating the B<OSSL_DECODER_CTX>, and the lack the decoder
  40. support and act accordingly.
  41. OSSL_DECODER_CTX_set_passphrase() gives the implementation a
  42. pass phrase to use when decrypting the encoded private key.
  43. Alternatively, a pass phrase callback may be specified with the
  44. following functions.
  45. OSSL_DECODER_CTX_set_pem_password_cb() and
  46. OSSL_DECODER_CTX_set_passphrase_ui() set up a callback method that
  47. the implementation can use to prompt for a pass phrase, giving the caller
  48. the choice of prefered pass phrase callback form. These are called
  49. indirectly, through an internal B<OSSL_PASSPHRASE_CALLBACK> function.
  50. The internal B<OSSL_PASSPHRASE_CALLBACK> function caches the pass phrase, to
  51. be re-used in all decodings that are performed in the same
  52. decoding run
  53. (for example, within one L<OSSL_DECODER_from_bio(3)> call).
  54. =for comment the name OSSL_DECODER_CTX_set_pem_password_cb() leaves
  55. open the future possibility of having a function where the caller can set a
  56. B<OSSL_PASSPHRASE_CALLBACK> method as another option.
  57. =head1 RETURN VALUES
  58. OSSL_DECODER_CTX_new_by_EVP_PKEY() returns a pointer to a
  59. B<OSSL_DECODER_CTX>, or NULL if it couldn't be created.
  60. OSSL_DECODER_CTX_set_passphrase(),
  61. OSSL_DECODER_CTX_set_pem_password_cb() and
  62. OSSL_DECODER_CTX_set_passphrase_ui()
  63. all return 1 on success, or 0 on failure.
  64. =head1 NOTES
  65. Parts of the function names are made to match already existing OpenSSL
  66. names.
  67. B<EVP_PKEY> in OSSL_DECODER_CTX_new_by_EVP_PKEY() matches the type
  68. name, thus making for the naming pattern
  69. B<OSSL_DECODER_CTX_new_by_I<TYPE>>() when new types are handled.
  70. =head1 SEE ALSO
  71. L<provider(7)>, L<OSSL_DECODER(3)>, L<OSSL_DECODER_CTX(3)>
  72. =head1 HISTORY
  73. The functions described here were added in OpenSSL 3.0.
  74. =head1 COPYRIGHT
  75. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  76. Licensed under the Apache License 2.0 (the "License"). You may not use
  77. this file except in compliance with the License. You can obtain a copy
  78. in the file LICENSE in the source distribution or at
  79. L<https://www.openssl.org/source/license.html>.
  80. =cut