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