Changeset 163863 in webkit
- Timestamp:
- Feb 10, 2014 10:32:39 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r163858 r163863 1 2014-02-10 Alexey Proskuryakov <ap@apple.com> 2 3 Add hooks for wrapping CryptoKeys in SerializedScriptValue 4 https://bugs.webkit.org/show_bug.cgi?id=128567 5 6 Reviewed by Anders Carlsson. 7 8 * bindings/js/SerializedScriptValue.cpp: Changed SerializedScriptValue to serialize 9 wrapped keys. Added a version number to crypto key serialization. 10 11 * dom/Document.cpp: 12 (WebCore::Document::wrapCryptoKey): 13 (WebCore::Document::unwrapCryptoKey): 14 * dom/Document.h: 15 * dom/ScriptExecutionContext.h: 16 * page/ChromeClient.h: 17 (WebCore::ChromeClient::wrapCryptoKey): 18 (WebCore::ChromeClient::unwrapCryptoKey): 19 Hand wrapping/unwrapping over to client code. 20 21 * workers/WorkerGlobalScope.cpp: 22 (WebCore::WorkerGlobalScope::wrapCryptoKey): 23 (WebCore::WorkerGlobalScope::unwrapCryptoKey): 24 * workers/WorkerGlobalScope.h: 25 Not implemented in workers. SubtleCrypto is currently not exposed in workers. It used 26 to be possible in WebKit implementation to post a CryptoKey to a worker anyway, 27 but this doesn't work any more. 28 1 29 2014-02-10 ChangSeok Oh <changseok.oh@collabora.com> 2 30 -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r163844 r163863 47 47 #include "JSNavigator.h" 48 48 #include "NotImplemented.h" 49 #include "ScriptExecutionContext.h" 49 50 #include "SharedBuffer.h" 50 51 #include "WebCoreJSClientData.h" … … 167 168 #if ENABLE(SUBTLE_CRYPTO) 168 169 170 const uint32_t currentKeyFormatVersion = 1; 171 169 172 enum class CryptoKeyClassSubtag { 170 173 HMAC = 0, … … 294 297 * | ArrayBufferViewTag ArrayBufferViewSubtag <byteOffset:uint32_t> <byteLength:uint32_t> (ArrayBuffer | ObjectReference) 295 298 * | ArrayBufferTransferTag <value:uint32_t> 296 * | CryptoKeyTag <extractable:int32_t> <usagesCount:uint32_t> <usages:byte{usagesCount}> CryptoKeyClassSubtag (CryptoKeyHMAC | CryptoKeyAES | CryptoKeyRSA) 299 * | CryptoKeyTag <wrappedKeyLength:uint32_t> <factor:byte{wrappedKeyLength}> 300 * 301 * Inside wrapped crypto key, data is serialized in this format: 302 * 303 * <keyFormatVersion:uint32_t> <extractable:int32_t> <usagesCount:uint32_t> <usages:byte{usagesCount}> CryptoKeyClassSubtag (CryptoKeyHMAC | CryptoKeyAES | CryptoKeyRSA) 297 304 * 298 305 * String :- … … 386 393 MarkedArgumentBuffer m_gcBuffer; 387 394 }; 395 396 #if ENABLE(SUBTLE_CRYPTO) 397 static bool wrapCryptoKey(ExecState* exec, const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) 398 { 399 ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(exec); 400 if (!scriptExecutionContext) 401 return false; 402 return scriptExecutionContext->wrapCryptoKey(key, wrappedKey); 403 } 404 405 static bool unwrapCryptoKey(ExecState* exec, const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) 406 { 407 ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(exec); 408 if (!scriptExecutionContext) 409 return false; 410 return scriptExecutionContext->unwrapCryptoKey(wrappedKey, key); 411 } 412 #endif 388 413 389 414 #if ASSUME_LITTLE_ENDIAN … … 831 856 if (CryptoKey* key = toCryptoKey(obj)) { 832 857 write(CryptoKeyTag); 833 write(key); 858 Vector<uint8_t> serializedKey; 859 Vector<String> dummyBlobURLs; 860 CloneSerializer rawKeySerializer(m_exec, nullptr, nullptr, dummyBlobURLs, serializedKey); 861 rawKeySerializer.write(key); 862 Vector<uint8_t> wrappedKey; 863 if (!wrapCryptoKey(m_exec, serializedKey, wrappedKey)) 864 return false; 865 write(wrappedKey); 834 866 return true; 835 867 } … … 1096 1128 void write(const CryptoKey* key) 1097 1129 { 1130 write(currentKeyFormatVersion); 1131 1098 1132 write(key->extractable()); 1099 1133 … … 1990 2024 bool readCryptoKey(JSValue& cryptoKey) 1991 2025 { 2026 uint32_t keyFormatVersion; 2027 if (!read(keyFormatVersion) || keyFormatVersion > currentKeyFormatVersion) 2028 return false; 2029 1992 2030 int32_t extractable; 1993 2031 if (!read(extractable)) … … 2261 2299 #if ENABLE(SUBTLE_CRYPTO) 2262 2300 case CryptoKeyTag: { 2301 Vector<uint8_t> wrappedKey; 2302 if (!read(wrappedKey)) { 2303 fail(); 2304 return JSValue(); 2305 } 2306 Vector<uint8_t> serializedKey; 2307 if (!unwrapCryptoKey(m_exec, wrappedKey, serializedKey)) { 2308 fail(); 2309 return JSValue(); 2310 } 2263 2311 JSValue cryptoKey; 2264 if (!readCryptoKey(cryptoKey)) { 2312 CloneDeserializer rawKeyDeserializer(m_exec, m_globalObject, nullptr, nullptr, serializedKey); 2313 if (!rawKeyDeserializer.readCryptoKey(cryptoKey)) { 2265 2314 fail(); 2266 2315 return JSValue(); -
trunk/Source/WebCore/dom/Document.cpp
r163725 r163863 5995 5995 } 5996 5996 5997 #if ENABLE(SUBTLE_CRYPTO) 5998 bool Document::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) 5999 { 6000 Page* page = this->page(); 6001 if (!page) 6002 return false; 6003 return page->chrome().client().wrapCryptoKey(key, wrappedKey); 6004 } 6005 6006 bool Document::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) 6007 { 6008 Page* page = this->page(); 6009 if (!page) 6010 return false; 6011 return page->chrome().client().unwrapCryptoKey(wrappedKey, key); 6012 } 6013 #endif // ENABLE(SUBTLE_CRYPTO) 6014 5997 6015 } // namespace WebCore -
trunk/Source/WebCore/dom/Document.h
r163654 r163863 1227 1227 void setVisualUpdatesAllowedByClient(bool); 1228 1228 1229 #if ENABLE(SUBTLE_CRYPTO) 1230 virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) override; 1231 virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override; 1232 #endif 1233 1229 1234 protected: 1230 1235 enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 }; -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r163568 r163863 89 89 PublicURLManager& publicURLManager(); 90 90 #endif 91 91 92 // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked. 92 93 bool canSuspendActiveDOMObjects(); … … 156 157 #if ENABLE(SQL_DATABASE) 157 158 void setDatabaseContext(DatabaseContext*); 159 #endif 160 161 #if ENABLE(SUBTLE_CRYPTO) 162 virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) = 0; 163 virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) = 0; 158 164 #endif 159 165 -
trunk/Source/WebCore/page/ChromeClient.h
r163726 r163863 404 404 virtual bool shouldUseTiledBackingForFrameView(const FrameView*) const { return false; } 405 405 406 #if ENABLE(SUBTLE_CRYPTO) 407 virtual bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const { return false; } 408 virtual bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const { return false; } 409 #endif 410 406 411 protected: 407 412 virtual ~ChromeClient() { } -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r163568 r163863 344 344 } 345 345 346 #if ENABLE(SUBTLE_CRYPTO) 347 bool WorkerGlobalScope::wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) 348 { 349 return false; 350 } 351 352 bool WorkerGlobalScope::unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) 353 { 354 return false; 355 } 356 #endif // ENABLE(SUBTLE_CRYPTO) 357 346 358 } // namespace WebCore -
trunk/Source/WebCore/workers/WorkerGlobalScope.h
r163568 r163863 136 136 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override; 137 137 138 #if ENABLE(SUBTLE_CRYPTO) 139 virtual bool wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) override; 140 virtual bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override; 141 #endif 142 138 143 protected: 139 144 WorkerGlobalScope(const URL&, const String& userAgent, std::unique_ptr<GroupSettings>, WorkerThread*, PassRefPtr<SecurityOrigin> topOrigin); -
trunk/Source/WebKit/mac/ChangeLog
r163739 r163863 1 2014-02-10 Alexey Proskuryakov <ap@apple.com> 2 3 Add hooks for wrapping CryptoKeys in SerializedScriptValue 4 https://bugs.webkit.org/show_bug.cgi?id=128567 5 6 Reviewed by Anders Carlsson. 7 8 * WebCoreSupport/WebChromeClient.h: 9 * WebCoreSupport/WebChromeClient.mm: 10 (WebChromeClient::wrapCryptoKey): 11 (WebChromeClient::unwrapCryptoKey): 12 Dummy implementation, to be filled in later. 13 1 14 2014-02-08 Ryosuke Niwa <rniwa@webkit.org> 2 15 -
trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
r163724 r163863 196 196 virtual void numWheelEventHandlersChanged(unsigned) override { } 197 197 198 #if ENABLE(SUBTLE_CRYPTO) 199 virtual bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override; 200 virtual bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override; 201 #endif 202 198 203 #if PLATFORM(IOS) 199 204 WebView* webView() const { return m_webView; } -
trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
r163717 r163863 997 997 } 998 998 999 #endif 999 #if ENABLE(SUBTLE_CRYPTO) 1000 bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) const 1001 { 1002 wrappedKey = key; 1003 return true; 1004 } 1005 1006 bool WebChromeClient::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) const 1007 { 1008 key = wrappedKey; 1009 return true; 1010 } 1011 #endif 1012 1013 #endif -
trunk/Source/WebKit2/ChangeLog
r163862 r163863 1 2014-02-10 Alexey Proskuryakov <ap@apple.com> 2 3 Add hooks for wrapping CryptoKeys in SerializedScriptValue 4 https://bugs.webkit.org/show_bug.cgi?id=128567 5 6 Reviewed by Anders Carlsson. 7 8 * UIProcess/WebPageProxy.cpp: 9 (WebKit::WebPageProxy::wrapCryptoKey): 10 (WebKit::WebPageProxy::unwrapCryptoKey): 11 * UIProcess/WebPageProxy.h: 12 * UIProcess/WebPageProxy.messages.in: 13 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 14 (WebKit::WebChromeClient::wrapCryptoKey): 15 (WebKit::WebChromeClient::unwrapCryptoKey): 16 * WebProcess/WebCoreSupport/WebChromeClient.h: 17 Dummy implementation, to be filled in later. 18 1 19 2014-02-10 Dan Bernstein <mitz@apple.com> 2 20 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r163860 r163863 4480 4480 } 4481 4481 4482 #if ENABLE(SUBTLE_CRYPTO) 4483 void WebPageProxy::wrapCryptoKey(const Vector<uint8_t>& key, bool& succeeded, Vector<uint8_t>& wrappedKey) 4484 { 4485 // FIXME: Implement. 4486 wrappedKey = key; 4487 succeeded = true; 4488 } 4489 4490 void WebPageProxy::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, bool& succeeded, Vector<uint8_t>& key) 4491 { 4492 // FIXME: Implement. 4493 key = wrappedKey; 4494 succeeded = true; 4495 } 4496 #endif 4497 4482 4498 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r163836 r163863 888 888 #endif 889 889 890 #if ENABLE(SUBTLE_CRYPTO) 891 void wrapCryptoKey(const Vector<uint8_t>&, bool& succeeded, Vector<uint8_t>&); 892 void unwrapCryptoKey(const Vector<uint8_t>&, bool& succeeded, Vector<uint8_t>&); 893 #endif 894 890 895 private: 891 896 WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r163516 r163863 335 335 336 336 DidSaveToPageCache() 337 338 #if ENABLE(SUBTLE_CRYPTO) 339 WrapCryptoKey(Vector<uint8_t> key) -> (bool succeeded, Vector<uint8_t> wrappedKey) 340 UnwrapCryptoKey(Vector<uint8_t> wrappedKey) -> (bool succeeded, Vector<uint8_t> key) 341 #endif 337 342 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r163724 r163863 939 939 } 940 940 941 #if ENABLE(SUBTLE_CRYPTO) 942 bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) const 943 { 944 bool succeeded; 945 if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::WrapCryptoKey(key), Messages::WebPageProxy::WrapCryptoKey::Reply(succeeded, wrappedKey), m_page->pageID())) 946 return false; 947 return succeeded; 948 } 949 950 bool WebChromeClient::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) const 951 { 952 bool succeeded; 953 if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::UnwrapCryptoKey(wrappedKey), Messages::WebPageProxy::UnwrapCryptoKey::Reply(succeeded, key), m_page->pageID())) 954 return false; 955 return succeeded; 956 } 957 #endif 958 959 941 960 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
r163724 r163863 271 271 virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) const override; 272 272 273 #if ENABLE(SUBTLE_CRYPTO) 274 virtual bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override; 275 virtual bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const override; 276 #endif 277 273 278 String m_cachedToolTip; 274 279 mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
Note: See TracChangeset
for help on using the changeset viewer.