property: move additional query functions to property_query.c

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15614)
This commit is contained in:
Pauli 2021-06-04 14:35:53 +10:00
parent fce102304a
commit 76157664c1
4 changed files with 25 additions and 24 deletions

View File

@ -2,4 +2,3 @@ LIBS=../../libcrypto
$COMMON=property_string.c property_parse.c property_query.c property.c defn_cache.c
SOURCE[../../libcrypto]=$COMMON property_err.c
SOURCE[../../providers/libfips.a]=$COMMON
SOURCE[../../providers/liblegacy.a]=$COMMON

View File

@ -34,6 +34,8 @@ struct ossl_property_list_st {
OSSL_PROPERTY_DEFINITION properties[1];
};
extern OSSL_PROPERTY_IDX ossl_property_true, ossl_property_false;
/* Property string functions */
OSSL_PROPERTY_IDX ossl_property_name(OSSL_LIB_CTX *ctx, const char *s,
int create);

View File

@ -19,7 +19,7 @@
#include "property_local.h"
#include "e_os.h"
static OSSL_PROPERTY_IDX ossl_property_true, ossl_property_false;
OSSL_PROPERTY_IDX ossl_property_true, ossl_property_false;
DEFINE_STACK_OF(OSSL_PROPERTY_DEFINITION)
@ -422,28 +422,6 @@ err:
return res;
}
/* Does a property query have any optional clauses */
int ossl_property_has_optional(const OSSL_PROPERTY_LIST *query)
{
return query->has_optional ? 1 : 0;
}
int ossl_property_is_enabled(OSSL_LIB_CTX *ctx, const char *property_name,
const OSSL_PROPERTY_LIST *prop_list)
{
const OSSL_PROPERTY_DEFINITION *prop;
prop = ossl_property_find_property(prop_list, ctx, property_name);
/* Do a separate check for override as it does not set type */
if (prop == NULL || prop->optional || prop->oper == OSSL_PROPERTY_OVERRIDE)
return 0;
return (prop->type == OSSL_PROPERTY_TYPE_STRING
&& ((prop->oper == OSSL_PROPERTY_OPER_EQ
&& prop->v.str_val == ossl_property_true)
|| (prop->oper == OSSL_PROPERTY_OPER_NE
&& prop->v.str_val != ossl_property_true)));
}
/*
* Compare a query against a definition.
* Return the number of clauses matched or -1 if a mandatory clause is false.

View File

@ -58,3 +58,25 @@ int64_t ossl_property_get_number_value(const OSSL_PROPERTY_DEFINITION *prop)
return value;
}
/* Does a property query have any optional clauses */
int ossl_property_has_optional(const OSSL_PROPERTY_LIST *query)
{
return query->has_optional ? 1 : 0;
}
int ossl_property_is_enabled(OSSL_LIB_CTX *ctx, const char *property_name,
const OSSL_PROPERTY_LIST *prop_list)
{
const OSSL_PROPERTY_DEFINITION *prop;
prop = ossl_property_find_property(prop_list, ctx, property_name);
/* Do a separate check for override as it does not set type */
if (prop == NULL || prop->optional || prop->oper == OSSL_PROPERTY_OVERRIDE)
return 0;
return (prop->type == OSSL_PROPERTY_TYPE_STRING
&& ((prop->oper == OSSL_PROPERTY_OPER_EQ
&& prop->v.str_val == ossl_property_true)
|| (prop->oper == OSSL_PROPERTY_OPER_NE
&& prop->v.str_val != ossl_property_true)));
}