2
0

provider.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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_module_path(OSSL_PROVIDER *prov, const char *module_path);
  35. int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name,
  36. const char *value);
  37. int ossl_provider_is_child(const OSSL_PROVIDER *prov);
  38. int ossl_provider_set_child(OSSL_PROVIDER *prov, const OSSL_CORE_HANDLE *handle);
  39. const OSSL_CORE_HANDLE *ossl_provider_get_parent(OSSL_PROVIDER *prov);
  40. int ossl_provider_up_ref_parent(OSSL_PROVIDER *prov, int activate);
  41. int ossl_provider_free_parent(OSSL_PROVIDER *prov, int deactivate);
  42. int ossl_provider_default_props_update(OSSL_LIB_CTX *libctx, const char *props);
  43. /* Disable fallback loading */
  44. int ossl_provider_disable_fallback_loading(OSSL_LIB_CTX *libctx);
  45. /*
  46. * Activate the Provider
  47. * If the Provider is a module, the module will be loaded
  48. */
  49. int ossl_provider_activate(OSSL_PROVIDER *prov, int upcalls, int aschild);
  50. int ossl_provider_deactivate(OSSL_PROVIDER *prov, int removechildren);
  51. int ossl_provider_add_to_store(OSSL_PROVIDER *prov, OSSL_PROVIDER **actualprov,
  52. int retain_fallbacks);
  53. /* Return pointer to the provider's context */
  54. void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
  55. /* Iterate over all loaded providers */
  56. int ossl_provider_doall_activated(OSSL_LIB_CTX *,
  57. int (*cb)(OSSL_PROVIDER *provider,
  58. void *cbdata),
  59. void *cbdata);
  60. /* Getters for other library functions */
  61. const char *ossl_provider_name(const OSSL_PROVIDER *prov);
  62. const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov);
  63. const char *ossl_provider_module_name(const OSSL_PROVIDER *prov);
  64. const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
  65. void *ossl_provider_prov_ctx(const OSSL_PROVIDER *prov);
  66. const OSSL_DISPATCH *ossl_provider_get0_dispatch(const OSSL_PROVIDER *prov);
  67. OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov);
  68. /* Thin wrappers around calls to the provider */
  69. void ossl_provider_teardown(const OSSL_PROVIDER *prov);
  70. const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov);
  71. int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
  72. int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov,
  73. const char *capability,
  74. OSSL_CALLBACK *cb,
  75. void *arg);
  76. int ossl_provider_self_test(const OSSL_PROVIDER *prov);
  77. const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
  78. int operation_id,
  79. int *no_cache);
  80. void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov,
  81. int operation_id,
  82. const OSSL_ALGORITHM *algs);
  83. /*
  84. * Cache of bits to see if we already added methods for an operation in
  85. * the "permanent" method store.
  86. * They should never be called for temporary method stores!
  87. */
  88. int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum);
  89. int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum,
  90. int *result);
  91. /* Configuration */
  92. void ossl_provider_add_conf_module(void);
  93. /* Child providers */
  94. int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx,
  95. const OSSL_CORE_HANDLE *handle,
  96. const OSSL_DISPATCH *in);
  97. void ossl_provider_deinit_child(OSSL_LIB_CTX *ctx);
  98. # ifdef __cplusplus
  99. }
  100. # endif
  101. #endif