Changeset 159160 in webkit
- Timestamp:
- Nov 12, 2013 4:32:37 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r159157 r159160 1 2013-11-12 Alexey Proskuryakov <ap@apple.com> 2 3 Implement key generation and JWK import for RSASSA-PKCS1-v1_5 4 https://bugs.webkit.org/show_bug.cgi?id=124236 5 6 Reviewed by Sam Weinig. 7 8 * crypto/subtle/resources/common.js: 9 (hexToArrayBuffer): Fixed a typo 10 (Base64URL.stringify): 11 (Base64URL.parse): 12 Added helpers to deal with Base64URL, as needed for JWK. 13 14 * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt: Added. 15 * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html: Added. 16 * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-expected.txt: Added. 17 * crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html: Added. 18 1 19 2013-11-12 Roger Fong <roger_fong@apple.com> 2 20 -
trunk/LayoutTests/crypto/subtle/resources/common.js
r158485 r159160 49 49 { 50 50 if (str.length % 2) 51 throw "Hex string leng htmust be even";51 throw "Hex string length must be even"; 52 52 var chars = []; 53 53 for (var i = 0; i < str.length; i += 2) … … 55 55 return new Uint8Array(chars); 56 56 } 57 58 var Base64URL = { 59 stringify: function (a) { 60 var base64string = btoa(String.fromCharCode.apply(0, a)); 61 return base64string.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); 62 }, 63 parse: function (s) { 64 s = s.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ''); 65 return new Uint8Array(Array.prototype.map.call(atob(s), function (c) { return c.charCodeAt(0) })); 66 } 67 }; 57 68 58 69 function printRejectedResult(value) -
trunk/Source/WebCore/ChangeLog
r159159 r159160 1 2013-11-12 Alexey Proskuryakov <ap@apple.com> 2 3 Implement key generation and JWK import for RSASSA-PKCS1-v1_5 4 https://bugs.webkit.org/show_bug.cgi?id=124236 5 6 Reviewed by Sam Weinig. 7 8 Tests: crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html 9 crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html 10 11 * WebCore.xcodeproj/project.pbxproj: Added new files. 12 13 * bindings/js/JSCryptoAlgorithmBuilder.cpp: 14 (WebCore::JSCryptoAlgorithmBuilder::add): 15 * bindings/js/JSCryptoAlgorithmBuilder.h: 16 * crypto/CryptoAlgorithmDescriptionBuilder.h: 17 Added a way to add an Uint8Array, as needed for RSA key.algorithm.publicExponent. 18 19 * bindings/js/JSCryptoAlgorithmDictionary.cpp: 20 (WebCore::createAesCbcParams): Removed unneeded JSC prefixes. 21 (WebCore::createAesKeyGenParams): Ditto. 22 (WebCore::createHmacParams): Ditto. 23 (WebCore::createHmacKeyParams): Ditto. 24 (WebCore::createRsaKeyGenParams): Added. 25 (WebCore::createRsaSsaKeyParams): Added. WebCrypto currently doesn't specify any 26 parameters for importKey, so the structure remains blank (unlike with JWK). 27 (WebCore::createRsaSsaParams): Added (currently unused, will be sued for sign/verify soon). 28 (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt): Removed unneeded JSC prefixes. 29 (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt): Ditto. 30 (WebCore::JSCryptoAlgorithmDictionary::createParametersForSign): Added support for RSAES_PKCS1_v1_5. 31 (WebCore::JSCryptoAlgorithmDictionary::createParametersForVerify): Ditto. 32 (WebCore::JSCryptoAlgorithmDictionary::createParametersForDigest): Removed unneeded JSC prefixes. 33 (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey): Ditto. 34 (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveKey): Ditto. 35 (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveBits): Ditto. 36 (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey): Added support for RSAES_PKCS1_v1_5. 37 (WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey): Removed unneeded JSC prefixes. 38 (WebCore::JSCryptoAlgorithmDictionary::createParametersForWrapKey): Ditto. 39 (WebCore::JSCryptoAlgorithmDictionary::createParametersForUnwrapKey): Ditto. 40 41 * bindings/js/JSCryptoKeySerializationJWK.h: 42 * bindings/js/JSCryptoKeySerializationJWK.cpp: 43 (WebCore::getJSArrayFromJSON): Added. 44 (WebCore::getBigIntegerVectorFromJSON): Added. 45 (WebCore::createRSASSAKeyParameters): Create parameters for key import. The key 46 will remember which algorithm it's allowed to be used with. 47 (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm): Added support for 48 RS256...RS512 (tha is, RSAES_PKCS1_v1_5 with SHA-256...SHA-512). 49 (WebCore::JSCryptoKeySerializationJWK::keyDataOctetSequence): Split out of keyData(). 50 (WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents): Added code to read 51 RSA key components from JWK. 52 (WebCore::JSCryptoKeySerializationJWK::keyData): Call one of the above functions. 53 54 * crypto/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: Added. 55 (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign): 56 (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify): 57 Placeholders. 58 59 * crypto/CryptoKey.h: (WebCore::CryptoKeyClass): Added RSA key class for poor man's RTTI. 60 61 * crypto/CryptoKeyData.h: (WebCore::CryptoKeyData::FormatRSAComponents): Added RSAComponents 62 for poor man's RTTI. 63 64 * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::importKey): 65 * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::importKey): 66 * crypto/keys/CryptoKeyAES.h: 67 (WebCore::isCryptoKeyAES): 68 (WebCore::toCryptoKeyAES): 69 * crypto/keys/CryptoKeyDataOctetSequence.h: 70 (WebCore::toCryptoKeyDataOctetSequence): 71 * crypto/keys/CryptoKeyHMAC.h: 72 (WebCore::isCryptoKeyHMAC): 73 (WebCore::toCryptoKeyHMAC): 74 * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: 75 (WebCore::CryptoAlgorithmAES_CBC::encrypt): 76 (WebCore::CryptoAlgorithmAES_CBC::decrypt): 77 * crypto/mac/CryptoAlgorithmHMACMac.cpp: 78 (WebCore::CryptoAlgorithmHMAC::sign): 79 (WebCore::CryptoAlgorithmHMAC::verify): 80 Switched from "as" functions to "is" and "to" ones, as that's more idiomatic. 81 82 * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: Added. 83 * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: Added. 84 Glue code for importKey/generateKey for now. 85 86 * crypto/keys/CryptoKeyDataRSAComponents.cpp: Added. 87 (WebCore::CryptoKeyDataRSAComponents::CryptoKeyDataRSAComponents): 88 (WebCore::CryptoKeyDataRSAComponents::~CryptoKeyDataRSAComponents): 89 * crypto/keys/CryptoKeyDataRSAComponents.h: Added. 90 (WebCore::toCryptoKeyDataRSAComponents): 91 Added a structure to hold RSA key components, extracted from JWK or another format. 92 93 * crypto/keys/CryptoKeyRSA.h: Added. 94 * crypto/mac/CryptoKeyRSAMac.cpp: Added. 95 96 * crypto/mac/CryptoAlgorithmRegistryMac.cpp: 97 (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): 98 Register RSASSA_PKCS1_v1_5. 99 100 * crypto/parameters/CryptoAlgorithmHmacKeyParams.h: Added a constructor to make 101 sure that hasLength is never left uninitialized, even when reading formats that 102 don't contain a length. 103 104 * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h: Added. 105 * crypto/parameters/CryptoAlgorithmRsaSsaKeyParams.h: Added. 106 * crypto/parameters/CryptoAlgorithmRsaSsaParams.h: Added. 107 Added parameter structures that are needed for RSASSA_PKCS1_v1_5. 108 1 109 2013-11-12 Bem Jones-Bey <bjonesbe@adobe.com> 2 110 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r159159 r159160 5595 5595 E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E15A36D61104572000B7B639 /* XMLNSNames.h */; }; 5596 5596 E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15A36D81104572700B7B639 /* XMLNSNames.cpp */; }; 5597 E164FAA318315BF400DB4E61 /* CryptoKeyRSA.h in Headers */ = {isa = PBXBuildFile; fileRef = E164FAA218315BF400DB4E61 /* CryptoKeyRSA.h */; }; 5598 E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */; }; 5597 5599 E169803D1133542D00894115 /* CRuntimeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E169803C1133542D00894115 /* CRuntimeObject.h */; }; 5598 5600 E16980491133644700894115 /* CRuntimeObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E16980481133644700894115 /* CRuntimeObject.cpp */; }; … … 5669 5671 E1BA671A1742BEF400C20251 /* WebCoreTestShimLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BA67191742BEF400C20251 /* WebCoreTestShimLibrary.cpp */; }; 5670 5672 E1BB84AD1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */; }; 5673 E1BD3319182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BD3317182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp */; }; 5674 E1BD331A182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */; }; 5675 E1BD331C182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BD331B182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h */; }; 5676 E1BD331E182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BD331D182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParams.h */; }; 5671 5677 E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */; }; 5672 5678 E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */ = {isa = PBXBuildFile; fileRef = E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */; }; 5679 E1C266D818317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */; }; 5680 E1C266DB18319935003F8B33 /* CryptoAlgorithmRsaSsaKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C266DA18319935003F8B33 /* CryptoAlgorithmRsaSsaKeyParams.h */; }; 5681 E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C266DC18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp */; }; 5682 E1C266DF18319F31003F8B33 /* CryptoKeyDataRSAComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */; }; 5673 5683 E1C2F24A1533A2120083F974 /* SettingsMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C2F2481533A2120083F974 /* SettingsMac.mm */; }; 5674 5684 E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */; }; … … 12676 12686 E15A36D61104572000B7B639 /* XMLNSNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLNSNames.h; sourceTree = "<group>"; }; 12677 12687 E15A36D81104572700B7B639 /* XMLNSNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLNSNames.cpp; sourceTree = "<group>"; }; 12688 E164FAA218315BF400DB4E61 /* CryptoKeyRSA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoKeyRSA.h; path = keys/CryptoKeyRSA.h; sourceTree = "<group>"; }; 12689 E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoKeyRSAMac.cpp; path = mac/CryptoKeyRSAMac.cpp; sourceTree = "<group>"; }; 12678 12690 E169803C1133542D00894115 /* CRuntimeObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CRuntimeObject.h; sourceTree = "<group>"; }; 12679 12691 E16980481133644700894115 /* CRuntimeObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CRuntimeObject.cpp; sourceTree = "<group>"; }; … … 12759 12771 E1BA67191742BEF400C20251 /* WebCoreTestShimLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreTestShimLibrary.cpp; sourceTree = "<group>"; }; 12760 12772 E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmRegistryMac.cpp; path = mac/CryptoAlgorithmRegistryMac.cpp; sourceTree = "<group>"; }; 12773 E1BD3317182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp; sourceTree = "<group>"; }; 12774 E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSASSA_PKCS1_v1_5.h; sourceTree = "<group>"; }; 12775 E1BD331B182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmRsaSsaParams.h; path = parameters/CryptoAlgorithmRsaSsaParams.h; sourceTree = "<group>"; }; 12776 E1BD331D182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmRsaKeyGenParams.h; path = parameters/CryptoAlgorithmRsaKeyGenParams.h; sourceTree = "<group>"; }; 12761 12777 E1BE512B0CF6C512002EA959 /* XSLTUnicodeSort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTUnicodeSort.cpp; sourceTree = "<group>"; }; 12762 12778 E1BE512C0CF6C512002EA959 /* XSLTUnicodeSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTUnicodeSort.h; sourceTree = "<group>"; }; 12779 E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp; sourceTree = "<group>"; }; 12780 E1C266DA18319935003F8B33 /* CryptoAlgorithmRsaSsaKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmRsaSsaKeyParams.h; path = parameters/CryptoAlgorithmRsaSsaKeyParams.h; sourceTree = "<group>"; }; 12781 E1C266DC18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoKeyDataRSAComponents.cpp; path = keys/CryptoKeyDataRSAComponents.cpp; sourceTree = "<group>"; }; 12782 E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoKeyDataRSAComponents.h; path = keys/CryptoKeyDataRSAComponents.h; sourceTree = "<group>"; }; 12763 12783 E1C2F2481533A2120083F974 /* SettingsMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SettingsMac.mm; sourceTree = "<group>"; }; 12764 12784 E1C362ED0EAF2AA9007410BC /* JSWorkerLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerLocation.h; sourceTree = "<group>"; }; … … 20326 20346 E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */, 20327 20347 E125F82D1822CFFF00D84CD9 /* CryptoAlgorithmSHA1Mac.cpp */, 20348 E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */, 20328 20349 E19AC3DE1824DC6900349426 /* CryptoAlgorithmSHA224Mac.cpp */, 20329 20350 E19AC3DF1824DC6900349426 /* CryptoAlgorithmSHA256Mac.cpp */, … … 20331 20352 E19AC3E11824DC6900349426 /* CryptoAlgorithmSHA512Mac.cpp */, 20332 20353 E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */, 20354 E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */, 20333 20355 ); 20334 20356 name = mac; … … 20342 20364 E125F82F1822F11B00D84CD9 /* CryptoAlgorithmHMAC.cpp */, 20343 20365 E125F8301822F11B00D84CD9 /* CryptoAlgorithmHMAC.h */, 20366 E1BD3317182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp */, 20367 E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */, 20344 20368 E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */, 20345 20369 E125F82A1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h */, … … 20363 20387 E125F861182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp */, 20364 20388 E125F862182C303A00D84CD9 /* CryptoKeyDataOctetSequence.h */, 20389 E1C266DC18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp */, 20390 E1C266DD18319F31003F8B33 /* CryptoKeyDataRSAComponents.h */, 20365 20391 E125F8331822F18A00D84CD9 /* CryptoKeyHMAC.cpp */, 20366 20392 E125F8341822F18A00D84CD9 /* CryptoKeyHMAC.h */, 20393 E164FAA218315BF400DB4E61 /* CryptoKeyRSA.h */, 20367 20394 E125F857182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp */, 20368 20395 E125F858182C1AA600D84CD9 /* CryptoKeySerializationRaw.h */, … … 20378 20405 E19DA29B18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParams.h */, 20379 20406 E1C6571E1816E50300256CDD /* CryptoAlgorithmHmacParams.h */, 20407 E1BD331D182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParams.h */, 20408 E1C266DA18319935003F8B33 /* CryptoAlgorithmRsaSsaKeyParams.h */, 20409 E1BD331B182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h */, 20380 20410 ); 20381 20411 name = parameters; … … 22107 22137 6550B6A0099DF0270090D781 /* CharacterData.h in Headers */, 22108 22138 97B8FFD116AE7F960038388D /* CharacterReferenceParserInlines.h in Headers */, 22139 E164FAA318315BF400DB4E61 /* CryptoKeyRSA.h in Headers */, 22109 22140 B2C3DA2A0D006C1D00EF6F26 /* CharsetData.h in Headers */, 22110 22141 F55B3DB21251F12D003EF269 /* CheckboxInputType.h in Headers */, … … 22308 22339 453EB637159C570400001BB7 /* DateTimeFormat.h in Headers */, 22309 22340 0705850317FA10D0005F2BCB /* JSAllVideoCapabilities.h in Headers */, 22341 E1BD331A182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h in Headers */, 22310 22342 F55B3DB81251F12D003EF269 /* DateTimeInputType.h in Headers */, 22311 22343 F55B3DBA1251F12D003EF269 /* DateTimeLocalInputType.h in Headers */, … … 22867 22899 B275356D0B053814002CE64F /* FloatSize.h in Headers */, 22868 22900 D72F6D7A153159A3001EE44E /* FlowThreadController.h in Headers */, 22901 E1BD331E182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParams.h in Headers */, 22869 22902 14993BE60B2F2B1C0050497F /* FocusController.h in Headers */, 22870 22903 062287840B4DB322000C34DF /* FocusDirection.h in Headers */, … … 23442 23475 070756D414239A4F00414161 /* JSHTMLTrackElement.h in Headers */, 23443 23476 1A85B2110A1B258700D8C87C /* JSHTMLUListElement.h in Headers */, 23477 E1C266DF18319F31003F8B33 /* CryptoKeyDataRSAComponents.h in Headers */, 23444 23478 6E4ABCD5138EA0B70071D291 /* JSHTMLUnknownElement.h in Headers */, 23445 23479 078E092717D14D1C00420AA1 /* RTCSessionDescriptionCallback.h in Headers */, … … 23670 23704 B2FA3DDF0AB75A6F000E5AC4 /* JSSVGPathSegMovetoRel.h in Headers */, 23671 23705 0705852117FDC140005F2BCB /* MediaTrackConstraint.h in Headers */, 23706 E1C266DB18319935003F8B33 /* CryptoAlgorithmRsaSsaKeyParams.h in Headers */, 23672 23707 CD8B5A46180DFF4E008B8E65 /* VideoTrackMediaSource.h in Headers */, 23673 23708 B2FA3DE10AB75A6F000E5AC4 /* JSSVGPatternElement.h in Headers */, … … 23982 24017 BC5EB5DD0E81B8DD00B25965 /* OutlineValue.h in Headers */, 23983 24018 1A0D57370A5C77FE007EDD4C /* OverflowEvent.h in Headers */, 24019 E1BD331C182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParams.h in Headers */, 23984 24020 3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */, 23985 24021 65A21468097A329100B9050A /* Page.h in Headers */, … … 25751 25787 50987C26157D676D00BDA835 /* CustomFilterGlobalContext.cpp in Sources */, 25752 25788 50D405F9147D31F300D30BB5 /* CustomFilterMesh.cpp in Sources */, 25789 E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */, 25753 25790 7E12E91015FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp in Sources */, 25754 25791 50CC0A3914C6F5B10017AB51 /* CustomFilterOperation.cpp in Sources */, … … 26352 26389 BCCD74E50A4C8DDF005FDA6D /* HTMLViewSourceDocument.cpp in Sources */, 26353 26390 977B3879122883E900B81FF8 /* HTMLViewSourceParser.cpp in Sources */, 26391 E1C266D818317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp in Sources */, 26354 26392 0B8C56D40F28627F000502E1 /* HTTPHeaderMap.cpp in Sources */, 26355 26393 514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */, … … 26767 26805 65DF31FB09D1CC60000BE325 /* JSMutationEvent.cpp in Sources */, 26768 26806 C6F0902C14327D4F00685849 /* JSMutationObserver.cpp in Sources */, 26807 E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */, 26769 26808 C6F0917F143A2BB900685849 /* JSMutationObserverCustom.cpp in Sources */, 26770 26809 C6F08FC91431000D00685849 /* JSMutationRecord.cpp in Sources */, … … 27057 27096 49C7B99B1042D2D30009D447 /* JSWebGLProgram.cpp in Sources */, 27058 27097 49C7B99D1042D2D30009D447 /* JSWebGLRenderbuffer.cpp in Sources */, 27098 E1BD3319182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp in Sources */, 27059 27099 49EED1461051969400099FAB /* JSWebGLRenderingContext.cpp in Sources */, 27060 27100 49EED14F1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp
r158396 r159160 31 31 #include <runtime/ObjectConstructor.h> 32 32 #include <runtime/Operations.h> 33 #include <runtime/TypedArrays.h> 33 34 34 35 using namespace JSC; … … 65 66 } 66 67 68 void JSCryptoAlgorithmBuilder::add(const char* key, const Vector<uint8_t>& buffer) 69 { 70 VM& vm = m_exec->vm(); 71 Identifier identifier(&vm, key); 72 RefPtr<Uint8Array> arrayView = Uint8Array::create(buffer.data(), buffer.size()); 73 m_dictionary->putDirect(vm, identifier, arrayView->wrap(m_exec, vm.dynamicGlobalObject)); 74 } 75 67 76 void JSCryptoAlgorithmBuilder::add(const char* key, const CryptoAlgorithmDescriptionBuilder& nestedBuilder) 68 77 { -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h
r158361 r159160 49 49 virtual void add(const char*, unsigned) OVERRIDE; 50 50 virtual void add(const char*, const String&) OVERRIDE; 51 virtual void add(const char*, const Vector<uint8_t>&) OVERRIDE; 51 52 virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&) OVERRIDE; 52 53 -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp
r158582 r159160 34 34 #include "CryptoAlgorithmHmacParams.h" 35 35 #include "CryptoAlgorithmRegistry.h" 36 #include "CryptoAlgorithmRsaKeyGenParams.h" 37 #include "CryptoAlgorithmRsaSsaKeyParams.h" 38 #include "CryptoAlgorithmRsaSsaParams.h" 36 39 #include "ExceptionCode.h" 37 40 #include "JSCryptoOperationData.h" … … 117 120 } 118 121 119 static std::unique_ptr<CryptoAlgorithmParameters> createAesCbcParams( JSC::ExecState* exec, JSC::JSValue value)122 static std::unique_ptr<CryptoAlgorithmParameters> createAesCbcParams(ExecState* exec, JSValue value) 120 123 { 121 124 if (!value.isObject()) { … … 146 149 } 147 150 148 static std::unique_ptr<CryptoAlgorithmParameters> createAesKeyGenParams( JSC::ExecState* exec, JSC::JSValue value)151 static std::unique_ptr<CryptoAlgorithmParameters> createAesKeyGenParams(ExecState* exec, JSValue value) 149 152 { 150 153 if (!value.isObject()) { … … 164 167 } 165 168 166 static std::unique_ptr<CryptoAlgorithmParameters> createHmacParams( JSC::ExecState* exec, JSC::JSValue value)169 static std::unique_ptr<CryptoAlgorithmParameters> createHmacParams(ExecState* exec, JSValue value) 167 170 { 168 171 if (!value.isObject()) { … … 182 185 } 183 186 184 static std::unique_ptr<CryptoAlgorithmParameters> createHmacKeyParams( JSC::ExecState* exec, JSC::JSValue value)187 static std::unique_ptr<CryptoAlgorithmParameters> createHmacKeyParams(ExecState* exec, JSValue value) 185 188 { 186 189 if (!value.isObject()) { … … 204 207 } 205 208 206 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForEncrypt(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 209 static std::unique_ptr<CryptoAlgorithmParameters> createRsaKeyGenParams(ExecState* exec, JSValue value) 210 { 211 if (!value.isObject()) { 212 throwTypeError(exec); 213 return nullptr; 214 } 215 216 auto result = std::make_unique<CryptoAlgorithmRsaKeyGenParams>(); 217 218 JSValue modulusLengthValue = getProperty(exec, value.getObject(), "modulusLength"); 219 if (exec->hadException()) 220 return nullptr; 221 222 // FIXME: Why no EnforceRange? Filed as <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23779>. 223 result->modulusLength = toUInt32(exec, modulusLengthValue, NormalConversion); 224 if (exec->hadException()) 225 return nullptr; 226 227 JSValue publicExponentValue = getProperty(exec, value.getObject(), "publicExponent"); 228 if (exec->hadException()) 229 return nullptr; 230 231 RefPtr<Uint8Array> publicExponentArray = toUint8Array(publicExponentValue); 232 if (publicExponentArray) { 233 throwTypeError(exec, "Expected a Uint8Array in publicExponent"); 234 return nullptr; 235 } 236 result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength()); 237 238 return std::move(result); 239 } 240 241 static std::unique_ptr<CryptoAlgorithmParameters> createRsaSsaKeyParams(ExecState*, JSValue) 242 { 243 // WebCrypto RSASSA-PKCS1-v1_5 algorithm currently does not take any parameters to importKey. 244 return std::make_unique<CryptoAlgorithmRsaSsaKeyParams>(); 245 } 246 247 static std::unique_ptr<CryptoAlgorithmParameters> createRsaSsaParams(ExecState* exec, JSValue value) 248 { 249 if (!value.isObject()) { 250 throwTypeError(exec); 251 return nullptr; 252 } 253 254 JSDictionary jsDictionary(exec, value.getObject()); 255 auto result = std::make_unique<CryptoAlgorithmRsaSsaParams>(); 256 257 if (!getHashAlgorithm(jsDictionary, result->hash)) { 258 ASSERT(exec->hadException()); 259 return nullptr; 260 } 261 262 return std::move(result); 263 } 264 265 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForEncrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 207 266 { 208 267 switch (algorithm) { … … 236 295 } 237 296 238 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDecrypt( JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value)297 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDecrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 239 298 { 240 299 switch (algorithm) { … … 268 327 } 269 328 270 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForSign(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 271 { 272 switch (algorithm) { 273 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 274 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 329 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForSign(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 330 { 331 switch (algorithm) { 332 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 333 setDOMException(exec, NOT_SUPPORTED_ERR); 334 return nullptr; 335 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 336 return createRsaSsaParams(exec, value); 275 337 case CryptoAlgorithmIdentifier::RSA_PSS: 276 338 case CryptoAlgorithmIdentifier::RSA_OAEP: … … 300 362 } 301 363 302 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForVerify(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 303 { 304 switch (algorithm) { 305 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 306 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 364 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForVerify(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 365 { 366 switch (algorithm) { 367 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 368 setDOMException(exec, NOT_SUPPORTED_ERR); 369 return nullptr; 370 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 371 return createRsaSsaParams(exec, value); 307 372 case CryptoAlgorithmIdentifier::RSA_PSS: 308 373 case CryptoAlgorithmIdentifier::RSA_OAEP: … … 332 397 } 333 398 334 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDigest( JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)399 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDigest(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue) 335 400 { 336 401 switch (algorithm) { … … 364 429 } 365 430 366 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 367 { 368 switch (algorithm) { 369 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 370 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 371 case CryptoAlgorithmIdentifier::RSA_PSS: 372 case CryptoAlgorithmIdentifier::RSA_OAEP: 431 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 432 { 433 switch (algorithm) { 434 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 435 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 436 case CryptoAlgorithmIdentifier::RSA_PSS: 437 case CryptoAlgorithmIdentifier::RSA_OAEP: 438 return createRsaKeyGenParams(exec, value); 373 439 case CryptoAlgorithmIdentifier::ECDSA: 374 440 case CryptoAlgorithmIdentifier::ECDH: … … 397 463 } 398 464 399 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 400 { 401 switch (algorithm) { 402 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 403 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 404 case CryptoAlgorithmIdentifier::RSA_PSS: 405 case CryptoAlgorithmIdentifier::RSA_OAEP: 406 case CryptoAlgorithmIdentifier::ECDSA: 407 case CryptoAlgorithmIdentifier::ECDH: 408 case CryptoAlgorithmIdentifier::AES_CTR: 409 case CryptoAlgorithmIdentifier::AES_CBC: 410 case CryptoAlgorithmIdentifier::AES_CMAC: 411 case CryptoAlgorithmIdentifier::AES_GCM: 412 case CryptoAlgorithmIdentifier::AES_CFB: 413 case CryptoAlgorithmIdentifier::HMAC: 414 case CryptoAlgorithmIdentifier::DH: 415 case CryptoAlgorithmIdentifier::SHA_1: 416 case CryptoAlgorithmIdentifier::SHA_224: 417 case CryptoAlgorithmIdentifier::SHA_256: 418 case CryptoAlgorithmIdentifier::SHA_384: 419 case CryptoAlgorithmIdentifier::SHA_512: 420 case CryptoAlgorithmIdentifier::CONCAT: 421 case CryptoAlgorithmIdentifier::HKDF_CTR: 422 case CryptoAlgorithmIdentifier::PBKDF2: 423 setDOMException(exec, NOT_SUPPORTED_ERR); 424 return nullptr; 425 } 426 } 427 428 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 429 { 430 switch (algorithm) { 431 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 432 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 433 case CryptoAlgorithmIdentifier::RSA_PSS: 434 case CryptoAlgorithmIdentifier::RSA_OAEP: 435 case CryptoAlgorithmIdentifier::ECDSA: 436 case CryptoAlgorithmIdentifier::ECDH: 437 case CryptoAlgorithmIdentifier::AES_CTR: 438 case CryptoAlgorithmIdentifier::AES_CBC: 439 case CryptoAlgorithmIdentifier::AES_CMAC: 440 case CryptoAlgorithmIdentifier::AES_GCM: 441 case CryptoAlgorithmIdentifier::AES_CFB: 442 case CryptoAlgorithmIdentifier::HMAC: 443 case CryptoAlgorithmIdentifier::DH: 444 case CryptoAlgorithmIdentifier::SHA_1: 445 case CryptoAlgorithmIdentifier::SHA_224: 446 case CryptoAlgorithmIdentifier::SHA_256: 447 case CryptoAlgorithmIdentifier::SHA_384: 448 case CryptoAlgorithmIdentifier::SHA_512: 449 case CryptoAlgorithmIdentifier::CONCAT: 450 case CryptoAlgorithmIdentifier::HKDF_CTR: 451 case CryptoAlgorithmIdentifier::PBKDF2: 452 setDOMException(exec, NOT_SUPPORTED_ERR); 453 return nullptr; 454 } 455 } 456 457 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 458 { 459 switch (algorithm) { 460 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 461 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 462 case CryptoAlgorithmIdentifier::RSA_PSS: 463 case CryptoAlgorithmIdentifier::RSA_OAEP: 464 case CryptoAlgorithmIdentifier::ECDSA: 465 case CryptoAlgorithmIdentifier::ECDH: 466 case CryptoAlgorithmIdentifier::AES_CTR: 467 case CryptoAlgorithmIdentifier::AES_CBC: 468 case CryptoAlgorithmIdentifier::AES_CMAC: 469 case CryptoAlgorithmIdentifier::AES_GCM: 470 case CryptoAlgorithmIdentifier::AES_CFB: 465 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue) 466 { 467 switch (algorithm) { 468 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 469 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 470 case CryptoAlgorithmIdentifier::RSA_PSS: 471 case CryptoAlgorithmIdentifier::RSA_OAEP: 472 case CryptoAlgorithmIdentifier::ECDSA: 473 case CryptoAlgorithmIdentifier::ECDH: 474 case CryptoAlgorithmIdentifier::AES_CTR: 475 case CryptoAlgorithmIdentifier::AES_CBC: 476 case CryptoAlgorithmIdentifier::AES_CMAC: 477 case CryptoAlgorithmIdentifier::AES_GCM: 478 case CryptoAlgorithmIdentifier::AES_CFB: 479 case CryptoAlgorithmIdentifier::HMAC: 480 case CryptoAlgorithmIdentifier::DH: 481 case CryptoAlgorithmIdentifier::SHA_1: 482 case CryptoAlgorithmIdentifier::SHA_224: 483 case CryptoAlgorithmIdentifier::SHA_256: 484 case CryptoAlgorithmIdentifier::SHA_384: 485 case CryptoAlgorithmIdentifier::SHA_512: 486 case CryptoAlgorithmIdentifier::CONCAT: 487 case CryptoAlgorithmIdentifier::HKDF_CTR: 488 case CryptoAlgorithmIdentifier::PBKDF2: 489 setDOMException(exec, NOT_SUPPORTED_ERR); 490 return nullptr; 491 } 492 } 493 494 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue) 495 { 496 switch (algorithm) { 497 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 498 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 499 case CryptoAlgorithmIdentifier::RSA_PSS: 500 case CryptoAlgorithmIdentifier::RSA_OAEP: 501 case CryptoAlgorithmIdentifier::ECDSA: 502 case CryptoAlgorithmIdentifier::ECDH: 503 case CryptoAlgorithmIdentifier::AES_CTR: 504 case CryptoAlgorithmIdentifier::AES_CBC: 505 case CryptoAlgorithmIdentifier::AES_CMAC: 506 case CryptoAlgorithmIdentifier::AES_GCM: 507 case CryptoAlgorithmIdentifier::AES_CFB: 508 case CryptoAlgorithmIdentifier::HMAC: 509 case CryptoAlgorithmIdentifier::DH: 510 case CryptoAlgorithmIdentifier::SHA_1: 511 case CryptoAlgorithmIdentifier::SHA_224: 512 case CryptoAlgorithmIdentifier::SHA_256: 513 case CryptoAlgorithmIdentifier::SHA_384: 514 case CryptoAlgorithmIdentifier::SHA_512: 515 case CryptoAlgorithmIdentifier::CONCAT: 516 case CryptoAlgorithmIdentifier::HKDF_CTR: 517 case CryptoAlgorithmIdentifier::PBKDF2: 518 setDOMException(exec, NOT_SUPPORTED_ERR); 519 return nullptr; 520 } 521 } 522 523 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 524 { 525 switch (algorithm) { 526 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 471 527 return std::make_unique<CryptoAlgorithmParameters>(); 528 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 529 return createRsaSsaKeyParams(exec, value); 530 case CryptoAlgorithmIdentifier::RSA_PSS: 531 case CryptoAlgorithmIdentifier::RSA_OAEP: 532 case CryptoAlgorithmIdentifier::ECDSA: 533 case CryptoAlgorithmIdentifier::ECDH: 534 case CryptoAlgorithmIdentifier::AES_CTR: 535 case CryptoAlgorithmIdentifier::AES_CBC: 536 case CryptoAlgorithmIdentifier::AES_CMAC: 537 case CryptoAlgorithmIdentifier::AES_GCM: 538 case CryptoAlgorithmIdentifier::AES_CFB: 539 return std::make_unique<CryptoAlgorithmParameters>(); 472 540 case CryptoAlgorithmIdentifier::HMAC: 473 541 return createHmacKeyParams(exec, value); … … 487 555 } 488 556 489 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey( JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)557 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue) 490 558 { 491 559 switch (algorithm) { … … 517 585 } 518 586 519 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForWrapKey( JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)520 { 521 switch (algorithm) { 522 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 523 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 524 case CryptoAlgorithmIdentifier::RSA_PSS: 525 case CryptoAlgorithmIdentifier::RSA_OAEP: 526 case CryptoAlgorithmIdentifier::ECDSA: 527 case CryptoAlgorithmIdentifier::ECDH: 528 case CryptoAlgorithmIdentifier::AES_CTR: 529 case CryptoAlgorithmIdentifier::AES_CBC: 530 case CryptoAlgorithmIdentifier::AES_CMAC: 531 case CryptoAlgorithmIdentifier::AES_GCM: 532 case CryptoAlgorithmIdentifier::AES_CFB: 533 case CryptoAlgorithmIdentifier::HMAC: 534 case CryptoAlgorithmIdentifier::DH: 535 case CryptoAlgorithmIdentifier::SHA_1: 536 case CryptoAlgorithmIdentifier::SHA_224: 537 case CryptoAlgorithmIdentifier::SHA_256: 538 case CryptoAlgorithmIdentifier::SHA_384: 539 case CryptoAlgorithmIdentifier::SHA_512: 540 case CryptoAlgorithmIdentifier::CONCAT: 541 case CryptoAlgorithmIdentifier::HKDF_CTR: 542 case CryptoAlgorithmIdentifier::PBKDF2: 543 setDOMException(exec, NOT_SUPPORTED_ERR); 544 return nullptr; 545 } 546 } 547 548 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForUnwrapKey( JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)587 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForWrapKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue) 588 { 589 switch (algorithm) { 590 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 591 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 592 case CryptoAlgorithmIdentifier::RSA_PSS: 593 case CryptoAlgorithmIdentifier::RSA_OAEP: 594 case CryptoAlgorithmIdentifier::ECDSA: 595 case CryptoAlgorithmIdentifier::ECDH: 596 case CryptoAlgorithmIdentifier::AES_CTR: 597 case CryptoAlgorithmIdentifier::AES_CBC: 598 case CryptoAlgorithmIdentifier::AES_CMAC: 599 case CryptoAlgorithmIdentifier::AES_GCM: 600 case CryptoAlgorithmIdentifier::AES_CFB: 601 case CryptoAlgorithmIdentifier::HMAC: 602 case CryptoAlgorithmIdentifier::DH: 603 case CryptoAlgorithmIdentifier::SHA_1: 604 case CryptoAlgorithmIdentifier::SHA_224: 605 case CryptoAlgorithmIdentifier::SHA_256: 606 case CryptoAlgorithmIdentifier::SHA_384: 607 case CryptoAlgorithmIdentifier::SHA_512: 608 case CryptoAlgorithmIdentifier::CONCAT: 609 case CryptoAlgorithmIdentifier::HKDF_CTR: 610 case CryptoAlgorithmIdentifier::PBKDF2: 611 setDOMException(exec, NOT_SUPPORTED_ERR); 612 return nullptr; 613 } 614 } 615 616 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForUnwrapKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue) 549 617 { 550 618 switch (algorithm) { -
trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp
r158943 r159160 32 32 #include "CryptoAlgorithmHmacParams.h" 33 33 #include "CryptoAlgorithmRegistry.h" 34 #include "CryptoAlgorithmRsaSsaKeyParams.h" 34 35 #include "CryptoKeyDataOctetSequence.h" 36 #include "CryptoKeyDataRSAComponents.h" 35 37 #include "ExceptionCode.h" 36 38 #include "JSDOMBinding.h" … … 42 44 43 45 namespace WebCore { 46 47 static bool getJSArrayFromJSON(ExecState* exec, JSObject* json, const char* key, JSArray*& result) 48 { 49 Identifier identifier(exec, key); 50 PropertySlot slot(json); 51 52 if (!json->getPropertySlot(exec, identifier, slot)) 53 return false; 54 55 JSValue value = slot.getValue(exec, identifier); 56 ASSERT(!exec->hadException()); 57 if (isJSArray(value)) { 58 throwTypeError(exec, String::format("Expected an array for \"%s\" JSON key", key)); 59 return false; 60 } 61 62 result = asArray(value); 63 64 return true; 65 } 44 66 45 67 static bool getStringFromJSON(ExecState* exec, JSObject* json, const char* key, String& result) … … 83 105 } 84 106 107 static bool getBigIntegerVectorFromJSON(ExecState* exec, JSObject* json, const char* key, Vector<char>& result) 108 { 109 String base64urlEncodedNumber; 110 if (!getStringFromJSON(exec, json, key, base64urlEncodedNumber)) 111 return false; 112 113 if (!base64URLDecode(base64urlEncodedNumber, result)) { 114 throwTypeError(exec, "Cannot decode base64url key data in JWK"); 115 return false; 116 } 117 118 if (result[0] == 0) { 119 throwTypeError(exec, "JWK BigInteger must utilize the minimum number of octets to represent the value"); 120 return false; 121 } 122 123 return true; 124 } 125 85 126 JSCryptoKeySerializationJWK::JSCryptoKeySerializationJWK(ExecState* exec, const String& jsonString) 86 127 : m_exec(exec) … … 108 149 return std::move(hmacParameters); 109 150 } 151 152 static std::unique_ptr<CryptoAlgorithmParameters> createRSASSAKeyParameters(CryptoAlgorithmIdentifier hashFunction) 153 { 154 std::unique_ptr<CryptoAlgorithmRsaSsaKeyParams> rsaSSAParameters = std::make_unique<CryptoAlgorithmRsaSsaKeyParams>(); 155 rsaSSAParameters->hasHash = true; 156 rsaSSAParameters->hash = hashFunction; 157 return std::move(rsaSSAParameters); 158 } 159 110 160 111 161 bool JSCryptoKeySerializationJWK::reconcileAlgorithm(std::unique_ptr<CryptoAlgorithm>& suggestedAlgorithm, std::unique_ptr<CryptoAlgorithmParameters>& suggestedParameters) const … … 127 177 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::HMAC); 128 178 parameters = createHMACParameters(CryptoAlgorithmIdentifier::SHA_512); 179 } else if (m_jwkAlgorithmName == "RS256") { 180 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5); 181 parameters = createRSASSAKeyParameters(CryptoAlgorithmIdentifier::SHA_256); 182 } else if (m_jwkAlgorithmName == "RS384") { 183 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5); 184 parameters = createRSASSAKeyParameters(CryptoAlgorithmIdentifier::SHA_384); 185 } else if (m_jwkAlgorithmName == "RS512") { 186 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5); 187 parameters = createRSASSAKeyParameters(CryptoAlgorithmIdentifier::SHA_512); 129 188 } else if (m_jwkAlgorithmName == "A128CBC") { 130 189 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_CBC); … … 153 212 return false; 154 213 155 // HMAC is the only algorithm that has parameters in importKey. 156 if (algorithm->identifier() != CryptoAlgorithmIdentifier::HMAC) 157 return true; 158 159 return static_cast<CryptoAlgorithmHmacParams&>(*parameters).hash == static_cast<CryptoAlgorithmHmacParams&>(*suggestedParameters).hash; 214 if (algorithm->identifier() == CryptoAlgorithmIdentifier::HMAC) 215 return static_cast<CryptoAlgorithmHmacParams&>(*parameters).hash == static_cast<CryptoAlgorithmHmacParams&>(*suggestedParameters).hash; 216 if (algorithm->identifier() == CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5) { 217 CryptoAlgorithmRsaSsaKeyParams& rsaSSAParameters = static_cast<CryptoAlgorithmRsaSsaKeyParams&>(*parameters); 218 CryptoAlgorithmRsaSsaKeyParams& suggestedRSASSAParameters = static_cast<CryptoAlgorithmRsaSsaKeyParams&>(*suggestedParameters); 219 ASSERT(rsaSSAParameters.hasHash); 220 if (suggestedRSASSAParameters.hasHash) 221 return suggestedRSASSAParameters.hash == rsaSSAParameters.hash; 222 suggestedRSASSAParameters.hasHash = true; 223 suggestedRSASSAParameters.hash = rsaSSAParameters.hash; 224 } 225 226 // Other algorithms don't have parameters. 227 return true; 160 228 } 161 229 … … 208 276 } 209 277 278 std::unique_ptr<CryptoKeyData> JSCryptoKeySerializationJWK::keyDataOctetSequence() const 279 { 280 String keyBase64URL; 281 if (!getStringFromJSON(m_exec, m_json.get(), "k", keyBase64URL)) { 282 if (!m_exec->hadException()) 283 throwTypeError(m_exec, "Secret key data is not present is JWK"); 284 return nullptr; 285 } 286 287 Vector<char> octetSequence; 288 if (!base64URLDecode(keyBase64URL, octetSequence)) { 289 throwTypeError(m_exec, "Cannot decode base64url key data in JWK"); 290 return nullptr; 291 } 292 293 if (!keySizeIsValid(octetSequence.size() * 8)) { 294 throwTypeError(m_exec, "Key size is not valid for " + m_jwkAlgorithmName); 295 return nullptr; 296 } 297 298 return CryptoKeyDataOctetSequence::create(octetSequence); 299 } 300 301 std::unique_ptr<CryptoKeyData> JSCryptoKeySerializationJWK::keyDataRSAComponents() const 302 { 303 Vector<char> modulus; 304 Vector<char> exponent; 305 Vector<char> privateExponent; 306 307 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "n", modulus)) { 308 if (!m_exec->hadException()) 309 throwTypeError(m_exec, "Required JWK \"n\" member is missing"); 310 return nullptr; 311 } 312 313 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "e", exponent)) { 314 if (!m_exec->hadException()) 315 throwTypeError(m_exec, "Required JWK \"e\" member is missing"); 316 return nullptr; 317 } 318 319 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "d", modulus)) { 320 if (m_exec->hadException()) 321 return nullptr; 322 return CryptoKeyDataRSAComponents::createPublic(modulus, exponent); 323 } 324 325 CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo; 326 CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo; 327 Vector<CryptoKeyDataRSAComponents::PrimeInfo> otherPrimeInfos; 328 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "p", firstPrimeInfo.primeFactor)) { 329 if (m_exec->hadException()) 330 return nullptr; 331 return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent); 332 } 333 334 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "dp", firstPrimeInfo.factorCRTExponent)) { 335 if (m_exec->hadException()) 336 return nullptr; 337 return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent); 338 } 339 340 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "q", secondPrimeInfo.primeFactor)) { 341 if (m_exec->hadException()) 342 return nullptr; 343 return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent); 344 } 345 346 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "dq", secondPrimeInfo.factorCRTExponent)) { 347 if (m_exec->hadException()) 348 return nullptr; 349 return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent); 350 } 351 352 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "qi", secondPrimeInfo.factorCRTCoefficient)) { 353 if (m_exec->hadException()) 354 return nullptr; 355 return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent); 356 } 357 358 JSArray* otherPrimeInfoJSArray; 359 if (!getJSArrayFromJSON(m_exec, m_json.get(), "oth", otherPrimeInfoJSArray)) { 360 if (m_exec->hadException()) 361 return nullptr; 362 return CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos); 363 } 364 365 for (size_t i = 0; i < otherPrimeInfoJSArray->length(); ++i) { 366 CryptoKeyDataRSAComponents::PrimeInfo info; 367 JSValue element = otherPrimeInfoJSArray->getIndex(m_exec, i); 368 if (m_exec->hadException()) 369 return nullptr; 370 if (!element.isObject()) { 371 throwTypeError(m_exec, "JWK \"oth\" array member is not an object"); 372 return nullptr; 373 } 374 if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "r", info.primeFactor)) { 375 if (!m_exec->hadException()) 376 throwTypeError(m_exec, "Cannot get prime factor for a prime in \"oth\" dictionary"); 377 return nullptr; 378 } 379 if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "d", info.factorCRTExponent)) { 380 if (!m_exec->hadException()) 381 throwTypeError(m_exec, "Cannot get factor CRT exponent for a prime in \"oth\" dictionary"); 382 return nullptr; 383 } 384 if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "t", info.factorCRTCoefficient)) { 385 if (!m_exec->hadException()) 386 throwTypeError(m_exec, "Cannot get factor CRT coefficient for a prime in \"oth\" dictionary"); 387 return nullptr; 388 } 389 otherPrimeInfos.append(info); 390 } 391 392 return CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos); 393 } 394 210 395 std::unique_ptr<CryptoKeyData> JSCryptoKeySerializationJWK::keyData() const 211 396 { … … 217 402 } 218 403 219 if (jwkKeyType != "oct") { 220 throwTypeError(m_exec, "Unsupported JWK key type " + jwkKeyType); 221 return nullptr; 222 } 223 224 String keyBase64URL; 225 if (!getStringFromJSON(m_exec, m_json.get(), "k", keyBase64URL)) { 226 if (!m_exec->hadException()) 227 throwTypeError(m_exec, "Secret key data is not present is JWK"); 228 return nullptr; 229 } 230 231 Vector<char> octetSequence; 232 if (!base64URLDecode(keyBase64URL, octetSequence)) { 233 throwTypeError(m_exec, "Cannot decode base64url key data in JWK"); 234 return nullptr; 235 } 236 237 if (!keySizeIsValid(octetSequence.size() * 8)) { 238 throwTypeError(m_exec, "Key size is not valid for " + m_jwkAlgorithmName); 239 return nullptr; 240 } 241 242 return CryptoKeyDataOctetSequence::create(octetSequence); 404 if (jwkKeyType == "oct") 405 return keyDataOctetSequence(); 406 407 if (jwkKeyType == "RSA") 408 return keyDataRSAComponents(); 409 410 throwTypeError(m_exec, "Unsupported JWK key type " + jwkKeyType); 411 return nullptr; 243 412 } 244 413 -
trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.h
r158943 r159160 64 64 65 65 bool keySizeIsValid(size_t sizeInBits) const; 66 std::unique_ptr<CryptoKeyData> keyDataOctetSequence() const; 67 std::unique_ptr<CryptoKeyData> keyDataRSAComponents() const; 66 68 67 69 JSC::ExecState* m_exec; -
trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h
r158361 r159160 29 29 #include <wtf/Forward.h> 30 30 #include <wtf/Noncopyable.h> 31 #include <wtf/Vector.h> 31 32 32 33 #if ENABLE(SUBTLE_CRYPTO) … … 44 45 virtual void add(const char*, unsigned) = 0; 45 46 virtual void add(const char*, const String&) = 0; 47 virtual void add(const char*, const Vector<uint8_t>&) = 0; 46 48 virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&) = 0; 47 49 }; -
trunk/Source/WebCore/crypto/CryptoKey.h
r158582 r159160 42 42 ENUM_CLASS(CryptoKeyClass) { 43 43 HMAC, 44 AES 44 AES, 45 RSA 45 46 }; 46 47 -
trunk/Source/WebCore/crypto/CryptoKeyData.h
r158943 r159160 37 37 public: 38 38 ENUM_CLASS(Format) { 39 OctetSequence 39 OctetSequence, 40 RSAComponents 40 41 }; 41 42 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
r158943 r159160 76 76 return; 77 77 } 78 const CryptoKeyDataOctetSequence& keyDataOctetSequence = asCryptoKeyDataOctetSequence(keyData);78 const CryptoKeyDataOctetSequence& keyDataOctetSequence = toCryptoKeyDataOctetSequence(keyData); 79 79 RefPtr<CryptoKeyAES> result = CryptoKeyAES::create(CryptoAlgorithmIdentifier::AES_CBC, keyDataOctetSequence.octetSequence(), extractable, usage); 80 80 promise->fulfill(result.release()); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
r158943 r159160 77 77 return; 78 78 } 79 const CryptoKeyDataOctetSequence& keyDataOctetSequence = asCryptoKeyDataOctetSequence(keyData);79 const CryptoKeyDataOctetSequence& keyDataOctetSequence = toCryptoKeyDataOctetSequence(keyData); 80 80 81 81 const CryptoAlgorithmHmacParams& hmacParameters = static_cast<const CryptoAlgorithmHmacParams&>(parameters); -
trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h
r158945 r159160 57 57 }; 58 58 59 inline const CryptoKeyAES* asCryptoKeyAES(const CryptoKey& key)59 inline bool isCryptoKeyAES(const CryptoKey& key) 60 60 { 61 if (key.keyClass() != CryptoKeyClass::AES) 62 return nullptr; 63 return static_cast<const CryptoKeyAES*>(&key); 61 return key.keyClass() == CryptoKeyClass::AES; 64 62 } 65 63 66 inline CryptoKeyAES* asCryptoKeyAES(CryptoKey& key)64 inline const CryptoKeyAES& toCryptoKeyAES(const CryptoKey& key) 67 65 { 68 if (key.keyClass() != CryptoKeyClass::AES) 69 return nullptr; 70 return static_cast<CryptoKeyAES*>(&key); 66 ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyAES(key)); 67 return static_cast<const CryptoKeyAES&>(key); 68 } 69 70 inline CryptoKeyAES& toCryptoKeyAES(CryptoKey& key) 71 { 72 ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyAES(key)); 73 return static_cast<CryptoKeyAES&>(key); 71 74 } 72 75 -
trunk/Source/WebCore/crypto/keys/CryptoKeyDataOctetSequence.h
r158943 r159160 50 50 }; 51 51 52 inline const CryptoKeyDataOctetSequence& asCryptoKeyDataOctetSequence(const CryptoKeyData& data)52 inline const CryptoKeyDataOctetSequence& toCryptoKeyDataOctetSequence(const CryptoKeyData& data) 53 53 { 54 54 ASSERT(data.format() == CryptoKeyData::Format::OctetSequence); -
trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h
r158582 r159160 58 58 }; 59 59 60 inline const CryptoKeyHMAC* asCryptoKeyHMAC(const CryptoKey& key)60 inline bool isCryptoKeyHMAC(const CryptoKey& key) 61 61 { 62 if (key.keyClass() != CryptoKeyClass::HMAC) 63 return nullptr; 64 return static_cast<const CryptoKeyHMAC*>(&key); 62 return key.keyClass() == CryptoKeyClass::HMAC; 65 63 } 66 64 67 inline CryptoKeyHMAC* asCryptoKeyHMAC(CryptoKey& key)65 inline const CryptoKeyHMAC& toCryptoKeyHMAC(const CryptoKey& key) 68 66 { 69 if (key.keyClass() != CryptoKeyClass::HMAC) 70 return nullptr; 71 return static_cast<CryptoKeyHMAC*>(&key); 67 ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyHMAC(key)); 68 return static_cast<const CryptoKeyHMAC&>(key); 69 } 70 71 inline CryptoKeyHMAC& toCryptoKeyHMAC(CryptoKey& key) 72 { 73 ASSERT_WITH_SECURITY_IMPLICATION(isCryptoKeyHMAC(key)); 74 return static_cast<CryptoKeyHMAC&>(key); 72 75 } 73 76 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp
r158582 r159160 93 93 { 94 94 const CryptoAlgorithmAesCbcParams& aesCBCParameters = static_cast<const CryptoAlgorithmAesCbcParams&>(parameters); 95 const CryptoKeyAES* aesKey = asCryptoKeyAES(key);96 95 97 if (! aesKey) {96 if (!isCryptoKeyAES(key)) { 98 97 ec = NOT_SUPPORTED_ERR; 99 98 return; 100 99 } 100 const CryptoKeyAES& aesKey = toCryptoKeyAES(key); 101 101 102 transformAES_CBC(kCCEncrypt, aesCBCParameters, *aesKey, data, std::move(promise));102 transformAES_CBC(kCCEncrypt, aesCBCParameters, aesKey, data, std::move(promise)); 103 103 } 104 104 … … 106 106 { 107 107 const CryptoAlgorithmAesCbcParams& aesCBCParameters = static_cast<const CryptoAlgorithmAesCbcParams&>(parameters); 108 const CryptoKeyAES* aesKey = asCryptoKeyAES(key);109 108 110 if (! aesKey) {109 if (!isCryptoKeyAES(key)) { 111 110 ec = NOT_SUPPORTED_ERR; 112 111 return; 113 112 } 113 const CryptoKeyAES& aesKey = toCryptoKeyAES(key); 114 114 115 transformAES_CBC(kCCDecrypt, aesCBCParameters, *aesKey, data, std::move(promise));115 transformAES_CBC(kCCDecrypt, aesCBCParameters, aesKey, data, std::move(promise)); 116 116 } 117 117 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp
r158582 r159160 96 96 { 97 97 const CryptoAlgorithmHmacParams& hmacParameters = static_cast<const CryptoAlgorithmHmacParams&>(parameters); 98 const CryptoKeyHMAC* hmacKey = asCryptoKeyHMAC(key); 98 99 if (!isCryptoKeyHMAC(key)) { 100 ec = NOT_SUPPORTED_ERR; 101 return; 102 } 103 const CryptoKeyHMAC& hmacKey = toCryptoKeyHMAC(key); 99 104 100 105 CCHmacAlgorithm algorithm; … … 104 109 } 105 110 106 if (!hmacKey) { 107 ec = NOT_SUPPORTED_ERR; 108 return; 109 } 110 111 Vector<unsigned char> signature = calculateSignature(algorithm, hmacKey->key(), data); 111 Vector<unsigned char> signature = calculateSignature(algorithm, hmacKey.key(), data); 112 112 113 113 promise->fulfill(signature); … … 117 117 { 118 118 const CryptoAlgorithmHmacParams& hmacParameters = static_cast<const CryptoAlgorithmHmacParams&>(parameters); 119 const CryptoKeyHMAC* hmacKey = asCryptoKeyHMAC(key); 119 120 if (!isCryptoKeyHMAC(key)) { 121 ec = NOT_SUPPORTED_ERR; 122 return; 123 } 124 const CryptoKeyHMAC& hmacKey = toCryptoKeyHMAC(key); 120 125 121 126 CCHmacAlgorithm algorithm; … … 125 130 } 126 131 127 if (!hmacKey) { 128 ec = NOT_SUPPORTED_ERR; 129 return; 130 } 131 132 Vector<unsigned char> signature = calculateSignature(algorithm, hmacKey->key(), data); 132 Vector<unsigned char> signature = calculateSignature(algorithm, hmacKey.key(), data); 133 133 134 134 bool result = signature.size() == expectedSignature.second && !memcmp(signature.data(), expectedSignature.first, signature.size()); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
r158494 r159160 31 31 #include "CryptoAlgorithmAES_CBC.h" 32 32 #include "CryptoAlgorithmHMAC.h" 33 #include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h" 33 34 #include "CryptoAlgorithmSHA1.h" 34 35 #include "CryptoAlgorithmSHA224.h" … … 43 44 registerAlgorithm(CryptoAlgorithmAES_CBC::s_name, CryptoAlgorithmAES_CBC::s_identifier, CryptoAlgorithmAES_CBC::create); 44 45 registerAlgorithm(CryptoAlgorithmHMAC::s_name, CryptoAlgorithmHMAC::s_identifier, CryptoAlgorithmHMAC::create); 46 registerAlgorithm(CryptoAlgorithmRSASSA_PKCS1_v1_5::s_name, CryptoAlgorithmRSASSA_PKCS1_v1_5::s_identifier, CryptoAlgorithmRSASSA_PKCS1_v1_5::create); 45 47 registerAlgorithm(CryptoAlgorithmSHA1::s_name, CryptoAlgorithmSHA1::s_identifier, CryptoAlgorithmSHA1::create); 46 48 registerAlgorithm(CryptoAlgorithmSHA224::s_name, CryptoAlgorithmSHA224::s_identifier, CryptoAlgorithmSHA224::create); -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h
r158366 r159160 36 36 class CryptoAlgorithmHmacKeyParams FINAL : public CryptoAlgorithmParameters { 37 37 public: 38 CryptoAlgorithmHmacKeyParams() 39 : hasLength(false) 40 { 41 } 42 38 43 // The inner hash function to use. 39 44 CryptoAlgorithmIdentifier hash;
Note: See TracChangeset
for help on using the changeset viewer.