aboutsummaryrefslogtreecommitdiff
path: root/lib/curl_darwinssl.c
diff options
context:
space:
mode:
authorNick Zitzmann <nick@chronosnet.com>2012-07-07 16:03:16 -0600
committerDaniel Stenberg <daniel@haxx.se>2012-07-08 15:42:36 +0200
commit59c88da74d6d35f3529bdf5aa8b2fbdd8b9f39af (patch)
tree267e2ce9a630b6e17188fe40078479580d35eebf /lib/curl_darwinssl.c
parentbce8bc203f70b72e9e015ac05ea665edea34e850 (diff)
darwinssl: don't use arc4random_buf
Re-wrote Curl_darwinssl_random() to not use arc4random_buf() because the function is not available prior to iOS 4.3 and OS X 10.7.
Diffstat (limited to 'lib/curl_darwinssl.c')
-rw-r--r--lib/curl_darwinssl.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/curl_darwinssl.c b/lib/curl_darwinssl.c
index 5a2bcf5ff..893a6fc2a 100644
--- a/lib/curl_darwinssl.c
+++ b/lib/curl_darwinssl.c
@@ -835,8 +835,19 @@ void Curl_darwinssl_random(struct SessionHandle *data,
unsigned char *entropy,
size_t length)
{
+ /* arc4random_buf() isn't available on cats older than Lion, so let's
+ do this manually for the benefit of the older cats. */
+ size_t i;
+ u_int32_t random = 0;
+
+ for(i = 0 ; i < length ; i++) {
+ if(i % sizeof(u_int32_t) == 0)
+ random = arc4random();
+ entropy[i] = random & 0xFF;
+ random >>= 8;
+ }
+ i = random = 0;
(void)data;
- arc4random_buf(entropy, length);
}
void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */