2 * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
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
11 #ifndef OSSL_INTERNAL_PROPERTY_H
12 # define OSSL_INTERNAL_PROPERTY_H
15 # include "internal/cryptlib.h"
17 typedef struct ossl_method_store_st OSSL_METHOD_STORE;
18 typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
21 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,
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);
37 /* Implementation store functions */
38 OSSL_METHOD_STORE *ossl_method_store_new(OSSL_LIB_CTX *ctx);
39 void ossl_method_store_free(OSSL_METHOD_STORE *store);
40 int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
41 int nid, const char *properties, void *method,
42 int (*method_up_ref)(void *),
43 void (*method_destruct)(void *));
44 int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid,
46 int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid,
47 const char *prop_query, void **method);
49 /* Get the global properties associate with the specified library context */
50 OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx,
53 /* property query cache functions */
54 int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, int nid,
55 const char *prop_query, void **result);
56 int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, int nid,
57 const char *prop_query, void *result,
58 int (*method_up_ref)(void *),
59 void (*method_destruct)(void *));
61 __owur int ossl_method_store_flush_cache(OSSL_METHOD_STORE *store, int all);
63 /* Merge two property queries together */
64 OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a,
65 const OSSL_PROPERTY_LIST *b);
67 size_t ossl_property_list_to_string(OSSL_LIB_CTX *ctx,
68 const OSSL_PROPERTY_LIST *list, char *buf,