Diff
Modified: branches/safari-601-branch/Source/WTF/ChangeLog (190767 => 190768)
--- branches/safari-601-branch/Source/WTF/ChangeLog 2015-10-09 01:50:16 UTC (rev 190767)
+++ branches/safari-601-branch/Source/WTF/ChangeLog 2015-10-09 01:56:22 UTC (rev 190768)
@@ -1,5 +1,27 @@
2015-10-08 Lucas Forschler <[email protected]>
+ Merge r189633. rdar://problem/22824646
+
+
+ 2015-09-11 Keith Miller <[email protected]>
+
+ cryptographicallyRandomValuesFromOS should use CCRandomCopyBytes when available.
+ https://bugs.webkit.org/show_bug.cgi?id=148439
+
+ Reviewed by Alexey Proskuryakov.
+
+ Recently, we switched to using arc4random_buf on Darwin but further research indicates that
+ arc4random_buf has the same behavior we had before and thus we were just pushing the problem
+ further down the stack. CCRandomCopyBytes, however, appears to be more advanced and has much
+ better error handling than we had before.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/OSRandomSource.cpp:
+ (WTF::cryptographicallyRandomValuesFromOS):
+ * wtf/spi/darwin/CommonCryptoSPI.h: Added.
+
+2015-10-08 Lucas Forschler <[email protected]>
+
Merge r188489
2015-08-14 Keith Miller <[email protected]>
Modified: branches/safari-601-branch/Source/WTF/WTF.xcodeproj/project.pbxproj (190767 => 190768)
--- branches/safari-601-branch/Source/WTF/WTF.xcodeproj/project.pbxproj 2015-10-09 01:50:16 UTC (rev 190767)
+++ branches/safari-601-branch/Source/WTF/WTF.xcodeproj/project.pbxproj 2015-10-09 01:56:22 UTC (rev 190768)
@@ -271,6 +271,7 @@
CD5497AD15857D0300B5BC30 /* MediaTime.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5497AB15857D0300B5BC30 /* MediaTime.h */; };
CE46516E19DB1FB4003ECA05 /* NSMapTableSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */; };
CE73E02519DCB7AB00580D5C /* XPCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE73E02419DCB7AB00580D5C /* XPCSPI.h */; };
+ DE5A09FC1BA36992003D4424 /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = DE5A09FB1BA36992003D4424 /* CommonCryptoSPI.h */; };
E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
E15556F618A0CC18006F48FB /* CryptographicUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E15556F418A0CC18006F48FB /* CryptographicUtilities.h */; };
E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
@@ -563,6 +564,7 @@
CD5497AB15857D0300B5BC30 /* MediaTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTime.h; sourceTree = "<group>"; };
CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMapTableSPI.h; sourceTree = "<group>"; };
CE73E02419DCB7AB00580D5C /* XPCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCSPI.h; sourceTree = "<group>"; };
+ DE5A09FB1BA36992003D4424 /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicUtilities.cpp; sourceTree = "<group>"; };
E15556F418A0CC18006F48FB /* CryptographicUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptographicUtilities.h; sourceTree = "<group>"; };
E4A0AD371A96245500536DF6 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
@@ -1005,6 +1007,7 @@
CE73E02319DCB7AB00580D5C /* darwin */ = {
isa = PBXGroup;
children = (
+ DE5A09FB1BA36992003D4424 /* CommonCryptoSPI.h */,
CE73E02419DCB7AB00580D5C /* XPCSPI.h */,
);
path = darwin;
@@ -1171,6 +1174,7 @@
A8A47426151A825B004123FF /* Spectrum.h in Headers */,
A8A47428151A825B004123FF /* StackBounds.h in Headers */,
FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */,
+ DE5A09FC1BA36992003D4424 /* CommonCryptoSPI.h in Headers */,
A8A47429151A825B004123FF /* StaticConstructors.h in Headers */,
A8A4742A151A825B004123FF /* StdLibExtras.h in Headers */,
1A6BB769162F300500DD16DB /* StreamBuffer.h in Headers */,
Modified: branches/safari-601-branch/Source/WTF/wtf/OSRandomSource.cpp (190767 => 190768)
--- branches/safari-601-branch/Source/WTF/wtf/OSRandomSource.cpp 2015-10-09 01:50:16 UTC (rev 190767)
+++ branches/safari-601-branch/Source/WTF/wtf/OSRandomSource.cpp 2015-10-09 01:56:22 UTC (rev 190768)
@@ -40,6 +40,10 @@
#include <wincrypt.h> // windows.h must be included before wincrypt.h.
#endif
+#if OS(DARWIN)
+#include "CommonCryptoSPI.h"
+#endif
+
namespace WTF {
#if !OS(DARWIN) && OS(UNIX)
@@ -57,7 +61,7 @@
void cryptographicallyRandomValuesFromOS(unsigned char* buffer, size_t length)
{
#if OS(DARWIN)
- return arc4random_buf(buffer, length);
+ RELEASE_ASSERT(!CCRandomCopyBytes(kCCRandomDefault, buffer, length));
#elif OS(UNIX)
int fd = open("/dev/urandom", O_RDONLY, 0);
if (fd < 0)
Copied: branches/safari-601-branch/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h (from rev 189633, trunk/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h) (0 => 190768)
--- branches/safari-601-branch/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h (rev 0)
+++ branches/safari-601-branch/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h 2015-10-09 01:56:22 UTC (rev 190768)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CommonCryptoSPI_h
+#define CommonCryptoSPI_h
+
+#if OS(DARWIN)
+
+#if defined(__has_include)
+#if __has_include(<CommonCrypto/CommonRandomSPI.h>)
+#include <CommonCrypto/CommonRandomSPI.h>
+#endif
+#endif
+
+typedef struct __CCRandom* CCRandomRef;
+extern const CCRandomRef kCCRandomDefault;
+extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
+
+#endif // OS(DARWIN)
+
+#endif /* CommonCryptoSPI_h */