⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 221189 in webkit


Ignore:
Timestamp:
Aug 25, 2017, 9:52:28 AM (9 years ago)
Author:
beidson@apple.com
Message:

Unreviewed, rolling out r221181.

Broke builds that use CryptoAlgorithmRSA_PSSMac.cpp

Reverted changeset:

"[WebCrypto] Push WorkQueue dispatches for RSA algorithms into
shared code"
​https://bugs.webkit.org/show_bug.cgi?id=175621
​http://trac.webkit.org/changeset/221181

Location:
trunk/Source/WebCore
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221184 r221189  
     12017-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
    1142017-08-25  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    215
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp

    r221181 r221189  
    2828
    2929#if ENABLE(SUBTLE_CRYPTO)
    30 
    31 #include "ScriptExecutionContext.h"
    3230
    3331namespace WebCore {
    … …  
    9391}
    9492
    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 
    13193}
    13294
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.h

    r221181 r221189  
    7777    virtual void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&);
    7878    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>()>&&);
    8279};
    8380
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp

    r221181 r221189  
    5454        return;
    5555    }
    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);
    6157}
    6258
    … …  
    6763        return;
    6864    }
    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);
    7466}
    7567
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h

    r221181 r221189  
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252
    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&);
    5555};
    5656
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp

    r221181 r221189  
    5959        return;
    6060    }
    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);
    6662}
    6763
    … …  
    7268        return;
    7369    }
    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);
    7971}
    8072
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h

    r221181 r221189  
    5050    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5151
    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&);
    5454};
    5555
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp

    r221181 r221189  
    6060        return;
    6161    }
    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);
    6763}
    6864
    … …  
    7470        return;
    7571    }
    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);
    8173}
    8274
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h

    r221181 r221189  
    5050    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5151
    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&);
    5454};
    5555
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp

    r221181 r221189  
    5959        return;
    6060    }
    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);
    6662}
    6763
    … …  
    7268        return;
    7369    }
    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);
    7971}
    8072
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h

    r221181 r221189  
    5050    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5151
    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&);
    5454};
    5555
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSAES_PKCS1_v1_5GCrypt.cpp

    r221181 r221189  
    3131#include "CryptoKeyRSA.h"
    3232#include "GCryptUtilities.h"
     33#include "ScriptExecutionContext.h"
    3334
    3435namespace WebCore {
    3536
    36 static std::optional<Vector<uint8_t>> gcryptEncrypt(gcry_sexp_t keySexp, const Vector<uint8_t>& plainText)
     37static std::optional<Vector<uint8_t>> gcryptEncrypt(gcry_sexp_t keySexp, Vector<uint8_t>&& plainText)
    3738{
    3839    // Embed the plain-text data in a `data` s-expression using PKCS#1 padding.
    … …  
    6465}
    6566
    66 static std::optional<Vector<uint8_t>> gcryptDecrypt(gcry_sexp_t keySexp, const Vector<uint8_t>& cipherText)
     67static std::optional<Vector<uint8_t>> gcryptDecrypt(gcry_sexp_t keySexp, Vector<uint8_t>&& cipherText)
    6768{
    6869    // Embed the cipher-text data in an `enc-val` s-expression using PKCS#1 padding.
    … …  
    9495}
    9596
    96 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKey& key, const Vector<uint8_t>& plainText)
     97void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    9798{
    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        });
    102122}
    103123
    104 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKey& key, const Vector<uint8_t>& cipherText)
     124void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    105125{
    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        });
    110149}
    111150
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSASSA_PKCS1_v1_5GCrypt.cpp

    r221181 r221189  
    3333#include "GCryptUtilities.h"
    3434#include "NotImplemented.h"
     35#include "ScriptExecutionContext.h"
    3536
    3637namespace WebCore {
    … …  
    135136}
    136137
    137 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)
     138void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    138139{
    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        });
    144163}
    145164
    146 ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
     165void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    147166{
    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        });
    153190}
    154191
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp

    r221181 r221189  
    3333#include "GCryptUtilities.h"
    3434#include "NotImplemented.h"
     35#include "ScriptExecutionContext.h"
    3536
    3637namespace WebCore {
    … …  
    111112}
    112113
    113 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
     114void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    114115{
    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());
    117121
    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        });
    122140}
    123141
    124 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
     142void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    125143{
    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());
    128149
    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        });
    133168}
    134169
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp

    r221181 r221189  
    3434#include "CryptoKeyRSA.h"
    3535#include "GCryptUtilities.h"
     36#include "ScriptExecutionContext.h"
    3637
    3738namespace WebCore {
    … …  
    141142}
    142143
    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);
     144void 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
     172void 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        });
    163198}
    164199
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp

    r221181 r221189  
    3131#include "CommonCryptoUtilities.h"
    3232#include "CryptoKeyRSA.h"
     33#include "ScriptExecutionContext.h"
    3334
    3435namespace WebCore {
    … …  
    5556}
    5657
    57 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(const CryptoKey& key, const Vector<uint8_t>& plainText)
     58void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    5859{
    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    });
    6178}
    6279
    63 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(const CryptoKey& key, const Vector<uint8_t>& cipherText)
     80void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    6481{
    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    });
    67100}
    68101
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp

    r221181 r221189  
    3232#include "CryptoDigestAlgorithm.h"
    3333#include "CryptoKeyRSA.h"
     34#include "ScriptExecutionContext.h"
    3435
    3536namespace WebCore {
    … …  
    8485}
    8586
    86 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoKey& key, const Vector<uint8_t>& data)
     87void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    8788{
    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    });
    90107}
    91108
    92 ExceptionOr<bool> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
     109void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    93110{
    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    });
    96129}
    97130
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp

    r221181 r221189  
    3232#include "CryptoAlgorithmRsaOaepParams.h"
    3333#include "CryptoKeyRSA.h"
     34#include "ScriptExecutionContext.h"
    3435
    3536namespace WebCore {
    … …  
    6465}
    6566
    66 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& plainText)
     67void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    6768{
    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    });
    7188}
    7289
    73 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& cipherText)
     90void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    7491{
    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    });
    78111}
    79112
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp

    r221181 r221189  
    3333#include "CryptoDigestAlgorithm.h"
    3434#include "CryptoKeyRSA.h"
     35#include "ScriptExecutionContext.h"
    3536
    3637namespace WebCore {
    … …  
    8283}
    8384
    84 void CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& data)
     85void CryptoAlgorithmRSA_PSS::platformSign(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    8586{
    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    });
    89106}
    90107
    91 void CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmParameters& parameters, const CryptoKey& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
     108void 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)
    92109{
    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    });
    96129}
    97130
Note: See TracChangeset for help on using the changeset viewer.