Changeset 209164 in webkit
- Timestamp:
- Nov 30, 2016 4:28:04 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 27 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209163 r209164 1 2016-11-26 Jiewen Tan <jiewen_tan@apple.com> 2 3 Update SubtleCrypto::digest to match the latest spec 4 https://bugs.webkit.org/show_bug.cgi?id=164742 5 <rdar://problem/29258037> 6 7 Reviewed by Darin Adler. 8 9 * crypto/subtle/digest-malformed-parameters-expected.txt: Added. 10 * crypto/subtle/digest-malformed-parameters.html: Added. 11 * crypto/subtle/sha1-digest-expected.txt: Added. 12 * crypto/subtle/sha1-digest.html: Added. 13 * crypto/subtle/sha224-digest-expected.txt: Added. 14 * crypto/subtle/sha224-digest.html: Added. 15 * crypto/subtle/sha256-digest-expected.txt: Added. 16 * crypto/subtle/sha256-digest.html: Added. 17 * crypto/subtle/sha384-digest-expected.txt: Added. 18 * crypto/subtle/sha384-digest.html: Added. 19 * crypto/subtle/sha512-digest-expected.txt: Added. 20 * crypto/subtle/sha512-digest.html: Added. 21 * crypto/workers/subtle/resources/sha1-digest.js: Added. 22 * crypto/workers/subtle/resources/sha224-digest.js: Added. 23 * crypto/workers/subtle/resources/sha256-digest.js: Added. 24 * crypto/workers/subtle/resources/sha384-digest.js: Added. 25 * crypto/workers/subtle/resources/sha512-digest.js: Added. 26 * crypto/workers/subtle/sha1-digest-expected.txt: Added. 27 * crypto/workers/subtle/sha1-digest.html: Added. 28 * crypto/workers/subtle/sha224-digest-expected.txt: Added. 29 * crypto/workers/subtle/sha224-digest.html: Added. 30 * crypto/workers/subtle/sha256-digest-expected.txt: Added. 31 * crypto/workers/subtle/sha256-digest.html: Added. 32 * crypto/workers/subtle/sha384-digest-expected.txt: Added. 33 * crypto/workers/subtle/sha384-digest.html: Added. 34 * crypto/workers/subtle/sha512-digest-expected.txt: Added. 35 * crypto/workers/subtle/sha512-digest.html: Added. 36 1 37 2016-11-30 Antoine Quint <graouts@apple.com> 2 38 -
trunk/LayoutTests/imported/w3c/ChangeLog
r209155 r209164 1 2016-11-26 Jiewen Tan <jiewen_tan@apple.com> 2 3 Update SubtleCrypto::digest to match the latest spec 4 https://bugs.webkit.org/show_bug.cgi?id=164742 5 <rdar://problem/29258037> 6 7 Reviewed by Darin Adler. 8 9 * WebCryptoAPI/digest/test_digest-expected.txt: 10 * WebCryptoAPI/idlharness-expected.txt: 11 1 12 2016-11-30 Jiewen Tan <jiewen_tan@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/WebCryptoAPI/digest/test_digest-expected.txt
r206883 r209164 2 2 3 3 4 FAIL SHA-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 5 FAIL sha-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 6 FAIL Sha-1 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 7 FAIL SHA-1 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 8 FAIL SHA-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 9 FAIL sha-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 10 FAIL Sha-256 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 11 FAIL SHA-256 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 12 FAIL SHA-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 13 FAIL sha-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 14 FAIL Sha-384 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 15 FAIL SHA-384 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 16 FAIL SHA-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 17 FAIL sha-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 18 FAIL Sha-512 with empty source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 19 FAIL SHA-512 with empty source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 20 FAIL SHA-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 21 FAIL sha-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 22 FAIL Sha-1 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 23 FAIL SHA-1 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 24 FAIL SHA-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 25 FAIL sha-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 26 FAIL Sha-256 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 27 FAIL SHA-256 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 28 FAIL SHA-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 29 FAIL sha-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 30 FAIL Sha-384 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 31 FAIL SHA-384 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 32 FAIL SHA-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 33 FAIL sha-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 34 FAIL Sha-512 with short source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 35 FAIL SHA-512 with short source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 36 FAIL SHA-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 37 FAIL sha-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 38 FAIL Sha-1 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 39 FAIL SHA-1 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 40 FAIL SHA-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 41 FAIL sha-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 42 FAIL Sha-256 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 43 FAIL SHA-256 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 44 FAIL SHA-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 45 FAIL sha-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 46 FAIL Sha-384 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 47 FAIL SHA-384 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 48 FAIL SHA-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 49 FAIL sha-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 50 FAIL Sha-512 with medium source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 51 FAIL SHA-512 with medium source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 52 FAIL SHA-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 53 FAIL sha-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 54 FAIL Sha-1 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 55 FAIL SHA-1 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 56 FAIL SHA-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 57 FAIL sha-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 58 FAIL Sha-256 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 59 FAIL SHA-256 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 60 FAIL SHA-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 61 FAIL sha-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 62 FAIL Sha-384 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 63 FAIL SHA-384 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 64 FAIL SHA-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: upCase}, sourceData[size])', 'subtle.digest' is undefined) 65 FAIL sha-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 66 FAIL Sha-512 with long source data subtle.digest is not a function. (In 'subtle.digest({name: mixedCase}, sourceData[size])', 'subtle.digest' is undefined) 67 FAIL SHA-512 with long source data and altered buffer after call subtle.digest is not a function. (In 'subtle.digest({name: upCase}, copiedBuffer)', 'subtle.digest' is undefined) 68 FAIL AES-GCM with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 69 FAIL RSA-OAEP with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 70 FAIL PBKDF2 with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 71 FAIL AES-KW with empty subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 72 FAIL AES-GCM with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 73 FAIL RSA-OAEP with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 74 FAIL PBKDF2 with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 75 FAIL AES-KW with short subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 76 FAIL AES-GCM with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 77 FAIL RSA-OAEP with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 78 FAIL PBKDF2 with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 79 FAIL AES-KW with medium subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 80 FAIL AES-GCM with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 81 FAIL RSA-OAEP with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 82 FAIL PBKDF2 with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 83 FAIL AES-KW with long subtle.digest is not a function. (In 'subtle.digest({name: badName}, sourceData[size])', 'subtle.digest' is undefined) 4 PASS SHA-1 with empty source data 5 PASS sha-1 with empty source data 6 PASS Sha-1 with empty source data 7 PASS SHA-1 with empty source data and altered buffer after call 8 PASS SHA-256 with empty source data 9 PASS sha-256 with empty source data 10 PASS Sha-256 with empty source data 11 PASS SHA-256 with empty source data and altered buffer after call 12 PASS SHA-384 with empty source data 13 PASS sha-384 with empty source data 14 PASS Sha-384 with empty source data 15 PASS SHA-384 with empty source data and altered buffer after call 16 PASS SHA-512 with empty source data 17 PASS sha-512 with empty source data 18 PASS Sha-512 with empty source data 19 PASS SHA-512 with empty source data and altered buffer after call 20 PASS SHA-1 with short source data 21 PASS sha-1 with short source data 22 PASS Sha-1 with short source data 23 PASS SHA-1 with short source data and altered buffer after call 24 PASS SHA-256 with short source data 25 PASS sha-256 with short source data 26 PASS Sha-256 with short source data 27 PASS SHA-256 with short source data and altered buffer after call 28 PASS SHA-384 with short source data 29 PASS sha-384 with short source data 30 PASS Sha-384 with short source data 31 PASS SHA-384 with short source data and altered buffer after call 32 PASS SHA-512 with short source data 33 PASS sha-512 with short source data 34 PASS Sha-512 with short source data 35 PASS SHA-512 with short source data and altered buffer after call 36 PASS SHA-1 with medium source data 37 PASS sha-1 with medium source data 38 PASS Sha-1 with medium source data 39 PASS SHA-1 with medium source data and altered buffer after call 40 PASS SHA-256 with medium source data 41 PASS sha-256 with medium source data 42 PASS Sha-256 with medium source data 43 PASS SHA-256 with medium source data and altered buffer after call 44 PASS SHA-384 with medium source data 45 PASS sha-384 with medium source data 46 PASS Sha-384 with medium source data 47 PASS SHA-384 with medium source data and altered buffer after call 48 PASS SHA-512 with medium source data 49 PASS sha-512 with medium source data 50 PASS Sha-512 with medium source data 51 PASS SHA-512 with medium source data and altered buffer after call 52 PASS SHA-1 with long source data 53 PASS sha-1 with long source data 54 PASS Sha-1 with long source data 55 PASS SHA-1 with long source data and altered buffer after call 56 PASS SHA-256 with long source data 57 PASS sha-256 with long source data 58 PASS Sha-256 with long source data 59 PASS SHA-256 with long source data and altered buffer after call 60 PASS SHA-384 with long source data 61 PASS sha-384 with long source data 62 PASS Sha-384 with long source data 63 PASS SHA-384 with long source data and altered buffer after call 64 PASS SHA-512 with long source data 65 PASS sha-512 with long source data 66 PASS Sha-512 with long source data 67 PASS SHA-512 with long source data and altered buffer after call 68 PASS AES-GCM with empty 69 PASS RSA-OAEP with empty 70 PASS PBKDF2 with empty 71 PASS AES-KW with empty 72 PASS AES-GCM with short 73 PASS RSA-OAEP with short 74 PASS PBKDF2 with short 75 PASS AES-KW with short 76 PASS AES-GCM with medium 77 PASS RSA-OAEP with medium 78 PASS PBKDF2 with medium 79 PASS AES-KW with medium 80 PASS AES-GCM with long 81 PASS RSA-OAEP with long 82 PASS PBKDF2 with long 83 PASS AES-KW with long 84 84 -
trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt
r209155 r209164 52 52 PASS SubtleCrypto interface: crypto.subtle must inherit property "verify" with the proper type (3) 53 53 PASS SubtleCrypto interface: calling verify(AlgorithmIdentifier,CryptoKey,BufferSource,BufferSource) on crypto.subtle with too few arguments must throw TypeError 54 FAIL SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4) assert_inherits: property "digest" not found in prototype chain 55 FAIL SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "digest" not found in prototype chain 54 PASS SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4) 55 PASS SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError 56 56 PASS SubtleCrypto interface: crypto.subtle must inherit property "generateKey" with the proper type (5) 57 57 PASS SubtleCrypto interface: calling generateKey(AlgorithmIdentifier,boolean,[object Object]) on crypto.subtle with too few arguments must throw TypeError -
trunk/Source/WebCore/ChangeLog
r209163 r209164 1 2016-11-26 Jiewen Tan <jiewen_tan@apple.com> 2 3 Update SubtleCrypto::digest to match the latest spec 4 https://bugs.webkit.org/show_bug.cgi?id=164742 5 <rdar://problem/29258037> 6 7 Reviewed by Darin Adler. 8 9 This patch updates the SubtleCrypto::digest method to match the latest spec: 10 https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-digest. 11 It also refers to the latest Editor's Draft to a certain degree: 12 https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-digest. 13 Currently supported digest algorithms are SHA-1, SHA-224, SHA-256, SHA-384, 14 and SHA-512. 15 16 Tests: crypto/subtle/digest-malformed-parameters.html 17 crypto/subtle/sha1-digest.html 18 crypto/subtle/sha224-digest.html 19 crypto/subtle/sha256-digest.html 20 crypto/subtle/sha384-digest.html 21 crypto/subtle/sha512-digest.html 22 crypto/workers/subtle/sha1-digest.html 23 crypto/workers/subtle/sha224-digest.html 24 crypto/workers/subtle/sha256-digest.html 25 crypto/workers/subtle/sha384-digest.html 26 crypto/workers/subtle/sha512-digest.html 27 28 * bindings/js/JSSubtleCryptoCustom.cpp: 29 (WebCore::jsSubtleCryptoFunctionDigestPromise): 30 (WebCore::JSSubtleCrypto::digest): 31 * crypto/CryptoAlgorithm.cpp: 32 (WebCore::CryptoAlgorithm::digest): 33 * crypto/CryptoAlgorithm.h: 34 * crypto/SubtleCrypto.idl: 35 * crypto/algorithms/CryptoAlgorithmSHA1.cpp: 36 (WebCore::CryptoAlgorithmSHA1::digest): 37 * crypto/algorithms/CryptoAlgorithmSHA1.h: 38 * crypto/algorithms/CryptoAlgorithmSHA224.cpp: 39 (WebCore::CryptoAlgorithmSHA224::digest): 40 * crypto/algorithms/CryptoAlgorithmSHA224.h: 41 * crypto/algorithms/CryptoAlgorithmSHA256.cpp: 42 (WebCore::CryptoAlgorithmSHA256::digest): 43 * crypto/algorithms/CryptoAlgorithmSHA256.h: 44 * crypto/algorithms/CryptoAlgorithmSHA384.cpp: 45 (WebCore::CryptoAlgorithmSHA384::digest): 46 * crypto/algorithms/CryptoAlgorithmSHA384.h: 47 * crypto/algorithms/CryptoAlgorithmSHA512.cpp: 48 (WebCore::CryptoAlgorithmSHA512::digest): 49 * crypto/algorithms/CryptoAlgorithmSHA512.h: 50 1 51 2016-11-30 Antoine Quint <graouts@apple.com> 2 52 -
trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
r209155 r209164 646 646 } 647 647 648 static void jsSubtleCryptoFunctionDigestPromise(ExecState& state, Ref<DeferredPromise>&& promise) 649 { 650 VM& vm = state.vm(); 651 auto scope = DECLARE_THROW_SCOPE(vm); 652 653 if (UNLIKELY(state.argumentCount() < 2)) { 654 promise->reject<JSValue>(createNotEnoughArgumentsError(&state)); 655 return; 656 } 657 658 auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Digest); 659 RETURN_IF_EXCEPTION(scope, void()); 660 661 auto data = toVector(state, state.uncheckedArgument(1)); 662 RETURN_IF_EXCEPTION(scope, void()); 663 664 auto algorithm = createAlgorithm(state, params->identifier); 665 RETURN_IF_EXCEPTION(scope, void()); 666 667 auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& digest) mutable { 668 fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), digest.data(), digest.size()); 669 return; 670 }; 671 auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable { 672 rejectWithException(WTFMove(capturedPromise), ec); 673 }; 674 675 auto subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue()); 676 ASSERT(subtle); 677 algorithm->digest(WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue()); 678 } 679 648 680 static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise) 649 681 { … … 911 943 } 912 944 945 JSValue JSSubtleCrypto::digest(ExecState& state) 946 { 947 return callPromiseFunction<jsSubtleCryptoFunctionDigestPromise, PromiseExecutionScope::WindowOrWorker>(state); 948 } 949 913 950 JSValue JSSubtleCrypto::generateKey(ExecState& state) 914 951 { -
trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp
r209155 r209164 49 49 50 50 void CryptoAlgorithm::verify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 51 { 52 exceptionCallback(NOT_SUPPORTED_ERR); 53 } 54 55 void CryptoAlgorithm::digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 51 56 { 52 57 exceptionCallback(NOT_SUPPORTED_ERR); -
trunk/Source/WebCore/crypto/CryptoAlgorithm.h
r209155 r209164 69 69 virtual void sign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 70 70 virtual void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 71 virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 71 72 virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&); 72 73 virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&); -
trunk/Source/WebCore/crypto/SubtleCrypto.idl
r209155 r209164 36 36 [Custom] Promise<any> sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data); 37 37 [Custom] Promise<any> verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data); 38 [Custom] Promise<any> digest(AlgorithmIdentifier algorithm, BufferSource data); 38 39 // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>? 39 40 [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp
r208669 r209164 30 30 31 31 #include "CryptoDigest.h" 32 #include "ExceptionCode.h" 33 #include "ScriptExecutionContext.h" 32 34 33 35 namespace WebCore { … … 41 43 { 42 44 return s_identifier; 45 } 46 47 void CryptoAlgorithmSHA1::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 48 { 49 auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_1); 50 if (!digest) { 51 exceptionCallback(OperationError); 52 return; 53 } 54 55 context.ref(); 56 workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable { 57 digest->addBytes(message.data(), message.size()); 58 auto result = digest->computeHash(); 59 context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) { 60 callback(result); 61 context.deref(); 62 }); 63 }); 43 64 } 44 65 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h
r208669 r209164 41 41 CryptoAlgorithmSHA1() = default; 42 42 CryptoAlgorithmIdentifier identifier() const final; 43 void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 43 44 ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; 44 45 }; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.cpp
r208669 r209164 30 30 31 31 #include "CryptoDigest.h" 32 #include "ExceptionCode.h" 33 #include "ScriptExecutionContext.h" 32 34 33 35 namespace WebCore { … … 41 43 { 42 44 return s_identifier; 45 } 46 47 void CryptoAlgorithmSHA224::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 48 { 49 auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_224); 50 if (!digest) { 51 exceptionCallback(OperationError); 52 return; 53 } 54 55 context.ref(); 56 workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable { 57 digest->addBytes(message.data(), message.size()); 58 auto result = digest->computeHash(); 59 context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) { 60 callback(result); 61 context.deref(); 62 }); 63 }); 43 64 } 44 65 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA224.h
r208669 r209164 41 41 CryptoAlgorithmSHA224() = default; 42 42 CryptoAlgorithmIdentifier identifier() const final; 43 void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 43 44 ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; 44 45 }; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.cpp
r208669 r209164 30 30 31 31 #include "CryptoDigest.h" 32 #include "ExceptionCode.h" 33 #include "ScriptExecutionContext.h" 32 34 33 35 namespace WebCore { … … 41 43 { 42 44 return s_identifier; 45 } 46 47 void CryptoAlgorithmSHA256::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 48 { 49 auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_256); 50 if (!digest) { 51 exceptionCallback(OperationError); 52 return; 53 } 54 55 context.ref(); 56 workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable { 57 digest->addBytes(message.data(), message.size()); 58 auto result = digest->computeHash(); 59 context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) { 60 callback(result); 61 context.deref(); 62 }); 63 }); 43 64 } 44 65 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA256.h
r208669 r209164 41 41 CryptoAlgorithmSHA256() = default; 42 42 CryptoAlgorithmIdentifier identifier() const final; 43 void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 43 44 ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; 44 45 }; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.cpp
r208669 r209164 30 30 31 31 #include "CryptoDigest.h" 32 #include "ExceptionCode.h" 33 #include "ScriptExecutionContext.h" 32 34 33 35 namespace WebCore { … … 41 43 { 42 44 return s_identifier; 45 } 46 47 void CryptoAlgorithmSHA384::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 48 { 49 auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_384); 50 if (!digest) { 51 exceptionCallback(OperationError); 52 return; 53 } 54 55 context.ref(); 56 workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable { 57 digest->addBytes(message.data(), message.size()); 58 auto result = digest->computeHash(); 59 context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) { 60 callback(result); 61 context.deref(); 62 }); 63 }); 43 64 } 44 65 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA384.h
r208669 r209164 41 41 CryptoAlgorithmSHA384() = default; 42 42 CryptoAlgorithmIdentifier identifier() const final; 43 void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 43 44 ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; 44 45 }; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.cpp
r208669 r209164 30 30 31 31 #include "CryptoDigest.h" 32 #include "ExceptionCode.h" 33 #include "ScriptExecutionContext.h" 32 34 33 35 namespace WebCore { … … 41 43 { 42 44 return s_identifier; 45 } 46 47 void CryptoAlgorithmSHA512::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 48 { 49 auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_512); 50 if (!digest) { 51 exceptionCallback(OperationError); 52 return; 53 } 54 55 context.ref(); 56 workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable { 57 digest->addBytes(message.data(), message.size()); 58 auto result = digest->computeHash(); 59 context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) { 60 callback(result); 61 context.deref(); 62 }); 63 }); 43 64 } 44 65 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA512.h
r208669 r209164 41 41 CryptoAlgorithmSHA512() = default; 42 42 CryptoAlgorithmIdentifier identifier() const final; 43 void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 43 44 ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final; 44 45 };
Note: See TracChangeset
for help on using the changeset viewer.