OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/renderer/pepper/ppb_nacl_hash_private_impl.h" |
| 6 |
| 7 #ifndef DISABLE_NACL |
| 8 |
| 9 #include "crypto/secure_hash.h" |
| 10 #include "crypto/secure_util.h" |
| 11 #include "ppapi/c/pp_bool.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 void* CreateSHA256Hash() { |
| 16 return static_cast<void*>(crypto::SecureHash::Create( |
| 17 crypto::SecureHash::SHA256)); |
| 18 } |
| 19 |
| 20 void Update(void* hasher, const void* data, uint32_t len) { |
| 21 crypto::SecureHash* h = static_cast<crypto::SecureHash*>(hasher); |
| 22 h->Update(data, len); |
| 23 } |
| 24 |
| 25 void Finish(void* hasher, void* output, uint32_t len) { |
| 26 crypto::SecureHash* h = static_cast<crypto::SecureHash*>(hasher); |
| 27 h->Finish(output, len); |
| 28 } |
| 29 |
| 30 void Delete(const void* hasher) { |
| 31 const crypto::SecureHash* h = |
| 32 static_cast<const crypto::SecureHash*>(hasher); |
| 33 delete h; |
| 34 } |
| 35 |
| 36 PP_Bool SecureMemEqual(const void* h1, const void* h2, uint32_t len) { |
| 37 return PP_FromBool(crypto::SecureMemEqual(h1, h2, len)); |
| 38 } |
| 39 |
| 40 const PPB_NaCl_Hash_Private nacl_hash_interface = { |
| 41 &CreateSHA256Hash, |
| 42 &Update, |
| 43 &Finish, |
| 44 &Delete, |
| 45 &SecureMemEqual |
| 46 }; |
| 47 |
| 48 } // namespace |
| 49 |
| 50 const PPB_NaCl_Hash_Private* PPB_NaCl_Hash_Private_Impl::GetInterface() { |
| 51 return &nacl_hash_interface; |
| 52 } |
| 53 |
| 54 #endif // DISABLE_NACL |
OLD | NEW |