Changeset 233898 in webkit
- Timestamp:
- Jul 17, 2018, 4:06:12 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 58 added
- 62 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key-expected.txt (added)
-
LayoutTests/crypto/subtle/aes-gcm-import-key-unwrap-ec-raw-key.html (added)
-
LayoutTests/http/wpt/crypto/aes-cbc-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/aes-cbc-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/aes-cbc-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/aes-cbc-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/aes-cbc-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/aes-ctr-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/aes-ctr-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/aes-ctr-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/aes-ctr-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/aes-ctr-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/aes-gcm-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/aes-gcm-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/aes-gcm-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/aes-gcm-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/aes-gcm-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/derive-hmac-key-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/derive-hmac-key-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/derive-hmac-key-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/derive-hmac-key-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/derive-hmac-key-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/ecdsa-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/ecdsa-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/ecdsa-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/ecdsa-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/ecdsa-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/hkdf-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/hkdf-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/hkdf-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/hkdf-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/hkdf-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/pbkdf2-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/pbkdf2-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/pbkdf2-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/pbkdf2-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/pbkdf2-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/resources/common.js (added)
-
LayoutTests/http/wpt/crypto/rsa-oaep-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/rsa-oaep-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/rsa-oaep-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/rsa-oaep-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/rsa-oaep-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/rsa-pss-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/rsa-pss-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/rsa-pss-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/rsa-pss-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/rsa-pss-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/unwrap-ec-key-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/unwrap-ec-key-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/unwrap-ec-key-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/unwrap-ec-key-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/unwrap-ec-key-crash.any.worker.html (added)
-
LayoutTests/http/wpt/crypto/unwrap-rsa-key-crash.any-expected.txt (added)
-
LayoutTests/http/wpt/crypto/unwrap-rsa-key-crash.any.html (added)
-
LayoutTests/http/wpt/crypto/unwrap-rsa-key-crash.any.js (added)
-
LayoutTests/http/wpt/crypto/unwrap-rsa-key-crash.any.worker-expected.txt (added)
-
LayoutTests/http/wpt/crypto/unwrap-rsa-key-crash.any.worker.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/js/BufferSource.h (modified) (2 diffs)
-
Source/WebCore/crypto/CryptoAlgorithm.cpp (modified) (4 diffs)
-
Source/WebCore/crypto/CryptoAlgorithm.h (modified) (4 diffs)
-
Source/WebCore/crypto/SubtleCrypto.cpp (modified) (14 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (modified) (7 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp (modified) (7 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.cpp (modified) (8 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp (modified) (7 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp (modified) (4 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.cpp (modified) (5 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp (modified) (4 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (modified) (3 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp (modified) (4 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp (modified) (8 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (modified) (6 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (modified) (6 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h (modified) (1 diff)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp (modified) (6 diffs)
-
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h (modified) (1 diff)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp (modified) (1 diff)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp (modified) (1 diff)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp (modified) (1 diff)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/mac/CryptoAlgorithmAES_CFBMac.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/mac/CryptoAlgorithmAES_CTRMac.cpp (modified) (2 diffs)
-
Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp (modified) (1 diff)
-
Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp (modified) (1 diff)
-
Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp (modified) (1 diff)
-
Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp (modified) (1 diff)
-
Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp (modified) (1 diff)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h (modified) (2 diffs)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmAesCtrParams.h (modified) (2 diffs)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmAesGcmParams.h (modified) (2 diffs)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmEcKeyParams.h (modified) (1 diff)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmEcdsaParams.h (modified) (1 diff)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmHkdfParams.h (modified) (3 diffs)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h (modified) (1 diff)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmPbkdf2Params.h (modified) (2 diffs)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h (modified) (1 diff)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h (modified) (1 diff)
-
Source/WebCore/crypto/parameters/CryptoAlgorithmRsaPssParams.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r233895 r233898 1 2018-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 1 73 2018-07-17 Ryan Haddad <ryanhaddad@apple.com> 2 74 -
trunk/LayoutTests/TestExpectations
r233895 r233898 1482 1482 # Flaky WebCrypto API tests 1483 1483 imported/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 ]1488 1484 1489 1485 # 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 ] 1486 imported/w3c/web-platform-tests/WebCryptoAPI/ [ Slow ] 1492 1487 1493 1488 # Imported Beacon test that is flaky because its last check is very slow. -
trunk/Source/WebCore/ChangeLog
r233892 r233898 1 2018-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 1 191 2018-07-17 Antoine Quint <graouts@apple.com> 2 192 -
trunk/Source/WebCore/bindings/js/BufferSource.h
r228218 r233898 47 47 { 48 48 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; 50 50 }, m_variant); 51 51 } … … 54 54 { 55 55 return WTF::visit([](auto& buffer) -> size_t { 56 return buffer ->byteLength();56 return buffer ? buffer->byteLength() : 0; 57 57 }, m_variant); 58 58 } -
trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp
r233882 r233898 33 33 namespace WebCore { 34 34 35 void CryptoAlgorithm::encrypt( std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)35 void CryptoAlgorithm::encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 36 36 { 37 37 exceptionCallback(NotSupportedError); 38 38 } 39 39 40 void CryptoAlgorithm::decrypt( std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)40 void CryptoAlgorithm::decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 41 41 { 42 42 exceptionCallback(NotSupportedError); 43 43 } 44 44 45 void CryptoAlgorithm::sign( std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)45 void CryptoAlgorithm::sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 46 46 { 47 47 exceptionCallback(NotSupportedError); 48 48 } 49 49 50 void CryptoAlgorithm::verify( std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)50 void CryptoAlgorithm::verify(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 51 51 { 52 52 exceptionCallback(NotSupportedError); … … 63 63 } 64 64 65 void CryptoAlgorithm::deriveBits( std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)65 void CryptoAlgorithm::deriveBits(const CryptoAlgorithmParameters&, Ref<CryptoKey>&&, size_t, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&) 66 66 { 67 67 exceptionCallback(NotSupportedError); 68 68 } 69 69 70 void CryptoAlgorithm::importKey(CryptoKeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&& exceptionCallback)70 void CryptoAlgorithm::importKey(CryptoKeyFormat, KeyData&&, const CryptoAlgorithmParameters&, bool, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&& exceptionCallback) 71 71 { 72 72 exceptionCallback(NotSupportedError); … … 96 96 static void dispatchAlgorithmOperation(WorkQueue& workQueue, ScriptExecutionContext& context, ResultCallbackType&& callback, CryptoAlgorithm::ExceptionCallback&& exceptionCallback, OperationType&& operation) 97 97 { 98 // There is no guarantee that callback and exceptionCallback will be destroyed in the thread in which they were created.99 98 workQueue.dispatch( 100 99 [operation = WTFMove(operation), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), contextIdentifier = context.contextIdentifier()]() mutable { … … 110 109 } 111 110 112 void CryptoAlgorithm::dispatchOperation (WorkQueue& workQueue, ScriptExecutionContext& context, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&& operation)111 void CryptoAlgorithm::dispatchOperationInWorkQueue(WorkQueue& workQueue, ScriptExecutionContext& context, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<Vector<uint8_t>>()>&& operation) 113 112 { 114 113 dispatchAlgorithmOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), WTFMove(operation)); 115 114 } 116 115 117 void CryptoAlgorithm::dispatchOperation (WorkQueue& workQueue, ScriptExecutionContext& context, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<bool>()>&& operation)116 void CryptoAlgorithm::dispatchOperationInWorkQueue(WorkQueue& workQueue, ScriptExecutionContext& context, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, WTF::Function<ExceptionOr<bool>()>&& operation) 118 117 { 119 118 dispatchAlgorithmOperation(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), WTFMove(operation)); -
trunk/Source/WebCore/crypto/CryptoAlgorithm.h
r233882 r233898 34 34 #include "SubtleCrypto.h" 35 35 #include <wtf/Function.h> 36 #include <wtf/ThreadSafeRefCounted.h> 36 37 #include <wtf/Variant.h> 37 38 #include <wtf/Vector.h> … … 49 50 using KeyOrKeyPair = Variant<RefPtr<CryptoKey>, CryptoKeyPair>; 50 51 51 class CryptoAlgorithm : public RefCounted<CryptoAlgorithm> {52 class CryptoAlgorithm : public ThreadSafeRefCounted<CryptoAlgorithm> { 52 53 public: 53 54 virtual ~CryptoAlgorithm() = default; … … 64 65 using KeyDataCallback = WTF::Function<void(CryptoKeyFormat, KeyData&&)>; 65 66 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&); 70 71 virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 71 72 virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&); 72 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&); 73 74 // 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&&); 75 76 virtual void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&); 76 77 virtual void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&); … … 78 79 virtual ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&); 79 80 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>()>&&); 82 83 }; 83 84 -
trunk/Source/WebCore/crypto/SubtleCrypto.cpp
r233882 r233898 517 517 } 518 518 519 static 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 519 539 // MARK: - Exposed functions. 520 540 … … 554 574 }; 555 575 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); 557 577 } 558 578 … … 592 612 }; 593 613 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); 595 615 } 596 616 … … 630 650 }; 631 651 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); 633 653 } 634 654 … … 669 689 }; 670 690 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); 672 692 } 673 693 … … 797 817 m_pendingPromises.add(index, WTFMove(promise)); 798 818 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 { 800 820 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395 801 821 KeyData data = derivedKey; … … 814 834 }; 815 835 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)); 817 837 }; 818 838 auto exceptionCallback = [index, subtleCryptoWeakPointer](ExceptionCode ec) mutable { … … 821 841 }; 822 842 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); 824 844 } 825 845 … … 857 877 }; 858 878 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); 860 880 } 861 881 … … 900 920 // https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey 901 921 // 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)); 903 923 } 904 924 … … 1030 1050 } 1031 1051 // 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); 1033 1053 } 1034 1054 } … … 1097 1117 m_pendingPromises.add(index, WTFMove(promise)); 1098 1118 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 { 1100 1120 if (subtleCryptoWeakPointer) { 1101 1121 if (auto promise = subtleCryptoWeakPointer->m_pendingPromises.get(index)) { … … 1143 1163 1144 1164 // 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)); 1146 1166 } 1147 1167 } … … 1160 1180 } 1161 1181 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); 1163 1183 } 1164 1184 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
r233882 r233898 32 32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 #include <wtf/CrossThreadCopier.h> 34 35 35 36 namespace WebCore { … … 57 58 } 58 59 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)60 void CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 60 61 { 61 62 using namespace CryptoAlgorithmAES_CBCInternal; 62 ASSERT(parameters); 63 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>( *parameters);63 64 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters); 64 65 if (aesParameters.ivVector().size() != IVSIZE) { 65 66 exceptionCallback(OperationError); … … 67 68 } 68 69 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); 72 73 }); 73 74 } 74 75 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)76 void CryptoAlgorithmAES_CBC::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 76 77 { 77 78 using namespace CryptoAlgorithmAES_CBCInternal; 78 ASSERT(parameters); 79 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>( *parameters);79 80 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters); 80 81 if (aesParameters.ivVector().size() != IVSIZE) { 81 82 exceptionCallback(OperationError); … … 83 84 } 84 85 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); 88 89 }); 89 90 } … … 107 108 } 108 109 109 void CryptoAlgorithmAES_CBC::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)110 void CryptoAlgorithmAES_CBC::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 110 111 { 111 112 using namespace CryptoAlgorithmAES_CBCInternal; 112 ASSERT(parameters); 113 113 114 if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) { 114 115 exceptionCallback(SyntaxError); … … 119 120 switch (format) { 120 121 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); 122 123 break; 123 124 case CryptoKeyFormat::Jwk: { … … 133 134 return false; 134 135 }; 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)); 136 137 break; 137 138 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 53 53 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>&); 56 56 }; 57 57 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp
r233882 r233898 32 32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 #include <wtf/CrossThreadCopier.h> 34 35 35 36 namespace WebCore { … … 57 58 } 58 59 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)60 void CryptoAlgorithmAES_CFB::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 60 61 { 61 62 using namespace CryptoAlgorithmAES_CFBInternal; 62 ASSERT(parameters); 63 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>( *parameters);63 64 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters); 64 65 if (aesParameters.ivVector().size() != IVSIZE) { 65 66 exceptionCallback(OperationError); … … 67 68 } 68 69 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); 72 73 }); 73 74 } 74 75 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)76 void CryptoAlgorithmAES_CFB::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 76 77 { 77 78 using namespace CryptoAlgorithmAES_CFBInternal; 78 ASSERT(parameters); 79 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>( *parameters);79 80 auto& aesParameters = downcast<CryptoAlgorithmAesCbcCfbParams>(parameters); 80 81 if (aesParameters.ivVector().size() != IVSIZE) { 81 82 exceptionCallback(OperationError); … … 83 84 } 84 85 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); 88 89 }); 89 90 } … … 107 108 } 108 109 109 void CryptoAlgorithmAES_CFB::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)110 void CryptoAlgorithmAES_CFB::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 110 111 { 111 112 using namespace CryptoAlgorithmAES_CFBInternal; 112 ASSERT(parameters);113 113 114 if (usagesAreInvalidForCryptoAlgorithmAES_CFB(usages)) { 114 115 exceptionCallback(SyntaxError); … … 119 120 switch (format) { 120 121 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); 122 123 break; 123 124 case CryptoKeyFormat::Jwk: { … … 133 134 return false; 134 135 }; 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)); 136 137 break; 137 138 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 53 53 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>&); 56 56 }; 57 57 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.cpp
r233882 r233898 32 32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 #include <wtf/CrossThreadCopier.h> 34 35 35 36 namespace WebCore { … … 47 48 } 48 49 49 static bool parametersAreValid( CryptoAlgorithmAesCtrParams& parameters)50 static bool parametersAreValid(const CryptoAlgorithmAesCtrParams& parameters) 50 51 { 51 52 using namespace CryptoAlgorithmAES_CTRInternal; … … 67 68 } 68 69 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); 70 void 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); 73 73 if (!parametersAreValid(aesParameters)) { 74 74 exceptionCallback(OperationError); … … 76 76 } 77 77 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); 81 81 }); 82 82 } 83 83 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); 84 void 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); 88 87 if (!parametersAreValid(aesParameters)) { 89 88 exceptionCallback(OperationError); … … 91 90 } 92 91 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); 96 95 }); 97 96 } … … 115 114 } 116 115 117 void CryptoAlgorithmAES_CTR::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)116 void CryptoAlgorithmAES_CTR::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 118 117 { 119 118 using namespace CryptoAlgorithmAES_CTRInternal; 120 ASSERT(parameters); 119 121 120 if (usagesAreInvalidForCryptoAlgorithmAES_CTR(usages)) { 122 121 exceptionCallback(SyntaxError); … … 127 126 switch (format) { 128 127 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); 130 129 break; 131 130 case CryptoKeyFormat::Jwk: { … … 141 140 return false; 142 141 }; 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)); 144 143 break; 145 144 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CTR.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 53 53 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>&); 56 56 }; 57 57 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp
r233882 r233898 32 32 #include "CryptoAlgorithmAesKeyParams.h" 33 33 #include "CryptoKeyAES.h" 34 #include <wtf/CrossThreadCopier.h> 34 35 35 36 namespace WebCore { … … 71 72 } 72 73 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);74 void 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); 78 79 79 80 #if __WORDSIZE >= 64 … … 98 99 } 99 100 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); 103 104 }); 104 105 } 105 106 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);107 void 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); 111 112 112 113 aesParameters.tagLength = aesParameters.tagLength ? aesParameters.tagLength : DefaultTagLength; … … 131 132 #endif 132 133 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); 136 137 }); 137 138 } … … 155 156 } 156 157 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); 158 void 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 161 162 if (usagesAreInvalidForCryptoAlgorithmAES_GCM(usages)) { 162 163 exceptionCallback(SyntaxError); … … 167 168 switch (format) { 168 169 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); 170 171 break; 171 172 case CryptoKeyFormat::Jwk: { … … 181 182 return false; 182 183 }; 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)); 184 185 break; 185 186 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 53 53 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>&); 56 56 }; 57 57 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
r233882 r233898 72 72 } 73 73 74 void CryptoAlgorithmAES_KW::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)74 void CryptoAlgorithmAES_KW::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 75 75 { 76 76 using namespace CryptoAlgorithmAES_KWInternal; 77 ASSERT(parameters); 77 78 78 if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) { 79 79 exceptionCallback(SyntaxError); … … 84 84 switch (format) { 85 85 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); 87 87 break; 88 88 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 { 90 90 switch (length) { 91 91 case CryptoKeyAES::s_length128: -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h
r233882 r233898 45 45 46 46 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; 48 48 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 49 49 void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp
r233882 r233898 67 67 } 68 68 69 void CryptoAlgorithmECDH::deriveBits( std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)69 void CryptoAlgorithmECDH::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 70 70 { 71 71 // We only accept length that is a multiple of 8. … … 75 75 } 76 76 77 ASSERT(parameters); 78 auto& ecParameters = downcast<CryptoAlgorithmEcdhKeyDeriveParams>(*parameters); 77 auto& ecParameters = downcast<CryptoAlgorithmEcdhKeyDeriveParams>(parameters); 79 78 80 79 if (baseKey->type() != CryptoKey::Type::Private) { … … 118 117 // the result validation and callback dispatch into unifiedCallback. 119 118 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)); 122 121 ScriptExecutionContext::postTaskTo(contextIdentifier, [derivedKey = WTFMove(derivedKey), length, unifiedCallback = WTFMove(unifiedCallback)](auto&) mutable { 123 122 unifiedCallback(WTFMove(derivedKey), length); … … 126 125 } 127 126 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); 127 void 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); 132 130 133 131 RefPtr<CryptoKeyEC> result; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h
r233882 r233898 45 45 46 46 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; 49 49 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 50 50 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.cpp
r233882 r233898 32 32 #include "CryptoAlgorithmEcdsaParams.h" 33 33 #include "CryptoKeyEC.h" 34 #include <JavaScriptCore/JSCJSValueInlines.h> 35 #include <wtf/CrossThreadCopier.h> 34 36 35 37 namespace WebCore { … … 52 54 } 53 55 54 void CryptoAlgorithmECDSA::sign( std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)56 void CryptoAlgorithmECDSA::sign(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 55 57 { 56 58 if (key->type() != CryptoKeyType::Private) { … … 59 61 } 60 62 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); 64 66 }); 65 67 } 66 68 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)69 void CryptoAlgorithmECDSA::verify(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 68 70 { 69 71 if (key->type() != CryptoKeyType::Public) { … … 72 74 } 73 75 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); 77 79 }); 78 80 } … … 99 101 } 100 102 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); 103 void 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); 105 106 106 107 RefPtr<CryptoKeyEC> result; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDSA.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp
r233882 r233898 31 31 #include "CryptoAlgorithmHkdfParams.h" 32 32 #include "CryptoKeyRaw.h" 33 #include <JavaScriptCore/JSCJSValueInlines.h> 34 #include <wtf/CrossThreadCopier.h> 33 35 34 36 namespace WebCore { … … 44 46 } 45 47 46 void CryptoAlgorithmHKDF::deriveBits( std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)48 void CryptoAlgorithmHKDF::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 47 49 { 48 50 if (!length || length % 8) { … … 51 53 } 52 54 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); 56 58 }); 57 59 } 58 60 59 void CryptoAlgorithmHKDF::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)61 void CryptoAlgorithmHKDF::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 60 62 { 61 63 if (format != CryptoKeyFormat::Raw) { … … 72 74 } 73 75 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)); 75 77 } 76 78 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 50 50 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); 52 52 }; 53 53 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
r233882 r233898 58 58 } 59 59 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),60 void 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), 63 63 [key = WTFMove(key), data = WTFMove(data)] { 64 64 return platformSign(downcast<CryptoKeyHMAC>(key.get()), data); … … 66 66 } 67 67 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),68 void 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), 71 71 [key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] { 72 72 return platformVerify(downcast<CryptoKeyHMAC>(key.get()), signature, data); … … 97 97 } 98 98 99 void CryptoAlgorithmHMAC::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)99 void CryptoAlgorithmHMAC::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 100 100 { 101 101 using namespace CryptoAlgorithmHMACInternal; 102 ASSERT(parameters); 103 const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>( *parameters);102 103 const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(parameters); 104 104 105 105 if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h
r233882 r233898 44 44 CryptoAlgorithmIdentifier identifier() const final; 45 45 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; 48 48 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; 50 50 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 51 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp
r233882 r233898 31 31 #include "CryptoAlgorithmPbkdf2Params.h" 32 32 #include "CryptoKeyRaw.h" 33 #include <JavaScriptCore/JSCJSValueInlines.h> 34 #include <wtf/CrossThreadCopier.h> 33 35 34 36 namespace WebCore { … … 44 46 } 45 47 46 void CryptoAlgorithmPBKDF2::deriveBits( std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)48 void CryptoAlgorithmPBKDF2::deriveBits(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 47 49 { 48 50 if (!length || length % 8) { … … 51 53 } 52 54 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); 56 58 }); 57 59 } 58 60 59 void CryptoAlgorithmPBKDF2::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)61 void CryptoAlgorithmPBKDF2::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 60 62 { 61 63 if (format != CryptoKeyFormat::Raw) { … … 72 74 } 73 75 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)); 75 77 } 76 78 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final; 50 50 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); 52 52 }; 53 53 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
r233882 r233898 48 48 } 49 49 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)50 void CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 51 51 { 52 52 if (key->type() != CryptoKeyType::Public) { … … 55 55 } 56 56 57 dispatchOperation (workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),57 dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 58 58 [key = WTFMove(key), plainText = WTFMove(plainText)] { 59 59 return platformEncrypt(downcast<CryptoKeyRSA>(key.get()), plainText); … … 61 61 } 62 62 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)63 void CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 64 64 { 65 65 if (key->type() != CryptoKeyType::Private) { … … 68 68 } 69 69 70 dispatchOperation (workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),70 dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 71 71 [key = WTFMove(key), cipherText = WTFMove(cipherText)] { 72 72 return platformDecrypt(downcast<CryptoKeyRSA>(key.get()), cipherText); … … 95 95 } 96 96 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)97 void CryptoAlgorithmRSAES_PKCS1_v1_5::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 98 98 { 99 ASSERT(parameters);100 99 RefPtr<CryptoKeyRSA> result; 101 100 switch (format) { … … 114 113 return; 115 114 } 116 result = CryptoKeyRSA::importJwk(parameters ->identifier, std::nullopt, WTFMove(key), extractable, usages);115 result = CryptoKeyRSA::importJwk(parameters.identifier, std::nullopt, WTFMove(key), extractable, usages); 117 116 break; 118 117 } … … 122 121 return; 123 122 } 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); 125 124 break; 126 125 } … … 130 129 return; 131 130 } 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); 133 132 break; 134 133 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h
r233882 r233898 44 44 CryptoAlgorithmIdentifier identifier() const final; 45 45 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; 48 48 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; 50 50 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 51 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
r233882 r233898 55 55 } 56 56 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)57 void CryptoAlgorithmRSASSA_PKCS1_v1_5::sign(const CryptoAlgorithmParameters&, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 58 58 { 59 59 if (key->type() != CryptoKeyType::Private) { … … 62 62 } 63 63 64 dispatchOperation (workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),64 dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 65 65 [key = WTFMove(key), data = WTFMove(data)] { 66 66 return platformSign(downcast<CryptoKeyRSA>(key.get()), data); … … 68 68 } 69 69 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)70 void 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) 71 71 { 72 72 if (key->type() != CryptoKeyType::Public) { … … 75 75 } 76 76 77 dispatchOperation (workQueue, context, WTFMove(callback), WTFMove(exceptionCallback),77 dispatchOperationInWorkQueue(workQueue, context, WTFMove(callback), WTFMove(exceptionCallback), 78 78 [key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data)] { 79 79 return platformVerify(downcast<CryptoKeyRSA>(key.get()), signature, data); … … 101 101 } 102 102 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)103 void CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 104 104 { 105 105 using namespace CryptoAlgorithmRSASSA_PKCS1_v1_5Internal; 106 ASSERT(parameters); 107 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>( *parameters);106 107 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(parameters); 108 108 109 109 RefPtr<CryptoKeyRSA> result; … … 164 164 } 165 165 // 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); 167 167 break; 168 168 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h
r233882 r233898 44 44 CryptoAlgorithmIdentifier identifier() const final; 45 45 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; 48 48 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; 50 50 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 51 51 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
r233882 r233898 34 34 #include "CryptoKeyPair.h" 35 35 #include "CryptoKeyRSA.h" 36 #include <wtf/CrossThreadCopier.h> 36 37 #include <wtf/Variant.h> 37 38 … … 56 57 } 57 58 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); 59 void CryptoAlgorithmRSA_OAEP::encrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& plainText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 60 { 61 61 if (key->type() != CryptoKeyType::Public) { 62 62 exceptionCallback(InvalidAccessError); … … 64 64 } 65 65 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); 69 69 }); 70 70 } 71 71 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); 72 void CryptoAlgorithmRSA_OAEP::decrypt(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 73 { 75 74 if (key->type() != CryptoKeyType::Private) { 76 75 exceptionCallback(InvalidAccessError); … … 78 77 } 79 78 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); 83 82 }); 84 83 } … … 104 103 } 105 104 106 void CryptoAlgorithmRSA_OAEP::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)105 void CryptoAlgorithmRSA_OAEP::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 107 106 { 108 107 using namespace CryptoAlgorithmRSA_OAEPInternal; 109 ASSERT(parameters); 110 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>( *parameters);108 109 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(parameters); 111 110 112 111 RefPtr<CryptoKeyRSA> result; … … 179 178 } 180 179 // 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); 182 181 break; 183 182 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 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>&); 55 55 }; 56 56 -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp
r233882 r233898 34 34 #include "CryptoKeyPair.h" 35 35 #include "CryptoKeyRSA.h" 36 #include <wtf/CrossThreadCopier.h> 36 37 #include <wtf/Variant.h> 37 38 … … 56 57 } 57 58 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)59 void CryptoAlgorithmRSA_PSS::sign(const CryptoAlgorithmParameters& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue) 59 60 { 60 61 if (key->type() != CryptoKeyType::Private) { … … 63 64 } 64 65 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); 68 69 }); 69 70 } 70 71 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)72 void 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) 72 73 { 73 74 if (key->type() != CryptoKeyType::Public) { … … 76 77 } 77 78 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); 81 82 }); 82 83 } … … 102 103 } 103 104 104 void CryptoAlgorithmRSA_PSS::importKey(CryptoKeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)105 void CryptoAlgorithmRSA_PSS::importKey(CryptoKeyFormat format, KeyData&& data, const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback) 105 106 { 106 107 using namespace CryptoAlgorithmRSA_PSSInternal; 107 ASSERT(parameters); 108 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>( *parameters);108 109 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedImportParams>(parameters); 109 110 110 111 RefPtr<CryptoKeyRSA> result; … … 165 166 } 166 167 // 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); 168 169 break; 169 170 } -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_PSS.h
r233882 r233898 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 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; 49 49 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; 51 51 void exportKey(CryptoKeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; 52 52 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>&); 55 55 }; 56 56 -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CBCGCrypt.cpp
r233882 r233898 167 167 } 168 168 169 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt( CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)169 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 170 170 { 171 171 auto output = gcryptEncrypt(key.key(), parameters.ivVector(), Vector<uint8_t>(plainText)); … … 175 175 } 176 176 177 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt( CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)177 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 178 178 { 179 179 auto output = gcryptDecrypt(key.key(), parameters.ivVector(), cipherText); -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CFBGCrypt.cpp
r233882 r233898 31 31 namespace WebCore { 32 32 33 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt( CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)33 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&) 34 34 { 35 35 return Exception { NotSupportedError }; 36 36 } 37 37 38 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt( CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&)38 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams&, const CryptoKeyAES&, const Vector<uint8_t>&) 39 39 { 40 40 return Exception { NotSupportedError }; -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_CTRGCrypt.cpp
r233882 r233898 196 196 } 197 197 198 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt( CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)198 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 199 199 { 200 200 auto output = gcryptAES_CTR(gcry_cipher_encrypt, key.key(), parameters.counterVector(), parameters.length, plainText); … … 204 204 } 205 205 206 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt( CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)206 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 207 207 { 208 208 auto output = gcryptAES_CTR(gcry_cipher_decrypt, key.key(), parameters.counterVector(), parameters.length, cipherText); -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmAES_GCMGCrypt.cpp
r233882 r233898 180 180 } 181 181 182 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt( CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)182 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 183 183 { 184 184 auto output = gcryptEncrypt(key.key(), parameters.ivVector(), plainText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8); … … 188 188 } 189 189 190 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt( CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)190 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 191 191 { 192 192 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 153 153 } 154 154 155 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits( CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)155 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(const CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length) 156 156 { 157 157 auto output = gcryptDeriveBits(key.key(), parameters.saltVector(), parameters.infoVector(), length / 8, parameters.hashIdentifier); -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmPBKDF2GCrypt.cpp
r233882 r233898 58 58 } 59 59 60 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits( CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)60 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(const CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length) 61 61 { 62 62 auto output = gcryptDeriveBits(key.key(), parameters.saltVector(), parameters.hashIdentifier, parameters.iterations, length); -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_OAEPGCrypt.cpp
r233882 r233898 111 111 } 112 112 113 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt( CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)113 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText) 114 114 { 115 115 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!(key.keySizeInBits() % 8)); … … 120 120 } 121 121 122 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt( CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)122 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText) 123 123 { 124 124 auto output = gcryptDecrypt(key.hashAlgorithmIdentifier(), key.platformKey(), parameters.labelVector(), cipherText); -
trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmRSA_PSSGCrypt.cpp
r233882 r233898 136 136 } 137 137 138 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign( CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)138 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data) 139 139 { 140 140 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!(key.keySizeInBits() % 8)); … … 145 145 } 146 146 147 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify( CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)147 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data) 148 148 { 149 149 auto output = gcryptVerify(key.platformKey(), signature, data, key.hashAlgorithmIdentifier(), parameters.saltLength); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp
r233882 r233898 63 63 } 64 64 65 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt( CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)65 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 66 66 { 67 67 ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128); … … 69 69 } 70 70 71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt( CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CBC::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 72 72 { 73 73 ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CFBMac.cpp
r233882 r233898 63 63 } 64 64 65 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt( CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)65 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformEncrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 66 66 { 67 67 ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128); … … 69 69 } 70 70 71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt( CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CFB::platformDecrypt(const CryptoAlgorithmAesCbcCfbParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 72 72 { 73 73 ASSERT(parameters.ivVector().size() == kCCBlockSizeAES128); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CTRMac.cpp
r233882 r233898 139 139 } 140 140 141 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt( CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)141 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformEncrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 142 142 { 143 143 ASSERT(parameters.counterVector().size() == kCCBlockSizeAES128); … … 145 145 } 146 146 147 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt( CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)147 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_CTR::platformDecrypt(const CryptoAlgorithmAesCtrParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 148 148 { 149 149 ASSERT(parameters.counterVector().size() == kCCBlockSizeAES128); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp
r233882 r233898 73 73 } 74 74 75 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt( CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText)75 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformEncrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& plainText) 76 76 { 77 77 return encryptAES_GCM(parameters.ivVector(), key.key(), plainText, parameters.additionalDataVector(), parameters.tagLength.value_or(0) / 8); 78 78 } 79 79 80 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt( CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText)80 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmAES_GCM::platformDecrypt(const CryptoAlgorithmAesGcmParams& parameters, const CryptoKeyAES& key, const Vector<uint8_t>& cipherText) 81 81 { 82 82 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 35 35 namespace WebCore { 36 36 37 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits( CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length)37 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmHKDF::platformDeriveBits(const CryptoAlgorithmHkdfParams& parameters, const CryptoKeyRaw& key, size_t length) 38 38 { 39 39 Vector<uint8_t> result(length / 8); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp
r233882 r233898 56 56 } 57 57 58 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits( CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length)58 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmPBKDF2::platformDeriveBits(const CryptoAlgorithmPbkdf2Params& parameters, const CryptoKeyRaw& key, size_t length) 59 59 { 60 60 Vector<uint8_t> result(length / 8); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp
r233882 r233898 64 64 } 65 65 66 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt( CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText)66 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& plainText) 67 67 { 68 68 return encryptRSA_OAEP(key.hashAlgorithmIdentifier(), parameters.labelVector(), key.platformKey(), key.keySizeInBits(), plainText); 69 69 } 70 70 71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt( CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText)71 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& cipherText) 72 72 { 73 73 return decryptRSA_OAEP(key.hashAlgorithmIdentifier(), parameters.labelVector(), key.platformKey(), key.keySizeInBits(), cipherText); -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_PSSMac.cpp
r233882 r233898 82 82 } 83 83 84 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign( CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data)84 ExceptionOr<Vector<uint8_t>> CryptoAlgorithmRSA_PSS::platformSign(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& data) 85 85 { 86 86 return signRSA_PSS(key.hashAlgorithmIdentifier(), key.platformKey(), key.keySizeInBits(), data, parameters.saltLength); 87 87 } 88 88 89 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify( CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data)89 ExceptionOr<bool> CryptoAlgorithmRSA_PSS::platformVerify(const CryptoAlgorithmRsaPssParams& parameters, const CryptoKeyRSA& key, const Vector<uint8_t>& signature, const Vector<uint8_t>& data) 90 90 { 91 91 return verifyRSA_PSS(key.hashAlgorithmIdentifier(), key.platformKey(), signature, data, parameters.saltLength); -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCbcCfbParams.h
r233882 r233898 40 40 Class parametersClass() const final { return Class::AesCbcCfbParams; } 41 41 42 const Vector<uint8_t>& ivVector() 42 const Vector<uint8_t>& ivVector() const 43 43 { 44 44 if (!m_ivVector.isEmpty() || !iv.length()) … … 49 49 } 50 50 51 CryptoAlgorithmAesCbcCfbParams isolatedCopy() const 52 { 53 CryptoAlgorithmAesCbcCfbParams result; 54 result.identifier = identifier; 55 result.m_ivVector = ivVector(); 56 57 return result; 58 } 59 51 60 private: 52 Vector<uint8_t> m_ivVector;61 mutable Vector<uint8_t> m_ivVector; 53 62 }; 54 63 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesCtrParams.h
r233882 r233898 41 41 Class parametersClass() const final { return Class::AesCtrParams; } 42 42 43 const Vector<uint8_t>& counterVector() 43 const Vector<uint8_t>& counterVector() const 44 44 { 45 45 if (!m_counterVector.isEmpty() || !counter.length()) … … 50 50 } 51 51 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 52 62 private: 53 Vector<uint8_t> m_counterVector;63 mutable Vector<uint8_t> m_counterVector; 54 64 }; 55 65 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesGcmParams.h
r233882 r233898 38 38 BufferSource iv; 39 39 // 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; 42 42 43 43 Class parametersClass() const final { return Class::AesGcmParams; } 44 44 45 const Vector<uint8_t>& ivVector() 45 const Vector<uint8_t>& ivVector() const 46 46 { 47 47 if (!m_ivVector.isEmpty() || !iv.length()) … … 52 52 } 53 53 54 const Vector<uint8_t>& additionalDataVector() 54 const Vector<uint8_t>& additionalDataVector() const 55 55 { 56 56 if (!m_additionalDataVector.isEmpty() || !additionalData) 57 57 return m_additionalDataVector; 58 58 59 m_additionalDataBuffer = WTFMove(*additionalData);59 BufferSource additionalDataBuffer = WTFMove(*additionalData); 60 60 additionalData = std::nullopt; 61 if (! m_additionalDataBuffer.length())61 if (!additionalDataBuffer.length()) 62 62 return m_additionalDataVector; 63 63 64 m_additionalDataVector.append( m_additionalDataBuffer.data(), m_additionalDataBuffer.length());64 m_additionalDataVector.append(additionalDataBuffer.data(), additionalDataBuffer.length()); 65 65 return m_additionalDataVector; 66 66 } 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 68 79 private: 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; 72 82 }; 73 83 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmEcKeyParams.h
r233882 r233898 37 37 38 38 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 } 39 48 }; 40 49 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmEcdsaParams.h
r233882 r233898 42 42 43 43 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 } 44 53 }; 45 54 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHkdfParams.h
r233882 r233898 44 44 BufferSource info; 45 45 46 const Vector<uint8_t>& saltVector() 46 const Vector<uint8_t>& saltVector() const 47 47 { 48 48 if (!m_saltVector.isEmpty() || !salt.length()) … … 53 53 } 54 54 55 const Vector<uint8_t>& infoVector() 55 const Vector<uint8_t>& infoVector() const 56 56 { 57 57 if (!m_infoVector.isEmpty() || !info.length()) … … 64 64 Class parametersClass() const final { return Class::HkdfParams; } 65 65 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 66 77 private: 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; 69 80 }; 70 81 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h
r233882 r233898 43 43 44 44 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 } 45 55 }; 46 56 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmPbkdf2Params.h
r233882 r233898 44 44 CryptoAlgorithmIdentifier hashIdentifier; 45 45 46 const Vector<uint8_t>& saltVector() 46 const Vector<uint8_t>& saltVector() const 47 47 { 48 48 if (!m_saltVector.isEmpty() || !salt.length()) … … 55 55 Class parametersClass() const final { return Class::Pbkdf2Params; } 56 56 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 57 68 private: 58 Vector<uint8_t> m_saltVector;69 mutable Vector<uint8_t> m_saltVector; 59 70 }; 60 71 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h
r233882 r233898 42 42 43 43 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 } 44 53 }; 45 54 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h
r233882 r233898 37 37 public: 38 38 // 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; 40 40 41 41 Class parametersClass() const final { return Class::RsaOaepParams; } 42 42 43 const Vector<uint8_t>& labelVector() 43 const Vector<uint8_t>& labelVector() const 44 44 { 45 45 if (!m_labelVector.isEmpty() || !label) 46 46 return m_labelVector; 47 47 48 m_labelBuffer = WTFMove(*label);48 BufferSource labelBuffer = WTFMove(*label); 49 49 label = std::nullopt; 50 if (! m_labelBuffer.length())50 if (!labelBuffer.length()) 51 51 return m_labelVector; 52 52 53 m_labelVector.append( m_labelBuffer.data(), m_labelBuffer.length());53 m_labelVector.append(labelBuffer.data(), labelBuffer.length()); 54 54 return m_labelVector; 55 55 } 56 56 57 CryptoAlgorithmRsaOaepParams isolatedCopy() const 58 { 59 CryptoAlgorithmRsaOaepParams result; 60 result.identifier = identifier; 61 result.m_labelVector = labelVector(); 62 63 return result; 64 } 65 57 66 private: 58 Vector<uint8_t> m_labelVector; 59 BufferSource m_labelBuffer; 67 mutable Vector<uint8_t> m_labelVector; 60 68 }; 61 69 -
trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaPssParams.h
r233882 r233898 37 37 38 38 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 } 39 48 }; 40 49
Note:
See TracChangeset
for help on using the changeset viewer.