Changeset 158387 in webkit
- Timestamp:
- Oct 31, 2013, 12:31:43 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r158384 r158387 1 2013-10-31 Alexey Proskuryakov <ap@apple.com> 2 3 [WebCrypto] Add SHA-1 4 https://bugs.webkit.org/show_bug.cgi?id=123582 5 6 Reviewed by Anders Carlsson. 7 8 * security/resources/common.js: Added from Blink. 9 (importTestKeys): 10 (asciiToArrayBuffer): 11 (printRejectedResult): 12 (printAcceptedResult): 13 (failAndFinishJSTest): 14 15 * security/crypto-subtle-arguments-expected.txt: Added. 16 * security/crypto-subtle-arguments.html: Added. 17 Added tests for how bindings treat crazy arguments. Heavily based on a test from Blink. 18 19 * security/crypto-subtle-sha1-expected.txt: Added. 20 * security/crypto-subtle-sha1.html: Added. 21 Test that SHA-1 works. 22 23 * TestExpectations: Skip these tests everywhere for now. 24 1 25 2013-10-31 Filip Pizlo <fpizlo@apple.com> 2 26 -
trunk/LayoutTests/TestExpectations
r158362 r158387 76 76 webkit.org/b/122679 security/crypto-subtle-gc-2.html [ Skip ] 77 77 webkit.org/b/122679 security/crypto-subtle-gc-3.html [ Skip ] 78 webkit.org/b/122679 security/crypto-subtle-sha1.html [ Skip ] 79 webkit.org/b/122679 security/crypto-subtle-arguments.html [ Skip ] 78 80 79 81 webkit.org/b/123555 [ Debug ] media/media-fragments/TC0054.html [ Crash ] -
trunk/Source/WebCore/ChangeLog
r158386 r158387 1 2013-10-31 Alexey Proskuryakov <ap@apple.com> 2 3 [WebCrypto] Add SHA-1 4 https://bugs.webkit.org/show_bug.cgi?id=123582 5 6 Reviewed by Anders Carlsson. 7 8 Tests: security/crypto-subtle-arguments.html 9 security/crypto-subtle-sha1.html 10 11 * WebCore.xcodeproj/project.pbxproj: Added new files. 12 13 * bindings/js/JSSubtleCryptoCustom.cpp: 14 (WebCore::createAlgorithmFromJSValue): 15 (WebCore::sequenceOfCryptoOperationDataFromJSValue): 16 (WebCore::JSSubtleCrypto::digest): 17 * crypto/SubtleCrypto.idl: 18 Added bindings for crypto.digest. 19 20 * crypto/algorithms: Added. 21 * crypto/algorithms/CryptoAlgorithmSHA1.cpp: Added. 22 * crypto/algorithms/CryptoAlgorithmSHA1.h: Added. 23 * crypto/mac/CryptoAlgorithmRegistryMac.cpp: 24 (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register SHA-1. 25 26 * crypto/mac/CryptoAlgorithmSHA1Mac.cpp: Added. 27 (WebCore::CryptoAlgorithmSHA1::digest): Performs the work synchronously, because 28 otherwise we'd have to copy the data first, which is crazy for something as simple 29 as hashing. We can change to a dispatch queue later if we find that it's actually 30 better to copy and do the work asynchronously. 31 1 32 2013-10-31 Sudarsana Nagineni <sudarsana.nagineni@intel.com> 2 33 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r158367 r158387 5503 5503 E11C9DB00EB3699500E409DB /* ScriptExecutionContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */; }; 5504 5504 E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E124748310AA161D00B79493 /* AuthenticationClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5505 E125F82B1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */; }; 5506 E125F82C1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = E125F82A1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h */; }; 5507 E125F82E1822CFFF00D84CD9 /* CryptoAlgorithmSHA1Mac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E125F82D1822CFFF00D84CD9 /* CryptoAlgorithmSHA1Mac.cpp */; }; 5505 5508 E12719C70EEEC16800F61213 /* NavigatorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = E12719C60EEEC16800F61213 /* NavigatorBase.h */; }; 5506 5509 E12719CA0EEEC21300F61213 /* NavigatorBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E12719C90EEEC21300F61213 /* NavigatorBase.cpp */; }; … … 12507 12510 E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptExecutionContext.cpp; sourceTree = "<group>"; }; 12508 12511 E124748310AA161D00B79493 /* AuthenticationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthenticationClient.h; sourceTree = "<group>"; }; 12512 E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmSHA1.cpp; sourceTree = "<group>"; }; 12513 E125F82A1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmSHA1.h; sourceTree = "<group>"; }; 12514 E125F82D1822CFFF00D84CD9 /* CryptoAlgorithmSHA1Mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmSHA1Mac.cpp; path = mac/CryptoAlgorithmSHA1Mac.cpp; sourceTree = "<group>"; }; 12509 12515 E12719C60EEEC16800F61213 /* NavigatorBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorBase.h; sourceTree = "<group>"; }; 12510 12516 E12719C90EEEC21300F61213 /* NavigatorBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorBase.cpp; sourceTree = "<group>"; }; … … 20133 20139 children = ( 20134 20140 E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */, 20141 E125F82D1822CFFF00D84CD9 /* CryptoAlgorithmSHA1Mac.cpp */, 20135 20142 ); 20136 20143 name = mac; … … 20140 20147 isa = PBXGroup; 20141 20148 children = ( 20149 E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */, 20150 E125F82A1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h */, 20142 20151 ); 20143 20152 path = algorithms; … … 23605 23614 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */, 23606 23615 07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */, 23616 E125F82C1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.h in Headers */, 23607 23617 A8EA800E0A19516E00A8EF5F /* MediaList.h in Headers */, 23608 23618 E44613E40CD681A200FADA75 /* MediaPlayer.h in Headers */, … … 25667 25677 85183B470AA6926100F19FA3 /* DOMHTMLParagraphElement.mm in Sources */, 25668 25678 85ECBEF80AA7626900544F0B /* DOMHTMLParamElement.mm in Sources */, 25679 E125F82B1822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp in Sources */, 25669 25680 85183B490AA6926100F19FA3 /* DOMHTMLPreElement.mm in Sources */, 25670 25681 A4226E961163D73A008B8397 /* DOMHTMLProgressElement.mm in Sources */, … … 26058 26069 A81369D7097374F600D74463 /* HTMLTextAreaElement.cpp in Sources */, 26059 26070 9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */, 26071 E125F82E1822CFFF00D84CD9 /* CryptoAlgorithmSHA1Mac.cpp in Sources */, 26060 26072 A871DC290A15205700B12A68 /* HTMLTitleElement.cpp in Sources */, 26061 26073 977B3877122883E900B81FF8 /* HTMLTokenizer.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
r157430 r158387 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CryptoAlgorithm.h" 32 #include "CryptoAlgorithmParameters.h" 33 #include "CryptoAlgorithmRegistry.h" 34 #include "Document.h" 35 #include "ExceptionCode.h" 36 #include "JSCryptoAlgorithmDictionary.h" 37 #include "JSDOMPromise.h" 38 #include <runtime/Error.h> 39 40 using namespace JSC; 41 31 42 namespace WebCore { 32 43 44 static std::unique_ptr<CryptoAlgorithm> createAlgorithmFromJSValue(ExecState* exec, JSValue value) 45 { 46 CryptoAlgorithmIdentifier algorithmIdentifier; 47 if (!JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(exec, value, algorithmIdentifier)) { 48 ASSERT(exec->hadException()); 49 return nullptr; 50 } 33 51 34 52 std::unique_ptr<CryptoAlgorithm> result(CryptoAlgorithmRegistry::shared().create(algorithmIdentifier)); 53 if (!result) 54 setDOMException(exec, NOT_SUPPORTED_ERR); 55 return result; 35 56 } 36 57 58 static bool sequenceOfCryptoOperationDataFromJSValue(ExecState* exec, JSValue value, Vector<CryptoOperationData>& result) 59 { 60 unsigned sequenceLength; 61 JSObject* sequence = toJSSequence(exec, value, sequenceLength); 62 if (!sequence) { 63 ASSERT(exec->hadException()); 64 return false; 65 } 66 67 for (unsigned i = 0; i < sequenceLength; ++i) { 68 JSValue item = sequence->get(exec, i); 69 if (ArrayBuffer* buffer = toArrayBuffer(item)) 70 result.append(std::make_pair(static_cast<char*>(buffer->data()), buffer->byteLength())); 71 else if (RefPtr<ArrayBufferView> bufferView = toArrayBufferView(item)) 72 result.append(std::make_pair(static_cast<char*>(bufferView->baseAddress()), bufferView->byteLength())); 73 else { 74 throwTypeError(exec, "Only ArrayBuffer and ArrayBufferView objects can be part of CryptoOperationData sequence"); 75 return false; 76 } 77 } 78 return true; 79 } 80 81 JSValue JSSubtleCrypto::digest(ExecState* exec) 82 { 83 if (exec->argumentCount() < 2) 84 return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec)); 85 86 std::unique_ptr<CryptoAlgorithm> algorithm = createAlgorithmFromJSValue(exec, exec->uncheckedArgument(0)); 87 if (!algorithm) { 88 ASSERT(exec->hadException()); 89 return jsUndefined(); 90 } 91 92 std::unique_ptr<CryptoAlgorithmParameters> parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(exec, algorithm->identifier(), exec->uncheckedArgument(0)); 93 if (!parameters) { 94 ASSERT(exec->hadException()); 95 return jsUndefined(); 96 } 97 98 Vector<CryptoOperationData> data; 99 if (!sequenceOfCryptoOperationDataFromJSValue(exec, exec->uncheckedArgument(1), data)) { 100 ASSERT(exec->hadException()); 101 return jsUndefined(); 102 } 103 104 JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject()); 105 std::unique_ptr<PromiseWrapper> promiseWrapper = PromiseWrapper::create(globalObject(), promise); 106 107 ExceptionCode ec = 0; 108 algorithm->digest(*parameters, data, std::move(promiseWrapper), ec); 109 if (ec) { 110 setDOMException(exec, ec); 111 return jsUndefined(); 112 } 113 114 return promise; 115 } 116 117 } // namespace WebCore 118 37 119 #endif -
trunk/Source/WebCore/crypto/SubtleCrypto.idl
r157430 r158387 31 31 OperationsNotDeletable 32 32 ] interface SubtleCrypto { 33 [Custom] Promise digest(AlgorithmIdentifier algorithm, sequence<CryptoOperationData> data); 33 34 }; -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
r158363 r158387 30 30 31 31 //#include "CryptoAlgorithmHMAC.h" 32 //#include "CryptoAlgorithmSHA1.h"32 #include "CryptoAlgorithmSHA1.h" 33 33 34 34 namespace WebCore { … … 36 36 void CryptoAlgorithmRegistry::platformRegisterAlgorithms() 37 37 { 38 // registerAlgorithm(CryptoAlgorithmHMAC:: m_name, CryptoAlgorithmHMAC::m_identifier, CryptoAlgorithmHMAC::create);39 // registerAlgorithm(CryptoAlgorithmSHA1::m_name, CryptoAlgorithmSHA1::m_identifier, CryptoAlgorithmSHA1::create);38 // registerAlgorithm(CryptoAlgorithmHMAC::s_name, CryptoAlgorithmHMAC::s_identifier, CryptoAlgorithmHMAC::create); 39 registerAlgorithm(CryptoAlgorithmSHA1::s_name, CryptoAlgorithmSHA1::s_identifier, CryptoAlgorithmSHA1::create); 40 40 } 41 41
Note:
See TracChangeset
for help on using the changeset viewer.