Latest update.
This commit is contained in:
@@ -2,3 +2,4 @@ LIBS=../../libcrypto
|
||||
$COMMON=property_string.c property_parse.c property.c defn_cache.c
|
||||
SOURCE[../../libcrypto]=$COMMON property_err.c
|
||||
SOURCE[../../providers/libfips.a]=$COMMON
|
||||
SOURCE[../../providers/liblegacy.a]=$COMMON
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
@@ -305,7 +305,7 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid,
|
||||
int ret = 0;
|
||||
int j, best = -1, score, optional;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
||||
#endif
|
||||
|
||||
@@ -362,10 +362,51 @@ fin:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ossl_method_store_set_global_properties(OSSL_METHOD_STORE *store,
|
||||
const char *prop_query) {
|
||||
int ossl_method_store_global_property_is_enabled(OSSL_METHOD_STORE *store,
|
||||
const char *prop_name)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (store == NULL)
|
||||
return 0;
|
||||
|
||||
ossl_property_read_lock(store);
|
||||
ret = ossl_property_is_enabled(store->ctx, prop_name,
|
||||
store->global_properties);
|
||||
ossl_property_unlock(store);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ossl_method_store_set_global_properties(OSSL_METHOD_STORE *store,
|
||||
const char *prop_query)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (store == NULL)
|
||||
return 1;
|
||||
|
||||
ossl_property_write_lock(store);
|
||||
ossl_method_cache_flush_all(store);
|
||||
|
||||
ossl_property_free(store->global_properties);
|
||||
store->global_properties = NULL;
|
||||
|
||||
if (prop_query == NULL) {
|
||||
ossl_property_unlock(store);
|
||||
return 1;
|
||||
}
|
||||
store->global_properties = ossl_parse_query(store->ctx, prop_query);
|
||||
ret = store->global_properties != NULL;
|
||||
ossl_property_unlock(store);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ossl_method_store_merge_global_properties(OSSL_METHOD_STORE *store,
|
||||
const char *prop_query)
|
||||
{
|
||||
int ret = 0;
|
||||
OSSL_PROPERTY_LIST *prop = NULL, *global;
|
||||
|
||||
if (store == NULL)
|
||||
return 1;
|
||||
|
||||
@@ -374,15 +415,31 @@ int ossl_method_store_set_global_properties(OSSL_METHOD_STORE *store,
|
||||
if (prop_query == NULL) {
|
||||
ossl_property_free(store->global_properties);
|
||||
store->global_properties = NULL;
|
||||
ossl_property_unlock(store);
|
||||
return 1;
|
||||
goto success;
|
||||
}
|
||||
store->global_properties = ossl_parse_query(store->ctx, prop_query);
|
||||
ret = store->global_properties != NULL;
|
||||
prop = ossl_parse_query(store->ctx, prop_query);
|
||||
if (prop == NULL)
|
||||
goto end;
|
||||
|
||||
if (store->global_properties == NULL) {
|
||||
store->global_properties = prop;
|
||||
prop = NULL;
|
||||
goto success;
|
||||
}
|
||||
global = ossl_property_merge(prop, store->global_properties);
|
||||
if (global == NULL)
|
||||
goto end;
|
||||
ossl_property_free(store->global_properties);
|
||||
store->global_properties = global;
|
||||
success:
|
||||
ret = 1;
|
||||
end:
|
||||
ossl_property_unlock(store);
|
||||
ossl_property_free(prop);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void impl_cache_flush_alg(ossl_uintmax_t idx, ALGORITHM *alg)
|
||||
{
|
||||
lh_QUERY_doall(alg->cache, &impl_cache_free);
|
||||
|
||||
@@ -453,6 +453,35 @@ int ossl_property_has_optional(const OSSL_PROPERTY_LIST *query)
|
||||
return query->has_optional ? 1 : 0;
|
||||
}
|
||||
|
||||
int ossl_property_is_enabled(OPENSSL_CTX *ctx, const char *property_name,
|
||||
const OSSL_PROPERTY_LIST *prop_list)
|
||||
{
|
||||
int i;
|
||||
OSSL_PROPERTY_IDX name_id;
|
||||
const PROPERTY_DEFINITION *prop = NULL;
|
||||
|
||||
if (prop_list == NULL)
|
||||
return 0;
|
||||
|
||||
if (!parse_name(ctx, &property_name, 0, &name_id))
|
||||
return 0;
|
||||
|
||||
prop = prop_list->properties;
|
||||
for (i = 0; i < prop_list->n; ++i) {
|
||||
if (prop[i].name_idx == name_id) {
|
||||
/* Do a separate check for override as it does not set type */
|
||||
if (prop[i].optional || prop[i].oper == PROPERTY_OVERRIDE)
|
||||
return 0;
|
||||
return (prop[i].type == PROPERTY_TYPE_STRING
|
||||
&& ((prop[i].oper == PROPERTY_OPER_EQ
|
||||
&& prop[i].v.str_val == ossl_property_true)
|
||||
|| (prop[i].oper == PROPERTY_OPER_NE
|
||||
&& prop[i].v.str_val != ossl_property_true)));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare a query against a definition.
|
||||
* Return the number of clauses matched or -1 if a mandatory clause is false.
|
||||
|
||||
Reference in New Issue
Block a user