provider_ctx.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 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. #include <stdlib.h>
  10. #include "prov/provider_ctx.h"
  11. #include "prov/bio.h"
  12. PROV_CTX *ossl_prov_ctx_new(void)
  13. {
  14. return OPENSSL_zalloc(sizeof(PROV_CTX));
  15. }
  16. void ossl_prov_ctx_free(PROV_CTX *ctx)
  17. {
  18. OPENSSL_free(ctx);
  19. }
  20. void ossl_prov_ctx_set0_libctx(PROV_CTX *ctx, OSSL_LIB_CTX *libctx)
  21. {
  22. if (ctx != NULL)
  23. ctx->libctx = libctx;
  24. }
  25. void ossl_prov_ctx_set0_handle(PROV_CTX *ctx, const OSSL_CORE_HANDLE *handle)
  26. {
  27. if (ctx != NULL)
  28. ctx->handle = handle;
  29. }
  30. void ossl_prov_ctx_set0_core_bio_method(PROV_CTX *ctx, BIO_METHOD *corebiometh)
  31. {
  32. if (ctx != NULL)
  33. ctx->corebiometh = corebiometh;
  34. }
  35. OSSL_LIB_CTX *ossl_prov_ctx_get0_libctx(PROV_CTX *ctx)
  36. {
  37. if (ctx == NULL)
  38. return NULL;
  39. return ctx->libctx;
  40. }
  41. const OSSL_CORE_HANDLE *ossl_prov_ctx_get0_handle(PROV_CTX *ctx)
  42. {
  43. if (ctx == NULL)
  44. return NULL;
  45. return ctx->handle;
  46. }
  47. BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(PROV_CTX *ctx)
  48. {
  49. if (ctx == NULL)
  50. return NULL;
  51. return ctx->corebiometh;
  52. }