Changeset 221189 in webkit
- Timestamp:
- Aug 25, 2017, 9:52:28 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 19 edited
-
ChangeLog (modified) (1 diff)
-
crypto/CryptoAlgorithm.cpp (modified) (2 diffs)
-
crypto/CryptoAlgorithm.h (modified) (1 diff)
-
crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (modified) (2 diffs)
-
crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h (modified) (1 diff)
-
crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (modified) (2 diffs)
-
crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h (modified) (1 diff)
-
crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (modified) (2 diffs)
-
crypto/algorithms/CryptoAlgorithmRSA_OAEP.h (modified) (1 diff)
-
crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp (modified) (2 diffs)
-
crypto/algorithms/CryptoAlgorithmRSA_PSS.h (modified) (1 diff)
-
crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp (modified) (3 diffs)
-
crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp (modified) (2 diffs)
-
crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp (modified) (2 diffs)
-
crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp (modified) (2 diffs)
-
crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp (modified) (2 diffs)
-
crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp (modified) (2 diffs)
-
crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp (modified) (2 diffs)
-
crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r221184 r221189 1 2017-08-25 Brady Eidson <beidson@apple.com> 2 3 Unreviewed, rolling out r221181. 4 5 Broke builds that use CryptoAlgorithmRSA_PSSMac.cpp 6 7 Reverted changeset: 8 9 "[WebCrypto] Push WorkQueue dispatches for RSA algorithms into 10 shared code" 11 https://bugs.webkit.org/show_bug.cgi?id=175621 12 http://trac.webkit.org/changeset/221181 13 1 14 2017-08-25 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 15 -
trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp
r221181 r221189 28 28 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 31 #include "ScriptExecutionContext.h"32 30 33 31 namespace WebCore { … … 93 91 } 94 92 95 template<typename ResultCallbackType, typename OperationType>96 static void dispatchAlgorithmOperation(WorkQueue& workQueue, ScriptExecutionContext& context, ResultCallbackType&& callback, CryptoAlgorithm::ExceptionCallback&& exceptionCallback, OperationType&& operation)97 {98 context.ref();99 workQueue.dispatch(100 [operation = WTFMove(operation), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {101 auto result = operation();102 if (result.hasException()) {103 // We should only dereference callbacks after being back to the Document/Worker threads.104 context.postTask(105 [ec = result.releaseException().code(), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {106 exceptionCallback(ec);107 context.deref();108 });109 return;110 }111 112 // We should only dereference callbacks after being back to the Document/Worker threads.113 context.postTask(114 [result = result.releaseReturnValue(), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {115 callback(result);116 context.deref();117 });118 });119 }120 121 void CryptoAlgorithm::dispatchOperation(WorkQueue& workQueue, ScriptExecutionContext& context, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&& operation)122 {123 dispatchAlgorithmOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), WTFMove(operation));124 }125 126 void CryptoAlgorithm::dispatchOperation(WorkQueue& workQueue, ScriptExecutionContext& context, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<bool>()>&& operation)127 {128 dispatchAlgorithmOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), WTFMove(operation));129 }130 131 93 } 132 94 -
trunk/Source/WebCore/crypto/CryptoAlgorithm.h
r221181 r221189 77 77 virtual void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&); 78 78 virtual ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&); 79 80 static void dispatchOperation(WorkQueue&, ScriptExecutionContext&, VectorCallback&&, ExceptionCallback&&, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&&);81 static void dispatchOperation(WorkQueue&, ScriptExecutionContext&, BoolCallback&&, ExceptionCallback&&, WTF::Function<ExceptionOr<bool>()>&&);82 79 }; 83 80 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
r221181 r221189 54 54 return; 55 55 } 56 57 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 58 [key = WTFMove(key), plainText = WTFMove(plainText)] { 59 return platformEncrypt(key, plainText); 60 }); 56 platformEncrypt(WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 61 57 } 62 58 … … 67 63 return; 68 64 } 69 70 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 71 [key = WTFMove(key), cipherText = WTFMove(cipherText)] { 72 return platformDecrypt(key, cipherText); 73 }); 65 platformDecrypt(WTFMove(key), WTFMove(cipherText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 74 66 } 75 67 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h
r221181 r221189 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 53 static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoKey&, const Vector<uint8_t>&);54 static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoKey&, const Vector<uint8_t>&);53 void platformEncrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 54 void platformDecrypt(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 55 55 }; 56 56 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
r221181 r221189 59 59 return; 60 60 } 61 62 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 63 [key = WTFMove(key), data = WTFMove(data)] { 64 return platformSign(key, data); 65 }); 61 platformSign(WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 66 62 } 67 63 … … 72 68 return; 73 69 } 74 75 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 76 [key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] { 77 return platformVerify(key, signature, data); 78 }); 70 platformVerify(WTFMove(key), WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 79 71 } 80 72 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h
r221181 r221189 50 50 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 51 52 static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoKey&, const Vector<uint8_t>&);53 static ExceptionOr<bool> platformVerify(const CryptoKey&, const Vector<uint8_t>&, const Vector<uint8_t>&);52 void platformSign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 53 void platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 54 54 }; 55 55 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
r221181 r221189 60 60 return; 61 61 } 62 63 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 64 [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] { 65 return platformEncrypt(*parameters, key, plainText); 66 }); 62 platformEncrypt(WTFMove(parameters), WTFMove(key), WTFMove(plainText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 67 63 } 68 64 … … 74 70 return; 75 71 } 76 77 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 78 [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] { 79 return platformDecrypt(*parameters, key, cipherText); 80 }); 72 platformDecrypt(WTFMove(parameters), WTFMove(key), WTFMove(cipherText), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 81 73 } 82 74 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h
r221181 r221189 50 50 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 51 52 static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);53 static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);52 void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 53 void platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 54 54 }; 55 55 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp
r221181 r221189 59 59 return; 60 60 } 61 62 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 63 [parameters = WTFMove(parameters), key = WTFMove(key), data = WTFMove(data)] { 64 return platformSign(*parameters, key, data); 65 }); 61 platformSign(WTFMove(parameters), WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 66 62 } 67 63 … … 72 68 return; 73 69 } 74 75 dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 76 [parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] { 77 return platformVerify(*parameters, key, signature, data); 78 }); 70 platformVerify(WTFMove(parameters), WTFMove(key), WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue); 79 71 } 80 72 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h
r221181 r221189 50 50 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 51 52 static ExceptionOr<Vector<uint8_t>> platformSign(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&);53 static ExceptionOr<bool> platformVerify(CryptoAlgorithmParameters&, const CryptoKey&, const Vector<uint8_t>&, const Vector<uint8_t>&);52 void platformSign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 53 void platformVerify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 54 54 }; 55 55 -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp
r221181 r221189 31 31 #include "CryptoKeyRSA.h" 32 32 #include "GCryptUtilities.h" 33 #include "ScriptExecutionContext.h" 33 34 34 35 namespace WebCore { 35 36 36 static std::optional<Vector<uint8_t>> gcryptEncrypt(gcry_sexp_t keySexp, const Vector<uint8_t>& plainText)37 static std::optional<Vector<uint8_t>> gcryptEncrypt(gcry_sexp_t keySexp, Vector<uint8_t>&& plainText) 37 38 { 38 39 // Embed the plain-text data in a `data` s-expression using PKCS#1 padding. … … 64 65 } 65 66 66 static std::optional<Vector<uint8_t>> gcryptDecrypt(gcry_sexp_t keySexp, const Vector<uint8_t>& cipherText)67 static std::optional<Vector<uint8_t>> gcryptDecrypt(gcry_sexp_t keySexp, Vector<uint8_t>&& cipherText) 67 68 { 68 69 // Embed the cipher-text data in an `enc-val` s-expression using PKCS#1 padding. … … 94 95 } 95 96 96 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKey& key, const Vector<uint8_t>& plainText)97 void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 97 98 { 98 auto output = gcryptEncrypt(downcast<CryptoKeyRSA>(key).platformKey(), plainText); 99 if (!output) 100 return Exception { OperationError }; 101 return WTFMove(*output); 99 context.ref(); 100 workQueue.dispatch( 101 [key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 102 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 103 104 auto output = gcryptEncrypt(rsaKey.platformKey(), WTFMove(plainText)); 105 if (!output) { 106 // We should only dereference callbacks after being back to the Document/Worker threads. 107 context.postTask( 108 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 109 exceptionCallback(OperationError); 110 context.deref(); 111 }); 112 return; 113 } 114 115 // We should only dereference callbacks after being back to the Document/Worker threads. 116 context.postTask( 117 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) mutable { 118 callback(WTFMove(output)); 119 context.deref(); 120 }); 121 }); 102 122 } 103 123 104 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKey& key, const Vector<uint8_t>& cipherText)124 void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 105 125 { 106 auto output = gcryptDecrypt(downcast<CryptoKeyRSA>(key).platformKey(), cipherText); 107 if (!output) 108 return Exception { OperationError }; 109 return WTFMove(*output); 126 context.ref(); 127 workQueue.dispatch( 128 [key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 129 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 130 131 auto output = gcryptDecrypt(rsaKey.platformKey(), WTFMove(cipherText)); 132 if (!output) { 133 // We should only dereference callbacks after being back to the Document/Worker threads. 134 context.postTask( 135 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 136 exceptionCallback(OperationError); 137 context.deref(); 138 }); 139 return; 140 } 141 142 // We should only dereference callbacks after being back to the Document/Worker threads. 143 context.postTask( 144 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) mutable { 145 callback(WTFMove(output)); 146 context.deref(); 147 }); 148 }); 110 149 } 111 150 -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp
r221181 r221189 33 33 #include "GCryptUtilities.h" 34 34 #include "NotImplemented.h" 35 #include "ScriptExecutionContext.h" 35 36 36 37 namespace WebCore { … … 135 136 } 136 137 137 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)138 void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 138 139 { 139 auto& rsaKey = downcast<CryptoKeyRSA>(key); 140 auto output = gcryptSign(rsaKey.platformKey(), data, rsaKey.hashAlgorithmIdentifier()); 141 if (!output) 142 return Exception { OperationError }; 143 return WTFMove(*output); 140 context.ref(); 141 workQueue.dispatch( 142 [key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 143 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 144 145 auto output = gcryptSign(rsaKey.platformKey(), data, rsaKey.hashAlgorithmIdentifier()); 146 if (!output) { 147 // We should only dereference callbacks after being back to the Document/Worker threads. 148 context.postTask( 149 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 150 exceptionCallback(OperationError); 151 context.deref(); 152 }); 153 return; 154 } 155 156 // We should only dereference callbacks after being back to the Document/Worker threads. 157 context.postTask( 158 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 159 callback(output); 160 context.deref(); 161 }); 162 }); 144 163 } 145 164 146 ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)165 void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 147 166 { 148 auto& rsaKey = downcast<CryptoKeyRSA>(key); 149 auto output = gcryptVerify(rsaKey.platformKey(), signature, data, rsaKey.hashAlgorithmIdentifier()); 150 if (!output) 151 return Exception { OperationError }; 152 return *output; 167 context.ref(); 168 workQueue.dispatch( 169 [key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 170 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 171 172 auto output = gcryptVerify(rsaKey.platformKey(), signature, data, rsaKey.hashAlgorithmIdentifier()); 173 if (!output) { 174 // We should only dereference callbacks after being back to the Document/Worker threads. 175 context.postTask( 176 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 177 exceptionCallback(OperationError); 178 context.deref(); 179 }); 180 return; 181 } 182 183 // We should only dereference callbacks after being back to the Document/Worker threads. 184 context.postTask( 185 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 186 callback(output); 187 context.deref(); 188 }); 189 }); 153 190 } 154 191 -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp
r221181 r221189 33 33 #include "GCryptUtilities.h" 34 34 #include "NotImplemented.h" 35 #include "ScriptExecutionContext.h" 35 36 36 37 namespace WebCore { … … 111 112 } 112 113 113 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)114 void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 114 115 { 115 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters); 116 auto& rsaKey = downcast<CryptoKeyRSA>(key); 116 context.ref(); 117 workQueue.dispatch( 118 [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 119 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters); 120 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 117 121 118 auto output = gcryptEncrypt(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaParameters.labelVector(), plainText); 119 if (!output) 120 return Exception { OperationError }; 121 return WTFMove(*output); 122 auto output = gcryptEncrypt(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaParameters.labelVector(), plainText); 123 if (!output) { 124 // We should only dereference callbacks after being back to the Document/Worker threads. 125 context.postTask( 126 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 127 exceptionCallback(OperationError); 128 context.deref(); 129 }); 130 return; 131 } 132 133 // We should only dereference callbacks after being back to the Document/Worker threads. 134 context.postTask( 135 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 136 callback(output); 137 context.deref(); 138 }); 139 }); 122 140 } 123 141 124 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)142 void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 125 143 { 126 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters); 127 auto& rsaKey = downcast<CryptoKeyRSA>(key); 144 context.ref(); 145 workQueue.dispatch( 146 [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 147 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters); 148 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 128 149 129 auto output = gcryptDecrypt(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaParameters.labelVector(), cipherText); 130 if (!output) 131 return Exception { OperationError }; 132 return WTFMove(*output); 150 auto output = gcryptDecrypt(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaParameters.labelVector(), cipherText); 151 if (!output) { 152 // We should only dereference callbacks after being back to the Document/Worker threads. 153 context.postTask( 154 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 155 exceptionCallback(OperationError); 156 context.deref(); 157 }); 158 return; 159 } 160 161 // We should only dereference callbacks after being back to the Document/Worker threads. 162 context.postTask( 163 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 164 callback(output); 165 context.deref(); 166 }); 167 }); 133 168 } 134 169 -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp
r221181 r221189 34 34 #include "CryptoKeyRSA.h" 35 35 #include "GCryptUtilities.h" 36 #include "ScriptExecutionContext.h" 36 37 37 38 namespace WebCore { … … 141 142 } 142 143 143 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data) 144 { 145 auto& rsaKey = downcast<CryptoKeyRSA>(key); 146 auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters); 147 148 auto output = gcryptSign(rsaKey.platformKey(), rsaKey.keySizeInBits(), data, rsaKey.hashAlgorithmIdentifier(), rsaParameters.saltLength); 149 if (!output) 150 return Exception { OperationError }; 151 return WTFMove(*output); 152 } 153 154 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data) 155 { 156 auto& rsaKey = downcast<CryptoKeyRSA>(key); 157 auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters); 158 159 auto output = gcryptVerify(rsaKey.platformKey(), signature, data, rsaKey.hashAlgorithmIdentifier(), rsaParameters.saltLength); 160 if (!output) 161 return Exception { OperationError }; 162 return WTFMove(*output); 144 void CryptoAlgorithmRSA_PSS::platformSign(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 145 { 146 context.ref(); 147 workQueue.dispatch( 148 [parameters = WTFMove(parameters), key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 149 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 150 auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(*parameters); 151 152 auto output = gcryptSign(rsaKey.platformKey(), rsaKey.keySizeInBits(), data, rsaKey.hashAlgorithmIdentifier(), rsaParameters.saltLength); 153 if (!output) { 154 // We should only dereference callbacks after being back to the Document/Worker threads. 155 context.postTask( 156 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 157 exceptionCallback(OperationError); 158 context.deref(); 159 }); 160 return; 161 } 162 163 // We should only dereference callbacks after being back to the Document/Worker threads. 164 context.postTask( 165 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 166 callback(output); 167 context.deref(); 168 }); 169 }); 170 } 171 172 void CryptoAlgorithmRSA_PSS::platformVerify(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 173 { 174 context.ref(); 175 workQueue.dispatch( 176 [parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 177 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 178 auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(*parameters); 179 180 auto output = gcryptVerify(rsaKey.platformKey(), signature, data, rsaKey.hashAlgorithmIdentifier(), rsaParameters.saltLength); 181 if (!output) { 182 // We should only dereference callbacks after being back to the Document/Worker threads. 183 context.postTask( 184 [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 185 exceptionCallback(OperationError); 186 context.deref(); 187 }); 188 return; 189 } 190 191 // We should only dereference callbacks after being back to the Document/Worker threads. 192 context.postTask( 193 [output = WTFMove(*output), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 194 callback(output); 195 context.deref(); 196 }); 197 }); 163 198 } 164 199 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp
r221181 r221189 31 31 #include "CommonCryptoUtilities.h" 32 32 #include "CryptoKeyRSA.h" 33 #include "ScriptExecutionContext.h" 33 34 34 35 namespace WebCore { … … 55 56 } 56 57 57 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKey& key, const Vector<uint8_t>& plainText)58 void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 58 59 { 59 auto& rsaKey = downcast<CryptoKeyRSA>(key); 60 return encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText); 60 context.ref(); 61 workQueue.dispatch([key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 62 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 63 auto result = encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText); 64 if (result.hasException()) { 65 // We should only dereference callbacks after being back to the Document/Worker threads. 66 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 67 exceptionCallback(ec); 68 context.deref(); 69 }); 70 return; 71 } 72 // We should only dereference callbacks after being back to the Document/Worker threads. 73 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 74 callback(result); 75 context.deref(); 76 }); 77 }); 61 78 } 62 79 63 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKey& key, const Vector<uint8_t>& cipherText)80 void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 64 81 { 65 auto& rsaKey = downcast<CryptoKeyRSA>(key); 66 return decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText); 82 context.ref(); 83 workQueue.dispatch([key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 84 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 85 auto result = decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText); 86 if (result.hasException()) { 87 // We should only dereference callbacks after being back to the Document/Worker threads. 88 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 89 exceptionCallback(ec); 90 context.deref(); 91 }); 92 return; 93 } 94 // We should only dereference callbacks after being back to the Document/Worker threads. 95 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 96 callback(result); 97 context.deref(); 98 }); 99 }); 67 100 } 68 101 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp
r221181 r221189 32 32 #include "CryptoDigestAlgorithm.h" 33 33 #include "CryptoKeyRSA.h" 34 #include "ScriptExecutionContext.h" 34 35 35 36 namespace WebCore { … … 84 85 } 85 86 86 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)87 void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 87 88 { 88 auto& rsaKey = downcast<CryptoKeyRSA>(key); 89 return signRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data); 89 context.ref(); 90 workQueue.dispatch([key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 91 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 92 auto result = signRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data); 93 if (result.hasException()) { 94 // We should only dereference callbacks after being back to the Document/Worker threads. 95 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 96 exceptionCallback(ec); 97 context.deref(); 98 }); 99 return; 100 } 101 // We should only dereference callbacks after being back to the Document/Worker threads. 102 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 103 callback(result); 104 context.deref(); 105 }); 106 }); 90 107 } 91 108 92 ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)109 void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 93 110 { 94 auto& rsaKey = downcast<CryptoKeyRSA>(key); 95 return verifyRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data); 111 context.ref(); 112 workQueue.dispatch([key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 113 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 114 auto result = verifyRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data); 115 if (result.hasException()) { 116 // We should only dereference callbacks after being back to the Document/Worker threads. 117 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 118 exceptionCallback(ec); 119 context.deref(); 120 }); 121 return; 122 } 123 // We should only dereference callbacks after being back to the Document/Worker threads. 124 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 125 callback(result); 126 context.deref(); 127 }); 128 }); 96 129 } 97 130 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp
r221181 r221189 32 32 #include "CryptoAlgorithmRsaOaepParams.h" 33 33 #include "CryptoKeyRSA.h" 34 #include "ScriptExecutionContext.h" 34 35 35 36 namespace WebCore { … … 64 65 } 65 66 66 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)67 void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 67 68 { 68 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters); 69 auto& rsaKey = downcast<CryptoKeyRSA>(key); 70 return encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText); 69 context.ref(); 70 workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 71 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters); 72 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 73 auto result = encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText); 74 if (result.hasException()) { 75 // We should only dereference callbacks after being back to the Document/Worker threads. 76 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 77 exceptionCallback(ec); 78 context.deref(); 79 }); 80 return; 81 } 82 // We should only dereference callbacks after being back to the Document/Worker threads. 83 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 84 callback(result); 85 context.deref(); 86 }); 87 }); 71 88 } 72 89 73 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)90 void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 74 91 { 75 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(parameters); 76 auto& rsaKey = downcast<CryptoKeyRSA>(key); 77 return decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText); 92 context.ref(); 93 workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 94 auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters); 95 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 96 auto result = decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText); 97 if (result.hasException()) { 98 // We should only dereference callbacks after being back to the Document/Worker threads. 99 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 100 exceptionCallback(ec); 101 context.deref(); 102 }); 103 return; 104 } 105 // We should only dereference callbacks after being back to the Document/Worker threads. 106 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 107 callback(result); 108 context.deref(); 109 }); 110 }); 78 111 } 79 112 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp
r221181 r221189 33 33 #include "CryptoDigestAlgorithm.h" 34 34 #include "CryptoKeyRSA.h" 35 #include "ScriptExecutionContext.h" 35 36 36 37 namespace WebCore { … … 82 83 } 83 84 84 void CryptoAlgorithmRSA_PSS::platformSign( CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data)85 void CryptoAlgorithmRSA_PSS::platformSign(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 85 86 { 86 auto& rsaKey = downcast<CryptoKeyRSA>(key); 87 auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters); 88 return signRSA_PSS(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data, rsaParameters.saltLength); 87 context.ref(); 88 workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 89 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 90 auto& rsaParams = downcast<CryptoAlgorithmRsaPssParams>(*parameters); 91 auto result = signRSA_PSS(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data, rsaParams.saltLength); 92 if (result.hasException()) { 93 // We should only dereference callbacks after being back to the Document/Worker threads. 94 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 95 exceptionCallback(ec); 96 context.deref(); 97 }); 98 return; 99 } 100 // We should only dereference callbacks after being back to the Document/Worker threads. 101 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 102 callback(result); 103 context.deref(); 104 }); 105 }); 89 106 } 90 107 91 void CryptoAlgorithmRSA_PSS::platformVerify( CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)108 void CryptoAlgorithmRSA_PSS::platformVerify(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 92 109 { 93 auto& rsaKey = downcast<CryptoKeyRSA>(key); 94 auto& rsaParameters = downcast<CryptoAlgorithmRsaPssParams>(parameters); 95 return verifyRSA_PSS(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data, rsaParameters.saltLength); 110 context.ref(); 111 workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { 112 auto& rsaKey = downcast<CryptoKeyRSA>(key.get()); 113 auto& rsaParams = downcast<CryptoAlgorithmRsaPssParams>(*parameters); 114 auto result = verifyRSA_PSS(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data, rsaParams.saltLength); 115 if (result.hasException()) { 116 // We should only dereference callbacks after being back to the Document/Worker threads. 117 context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { 118 exceptionCallback(ec); 119 context.deref(); 120 }); 121 return; 122 } 123 // We should only dereference callbacks after being back to the Document/Worker threads. 124 context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { 125 callback(result); 126 context.deref(); 127 }); 128 }); 96 129 } 97 130
Note:
See TracChangeset
for help on using the changeset viewer.