OSSL_PROVIDER.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. =pod
  2. =head1 NAME
  3. OSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_unload,
  4. OSSL_PROVIDER_available,
  5. OSSL_PROVIDER_gettable_params, OSSL_PROVIDER_get_params,
  6. OSSL_PROVIDER_add_builtin, OSSL_PROVIDER_name - provider routines
  7. =head1 SYNOPSIS
  8. #include <openssl/provider.h>
  9. typedef struct ossl_provider_st OSSL_PROVIDER;
  10. OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *libctx, const char *name);
  11. int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
  12. int OSSL_PROVIDER_available(OPENSSL_CTX *libctx, const char *name);
  13. const OSSL_PARAM *OSSL_PROVIDER_gettable_params(OSSL_PROVIDER *prov);
  14. int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]);
  15. int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *libctx, const char *name,
  16. ossl_provider_init_fn *init_fn);
  17. const char *OSSL_PROVIDER_name(const OSSL_PROVIDER *prov);
  18. =head1 DESCRIPTION
  19. B<OSSL_PROVIDER> is a type that holds internal information about
  20. implementation providers (see L<provider(7)> for information on what a
  21. provider is).
  22. A provider can be built in to the application or the OpenSSL
  23. libraries, or can be a loadable module.
  24. The functions described here handle both forms.
  25. Some of these functions operate within a library context, please see
  26. L<OPENSSL_CTX(3)> for further details.
  27. =head2 Functions
  28. OSSL_PROVIDER_add_builtin() is used to add a built in provider to
  29. B<OSSL_PROVIDER> store in the given library context, by associating a
  30. provider name with a provider initialization function.
  31. This name can then be used with OSSL_PROVIDER_load().
  32. OSSL_PROVIDER_load() loads and initializes a provider.
  33. This may simply initialize a provider that was previously added with
  34. OSSL_PROVIDER_add_builtin() and run its given initialization function,
  35. or load a provider module with the given name and run its provider
  36. entry point, C<OSSL_provider_init>.
  37. OSSL_PROVIDER_unload() unloads the given provider.
  38. For a provider added with OSSL_PROVIDER_add_builtin(), this simply
  39. runs its teardown function.
  40. OSSL_PROVIDER_available() checks if a named provider is available
  41. for use.
  42. OSSL_PROVIDER_gettable_params() is used to get a provider parameter
  43. descriptor set as a constant B<OSSL_PARAM> array.
  44. See L<OSSL_PARAM(3)> for more information.
  45. OSSL_PROVIDER_get_params() is used to get provider parameter values.
  46. The caller must prepare the B<OSSL_PARAM> array before calling this
  47. function, and the variables acting as buffers for this parameter array
  48. should be filled with data when it returns successfully.
  49. OSSL_PROVIDER_name() returns the name of the given provider.
  50. =head1 RETURN VALUES
  51. OSSL_PROVIDER_add() returns 1 on success, or 0 on error.
  52. OSSL_PROVIDER_load() returns a pointer to a provider object on
  53. success, or B<NULL> on error.
  54. OSSL_PROVIDER_unload() returns 1 on success, or 0 on error.
  55. OSSL_PROVIDER_available() returns 1 if the named provider is available,
  56. otherwise 0.
  57. OSSL_PROVIDER_gettable_params() returns a pointer to an array
  58. of constant B<OSSL_PARAM>, or NULL if none is provided.
  59. OSSL_PROVIDER_get_params() returns 1 on success, or 0 on error.
  60. =head1 EXAMPLES
  61. This demonstrates how to load the provider module "foo" and ask for
  62. its build number.
  63. OSSL_PROVIDER *prov = NULL;
  64. const char *build = NULL;
  65. size_t built_l = 0;
  66. OSSL_PARAM request[] = {
  67. { "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l },
  68. { NULL, 0, NULL, 0, NULL }
  69. };
  70. if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL
  71. && OSSL_PROVIDER_get_params(prov, request))
  72. printf("Provider 'foo' build %s\n", build);
  73. else
  74. ERR_print_errors_fp(stderr);
  75. =head1 SEE ALSO
  76. L<openssl-core.h(7)>, L<OPENSSL_CTX(3)>, L<provider(7)>
  77. =head1 HISTORY
  78. The type and functions described here were added in OpenSSL 3.0.
  79. =head1 COPYRIGHT
  80. Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  81. Licensed under the Apache License 2.0 (the "License"). You may not use
  82. this file except in compliance with the License. You can obtain a copy
  83. in the file LICENSE in the source distribution or at
  84. L<https://www.openssl.org/source/license.html>.
  85. =cut