2
0

property.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
  4. *
  5. * Licensed under the Apache License 2.0 (the "License"). You may not use
  6. * this file except in compliance with the License. You can obtain a copy
  7. * in the file LICENSE in the source distribution or at
  8. * https://www.openssl.org/source/license.html
  9. */
  10. #ifndef OSSL_INTERNAL_PROPERTY_H
  11. # define OSSL_INTERNAL_PROPERTY_H
  12. # pragma once
  13. # include "internal/cryptlib.h"
  14. typedef struct ossl_method_store_st OSSL_METHOD_STORE;
  15. typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
  16. typedef enum {
  17. OSSL_PROPERTY_TYPE_STRING, OSSL_PROPERTY_TYPE_NUMBER,
  18. OSSL_PROPERTY_TYPE_VALUE_UNDEFINED
  19. } OSSL_PROPERTY_TYPE;
  20. typedef struct ossl_property_definition_st OSSL_PROPERTY_DEFINITION;
  21. /* Initialisation */
  22. int ossl_property_parse_init(OSSL_LIB_CTX *ctx);
  23. /* Property definition parser */
  24. OSSL_PROPERTY_LIST *ossl_parse_property(OSSL_LIB_CTX *ctx, const char *defn);
  25. /* Property query parser */
  26. OSSL_PROPERTY_LIST *ossl_parse_query(OSSL_LIB_CTX *ctx, const char *s,
  27. int create_values);
  28. /* Property checker of query vs definition */
  29. int ossl_property_match_count(const OSSL_PROPERTY_LIST *query,
  30. const OSSL_PROPERTY_LIST *defn);
  31. int ossl_property_is_enabled(OSSL_LIB_CTX *ctx, const char *property_name,
  32. const OSSL_PROPERTY_LIST *prop_list);
  33. /* Free a parsed property list */
  34. void ossl_property_free(OSSL_PROPERTY_LIST *p);
  35. /* Get a property from a property list */
  36. const OSSL_PROPERTY_DEFINITION *
  37. ossl_property_find_property(const OSSL_PROPERTY_LIST *list,
  38. OSSL_LIB_CTX *libctx, const char *name);
  39. OSSL_PROPERTY_TYPE ossl_property_get_type(const OSSL_PROPERTY_DEFINITION *prop);
  40. const char *ossl_property_get_string_value(OSSL_LIB_CTX *libctx,
  41. const OSSL_PROPERTY_DEFINITION *prop);
  42. int64_t ossl_property_get_number_value(const OSSL_PROPERTY_DEFINITION *prop);
  43. /* Implementation store functions */
  44. OSSL_METHOD_STORE *ossl_method_store_new(OSSL_LIB_CTX *ctx);
  45. void ossl_method_store_free(OSSL_METHOD_STORE *store);
  46. int ossl_method_lock_store(OSSL_METHOD_STORE *store);
  47. int ossl_method_unlock_store(OSSL_METHOD_STORE *store);
  48. int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
  49. int nid, const char *properties, void *method,
  50. int (*method_up_ref)(void *),
  51. void (*method_destruct)(void *));
  52. int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid,
  53. const void *method);
  54. void ossl_method_store_do_all(OSSL_METHOD_STORE *store,
  55. void (*fn)(int id, void *method, void *fnarg),
  56. void *fnarg);
  57. int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
  58. int nid, const char *prop_query,
  59. const OSSL_PROVIDER **prov, void **method);
  60. int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store,
  61. const OSSL_PROVIDER *prov);
  62. /* Get the global properties associate with the specified library context */
  63. OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx,
  64. int loadconfig);
  65. /* property query cache functions */
  66. int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
  67. int nid, const char *prop_query, void **result);
  68. int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
  69. int nid, const char *prop_query, void *result,
  70. int (*method_up_ref)(void *),
  71. void (*method_destruct)(void *));
  72. __owur int ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store);
  73. /* Merge two property queries together */
  74. OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a,
  75. const OSSL_PROPERTY_LIST *b);
  76. size_t ossl_property_list_to_string(OSSL_LIB_CTX *ctx,
  77. const OSSL_PROPERTY_LIST *list, char *buf,
  78. size_t bufsize);
  79. int ossl_global_properties_no_mirrored(OSSL_LIB_CTX *libctx);
  80. void ossl_global_properties_stop_mirroring(OSSL_LIB_CTX *libctx);
  81. #endif