| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/crypto_impl.h" | 5 #include "ppapi/shared_impl/crypto_impl.h" |
| 6 | 6 |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 | 8 |
| 9 namespace pp { | 9 namespace pp { |
| 10 namespace shared_impl { | 10 namespace shared_impl { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 void CryptoImpl::GetRandomBytes(char* buffer, uint32_t num_bytes) { | 13 void CryptoImpl::GetRandomBytes(char* buffer, uint32_t num_bytes) { |
| 14 // Note: this is a copy of WebKitClientImpl::cryptographicallyRandomValues. | 14 base::RandBytes(buffer, num_bytes); |
| 15 uint64 bytes = 0; | |
| 16 for (uint32_t i = 0; i < num_bytes; ++i) { | |
| 17 uint32_t offset = i % sizeof(bytes); | |
| 18 if (!offset) | |
| 19 bytes = base::RandUint64(); | |
| 20 buffer[i] = reinterpret_cast<char*>(&bytes)[offset]; | |
| 21 } | |
| 22 } | 15 } |
| 23 | 16 |
| 24 } // namespace shared_impl | 17 } // namespace shared_impl |
| 25 } // namespace pp | 18 } // namespace pp |
| OLD | NEW |