Changeset 213628 in webkit
- Timestamp:
- Mar 8, 2017 9:50:31 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 2 deleted
- 29 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r213626 r213628 1 2017-03-08 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebCrypto] Implement SubtleCrypto::DeriveKey method 4 https://bugs.webkit.org/show_bug.cgi?id=169386 5 <rdar://problem/23789585> 6 7 Reviewed by Brent Fulgham. 8 9 * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt: 10 * crypto/subtle/derive-key-malformed-parameters-expected.txt: Added. 11 * crypto/subtle/derive-key-malformed-parameters.html: Added. 12 * crypto/subtle/deriveKey-malformed-parameters-expected.txt: Removed. 13 * crypto/subtle/deriveKey-malformed-parameters.html: Removed. 14 * crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt: Added. 15 * crypto/subtle/ecdh-import-key-derive-aes-key.html: Added. 16 * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt: Added. 17 * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html: Added. 18 * crypto/subtle/unwrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt. 19 * crypto/subtle/unwrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html. 20 * crypto/subtle/wrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt. 21 * crypto/subtle/wrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html. 22 A bit renaming. 23 * crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt: Added. 24 * crypto/workers/subtle/ecdh-import-key-derive-key.html: Added. 25 * crypto/workers/subtle/resources/ecdh-import-key-derive-key.js: Added. 26 1 27 2017-03-08 Matt Baker <mattbaker@apple.com> 2 28 -
trunk/LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters-expected.txt
r213345 r213628 4 4 5 5 6 PASS crypto.subtle.generateKey("aes-cbc", extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKey GenParams.length is required and must be an instance of unsigned short.7 PASS crypto.subtle.generateKey({name: "aes-cbc"}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKey GenParams.length is required and must be an instance of unsigned short.6 PASS crypto.subtle.generateKey("aes-cbc", extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short. 7 PASS crypto.subtle.generateKey({name: "aes-cbc"}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short. 8 8 PASS crypto.subtle.generateKey({name: "aes-cbc", length: true}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason. 9 9 PASS crypto.subtle.generateKey({name: "aes-cbc", length: null}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason. 10 PASS crypto.subtle.generateKey({name: "aes-cbc", length: undefined}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKey GenParams.length is required and must be an instance of unsigned short.10 PASS crypto.subtle.generateKey({name: "aes-cbc", length: undefined}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short. 11 11 PASS crypto.subtle.generateKey({name: "aes-cbc", length: Symbol()}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Cannot convert a symbol to a number. 12 12 PASS crypto.subtle.generateKey({name: "aes-cbc", length: { }}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason. -
trunk/Source/WebCore/CMakeLists.txt
r213624 r213628 343 343 crypto/parameters/AesCbcCfbParams.idl 344 344 crypto/parameters/AesGcmParams.idl 345 crypto/parameters/AesKey GenParams.idl345 crypto/parameters/AesKeyParams.idl 346 346 crypto/parameters/EcKeyParams.idl 347 347 crypto/parameters/EcdhKeyDeriveParams.idl -
trunk/Source/WebCore/ChangeLog
r213627 r213628 1 2017-03-08 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebCrypto] Implement SubtleCrypto::DeriveKey method 4 https://bugs.webkit.org/show_bug.cgi?id=169386 5 <rdar://problem/23789585> 6 7 Reviewed by Brent Fulgham. 8 9 This patch does following few things: 10 1. It implements SubtleCrypto::DeriveKey method according to the spec: 11 https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveKey. 12 2. It implements getKeyLength operations for AES-CBC, AES-KW, AES-CFB, 13 AES-GCM, and HMAC, which is needed by the SubtleCrypto::DeriveKey method. 14 3. It enables ECDH DeriveKey operation. 15 4. It replaces unigned long with size_t in all the crypto codes. 16 17 Tests: crypto/subtle/derive-key-malformed-parameters.html 18 crypto/subtle/ecdh-import-key-derive-aes-key.html 19 crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html 20 crypto/subtle/unwrap-key-malformed-parameters.html 21 crypto/subtle/wrap-key-malformed-parameters.html 22 crypto/workers/subtle/ecdh-import-key-derive-key.html 23 24 * CMakeLists.txt: 25 * DerivedSources.make: 26 * WebCore.xcodeproj/project.pbxproj: 27 * bindings/js/JSSubtleCryptoCustom.cpp: 28 (WebCore::normalizeCryptoAlgorithmParameters): 29 (WebCore::jsSubtleCryptoFunctionEncryptPromise): 30 (WebCore::jsSubtleCryptoFunctionDecryptPromise): 31 (WebCore::jsSubtleCryptoFunctionSignPromise): 32 (WebCore::jsSubtleCryptoFunctionVerifyPromise): 33 (WebCore::jsSubtleCryptoFunctionDigestPromise): 34 (WebCore::jsSubtleCryptoFunctionDeriveKeyPromise): 35 (WebCore::jsSubtleCryptoFunctionDeriveBitsPromise): 36 Remove unnecessary return statement from callbacks. 37 * crypto/CryptoAlgorithm.cpp: 38 (WebCore::CryptoAlgorithm::deriveBits): 39 (WebCore::CryptoAlgorithm::getKeyLength): 40 * crypto/CryptoAlgorithm.h: 41 * crypto/CryptoAlgorithmParameters.h: 42 * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: 43 (WebCore::CryptoAlgorithmAES_CBC::generateKey): 44 (WebCore::CryptoAlgorithmAES_CBC::getKeyLength): 45 * crypto/algorithms/CryptoAlgorithmAES_CBC.h: 46 * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp: 47 (WebCore::CryptoAlgorithmAES_CFB::generateKey): 48 (WebCore::CryptoAlgorithmAES_CFB::getKeyLength): 49 * crypto/algorithms/CryptoAlgorithmAES_CFB.h: 50 * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp: 51 (WebCore::CryptoAlgorithmAES_GCM::generateKey): 52 (WebCore::CryptoAlgorithmAES_GCM::getKeyLength): 53 * crypto/algorithms/CryptoAlgorithmAES_GCM.h: 54 * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: 55 (WebCore::CryptoAlgorithmAES_KW::generateKey): 56 (WebCore::CryptoAlgorithmAES_KW::getKeyLength): 57 * crypto/algorithms/CryptoAlgorithmAES_KW.h: 58 * crypto/algorithms/CryptoAlgorithmECDH.cpp: 59 (WebCore::CryptoAlgorithmECDH::deriveBits): 60 * crypto/algorithms/CryptoAlgorithmECDH.h: 61 * crypto/algorithms/CryptoAlgorithmHMAC.cpp: 62 (WebCore::CryptoAlgorithmHMAC::getKeyLength): 63 * crypto/algorithms/CryptoAlgorithmHMAC.h: 64 * crypto/keys/CryptoKeyAES.cpp: 65 (WebCore::CryptoKeyAES::getKeyLength): 66 * crypto/keys/CryptoKeyAES.h: 67 * crypto/keys/CryptoKeyHMAC.cpp: 68 (WebCore::getKeyLengthFromHash): 69 (WebCore::CryptoKeyHMAC::generate): 70 (WebCore::CryptoKeyHMAC::getKeyLength): 71 * crypto/keys/CryptoKeyHMAC.h: 72 * crypto/mac/CryptoAlgorithmECDHMac.cpp: 73 (WebCore::CryptoAlgorithmECDH::platformDeriveBits): 74 * crypto/parameters/AesKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/AesKeyGenParams.idl. 75 * crypto/parameters/CryptoAlgorithmAesKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h. 76 Rename AesKeyGenParams to AesKeyParams to represent a unified dictionary for AesKeyGenParams and AesDerivedKeyParams. 77 * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: 78 * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: 79 1 80 2017-03-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 81 -
trunk/Source/WebCore/DerivedSources.make
r213624 r213628 275 275 $(WebCore)/crypto/parameters/AesCbcCfbParams.idl \ 276 276 $(WebCore)/crypto/parameters/AesGcmParams.idl \ 277 $(WebCore)/crypto/parameters/AesKey GenParams.idl \277 $(WebCore)/crypto/parameters/AesKeyParams.idl \ 278 278 $(WebCore)/crypto/parameters/EcKeyParams.idl \ 279 279 $(WebCore)/crypto/parameters/EcdhKeyDeriveParams.idl \ -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r213624 r213628 2383 2383 576814401E709FA100E77754 /* JSEcdhKeyDeriveParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5768143D1E709C3600E77754 /* JSEcdhKeyDeriveParams.cpp */; }; 2384 2384 576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; }; 2385 576814441E70CB1B00E77754 /* JSAesKeyParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576814421E70CB1000E77754 /* JSAesKeyParams.cpp */; }; 2386 576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814431E70CB1000E77754 /* JSAesKeyParams.h */; }; 2385 2387 5768E4341DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */; }; 2386 2388 5768E4361DB7527400D0A4F7 /* JSRsaHashedKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */; }; 2387 577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */; }; 2388 577483141DAEC2EB00716EF9 /* JSAesKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */; }; 2389 577483161DAEC32300716EF9 /* JSAesKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */; }; 2389 577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h */; }; 2390 2390 577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */; }; 2391 2391 5778BD821DA4806C009E3009 /* SubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 5778BD811DA4802C009E3009 /* SubtleCrypto.h */; }; … … 9817 9817 5768143D1E709C3600E77754 /* JSEcdhKeyDeriveParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEcdhKeyDeriveParams.cpp; sourceTree = "<group>"; }; 9818 9818 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEcdhKeyDeriveParams.h; sourceTree = "<group>"; }; 9819 576814421E70CB1000E77754 /* JSAesKeyParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesKeyParams.cpp; sourceTree = "<group>"; }; 9820 576814431E70CB1000E77754 /* JSAesKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesKeyParams.h; sourceTree = "<group>"; }; 9819 9821 5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaHashedKeyGenParams.h; sourceTree = "<group>"; }; 9820 9822 5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaHashedKeyGenParams.cpp; sourceTree = "<group>"; }; 9821 577483101DADC49900716EF9 /* AesKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesKeyGenParams.idl; sourceTree = "<group>"; }; 9822 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; }; 9823 577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesKeyGenParams.h; sourceTree = "<group>"; }; 9824 577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesKeyGenParams.cpp; sourceTree = "<group>"; }; 9823 577483101DADC49900716EF9 /* AesKeyParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesKeyParams.idl; sourceTree = "<group>"; }; 9824 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyParams.h; sourceTree = "<group>"; }; 9825 9825 577483171DB1FE8900716EF9 /* HmacKeyParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HmacKeyParams.idl; sourceTree = "<group>"; }; 9826 9826 577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmHmacKeyParams.h; sourceTree = "<group>"; }; … … 10002 10002 5DB1BC6910715A6400EFAA49 /* TransformSourceLibxslt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformSourceLibxslt.cpp; sourceTree = "<group>"; }; 10003 10003 5DFEBAB618592B6D00C75BEB /* WebKitAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAvailability.h; sourceTree = "<group>"; }; 10004 5E16A2E21BFA64FB0029A21E /* MediaEndpointPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = MediaEndpointPeerConnection.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };10005 5E16A2E31BFA64FB0029A21E /* MediaEndpointPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MediaEndpointPeerConnection.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };10004 5E16A2E21BFA64FB0029A21E /* MediaEndpointPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEndpointPeerConnection.cpp; sourceTree = "<group>"; }; 10005 5E16A2E31BFA64FB0029A21E /* MediaEndpointPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEndpointPeerConnection.h; sourceTree = "<group>"; }; 10006 10006 5E2C434D1BCEE2E50001E2BC /* PeerConnectionBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PeerConnectionBackend.h; sourceTree = "<group>"; }; 10007 10007 5E2C43541BCEE30D0001E2BC /* RTCPeerConnection.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = RTCPeerConnection.js; sourceTree = "<group>"; }; … … 23683 23683 572093D11DDCEA4B00310AB0 /* AesCbcCfbParams.idl */, 23684 23684 57B5F8071E5D19F200F34F90 /* AesGcmParams.idl */, 23685 577483101DADC49900716EF9 /* AesKey GenParams.idl */,23685 577483101DADC49900716EF9 /* AesKeyParams.idl */, 23686 23686 572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h */, 23687 23687 E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParamsDeprecated.h */, 23688 23688 57B5F8081E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h */, 23689 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKey GenParams.h */,23689 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h */, 23690 23690 E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h */, 23691 23691 5750A97D1E6A13EF00705C4A /* CryptoAlgorithmEcKeyParams.h */, … … 23868 23868 57B5F80A1E5D22DA00F34F90 /* JSAesGcmParams.cpp */, 23869 23869 57B5F80B1E5D22DA00F34F90 /* JSAesGcmParams.h */, 23870 57 7483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */,23871 57 7483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */,23870 576814421E70CB1000E77754 /* JSAesKeyParams.cpp */, 23871 576814431E70CB1000E77754 /* JSAesKeyParams.h */, 23872 23872 5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */, 23873 23873 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */, … … 25883 25883 572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h in Headers */, 25884 25884 E125F83A1824104800D84CD9 /* CryptoAlgorithmAesCbcParamsDeprecated.h in Headers */, 25885 577483121DADC55D00716EF9 /* CryptoAlgorithmAesKey GenParams.h in Headers */,25885 577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h in Headers */, 25886 25886 E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h in Headers */, 25887 25887 E125F8321822F11B00D84CD9 /* CryptoAlgorithmHMAC.h in Headers */, … … 26738 26738 07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */, 26739 26739 418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */, 26740 577483141DAEC2EB00716EF9 /* JSAesKeyGenParams.h in Headers */,26741 26740 FDA15ECA12B03F50003A583A /* JSAnalyserNode.h in Headers */, 26742 26741 12A253E31C8FFF6600C22295 /* JSAnimatable.h in Headers */, … … 26750 26749 7C6523181E00DBB500677F22 /* JSApplePayPaymentMethod.h in Headers */, 26751 26750 1AE96A8D1D1A0DDD00B86768 /* JSApplePayPaymentMethodSelectedEvent.h in Headers */, 26751 576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */, 26752 26752 7C65231A1E00DBB500677F22 /* JSApplePayPaymentPass.h in Headers */, 26753 26753 7C6579F21E00856600E3A27A /* JSApplePayPaymentRequest.h in Headers */, … … 30585 30585 07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */, 30586 30586 418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */, 30587 577483161DAEC32300716EF9 /* JSAesKeyGenParams.cpp in Sources */,30588 30587 FDA15EC912B03F50003A583A /* JSAnalyserNode.cpp in Sources */, 30589 30588 31A795C61888BADC00382F90 /* JSANGLEInstancedArrays.cpp in Sources */, … … 30848 30847 A6148A7812E41E3B0044A784 /* JSHTMLKeygenElement.cpp in Sources */, 30849 30848 1AE2AB210A1CE63B00B42B25 /* JSHTMLLabelElement.cpp in Sources */, 30849 576814441E70CB1B00E77754 /* JSAesKeyParams.cpp in Sources */, 30850 30850 1AE2AB230A1CE63B00B42B25 /* JSHTMLLegendElement.cpp in Sources */, 30851 30851 1AE2AB250A1CE63B00B42B25 /* JSHTMLLIElement.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
r213624 r213628 33 33 #include "JSAesCbcCfbParams.h" 34 34 #include "JSAesGcmParams.h" 35 #include "JSAesKey GenParams.h"35 #include "JSAesKeyParams.h" 36 36 #include "JSCryptoAlgorithmParameters.h" 37 37 #include "JSCryptoKey.h" … … 62 62 Verify, 63 63 Digest, 64 DeriveKey,64 GenerateKey, 65 65 DeriveBits, 66 GenerateKey,67 66 ImportKey, 68 67 WrapKey, 69 UnwrapKey 68 UnwrapKey, 69 GetKeyLength 70 70 }; 71 71 … … 161 161 } 162 162 break; 163 case Operations::DeriveKey:164 throwNotSupportedError(state, scope);165 return nullptr;166 163 case Operations::DeriveBits: 167 164 switch (*identifier) { … … 208 205 case CryptoAlgorithmIdentifier::AES_CFB: 209 206 case CryptoAlgorithmIdentifier::AES_KW: { 210 auto params = convertDictionary<CryptoAlgorithmAesKey GenParams>(state, value);211 RETURN_IF_EXCEPTION(scope, nullptr); 212 result = std::make_unique<CryptoAlgorithmAesKey GenParams>(params);207 auto params = convertDictionary<CryptoAlgorithmAesKeyParams>(state, value); 208 RETURN_IF_EXCEPTION(scope, nullptr); 209 result = std::make_unique<CryptoAlgorithmAesKeyParams>(params); 213 210 break; 214 211 } … … 282 279 result = std::make_unique<CryptoAlgorithmParameters>(params); 283 280 break; 281 default: 282 throwNotSupportedError(state, scope); 283 return nullptr; 284 } 285 break; 286 case Operations::GetKeyLength: 287 switch (*identifier) { 288 case CryptoAlgorithmIdentifier::AES_CTR: 289 case CryptoAlgorithmIdentifier::AES_CBC: 290 case CryptoAlgorithmIdentifier::AES_CMAC: 291 case CryptoAlgorithmIdentifier::AES_GCM: 292 case CryptoAlgorithmIdentifier::AES_CFB: 293 case CryptoAlgorithmIdentifier::AES_KW: { 294 auto params = convertDictionary<CryptoAlgorithmAesKeyParams>(state, value); 295 RETURN_IF_EXCEPTION(scope, nullptr); 296 result = std::make_unique<CryptoAlgorithmAesKeyParams>(params); 297 break; 298 } 299 case CryptoAlgorithmIdentifier::HMAC: { 300 auto params = convertDictionary<CryptoAlgorithmHmacKeyParams>(state, value); 301 RETURN_IF_EXCEPTION(scope, nullptr); 302 params.hashIdentifier = toHashIdentifier(state, params.hash); 303 RETURN_IF_EXCEPTION(scope, nullptr); 304 result = std::make_unique<CryptoAlgorithmHmacKeyParams>(params); 305 break; 306 } 284 307 default: 285 308 throwNotSupportedError(state, scope); … … 488 511 auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& cipherText) mutable { 489 512 fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), cipherText.data(), cipherText.size()); 490 return;491 513 }; 492 514 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { … … 536 558 auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& plainText) mutable { 537 559 fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), plainText.data(), plainText.size()); 538 return;539 560 }; 540 561 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { … … 584 605 auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& signature) mutable { 585 606 fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), signature.data(), signature.size()); 586 return;587 607 }; 588 608 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { … … 635 655 auto callback = [capturedPromise = promise.copyRef()](bool result) mutable { 636 656 capturedPromise->resolve<IDLBoolean>(result); 637 return;638 657 }; 639 658 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { … … 670 689 auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& digest) mutable { 671 690 fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), digest.data(), digest.size()); 672 return;673 691 }; 674 692 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { … … 744 762 } 745 763 746 auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::DeriveKey); 747 RETURN_IF_EXCEPTION(scope, void()); 748 749 // We should always return a NOT_SUPPORTED_ERR since we currently don't support any algorithms that has deriveKey operation. 750 ASSERT_NOT_REACHED(); 764 auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::DeriveBits); 765 RETURN_IF_EXCEPTION(scope, void()); 766 767 auto baseKey = toCryptoKey(state, state.uncheckedArgument(1)); 768 RETURN_IF_EXCEPTION(scope, void()); 769 770 auto importParams = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(2), Operations::ImportKey); 771 RETURN_IF_EXCEPTION(scope, void()); 772 773 auto getLengthParams = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(2), Operations::GetKeyLength); 774 RETURN_IF_EXCEPTION(scope, void()); 775 776 auto extractable = state.uncheckedArgument(3).toBoolean(&state); 777 RETURN_IF_EXCEPTION(scope, void()); 778 779 auto keyUsages = cryptoKeyUsageBitmapFromJSValue(state, state.uncheckedArgument(4)); 780 RETURN_IF_EXCEPTION(scope, void()); 781 782 if (params->identifier != baseKey->algorithmIdentifier()) { 783 promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't match AlgorithmIdentifier")); 784 return; 785 } 786 787 if (!baseKey->allows(CryptoKeyUsageDeriveKey)) { 788 promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't support CryptoKey derivation")); 789 return; 790 } 791 792 auto getLengthAlgorithm = CryptoAlgorithmRegistry::singleton().create(getLengthParams->identifier); 793 if (UNLIKELY(!getLengthAlgorithm)) { 794 throwNotSupportedError(state, scope); 795 return; 796 } 797 auto result = getLengthAlgorithm->getKeyLength(*getLengthParams); 798 if (result.hasException()) { 799 promise->reject(result.releaseException().code(), ASCIILiteral("Cannot get key length from derivedKeyType")); 800 return; 801 } 802 size_t length = result.releaseReturnValue(); 803 804 auto importAlgorithm = CryptoAlgorithmRegistry::singleton().create(importParams->identifier); 805 if (UNLIKELY(!importAlgorithm)) { 806 throwNotSupportedError(state, scope); 807 return; 808 } 809 810 auto algorithm = CryptoAlgorithmRegistry::singleton().create(params->identifier); 811 if (UNLIKELY(!algorithm)) { 812 throwNotSupportedError(state, scope); 813 return; 814 } 815 816 auto callback = [promise = promise.copyRef(), importAlgorithm, importParams = WTFMove(importParams), extractable, keyUsages](const Vector<uint8_t>& derivedKey) mutable { 817 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395 818 KeyData data = derivedKey; 819 auto callback = [capturedPromise = promise.copyRef()](CryptoKey& key) mutable { 820 if ((key.type() == CryptoKeyType::Private || key.type() == CryptoKeyType::Secret) && !key.usagesBitmap()) { 821 rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR); 822 return; 823 } 824 capturedPromise->resolve<IDLInterface<CryptoKey>>(key); 825 }; 826 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { 827 rejectWithException(WTFMove(capturedPromise), ec); 828 }; 829 830 importAlgorithm->importKey(SubtleCrypto::KeyFormat::Raw, WTFMove(data), WTFMove(importParams), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback)); 831 }; 832 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { 833 rejectWithException(WTFMove(capturedPromise), ec); 834 }; 835 836 auto subtle = jsDynamicDowncast<JSSubtleCrypto*>(vm, state.thisValue()); 837 ASSERT(subtle); 838 algorithm->deriveBits(WTFMove(params), baseKey.releaseNonNull(), length, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue()); 751 839 } 752 840 … … 788 876 auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& derivedKey) mutable { 789 877 fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), derivedKey.data(), derivedKey.size()); 790 return;791 878 }; 792 879 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { -
trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp
r213624 r213628 63 63 } 64 64 65 void CryptoAlgorithm::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, unsigned long, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)65 void CryptoAlgorithm::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 66 66 { 67 67 exceptionCallback(NOT_SUPPORTED_ERR); … … 86 86 { 87 87 exceptionCallback(NOT_SUPPORTED_ERR); 88 } 89 90 ExceptionOr<size_t> CryptoAlgorithm::getKeyLength(const CryptoAlgorithmParameters&) 91 { 92 return Exception { NOT_SUPPORTED_ERR }; 88 93 } 89 94 … … 123 128 } 124 129 125 ExceptionOr<void> CryptoAlgorithm::deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, unsigned long, VectorCallback&&, VoidCallback&&)130 ExceptionOr<void> CryptoAlgorithm::deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, size_t, VectorCallback&&, VoidCallback&&) 126 131 { 127 132 return Exception { NOT_SUPPORTED_ERR }; -
trunk/Source/WebCore/crypto/CryptoAlgorithm.h
r213624 r213628 62 62 using KeyCallback = WTF::Function<void(CryptoKey&)>; 63 63 using KeyOrKeyPairCallback = WTF::Function<void(KeyOrKeyPair&&)>; 64 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395 64 65 using VectorCallback = WTF::Function<void(const Vector<uint8_t>&)>; 65 66 using VoidCallback = WTF::Function<void()>; … … 73 74 virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 74 75 virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&); 75 virtual void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, unsigned longlength, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);76 virtual void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 76 77 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169262 77 78 virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&); … … 79 80 virtual void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&); 80 81 virtual void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&); 82 virtual ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&); 81 83 82 84 // The following will be deprecated. … … 88 90 virtual ExceptionOr<void> generateKey(const CryptoAlgorithmParametersDeprecated&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, VoidCallback&& failureCallback, ScriptExecutionContext&); 89 91 virtual ExceptionOr<void> deriveKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& baseKey, CryptoAlgorithm* derivedKeyType, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback); 90 virtual ExceptionOr<void> deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& baseKey, unsigned longlength, VectorCallback&&, VoidCallback&& failureCallback);92 virtual ExceptionOr<void> deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& baseKey, size_t length, VectorCallback&&, VoidCallback&& failureCallback); 91 93 virtual ExceptionOr<void> importKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKeyData&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback); 92 94 -
trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h
r213624 r213628 40 40 AesCbcCfbParams, 41 41 AesGcmParams, 42 AesKey GenParams,42 AesKeyParams, 43 43 EcKeyParams, 44 44 EcdhKeyDeriveParams, -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
r212736 r213628 31 31 #include "CryptoAlgorithmAesCbcCfbParams.h" 32 32 #include "CryptoAlgorithmAesCbcParamsDeprecated.h" 33 #include "CryptoAlgorithmAesKeyGenParams.h"34 33 #include "CryptoAlgorithmAesKeyGenParamsDeprecated.h" 34 #include "CryptoAlgorithmAesKeyParams.h" 35 35 #include "CryptoKeyAES.h" 36 36 #include "CryptoKeyDataOctetSequence.h" … … 91 91 void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 92 92 { 93 const auto& aesParameters = downcast<CryptoAlgorithmAesKey GenParams>(parameters);93 const auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters); 94 94 95 95 if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) { … … 187 187 } 188 188 189 ExceptionOr<size_t> CryptoAlgorithmAES_CBC::getKeyLength(const CryptoAlgorithmParameters& parameters) 190 { 191 return CryptoKeyAES::getKeyLength(parameters); 192 } 193 189 194 ExceptionOr<void> CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParametersDeprecated& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback) 190 195 { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h
r209077 r213628 50 50 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 51 51 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 52 53 53 54 ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp
r212736 r213628 30 30 31 31 #include "CryptoAlgorithmAesCbcCfbParams.h" 32 #include "CryptoAlgorithmAesKey GenParams.h"32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 34 #include "ExceptionCode.h" … … 80 80 void CryptoAlgorithmAES_CFB::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 81 81 { 82 const auto& aesParameters = downcast<CryptoAlgorithmAesKey GenParams>(parameters);82 const auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters); 83 83 84 84 if (usagesAreInvalidForCryptoAlgorithmAES_CFB(usages)) { … … 176 176 } 177 177 178 ExceptionOr<size_t> CryptoAlgorithmAES_CFB::getKeyLength(const CryptoAlgorithmParameters& parameters) 179 { 180 return CryptoKeyAES::getKeyLength(parameters); 181 } 182 178 183 } 179 184 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h
r212736 r213628 49 49 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 50 50 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 51 52 52 53 void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp
r213345 r213628 30 30 31 31 #include "CryptoAlgorithmAesGcmParams.h" 32 #include "CryptoAlgorithmAesKey GenParams.h"32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 34 #include "ExceptionCode.h" … … 129 129 void CryptoAlgorithmAES_GCM::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 130 130 { 131 const auto& aesParameters = downcast<CryptoAlgorithmAesKey GenParams>(parameters);131 const auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters); 132 132 133 133 if (usagesAreInvalidForCryptoAlgorithmAES_GCM(usages)) { … … 225 225 } 226 226 227 ExceptionOr<size_t> CryptoAlgorithmAES_GCM::getKeyLength(const CryptoAlgorithmParameters& parameters) 228 { 229 return CryptoKeyAES::getKeyLength(parameters); 230 } 231 227 232 } 228 233 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h
r213345 r213628 49 49 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 50 50 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 51 52 52 53 void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
r212465 r213628 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CryptoAlgorithmAesKeyGenParams.h"32 31 #include "CryptoAlgorithmAesKeyGenParamsDeprecated.h" 32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 34 #include "CryptoKeyDataOctetSequence.h" … … 72 72 } 73 73 74 auto result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, downcast<CryptoAlgorithmAesKey GenParams>(parameters).length, extractable, usages);74 auto result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, downcast<CryptoAlgorithmAesKeyParams>(parameters).length, extractable, usages); 75 75 if (!result) { 76 76 exceptionCallback(OperationError); … … 174 174 } 175 175 176 ExceptionOr<size_t> CryptoAlgorithmAES_KW::getKeyLength(const CryptoAlgorithmParameters& parameters) 177 { 178 return CryptoKeyAES::getKeyLength(parameters); 179 } 180 176 181 ExceptionOr<void> CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback) 177 182 { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h
r209200 r213628 49 49 void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final; 50 50 void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final; 51 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 51 52 52 53 ExceptionOr<void> encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp
r213624 r213628 67 67 } 68 68 69 void CryptoAlgorithmECDH::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, unsigned longlength, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)69 void CryptoAlgorithmECDH::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 70 70 { 71 71 // We only accept length that is a multiple of 8. … … 98 98 } 99 99 100 auto unifiedCallback = [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](std::optional<Vector<uint8_t>>&& derivedKey, unsigned longlength) mutable {100 auto unifiedCallback = [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](std::optional<Vector<uint8_t>>&& derivedKey, size_t length) mutable { 101 101 if (!derivedKey) { 102 102 exceptionCallback(OperationError); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h
r213624 r213628 43 43 44 44 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 45 void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, unsigned longlength, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;45 void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 46 46 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 47 47 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 48 48 49 using Callback = Function<void(std::optional<Vector<uint8_t>>&&, unsigned long)>;50 void platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, unsigned longlength, Callback&&, ScriptExecutionContext&, WorkQueue&);49 using Callback = Function<void(std::optional<Vector<uint8_t>>&&, size_t)>; 50 void platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, size_t length, Callback&&, ScriptExecutionContext&, WorkQueue&); 51 51 }; 52 52 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
r212465 r213628 198 198 } 199 199 200 ExceptionOr<size_t> CryptoAlgorithmHMAC::getKeyLength(const CryptoAlgorithmParameters& parameters) 201 { 202 return CryptoKeyHMAC::getKeyLength(parameters); 203 } 204 200 205 ExceptionOr<void> CryptoAlgorithmHMAC::sign(const CryptoAlgorithmParametersDeprecated& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback) 201 206 { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h
r209150 r213628 50 50 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 51 51 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 52 53 53 54 // The following will be deprecated. -
trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp
r212465 r213628 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CryptoAlgorithmAesKeyParams.h" 31 32 #include "CryptoAlgorithmRegistry.h" 32 33 #include "CryptoKeyDataOctetSequence.h" 34 #include "ExceptionCode.h" 35 #include "ExceptionOr.h" 33 36 #include "JsonWebKey.h" 34 37 #include <wtf/text/Base64.h> … … 115 118 } 116 119 120 ExceptionOr<size_t> CryptoKeyAES::getKeyLength(const CryptoAlgorithmParameters& parameters) 121 { 122 auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters); 123 if (!lengthIsValid(aesParameters.length)) 124 return Exception { OperationError }; 125 return aesParameters.length; 126 } 127 117 128 std::unique_ptr<KeyAlgorithm> CryptoKeyAES::buildAlgorithm() const 118 129 { -
trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h
r212465 r213628 28 28 #include "CryptoAlgorithmIdentifier.h" 29 29 #include "CryptoKey.h" 30 #include "ExceptionOr.h" 30 31 #include <wtf/Function.h> 31 32 #include <wtf/Vector.h> … … 34 35 35 36 namespace WebCore { 37 38 class CryptoAlgorithmParameters; 36 39 37 40 struct JsonWebKey; … … 77 80 JsonWebKey exportJwk() const; 78 81 82 static ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&); 83 79 84 private: 80 85 CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector<uint8_t>& key, bool extractable, CryptoKeyUsageBitmap); -
trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp
r213560 r213628 32 32 #include "CryptoAlgorithmRegistry.h" 33 33 #include "CryptoKeyDataOctetSequence.h" 34 #include "ExceptionCode.h" 35 #include "ExceptionOr.h" 34 36 #include "JsonWebKey.h" 35 37 #include <wtf/text/Base64.h> … … 37 39 38 40 namespace WebCore { 41 42 static size_t getKeyLengthFromHash(CryptoAlgorithmIdentifier hash) 43 { 44 switch (hash) { 45 case CryptoAlgorithmIdentifier::SHA_1: 46 case CryptoAlgorithmIdentifier::SHA_224: 47 case CryptoAlgorithmIdentifier::SHA_256: 48 return 512; 49 case CryptoAlgorithmIdentifier::SHA_384: 50 case CryptoAlgorithmIdentifier::SHA_512: 51 return 1024; 52 default: 53 ASSERT_NOT_REACHED(); 54 return 0; 55 } 56 } 39 57 40 58 CryptoKeyHMAC::CryptoKeyHMAC(const Vector<uint8_t>& key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap usage) … … 59 77 { 60 78 if (!lengthBits) { 61 switch (hash) { 62 case CryptoAlgorithmIdentifier::SHA_1: 63 case CryptoAlgorithmIdentifier::SHA_224: 64 case CryptoAlgorithmIdentifier::SHA_256: 65 lengthBits = 512; 66 break; 67 case CryptoAlgorithmIdentifier::SHA_384: 68 case CryptoAlgorithmIdentifier::SHA_512: 69 lengthBits = 1024; 70 break; 71 default: 79 lengthBits = getKeyLengthFromHash(hash); 80 if (!lengthBits) 72 81 return nullptr; 73 }74 82 } 75 83 // CommonHMAC only supports key length that is a multiple of 8. Therefore, here we are a little bit different … … 125 133 } 126 134 135 ExceptionOr<size_t> CryptoKeyHMAC::getKeyLength(const CryptoAlgorithmParameters& parameters) 136 { 137 auto& aesParameters = downcast<CryptoAlgorithmHmacKeyParams>(parameters); 138 139 size_t result = aesParameters.length ? *(aesParameters.length) : getKeyLengthFromHash(aesParameters.hashIdentifier); 140 if (result) 141 return result; 142 143 return Exception { TypeError }; 144 } 145 127 146 std::unique_ptr<KeyAlgorithm> CryptoKeyHMAC::buildAlgorithm() const 128 147 { -
trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h
r212465 r213628 29 29 30 30 #include "CryptoKey.h" 31 #include "ExceptionOr.h" 31 32 #include <wtf/Function.h> 32 33 #include <wtf/Vector.h> 33 34 34 35 namespace WebCore { 36 37 class CryptoAlgorithmParameters; 35 38 36 39 struct JsonWebKey; … … 75 78 CryptoAlgorithmIdentifier hashAlgorithmIdentifier() const { return m_hash; } 76 79 80 static ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&); 81 77 82 private: 78 83 CryptoKeyHMAC(const Vector<uint8_t>& key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp
r213624 r213628 35 35 namespace WebCore { 36 36 37 void CryptoAlgorithmECDH::platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, unsigned longlength, Callback&& callback, ScriptExecutionContext& context, WorkQueue& workQueue)37 void CryptoAlgorithmECDH::platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, size_t length, Callback&& callback, ScriptExecutionContext& context, WorkQueue& workQueue) 38 38 { 39 39 context.ref(); -
trunk/Source/WebCore/crypto/parameters/AesKeyParams.idl
r213627 r213628 24 24 */ 25 25 26 // This is a unified dictionary for AesDerivedKeyParams and AesKeyGenParams. 27 // https://www.w3.org/TR/WebCryptoAPI/#aes-derivedkey-params, and 28 // https://www.w3.org/TR/WebCryptoAPI/#aes-keygen-params 26 29 [ 27 30 Conditional=SUBTLE_CRYPTO, 28 ImplementedAs=CryptoAlgorithmAesKey GenParams29 ] dictionary AesKey GenParams : CryptoAlgorithmParameters {31 ImplementedAs=CryptoAlgorithmAesKeyParams 32 ] dictionary AesKeyParams : CryptoAlgorithmParameters { 30 33 // The length, in bits, of the key. 31 34 [EnforceRange] required unsigned short length; -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyParams.h
r213627 r213628 32 32 namespace WebCore { 33 33 34 class CryptoAlgorithmAesKey GenParams final : public CryptoAlgorithmParameters {34 class CryptoAlgorithmAesKeyParams final : public CryptoAlgorithmParameters { 35 35 public: 36 36 unsigned short length; 37 37 38 Class parametersClass() const final { return Class::AesKey GenParams; }38 Class parametersClass() const final { return Class::AesKeyParams; } 39 39 }; 40 40 41 41 } // namespace WebCore 42 42 43 SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(AesKey GenParams)43 SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(AesKeyParams) 44 44 45 45 #endif // ENABLE(SUBTLE_CRYPTO) -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h
r208985 r213628 38 38 JSC::JSValue hash; 39 39 CryptoAlgorithmIdentifier hashIdentifier; 40 std::optional< unsigned long> length;40 std::optional<size_t> length; 41 41 42 42 Class parametersClass() const final { return Class::HmacKeyParams; } -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h
r207809 r213628 36 36 class CryptoAlgorithmRsaKeyGenParams : public CryptoAlgorithmParameters { 37 37 public: 38 unsigned longmodulusLength;38 size_t modulusLength; 39 39 RefPtr<Uint8Array> publicExponent; 40 40
Note: See TracChangeset
for help on using the changeset viewer.