Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1463)

Unified Diff: Source/platform/Crypto.cpp

Issue 235893003: Remove use of WebCrypto digestSynchronous in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changed ASSERT_WITH_SECURITY_IMPLICATIONS to RELEASE_ASSERT Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/Crypto.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/Crypto.cpp
diff --git a/Source/platform/Crypto.cpp b/Source/platform/Crypto.cpp
index d168583acd616be8f4f6b272a9ce20de0ddd148b..009ae0a278f8408c2da460d8f5b8f5323fe4d247 100644
--- a/Source/platform/Crypto.cpp
+++ b/Source/platform/Crypto.cpp
@@ -31,19 +31,21 @@ static blink::WebCryptoAlgorithmId toWebCryptoAlgorithmId(HashAlgorithm algorith
return blink::WebCryptoAlgorithmIdSha256;
}
-void computeDigest(HashAlgorithm algorithm, const char* digestable, size_t length, DigestValue& digestResult)
+bool computeDigest(HashAlgorithm algorithm, const char* digestable, size_t length, DigestValue& digestResult)
{
blink::WebCryptoAlgorithmId algorithmId = toWebCryptoAlgorithmId(algorithm);
blink::WebCrypto* crypto = blink::Platform::current()->crypto();
- blink::WebArrayBuffer result;
+ unsigned char* result;
+ unsigned resultSize;
ASSERT(crypto);
- crypto->digestSynchronous(algorithmId, reinterpret_cast<const unsigned char*>(digestable), length, result);
+ OwnPtr<blink::WebCryptoDigestor> digestor = adoptPtr(crypto->createDigestor(algorithmId));
+ if (!digestor.get() || !digestor->consume(reinterpret_cast<const unsigned char*>(digestable), length) || !digestor->finish(result, resultSize))
+ return false;
- ASSERT(!result.isNull());
-
- digestResult.append(static_cast<uint8_t*>(result.data()), result.byteLength());
+ digestResult.append(static_cast<uint8_t*>(result), resultSize);
+ return true;
}
PassOwnPtr<blink::WebCryptoDigestor> createDigestor(HashAlgorithm algorithm)
« no previous file with comments | « Source/platform/Crypto.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698