Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto/dh
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-04-16 00:29:53 +0300
committerAdam Langley <agl@google.com>2015-04-16 02:59:35 +0300
commit9f33fc63c6219dd43db438d2ffaca480f1b4bb5d (patch)
tree28cea76d3e797b46ac3a8aae969249ddf4fb69ec /crypto/dh
parent2ab9090b8784b1c188f91f1093ee8aad24269871 (diff)
Remove hash table lookups from ex_data.
Instead, each module defines a static CRYPTO_EX_DATA_CLASS to hold the values. This makes CRYPTO_cleanup_all_ex_data a no-op as spreading the CRYPTO_EX_DATA_CLASSes across modules (and across crypto and ssl) makes cleanup slightly trickier. We can make it do something if needbe, but it's probably not worth the trouble. Change-Id: Ib6f6fd39a51d8ba88649f0fa29c66db540610c76 Reviewed-on: https://boringssl-review.googlesource.com/4375 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/dh')
-rw-r--r--crypto/dh/dh.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/crypto/dh/dh.c b/crypto/dh/dh.c
index 86804bf8..77ebb1d1 100644
--- a/crypto/dh/dh.c
+++ b/crypto/dh/dh.c
@@ -71,6 +71,8 @@
extern const DH_METHOD DH_default_method;
+static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
+
DH *DH_new(void) { return DH_new_method(NULL); }
DH *DH_new_method(const ENGINE *engine) {
@@ -94,13 +96,13 @@ DH *DH_new_method(const ENGINE *engine) {
CRYPTO_MUTEX_init(&dh->method_mont_p_lock);
dh->references = 1;
- if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, dh, &dh->ex_data)) {
+ if (!CRYPTO_new_ex_data(&g_ex_data_class, dh, &dh->ex_data)) {
OPENSSL_free(dh);
return NULL;
}
if (dh->meth->init && !dh->meth->init(dh)) {
- CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, dh, &dh->ex_data);
+ CRYPTO_free_ex_data(&g_ex_data_class, dh, &dh->ex_data);
METHOD_unref(dh->meth);
OPENSSL_free(dh);
return NULL;
@@ -123,7 +125,7 @@ void DH_free(DH *dh) {
}
METHOD_unref(dh->meth);
- CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, dh, &dh->ex_data);
+ CRYPTO_free_ex_data(&g_ex_data_class, dh, &dh->ex_data);
if (dh->method_mont_p) BN_MONT_CTX_free(dh->method_mont_p);
if (dh->p != NULL) BN_clear_free(dh->p);
@@ -234,8 +236,12 @@ DH *DHparams_dup(const DH *dh) {
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) {
- return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, argl, argp, new_func,
- dup_func, free_func);
+ int index;
+ if (!CRYPTO_get_ex_new_index(&g_ex_data_class, &index, argl, argp, new_func,
+ dup_func, free_func)) {
+ return -1;
+ }
+ return index;
}
int DH_set_ex_data(DH *d, int idx, void *arg) {