mirror of
https://github.com/openssl/openssl.git
synced 2026-01-18 17:11:31 +01:00
Remove frozen store. This is a mock up that will be replaced with the real implementation.
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org> (Merged from https://github.com/openssl/openssl/pull/29331)
This commit is contained in:
@@ -388,6 +388,7 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata,
|
|||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: FREEZE: Replace with actual implementation */
|
||||||
/*
|
/*
|
||||||
* Returns 1 if method store is frozen AND prop query is equal to frozen prop
|
* Returns 1 if method store is frozen AND prop query is equal to frozen prop
|
||||||
* query. Only sets METHOD if found.
|
* query. Only sets METHOD if found.
|
||||||
@@ -397,7 +398,6 @@ int evp_generic_fetch_frozen(OSSL_LIB_CTX *libctx, int operation_id,
|
|||||||
OSSL_PROVIDER *prov, void **method)
|
OSSL_PROVIDER *prov, void **method)
|
||||||
{
|
{
|
||||||
OSSL_METHOD_STORE *store = get_evp_method_store(libctx);
|
OSSL_METHOD_STORE *store = get_evp_method_store(libctx);
|
||||||
OSSL_FROZEN_METHOD_STORE *frozen_store;
|
|
||||||
const char *store_propq;
|
const char *store_propq;
|
||||||
OSSL_NAMEMAP *namemap;
|
OSSL_NAMEMAP *namemap;
|
||||||
uint32_t meth_id;
|
uint32_t meth_id;
|
||||||
@@ -428,14 +428,12 @@ int evp_generic_fetch_frozen(OSSL_LIB_CTX *libctx, int operation_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return 0 if not frozen or prop query is different than frozen prop query */
|
/* Return 0 if not frozen or prop query is different than frozen prop query */
|
||||||
if (!ossl_method_store_is_frozen(store)
|
if (!ossl_method_store_is_frozen(store))
|
||||||
|| (frozen_store = ossl_get_frozen_method_store(store)) == NULL)
|
return 0;
|
||||||
|
if (strlen(propq) != 0
|
||||||
|
&& (store_propq = ossl_method_store_frozen_propq(store)) != NULL
|
||||||
|
&& strcmp(propq, store_propq) != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strlen(propq) != 0) {
|
|
||||||
store_propq = ossl_get_frozen_method_store_propq(frozen_store);
|
|
||||||
if (strcmp(propq, store_propq) != 0)
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we haven't received a name id yet, try to get one for the name */
|
/* If we haven't received a name id yet, try to get one for the name */
|
||||||
|
|||||||
@@ -63,13 +63,6 @@ typedef struct {
|
|||||||
LHASH_OF(QUERY) *cache;
|
LHASH_OF(QUERY) *cache;
|
||||||
} ALGORITHM;
|
} ALGORITHM;
|
||||||
|
|
||||||
struct ossl_frozen_method_store_st {
|
|
||||||
/* Property query associated with frozen state */
|
|
||||||
char *propq;
|
|
||||||
|
|
||||||
/* TODO: FREEZE */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ossl_method_store_st {
|
struct ossl_method_store_st {
|
||||||
OSSL_LIB_CTX *ctx;
|
OSSL_LIB_CTX *ctx;
|
||||||
SPARSE_ARRAY_OF(ALGORITHM) * algs;
|
SPARSE_ARRAY_OF(ALGORITHM) * algs;
|
||||||
@@ -95,8 +88,11 @@ struct ossl_method_store_st {
|
|||||||
/* Flag: 1 if query cache entries for all algs need flushing */
|
/* Flag: 1 if query cache entries for all algs need flushing */
|
||||||
int cache_need_flush;
|
int cache_need_flush;
|
||||||
|
|
||||||
/* Non-null if method store is frozen */
|
/* Flag: 1 if method store is frozen */
|
||||||
OSSL_FROZEN_METHOD_STORE *frozen_store;
|
int frozen;
|
||||||
|
|
||||||
|
/* Property query associated with frozen state */
|
||||||
|
char *frozen_propq;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -276,9 +272,7 @@ void ossl_method_store_free(OSSL_METHOD_STORE *store)
|
|||||||
ossl_sa_ALGORITHM_free(store->algs);
|
ossl_sa_ALGORITHM_free(store->algs);
|
||||||
CRYPTO_THREAD_lock_free(store->lock);
|
CRYPTO_THREAD_lock_free(store->lock);
|
||||||
CRYPTO_THREAD_lock_free(store->biglock);
|
CRYPTO_THREAD_lock_free(store->biglock);
|
||||||
if (store->frozen_store != NULL)
|
OPENSSL_free(store->frozen_propq);
|
||||||
OPENSSL_free(store->frozen_store->propq);
|
|
||||||
OPENSSL_free(store->frozen_store);
|
|
||||||
OPENSSL_free(store);
|
OPENSSL_free(store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +332,7 @@ int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (nid <= 0 || method == NULL || store == NULL || store->frozen_store != NULL)
|
if (nid <= 0 || method == NULL || store == NULL || store->frozen == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (properties == NULL)
|
if (properties == NULL)
|
||||||
@@ -452,7 +446,7 @@ int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid,
|
|||||||
ALGORITHM *alg = NULL;
|
ALGORITHM *alg = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (nid <= 0 || method == NULL || store == NULL || store->frozen_store != NULL)
|
if (nid <= 0 || method == NULL || store == NULL || store->frozen == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!ossl_property_write_lock(store))
|
if (!ossl_property_write_lock(store))
|
||||||
@@ -554,7 +548,7 @@ int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store,
|
|||||||
{
|
{
|
||||||
struct alg_cleanup_by_provider_data_st data;
|
struct alg_cleanup_by_provider_data_st data;
|
||||||
|
|
||||||
if (store == NULL || store->frozen_store != NULL || !ossl_property_write_lock(store))
|
if (store == NULL || store->frozen == 1 || !ossl_property_write_lock(store))
|
||||||
return 0;
|
return 0;
|
||||||
data.prov = prov;
|
data.prov = prov;
|
||||||
data.store = store;
|
data.store = store;
|
||||||
@@ -565,37 +559,30 @@ int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store,
|
|||||||
|
|
||||||
int ossl_method_store_freeze(OSSL_METHOD_STORE *store, const char *propq)
|
int ossl_method_store_freeze(OSSL_METHOD_STORE *store, const char *propq)
|
||||||
{
|
{
|
||||||
if (store == NULL || store->frozen_store != NULL)
|
if (store == NULL || store->frozen == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
store->frozen_store = OPENSSL_zalloc(sizeof(store->frozen_store));
|
|
||||||
if (store->frozen_store == NULL)
|
|
||||||
return 0;
|
|
||||||
if (propq != NULL) {
|
if (propq != NULL) {
|
||||||
store->frozen_store->propq = OPENSSL_strdup(propq);
|
store->frozen_propq = OPENSSL_strdup(propq);
|
||||||
if (store->frozen_store->propq == NULL) {
|
if (store->frozen_propq == NULL)
|
||||||
OPENSSL_free(store->frozen_store);
|
|
||||||
store->frozen_store = NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* TODO: FREEZE: Create frozen caches */
|
/* TODO: FREEZE: Create frozen caches */
|
||||||
|
store->frozen = 1;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ossl_method_store_is_frozen(OSSL_METHOD_STORE *store)
|
int ossl_method_store_is_frozen(OSSL_METHOD_STORE *store)
|
||||||
{
|
{
|
||||||
return store != NULL && store->frozen_store != NULL;
|
return store != NULL && store->frozen == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSSL_FROZEN_METHOD_STORE *ossl_get_frozen_method_store(OSSL_METHOD_STORE *store)
|
const char *ossl_method_store_frozen_propq(OSSL_METHOD_STORE *store)
|
||||||
{
|
{
|
||||||
return store != NULL ? store->frozen_store : NULL;
|
if (store == NULL)
|
||||||
}
|
return NULL;
|
||||||
|
return store->frozen_propq;
|
||||||
const char *ossl_get_frozen_method_store_propq(OSSL_FROZEN_METHOD_STORE *store)
|
|
||||||
{
|
|
||||||
return (store != NULL && store->propq != NULL) ? store->propq : "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alg_do_one(ALGORITHM *alg, IMPLEMENTATION *impl,
|
static void alg_do_one(ALGORITHM *alg, IMPLEMENTATION *impl,
|
||||||
@@ -823,7 +810,7 @@ static void ossl_method_cache_flush(OSSL_METHOD_STORE *store, int nid)
|
|||||||
|
|
||||||
int ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store)
|
int ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store)
|
||||||
{
|
{
|
||||||
if (store == NULL || store->frozen_store != NULL || !ossl_property_write_lock(store))
|
if (store == NULL || store->frozen == 1 || !ossl_property_write_lock(store))
|
||||||
return 0;
|
return 0;
|
||||||
ossl_sa_ALGORITHM_doall(store->algs, &impl_cache_flush_alg);
|
ossl_sa_ALGORITHM_doall(store->algs, &impl_cache_flush_alg);
|
||||||
store->cache_nelem = 0;
|
store->cache_nelem = 0;
|
||||||
@@ -909,6 +896,7 @@ static void ossl_method_cache_flush_some(OSSL_METHOD_STORE *store)
|
|||||||
static EVP_MD andrew_md;
|
static EVP_MD andrew_md;
|
||||||
static void *andrew_method = NULL;
|
static void *andrew_method = NULL;
|
||||||
|
|
||||||
|
/* TODO: FREEZE: Replace with actual implementation */
|
||||||
int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
|
int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
|
||||||
int nid, const char *prop_query, void **method)
|
int nid, const char *prop_query, void **method)
|
||||||
{
|
{
|
||||||
@@ -939,6 +927,7 @@ err:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: FREEZE: Replace with actual implementation */
|
||||||
int ossl_frozen_method_store_cache_get(OSSL_METHOD_STORE *store,
|
int ossl_frozen_method_store_cache_get(OSSL_METHOD_STORE *store,
|
||||||
OSSL_PROVIDER *prov, int nid,
|
OSSL_PROVIDER *prov, int nid,
|
||||||
const char *prop_query, void **method)
|
const char *prop_query, void **method)
|
||||||
@@ -981,7 +970,7 @@ int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
|
|||||||
size_t len;
|
size_t len;
|
||||||
int res = 1;
|
int res = 1;
|
||||||
|
|
||||||
if (nid <= 0 || store == NULL || prop_query == NULL || store->frozen_store != NULL)
|
if (nid <= 0 || store == NULL || prop_query == NULL || store->frozen == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!ossl_assert(prov != NULL))
|
if (!ossl_assert(prov != NULL))
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include "internal/cryptlib.h"
|
#include "internal/cryptlib.h"
|
||||||
|
|
||||||
typedef struct ossl_method_store_st OSSL_METHOD_STORE;
|
typedef struct ossl_method_store_st OSSL_METHOD_STORE;
|
||||||
typedef struct ossl_frozen_method_store_st OSSL_FROZEN_METHOD_STORE;
|
|
||||||
typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
|
typedef struct ossl_property_list_st OSSL_PROPERTY_LIST;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -75,8 +74,7 @@ int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store,
|
|||||||
/* Frozen method store related functions */
|
/* Frozen method store related functions */
|
||||||
int ossl_method_store_freeze(OSSL_METHOD_STORE *store, const char *propq);
|
int ossl_method_store_freeze(OSSL_METHOD_STORE *store, const char *propq);
|
||||||
int ossl_method_store_is_frozen(OSSL_METHOD_STORE *store);
|
int ossl_method_store_is_frozen(OSSL_METHOD_STORE *store);
|
||||||
OSSL_FROZEN_METHOD_STORE *ossl_get_frozen_method_store(OSSL_METHOD_STORE *store);
|
const char *ossl_method_store_frozen_propq(OSSL_METHOD_STORE *store);
|
||||||
const char *ossl_get_frozen_method_store_propq(OSSL_FROZEN_METHOD_STORE *store);
|
|
||||||
|
|
||||||
/* Get the global properties associate with the specified library context */
|
/* Get the global properties associate with the specified library context */
|
||||||
OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx,
|
OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user