store_init.c 876 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright 2016-2018 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 <openssl/err.h>
  10. #include "internal/store.h"
  11. #include "store_locl.h"
  12. static CRYPTO_ONCE store_init = CRYPTO_ONCE_STATIC_INIT;
  13. DEFINE_RUN_ONCE_STATIC(do_store_init)
  14. {
  15. return OPENSSL_init_crypto(0, NULL)
  16. && ossl_store_file_loader_init();
  17. }
  18. int ossl_store_init_once(void)
  19. {
  20. if (!RUN_ONCE(&store_init, do_store_init)) {
  21. OSSL_STOREerr(OSSL_STORE_F_OSSL_STORE_INIT_ONCE, ERR_R_MALLOC_FAILURE);
  22. return 0;
  23. }
  24. return 1;
  25. }
  26. void ossl_store_cleanup_int(void)
  27. {
  28. ossl_store_destroy_loaders_int();
  29. }