core.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2019-2022 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_CORE_H
  10. # define OSSL_INTERNAL_CORE_H
  11. # pragma once
  12. /*
  13. * namespaces:
  14. *
  15. * ossl_method_ Core Method API
  16. */
  17. /*
  18. * construct an arbitrary method from a dispatch table found by looking
  19. * up a match for the < operation_id, name, property > combination.
  20. * constructor and destructor are the constructor and destructor for that
  21. * arbitrary object.
  22. *
  23. * These objects are normally cached, unless the provider says not to cache.
  24. * However, force_cache can be used to force caching whatever the provider
  25. * says (for example, because the application knows better).
  26. */
  27. typedef struct ossl_method_construct_method_st {
  28. /* Get a temporary store */
  29. void *(*get_tmp_store)(void *data);
  30. /* Reserve the appropriate method store */
  31. int (*lock_store)(void *store, void *data);
  32. /* Unreserve the appropriate method store */
  33. int (*unlock_store)(void *store, void *data);
  34. /* Get an already existing method from a store */
  35. void *(*get)(void *store, const OSSL_PROVIDER **prov, void *data);
  36. /* Store a method in a store */
  37. int (*put)(void *store, void *method, const OSSL_PROVIDER *prov,
  38. const char *name, const char *propdef, void *data);
  39. /* Construct a new method */
  40. void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov,
  41. void *data);
  42. /* Destruct a method */
  43. void (*destruct)(void *method, void *data);
  44. } OSSL_METHOD_CONSTRUCT_METHOD;
  45. void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id,
  46. OSSL_PROVIDER **provider_rw, int force_cache,
  47. OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data);
  48. void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id,
  49. OSSL_PROVIDER *provider,
  50. int (*pre)(OSSL_PROVIDER *, int operation_id,
  51. int no_store, void *data, int *result),
  52. int (*reserve_store)(int no_store, void *data),
  53. void (*fn)(OSSL_PROVIDER *provider,
  54. const OSSL_ALGORITHM *algo,
  55. int no_store, void *data),
  56. int (*unreserve_store)(void *data),
  57. int (*post)(OSSL_PROVIDER *, int operation_id,
  58. int no_store, void *data, int *result),
  59. void *data);
  60. char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo);
  61. __owur int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx);
  62. __owur int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx);
  63. int ossl_lib_ctx_unlock(OSSL_LIB_CTX *ctx);
  64. int ossl_lib_ctx_is_child(OSSL_LIB_CTX *ctx);
  65. #endif