1 // Copyright (c) 2012 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.
5 #include "base/rand_util.h"
7 #include <nacl/nacl_random.h>
11 #include "base/check_op.h"
15 void RandBytes(void* output, size_t output_length) {
16 char* output_ptr = static_cast<char*>(output);
17 while (output_length > 0) {
19 const int error = nacl_secure_random(output_ptr, output_length, &nread);
21 CHECK_LE(nread, output_length);
23 output_length -= nread;