From e44fa1c254651a72a640a2208a6059163505c64f Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Sat, 19 Aug 2017 16:41:47 +0000 Subject: [PATCH] [Mac] Change uint8_t* to Vector type in all crypto algorithm implementation https://bugs.webkit.org/show_bug.cgi?id=164939 Patch by Sam Weinig on 2017-08-19 Reviewed by Chris Dumez. Address FIXMEs, replacing uint8_t*/size_t parameters with Vector&. * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: (WebCore::transformAES_CBC): (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt): (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): * crypto/mac/CryptoAlgorithmAES_KWMac.cpp: (WebCore::wrapKeyAES_KW): (WebCore::unwrapKeyAES_KW): (WebCore::CryptoAlgorithmAES_KW::platformWrapKey): (WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey): * crypto/mac/CryptoAlgorithmHMACMac.cpp: (WebCore::calculateSignature): (WebCore::CryptoAlgorithmHMAC::platformSign): (WebCore::CryptoAlgorithmHMAC::platformVerify): * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp: (WebCore::encryptRSAES_PKCS1_v1_5): (WebCore::decryptRSAES_PKCS1_v1_5): (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt): (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: (WebCore::signRSASSA_PKCS1_v1_5): (WebCore::verifyRSASSA_PKCS1_v1_5): (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: (WebCore::encryptRSA_OAEP): (WebCore::decryptRSA_OAEP): (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt): (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220953 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 38 +++++++++++++++++++ .../crypto/mac/CryptoAlgorithmAES_CBCMac.cpp | 14 +++---- .../crypto/mac/CryptoAlgorithmAES_KWMac.cpp | 20 ++++------ .../crypto/mac/CryptoAlgorithmHMACMac.cpp | 10 ++--- .../CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp | 16 +++----- .../CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp | 18 ++++----- .../crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp | 16 +++----- 7 files changed, 75 insertions(+), 57 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 5a9cf97901f9..bad7d27742d7 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,41 @@ +2017-08-19 Sam Weinig + + [Mac] Change uint8_t* to Vector type in all crypto algorithm implementation + https://bugs.webkit.org/show_bug.cgi?id=164939 + + Reviewed by Chris Dumez. + + Address FIXMEs, replacing uint8_t*/size_t parameters with Vector&. + + * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: + (WebCore::transformAES_CBC): + (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt): + (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): + * crypto/mac/CryptoAlgorithmAES_KWMac.cpp: + (WebCore::wrapKeyAES_KW): + (WebCore::unwrapKeyAES_KW): + (WebCore::CryptoAlgorithmAES_KW::platformWrapKey): + (WebCore::CryptoAlgorithmAES_KW::platformUnwrapKey): + * crypto/mac/CryptoAlgorithmHMACMac.cpp: + (WebCore::calculateSignature): + (WebCore::CryptoAlgorithmHMAC::platformSign): + (WebCore::CryptoAlgorithmHMAC::platformVerify): + * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp: + (WebCore::encryptRSAES_PKCS1_v1_5): + (WebCore::decryptRSAES_PKCS1_v1_5): + (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt): + (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): + * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: + (WebCore::signRSASSA_PKCS1_v1_5): + (WebCore::verifyRSASSA_PKCS1_v1_5): + (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): + (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): + * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: + (WebCore::encryptRSA_OAEP): + (WebCore::decryptRSA_OAEP): + (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt): + (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): + 2017-08-18 Ryosuke Niwa Forbid setDragImage after dragstart diff --git a/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp b/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp index e3fbfc4eeb84..9c88f7449e5e 100644 --- a/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp +++ b/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp @@ -35,19 +35,17 @@ namespace WebCore { -// FIXME: We should change iv and data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> transformAES_CBC(CCOperation operation, const uint8_t* iv, const Vector& key, const uint8_t* data, size_t dataLength) +static ExceptionOr> transformAES_CBC(CCOperation operation, const Vector& iv, const Vector& key, const Vector& data) { CCCryptorRef cryptor; - CCCryptorStatus status = CCCryptorCreate(operation, kCCAlgorithmAES, kCCOptionPKCS7Padding, key.data(), key.size(), iv, &cryptor); + CCCryptorStatus status = CCCryptorCreate(operation, kCCAlgorithmAES, kCCOptionPKCS7Padding, key.data(), key.size(), iv.data(), &cryptor); if (status) return Exception { OperationError }; - Vector result(CCCryptorGetOutputLength(cryptor, dataLength, true)); + Vector result(CCCryptorGetOutputLength(cryptor, data.size(), true)); size_t bytesWritten; - status = CCCryptorUpdate(cryptor, data, dataLength, result.data(), result.size(), &bytesWritten); + status = CCCryptorUpdate(cryptor, data.data(), data.size(), result.data(), result.size(), &bytesWritten); if (status) return Exception { OperationError }; @@ -72,7 +70,7 @@ void CryptoAlgorithmAES_CBC::platformEncrypt(std::unique_ptr(*parameters); auto& aesKey = downcast(key.get()); ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128); - auto result = transformAES_CBC(kCCEncrypt, aesParameters.ivVector().data(), aesKey.key(), plainText.data(), plainText.size()); + auto result = transformAES_CBC(kCCEncrypt, aesParameters.ivVector(), aesKey.key(), plainText); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { @@ -96,7 +94,7 @@ void CryptoAlgorithmAES_CBC::platformDecrypt(std::unique_ptr(*parameters); auto& aesKey = downcast(key.get()); assert(aesParameters.ivVector().size() == kCCBlockSizeAES128); - auto result = transformAES_CBC(kCCDecrypt, aesParameters.ivVector().data(), aesKey.key(), cipherText.data(), cipherText.size()); + auto result = transformAES_CBC(kCCDecrypt, aesParameters.ivVector(), aesKey.key(), cipherText); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { diff --git a/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp b/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp index 1ca5548ecda1..490d6f9792f7 100644 --- a/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp +++ b/Source/WebCore/crypto/mac/CryptoAlgorithmAES_KWMac.cpp @@ -33,30 +33,26 @@ namespace WebCore { -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> wrapKeyAES_KW(const Vector& key, const uint8_t* data, size_t dataLength) +static ExceptionOr> wrapKeyAES_KW(const Vector& key, const Vector& data) { - Vector result(CCSymmetricWrappedSize(kCCWRAPAES, dataLength)); + Vector result(CCSymmetricWrappedSize(kCCWRAPAES, data.size())); size_t resultSize = result.size(); - if (CCSymmetricKeyWrap(kCCWRAPAES, CCrfc3394_iv, CCrfc3394_ivLen, key.data(), key.size(), data, dataLength, result.data(), &resultSize)) + if (CCSymmetricKeyWrap(kCCWRAPAES, CCrfc3394_iv, CCrfc3394_ivLen, key.data(), key.size(), data.data(), data.size(), result.data(), &resultSize)) return Exception { OperationError }; result.shrink(resultSize); return WTFMove(result); } -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> unwrapKeyAES_KW(const Vector& key, const uint8_t* data, size_t dataLength) +static ExceptionOr> unwrapKeyAES_KW(const Vector& key, const Vector& data) { - Vector result(CCSymmetricUnwrappedSize(kCCWRAPAES, dataLength)); + Vector result(CCSymmetricUnwrappedSize(kCCWRAPAES, data.size())); size_t resultSize = result.size(); if (resultSize % 8) return Exception { OperationError }; - if (CCSymmetricKeyUnwrap(kCCWRAPAES, CCrfc3394_iv, CCrfc3394_ivLen, key.data(), key.size(), data, dataLength, result.data(), &resultSize)) + if (CCSymmetricKeyUnwrap(kCCWRAPAES, CCrfc3394_iv, CCrfc3394_ivLen, key.data(), key.size(), data.data(), data.size(), result.data(), &resultSize)) return Exception { OperationError }; result.shrink(resultSize); @@ -66,7 +62,7 @@ static ExceptionOr> unwrapKeyAES_KW(const Vector& key, void CryptoAlgorithmAES_KW::platformWrapKey(Ref&& key, Vector&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback) { auto& aesKey = downcast(key.get()); - auto result = wrapKeyAES_KW(aesKey.key(), data.data(), data.size()); + auto result = wrapKeyAES_KW(aesKey.key(), data); if (result.hasException()) { exceptionCallback(result.releaseException().code()); return; @@ -77,7 +73,7 @@ void CryptoAlgorithmAES_KW::platformWrapKey(Ref&& key, Vector&& key, Vector&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback) { auto& aesKey = downcast(key.get()); - auto result = unwrapKeyAES_KW(aesKey.key(), data.data(), data.size()); + auto result = unwrapKeyAES_KW(aesKey.key(), data); if (result.hasException()) { exceptionCallback(result.releaseException().code()); return; diff --git a/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp b/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp index 3b729de759fd..56b6a7a0ce9c 100644 --- a/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp +++ b/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp @@ -53,9 +53,7 @@ static std::optional commonCryptoHMACAlgorithm(CryptoAlgorithmI } } -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static Vector calculateSignature(CCHmacAlgorithm algorithm, const Vector& key, const uint8_t* data, size_t dataLength) +static Vector calculateSignature(CCHmacAlgorithm algorithm, const Vector& key, const Vector& data) { size_t digestLength; switch (algorithm) { @@ -80,7 +78,7 @@ static Vector calculateSignature(CCHmacAlgorithm algorithm, const Vecto } Vector result(digestLength); - CCHmac(algorithm, key.data(), key.size(), data, dataLength, result.data()); + CCHmac(algorithm, key.data(), key.size(), data.data(), data.size(), result.data()); return result; } @@ -98,7 +96,7 @@ void CryptoAlgorithmHMAC::platformSign(Ref&& key, Vector&& d }); return; } - auto result = calculateSignature(*algorithm, hmacKey.key(), data.data(), data.size()); + auto result = calculateSignature(*algorithm, hmacKey.key(), data); // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([callback = WTFMove(callback), result = WTFMove(result), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) { callback(result); @@ -122,7 +120,7 @@ void CryptoAlgorithmHMAC::platformVerify(Ref&& key, Vector&& }); return; } - auto expectedSignature = calculateSignature(*algorithm, hmacKey.key(), data.data(), data.size()); + auto expectedSignature = calculateSignature(*algorithm, hmacKey.key(), data); // Using a constant time comparison to prevent timing attacks. bool result = signature.size() == expectedSignature.size() && !constantTimeMemcmp(expectedSignature.data(), signature.data(), expectedSignature.size()); // We should only dereference callbacks after being back to the Document/Worker threads. diff --git a/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp b/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp index f930f4c9bc65..3ac04e5a0519 100644 --- a/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp +++ b/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp @@ -34,25 +34,21 @@ namespace WebCore { -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> encryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength) +static ExceptionOr> encryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const Vector& data) { Vector cipherText(keyLength / 8); // Per Step 3.c of https://tools.ietf.org/html/rfc3447#section-7.2.1 size_t cipherTextLength = cipherText.size(); - if (CCRSACryptorEncrypt(key, ccPKCS1Padding, data, dataLength, cipherText.data(), &cipherTextLength, 0, 0, kCCDigestNone)) + if (CCRSACryptorEncrypt(key, ccPKCS1Padding, data.data(), data.size(), cipherText.data(), &cipherTextLength, 0, 0, kCCDigestNone)) return Exception { OperationError }; return WTFMove(cipherText); } -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> decryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength) +static ExceptionOr> decryptRSAES_PKCS1_v1_5(const PlatformRSAKey key, size_t keyLength, const Vector& data) { Vector plainText(keyLength / 8); // Per Step 1 of https://tools.ietf.org/html/rfc3447#section-7.2.1 size_t plainTextLength = plainText.size(); - if (CCRSACryptorDecrypt(key, ccPKCS1Padding, data, dataLength, plainText.data(), &plainTextLength, 0, 0, kCCDigestNone)) + if (CCRSACryptorDecrypt(key, ccPKCS1Padding, data.data(), data.size(), plainText.data(), &plainTextLength, 0, 0, kCCDigestNone)) return Exception { OperationError }; plainText.resize(plainTextLength); @@ -64,7 +60,7 @@ void CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt(Ref&& key, Vect context.ref(); workQueue.dispatch([key = WTFMove(key), plainText = WTFMove(plainText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { auto& rsaKey = downcast(key.get()); - auto result = encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText.data(), plainText.size()); + auto result = encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { @@ -86,7 +82,7 @@ void CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt(Ref&& key, Vect context.ref(); workQueue.dispatch([key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { auto& rsaKey = downcast(key.get()); - auto result = decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size()); + auto result = decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { diff --git a/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp b/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp index e321c229490c..0152f664c330 100644 --- a/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp +++ b/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp @@ -35,9 +35,7 @@ namespace WebCore { -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> signRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength) +static ExceptionOr> signRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, const PlatformRSAKey key, size_t keyLength, const Vector& data) { CCDigestAlgorithm digestAlgorithm; if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm)) @@ -49,7 +47,7 @@ static ExceptionOr> signRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentif auto digest = PAL::CryptoDigest::create(*cryptoDigestAlgorithm); if (!digest) return Exception { OperationError }; - digest->addBytes(data, dataLength); + digest->addBytes(data.data(), data.size()); auto digestData = digest->computeHash(); Vector signature(keyLength / 8); // Per https://tools.ietf.org/html/rfc3447#section-8.2.1 @@ -62,9 +60,7 @@ static ExceptionOr> signRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentif return WTFMove(signature); } -// FIXME: We should change signature, data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr verifyRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, const PlatformRSAKey key, const uint8_t* signature, size_t signatureLength, const uint8_t* data, size_t dataLength) +static ExceptionOr verifyRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, const PlatformRSAKey key, const Vector& signature, const Vector& data) { CCDigestAlgorithm digestAlgorithm; if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm)) @@ -76,10 +72,10 @@ static ExceptionOr verifyRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, auto digest = PAL::CryptoDigest::create(*cryptoDigestAlgorithm); if (!digest) return Exception { OperationError }; - digest->addBytes(data, dataLength); + digest->addBytes(data.data(), data.size()); auto digestData = digest->computeHash(); - auto status = CCRSACryptorVerify(key, ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature, signatureLength); + auto status = CCRSACryptorVerify(key, ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature.data(), signature.size()); if (!status) return true; if (status == kCCNotVerified || status == kCCDecodeError) // CCRSACryptorVerify returns kCCDecodeError instead of kCCNotVerified sometimes @@ -93,7 +89,7 @@ void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref&& key, Vector context.ref(); workQueue.dispatch([key = WTFMove(key), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { auto& rsaKey = downcast(key.get()); - auto result = signRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data.data(), data.size()); + auto result = signRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), rsaKey.keySizeInBits(), data); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { @@ -115,7 +111,7 @@ void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref&& key, Vect context.ref(); workQueue.dispatch([key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable { auto& rsaKey = downcast(key.get()); - auto result = verifyRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature.data(), signature.size(), data.data(), data.size()); + auto result = verifyRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature, data); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { diff --git a/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp b/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp index 2692c485fc8e..11d18c7ae022 100644 --- a/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp +++ b/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp @@ -35,9 +35,7 @@ namespace WebCore { -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> encryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector& label, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength) +static ExceptionOr> encryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector& label, const PlatformRSAKey key, size_t keyLength, const Vector& data) { CCDigestAlgorithm digestAlgorithm; if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm)) @@ -45,15 +43,13 @@ static ExceptionOr> encryptRSA_OAEP(CryptoAlgorithmIdentifier ha Vector cipherText(keyLength / 8); // Per Step 3.c of https://tools.ietf.org/html/rfc3447#section-7.1.1 size_t cipherTextLength = cipherText.size(); - if (CCRSACryptorEncrypt(key, ccOAEPPadding, data, dataLength, cipherText.data(), &cipherTextLength, label.data(), label.size(), digestAlgorithm)) + if (CCRSACryptorEncrypt(key, ccOAEPPadding, data.data(), data.size(), cipherText.data(), &cipherTextLength, label.data(), label.size(), digestAlgorithm)) return Exception { OperationError }; return WTFMove(cipherText); } -// FIXME: We should change data to Vector type once WebKitSubtleCrypto is deprecated. -// https://bugs.webkit.org/show_bug.cgi?id=164939 -static ExceptionOr> decryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector& label, const PlatformRSAKey key, size_t keyLength, const uint8_t* data, size_t dataLength) +static ExceptionOr> decryptRSA_OAEP(CryptoAlgorithmIdentifier hash, const Vector& label, const PlatformRSAKey key, size_t keyLength, const Vector& data) { CCDigestAlgorithm digestAlgorithm; if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm)) @@ -61,7 +57,7 @@ static ExceptionOr> decryptRSA_OAEP(CryptoAlgorithmIdentifier ha Vector plainText(keyLength / 8); // Per Step 1.b of https://tools.ietf.org/html/rfc3447#section-7.1.1 size_t plainTextLength = plainText.size(); - if (CCRSACryptorDecrypt(key, ccOAEPPadding, data, dataLength, plainText.data(), &plainTextLength, label.data(), label.size(), digestAlgorithm)) + if (CCRSACryptorDecrypt(key, ccOAEPPadding, data.data(), data.size(), plainText.data(), &plainTextLength, label.data(), label.size(), digestAlgorithm)) return Exception { OperationError }; plainText.resize(plainTextLength); @@ -74,7 +70,7 @@ void CryptoAlgorithmRSA_OAEP::platformEncrypt(std::unique_ptr(*parameters); auto& rsaKey = downcast(key.get()); - auto result = encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText.data(), plainText.size()); + auto result = encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { @@ -97,7 +93,7 @@ void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr(*parameters); auto& rsaKey = downcast(key.get()); - auto result = decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size()); + auto result = decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText); if (result.hasException()) { // We should only dereference callbacks after being back to the Document/Worker threads. context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) { -- 2.36.0