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

Unified Diff: content/renderer/webcrypto_impl.cc

Issue 19757011: WebCrypto: Implement digest() using NSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
Index: content/renderer/webcrypto_impl.cc
diff --git a/content/renderer/webcrypto_impl.cc b/content/renderer/webcrypto_impl.cc
index 80c551240eeb141a4c5b305f9485e5df2c241b6e..fdc7d6b66dd6097eb854274ea9120dddc72a0fa1 100644
--- a/content/renderer/webcrypto_impl.cc
+++ b/content/renderer/webcrypto_impl.cc
@@ -4,24 +4,46 @@
#include "content/renderer/webcrypto_impl.h"
+// TODO(bryaneyler): Also include these in OpenSSL build.
Ryan Sleevi 2013/08/02 23:29:27 nit: Add a BUG # for each TODO - could just be a m
Bryan Eyler 2013/08/03 00:16:45 Done.
+#if defined(USE_NSS)
+#include "content/renderer/webcrypto_digest.h"
+#endif
+
+#include "base/memory/scoped_ptr.h"
#include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
namespace content {
-WebKit::WebCryptoOperation* WebCryptoImpl::digest(
- const WebKit::WebCryptoAlgorithm& algorithm) {
+void WebCryptoImpl::digest(
+ const WebKit::WebCryptoAlgorithm& algorithm,
+ WebKit::WebCryptoOperationResult& result) {
+// TODO(bryaneyler): Also include these in OpenSSL build.
Ryan Sleevi 2013/08/02 23:29:27 same
Bryan Eyler 2013/08/03 00:16:45 Done.
+#if defined(USE_NSS)
switch (algorithm.id()) {
case WebKit::WebCryptoAlgorithmIdSha1:
case WebKit::WebCryptoAlgorithmIdSha224:
case WebKit::WebCryptoAlgorithmIdSha256:
case WebKit::WebCryptoAlgorithmIdSha384:
- case WebKit::WebCryptoAlgorithmIdSha512:
- // TODO(eroman): Implement.
- return NULL;
+ case WebKit::WebCryptoAlgorithmIdSha512: {
+ scoped_ptr<WebCryptoDigest> operation(
+ new WebCryptoDigest(result));
+
+ if (!operation->Initialize(algorithm)) {
+ result.initializationFailed();
+ } else {
+ result.initializationSucceeded(operation.release());
+ }
+ return;
+ }
default:
// Not a digest algorithm.
- return NULL;
+ result.initializationFailed();
+ return;
}
+#else
+ // No way to process.
+ result.initializationFailed();
+#endif
}
} // namespace content
« content/renderer/webcrypto_digest_unittest.cc ('K') | « content/renderer/webcrypto_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698