Changeset 163976 in webkit


Ignore:
Timestamp:
Feb 12, 2014 1:08:40 PM (10 years ago)
Author:
ap@apple.com
Message:

Wrap WebCrypto keys in SerializedScriptValue
https://bugs.webkit.org/show_bug.cgi?id=128680

Reviewed by Anders Carlsson.

Source/WebCore:

Test: crypto/subtle/rsa-indexeddb.html

Added Mac code to wrap a key with AES-GCM. We then serialize it into a plist,
because more custom formats would be crazy (even the custom format in SerializedScriptValue
makes me nervous, we'll certainly need to change CryptoKey in the future).

  • WebCore.exp.in:
  • WebCore.xcodeproj/project.pbxproj:
  • crypto/CommonCryptoUtilities.h:
  • crypto/SerializedCryptoKeyWrap.h: Added.
  • crypto/mac/SerializedCryptoKeyWrapMac.mm: Added.

(WebCore::vectorFromNSData):
(WebCore::wrapSerializedCryptoKey):
(WebCore::unwrapSerializedCryptoKey):

Source/WebKit/mac:

Retrieve a master key (placeholder code for now), and use it to wrap key data.

  • WebCoreSupport/WebChromeClient.mm:

(WebChromeClient::wrapCryptoKey):
(WebChromeClient::unwrapCryptoKey):

Source/WebKit2:

Retrieve a master key (placeholder code for now), and use it to wrap key data.

  • UIProcess/WebPageProxy.cpp:

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

  • UIProcess/mac/WebPageProxyMac.mm:

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

LayoutTests:

  • crypto/subtle/rsa-indexeddb-expected.txt: Added.
  • crypto/subtle/rsa-indexeddb.html: Added.
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:
  • platform/mac-wk1/TestExpectations:
  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:
Location:
trunk
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163974 r163976  
     12014-02-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Wrap WebCrypto keys in SerializedScriptValue
     4        https://bugs.webkit.org/show_bug.cgi?id=128680
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * crypto/subtle/rsa-indexeddb-expected.txt: Added.
     9        * crypto/subtle/rsa-indexeddb.html: Added.
     10        * platform/efl/TestExpectations:
     11        * platform/gtk/TestExpectations:
     12        * platform/mac-wk1/TestExpectations:
     13        * platform/win/TestExpectations:
     14        * platform/wincairo/TestExpectations:
     15
    1162014-02-12  Brendan Long  <b.long@cablelabs.com>
    217
  • trunk/LayoutTests/platform/efl/TestExpectations

    r163953 r163976  
    272272webkit.org/b/87661 http/tests/security/cross-origin-worker-indexeddb.html [ Skip ]
    273273webkit.org/b/87661 http/tests/security/no-indexeddb-from-sandbox.html [ Skip ]
     274webkit.org/b/87661 crypto/subtle/rsa-indexeddb.html [ Skip ]
    274275
    275276#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r163891 r163976  
    494494webkit.org/b/107194 http/tests/security/cross-origin-worker-indexeddb.html [ Skip ]
    495495webkit.org/b/107194 http/tests/security/no-indexeddb-from-sandbox.html [ Skip ]
     496crypto/subtle/rsa-indexeddb.html
    496497
    497498# crypto.subtle is not yet enabled
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r163968 r163976  
    66http/tests/security/cross-origin-worker-indexeddb.html
    77http/tests/security/no-indexeddb-from-sandbox.html
     8crypto/subtle/rsa-indexeddb.html
  • trunk/LayoutTests/platform/win/TestExpectations

    r163924 r163976  
    10851085http/tests/security/cross-origin-worker-indexeddb.html
    10861086http/tests/security/no-indexeddb-from-sandbox.html
     1087crypto/subtle/rsa-indexeddb.html
    10871088
    10881089# StorageTracker is not enabled.
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r163619 r163976  
    15821582http/tests/security/cross-origin-worker-indexeddb.html
    15831583http/tests/security/no-indexeddb-from-sandbox.html
     1584crypto/subtle/rsa-indexeddb.html
    15841585
    15851586# StorageTracker is not enabled.
  • trunk/Source/WebCore/ChangeLog

    r163975 r163976  
     12014-02-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Wrap WebCrypto keys in SerializedScriptValue
     4        https://bugs.webkit.org/show_bug.cgi?id=128680
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Test: crypto/subtle/rsa-indexeddb.html
     9
     10        Added Mac code to wrap a key with AES-GCM. We then serialize it into a plist,
     11        because more custom formats would be crazy (even the custom format in SerializedScriptValue
     12        makes me nervous, we'll certainly need to change CryptoKey in the future).
     13
     14        * WebCore.exp.in:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * crypto/CommonCryptoUtilities.h:
     17        * crypto/SerializedCryptoKeyWrap.h: Added.
     18        * crypto/mac/SerializedCryptoKeyWrapMac.mm: Added.
     19        (WebCore::vectorFromNSData):
     20        (WebCore::wrapSerializedCryptoKey):
     21        (WebCore::unwrapSerializedCryptoKey):
     22
    1232014-02-12  Brent Fulgham  <bfulgham@apple.com>
    224
  • trunk/Source/WebCore/WebCore.exp.in

    r163975 r163976  
    912912__ZN7WebCore23getFileModificationTimeERKN3WTF6StringERl
    913913__ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
     914__ZN7WebCore23wrapSerializedCryptoKeyERKN3WTF6VectorIhLm0ENS0_15CrashOnOverflowEEES5_RS3_
    914915__ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
    915916__ZN7WebCore24DocumentMarkerController10markersForEPNS_4NodeENS_14DocumentMarker11MarkerTypesE
     
    934935__ZN7WebCore25computeViewportAttributesENS_17ViewportArgumentsEiiifNS_7IntSizeE
    935936__ZN7WebCore25createCanonicalUUIDStringEv
     937__ZN7WebCore25unwrapSerializedCryptoKeyERKN3WTF6VectorIhLm0ENS0_15CrashOnOverflowEEES5_RS3_
    936938__ZN7WebCore26ContextDestructionObserver16contextDestroyedEv
    937939__ZN7WebCore26ContextDestructionObserverC2EPNS_22ScriptExecutionContextE
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r163974 r163976  
    57855785                E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = E187056216E54A0D00585E97 /* MainThreadTask.h */; };
    57865786                E18772F1126E2629003DD586 /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18772F0126E2629003DD586 /* Language.cpp */; };
     5787                E18DF33518AAF12C00773E59 /* SerializedCryptoKeyWrap.h in Headers */ = {isa = PBXBuildFile; fileRef = E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */; settings = {ATTRIBUTES = (Private, ); }; };
     5788                E18DF33818AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E18DF33618AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm */; };
    57875789                E19727161820549E00592D51 /* CryptoKeyType.h in Headers */ = {isa = PBXBuildFile; fileRef = E19727151820549E00592D51 /* CryptoKeyType.h */; };
    57885790                E19AC3EE1824DC7900349426 /* CryptoAlgorithmSHA224.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E19AC3E61824DC7900349426 /* CryptoAlgorithmSHA224.cpp */; };
     
    1307713079                E187056216E54A0D00585E97 /* MainThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainThreadTask.h; sourceTree = "<group>"; };
    1307813080                E18772F0126E2629003DD586 /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Language.cpp; sourceTree = "<group>"; };
     13081                E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedCryptoKeyWrap.h; sourceTree = "<group>"; };
     13082                E18DF33618AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SerializedCryptoKeyWrapMac.mm; path = mac/SerializedCryptoKeyWrapMac.mm; sourceTree = "<group>"; };
    1307913083                E19727151820549E00592D51 /* CryptoKeyType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyType.h; sourceTree = "<group>"; };
    1308013084                E19AC3E61824DC7900349426 /* CryptoAlgorithmSHA224.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmSHA224.cpp; sourceTree = "<group>"; };
     
    2103621040                                E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */,
    2103721041                                E1FE13621834351100892F13 /* CryptoDigestMac.cpp */,
     21042                                E18DF33618AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm */,
    2103821043                        );
    2103921044                        name = mac;
     
    2123721242                                E19727151820549E00592D51 /* CryptoKeyType.h */,
    2123821243                                E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */,
     21244                                E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */,
    2123921245                                E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */,
    2124021246                                E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */,
     
    2343723443                                15C770A6100D41CD005BA267 /* DOMValidityState.h in Headers */,
    2343823444                                BC1A37C0097C715F0019F3D8 /* DOMViews.h in Headers */,
     23445                                E18DF33518AAF12C00773E59 /* SerializedCryptoKeyWrap.h in Headers */,
    2343923446                                31C0FF490E4CEFDD007D6FE5 /* DOMWebKitAnimationEvent.h in Headers */,
    2344023447                                31C0FF4B0E4CEFDD007D6FE5 /* DOMWebKitAnimationEventInternal.h in Headers */,
     
    2632126328                                E1FE137A184D21BB00892F13 /* CryptoAlgorithmAES_KW.cpp in Sources */,
    2632226329                                512DD8F70D91E6AF000F89EE /* ArchiveResourceCollection.cpp in Sources */,
     26330                                E18DF33818AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm in Sources */,
    2632326331                                49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */,
    2632426332                                FD5686C913AC180200B69C68 /* AsyncAudioDecoder.cpp in Sources */,
  • trunk/Source/WebCore/crypto/CommonCryptoUtilities.h

    r160503 r163976  
    9090extern "C" CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength);
    9191extern "C" CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key);
     92extern "C" CCCryptorStatus CCCryptorGCM(CCOperation op, CCAlgorithm alg, const void* key, size_t keyLength, const void* iv, size_t ivLen, const void* aData, size_t aDataLen, const void* dataIn, size_t dataInLength, void* dataOut, const void* tag, size_t* tagLength);
    9293
    9394namespace WebCore {
  • trunk/Source/WebKit/mac/ChangeLog

    r163920 r163976  
     12014-02-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Wrap WebCrypto keys in SerializedScriptValue
     4        https://bugs.webkit.org/show_bug.cgi?id=128680
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Retrieve a master key (placeholder code for now), and use it to wrap key data.
     9
     10        * WebCoreSupport/WebChromeClient.mm:
     11        (WebChromeClient::wrapCryptoKey):
     12        (WebChromeClient::unwrapCryptoKey):
     13
    1142014-02-11  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm

    r163883 r163976  
    8080#import <WebCore/PlatformScreen.h>
    8181#import <WebCore/ResourceRequest.h>
     82#import <WebCore/SerializedCryptoKeyWrap.h>
    8283#import <WebCore/Widget.h>
    8384#import <WebCore/WindowFeatures.h>
     
    10021003bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) const
    10031004{
    1004     wrappedKey = key;
    1005     return true;
     1005    Vector<uint8_t> masterKey(16);
     1006    memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
     1007    return wrapSerializedCryptoKey(masterKey, key, wrappedKey);
    10061008}
    10071009
    10081010bool WebChromeClient::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) const
    10091011{
    1010     key = wrappedKey;
    1011     return true;
    1012 }
    1013 #endif
     1012    Vector<uint8_t> masterKey(16);
     1013    memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
     1014    return unwrapSerializedCryptoKey(masterKey, wrappedKey, key);
     1015}
     1016#endif
  • trunk/Source/WebKit2/ChangeLog

    r163972 r163976  
     12014-02-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Wrap WebCrypto keys in SerializedScriptValue
     4        https://bugs.webkit.org/show_bug.cgi?id=128680
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Retrieve a master key (placeholder code for now), and use it to wrap key data.
     9
     10        * UIProcess/WebPageProxy.cpp:
     11        (WebKit::WebPageProxy::wrapCryptoKey):
     12        (WebKit::WebPageProxy::unwrapCryptoKey):
     13        * UIProcess/mac/WebPageProxyMac.mm:
     14        (WebKit::WebPageProxy::wrapCryptoKey):
     15        (WebKit::WebPageProxy::unwrapCryptoKey):
     16
    1172014-02-12  Zan Dobersek  <zdobersek@igalia.com>
    218
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r163959 r163976  
    44804480}
    44814481
    4482 #if ENABLE(SUBTLE_CRYPTO)
     4482#if ENABLE(SUBTLE_CRYPTO) && !PLATFORM(COCOA)
    44834483void WebPageProxy::wrapCryptoKey(const Vector<uint8_t>& key, bool& succeeded, Vector<uint8_t>& wrappedKey)
    44844484{
    4485     // FIXME: Implement.
    4486     wrappedKey = key;
    4487     succeeded = true;
     4485    notImplemented();
     4486    succeeded = false;
    44884487}
    44894488
    44904489void WebPageProxy::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, bool& succeeded, Vector<uint8_t>& key)
    44914490{
    4492     // FIXME: Implement.
    4493     key = wrappedKey;
    4494     succeeded = true;
     4491    notImplemented();
     4492    succeeded = false;
    44954493}
    44964494#endif
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r163480 r163976  
    4545#import <WebCore/GraphicsLayer.h>
    4646#import <WebCore/RuntimeApplicationChecks.h>
     47#import <WebCore/SerializedCryptoKeyWrap.h>
    4748#import <WebCore/SharedBuffer.h>
    4849#import <WebCore/TextAlternativeWithRange.h>
     
    573574}
    574575
     576#if ENABLE(SUBTLE_CRYPTO)
     577void WebPageProxy::wrapCryptoKey(const Vector<uint8_t>& key, bool& succeeded, Vector<uint8_t>& wrappedKey)
     578{
     579    Vector<uint8_t> masterKey(16);
     580    memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
     581    succeeded = wrapSerializedCryptoKey(masterKey, key, wrappedKey);
     582}
     583
     584void WebPageProxy::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, bool& succeeded, Vector<uint8_t>& key)
     585{
     586    Vector<uint8_t> masterKey(16);
     587    memset(masterKey.data(), 0, masterKey.size()); // FIXME: Not implemented yet, will be getting a key from client.
     588    succeeded = unwrapSerializedCryptoKey(masterKey, wrappedKey, key);
     589}
     590#endif
     591
    575592} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.