changeset 11207:94ab600ac567

8219734: [WebView] Get rid of macOS SDK private API usage Reviewed-by: kcr, mbilla
author arajkumar
date Fri, 01 Mar 2019 13:54:26 +0530
parents 971d58a20171
children db2c977a840b
files modules/javafx.web/src/main/native/Source/WTF/wtf/BlockPtr.h modules/javafx.web/src/main/native/Source/WTF/wtf/CMakeLists.txt modules/javafx.web/src/main/native/Source/WTF/wtf/RandomDevice.cpp modules/javafx.web/src/main/native/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h modules/javafx.web/src/main/native/Source/WebCore/crypto/CommonCryptoUtilities.h modules/javafx.web/src/main/native/Source/WebCore/page/Crypto.cpp modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/CryptoRandom.cpp
diffstat 7 files changed, 10 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.web/src/main/native/Source/WTF/wtf/BlockPtr.h	Wed Feb 27 15:10:53 2019 -0800
+++ b/modules/javafx.web/src/main/native/Source/WTF/wtf/BlockPtr.h	Fri Mar 01 13:54:26 2019 +0530
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <Block.h>
+#include <objc/runtime.h>
 #include <utility>
 #include <wtf/Assertions.h>
 #include <wtf/StdLibExtras.h>
@@ -40,8 +41,6 @@
 
 namespace WTF {
 
-extern "C" void* _NSConcreteMallocBlock[32];
-
 template<typename> class BlockPtr;
 
 template<typename R, typename... Args>
@@ -82,7 +81,7 @@
         };
 
         Block* block = static_cast<Block*>(malloc(sizeof(Block)));
-        block->isa = _NSConcreteMallocBlock;
+        block->isa = objc_getClass("__NSMallocBlock__");
 
         enum {
             BLOCK_NEEDS_FREE = (1 << 24),
--- a/modules/javafx.web/src/main/native/Source/WTF/wtf/CMakeLists.txt	Wed Feb 27 15:10:53 2019 -0800
+++ b/modules/javafx.web/src/main/native/Source/WTF/wtf/CMakeLists.txt	Fri Mar 01 13:54:26 2019 +0530
@@ -459,15 +459,6 @@
     ${CMAKE_DL_LIBS}
 )
 
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-    list(APPEND WTF_PUBLIC_HEADERS
-        spi/darwin/CommonCryptoSPI.h
-    )
-list(APPEND WTF_PRIVATE_INCLUDE_DIRECTORIES
-        "${WTF_DIR}/wtf/spi/darwin"
-    )
-endif ()
-
 if (NOT USE_SYSTEM_MALLOC)
     list(APPEND WTF_LIBRARIES bmalloc)
 endif ()
--- a/modules/javafx.web/src/main/native/Source/WTF/wtf/RandomDevice.cpp	Wed Feb 27 15:10:53 2019 -0800
+++ b/modules/javafx.web/src/main/native/Source/WTF/wtf/RandomDevice.cpp	Fri Mar 01 13:54:26 2019 +0530
@@ -42,7 +42,8 @@
 #endif
 
 #if OS(DARWIN)
-#include "CommonCryptoSPI.h"
+#include <CommonCrypto/CommonCryptoError.h>
+#include <CommonCrypto/CommonRandom.h>
 #endif
 
 #if OS(FUCHSIA)
@@ -88,7 +89,7 @@
 void RandomDevice::cryptographicallyRandomValues(unsigned char* buffer, size_t length)
 {
 #if OS(DARWIN)
-    RELEASE_ASSERT(!CCRandomCopyBytes(kCCRandomDefault, buffer, length));
+    RELEASE_ASSERT(!CCRandomGenerateBytes(buffer, length));
 #elif OS(FUCHSIA)
     zx_cprng_draw(buffer, length);
 #elif OS(UNIX)
--- a/modules/javafx.web/src/main/native/Source/WTF/wtf/spi/darwin/CommonCryptoSPI.h	Wed Feb 27 15:10:53 2019 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015-2016 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 USE(APPLE_INTERNAL_SDK)
-#include <CommonCrypto/CommonRandomSPI.h>
-#endif
-
-typedef struct __CCRandom* CCRandomRef;
-
-WTF_EXTERN_C_BEGIN
-
-extern const CCRandomRef kCCRandomDefault;
-int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-
-WTF_EXTERN_C_END
-
-#endif // OS(DARWIN)
-
-#endif /* CommonCryptoSPI_h */
--- a/modules/javafx.web/src/main/native/Source/WebCore/crypto/CommonCryptoUtilities.h	Wed Feb 27 15:10:53 2019 -0800
+++ b/modules/javafx.web/src/main/native/Source/WebCore/crypto/CommonCryptoUtilities.h	Fri Mar 01 13:54:26 2019 +0530
@@ -33,6 +33,7 @@
 
 #include "CryptoAlgorithmIdentifier.h"
 #include <CommonCrypto/CommonCryptor.h>
+#include <CommonCrypto/CommonRandom.h>
 #include <wtf/Vector.h>
 
 #if USE(APPLE_INTERNAL_SDK)
@@ -41,7 +42,6 @@
 // FIXME: <rdar://problem/31508959>
 // #include <CommonCrypto/CommonKeyDerivationSPI.h>
 #include <CommonCrypto/CommonRSACryptor.h>
-#include <CommonCrypto/CommonRandomSPI.h>
 #endif
 
 #if USE(APPLE_INTERNAL_SDK) && HAVE(CCRSAGetCRTComponents)
@@ -79,10 +79,6 @@
 
 typedef struct _CCBigNumRef *CCBigNumRef;
 
-typedef struct __CCRandom *CCRandomRef;
-extern const CCRandomRef kCCRandomDefault;
-extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-
 typedef struct _CCRSACryptor *CCRSACryptorRef;
 extern "C" CCCryptorStatus CCRSACryptorEncrypt(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType);
 extern "C" CCCryptorStatus CCRSACryptorDecrypt(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType);
--- a/modules/javafx.web/src/main/native/Source/WebCore/page/Crypto.cpp	Wed Feb 27 15:10:53 2019 -0800
+++ b/modules/javafx.web/src/main/native/Source/WebCore/page/Crypto.cpp	Fri Mar 01 13:54:26 2019 +0530
@@ -59,7 +59,7 @@
     if (array.byteLength() > 65536)
         return Exception { QuotaExceededError };
 #if OS(DARWIN) && ENABLE(SUBTLE_CRYPTO)
-    int rc = CCRandomCopyBytes(kCCRandomDefault, array.baseAddress(), array.byteLength());
+    auto rc = CCRandomGenerateBytes(array.baseAddress(), array.byteLength());
     RELEASE_ASSERT(rc == kCCSuccess);
 #else
     cryptographicallyRandomValues(array.baseAddress(), array.byteLength());
--- a/modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/CryptoRandom.cpp	Wed Feb 27 15:10:53 2019 -0800
+++ b/modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/CryptoRandom.cpp	Fri Mar 01 13:54:26 2019 +0530
@@ -44,12 +44,8 @@
 #endif
 
 #if BOS(DARWIN)
-typedef struct __CCRandom* CCRandomRef;
-
-extern "C" {
-extern const CCRandomRef kCCRandomDefault;
-int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-}
+#include <CommonCrypto/CommonCryptoError.h>
+#include <CommonCrypto/CommonRandom.h>
 #endif
 
 namespace bmalloc {
@@ -113,7 +109,7 @@
     size_t length = sizeof(randomness);
 
 #if BOS(DARWIN)
-    RELEASE_BASSERT(!CCRandomCopyBytes(kCCRandomDefault, randomness, length));
+    RELEASE_BASSERT(!CCRandomGenerateBytes(randomness, length));
 #else
     static std::once_flag onceFlag;
     static int fd;