Skip to content

Commit 07a5db2

Browse files
committed
Import patches for old macOS from MacPorts
1 parent 6c29312 commit 07a5db2

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

ext/digest/md5/md5cc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ static DEFINE_FINISH_FUNC_FROM_FINAL(MD5)
2525
#undef MD5_Finish
2626
#define MD5_Update rb_digest_MD5_update
2727
#define MD5_Finish rb_digest_MD5_finish
28+
29+
/*
30+
* Pre-10.6 defines are with args, which don't match the argless use in
31+
* the function pointer inits. Thus, we redefine MD5_Init as well.
32+
* This is a NOP on 10.6+.
33+
*/
34+
#undef MD5_Init
35+
#define MD5_Init CC_MD5_Init

ext/digest/sha1/sha1cc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ static DEFINE_FINISH_FUNC_FROM_FINAL(SHA1)
1212
#undef SHA1_Finish
1313
#define SHA1_Update rb_digest_SHA1_update
1414
#define SHA1_Finish rb_digest_SHA1_finish
15+
16+
/*
17+
* Pre-10.6 defines are with args, which don't match the argless use in
18+
* the function pointer inits. Thus, we redefine SHA1_Init as well.
19+
* This is a NOP on 10.6+.
20+
*/
21+
#undef SHA1_Init
22+
#define SHA1_Init CC_SHA1_Init

ext/digest/sha2/sha2cc.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
#define COMMON_DIGEST_FOR_OPENSSL 1
22
#include <CommonCrypto/CommonDigest.h>
33

4+
/*
5+
* Prior to 10.5, OpenSSL-compatible definitions are missing for
6+
* SHA2 macros, though the CC_ versions are present.
7+
* Add the missing definitions we actually use here if needed.
8+
* Note that the definitions are the argless 10.6+-style.
9+
* The weird CTX mismatch is copied from the 10.6 header.
10+
*/
11+
#ifndef SHA256_DIGEST_LENGTH
12+
#define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH
13+
#define SHA256_CTX CC_SHA256_CTX
14+
#define SHA256_Update CC_SHA256_Update
15+
#define SHA256_Final CC_SHA256_Final
16+
#endif /* !defined SHA256_DIGEST_LENGTH */
17+
18+
#ifndef SHA384_DIGEST_LENGTH
19+
#define SHA384_DIGEST_LENGTH CC_SHA384_DIGEST_LENGTH
20+
#define SHA512_CTX CC_SHA512_CTX
21+
#define SHA384_Update CC_SHA384_Update
22+
#define SHA384_Final CC_SHA384_Final
23+
#endif /* !defined SHA384_DIGEST_LENGTH */
24+
25+
#ifndef SHA512_DIGEST_LENGTH
26+
#define SHA512_DIGEST_LENGTH CC_SHA512_DIGEST_LENGTH
27+
#define SHA512_Update CC_SHA512_Update
28+
#define SHA512_Final CC_SHA512_Final
29+
#endif /* !defined SHA512_DIGEST_LENGTH */
30+
431
#define SHA256_BLOCK_LENGTH CC_SHA256_BLOCK_BYTES
532
#define SHA384_BLOCK_LENGTH CC_SHA384_BLOCK_BYTES
633
#define SHA512_BLOCK_LENGTH CC_SHA512_BLOCK_BYTES
@@ -29,3 +56,15 @@ static DEFINE_FINISH_FUNC_FROM_FINAL(SHA512)
2956
#undef SHA512_Finish
3057
#define SHA512_Update rb_digest_SHA512_update
3158
#define SHA512_Finish rb_digest_SHA512_finish
59+
60+
/*
61+
* Pre-10.6 defines are with args, which don't match the argless use in
62+
* the function pointer inits. Thus, we redefine SHA*_Init as well.
63+
* This is a NOP on 10.6+.
64+
*/
65+
#undef SHA256_Init
66+
#define SHA256_Init CC_SHA256_Init
67+
#undef SHA384_Init
68+
#define SHA384_Init CC_SHA384_Init
69+
#undef SHA512_Init
70+
#define SHA512_Init CC_SHA512_Init

0 commit comments

Comments
 (0)