diff options
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_lib.c')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index da2cdfa3d6..4171af24c6 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
@@ -63,7 +63,9 @@ | |||
63 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
64 | #include <openssl/dsa.h> | 64 | #include <openssl/dsa.h> |
65 | #include <openssl/asn1.h> | 65 | #include <openssl/asn1.h> |
66 | #ifndef OPENSSL_NO_ENGINE | ||
66 | #include <openssl/engine.h> | 67 | #include <openssl/engine.h> |
68 | #endif | ||
67 | 69 | ||
68 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; | 70 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; |
69 | 71 | ||
@@ -93,11 +95,13 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth) | |||
93 | const DSA_METHOD *mtmp; | 95 | const DSA_METHOD *mtmp; |
94 | mtmp = dsa->meth; | 96 | mtmp = dsa->meth; |
95 | if (mtmp->finish) mtmp->finish(dsa); | 97 | if (mtmp->finish) mtmp->finish(dsa); |
98 | #ifndef OPENSSL_NO_ENGINE | ||
96 | if (dsa->engine) | 99 | if (dsa->engine) |
97 | { | 100 | { |
98 | ENGINE_finish(dsa->engine); | 101 | ENGINE_finish(dsa->engine); |
99 | dsa->engine = NULL; | 102 | dsa->engine = NULL; |
100 | } | 103 | } |
104 | #endif | ||
101 | dsa->meth = meth; | 105 | dsa->meth = meth; |
102 | if (meth->init) meth->init(dsa); | 106 | if (meth->init) meth->init(dsa); |
103 | return 1; | 107 | return 1; |
@@ -114,6 +118,7 @@ DSA *DSA_new_method(ENGINE *engine) | |||
114 | return(NULL); | 118 | return(NULL); |
115 | } | 119 | } |
116 | ret->meth = DSA_get_default_method(); | 120 | ret->meth = DSA_get_default_method(); |
121 | #ifndef OPENSSL_NO_ENGINE | ||
117 | if (engine) | 122 | if (engine) |
118 | { | 123 | { |
119 | if (!ENGINE_init(engine)) | 124 | if (!ENGINE_init(engine)) |
@@ -138,6 +143,7 @@ DSA *DSA_new_method(ENGINE *engine) | |||
138 | return NULL; | 143 | return NULL; |
139 | } | 144 | } |
140 | } | 145 | } |
146 | #endif | ||
141 | 147 | ||
142 | ret->pad=0; | 148 | ret->pad=0; |
143 | ret->version=0; | 149 | ret->version=0; |
@@ -158,8 +164,10 @@ DSA *DSA_new_method(ENGINE *engine) | |||
158 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); | 164 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); |
159 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | 165 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) |
160 | { | 166 | { |
167 | #ifndef OPENSSL_NO_ENGINE | ||
161 | if (ret->engine) | 168 | if (ret->engine) |
162 | ENGINE_finish(ret->engine); | 169 | ENGINE_finish(ret->engine); |
170 | #endif | ||
163 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); | 171 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); |
164 | OPENSSL_free(ret); | 172 | OPENSSL_free(ret); |
165 | ret=NULL; | 173 | ret=NULL; |
@@ -189,8 +197,10 @@ void DSA_free(DSA *r) | |||
189 | 197 | ||
190 | if(r->meth->finish) | 198 | if(r->meth->finish) |
191 | r->meth->finish(r); | 199 | r->meth->finish(r); |
200 | #ifndef OPENSSL_NO_ENGINE | ||
192 | if(r->engine) | 201 | if(r->engine) |
193 | ENGINE_finish(r->engine); | 202 | ENGINE_finish(r->engine); |
203 | #endif | ||
194 | 204 | ||
195 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); | 205 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); |
196 | 206 | ||
@@ -224,7 +234,10 @@ int DSA_size(const DSA *r) | |||
224 | { | 234 | { |
225 | int ret,i; | 235 | int ret,i; |
226 | ASN1_INTEGER bs; | 236 | ASN1_INTEGER bs; |
227 | unsigned char buf[4]; | 237 | unsigned char buf[4]; /* 4 bytes looks really small. |
238 | However, i2d_ASN1_INTEGER() will not look | ||
239 | beyond the first byte, as long as the second | ||
240 | parameter is NULL. */ | ||
228 | 241 | ||
229 | i=BN_num_bits(r->q); | 242 | i=BN_num_bits(r->q); |
230 | bs.length=(i+7)/8; | 243 | bs.length=(i+7)/8; |