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

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: minor 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
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..7a58d90675a9757d9cba68f2d2d4b3d9214427c5
--- /dev/null
+++ b/chrome/renderer/pepper/ppb_nacl_hash_private_impl.cc
@@ -0,0 +1,53 @@
+// 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(void* hasher) {
+ crypto::SecureHash* h = static_cast<crypto::SecureHash*>(hasher);
+ delete h;
+}
+
+PP_Bool SecureMemEqual(const char* h1, const char* 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

Powered by Google App Engine
This is Rietveld 408576698