provider.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2019-2020 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. # include <openssl/core.h>
  12. # include <openssl/core_dispatch.h>
  13. # include "internal/dso.h"
  14. # include "internal/symhacks.h"
  15. # ifdef __cplusplus
  16. extern "C" {
  17. # endif
  18. /*
  19. * namespaces:
  20. *
  21. * ossl_provider_ Provider Object internal API
  22. * OSSL_PROVIDER Provider Object
  23. */
  24. /* Provider Object finder, constructor and destructor */
  25. OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
  26. int noconfig);
  27. OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
  28. OSSL_provider_init_fn *init_function,
  29. int noconfig);
  30. int ossl_provider_up_ref(OSSL_PROVIDER *prov);
  31. void ossl_provider_free(OSSL_PROVIDER *prov);
  32. /* Setters */
  33. int ossl_provider_set_fallback(OSSL_PROVIDER *prov);
  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. /* Disable fallback loading */
  38. int ossl_provider_disable_fallback_loading(OSSL_LIB_CTX *libctx);
  39. /*
  40. * Activate the Provider
  41. * If the Provider is a module, the module will be loaded
  42. * Inactivation is done by freeing the Provider
  43. */
  44. int ossl_provider_activate(OSSL_PROVIDER *prov);
  45. /* Check if the provider is available */
  46. int ossl_provider_available(OSSL_PROVIDER *prov);
  47. /* Return pointer to the provider's context */
  48. void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
  49. /* Iterate over all loaded providers */
  50. int ossl_provider_forall_loaded(OSSL_LIB_CTX *,
  51. int (*cb)(OSSL_PROVIDER *provider,
  52. void *cbdata),
  53. void *cbdata);
  54. /* Getters for other library functions */
  55. const char *ossl_provider_name(const OSSL_PROVIDER *prov);
  56. const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov);
  57. const char *ossl_provider_module_name(const OSSL_PROVIDER *prov);
  58. const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
  59. void *ossl_provider_prov_ctx(const OSSL_PROVIDER *prov);
  60. OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov);
  61. /* Thin wrappers around calls to the provider */
  62. void ossl_provider_teardown(const OSSL_PROVIDER *prov);
  63. const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov);
  64. int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
  65. int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov,
  66. const char *capability,
  67. OSSL_CALLBACK *cb,
  68. void *arg);
  69. int ossl_provider_self_test(const OSSL_PROVIDER *prov);
  70. const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
  71. int operation_id,
  72. int *no_cache);
  73. /* Cache of bits to see if we already queried an operation */
  74. int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum);
  75. int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum,
  76. int *result);
  77. /* Configuration */
  78. void ossl_provider_add_conf_module(void);
  79. # ifdef __cplusplus
  80. }
  81. # endif
  82. #endif