diff options
author | David Benjamin <davidben@chromium.org> | 2015-04-16 00:29:53 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-04-16 02:59:35 +0300 |
commit | 9f33fc63c6219dd43db438d2ffaca480f1b4bb5d (patch) | |
tree | 28cea76d3e797b46ac3a8aae969249ddf4fb69ec /crypto/dsa | |
parent | 2ab9090b8784b1c188f91f1093ee8aad24269871 (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/dsa')
-rw-r--r-- | crypto/dsa/dsa.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crypto/dsa/dsa.c b/crypto/dsa/dsa.c index c5809562..78e41549 100644 --- a/crypto/dsa/dsa.c +++ b/crypto/dsa/dsa.c @@ -75,6 +75,8 @@ extern const DSA_METHOD DSA_default_method; +static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT; + DSA *DSA_new(void) { return DSA_new_method(NULL); } DSA *DSA_new_method(const ENGINE *engine) { @@ -100,14 +102,14 @@ DSA *DSA_new_method(const ENGINE *engine) { CRYPTO_MUTEX_init(&dsa->method_mont_p_lock); - if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, dsa, &dsa->ex_data)) { + if (!CRYPTO_new_ex_data(&g_ex_data_class, dsa, &dsa->ex_data)) { METHOD_unref(dsa->meth); OPENSSL_free(dsa); return NULL; } if (dsa->meth->init && !dsa->meth->init(dsa)) { - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, dsa, &dsa->ex_data); + CRYPTO_free_ex_data(&g_ex_data_class, dsa, &dsa->ex_data); METHOD_unref(dsa->meth); OPENSSL_free(dsa); return NULL; @@ -130,7 +132,7 @@ void DSA_free(DSA *dsa) { } METHOD_unref(dsa->meth); - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, dsa, &dsa->ex_data); + CRYPTO_free_ex_data(&g_ex_data_class, dsa, &dsa->ex_data); if (dsa->p != NULL) { BN_clear_free(dsa->p); @@ -321,8 +323,12 @@ int DSA_sign_setup(const DSA *dsa, BN_CTX *ctx, BIGNUM **out_kinv, int DSA_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_DSA, 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 DSA_set_ex_data(DSA *d, int idx, void *arg) { |