provider.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright 2019-2021 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 OSSL_INTERNAL_PROVIDER_H
  10. # define OSSL_INTERNAL_PROVIDER_H
  11. # pragma once
  12. # include <openssl/core.h>
  13. # include <openssl/core_dispatch.h>
  14. # include "internal/dso.h"
  15. # include "internal/symhacks.h"
  16. # ifdef __cplusplus
  17. extern "C" {
  18. # endif
  19. /*
  20. * namespaces:
  21. *
  22. * ossl_provider_ Provider Object internal API
  23. * OSSL_PROVIDER Provider Object
  24. */
  25. /* Provider Object finder, constructor and destructor */
  26. OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
  27. int noconfig);
  28. OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
  29. OSSL_provider_init_fn *init_function,
  30. int noconfig);
  31. int ossl_provider_up_ref(OSSL_PROVIDER *prov);
  32. void ossl_provider_free(OSSL_PROVIDER *prov);
  33. /* Setters */
  34. int ossl_provider_set_fallback(OSSL_PROVIDER *prov);
  35. int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *module_path);
  36. int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name,
  37. const char *value);
  38. int ossl_provider_is_child(const OSSL_PROVIDER *prov);
  39. int ossl_provider_set_child(OSSL_PROVIDER *prov, const OSSL_CORE_HANDLE *handle);
  40. int ossl_provider_convert_to_child(OSSL_PROVIDER *prov,
  41. const OSSL_CORE_HANDLE *handle,
  42. OSSL_provider_init_fn *init_function);
  43. const OSSL_CORE_HANDLE *ossl_provider_get_parent(OSSL_PROVIDER *prov);
  44. int ossl_provider_up_ref_parent(OSSL_PROVIDER *prov, int activate);
  45. int ossl_provider_free_parent(OSSL_PROVIDER *prov, int deactivate);
  46. int ossl_provider_default_props_update(OSSL_LIB_CTX *libctx, const char *props);
  47. /* Disable fallback loading */
  48. int ossl_provider_disable_fallback_loading(OSSL_LIB_CTX *libctx);
  49. /*
  50. * Activate the Provider
  51. * If the Provider is a module, the module will be loaded
  52. */
  53. int ossl_provider_activate(OSSL_PROVIDER *prov, int retain_fallbacks,
  54. int upcalls);
  55. int ossl_provider_deactivate(OSSL_PROVIDER *prov);
  56. /* Check if the provider is available (activated) */
  57. int ossl_provider_available(OSSL_PROVIDER *prov);
  58. /* Return pointer to the provider's context */
  59. void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
  60. /* Iterate over all loaded providers */
  61. int ossl_provider_doall_activated(OSSL_LIB_CTX *,
  62. int (*cb)(OSSL_PROVIDER *provider,
  63. void *cbdata),
  64. void *cbdata);
  65. /* Getters for other library functions */
  66. const char *ossl_provider_name(const OSSL_PROVIDER *prov);
  67. const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov);
  68. const char *ossl_provider_module_name(const OSSL_PROVIDER *prov);
  69. const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
  70. void *ossl_provider_prov_ctx(const OSSL_PROVIDER *prov);
  71. const OSSL_DISPATCH *ossl_provider_get0_dispatch(const OSSL_PROVIDER *prov);
  72. OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov);
  73. /* Thin wrappers around calls to the provider */
  74. void ossl_provider_teardown(const OSSL_PROVIDER *prov);
  75. const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov);
  76. int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
  77. int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov,
  78. const char *capability,
  79. OSSL_CALLBACK *cb,
  80. void *arg);
  81. int ossl_provider_self_test(const OSSL_PROVIDER *prov);
  82. const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
  83. int operation_id,
  84. int *no_cache);
  85. void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov,
  86. int operation_id,
  87. const OSSL_ALGORITHM *algs);
  88. /* Cache of bits to see if we already queried an operation */
  89. int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum);
  90. int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum,
  91. int *result);
  92. int ossl_provider_clear_all_operation_bits(OSSL_LIB_CTX *libctx);
  93. /* Configuration */
  94. void ossl_provider_add_conf_module(void);
  95. /* Child providers */
  96. int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx,
  97. const OSSL_CORE_HANDLE *handle,
  98. const OSSL_DISPATCH *in);
  99. # ifdef __cplusplus
  100. }
  101. # endif
  102. #endif