Skip to content

Commit dbf24f4

Browse files
authored
Merge pull request #60 from timlegge/version-fixes
Version fixes for libressl on openbsd
2 parents 0792f93 + c7b5191 commit dbf24f4

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

RSA.xs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
#include <openssl/rand.h>
1212
#include <openssl/ripemd.h>
1313
#if OPENSSL_VERSION_NUMBER >= 0x10000000 & OPENSSL_VERSION_NUMBER < 0x30000000
14+
#ifndef LIBRESSL_VERSION_NUMBER
1415
#include <openssl/whrlpool.h>
1516
#endif
17+
#endif
1618
#include <openssl/rsa.h>
1719
#include <openssl/sha.h>
1820
#include <openssl/ssl.h>
@@ -200,47 +202,47 @@ unsigned char* get_message_digest(SV* text_SV, int hash_method)
200202
{
201203
STRLEN text_length;
202204
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];
206207
text = (unsigned char*) SvPV(text_SV, text_length);
208+
md = m;
207209

208210
switch(hash_method)
209211
{
210212
case NID_md5:
211213
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
212214
return EVP_Q_digest(NULL, "MD5", NULL, text, text_length, md, NULL) ? md : NULL;
213215
#else
214-
return MD5(text, text_length, NULL);
216+
return MD5(text, text_length, md);
215217
#endif
216218
break;
217219
case NID_sha1:
218-
return SHA1(text, text_length, NULL);
220+
return SHA1(text, text_length, md);
219221
break;
220222
#ifdef SHA512_DIGEST_LENGTH
221223
case NID_sha224:
222-
return SHA224(text, text_length, NULL);
224+
return SHA224(text, text_length, md);
223225
break;
224226
case NID_sha256:
225-
return SHA256(text, text_length, NULL);
227+
return SHA256(text, text_length, md);
226228
break;
227229
case NID_sha384:
228-
return SHA384(text, text_length, NULL);
230+
return SHA384(text, text_length, md);
229231
break;
230232
case NID_sha512:
231-
return SHA512(text, text_length, NULL);
233+
return SHA512(text, text_length, md);
232234
break;
233235
#endif
234236
case NID_ripemd160:
235237
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
236238
return EVP_Q_digest(NULL, "RIPEMD160", NULL, text, text_length, md, NULL) ? md : NULL;
237239
#else
238-
return RIPEMD160(text, text_length, NULL);
240+
return RIPEMD160(text, text_length, md);
239241
#endif
240242
break;
241243
#ifdef WHIRLPOOL_DIGEST_LENGTH
242244
case NID_whirlpool:
243-
return WHIRLPOOL(text, text_length, NULL);
245+
return WHIRLPOOL(text, text_length, md);
244246
break;
245247
#endif
246248
default:

0 commit comments

Comments
 (0)