OSSL_DECODER_CTX_new_by_EVP_PKEY.pod 4.1 KB

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