Title: [164042] trunk
Revision
164042
Author
[email protected]
Date
2014-02-13 11:32:32 -0800 (Thu, 13 Feb 2014)

Log Message

[Mac] Add a WebKit1 SPI to get WebCrypto master key from a client
https://bugs.webkit.org/show_bug.cgi?id=128725

Reviewed by Anders Carlsson.

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::wrapCryptoKey):
(WebChromeClient::unwrapCryptoKey):
* WebView/WebUIDelegatePrivate.h:
Looks like UIDelegate is the closest we have to a reasonable place.

Tools:

* DumpRenderTree/mac/UIDelegate.mm: (-[UIDelegate webCryptoMasterKeyForWebView:]):
Use the SPI to specify a key.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (164041 => 164042)


--- trunk/Source/WebKit/mac/ChangeLog	2014-02-13 18:56:16 UTC (rev 164041)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-02-13 19:32:32 UTC (rev 164042)
@@ -1,3 +1,16 @@
+2014-02-13  Alexey Proskuryakov  <[email protected]>
+
+        [Mac] Add a WebKit1 SPI to get WebCrypto master key from a client
+        https://bugs.webkit.org/show_bug.cgi?id=128725
+
+        Reviewed by Anders Carlsson.
+
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::wrapCryptoKey):
+        (WebChromeClient::unwrapCryptoKey):
+        * WebView/WebUIDelegatePrivate.h:
+        Looks like UIDelegate is the closest we have to a reasonable place.
+
 2014-02-13  Dan Bernstein  <[email protected]>
 
         iOS build fix.

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm (164041 => 164042)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm	2014-02-13 18:56:16 UTC (rev 164041)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm	2014-02-13 19:32:32 UTC (rev 164042)
@@ -1002,15 +1002,27 @@
 #if ENABLE(SUBTLE_CRYPTO)
 bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) const
 {
-    Vector<uint8_t> masterKey(16);
-    memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
+    SEL selector = @selector(webCryptoMasterKeyForWebView:);
+    if (![[m_webView UIDelegate] respondsToSelector:selector])
+        return false;
+
+    NSData* keyData = CallUIDelegate(m_webView, selector);
+
+    Vector<uint8_t> masterKey;
+    masterKey.append((uint8_t*)[keyData bytes], [keyData length]);
     return wrapSerializedCryptoKey(masterKey, key, wrappedKey);
 }
 
 bool WebChromeClient::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) const
 {
-    Vector<uint8_t> masterKey(16);
-    memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
+    SEL selector = @selector(webCryptoMasterKeyForWebView:);
+    if (![[m_webView UIDelegate] respondsToSelector:selector])
+        return false;
+
+    NSData *keyData = CallUIDelegate(m_webView, selector);
+
+    Vector<uint8_t> masterKey;
+    masterKey.append((uint8_t*)[keyData bytes], [keyData length]);
     return unwrapSerializedCryptoKey(masterKey, wrappedKey, key);
 }
 #endif

Modified: trunk/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h (164041 => 164042)


--- trunk/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h	2014-02-13 18:56:16 UTC (rev 164041)
+++ trunk/Source/WebKit/mac/WebView/WebUIDelegatePrivate.h	2014-02-13 19:32:32 UTC (rev 164042)
@@ -267,4 +267,6 @@
 - (BOOL)webViewCanCheckGeolocationAuthorizationStatus:(WebView *)sender;
 #endif
 
+- (NSData *)webCryptoMasterKeyForWebView:(WebView *)sender;
+
 @end

Modified: trunk/Tools/ChangeLog (164041 => 164042)


--- trunk/Tools/ChangeLog	2014-02-13 18:56:16 UTC (rev 164041)
+++ trunk/Tools/ChangeLog	2014-02-13 19:32:32 UTC (rev 164042)
@@ -1,3 +1,13 @@
+2014-02-13  Alexey Proskuryakov  <[email protected]>
+
+        [Mac] Add a WebKit1 SPI to get WebCrypto master key from a client
+        https://bugs.webkit.org/show_bug.cgi?id=128725
+
+        Reviewed by Anders Carlsson.
+
+        * DumpRenderTree/mac/UIDelegate.mm: (-[UIDelegate webCryptoMasterKeyForWebView:]):
+        Use the SPI to specify a key.
+
 2014-02-13  Sergio Villar Senin  <[email protected]>
 
         Unreviewed. Moved myself to the list of reviewers.

Modified: trunk/Tools/DumpRenderTree/mac/UIDelegate.mm (164041 => 164042)


--- trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2014-02-13 18:56:16 UTC (rev 164041)
+++ trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2014-02-13 19:32:32 UTC (rev 164042)
@@ -349,6 +349,12 @@
     [listener allow];
 }
 
+- (NSData *)webCryptoMasterKeyForWebView:(WebView *)sender
+{
+    // Any 128 bit key would do, all we need for testing is to implement the callback.
+    return [NSData dataWithBytes:"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" length:16];
+}
+
 - (void)dealloc
 {
 #if !PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to