store_locl.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 "internal/thread_once.h"
  10. #include <openssl/dsa.h>
  11. #include <openssl/engine.h>
  12. #include <openssl/evp.h>
  13. #include <openssl/lhash.h>
  14. #include <openssl/x509.h>
  15. #include <openssl/store.h>
  16. /*-
  17. * OSSL_STORE_INFO stuff
  18. * ---------------------
  19. */
  20. struct ossl_store_info_st {
  21. int type;
  22. union {
  23. void *data; /* used internally as generic pointer */
  24. struct {
  25. BUF_MEM *blob;
  26. char *pem_name;
  27. } embedded; /* when type == OSSL_STORE_INFO_EMBEDDED */
  28. struct {
  29. char *name;
  30. char *desc;
  31. } name; /* when type == OSSL_STORE_INFO_NAME */
  32. EVP_PKEY *params; /* when type == OSSL_STORE_INFO_PARAMS */
  33. EVP_PKEY *pkey; /* when type == OSSL_STORE_INFO_PKEY */
  34. X509 *x509; /* when type == OSSL_STORE_INFO_CERT */
  35. X509_CRL *crl; /* when type == OSSL_STORE_INFO_CRL */
  36. } _;
  37. };
  38. DEFINE_STACK_OF(OSSL_STORE_INFO)
  39. /*
  40. * EMBEDDED is a special type of OSSL_STORE_INFO, specially for the file
  41. * handlers. It should never reach a calling application or any engine.
  42. * However, it can be used by a FILE_HANDLER's try_decode function to signal
  43. * that it has decoded the incoming blob into a new blob, and that the
  44. * attempted decoding should be immediately restarted with the new blob, using
  45. * the new PEM name.
  46. */
  47. /*
  48. * Because this is an internal type, we don't make it public.
  49. */
  50. #define OSSL_STORE_INFO_EMBEDDED -1
  51. OSSL_STORE_INFO *ossl_store_info_new_EMBEDDED(const char *new_pem_name,
  52. BUF_MEM *embedded);
  53. BUF_MEM *ossl_store_info_get0_EMBEDDED_buffer(OSSL_STORE_INFO *info);
  54. char *ossl_store_info_get0_EMBEDDED_pem_name(OSSL_STORE_INFO *info);
  55. /*-
  56. * OSSL_STORE_SEARCH stuff
  57. * -----------------------
  58. */
  59. struct ossl_store_search_st {
  60. int search_type;
  61. /*
  62. * Used by OSSL_STORE_SEARCH_BY_NAME and
  63. * OSSL_STORE_SEARCH_BY_ISSUER_SERIAL
  64. */
  65. X509_NAME *name;
  66. /* Used by OSSL_STORE_SEARCH_BY_ISSUER_SERIAL */
  67. const ASN1_INTEGER *serial;
  68. /* Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT */
  69. const EVP_MD *digest;
  70. /*
  71. * Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT and
  72. * OSSL_STORE_SEARCH_BY_ALIAS
  73. */
  74. const unsigned char *string;
  75. size_t stringlength;
  76. };
  77. /*-
  78. * OSSL_STORE_LOADER stuff
  79. * -----------------------
  80. */
  81. int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader);
  82. OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme);
  83. /* loader stuff */
  84. struct ossl_store_loader_st {
  85. const char *scheme;
  86. ENGINE *engine;
  87. OSSL_STORE_open_fn open;
  88. OSSL_STORE_ctrl_fn ctrl;
  89. OSSL_STORE_expect_fn expect;
  90. OSSL_STORE_find_fn find;
  91. OSSL_STORE_load_fn load;
  92. OSSL_STORE_eof_fn eof;
  93. OSSL_STORE_error_fn error;
  94. OSSL_STORE_close_fn close;
  95. };
  96. DEFINE_LHASH_OF(OSSL_STORE_LOADER);
  97. const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme);
  98. void ossl_store_destroy_loaders_int(void);
  99. /*-
  100. * OSSL_STORE init stuff
  101. * ---------------------
  102. */
  103. int ossl_store_init_once(void);
  104. int ossl_store_file_loader_init(void);
  105. /*-
  106. * 'file' scheme stuff
  107. * -------------------
  108. */
  109. OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp);
  110. int ossl_store_file_detach_pem_bio_int(OSSL_STORE_LOADER_CTX *ctx);