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

Unified Diff: chrome/renderer/pepper/ppb_nacl_hash_private_impl.cc

Issue 14683004: Check that the PNaCl cache hash is truly derived from the bitcode content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 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 | « chrome/renderer/pepper/ppb_nacl_hash_private_impl.h ('k') | chrome/test/data/nacl/nacl_test_data.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/pepper/ppb_nacl_hash_private_impl.cc
diff --git a/chrome/renderer/pepper/ppb_nacl_hash_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_hash_private_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1ef81cfa0096a3ac1fb1023173f6c2074de43177
--- /dev/null
+++ b/chrome/renderer/pepper/ppb_nacl_hash_private_impl.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/pepper/ppb_nacl_hash_private_impl.h"
+
+#ifndef DISABLE_NACL
+
+#include "crypto/secure_hash.h"
+#include "crypto/secure_util.h"
+#include "ppapi/c/pp_bool.h"
+
+namespace {
+
+void* CreateSHA256Hash() {
+ return static_cast<void*>(crypto::SecureHash::Create(
+ crypto::SecureHash::SHA256));
+}
+
+void Update(void* hasher, const void* data, uint32_t len) {
+ crypto::SecureHash* h = static_cast<crypto::SecureHash*>(hasher);
+ h->Update(data, len);
+}
+
+void Finish(void* hasher, void* output, uint32_t len) {
+ crypto::SecureHash* h = static_cast<crypto::SecureHash*>(hasher);
+ h->Finish(output, len);
+}
+
+void Delete(const void* hasher) {
+ const crypto::SecureHash* h =
+ static_cast<const crypto::SecureHash*>(hasher);
+ delete h;
+}
+
+PP_Bool SecureMemEqual(const void* h1, const void* h2, uint32_t len) {
+ return PP_FromBool(crypto::SecureMemEqual(h1, h2, len));
+}
+
+const PPB_NaCl_Hash_Private nacl_hash_interface = {
+ &CreateSHA256Hash,
+ &Update,
+ &Finish,
+ &Delete,
+ &SecureMemEqual
+};
+
+} // namespace
+
+const PPB_NaCl_Hash_Private* PPB_NaCl_Hash_Private_Impl::GetInterface() {
+ return &nacl_hash_interface;
+}
+
+#endif // DISABLE_NACL
« no previous file with comments | « chrome/renderer/pepper/ppb_nacl_hash_private_impl.h ('k') | chrome/test/data/nacl/nacl_test_data.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698