2018-11-16 09:44:30 +08:00
|
|
|
/*
|
2022-05-03 18:52:38 +08:00
|
|
|
* Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
|
2018-11-16 09:44:30 +08:00
|
|
|
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <openssl/crypto.h>
|
2021-04-27 13:17:25 +08:00
|
|
|
#include "internal/core.h"
|
2018-11-16 09:44:30 +08:00
|
|
|
#include "internal/property.h"
|
2021-04-27 13:17:25 +08:00
|
|
|
#include "internal/provider.h"
|
2022-07-29 09:00:50 +08:00
|
|
|
#include "internal/tsan_assist.h"
|
2019-09-28 06:45:33 +08:00
|
|
|
#include "crypto/ctype.h"
|
2018-11-16 09:44:30 +08:00
|
|
|
#include <openssl/lhash.h>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
#include "internal/thread_once.h"
|
2019-09-28 06:45:33 +08:00
|
|
|
#include "crypto/lhash.h"
|
|
|
|
#include "crypto/sparse_array.h"
|
2019-09-28 06:45:40 +08:00
|
|
|
#include "property_local.h"
|
2022-03-14 16:13:12 +08:00
|
|
|
#include "crypto/context.h"
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2019-11-23 06:04:38 +08:00
|
|
|
/*
|
|
|
|
* The number of elements in the query cache before we initiate a flush.
|
|
|
|
* If reducing this, also ensure the stochastic test in test/property_test.c
|
|
|
|
* isn't likely to fail.
|
|
|
|
*/
|
|
|
|
#define IMPL_CACHE_FLUSH_THRESHOLD 500
|
2019-11-11 09:17:32 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void *method;
|
|
|
|
int (*up_ref)(void *);
|
|
|
|
void (*free)(void *);
|
|
|
|
} METHOD;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
|
|
|
typedef struct {
|
2019-08-21 16:08:44 +08:00
|
|
|
const OSSL_PROVIDER *provider;
|
2018-11-16 09:44:30 +08:00
|
|
|
OSSL_PROPERTY_LIST *properties;
|
2019-11-11 09:17:32 +08:00
|
|
|
METHOD method;
|
2018-11-16 09:44:30 +08:00
|
|
|
} IMPLEMENTATION;
|
|
|
|
|
|
|
|
DEFINE_STACK_OF(IMPLEMENTATION)
|
|
|
|
|
|
|
|
typedef struct {
|
2021-10-04 21:33:37 +08:00
|
|
|
const OSSL_PROVIDER *provider;
|
2018-11-16 09:44:30 +08:00
|
|
|
const char *query;
|
2019-11-11 09:17:32 +08:00
|
|
|
METHOD method;
|
2018-11-16 09:44:30 +08:00
|
|
|
char body[1];
|
|
|
|
} QUERY;
|
|
|
|
|
2022-03-22 19:52:27 +08:00
|
|
|
DEFINE_LHASH_OF_EX(QUERY);
|
2018-11-16 09:44:30 +08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int nid;
|
|
|
|
STACK_OF(IMPLEMENTATION) *impls;
|
|
|
|
LHASH_OF(QUERY) *cache;
|
|
|
|
} ALGORITHM;
|
|
|
|
|
|
|
|
struct ossl_method_store_st {
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *ctx;
|
2018-11-16 09:44:30 +08:00
|
|
|
SPARSE_ARRAY_OF(ALGORITHM) *algs;
|
2022-04-14 23:52:12 +08:00
|
|
|
/*
|
|
|
|
* Lock to protect the |algs| array from concurrent writing, when
|
|
|
|
* individual implementations or queries are inserted. This is used
|
|
|
|
* by the appropriate functions here.
|
|
|
|
*/
|
2018-11-16 09:44:30 +08:00
|
|
|
CRYPTO_RWLOCK *lock;
|
2022-04-14 23:52:12 +08:00
|
|
|
/*
|
|
|
|
* Lock to reserve the whole store. This is used when fetching a set
|
|
|
|
* of algorithms, via these functions, found in crypto/core_fetch.c:
|
|
|
|
* ossl_method_construct_reserve_store()
|
|
|
|
* ossl_method_construct_unreserve_store()
|
|
|
|
*/
|
|
|
|
CRYPTO_RWLOCK *biglock;
|
2022-04-22 17:00:36 +08:00
|
|
|
|
|
|
|
/* query cache specific values */
|
|
|
|
|
|
|
|
/* Count of the query cache entries for all algs */
|
|
|
|
size_t cache_nelem;
|
|
|
|
|
|
|
|
/* Flag: 1 if query cache entries for all algs need flushing */
|
|
|
|
int cache_need_flush;
|
2018-11-16 09:44:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
LHASH_OF(QUERY) *cache;
|
|
|
|
size_t nelem;
|
2019-07-31 17:31:21 +08:00
|
|
|
uint32_t seed;
|
2022-07-29 09:00:50 +08:00
|
|
|
unsigned char using_global_seed;
|
2018-11-16 09:44:30 +08:00
|
|
|
} IMPL_CACHE_FLUSH;
|
|
|
|
|
|
|
|
DEFINE_SPARSE_ARRAY_OF(ALGORITHM);
|
|
|
|
|
2021-05-11 23:50:27 +08:00
|
|
|
typedef struct ossl_global_properties_st {
|
|
|
|
OSSL_PROPERTY_LIST *list;
|
|
|
|
#ifndef FIPS_MODULE
|
|
|
|
unsigned int no_mirrored : 1;
|
|
|
|
#endif
|
|
|
|
} OSSL_GLOBAL_PROPERTIES;
|
|
|
|
|
2022-04-22 22:44:51 +08:00
|
|
|
static void ossl_method_cache_flush_alg(OSSL_METHOD_STORE *store,
|
|
|
|
ALGORITHM *alg);
|
2018-11-16 09:44:30 +08:00
|
|
|
static void ossl_method_cache_flush(OSSL_METHOD_STORE *store, int nid);
|
2020-06-12 08:34:46 +08:00
|
|
|
|
|
|
|
/* Global properties are stored per library context */
|
2022-03-14 16:13:12 +08:00
|
|
|
void ossl_ctx_global_properties_free(void *vglobp)
|
2020-06-12 08:34:46 +08:00
|
|
|
{
|
2021-05-11 23:50:27 +08:00
|
|
|
OSSL_GLOBAL_PROPERTIES *globp = vglobp;
|
2020-06-12 08:34:46 +08:00
|
|
|
|
2021-05-11 23:50:27 +08:00
|
|
|
if (globp != NULL) {
|
|
|
|
ossl_property_free(globp->list);
|
|
|
|
OPENSSL_free(globp);
|
2020-06-12 08:34:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-14 16:13:12 +08:00
|
|
|
void *ossl_ctx_global_properties_new(OSSL_LIB_CTX *ctx)
|
2020-06-12 08:34:46 +08:00
|
|
|
{
|
2021-05-11 23:50:27 +08:00
|
|
|
return OPENSSL_zalloc(sizeof(OSSL_GLOBAL_PROPERTIES));
|
2020-06-12 08:34:46 +08:00
|
|
|
}
|
|
|
|
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *libctx,
|
2023-08-02 08:44:47 +08:00
|
|
|
ossl_unused int loadconfig)
|
2020-06-12 08:34:46 +08:00
|
|
|
{
|
2021-05-11 23:50:27 +08:00
|
|
|
OSSL_GLOBAL_PROPERTIES *globp;
|
|
|
|
|
2023-08-02 08:44:47 +08:00
|
|
|
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_AUTOLOAD_CONFIG)
|
2020-08-01 00:29:21 +08:00
|
|
|
if (loadconfig && !OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL))
|
|
|
|
return NULL;
|
|
|
|
#endif
|
2022-03-14 16:13:12 +08:00
|
|
|
globp = ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES);
|
2021-05-11 23:50:27 +08:00
|
|
|
|
2021-11-11 04:49:49 +08:00
|
|
|
return globp != NULL ? &globp->list : NULL;
|
2021-05-11 23:50:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef FIPS_MODULE
|
|
|
|
int ossl_global_properties_no_mirrored(OSSL_LIB_CTX *libctx)
|
|
|
|
{
|
|
|
|
OSSL_GLOBAL_PROPERTIES *globp
|
2022-03-14 16:13:12 +08:00
|
|
|
= ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES);
|
2021-05-11 23:50:27 +08:00
|
|
|
|
2021-11-11 04:49:49 +08:00
|
|
|
return globp != NULL && globp->no_mirrored ? 1 : 0;
|
2021-05-11 23:50:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ossl_global_properties_stop_mirroring(OSSL_LIB_CTX *libctx)
|
|
|
|
{
|
|
|
|
OSSL_GLOBAL_PROPERTIES *globp
|
2022-03-14 16:13:12 +08:00
|
|
|
= ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES);
|
2021-05-11 23:50:27 +08:00
|
|
|
|
2021-11-11 04:49:49 +08:00
|
|
|
if (globp != NULL)
|
|
|
|
globp->no_mirrored = 1;
|
2020-06-12 08:34:46 +08:00
|
|
|
}
|
2021-05-11 23:50:27 +08:00
|
|
|
#endif
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2019-11-11 09:17:32 +08:00
|
|
|
static int ossl_method_up_ref(METHOD *method)
|
|
|
|
{
|
|
|
|
return (*method->up_ref)(method->method);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ossl_method_free(METHOD *method)
|
|
|
|
{
|
|
|
|
(*method->free)(method->method);
|
|
|
|
}
|
|
|
|
|
2021-03-30 08:29:01 +08:00
|
|
|
static __owur int ossl_property_read_lock(OSSL_METHOD_STORE *p)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
return p != NULL ? CRYPTO_THREAD_read_lock(p->lock) : 0;
|
|
|
|
}
|
|
|
|
|
2021-03-30 08:29:01 +08:00
|
|
|
static __owur int ossl_property_write_lock(OSSL_METHOD_STORE *p)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
return p != NULL ? CRYPTO_THREAD_write_lock(p->lock) : 0;
|
|
|
|
}
|
|
|
|
|
2021-03-30 08:29:01 +08:00
|
|
|
static int ossl_property_unlock(OSSL_METHOD_STORE *p)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
return p != 0 ? CRYPTO_THREAD_unlock(p->lock) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long query_hash(const QUERY *a)
|
|
|
|
{
|
|
|
|
return OPENSSL_LH_strhash(a->query);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int query_cmp(const QUERY *a, const QUERY *b)
|
|
|
|
{
|
2021-10-04 21:33:37 +08:00
|
|
|
int res = strcmp(a->query, b->query);
|
|
|
|
|
|
|
|
if (res == 0 && a->provider != NULL && b->provider != NULL)
|
|
|
|
res = b->provider > a->provider ? 1
|
|
|
|
: b->provider < a->provider ? -1
|
|
|
|
: 0;
|
|
|
|
return res;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void impl_free(IMPLEMENTATION *impl)
|
|
|
|
{
|
|
|
|
if (impl != NULL) {
|
2019-11-11 09:17:32 +08:00
|
|
|
ossl_method_free(&impl->method);
|
2018-11-16 09:44:30 +08:00
|
|
|
OPENSSL_free(impl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void impl_cache_free(QUERY *elem)
|
|
|
|
{
|
2019-11-11 09:17:32 +08:00
|
|
|
if (elem != NULL) {
|
|
|
|
ossl_method_free(&elem->method);
|
|
|
|
OPENSSL_free(elem);
|
|
|
|
}
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
2022-04-22 22:44:51 +08:00
|
|
|
static void impl_cache_flush_alg(ossl_uintmax_t idx, ALGORITHM *alg)
|
|
|
|
{
|
|
|
|
lh_QUERY_doall(alg->cache, &impl_cache_free);
|
|
|
|
lh_QUERY_flush(alg->cache);
|
|
|
|
}
|
|
|
|
|
2022-04-25 13:22:27 +08:00
|
|
|
static void alg_cleanup(ossl_uintmax_t idx, ALGORITHM *a, void *arg)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
2022-04-25 13:22:27 +08:00
|
|
|
OSSL_METHOD_STORE *store = arg;
|
|
|
|
|
2018-11-16 09:44:30 +08:00
|
|
|
if (a != NULL) {
|
|
|
|
sk_IMPLEMENTATION_pop_free(a->impls, &impl_free);
|
|
|
|
lh_QUERY_doall(a->cache, &impl_cache_free);
|
|
|
|
lh_QUERY_free(a->cache);
|
|
|
|
OPENSSL_free(a);
|
|
|
|
}
|
2022-04-25 13:22:27 +08:00
|
|
|
if (store != NULL)
|
|
|
|
ossl_sa_ALGORITHM_set(store->algs, idx, NULL);
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
2019-05-01 18:02:43 +08:00
|
|
|
/*
|
2020-10-15 17:55:50 +08:00
|
|
|
* The OSSL_LIB_CTX param here allows access to underlying property data needed
|
2019-05-01 18:02:43 +08:00
|
|
|
* for computation
|
|
|
|
*/
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_METHOD_STORE *ossl_method_store_new(OSSL_LIB_CTX *ctx)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
2019-02-24 19:26:20 +08:00
|
|
|
OSSL_METHOD_STORE *res;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2019-02-24 19:26:20 +08:00
|
|
|
res = OPENSSL_zalloc(sizeof(*res));
|
2018-11-16 09:44:30 +08:00
|
|
|
if (res != NULL) {
|
2019-05-01 18:02:43 +08:00
|
|
|
res->ctx = ctx;
|
2022-04-14 23:52:12 +08:00
|
|
|
if ((res->algs = ossl_sa_ALGORITHM_new()) == NULL
|
|
|
|
|| (res->lock = CRYPTO_THREAD_lock_new()) == NULL
|
|
|
|
|| (res->biglock = CRYPTO_THREAD_lock_new()) == NULL) {
|
|
|
|
ossl_method_store_free(res);
|
2018-11-16 09:44:30 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ossl_method_store_free(OSSL_METHOD_STORE *store)
|
|
|
|
{
|
|
|
|
if (store != NULL) {
|
2022-04-14 23:52:12 +08:00
|
|
|
if (store->algs != NULL)
|
|
|
|
ossl_sa_ALGORITHM_doall_arg(store->algs, &alg_cleanup, store);
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_sa_ALGORITHM_free(store->algs);
|
|
|
|
CRYPTO_THREAD_lock_free(store->lock);
|
2022-04-14 23:52:12 +08:00
|
|
|
CRYPTO_THREAD_lock_free(store->biglock);
|
2018-11-16 09:44:30 +08:00
|
|
|
OPENSSL_free(store);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-14 23:52:12 +08:00
|
|
|
int ossl_method_lock_store(OSSL_METHOD_STORE *store)
|
|
|
|
{
|
|
|
|
return store != NULL ? CRYPTO_THREAD_write_lock(store->biglock) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ossl_method_unlock_store(OSSL_METHOD_STORE *store)
|
|
|
|
{
|
|
|
|
return store != NULL ? CRYPTO_THREAD_unlock(store->biglock) : 0;
|
|
|
|
}
|
|
|
|
|
2018-11-16 09:44:30 +08:00
|
|
|
static ALGORITHM *ossl_method_store_retrieve(OSSL_METHOD_STORE *store, int nid)
|
|
|
|
{
|
|
|
|
return ossl_sa_ALGORITHM_get(store->algs, nid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ossl_method_store_insert(OSSL_METHOD_STORE *store, ALGORITHM *alg)
|
|
|
|
{
|
2022-04-14 23:52:12 +08:00
|
|
|
return ossl_sa_ALGORITHM_set(store->algs, alg->nid, alg);
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
2019-08-21 16:08:44 +08:00
|
|
|
int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
|
2019-08-21 15:58:10 +08:00
|
|
|
int nid, const char *properties, void *method,
|
|
|
|
int (*method_up_ref)(void *),
|
|
|
|
void (*method_destruct)(void *))
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
ALGORITHM *alg = NULL;
|
|
|
|
IMPLEMENTATION *impl;
|
|
|
|
int ret = 0;
|
2019-08-21 16:08:44 +08:00
|
|
|
int i;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2019-02-18 16:40:07 +08:00
|
|
|
if (nid <= 0 || method == NULL || store == NULL)
|
2018-11-16 09:44:30 +08:00
|
|
|
return 0;
|
|
|
|
if (properties == NULL)
|
|
|
|
properties = "";
|
|
|
|
|
2021-10-04 21:33:37 +08:00
|
|
|
if (!ossl_assert(prov != NULL))
|
|
|
|
return 0;
|
|
|
|
|
2018-11-16 09:44:30 +08:00
|
|
|
/* Create new entry */
|
|
|
|
impl = OPENSSL_malloc(sizeof(*impl));
|
|
|
|
if (impl == NULL)
|
|
|
|
return 0;
|
2019-11-11 09:17:32 +08:00
|
|
|
impl->method.method = method;
|
|
|
|
impl->method.up_ref = method_up_ref;
|
|
|
|
impl->method.free = method_destruct;
|
|
|
|
if (!ossl_method_up_ref(&impl->method)) {
|
2019-08-21 16:08:44 +08:00
|
|
|
OPENSSL_free(impl);
|
2019-08-21 15:58:10 +08:00
|
|
|
return 0;
|
2019-08-21 16:08:44 +08:00
|
|
|
}
|
|
|
|
impl->provider = prov;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2021-06-23 12:18:25 +08:00
|
|
|
/* Insert into the hash table if required */
|
2021-03-30 08:29:01 +08:00
|
|
|
if (!ossl_property_write_lock(store)) {
|
|
|
|
OPENSSL_free(impl);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_method_cache_flush(store, nid);
|
2019-05-01 18:02:43 +08:00
|
|
|
if ((impl->properties = ossl_prop_defn_get(store->ctx, properties)) == NULL) {
|
|
|
|
impl->properties = ossl_parse_property(store->ctx, properties);
|
|
|
|
if (impl->properties == NULL)
|
2018-11-16 09:44:30 +08:00
|
|
|
goto err;
|
2022-11-25 01:48:10 +08:00
|
|
|
if (!ossl_prop_defn_set(store->ctx, properties, &impl->properties)) {
|
2022-06-02 18:14:32 +08:00
|
|
|
ossl_property_free(impl->properties);
|
|
|
|
impl->properties = NULL;
|
|
|
|
goto err;
|
|
|
|
}
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
alg = ossl_method_store_retrieve(store, nid);
|
|
|
|
if (alg == NULL) {
|
|
|
|
if ((alg = OPENSSL_zalloc(sizeof(*alg))) == NULL
|
|
|
|
|| (alg->impls = sk_IMPLEMENTATION_new_null()) == NULL
|
|
|
|
|| (alg->cache = lh_QUERY_new(&query_hash, &query_cmp)) == NULL)
|
|
|
|
goto err;
|
|
|
|
alg->nid = nid;
|
|
|
|
if (!ossl_method_store_insert(store, alg))
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2019-08-21 16:08:44 +08:00
|
|
|
/* Push onto stack if there isn't one there already */
|
|
|
|
for (i = 0; i < sk_IMPLEMENTATION_num(alg->impls); i++) {
|
|
|
|
const IMPLEMENTATION *tmpimpl = sk_IMPLEMENTATION_value(alg->impls, i);
|
|
|
|
|
|
|
|
if (tmpimpl->provider == impl->provider
|
|
|
|
&& tmpimpl->properties == impl->properties)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == sk_IMPLEMENTATION_num(alg->impls)
|
|
|
|
&& sk_IMPLEMENTATION_push(alg->impls, impl))
|
2018-11-16 09:44:30 +08:00
|
|
|
ret = 1;
|
|
|
|
ossl_property_unlock(store);
|
|
|
|
if (ret == 0)
|
|
|
|
impl_free(impl);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
err:
|
|
|
|
ossl_property_unlock(store);
|
2022-04-25 13:22:27 +08:00
|
|
|
alg_cleanup(0, alg, NULL);
|
2018-11-16 09:44:30 +08:00
|
|
|
impl_free(impl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid,
|
2019-02-18 16:40:07 +08:00
|
|
|
const void *method)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
ALGORITHM *alg = NULL;
|
|
|
|
int i;
|
|
|
|
|
2019-02-18 16:40:07 +08:00
|
|
|
if (nid <= 0 || method == NULL || store == NULL)
|
2018-11-16 09:44:30 +08:00
|
|
|
return 0;
|
|
|
|
|
2021-03-30 08:29:01 +08:00
|
|
|
if (!ossl_property_write_lock(store))
|
|
|
|
return 0;
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_method_cache_flush(store, nid);
|
|
|
|
alg = ossl_method_store_retrieve(store, nid);
|
|
|
|
if (alg == NULL) {
|
|
|
|
ossl_property_unlock(store);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A sorting find then a delete could be faster but these stacks should be
|
|
|
|
* relatively small, so we avoid the overhead. Sorting could also surprise
|
|
|
|
* users when result orderings change (even though they are not guaranteed).
|
|
|
|
*/
|
|
|
|
for (i = 0; i < sk_IMPLEMENTATION_num(alg->impls); i++) {
|
|
|
|
IMPLEMENTATION *impl = sk_IMPLEMENTATION_value(alg->impls, i);
|
|
|
|
|
2019-11-11 09:17:32 +08:00
|
|
|
if (impl->method.method == method) {
|
|
|
|
impl_free(impl);
|
2020-09-10 23:34:17 +08:00
|
|
|
(void)sk_IMPLEMENTATION_delete(alg->impls, i);
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_property_unlock(store);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ossl_property_unlock(store);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-22 22:44:51 +08:00
|
|
|
struct alg_cleanup_by_provider_data_st {
|
|
|
|
OSSL_METHOD_STORE *store;
|
|
|
|
const OSSL_PROVIDER *prov;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
alg_cleanup_by_provider(ossl_uintmax_t idx, ALGORITHM *alg, void *arg)
|
|
|
|
{
|
|
|
|
struct alg_cleanup_by_provider_data_st *data = arg;
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We walk the stack backwards, to avoid having to deal with stack shifts
|
|
|
|
* caused by deletion
|
|
|
|
*/
|
|
|
|
for (count = 0, i = sk_IMPLEMENTATION_num(alg->impls); i-- > 0;) {
|
|
|
|
IMPLEMENTATION *impl = sk_IMPLEMENTATION_value(alg->impls, i);
|
|
|
|
|
|
|
|
if (impl->provider == data->prov) {
|
|
|
|
impl_free(impl);
|
|
|
|
(void)sk_IMPLEMENTATION_delete(alg->impls, i);
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we removed any implementation, we also clear the whole associated
|
|
|
|
* cache, 'cause that's the sensible thing to do.
|
|
|
|
* There's no point flushing the cache entries where we didn't remove
|
|
|
|
* any implementation, though.
|
|
|
|
*/
|
|
|
|
if (count > 0)
|
|
|
|
ossl_method_cache_flush_alg(data->store, alg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store,
|
|
|
|
const OSSL_PROVIDER *prov)
|
|
|
|
{
|
|
|
|
struct alg_cleanup_by_provider_data_st data;
|
|
|
|
|
|
|
|
if (!ossl_property_write_lock(store))
|
|
|
|
return 0;
|
|
|
|
data.prov = prov;
|
|
|
|
data.store = store;
|
|
|
|
ossl_sa_ALGORITHM_doall_arg(store->algs, &alg_cleanup_by_provider, &data);
|
|
|
|
ossl_property_unlock(store);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-06-03 15:09:19 +08:00
|
|
|
static void alg_do_one(ALGORITHM *alg, IMPLEMENTATION *impl,
|
|
|
|
void (*fn)(int id, void *method, void *fnarg),
|
|
|
|
void *fnarg)
|
|
|
|
{
|
|
|
|
fn(alg->nid, impl->method.method, fnarg);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct alg_do_each_data_st {
|
|
|
|
void (*fn)(int id, void *method, void *fnarg);
|
|
|
|
void *fnarg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void alg_do_each(ossl_uintmax_t idx, ALGORITHM *alg, void *arg)
|
|
|
|
{
|
|
|
|
struct alg_do_each_data_st *data = arg;
|
|
|
|
int i, end = sk_IMPLEMENTATION_num(alg->impls);
|
|
|
|
|
|
|
|
for (i = 0; i < end; i++) {
|
|
|
|
IMPLEMENTATION *impl = sk_IMPLEMENTATION_value(alg->impls, i);
|
|
|
|
|
|
|
|
alg_do_one(alg, impl, data->fn, data->fnarg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ossl_method_store_do_all(OSSL_METHOD_STORE *store,
|
|
|
|
void (*fn)(int id, void *method, void *fnarg),
|
|
|
|
void *fnarg)
|
|
|
|
{
|
|
|
|
struct alg_do_each_data_st data;
|
|
|
|
|
|
|
|
data.fn = fn;
|
|
|
|
data.fnarg = fnarg;
|
|
|
|
if (store != NULL)
|
|
|
|
ossl_sa_ALGORITHM_doall_arg(store->algs, alg_do_each, &data);
|
|
|
|
}
|
|
|
|
|
2021-10-04 21:33:37 +08:00
|
|
|
int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
|
|
|
|
int nid, const char *prop_query,
|
|
|
|
const OSSL_PROVIDER **prov_rw, void **method)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
2020-06-29 06:33:35 +08:00
|
|
|
OSSL_PROPERTY_LIST **plp;
|
2018-11-16 09:44:30 +08:00
|
|
|
ALGORITHM *alg;
|
2021-10-04 21:33:37 +08:00
|
|
|
IMPLEMENTATION *impl, *best_impl = NULL;
|
2020-06-12 08:34:46 +08:00
|
|
|
OSSL_PROPERTY_LIST *pq = NULL, *p2 = NULL;
|
2021-10-04 21:33:37 +08:00
|
|
|
const OSSL_PROVIDER *prov = prov_rw != NULL ? *prov_rw : NULL;
|
2018-11-16 09:44:30 +08:00
|
|
|
int ret = 0;
|
2019-05-16 12:50:18 +08:00
|
|
|
int j, best = -1, score, optional;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2023-02-20 22:47:20 +08:00
|
|
|
if (nid <= 0 || method == NULL || store == NULL)
|
2021-06-18 15:50:54 +08:00
|
|
|
return 0;
|
2019-07-30 23:42:53 +08:00
|
|
|
|
2023-08-02 08:44:47 +08:00
|
|
|
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_AUTOLOAD_CONFIG)
|
2023-02-20 22:47:20 +08:00
|
|
|
if (ossl_lib_ctx_is_default(store->ctx)
|
|
|
|
&& !OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL))
|
2018-11-16 09:44:30 +08:00
|
|
|
return 0;
|
2023-02-20 22:47:20 +08:00
|
|
|
#endif
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2021-06-23 12:18:25 +08:00
|
|
|
/* This only needs to be a read lock, because the query won't create anything */
|
2021-03-30 08:29:01 +08:00
|
|
|
if (!ossl_property_read_lock(store))
|
|
|
|
return 0;
|
2018-11-16 09:44:30 +08:00
|
|
|
alg = ossl_method_store_retrieve(store, nid);
|
|
|
|
if (alg == NULL) {
|
|
|
|
ossl_property_unlock(store);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-29 06:33:35 +08:00
|
|
|
if (prop_query != NULL)
|
2021-03-13 08:34:49 +08:00
|
|
|
p2 = pq = ossl_parse_query(store->ctx, prop_query, 0);
|
2020-11-05 03:55:36 +08:00
|
|
|
plp = ossl_ctx_global_properties(store->ctx, 0);
|
2020-06-12 08:34:46 +08:00
|
|
|
if (plp != NULL && *plp != NULL) {
|
|
|
|
if (pq == NULL) {
|
|
|
|
pq = *plp;
|
|
|
|
} else {
|
|
|
|
p2 = ossl_property_merge(pq, *plp);
|
2020-07-06 12:08:58 +08:00
|
|
|
ossl_property_free(pq);
|
2020-06-12 08:34:46 +08:00
|
|
|
if (p2 == NULL)
|
|
|
|
goto fin;
|
|
|
|
pq = p2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pq == NULL) {
|
2021-10-04 21:33:37 +08:00
|
|
|
for (j = 0; j < sk_IMPLEMENTATION_num(alg->impls); j++) {
|
|
|
|
if ((impl = sk_IMPLEMENTATION_value(alg->impls, j)) != NULL
|
|
|
|
&& (prov == NULL || impl->provider == prov)) {
|
|
|
|
best_impl = impl;
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
goto fin;
|
|
|
|
}
|
2019-05-16 12:50:18 +08:00
|
|
|
optional = ossl_property_has_optional(pq);
|
2018-11-16 09:44:30 +08:00
|
|
|
for (j = 0; j < sk_IMPLEMENTATION_num(alg->impls); j++) {
|
2021-10-04 21:33:37 +08:00
|
|
|
if ((impl = sk_IMPLEMENTATION_value(alg->impls, j)) != NULL
|
|
|
|
&& (prov == NULL || impl->provider == prov)) {
|
|
|
|
score = ossl_property_match_count(pq, impl->properties);
|
|
|
|
if (score > best) {
|
|
|
|
best_impl = impl;
|
|
|
|
best = score;
|
|
|
|
ret = 1;
|
|
|
|
if (!optional)
|
|
|
|
goto fin;
|
|
|
|
}
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fin:
|
2021-10-04 21:33:37 +08:00
|
|
|
if (ret && ossl_method_up_ref(&best_impl->method)) {
|
|
|
|
*method = best_impl->method.method;
|
|
|
|
if (prov_rw != NULL)
|
|
|
|
*prov_rw = best_impl->provider;
|
|
|
|
} else {
|
2019-11-11 09:17:32 +08:00
|
|
|
ret = 0;
|
2021-10-04 21:33:37 +08:00
|
|
|
}
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_property_unlock(store);
|
2020-06-12 08:34:46 +08:00
|
|
|
ossl_property_free(p2);
|
2018-11-16 09:44:30 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-04-22 22:44:51 +08:00
|
|
|
static void ossl_method_cache_flush_alg(OSSL_METHOD_STORE *store,
|
|
|
|
ALGORITHM *alg)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
2022-04-22 22:44:51 +08:00
|
|
|
store->cache_nelem -= lh_QUERY_num_items(alg->cache);
|
|
|
|
impl_cache_flush_alg(0, alg);
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ossl_method_cache_flush(OSSL_METHOD_STORE *store, int nid)
|
|
|
|
{
|
|
|
|
ALGORITHM *alg = ossl_method_store_retrieve(store, nid);
|
|
|
|
|
2022-04-22 22:44:51 +08:00
|
|
|
if (alg != NULL)
|
|
|
|
ossl_method_cache_flush_alg(store, alg);
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:00:36 +08:00
|
|
|
int ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
2021-03-30 08:29:01 +08:00
|
|
|
if (!ossl_property_write_lock(store))
|
|
|
|
return 0;
|
2022-04-22 17:00:36 +08:00
|
|
|
ossl_sa_ALGORITHM_doall(store->algs, &impl_cache_flush_alg);
|
|
|
|
store->cache_nelem = 0;
|
2020-06-12 08:34:46 +08:00
|
|
|
ossl_property_unlock(store);
|
2021-03-30 08:29:01 +08:00
|
|
|
return 1;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_LHASH_DOALL_ARG(QUERY, IMPL_CACHE_FLUSH);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush an element from the query cache (perhaps).
|
|
|
|
*
|
2019-07-31 17:31:21 +08:00
|
|
|
* In order to avoid taking a write lock or using atomic operations
|
|
|
|
* to keep accurate least recently used (LRU) or least frequently used
|
|
|
|
* (LFU) information, the procedure used here is to stochastically
|
|
|
|
* flush approximately half the cache.
|
2018-11-16 09:44:30 +08:00
|
|
|
*
|
2019-07-31 17:31:21 +08:00
|
|
|
* This procedure isn't ideal, LRU or LFU would be better. However,
|
|
|
|
* in normal operation, reaching a full cache would be unexpected.
|
|
|
|
* It means that no steady state of algorithm queries has been reached.
|
|
|
|
* That is, it is most likely an attack of some form. A suboptimal clearance
|
|
|
|
* strategy that doesn't degrade performance of the normal case is
|
|
|
|
* preferable to a more refined approach that imposes a performance
|
|
|
|
* impact.
|
2018-11-16 09:44:30 +08:00
|
|
|
*/
|
|
|
|
static void impl_cache_flush_cache(QUERY *c, IMPL_CACHE_FLUSH *state)
|
|
|
|
{
|
2019-07-31 17:31:21 +08:00
|
|
|
uint32_t n;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implement the 32 bit xorshift as suggested by George Marsaglia in:
|
|
|
|
* https://doi.org/10.18637/jss.v008.i14
|
|
|
|
*
|
|
|
|
* This is a very fast PRNG so there is no need to extract bits one at a
|
|
|
|
* time and use the entire value each time.
|
|
|
|
*/
|
|
|
|
n = state->seed;
|
|
|
|
n ^= n << 13;
|
|
|
|
n ^= n >> 17;
|
|
|
|
n ^= n << 5;
|
|
|
|
state->seed = n;
|
|
|
|
|
|
|
|
if ((n & 1) != 0)
|
2019-11-11 09:17:32 +08:00
|
|
|
impl_cache_free(lh_QUERY_delete(state->cache, c));
|
2018-11-16 09:44:30 +08:00
|
|
|
else
|
|
|
|
state->nelem++;
|
|
|
|
}
|
|
|
|
|
2019-03-06 11:50:54 +08:00
|
|
|
static void impl_cache_flush_one_alg(ossl_uintmax_t idx, ALGORITHM *alg,
|
|
|
|
void *v)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
IMPL_CACHE_FLUSH *state = (IMPL_CACHE_FLUSH *)v;
|
|
|
|
|
|
|
|
state->cache = alg->cache;
|
|
|
|
lh_QUERY_doall_IMPL_CACHE_FLUSH(state->cache, &impl_cache_flush_cache,
|
|
|
|
state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ossl_method_cache_flush_some(OSSL_METHOD_STORE *store)
|
|
|
|
{
|
|
|
|
IMPL_CACHE_FLUSH state;
|
2022-07-29 09:00:50 +08:00
|
|
|
static TSAN_QUALIFIER uint32_t global_seed = 1;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
|
|
|
state.nelem = 0;
|
2022-07-29 09:00:50 +08:00
|
|
|
state.using_global_seed = 0;
|
|
|
|
if ((state.seed = OPENSSL_rdtsc()) == 0) {
|
|
|
|
/* If there is no timer available, seed another way */
|
|
|
|
state.using_global_seed = 1;
|
|
|
|
state.seed = tsan_load(&global_seed);
|
|
|
|
}
|
2022-04-22 17:00:36 +08:00
|
|
|
store->cache_need_flush = 0;
|
2019-07-31 17:31:45 +08:00
|
|
|
ossl_sa_ALGORITHM_doall_arg(store->algs, &impl_cache_flush_one_alg, &state);
|
2022-04-22 17:00:36 +08:00
|
|
|
store->cache_nelem = state.nelem;
|
2022-07-29 09:00:50 +08:00
|
|
|
/* Without a timer, update the global seed */
|
|
|
|
if (state.using_global_seed)
|
|
|
|
tsan_add(&global_seed, state.seed);
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
2021-10-04 21:33:37 +08:00
|
|
|
int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
|
|
|
|
int nid, const char *prop_query, void **method)
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
ALGORITHM *alg;
|
|
|
|
QUERY elem, *r;
|
2019-11-11 09:17:32 +08:00
|
|
|
int res = 0;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2022-02-25 10:37:08 +08:00
|
|
|
if (nid <= 0 || store == NULL || prop_query == NULL)
|
2018-11-16 09:44:30 +08:00
|
|
|
return 0;
|
|
|
|
|
2021-03-30 08:29:01 +08:00
|
|
|
if (!ossl_property_read_lock(store))
|
|
|
|
return 0;
|
2018-11-16 09:44:30 +08:00
|
|
|
alg = ossl_method_store_retrieve(store, nid);
|
2019-11-11 09:17:32 +08:00
|
|
|
if (alg == NULL)
|
|
|
|
goto err;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2022-02-25 10:37:08 +08:00
|
|
|
elem.query = prop_query;
|
2021-10-04 21:33:37 +08:00
|
|
|
elem.provider = prov;
|
2018-11-16 09:44:30 +08:00
|
|
|
r = lh_QUERY_retrieve(alg->cache, &elem);
|
2019-11-11 09:17:32 +08:00
|
|
|
if (r == NULL)
|
|
|
|
goto err;
|
|
|
|
if (ossl_method_up_ref(&r->method)) {
|
|
|
|
*method = r->method.method;
|
|
|
|
res = 1;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
2019-11-11 09:17:32 +08:00
|
|
|
err:
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_property_unlock(store);
|
2019-11-11 09:17:32 +08:00
|
|
|
return res;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
|
2021-10-04 21:33:37 +08:00
|
|
|
int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
|
|
|
|
int nid, const char *prop_query, void *method,
|
2019-11-11 09:17:32 +08:00
|
|
|
int (*method_up_ref)(void *),
|
|
|
|
void (*method_destruct)(void *))
|
2018-11-16 09:44:30 +08:00
|
|
|
{
|
|
|
|
QUERY elem, *old, *p = NULL;
|
|
|
|
ALGORITHM *alg;
|
|
|
|
size_t len;
|
2019-11-11 09:17:32 +08:00
|
|
|
int res = 1;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2022-02-25 10:37:08 +08:00
|
|
|
if (nid <= 0 || store == NULL || prop_query == NULL)
|
2018-11-16 09:44:30 +08:00
|
|
|
return 0;
|
|
|
|
|
2021-10-04 21:33:37 +08:00
|
|
|
if (!ossl_assert(prov != NULL))
|
|
|
|
return 0;
|
|
|
|
|
2021-03-30 08:29:01 +08:00
|
|
|
if (!ossl_property_write_lock(store))
|
|
|
|
return 0;
|
2022-04-22 17:00:36 +08:00
|
|
|
if (store->cache_need_flush)
|
2018-11-16 09:44:30 +08:00
|
|
|
ossl_method_cache_flush_some(store);
|
|
|
|
alg = ossl_method_store_retrieve(store, nid);
|
2019-11-11 09:17:32 +08:00
|
|
|
if (alg == NULL)
|
|
|
|
goto err;
|
2018-11-16 09:44:30 +08:00
|
|
|
|
2019-02-18 16:40:07 +08:00
|
|
|
if (method == NULL) {
|
2018-11-16 09:44:30 +08:00
|
|
|
elem.query = prop_query;
|
2021-10-04 21:33:37 +08:00
|
|
|
elem.provider = prov;
|
2019-11-11 09:17:32 +08:00
|
|
|
if ((old = lh_QUERY_delete(alg->cache, &elem)) != NULL) {
|
|
|
|
impl_cache_free(old);
|
2022-04-22 17:00:36 +08:00
|
|
|
store->cache_nelem--;
|
2019-11-11 09:17:32 +08:00
|
|
|
}
|
|
|
|
goto end;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
|
|
|
p = OPENSSL_malloc(sizeof(*p) + (len = strlen(prop_query)));
|
|
|
|
if (p != NULL) {
|
|
|
|
p->query = p->body;
|
2021-10-04 21:33:37 +08:00
|
|
|
p->provider = prov;
|
2019-11-11 09:17:32 +08:00
|
|
|
p->method.method = method;
|
|
|
|
p->method.up_ref = method_up_ref;
|
|
|
|
p->method.free = method_destruct;
|
|
|
|
if (!ossl_method_up_ref(&p->method))
|
|
|
|
goto err;
|
2018-11-16 09:44:30 +08:00
|
|
|
memcpy((char *)p->query, prop_query, len + 1);
|
2019-07-31 17:31:21 +08:00
|
|
|
if ((old = lh_QUERY_insert(alg->cache, p)) != NULL) {
|
2019-11-11 09:17:32 +08:00
|
|
|
impl_cache_free(old);
|
|
|
|
goto end;
|
2019-07-31 17:31:21 +08:00
|
|
|
}
|
|
|
|
if (!lh_QUERY_error(alg->cache)) {
|
2022-04-22 17:00:36 +08:00
|
|
|
if (++store->cache_nelem >= IMPL_CACHE_FLUSH_THRESHOLD)
|
|
|
|
store->cache_need_flush = 1;
|
2019-11-11 09:17:32 +08:00
|
|
|
goto end;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
2019-11-11 09:17:32 +08:00
|
|
|
ossl_method_free(&p->method);
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|
2019-11-11 09:17:32 +08:00
|
|
|
err:
|
|
|
|
res = 0;
|
2019-11-24 16:15:15 +08:00
|
|
|
OPENSSL_free(p);
|
2019-11-11 09:17:32 +08:00
|
|
|
end:
|
|
|
|
ossl_property_unlock(store);
|
|
|
|
return res;
|
2018-11-16 09:44:30 +08:00
|
|
|
}
|