Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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.


Canonical link: https://commits.webkit.org/146781@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164042 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aproskuryakov committed Feb 13, 2014
1 parent 14367dc commit c3e1cac
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
13 changes: 13 additions & 0 deletions Source/WebKit/mac/ChangeLog
@@ -1,3 +1,16 @@
2014-02-13 Alexey Proskuryakov <ap@apple.com>

[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 <mitz@apple.com>

iOS build fix.
Expand Down
20 changes: 16 additions & 4 deletions Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Expand Up @@ -1002,15 +1002,27 @@ - (NSRect)_growBoxRect;
#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
2 changes: 2 additions & 0 deletions Source/WebKit/mac/WebView/WebUIDelegatePrivate.h
Expand Up @@ -267,4 +267,6 @@ extern NSString *WebConsoleMessageErrorMessageLevel;
- (BOOL)webViewCanCheckGeolocationAuthorizationStatus:(WebView *)sender;
#endif

- (NSData *)webCryptoMasterKeyForWebView:(WebView *)sender;

@end
10 changes: 10 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,13 @@
2014-02-13 Alexey Proskuryakov <ap@apple.com>

[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 <svillar@igalia.com>

Unreviewed. Moved myself to the list of reviewers.
Expand Down
6 changes: 6 additions & 0 deletions Tools/DumpRenderTree/mac/UIDelegate.mm
Expand Up @@ -349,6 +349,12 @@ - (void)webView:(WebView *)webView decidePolicyForUserMediaRequestFromOrigin:(We
[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)
Expand Down

0 comments on commit c3e1cac

Please sign in to comment.