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