summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dh/dh_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dh/dh_lib.c')
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index ba5fd41057..09965ee2ea 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -60,7 +60,9 @@
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/bn.h> 61#include <openssl/bn.h>
62#include <openssl/dh.h> 62#include <openssl/dh.h>
63#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h> 64#include <openssl/engine.h>
65#endif
64 66
65const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT; 67const char *DH_version="Diffie-Hellman" OPENSSL_VERSION_PTEXT;
66 68
@@ -85,11 +87,13 @@ int DH_set_method(DH *dh, const DH_METHOD *meth)
85 const DH_METHOD *mtmp; 87 const DH_METHOD *mtmp;
86 mtmp = dh->meth; 88 mtmp = dh->meth;
87 if (mtmp->finish) mtmp->finish(dh); 89 if (mtmp->finish) mtmp->finish(dh);
90#ifndef OPENSSL_NO_ENGINE
88 if (dh->engine) 91 if (dh->engine)
89 { 92 {
90 ENGINE_finish(dh->engine); 93 ENGINE_finish(dh->engine);
91 dh->engine = NULL; 94 dh->engine = NULL;
92 } 95 }
96#endif
93 dh->meth = meth; 97 dh->meth = meth;
94 if (meth->init) meth->init(dh); 98 if (meth->init) meth->init(dh);
95 return 1; 99 return 1;
@@ -112,6 +116,7 @@ DH *DH_new_method(ENGINE *engine)
112 } 116 }
113 117
114 ret->meth = DH_get_default_method(); 118 ret->meth = DH_get_default_method();
119#ifndef OPENSSL_NO_ENGINE
115 if (engine) 120 if (engine)
116 { 121 {
117 if (!ENGINE_init(engine)) 122 if (!ENGINE_init(engine))
@@ -135,6 +140,7 @@ DH *DH_new_method(ENGINE *engine)
135 return NULL; 140 return NULL;
136 } 141 }
137 } 142 }
143#endif
138 144
139 ret->pad=0; 145 ret->pad=0;
140 ret->version=0; 146 ret->version=0;
@@ -154,8 +160,10 @@ DH *DH_new_method(ENGINE *engine)
154 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); 160 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
155 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 161 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
156 { 162 {
163#ifndef OPENSSL_NO_ENGINE
157 if (ret->engine) 164 if (ret->engine)
158 ENGINE_finish(ret->engine); 165 ENGINE_finish(ret->engine);
166#endif
159 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data); 167 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
160 OPENSSL_free(ret); 168 OPENSSL_free(ret);
161 ret=NULL; 169 ret=NULL;
@@ -182,8 +190,10 @@ void DH_free(DH *r)
182 190
183 if (r->meth->finish) 191 if (r->meth->finish)
184 r->meth->finish(r); 192 r->meth->finish(r);
193#ifndef OPENSSL_NO_ENGINE
185 if (r->engine) 194 if (r->engine)
186 ENGINE_finish(r->engine); 195 ENGINE_finish(r->engine);
196#endif
187 197
188 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); 198 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);
189 199