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

Changeset 233898 in webkit


Ignore:
Timestamp:
Jul 17, 2018, 4:06:12 PM (8 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebCrypto] Crypto operations should copy their parameters before hoping to another thread
​https://bugs.webkit.org/show_bug.cgi?id=187501
<rdar://problem/41438160>

Reviewed by Youenn Fablet.

Source/WebCore:

This patch aims at making all captured variables in all crypto lambdas that need to be passed
to a worker thread thread safe, which includes:
1) changing ref counted objects to thread safe ref counted object.
2) adding isolatedCopy methods to non ref counted classes, so they can be called by CrossThreadCopy().

In addition to above changes, this patch also does the following things:
1) change the name CryptoAlgorithm::dispatchOperation => CryptoAlgorithm::dispatchOperationInWorkQueue
to make it clear that lambdas will be passed to a secondary thread.
2) make CryptoAlgorithmParameters as const parameters for all methods.
3) add null checks on BufferSource.length() and .data().

Tests: crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html

http/wpt/crypto/aes-cbc-crash.any.html
http/wpt/crypto/aes-cbc-crash.any.worker.html
http/wpt/crypto/aes-ctr-crash.any.html
http/wpt/crypto/aes-ctr-crash.any.worker.html
http/wpt/crypto/aes-gcm-crash.any.html
http/wpt/crypto/aes-gcm-crash.any.worker.html
http/wpt/crypto/derive-hmac-key-crash.any.html
http/wpt/crypto/derive-hmac-key-crash.any.worker.html
http/wpt/crypto/ecdsa-crash.any.html
http/wpt/crypto/ecdsa-crash.any.worker.html
http/wpt/crypto/hkdf-crash.any.html
http/wpt/crypto/hkdf-crash.any.worker.html
http/wpt/crypto/pbkdf2-crash.any.html
http/wpt/crypto/pbkdf2-crash.any.worker.html
http/wpt/crypto/rsa-oaep-crash.any.html
http/wpt/crypto/rsa-oaep-crash.any.worker.html
http/wpt/crypto/rsa-pss-crash.any.html
http/wpt/crypto/rsa-pss-crash.any.worker.html
http/wpt/crypto/unwrap-ec-key-crash.any.html
http/wpt/crypto/unwrap-ec-key-crash.any.worker.html
http/wpt/crypto/unwrap-rsa-key-crash.any.html
http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html

  • bindings/js/BufferSource.h:

(WebCore::BufferSource::data const):
(WebCore::BufferSource::length const):

  • crypto/CryptoAlgorithm.cpp:

(WebCore::CryptoAlgorithm::encrypt):
(WebCore::CryptoAlgorithm::decrypt):
(WebCore::CryptoAlgorithm::sign):
(WebCore::CryptoAlgorithm::verify):
(WebCore::CryptoAlgorithm::deriveBits):
(WebCore::CryptoAlgorithm::importKey):
(WebCore::dispatchAlgorithmOperation):
(WebCore::CryptoAlgorithm::dispatchOperationInWorkQueue):
(WebCore::CryptoAlgorithm::dispatchOperation): Deleted.

  • crypto/CryptoAlgorithm.h:
  • crypto/SubtleCrypto.cpp:

(WebCore::crossThreadCopyImportParams):
(WebCore::SubtleCrypto::encrypt):
(WebCore::SubtleCrypto::decrypt):
(WebCore::SubtleCrypto::sign):
(WebCore::SubtleCrypto::verify):
(WebCore::SubtleCrypto::deriveKey):
(WebCore::SubtleCrypto::deriveBits):
(WebCore::SubtleCrypto::importKey):
(WebCore::SubtleCrypto::wrapKey):
(WebCore::SubtleCrypto::unwrapKey):

  • crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:

(WebCore::CryptoAlgorithmAES_CBC::encrypt):
(WebCore::CryptoAlgorithmAES_CBC::decrypt):
(WebCore::CryptoAlgorithmAES_CBC::importKey):

  • crypto/algorithms/CryptoAlgorithmAES_CBC.h:
  • crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:

(WebCore::CryptoAlgorithmAES_CFB::encrypt):
(WebCore::CryptoAlgorithmAES_CFB::decrypt):
(WebCore::CryptoAlgorithmAES_CFB::importKey):

  • crypto/algorithms/CryptoAlgorithmAES_CFB.h:
  • crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:

(WebCore::parametersAreValid):
(WebCore::CryptoAlgorithmAES_CTR::encrypt):
(WebCore::CryptoAlgorithmAES_CTR::decrypt):
(WebCore::CryptoAlgorithmAES_CTR::importKey):

  • crypto/algorithms/CryptoAlgorithmAES_CTR.h:
  • crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:

(WebCore::CryptoAlgorithmAES_GCM::encrypt):
(WebCore::CryptoAlgorithmAES_GCM::decrypt):
(WebCore::CryptoAlgorithmAES_GCM::importKey):

  • crypto/algorithms/CryptoAlgorithmAES_GCM.h:
  • crypto/algorithms/CryptoAlgorithmAES_KW.cpp:

(WebCore::CryptoAlgorithmAES_KW::importKey):

  • crypto/algorithms/CryptoAlgorithmAES_KW.h:
  • crypto/algorithms/CryptoAlgorithmECDH.cpp:

(WebCore::CryptoAlgorithmECDH::deriveBits):
(WebCore::CryptoAlgorithmECDH::importKey):

  • crypto/algorithms/CryptoAlgorithmECDH.h:
  • crypto/algorithms/CryptoAlgorithmECDSA.cpp:

(WebCore::CryptoAlgorithmECDSA::sign):
(WebCore::CryptoAlgorithmECDSA::verify):
(WebCore::CryptoAlgorithmECDSA::importKey):

  • crypto/algorithms/CryptoAlgorithmECDSA.h:
  • crypto/algorithms/CryptoAlgorithmHKDF.cpp:

(WebCore::CryptoAlgorithmHKDF::deriveBits):
(WebCore::CryptoAlgorithmHKDF::importKey):

  • crypto/algorithms/CryptoAlgorithmHKDF.h:
  • crypto/algorithms/CryptoAlgorithmHMAC.cpp:

(WebCore::CryptoAlgorithmHMAC::sign):
(WebCore::CryptoAlgorithmHMAC::verify):
(WebCore::CryptoAlgorithmHMAC::importKey):

  • crypto/algorithms/CryptoAlgorithmHMAC.h:
  • crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:

(WebCore::CryptoAlgorithmPBKDF2::deriveBits):
(WebCore::CryptoAlgorithmPBKDF2::importKey):

  • crypto/algorithms/CryptoAlgorithmPBKDF2.h:
  • crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:

(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):

  • crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
  • crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:

(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):

  • crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
  • crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:

(WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::importKey):

  • crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
  • crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:

(WebCore::CryptoAlgorithmRSA_PSS::sign):
(WebCore::CryptoAlgorithmRSA_PSS::verify):
(WebCore::CryptoAlgorithmRSA_PSS::importKey):

  • crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
  • crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:

(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):

  • crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:

(WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):

  • crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:

(WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):

  • crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:

(WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
(WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):

  • crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:

(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):

  • crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:

(WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):

  • crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:

(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):

  • crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:

(WebCore::CryptoAlgorithmRSA_PSS::platformSign):
(WebCore::CryptoAlgorithmRSA_PSS::platformVerify):

  • crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:

(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):

  • crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:

(WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):

  • crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:

(WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):

  • crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:

(WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
(WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):

  • crypto/mac/CryptoAlgorithmHKDFMac.cpp:

(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):

  • crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:

(WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):

  • crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:

(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):

  • crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:

(WebCore::CryptoAlgorithmRSA_PSS::platformSign):
(WebCore::CryptoAlgorithmRSA_PSS::platformVerify):

  • crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h:
  • crypto/parameters/CryptoAlgorithmAesCtrParams.h:
  • crypto/parameters/CryptoAlgorithmAesGcmParams.h:
  • crypto/parameters/CryptoAlgorithmEcKeyParams.h:
  • crypto/parameters/CryptoAlgorithmEcdsaParams.h:
  • crypto/parameters/CryptoAlgorithmHkdfParams.h:
  • crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
  • crypto/parameters/CryptoAlgorithmPbkdf2Params.h:
  • crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
  • crypto/parameters/CryptoAlgorithmRsaOaepParams.h:
  • crypto/parameters/CryptoAlgorithmRsaPssParams.h:

LayoutTests:

crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html is an exception of this series of tests as
it only aims to test the correct behavoir of suggested algorithms. This patch aslo does some test
gardening.

  • TestExpectations:
  • crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key-expected.txt: Added.
  • crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html: Added.
  • http/wpt/crypto/aes-cbc-crash.any-expected.txt: Added.
  • http/wpt/crypto/aes-cbc-crash.any.html: Added.
  • http/wpt/crypto/aes-cbc-crash.any.js: Added.
  • http/wpt/crypto/aes-cbc-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/aes-cbc-crash.any.worker.html: Added.
  • http/wpt/crypto/aes-ctr-crash.any-expected.txt: Added.
  • http/wpt/crypto/aes-ctr-crash.any.html: Added.
  • http/wpt/crypto/aes-ctr-crash.any.js: Added.
  • http/wpt/crypto/aes-ctr-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/aes-ctr-crash.any.worker.html: Added.
  • http/wpt/crypto/aes-gcm-crash.any-expected.txt: Added.
  • http/wpt/crypto/aes-gcm-crash.any.html: Added.
  • http/wpt/crypto/aes-gcm-crash.any.js: Added.
  • http/wpt/crypto/aes-gcm-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/aes-gcm-crash.any.worker.html: Added.
  • http/wpt/crypto/derive-hmac-key-crash.any-expected.txt: Added.
  • http/wpt/crypto/derive-hmac-key-crash.any.html: Added.
  • http/wpt/crypto/derive-hmac-key-crash.any.js: Added.
  • http/wpt/crypto/derive-hmac-key-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/derive-hmac-key-crash.any.worker.html: Added.
  • http/wpt/crypto/ecdsa-crash.any-expected.txt: Added.
  • http/wpt/crypto/ecdsa-crash.any.html: Added.
  • http/wpt/crypto/ecdsa-crash.any.js: Added.
  • http/wpt/crypto/ecdsa-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/ecdsa-crash.any.worker.html: Added.
  • http/wpt/crypto/hkdf-crash.any-expected.txt: Added.
  • http/wpt/crypto/hkdf-crash.any.html: Added.
  • http/wpt/crypto/hkdf-crash.any.js: Added.
  • http/wpt/crypto/hkdf-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/hkdf-crash.any.worker.html: Added.
  • http/wpt/crypto/pbkdf2-crash.any-expected.txt: Added.
  • http/wpt/crypto/pbkdf2-crash.any.html: Added.
  • http/wpt/crypto/pbkdf2-crash.any.js: Added.
  • http/wpt/crypto/pbkdf2-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/pbkdf2-crash.any.worker.html: Added.
  • http/wpt/crypto/resources/common.js: Added.
  • http/wpt/crypto/rsa-oaep-crash.any-expected.txt: Added.
  • http/wpt/crypto/rsa-oaep-crash.any.html: Added.
  • http/wpt/crypto/rsa-oaep-crash.any.js: Added.
  • http/wpt/crypto/rsa-oaep-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/rsa-oaep-crash.any.worker.html: Added.
  • http/wpt/crypto/rsa-pss-crash.any-expected.txt: Added.
  • http/wpt/crypto/rsa-pss-crash.any.html: Added.
  • http/wpt/crypto/rsa-pss-crash.any.js: Added.
  • http/wpt/crypto/rsa-pss-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/rsa-pss-crash.any.worker.html: Added.
  • http/wpt/crypto/unwrap-ec-key-crash.any-expected.txt: Added.
  • http/wpt/crypto/unwrap-ec-key-crash.any.html: Added.
  • http/wpt/crypto/unwrap-ec-key-crash.any.js: Added.
  • http/wpt/crypto/unwrap-ec-key-crash.any.worker-expected.txt: Added.
  • http/wpt/crypto/unwrap-ec-key-crash.any.worker.html: Added.
  • http/wpt/crypto/unwrap-rsa-key-crash.any-expected.txt: Added.
  • http/wpt/crypto/unwrap-rsa-key-crash.any.html: Added.
  • http/wpt/crypto/unwrap-rsa-key-crash.any.js: Added.
  • http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html: Added.
  • http/wpt/crypto/unwrap-rsa-key-crash.any.worker-expected.txt: Added.
Location:
trunk
Files:
58 added
62 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r233895 r233898  
     12018-07-15  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] Crypto operations should copy their parameters before hoping to another thread
     4        https://bugs.webkit.org/show_bug.cgi?id=187501
     5        <rdar://problem/41438160>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html is an exception of this series of tests as
     10        it only aims to test the correct behavoir of suggested algorithms. This patch aslo does some test
     11        gardening.
     12
     13        * TestExpectations:
     14        * crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key-expected.txt: Added.
     15        * crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html: Added.
     16        * http/wpt/crypto/aes-cbc-crash.any-expected.txt: Added.
     17        * http/wpt/crypto/aes-cbc-crash.any.html: Added.
     18        * http/wpt/crypto/aes-cbc-crash.any.js: Added.
     19        * http/wpt/crypto/aes-cbc-crash.any.worker-expected.txt: Added.
     20        * http/wpt/crypto/aes-cbc-crash.any.worker.html: Added.
     21        * http/wpt/crypto/aes-ctr-crash.any-expected.txt: Added.
     22        * http/wpt/crypto/aes-ctr-crash.any.html: Added.
     23        * http/wpt/crypto/aes-ctr-crash.any.js: Added.
     24        * http/wpt/crypto/aes-ctr-crash.any.worker-expected.txt: Added.
     25        * http/wpt/crypto/aes-ctr-crash.any.worker.html: Added.
     26        * http/wpt/crypto/aes-gcm-crash.any-expected.txt: Added.
     27        * http/wpt/crypto/aes-gcm-crash.any.html: Added.
     28        * http/wpt/crypto/aes-gcm-crash.any.js: Added.
     29        * http/wpt/crypto/aes-gcm-crash.any.worker-expected.txt: Added.
     30        * http/wpt/crypto/aes-gcm-crash.any.worker.html: Added.
     31        * http/wpt/crypto/derive-hmac-key-crash.any-expected.txt: Added.
     32        * http/wpt/crypto/derive-hmac-key-crash.any.html: Added.
     33        * http/wpt/crypto/derive-hmac-key-crash.any.js: Added.
     34        * http/wpt/crypto/derive-hmac-key-crash.any.worker-expected.txt: Added.
     35        * http/wpt/crypto/derive-hmac-key-crash.any.worker.html: Added.
     36        * http/wpt/crypto/ecdsa-crash.any-expected.txt: Added.
     37        * http/wpt/crypto/ecdsa-crash.any.html: Added.
     38        * http/wpt/crypto/ecdsa-crash.any.js: Added.
     39        * http/wpt/crypto/ecdsa-crash.any.worker-expected.txt: Added.
     40        * http/wpt/crypto/ecdsa-crash.any.worker.html: Added.
     41        * http/wpt/crypto/hkdf-crash.any-expected.txt: Added.
     42        * http/wpt/crypto/hkdf-crash.any.html: Added.
     43        * http/wpt/crypto/hkdf-crash.any.js: Added.
     44        * http/wpt/crypto/hkdf-crash.any.worker-expected.txt: Added.
     45        * http/wpt/crypto/hkdf-crash.any.worker.html: Added.
     46        * http/wpt/crypto/pbkdf2-crash.any-expected.txt: Added.
     47        * http/wpt/crypto/pbkdf2-crash.any.html: Added.
     48        * http/wpt/crypto/pbkdf2-crash.any.js: Added.
     49        * http/wpt/crypto/pbkdf2-crash.any.worker-expected.txt: Added.
     50        * http/wpt/crypto/pbkdf2-crash.any.worker.html: Added.
     51        * http/wpt/crypto/resources/common.js: Added.
     52        * http/wpt/crypto/rsa-oaep-crash.any-expected.txt: Added.
     53        * http/wpt/crypto/rsa-oaep-crash.any.html: Added.
     54        * http/wpt/crypto/rsa-oaep-crash.any.js: Added.
     55        * http/wpt/crypto/rsa-oaep-crash.any.worker-expected.txt: Added.
     56        * http/wpt/crypto/rsa-oaep-crash.any.worker.html: Added.
     57        * http/wpt/crypto/rsa-pss-crash.any-expected.txt: Added.
     58        * http/wpt/crypto/rsa-pss-crash.any.html: Added.
     59        * http/wpt/crypto/rsa-pss-crash.any.js: Added.
     60        * http/wpt/crypto/rsa-pss-crash.any.worker-expected.txt: Added.
     61        * http/wpt/crypto/rsa-pss-crash.any.worker.html: Added.
     62        * http/wpt/crypto/unwrap-ec-key-crash.any-expected.txt: Added.
     63        * http/wpt/crypto/unwrap-ec-key-crash.any.html: Added.
     64        * http/wpt/crypto/unwrap-ec-key-crash.any.js: Added.
     65        * http/wpt/crypto/unwrap-ec-key-crash.any.worker-expected.txt: Added.
     66        * http/wpt/crypto/unwrap-ec-key-crash.any.worker.html: Added.
     67        * http/wpt/crypto/unwrap-rsa-key-crash.any-expected.txt: Added.
     68        * http/wpt/crypto/unwrap-rsa-key-crash.any.html: Added.
     69        * http/wpt/crypto/unwrap-rsa-key-crash.any.js: Added.
     70        * http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html: Added.
     71        * http/wpt/crypto/unwrap-rsa-key-crash.any.worker-expected.txt: Added.
     72
    1732018-07-17  Ryan Haddad  <ryanhaddad@apple.com>
    274
  • trunk/LayoutTests/TestExpectations

    r233895 r233898  
    14821482# Flaky WebCrypto API tests
    14831483imported/w3c/web-platform-tests/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html [ Pass Failure ]
    1484 imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/pbkdf2.https.worker.html [ Pass Failure Slow ]
    1485 webkit.org/b/186940 imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSASSA-PKCS1-v1_5.https.any.html [ Pass Failure Slow ]
    1486 webkit.org/b/186940 imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSA-PSS.https.any.html [ Pass Failure Slow ]
    1487 webkit.org/b/187025 imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_RSASSA-PKCS1-v1_5.https.any.worker.html  [ Pass Failure Slow ]
    14881484
    14891485# WebCryptoAPI tests that take too long to complete
    1490 imported/w3c/web-platform-tests/WebCryptoAPI/import_export/rsa_importKey.https.worker.html [ Slow ]
    1491 imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_rsa_importKey.https.html [ Slow ]
     1486imported/w3c/web-platform-tests/WebCryptoAPI/ [ Slow ]
    14921487
    14931488# Imported Beacon test that is flaky because its last check is very slow.
  • trunk/Source/WebCore/ChangeLog

    r233892 r233898  
     12018-07-15  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] Crypto operations should copy their parameters before hoping to another thread
     4        https://bugs.webkit.org/show_bug.cgi?id=187501
     5        <rdar://problem/41438160>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        This patch aims at making all captured variables in all crypto lambdas that need to be passed
     10        to a worker thread thread safe, which includes:
     11        1) changing ref counted objects to thread safe ref counted object.
     12        2) adding isolatedCopy methods to non ref counted classes, so they can be called by CrossThreadCopy().
     13
     14        In addition to above changes, this patch also does the following things:
     15        1) change the name CryptoAlgorithm::dispatchOperation => CryptoAlgorithm::dispatchOperationInWorkQueue
     16        to make it clear that lambdas will be passed to a secondary thread.
     17        2) make CryptoAlgorithmParameters as const parameters for all methods.
     18        3) add null checks on BufferSource.length() and .data().
     19
     20        Tests: crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html
     21               http/wpt/crypto/aes-cbc-crash.any.html
     22               http/wpt/crypto/aes-cbc-crash.any.worker.html
     23               http/wpt/crypto/aes-ctr-crash.any.html
     24               http/wpt/crypto/aes-ctr-crash.any.worker.html
     25               http/wpt/crypto/aes-gcm-crash.any.html
     26               http/wpt/crypto/aes-gcm-crash.any.worker.html
     27               http/wpt/crypto/derive-hmac-key-crash.any.html
     28               http/wpt/crypto/derive-hmac-key-crash.any.worker.html
     29               http/wpt/crypto/ecdsa-crash.any.html
     30               http/wpt/crypto/ecdsa-crash.any.worker.html
     31               http/wpt/crypto/hkdf-crash.any.html
     32               http/wpt/crypto/hkdf-crash.any.worker.html
     33               http/wpt/crypto/pbkdf2-crash.any.html
     34               http/wpt/crypto/pbkdf2-crash.any.worker.html
     35               http/wpt/crypto/rsa-oaep-crash.any.html
     36               http/wpt/crypto/rsa-oaep-crash.any.worker.html
     37               http/wpt/crypto/rsa-pss-crash.any.html
     38               http/wpt/crypto/rsa-pss-crash.any.worker.html
     39               http/wpt/crypto/unwrap-ec-key-crash.any.html
     40               http/wpt/crypto/unwrap-ec-key-crash.any.worker.html
     41               http/wpt/crypto/unwrap-rsa-key-crash.any.html
     42               http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html
     43
     44        * bindings/js/BufferSource.h:
     45        (WebCore::BufferSource::data const):
     46        (WebCore::BufferSource::length const):
     47        * crypto/CryptoAlgorithm.cpp:
     48        (WebCore::CryptoAlgorithm::encrypt):
     49        (WebCore::CryptoAlgorithm::decrypt):
     50        (WebCore::CryptoAlgorithm::sign):
     51        (WebCore::CryptoAlgorithm::verify):
     52        (WebCore::CryptoAlgorithm::deriveBits):
     53        (WebCore::CryptoAlgorithm::importKey):
     54        (WebCore::dispatchAlgorithmOperation):
     55        (WebCore::CryptoAlgorithm::dispatchOperationInWorkQueue):
     56        (WebCore::CryptoAlgorithm::dispatchOperation): Deleted.
     57        * crypto/CryptoAlgorithm.h:
     58        * crypto/SubtleCrypto.cpp:
     59        (WebCore::crossThreadCopyImportParams):
     60        (WebCore::SubtleCrypto::encrypt):
     61        (WebCore::SubtleCrypto::decrypt):
     62        (WebCore::SubtleCrypto::sign):
     63        (WebCore::SubtleCrypto::verify):
     64        (WebCore::SubtleCrypto::deriveKey):
     65        (WebCore::SubtleCrypto::deriveBits):
     66        (WebCore::SubtleCrypto::importKey):
     67        (WebCore::SubtleCrypto::wrapKey):
     68        (WebCore::SubtleCrypto::unwrapKey):
     69        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
     70        (WebCore::CryptoAlgorithmAES_CBC::encrypt):
     71        (WebCore::CryptoAlgorithmAES_CBC::decrypt):
     72        (WebCore::CryptoAlgorithmAES_CBC::importKey):
     73        * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
     74        * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
     75        (WebCore::CryptoAlgorithmAES_CFB::encrypt):
     76        (WebCore::CryptoAlgorithmAES_CFB::decrypt):
     77        (WebCore::CryptoAlgorithmAES_CFB::importKey):
     78        * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
     79        * crypto/algorithms/CryptoAlgorithmAES_CTR.cpp:
     80        (WebCore::parametersAreValid):
     81        (WebCore::CryptoAlgorithmAES_CTR::encrypt):
     82        (WebCore::CryptoAlgorithmAES_CTR::decrypt):
     83        (WebCore::CryptoAlgorithmAES_CTR::importKey):
     84        * crypto/algorithms/CryptoAlgorithmAES_CTR.h:
     85        * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
     86        (WebCore::CryptoAlgorithmAES_GCM::encrypt):
     87        (WebCore::CryptoAlgorithmAES_GCM::decrypt):
     88        (WebCore::CryptoAlgorithmAES_GCM::importKey):
     89        * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
     90        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
     91        (WebCore::CryptoAlgorithmAES_KW::importKey):
     92        * crypto/algorithms/CryptoAlgorithmAES_KW.h:
     93        * crypto/algorithms/CryptoAlgorithmECDH.cpp:
     94        (WebCore::CryptoAlgorithmECDH::deriveBits):
     95        (WebCore::CryptoAlgorithmECDH::importKey):
     96        * crypto/algorithms/CryptoAlgorithmECDH.h:
     97        * crypto/algorithms/CryptoAlgorithmECDSA.cpp:
     98        (WebCore::CryptoAlgorithmECDSA::sign):
     99        (WebCore::CryptoAlgorithmECDSA::verify):
     100        (WebCore::CryptoAlgorithmECDSA::importKey):
     101        * crypto/algorithms/CryptoAlgorithmECDSA.h:
     102        * crypto/algorithms/CryptoAlgorithmHKDF.cpp:
     103        (WebCore::CryptoAlgorithmHKDF::deriveBits):
     104        (WebCore::CryptoAlgorithmHKDF::importKey):
     105        * crypto/algorithms/CryptoAlgorithmHKDF.h:
     106        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
     107        (WebCore::CryptoAlgorithmHMAC::sign):
     108        (WebCore::CryptoAlgorithmHMAC::verify):
     109        (WebCore::CryptoAlgorithmHMAC::importKey):
     110        * crypto/algorithms/CryptoAlgorithmHMAC.h:
     111        * crypto/algorithms/CryptoAlgorithmPBKDF2.cpp:
     112        (WebCore::CryptoAlgorithmPBKDF2::deriveBits):
     113        (WebCore::CryptoAlgorithmPBKDF2::importKey):
     114        * crypto/algorithms/CryptoAlgorithmPBKDF2.h:
     115        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
     116        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
     117        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
     118        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
     119        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h:
     120        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
     121        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
     122        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
     123        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
     124        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
     125        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
     126        (WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
     127        (WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
     128        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
     129        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h:
     130        * crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
     131        (WebCore::CryptoAlgorithmRSA_PSS::sign):
     132        (WebCore::CryptoAlgorithmRSA_PSS::verify):
     133        (WebCore::CryptoAlgorithmRSA_PSS::importKey):
     134        * crypto/algorithms/CryptoAlgorithmRSA_PSS.h:
     135        * crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp:
     136        (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
     137        (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
     138        * crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp:
     139        (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
     140        (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
     141        * crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp:
     142        (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
     143        (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
     144        * crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp:
     145        (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
     146        (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
     147        * crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp:
     148        (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
     149        * crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp:
     150        (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
     151        * crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp:
     152        (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
     153        (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
     154        * crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp:
     155        (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
     156        (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
     157        * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
     158        (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
     159        (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
     160        * crypto/mac/CryptoAlgorithmAES_CFBMac.cpp:
     161        (WebCore::CryptoAlgorithmAES_CFB::platformEncrypt):
     162        (WebCore::CryptoAlgorithmAES_CFB::platformDecrypt):
     163        * crypto/mac/CryptoAlgorithmAES_CTRMac.cpp:
     164        (WebCore::CryptoAlgorithmAES_CTR::platformEncrypt):
     165        (WebCore::CryptoAlgorithmAES_CTR::platformDecrypt):
     166        * crypto/mac/CryptoAlgorithmAES_GCMMac.cpp:
     167        (WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
     168        (WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
     169        * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
     170        (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
     171        * crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp:
     172        (WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
     173        * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
     174        (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
     175        (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
     176        * crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp:
     177        (WebCore::CryptoAlgorithmRSA_PSS::platformSign):
     178        (WebCore::CryptoAlgorithmRSA_PSS::platformVerify):
     179        * crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h:
     180        * crypto/parameters/CryptoAlgorithmAesCtrParams.h:
     181        * crypto/parameters/CryptoAlgorithmAesGcmParams.h:
     182        * crypto/parameters/CryptoAlgorithmEcKeyParams.h:
     183        * crypto/parameters/CryptoAlgorithmEcdsaParams.h:
     184        * crypto/parameters/CryptoAlgorithmHkdfParams.h:
     185        * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
     186        * crypto/parameters/CryptoAlgorithmPbkdf2Params.h:
     187        * crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
     188        * crypto/parameters/CryptoAlgorithmRsaOaepParams.h:
     189        * crypto/parameters/CryptoAlgorithmRsaPssParams.h:
     190
    11912018-07-17  Antoine Quint  <graouts@apple.com>
    2192
  • trunk/Source/WebCore/bindings/js/BufferSource.h

    r228218 r233898  
    4747    {
    4848        return WTF::visit([](auto& buffer) -> const uint8_t* {
    49             return static_cast<const uint8_t*>(buffer->data());
     49            return buffer ? static_cast<const uint8_t*>(buffer->data()) : nullptr;
    5050        }, m_variant);
    5151    }
    … …  
    5454    {
    5555        return WTF::visit([](auto& buffer) -> size_t {
    56             return buffer->byteLength();
     56            return buffer ? buffer->byteLength() : 0;
    5757        }, m_variant);
    5858    }
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp

    r233882 r233898  
    3333namespace WebCore {
    3434
    35 void CryptoAlgorithm::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
     35void CryptoAlgorithm::encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
    3636{
    3737    exceptionCallback(NotSupportedError);
    3838}
    3939
    40 void CryptoAlgorithm::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
     40void CryptoAlgorithm::decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
    4141{
    4242    exceptionCallback(NotSupportedError);
    4343}
    4444
    45 void CryptoAlgorithm::sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
     45void CryptoAlgorithm::sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
    4646{
    4747    exceptionCallback(NotSupportedError);
    4848}
    4949
    50 void CryptoAlgorithm::verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
     50void CryptoAlgorithm::verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
    5151{
    5252    exceptionCallback(NotSupportedError);
    … …  
    6363}
    6464
    65 void CryptoAlgorithm::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
     65void CryptoAlgorithm::deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
    6666{
    6767    exceptionCallback(NotSupportedError);
    6868}
    6969
    70 void CryptoAlgorithm::importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&& exceptionCallback)
     70void CryptoAlgorithm::importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&& exceptionCallback)
    7171{
    7272    exceptionCallback(NotSupportedError);
    … …  
    9696static void dispatchAlgorithmOperation(WorkQueue& workQueue, ScriptExecutionContext& context, ResultCallbackType&& callback, CryptoAlgorithm::ExceptionCallback&& exceptionCallback, OperationType&& operation)
    9797{
    98     // There is no guarantee that callback and exceptionCallback will be destroyed in the thread in which they were created.
    9998    workQueue.dispatch(
    10099        [operation = WTFMove(operation), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), contextIdentifier = context.contextIdentifier()]() mutable {
    … …  
    110109}
    111110
    112 void CryptoAlgorithm::dispatchOperation(WorkQueue& workQueue, ScriptExecutionContext& context, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&& operation)
     111void CryptoAlgorithm::dispatchOperationInWorkQueue(WorkQueue& workQueue, ScriptExecutionContext& context, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&& operation)
    113112{
    114113    dispatchAlgorithmOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), WTFMove(operation));
    115114}
    116115
    117 void CryptoAlgorithm::dispatchOperation(WorkQueue& workQueue, ScriptExecutionContext& context, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<bool>()>&& operation)
     116void CryptoAlgorithm::dispatchOperationInWorkQueue(WorkQueue& workQueue, ScriptExecutionContext& context, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<bool>()>&& operation)
    118117{
    119118    dispatchAlgorithmOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), WTFMove(operation));
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.h

    r233882 r233898  
    3434#include "SubtleCrypto.h"
    3535#include <wtf/Function.h>
     36#include <wtf/ThreadSafeRefCounted.h>
    3637#include <wtf/Variant.h>
    3738#include <wtf/Vector.h>
    … …  
    4950using KeyOrKeyPair = Variant<RefPtr<CryptoKey>, CryptoKeyPair>;
    5051
    51 class CryptoAlgorithm : public RefCounted<CryptoAlgorithm> {
     52class CryptoAlgorithm : public ThreadSafeRefCounted<CryptoAlgorithm> {
    5253public:
    5354    virtual ~CryptoAlgorithm() = default;
    … …  
    6465    using KeyDataCallback = WTF::Function<void(CryptoKeyFormat, KeyData&&)>;
    6566
    66     virtual void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    67     virtual void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    68     virtual void sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    69     virtual void verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     67    virtual void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     68    virtual void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     69    virtual void sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     70    virtual void verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    7071    virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    7172    virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
    72     virtual void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
     73    virtual void deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    7374    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169262
    74     virtual void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
     75    virtual void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
    7576    virtual void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
    7677    virtual void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&);
    … …  
    7879    virtual ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&);
    7980
    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>()>&&);
     81    static void dispatchOperationInWorkQueue(WorkQueue&, ScriptExecutionContext&, VectorCallback&&, ExceptionCallback&&, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&&);
     82    static void dispatchOperationInWorkQueue(WorkQueue&, ScriptExecutionContext&, BoolCallback&&, ExceptionCallback&&, WTF::Function<ExceptionOr<bool>()>&&);
    8283};
    8384
  • trunk/Source/WebCore/crypto/SubtleCrypto.cpp

    r233882 r233898  
    517517}
    518518
     519static std::unique_ptr<CryptoAlgorithmParameters> crossThreadCopyImportParams(const CryptoAlgorithmParameters& importParams)
     520{
     521    switch (importParams.parametersClass()) {
     522    case CryptoAlgorithmParameters::Class::None: {
     523        auto result = std::make_unique<CryptoAlgorithmParameters>();
     524        result->identifier = importParams.identifier;
     525        return result;
     526    }
     527    case CryptoAlgorithmParameters::Class::EcKeyParams:
     528        return std::make_unique<CryptoAlgorithmEcKeyParams>(crossThreadCopy(downcast<CryptoAlgorithmEcKeyParams>(importParams)));
     529    case CryptoAlgorithmParameters::Class::HmacKeyParams:
     530        return std::make_unique<CryptoAlgorithmHmacKeyParams>(crossThreadCopy(downcast<CryptoAlgorithmHmacKeyParams>(importParams)));
     531    case CryptoAlgorithmParameters::Class::RsaHashedImportParams:
     532        return std::make_unique<CryptoAlgorithmRsaHashedImportParams>(crossThreadCopy(downcast<CryptoAlgorithmRsaHashedImportParams>(importParams)));
     533    default:
     534        ASSERT_NOT_REACHED();
     535        return nullptr;
     536    }
     537}
     538
    519539// MARK: - Exposed functions.
    520540
    … …  
    554574    };
    555575
    556     algorithm->encrypt(WTFMove(params), key, WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     576    algorithm->encrypt(*params, key, WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    557577}
    558578
    … …  
    592612    };
    593613
    594     algorithm->decrypt(WTFMove(params), key, WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     614    algorithm->decrypt(*params, key, WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    595615}
    596616
    … …  
    630650    };
    631651
    632     algorithm->sign(WTFMove(params), key, WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     652    algorithm->sign(*params, key, WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    633653}
    634654
    … …  
    669689    };
    670690
    671     algorithm->verify(WTFMove(params), key, WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     691    algorithm->verify(*params, key, WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    672692}
    673693
    … …  
    797817    m_pendingPromises.add(index, WTFMove(promise));
    798818    auto subtleCryptoWeakPointer = makeWeakPtr(*this);
    799     auto callback = [index, subtleCryptoWeakPointer, importAlgorithm, importParams = WTFMove(importParams), extractable, keyUsagesBitmap](const Vector<uint8_t>& derivedKey) mutable {
     819    auto callback = [index, subtleCryptoWeakPointer, importAlgorithm = WTFMove(importAlgorithm), importParams = crossThreadCopyImportParams(*importParams), extractable, keyUsagesBitmap](const Vector<uint8_t>& derivedKey) mutable {
    800820        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395
    801821        KeyData data = derivedKey;
    … …  
    814834        };
    815835
    816         importAlgorithm->importKey(SubtleCrypto::KeyFormat::Raw, WTFMove(data), WTFMove(importParams), extractable, keyUsagesBitmap, WTFMove(callback), WTFMove(exceptionCallback));
     836        importAlgorithm->importKey(SubtleCrypto::KeyFormat::Raw, WTFMove(data), *importParams, extractable, keyUsagesBitmap, WTFMove(callback), WTFMove(exceptionCallback));
    817837    };
    818838    auto exceptionCallback = [index, subtleCryptoWeakPointer](ExceptionCode ec) mutable {
    … …  
    821841    };
    822842
    823     algorithm->deriveBits(WTFMove(params), baseKey, length, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     843    algorithm->deriveBits(*params, baseKey, length, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    824844}
    825845
    … …  
    857877    };
    858878
    859     algorithm->deriveBits(WTFMove(params), baseKey, length, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     879    algorithm->deriveBits(*params, baseKey, length, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    860880}
    861881
    … …  
    900920    // https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey
    901921    // It is not beneficial for less time consuming operations. Therefore, we perform it synchronously.
    902     algorithm->importKey(format, WTFMove(keyData), WTFMove(params), extractable, keyUsagesBitmap, WTFMove(callback), WTFMove(exceptionCallback));
     922    algorithm->importKey(format, WTFMove(keyData), *params, extractable, keyUsagesBitmap, WTFMove(callback), WTFMove(exceptionCallback));
    903923}
    904924
    … …  
    10301050                }
    10311051                // The following operation should be performed asynchronously.
    1032                 wrapAlgorithm->encrypt(WTFMove(wrapParams), WTFMove(wrappingKey), WTFMove(bytes), WTFMove(callback), WTFMove(exceptionCallback), *context, workQueue);
     1052                wrapAlgorithm->encrypt(*wrapParams, WTFMove(wrappingKey), WTFMove(bytes), WTFMove(callback), WTFMove(exceptionCallback), *context, workQueue);
    10331053            }
    10341054        }
    … …  
    10971117    m_pendingPromises.add(index, WTFMove(promise));
    10981118    auto subtleCryptoWeakPointer = makeWeakPtr(*this);
    1099     auto callback = [index, subtleCryptoWeakPointer, format, importAlgorithm, unwrappedKeyAlgorithm = WTFMove(unwrappedKeyAlgorithm), extractable, keyUsagesBitmap](const Vector<uint8_t>& bytes) mutable {
     1119    auto callback = [index, subtleCryptoWeakPointer, format, importAlgorithm, unwrappedKeyAlgorithm = crossThreadCopyImportParams(*unwrappedKeyAlgorithm), extractable, keyUsagesBitmap](const Vector<uint8_t>& bytes) mutable {
    11001120        if (subtleCryptoWeakPointer) {
    11011121            if (auto promise = subtleCryptoWeakPointer->m_pendingPromises.get(index)) {
    … …  
    11431163
    11441164                // The following operation should be performed synchronously.
    1145                 importAlgorithm->importKey(format, WTFMove(keyData), WTFMove(unwrappedKeyAlgorithm), extractable, keyUsagesBitmap, WTFMove(callback), WTFMove(exceptionCallback));
     1165                importAlgorithm->importKey(format, WTFMove(keyData), *unwrappedKeyAlgorithm, extractable, keyUsagesBitmap, WTFMove(callback), WTFMove(exceptionCallback));
    11461166            }
    11471167        }
    … …  
    11601180    }
    11611181
    1162     unwrapAlgorithm->decrypt(WTFMove(unwrapParams), unwrappingKey, WTFMove(wrappedKey), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
     1182    unwrapAlgorithm->decrypt(*unwrapParams, unwrappingKey, WTFMove(wrappedKey), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContext(), m_workQueue);
    11631183}
    11641184
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp

    r233882 r233898  
    3232#include "CryptoAlgorithmAesKeyParams.h"
    3333#include "CryptoKeyAES.h"
     34#include <wtf/CrossThreadCopier.h>
    3435
    3536namespace WebCore {
    … …  
    5758}
    5859
    59 void CryptoAlgorithmAES_CBC::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     60void CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    6061{
    6162    using namespace CryptoAlgorithmAES_CBCInternal;
    62     ASSERT(parameters);
    63     auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters);
     63
     64    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
    6465    if (aesParameters.ivVector().size() != IVSIZE) {
    6566        exceptionCallback(OperationError);
    … …  
    6768    }
    6869
    69     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    70         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
    71             return platformEncrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
     70    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     71        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
     72            return platformEncrypt(parameters, downcast<CryptoKeyAES>(key.get()), plainText);
    7273        });
    7374}
    7475
    75 void CryptoAlgorithmAES_CBC::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     76void CryptoAlgorithmAES_CBC::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    7677{
    7778    using namespace CryptoAlgorithmAES_CBCInternal;
    78     ASSERT(parameters);
    79     auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters);
     79
     80    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
    8081    if (aesParameters.ivVector().size() != IVSIZE) {
    8182        exceptionCallback(OperationError);
    … …  
    8384    }
    8485
    85     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    86         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
    87             return platformDecrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
     86    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     87        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
     88            return platformDecrypt(parameters, downcast<CryptoKeyAES>(key.get()), cipherText);
    8889        });
    8990}
    … …  
    107108}
    108109
    109 void CryptoAlgorithmAES_CBC::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     110void CryptoAlgorithmAES_CBC::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    110111{
    111112    using namespace CryptoAlgorithmAES_CBCInternal;
    112     ASSERT(parameters);
     113
    113114    if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) {
    114115        exceptionCallback(SyntaxError);
    … …  
    119120    switch (format) {
    120121    case CryptoKeyFormat::Raw:
    121         result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     122        result = CryptoKeyAES::importRaw(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    122123        break;
    123124    case CryptoKeyFormat::Jwk: {
    … …  
    133134            return false;
    134135        };
    135         result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
     136        result = CryptoKeyAES::importJwk(parameters.identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
    136137        break;
    137138    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
    5353
    54     static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    55     static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     54    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     55    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    5656};
    5757
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp

    r233882 r233898  
    3232#include "CryptoAlgorithmAesKeyParams.h"
    3333#include "CryptoKeyAES.h"
     34#include <wtf/CrossThreadCopier.h>
    3435
    3536namespace WebCore {
    … …  
    5758}
    5859
    59 void CryptoAlgorithmAES_CFB::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     60void CryptoAlgorithmAES_CFB::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    6061{
    6162    using namespace CryptoAlgorithmAES_CFBInternal;
    62     ASSERT(parameters);
    63     auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters);
     63
     64    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
    6465    if (aesParameters.ivVector().size() != IVSIZE) {
    6566        exceptionCallback(OperationError);
    … …  
    6768    }
    6869
    69     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    70         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
    71             return platformEncrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
     70    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     71        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
     72            return platformEncrypt(parameters, downcast<CryptoKeyAES>(key.get()), plainText);
    7273        });
    7374}
    7475
    75 void CryptoAlgorithmAES_CFB::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     76void CryptoAlgorithmAES_CFB::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    7677{
    7778    using namespace CryptoAlgorithmAES_CFBInternal;
    78     ASSERT(parameters);
    79     auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters);
     79
     80    auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters);
    8081    if (aesParameters.ivVector().size() != IVSIZE) {
    8182        exceptionCallback(OperationError);
    … …  
    8384    }
    8485
    85     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    86         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
    87             return platformDecrypt(downcast<CryptoAlgorithmAesCbcCfbParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
     86    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     87        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
     88            return platformDecrypt(parameters, downcast<CryptoKeyAES>(key.get()), cipherText);
    8889        });
    8990}
    … …  
    107108}
    108109
    109 void CryptoAlgorithmAES_CFB::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     110void CryptoAlgorithmAES_CFB::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    110111{
    111112    using namespace CryptoAlgorithmAES_CFBInternal;
    112     ASSERT(parameters);
     113   
    113114    if (usagesAreInvalidForCryptoAlgorithmAES_CFB(usages)) {
    114115        exceptionCallback(SyntaxError);
    … …  
    119120    switch (format) {
    120121    case CryptoKeyFormat::Raw:
    121         result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     122        result = CryptoKeyAES::importRaw(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    122123        break;
    123124    case CryptoKeyFormat::Jwk: {
    … …  
    133134            return false;
    134135        };
    135         result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
     136        result = CryptoKeyAES::importJwk(parameters.identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
    136137        break;
    137138    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
    5353
    54     static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    55     static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     54    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     55    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    5656};
    5757
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.cpp

    r233882 r233898  
    3232#include "CryptoAlgorithmAesKeyParams.h"
    3333#include "CryptoKeyAES.h"
     34#include <wtf/CrossThreadCopier.h>
    3435
    3536namespace WebCore {
    … …  
    4748}
    4849
    49 static bool parametersAreValid(CryptoAlgorithmAesCtrParams& parameters)
     50static bool parametersAreValid(const CryptoAlgorithmAesCtrParams& parameters)
    5051{
    5152    using namespace CryptoAlgorithmAES_CTRInternal;
    … …  
    6768}
    6869
    69 void CryptoAlgorithmAES_CTR::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    70 {
    71     ASSERT(parameters);
    72     auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(*parameters);
     70void CryptoAlgorithmAES_CTR::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     71{
     72    auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(parameters);
    7373    if (!parametersAreValid(aesParameters)) {
    7474        exceptionCallback(OperationError);
    … …  
    7676    }
    7777
    78     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    79         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
    80             return platformEncrypt(downcast<CryptoAlgorithmAesCtrParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
     78    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     79        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
     80            return platformEncrypt(parameters, downcast<CryptoKeyAES>(key.get()), plainText);
    8181        });
    8282}
    8383
    84 void CryptoAlgorithmAES_CTR::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    85 {
    86     ASSERT(parameters);
    87     auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(*parameters);
     84void CryptoAlgorithmAES_CTR::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     85{
     86    auto& aesParameters = downcast<CryptoAlgorithmAesCtrParams>(parameters);
    8887    if (!parametersAreValid(aesParameters)) {
    8988        exceptionCallback(OperationError);
    … …  
    9190    }
    9291
    93     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    94         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
    95             return platformDecrypt(downcast<CryptoAlgorithmAesCtrParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
     92    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     93        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
     94            return platformDecrypt(parameters, downcast<CryptoKeyAES>(key.get()), cipherText);
    9695        });
    9796}
    … …  
    115114}
    116115
    117 void CryptoAlgorithmAES_CTR::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     116void CryptoAlgorithmAES_CTR::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    118117{
    119118    using namespace CryptoAlgorithmAES_CTRInternal;
    120     ASSERT(parameters);
     119
    121120    if (usagesAreInvalidForCryptoAlgorithmAES_CTR(usages)) {
    122121        exceptionCallback(SyntaxError);
    … …  
    127126    switch (format) {
    128127    case CryptoKeyFormat::Raw:
    129         result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     128        result = CryptoKeyAES::importRaw(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    130129        break;
    131130    case CryptoKeyFormat::Jwk: {
    … …  
    141140            return false;
    142141        };
    143         result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
     142        result = CryptoKeyAES::importJwk(parameters.identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
    144143        break;
    145144    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
    5353
    54     static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesCtrParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    55     static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesCtrParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     54    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmAesCtrParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     55    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmAesCtrParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    5656};
    5757
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp

    r233882 r233898  
    3232#include "CryptoAlgorithmAesKeyParams.h"
    3333#include "CryptoKeyAES.h"
     34#include <wtf/CrossThreadCopier.h>
    3435
    3536namespace WebCore {
    … …  
    7172}
    7273
    73 void CryptoAlgorithmAES_GCM::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    74 {
    75     using namespace CryptoAlgorithmAES_GCMInternal;
    76     ASSERT(parameters);
    77     auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(*parameters);
     74void CryptoAlgorithmAES_GCM::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     75{
     76    using namespace CryptoAlgorithmAES_GCMInternal;
     77
     78    auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters);
    7879
    7980#if __WORDSIZE >= 64
    … …  
    9899    }
    99100
    100     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    101         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
    102             return platformEncrypt(downcast<CryptoAlgorithmAesGcmParams>(*parameters), downcast<CryptoKeyAES>(key.get()), plainText);
     101    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     102        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
     103            return platformEncrypt(parameters, downcast<CryptoKeyAES>(key.get()), plainText);
    103104        });
    104105}
    105106
    106 void CryptoAlgorithmAES_GCM::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    107 {
    108     using namespace CryptoAlgorithmAES_GCMInternal;
    109     ASSERT(parameters);
    110     auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(*parameters);
     107void CryptoAlgorithmAES_GCM::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     108{
     109    using namespace CryptoAlgorithmAES_GCMInternal;
     110
     111    auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters);
    111112
    112113    aesParameters.tagLength = aesParameters.tagLength ? aesParameters.tagLength : DefaultTagLength;
    … …  
    131132#endif
    132133
    133     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    134         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
    135             return platformDecrypt(downcast<CryptoAlgorithmAesGcmParams>(*parameters), downcast<CryptoKeyAES>(key.get()), cipherText);
     134    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     135        [parameters = crossThreadCopy(aesParameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
     136            return platformDecrypt(parameters, downcast<CryptoKeyAES>(key.get()), cipherText);
    136137        });
    137138}
    … …  
    155156}
    156157
    157 void CryptoAlgorithmAES_GCM::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    158 {
    159     using namespace CryptoAlgorithmAES_GCMInternal;
    160     ASSERT(parameters);
     158void CryptoAlgorithmAES_GCM::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     159{
     160    using namespace CryptoAlgorithmAES_GCMInternal;
     161
    161162    if (usagesAreInvalidForCryptoAlgorithmAES_GCM(usages)) {
    162163        exceptionCallback(SyntaxError);
    … …  
    167168    switch (format) {
    168169    case CryptoKeyFormat::Raw:
    169         result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     170        result = CryptoKeyAES::importRaw(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    170171        break;
    171172    case CryptoKeyFormat::Jwk: {
    … …  
    181182            return false;
    182183        };
    183         result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
     184        result = CryptoKeyAES::importJwk(parameters.identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, WTFMove(checkAlgCallback));
    184185        break;
    185186    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
    5353
    54     static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmAesGcmParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    55     static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmAesGcmParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     54    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmAesGcmParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
     55    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmAesGcmParams&, const CryptoKeyAES&, const Vector<uint8_t>&);
    5656};
    5757
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp

    r233882 r233898  
    7272}
    7373
    74 void CryptoAlgorithmAES_KW::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     74void CryptoAlgorithmAES_KW::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    7575{
    7676    using namespace CryptoAlgorithmAES_KWInternal;
    77     ASSERT(parameters);
     77
    7878    if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) {
    7979        exceptionCallback(SyntaxError);
    … …  
    8484    switch (format) {
    8585    case CryptoKeyFormat::Raw:
    86         result = CryptoKeyAES::importRaw(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     86        result = CryptoKeyAES::importRaw(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    8787        break;
    8888    case CryptoKeyFormat::Jwk: {
    89         result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, [](size_t length, const String& alg) -> bool {
     89        result = CryptoKeyAES::importJwk(parameters.identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, [](size_t length, const String& alg) -> bool {
    9090            switch (length) {
    9191            case CryptoKeyAES::s_length128:
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h

    r233882 r233898  
    4545
    4646    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    47     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     47    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    4848    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    4949    void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp

    r233882 r233898  
    6767}
    6868
    69 void CryptoAlgorithmECDH::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     69void CryptoAlgorithmECDH::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    7070{
    7171    // We only accept length that is a multiple of 8.
    … …  
    7575    }
    7676
    77     ASSERT(parameters);
    78     auto& ecParameters = downcast<CryptoAlgorithmEcdhKeyDeriveParams>(*parameters);
     77    auto& ecParameters = downcast<CryptoAlgorithmEcdhKeyDeriveParams>(parameters);
    7978
    8079    if (baseKey->type() != CryptoKey::Type::Private) {
    … …  
    118117    // the result validation and callback dispatch into unifiedCallback.
    119118    workQueue.dispatch(
    120         [baseKey = WTFMove(baseKey), publicKey = ecParameters.publicKey.releaseNonNull(), length, unifiedCallback = WTFMove(unifiedCallback), contextIdentifier = context.contextIdentifier()]() mutable {
    121             auto derivedKey = platformDeriveBits(downcast<CryptoKeyEC>(baseKey.get()), downcast<CryptoKeyEC>(publicKey.get()));
     119        [baseKey = WTFMove(baseKey), publicKey = ecParameters.publicKey, length, unifiedCallback = WTFMove(unifiedCallback), contextIdentifier = context.contextIdentifier()]() mutable {
     120            auto derivedKey = platformDeriveBits(downcast<CryptoKeyEC>(baseKey.get()), downcast<CryptoKeyEC>(*publicKey));
    122121            ScriptExecutionContext::postTaskTo(contextIdentifier, [derivedKey = WTFMove(derivedKey), length, unifiedCallback = WTFMove(unifiedCallback)](auto&) mutable {
    123122                unifiedCallback(WTFMove(derivedKey), length);
    … …  
    126125}
    127126
    128 void CryptoAlgorithmECDH::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    129 {
    130     ASSERT(parameters);
    131     const auto& ecParameters = downcast<CryptoAlgorithmEcKeyParams>(*parameters);
     127void CryptoAlgorithmECDH::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     128{
     129    const auto& ecParameters = downcast<CryptoAlgorithmEcKeyParams>(parameters);
    132130
    133131    RefPtr<CryptoKeyEC> result;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h

    r233882 r233898  
    4545
    4646    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    47     void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     47    void deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    4949    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5050
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.cpp

    r233882 r233898  
    3232#include "CryptoAlgorithmEcdsaParams.h"
    3333#include "CryptoKeyEC.h"
     34#include <JavaScriptCore/JSCJSValueInlines.h>
     35#include <wtf/CrossThreadCopier.h>
    3436
    3537namespace WebCore {
    … …  
    5254}
    5355
    54 void CryptoAlgorithmECDSA::sign(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     56void CryptoAlgorithmECDSA::sign(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    5557{
    5658    if (key->type() != CryptoKeyType::Private) {
    … …  
    5961    }
    6062
    61     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    62         [parameters = WTFMove(parameters), key = WTFMove(key), data = WTFMove(data)] {
    63             return platformSign(downcast<CryptoAlgorithmEcdsaParams>(*parameters), downcast<CryptoKeyEC>(key.get()), data);
     63    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     64        [parameters = crossThreadCopy(downcast<CryptoAlgorithmEcdsaParams>(parameters)), key = WTFMove(key), data = WTFMove(data)] {
     65            return platformSign(parameters, downcast<CryptoKeyEC>(key.get()), data);
    6466        });
    6567}
    6668
    67 void CryptoAlgorithmECDSA::verify(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     69void CryptoAlgorithmECDSA::verify(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    6870{
    6971    if (key->type() != CryptoKeyType::Public) {
    … …  
    7274    }
    7375
    74     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    75         [parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] {
    76             return platformVerify(downcast<CryptoAlgorithmEcdsaParams>(*parameters), downcast<CryptoKeyEC>(key.get()), signature, data);
     76    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     77        [parameters = crossThreadCopy(downcast<CryptoAlgorithmEcdsaParams>(parameters)), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] {
     78            return platformVerify(parameters, downcast<CryptoKeyEC>(key.get()), signature, data);
    7779        });
    7880}
    … …  
    99101}
    100102
    101 void CryptoAlgorithmECDSA::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    102 {
    103     ASSERT(parameters);
    104     const auto& ecParameters = downcast<CryptoAlgorithmEcKeyParams>(*parameters);
     103void CryptoAlgorithmECDSA::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     104{
     105    const auto& ecParameters = downcast<CryptoAlgorithmEcKeyParams>(parameters);
    105106
    106107    RefPtr<CryptoKeyEC> result;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp

    r233882 r233898  
    3131#include "CryptoAlgorithmHkdfParams.h"
    3232#include "CryptoKeyRaw.h"
     33#include <JavaScriptCore/JSCJSValueInlines.h>
     34#include <wtf/CrossThreadCopier.h>
    3335
    3436namespace WebCore {
    … …  
    4446}
    4547
    46 void CryptoAlgorithmHKDF::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48void CryptoAlgorithmHKDF::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    4749{
    4850    if (!length || length % 8) {
    … …  
    5153    }
    5254
    53     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    54         [parameters = WTFMove(parameters), baseKey = WTFMove(baseKey), length] {
    55             return platformDeriveBits(downcast<CryptoAlgorithmHkdfParams>(*parameters), downcast<CryptoKeyRaw>(baseKey.get()), length);
     55    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     56        [parameters = crossThreadCopy(downcast<CryptoAlgorithmHkdfParams>(parameters)), baseKey = WTFMove(baseKey), length] {
     57            return platformDeriveBits(parameters, downcast<CryptoKeyRaw>(baseKey.get()), length);
    5658        });
    5759}
    5860
    59 void CryptoAlgorithmHKDF::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     61void CryptoAlgorithmHKDF::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    6062{
    6163    if (format != CryptoKeyFormat::Raw) {
    … …  
    7274    }
    7375
    74     callback(CryptoKeyRaw::create(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), usages));
     76    callback(CryptoKeyRaw::create(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), usages));
    7577}
    7678
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     47    void deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    4949    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
    5050
    51     static ExceptionOr<Vector<uint8_t>> platformDeriveBits(CryptoAlgorithmHkdfParams&, const CryptoKeyRaw&, size_t);
     51    static ExceptionOr<Vector<uint8_t>> platformDeriveBits(const CryptoAlgorithmHkdfParams&, const CryptoKeyRaw&, size_t);
    5252};
    5353
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp

    r233882 r233898  
    5858}
    5959
    60 void CryptoAlgorithmHMAC::sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    61 {
    62     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     60void CryptoAlgorithmHMAC::sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     61{
     62    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    6363        [key = WTFMove(key), data = WTFMove(data)] {
    6464            return platformSign(downcast<CryptoKeyHMAC>(key.get()), data);
    … …  
    6666}
    6767
    68 void CryptoAlgorithmHMAC::verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    69 {
    70     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     68void CryptoAlgorithmHMAC::verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     69{
     70    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    7171        [key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] {
    7272            return platformVerify(downcast<CryptoKeyHMAC>(key.get()), signature, data);
    … …  
    9797}
    9898
    99 void CryptoAlgorithmHMAC::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     99void CryptoAlgorithmHMAC::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    100100{
    101101    using namespace CryptoAlgorithmHMACInternal;
    102     ASSERT(parameters);
    103     const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(*parameters);
     102
     103    const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(parameters);
    104104
    105105    if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) {
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h

    r233882 r233898  
    4444    CryptoAlgorithmIdentifier identifier() const final;
    4545
    46     void sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    47     void verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     46    void sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4848    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    49     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     49    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5050    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5151    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp

    r233882 r233898  
    3131#include "CryptoAlgorithmPbkdf2Params.h"
    3232#include "CryptoKeyRaw.h"
     33#include <JavaScriptCore/JSCJSValueInlines.h>
     34#include <wtf/CrossThreadCopier.h>
    3335
    3436namespace WebCore {
    … …  
    4446}
    4547
    46 void CryptoAlgorithmPBKDF2::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     48void CryptoAlgorithmPBKDF2::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    4749{
    4850    if (!length || length % 8) {
    … …  
    5153    }
    5254
    53     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    54         [parameters = WTFMove(parameters), baseKey = WTFMove(baseKey), length] {
    55             return platformDeriveBits(downcast<CryptoAlgorithmPbkdf2Params>(*parameters), downcast<CryptoKeyRaw>(baseKey.get()), length);
     55    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     56        [parameters = crossThreadCopy(downcast<CryptoAlgorithmPbkdf2Params>(parameters)), baseKey = WTFMove(baseKey), length] {
     57            return platformDeriveBits(parameters, downcast<CryptoKeyRaw>(baseKey.get()), length);
    5658        });
    5759}
    5860
    59 void CryptoAlgorithmPBKDF2::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     61void CryptoAlgorithmPBKDF2::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    6062{
    6163    if (format != CryptoKeyFormat::Raw) {
    … …  
    7274    }
    7375
    74     callback(CryptoKeyRaw::create(parameters->identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), usages));
     76    callback(CryptoKeyRaw::create(parameters.identifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), usages));
    7577}
    7678
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     47    void deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    4949    ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
    5050
    51     static ExceptionOr<Vector<uint8_t>> platformDeriveBits(CryptoAlgorithmPbkdf2Params&, const CryptoKeyRaw&, size_t);
     51    static ExceptionOr<Vector<uint8_t>> platformDeriveBits(const CryptoAlgorithmPbkdf2Params&, const CryptoKeyRaw&, size_t);
    5252};
    5353
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp

    r233882 r233898  
    4848}
    4949
    50 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)
     50void CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    5151{
    5252    if (key->type() != CryptoKeyType::Public) {
    … …  
    5555    }
    5656
    57     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     57    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    5858        [key = WTFMove(key), plainText = WTFMove(plainText)] {
    5959            return platformEncrypt(downcast<CryptoKeyRSA>(key.get()), plainText);
    … …  
    6161}
    6262
    63 void CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     63void CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    6464{
    6565    if (key->type() != CryptoKeyType::Private) {
    … …  
    6868    }
    6969
    70     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     70    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    7171        [key = WTFMove(key), cipherText = WTFMove(cipherText)] {
    7272            return platformDecrypt(downcast<CryptoKeyRSA>(key.get()), cipherText);
    … …  
    9595}
    9696
    97 void CryptoAlgorithmRSAES_PKCS1_v1_5::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     97void CryptoAlgorithmRSAES_PKCS1_v1_5::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    9898{
    99     ASSERT(parameters);
    10099    RefPtr<CryptoKeyRSA> result;
    101100    switch (format) {
    … …  
    114113            return;
    115114        }
    116         result = CryptoKeyRSA::importJwk(parameters->identifier, std::nullopt, WTFMove(key), extractable, usages);
     115        result = CryptoKeyRSA::importJwk(parameters.identifier, std::nullopt, WTFMove(key), extractable, usages);
    117116        break;
    118117    }
    … …  
    122121            return;
    123122        }
    124         result = CryptoKeyRSA::importSpki(parameters->identifier, std::nullopt, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     123        result = CryptoKeyRSA::importSpki(parameters.identifier, std::nullopt, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    125124        break;
    126125    }
    … …  
    130129            return;
    131130        }
    132         result = CryptoKeyRSA::importPkcs8(parameters->identifier, std::nullopt, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     131        result = CryptoKeyRSA::importPkcs8(parameters.identifier, std::nullopt, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    133132        break;
    134133    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h

    r233882 r233898  
    4444    CryptoAlgorithmIdentifier identifier() const final;
    4545
    46     void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    47     void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     46    void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4848    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    49     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     49    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5050    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5151
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp

    r233882 r233898  
    5555}
    5656
    57 void CryptoAlgorithmRSASSA_PKCS1_v1_5::sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     57void CryptoAlgorithmRSASSA_PKCS1_v1_5::sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    5858{
    5959    if (key->type() != CryptoKeyType::Private) {
    … …  
    6262    }
    6363
    64     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     64    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    6565        [key = WTFMove(key), data = WTFMove(data)] {
    6666            return platformSign(downcast<CryptoKeyRSA>(key.get()), data);
    … …  
    6868}
    6969
    70 void CryptoAlgorithmRSASSA_PKCS1_v1_5::verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     70void CryptoAlgorithmRSASSA_PKCS1_v1_5::verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    7171{
    7272    if (key->type() != CryptoKeyType::Public) {
    … …  
    7575    }
    7676
    77     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     77    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    7878        [key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] {
    7979            return platformVerify(downcast<CryptoKeyRSA>(key.get()), signature, data);
    … …  
    101101}
    102102
    103 void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     103void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    104104{
    105105    using namespace CryptoAlgorithmRSASSA_PKCS1_v1_5Internal;
    106     ASSERT(parameters);
    107     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(*parameters);
     106
     107    const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(parameters);
    108108
    109109    RefPtr<CryptoKeyRSA> result;
    … …  
    164164        }
    165165        // FIXME: <webkit.org/b/165436>
    166         result = CryptoKeyRSA::importPkcs8(parameters->identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     166        result = CryptoKeyRSA::importPkcs8(parameters.identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    167167        break;
    168168    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h

    r233882 r233898  
    4444    CryptoAlgorithmIdentifier identifier() const final;
    4545
    46     void sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    47     void verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     46    void sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4848    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    49     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     49    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5050    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5151
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp

    r233882 r233898  
    3434#include "CryptoKeyPair.h"
    3535#include "CryptoKeyRSA.h"
     36#include <wtf/CrossThreadCopier.h>
    3637#include <wtf/Variant.h>
    3738
    … …  
    5657}
    5758
    58 void CryptoAlgorithmRSA_OAEP::encrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    59 {
    60     ASSERT(parameters);
     59void CryptoAlgorithmRSA_OAEP::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     60{
    6161    if (key->type() != CryptoKeyType::Public) {
    6262        exceptionCallback(InvalidAccessError);
    … …  
    6464    }
    6565
    66     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    67         [parameters = WTFMove(parameters), key = WTFMove(key), plainText = WTFMove(plainText)] {
    68             return platformEncrypt(downcast<CryptoAlgorithmRsaOaepParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), plainText);
     66    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     67        [parameters = crossThreadCopy(downcast<CryptoAlgorithmRsaOaepParams>(parameters)), key = WTFMove(key), plainText = WTFMove(plainText)] {
     68            return platformEncrypt(parameters, downcast<CryptoKeyRSA>(key.get()), plainText);
    6969        });
    7070}
    7171
    72 void CryptoAlgorithmRSA_OAEP::decrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    73 {
    74     ASSERT(parameters);
     72void CryptoAlgorithmRSA_OAEP::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     73{
    7574    if (key->type() != CryptoKeyType::Private) {
    7675        exceptionCallback(InvalidAccessError);
    … …  
    7877    }
    7978
    80     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    81         [parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
    82             return platformDecrypt(downcast<CryptoAlgorithmRsaOaepParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), cipherText);
     79    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     80        [parameters = crossThreadCopy(downcast<CryptoAlgorithmRsaOaepParams>(parameters)), key = WTFMove(key), cipherText = WTFMove(cipherText)] {
     81            return platformDecrypt(parameters, downcast<CryptoKeyRSA>(key.get()), cipherText);
    8382        });
    8483}
    … …  
    104103}
    105104
    106 void CryptoAlgorithmRSA_OAEP::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     105void CryptoAlgorithmRSA_OAEP::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    107106{
    108107    using namespace CryptoAlgorithmRSA_OAEPInternal;
    109     ASSERT(parameters);
    110     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(*parameters);
     108
     109    const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(parameters);
    111110
    112111    RefPtr<CryptoKeyRSA> result;
    … …  
    179178        }
    180179        // FIXME: <webkit.org/b/165436>
    181         result = CryptoKeyRSA::importPkcs8(parameters->identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     180        result = CryptoKeyRSA::importPkcs8(parameters.identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    182181        break;
    183182    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252
    53     static ExceptionOr<Vector<uint8_t>> platformEncrypt(CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
    54     static ExceptionOr<Vector<uint8_t>> platformDecrypt(CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
     53    static ExceptionOr<Vector<uint8_t>> platformEncrypt(const CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
     54    static ExceptionOr<Vector<uint8_t>> platformDecrypt(const CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
    5555};
    5656
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp

    r233882 r233898  
    3434#include "CryptoKeyPair.h"
    3535#include "CryptoKeyRSA.h"
     36#include <wtf/CrossThreadCopier.h>
    3637#include <wtf/Variant.h>
    3738
    … …  
    5657}
    5758
    58 void CryptoAlgorithmRSA_PSS::sign(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     59void CryptoAlgorithmRSA_PSS::sign(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    5960{
    6061    if (key->type() != CryptoKeyType::Private) {
    … …  
    6364    }
    6465
    65     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    66         [parameters = WTFMove(parameters), key = WTFMove(key), data = WTFMove(data)] {
    67             return platformSign(downcast<CryptoAlgorithmRsaPssParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), data);
     66    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     67        [parameters = crossThreadCopy(downcast<CryptoAlgorithmRsaPssParams>(parameters)), key = WTFMove(key), data = WTFMove(data)] {
     68            return platformSign(parameters, downcast<CryptoKeyRSA>(key.get()), data);
    6869        });
    6970}
    7071
    71 void CryptoAlgorithmRSA_PSS::verify(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
     72void CryptoAlgorithmRSA_PSS::verify(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
    7273{
    7374    if (key->type() != CryptoKeyType::Public) {
    … …  
    7677    }
    7778
    78     dispatchOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
    79         [parameters = WTFMove(parameters), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] {
    80             return platformVerify(downcast<CryptoAlgorithmRsaPssParams>(*parameters), downcast<CryptoKeyRSA>(key.get()), signature, data);
     79    dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),
     80        [parameters = crossThreadCopy(downcast<CryptoAlgorithmRsaPssParams>(parameters)), key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] {
     81            return platformVerify(parameters, downcast<CryptoKeyRSA>(key.get()), signature, data);
    8182        });
    8283}
    … …  
    102103}
    103104
    104 void CryptoAlgorithmRSA_PSS::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     105void CryptoAlgorithmRSA_PSS::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
    105106{
    106107    using namespace CryptoAlgorithmRSA_PSSInternal;
    107     ASSERT(parameters);
    108     const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(*parameters);
     108
     109    const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(parameters);
    109110
    110111    RefPtr<CryptoKeyRSA> result;
    … …  
    165166        }
    166167        // FIXME: <webkit.org/b/165436>
    167         result = CryptoKeyRSA::importPkcs8(parameters->identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     168        result = CryptoKeyRSA::importPkcs8(parameters.identifier, rsaParameters.hashIdentifier, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
    168169        break;
    169170    }
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h

    r233882 r233898  
    4545    CryptoAlgorithmIdentifier identifier() const final;
    4646
    47     void sign(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    48     void verify(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     47    void sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
     48    void verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
    4949    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
    50     void importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     50    void importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
    5151    void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    5252
    53     static ExceptionOr<Vector<uint8_t>> platformSign(CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
    54     static ExceptionOr<bool> platformVerify(CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
     53    static ExceptionOr<Vector<uint8_t>> platformSign(const CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&);
     54    static ExceptionOr<bool> platformVerify(const CryptoAlgorithmRsaPssParams&, const CryptoKeyRSA&, const Vector<uint8_t>&, const Vector<uint8_t>&);
    5555};
    5656
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp

    r233882 r233898  
    167167}
    168168
    169 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     169ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    170170{
    171171    auto output = gcryptEncrypt(key.key(), parameters.ivVector(), Vector<uint8_t>(plainText));
    … …  
    175175}
    176176
    177 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     177ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    178178{
    179179    auto output = gcryptDecrypt(key.key(), parameters.ivVector(), cipherText);
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp

    r233882 r233898  
    3131namespace WebCore {
    3232
    33 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)
     33ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)
    3434{
    3535    return Exception { NotSupportedError };
    3636}
    3737
    38 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)
     38ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)
    3939{
    4040    return Exception { NotSupportedError };
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp

    r233882 r233898  
    196196}
    197197
    198 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     198ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    199199{
    200200    auto output = gcryptAES_CTR(gcry_cipher_encrypt, key.key(), parameters.counterVector(), parameters.length, plainText);
    … …  
    204204}
    205205
    206 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     206ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    207207{
    208208    auto output = gcryptAES_CTR(gcry_cipher_decrypt, key.key(), parameters.counterVector(), parameters.length, cipherText);
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp

    r233882 r233898  
    180180}
    181181
    182 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     182ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    183183{
    184184    auto output = gcryptEncrypt(key.key(), parameters.ivVector(), plainText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
    … …  
    188188}
    189189
    190 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     190ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    191191{
    192192    auto output = gcryptDecrypt(key.key(), parameters.ivVector(), cipherText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp

    r233882 r233898  
    153153}
    154154
    155 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)
     155ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(const CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)
    156156{
    157157    auto output = gcryptDeriveBits(key.key(), parameters.saltVector(), parameters.infoVector(), length / 8, parameters.hashIdentifier);
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp

    r233882 r233898  
    5858}
    5959
    60 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)
     60ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(const CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)
    6161{
    6262    auto output = gcryptDeriveBits(key.key(), parameters.saltVector(), parameters.hashIdentifier, parameters.iterations, length);
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp

    r233882 r233898  
    111111}
    112112
    113 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
     113ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
    114114{
    115115    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!(key.keySizeInBits() % 8));
    … …  
    120120}
    121121
    122 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
     122ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
    123123{
    124124    auto output = gcryptDecrypt(key.hashAlgorithmIdentifier(), key.platformKey(), parameters.labelVector(), cipherText);
  • trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp

    r233882 r233898  
    136136}
    137137
    138 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
     138ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
    139139{
    140140    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!(key.keySizeInBits() % 8));
    … …  
    145145}
    146146
    147 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
     147ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
    148148{
    149149    auto output = gcryptVerify(key.platformKey(), signature, data, key.hashAlgorithmIdentifier(), parameters.saltLength);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp

    r233882 r233898  
    6363}
    6464
    65 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     65ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    6666{
    6767    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
    … …  
    6969}
    7070
    71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     71ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    7272{
    7373    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CFBMac.cpp

    r233882 r233898  
    6363}
    6464
    65 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     65ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    6666{
    6767    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
    … …  
    6969}
    7070
    71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     71ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    7272{
    7373    ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CTRMac.cpp

    r233882 r233898  
    139139}
    140140
    141 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     141ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    142142{
    143143    ASSERT(parameters.counterVector().size() == kCCBlockSizeAES128);
    … …  
    145145}
    146146
    147 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     147ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    148148{
    149149      ASSERT(parameters.counterVector().size() == kCCBlockSizeAES128);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp

    r233882 r233898  
    7373}
    7474
    75 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
     75ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)
    7676{
    7777    return encryptAES_GCM(parameters.ivVector(), key.key(), plainText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
    7878}
    7979
    80 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
     80ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)
    8181{
    8282    return decyptAES_GCM(parameters.ivVector(), key.key(), cipherText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp

    r233882 r233898  
    3535namespace WebCore {
    3636
    37 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)
     37ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(const CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)
    3838{
    3939    Vector<uint8_t> result(length / 8);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp

    r233882 r233898  
    5656}
    5757
    58 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)
     58ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(const CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)
    5959{
    6060    Vector<uint8_t> result(length / 8);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp

    r233882 r233898  
    6464}
    6565
    66 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
     66ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)
    6767{
    6868    return encryptRSA_OAEP(key.hashAlgorithmIdentifier(), parameters.labelVector(), key.platformKey(), key.keySizeInBits(), plainText);
    6969}
    7070
    71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
     71ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)
    7272{
    7373    return decryptRSA_OAEP(key.hashAlgorithmIdentifier(), parameters.labelVector(), key.platformKey(), key.keySizeInBits(), cipherText);
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp

    r233882 r233898  
    8282}
    8383
    84 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
     84ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)
    8585{
    8686    return signRSA_PSS(key.hashAlgorithmIdentifier(), key.platformKey(), key.keySizeInBits(), data, parameters.saltLength);
    8787}
    8888
    89 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
     89ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)
    9090{
    9191    return verifyRSA_PSS(key.hashAlgorithmIdentifier(), key.platformKey(), signature, data, parameters.saltLength);
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h

    r233882 r233898  
    4040    Class parametersClass() const final { return Class::AesCbcCfbParams; }
    4141
    42     const Vector<uint8_t>& ivVector()
     42    const Vector<uint8_t>& ivVector() const
    4343    {
    4444        if (!m_ivVector.isEmpty() || !iv.length())
    … …  
    4949    }
    5050
     51    CryptoAlgorithmAesCbcCfbParams isolatedCopy() const
     52    {
     53        CryptoAlgorithmAesCbcCfbParams result;
     54        result.identifier = identifier;
     55        result.m_ivVector = ivVector();
     56
     57        return result;
     58    }
     59
    5160private:
    52     Vector<uint8_t> m_ivVector;
     61    mutable Vector<uint8_t> m_ivVector;
    5362};
    5463
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCtrParams.h

    r233882 r233898  
    4141    Class parametersClass() const final { return Class::AesCtrParams; }
    4242
    43     const Vector<uint8_t>& counterVector()
     43    const Vector<uint8_t>& counterVector() const
    4444    {
    4545        if (!m_counterVector.isEmpty() || !counter.length())
    … …  
    5050    }
    5151
     52    CryptoAlgorithmAesCtrParams isolatedCopy() const
     53    {
     54        CryptoAlgorithmAesCtrParams result;
     55        result.identifier = identifier;
     56        result.m_counterVector = counterVector();
     57        result.length = length;
     58
     59        return result;
     60    }
     61
    5262private:
    53     Vector<uint8_t> m_counterVector;
     63    mutable Vector<uint8_t> m_counterVector;
    5464};
    5565
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesGcmParams.h

    r233882 r233898  
    3838    BufferSource iv;
    3939    // Use additionalDataVector() instead of additionalData. The label will be gone once additionalDataVector() is called.
    40     std::optional<BufferSource::VariantType> additionalData;
    41     std::optional<uint8_t> tagLength;
     40    mutable std::optional<BufferSource::VariantType> additionalData;
     41    mutable std::optional<uint8_t> tagLength;
    4242
    4343    Class parametersClass() const final { return Class::AesGcmParams; }
    4444
    45     const Vector<uint8_t>& ivVector()
     45    const Vector<uint8_t>& ivVector() const
    4646    {
    4747        if (!m_ivVector.isEmpty() || !iv.length())
    … …  
    5252    }
    5353
    54     const Vector<uint8_t>& additionalDataVector()
     54    const Vector<uint8_t>& additionalDataVector() const
    5555    {
    5656        if (!m_additionalDataVector.isEmpty() || !additionalData)
    5757            return m_additionalDataVector;
    5858
    59         m_additionalDataBuffer = WTFMove(*additionalData);
     59        BufferSource additionalDataBuffer = WTFMove(*additionalData);
    6060        additionalData = std::nullopt;
    61         if (!m_additionalDataBuffer.length())
     61        if (!additionalDataBuffer.length())
    6262            return m_additionalDataVector;
    6363
    64         m_additionalDataVector.append(m_additionalDataBuffer.data(), m_additionalDataBuffer.length());
     64        m_additionalDataVector.append(additionalDataBuffer.data(), additionalDataBuffer.length());
    6565        return m_additionalDataVector;
    6666    }
    67    
     67
     68    CryptoAlgorithmAesGcmParams isolatedCopy() const
     69    {
     70        CryptoAlgorithmAesGcmParams result;
     71        result.identifier = identifier;
     72        result.m_ivVector = ivVector();
     73        result.m_additionalDataVector = additionalDataVector();
     74        result.tagLength = tagLength;
     75
     76        return result;
     77    }
     78
    6879private:
    69     Vector<uint8_t> m_ivVector;
    70     Vector<uint8_t> m_additionalDataVector;
    71     BufferSource m_additionalDataBuffer;
     80    mutable Vector<uint8_t> m_ivVector;
     81    mutable Vector<uint8_t> m_additionalDataVector;
    7282};
    7383
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmEcKeyParams.h

    r233882 r233898  
    3737
    3838    Class parametersClass() const final { return Class::EcKeyParams; }
     39
     40    CryptoAlgorithmEcKeyParams isolatedCopy() const
     41    {
     42        CryptoAlgorithmEcKeyParams result;
     43        result.identifier = identifier;
     44        result.namedCurve = namedCurve.isolatedCopy();
     45
     46        return result;
     47    }
    3948};
    4049
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmEcdsaParams.h

    r233882 r233898  
    4242
    4343    Class parametersClass() const final { return Class::EcdsaParams; }
     44
     45    CryptoAlgorithmEcdsaParams isolatedCopy() const
     46    {
     47        CryptoAlgorithmEcdsaParams result;
     48        result.identifier = identifier;
     49        result.hashIdentifier = hashIdentifier;
     50
     51        return result;
     52    }
    4453};
    4554
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHkdfParams.h

    r233882 r233898  
    4444    BufferSource info;
    4545
    46     const Vector<uint8_t>& saltVector()
     46    const Vector<uint8_t>& saltVector() const
    4747    {
    4848        if (!m_saltVector.isEmpty() || !salt.length())
    … …  
    5353    }
    5454
    55     const Vector<uint8_t>& infoVector()
     55    const Vector<uint8_t>& infoVector() const
    5656    {
    5757        if (!m_infoVector.isEmpty() || !info.length())
    … …  
    6464    Class parametersClass() const final { return Class::HkdfParams; }
    6565
     66    CryptoAlgorithmHkdfParams isolatedCopy() const
     67    {
     68        CryptoAlgorithmHkdfParams result;
     69        result.identifier = identifier;
     70        result.m_saltVector = saltVector();
     71        result.m_infoVector = infoVector();
     72        result.hashIdentifier = hashIdentifier;
     73
     74        return result;
     75    }
     76
    6677private:
    67     Vector<uint8_t> m_saltVector;
    68     Vector<uint8_t> m_infoVector;
     78    mutable Vector<uint8_t> m_saltVector;
     79    mutable Vector<uint8_t> m_infoVector;
    6980};
    7081
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h

    r233882 r233898  
    4343
    4444    Class parametersClass() const final { return Class::HmacKeyParams; }
     45
     46    CryptoAlgorithmHmacKeyParams isolatedCopy() const
     47    {
     48        CryptoAlgorithmHmacKeyParams result;
     49        result.identifier = identifier;
     50        result.hashIdentifier = hashIdentifier;
     51        result.length = length;
     52
     53        return result;
     54    }
    4555};
    4656
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmPbkdf2Params.h

    r233882 r233898  
    4444    CryptoAlgorithmIdentifier hashIdentifier;
    4545
    46     const Vector<uint8_t>& saltVector()
     46    const Vector<uint8_t>& saltVector() const
    4747    {
    4848        if (!m_saltVector.isEmpty() || !salt.length())
    … …  
    5555    Class parametersClass() const final { return Class::Pbkdf2Params; }
    5656
     57    CryptoAlgorithmPbkdf2Params isolatedCopy() const
     58    {
     59        CryptoAlgorithmPbkdf2Params result;
     60        result.identifier = identifier;
     61        result.m_saltVector = saltVector();
     62        result.iterations = iterations;
     63        result.hashIdentifier = hashIdentifier;
     64
     65        return result;
     66    }
     67
    5768private:
    58     Vector<uint8_t> m_saltVector;
     69    mutable Vector<uint8_t> m_saltVector;
    5970};
    6071
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h

    r233882 r233898  
    4242
    4343    Class parametersClass() const final { return Class::RsaHashedImportParams; }
     44
     45    CryptoAlgorithmRsaHashedImportParams isolatedCopy() const
     46    {
     47        CryptoAlgorithmRsaHashedImportParams result;
     48        result.identifier = identifier;
     49        result.hashIdentifier = hashIdentifier;
     50
     51        return result;
     52    }
    4453};
    4554
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h

    r233882 r233898  
    3737public:
    3838    // Use labelVector() instead of label. The label will be gone once labelVector() is called.
    39     std::optional<BufferSource::VariantType> label;
     39    mutable std::optional<BufferSource::VariantType> label;
    4040
    4141    Class parametersClass() const final { return Class::RsaOaepParams; }
    4242
    43     const Vector<uint8_t>& labelVector()
     43    const Vector<uint8_t>& labelVector() const
    4444    {
    4545        if (!m_labelVector.isEmpty() || !label)
    4646            return m_labelVector;
    4747
    48         m_labelBuffer = WTFMove(*label);
     48        BufferSource labelBuffer = WTFMove(*label);
    4949        label = std::nullopt;
    50         if (!m_labelBuffer.length())
     50        if (!labelBuffer.length())
    5151            return m_labelVector;
    5252
    53         m_labelVector.append(m_labelBuffer.data(), m_labelBuffer.length());
     53        m_labelVector.append(labelBuffer.data(), labelBuffer.length());
    5454        return m_labelVector;
    5555    }
    5656
     57    CryptoAlgorithmRsaOaepParams isolatedCopy() const
     58    {
     59        CryptoAlgorithmRsaOaepParams result;
     60        result.identifier = identifier;
     61        result.m_labelVector = labelVector();
     62
     63        return result;
     64    }
     65
    5766private:
    58     Vector<uint8_t> m_labelVector;
    59     BufferSource m_labelBuffer;
     67    mutable Vector<uint8_t> m_labelVector;
    6068};
    6169
  • trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaPssParams.h

    r233882 r233898  
    3737
    3838    Class parametersClass() const final { return Class::RsaPssParams; }
     39
     40    CryptoAlgorithmRsaPssParams isolatedCopy() const
     41    {
     42        CryptoAlgorithmRsaPssParams result;
     43        result.identifier = identifier;
     44        result.saltLength = saltLength;
     45
     46        return result;
     47    }
    3948};
    4049
Note: See TracChangeset for help on using the changeset viewer.