|
11 | 11 | #include <openssl/rand.h> |
12 | 12 | #include <openssl/ripemd.h> |
13 | 13 | #if OPENSSL_VERSION_NUMBER >= 0x10000000 & OPENSSL_VERSION_NUMBER < 0x30000000 |
| 14 | +#ifndef LIBRESSL_VERSION_NUMBER |
14 | 15 | #include <openssl/whrlpool.h> |
15 | 16 | #endif |
| 17 | +#endif |
16 | 18 | #include <openssl/rsa.h> |
17 | 19 | #include <openssl/sha.h> |
18 | 20 | #include <openssl/ssl.h> |
@@ -200,47 +202,47 @@ unsigned char* get_message_digest(SV* text_SV, int hash_method) |
200 | 202 | { |
201 | 203 | STRLEN text_length; |
202 | 204 | unsigned char* text; |
203 | | -#if OPENSSL_VERSION_NUMBER >= 0x30000000L |
204 | | - static unsigned char md[EVP_MAX_MD_SIZE]; |
205 | | -#endif |
| 205 | + unsigned char *md; |
| 206 | + static unsigned char m[EVP_MAX_MD_SIZE]; |
206 | 207 | text = (unsigned char*) SvPV(text_SV, text_length); |
| 208 | + md = m; |
207 | 209 |
|
208 | 210 | switch(hash_method) |
209 | 211 | { |
210 | 212 | case NID_md5: |
211 | 213 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L |
212 | 214 | return EVP_Q_digest(NULL, "MD5", NULL, text, text_length, md, NULL) ? md : NULL; |
213 | 215 | #else |
214 | | - return MD5(text, text_length, NULL); |
| 216 | + return MD5(text, text_length, md); |
215 | 217 | #endif |
216 | 218 | break; |
217 | 219 | case NID_sha1: |
218 | | - return SHA1(text, text_length, NULL); |
| 220 | + return SHA1(text, text_length, md); |
219 | 221 | break; |
220 | 222 | #ifdef SHA512_DIGEST_LENGTH |
221 | 223 | case NID_sha224: |
222 | | - return SHA224(text, text_length, NULL); |
| 224 | + return SHA224(text, text_length, md); |
223 | 225 | break; |
224 | 226 | case NID_sha256: |
225 | | - return SHA256(text, text_length, NULL); |
| 227 | + return SHA256(text, text_length, md); |
226 | 228 | break; |
227 | 229 | case NID_sha384: |
228 | | - return SHA384(text, text_length, NULL); |
| 230 | + return SHA384(text, text_length, md); |
229 | 231 | break; |
230 | 232 | case NID_sha512: |
231 | | - return SHA512(text, text_length, NULL); |
| 233 | + return SHA512(text, text_length, md); |
232 | 234 | break; |
233 | 235 | #endif |
234 | 236 | case NID_ripemd160: |
235 | 237 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L |
236 | 238 | return EVP_Q_digest(NULL, "RIPEMD160", NULL, text, text_length, md, NULL) ? md : NULL; |
237 | 239 | #else |
238 | | - return RIPEMD160(text, text_length, NULL); |
| 240 | + return RIPEMD160(text, text_length, md); |
239 | 241 | #endif |
240 | 242 | break; |
241 | 243 | #ifdef WHIRLPOOL_DIGEST_LENGTH |
242 | 244 | case NID_whirlpool: |
243 | | - return WHIRLPOOL(text, text_length, NULL); |
| 245 | + return WHIRLPOOL(text, text_length, md); |
244 | 246 | break; |
245 | 247 | #endif |
246 | 248 | default: |
|
0 commit comments