Changeset 163999 in webkit


Ignore:
Timestamp:
Feb 12, 2014 4:39:21 PM (10 years ago)
Author:
ap@apple.com
Message:

[WK2] Add a C API to get WebCrypto master key from a client
https://bugs.webkit.org/show_bug.cgi?id=128702

Reviewed by Anders Carlsson.

Source/WebKit2:

Added a new version of WKContextClient, with a function that returns the key.

  • UIProcess/API/C/WKContext.h:
  • UIProcess/WebContextClient.cpp:

(WebKit::WebContextClient::copyWebCryptoMasterKey):

  • UIProcess/WebContextClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::wrapCryptoKey):
(WebKit::WebPageProxy::unwrapCryptoKey):

  • UIProcess/mac/WebPageProxyMac.mm:

Tools:

  • WebKitTestRunner/TestController.cpp:

(WTR::copyWebCryptoMasterKey):
(WTR::TestController::initialize):
Return a hardcoded key.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r163997 r163999  
     12014-02-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [WK2] Add a C API to get WebCrypto master key from a client
     4        https://bugs.webkit.org/show_bug.cgi?id=128702
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Added a new version of WKContextClient, with a function that returns the key.
     9
     10        * UIProcess/API/C/WKContext.h:
     11        * UIProcess/WebContextClient.cpp:
     12        (WebKit::WebContextClient::copyWebCryptoMasterKey):
     13        * UIProcess/WebContextClient.h:
     14        * UIProcess/WebPageProxy.cpp:
     15        (WebKit::WebPageProxy::wrapCryptoKey):
     16        (WebKit::WebPageProxy::unwrapCryptoKey):
     17        * UIProcess/mac/WebPageProxyMac.mm:
     18
    1192014-02-12  Anders Carlsson  <andersca@apple.com>
    220
  • trunk/Source/WebKit2/UIProcess/API/C/WKContext.h

    r160940 r163999  
    4848typedef void (*WKContextNetworkProcessDidCrashCallback)(WKContextRef context, const void *clientInfo);
    4949typedef void (*WKContextPlugInInformationBecameAvailableCallback)(WKContextRef context, WKArrayRef plugIn, const void *clientInfo);
     50typedef WKDataRef (*WKContextCopyWebCryptoMasterKeyCallback)(WKContextRef context, const void *clientInfo);
    5051
    5152typedef struct WKContextClientBase {
     
    6364} WKContextClientV0;
    6465
    65 enum { kWKContextClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
     66typedef struct WKContextClientV1 {
     67    WKContextClientBase                                                 base;
     68
     69    // Version 0.
     70    WKContextPlugInAutoStartOriginHashesChangedCallback                 plugInAutoStartOriginHashesChanged;
     71    WKContextNetworkProcessDidCrashCallback                             networkProcessDidCrash;
     72    WKContextPlugInInformationBecameAvailableCallback                   plugInInformationBecameAvailable;
     73
     74    // Version 1.
     75    WKContextCopyWebCryptoMasterKeyCallback                             copyWebCryptoMasterKey;
     76} WKContextClientV1;
     77
     78enum { kWKContextClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 1 };
    6679typedef struct WKContextClient {
    6780    int                                                                 version;
  • trunk/Source/WebKit2/UIProcess/WebContextClient.cpp

    r159988 r163999  
    5959}
    6060
     61PassRefPtr<API::Data> WebContextClient::copyWebCryptoMasterKey(WebContext* context)
     62{
     63    if (!m_client.copyWebCryptoMasterKey)
     64        return nullptr;
     65
     66    return adoptRef(toImpl(m_client.copyWebCryptoMasterKey(toAPI(context), m_client.base.clientInfo)));
     67}
     68
    6169} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebContextClient.h

    r159994 r163999  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#include "APIClient.h"
     30#include "APIData.h"
    3031#include "WKContext.h"
    3132
     
    3435
    3536template<> struct ClientTraits<WKContextClientBase> {
    36     typedef std::tuple<WKContextClientV0> Versions;
     37    typedef std::tuple<WKContextClientV0, WKContextClientV1> Versions;
    3738};
    3839}
     
    4748    void networkProcessDidCrash(WebContext*);
    4849    void plugInInformationBecameAvailable(WebContext*, API::Array*);
     50    PassRefPtr<API::Data> copyWebCryptoMasterKey(WebContext*);
    4951};
    5052
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r163992 r163999  
    44844484void WebPageProxy::wrapCryptoKey(const Vector<uint8_t>& key, bool& succeeded, Vector<uint8_t>& wrappedKey)
    44854485{
    4486     Vector<uint8_t> masterKey(16);
    4487     memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
     4486    RefPtr<API::Data> keyData = m_process->context().client().copyWebCryptoMasterKey(&m_process->context());
     4487    if (!keyData) {
     4488        succeeded = false;
     4489        return;
     4490    }
     4491
     4492    Vector<uint8_t> masterKey = keyData->dataReference().vector();
    44884493    succeeded = wrapSerializedCryptoKey(masterKey, key, wrappedKey);
    44894494}
     
    44914496void WebPageProxy::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, bool& succeeded, Vector<uint8_t>& key)
    44924497{
    4493     Vector<uint8_t> masterKey(16);
    4494     memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
     4498    RefPtr<API::Data> keyData = m_process->context().client().copyWebCryptoMasterKey(&m_process->context());
     4499    if (!keyData) {
     4500        succeeded = false;
     4501        return;
     4502    }
     4503
     4504    Vector<uint8_t> masterKey = keyData->dataReference().vector();
    44954505    succeeded = unwrapSerializedCryptoKey(masterKey, wrappedKey, key);
    44964506}
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r163992 r163999  
    4040#import "TextChecker.h"
    4141#import "WKBrowsingContextControllerInternal.h"
     42#import "WebContext.h"
    4243#import "WebPageMessages.h"
    4344#import "WebProcessProxy.h"
  • trunk/Tools/ChangeLog

    r163998 r163999  
     12014-02-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [WK2] Add a C API to get WebCrypto master key from a client
     4        https://bugs.webkit.org/show_bug.cgi?id=128702
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebKitTestRunner/TestController.cpp:
     9        (WTR::copyWebCryptoMasterKey):
     10        (WTR::TestController::initialize):
     11        Return a hardcoded key.
     12
    1132014-02-12  David Farler  <dfarler@apple.com>
    214
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r163821 r163999  
    8080    static WKURLRef staticBlankURL = WKURLCreateWithUTF8CString("about:blank");
    8181    return staticBlankURL;
     82}
     83
     84static WKDataRef copyWebCryptoMasterKey(WKContextRef, const void*)
     85{
     86    // Any 128 bit key would do, all we need for testing is to implement the callback.
     87    return WKDataCreate((const uint8_t*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", 16);
    8288}
    8389
     
    336342
    337343    platformInitializeContext();
     344
     345    WKContextClientV1 contextClient = {
     346        { 1, this },
     347        nullptr, // plugInAutoStartOriginHashesChanged
     348        nullptr, // networkProcessDidCrash,
     349        nullptr, // plugInInformationBecameAvailable,
     350        copyWebCryptoMasterKey
     351    };
     352    WKContextSetClient(m_context.get(), &contextClient.base);
    338353
    339354    WKContextInjectedBundleClientV1 injectedBundleClient = {
Note: See TracChangeset for help on using the changeset viewer.