summaryrefslogtreecommitdiffstats
path: root/crypto/dh
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2001-08-25 17:24:21 +0000
committerGeoff Thorpe <geoff@openssl.org>2001-08-25 17:24:21 +0000
commit5cbc2e8bc187058e2ec2f17f53c3429c16dbc0d8 (patch)
tree0a50486525b7a160cf7bc1cbccdb9fe76d295aaa /crypto/dh
parente7cf7fcd216e8680200b3e3f9feb112f8c5952f3 (diff)
Give DH, DSA, and RSA functions to "up" their reference counts. Otherwise,
dependant code has to directly increment the "references" value of each such structure using the corresponding lock. Apart from code duplication, this provided no "REF_CHECK/REF_PRINT" checking and violated encapsulation.
Diffstat (limited to 'crypto/dh')
-rw-r--r--crypto/dh/dh.h1
-rw-r--r--crypto/dh/dh_lib.c16
2 files changed, 17 insertions, 0 deletions
diff --git a/crypto/dh/dh.h b/crypto/dh/dh.h
index 2b9a059373..b6601c66f8 100644
--- a/crypto/dh/dh.h
+++ b/crypto/dh/dh.h
@@ -166,6 +166,7 @@ DH *DH_new_method(struct engine_st *engine);
DH * DH_new(void);
void DH_free(DH *dh);
+int DH_up(DH *dh);
int DH_size(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);
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index 7a6e620715..f96b454757 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -219,6 +219,22 @@ void DH_free(DH *r)
OPENSSL_free(r);
}
+int DH_up(DH *r)
+ {
+ int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH);
+#ifdef REF_PRINT
+ REF_PRINT("DH",r);
+#endif
+#ifdef REF_CHECK
+ if (i < 2)
+ {
+ fprintf(stderr, "DH_up, bad reference count\n");
+ abort();
+ }
+#endif
+ return ((i > 1) ? 1 : 0);
+ }
+
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)
{