Changeset 189633 in webkit


Ignore:
Timestamp:
Sep 11, 2015 2:34:15 PM (9 years ago)
Author:
keith_miller@apple.com
Message:

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.
Location:
trunk/Source/WTF
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r189586 r189633  
     1
     22015-09-11  Keith Miller  <keith_miller@apple.com>
     3
     4        cryptographicallyRandomValuesFromOS should use CCRandomCopyBytes when available.
     5        https://bugs.webkit.org/show_bug.cgi?id=148439
     6
     7        Reviewed by Alexey Proskuryakov.
     8
     9        Recently, we switched to using arc4random_buf on Darwin but further research indicates that
     10        arc4random_buf has the same behavior we had before and thus we were just pushing the problem
     11        further down the stack. CCRandomCopyBytes, however, appears to be more advanced and has much
     12        better error handling than we had before.
     13
     14        * WTF.xcodeproj/project.pbxproj:
     15        * wtf/OSRandomSource.cpp:
     16        (WTF::cryptographicallyRandomValuesFromOS):
     17        * wtf/spi/darwin/CommonCryptoSPI.h: Added.
     18
    1192015-09-08  Filip Pizlo  <fpizlo@apple.com>
    220
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r188677 r189633  
    279279                CE46516E19DB1FB4003ECA05 /* NSMapTableSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */; };
    280280                CE73E02519DCB7AB00580D5C /* XPCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE73E02419DCB7AB00580D5C /* XPCSPI.h */; };
     281                DE5A09FC1BA36992003D4424 /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = DE5A09FB1BA36992003D4424 /* CommonCryptoSPI.h */; };
    281282                E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
    282283                E15556F618A0CC18006F48FB /* CryptographicUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E15556F418A0CC18006F48FB /* CryptographicUtilities.h */; };
     
    576577                CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMapTableSPI.h; sourceTree = "<group>"; };
    577578                CE73E02419DCB7AB00580D5C /* XPCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCSPI.h; sourceTree = "<group>"; };
     579                DE5A09FB1BA36992003D4424 /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
    578580                E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicUtilities.cpp; sourceTree = "<group>"; };
    579581                E15556F418A0CC18006F48FB /* CryptographicUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptographicUtilities.h; sourceTree = "<group>"; };
     
    10221024                        isa = PBXGroup;
    10231025                        children = (
     1026                                DE5A09FB1BA36992003D4424 /* CommonCryptoSPI.h */,
    10241027                                CE73E02419DCB7AB00580D5C /* XPCSPI.h */,
    10251028                        );
     
    11911194                                A8A47428151A825B004123FF /* StackBounds.h in Headers */,
    11921195                                FEDACD3E1630F83F00C69634 /* StackStats.h in Headers */,
     1196                                DE5A09FC1BA36992003D4424 /* CommonCryptoSPI.h in Headers */,
    11931197                                A8A47429151A825B004123FF /* StaticConstructors.h in Headers */,
    11941198                                A8A4742A151A825B004123FF /* StdLibExtras.h in Headers */,
  • trunk/Source/WTF/wtf/OSRandomSource.cpp

    r188489 r189633  
    4141#endif
    4242
     43#if OS(DARWIN)
     44#include "CommonCryptoSPI.h"
     45#endif
     46
    4347namespace WTF {
    4448
     
    5862{
    5963#if OS(DARWIN)
    60     return arc4random_buf(buffer, length);
     64    RELEASE_ASSERT(!CCRandomCopyBytes(kCCRandomDefault, buffer, length));
    6165#elif OS(UNIX)
    6266    int fd = open("/dev/urandom", O_RDONLY, 0);
Note: See TracChangeset for help on using the changeset viewer.