WebKit Bugzilla
Attachment 359537 Details for
Bug 193590
: add support for encrypted localstorage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193590-20190118140331.patch (text/plain), 26.84 KB, created by
Gurdal Oruklu
on 2019-01-18 14:03:32 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Gurdal Oruklu
Created:
2019-01-18 14:03:32 PST
Size:
26.84 KB
patch
obsolete
>Subversion Revision: 240155 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ae955eaba79786417e9bb21d8ae810433084f30e..69932ff564fb34d1c4be9b9948f099d7d9b069e3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2019-01-18 Eugene Mutavchi <Ievgen_Mutavchi@comcast.com> >+ >+ add support for encrypted localstorage >+ https://bugs.webkit.org/show_bug.cgi?id=193590 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Initial support for SQLite Encryption Extension >+ >+ Covered by existing tests. >+ >+ * CMakeLists.txt: >+ * platform/sql/SQLiteDatabase.cpp: >+ (WebCore::isEncryped): >+ (WebCore::SQLiteDatabase::open): >+ * platform/sql/SQLiteDatabase.h: >+ > 2019-01-18 Youenn Fablet <youenn@apple.com> > > A track source should be unmuted whenever reenabled after setDirection changes >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 927032f3b170c207eb385a98aab9de74eabf284a..6b22bbfadc88acd2719aca8f22e39783bc13aa87 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,27 @@ >+2019-01-18 Eugene Mutavchi <Ievgen_Mutavchi@comcast.com> >+ >+ add support for encrypted localstorage >+ https://bugs.webkit.org/show_bug.cgi?id=193590 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Initial support for SQLite Encryption Extension >+ >+ * Sources.txt: >+ * UIProcess/API/APILocalStorageEncryptionExtensionClient.h: Added. >+ (API::LocalStorageEncryptionExtensionClient::~LocalStorageEncryptionExtensionClient): >+ (API::LocalStorageEncryptionExtensionClient::loadKeyWithOrigin): >+ * UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.cpp: Added. >+ (WKLocalStorageEncryptionExtensionSetClient): >+ * UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.h: Added. >+ * UIProcess/WebStorage/LocalStorageDatabase.cpp: >+ (WebKit::LocalStorageDatabase::tryToOpenDatabase): >+ * UIProcess/WebStorage/LocalStorageEncryptionExtension.cpp: Added. >+ (WebKit::LocalStorageEncryptionExtension::singleton): >+ (WebKit::LocalStorageEncryptionExtension::setClient): >+ (WebKit::LocalStorageEncryptionExtension::loadKeyWithOrigin): >+ * UIProcess/WebStorage/LocalStorageEncryptionExtension.h: Added. >+ > 2019-01-18 Philippe Normand <pnormand@igalia.com> > > [WPE] Add Qt extension >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 0de5943666d2239aeacbb873fd517d91996e5314..55cde67ec04039f168a7bdb0995c6ae831712498 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -158,6 +158,8 @@ set(WebCore_INCLUDE_DIRECTORIES > "${DERIVED_SOURCES_WEBCORE_DIR}" > ) > >+add_definitions(${SQLITE_DEFINITIONS}) >+ > set(WebCore_SYSTEM_INCLUDE_DIRECTORIES > ${ICU_INCLUDE_DIRS} > ${LIBXML2_INCLUDE_DIR} >diff --git a/Source/WebCore/platform/sql/SQLiteDatabase.cpp b/Source/WebCore/platform/sql/SQLiteDatabase.cpp >index 663e0bc0b8567083aa97ef8115a5468c517e96c5..77563d113e629937e383f2d5bde34aafd2bd618c 100644 >--- a/Source/WebCore/platform/sql/SQLiteDatabase.cpp >+++ b/Source/WebCore/platform/sql/SQLiteDatabase.cpp >@@ -28,6 +28,8 @@ > #include "SQLiteDatabase.h" > > #include "DatabaseAuthorizer.h" >+#include "FileHandle.h" >+#include "FileSystem.h" > #include "Logging.h" > #include "MemoryRelease.h" > #include "SQLiteFileSystem.h" >@@ -39,6 +41,10 @@ > #include <wtf/text/CString.h> > #include <wtf/text/WTFString.h> > >+#ifndef SQLITE_FILE_HEADER >+# define SQLITE_FILE_HEADER "SQLite format 3" >+#endif >+ > namespace WebCore { > > static const char notOpenErrorMessage[] = "database is not open"; >@@ -70,6 +76,22 @@ static void initializeSQLiteIfNecessary() > }); > } > >+#if defined(SQLITE_HAS_CODEC) && ENABLE(SQLITE_ENCRYPTION_EXTENSION) >+static bool isEncryped(const String& filename) >+{ >+ auto fileHandle = WebCore::FileHandle(filename, WebCore::OpenForRead); >+ if (!fileHandle.open()) >+ return false; >+ >+ int magicSize = WTF_ARRAY_LENGTH(SQLITE_FILE_HEADER); >+ auto fileHeader = MallocPtr<char>::malloc(magicSize); >+ if (magicSize != fileHandle.read(fileHeader.get(), magicSize)) >+ return false; >+ >+ return ::memcmp(fileHeader.get(), SQLITE_FILE_HEADER, magicSize); >+} >+#endif >+ > SQLiteDatabase::SQLiteDatabase() = default; > > SQLiteDatabase::~SQLiteDatabase() >@@ -77,12 +99,18 @@ SQLiteDatabase::~SQLiteDatabase() > close(); > } > >-bool SQLiteDatabase::open(const String& filename, bool forWebSQLDatabase) >+bool SQLiteDatabase::open(const String& filename, bool forWebSQLDatabase, WTF::Optional<Vector<uint8_t>> key) > { > initializeSQLiteIfNecessary(); > > close(); > >+#if defined(SQLITE_HAS_CODEC) && ENABLE(SQLITE_ENCRYPTION_EXTENSION) >+ bool shouldReKey = false; >+ if (key && key->size()) >+ shouldReKey = fileExists(filename) && !isEncryped(filename); >+#endif >+ > m_openError = SQLiteFileSystem::openDatabase(filename, &m_db, forWebSQLDatabase); > if (m_openError != SQLITE_OK) { > m_openErrorMessage = m_db ? sqlite3_errmsg(m_db) : "sqlite_open returned null"; >@@ -93,6 +121,36 @@ bool SQLiteDatabase::open(const String& filename, bool forWebSQLDatabase) > return false; > } > >+ if (key && key->size()) { >+#if defined(SQLITE_HAS_CODEC) && ENABLE(SQLITE_ENCRYPTION_EXTENSION) >+ if (!shouldReKey) >+ m_openError = sqlite3_key_v2(m_db, nullptr, key->data(), key->size()); >+ else { >+ m_openError = sqlite3_rekey_v2(m_db, nullptr, key->data(), key->size()); >+ if (m_openError == SQLITE_OK) >+ m_openError = runVacuumCommand(); >+ } >+ >+ key->fill(0); >+ >+ if (m_openError != SQLITE_OK) { >+ m_openErrorMessage = sqlite3_errmsg(m_db); >+ LOG_ERROR("Failed to attach encryption key to SQLite database %s\nCause - %s", filename.ascii().data(), m_openErrorMessage.data()); >+ sqlite3_close(m_db); >+ m_db = 0; >+ return false; >+ } >+ >+ if (shouldReKey) { >+ if (!isEncryped(filename)) >+ LOG_ERROR("SQLite database file is clear after re-key, path=%s", filename.ascii().data()); >+ } >+#else >+ key->fill(0); >+ LOG_ERROR("SQLite codec support is disabled, ignoring encryption key for database %s", filename.ascii().data()); >+#endif >+ } >+ > overrideUnauthorizedFunctions(); > > m_openError = sqlite3_extended_result_codes(m_db, 1); >diff --git a/Source/WebCore/platform/sql/SQLiteDatabase.h b/Source/WebCore/platform/sql/SQLiteDatabase.h >index acec5490078356d4c0dc94ece0e08c5c56c1dc26..297f614da0cbbb64064898d7970e4efc4524b22d 100644 >--- a/Source/WebCore/platform/sql/SQLiteDatabase.h >+++ b/Source/WebCore/platform/sql/SQLiteDatabase.h >@@ -52,7 +52,7 @@ public: > WEBCORE_EXPORT SQLiteDatabase(); > WEBCORE_EXPORT ~SQLiteDatabase(); > >- WEBCORE_EXPORT bool open(const String& filename, bool forWebSQLDatabase = false); >+ WEBCORE_EXPORT bool open(const String& filename, bool forWebSQLDatabase = false, WTF::Optional<Vector<uint8_t>> = WTF::nullopt); > bool isOpen() const { return m_db; } > WEBCORE_EXPORT void close(); > >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index 4de0c6fefe8eaf3ca4a0fdf07d05a1117dabcb32..c23254b3c2ee7488175ce3cd378a2de31197342d 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -352,6 +352,7 @@ UIProcess/API/C/WKUserMediaPermissionRequest.cpp > UIProcess/API/C/WKWebsiteDataStoreRef.cpp > UIProcess/API/C/WKWebsitePolicies.cpp > UIProcess/API/C/WKWindowFeaturesRef.cpp >+UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.cpp > > UIProcess/Authentication/AuthenticationChallengeProxy.cpp > UIProcess/Authentication/AuthenticationDecisionListener.cpp >@@ -400,6 +401,7 @@ UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp > > UIProcess/WebStorage/LocalStorageDatabase.cpp > UIProcess/WebStorage/LocalStorageDatabaseTracker.cpp >+UIProcess/WebStorage/LocalStorageEncryptionExtension.cpp > > UIProcess/WebsiteData/WebsiteDataRecord.cpp > UIProcess/WebsiteData/WebsiteDataStore.cpp >diff --git a/Source/WebKit/UIProcess/API/APILocalStorageEncryptionExtensionClient.h b/Source/WebKit/UIProcess/API/APILocalStorageEncryptionExtensionClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a919c4adf8be2cd98f1cc29133262288809f9c67 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/APILocalStorageEncryptionExtensionClient.h >@@ -0,0 +1,44 @@ >+/* >+* Copyright (c) 2018, Comcast >+* All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without modification, >+* are permitted provided that the following conditions are met: >+* >+* * Redistributions of source code must retain the above copyright notice, >+* this list of conditions and the following disclaimer. >+* * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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 OR; PROFITS BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+* ANY OF THEORY 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. >+*/ >+ >+#pragma once >+ >+#include <wtf/Optional.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+struct SecurityOriginData; >+} >+ >+namespace API { >+ >+class LocalStorageEncryptionExtensionClient { >+public: >+ virtual ~LocalStorageEncryptionExtensionClient() { } >+ >+ virtual WTF::Optional<Vector<uint8_t>> loadKeyWithOrigin(const WebCore::SecurityOriginData&) { return WTF::nullopt; } >+}; >+ >+} // namespace API >diff --git a/Source/WebKit/UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.cpp b/Source/WebKit/UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..10cdd700b96651e5b4a0d98e477f420cdafd4cd2 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.cpp >@@ -0,0 +1,82 @@ >+/* >+* Copyright (c) 2018, Comcast >+* All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without modification, >+* are permitted provided that the following conditions are met: >+* >+* * Redistributions of source code must retain the above copyright notice, >+* this list of conditions and the following disclaimer. >+* * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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 OR; PROFITS BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+* ANY OF THEORY 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. >+*/ >+ >+#include "config.h" >+#include "WKLocalStorageEncryptionExtensionClient.h" >+ >+#include "APIClient.h" >+#include "APIData.h" >+#include "APILocalStorageEncryptionExtensionClient.h" >+#include "LocalStorageEncryptionExtension.h" >+#include "WKAPICast.h" >+#include <WebCore/SecurityOriginData.h> >+ >+#include <cstring> >+ >+using namespace WebKit; >+ >+namespace API { >+template<> struct ClientTraits<WKLocalStorageEncryptionExtensionClientBase> { >+ typedef std::tuple<WKLocalStorageEncryptionExtensionClientV0> Versions; >+}; >+} >+ >+void WKLocalStorageEncryptionExtensionSetClient(const WKLocalStorageEncryptionExtensionClientBase* wkClient) >+{ >+ if (!wkClient) { >+ LocalStorageEncryptionExtension::singleton().setClient(nullptr); >+ return; >+ } >+ >+ class WebLocalStorageEncryptionExtensionClient : public API::Client<WKLocalStorageEncryptionExtensionClientBase>, public API::LocalStorageEncryptionExtensionClient { >+ public: >+ explicit WebLocalStorageEncryptionExtensionClient(const WKLocalStorageEncryptionExtensionClientBase* client) >+ { >+ initialize(client); >+ } >+ private: >+ WTF::Optional<Vector<uint8_t>> loadKeyWithOrigin(const WebCore::SecurityOriginData& securityOriginData) final >+ { >+ if (!m_client.loadKeyWithOrigin) >+ return WTF::nullopt; >+ >+ WKDataRef keyDataRef = nullptr; >+ RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(securityOriginData.protocol, securityOriginData.host, securityOriginData.port); >+ m_client.loadKeyWithOrigin(toAPI(securityOrigin.get()), &keyDataRef, m_client.base.clientInfo); >+ >+ if (!keyDataRef) >+ return WTF::nullopt; >+ >+ auto data = adoptRef(WebKit::toImpl(keyDataRef)); >+ Vector<uint8_t> keyVector; >+ keyVector.append(data->bytes(), data->size()); >+ ::memset(const_cast<unsigned char*>(data->bytes()), 0, data->size()); >+ return WTF::makeOptional(WTFMove(keyVector)); >+ } >+ }; >+ >+ auto client = std::make_unique<WebLocalStorageEncryptionExtensionClient>(wkClient); >+ LocalStorageEncryptionExtension::singleton().setClient(WTFMove(client)); >+} >diff --git a/Source/WebKit/UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.h b/Source/WebKit/UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..48d7a5043fbeb562488470bea3507f73d1d0236e >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/C/WKLocalStorageEncryptionExtensionClient.h >@@ -0,0 +1,52 @@ >+/* >+* Copyright (c) 2018, Comcast >+* All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without modification, >+* are permitted provided that the following conditions are met: >+* >+* * Redistributions of source code must retain the above copyright notice, >+* this list of conditions and the following disclaimer. >+* * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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 OR; PROFITS BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+* ANY OF THEORY 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. >+*/ >+ >+#pragma once >+ >+#include <WebKit/WKBase.h> >+ >+#ifdef __cplusplus >+extern "C" { >+#endif >+ >+typedef void (*WKLoadKeyWithOrigin)(WKSecurityOriginRef origin, WKDataRef *returnKeyData, const void* clientInfo); >+ >+typedef struct WKLocalStorageEncryptionExtensionClientBase { >+ int version; >+ const void * clientInfo; >+} WKLocalStorageEncryptionExtensionClientBase; >+ >+typedef struct WKLocalStorageEncryptionExtensionClientV0 { >+ WKLocalStorageEncryptionExtensionClientBase base; >+ >+ // Version 0. >+ WKLoadKeyWithOrigin loadKeyWithOrigin; >+} WKLocalStorageEncryptionExtensionClientV0; >+ >+WK_EXPORT void WKLocalStorageEncryptionExtensionSetClient(const WKLocalStorageEncryptionExtensionClientBase* client); >+ >+#ifdef __cplusplus >+} >+#endif >diff --git a/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabase.cpp b/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabase.cpp >index 0c25d657e9776a7474d2055fdf54872a00d8eddb..cd6ceb2db8e45bc85b2a7d6b0e5884d942a5214a 100644 >--- a/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabase.cpp >+++ b/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabase.cpp >@@ -27,6 +27,7 @@ > #include "LocalStorageDatabase.h" > > #include "LocalStorageDatabaseTracker.h" >+#include "LocalStorageEncryptionExtension.h" > #include <WebCore/FileSystem.h> > #include <WebCore/SQLiteStatement.h> > #include <WebCore/SQLiteTransaction.h> >@@ -92,7 +93,9 @@ bool LocalStorageDatabase::tryToOpenDatabase(DatabaseOpeningStrategy openingStra > return false; > } > >- if (!m_database.open(m_databasePath)) { >+ WTF::Optional<Vector<uint8_t>> key = LocalStorageEncryptionExtension::singleton().loadKeyWithOrigin(m_securityOrigin); >+ >+ if (!m_database.open(m_databasePath, false, WTFMove(key))) { > LOG_ERROR("Failed to open database file %s for local storage", m_databasePath.utf8().data()); > return false; > } >diff --git a/Source/WebKit/UIProcess/WebStorage/LocalStorageEncryptionExtension.cpp b/Source/WebKit/UIProcess/WebStorage/LocalStorageEncryptionExtension.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7bd573e14dcd9368e20df5bc46c629f191bae904 >--- /dev/null >+++ b/Source/WebKit/UIProcess/WebStorage/LocalStorageEncryptionExtension.cpp >@@ -0,0 +1,48 @@ >+/* >+* Copyright (c) 2018, Comcast >+* All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without modification, >+* are permitted provided that the following conditions are met: >+* >+* * Redistributions of source code must retain the above copyright notice, >+* this list of conditions and the following disclaimer. >+* * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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 OR; PROFITS BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+* ANY OF THEORY 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. >+*/ >+ >+#include "config.h" >+#include "LocalStorageEncryptionExtension.h" >+ >+#include <wtf/NeverDestroyed.h> >+ >+namespace WebKit { >+ >+LocalStorageEncryptionExtension& LocalStorageEncryptionExtension::singleton() >+{ >+ static NeverDestroyed<LocalStorageEncryptionExtension> instance; >+ return instance; >+} >+ >+void LocalStorageEncryptionExtension::setClient(std::unique_ptr<API::LocalStorageEncryptionExtensionClient>&& client) >+{ >+ m_client = WTFMove(client); >+} >+WTF::Optional<Vector<uint8_t>> LocalStorageEncryptionExtension::loadKeyWithOrigin(const WebCore::SecurityOriginData& originData) >+{ >+ return m_client ? m_client->loadKeyWithOrigin(originData) : WTF::nullopt; >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebStorage/LocalStorageEncryptionExtension.h b/Source/WebKit/UIProcess/WebStorage/LocalStorageEncryptionExtension.h >new file mode 100644 >index 0000000000000000000000000000000000000000..b7a4d1d3ec706679268127a84ab6ba5f6354569a >--- /dev/null >+++ b/Source/WebKit/UIProcess/WebStorage/LocalStorageEncryptionExtension.h >@@ -0,0 +1,56 @@ >+/* >+* Copyright (c) 2018, Comcast >+* All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without modification, >+* are permitted provided that the following conditions are met: >+* >+* * Redistributions of source code must retain the above copyright notice, >+* this list of conditions and the following disclaimer. >+* * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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 OR; PROFITS BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+* ANY OF THEORY 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. >+*/ >+#pragma once >+ >+#include "APILocalStorageEncryptionExtensionClient.h" >+ >+#include <wtf/Forward.h> >+#include <wtf/Noncopyable.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+struct SecurityOriginData; >+} >+ >+namespace WebKit { >+ >+class LocalStorageEncryptionExtension { >+ WTF_MAKE_NONCOPYABLE(LocalStorageEncryptionExtension); >+public: >+ static LocalStorageEncryptionExtension& singleton(); >+ >+ void setClient(std::unique_ptr<API::LocalStorageEncryptionExtensionClient>&&); >+ WTF::Optional<Vector<uint8_t>> loadKeyWithOrigin(const WebCore::SecurityOriginData&); >+ >+private: >+ LocalStorageEncryptionExtension() = default; >+ ~LocalStorageEncryptionExtension() = default; >+ >+ std::unique_ptr<API::LocalStorageEncryptionExtensionClient> m_client; >+ >+ friend class NeverDestroyed<LocalStorageEncryptionExtension>; >+}; >+ >+} >diff --git a/Source/cmake/FindSqlite3See.cmake b/Source/cmake/FindSqlite3See.cmake >new file mode 100644 >index 0000000000000000000000000000000000000000..25eb3951d4e5b238e8a1239de95e8e139cf2c0bb >--- /dev/null >+++ b/Source/cmake/FindSqlite3See.cmake >@@ -0,0 +1,42 @@ >+# Copyright (c) 2018, Comcast >+# All rights reserved. >+# >+# Redistribution and use in source and binary forms, with or without modification, >+# are permitted provided that the following conditions are met: >+# >+# * Redistributions of source code must retain the above copyright notice, >+# this list of conditions and the following disclaimer. >+# * 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER 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 OR; PROFITS BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+# ANY OF THEORY 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. >+ >+find_package(PkgConfig) >+pkg_check_modules(PC_SQLITE sqlite3see) >+ >+set(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER}) >+ >+find_path(SQLITE_INCLUDE_DIR NAMES sqlite3.h >+ PATH_SUFFIXES sqlite3see >+ PATHS ${PC_SQLITE_INCLUDEDIR} >+) >+find_library(SQLITE_LIBRARIES NAMES sqlite3see >+ PATHS >+ ${PC_SQLITE_LIBDIR} >+ ${PC_SQLITE_LIBRARY_DIRS} >+) >+ >+include(FindPackageHandleStandardArgs) >+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlite3See DEFAULT_MSG SQLITE_INCLUDE_DIR SQLITE_LIBRARIES) >+ >+mark_as_advanced(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES) >diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake >index 5f311b83c5ab98786f83b3ba50429374d0ab784d..fed302c348d052c281b2ed4fa8dda88a6e1139e1 100644 >--- a/Source/cmake/OptionsWPE.cmake >+++ b/Source/cmake/OptionsWPE.cmake >@@ -80,7 +80,13 @@ find_package(LibGcrypt 1.6.0 REQUIRED) > find_package(LibSoup 2.42.0 REQUIRED) > find_package(LibXml2 2.8.0 REQUIRED) > find_package(PNG REQUIRED) >-find_package(Sqlite REQUIRED) >+ >+if (ENABLE_SQLITE_ENCRYPTION_EXTENSION) >+ find_package(Sqlite3See REQUIRED) >+else () >+ find_package(Sqlite REQUIRED) >+endif () >+ > find_package(Threads REQUIRED) > find_package(WebP REQUIRED) > find_package(WPE REQUIRED) >diff --git a/Source/cmake/WebKitFeatures.cmake b/Source/cmake/WebKitFeatures.cmake >index 041ab32d2b8f186e0fdd3e0372a7c410e6cb22c8..16437a6dbedfc2ee59a31c61e6ce100680bbce48 100644 >--- a/Source/cmake/WebKitFeatures.cmake >+++ b/Source/cmake/WebKitFeatures.cmake >@@ -215,6 +215,7 @@ macro(WEBKIT_OPTION_BEGIN) > WEBKIT_OPTION_DEFINE(ENABLE_WIRELESS_PLAYBACK_TARGET "Enable wireless playback target support" PRIVATE OFF) > WEBKIT_OPTION_DEFINE(ENABLE_XSLT "Toggle XSLT support" PRIVATE ON) > WEBKIT_OPTION_DEFINE(USE_SYSTEM_MALLOC "Toggle system allocator instead of WebKit's custom allocator" PRIVATE ${USE_SYSTEM_MALLOC_DEFAULT}) >+ WEBKIT_OPTION_DEFINE(ENABLE_SQLITE_ENCRYPTION_EXTENSION "Toggle SQLite encryption extension support" PRIVATE OFF) > > WEBKIT_OPTION_CONFLICT(ENABLE_JIT ENABLE_C_LOOP) > WEBKIT_OPTION_CONFLICT(ENABLE_SAMPLING_PROFILER ENABLE_C_LOOP) >diff --git a/ChangeLog b/ChangeLog >index 9af449ddb040f51c84f7cc5ebb56b631eed7fc3c..f5862e633f439d895f669e47588baa635749a07b 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,16 @@ >+2019-01-18 Eugene Mutavchi <Ievgen_Mutavchi@comcast.com> >+ >+ add support for encrypted localstorage >+ https://bugs.webkit.org/show_bug.cgi?id=193590 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Initial support for SQLite Encryption Extension >+ >+ * Source/cmake/FindSqlite3See.cmake: Added. >+ * Source/cmake/OptionsWPE.cmake: >+ * Source/cmake/WebKitFeatures.cmake: >+ > 2019-01-18 Philippe Normand <pnormand@igalia.com> > > [WPE] Add Qt extension
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
gurdal_oruklu
:
review?
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193590
: 359537