Changeset 209077 in webkit
- Timestamp:
- Nov 29, 2016 10:51:45 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r209076 r209077 1 2016-11-29 Daniel Bates <dabates@apple.com> 2 3 CryptoAlgorithm::generateKey() should take lvalue reference to const CryptoAlgorithmParameters 4 https://bugs.webkit.org/show_bug.cgi?id=165111 5 6 Reviewed by Darin Adler. 7 8 CryptoAlgorithm::generateKey() and its overrides always expect to receive a non-null pointer 9 to a CryptoAlgorithmParameter object and never take ownership of it. This kind of relationship 10 is best expressed by modifying CryptoAlgorithm::generateKey() to take a lvalue reference to 11 a const CryptoAlgorithmParameter object. 12 13 * bindings/js/JSSubtleCryptoCustom.cpp: 14 (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): 15 * crypto/CryptoAlgorithm.cpp: 16 (WebCore::CryptoAlgorithm::generateKey): 17 * crypto/CryptoAlgorithm.h: 18 * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: 19 (WebCore::CryptoAlgorithmAES_CBC::generateKey): 20 * crypto/algorithms/CryptoAlgorithmAES_CBC.h: 21 * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: 22 (WebCore::CryptoAlgorithmAES_KW::generateKey): 23 * crypto/algorithms/CryptoAlgorithmAES_KW.h: 24 * crypto/algorithms/CryptoAlgorithmHMAC.cpp: 25 (WebCore::CryptoAlgorithmHMAC::generateKey): 26 * crypto/algorithms/CryptoAlgorithmHMAC.h: 27 * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: 28 (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey): 29 * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: 30 * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: 31 (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey): 32 * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: 33 * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: 34 (WebCore::CryptoAlgorithmRSA_OAEP::generateKey): 35 * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: 36 1 37 2016-11-29 Andy Estes <aestes@apple.com> 2 38 -
trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
r208918 r209077 553 553 // regardless what kind of keys it produces: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey 554 554 // That's simply not efficient for AES and HMAC keys. Therefore, we perform it as an async task conditionally. 555 algorithm->generateKey( WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state));555 algorithm->generateKey(*params, extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state)); 556 556 } 557 557 -
trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp
r208918 r209077 43 43 } 44 44 45 void CryptoAlgorithm::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)45 void CryptoAlgorithm::generateKey(const CryptoAlgorithmParameters&, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 46 46 { 47 47 exceptionCallback(NOT_SUPPORTED_ERR); -
trunk/Source/WebCore/crypto/CryptoAlgorithm.h
r208918 r209077 67 67 virtual void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 68 68 virtual void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&); 69 virtual void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);69 virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&); 70 70 virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&); 71 71 virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
r208985 r209077 89 89 } 90 90 91 void CryptoAlgorithmAES_CBC::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 92 { 93 ASSERT(parameters); 94 auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(*parameters); 91 void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 92 { 93 const auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(parameters); 95 94 96 95 if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h
r208918 r209077 47 47 void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 48 48 void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 49 void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;49 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 50 50 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 51 51 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
r208985 r209077 64 64 } 65 65 66 void CryptoAlgorithmAES_KW::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)66 void CryptoAlgorithmAES_KW::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 67 67 { 68 ASSERT(parameters);69 68 if (usagesAreInvalidForCryptoAlgorithmAES_KW(usages)) { 70 69 exceptionCallback(SYNTAX_ERR); … … 72 71 } 73 72 74 auto result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, downcast<CryptoAlgorithmAesKeyGenParams>( *parameters).length, extractable, usages);73 auto result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, downcast<CryptoAlgorithmAesKeyGenParams>(parameters).length, extractable, usages); 75 74 if (!result) { 76 75 exceptionCallback(OperationError); -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h
r208891 r209077 44 44 CryptoAlgorithmIdentifier identifier() const final; 45 45 46 void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;46 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 47 47 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 48 48 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
r208985 r209077 70 70 } 71 71 72 void CryptoAlgorithmHMAC::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 73 { 74 ASSERT(parameters); 75 const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(*parameters); 72 void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&) 73 { 74 const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(parameters); 76 75 77 76 if (usagesAreInvalidForCryptoAlgorithmHMAC(usages)) { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h
r208891 r209077 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 47 void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;47 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 48 48 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 49 49 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
r208985 r209077 78 78 } 79 79 80 void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)80 void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context) 81 81 { 82 ASSERT(parameters); 83 const auto& rsaParameters = downcast<CryptoAlgorithmRsaKeyGenParams>(*parameters); 82 const auto& rsaParameters = downcast<CryptoAlgorithmRsaKeyGenParams>(parameters); 84 83 85 84 if (usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey)) { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h
r208918 r209077 47 47 void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 48 48 void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 49 void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;49 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 50 50 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 51 51 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
r208891 r209077 69 69 } 70 70 71 void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context) 72 { 73 ASSERT(parameters); 74 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(*parameters); 71 void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context) 72 { 73 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(parameters); 75 74 76 75 if (usages & (CryptoKeyUsageDecrypt | CryptoKeyUsageEncrypt | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey)) { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h
r208891 r209077 45 45 CryptoAlgorithmIdentifier identifier() const final; 46 46 47 void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;47 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 48 48 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 49 49 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
r208918 r209077 89 89 } 90 90 91 void CryptoAlgorithmRSA_OAEP::generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context) 92 { 93 ASSERT(parameters); 94 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(*parameters); 91 void CryptoAlgorithmRSA_OAEP::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context) 92 { 93 const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(parameters); 95 94 96 95 if (usages & (CryptoKeyUsageSign | CryptoKeyUsageVerify | CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits)) { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h
r208918 r209077 47 47 void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 48 48 void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final; 49 void generateKey(const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;49 void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final; 50 50 void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final; 51 51 void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
Note: See TracChangeset
for help on using the changeset viewer.