Changeset 159068 in webkit


Ignore:
Timestamp:
Nov 11, 2013 1:20:20 PM (10 years ago)
Author:
ap@apple.com
Message:

Support WebCrypto KeyPair interface
https://bugs.webkit.org/show_bug.cgi?id=124161

Reviewed by Geoffrey Garen.

No new tests yet, will be tested once generateKey is implemented for any RSA algorithms.

  • CMakeLists.txt:
  • DerivedSources.make:
  • GNUmakefile.list.am:
  • WebCore.xcodeproj/project.pbxproj:

Added new files.

  • bindings/js/JSDOMPromise.h: Support returning a key pair via a promise.
  • bindings/js/JSCryptoKeyPairCustom.cpp: Added.

(WebCore::JSCryptoKeyPair::visitChildren):

  • crypto/CryptoKey.idl:

CryptoKey wrapper is reachable through KeyPair, but it doesn't have (or need)
a back pointer.

  • crypto/CryptoKeyPair.cpp: Added.

(WebCore::CryptoKeyPair::CryptoKeyPair):
(WebCore::CryptoKeyPair::~CryptoKeyPair):

  • crypto/CryptoKeyPair.h: Added.

(WebCore::CryptoKeyPair::create):
(WebCore::CryptoKeyPair::publicKey):
(WebCore::CryptoKeyPair::privateKey):

  • crypto/CryptoKeyPair.idl: Added.
Location:
trunk/Source/WebCore
Files:
7 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r159001 r159068  
    282282
    283283    crypto/CryptoKey.idl
     284    crypto/CryptoKeyPair.idl
    284285    crypto/SubtleCrypto.idl
    285286
  • trunk/Source/WebCore/ChangeLog

    r159065 r159068  
     12013-11-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Support WebCrypto KeyPair interface
     4        https://bugs.webkit.org/show_bug.cgi?id=124161
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        No new tests yet, will be tested once generateKey is implemented for any RSA algorithms.
     9
     10        * CMakeLists.txt:
     11        * DerivedSources.make:
     12        * GNUmakefile.list.am:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        Added new files.
     15
     16        * bindings/js/JSDOMPromise.h: Support returning a key pair via a promise.
     17
     18        * bindings/js/JSCryptoKeyPairCustom.cpp: Added.
     19        (WebCore::JSCryptoKeyPair::visitChildren):
     20        * crypto/CryptoKey.idl:
     21        CryptoKey wrapper is reachable through KeyPair, but it doesn't have (or need)
     22        a back pointer.
     23
     24        * crypto/CryptoKeyPair.cpp: Added.
     25        (WebCore::CryptoKeyPair::CryptoKeyPair):
     26        (WebCore::CryptoKeyPair::~CryptoKeyPair):
     27        * crypto/CryptoKeyPair.h: Added.
     28        (WebCore::CryptoKeyPair::create):
     29        (WebCore::CryptoKeyPair::publicKey):
     30        (WebCore::CryptoKeyPair::privateKey):
     31        * crypto/CryptoKeyPair.idl: Added.
     32
    1332013-11-11  Nick Diego Yamane  <nick.yamane@openbossa.org>
    234
  • trunk/Source/WebCore/DerivedSources.make

    r158821 r159068  
    200200    $(WebCore)/Modules/websockets/WebSocket.idl \
    201201    $(WebCore)/crypto/CryptoKey.idl \
     202    $(WebCore)/crypto/CryptoKeyPair.idl \
    202203    $(WebCore)/crypto/SubtleCrypto.idl \
    203204    $(WebCore)/css/CSSCharsetRule.idl \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r159001 r159068  
    153153        DerivedSources/WebCore/JSCryptoKey.cpp \
    154154        DerivedSources/WebCore/JSCryptoKey.h \
     155        DerivedSources/WebCore/JSCryptoKeyPair.cpp \
     156        DerivedSources/WebCore/JSCryptoKeyPair.h \
    155157        DerivedSources/WebCore/JSCustomEvent.cpp \
    156158        DerivedSources/WebCore/JSCustomEvent.h \
     
    12921294        $(WebCore)/Modules/websockets/WebSocket.idl \
    12931295        $(WebCore)/crypto/CryptoKey.idl \
     1296        $(WebCore)/crypto/CryptoKeyPair.idl \
    12941297        $(WebCore)/crypto/SubtleCrypto.idl \
    12951298        $(WebCore)/css/CSSCharsetRule.idl \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r159001 r159068  
    56995699                E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */; };
    57005700                E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */; };
     5701                E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B8518317252007885C3 /* CryptoKeyPair.cpp */; };
     5702                E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8618317252007885C3 /* CryptoKeyPair.h */; };
     5703                E1F80B8A183172A2007885C3 /* JSCryptoKeyPairCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */; };
     5704                E1F80B8D183172B5007885C3 /* JSCryptoKeyPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */; };
     5705                E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */; };
    57015706                E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    57025707                E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
     
    1278112786                E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTExtensions.cpp; sourceTree = "<group>"; };
    1278212787                E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTExtensions.h; sourceTree = "<group>"; };
     12788                E1F80B8418317247007885C3 /* CryptoKeyPair.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CryptoKeyPair.idl; sourceTree = "<group>"; };
     12789                E1F80B8518317252007885C3 /* CryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyPair.cpp; sourceTree = "<group>"; };
     12790                E1F80B8618317252007885C3 /* CryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyPair.h; sourceTree = "<group>"; };
     12791                E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPairCustom.cpp; sourceTree = "<group>"; };
     12792                E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPair.cpp; sourceTree = "<group>"; };
     12793                E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeyPair.h; sourceTree = "<group>"; };
    1278312794                E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; };
    1278412795                E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; };
     
    1958319594                                209B456A16796A7E00E54E4E /* JSCryptoCustom.cpp */,
    1958419595                                E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */,
     19596                                E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */,
    1958519597                                BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
    1958619598                                AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */,
     
    2048620498                                E157A8E318173A3A009F821D /* CryptoKey.h */,
    2048720499                                E125F85D182C2DF600D84CD9 /* CryptoKeyData.h */,
     20500                                E1F80B8518317252007885C3 /* CryptoKeyPair.cpp */,
     20501                                E1F80B8618317252007885C3 /* CryptoKeyPair.h */,
     20502                                E1F80B8418317247007885C3 /* CryptoKeyPair.idl */,
    2048820503                                E125F855182C0F8300D84CD9 /* CryptoKeySerialization.h */,
    2048920504                                E19727151820549E00592D51 /* CryptoKeyType.h */,
     
    2050120516                                E157A8DE1817331C009F821D /* JSCryptoKey.cpp */,
    2050220517                                E157A8DF1817331C009F821D /* JSCryptoKey.h */,
     20518                                E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */,
     20519                                E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */,
    2050320520                                E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */,
    2050420521                                E1FF8F63180745D800132674 /* JSSubtleCrypto.h */,
     
    2218122198                                BC772B3C0C4EA91E0083285F /* CSSHelper.h in Headers */,
    2218222199                                FB49C39D16784947007FFB5D /* CSSHostRule.h in Headers */,
     22200                                E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */,
    2218322201                                BC23EE920DAED2BC009FDC91 /* CSSImageGeneratorValue.h in Headers */,
    2218422202                                9393E600151A99F200066F06 /* CSSImageSetValue.h in Headers */,
     
    2421624234                                BCEA488C097D93020094C9E4 /* RenderText.h in Headers */,
    2421724235                                AB67D1A9097F3AE300F9392E /* RenderTextControl.h in Headers */,
     24236                                E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */,
    2421824237                                083DAEA70F01A7FB00342754 /* RenderTextControlMultiLine.h in Headers */,
    2421924238                                083DAEA90F01A7FB00342754 /* RenderTextControlSingleLine.h in Headers */,
     
    2584525864                                85CA96B90A9621A600690CCF /* DOMEntity.mm in Sources */,
    2584625865                                85089CDE0A98C42800A275AA /* DOMEntityReference.mm in Sources */,
     25866                                E1F80B8D183172B5007885C3 /* JSCryptoKeyPair.cpp in Sources */,
    2584725867                                BC1BDF24156C1883001C1243 /* DOMError.cpp in Sources */,
    2584825868                                85AFA8230AAF528A00E84305 /* DOMEvent.mm in Sources */,
     
    2637826398                                4F707A9911EF679400ACDA69 /* InspectorBackendDispatcher.cpp in Sources */,
    2637926399                                7AA51B6F1483B61600AD2752 /* InspectorBaseAgent.cpp in Sources */,
     26400                                E1F80B8A183172A2007885C3 /* JSCryptoKeyPairCustom.cpp in Sources */,
    2638026401                                AAD766EB157E502F00E85423 /* InspectorCanvasAgent.cpp in Sources */,
    2638126402                                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
     
    2747627497                                51D719E9181106E00016DC51 /* IDBPendingTransactionMonitor.cpp in Sources */,
    2747727498                                FD3160AC12B026F700C1A359 /* ReverbInputBuffer.cpp in Sources */,
     27499                                E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */,
    2747827500                                BC74DA381013F3F7007987AD /* RGBColor.cpp in Sources */,
    2747927501                                A8CFF5E70A155A05000A4234 /* RootInlineBox.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSCryptoKeyPairCustom.cpp

    r159067 r159068  
    2424 */
    2525
    26 enum KeyType {
    27     "secret",
    28     "public",
    29     "private"
    30 };
     26#include "config.h"
     27#include "JSCryptoKeyPair.h"
    3128
    32 enum KeyUsage {
    33     "encrypt",
    34     "decrypt",
    35     "sign",
    36     "verify",
    37     "deriveKey",
    38     "deriveBits",
    39     "wrapKey",
    40     "unwrapKey"
    41 };
     29#if ENABLE(SUBTLE_CRYPTO)
    4230
    43 [
    44     Conditional=SUBTLE_CRYPTO,
    45     InterfaceName=Key,
    46     NoInterfaceObject,
    47     SkipVTableValidation
    48 ] interface CryptoKey {
    49     readonly attribute KeyType type;
    50     readonly attribute boolean extractable;
    51     [Custom] readonly attribute Algorithm algorithm;
    52     readonly attribute KeyUsage[] usages;
    53 };
     31using namespace JSC;
     32
     33namespace WebCore {
     34
     35void JSCryptoKeyPair::visitChildren(JSCell* cell, SlotVisitor& visitor)
     36{
     37    JSCryptoKeyPair* thisObject = jsCast<JSCryptoKeyPair*>(cell);
     38    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
     39    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
     40    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
     41    Base::visitChildren(thisObject, visitor);
     42
     43    visitor.addOpaqueRoot(thisObject->m_impl->publicKey());
     44    visitor.addOpaqueRoot(thisObject->m_impl->privateKey());
     45}
     46
     47} // namespace WebCore
     48
     49#endif // ENABLE(SUBTLE_CRYPTO)
  • trunk/Source/WebCore/bindings/js/JSDOMPromise.h

    r158485 r159068  
    2828
    2929#include "JSCryptoKey.h"
     30#include "JSCryptoKeyPair.h"
    3031#include "JSDOMBinding.h"
    3132#include <runtime/JSGlobalObject.h>
  • trunk/Source/WebCore/crypto/CryptoKey.idl

    r159061 r159068  
    4343[
    4444    Conditional=SUBTLE_CRYPTO,
     45    GenerateIsReachable=Impl,
    4546    InterfaceName=Key,
    4647    NoInterfaceObject,
  • trunk/Source/WebCore/crypto/CryptoKeyPair.cpp

    r159067 r159068  
    2424 */
    2525
    26 enum KeyType {
    27     "secret",
    28     "public",
    29     "private"
    30 };
     26#include "config.h"
     27#include "CryptoKeyPair.h"
    3128
    32 enum KeyUsage {
    33     "encrypt",
    34     "decrypt",
    35     "sign",
    36     "verify",
    37     "deriveKey",
    38     "deriveBits",
    39     "wrapKey",
    40     "unwrapKey"
    41 };
     29#if ENABLE(SUBTLE_CRYPTO)
    4230
    43 [
    44     Conditional=SUBTLE_CRYPTO,
    45     InterfaceName=Key,
    46     NoInterfaceObject,
    47     SkipVTableValidation
    48 ] interface CryptoKey {
    49     readonly attribute KeyType type;
    50     readonly attribute boolean extractable;
    51     [Custom] readonly attribute Algorithm algorithm;
    52     readonly attribute KeyUsage[] usages;
    53 };
     31namespace WebCore {
     32
     33CryptoKeyPair::CryptoKeyPair(PassRefPtr<CryptoKey> publicKey, PassRefPtr<CryptoKey> privateKey)
     34    : m_publicKey(publicKey)
     35    , m_privateKey(privateKey)
     36{
     37}
     38
     39CryptoKeyPair::~CryptoKeyPair()
     40{
     41}
     42
     43} // namespace WebCore
     44
     45#endif // ENABLE(SUBTLE_CRYPTO)
  • trunk/Source/WebCore/crypto/CryptoKeyPair.h

    r159067 r159068  
    2424 */
    2525
    26 enum KeyType {
    27     "secret",
    28     "public",
    29     "private"
     26#ifndef CryptoKeyPair_h
     27#define CryptoKeyPair_h
     28
     29#include "CryptoKey.h"
     30#include <wtf/PassRefPtr.h>
     31#include <wtf/RefCounted.h>
     32#include <wtf/RefPtr.h>
     33
     34#if ENABLE(SUBTLE_CRYPTO)
     35
     36namespace WebCore {
     37
     38class CryptoKeyPair : public RefCounted<CryptoKeyPair> {
     39public:
     40    static PassRefPtr<CryptoKeyPair> create(PassRefPtr<CryptoKey> publicKey, PassRefPtr<CryptoKey> privateKey)
     41    {
     42        return adoptRef(new CryptoKeyPair(publicKey, privateKey));
     43    }
     44    ~CryptoKeyPair();
     45
     46    CryptoKey* publicKey() { return m_publicKey.get(); }
     47    CryptoKey* privateKey() { return m_privateKey.get(); }
     48
     49private:
     50    CryptoKeyPair(PassRefPtr<CryptoKey> publicKey, PassRefPtr<CryptoKey> privateKey);
     51
     52    RefPtr<CryptoKey> m_publicKey;
     53    RefPtr<CryptoKey> m_privateKey;
    3054};
    3155
    32 enum KeyUsage {
    33     "encrypt",
    34     "decrypt",
    35     "sign",
    36     "verify",
    37     "deriveKey",
    38     "deriveBits",
    39     "wrapKey",
    40     "unwrapKey"
    41 };
     56} // namespace WebCore
    4257
    43 [
    44     Conditional=SUBTLE_CRYPTO,
    45     InterfaceName=Key,
    46     NoInterfaceObject,
    47     SkipVTableValidation
    48 ] interface CryptoKey {
    49     readonly attribute KeyType type;
    50     readonly attribute boolean extractable;
    51     [Custom] readonly attribute Algorithm algorithm;
    52     readonly attribute KeyUsage[] usages;
    53 };
     58#endif // ENABLE(SUBTLE_CRYPTO)
     59#endif // CryptoKeyPair_h
  • trunk/Source/WebCore/crypto/CryptoKeyPair.idl

    r159067 r159068  
    2424 */
    2525
    26 enum KeyType {
    27     "secret",
    28     "public",
    29     "private"
    30 };
    31 
    32 enum KeyUsage {
    33     "encrypt",
    34     "decrypt",
    35     "sign",
    36     "verify",
    37     "deriveKey",
    38     "deriveBits",
    39     "wrapKey",
    40     "unwrapKey"
    41 };
    42 
    4326[
    4427    Conditional=SUBTLE_CRYPTO,
    45     InterfaceName=Key,
     28    ImplementationLacksVTable,
     29    InterfaceName=KeyPair,
     30    JSCustomMarkFunction,
    4631    NoInterfaceObject,
    47     SkipVTableValidation
    48 ] interface CryptoKey {
    49     readonly attribute KeyType type;
    50     readonly attribute boolean extractable;
    51     [Custom] readonly attribute Algorithm algorithm;
    52     readonly attribute KeyUsage[] usages;
     32    OperationsNotDeletable
     33] interface CryptoKeyPair {
     34    readonly attribute CryptoKey publicKey;
     35    readonly attribute CryptoKey privateKey;
    5336};
Note: See TracChangeset for help on using the changeset viewer.