app_libctx.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 1995-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. #include "app_libctx.h"
  10. #include "apps.h"
  11. static OSSL_LIB_CTX *app_libctx = NULL;
  12. static const char *app_propq = NULL;
  13. int app_set_propq(const char *arg)
  14. {
  15. app_propq = arg;
  16. return 1;
  17. }
  18. const char *app_get0_propq(void)
  19. {
  20. return app_propq;
  21. }
  22. OSSL_LIB_CTX *app_get0_libctx(void)
  23. {
  24. return app_libctx;
  25. }
  26. OSSL_LIB_CTX *app_create_libctx(void)
  27. {
  28. /*
  29. * Load the NULL provider into the default library context and create a
  30. * library context which will then be used for any OPT_PROV options.
  31. */
  32. if (app_libctx == NULL) {
  33. if (!app_provider_load(NULL, "null")) {
  34. opt_printf_stderr("Failed to create null provider\n");
  35. return NULL;
  36. }
  37. app_libctx = OSSL_LIB_CTX_new();
  38. }
  39. if (app_libctx == NULL)
  40. opt_printf_stderr("Failed to create library context\n");
  41. return app_libctx;
  42. }