Update SubtleCrypto::encrypt to match the latest spec
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Nov 2016 21:31:42 +0000 (21:31 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Nov 2016 21:31:42 +0000 (21:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164738
<rdar://problem/29257812>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt:
* WebCryptoAPI/encrypt_decrypt/test_aes_ctr-expected.txt:
* WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt:
* WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt:
* WebCryptoAPI/idlharness-expected.txt:

Source/WebCore:

This patch does following few things:
1. It updates the SubtleCrypto::encrypt method to match the latest spec:
   https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-encrypt.
   It also refers to the latest Editor's Draft to a certain degree:
   https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-encrypt.
2. It implements encrypt operations of the following algorithms: AES-CBC,
   RSAES-PKCS1-V1_5, and RSA-OAEP.
3. It addes ASSERT(parameters) for every method that accepts a
   std::unique_ptr<CryptoAlgorithmParameters>&& type parameter.
4. It changes RefPtr<CryptoKey>&& to Ref<CryptoKey>&& for every method that
   accepts a CryptoKey.

Tests: crypto/subtle/aes-cbc-encrypt-malformed-parameters.html
       crypto/subtle/aes-cbc-import-key-encrypt.html
       crypto/subtle/encrypt-malformed-parameters.html
       crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html
       crypto/subtle/rsa-oaep-import-key-encrypt-label.html
       crypto/subtle/rsa-oaep-import-key-encrypt.html
       crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html
       crypto/workers/subtle/aes-cbc-import-key-encrypt.html
       crypto/workers/subtle/rsa-oaep-import-key-encrypt.html
       crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/BufferSource.h:
(WebCore::BufferSource::BufferSource):
Add a default constructor for initializing an empty BufferSource object.
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionEncryptPromise):
(WebCore::JSSubtleCrypto::encrypt):
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::encrypt):
(WebCore::CryptoAlgorithm::exportKey):
* crypto/CryptoAlgorithm.h:
* crypto/CryptoAlgorithmParameters.h:
* crypto/CryptoKey.h:
* crypto/SubtleCrypto.cpp:
(WebCore::SubtleCrypto::SubtleCrypto):
* crypto/SubtleCrypto.h:
(WebCore::SubtleCrypto::workQueue):
* crypto/SubtleCrypto.idl:
* crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp:
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
* crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
* crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
* crypto/gnutls/CryptoKeyRSAGnuTLS.cpp:
(WebCore::CryptoKeyRSA::generatePair):
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::encrypt):
(WebCore::CryptoAlgorithmAES_CBC::generateKey):
(WebCore::CryptoAlgorithmAES_CBC::importKey):
(WebCore::CryptoAlgorithmAES_CBC::exportKey):
* crypto/algorithms/CryptoAlgorithmAES_CBC.h:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::generateKey):
(WebCore::CryptoAlgorithmAES_KW::importKey):
(WebCore::CryptoAlgorithmAES_KW::exportKey):
* crypto/algorithms/CryptoAlgorithmAES_KW.h:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::generateKey):
(WebCore::CryptoAlgorithmHMAC::importKey):
(WebCore::CryptoAlgorithmHMAC::exportKey):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::generateKey):
(WebCore::CryptoAlgorithmRSA_OAEP::importKey):
(WebCore::CryptoAlgorithmRSA_OAEP::exportKey):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
* crypto/keys/CryptoKeyRSA.h:
* crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
(WebCore::transformAES_CBC):
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
* crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
(WebCore::encryptRSAES_PKCS1_v1_5):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
* crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
(WebCore::encryptRSA_OAEP):
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::generatePair):
* crypto/parameters/AesCbcParams.idl: Added.
* crypto/parameters/CryptoAlgorithmAesCbcParams.h: Added.
* crypto/parameters/CryptoAlgorithmAesCbcParamsDeprecated.h:
* crypto/parameters/CryptoAlgorithmRsaOaepParams.h: Added.
* crypto/parameters/RsaOaepParams.idl: Added.

LayoutTests:

* TestExpectations:
* crypto/subtle/aes-cbc-encrypt-malformed-parameters-expected.txt: Added.
* crypto/subtle/aes-cbc-encrypt-malformed-parameters.html: Added.
* crypto/subtle/aes-cbc-import-key-encrypt-expected.txt: Added.
* crypto/subtle/aes-cbc-import-key-encrypt.html: Added.
* crypto/subtle/encrypt-malformed-parameters-expected.txt: Added.
* crypto/subtle/encrypt-malformed-parameters.html: Added.
* crypto/subtle/rsa-oaep-encrypt-malformed-parameters-expected.txt: Added.
* crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html: Added.
* crypto/subtle/rsa-oaep-import-key-encrypt-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-key-encrypt-label-expected.txt: Added.
* crypto/subtle/rsa-oaep-import-key-encrypt-label.html: Added.
* crypto/subtle/rsa-oaep-import-key-encrypt.html: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt: Added.
* crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html: Added.
* crypto/workers/subtle/aes-cbc-import-key-encrypt-expected.txt: Added.
* crypto/workers/subtle/aes-cbc-import-key-encrypt.html: Added.
* crypto/workers/subtle/resources/aes-cbc-import-key-encrypt.js: Added.
* crypto/workers/subtle/resources/rsa-oaep-import-key-encrypt.js: Added.
* crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-encrypt.js: Added.
* crypto/workers/subtle/rsa-oaep-import-key-encrypt-expected.txt: Added.
* crypto/workers/subtle/rsa-oaep-import-key-encrypt.html: Added.
* crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt: Added.
* crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208891 268f45cc-cd09-0410-ab3c-d52691b4dbfc

70 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/crypto/subtle/aes-cbc-encrypt-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-encrypt-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/subtle/encrypt-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/encrypt-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-encrypt-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-label-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-label.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-cbc-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-cbc-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-encrypt.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-encrypt.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-encrypt.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt
LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_ctr-expected.txt
LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt
LayoutTests/imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt
LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/BufferSource.h
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/crypto/CryptoAlgorithm.cpp
Source/WebCore/crypto/CryptoAlgorithm.h
Source/WebCore/crypto/CryptoAlgorithmParameters.h
Source/WebCore/crypto/CryptoKey.h
Source/WebCore/crypto/SubtleCrypto.cpp
Source/WebCore/crypto/SubtleCrypto.h
Source/WebCore/crypto/SubtleCrypto.idl
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h
Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp
Source/WebCore/crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp
Source/WebCore/crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp
Source/WebCore/crypto/gnutls/CryptoKeyRSAGnuTLS.cpp
Source/WebCore/crypto/keys/CryptoKeyRSA.h
Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp
Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp
Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp
Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp
Source/WebCore/crypto/parameters/AesCbcParams.idl [new file with mode: 0644]
Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h [new file with mode: 0644]
Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParamsDeprecated.h
Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h [new file with mode: 0644]
Source/WebCore/crypto/parameters/RsaOaepParams.idl [new file with mode: 0644]

index b124733..84c6023 100644 (file)
@@ -1,3 +1,36 @@
+2016-11-17  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update SubtleCrypto::encrypt to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164738
+        <rdar://problem/29257812>
+
+        Reviewed by Brent Fulgham.
+
+        * TestExpectations:
+        * crypto/subtle/aes-cbc-encrypt-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/aes-cbc-encrypt-malformed-parameters.html: Added.
+        * crypto/subtle/aes-cbc-import-key-encrypt-expected.txt: Added.
+        * crypto/subtle/aes-cbc-import-key-encrypt.html: Added.
+        * crypto/subtle/encrypt-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/encrypt-malformed-parameters.html: Added.
+        * crypto/subtle/rsa-oaep-encrypt-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html: Added.
+        * crypto/subtle/rsa-oaep-import-key-encrypt-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-key-encrypt-label-expected.txt: Added.
+        * crypto/subtle/rsa-oaep-import-key-encrypt-label.html: Added.
+        * crypto/subtle/rsa-oaep-import-key-encrypt.html: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt: Added.
+        * crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html: Added.
+        * crypto/workers/subtle/aes-cbc-import-key-encrypt-expected.txt: Added.
+        * crypto/workers/subtle/aes-cbc-import-key-encrypt.html: Added.
+        * crypto/workers/subtle/resources/aes-cbc-import-key-encrypt.js: Added.
+        * crypto/workers/subtle/resources/rsa-oaep-import-key-encrypt.js: Added.
+        * crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-encrypt.js: Added.
+        * crypto/workers/subtle/rsa-oaep-import-key-encrypt-expected.txt: Added.
+        * crypto/workers/subtle/rsa-oaep-import-key-encrypt.html: Added.
+        * crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt: Added.
+        * crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html: Added.
+
 2016-11-18  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [CSS Font Loading] FontFaceSet.load() promises don't always fire
index b03d312..ab3d51b 100644 (file)
@@ -919,12 +919,7 @@ webkit.org/b/159678 http/tests/preload/single_download_preload_runner.html [ Tim
 # This test is just way too slow.
 workers/bomb-with-v8.html [ Skip ]
 
-# WebCryptoAPI tests, skip for unimplemented features. webkit.org/b/159638
-imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_cbc.html [ Skip ]
-imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_ctr.html [ Skip ]
-imported/w3c/WebCryptoAPI/encrypt_decrypt/test_aes_gcm.html [ Skip ]
-imported/w3c/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep.html [ Skip ]
-# Take too long to complete, need to scale down.
+# WebCryptoAPI tests that take too long to complete, need to scale down. webkit.org/b/159638
 imported/w3c/WebCryptoAPI/generateKey/test_failures.html [ Slow ]
 imported/w3c/WebCryptoAPI/generateKey/test_successes_RSA-OAEP.html [ Skip ]
 imported/w3c/WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.html [ Slow ]
diff --git a/LayoutTests/crypto/subtle/aes-cbc-encrypt-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-encrypt-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..313d962
--- /dev/null
@@ -0,0 +1,21 @@
+Test encrypting using AES-CBC with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.encrypt("aes-cbc", key, plainText) rejected promise  with TypeError: Member AesCbcParams.iv is required and must be an instance of BufferSource.
+PASS crypto.subtle.encrypt({name: "aes-cbc"}, key, plainText) rejected promise  with TypeError: Member AesCbcParams.iv is required and must be an instance of BufferSource.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: true}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: 1}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: null}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: undefined}, key, plainText) rejected promise  with TypeError: Member AesCbcParams.iv is required and must be an instance of BufferSource.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: Symbol()}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: { }}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: "foo"}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: asciiToUint8Array("")}, key, plainText) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: asciiToUint8Array("j")}, key, plainText) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd")}, key, plainText) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-encrypt-malformed-parameters.html b/LayoutTests/crypto/subtle/aes-cbc-encrypt-malformed-parameters.html
new file mode 100644 (file)
index 0000000..9b0b3fb
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting using AES-CBC with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]).then(function(result) {
+    key = result;
+    // Malformed AlgorithmIdentifiers
+    shouldReject('crypto.subtle.encrypt("aes-cbc", key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc"}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: true}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: 1}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: null}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: undefined}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: Symbol()}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: { }}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: "foo"}, key, plainText)');
+    // Wrong iv length
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: asciiToUint8Array("")}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: asciiToUint8Array("j")}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "aes-cbc", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd")}, key, plainText)');
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt-expected.txt b/LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt-expected.txt
new file mode 100644 (file)
index 0000000..322e1aa
--- /dev/null
@@ -0,0 +1,10 @@
+Test encrypting using AES-CBC with an imported 128bit key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bytesToHexString(cipherText) is expectedCipherText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt.html b/LayoutTests/crypto/subtle/aes-cbc-import-key-encrypt.html
new file mode 100644 (file)
index 0000000..f4a14e6
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting using AES-CBC with an imported 128bit key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var aesCbcParams = {
+    name: "aes-cbc",
+    iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var expectedCipherText = "2ffa4618784dfd414b22c40c6330d022";
+
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt(aesCbcParams, key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("bytesToHexString(cipherText)", "expectedCipherText");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/encrypt-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/encrypt-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..bed02ca
--- /dev/null
@@ -0,0 +1,15 @@
+Test encrypting with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.encrypt() rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.encrypt(1) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.encrypt(1, 2) rejected promise  with TypeError: Not enough arguments.
+PASS crypto.subtle.encrypt(aesCbcParams, fakedKey, plainText) rejected promise  with TypeError: Invalid CryptoKey.
+PASS crypto.subtle.encrypt(aesCbcParams, wrongKey, plainText) rejected promise  with InvalidAccessError (DOM Exception 15): CryptoKey doesn't match AlgorithmIdentifier.
+PASS crypto.subtle.encrypt(aesCbcParams, wrongKey, plainText) rejected promise  with InvalidAccessError (DOM Exception 15): CryptoKey doesn't support encryption.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/encrypt-malformed-parameters.html b/LayoutTests/crypto/subtle/encrypt-malformed-parameters.html
new file mode 100644 (file)
index 0000000..c0ff089
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var aesCbcParams = {
+    name: "aes-cbc",
+    iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var fakedKey = {
+    type: "secret",
+    extractable: true,
+    algorithm: {name: "AES-CBC", length: 128},
+    usages: ["encrypt", "decrypt"]
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.encrypt()');
+shouldReject('crypto.subtle.encrypt(1)');
+shouldReject('crypto.subtle.encrypt(1, 2)');
+// Wrong CryptoKey.
+shouldReject('crypto.subtle.encrypt(aesCbcParams, fakedKey, plainText)');
+
+crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+    wrongKey = result;
+    // Wrong algorithm identifier.
+    shouldReject('crypto.subtle.encrypt(aesCbcParams, wrongKey, plainText)');
+
+    return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey", "unwrapKey"]);
+}).then(function(result) {
+    wrongKey = result;
+    // Wrong usage.
+    return shouldReject('crypto.subtle.encrypt(aesCbcParams, wrongKey, plainText)');
+}).then(finishJSTest);
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-encrypt-malformed-parameters-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-encrypt-malformed-parameters-expected.txt
new file mode 100644 (file)
index 0000000..ef3531b
--- /dev/null
@@ -0,0 +1,15 @@
+Test encrypting using RSA-OAEP with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.encrypt({name: "RSA-OAEP", label: true}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "RSA-OAEP", label: 1}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "RSA-OAEP", label: null}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "RSA-OAEP", label: Symbol()}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "RSA-OAEP", label: { }}, key, plainText) rejected promise  with TypeError: Type error.
+PASS crypto.subtle.encrypt({name: "RSA-OAEP", label: "foo"}, key, plainText) rejected promise  with TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html b/LayoutTests/crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html
new file mode 100644 (file)
index 0000000..a7df54b
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting using RSA-OAEP with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt"]).then(function(result) {
+    key = result;
+    // Malformed AlgorithmIdentifiers
+    shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: true}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: 1}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: null}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: Symbol()}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: { }}, key, plainText)');
+    shouldReject('crypto.subtle.encrypt({name: "RSA-OAEP", label: "foo"}, key, plainText)');
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-expected.txt
new file mode 100644 (file)
index 0000000..308900d
--- /dev/null
@@ -0,0 +1,10 @@
+Test encrypting using RSA-OAEP SHA-1 with an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS cipherText.byteLength is 256
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-label-expected.txt b/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-label-expected.txt
new file mode 100644 (file)
index 0000000..1a26cb3
--- /dev/null
@@ -0,0 +1,10 @@
+Test encrypting using RSA-OAEP SHA-1 with an imported key and a label
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS cipherText.byteLength is 256
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-label.html b/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt-label.html
new file mode 100644 (file)
index 0000000..d87590a
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting using RSA-OAEP SHA-1 with an imported key and a label");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var rsaOaepParams = {
+    name: "rsa-oaep",
+    label: asciiToUint8Array("WebKit.org"),
+}
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt(rsaOaepParams, key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("cipherText.byteLength", "256");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt.html b/LayoutTests/crypto/subtle/rsa-oaep-import-key-encrypt.html
new file mode 100644 (file)
index 0000000..2099c85
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting using RSA-OAEP SHA-1 with an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var rsaOaepParams = {
+    name: "rsa-oaep"
+}
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt(rsaOaepParams, key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("cipherText.byteLength", "256");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt
new file mode 100644 (file)
index 0000000..6df7412
--- /dev/null
@@ -0,0 +1,10 @@
+Test encrypting using RSAES-PKCS1-v1_5 with an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS cipherText.byteLength is 256
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html b/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html
new file mode 100644 (file)
index 0000000..b4321e3
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test encrypting using RSAES-PKCS1-v1_5 with an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA1_5",
+    use: "enc",
+    key_ops: ["encrypt"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt("RSAES-PKCS1-v1_5", key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("cipherText.byteLength", "256");
+
+    finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-encrypt-expected.txt b/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-encrypt-expected.txt
new file mode 100644 (file)
index 0000000..cd7f9fa
--- /dev/null
@@ -0,0 +1,11 @@
+[Worker] Test encrypting using AES-CBC with an imported 128bit key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/aes-cbc-import-key-encrypt.js
+PASS [Worker] bytesToHexString(cipherText) is expectedCipherText
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-encrypt.html b/LayoutTests/crypto/workers/subtle/aes-cbc-import-key-encrypt.html
new file mode 100644 (file)
index 0000000..ff65758
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/aes-cbc-import-key-encrypt.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-encrypt.js b/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-encrypt.js
new file mode 100644 (file)
index 0000000..ffd73ec
--- /dev/null
@@ -0,0 +1,25 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test encrypting using AES-CBC with an imported 128bit key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var aesCbcParams = {
+    name: "aes-cbc",
+    iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var expectedCipherText = "2ffa4618784dfd414b22c40c6330d022";
+
+crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt(aesCbcParams, key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("bytesToHexString(cipherText)", "expectedCipherText");
+
+    finishJSTest();
+});
\ No newline at end of file
diff --git a/LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-encrypt.js b/LayoutTests/crypto/workers/subtle/resources/rsa-oaep-import-key-encrypt.js
new file mode 100644 (file)
index 0000000..47423ef
--- /dev/null
@@ -0,0 +1,32 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test encrypting using RSA-OAEP SHA-1 with an imported key and a label in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA-OAEP",
+    use: "enc",
+    key_ops: ["encrypt", "wrapKey"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+var rsaOaepParams = {
+    name: "rsa-oaep",
+    label: asciiToUint8Array("WebKit.org"),
+}
+
+crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt(rsaOaepParams, key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("cipherText.byteLength", "256");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-encrypt.js b/LayoutTests/crypto/workers/subtle/resources/rsaes-pkcs1-v1_5-import-key-encrypt.js
new file mode 100644 (file)
index 0000000..3f341a0
--- /dev/null
@@ -0,0 +1,28 @@
+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test encrypting using RSAES-PKCS1-v1_5 with an imported key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var plainText = asciiToUint8Array("Hello, World!");
+var jwkKey = {
+    kty: "RSA",
+    alg: "RSA1_5",
+    use: "enc",
+    key_ops: ["encrypt"],
+    ext: true,
+    n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+    e: "AQAB"
+};
+
+crypto.subtle.importKey("jwk", jwkKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]).then(function(key) {
+    return crypto.subtle.encrypt("RSAES-PKCS1-v1_5", key, plainText);
+}).then(function(result) {
+    cipherText = result;
+
+    shouldBe("cipherText.byteLength", "256");
+
+    finishJSTest();
+});
diff --git a/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-encrypt-expected.txt b/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-encrypt-expected.txt
new file mode 100644 (file)
index 0000000..c0304f3
--- /dev/null
@@ -0,0 +1,11 @@
+[Worker] Test encrypting using RSA-OAEP SHA-1 with an imported key and a label in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsa-oaep-import-key-encrypt.js
+PASS [Worker] cipherText.byteLength is 256
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-encrypt.html b/LayoutTests/crypto/workers/subtle/rsa-oaep-import-key-encrypt.html
new file mode 100644 (file)
index 0000000..29082c3
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/rsa-oaep-import-key-encrypt.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt b/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt-expected.txt
new file mode 100644 (file)
index 0000000..0325862
--- /dev/null
@@ -0,0 +1,11 @@
+[Worker] Test encrypting using RSAES-PKCS1-v1_5 with an imported key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsaes-pkcs1-v1_5-import-key-encrypt.js
+PASS [Worker] cipherText.byteLength is 256
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html b/LayoutTests/crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html
new file mode 100644 (file)
index 0000000..1d7d642
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <script>
+        worker = startWorker('resources/rsaes-pkcs1-v1_5-import-key-encrypt.js');
+    </script>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index 24f1c00..8b4ebf2 100644 (file)
@@ -1,3 +1,17 @@
+2016-11-17  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update SubtleCrypto::encrypt to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164738
+        <rdar://problem/29257812>
+
+        Reviewed by Brent Fulgham.
+
+        * WebCryptoAPI/encrypt_decrypt/test_aes_cbc-expected.txt:
+        * WebCryptoAPI/encrypt_decrypt/test_aes_ctr-expected.txt:
+        * WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt:
+        * WebCryptoAPI/encrypt_decrypt/test_rsa_oaep-expected.txt:
+        * WebCryptoAPI/idlharness-expected.txt:
+
 2016-11-17  Alex Christensen  <achristensen@webkit.org>
 
         Implement TextDecoder and TextEncoder
index edb07f4..c4ad357 100644 (file)
@@ -1,3 +1,46 @@
-CONSOLE MESSAGE: line 285: TypeError: undefined is not an object (evaluating 'subtle.importKey')
-FAIL: Timed out waiting for notifyDone to be called
+encrypt Tests for AES-CBC
+
+
+PASS AES-CBC 128-bit key 
+PASS AES-CBC 192-bit key 
+PASS AES-CBC 256-bit key 
+PASS AES-CBC 128-bit key with altered plaintext 
+PASS AES-CBC 192-bit key with altered plaintext 
+PASS AES-CBC 256-bit key with altered plaintext 
+FAIL AES-CBC 128-bit key decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 128-bit key decryption with altered ciphertext subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, ciphertext)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key decryption with altered ciphertext subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, ciphertext)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key decryption with altered ciphertext subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, ciphertext)', 'subtle.decrypt' is undefined)
+PASS AES-CBC 128-bit key without encrypt usage 
+PASS AES-CBC 192-bit key without encrypt usage 
+PASS AES-CBC 256-bit key without encrypt usage 
+FAIL AES-CBC 128-bit key with mismatched key and algorithm assert_equals: Mismatch should cause InvalidAccessError instead of The operation is not supported. expected "InvalidAccessError" but got "NotSupportedError"
+FAIL AES-CBC 192-bit key with mismatched key and algorithm assert_equals: Mismatch should cause InvalidAccessError instead of The operation is not supported. expected "InvalidAccessError" but got "NotSupportedError"
+FAIL AES-CBC 256-bit key with mismatched key and algorithm assert_equals: Mismatch should cause InvalidAccessError instead of The operation is not supported. expected "InvalidAccessError" but got "NotSupportedError"
+FAIL AES-CBC 128-bit key without decrypt usage subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key without decrypt usage subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key without decrypt usage subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+PASS AES-CBC 128-bit key, 64-bit IV 
+PASS AES-CBC 128-bit key, 192-bit IV 
+PASS AES-CBC 192-bit key, 64-bit IV 
+PASS AES-CBC 192-bit key, 192-bit IV 
+PASS AES-CBC 256-bit key, 64-bit IV 
+PASS AES-CBC 256-bit key, 192-bit IV 
+FAIL AES-CBC 128-bit key, 64-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 128-bit key, 192-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key, 64-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key, 192-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key, 64-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key, 192-bit IV decryption subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 128-bit key, zeroPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 128-bit key, bigPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 128-bit key, inconsistentPadChars subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key, zeroPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key, bigPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 192-bit key, inconsistentPadChars subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key, zeroPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key, bigPadChar subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
+FAIL AES-CBC 256-bit key, inconsistentPadChars subtle.decrypt is not a function. (In 'subtle.decrypt(vector.algorithm, vector.key, vector.result)', 'subtle.decrypt' is undefined)
 
index edb07f4..4ef9073 100644 (file)
@@ -1,3 +1,37 @@
-CONSOLE MESSAGE: line 285: TypeError: undefined is not an object (evaluating 'subtle.importKey')
-FAIL: Timed out waiting for notifyDone to be called
+encrypt Tests for AES-CTR
+
+
+FAIL importKey step: AES-CTR 128-bit key assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 128-bit key with altered plaintext assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key with altered plaintext assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key with altered plaintext assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step for decryption: AES-CTR 128-bit key assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step for decryption: AES-CTR 192-bit key assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step for decryption: AES-CTR 256-bit key assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step for decryption: AES-CTR 128-bit key with altered ciphertext assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step for decryption: AES-CTR 192-bit key with altered ciphertext assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step for decryption: AES-CTR 256-bit key with altered ciphertext assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 128-bit key without encrypt usage assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key without encrypt usage assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key without encrypt usage assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 128-bit key with mismatched key and algorithm assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key with mismatched key and algorithm assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key with mismatched key and algorithm assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 128-bit key without decrypt usage assert_unreached: importKey failed for AES-CTR 128-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key without decrypt usage assert_unreached: importKey failed for AES-CTR 192-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key without decrypt usage assert_unreached: importKey failed for AES-CTR 256-bit key Reached unreachable code
+FAIL importKey step: AES-CTR 128-bit key, 0-bit counter assert_unreached: importKey failed for AES-CTR 128-bit key, 0-bit counter Reached unreachable code
+FAIL importKey step: AES-CTR 128-bit key, 129-bit counter assert_unreached: importKey failed for AES-CTR 128-bit key, 129-bit counter Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key, 0-bit counter assert_unreached: importKey failed for AES-CTR 192-bit key, 0-bit counter Reached unreachable code
+FAIL importKey step: AES-CTR 192-bit key, 129-bit counter assert_unreached: importKey failed for AES-CTR 192-bit key, 129-bit counter Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key, 0-bit counter assert_unreached: importKey failed for AES-CTR 256-bit key, 0-bit counter Reached unreachable code
+FAIL importKey step: AES-CTR 256-bit key, 129-bit counter assert_unreached: importKey failed for AES-CTR 256-bit key, 129-bit counter Reached unreachable code
+FAIL importKey step: decryption AES-CTR 128-bit key, 0-bit counter assert_unreached: importKey failed for AES-CTR 128-bit key, 0-bit counter Reached unreachable code
+FAIL importKey step: decryption AES-CTR 128-bit key, 129-bit counter assert_unreached: importKey failed for AES-CTR 128-bit key, 129-bit counter Reached unreachable code
+FAIL importKey step: decryption AES-CTR 192-bit key, 0-bit counter assert_unreached: importKey failed for AES-CTR 192-bit key, 0-bit counter Reached unreachable code
+FAIL importKey step: decryption AES-CTR 192-bit key, 129-bit counter assert_unreached: importKey failed for AES-CTR 192-bit key, 129-bit counter Reached unreachable code
+FAIL importKey step: decryption AES-CTR 256-bit key, 0-bit counter assert_unreached: importKey failed for AES-CTR 256-bit key, 0-bit counter Reached unreachable code
+FAIL importKey step: decryption AES-CTR 256-bit key, 129-bit counter assert_unreached: importKey failed for AES-CTR 256-bit key, 129-bit counter Reached unreachable code
 
index edb07f4..42f6a61 100644 (file)
@@ -1,3 +1,334 @@
-CONSOLE MESSAGE: line 285: TypeError: undefined is not an object (evaluating 'subtle.importKey')
-FAIL: Timed out waiting for notifyDone to be called
+encrypt Tests for AES-GCM
+
+
+FAIL importKey step: AES-GCM 128-bit key, 32-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 32-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 64-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 64-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 96-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 96-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 104-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 104-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 112-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 112-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 120-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 120-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 128-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 128-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 32-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 32-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 64-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 64-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 96-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 96-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 104-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 104-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 112-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 112-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 120-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 120-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 128-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 128-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 32-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 32-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 64-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 64-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 96-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 96-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 104-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 104-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 112-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 112-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 120-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 120-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 128-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 128-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 32-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 32-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 64-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 64-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 96-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 96-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 104-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 104-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 112-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 112-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 120-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 120-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 128-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 128-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 32-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 32-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 64-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 64-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 96-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 96-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 104-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 104-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 112-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 112-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 120-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 120-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 128-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 128-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 32-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 32-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 64-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 64-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 96-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 96-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 104-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 104-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 112-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 112-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 120-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 120-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 128-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 128-bit tag with altered plaintext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 32-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 32-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 64-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 64-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 96-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 96-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 104-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 104-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 112-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 112-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 120-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 120-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 128-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 128-bit tag assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 32-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 32-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 64-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 64-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 96-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 96-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 104-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 104-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 112-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 112-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 120-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 120-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 128-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 128-bit tag assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 32-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 32-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 64-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 64-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 96-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 96-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 104-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 104-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 112-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 112-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 120-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 120-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 128-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 128-bit tag assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 32-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 32-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 64-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 64-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 96-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 96-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 104-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 104-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 112-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 112-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 120-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 120-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, 128-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 128-bit key, no additional data, 128-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 32-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 32-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 64-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 64-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 96-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 96-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 104-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 104-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 112-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 112-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 120-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 120-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, 128-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 192-bit key, no additional data, 128-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 32-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 32-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 64-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 64-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 96-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 96-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 104-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 104-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 112-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 112-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 120-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 120-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, 128-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step for decryption: AES-GCM 256-bit key, no additional data, 128-bit tag with altered ciphertext assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 32-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 32-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 64-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 64-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 96-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 96-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 104-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 104-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 112-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 112-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 120-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 120-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 128-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 128-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 32-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 32-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 64-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 64-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 96-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 96-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 104-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 104-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 112-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 112-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 120-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 120-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 128-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 128-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 32-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 32-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 64-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 64-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 96-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 96-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 104-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 104-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 112-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 112-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 120-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 120-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 128-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 128-bit tag without encrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 32-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 32-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 64-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 64-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 96-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 96-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 104-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 104-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 112-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 112-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 120-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 120-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 128-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 128-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 32-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 32-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 64-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 64-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 96-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 96-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 104-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 104-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 112-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 112-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 120-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 120-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 128-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 128-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 32-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 32-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 64-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 64-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 96-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 96-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 104-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 104-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 112-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 112-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 120-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 120-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 128-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 128-bit tag with mismatched key and algorithm assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 32-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 32-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 64-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 64-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 96-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 96-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 104-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 104-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 112-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 112-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 120-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 120-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, 128-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, no additional data, 128-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 128-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 32-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 32-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 64-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 64-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 96-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 96-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 104-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 104-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 112-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 112-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 120-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 120-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, 128-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, no additional data, 128-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 192-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 32-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 32-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 32-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 64-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 64-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 64-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 96-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 96-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 96-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 104-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 104-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 104-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 112-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 112-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 112-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 120-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 120-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 120-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, 128-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, no additional data, 128-bit tag without decrypt usage assert_unreached: importKey failed for AES-GCM 256-bit key, no additional data, 128-bit tag Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, illegal tag length 24-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 24-bits Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, illegal tag length 48-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 48-bits Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, illegal tag length 72-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 72-bits Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, illegal tag length 95-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 95-bits Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, illegal tag length 129-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 129-bits Reached unreachable code
+FAIL importKey step: AES-GCM 128-bit key, illegal tag length 256-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 256-bits Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, illegal tag length 24-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 24-bits Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, illegal tag length 48-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 48-bits Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, illegal tag length 72-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 72-bits Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, illegal tag length 95-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 95-bits Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, illegal tag length 129-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 129-bits Reached unreachable code
+FAIL importKey step: AES-GCM 192-bit key, illegal tag length 256-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 256-bits Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, illegal tag length 24-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 24-bits Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, illegal tag length 48-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 48-bits Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, illegal tag length 72-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 72-bits Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, illegal tag length 95-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 95-bits Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, illegal tag length 129-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 129-bits Reached unreachable code
+FAIL importKey step: AES-GCM 256-bit key, illegal tag length 256-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 256-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 128-bit key, illegal tag length 24-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 24-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 128-bit key, illegal tag length 48-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 48-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 128-bit key, illegal tag length 72-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 72-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 128-bit key, illegal tag length 95-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 95-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 128-bit key, illegal tag length 129-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 129-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 128-bit key, illegal tag length 256-bits assert_unreached: importKey failed for AES-GCM 128-bit key, illegal tag length 256-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 192-bit key, illegal tag length 24-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 24-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 192-bit key, illegal tag length 48-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 48-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 192-bit key, illegal tag length 72-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 72-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 192-bit key, illegal tag length 95-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 95-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 192-bit key, illegal tag length 129-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 129-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 192-bit key, illegal tag length 256-bits assert_unreached: importKey failed for AES-GCM 192-bit key, illegal tag length 256-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 256-bit key, illegal tag length 24-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 24-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 256-bit key, illegal tag length 48-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 48-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 256-bit key, illegal tag length 72-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 72-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 256-bit key, illegal tag length 95-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 95-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 256-bit key, illegal tag length 129-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 129-bits Reached unreachable code
+FAIL importKey step: decryption AES-GCM 256-bit key, illegal tag length 256-bits assert_unreached: importKey failed for AES-GCM 256-bit key, illegal tag length 256-bits Reached unreachable code
 
index ab3d9dc..ad864fe 100644 (file)
@@ -1,3 +1,112 @@
-CONSOLE MESSAGE: line 313: TypeError: undefined is not an object (evaluating 'subtle.importKey')
-FAIL: Timed out waiting for notifyDone to be called
+encrypt Tests for RSA-OAEP
+
+
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label decryption assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label decryption with altered ciphertext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label using publicKey to decrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label no decrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label with altered plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label too long plaintext assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label using privateKey to encrypt assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and no label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and no label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and empty label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and empty label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-1 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-1 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-256 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-256 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-384 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-384 and a label. Message: ''The operation is not supported.'' Reached unreachable code
+FAIL importVectorKeys step: RSA-OAEP with SHA-512 and a label no encrypt usage assert_unreached: importVectorKeys failed for RSA-OAEP with SHA-512 and a label. Message: ''The operation is not supported.'' Reached unreachable code
 
index be7350f..22d8108 100644 (file)
@@ -43,8 +43,8 @@ FAIL SubtleCrypto interface: operation wrapKey(KeyFormat,CryptoKey,CryptoKey,Alg
 FAIL SubtleCrypto interface: operation unwrapKey(KeyFormat,BufferSource,CryptoKey,AlgorithmIdentifier,AlgorithmIdentifier,boolean,[object Object]) assert_own_property: self does not have own property "SubtleCrypto" expected property "SubtleCrypto" missing
 FAIL SubtleCrypto must be primary interface of crypto.subtle assert_own_property: self does not have own property "SubtleCrypto" expected property "SubtleCrypto" missing
 PASS Stringification of crypto.subtle 
-FAIL SubtleCrypto interface: crypto.subtle must inherit property "encrypt" with the proper type (0) assert_inherits: property "encrypt" not found in prototype chain
-FAIL SubtleCrypto interface: calling encrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "encrypt" not found in prototype chain
+PASS SubtleCrypto interface: crypto.subtle must inherit property "encrypt" with the proper type (0) 
+PASS SubtleCrypto interface: calling encrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError 
 FAIL SubtleCrypto interface: crypto.subtle must inherit property "decrypt" with the proper type (1) assert_inherits: property "decrypt" not found in prototype chain
 FAIL SubtleCrypto interface: calling decrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "decrypt" not found in prototype chain
 FAIL SubtleCrypto interface: crypto.subtle must inherit property "sign" with the proper type (2) assert_inherits: property "sign" not found in prototype chain
index faa4962..f39d22c 100644 (file)
@@ -333,11 +333,13 @@ set(WebCore_NON_SVG_IDL_FILES
     crypto/SubtleCrypto.idl
     crypto/WebKitSubtleCrypto.idl
 
+    crypto/parameters/AesCbcParams.idl
     crypto/parameters/AesKeyGenParams.idl
     crypto/parameters/HmacKeyParams.idl
     crypto/parameters/RsaHashedImportParams.idl
     crypto/parameters/RsaHashedKeyGenParams.idl
     crypto/parameters/RsaKeyGenParams.idl
+    crypto/parameters/RsaOaepParams.idl
 
     css/CSSFontFaceLoadEvent.idl
     css/CSSFontFaceRule.idl
index 7f645c6..4ef3b8c 100644 (file)
@@ -1,3 +1,115 @@
+2016-11-17  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Update SubtleCrypto::encrypt to match the latest spec
+        https://bugs.webkit.org/show_bug.cgi?id=164738
+        <rdar://problem/29257812>
+
+        Reviewed by Brent Fulgham.
+
+        This patch does following few things:
+        1. It updates the SubtleCrypto::encrypt method to match the latest spec:
+           https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-encrypt.
+           It also refers to the latest Editor's Draft to a certain degree:
+           https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-encrypt.
+        2. It implements encrypt operations of the following algorithms: AES-CBC,
+           RSAES-PKCS1-V1_5, and RSA-OAEP.
+        3. It addes ASSERT(parameters) for every method that accepts a
+           std::unique_ptr<CryptoAlgorithmParameters>&& type parameter.
+        4. It changes RefPtr<CryptoKey>&& to Ref<CryptoKey>&& for every method that
+           accepts a CryptoKey.
+
+        Tests: crypto/subtle/aes-cbc-encrypt-malformed-parameters.html
+               crypto/subtle/aes-cbc-import-key-encrypt.html
+               crypto/subtle/encrypt-malformed-parameters.html
+               crypto/subtle/rsa-oaep-encrypt-malformed-parameters.html
+               crypto/subtle/rsa-oaep-import-key-encrypt-label.html
+               crypto/subtle/rsa-oaep-import-key-encrypt.html
+               crypto/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html
+               crypto/workers/subtle/aes-cbc-import-key-encrypt.html
+               crypto/workers/subtle/rsa-oaep-import-key-encrypt.html
+               crypto/workers/subtle/rsaes-pkcs1-v1_5-import-key-encrypt.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/BufferSource.h:
+        (WebCore::BufferSource::BufferSource):
+        Add a default constructor for initializing an empty BufferSource object.
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::normalizeCryptoAlgorithmParameters):
+        (WebCore::jsSubtleCryptoFunctionEncryptPromise):
+        (WebCore::JSSubtleCrypto::encrypt):
+        * crypto/CryptoAlgorithm.cpp:
+        (WebCore::CryptoAlgorithm::encrypt):
+        (WebCore::CryptoAlgorithm::exportKey):
+        * crypto/CryptoAlgorithm.h:
+        * crypto/CryptoAlgorithmParameters.h:
+        * crypto/CryptoKey.h:
+        * crypto/SubtleCrypto.cpp:
+        (WebCore::SubtleCrypto::SubtleCrypto):
+        * crypto/SubtleCrypto.h:
+        (WebCore::SubtleCrypto::workQueue):
+        * crypto/SubtleCrypto.idl:
+        * crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
+        * crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
+        * crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
+        * crypto/gnutls/CryptoKeyRSAGnuTLS.cpp:
+        (WebCore::CryptoKeyRSA::generatePair):
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::encrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::generateKey):
+        (WebCore::CryptoAlgorithmAES_CBC::importKey):
+        (WebCore::CryptoAlgorithmAES_CBC::exportKey):
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::generateKey):
+        (WebCore::CryptoAlgorithmAES_KW::importKey):
+        (WebCore::CryptoAlgorithmAES_KW::exportKey):
+        * crypto/algorithms/CryptoAlgorithmAES_KW.h:
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::generateKey):
+        (WebCore::CryptoAlgorithmHMAC::importKey):
+        (WebCore::CryptoAlgorithmHMAC::exportKey):
+        * crypto/algorithms/CryptoAlgorithmHMAC.h:
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
+        (WebCore::CryptoAlgorithmRSA_OAEP::generateKey):
+        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
+        (WebCore::CryptoAlgorithmRSA_OAEP::exportKey):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
+        (WebCore::transformAES_CBC):
+        (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
+        (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
+        * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
+        (WebCore::encryptRSAES_PKCS1_v1_5):
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
+        * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
+        (WebCore::encryptRSA_OAEP):
+        (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::generatePair):
+        * crypto/parameters/AesCbcParams.idl: Added.
+        * crypto/parameters/CryptoAlgorithmAesCbcParams.h: Added.
+        * crypto/parameters/CryptoAlgorithmAesCbcParamsDeprecated.h:
+        * crypto/parameters/CryptoAlgorithmRsaOaepParams.h: Added.
+        * crypto/parameters/RsaOaepParams.idl: Added.
+
 2016-11-18  Ryan Haddad  <ryanhaddad@apple.com>
 
         Attempt to fix iOS build again.
index f6f9a8e..30c1ece 100644 (file)
@@ -254,11 +254,13 @@ JS_BINDING_IDLS = \
     $(WebCore)/crypto/CryptoKeyPair.idl \
     $(WebCore)/crypto/CryptoKeyUsage.idl \
     $(WebCore)/crypto/JsonWebKey.idl \
+    $(WebCore)/crypto/parameters/AesCbcParams.idl \
     $(WebCore)/crypto/parameters/AesKeyGenParams.idl \
     $(WebCore)/crypto/parameters/HmacKeyParams.idl \
     $(WebCore)/crypto/parameters/RsaHashedImportParams.idl \
     $(WebCore)/crypto/parameters/RsaHashedKeyGenParams.idl \
     $(WebCore)/crypto/parameters/RsaKeyGenParams.idl \
+    $(WebCore)/crypto/parameters/RsaOaepParams.idl \
     $(WebCore)/crypto/RsaOtherPrimesInfo.idl \
     $(WebCore)/crypto/SubtleCrypto.idl \
     $(WebCore)/crypto/WebKitSubtleCrypto.idl \
index 1bd481d..38f89b8 100644 (file)
                5597F8271D91C3130066BC21 /* ImageFrameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5597F8251D91C3130066BC21 /* ImageFrameCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
                55A336F71D8209F40022C4C7 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F61D8209F40022C4C7 /* NativeImage.h */; };
                55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5706A6961DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5706A6951DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h */; };
+               5706A6981DDE5E4600A03B14 /* JSRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5706A6971DDE5E4600A03B14 /* JSRsaOaepParams.h */; };
+               5706A69A1DDE5E8500A03B14 /* JSRsaOaepParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5706A6991DDE5E8500A03B14 /* JSRsaOaepParams.cpp */; };
                5709E8CD1D413D47003244AC /* WebKitSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */; };
                5709E8CE1D413D5B003244AC /* JSWebKitSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */; };
                5709E8CF1D413D9A003244AC /* WebKitSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */; };
                570A99DB1D41A2F3004EC630 /* JSWebKitSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F63180745D800132674 /* JSWebKitSubtleCrypto.h */; };
                571F21891DA57C54005C9EFD /* JSSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 571F21881DA57C54005C9EFD /* JSSubtleCrypto.h */; };
                571F218B1DA57C7B005C9EFD /* JSSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 571F218A1DA57C7A005C9EFD /* JSSubtleCrypto.cpp */; };
+               572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcParams.h */; };
+               572093D51DDCED8E00310AB0 /* JSAesCbcParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 572093D41DDCED8E00310AB0 /* JSAesCbcParams.h */; };
+               572093D71DDCEDA700310AB0 /* JSAesCbcParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572093D61DDCEDA700310AB0 /* JSAesCbcParams.cpp */; };
                572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; };
                572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; };
                573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
                55A336F61D8209F40022C4C7 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
                55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBackingStore.h; sourceTree = "<group>"; };
                55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
+               5706A6941DDE5BF800A03B14 /* RsaOaepParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RsaOaepParams.idl; sourceTree = "<group>"; };
+               5706A6951DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRsaOaepParams.h; sourceTree = "<group>"; };
+               5706A6971DDE5E4600A03B14 /* JSRsaOaepParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaOaepParams.h; sourceTree = "<group>"; };
+               5706A6991DDE5E8500A03B14 /* JSRsaOaepParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaOaepParams.cpp; sourceTree = "<group>"; };
                5709E8CA1D413CE3003244AC /* WebKitSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitSubtleCrypto.cpp; sourceTree = "<group>"; };
                5709E8CB1D413CE3003244AC /* WebKitSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitSubtleCrypto.h; sourceTree = "<group>"; };
                5709E8CC1D413CE3003244AC /* WebKitSubtleCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitSubtleCrypto.idl; sourceTree = "<group>"; };
                571F21881DA57C54005C9EFD /* JSSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSubtleCrypto.h; sourceTree = "<group>"; };
                571F218A1DA57C7A005C9EFD /* JSSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCrypto.cpp; sourceTree = "<group>"; };
+               572093D11DDCEA4B00310AB0 /* AesCbcParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesCbcParams.idl; sourceTree = "<group>"; };
+               572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesCbcParams.h; sourceTree = "<group>"; };
+               572093D41DDCED8E00310AB0 /* JSAesCbcParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesCbcParams.h; sourceTree = "<group>"; };
+               572093D61DDCEDA700310AB0 /* JSAesCbcParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesCbcParams.cpp; sourceTree = "<group>"; };
                572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
                572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
                573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; };
                E1C657141816015F00256CDD /* parameters */ = {
                        isa = PBXGroup;
                        children = (
+                               572093D11DDCEA4B00310AB0 /* AesCbcParams.idl */,
                                577483101DADC49900716EF9 /* AesKeyGenParams.idl */,
+                               572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcParams.h */,
                                E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParamsDeprecated.h */,
                                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */,
                                E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h */,
                                57FEDD3E1DB6D59200EB96F5 /* CryptoAlgorithmRsaKeyGenParams.h */,
                                E1BD331D182D8F4200C05D9F /* CryptoAlgorithmRsaKeyGenParamsDeprecated.h */,
                                E1C266DA18319935003F8B33 /* CryptoAlgorithmRsaKeyParamsWithHashDeprecated.h */,
+                               5706A6951DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h */,
                                E1FE1376184D1E3300892F13 /* CryptoAlgorithmRsaOaepParamsDeprecated.h */,
                                E1BD331B182D8EE900C05D9F /* CryptoAlgorithmRsaSsaParamsDeprecated.h */,
                                577483171DB1FE8900716EF9 /* HmacKeyParams.idl */,
                                57E2336C1DCD437000F28D01 /* RsaHashedImportParams.idl */,
                                57F827391DB72C22009D2BF4 /* RsaHashedKeyGenParams.idl */,
                                57FEDD3D1DB6D47F00EB96F5 /* RsaKeyGenParams.idl */,
+                               5706A6941DDE5BF800A03B14 /* RsaOaepParams.idl */,
                        );
                        path = parameters;
                        sourceTree = "<group>";
                E1FF8F61180745C600132674 /* Crypto */ = {
                        isa = PBXGroup;
                        children = (
+                               572093D61DDCEDA700310AB0 /* JSAesCbcParams.cpp */,
+                               572093D41DDCED8E00310AB0 /* JSAesCbcParams.h */,
                                577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */,
                                577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */,
                                5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */,
                                5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */,
                                57FEDD421DB6D76000EB96F5 /* JSRsaKeyGenParams.cpp */,
                                57FEDD401DB6D73A00EB96F5 /* JSRsaKeyGenParams.h */,
+                               5706A6991DDE5E8500A03B14 /* JSRsaOaepParams.cpp */,
+                               5706A6971DDE5E4600A03B14 /* JSRsaOaepParams.h */,
                                57E233601DC7D6AA00F28D01 /* JSRsaOtherPrimesInfo.cpp */,
                                57E2335C1DC7D60800F28D01 /* JSRsaOtherPrimesInfo.h */,
                                571F218A1DA57C7A005C9EFD /* JSSubtleCrypto.cpp */,
                                5CDFA6C81AA4F2DA00EA8746 /* ContentExtensionActions.h in Headers */,
                                7C93F34E1AA6BF0700A98BAB /* ContentExtensionCompiler.h in Headers */,
                                7CFDC57D1AC1D80500E24A57 /* ContentExtensionError.h in Headers */,
+                               572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcParams.h in Headers */,
                                26F0C8981A2E724B002794F8 /* ContentExtensionParser.h in Headers */,
                                26F0C89C1A2EC110002794F8 /* ContentExtensionRule.h in Headers */,
                                26F0C8A01A2EC3BE002794F8 /* ContentExtensionsBackend.h in Headers */,
                                E35802B61DC8435D00A9773C /* DOMJITIDLTypeFilter.h in Headers */,
                                A9C6E4E40D745E05006442E9 /* DOMMimeType.h in Headers */,
                                A9C6E4E80D745E18006442E9 /* DOMMimeTypeArray.h in Headers */,
+                               5706A6961DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h in Headers */,
                                52B6C9C315E3F4DF00690B05 /* DOMNamedFlowCollection.h in Headers */,
                                1ACE53E80A8D18E70022947D /* DOMParser.h in Headers */,
                                7A54881714E432A1006AE05A /* DOMPatchSupport.h in Headers */,
                                1AE2AB2A0A1CE63B00B42B25 /* JSHTMLModElement.h in Headers */,
                                BC305C7A0C076BB300CD20F0 /* JSHTMLObjectElement.h in Headers */,
                                1A85B1EB0A1B240500D8C87C /* JSHTMLOListElement.h in Headers */,
+                               5706A6981DDE5E4600A03B14 /* JSRsaOaepParams.h in Headers */,
                                A80E7E9B0A1A83E3007FB8C5 /* JSHTMLOptGroupElement.h in Headers */,
+                               572093D51DDCED8E00310AB0 /* JSAesCbcParams.h in Headers */,
                                A80E7E990A1A83E3007FB8C5 /* JSHTMLOptionElement.h in Headers */,
                                448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */,
                                4AD0173D127E82860015035F /* JSHTMLOutputElement.h in Headers */,
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               5706A69A1DDE5E8500A03B14 /* JSRsaOaepParams.cpp in Sources */,
+                               572093D71DDCEDA700310AB0 /* JSAesCbcParams.cpp in Sources */,
                                57D0018F1DD5415300ED19D9 /* JSCryptoKeyUsage.cpp in Sources */,
                                41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */,
                                37F57AB91A50726900876F98 /* AccessibilityARIAGrid.cpp in Sources */,
index 03b7cc6..01e4584 100644 (file)
@@ -36,6 +36,7 @@ class BufferSource {
 public:
     using VariantType = WTF::Variant<RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>>;
 
+    BufferSource() { }
     BufferSource(VariantType&& variant)
         : m_variant(WTFMove(variant))
     { }
index 27b1bed..3d4d95d 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "CryptoAlgorithm.h"
 #include "CryptoAlgorithmRegistry.h"
+#include "JSAesCbcParams.h"
 #include "JSAesKeyGenParams.h"
 #include "JSCryptoAlgorithmParameters.h"
 #include "JSCryptoKey.h"
@@ -40,6 +41,7 @@
 #include "JSRsaHashedImportParams.h"
 #include "JSRsaHashedKeyGenParams.h"
 #include "JSRsaKeyGenParams.h"
+#include "JSRsaOaepParams.h"
 #include "ScriptState.h"
 #include <runtime/Error.h>
 #include <runtime/IteratorOperations.h>
@@ -50,6 +52,7 @@ using namespace JSC;
 namespace WebCore {
 
 enum class Operations {
+    Encrypt,
     Digest,
     GenerateKey,
     ImportKey,
@@ -90,6 +93,28 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
 
         std::unique_ptr<CryptoAlgorithmParameters> result;
         switch (operation) {
+        case Operations::Encrypt:
+            switch (*identifier) {
+            case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
+                result = std::make_unique<CryptoAlgorithmParameters>(params);
+                break;
+            case CryptoAlgorithmIdentifier::RSA_OAEP: {
+                auto params = convertDictionary<CryptoAlgorithmRsaOaepParams>(state, value);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                result = std::make_unique<CryptoAlgorithmRsaOaepParams>(params);
+                break;
+            }
+            case CryptoAlgorithmIdentifier::AES_CBC: {
+                auto params = convertDictionary<CryptoAlgorithmAesCbcParams>(state, value);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                result = std::make_unique<CryptoAlgorithmAesCbcParams>(params);
+                break;
+            }
+            default:
+                setDOMException(&state, NOT_SUPPORTED_ERR);
+                return nullptr;
+            }
+            break;
         case Operations::Digest:
             switch (*identifier) {
             case CryptoAlgorithmIdentifier::SHA_1:
@@ -363,6 +388,56 @@ static JSValue toJSValueFromJsonWebKey(JSDOMGlobalObject& globalObject, JsonWebK
     return result;
 }
 
+static void jsSubtleCryptoFunctionEncryptPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+    VM& vm = state.vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (UNLIKELY(state.argumentCount() < 3)) {
+        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        return;
+    }
+
+    auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Encrypt);
+    RETURN_IF_EXCEPTION(scope, void());
+
+    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
+    if (!key) {
+        promise->reject(TypeError, ASCIILiteral("Invalid CryptoKey"));
+        return;
+    }
+
+    BufferSource data = convert<IDLBufferSource>(state, state.uncheckedArgument(2));
+    RETURN_IF_EXCEPTION(scope, void());
+    Vector<uint8_t> dataVector;
+    dataVector.append(data.data(), data.length());
+
+    if (params->identifier != key->algorithmIdentifier()) {
+        promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't match AlgorithmIdentifier"));
+        return;
+    }
+
+    if (!key->allows(CryptoKeyUsageEncrypt)) {
+        promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't support encryption"));
+        return;
+    }
+
+    auto algorithm = createAlgorithm(state, key->algorithmIdentifier());
+    RETURN_IF_EXCEPTION(scope, void());
+
+    auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& cipherText) mutable {
+        fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), cipherText.data(), cipherText.size());
+        return;
+    };
+    auto exceptionCallback = [capturedPromise = promise.copyRef()](ExceptionCode ec) mutable {
+        rejectWithException(WTFMove(capturedPromise), ec);
+    };
+
+    JSSubtleCrypto* subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue());
+    ASSERT(subtle);
+    algorithm->encrypt(WTFMove(params), key.releaseNonNull(), WTFMove(dataVector), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
+}
+
 static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state.vm();
@@ -524,7 +599,12 @@ static void jsSubtleCryptoFunctionExportKeyPromise(ExecState& state, Ref<Deferre
     // The 11 December 2014 version of the specification suggests we should perform the following task asynchronously:
     // https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-exportKey
     // It is not beneficial for less time consuming operations. Therefore, we perform it synchronously.
-    algorithm->exportKey(format, WTFMove(key), WTFMove(callback), WTFMove(exceptionCallback));
+    algorithm->exportKey(format, key.releaseNonNull(), WTFMove(callback), WTFMove(exceptionCallback));
+}
+
+JSValue JSSubtleCrypto::encrypt(ExecState& state)
+{
+    return callPromiseFunction<jsSubtleCryptoFunctionEncryptPromise, PromiseExecutionScope::WindowOrWorker>(state);
 }
 
 JSValue JSSubtleCrypto::generateKey(ExecState& state)
index 416efa8..d41850c 100644 (file)
 
 namespace WebCore {
 
+void CryptoAlgorithm::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
+{
+    exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
 void CryptoAlgorithm::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
 {
     exceptionCallback(NOT_SUPPORTED_ERR);
@@ -42,7 +47,7 @@ void CryptoAlgorithm::importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::u
     exceptionCallback(NOT_SUPPORTED_ERR);
 }
 
-void CryptoAlgorithm::exportKey(SubtleCrypto::KeyFormat, RefPtr<WebCore::CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithm::exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&& exceptionCallback)
 {
     exceptionCallback(NOT_SUPPORTED_ERR);
 }
index 3756d19..408093e 100644 (file)
@@ -32,6 +32,7 @@
 #include "SubtleCrypto.h"
 #include <wtf/Function.h>
 #include <wtf/Vector.h>
+#include <wtf/WorkQueue.h>
 
 #if ENABLE(SUBTLE_CRYPTO)
 
@@ -63,9 +64,10 @@ public:
     using ExceptionCallback = WTF::Function<void(ExceptionCode)>;
     using KeyDataCallback = WTF::Function<void(SubtleCrypto::KeyFormat, KeyData&&)>;
 
+    virtual void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     virtual void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
     virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
-    virtual void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
+    virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
 
     // The following will be deprecated.
     virtual ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
index 10a6141..b941521 100644 (file)
@@ -37,11 +37,13 @@ class CryptoAlgorithmParameters {
 public:
     enum class Class {
         None,
+        AesCbcParams,
         AesKeyGenParams,
         HmacKeyParams,
         RsaHashedKeyGenParams,
         RsaHashedImportParams,
         RsaKeyGenParams,
+        RsaOaepParams,
     };
 
     // FIXME: Consider merging name and identifier.
index f6c136f..df06b54 100644 (file)
@@ -31,7 +31,7 @@
 #include "CryptoKeyType.h"
 #include "CryptoKeyUsage.h"
 #include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
+#include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/TypeCasts.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -74,7 +74,7 @@ private:
     String m_name;
 };
 
-class CryptoKey : public RefCounted<CryptoKey> {
+class CryptoKey : public ThreadSafeRefCounted<CryptoKey> {
 public:
     using Type = CryptoKeyType;
     CryptoKey(CryptoAlgorithmIdentifier, Type, bool extractable, CryptoKeyUsageBitmap);
index 6eddcc7..f691f6b 100644 (file)
@@ -32,6 +32,7 @@ namespace WebCore {
 
 SubtleCrypto::SubtleCrypto(ScriptExecutionContext& context)
     : ContextDestructionObserver(&context)
+    , m_workQueue(WorkQueue::create("com.apple.WebKit.CryptoQueue"))
 {
 }
 
index fe2eccf..39b945f 100644 (file)
@@ -28,6 +28,7 @@
 #include "ContextDestructionObserver.h"
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
+#include <wtf/WorkQueue.h>
 
 #if ENABLE(SUBTLE_CRYPTO)
 
@@ -39,8 +40,12 @@ public:
 
     static Ref<SubtleCrypto> create(ScriptExecutionContext& context) { return adoptRef(*new SubtleCrypto(context)); }
 
+    WorkQueue& workQueue() { return m_workQueue.get(); };
+
 private:
     SubtleCrypto(ScriptExecutionContext&);
+
+    Ref<WorkQueue> m_workQueue;
 };
 
 }
index dd224be..145eea0 100644 (file)
@@ -31,6 +31,7 @@ enum KeyFormat { "raw", "spki", "pkcs8", "jwk" };
     GenerateIsReachable=ImplScriptExecutionContext,
     NoInterfaceObject,
 ] interface SubtleCrypto {
+    [Custom] Promise<any> encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
     // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
     [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages);
     [Custom] Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence<CryptoKeyUsage> keyUsages);
index 0b96c87..9053046 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(SUBTLE_CRYPTO)
 
+#include "CryptoAlgorithmAesCbcParams.h"
 #include "CryptoAlgorithmAesCbcParamsDeprecated.h"
 #include "CryptoAlgorithmAesKeyGenParams.h"
 #include "CryptoAlgorithmAesKeyGenParamsDeprecated.h"
@@ -40,6 +41,7 @@ namespace WebCore {
 static const char* const ALG128 = "A128CBC";
 static const char* const ALG192 = "A192CBC";
 static const char* const ALG256 = "A256CBC";
+static const size_t IVSIZE = 16;
 
 static inline bool usagesAreInvalidForCryptoAlgorithmAES_CBC(CryptoKeyUsageBitmap usages)
 {
@@ -64,8 +66,20 @@ bool CryptoAlgorithmAES_CBC::keyAlgorithmMatches(const CryptoAlgorithmAesCbcPara
     return true;
 }
 
+void CryptoAlgorithmAES_CBC::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+    ASSERT(parameters);
+    auto& aesParameters = downcast<CryptoAlgorithmAesCbcParams>(*parameters);
+    if (aesParameters.ivVector().size() != IVSIZE) {
+        exceptionCallback(OperationError);
+        return;
+    }
+    platformEncrypt(WTFMove(parameters), WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
 void CryptoAlgorithmAES_CBC::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
 {
+    ASSERT(parameters);
     auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(*parameters);
 
     if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) {
@@ -84,6 +98,7 @@ void CryptoAlgorithmAES_CBC::generateKey(const std::unique_ptr<CryptoAlgorithmPa
 
 void CryptoAlgorithmAES_CBC::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
+    ASSERT(parameters);
     if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) {
         exceptionCallback(SYNTAX_ERR);
         return;
@@ -121,9 +136,9 @@ void CryptoAlgorithmAES_CBC::importKey(SubtleCrypto::KeyFormat format, KeyData&&
     callback(*result);
 }
 
-void CryptoAlgorithmAES_CBC::exportKey(SubtleCrypto::KeyFormat format, RefPtr<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithmAES_CBC::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    const auto& aesKey = downcast<CryptoKeyAES>(*key);
+    const auto& aesKey = downcast<CryptoKeyAES>(key.get());
 
     if (aesKey.key().isEmpty()) {
         exceptionCallback(OperationError);
index c4cc5c9..b22c9a3 100644 (file)
@@ -44,9 +44,10 @@ private:
     CryptoAlgorithmAES_CBC() = default;
     CryptoAlgorithmIdentifier identifier() const final;
 
+    void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
-    void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
     ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
     ExceptionOr<void> decrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
@@ -54,6 +55,7 @@ private:
     ExceptionOr<void> importKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKeyData&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback) final;
 
     bool keyAlgorithmMatches(const CryptoAlgorithmAesCbcParamsDeprecated& algorithmParameters, const CryptoKey&) const;
+    void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     ExceptionOr<void> platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&, const CryptoKeyAES&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
     ExceptionOr<void> platformDecrypt(const CryptoAlgorithmAesCbcParamsDeprecated&, const CryptoKeyAES&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
 };
index 6f62c86..b675e05 100644 (file)
@@ -65,6 +65,7 @@ bool CryptoAlgorithmAES_KW::keyAlgorithmMatches(const CryptoKey& key) const
 
 void CryptoAlgorithmAES_KW::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
 {
+    ASSERT(parameters);
     if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) {
         exceptionCallback(SYNTAX_ERR);
         return;
@@ -81,6 +82,7 @@ void CryptoAlgorithmAES_KW::generateKey(const std::unique_ptr<CryptoAlgorithmPar
 
 void CryptoAlgorithmAES_KW::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
+    ASSERT(parameters);
     if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) {
         exceptionCallback(SYNTAX_ERR);
         return;
@@ -117,9 +119,9 @@ void CryptoAlgorithmAES_KW::importKey(SubtleCrypto::KeyFormat format, KeyData&&
     callback(*result);
 }
 
-void CryptoAlgorithmAES_KW::exportKey(SubtleCrypto::KeyFormat format, RefPtr<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithmAES_KW::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    const auto& aesKey = downcast<CryptoKeyAES>(*key);
+    const auto& aesKey = downcast<CryptoKeyAES>(key.get());
 
     if (aesKey.key().isEmpty()) {
         exceptionCallback(OperationError);
index 33fc302..df2f487 100644 (file)
@@ -45,7 +45,7 @@ private:
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
-    void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
     ExceptionOr<void> encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
     ExceptionOr<void> decryptForUnwrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
index 7c35c5a..bc486d9 100644 (file)
@@ -71,6 +71,7 @@ bool CryptoAlgorithmHMAC::keyAlgorithmMatches(const CryptoAlgorithmHmacParamsDep
 
 void CryptoAlgorithmHMAC::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
 {
+    ASSERT(parameters);
     const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(*parameters);
 
     if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) {
@@ -94,6 +95,7 @@ void CryptoAlgorithmHMAC::generateKey(const std::unique_ptr<CryptoAlgorithmParam
 
 void CryptoAlgorithmHMAC::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
+    ASSERT(parameters);
     const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(*parameters);
 
     if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) {
@@ -139,9 +141,9 @@ void CryptoAlgorithmHMAC::importKey(SubtleCrypto::KeyFormat format, KeyData&& da
     callback(*result);
 }
 
-void CryptoAlgorithmHMAC::exportKey(SubtleCrypto::KeyFormat format, RefPtr<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithmHMAC::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    const auto& hmacKey = downcast<CryptoKeyHMAC>(*key);
+    const auto& hmacKey = downcast<CryptoKeyHMAC>(key.get());
 
     if (hmacKey.key().isEmpty()) {
         exceptionCallback(OperationError);
index baa4d91..6f8f882 100644 (file)
@@ -46,7 +46,7 @@ private:
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
-    void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
     // The following will be deprecated.
     ExceptionOr<void> sign(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
index ae14d28..6777eed 100644 (file)
@@ -59,8 +59,18 @@ bool CryptoAlgorithmRSAES_PKCS1_v1_5::keyAlgorithmMatches(const CryptoKey& key)
     return true;
 }
 
+void CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+    if (key->type() != CryptoKeyType::Public) {
+        exceptionCallback(INVALID_ACCESS_ERR);
+        return;
+    }
+    platformEncrypt(WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
 void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)
 {
+    ASSERT(parameters);
     const auto& rsaParameters = downcast<CryptoAlgorithmRsaKeyGenParams>(*parameters);
 
     if (usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey)) {
@@ -82,6 +92,7 @@ void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAl
 
 void CryptoAlgorithmRSAES_PKCS1_v1_5::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
+    ASSERT(parameters);
     RefPtr<CryptoKeyRSA> result;
     switch (format) {
     case SubtleCrypto::KeyFormat::Jwk: {
@@ -113,9 +124,9 @@ void CryptoAlgorithmRSAES_PKCS1_v1_5::importKey(SubtleCrypto::KeyFormat format,
     callback(*result);
 }
 
-void CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey(SubtleCrypto::KeyFormat format, RefPtr<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithmRSAES_PKCS1_v1_5::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    const auto& rsaKey = downcast<CryptoKeyRSA>(*key);
+    const auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
 
     if (!rsaKey.keySizeInBits()) {
         exceptionCallback(OperationError);
index c9bc405..5acf24c 100644 (file)
@@ -44,17 +44,18 @@ private:
     CryptoAlgorithmRSAES_PKCS1_v1_5() = default;
     CryptoAlgorithmIdentifier identifier() const final;
 
+    void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
-    void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
-    // The following will be deprecated.
     ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
     ExceptionOr<void> decrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
     ExceptionOr<void> generateKey(const CryptoAlgorithmParametersDeprecated&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, VoidCallback&& failureCallback, ScriptExecutionContext&) final;
     ExceptionOr<void> importKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKeyData&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback) final;
 
     bool keyAlgorithmMatches(const CryptoKey&) const;
+    void platformEncrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     ExceptionOr<void> platformEncrypt(const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
     ExceptionOr<void> platformDecrypt(const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
 };
index 1c53667..070428b 100644 (file)
@@ -70,6 +70,7 @@ bool CryptoAlgorithmRSASSA_PKCS1_v1_5::keyAlgorithmMatches(const CryptoAlgorithm
 
 void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)
 {
+    ASSERT(parameters);
     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(*parameters);
 
     if (usages & (CryptoKeyUsageDecrypt | CryptoKeyUsageEncrypt | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey)) {
@@ -90,6 +91,7 @@ void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoA
 
 void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
+    ASSERT(parameters);
     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(*parameters);
 
     RefPtr<CryptoKeyRSA> result;
@@ -146,9 +148,9 @@ void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(SubtleCrypto::KeyFormat format,
     callback(*result);
 }
 
-void CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey(SubtleCrypto::KeyFormat format, RefPtr<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithmRSASSA_PKCS1_v1_5::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    const auto& rsaKey = downcast<CryptoKeyRSA>(*key);
+    const auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
 
     if (!rsaKey.keySizeInBits()) {
         exceptionCallback(OperationError);
index 2f9221c..a33e5a0 100644 (file)
@@ -46,7 +46,7 @@ private:
 
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
-    void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
     ExceptionOr<void> sign(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
     ExceptionOr<void> verify(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData& signature, const CryptoOperationData&, BoolCallback&&, VoidCallback&& failureCallback) final;
index 4d62bb0..87fad23 100644 (file)
@@ -68,8 +68,20 @@ bool CryptoAlgorithmRSA_OAEP::keyAlgorithmMatches(const CryptoAlgorithmRsaOaepPa
     return true;
 }
 
+void CryptoAlgorithmRSA_OAEP::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+    ASSERT(parameters);
+    if (key->type() != CryptoKeyType::Public) {
+        exceptionCallback(INVALID_ACCESS_ERR);
+        return;
+    }
+    platformEncrypt(WTFMove(parameters), WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
+
 void CryptoAlgorithmRSA_OAEP::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)
 {
+    ASSERT(parameters);
     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(*parameters);
 
     if (usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits)) {
@@ -90,6 +102,7 @@ void CryptoAlgorithmRSA_OAEP::generateKey(const std::unique_ptr<CryptoAlgorithmP
 
 void CryptoAlgorithmRSA_OAEP::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
+    ASSERT(parameters);
     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(*parameters);
 
     RefPtr<CryptoKeyRSA> result;
@@ -157,9 +170,9 @@ void CryptoAlgorithmRSA_OAEP::importKey(SubtleCrypto::KeyFormat format, KeyData&
     callback(*result);
 }
 
-void CryptoAlgorithmRSA_OAEP::exportKey(SubtleCrypto::KeyFormat format, RefPtr<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
+void CryptoAlgorithmRSA_OAEP::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
 {
-    const auto& rsaKey = downcast<CryptoKeyRSA>(*key);
+    const auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
 
     if (!rsaKey.keySizeInBits()) {
         exceptionCallback(OperationError);
index b5fd582..1c72cad 100644 (file)
@@ -44,9 +44,10 @@ private:
     CryptoAlgorithmRSA_OAEP() = default;
     CryptoAlgorithmIdentifier identifier() const final;
 
+    void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
-    void exportKey(SubtleCrypto::KeyFormat, RefPtr<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
 
     ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
     ExceptionOr<void> decrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
@@ -54,6 +55,7 @@ private:
     ExceptionOr<void> importKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKeyData&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback) final;
 
     bool keyAlgorithmMatches(const CryptoAlgorithmRsaOaepParamsDeprecated& algorithmParameters, const CryptoKey&) const;
+    void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     ExceptionOr<void> platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
     ExceptionOr<void> platformDecrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
 };
index dbfa5fc..7262ff8 100644 (file)
 
 namespace WebCore {
 
+void CryptoAlgorithmAES_CBC::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+    notImplemented();
+}
+
 ExceptionOr<void> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated&, const CryptoKeyAES&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
 {
     notImplemented();
index 2b06af8..ea0e7c5 100644 (file)
 
 namespace WebCore {
 
+void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+    notImplemented();
+}
+
 ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
 {
     notImplemented();
index cc2e402..c85b91c 100644 (file)
 
 namespace WebCore {
 
+void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+    notImplemented();
+}
+
 ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
 {
     notImplemented();
index 0ea2560..ae11b36 100644 (file)
@@ -95,7 +95,7 @@ std::unique_ptr<CryptoKeyData> CryptoKeyRSA::exportData() const
     return nullptr;
 }
 
-void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap usage, KeyPairCallback callback, VoidCallback failureCallback, ScriptExecutionContext* context)
+void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap usage, KeyPairCallback&& callback, VoidCallback&& failureCallback, ScriptExecutionContext* context)
 {
     notImplemented();
     failureCallback();
index eabda2b..8062101 100644 (file)
@@ -99,7 +99,7 @@ public:
 
     using KeyPairCallback = WTF::Function<void(CryptoKeyPair&)>;
     using VoidCallback = WTF::Function<void()>;
-    static void generatePair(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap, KeyPairCallback, VoidCallback failureCallback, ScriptExecutionContext*);
+    static void generatePair(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap, KeyPairCallback&&, VoidCallback&& failureCallback, ScriptExecutionContext*);
     static RefPtr<CryptoKeyRSA> importJwk(CryptoAlgorithmIdentifier, Optional<CryptoAlgorithmIdentifier> hash, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap);
 
     PlatformRSAKey platformKey() const { return m_platformKey; }
index 78a2a27..0343065 100644 (file)
 
 #if ENABLE(SUBTLE_CRYPTO)
 
+#include "CryptoAlgorithmAesCbcParams.h"
 #include "CryptoAlgorithmAesCbcParamsDeprecated.h"
 #include "CryptoKeyAES.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
 #include <CommonCrypto/CommonCrypto.h>
 
 namespace WebCore {
 
-static void transformAES_CBC(CCOperation operation, const CryptoAlgorithmAesCbcParamsDeprecated& parameters, const CryptoKeyAES& key, const CryptoOperationData& data, CryptoAlgorithm::VectorCallback&& callback, CryptoAlgorithm::VoidCallback&& failureCallback)
+// FIXME: We should change iv and data to Vector<uint8_t> type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr<Vector<uint8_t>> transformAES_CBC(CCOperation operation, const uint8_t* iv, const Vector<uint8_t>& key, const uint8_t* data, size_t dataLength)
 {
-    static_assert(sizeof(parameters.iv) == kCCBlockSizeAES128, "Initialization vector size must be the same as algorithm block size");
-
-    size_t keyLengthInBytes = key.key().size();
-    if (keyLengthInBytes != 16 && keyLengthInBytes != 24 && keyLengthInBytes != 32) {
-        failureCallback();
-        return;
-    }
-
+    size_t keyLengthInBytes = key.size();
     CCCryptorRef cryptor;
 #if PLATFORM(COCOA)
     CCAlgorithm aesAlgorithm = kCCAlgorithmAES;
 #else
     CCAlgorithm aesAlgorithm = kCCAlgorithmAES128;
 #endif
-    CCCryptorStatus status = CCCryptorCreate(operation, aesAlgorithm, kCCOptionPKCS7Padding, key.key().data(), keyLengthInBytes, parameters.iv.data(), &cryptor);
-    if (status) {
-        failureCallback();
-        return;
-    }
+    CCCryptorStatus status = CCCryptorCreate(operation, aesAlgorithm, kCCOptionPKCS7Padding, key.data(), keyLengthInBytes, iv, &cryptor);
+    if (status)
+        return Exception { OperationError };
 
-    Vector<uint8_t> result(CCCryptorGetOutputLength(cryptor, data.second, true));
+    Vector<uint8_t> result(CCCryptorGetOutputLength(cryptor, dataLength, true));
 
     size_t bytesWritten;
-    status = CCCryptorUpdate(cryptor, data.first, data.second, result.data(), result.size(), &bytesWritten);
-    if (status) {
-        failureCallback();
-        return;
-    }
+    status = CCCryptorUpdate(cryptor, data, dataLength, result.data(), result.size(), &bytesWritten);
+    if (status)
+        return Exception { OperationError };
 
     uint8_t* p = result.data() + bytesWritten;
     status = CCCryptorFinal(cryptor, p, result.end() - p, &bytesWritten);
     p += bytesWritten;
-    if (status) {
-        failureCallback();
-        return;
-    }
+    if (status)
+        return Exception { OperationError };
 
     ASSERT(p <= result.end());
     result.shrink(p - result.begin());
 
     CCCryptorRelease(cryptor);
 
-    callback(result);
+    return WTFMove(result);
+}
+
+void CryptoAlgorithmAES_CBC::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+    context.ref();
+    workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+        auto& aesParameters = downcast<CryptoAlgorithmAesCbcParams>(*parameters);
+        auto& aesKey = downcast<CryptoKeyAES>(key.get());
+        ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128);
+        auto result = transformAES_CBC(kCCEncrypt, aesParameters.ivVector().data(), aesKey.key(), plainText.data(), plainText.size());
+        if (result.hasException()) {
+            context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+            callback(result);
+            context.deref();
+        });
+    });
 }
 
 ExceptionOr<void> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcParamsDeprecated& parameters, const CryptoKeyAES& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
 {
-    transformAES_CBC(kCCEncrypt, parameters, key, data, WTFMove(callback), WTFMove(failureCallback));
+    ASSERT(sizeof(parameters.iv) == kCCBlockSizeAES128);
+    auto result = transformAES_CBC(kCCEncrypt, parameters.iv.data(), key.key(), data.first, data.second);
+    if (result.hasException()) {
+        failureCallback();
+        return { };
+    }
+    callback(result.releaseReturnValue());
     return { };
 }
 
 ExceptionOr<void> CryptoAlgorithmAES_CBC::platformDecrypt(const CryptoAlgorithmAesCbcParamsDeprecated& parameters, const CryptoKeyAES& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
 {
-    transformAES_CBC(kCCDecrypt, parameters, key, data, WTFMove(callback), WTFMove(failureCallback));
+    ASSERT(sizeof(parameters.iv) == kCCBlockSizeAES128);
+    auto result = transformAES_CBC(kCCDecrypt, parameters.iv.data(), key.key(), data.first, data.second);
+    if (result.hasException()) {
+        failureCallback();
+        return { };
+    }
+    callback(result.releaseReturnValue());
     return { };
 }
 
index 00bacd4..31b0a07 100644 (file)
 
 #include "CommonCryptoUtilities.h"
 #include "CryptoKeyRSA.h"
+#include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
 
 namespace WebCore {
 
-ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
+// FIXME: We should change data to Vector<uint8_t> type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr<Vector<uint8_t>> encryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
 {
-    Vector<uint8_t> cipherText(1024);
+    Vector<uint8_t> cipherText(keyLength / 8); // Per Step 3.c of https://tools.ietf.org/html/rfc3447#section-7.2.1
     size_t cipherTextLength = cipherText.size();
-    CCCryptorStatus status = CCRSACryptorEncrypt(key.platformKey(), ccPKCS1Padding, data.first, data.second, cipherText.data(), &cipherTextLength, 0, 0, kCCDigestNone);
-    if (status) {
+    if (CCRSACryptorEncrypt(key, ccPKCS1Padding, data, dataLength, cipherText.data(), &cipherTextLength, 0, 0, kCCDigestNone))
+        return Exception { OperationError };
+
+    return WTFMove(cipherText);
+}
+
+void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+    context.ref();
+    workQueue.dispatch([key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+        auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
+        auto result = encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText.data(), plainText.size());
+        if (result.hasException()) {
+            context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+            callback(result);
+            context.deref();
+        });
+    });
+}
+
+ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
+{
+    auto result = encryptRSAES_PKCS1_v1_5(key.platformKey(), key.keySizeInBits(), data.first, data.second);
+    if (result.hasException()) {
         failureCallback();
         return { };
     }
-
-    cipherText.resize(cipherTextLength);
-    callback(cipherText);
+    callback(result.releaseReturnValue());
     return { };
 }
 
+// FIXME: We should get rid of the magic number 1024. It only makes sense when key length < 8192 bits
 ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
 {
     Vector<uint8_t> plainText(1024);
index 9378ed4..c36ce6c 100644 (file)
 #if ENABLE(SUBTLE_CRYPTO)
 
 #include "CommonCryptoUtilities.h"
+#include "CryptoAlgorithmRsaOaepParams.h"
 #include "CryptoAlgorithmRsaOaepParamsDeprecated.h"
 #include "CryptoKeyRSA.h"
 #include "ExceptionCode.h"
+#include "ScriptExecutionContext.h"
 
 namespace WebCore {
 
-ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
+// FIXME: We should change data to Vector<uint8_t> type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr<Vector<uint8_t>> encryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector<uint8_t>& label, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength)
 {
     CCDigestAlgorithm digestAlgorithm;
-    if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm))
-        return Exception { NOT_SUPPORTED_ERR };
+    if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm))
+        return Exception { OperationError };
 
-    Vector<uint8_t> cipherText(1024);
+    Vector<uint8_t> cipherText(keyLength / 8); // Per Step 3.c of https://tools.ietf.org/html/rfc3447#section-7.1.1
     size_t cipherTextLength = cipherText.size();
+    if (CCRSACryptorEncrypt(key, ccOAEPPadding, data, dataLength, cipherText.data(), &cipherTextLength, label.data(), label.size(), digestAlgorithm))
+        return Exception { OperationError };
+
+    return WTFMove(cipherText);
+}
+
+void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+    context.ref();
+    workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+        auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters);
+        auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
+        auto result = encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText.data(), plainText.size());
+        if (result.hasException()) {
+            context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+                exceptionCallback(ec);
+                context.deref();
+            });
+            return;
+        }
+        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+            callback(result);
+            context.deref();
+        });
+    });
+}
+
+ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
+{
     ASSERT(parameters.hasLabel || parameters.label.isEmpty());
-    CCCryptorStatus status = CCRSACryptorEncrypt(key.platformKey(), ccOAEPPadding, data.first, data.second, cipherText.data(), &cipherTextLength, parameters.label.data(), parameters.label.size(), digestAlgorithm);
-    if (status) {
+    auto result = encryptRSA_OAEP(parameters.hash, parameters.label, key.platformKey(), key.keySizeInBits(), data.first, data.second);
+    if (result.hasException()) {
         failureCallback();
         return { };
     }
-
-    cipherText.resize(cipherTextLength);
-    callback(cipherText);
+    callback(result.releaseReturnValue());
     return { };
 }
 
+// FIXME: We should get rid of the magic number 1024. It only makes sense when key length < 8192 bits
 ExceptionOr<void> CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
 {
     CCDigestAlgorithm digestAlgorithm;
index d0acbff..a798c31 100644 (file)
@@ -37,6 +37,8 @@
 
 namespace WebCore {
 
+// FIXME: We should get rid of magic number 16384. It assumes that the length of provided key will not exceed 16KB.
+// https://bugs.webkit.org/show_bug.cgi?id=164942
 static CCCryptorStatus getPublicKeyComponents(CCRSACryptorRef rsaKey, Vector<uint8_t>& modulus, Vector<uint8_t>& publicExponent)
 {
     ASSERT(CCRSAGetKeyType(rsaKey) == ccRSAKeyPublic || CCRSAGetKeyType(rsaKey) == ccRSAKeyPrivate);
@@ -233,7 +235,9 @@ static bool bigIntegerToUInt32(const Vector<uint8_t>& bigInteger, uint32_t& resu
     return true;
 }
 
-void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap usage, KeyPairCallback callback, VoidCallback failureCallback, ScriptExecutionContext* context)
+// FIXME: We should use WorkQueue here instead of dispatch_async once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164943
+void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap usage, KeyPairCallback&& callback, VoidCallback&& failureCallback, ScriptExecutionContext* context)
 {
     uint32_t e;
     if (!bigIntegerToUInt32(publicExponent, e)) {
diff --git a/Source/WebCore/crypto/parameters/AesCbcParams.idl b/Source/WebCore/crypto/parameters/AesCbcParams.idl
new file mode 100644 (file)
index 0000000..bdd9043
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=SUBTLE_CRYPTO,
+    ImplementedAs=CryptoAlgorithmAesCbcParams
+] dictionary AesCbcParams : CryptoAlgorithmParameters {
+    // The initialization vector. MUST be 16 bytes.
+    required BufferSource iv;
+};
diff --git a/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h b/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcParams.h
new file mode 100644 (file)
index 0000000..e1bcebf
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "BufferSource.h"
+#include "CryptoAlgorithmParameters.h"
+#include <wtf/Vector.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmAesCbcParams final : public CryptoAlgorithmParameters {
+public:
+    BufferSource iv;
+
+    Class parametersClass() const final { return Class::AesCbcParams; }
+
+    const Vector<uint8_t>& ivVector()
+    {
+        if (!m_ivVector.isEmpty() || !iv.length())
+            return m_ivVector;
+
+        m_ivVector.append(iv.data(), iv.length());
+        return m_ivVector;
+    }
+
+private:
+    Vector<uint8_t> m_ivVector;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(AesCbcParams)
+
+#endif // ENABLE(SUBTLE_CRYPTO)
index 90b4eb3..2f10a70 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 class CryptoAlgorithmAesCbcParamsDeprecated final : public CryptoAlgorithmParametersDeprecated {
 public:
     // The initialization vector. MUST be 16 bytes.
-    std::array<char, 16> iv;
+    std::array<uint8_t, 16> iv;
 
     Class parametersClass() const override { return Class::AesCbcParams; }
 };
diff --git a/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h b/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h
new file mode 100644 (file)
index 0000000..e689936
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "BufferSource.h"
+#include "CryptoAlgorithmParameters.h"
+#include <wtf/Vector.h>
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmRsaOaepParams final : public CryptoAlgorithmParameters {
+public:
+    // Use labelVector() instead of label. The label will be gone once labelVector() is called.
+    Optional<BufferSource::VariantType> label;
+
+    Class parametersClass() const final { return Class::RsaOaepParams; }
+
+    const Vector<uint8_t>& labelVector()
+    {
+        if (!m_labelVector.isEmpty() || !label)
+            return m_labelVector;
+
+        m_labelBuffer = WTFMove(*label);
+        label = Nullopt;
+        if (!m_labelBuffer.length())
+            return m_labelVector;
+
+        m_labelVector.append(m_labelBuffer.data(), m_labelBuffer.length());
+        return m_labelVector;
+    }
+
+private:
+    Vector<uint8_t> m_labelVector;
+    BufferSource m_labelBuffer;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(RsaOaepParams)
+
+#endif // ENABLE(SUBTLE_CRYPTO)
diff --git a/Source/WebCore/crypto/parameters/RsaOaepParams.idl b/Source/WebCore/crypto/parameters/RsaOaepParams.idl
new file mode 100644 (file)
index 0000000..778ecd9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+* Copyright (C) 2016 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+[
+    Conditional=SUBTLE_CRYPTO,
+    ImplementedAs=CryptoAlgorithmRsaOaepParams
+] dictionary RsaOaepParams : CryptoAlgorithmParameters {
+    // The optional label/application data to associate with the message
+    BufferSource label;
+};