ipc/chromium/src/base/rand_util_posix.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright (c) 2008 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 <fcntl.h>
     8 #include <unistd.h>
    10 #include "base/file_util.h"
    11 #include "base/logging.h"
    13 namespace base {
    15 uint64_t RandUint64() {
    16   uint64_t number;
    18   int urandom_fd = open("/dev/urandom", O_RDONLY);
    19   CHECK(urandom_fd >= 0);
    20   bool success = file_util::ReadFromFD(urandom_fd,
    21                                        reinterpret_cast<char*>(&number),
    22                                        sizeof(number));
    23   CHECK(success);
    24   close(urandom_fd);
    26   return number;
    27 }
    29 }  // namespace base

mercurial