Changeset 158236 in webkit
- Timestamp:
- Oct 29, 2013, 4:12:43 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r158235 r158236 1 2013-10-29 Alexey Proskuryakov <ap@apple.com> 2 3 Beef up CryptoKey 4 https://bugs.webkit.org/show_bug.cgi?id=123462 5 6 Reviewed by Sam Weinig. 7 8 * WebCore.xcodeproj/project.pbxproj: Added new files. 9 10 * crypto/CryptoAlgorithmIdentifier.h: Added an enum with all registered algorithms 11 (they don't have to be all implemented in any port). 12 13 * crypto/CryptoKey.cpp: 14 (WebCore::CryptoKey::CryptoKey): Initialize base class variables. 15 (WebCore::CryptoKey::type): Convert internal representation for bindings use. 16 (WebCore::CryptoKey::buildAlgorithmDescription): Ditto. This function is supposed 17 to be called by derived classes before adding other keyes. 18 (WebCore::CryptoKey::usages): Convert internal representation for bindings use. 19 20 * crypto/CryptoKey.h: 21 (WebCore::CryptoKey::extractable): Expose for bindings. 22 (WebCore::CryptoKey::allows): A faster way to check allowed key usage from C++ code. 23 24 * crypto/CryptoKey.idl: Added SkipVTableValidation, because validation doesn't work 25 with derived classes. Corrected "usages" attribute name. 26 27 * crypto/CryptoKeyFormat.h: Added. 28 * crypto/CryptoKeyType.h: Added. 29 * crypto/CryptoKeyUsage.h: Added. 30 Added enums used by CryptoKey. 31 1 32 2013-10-29 Hugo Parente Lima <hugo.lima@openbossa.org> 2 33 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r158232 r158236 5559 5559 E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E16A84F714C85CCC002977DF /* CSSBorderImage.cpp */; }; 5560 5560 E16A84FA14C85CCC002977DF /* CSSBorderImage.h in Headers */ = {isa = PBXBuildFile; fileRef = E16A84F814C85CCC002977DF /* CSSBorderImage.h */; }; 5561 E172AF70180F289500FBADB9 /* CryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */; }; 5562 E172AF77180F366C00FBADB9 /* CryptoKeyFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = E172AF76180F366C00FBADB9 /* CryptoKeyFormat.h */; }; 5561 5563 E17B491516A9B094001C8839 /* TransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E17B491316A9B093001C8839 /* TransitionEvent.cpp */; }; 5562 5564 E17B491616A9B094001C8839 /* TransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E17B491416A9B093001C8839 /* TransitionEvent.h */; }; … … 5573 5575 E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = E187056216E54A0D00585E97 /* MainThreadTask.h */; }; 5574 5576 E18772F1126E2629003DD586 /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18772F0126E2629003DD586 /* Language.cpp */; }; 5577 E19727161820549E00592D51 /* CryptoKeyType.h in Headers */ = {isa = PBXBuildFile; fileRef = E19727151820549E00592D51 /* CryptoKeyType.h */; }; 5575 5578 E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */; }; 5576 5579 E1A3162D134BC32D007C9A4F /* WebNSAttributedStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A3162B134BC32D007C9A4F /* WebNSAttributedStringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 5620 5623 E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5621 5624 E1C4DE6E0EA75C650023CCD6 /* ActiveDOMObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */; }; 5625 E1C657251816E69D00256CDD /* CryptoAlgorithmIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C657241816E69D00256CDD /* CryptoAlgorithmIdentifier.h */; }; 5622 5626 E1C8BE5D0E8BD15A0064CB7D /* JSWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */; }; 5623 5627 E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */; }; … … 12560 12564 E16A84F714C85CCC002977DF /* CSSBorderImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSBorderImage.cpp; sourceTree = "<group>"; }; 12561 12565 E16A84F814C85CCC002977DF /* CSSBorderImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSBorderImage.h; sourceTree = "<group>"; }; 12566 E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyUsage.h; sourceTree = "<group>"; }; 12567 E172AF76180F366C00FBADB9 /* CryptoKeyFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyFormat.h; sourceTree = "<group>"; }; 12562 12568 E176580C180DF3A0005A96D1 /* OESElementIndexUint.idl */ = {isa = PBXFileReference; lastKnownFileType = text; name = OESElementIndexUint.idl; path = canvas/OESElementIndexUint.idl; sourceTree = "<group>"; }; 12563 12569 E17B490B16A97269001C8839 /* TransitionEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TransitionEvent.idl; sourceTree = "<group>"; }; … … 12576 12582 E187056216E54A0D00585E97 /* MainThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainThreadTask.h; sourceTree = "<group>"; }; 12577 12583 E18772F0126E2629003DD586 /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Language.cpp; sourceTree = "<group>"; }; 12584 E19727151820549E00592D51 /* CryptoKeyType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyType.h; sourceTree = "<group>"; }; 12578 12585 E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContainerNodeAlgorithms.h; sourceTree = "<group>"; }; 12579 12586 E1A3162B134BC32D007C9A4F /* WebNSAttributedStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNSAttributedStringExtras.h; sourceTree = "<group>"; }; … … 12630 12637 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMObject.h; sourceTree = "<group>"; }; 12631 12638 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActiveDOMObject.cpp; sourceTree = "<group>"; }; 12639 E1C657241816E69D00256CDD /* CryptoAlgorithmIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmIdentifier.h; sourceTree = "<group>"; }; 12632 12640 E1C6CFC21746D293007B87A1 /* DOMWindowConstructors.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowConstructors.idl; sourceTree = "<group>"; }; 12633 12641 E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorker.cpp; sourceTree = "<group>"; }; … … 20231 20239 E157A8EA181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.cpp */, 20232 20240 E157A8EB181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h */, 20241 E1C657241816E69D00256CDD /* CryptoAlgorithmIdentifier.h */, 20233 20242 E157A8DC18172C2C009F821D /* CryptoKey.idl */, 20234 20243 E157A8E218173A3A009F821D /* CryptoKey.cpp */, 20235 20244 E157A8E318173A3A009F821D /* CryptoKey.h */, 20245 E172AF76180F366C00FBADB9 /* CryptoKeyFormat.h */, 20246 E19727151820549E00592D51 /* CryptoKeyType.h */, 20247 E172AF6F180F289500FBADB9 /* CryptoKeyUsage.h */, 20236 20248 E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */, 20237 20249 E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */, … … 22601 22613 658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */, 22602 22614 628D214E12131EF40055DCFC /* FrameNetworkingContext.h in Headers */, 22615 E172AF70180F289500FBADB9 /* CryptoKeyUsage.h in Headers */, 22603 22616 93309E0E099E64920056E581 /* FrameSelection.h in Headers */, 22604 22617 7CE30DAA171B63D200EC33E1 /* FrameSnapshottingMac.h in Headers */, … … 23004 23017 A9D247FF0D757E6900FDF959 /* JSDOMPlugin.h in Headers */, 23005 23018 A9D248010D757E6900FDF959 /* JSDOMPluginArray.h in Headers */, 23019 E19727161820549E00592D51 /* CryptoKeyType.h in Headers */, 23006 23020 BC5A86B60C3367E800EEA649 /* JSDOMSelection.h in Headers */, 23007 23021 4ACBC0CB12713D0A0094F9B2 /* JSDOMSettableTokenList.h in Headers */, … … 23218 23232 1AFE119A0CBFFCC4003017FA /* JSSQLResultSetRowList.h in Headers */, 23219 23233 B59DD6A511902A62007E9684 /* JSSQLStatementCallback.h in Headers */, 23234 E172AF77180F366C00FBADB9 /* CryptoKeyFormat.h in Headers */, 23220 23235 B59DD6A911902A71007E9684 /* JSSQLStatementErrorCallback.h in Headers */, 23221 23236 BC82432A0D0CE8A200460C8F /* JSSQLTransaction.h in Headers */, … … 24606 24621 AAA728F716D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.h in Headers */, 24607 24622 AA478A7F16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.h in Headers */, 24623 E1C657251816E69D00256CDD /* CryptoAlgorithmIdentifier.h in Headers */, 24608 24624 93F199A808245E59001E9ABC /* WebCoreFrameView.h in Headers */, 24609 24625 CDC69DDA16371FD4007C38DF /* WebCoreFullScreenPlaceholderView.h in Headers */, -
trunk/Source/WebCore/crypto/CryptoKey.cpp
r157936 r158236 30 30 31 31 #include "CryptoAlgorithmDescriptionBuilder.h" 32 #include "CryptoAlgorithmRegistry.h" 33 #include <wtf/text/WTFString.h> 32 34 33 35 namespace WebCore { 36 37 CryptoKey::CryptoKey(CryptoAlgorithmIdentifier algorithm, CryptoKeyType type, bool extractable, CryptoKeyUsage usages) 38 : m_algorithm(algorithm) 39 , m_type(type) 40 , m_extractable(extractable) 41 , m_usages(usages) 42 { 43 } 34 44 35 45 CryptoKey::~CryptoKey() … … 37 47 } 38 48 39 void CryptoKey::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& /*builder*/) const49 String CryptoKey::type() const 40 50 { 41 // Will do something like builder.add("name", m_algorithmName); 51 switch (m_type) { 52 case CryptoKeyType::Secret: 53 return ASCIILiteral("secret"); 54 case CryptoKeyType::Public: 55 return ASCIILiteral("public"); 56 case CryptoKeyType::Private: 57 return ASCIILiteral("private"); 58 } 59 } 60 61 void CryptoKey::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const 62 { 63 builder.add("name", CryptoAlgorithmRegistry::shared().nameForIdentifier(m_algorithm)); 42 64 // Subclasses will add other keys. 65 } 66 67 Vector<String> CryptoKey::usages() const 68 { 69 Vector<String> result; 70 if (m_usages & CryptoKeyUsageEncrypt) 71 result.append(ASCIILiteral("encrypt")); 72 if (m_usages & CryptoKeyUsageDecrypt) 73 result.append(ASCIILiteral("decrypt")); 74 if (m_usages & CryptoKeyUsageSign) 75 result.append(ASCIILiteral("sign")); 76 if (m_usages & CryptoKeyUsageVerify) 77 result.append(ASCIILiteral("verify")); 78 if (m_usages & CryptoKeyUsageDeriveKey) 79 result.append(ASCIILiteral("deriveKey")); 80 if (m_usages & CryptoKeyUsageDeriveBits) 81 result.append(ASCIILiteral("deriveBits")); 82 if (m_usages & CryptoKeyUsageWrapKey) 83 result.append(ASCIILiteral("wrapKey")); 84 if (m_usages & CryptoKeyUsageUnwrapKey) 85 result.append(ASCIILiteral("unwrapKey")); 86 87 return result; 43 88 } 44 89 -
trunk/Source/WebCore/crypto/CryptoKey.h
r157936 r158236 27 27 #define CryptoKey_h 28 28 29 #include "CryptoAlgorithmIdentifier.h" 30 #include "CryptoKeyType.h" 31 #include "CryptoKeyUsage.h" 29 32 #include <wtf/Forward.h> 30 33 #include <wtf/RefCounted.h> … … 37 40 class CryptoAlgorithmDescriptionBuilder; 38 41 42 ENUM_CLASS(CryptoKeyType) { 43 Secret, 44 Public, 45 Private 46 }; 47 39 48 class CryptoKey : public RefCounted<CryptoKey> { 40 49 public: 50 CryptoKey(CryptoAlgorithmIdentifier, CryptoKeyType, bool extractable, CryptoKeyUsage); 41 51 virtual ~CryptoKey(); 42 52 43 virtual String type() const = 0;44 virtual bool extractable() const = 0;53 String type() const; 54 bool extractable() const { return m_extractable; } 45 55 virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&) const; 46 virtual Vector<String> usage() const = 0; 56 Vector<String> usages() const; 57 58 bool allows(CryptoKeyUsage usage) const { return usage == (m_usages & usage); } 59 60 private: 61 CryptoAlgorithmIdentifier m_algorithm; 62 CryptoKeyType m_type; 63 bool m_extractable; 64 CryptoKeyUsage m_usages; 47 65 }; 48 66 -
trunk/Source/WebCore/crypto/CryptoKey.idl
r157936 r158236 45 45 InterfaceName=Key, 46 46 NoInterfaceObject, 47 OperationsNotDeletable 47 OperationsNotDeletable, 48 SkipVTableValidation 48 49 ] interface CryptoKey { 49 50 readonly attribute KeyType type; 50 51 readonly attribute boolean extractable; 51 52 [Custom] readonly attribute Algorithm algorithm; 52 readonly attribute KeyUsage[] usage ;53 readonly attribute KeyUsage[] usages; 53 54 };
Note:
See TracChangeset
for help on using the changeset viewer.